├── VERSION ├── .gitignore ├── runtime ├── javadoc │ └── wrappers │ │ ├── package-list │ │ └── resources │ │ ├── tab.gif │ │ ├── titlebar.gif │ │ ├── background.gif │ │ └── titlebar_end.gif ├── prebuilt │ ├── ocamlrun.jar │ ├── ocamlrun-labltk.jar │ ├── ocamlrun.primitives │ ├── ocamlrun-scripting.jar │ └── services-labltk.xml ├── Makefile └── src │ └── org │ └── ocamljava │ └── runtime │ └── Infos.tmpl ├── third-party ├── swank.tar.gz ├── jacl1.4.1.tar.gz ├── jaclBinary141.zip ├── camlzip-1.05.tar.gz ├── ocaml-4.01.0.tar.gz ├── camomile-0.8.5.tar.bz2 ├── barista-2.0-beta2.tar.gz ├── bootstrap-3.3.2-dist.zip ├── javax.servlet-api-3.1.0.jar ├── Makefile.versions ├── LICENSES ├── README └── ocaml-4.01.0.patch ├── doc ├── ocamljava-cheat-sheet.pdf └── manual │ ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 │ └── examples │ ├── concurrent-stm │ └── source.ml │ └── javaext-temperature │ └── source.ml ├── README ├── compiler ├── toplevel │ ├── javatopstart.mli │ ├── scriptstart.mli │ ├── javatopmain.mli │ ├── javatopstart.ml │ ├── scriptstart.ml │ ├── scriptmain.mli │ ├── scriptmain.ml │ ├── javatopdirs.mli │ └── scriptloop.mli ├── tools │ └── Makefile-ocamljava ├── driver │ ├── javamain.mli │ ├── javaerrors.mli │ └── javacompile.mli ├── otherlibs │ ├── str │ │ └── Makefile-ocamljava │ ├── graph │ │ └── Makefile-ocamljava │ ├── unix │ │ └── Makefile-ocamljava │ ├── bigarray │ │ └── Makefile-ocamljava │ ├── num │ │ └── Makefile-ocamljava │ ├── systhreads │ │ └── Makefile-ocamljava │ ├── labltk │ │ ├── Makefile-ocamljava │ │ ├── labltk │ │ │ └── Makefile-ocamljava │ │ ├── camltk │ │ │ └── Makefile-ocamljava │ │ ├── jpf │ │ │ └── Makefile-ocamljava │ │ ├── support │ │ │ └── Makefile-ocamljava │ │ ├── frx │ │ │ └── Makefile-ocamljava │ │ └── lib │ │ │ └── Makefile-ocamljava │ └── dynlink │ │ └── Makefile-ocamljava ├── javacomp │ ├── bytecodegen_global.mli │ ├── javalink_parameters.mli │ ├── printmacroinstr.mli │ ├── bytecodegen_size.mli │ ├── javagen_servlet.mli │ ├── printbytecode.mli │ ├── javalink_servlet.mli │ ├── macrogen_global.mli │ ├── javalibrarian.mli │ ├── printjlambda.mli │ ├── javagen.mli │ ├── javalink_startup.mli │ ├── bytecodegen_prim.mli │ ├── bytecodegen_javaprim.mli │ ├── javapackager.mli │ ├── jclosure.mli │ ├── cmj_format.ml │ ├── archiveutils.mli │ ├── javalink_fxapplication.mli │ ├── macrogen.mli │ ├── jclosure_arrays.mli │ ├── instrtree.ml │ ├── bytecodegen.mli │ ├── archiveutils.ml │ ├── macrogen_primitives.mli │ └── javalink_applet.mli ├── Warnflags ├── stdlib │ ├── Makefile-ocamljava │ ├── Jcompflags │ └── Makefile-ocamljava.shared ├── utils │ ├── jcomp.mli │ └── jcomp.ml ├── build │ ├── camlp4-java-only.sh │ └── camlp4-targets.sh ├── scripts │ └── ocamlj ├── javatyping │ └── jutils.mli └── lex │ └── Makefile-ocamljava ├── Makefile.project ├── wrapper ├── src │ ├── wrap_abstract.mli │ ├── wrap_exception.mli │ ├── wrap_class_type.mli │ ├── wrap_value.mli │ ├── state.ml │ ├── wrap.mli │ ├── wrap_module_type.mli │ ├── wrap_structure.mli │ ├── wrap_record.mli │ ├── wrap_variant.mli │ ├── wrap_functor.mli │ ├── state.mli │ ├── output.mli │ ├── ocamlwrap.ml │ ├── typeInfo.mli │ ├── wrap_value.ml │ ├── typeParametersTable.ml │ ├── wrap_arrow.mli │ └── typeMap.mli ├── _tags ├── Makefile └── myocamlbuild.ml ├── clean.sh ├── INSTALL ├── library ├── concurrent │ ├── _tags │ ├── src │ │ ├── forkjoin │ │ │ └── forkJoin.ml │ │ ├── timeUnit.ml │ │ ├── futures │ │ │ ├── rejectedExecutionHandler.ml │ │ │ ├── rejectedExecutionHandler.mli │ │ │ ├── future.ml │ │ │ ├── scheduledFuture.ml │ │ │ └── executorCompletionService.ml │ │ ├── timeUnit.mli │ │ ├── sync │ │ │ ├── exchanger.ml │ │ │ ├── countDownLatch.ml │ │ │ └── cyclicBarrier.ml │ │ ├── threads │ │ │ └── threadLocal.ml │ │ ├── locks │ │ │ ├── readWriteLock.ml │ │ │ ├── lock.ml │ │ │ └── condition.ml │ │ └── atomic │ │ │ └── atomicReference.ml │ └── Makefile └── javalib │ ├── _tags │ ├── src │ ├── javaPervasives.ml │ ├── javaRuntime.ml │ ├── javaStringFormat.ml │ ├── javaStringPrintf.ml │ ├── javaPervasives.mli │ ├── javaSystem.ml │ ├── javaFX.ml │ ├── javaRuntime.mli │ ├── javaTimeZone.ml │ └── javaArraySignature.ml │ ├── Makefile │ └── templates │ └── throwable-template.ml ├── optimizer ├── _tags ├── src │ ├── state.mli │ ├── mapper.mli │ ├── state.ml │ ├── misc.ml │ ├── args.mli │ ├── misc.mli │ └── ocamljar.ml ├── Makefile └── myocamlbuild.ml └── COPYING /VERSION: -------------------------------------------------------------------------------- 1 | 2.0-alpha4 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | Makefile.config 3 | trash 4 | -------------------------------------------------------------------------------- /runtime/javadoc/wrappers/package-list: -------------------------------------------------------------------------------- 1 | org.ocamljava.runtime.wrappers 2 | -------------------------------------------------------------------------------- /third-party/swank.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/third-party/swank.tar.gz -------------------------------------------------------------------------------- /third-party/jacl1.4.1.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/third-party/jacl1.4.1.tar.gz -------------------------------------------------------------------------------- /doc/ocamljava-cheat-sheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/doc/ocamljava-cheat-sheet.pdf -------------------------------------------------------------------------------- /runtime/prebuilt/ocamlrun.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/runtime/prebuilt/ocamlrun.jar -------------------------------------------------------------------------------- /third-party/jaclBinary141.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/third-party/jaclBinary141.zip -------------------------------------------------------------------------------- /third-party/camlzip-1.05.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/third-party/camlzip-1.05.tar.gz -------------------------------------------------------------------------------- /third-party/ocaml-4.01.0.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/third-party/ocaml-4.01.0.tar.gz -------------------------------------------------------------------------------- /third-party/camomile-0.8.5.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/third-party/camomile-0.8.5.tar.bz2 -------------------------------------------------------------------------------- /runtime/prebuilt/ocamlrun-labltk.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/runtime/prebuilt/ocamlrun-labltk.jar -------------------------------------------------------------------------------- /runtime/prebuilt/ocamlrun.primitives: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/runtime/prebuilt/ocamlrun.primitives -------------------------------------------------------------------------------- /third-party/barista-2.0-beta2.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/third-party/barista-2.0-beta2.tar.gz -------------------------------------------------------------------------------- /third-party/bootstrap-3.3.2-dist.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/third-party/bootstrap-3.3.2-dist.zip -------------------------------------------------------------------------------- /runtime/prebuilt/ocamlrun-scripting.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/runtime/prebuilt/ocamlrun-scripting.jar -------------------------------------------------------------------------------- /third-party/javax.servlet-api-3.1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/third-party/javax.servlet-api-3.1.0.jar -------------------------------------------------------------------------------- /runtime/javadoc/wrappers/resources/tab.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/runtime/javadoc/wrappers/resources/tab.gif -------------------------------------------------------------------------------- /runtime/javadoc/wrappers/resources/titlebar.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/runtime/javadoc/wrappers/resources/titlebar.gif -------------------------------------------------------------------------------- /doc/manual/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/doc/manual/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /doc/manual/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/doc/manual/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /doc/manual/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/doc/manual/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /runtime/javadoc/wrappers/resources/background.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/runtime/javadoc/wrappers/resources/background.gif -------------------------------------------------------------------------------- /doc/manual/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/doc/manual/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /runtime/javadoc/wrappers/resources/titlebar_end.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xclerc/ocamljava/HEAD/runtime/javadoc/wrappers/resources/titlebar_end.gif -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | OCaml-Java is an effort to make OCaml available on the Java platform. 2 | OCaml-Java is Copyright (C) 2007-2015 Xavier Clerc. 3 | The official website of OCaml-Java is . 4 | -------------------------------------------------------------------------------- /third-party/Makefile.versions: -------------------------------------------------------------------------------- 1 | BARISTA_VERSION="2.0-beta2" 2 | BOOTSTRAP_VERSION="3.3.2" 3 | CAMLZIP_VERSION="1.05" 4 | CAMOMILE_VERSION="0.8.5" 5 | JACL_VERSION="1.4.1" 6 | JACL_VERSION_NO_DOTS="141" 7 | OCAML_VERSION="4.01.0" 8 | SERVLET_VERSION="3.1.0" 9 | SWANK_VERSION="2" 10 | -------------------------------------------------------------------------------- /third-party/LICENSES: -------------------------------------------------------------------------------- 1 | This directory contains third-party software that is needed in order to build 2 | OCaml-Java. Each archive contains the copyright and licensing information 3 | related to its contents. The copyright and licenses of OCaml-Java therefore DO 4 | NOT apply to the elements stored in the various archives of this directory. 5 | -------------------------------------------------------------------------------- /third-party/README: -------------------------------------------------------------------------------- 1 | The various archives in this directory are copies of the following open source 2 | software: 3 | - Barista, from http://barista.x9c.fr 4 | - Bootstrap, from http://getbootstrap.com 5 | - Camlzip, from http://forge.ocamlcore.org/projects/camlzip 6 | - Camomile, from https://github.com/yoriyuki/Camomile 7 | - Jacl, from http://tcljava.sourceforge.net 8 | - OCaml, from http://caml.inria.fr 9 | - Servlet API, from http://tomcat.apache.org 10 | - Swank, from http://kenai.com/projects/swank 11 | -------------------------------------------------------------------------------- /doc/manual/examples/concurrent-stm/source.ml: -------------------------------------------------------------------------------- 1 | type account = { 2 | name : string; (* bare value *) 3 | balance : int STM.ref; (* value protected by transactions *) 4 | } 5 | 6 | let make_account n b = 7 | { name = n; balance = STM.ref b } 8 | 9 | let print_account acc = 10 | STM.run_read_only (fun get -> 11 | Printf.printf "%s = %dn" acc.name (get acc.balance)) 12 | 13 | let transfer x y a = 14 | STM.run (fun get set -> 15 | let xv, yv = get x.balance, get y.balance in 16 | set x.balance (xv - a); 17 | set y.balance (yv + a)); 18 | -------------------------------------------------------------------------------- /third-party/ocaml-4.01.0.patch: -------------------------------------------------------------------------------- 1 | diff -aur original/configure patched/configure 2 | --- original/configure 2014-03-11 21:58:51.000000000 +0100 3 | +++ patched/configure 2014-03-11 21:57:32.000000000 +0100 4 | @@ -278,7 +278,7 @@ 5 | bytecccompopts="-fno-defer-pop $gcc_warnings -DSHRINKED_GNUC" 6 | mathlib="";; 7 | *,*-*-darwin*) 8 | - bytecccompopts="-fno-defer-pop $gcc_warnings" 9 | + bytecccompopts="$gcc_warnings" 10 | mathlib="" 11 | mkexe="$mkexe -Wl,-no_compact_unwind" 12 | # Tell gcc that we can use 32-bit code addresses for threaded code 13 | -------------------------------------------------------------------------------- /compiler/toplevel/javatopstart.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | (* Intentionally empty. *) 20 | -------------------------------------------------------------------------------- /compiler/toplevel/scriptstart.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | (* Intentionally empty. *) 20 | -------------------------------------------------------------------------------- /compiler/tools/Makefile-ocamljava: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java compiler. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # Original file (tools/Makefile in the OCaml source 5 | # distribution) is Copyright (C) INRIA. 6 | # 7 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | # it under the terms of the Q Public License v1.0 as published by 9 | # Trolltech (with a change to choice of law). 10 | # 11 | # OCaml-Java compiler is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # Q Public License for more details. 15 | # 16 | # You should have received a copy of the Q Public License 17 | # along with this program. If not, see 18 | # . 19 | # 20 | 21 | include Makefile-ocamljava.shared 22 | -------------------------------------------------------------------------------- /compiler/driver/javamain.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * Original file (driver/optmain.mli in the OCaml source 5 | * distribution) is Copyright (C) INRIA. 6 | * 7 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | * it under the terms of the Q Public License as published by 9 | * Trolltech (with a change to choice of law). 10 | * 11 | * OCaml-Java compiler is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * Q Public License for more details. 15 | * 16 | * You should have received a copy of the Q Public License 17 | * along with this program. If not, see 18 | * . 19 | *) 20 | 21 | (* intentionally empty *) 22 | -------------------------------------------------------------------------------- /compiler/otherlibs/str/Makefile-ocamljava: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java compiler. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | # it under the terms of the Q Public License v1.0 as published by 7 | # Trolltech (with a change to choice of law). 8 | # 9 | # OCaml-Java compiler is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # Q Public License for more details. 13 | # 14 | # You should have received a copy of the Q Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | 19 | LIBRARY=str 20 | JAVA_PACKAGE='ocaml.otherlibs.str' 21 | MODULES=str 22 | EXTRAFLAGS= 23 | 24 | include ../Makefile-ocamljava.shared 25 | -------------------------------------------------------------------------------- /compiler/toplevel/javatopmain.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * Original file (toplevel/opttopmain.mli in the OCaml source 5 | * distribution) is Copyright (C) INRIA. 6 | * 7 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | * it under the terms of the Q Public License as published by 9 | * Trolltech (with a change to choice of law). 10 | * 11 | * OCaml-Java compiler is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * Q Public License for more details. 15 | * 16 | * You should have received a copy of the Q Public License 17 | * along with this program. If not, see 18 | * . 19 | *) 20 | 21 | val main: unit -> unit 22 | -------------------------------------------------------------------------------- /compiler/toplevel/javatopstart.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * Original file (toplevel/opttopstart.ml in the OCaml source 5 | * distribution) is Copyright (C) INRIA. 6 | * 7 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | * it under the terms of the Q Public License as published by 9 | * Trolltech (with a change to choice of law). 10 | * 11 | * OCaml-Java compiler is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * Q Public License for more details. 15 | * 16 | * You should have received a copy of the Q Public License 17 | * along with this program. If not, see 18 | * . 19 | *) 20 | 21 | let _ = Javatopmain.main() 22 | -------------------------------------------------------------------------------- /compiler/toplevel/scriptstart.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * Original file (toplevel/opttopstart.ml in the OCaml source 5 | * distribution) is Copyright (C) INRIA. 6 | * 7 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | * it under the terms of the Q Public License as published by 9 | * Trolltech (with a change to choice of law). 10 | * 11 | * OCaml-Java compiler is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * Q Public License for more details. 15 | * 16 | * You should have received a copy of the Q Public License 17 | * along with this program. If not, see 18 | * . 19 | *) 20 | 21 | let _ = Scriptmain.main () 22 | -------------------------------------------------------------------------------- /compiler/otherlibs/graph/Makefile-ocamljava: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java compiler. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | # it under the terms of the Q Public License v1.0 as published by 7 | # Trolltech (with a change to choice of law). 8 | # 9 | # OCaml-Java compiler is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # Q Public License for more details. 13 | # 14 | # You should have received a copy of the Q Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | 19 | LIBRARY=graphics 20 | JAVA_PACKAGE='ocaml.otherlibs.graph' 21 | MODULES=graphics graphicsX11 22 | EXTRAFLAGS= 23 | 24 | include ../Makefile-ocamljava.shared 25 | -------------------------------------------------------------------------------- /compiler/otherlibs/unix/Makefile-ocamljava: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java compiler. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | # it under the terms of the Q Public License v1.0 as published by 7 | # Trolltech (with a change to choice of law). 8 | # 9 | # OCaml-Java compiler is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # Q Public License for more details. 13 | # 14 | # You should have received a copy of the Q Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | 19 | LIBRARY=unix 20 | JAVA_PACKAGE='ocaml.otherlibs.unix' 21 | MODULES=unix unixLabels 22 | EXTRAFLAGS=-nolabels 23 | 24 | include ../Makefile-ocamljava.shared 25 | -------------------------------------------------------------------------------- /compiler/otherlibs/bigarray/Makefile-ocamljava: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java compiler. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | # it under the terms of the Q Public License v1.0 as published by 7 | # Trolltech (with a change to choice of law). 8 | # 9 | # OCaml-Java compiler is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # Q Public License for more details. 13 | # 14 | # You should have received a copy of the Q Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | 19 | LIBRARY=bigarray 20 | JAVA_PACKAGE='ocaml.otherlibs.bigarray' 21 | MODULES=bigarray 22 | EXTRAFLAGS=-I ../unix 23 | 24 | include ../Makefile-ocamljava.shared 25 | -------------------------------------------------------------------------------- /compiler/otherlibs/num/Makefile-ocamljava: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java compiler. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | # it under the terms of the Q Public License v1.0 as published by 7 | # Trolltech (with a change to choice of law). 8 | # 9 | # OCaml-Java compiler is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # Q Public License for more details. 13 | # 14 | # You should have received a copy of the Q Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | 19 | LIBRARY=nums 20 | JAVA_PACKAGE='ocaml.otherlibs.num' 21 | MODULES=int_misc nat big_int arith_flags ratio num arith_status 22 | EXTRAFLAGS= 23 | 24 | include ../Makefile-ocamljava.shared 25 | -------------------------------------------------------------------------------- /Makefile.project: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java build. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java build is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU Lesser General Public License as published by 7 | # the Free Software Foundation; either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # OCaml-Java build is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public License 16 | # along with this program. If not, see . 17 | # 18 | 19 | 20 | OCAMLJAVA_AUTHOR="Xavier Clerc" 21 | OCAMLJAVA_YEARS="2007-2015" 22 | OCAMLJAVA_MAIL="xclerc@ocamljava.org" 23 | OCAMLJAVA_URL="http://www.ocamljava.org" 24 | -------------------------------------------------------------------------------- /compiler/otherlibs/systhreads/Makefile-ocamljava: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java compiler. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | # it under the terms of the Q Public License v1.0 as published by 7 | # Trolltech (with a change to choice of law). 8 | # 9 | # OCaml-Java compiler is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # Q Public License for more details. 13 | # 14 | # You should have received a copy of the Q Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | 19 | LIBRARY=threads 20 | JAVA_PACKAGE='ocaml.otherlibs.systhreads' 21 | MODULES=thread mutex condition event threadUnix 22 | EXTRAFLAGS=-I ../unix 23 | 24 | default: all 25 | 26 | include ../Makefile-ocamljava.shared 27 | -------------------------------------------------------------------------------- /runtime/prebuilt/services-labltk.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /compiler/javacomp/bytecodegen_global.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | (** Compilation of globals. *) 20 | 21 | 22 | val compile_class : unit -> BaristaLibrary.Bytes.t 23 | (** Builds a class from environment to hold globals. 24 | 25 | Returns the compiled class as an array of bytes. *) 26 | -------------------------------------------------------------------------------- /compiler/javacomp/javalink_parameters.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | (** Check and compile a runtime parameter list. *) 20 | 21 | val compile : string list -> BaristaLibrary.Bytes.t 22 | (** Compile the passed runtime parameter list, raising an exception if 23 | any parameter is invalid. *) 24 | -------------------------------------------------------------------------------- /compiler/javacomp/printmacroinstr.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | (** Pretty-printing for Macroinstr structure. *) 20 | 21 | 22 | val macroinstr : Format.formatter -> Macroinstr.fundecl list -> unit 23 | (** [macroinstr fmt l] prints the list [l] of function declarations onto 24 | [fmt]. *) 25 | -------------------------------------------------------------------------------- /wrapper/src/wrap_abstract.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | 20 | val wrap : Ident.t -> (string * int) list -> JavaAST.class_ 21 | (** Returns the class wrapping the abstract type whose name is passed. *) 22 | -------------------------------------------------------------------------------- /compiler/driver/javaerrors.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * Original file (driver/opterrors.mli in the OCaml source 5 | * distribution) is Copyright (C) INRIA. 6 | * 7 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | * it under the terms of the Q Public License as published by 9 | * Trolltech (with a change to choice of law). 10 | * 11 | * OCaml-Java compiler is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * Q Public License for more details. 15 | * 16 | * You should have received a copy of the Q Public License 17 | * along with this program. If not, see 18 | * . 19 | *) 20 | 21 | (** Error report *) 22 | 23 | val report_error: Format.formatter -> exn -> unit 24 | (** Pretty-prints the exception using the passed formatter. *) 25 | -------------------------------------------------------------------------------- /wrapper/src/wrap_exception.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | 20 | val wrap : Ident.t -> Types.type_expr list -> int -> JavaAST.class_ 21 | (** Returns the class wrapping the exception type whose name and types are passed. *) 22 | -------------------------------------------------------------------------------- /wrapper/src/wrap_class_type.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | 20 | val wrap : Ident.t -> Types.class_type_declaration -> JavaAST.class_ * JavaAST.class_ 21 | (** Returns the classes wrapping the class type whose name and definition are passed. *) 22 | -------------------------------------------------------------------------------- /wrapper/src/wrap_value.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | 20 | val wrap : string -> Ident.t -> Types.type_expr -> int -> JavaAST.method_ 21 | (** Returns the method wrapping the value whose module name, name type, and global index are passed. *) 22 | -------------------------------------------------------------------------------- /wrapper/src/state.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | 20 | let environment = ref Env.initial 21 | 22 | let update_environment_with_signature signature = 23 | environment := Env.add_signature signature !environment 24 | 25 | let java_class = ref None 26 | -------------------------------------------------------------------------------- /clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # This file is part of OCaml-Java build. 5 | # Copyright (C) 2007-2015 Xavier Clerc. 6 | # 7 | # OCaml-Java build is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU Lesser General Public License as published by 9 | # the Free Software Foundation; either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # OCaml-Java build is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public License 18 | # along with this program. If not, see . 19 | # 20 | 21 | 22 | # deletes the configuration file, if any 23 | if [ -f Makefile.config ]; then 24 | rm -f Makefile.config 25 | fi 26 | 27 | # deletes the build directory, if any 28 | if [ -d _build ]; then 29 | rm -fr _build 30 | fi 31 | -------------------------------------------------------------------------------- /compiler/Warnflags: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # This file is part of OCaml-Java compiler. 5 | # Copyright (C) 2007-2015 Xavier Clerc. 6 | # 7 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | # it under the terms of the Q Public License v1.0 as published by 9 | # Trolltech (with a change to choice of law). 10 | # 11 | # OCaml-Java compiler is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # Q Public License for more details. 15 | # 16 | # You should have received a copy of the Q Public License 17 | # along with this program. If not, see 18 | # . 19 | # 20 | 21 | if [ -f ../../compiler/$1 ]; then 22 | # the file comes from OCaml-Java, enable almost all warnings 23 | echo '-w Ae -warn-error A' 24 | else 25 | # the file comes from vanilla OCaml, use the warnings from 26 | # the original OCaml build system 27 | echo '-w +33..39 -warn-error A' 28 | fi 29 | -------------------------------------------------------------------------------- /wrapper/src/wrap.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | 20 | val file : string -> string option -> unit 21 | (** [file cmi_filename package_name] wrap the cmi file whose path 22 | [cmi_filename], using [package_name] as the package for the generated 23 | class. *) 24 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Dependencies: 2 | ------------- 3 | Most dependencies are provided as archives in the "third-party/" directory, but 4 | the following elements are needed in order to build and then use OCaml-Java: 5 | - a "decent" shell 6 | - GNU Make 3.81 7 | - Apache Ant 1.9.0 8 | - JDK 1.7, with the "JAVA_HOME" environment variable properly set 9 | 10 | Installation steps: 11 | ------------------- 12 | ./configure.sh -prefix [options] # also checks dependencies 13 | ./build.sh # also performs installation 14 | ./clean.sh # optional, removes all produced files 15 | 16 | Configuration options: 17 | ---------------------- 18 | The full list of options accepted by the "./configure" script can be retrieved 19 | by passing the "-help" option to the script. One option is mandatory: "-prefix 20 | " that is used to set the installation path. The specified path must be 21 | absolute. 22 | 23 | 24 | For additional information and required dependencies, please refer to the 25 | manual available in the "doc/" directory. 26 | -------------------------------------------------------------------------------- /wrapper/src/wrap_module_type.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | 20 | val wrap : Ident.t -> Types.signature -> JavaAST.class_ * JavaAST.class_ * (string list) 21 | (** Returns the abstract and final classes (with type parameters) wrapping the module whose name and type are passed. *) 22 | -------------------------------------------------------------------------------- /wrapper/src/wrap_structure.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | 20 | val make_methods : bool -> (string * Types.type_expr * int option) list -> JavaAST.method_ list * JavaAST.method_ list * JavaAST.method_ list 21 | (** Returns the methods wrapping the functions whose signatures are passed. *) 22 | -------------------------------------------------------------------------------- /compiler/javacomp/bytecodegen_size.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | (** Utilities for size optimization. *) 20 | 21 | 22 | val shrink : BaristaLibrary.Instruction.t list -> BaristaLibrary.Instruction.t list 23 | (** Tries to transform the passed instruction list into an equivalent one 24 | with a reduced size, returning the original if it fails. 25 | 26 | The passed list is supposed to be jump-free. *) 27 | -------------------------------------------------------------------------------- /compiler/javacomp/javagen_servlet.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | val compile : Jclflags.servlet_kind -> string -> string -> Types.signature -> BaristaLibrary.Bytes.t 20 | (** [compile kind mod_kind base_class_name signature] compiles a class 21 | implementing a servlet for kind [kind]/[mod_kind], named [base_class_name], 22 | whose signature is [signature]. Returns the contents of the compiled 23 | class file. *) 24 | -------------------------------------------------------------------------------- /wrapper/src/wrap_record.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | 20 | val wrap : Ident.t -> (Ident.t * Asttypes.mutable_flag * Types.type_expr) list -> Types.record_representation -> (string * int) list -> JavaAST.class_ 21 | (** Returns the class wrapping the record type whose name, fields, representation and type parameters are passed. *) 22 | -------------------------------------------------------------------------------- /compiler/javacomp/printbytecode.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | (** Pretty-printing for bytecode. *) 20 | 21 | val bytecode : Format.formatter -> string -> BaristaLibrary.Instruction.t list -> BaristaLibrary.Attribute.exception_table_element list -> unit 22 | (** [bytecode fmt header l e] prints the string [header], then the list 23 | [l] of bytecode instructions, and finally the exception handlers [e] 24 | onto [fmt]. *) 25 | -------------------------------------------------------------------------------- /library/concurrent/_tags: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java library. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java library is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU Lesser General Public License as published by 7 | # the Free Software Foundation; either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # OCaml-Java library is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public License 16 | # along with this program. If not, see . 17 | # 18 | 19 | # Directories 20 | true: -traverse 21 | : include 22 | 23 | # Options 24 | : warnings 25 | : java-extensions, use_javalib 26 | <**/*.docdir>: java-extensions, sort, html5, title(Concurrent library) 27 | : java-package(org.ocamljava.library.concurrent) 28 | -------------------------------------------------------------------------------- /wrapper/src/wrap_variant.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | 20 | type variant_kind = 21 | | Simple_variant 22 | | Polymorphic_variant 23 | 24 | val wrap : Ident.t -> (string * Types.type_expr list) list -> variant_kind -> (string * int) list -> JavaAST.class_ 25 | (** Returns the class wrapping the variant type whose name constructors and type parameters are passed. *) 26 | -------------------------------------------------------------------------------- /runtime/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java runtime. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java runtime is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU Lesser General Public License as published by 7 | # the Free Software Foundation; either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # OCaml-Java runtime is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public License 16 | # along with this program. If not, see . 17 | # 18 | 19 | 20 | include ../Makefile.config 21 | 22 | default: 23 | @echo "no target provided" 24 | exit 1 25 | 26 | build: 27 | ant build 28 | 29 | install: 30 | cp build/ocamlrun.primitives \ 31 | build/ocamlrun.jar \ 32 | build/ocamlrun-labltk.jar \ 33 | $(PREFIX)/lib/ocaml 34 | 35 | .PHONY: default 36 | .PHONY: build 37 | .PHONY: install 38 | -------------------------------------------------------------------------------- /compiler/stdlib/Makefile-ocamljava: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java compiler. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # Original file (stdlib/Makefile in the OCaml source 5 | # distribution) is Copyright (C) INRIA. 6 | # 7 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | # it under the terms of the Q Public License v1.0 as published by 9 | # Trolltech (with a change to choice of law). 10 | # 11 | # OCaml-Java compiler is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # Q Public License for more details. 15 | # 16 | # You should have received a copy of the Q Public License 17 | # along with this program. If not, see 18 | # . 19 | # 20 | 21 | include Makefile-ocamljava.shared 22 | 23 | all: stdlib.cmja 24 | 25 | install: 26 | cp stdlib.cmja stdlib.ja *.cmj $(LIBDIR) 27 | 28 | stdlib.cmja: $(OBJS) 29 | $(CAMLJAVA) -a -o stdlib.cmja $(OBJS) 30 | 31 | sys.ml: sys.mlp ../VERSION 32 | sed -e "s|%%VERSION%%|`head -1 ../VERSION`|" sys.mlp > sys.ml 33 | 34 | clean:: 35 | rm -f sys.ml 36 | -------------------------------------------------------------------------------- /wrapper/src/wrap_functor.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | val wrap : string -> Ident.t -> Path.t -> (Ident.t * Path.t) list -> (string * string * string) list -> (Ident.t * Types.signature * string list) list -> Jlambda.value_approximation option -> int -> JavaAST.method_ 20 | (** Returns the method wrapping the functor whose module name, name, prameters, approximation and approximation index are passed. *) 21 | -------------------------------------------------------------------------------- /compiler/otherlibs/labltk/Makefile-ocamljava: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java compiler. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | # it under the terms of the Q Public License v1.0 as published by 7 | # Trolltech (with a change to choice of law). 8 | # 9 | # OCaml-Java compiler is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # Q Public License for more details. 13 | # 14 | # You should have received a copy of the Q Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | 19 | all: 20 | for d in support labltk camltk lib jpf frx; do \ 21 | cd $$d && $(MAKE) -f Makefile-ocamljava && cd ..; \ 22 | done 23 | 24 | install: 25 | for d in support lib labltk camltk jpf frx; do \ 26 | cd $$d && $(MAKE) -f Makefile-ocamljava install && cd ..; \ 27 | done 28 | 29 | partialclean clean:: 30 | for d in support lib labltk camltk jpf frx; do \ 31 | cd $$d && $(MAKE) -f Makefile-ocamljava clean && cd ..; \ 32 | done 33 | -------------------------------------------------------------------------------- /compiler/toplevel/scriptmain.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * Original file (toplevel/opttopmain.mli in the OCaml source 5 | * distribution) is Copyright (C) INRIA. 6 | * 7 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | * it under the terms of the Q Public License as published by 9 | * Trolltech (with a change to choice of law). 10 | * 11 | * OCaml-Java compiler is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * Q Public License for more details. 15 | * 16 | * You should have received a copy of the Q Public License 17 | * along with this program. If not, see 18 | * . 19 | *) 20 | 21 | (** Entry point of scripting engine. *) 22 | 23 | 24 | val main: unit -> unit 25 | (** Initializes the scripting engine. Contrary to the classical toplevel, 26 | it does not start an interpreter loop. The evaluation of a given 27 | phrase should be requested by using a callback registered by 28 | [Scriptloop.init]. *) 29 | -------------------------------------------------------------------------------- /library/javalib/_tags: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java library. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java library is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU Lesser General Public License as published by 7 | # the Free Software Foundation; either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # OCaml-Java library is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public License 16 | # along with this program. If not, see . 17 | # 18 | 19 | # Directories 20 | true: -traverse 21 | : include 22 | 23 | # Options 24 | : warnings 25 | : java-extensions 26 | "src/javaString.ml": needs-java-pervasives 27 | : servlet-api 28 | <**/*.docdir>: servlet-api, java-extensions, sort, html5, title(Java library) 29 | : java-package(org.ocamljava.library.javalib) 30 | -------------------------------------------------------------------------------- /compiler/javacomp/javalink_servlet.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | val make_servlet_class : unit -> string * BaristaLibrary.Bytes.t 20 | (** Compiles the class responsible for initialization, returning class 21 | name and contents of class file. *) 22 | 23 | val make_servlet_aux_class : string -> string * BaristaLibrary.Bytes.t 24 | (** Compiles the auxiliary for package whose name is passed (redirecting 25 | to the class responsible for initialization), returning class name 26 | and contents of class file. *) 27 | -------------------------------------------------------------------------------- /optimizer/_tags: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java optimizer. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java optimizer is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU Lesser General Public License as published by 7 | # the Free Software Foundation; either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # OCaml-Java optimizer is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public License 16 | # along with this program. If not, see . 17 | # 18 | 19 | # Directories 20 | true: -traverse 21 | : include 22 | 23 | # Options 24 | : use_barista 25 | : use_barista 26 | : warnings 27 | : java-package(org.ocamljava.optimizer) 28 | : runtime-parameter(embedded=on), runtime-parameter(embedded-base=FileAnchor), additional-jar-ref(ocaml-lib-files.jar) 29 | -------------------------------------------------------------------------------- /wrapper/_tags: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java wrapper. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU Lesser General Public License as published by 7 | # the Free Software Foundation; either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public License 16 | # along with this program. If not, see . 17 | # 18 | 19 | # Directories 20 | true: -traverse 21 | : include 22 | 23 | # Options 24 | : use_compiler_libs 25 | : use_compiler_libs 26 | : warnings 27 | : java-package(org.ocamljava.wrapper) 28 | : runtime-parameter(embedded=on), runtime-parameter(embedded-base=FileAnchor), additional-jar-ref(ocaml-lib-files.jar) 29 | -------------------------------------------------------------------------------- /compiler/toplevel/scriptmain.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * Original file (toplevel/opttopmain.ml in the OCaml source 5 | * distribution) is Copyright (C) INRIA. 6 | * 7 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | * it under the terms of the Q Public License as published by 9 | * Trolltech (with a change to choice of law). 10 | * 11 | * OCaml-Java compiler is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * Q Public License for more details. 15 | * 16 | * You should have received a copy of the Q Public License 17 | * along with this program. If not, see 18 | * . 19 | *) 20 | 21 | let main () = 22 | let ppf = Format.err_formatter in 23 | Compenv.(readenv ppf Before_args); 24 | (* there is no command-line to analyze, 25 | but there are some parameters to set *) 26 | Warnings.parse_options false "-a"; 27 | Scriptloop.set_paths (); 28 | Compenv.(readenv ppf Before_link); 29 | (* actually initializes the engine *) 30 | Scriptloop.init () 31 | -------------------------------------------------------------------------------- /compiler/utils/jcomp.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | 20 | (** Compilation of Java source files. *) 21 | 22 | val compile_file : string -> int 23 | (** Compiles the passed Java file through a Java compiler, using the 24 | values passed by {i -javac} (compiler), {i -jopt} (compiler options), 25 | and {i -cp}/{i -classpath} (compilation classpath) command-line 26 | switches. 27 | 28 | The path to the runtime support jar is prepended to the classpath. 29 | 30 | Returns the exit code of the process running the Java compiler. *) 31 | -------------------------------------------------------------------------------- /library/javalib/src/javaPervasives.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | 20 | external (|.) : ('a -> 'b) -> 'a -> 'b = "%apply" 21 | 22 | external (!@) : string -> _'String java_instance = 23 | "ocamljava_javastring_of_string" 24 | 25 | let (^^^) str1 str2 = 26 | Java.make "StringBuilder()" () 27 | |> Java.call "StringBuilder.append(String):StringBuilder" |. str1 28 | |> Java.call "StringBuilder.append(String):StringBuilder" |. str2 29 | |> Java.call "StringBuilder.toString()" 30 | -------------------------------------------------------------------------------- /library/javalib/src/javaRuntime.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | type t = java'lang'Runtime java_instance 20 | 21 | let get_runtime () = 22 | Java.call "Runtime.getRuntime()" () 23 | 24 | let available_processors rt = 25 | Java.call "Runtime.availableProcessors()" rt 26 | 27 | let free_memory rt = 28 | Java.call "Runtime.freeMemory()" rt 29 | 30 | let max_memory rt = 31 | Java.call "Runtime.maxMemory()" rt 32 | 33 | let total_memory rt = 34 | Java.call "Runtime.totalMemory()" rt 35 | -------------------------------------------------------------------------------- /library/javalib/src/javaStringFormat.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | let fprintf fmt str = 20 | Format.pp_print_string fmt (JavaString.to_string str) 21 | 22 | let printf x y = fprintf x y 23 | 24 | let eprintf x y = fprintf x y 25 | 26 | let sprintf () str = 27 | JavaString.to_string str 28 | 29 | let asprintf x y = fprintf x y 30 | 31 | let ifprintf x y = fprintf x y 32 | 33 | let kfprintf x y = fprintf x y 34 | 35 | let ikfprintf x y = fprintf x y 36 | 37 | let ksprintf x y = sprintf x y 38 | -------------------------------------------------------------------------------- /wrapper/src/state.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | (** This module centralizes various mutable variables used throughout the 20 | program. *) 21 | 22 | 23 | val environment : Env.t ref 24 | (** The environment containing loaded modules. *) 25 | 26 | val update_environment_with_signature : Types.signature -> unit 27 | (** [update_environment_with_signature sign] augments [environment] with 28 | [sign]. *) 29 | 30 | val java_class : string option ref 31 | (** The Java class currently wrapped. *) 32 | -------------------------------------------------------------------------------- /library/concurrent/src/forkjoin/forkJoin.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | external split : ForkJoinPool.t -> ('a -> ('a * 'a) option) -> ('b -> 'b -> 'b) -> ('a -> 'b) -> 'a -> 'b = 20 | "ocamljava_forkjoin_split" 21 | 22 | external split_list : ForkJoinPool.t -> ('a -> 'a list) -> ('b -> 'b -> 'b) -> ('a -> 'b) -> 'a -> 'b = 23 | "ocamljava_forkjoin_split_list" 24 | 25 | external split_array : ForkJoinPool.t -> ('a -> 'a array) -> ('b -> 'b -> 'b) -> ('a -> 'b) -> 'a -> 'b = 26 | "ocamljava_forkjoin_split_array" 27 | -------------------------------------------------------------------------------- /compiler/build/camlp4-java-only.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # This file is part of OCaml-Java compiler. 5 | # Copyright (C) 2007-2015 Xavier Clerc. 6 | # Original file (build/camlp4-native-only.sh in the OCaml source 7 | # distribution) is Copyright (C) INRIA. 8 | # 9 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 10 | # it under the terms of the Q Public License v1.0 as published by 11 | # Trolltech (with a change to choice of law). 12 | # 13 | # OCaml-Java compiler is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # Q Public License for more details. 17 | # 18 | # You should have received a copy of the Q Public License 19 | # along with this program. If not, see 20 | # . 21 | # 22 | 23 | set -e 24 | cd `dirname $0`/.. 25 | . build/targets.sh 26 | set -x 27 | 28 | # If you modify this list, modify it also in boot.sh 29 | STDLIB_MODULES='Pervasives,Arg,Array,Buffer,Char,Digest,Filename,Format,Hashtbl,Lazy,Lexing,List,Map,Printexc,Printf,Scanf,Set,String,Sys,Parsing,Int32,Int64,Nativeint,Obj,Queue,Sort,Stream,Stack' 30 | 31 | ./ocamlbuild/ocamlbuild.native -ignore "$STDLIB_MODULES" $@ java_stdlib_mixed_mode $CAMLP4_JAVA 32 | -------------------------------------------------------------------------------- /compiler/otherlibs/dynlink/Makefile-ocamljava: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java compiler. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | # it under the terms of the Q Public License v1.0 as published by 7 | # Trolltech (with a change to choice of law). 8 | # 9 | # OCaml-Java compiler is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # Q Public License for more details. 13 | # 14 | # You should have received a copy of the Q Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | 19 | LIBRARY=dynlink 20 | JAVA_PACKAGE='ocaml.otherlibs.dynlink' 21 | MODULES=dynlink 22 | EXTRAFLAGS=-I ../../utils -I ../../typing -I ../../bytecomp -I ../../asmcomp 23 | 24 | hook: 25 | $(MAKE) -f Makefile-ocamljava prepare 26 | $(MAKE) -f Makefile-ocamljava all 27 | $(MAKE) -f Makefile-ocamljava restore 28 | 29 | prepare: 30 | mv dynlink.ml dynlink.orig 31 | cp natdynlink.ml dynlink.ml 32 | 33 | restore: 34 | rm -f dynlink.ml 35 | mv dynlink.orig dynlink.ml 36 | 37 | partialclean:: 38 | rm -f extract_crc *.cmi *.cmj* 39 | 40 | include ../Makefile-ocamljava.shared 41 | -------------------------------------------------------------------------------- /compiler/javacomp/macrogen_global.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | (** Uses of global elements (read/write). *) 20 | 21 | val reset_global_uses : unit -> unit 22 | (** Resets the sets of global uses (for both reads and writes). *) 23 | 24 | val record_global_uses : Jlambda.jlambda -> unit 25 | (** Record all the global uses occurring in the passed lambda. *) 26 | 27 | val compile_global_uses : unit -> BaristaLibrary.Annotation.t list 28 | (** Compiles all recorded global uses into a list of 29 | {i org.ocamljava.runtime.annotations.markers.GlobalUses} 30 | annotations, each holding the sets of read and written indices for 31 | a given global. *) 32 | -------------------------------------------------------------------------------- /compiler/stdlib/Jcompflags: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # This file is part of OCaml-Java compiler. 5 | # Copyright (C) 2007-2015 Xavier Clerc. 6 | # Original file (stdlib/Compflags in the OCaml source 7 | # distribution) is Copyright (C) INRIA. 8 | # 9 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 10 | # it under the terms of the Q Public License v1.0 as published by 11 | # Trolltech (with a change to choice of law). 12 | # 13 | # OCaml-Java compiler is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # Q Public License for more details. 17 | # 18 | # You should have received a copy of the Q Public License 19 | # along with this program. If not, see 20 | # . 21 | # 22 | 23 | case $1 in 24 | pervasives.cm[ij]) echo ' -nopervasives';; 25 | camlinternalOO.cmi) echo ' -nopervasives';; 26 | camlinternalOO.cmj) echo ' -inline 0';; 27 | buffer.cmj) echo ' -inline 3';; 28 | buffer.cm[ij]|printf.cm[ij]|format.cm[ij]|scanf.cm[ij]) echo ' -w A';; 29 | scanf.cmj) echo ' -inline 9';; 30 | arrayLabels.cmj) echo ' -nolabels';; 31 | listLabels.cmj) echo ' -nolabels';; 32 | stringLabels.cmj) echo ' -nolabels';; 33 | moreLabels.cmj) echo ' -nolabels';; 34 | *) echo ' ';; 35 | esac 36 | -------------------------------------------------------------------------------- /library/javalib/src/javaStringPrintf.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | let fprintf chan str = 20 | JavaString.output_string chan str 21 | 22 | let printf x y = fprintf x y 23 | 24 | let eprintf x y = fprintf x y 25 | 26 | let sprintf () str = 27 | JavaString.to_string str 28 | 29 | let bprintf buff str = 30 | Buffer.add_string buff (JavaString.to_string str) 31 | 32 | let ifprintf _dummy _str = 33 | () 34 | 35 | let kfprintf x y = fprintf x y 36 | 37 | let ikfprintf x y = fprintf x y 38 | 39 | let ksprintf x y = sprintf x y 40 | 41 | let kbprintf x y = bprintf x y 42 | -------------------------------------------------------------------------------- /compiler/javacomp/javalibrarian.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * Original file (asmcomp/asmlibrarian.mli in the OCaml source 5 | * distribution) is Copyright (C) INRIA. 6 | * 7 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | * it under the terms of the Q Public License as published by 9 | * Trolltech (with a change to choice of law). 10 | * 11 | * OCaml-Java compiler is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * Q Public License for more details. 15 | * 16 | * You should have received a copy of the Q Public License 17 | * along with this program. If not, see 18 | * . 19 | *) 20 | 21 | (** Build libraries of .cmj files. *) 22 | 23 | val create_archive: string list -> string -> unit 24 | (** [create_archive file_list lib_name] compiles a library named 25 | [lib_name] from files in [file_list] (that should be .cmj files). *) 26 | 27 | type error = 28 | File_not_found of string 29 | | Archiver_error of string * string 30 | | File_compiled_with_a_different_int_size of string 31 | 32 | exception Error of error 33 | 34 | val report_error: Format.formatter -> error -> unit 35 | (** Pretty-prints an error. *) 36 | -------------------------------------------------------------------------------- /compiler/javacomp/printjlambda.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | (** Pretty-printing for Jlambda structure. *) 20 | 21 | 22 | val loop_inlining_info : Format.formatter -> Jlambda.jlamdba_loop_inlining_info -> unit 23 | (** [loop_inlining_info fmt lii] prints loop inlining info [lii] onto 24 | [fmt]. *) 25 | 26 | val java_primitive : Format.formatter -> Jlambda.java_primitive -> unit 27 | (** [java_primitive fmt jp] prints the primitive [jp] onto [fmt]. *) 28 | 29 | val const : Format.formatter -> Jlambda.const -> unit 30 | (** [const fmt cst] prints the constant [cst] onto [fmt]. *) 31 | 32 | val jlambda : Format.formatter -> Jlambda.jlambda -> unit 33 | (** [jlambda fmt j] prints the jlambda [j] onto [fmt]. *) 34 | -------------------------------------------------------------------------------- /wrapper/src/output.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | (** Verbose/warning output. *) 20 | 21 | 22 | type warning = 23 | | Discard_unit_value of Ident.t 24 | | Discard_object_value of Ident.t 25 | | Discard_polymorphic_variant_value of Ident.t 26 | | Discard_unsupported_value of Ident.t 27 | | Discard_unsupported_type of Ident.t 28 | | Discard_nested_module of Ident.t 29 | | Discard_object_type of Ident.t 30 | 31 | val verbose : string -> unit 32 | (** Prints the passed string, if enabled by command-line. *) 33 | 34 | val warning : warning -> unit 35 | (** Prints the passed warning, unless disabled by command-line. *) 36 | -------------------------------------------------------------------------------- /compiler/javacomp/javagen.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * Original file (asmcomp/cmmgen.mli in the OCaml source 5 | * distribution) is Copyright (C) INRIA. 6 | * 7 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | * it under the terms of the Q Public License as published by 9 | * Trolltech (with a change to choice of law). 10 | * 11 | * OCaml-Java compiler is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * Q Public License for more details. 15 | * 16 | * You should have received a copy of the Q Public License 17 | * along with this program. If not, see 18 | * . 19 | *) 20 | 21 | (** Compilation from lambda to Java bytecode. *) 22 | 23 | val compile_implementation : string -> Format.formatter -> int * Lambda.lambda -> unit 24 | (** [compile_implementation prefixname ppf (size, lam)] compiles lambda 25 | [lam], [size] being the size of its associated global. [prefixname] 26 | is the prefix path of created files, while [fmt] is used for 27 | pretty-printing. *) 28 | 29 | type error = 30 | Invalid_servlet_signature of string 31 | 32 | exception Error of error 33 | 34 | val report_error: Format.formatter -> error -> unit 35 | (** Pretty-prints an error. *) 36 | -------------------------------------------------------------------------------- /compiler/otherlibs/labltk/labltk/Makefile-ocamljava: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java compiler. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | # it under the terms of the Q Public License v1.0 as published by 7 | # Trolltech (with a change to choice of law). 8 | # 9 | # OCaml-Java compiler is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # Q Public License for more details. 13 | # 14 | # You should have received a copy of the Q Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | 19 | TOPDIR=../../.. 20 | LIBNAME=labltk 21 | include $(TOPDIR)/config/Makefile 22 | INSTALLDIR=$(LIBDIR)/$(LIBNAME) 23 | 24 | OCAMLJAVA=$(TOPDIR)/ocamljava.opt 25 | COMPFLAGS=-g -java-package 'ocaml.otherlibs.labltk' -nostdlib -I $(TOPDIR)/stdlib -I ../support 26 | 27 | default: all 28 | 29 | include ./modules 30 | 31 | OBJS=tk.cmj $(WIDGETOBJS:.cmo=.cmj) labltk.cmj 32 | 33 | all: $(patsubst %.cmj,%.cmi,$(OBJS)) $(OBJS) 34 | 35 | clean: 36 | $(MAKE) -f Makefile.gen clean 37 | 38 | install: 39 | cp $(OBJS) $(INSTALLDIR) 40 | 41 | .SUFFIXES: 42 | .SUFFIXES: .mli .ml .cmi .cmj 43 | 44 | .mli.cmi: 45 | $(OCAMLJAVA) -c $(COMPFLAGS) $< 46 | 47 | .ml.cmj: 48 | $(OCAMLJAVA) -c $(COMPFLAGS) $< 49 | -------------------------------------------------------------------------------- /compiler/toplevel/javatopdirs.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * Original file (toplevel/opttopdirs.mli in the OCaml source 5 | * distribution) is Copyright (C) INRIA. 6 | * 7 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | * it under the terms of the Q Public License as published by 9 | * Trolltech (with a change to choice of law). 10 | * 11 | * OCaml-Java compiler is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * Q Public License for more details. 15 | * 16 | * You should have received a copy of the Q Public License 17 | * along with this program. If not, see 18 | * . 19 | *) 20 | 21 | (* The toplevel directives. *) 22 | 23 | open Format 24 | 25 | val dir_quit : unit -> unit 26 | val dir_directory : string -> unit 27 | val dir_remove_directory : string -> unit 28 | val dir_cd : string -> unit 29 | val dir_load : formatter -> string -> unit 30 | val dir_use : formatter -> string -> unit 31 | val dir_install_printer : formatter -> Longident.t -> unit 32 | val dir_remove_printer : formatter -> Longident.t -> unit 33 | 34 | type 'a printer_type_new = Format.formatter -> 'a -> unit 35 | type 'a printer_type_old = 'a -> unit 36 | 37 | val load_file : formatter -> string -> bool 38 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | The OCaml-Java project uses different licences for its different components, 2 | in order to match the licences of the corresponding elements in the original 3 | OCaml distribution. The copyright holder for the whole OCaml-Java project is 4 | Xavier Clerc. 5 | 6 | The various components are: 7 | - the build system: "*.sh" files of the root directory, and all files of the 8 | "build/" directory; 9 | - the compiler: all files of the "compiler/" directory, and subdirectories; 10 | - the library: all files of the "library/" directory, and subdirectories; 11 | - the optimizer: all files of the "optimizer/" directory, and subdirectories; 12 | - the runtime: all files of the "runtime/" directory, and subdirectories; 13 | - the wrapper: all files of the "wrapper/" directory, and subdirectories. 14 | 15 | The related licences are: 16 | - the LGPL for the build system, library, optimizer, runtime, and wrapper; 17 | - the QPL for the compiler. 18 | The texts of the licences can be found in the files named "COPYING.GPL", 19 | "COPYING.LGPL", and "COPYING.QPL" in the root directory. 20 | 21 | The files in the "third-party/" directory are copies of software needed in 22 | order to build OCaml-Java, and to then run files produced by its compiler. 23 | Each archive contains the copyright and licensing information related to its 24 | contents. The copyright and licenses of OCaml-Java therefore DO NOT apply to 25 | the elements stored in the various archives of this directory. 26 | -------------------------------------------------------------------------------- /compiler/otherlibs/labltk/camltk/Makefile-ocamljava: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java compiler. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | # it under the terms of the Q Public License v1.0 as published by 7 | # Trolltech (with a change to choice of law). 8 | # 9 | # OCaml-Java compiler is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # Q Public License for more details. 13 | # 14 | # You should have received a copy of the Q Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | 19 | TOPDIR=../../.. 20 | LIBNAME=labltk 21 | include $(TOPDIR)/config/Makefile 22 | INSTALLDIR=$(LIBDIR)/$(LIBNAME) 23 | 24 | OCAMLJAVA=$(TOPDIR)/ocamljava.opt 25 | COMPFLAGS=-g -java-package 'ocaml.otherlibs.labltk' -nostdlib -I $(TOPDIR)/stdlib -I ../support 26 | 27 | default: all 28 | 29 | include ./modules 30 | 31 | OBJS=cTk.cmj $(CWIDGETOBJS:.cmo=.cmj) camltk.cmj 32 | 33 | all: $(patsubst %.cmj,%.cmi,$(CMJ_FILES)) $(OBJS) 34 | 35 | install: 36 | cp $(OBJS) $(INSTALLDIR) 37 | 38 | clean: 39 | $(MAKE) -f Makefile.gen clean 40 | 41 | .SUFFIXES: 42 | .SUFFIXES: .mli .ml .cmi .cmj 43 | 44 | .mli.cmi: 45 | $(OCAMLJAVA) -c $(COMPFLAGS) $< 46 | 47 | .ml.cmj: 48 | $(OCAMLJAVA) -c $(COMPFLAGS) $< 49 | -------------------------------------------------------------------------------- /library/concurrent/src/timeUnit.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | open Class'java'util'concurrent'TimeUnit 20 | 21 | type t = _'TimeUnit java_instance 22 | 23 | let nanoseconds = Java.get "TimeUnit.NANOSECONDS" () 24 | 25 | let microseconds = Java.get "TimeUnit.MICROSECONDS" () 26 | 27 | let milliseconds = Java.get "TimeUnit.MILLISECONDS" () 28 | 29 | let seconds = Java.get "TimeUnit.SECONDS" () 30 | 31 | let minutes = Java.get "TimeUnit.MINUTES" () 32 | 33 | let hours = Java.get "TimeUnit.HOURS" () 34 | 35 | let days = Java.get "TimeUnit.DAYS" () 36 | 37 | let convert ~src ~dst x = 38 | Java.call "TimeUnit.convert(long,TimeUnit)" dst x src 39 | -------------------------------------------------------------------------------- /optimizer/src/state.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java optimizer. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java optimizer is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java optimizer is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | (** This module centralizes various mutable variables used throughout the 20 | program. *) 21 | 22 | 23 | val input_file : string ref 24 | (** The name of the input file, should not change once set. *) 25 | 26 | val current_class_name : BaristaLibrary.Name.for_class ref 27 | (** The name of the currently processed class. *) 28 | 29 | val get_class_loader : unit -> BaristaLibrary.ClassLoader.t 30 | (** Returns the class loader lazily created at the first call. *) 31 | 32 | val get_unifier : unit -> BaristaLibrary.StackState.instance BaristaLibrary.StackState.unifier 33 | (** Returns the unifier based on the class loader returned by 34 | [get_class_loader]. *) 35 | -------------------------------------------------------------------------------- /compiler/javacomp/javalink_startup.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | val compile_class : 20 | name:BaristaLibrary.Name.for_class -> 21 | parent:BaristaLibrary.Name.for_class -> 22 | fields:BaristaLibrary.Field.t list -> 23 | methods:BaristaLibrary.Method.t list -> 24 | attributes:BaristaLibrary.Attribute.for_class list -> 25 | BaristaLibrary.Bytes.t 26 | (** Compiles to class file format the class definition whose elements are 27 | passed. *) 28 | 29 | val make_startup_class : (Cmj_format.unit_infos * string * Digest.t) list -> string -> string * BaristaLibrary.Bytes.t 30 | (** [make_startup_class units_to_link execname] compiles the startup 31 | class, and returns its name and class file contents. [units_to_link] 32 | contains the list of module to link, and [execname] is the name of 33 | the executable file to be created. *) 34 | 35 | -------------------------------------------------------------------------------- /compiler/driver/javacompile.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * Original file (driver/optcompile.mli in the OCaml source 5 | * distribution) is Copyright (C) INRIA. 6 | * 7 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | * it under the terms of the Q Public License as published by 9 | * Trolltech (with a change to choice of law). 10 | * 11 | * OCaml-Java compiler is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * Q Public License for more details. 15 | * 16 | * You should have received a copy of the Q Public License 17 | * along with this program. If not, see 18 | * . 19 | *) 20 | 21 | (** Compile a .mli, .ml, or .java file *) 22 | 23 | val interface: Format.formatter -> string -> string -> unit 24 | (** [interface fmt src prefix] compiles the interface file whose path is 25 | [src] and produces files with prefix [prefix]. [fmt] is used for 26 | output (errors, warnings, etc.). *) 27 | 28 | val implementation: Format.formatter -> string -> string -> unit 29 | (** [implementation fmt src prefix] compiles the implementation file 30 | whose path is [src] and produces files with prefix [prefix]. [fmt] is 31 | used for output (errors, warnings, etc.). *) 32 | 33 | val java_file: string -> unit 34 | (** Compiles the file whose path is passed using a Java compiler. *) 35 | -------------------------------------------------------------------------------- /compiler/javacomp/bytecodegen_prim.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | (** Compilation of OCaml primitives. *) 20 | 21 | val compile_primitive : int -> Lambda.primitive -> Macroinstr.expression list -> 22 | (int -> Macroinstr.expression list -> Instrtree.t) -> 23 | (bool -> int -> Macroinstr.expression -> Instrtree.t) -> 24 | Instrtree.t 25 | (** [compile_primitive ofs prim args cl ce] compiles the primitive [prim] 26 | at offset [ofs] with arguments [args]; the functions [cl] and [ce] 27 | are used to compile respectively expression lists and simple 28 | expressions. The first function takes the following parameters: 29 | - offset; 30 | - expression list to compile. 31 | 32 | The second function takes the following parameters: 33 | - whether the expression is in a tail position; 34 | - offest; 35 | - expression to compile. *) 36 | -------------------------------------------------------------------------------- /compiler/otherlibs/labltk/jpf/Makefile-ocamljava: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java compiler. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | # it under the terms of the Q Public License v1.0 as published by 7 | # Trolltech (with a change to choice of law). 8 | # 9 | # OCaml-Java compiler is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # Q Public License for more details. 13 | # 14 | # You should have received a copy of the Q Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | 19 | TOPDIR=../../.. 20 | LIBNAME=labltk 21 | include $(TOPDIR)/config/Makefile 22 | INSTALLDIR=$(LIBDIR)/$(LIBNAME) 23 | 24 | OCAMLJAVA=$(TOPDIR)/ocamljava.opt 25 | COMPFLAGS=-g -java-package 'ocaml.otherlibs.labltk' -nostdlib -I $(TOPDIR)/stdlib -I $(TOPDIR)/otherlibs/unix -I $(TOPDIR)/otherlibs/str -I ../labltk -I ../support 26 | 27 | OBJS=fileselect.cmj balloon.cmj shell.cmj jpf_font.cmj 28 | 29 | all: jpflib.cmja 30 | 31 | jpflib.cmja: $(patsubst %.cmj,%.cmi,$(CMJ_FILES)) $(OBJS) 32 | $(OCAMLJAVA) -a -o jpflib.cmja $(OBJS) 33 | 34 | install: 35 | cp jpflib.cmja jpflib.ja $(OBJS) $(INSTALLDIR) 36 | 37 | clean: 38 | rm -f *.cm* *.jo *.ja 39 | 40 | .SUFFIXES: 41 | .SUFFIXES: .mli .ml .cmi .cmj 42 | 43 | .mli.cmi: 44 | $(OCAMLJAVA) -c $(COMPFLAGS) $< 45 | 46 | .ml.cmj: 47 | $(OCAMLJAVA) -c $(COMPFLAGS) $< 48 | -------------------------------------------------------------------------------- /compiler/javacomp/bytecodegen_javaprim.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | (** Compilation of ocamljava-specific primitives. *) 20 | 21 | val compile_java_primitive : int -> Jlambda.java_primitive -> Macroinstr.expression list -> 22 | (int -> Macroinstr.expression list -> Instrtree.t) -> 23 | (bool -> int -> Macroinstr.expression -> Instrtree.t) -> 24 | Instrtree.t 25 | (** [compile_java_primitive ofs prim args cl ce] compiles the primitive 26 | [prim] at offset [ofs] with arguments [args]; the functions [cl] and 27 | [ce] are used to compile respectively expression lists and simple 28 | expressions. The first function takes the following parameters: 29 | - offset; 30 | - expression list to compile. 31 | 32 | The second function takes the following parameters: 33 | - whether the expression is in a tail position; 34 | - offest; 35 | - expression to compile. *) 36 | -------------------------------------------------------------------------------- /compiler/scripts/ocamlj: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java compiler. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | # it under the terms of the Q Public License v1.0 as published by 7 | # Trolltech (with a change to choice of law). 8 | # 9 | # OCaml-Java compiler is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # Q Public License for more details. 13 | # 14 | # You should have received a copy of the Q Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | 19 | case "`uname`" in 20 | CYGWIN*) 21 | if [ ! -z "$JAVA_HOME" ]; then 22 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 23 | fi 24 | ;; 25 | Darwin*) 26 | if [ -z "$JAVA_HOME" ]; then 27 | JAVA_HOME=`/usr/libexec/java_home -F -v 1.7+` 28 | if [ $? != 0 ]; then 29 | echo 'error: unable to find a Java 1.7 installation.' 30 | exit 1 31 | fi 32 | fi 33 | ;; 34 | *) ;; 35 | esac 36 | 37 | if [ -z "$JAVA_HOME" ]; then 38 | OCJ_JAVA=`which java 2> /dev/null` 39 | if [ -z "$OCJ_JAVA" ]; then 40 | echo 'error: unable to find Java home.' 41 | exit 1 42 | fi 43 | else 44 | OCJ_JAVA=$JAVA_HOME/bin/java 45 | fi 46 | 47 | OCJ_JAR=`dirname $0`/ocamlj.jar 48 | case "`uname`" in 49 | CYGWIN*) OCJ_JAR=`cygpath --mixed "$OCJ_JAR"` ;; 50 | *) ;; 51 | esac 52 | exec "$OCJ_JAVA" -Xss8M -jar "$OCJ_JAR" $@ 53 | -------------------------------------------------------------------------------- /compiler/javacomp/javapackager.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * Original file (asmcomp/asmpackager.mli in the OCaml source 5 | * distribution) is Copyright (C) INRIA. 6 | * 7 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | * it under the terms of the Q Public License as published by 9 | * Trolltech (with a change to choice of law). 10 | * 11 | * OCaml-Java compiler is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * Q Public License for more details. 15 | * 16 | * You should have received a copy of the Q Public License 17 | * along with this program. If not, see 18 | * . 19 | *) 20 | 21 | (** "Package" a set of .cmj/.jo files into one .cmj/.jo file having the 22 | original compilation units as sub-modules. *) 23 | 24 | val package_files: Format.formatter -> string list -> string -> unit 25 | (** [package_files fmt files targetcmj] packages [files] into 26 | [targetcmj], [fmt] being used for verbose output. *) 27 | 28 | type error = 29 | Illegal_renaming of string * string * string 30 | | Forward_reference of string * string 31 | | Wrong_for_pack of string * string 32 | | Linking_error of string 33 | | File_not_found of string 34 | | File_compiled_with_a_different_int_size of string 35 | 36 | exception Error of error 37 | 38 | val report_error: Format.formatter -> error -> unit 39 | (** Pretty-prints an error. *) 40 | -------------------------------------------------------------------------------- /compiler/javacomp/jclosure.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * Original file (asmcomp/closure.mli in the OCaml source 5 | * distribution) is Copyright (C) INRIA. 6 | * 7 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | * it under the terms of the Q Public License as published by 9 | * Trolltech (with a change to choice of law). 10 | * 11 | * OCaml-Java compiler is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * Q Public License for more details. 15 | * 16 | * You should have received a copy of the Q Public License 17 | * along with this program. If not, see 18 | * . 19 | *) 20 | 21 | (** Introduction of closures, uncurrying, recognition of direct calls. *) 22 | 23 | val occurs_var : Ident.t -> Jlambda.jlambda -> bool 24 | (** Tests whether the passed variable occurs in the passed lambda. *) 25 | 26 | val is_pure_jlambda : Jlambda.jlambda -> bool 27 | (** Checks whether the passed jlambda is pure ({i i.e.} with no 28 | side-efect, and without function definition). *) 29 | 30 | val intro: int -> Lambda.lambda -> Jlambda.jlambda 31 | (** Converts the passed lambda into its equivalent jlambda, passed [int] 32 | being the size of global. *) 33 | 34 | type error = 35 | Special_primitive_first_argument 36 | 37 | exception Error of error 38 | 39 | val report_error: Format.formatter -> error -> unit 40 | (** Pretty-prints an error. *) 41 | -------------------------------------------------------------------------------- /compiler/otherlibs/labltk/support/Makefile-ocamljava: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java compiler. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | # it under the terms of the Q Public License v1.0 as published by 7 | # Trolltech (with a change to choice of law). 8 | # 9 | # OCaml-Java compiler is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # Q Public License for more details. 13 | # 14 | # You should have received a copy of the Q Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | 19 | TOPDIR=../../.. 20 | LIBNAME=labltk 21 | include $(TOPDIR)/config/Makefile 22 | INSTALLDIR=$(LIBDIR)/$(LIBNAME) 23 | 24 | OCAMLJAVA=$(TOPDIR)/ocamljava.opt 25 | COMPFLAGS=-g -java-package 'ocaml.otherlibs.labltk' -nostdlib -I $(TOPDIR)/stdlib -I $(TOPDIR)/otherlibs/systhreads -I $(TOPDIR)/otherlibs/unix 26 | CMJ_FILES=support.cmj rawwidget.cmj widget.cmj protocol.cmj textvariable.cmj timer.cmj \ 27 | fileevent.cmj camltkwrap.cmj tkthread.cmj 28 | 29 | all: $(patsubst %.cmj,%.cmi,$(CMJ_FILES)) $(CMJ_FILES) 30 | 31 | install: 32 | cp fileevent.cmj protocol.cmj textvariable.cmj timer.cmj rawwidget.cmj widget.cmj tkthread.cmj \ 33 | $(INSTALLDIR) 34 | 35 | clean: 36 | rm -f *.cm* *.jo *.ja 37 | 38 | .SUFFIXES: 39 | .SUFFIXES: .mli .ml .cmi .cmj 40 | 41 | .mli.cmi: 42 | $(OCAMLJAVA) -c $(COMPFLAGS) $< 43 | 44 | .ml.cmj: 45 | $(OCAMLJAVA) -c $(COMPFLAGS) $< 46 | -------------------------------------------------------------------------------- /library/concurrent/src/futures/rejectedExecutionHandler.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | open Class'java'util'concurrent'RejectedExecutionHandler 20 | 21 | type t = _'RejectedExecutionHandler java_instance 22 | 23 | let abort_policy = 24 | Java.make "java.util.concurrent.ThreadPoolExecutor.AbortPolicy()" () 25 | |> Java.cast "RejectedExecutionHandler" 26 | 27 | let caller_runs_policy = 28 | Java.make "java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy()" () 29 | |> Java.cast "RejectedExecutionHandler" 30 | 31 | let discard_oldest_policy = 32 | Java.make "java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy()" () 33 | |> Java.cast "RejectedExecutionHandler" 34 | 35 | let discard_policy = 36 | Java.make "java.util.concurrent.ThreadPoolExecutor.DiscardPolicy()" () 37 | |> Java.cast "RejectedExecutionHandler" 38 | -------------------------------------------------------------------------------- /wrapper/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java wrapper. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU Lesser General Public License as published by 7 | # the Free Software Foundation; either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public License 16 | # along with this program. If not, see . 17 | # 18 | 19 | include ../Makefile.config 20 | 21 | MAIN_MODULE=ocamlwrap 22 | OCAMLBUILD=$(PREFIX)/bin/ocamlbuild -classic-display -no-links 23 | 24 | default: 25 | @echo "available targets:" 26 | @echo " clean deletes all produced files" 27 | @echo " build compiles all versions (bytecode, native, jar)" 28 | @echo " install copies executable files" 29 | 30 | clean: 31 | $(OCAMLBUILD) -clean 32 | 33 | build: 34 | $(OCAMLBUILD) $(MAIN_MODULE).byte 35 | $(OCAMLBUILD) $(MAIN_MODULE).native 36 | $(OCAMLBUILD) $(MAIN_MODULE).jar 37 | 38 | install: 39 | cp _build/src/$(MAIN_MODULE).byte $(PREFIX)/bin/$(MAIN_MODULE) 40 | cp _build/src/$(MAIN_MODULE).native $(PREFIX)/bin/$(MAIN_MODULE).opt 41 | cp _build/src/$(MAIN_MODULE).jar $(PREFIX)/bin/$(MAIN_MODULE).jar 42 | 43 | .PHONY: default clean build install 44 | -------------------------------------------------------------------------------- /library/javalib/src/javaPervasives.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | (** An initially-opened module for Java. 20 | 21 | The module is automatically opened when {k -java-extensions} is 22 | passed to the {k ocamljava} compiler. *) 23 | 24 | external (|.) : ('a -> 'b) -> 'a -> 'b = "%apply" 25 | (** Akin to [Pervasives.(@@)], with a different priority allowing to 26 | chain calls with parameters: 27 | {[ 28 | Java.make "..." 29 | |> Java.call "..." |. p1 |. ... |. pn 30 | |> ... 31 | ]} *) 32 | 33 | external (!@) : string -> java'lang'String java_instance = 34 | "ocamljava_javastring_of_string" 35 | (** Synonym for {!JavaString.of_string}. *) 36 | 37 | val (^^^) : java'lang'String java_instance -> java'lang'String java_instance -> java'lang'String java_instance 38 | (** Concatenation of Java strings. *) 39 | -------------------------------------------------------------------------------- /optimizer/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java optimizer. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java optimizer is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU Lesser General Public License as published by 7 | # the Free Software Foundation; either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # OCaml-Java optimizer is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public License 16 | # along with this program. If not, see . 17 | # 18 | 19 | include ../Makefile.config 20 | 21 | MAIN_MODULE=ocamljar 22 | OCAMLBUILD=$(PREFIX)/bin/ocamlbuild -classic-display -no-links 23 | 24 | default: 25 | @echo "available targets:" 26 | @echo " clean deletes all produced files" 27 | @echo " build compiles all versions (bytecode, native, jar)" 28 | @echo " install copies executable files" 29 | 30 | clean: 31 | $(OCAMLBUILD) -clean 32 | 33 | build: 34 | $(OCAMLBUILD) $(MAIN_MODULE).byte 35 | $(OCAMLBUILD) $(MAIN_MODULE).native 36 | $(OCAMLBUILD) $(MAIN_MODULE).jar 37 | 38 | install: 39 | cp _build/src/$(MAIN_MODULE).byte $(PREFIX)/bin/$(MAIN_MODULE) 40 | cp _build/src/$(MAIN_MODULE).native $(PREFIX)/bin/$(MAIN_MODULE).opt 41 | cp _build/src/$(MAIN_MODULE).jar $(PREFIX)/bin/$(MAIN_MODULE).jar 42 | 43 | .PHONY: default clean build install 44 | -------------------------------------------------------------------------------- /compiler/toplevel/scriptloop.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * Original file (toplevel/opttoploop.mli in the OCaml source 5 | * distribution) is Copyright (C) INRIA. 6 | * 7 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | * it under the terms of the Q Public License as published by 9 | * Trolltech (with a change to choice of law). 10 | * 11 | * OCaml-Java compiler is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * Q Public License for more details. 15 | * 16 | * You should have received a copy of the Q Public License 17 | * along with this program. If not, see 18 | * . 19 | *) 20 | 21 | (** Implementation of scripting engine. *) 22 | 23 | 24 | val set_paths : unit -> unit 25 | (** Initializes load path. *) 26 | 27 | val init : unit -> unit 28 | (** Initializes the scripting engine, to make it ready to evaluate 29 | toplevel phrases. Registers the following callbacks: 30 | - ["ocamljava javax.script.eval"] of type [string -> 'a] 31 | that evaluates the passed phrase and returns the result of its 32 | evaluation, raising an exception if evaluation either fails or 33 | raises an exception; 34 | - ["ocamljava javax.script.directory"] of type [string -> unit] 35 | that adds the passed directory to the search path; 36 | - ["ocamljava javax.script.load"] of type [string -> unit] 37 | that loads the file whose path is passed. *) 38 | -------------------------------------------------------------------------------- /optimizer/src/mapper.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java optimizer. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java optimizer is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java optimizer is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | (** Mappers for various structures. *) 20 | 21 | 22 | class for_compiled_module : Misc.remove_index_function -> BaristaLibrary.ClassTraversal.class_definition_mapper 23 | (** Mapper for OCaml modules compiled into Java classes by the OCaml-Java 24 | compiler. *) 25 | 26 | class for_entry_point : BaristaLibrary.ClassTraversal.class_definition_mapper 27 | (** Mapper for program entry points created at link time by the 28 | OCaml-Java compiler. *) 29 | 30 | class for_runtime : bool -> BaristaLibrary.ClassTraversal.class_definition_mapper 31 | (** Mapper for classes from the runtime support of OCaml-Java. *) 32 | 33 | class for_archive : BaristaLibrary.ArchiveFile.t -> Misc.remove_index_function -> BaristaLibrary.ArchiveTraversal.archive_mapper 34 | (** Mapper for whole archives containing standalone OCaml programs. *) 35 | -------------------------------------------------------------------------------- /wrapper/src/ocamlwrap.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | 20 | let main () = 21 | Args.parse (); 22 | Config.load_path := 23 | [ "."; Config.standard_library ] 24 | @ (List.rev !Args.includes) 25 | @ !Config.load_path; 26 | List.iter 27 | (fun { Args.file_name; file_package } -> 28 | let packname= 29 | match file_package with 30 | | Some _ -> file_package 31 | | None -> !Args.package in 32 | Wrap.file file_name packname) 33 | (List.rev !Args.files) 34 | 35 | let error kind msg = 36 | Printf.eprintf "*** %s: %s\n" kind msg; 37 | exit 1 38 | 39 | let () = 40 | try 41 | main (); 42 | exit 0 43 | with 44 | | Wrap_common.Exception e -> 45 | error "error" (Wrap_common.string_of_error e) 46 | | Sys_error se -> 47 | error "system error" se 48 | | e -> 49 | error "error" (Printexc.to_string e) 50 | -------------------------------------------------------------------------------- /library/javalib/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java library. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java library is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU Lesser General Public License as published by 7 | # the Free Software Foundation; either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # OCaml-Java library is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public License 16 | # along with this program. If not, see . 17 | # 18 | 19 | include ../../Makefile.config 20 | 21 | LIBRARY_NAME=javalib 22 | OCAMLBUILD=$(PREFIX)/bin/ocamlbuild -classic-display -no-links 23 | INSTALL_PATH=$(PREFIX)/lib/ocaml/$(LIBRARY_NAME) 24 | 25 | default: 26 | @echo "available targets:" 27 | @echo " clean deletes all produced files" 28 | @echo " build compiles library and generates documentation" 29 | @echo " install copies library files" 30 | 31 | clean: 32 | $(OCAMLBUILD) -clean 33 | rm -f $(LIBRARY_NAME).mllib $(LIBRARY_NAME).odocl 34 | 35 | build: 36 | $(OCAMLBUILD) $(LIBRARY_NAME).cmja 37 | $(OCAMLBUILD) $(LIBRARY_NAME).docdir/index.html 38 | 39 | install: 40 | mkdir -p $(INSTALL_PATH) 41 | cp _build/$(LIBRARY_NAME).cm* _build/$(LIBRARY_NAME).j* $(INSTALL_PATH) 42 | cp `find _build/src -name '*.cm*' -o -name '*.j*'` $(INSTALL_PATH) 43 | 44 | .PHONY: default clean build install 45 | -------------------------------------------------------------------------------- /library/concurrent/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java library. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java library is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU Lesser General Public License as published by 7 | # the Free Software Foundation; either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # OCaml-Java library is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public License 16 | # along with this program. If not, see . 17 | # 18 | 19 | include ../../Makefile.config 20 | 21 | LIBRARY_NAME=concurrent 22 | OCAMLBUILD=$(PREFIX)/bin/ocamlbuild -classic-display -no-links 23 | INSTALL_PATH=$(PREFIX)/lib/ocaml/$(LIBRARY_NAME) 24 | 25 | default: 26 | @echo "available targets:" 27 | @echo " clean deletes all produced files" 28 | @echo " build compiles library and generates documentation" 29 | @echo " install copies library files" 30 | 31 | clean: 32 | $(OCAMLBUILD) -clean 33 | rm -f $(LIBRARY_NAME).mllib $(LIBRARY_NAME).odocl 34 | 35 | build: 36 | $(OCAMLBUILD) $(LIBRARY_NAME).cmja 37 | $(OCAMLBUILD) $(LIBRARY_NAME).docdir/index.html 38 | 39 | install: 40 | mkdir -p $(INSTALL_PATH) 41 | cp _build/$(LIBRARY_NAME).cm* _build/$(LIBRARY_NAME).j* $(INSTALL_PATH) 42 | cp `find _build/src -name '*.cm*' -o -name '*.j*'` $(INSTALL_PATH) 43 | 44 | .PHONY: default clean build install 45 | -------------------------------------------------------------------------------- /library/concurrent/src/timeUnit.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | (** Time units. *) 20 | 21 | 22 | type t = java'util'concurrent'TimeUnit java_instance 23 | (** The type of units used to express durations ({i e.g.} for timeouts). *) 24 | 25 | val nanoseconds : t 26 | (** Time unit for nanoseconds. *) 27 | 28 | val microseconds : t 29 | (** Time unit for microseconds. *) 30 | 31 | val milliseconds : t 32 | (** Time unit for milliseconds. *) 33 | 34 | val seconds : t 35 | (** Time unit for seconds. *) 36 | 37 | val minutes : t 38 | (** Time unit for minutes. *) 39 | 40 | val hours : t 41 | (** Time unit for hours. *) 42 | 43 | val days : t 44 | (** Time unit for days. *) 45 | 46 | val convert : src:t -> dst:t -> java_long -> java_long 47 | (** [convert ~src ~dst x] converts the value [x] from unit [src] to unit 48 | [dst]; see {java java.util.concurrent.TimeUnit#convert(long, java.util.concurrent.TimeUnit)} *) 49 | -------------------------------------------------------------------------------- /library/concurrent/src/sync/exchanger.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | open Class'java'util'concurrent'Exchanger 20 | 21 | type 'a t = _'Exchanger java_instance 22 | 23 | let make () = 24 | Java.make "Exchanger()" () 25 | 26 | external exchange : 'a t -> 'a -> 'a = 27 | "ocamljava_exchanger_exchange" 28 | 29 | external exchange_time : 'a t -> 'a -> int64 -> TimeUnit.t -> 'a = 30 | "ocamljava_exchanger_exchange_time" 31 | 32 | 33 | (* Null value *) 34 | 35 | external null : unit -> 'a java_instance = 36 | "java null" 37 | 38 | let null = null () 39 | 40 | external is_null : 'a java_instance -> bool = 41 | "java is_null" 42 | 43 | external is_not_null : 'a java_instance -> bool = 44 | "java is_not_null" 45 | 46 | 47 | (* Miscellaneous *) 48 | 49 | let wrap x = 50 | if is_null x then 51 | None 52 | else 53 | Some x 54 | 55 | let unwrap = function 56 | | Some x -> x 57 | | None -> null 58 | -------------------------------------------------------------------------------- /library/concurrent/src/threads/threadLocal.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | type 'a t = _'ThreadLocal java_instance 20 | 21 | external make : 'a -> 'a t = 22 | "ocamljava_threadlocal_make" 23 | 24 | external get : 'a t -> 'a = 25 | "ocamljava_threadlocal_get" 26 | 27 | external remove : 'a t -> unit = 28 | "ocamljava_threadlocal_remove" 29 | 30 | external set : 'a t -> 'a -> unit = 31 | "ocamljava_threadlocal_set" 32 | 33 | 34 | (* Null value *) 35 | 36 | external null : unit -> 'a java_instance = 37 | "java null" 38 | 39 | let null = null () 40 | 41 | external is_null : 'a java_instance -> bool = 42 | "java is_null" 43 | 44 | external is_not_null : 'a java_instance -> bool = 45 | "java is_not_null" 46 | 47 | 48 | (* Miscellaneous *) 49 | 50 | let wrap x = 51 | if is_null x then 52 | None 53 | else 54 | Some x 55 | 56 | let unwrap = function 57 | | Some x -> x 58 | | None -> null 59 | -------------------------------------------------------------------------------- /compiler/otherlibs/labltk/frx/Makefile-ocamljava: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java compiler. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | # it under the terms of the Q Public License v1.0 as published by 7 | # Trolltech (with a change to choice of law). 8 | # 9 | # OCaml-Java compiler is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # Q Public License for more details. 13 | # 14 | # You should have received a copy of the Q Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | 19 | TOPDIR=../../.. 20 | LIBNAME=labltk 21 | include $(TOPDIR)/config/Makefile 22 | INSTALLDIR=$(LIBDIR)/$(LIBNAME) 23 | 24 | OCAMLJAVA=$(TOPDIR)/ocamljava.opt 25 | COMPFLAGS=-g -java-package 'ocaml.otherlibs.labltk' -nostdlib -I $(TOPDIR)/stdlib -I ../camltk -I ../support 26 | 27 | OBJS=frx_misc.cmj frx_widget.cmj frx_font.cmj frx_entry.cmj frx_text.cmj frx_listbox.cmj \ 28 | frx_req.cmj frx_fillbox.cmj frx_focus.cmj frx_dialog.cmj frx_mem.cmj frx_rpc.cmj frx_synth.cmj \ 29 | frx_selection.cmj frx_after.cmj frx_fit.cmj frx_ctext.cmj frx_color.cmj 30 | 31 | all: frxlib.cmja 32 | 33 | frxlib.cmja: $(patsubst %.cmj,%.cmi,$(CMJ_FILES)) $(OBJS) 34 | $(OCAMLJAVA) -a -o frxlib.cmja $(OBJS) 35 | 36 | install: 37 | cp frxlib.cmja frxlib.ja $(INSTALLDIR) 38 | 39 | clean: 40 | rm -f *.cm* *.jo *.ja 41 | 42 | .SUFFIXES: 43 | .SUFFIXES: .mli .ml .cmi .cmj 44 | 45 | .mli.cmi: 46 | $(OCAMLJAVA) -c $(COMPFLAGS) $< 47 | 48 | .ml.cmj: 49 | $(OCAMLJAVA) -c $(COMPFLAGS) $< 50 | -------------------------------------------------------------------------------- /library/javalib/src/javaSystem.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | 20 | (* Properties *) 21 | 22 | let clear_property name = 23 | Java.call "System.clearProperty(String)" name 24 | 25 | let get_property name = 26 | Java.call "System.getProperty(String)" name 27 | 28 | let get_property_default name default = 29 | Java.call "System.getProperty(String,String)" name default 30 | 31 | let set_property name value = 32 | Java.call "System.setProperty(String,String)" name value 33 | 34 | 35 | (* Time *) 36 | 37 | let current_time_millis () = 38 | Java.call "System.currentTimeMillis()" () 39 | 40 | let nano_time () = 41 | Java.call "System.nanoTime()" () 42 | 43 | 44 | (* Garbage collector *) 45 | 46 | let gc () = 47 | Java.call "System.gc()" () 48 | 49 | let run_finalization () = 50 | Java.call "System.runFinalization()" () 51 | 52 | 53 | (* Environment *) 54 | 55 | let get_env name = 56 | Java.call "System.getenv(String)" name 57 | -------------------------------------------------------------------------------- /library/concurrent/src/futures/rejectedExecutionHandler.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | (** Policies for blocked executions. *) 20 | 21 | 22 | type t = java'util'concurrent'RejectedExecutionHandler java_instance 23 | (** The type of policies for blocked executions, that is when thread and 24 | queue bounds have been reached. *) 25 | 26 | val abort_policy : t 27 | (** Reject computation; see 28 | {java java.util.concurrent.ThreadPoolExecutor.AbortPolicy}. *) 29 | 30 | val caller_runs_policy : t 31 | (** Run the computation in the calling thread; see 32 | {java java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy}. *) 33 | 34 | val discard_oldest_policy : t 35 | (** Discard the oldest unstarted computation; see 36 | {java java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy}. *) 37 | 38 | val discard_policy : t 39 | (** Discard the submitted computation; see 40 | {java java.util.concurrent.ThreadPoolExecutor.DiscardPolicy}. *) 41 | -------------------------------------------------------------------------------- /library/javalib/src/javaFX.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | (** Support for JavaFX applications. 20 | 21 | In order to produce a jar archive containing a JavaFX application, it 22 | is necessary to link the application with the {k -javafx-application} 23 | command-line switch. An application class will be generated, 24 | with the name {i pack.ocamljavaFXApplication} where {i pack} can be 25 | set using the {k -java-package {i pack}} command-line switch. 26 | 27 | When linking with the {k -javafx-application {i k}} command-line 28 | switch, the last module to be linked has to be compatible with the 29 | [JavaFX.Application] module type. *) 30 | 31 | 32 | (* Applications *) 33 | 34 | type application = javafx'application'Application java_instance 35 | 36 | type stage = javafx'stage'Stage java_instance 37 | 38 | module type Application = sig 39 | val init : application -> unit 40 | val start : application -> stage -> unit 41 | val stop : application -> unit 42 | end 43 | -------------------------------------------------------------------------------- /wrapper/src/typeInfo.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | (** Definition of types: names and conversion functions. *) 20 | 21 | type conversion_function = JavaAST.expression -> JavaAST.expression 22 | (** The type of conversion functions, mapping code fragments. *) 23 | 24 | type t = { 25 | ocaml_type : Path.t option; (** OCaml type name. *) 26 | java_type : JavaAST.type_; (** Java type name. *) 27 | java_of_ocaml : conversion_function; (** Conversion from OCaml to Java. *) 28 | ocaml_of_java : conversion_function; (** Conversion from Java to OCaml. *) 29 | } 30 | (** The type of type definitions. *) 31 | 32 | val make_simple : Ident.t -> Path.t * t 33 | (** [make_simple id] returns a [(path, info)] couple for the passed OCaml 34 | name [id], where [path] is just [id] unqualified and [info] contains 35 | the default conversion functions. *) 36 | 37 | val predefined_types : bool -> t list 38 | (** Returns the list of predefined types, the passed boolean indicating 39 | whether types are boxed. *) 40 | -------------------------------------------------------------------------------- /library/concurrent/src/locks/readWriteLock.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | open Class'java'util'concurrent'locks'Lock 20 | open Class'java'util'concurrent'locks'ReentrantReadWriteLock 21 | 22 | type t = _'ReentrantReadWriteLock java_instance 23 | 24 | let make_reentrant ?(fair = false) () = 25 | Java.make "ReentrantReadWriteLock(boolean)" fair 26 | 27 | let read_lock rwl = 28 | Java.call "ReentrantReadWriteLock.readLock():Lock" rwl 29 | 30 | let write_lock rwl = 31 | Java.call "ReentrantReadWriteLock.writeLock():Lock" rwl 32 | 33 | 34 | (* Null value *) 35 | 36 | external null : unit -> 'a java_instance = 37 | "java null" 38 | 39 | let null = null () 40 | 41 | external is_null : 'a java_instance -> bool = 42 | "java is_null" 43 | 44 | external is_not_null : 'a java_instance -> bool = 45 | "java is_not_null" 46 | 47 | 48 | (* Miscellaneous *) 49 | 50 | let wrap x = 51 | if is_null x then 52 | None 53 | else 54 | Some x 55 | 56 | let unwrap = function 57 | | Some x -> x 58 | | None -> null 59 | -------------------------------------------------------------------------------- /library/javalib/src/javaRuntime.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | (** Runtime information. *) 20 | 21 | 22 | type t = java'lang'Runtime java_instance 23 | (** The type of runtime instances. *) 24 | 25 | val get_runtime : unit -> t 26 | (** Returns the runtime for the current Java application; see 27 | {java java.lang.Runtime#getRuntime()}. *) 28 | 29 | val available_processors : t -> java_int 30 | (** Returns the number of (logical) available processors; see 31 | {java java.lang.Runtime#availableProcessors()}. *) 32 | 33 | val free_memory : t -> java_long 34 | (** Returns the amount of free memory in the JVM (in bytes); see 35 | {java java.lang.Runtime#freeMemory()}. *) 36 | 37 | val max_memory : t -> java_long 38 | (** Returns the maximum amount of memory to be used by the JVM 39 | (in bytes); see {java java.lang.Runtime#maxMemory()}. *) 40 | 41 | val total_memory : t -> java_long 42 | (** Returns the total amount of memory used by the JVM (in bytes); see 43 | {java java.lang.Runtime#totalMemory()}. *) 44 | -------------------------------------------------------------------------------- /compiler/utils/jcomp.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | 20 | open BaristaLibrary 21 | 22 | let compile_file name = 23 | (* There is no needed to check 'Jclflags.classpath_reset' because it is 24 | only used to know whether to include the elements of the system 25 | classpath, and we never have to pass such elements to the Java 26 | compiler. *) 27 | let separator = 28 | ClassPath.default_separator 29 | |> UChar.to_char 30 | |> String.make 1 in 31 | let classpath = 32 | ((Jconfig.get_runtime_jar ()) :: (List.rev !Jclflags.classpath)) 33 | |> String.concat separator in 34 | let options = 35 | match !Clflags.all_ccopts with 36 | | _ :: _ -> 37 | let opts = 38 | !Clflags.all_ccopts 39 | |> List.rev 40 | |> String.concat " " in 41 | " " ^ opts 42 | | [] -> 43 | "" in 44 | let command = 45 | Printf.sprintf "%s -cp %s%s %s" 46 | (match !Clflags.c_compiler with 47 | | Some x -> x 48 | | None -> "javac") 49 | classpath 50 | options 51 | (Filename.quote name) in 52 | Ccomp.command command 53 | -------------------------------------------------------------------------------- /optimizer/myocamlbuild.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java optimizer. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java optimizer is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java optimizer is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | open Ocamlbuild_plugin 20 | 21 | let () = 22 | dispatch begin function 23 | | After_rules -> 24 | flag ["ocaml"; "compile"; "warnings"] 25 | (S[A"-w"; A"Ae"; A"-warn-error"; A"A"]); 26 | flag ["ocaml"; "compile"; "use_barista"] 27 | (S[A"-I"; A"+barista"]); 28 | flag ["ocaml"; "link"; "byte"; "use_barista"] 29 | (S[A"unix.cma"; 30 | A"-I"; A"+zip"; A"zip.cma"; 31 | A"bigarray.cma"; 32 | A"camomile.cma"; 33 | A"-I"; A"+barista"; A"baristaLibrary.cma"]); 34 | flag ["ocaml"; "link"; "native"; "use_barista"] 35 | (S[A"unix.cmxa"; 36 | A"-I"; A"+zip"; A"zip.cmxa"; 37 | A"bigarray.cmxa"; 38 | A"camomile.cmxa"; 39 | A"-I"; A"+barista"; A"baristaLibrary.cmxa"]); 40 | flag ["ocaml"; "link"; "java"; "use_barista"] 41 | (S[A"-I"; A"+barista"; A"baristaLibrary.cmja"]); 42 | | _ -> () 43 | end 44 | -------------------------------------------------------------------------------- /optimizer/src/state.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java optimizer. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java optimizer is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java optimizer is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | open BaristaLibrary 20 | 21 | 22 | let input_file = ref "UNINITALIZED" 23 | 24 | let current_class_name = ref (Misc.make_class_name_ext "UNINITALIZED") 25 | 26 | let class_loader = ref None 27 | 28 | let get_class_loader () = 29 | match !class_loader with 30 | | Some x -> x 31 | | None -> 32 | let cl_init = 33 | ClassPath.make () 34 | |> ClassPath.append (UTF8.of_string !input_file) in 35 | let cl = 36 | List.fold_left 37 | (fun acc elem -> ClassPath.append (UTF8.of_string elem) acc) 38 | cl_init 39 | !Args.classpath 40 | |> ClassLoader.make_of_class_path in 41 | class_loader := Some cl; 42 | cl 43 | 44 | let unifier = ref None 45 | 46 | let get_unifier () = 47 | match !unifier with 48 | | Some x -> x 49 | | None -> 50 | let unif = 51 | StackState.unify_to_closest_common_parent 52 | (get_class_loader ()) 53 | [] in 54 | unifier := Some unif; 55 | unif 56 | -------------------------------------------------------------------------------- /compiler/javacomp/cmj_format.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * Original file (asmcomp/cmj_format.ml in the OCaml source 5 | * distribution) is Copyright (C) INRIA. 6 | * 7 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | * it under the terms of the Q Public License as published by 9 | * Trolltech (with a change to choice of law). 10 | * 11 | * OCaml-Java compiler is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * Q Public License for more details. 15 | * 16 | * You should have received a copy of the Q Public License 17 | * along with this program. If not, see 18 | * . 19 | *) 20 | 21 | type unit_infos = 22 | { mutable ui_name: string; 23 | mutable ui_javaname: string; 24 | mutable ui_additional_classes: string list; 25 | mutable ui_symbol: string; 26 | mutable ui_defines: string list; 27 | mutable ui_imports_cmi: (string * Digest.t) list; 28 | mutable ui_imports_cmj: (string * Digest.t) list; 29 | mutable ui_approx: Jlambda.value_approximation; 30 | mutable ui_force_link: bool; 31 | mutable ui_ensure_init: string list; 32 | ui_ints_are_63_bit_long: bool; } 33 | 34 | type library_infos = 35 | { lib_units: (unit_infos * Digest.t) list; 36 | lib_ccobjs: string list; 37 | lib_ints_are_63_bit_long: bool; } 38 | 39 | type dynunit = { 40 | dynu_name: string; 41 | dynu_crc: Digest.t; 42 | dynu_imports_cmi: (string * Digest.t) list; 43 | dynu_imports_cmj: (string * Digest.t) list; 44 | dynu_defines: string list; 45 | } 46 | 47 | type dynheader = { 48 | dynu_magic: string; 49 | dynu_units: dynunit list; 50 | } 51 | -------------------------------------------------------------------------------- /wrapper/src/wrap_value.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | 20 | open Wrap_common 21 | 22 | let wrap modname ident type_expr global_idx = 23 | let name = Ident.name ident in 24 | Output.verbose (Printf.sprintf " wrapping value %S..." name); 25 | let open JavaAST in 26 | let meth_javadoc = 27 | Printf.sprintf "Returns the value of {@code %s.%s}." modname name in 28 | let info = TypeMap.find false type_expr in 29 | let type_needs_cast = 30 | match info.TypeInfo.java_type with 31 | | Reference (_, _ :: _) -> true 32 | | _ -> false in 33 | let value = get_global global_idx in 34 | let res = info.TypeInfo.java_of_ocaml (Identifier "res") in 35 | let needs_cast = match res with Cast _ -> false | _ -> type_needs_cast in 36 | let res = 37 | if needs_cast then 38 | Cast (info.TypeInfo.java_type, res) 39 | else 40 | res in 41 | method_ 42 | ~javadoc:[meth_javadoc] 43 | [Public; Static] ~return:(Some info.TypeInfo.java_type) name 44 | [Variable_declaration (type_Value, "res", value); 45 | return res] 46 | -------------------------------------------------------------------------------- /library/concurrent/src/futures/future.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | open Class'java'util'concurrent'Future 20 | open Class'java'util'concurrent'TimeUnit 21 | 22 | type 'a t = _'Future java_instance 23 | 24 | let cancel f i = 25 | Java.call "Future.cancel(boolean)" f i 26 | 27 | external get : 'a t -> 'a = 28 | "ocamljava_future_get" 29 | 30 | external get_time : 'a t -> java_long -> TimeUnit.t -> 'a = 31 | "ocamljava_future_get_time" 32 | 33 | let is_cancelled f = 34 | Java.call "Future.isCancelled()" f 35 | 36 | let is_done f = 37 | Java.call "Future.isDone()" f 38 | 39 | 40 | (* Null value *) 41 | 42 | external null : unit -> 'a java_instance = 43 | "java null" 44 | 45 | let null = null () 46 | 47 | external is_null : 'a java_instance -> bool = 48 | "java is_null" 49 | 50 | external is_not_null : 'a java_instance -> bool = 51 | "java is_not_null" 52 | 53 | 54 | (* Miscellaneous *) 55 | 56 | let wrap x = 57 | if is_null x then 58 | None 59 | else 60 | Some x 61 | 62 | let unwrap = function 63 | | Some x -> x 64 | | None -> null 65 | -------------------------------------------------------------------------------- /wrapper/src/typeParametersTable.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | type location = 20 | | Parameter of int list 21 | | Field of string 22 | | Nowhere 23 | 24 | module StringMap = Map.Make (String) 25 | 26 | type t = location StringMap.t 27 | 28 | let empty = StringMap.empty 29 | 30 | let make l = 31 | List.fold_left 32 | (fun acc (id, _) -> 33 | if StringMap.mem id acc then 34 | acc 35 | else 36 | StringMap.add id (Field ("w" ^ id)) acc) 37 | StringMap.empty 38 | l 39 | 40 | let size t = 41 | StringMap.cardinal t 42 | 43 | let mem k t = 44 | StringMap.mem k t 45 | 46 | let find k t = 47 | StringMap.find k t 48 | 49 | let add k v t = 50 | if not (StringMap.mem k t) then 51 | StringMap.add k v t 52 | else 53 | t 54 | 55 | let iter f t = 56 | StringMap.iter f t 57 | 58 | let fold f t z = 59 | StringMap.fold f t z 60 | 61 | let add_parameter t s l = 62 | t := add s (Parameter l) !t 63 | 64 | let add_field t s f = 65 | t := add s (Field f) !t 66 | 67 | let add_nowhere t s = 68 | t := add s Nowhere !t 69 | -------------------------------------------------------------------------------- /compiler/javacomp/archiveutils.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | (** Utility functions over [BaristaLibrary.ArchiveBuilder.t]. *) 20 | 21 | 22 | val open_builder : string -> BaristaLibrary.ArchiveBuilder.t 23 | (** Creates a buider for the given path. *) 24 | 25 | val add_entry : BaristaLibrary.ArchiveBuilder.t -> string -> BaristaLibrary.Bytes.t -> unit 26 | (** [add_entry builder name bytes] adds to [builder] an entry named 27 | [name] whose data is [bytes]. *) 28 | 29 | val add_entry_from_file : BaristaLibrary.ArchiveBuilder.t -> string -> string -> unit 30 | (** [add_entry_from_file builder name file] adds to [builder] an entry 31 | named [name] whose data is read from [file]. *) 32 | 33 | val close : BaristaLibrary.ArchiveBuilder.t -> unit 34 | (** Closes the passed builder, possibly raising an exception. *) 35 | 36 | val close_noerr : BaristaLibrary.ArchiveBuilder.t -> unit 37 | (** Closes the passed builder, discarding any exception. *) 38 | 39 | val copy_entries_list : string list -> string -> string option 40 | (** [copy_entries_list archive_list archive] creates the archive 41 | [archive] and copies to it all entries for the archives in 42 | [archive_list]. *) 43 | -------------------------------------------------------------------------------- /library/concurrent/src/sync/countDownLatch.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | open Class'java'util'concurrent'CountDownLatch 20 | open Class'java'util'concurrent'TimeUnit 21 | 22 | type t = _'CountDownLatch java_instance 23 | 24 | let make n = 25 | Java.make "CountDownLatch(int)" n 26 | 27 | let await cdl = 28 | Java.call "CountDownLatch.await()" cdl 29 | 30 | let await_time cdl time timeunit = 31 | Java.call "CountDownLatch.await(long,TimeUnit)" cdl time timeunit 32 | 33 | let count_down cdl = 34 | Java.call "CountDownLatch.countDown()" cdl 35 | 36 | let get_count cdl = 37 | Java.call "CountDownLatch.getCount()" cdl 38 | 39 | 40 | (* Null value *) 41 | 42 | external null : unit -> 'a java_instance = 43 | "java null" 44 | 45 | let null = null () 46 | 47 | external is_null : 'a java_instance -> bool = 48 | "java is_null" 49 | 50 | external is_not_null : 'a java_instance -> bool = 51 | "java is_not_null" 52 | 53 | 54 | (* Miscellaneous *) 55 | 56 | let wrap x = 57 | if is_null x then 58 | None 59 | else 60 | Some x 61 | 62 | let unwrap = function 63 | | Some x -> x 64 | | None -> null 65 | -------------------------------------------------------------------------------- /compiler/javatyping/jutils.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | (** Basic utility elements related to Java and typing. *) 20 | 21 | 22 | val ocamldoc_mode : bool ref 23 | (** Whether typing code is called from ocamldoc (in this case, 24 | [Path]/[Predef] cannot be used to know whether a given constructor is 25 | an ocamljava-specific one). *) 26 | 27 | val get_class_loader : unit -> BaristaLibrary.ClassLoader.t 28 | (** Returns the class loader used by the compiler, initializing it 29 | if necessary. *) 30 | 31 | val get_unifier : unit -> BaristaLibrary.StackState.instance BaristaLibrary.StackState.unifier 32 | (** Returns a unifier usinsg closest-common-parent policy, based on the 33 | class loader returned by [get_class_loader]. *) 34 | 35 | val is_subtype : BaristaLibrary.Name.for_class -> BaristaLibrary.Name.for_class -> bool 36 | (** [is_subtype x y] returns [true] iff [x] is a subtype of [y]. *) 37 | 38 | val use_dots : string -> string 39 | (** [use_dots s] returns a copy of [s] where all single quotes have been 40 | replaced by dots. *) 41 | 42 | val use_single_quotes : string -> string 43 | (** [use_single_quotes s] returns a copy of [s] where all dots and 44 | dollars have been replaced by single quotes. *) 45 | -------------------------------------------------------------------------------- /doc/manual/examples/javaext-temperature/source.ml: -------------------------------------------------------------------------------- 1 | open Package'java'awt 2 | open Package'java'awt'event 3 | open Package'javax'swing 4 | 5 | let () = 6 | let str = JavaString.of_string in 7 | let open Java in 8 | let title = str "Celsius Converter" in 9 | let frame = make "JFrame(String)" title in 10 | let temp_text = make "JTextField()" () in 11 | let celsius_label = make "JLabel(String)" (str "Celsius") in 12 | let convert_button = make "JButton(String)" (str "Convert") in 13 | let farenheit_label = make "JLabel(String)" (str "Farenheit") in 14 | let handler = proxy "ActionListener" (object 15 | method actionPerformed _ = 16 | try 17 | let c = call "JTextField.getText()" temp_text in 18 | let c = call "Double.parseDouble(_)" c in 19 | let f = (c *. 1.8) +. 32.0 in 20 | let f = Printf.sprintf "%f Farenheit" f in 21 | call "JLabel.setText(_)" farenheit_label (str f) 22 | with Java_exception je -> 23 | let je_msg = call "Throwable.getMessage()" je in 24 | let je_msg = JavaString.to_string je_msg in 25 | let msg = str (Printf.sprintf "invalid float value (%s)" je_msg) in 26 | let error = get "JOptionPane.ERROR_MESSAGE" () in 27 | call "JOptionPane.showMessageDialog(_,_,_,_)" 28 | frame msg title error 29 | end) in 30 | let () = call "JButton.addActionListener(_)" convert_button handler in 31 | let layout = make "GridLayout(_,_,_,_)" 2l 2l 3l 3l in 32 | call "JFrame.setLayout(_)" frame layout; 33 | ignore (call "JFrame.add(Component)" frame temp_text); 34 | ignore (call "JFrame.add(Component)" frame celsius_label); 35 | ignore (call "JFrame.add(Component)" frame convert_button); 36 | ignore (call "JFrame.add(Component)" frame farenheit_label); 37 | call "JFrame.setSize(_,_)" frame 300l 80l; 38 | let exit = get "WindowConstants.EXIT_ON_CLOSE" () in 39 | call "JFrame.setDefaultCloseOperation(int)" frame exit; 40 | call "JFrame.setVisible(_)" frame true 41 | -------------------------------------------------------------------------------- /wrapper/src/wrap_arrow.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | 20 | val get_type_parameters : Types.type_expr list -> Types.type_expr -> TypeParametersTable.t 21 | 22 | val generics_of_type_parameters : TypeParametersTable.t -> string list 23 | 24 | val return_type_of_type_expr : ?reverse:bool -> TypeParametersTable.t -> Types.type_expr -> (JavaAST.type_ * TypeInfo.conversion_function * bool) option 25 | 26 | val make_body : (JavaAST.type_ * (JavaAST.expression -> JavaAST.expression) * bool) option -> TypeParametersTable.t -> JavaAST.expression -> JavaAST.statement list 27 | 28 | val make_try_catch : ?catch_all:bool -> JavaAST.block -> JavaAST.block 29 | 30 | val throws_list : string list 31 | 32 | val wrap_closure : string -> Ident.t -> Types.type_expr -> Jlambda.value_approximation option -> int -> JavaAST.method_ option 33 | (** Returns the method wrapping the closure whose module name, name, type, approximation and global index are passed. *) 34 | 35 | val wrap : string -> Ident.t -> Types.type_expr -> Jlambda.value_approximation option -> int -> JavaAST.method_ 36 | (** Returns the method wrapping the function whose module name, name, type, approximation and global index are passed. *) 37 | -------------------------------------------------------------------------------- /optimizer/src/misc.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java optimizer. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java optimizer is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java optimizer is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | open BaristaLibrary 20 | 21 | 22 | type remove_index_function = BaristaLibrary.Name.for_class -> int -> bool 23 | 24 | let make_class_name_ext s = 25 | s 26 | |> UTF8.of_string 27 | |> Name.make_for_class_from_external 28 | 29 | let make_method_name s = 30 | s 31 | |> UTF8.of_string 32 | |> Name.make_for_method 33 | 34 | let make_field_name s = 35 | s 36 | |> UTF8.of_string 37 | |> Name.make_for_field 38 | 39 | let global_class_of_class cn = 40 | UTF8.(Name.internal_utf8_for_class cn ++ (of_string "$Global")) 41 | |> Name.make_for_class_from_internal 42 | 43 | let runtime_prefix = UTF8.of_string "org.ocamljava.runtime." 44 | 45 | let is_runtime_class cn = 46 | cn 47 | |> Name.external_utf8_for_class 48 | |> UTF8.starts_with runtime_prefix 49 | 50 | let shared_constant_prefixes = 51 | [ UTF8.of_string "INT_" ; 52 | UTF8.of_string "INT32_" ; 53 | UTF8.of_string "INT64_" ; 54 | UTF8.of_string "NATIVEINT_" ; 55 | UTF8.of_string "FLOAT_" ] 56 | 57 | let is_shared_constant fn = 58 | let fn = Name.utf8_for_field fn in 59 | List.exists 60 | (fun p -> UTF8.starts_with p fn) 61 | shared_constant_prefixes 62 | -------------------------------------------------------------------------------- /compiler/javacomp/javalink_fxapplication.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | val check_fxapplication_signature : Cmj_format.unit_infos -> string -> Types.signature * Jlambda.value_approximation array 20 | (** [check_fxapplication_signature unit_infos cmj_file] checks that the 21 | module defined by [unit_infos] and stored in [cmj_file] has a correct 22 | signature with respect to application to compile. 23 | 24 | Returns the actual type for the application, and the approximation 25 | for its module implementation. *) 26 | 27 | type approx = { 28 | init : Jlambda.value_approximation * int; 29 | start : Jlambda.value_approximation * int; 30 | stop : Jlambda.value_approximation * int; 31 | } 32 | (** Approximation for application: approximation value, and approximation 33 | index for each signature element. *) 34 | 35 | val extract_fxapplication_approx : Types.signature_item list -> Jlambda.value_approximation list -> approx 36 | (** Returns the application-specific approximation for the passed 37 | signature and full approximation corresponding to the application 38 | module. *) 39 | 40 | val make_fxapplication_class : Cmj_format.unit_infos -> approx -> string * BaristaLibrary.Bytes.t 41 | (** Compiles the main application class, and returns its name and class file 42 | contents. *) 43 | -------------------------------------------------------------------------------- /library/concurrent/src/futures/scheduledFuture.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | open Class'java'util'concurrent'ScheduledFuture 20 | open Class'java'util'concurrent'TimeUnit 21 | 22 | type 'a t = _'ScheduledFuture java_instance 23 | 24 | let cancel f i = 25 | Java.call "ScheduledFuture.cancel(boolean)" f i 26 | 27 | external get : 'a t -> 'a = 28 | "ocamljava_future_get" 29 | 30 | external get_time : 'a t -> java_long -> TimeUnit.t -> 'a = 31 | "ocamljava_future_get_time" 32 | 33 | let is_cancelled f = 34 | Java.call "ScheduledFuture.isCancelled()" f 35 | 36 | let is_done f = 37 | Java.call "ScheduledFuture.isDone()" f 38 | 39 | let get_delay f timeunit = 40 | Java.call "ScheduledFuture.getDelay(TimeUnit)" f timeunit 41 | 42 | 43 | (* Null value *) 44 | 45 | external null : unit -> 'a java_instance = 46 | "java null" 47 | 48 | let null = null () 49 | 50 | external is_null : 'a java_instance -> bool = 51 | "java is_null" 52 | 53 | external is_not_null : 'a java_instance -> bool = 54 | "java is_not_null" 55 | 56 | 57 | (* Miscellaneous *) 58 | 59 | let wrap x = 60 | if is_null x then 61 | None 62 | else 63 | Some x 64 | 65 | let unwrap = function 66 | | Some x -> x 67 | | None -> null 68 | -------------------------------------------------------------------------------- /compiler/stdlib/Makefile-ocamljava.shared: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java compiler. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # Original file (stdlib/Makefile.shared in the OCaml source 5 | # distribution) is Copyright (C) INRIA. 6 | # 7 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | # it under the terms of the Q Public License v1.0 as published by 9 | # Trolltech (with a change to choice of law). 10 | # 11 | # OCaml-Java compiler is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # Q Public License for more details. 15 | # 16 | # You should have received a copy of the Q Public License 17 | # along with this program. If not, see 18 | # . 19 | # 20 | 21 | include ../config/Makefile 22 | CAMLJAVA=../ocamljava.opt 23 | COMPFLAGS=-strict-sequence -w +33..39 -g -warn-error A -nostdlib -java-package 'ocaml.stdlib' 24 | CAMLDEP=../tools/ocamldep.opt 25 | 26 | OBJS=pervasives.cmj $(OTHERS) 27 | OTHERS=array.cmj list.cmj char.cmj string.cmj sys.cmj \ 28 | sort.cmj marshal.cmj obj.cmj \ 29 | int32.cmj int64.cmj nativeint.cmj \ 30 | lexing.cmj parsing.cmj \ 31 | set.cmj map.cmj stack.cmj queue.cmj \ 32 | camlinternalLazy.cmj lazy.cmj stream.cmj \ 33 | buffer.cmj printf.cmj \ 34 | arg.cmj printexc.cmj gc.cmj \ 35 | digest.cmj random.cmj hashtbl.cmj format.cmj scanf.cmj callback.cmj \ 36 | camlinternalOO.cmj oo.cmj camlinternalMod.cmj \ 37 | genlex.cmj weak.cmj \ 38 | filename.cmj complex.cmj \ 39 | arrayLabels.cmj listLabels.cmj stringLabels.cmj moreLabels.cmj stdLabels.cmj 40 | 41 | .SUFFIXES: .mli .ml .cmi .cmj 42 | 43 | .mli.cmi: 44 | $(CAMLJAVA) $(COMPFLAGS) `./Jcompflags $@` -c $< 45 | 46 | .ml.cmj: 47 | $(CAMLJAVA) $(COMPFLAGS) `./Jcompflags $@` -c $< 48 | 49 | clean:: 50 | rm -f *.cm* *.jo *.ja 51 | rm -f *~ 52 | 53 | include .depend 54 | 55 | depend: 56 | $(CAMLDEP) *.mli *.ml > .depend 57 | -------------------------------------------------------------------------------- /compiler/javacomp/macrogen.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * Original file (asmcomp/cmmgen.mli in the OCaml source 5 | * distribution) is Copyright (C) INRIA. 6 | * 7 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | * it under the terms of the Q Public License as published by 9 | * Trolltech (with a change to choice of law). 10 | * 11 | * OCaml-Java compiler is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * Q Public License for more details. 15 | * 16 | * You should have received a copy of the Q Public License 17 | * along with this program. If not, see 18 | * . 19 | *) 20 | 21 | (** Choice of runtime representation for values, mapping from idents to 22 | locals, recording of global uses. *) 23 | 24 | type error = 25 | | Special_primitive_string of string 26 | 27 | exception Error of error 28 | 29 | type add_function = string -> string -> (Ident.t * Lambda.repr) list -> Lambda.repr -> Jlambda.jlambda -> unit 30 | (** Type of callbacks adding a function to the list of functions to 31 | compile. 32 | 33 | Parameters are: 34 | - class name; 35 | - function/method name; 36 | - parameter identifiers and representations; 37 | - return representation; 38 | - function body. *) 39 | 40 | val translate : add_function -> bool -> (Ident.t * Lambda.repr) list -> Lambda.repr -> Jlambda.jlambda -> Macroinstr.expression 41 | (** [translate af entry params body] converts the function whose body 42 | [body], and parameters [params] are passed into a macroinstr. [entry] 43 | indicates whether the function is the entry function of a module. The 44 | callback [af] is used to request the compilation of another function. *) 45 | 46 | val report_error : Format.formatter -> error -> unit 47 | (** Pretty-prints an error. *) 48 | -------------------------------------------------------------------------------- /compiler/otherlibs/labltk/lib/Makefile-ocamljava: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java compiler. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # 5 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | # it under the terms of the Q Public License v1.0 as published by 7 | # Trolltech (with a change to choice of law). 8 | # 9 | # OCaml-Java compiler is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # Q Public License for more details. 13 | # 14 | # You should have received a copy of the Q Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | 19 | TOPDIR=../../.. 20 | LIBNAME=labltk 21 | include $(TOPDIR)/config/Makefile 22 | INSTALLDIR=$(LIBDIR)/$(LIBNAME) 23 | 24 | OCAMLJAVA=$(TOPDIR)/ocamljava.opt 25 | COMPFLAGS=-I ../support -g -java-package 'ocaml.otherlibs.labltk' 26 | 27 | default: all 28 | 29 | include ../labltk/modules 30 | LABLTKOBJS=tk.cmj $(WIDGETOBJS:.cmo=.cmj) 31 | 32 | include ../camltk/modules 33 | CAMLTKOBJS=cTk.cmj $(CWIDGETOBJS:.cmo=.cmj) labltk.cmj camltk.cmj 34 | 35 | SUPPORTOBJS=../support/support.cmj ../support/rawwidget.cmj ../support/widget.cmj \ 36 | ../support/protocol.cmj ../support/textvariable.cmj ../support/timer.cmj \ 37 | ../support/fileevent.cmj ../support/camltkwrap.cmj 38 | 39 | TKOBJS=$(SUPPORTOBJS) $(LABLTKOBJS) $(CAMLTKOBJS) 40 | 41 | all: $(LIBNAME).cmja 42 | 43 | clean: 44 | rm -f $(LIBNAME).cmja *.cm* *.jo *.ja 45 | 46 | superclean: 47 | if [ -f tk.cmj ]; then \ 48 | rm -f *.cm* *.jo; \ 49 | fi 50 | 51 | $(LIBNAME).cmja: 52 | $(MAKE) superclean 53 | $(OCAMLJAVA) -a -o $(LIBNAME).cmja -I ../labltk -I ../camltk $(TKOBJS) 54 | 55 | install: 56 | cp $(LIBNAME).cmja $(LIBNAME).ja $(INSTALLDIR) 57 | 58 | .SUFFIXES: 59 | .SUFFIXES: .mli .ml .cmi .cmj 60 | 61 | .mli.cmi: 62 | $(OCAMLJAVA) -c $(COMPFLAGS) $< 63 | 64 | .ml.cmj: 65 | $(OCAMLJAVA) -c $(COMPFLAGS) $< 66 | -------------------------------------------------------------------------------- /optimizer/src/args.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java optimizer. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java optimizer is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java optimizer is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | (** Handling of command-line parameters. *) 20 | 21 | 22 | val classpath : string list ref 23 | (** Classpath elements. *) 24 | 25 | val no_backtrace : bool ref 26 | (** Whether to assume absence of backtrace. *) 27 | 28 | val no_debug : bool ref 29 | (** Whether to remove debug statements. *) 30 | 31 | val no_dynlink : bool ref 32 | (** Whether to assume absence of dynamic linking. *) 33 | 34 | val no_runtime_lock : bool ref 35 | (** Whether to remove support for runtime lock. *) 36 | 37 | val no_signals : bool ref 38 | (** Whether to remove support for signals. *) 39 | 40 | val no_unused_global : bool ref 41 | (** Whether to remove initialization of unused globals. *) 42 | 43 | val one_context : bool ref 44 | (** Whether to assume unique context. *) 45 | 46 | val unsafe : bool ref 47 | (** Whether to use unsafe containers. *) 48 | 49 | val verbose : bool ref 50 | (** Whether to enable verbose mode. *) 51 | 52 | val war : bool ref 53 | (** Whether optimized file is a war file. *) 54 | 55 | val files : string list ref 56 | (** Files provided on the command line. *) 57 | 58 | val parse : unit -> unit 59 | (** Parses the command line, and initializes the values exported by this 60 | module. *) 61 | -------------------------------------------------------------------------------- /wrapper/src/typeMap.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | (** This module maintains a map from OCaml types to type informations. *) 20 | 21 | 22 | val add_local : Ident.t -> bool -> unit 23 | (** [add_local id exp] adds a type definition for name [id], [exp] 24 | indicating whether the type should not be expanded. *) 25 | 26 | val is_defined_and_doesnt_expand : Path.t -> bool 27 | (** Tests whether the type whose path is passed is both defined and 28 | should not be expanded. *) 29 | 30 | val promote : string -> unit 31 | (** [promote modname] promotes the locally-defined types to be declared 32 | as part of the module with name [modname]. *) 33 | 34 | val make_wrapper : TypeParametersTable.t -> JavaAST.type_ -> JavaAST.expression 35 | (** [make_wrapper generics typ] returns the code fragment building the 36 | wrapper for type [typ], [generics] indicating how to access to 37 | generic types. *) 38 | 39 | val find : ?generics:TypeParametersTable.t -> bool -> Types.type_expr -> TypeInfo.t 40 | (** [find ~generics b te] returns the type information for type [te], 41 | [generics] indicating how to access to generic types and [b] whether 42 | the type is boxed. 43 | 44 | Raises [Wrap_common.Exception] if no type information is found. *) 45 | -------------------------------------------------------------------------------- /compiler/lex/Makefile-ocamljava: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of OCaml-Java compiler. 3 | # Copyright (C) 2007-2015 Xavier Clerc. 4 | # Original file (lex/Makefile in the OCaml source 5 | # distribution) is Copyright (C) INRIA. 6 | # 7 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 8 | # it under the terms of the Q Public License v1.0 as published by 9 | # Trolltech (with a change to choice of law). 10 | # 11 | # OCaml-Java compiler is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # Q Public License for more details. 15 | # 16 | # You should have received a copy of the Q Public License 17 | # along with this program. If not, see 18 | # . 19 | # 20 | 21 | # The lexer generator 22 | CAMLJAVA=../ocamljava.opt -strict-sequence -nostdlib -I ../boot -I ../stdlib -java-package 'ocaml.tools.ocamllex' 23 | COMPFLAGS=-w +33..39 -warn-error A 24 | CAMLYACC=../boot/ocamlyacc 25 | YACCFLAGS=-v 26 | CAMLLEX=./ocamllex.opt 27 | CAMLDEP=../tools/ocamldep.opt 28 | 29 | 30 | OBJS=cset.cmj syntax.cmj parser.cmj lexer.cmj table.cmj lexgen.cmj \ 31 | compact.cmj common.cmj output.cmj outputbis.cmj main.cmj 32 | 33 | all: ocamllex 34 | 35 | ocamllex: $(OBJS) 36 | $(CAMLJAVA) $(LINKFLAGS) -o ocamllex.jar $(OBJS) 37 | 38 | clean:: 39 | rm -f ocamllex.jar 40 | rm -f *.cmj *.cmi *.jo *.ja *~ 41 | 42 | parser.ml parser.mli: parser.mly 43 | $(CAMLYACC) $(YACCFLAGS) parser.mly 44 | 45 | clean:: 46 | rm -f parser.ml parser.mli parser.output 47 | 48 | beforedepend:: parser.ml parser.mli 49 | 50 | lexer.ml: lexer.mll 51 | $(CAMLLEX) lexer.mll 52 | 53 | clean:: 54 | rm -f lexer.ml 55 | 56 | beforedepend:: lexer.ml 57 | 58 | .SUFFIXES: 59 | .SUFFIXES: .ml .cmj .mli .cmi 60 | 61 | .ml.cmj: 62 | $(CAMLJAVA) -c $(COMPFLAGS) $< 63 | 64 | .mli.cmi: 65 | $(CAMLJAVA) -c $(COMPFLAGS) $< 66 | 67 | depend: beforedepend 68 | $(CAMLDEP) *.mli *.ml > .depend 69 | 70 | include .depend 71 | -------------------------------------------------------------------------------- /compiler/javacomp/jclosure_arrays.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | val is_java_array_primitive : string -> bool 20 | (** Test whether the primitive whose identifier is passed is a primitive 21 | operating on a Java array ([get]/[set]/[length]/[to_object]/[of_object] 22 | on any Java array type). *) 23 | 24 | val java_array_primitive_infos : string -> Jlambda.java_primitive * Lambda.repr 25 | (** Returns the Java primitive and return type representation for the 26 | primitive whose identifier is passed, raising an exception if such a 27 | primitive does not exist. *) 28 | 29 | val optimize_intarray_call : Jlambda.function_description -> Types.type_expr option list -> Jlambda.function_description 30 | (** [optimize_intarray_call fundesc params] optimizes a call to [fundesc] 31 | made with parameters [params] by redirecting the call to another 32 | function specialized for [int] arrays. 33 | 34 | Returns [fundesc] if the call cannot be optimized. *) 35 | 36 | val optimize_intarray_primitive : Lambda.primitive -> (Lambda.lambda * Types.type_expr option) list -> Lambda.primitive 37 | (** [optimize_intarray_primitive prim params] optimizes a call to [prim] 38 | made with parameters [params] by redirecting the call to another 39 | primitive specialized for [int] arrays]. 40 | 41 | Returns [prim] if the call cannot be optimized. *) 42 | -------------------------------------------------------------------------------- /library/concurrent/src/sync/cyclicBarrier.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | open Class'java'util'concurrent'CyclicBarrier 20 | open Class'java'util'concurrent'TimeUnit 21 | 22 | type t = _'CyclicBarrier java_instance 23 | 24 | let make n = 25 | Java.make "CyclicBarrier(int)" n 26 | 27 | let await cb = 28 | Java.call "CyclicBarrier.await()" cb 29 | 30 | let await_time cb time timeunit = 31 | Java.call "CyclicBarrier.await(long,TimeUnit)" cb time timeunit 32 | 33 | let get_number_waiting cb = 34 | Java.call "CyclicBarrier.getNumberWaiting()" cb 35 | 36 | let get_parties cb = 37 | Java.call "CyclicBarrier.getParties()" cb 38 | 39 | let is_broken cb = 40 | Java.call "CyclicBarrier.isBroken()" cb 41 | 42 | let reset cb = 43 | Java.call "CyclicBarrier.reset()" cb 44 | 45 | 46 | (* Null value *) 47 | 48 | external null : unit -> 'a java_instance = 49 | "java null" 50 | 51 | let null = null () 52 | 53 | external is_null : 'a java_instance -> bool = 54 | "java is_null" 55 | 56 | external is_not_null : 'a java_instance -> bool = 57 | "java is_not_null" 58 | 59 | 60 | (* Miscellaneous *) 61 | 62 | let wrap x = 63 | if is_null x then 64 | None 65 | else 66 | Some x 67 | 68 | let unwrap = function 69 | | Some x -> x 70 | | None -> null 71 | -------------------------------------------------------------------------------- /runtime/src/org/ocamljava/runtime/Infos.tmpl: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OCaml-Java runtime. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java runtime is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java runtime is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package org.ocamljava.runtime; 20 | 21 | /** 22 | * This class defines some project-wide constants. 23 | * 24 | * @author Xavier Clerc 25 | * @version 2.0 26 | * @since 1.3 27 | */ 28 | public final class Infos { 29 | 30 | /** Version number. */ 31 | public static final String OCAMLJAVA_VERSION = @@OCAMLJAVA_VERSION@@; 32 | 33 | /** Author name. */ 34 | public static final String OCAMLJAVA_AUTHOR = @@OCAMLJAVA_AUTHOR@@; 35 | 36 | /** Copyright years. */ 37 | public static final String OCAMLJAVA_YEARS = @@OCAMLJAVA_YEARS@@; 38 | 39 | /** Mail address. */ 40 | public static final String OCAMLJAVA_MAIL = @@OCAMLJAVA_MAIL@@; 41 | 42 | /** Homepage. */ 43 | public static final String OCAMLJAVA_URL = @@OCAMLJAVA_URL@@; 44 | 45 | /** Supported OCaml version. */ 46 | public static final String OCAML_VERSION = @@OCAML_VERSION@@; 47 | 48 | /** Installation prefix. */ 49 | public static String getPrefix() { 50 | return @@PREFIX@@; 51 | } 52 | 53 | /** 54 | * No instance of this class. 55 | */ 56 | private Infos() { 57 | } // end empty constructor 58 | 59 | } // end class 'Infos' 60 | -------------------------------------------------------------------------------- /optimizer/src/misc.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java optimizer. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java optimizer is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java optimizer is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | (** Utility functions. *) 20 | 21 | 22 | type remove_index_function = BaristaLibrary.Name.for_class -> int -> bool 23 | (** The type of functions that are used to determine whether a global 24 | should be removed; the parameters are: 25 | - the class name; 26 | - the global's index for the class. *) 27 | 28 | val make_class_name_ext : string -> BaristaLibrary.Name.for_class 29 | (** Creates a class name from a string (assuming external form). *) 30 | 31 | val make_method_name : string -> BaristaLibrary.Name.for_method 32 | (** Creates a method name from a string. *) 33 | 34 | val make_field_name : string -> BaristaLibrary.Name.for_field 35 | (** Creates a field name from a string. *) 36 | 37 | val global_class_of_class : BaristaLibrary.Name.for_class -> BaristaLibrary.Name.for_class 38 | (** Returns the name of the class holding globals for the class whose 39 | name is passed. *) 40 | 41 | val is_runtime_class : BaristaLibrary.Name.for_class -> bool 42 | (** Tests whether the class whose name is passed is part of the 43 | OCaml-Java runtime. *) 44 | 45 | val is_shared_constant : BaristaLibrary.Name.for_field -> bool 46 | (** Tests whether the field whose name is passed is a field holding a 47 | shared constant. *) 48 | -------------------------------------------------------------------------------- /library/concurrent/src/locks/lock.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | open Class'java'util'concurrent'TimeUnit 20 | open Class'java'util'concurrent'locks'Lock 21 | open Class'java'util'concurrent'locks'ReentrantLock 22 | 23 | type t = _'Lock java_instance 24 | 25 | let make_reentrant ?(fair = false) () = 26 | Java.make "ReentrantLock(boolean)" fair 27 | |> Java.cast "Lock" 28 | 29 | let lock l = 30 | Java.call "Lock.lock()" l 31 | 32 | let lock_interruptibly l = 33 | Java.call "Lock.lockInterruptibly()" l 34 | 35 | let new_condition l = 36 | Java.call "Lock.newCondition()" l 37 | 38 | let try_lock l = 39 | Java.call "Lock.tryLock()" l 40 | 41 | let try_lock_time l time timeunit = 42 | Java.call "Lock.tryLock(long,TimeUnit)" l time timeunit 43 | 44 | let unlock l = 45 | Java.call "Lock.unlock()" l 46 | 47 | 48 | (* Null value *) 49 | 50 | external null : unit -> 'a java_instance = 51 | "java null" 52 | 53 | let null = null () 54 | 55 | external is_null : 'a java_instance -> bool = 56 | "java is_null" 57 | 58 | external is_not_null : 'a java_instance -> bool = 59 | "java is_not_null" 60 | 61 | 62 | (* Miscellaneous *) 63 | 64 | let wrap x = 65 | if is_null x then 66 | None 67 | else 68 | Some x 69 | 70 | let unwrap = function 71 | | Some x -> x 72 | | None -> null 73 | -------------------------------------------------------------------------------- /library/concurrent/src/atomic/atomicReference.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | type 'a t = java'util'concurrent'atomic'AtomicReference java_instance 20 | 21 | external make : 'a -> 'a t = 22 | "ocamljava_atomicreference_make" 23 | 24 | external compare_and_set : 'a t -> 'a -> 'a -> bool = 25 | "ocamljava_atomicreference_compare_and_set" 26 | 27 | external get : 'a t -> 'a = 28 | "ocamljava_atomicreference_get" 29 | 30 | external get_and_set : 'a t -> 'a -> 'a = 31 | "ocamljava_atomicreference_get_and_set" 32 | 33 | external lazy_set : 'a t -> 'a -> unit = 34 | "ocamljava_atomicreference_lazy_set" 35 | 36 | external set : 'a t -> 'a -> unit = 37 | "ocamljava_atomicreference_set" 38 | 39 | external weak_compare_and_set : 'a t -> 'a -> 'a -> bool = 40 | "ocamljava_atomicreference_weak_compare_and_set" 41 | 42 | 43 | (* Null value *) 44 | 45 | external null : unit -> 'a java_instance = 46 | "java null" 47 | 48 | let null = null () 49 | 50 | external is_null : 'a java_instance -> bool = 51 | "java is_null" 52 | 53 | external is_not_null : 'a java_instance -> bool = 54 | "java is_not_null" 55 | 56 | 57 | (* Miscellaneous *) 58 | 59 | let wrap x = 60 | if is_null x then 61 | None 62 | else 63 | Some x 64 | 65 | let unwrap = function 66 | | Some x -> x 67 | | None -> null 68 | -------------------------------------------------------------------------------- /wrapper/myocamlbuild.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java wrapper. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java wrapper is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java wrapper is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | open Ocamlbuild_plugin 20 | 21 | let () = 22 | dispatch begin function 23 | | After_rules -> 24 | flag ["ocaml"; "compile"; "warnings"] 25 | (S[A"-w"; A"Ae"; A"-warn-error"; A"A"]); 26 | flag ["ocaml"; "compile"; "use_compiler_libs"] 27 | (S[A"-I"; A"+compiler-libs"]); 28 | flag ["ocaml"; "link"; "byte"; "use_compiler_libs"] 29 | (S[A"unix.cma"; 30 | A"-I"; A"+zip"; A"zip.cma"; 31 | A"bigarray.cma"; 32 | A"camomile.cma"; 33 | A"-I"; A"+barista"; A"baristaLibrary.cma"; 34 | A"-I"; A"+compiler-libs"; A"ocamlcommon.cma"; A"ocamljavacomp.cma"]); 35 | flag ["ocaml"; "link"; "native"; "use_compiler_libs"] 36 | (S[A"unix.cmxa"; 37 | A"-I"; A"+zip"; A"zip.cmxa"; 38 | A"bigarray.cmxa"; 39 | A"camomile.cmxa"; 40 | A"-I"; A"+barista"; A"baristaLibrary.cmxa"; 41 | A"-I"; A"+compiler-libs"; A"ocamlcommon.cmxa"; A"ocamljavacomp.cmxa"]); 42 | flag ["ocaml"; "link"; "java"; "use_compiler_libs"] 43 | (S[A"-I"; A"+barista"; A"baristaLibrary.cmja"; 44 | A"-I"; A"+compiler-libs"; A"ocamlcommon.cmja"; A"ocamljavacomp.cmja"]); 45 | | _ -> () 46 | end 47 | -------------------------------------------------------------------------------- /compiler/javacomp/instrtree.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | open BaristaLibrary 20 | 21 | type t = 22 | | Node of int * (t list) 23 | | Leaf of int * (Instruction.t list) 24 | | Suspended of int * (Instruction.t list lazy_t) 25 | 26 | let size = function 27 | | Node (sz, _) 28 | | Leaf (sz, _) 29 | | Suspended (sz, _) -> sz 30 | 31 | let node l = 32 | let sz = 33 | List.fold_left 34 | (fun acc elem -> 35 | acc + (size elem)) 36 | 0 37 | l in 38 | Node (sz, l) 39 | 40 | let leaf ?(ofs = -1) l = 41 | let is_switch_instruction = function 42 | | Instruction.LOOKUPSWITCH _ | Instruction.TABLESWITCH _ -> true 43 | | _ -> false in 44 | if (ofs < 0) && (List.exists is_switch_instruction l) then 45 | Misc.fatal_error "Instrtree.leaf: missing offset with a list containing a switch"; 46 | let sz = Instruction.size_of_list (Utils.max_int ofs 0) l in 47 | Leaf (sz, l) 48 | 49 | let suspended sz lz = 50 | Suspended (sz, lz) 51 | 52 | let flatten x = 53 | let res = ref [] in 54 | let rec visit = function 55 | | Node (_, l) -> List.iter visit l 56 | | Leaf (_, l) -> res := l :: !res 57 | | Suspended (_, l) -> res := (Lazy.force l) :: !res in 58 | visit x; 59 | List.flatten (List.rev !res) 60 | 61 | let rec map f = function 62 | | Node (sz, l) -> Node (sz, List.map (map f) l) 63 | | Leaf (sz, l) -> Leaf (sz, List.map f l) 64 | | (Suspended _) as x -> x 65 | -------------------------------------------------------------------------------- /library/javalib/templates/throwable-template.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | 20 | (* Null value *) 21 | 22 | external null : unit -> 'a java_instance = 23 | "java null" 24 | 25 | let null = null () 26 | 27 | external is_null : 'a java_instance -> bool = 28 | "java is_null" 29 | 30 | external is_not_null : 'a java_instance -> bool = 31 | "java is_not_null" 32 | 33 | 34 | (* Instance creation *) 35 | 36 | type t = $(ocaml_short_name) java_instance 37 | 38 | let make ?(cause = null) ?(message = JavaString.null) () = 39 | if JavaString.is_null message then 40 | Java.make "$(java_short_name)(Throwable)" cause 41 | else 42 | Java.make "$(java_short_name)(String,Throwable)" message cause 43 | 44 | 45 | (* Throw *) 46 | 47 | external throw : t -> 'a = "java throw" 48 | 49 | 50 | (* Base methods *) 51 | 52 | let get_cause th = 53 | Java.call "Throwable.getCause()" th 54 | 55 | let get_message th = 56 | Java.call "Throwable.getMessage()" th 57 | 58 | let get_stack_trace th = 59 | Java.call "Throwable.getStackTrace()" th 60 | 61 | let print_stack_trace th = 62 | Java.call "Throwable.printStackTrace()" th 63 | 64 | 65 | (* Miscellaneous *) 66 | 67 | let wrap x = 68 | if is_null x then 69 | None 70 | else 71 | Some x 72 | 73 | let unwrap = function 74 | | Some x -> x 75 | | None -> null 76 | -------------------------------------------------------------------------------- /compiler/javacomp/bytecodegen.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | (** Compilation from macroinstructions to Java bytecode. *) 20 | 21 | val compile_fields : Format.formatter -> BaristaLibrary.Method.t * (BaristaLibrary.Field.t list) 22 | (** Returns the fields for the current class, as a list of fields along 23 | with the static block initializing the fields. These fields contain 24 | the method handles for the functions. *) 25 | 26 | val compile_function : Format.formatter -> Macroinstr.fundecl -> BaristaLibrary.Method.t 27 | (** Translates the passed macroinstruction-level function into its 28 | Java-bytecode equivalent. *) 29 | 30 | val compile_surrogate : Macroinstr.fundecl -> BaristaLibrary.Method.t 31 | (** Compiles the surrogate (i.e. unboxing parameters, and boxing result 32 | value) method for the passed function. *) 33 | 34 | val compile_class : BaristaLibrary.Field.t list -> BaristaLibrary.Method.t list -> BaristaLibrary.Annotation.t list -> BaristaLibrary.Bytes.t 35 | (** Builds a class from environment and passed lists of fields and 36 | methods. Returns the compiled class as an array of bytes. *) 37 | 38 | val compile_constants_to_methods : Format.formatter -> BaristaLibrary.Method.t list * bool 39 | (** Compiles the constants, returning the constants as a method. *) 40 | 41 | val compile_get_global_method : string -> BaristaLibrary.Method.t 42 | (** Returns a method returning the global for the module. *) 43 | -------------------------------------------------------------------------------- /library/concurrent/src/locks/condition.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | open Class'java'util'Date 20 | open Class'java'util'concurrent'TimeUnit 21 | open Class'java'util'concurrent'locks'Condition 22 | 23 | type t = _'Condition java_instance 24 | 25 | let await cond = 26 | Java.call "Condition.await()" cond 27 | 28 | let await_time cond time timeunit = 29 | Java.call "Condition.await(long,TimeUnit)" cond time timeunit 30 | 31 | let await_nanos cond nanos = 32 | Java.call "Condition.awaitNanos(long)" cond nanos 33 | 34 | let await_uninterruptibly cond = 35 | Java.call "Condition.awaitUninterruptibly()" cond 36 | 37 | let await_until cond date = 38 | Java.call "Condition.awaitUntil(Date)" cond date 39 | 40 | let signal cond = 41 | Java.call "Condition.signal()" cond 42 | 43 | let signal_all cond = 44 | Java.call "Condition.signalAll()" cond 45 | 46 | 47 | (* Null value *) 48 | 49 | external null : unit -> 'a java_instance = 50 | "java null" 51 | 52 | let null = null () 53 | 54 | external is_null : 'a java_instance -> bool = 55 | "java is_null" 56 | 57 | external is_not_null : 'a java_instance -> bool = 58 | "java is_not_null" 59 | 60 | 61 | (* Miscellaneous *) 62 | 63 | let wrap x = 64 | if is_null x then 65 | None 66 | else 67 | Some x 68 | 69 | let unwrap = function 70 | | Some x -> x 71 | | None -> null 72 | -------------------------------------------------------------------------------- /compiler/javacomp/archiveutils.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | open BaristaLibrary 20 | 21 | let open_builder archive = 22 | archive 23 | |> Path.make_of_string 24 | |> ArchiveBuilder.make ~fail_on_duplicate:true 25 | 26 | let add_entry builder name bytes = 27 | ArchiveBuilder.add_entry builder (UTF8.of_string name) bytes 28 | 29 | let add_entry_from_file builder name file = 30 | ArchiveBuilder.add_entry_from_file builder (UTF8.of_string name) (Path.make_of_string file) 31 | 32 | let close builder = 33 | ArchiveBuilder.close builder 34 | 35 | let close_noerr builder = 36 | ArchiveBuilder.close_noerr builder 37 | 38 | let copy_entries_list archive_list archive = 39 | let builder = 40 | try 41 | Some (open_builder archive) 42 | with _ -> 43 | None in 44 | match builder with 45 | | Some builder -> 46 | (try 47 | archive_list 48 | |> List.map Path.make_of_string 49 | |> ArchiveBuilder.add_entries_from_archive_files builder; 50 | ArchiveBuilder.close builder; 51 | None 52 | with 53 | | ArchiveBuilder.Exception (ArchiveBuilder.Duplicate_entry _) 54 | | ArchiveBuilder.Exception (ArchiveBuilder.Duplicate_service _) -> 55 | ArchiveBuilder.close_noerr builder; 56 | Some "duplicate entry" 57 | | _ -> 58 | ArchiveBuilder.close_noerr builder; 59 | Some "cannot copy data") 60 | | None -> 61 | Some "cannot create archive" 62 | -------------------------------------------------------------------------------- /library/javalib/src/javaTimeZone.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | 20 | (* Instance creation *) 21 | 22 | open Class'java'util'TimeZone 23 | 24 | type t = _'TimeZone java_instance 25 | 26 | let make id = 27 | Java.call "TimeZone.getTimeZone(String)" id 28 | 29 | let get_available_ids () = 30 | let arr = Java.call "TimeZone.getAvailableIDs()" () in 31 | let i = ref @@ JavaReferenceArray.length arr in 32 | let res = ref [] in 33 | while !i >= 0l do 34 | res := (JavaReferenceArray.get arr !i) :: !res 35 | done; 36 | !res 37 | 38 | let get_default () = 39 | Java.call "TimeZone.getDefault()" () 40 | 41 | let set_default tz = 42 | Java.call "TimeZone.setDefault(TimeZone)" tz 43 | 44 | 45 | (* Properties *) 46 | 47 | let get_display_name tz = 48 | Java.call "TimeZone.getDisplayName()" tz 49 | 50 | let get_id tz = 51 | Java.call "TimeZone.getID()" tz 52 | 53 | 54 | (* Null value *) 55 | 56 | external null : unit -> 'a java_instance = 57 | "java null" 58 | 59 | let null = null () 60 | 61 | external is_null : 'a java_instance -> bool = 62 | "java is_null" 63 | 64 | external is_not_null : 'a java_instance -> bool = 65 | "java is_not_null" 66 | 67 | 68 | (* Miscellaneous *) 69 | 70 | let wrap x = 71 | if is_null x then 72 | None 73 | else 74 | Some x 75 | 76 | let unwrap = function 77 | | Some x -> x 78 | | None -> null 79 | -------------------------------------------------------------------------------- /compiler/javacomp/macrogen_primitives.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | (** Signatures of primitives. *) 20 | 21 | 22 | val is_unary_math_primitive : string -> bool 23 | (** Tests whether the passed external name designates a unary math 24 | function. *) 25 | 26 | val unary_method : string -> string 27 | (** Returns the Java method (in {i java.lang.Math} class) for the passed 28 | external name. 29 | 30 | Raises [Not_found] if the passed name does not designate a unary math 31 | function. *) 32 | 33 | val is_binary_math_primitive : string -> bool 34 | (** Tests whether the passed external name designates a binary math 35 | function. *) 36 | 37 | val binary_method : string -> string 38 | (** Returns the Java method (in {i java.lang.Math} class) for the passed 39 | external name. 40 | 41 | Raises [Not_found] if the passed name does not designate a binary 42 | math function. *) 43 | 44 | val signature_of_primitive : Lambda.primitive -> Jlambda.jlambda list -> Macroinstr.parameters * Macroinstr.value_kind 45 | (** Returns the signature of a regular primitive. *) 46 | 47 | val signature_of_java_primitive : Jlambda.java_primitive -> Macroinstr.value_kind list * Macroinstr.value_kind 48 | (** Returns the signature of an ocamljava-specific primitive. *) 49 | 50 | val simplif_primitive : Lambda.primitive -> string option 51 | (** Simplifies the passed primitive into a call to an external, 52 | returning [None] if primitive is not optimized. *) 53 | -------------------------------------------------------------------------------- /compiler/javacomp/javalink_applet.mli: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java compiler. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java compiler is free software; you can redistribute it and/or modify 6 | * it under the terms of the Q Public License as published by 7 | * Trolltech (with a change to choice of law). 8 | * 9 | * OCaml-Java compiler is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * Q Public License for more details. 13 | * 14 | * You should have received a copy of the Q Public License 15 | * along with this program. If not, see 16 | * . 17 | *) 18 | 19 | val check_applet_signature : Cmj_format.unit_infos -> string -> Types.signature * Jlambda.value_approximation array 20 | (** [check_applet_signature unit_infos cmj_file] checks that the module 21 | defined by [unit_infos] and stored in [cmj_file] has a correct 22 | signature with respect to the kind of applet to compile. 23 | 24 | Returns the actual type for the applet, and the approximation for 25 | its module implementation. *) 26 | 27 | type approx = { 28 | applet_info : Jlambda.value_approximation * int; 29 | parameter_info : Jlambda.value_approximation * int; 30 | init : Jlambda.value_approximation * int; 31 | start : Jlambda.value_approximation * int; 32 | run : Jlambda.value_approximation * int; 33 | stop : Jlambda.value_approximation * int; 34 | destroy : Jlambda.value_approximation * int; 35 | } 36 | (** Approximation for applet: approximation value, and approximation 37 | index for each signature element. *) 38 | 39 | val extract_applet_approx : Types.signature_item list -> Jlambda.value_approximation list -> approx 40 | (** Returns the applet-specific approximation for the passed signature 41 | and full approximation corresponding to the applet module. *) 42 | 43 | val make_applet_class : Cmj_format.unit_infos -> approx -> string * BaristaLibrary.Bytes.t 44 | (** Compiles the main applet class, and returns its name and class file 45 | contents. *) 46 | -------------------------------------------------------------------------------- /optimizer/src/ocamljar.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java optimizer. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java optimizer is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java optimizer is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | open BaristaLibrary 20 | 21 | 22 | let error kind msg = 23 | Printf.eprintf "*** %s: %s\n" kind msg; 24 | exit 1 25 | 26 | let main () = 27 | Args.parse (); 28 | match !Args.files with 29 | | [ file_out; file_in ] -> 30 | State.input_file := file_in; 31 | let file_in = Path.make_of_string file_in in 32 | let file_out = Path.make_of_string file_out in 33 | WholeProgram.iter_archive file_in; 34 | let make_mapper arch = 35 | WholeProgram.make_remove_indices_function () 36 | |> new Mapper.for_archive arch in 37 | let post arch = 38 | let path, contents = WholeProgram.compile_shared_constant_class () in 39 | ArchiveOutputStream.add_entry arch path contents in 40 | ArchiveTraversal.map_file make_mapper ~post file_in file_out 41 | | _ -> 42 | error 43 | "error" 44 | "input and output files should be provided on the command line" 45 | 46 | let () = 47 | try 48 | main (); 49 | exit 0 50 | with 51 | | StackState.Exception e -> 52 | error "stack state exception" (StackState.string_of_error e) 53 | | Annotation.Exception e -> 54 | error "annotation exception" (Annotation.string_of_error e) 55 | | Sys_error se -> 56 | error "system error" se 57 | | e -> 58 | error "error" (Printexc.to_string e) 59 | -------------------------------------------------------------------------------- /library/concurrent/src/futures/executorCompletionService.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | open Class'java'util'concurrent'Executor 20 | open Class'java'util'concurrent'ExecutorCompletionService 21 | open Class'java'util'concurrent'TimeUnit 22 | 23 | type t = _'ExecutorCompletionService java_instance 24 | 25 | let make tpe = 26 | Java.make "ExecutorCompletionService(Executor)" tpe 27 | 28 | let poll ecs = 29 | let res = Java.call "ExecutorCompletionService.poll()" ecs in 30 | if Java.is_null res then 31 | None 32 | else 33 | Some res 34 | 35 | let poll_time ecs time timeunit = 36 | let res = Java.call "ExecutorCompletionService.poll(long,TimeUnit)" ecs time timeunit in 37 | if Java.is_null res then 38 | None 39 | else 40 | Some res 41 | 42 | external submit : t -> ('a -> 'b) -> 'a -> 'b Future.t = 43 | "ocamljava_executorcompletionservice_submit" 44 | 45 | let take ecs = 46 | Java.call "ExecutorCompletionService.take()" ecs 47 | 48 | 49 | (* Null value *) 50 | 51 | external null : unit -> 'a java_instance = 52 | "java null" 53 | 54 | let null = null () 55 | 56 | external is_null : 'a java_instance -> bool = 57 | "java is_null" 58 | 59 | external is_not_null : 'a java_instance -> bool = 60 | "java is_not_null" 61 | 62 | 63 | (* Miscellaneous *) 64 | 65 | let wrap x = 66 | if is_null x then 67 | None 68 | else 69 | Some x 70 | 71 | let unwrap = function 72 | | Some x -> x 73 | | None -> null 74 | -------------------------------------------------------------------------------- /compiler/build/camlp4-targets.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # This file is part of OCaml-Java compiler. 5 | # Copyright (C) 2007-2015 Xavier Clerc. 6 | # Original file (build/camlp4-targets.sh in the OCaml source 7 | # distribution) is Copyright (C) INRIA. 8 | # 9 | # OCaml-Java compiler is free software; you can redistribute it and/or modify 10 | # it under the terms of the Q Public License v1.0 as published by 11 | # Trolltech (with a change to choice of law). 12 | # 13 | # OCaml-Java compiler is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # Q Public License for more details. 17 | # 18 | # You should have received a copy of the Q Public License 19 | # along with this program. If not, see 20 | # . 21 | # 22 | 23 | CAMLP4_COMMON="\ 24 | camlp4/Camlp4/Camlp4Ast.partial.ml \ 25 | camlp4/boot/camlp4boot.byte" 26 | CAMLP4_BYTE="$CAMLP4_COMMON \ 27 | camlp4/Camlp4.cmo \ 28 | camlp4/Camlp4Top.cmo \ 29 | camlp4/camlp4prof.byte$EXE \ 30 | camlp4/mkcamlp4.byte$EXE \ 31 | camlp4/camlp4.byte$EXE \ 32 | camlp4/camlp4fulllib.cma" 33 | CAMLP4_NATIVE="$CAMLP4_COMMON \ 34 | camlp4/Camlp4.cmx \ 35 | camlp4/Camlp4Top.cmx \ 36 | camlp4/camlp4prof.native$EXE \ 37 | camlp4/mkcamlp4.native$EXE \ 38 | camlp4/camlp4.native$EXE \ 39 | camlp4/camlp4fulllib.cmxa" 40 | CAMLP4_JAVA="$CAMLP4_COMMON \ 41 | camlp4/Camlp4.cmj \ 42 | camlp4/Camlp4Top.cmj \ 43 | camlp4/camlp4prof.jar \ 44 | camlp4/mkcamlp4.jar \ 45 | camlp4/camlp4.jar \ 46 | camlp4/camlp4fulllib.cmja" 47 | 48 | for i in camlp4boot camlp4r camlp4rf camlp4o camlp4of camlp4oof camlp4orf; do 49 | CAMLP4_BYTE="$CAMLP4_BYTE camlp4/$i.byte$EXE camlp4/$i.cma" 50 | CAMLP4_NATIVE="$CAMLP4_NATIVE camlp4/$i.native$EXE" 51 | CAMLP4_JAVA="$CAMLP4_JAVA camlp4/$i.jar" 52 | done 53 | 54 | cd camlp4 55 | for dir in Camlp4Parsers Camlp4Printers Camlp4Filters; do 56 | for file in $dir/*.ml; do 57 | base=camlp4/$dir/`basename $file .ml` 58 | CAMLP4_BYTE="$CAMLP4_BYTE $base.cmo" 59 | CAMLP4_NATIVE="$CAMLP4_NATIVE $base.cmx $base.$O" 60 | CAMLP4_JAVA="$CAMLP4_JAVA $base.cmj $base.jo" 61 | done 62 | done 63 | cd .. 64 | -------------------------------------------------------------------------------- /library/javalib/src/javaArraySignature.ml: -------------------------------------------------------------------------------- 1 | (* 2 | * This file is part of OCaml-Java library. 3 | * Copyright (C) 2007-2015 Xavier Clerc. 4 | * 5 | * OCaml-Java library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * OCaml-Java library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | *) 18 | 19 | 20 | module type T = sig 21 | type e 22 | type 'a t 23 | val make : java_int -> e t 24 | val init : java_int -> (java_int -> e) -> e t 25 | val length : e t -> java_int 26 | val get : e t -> java_int -> e 27 | val set : e t -> java_int -> e -> unit 28 | val append : e t -> e t -> e t 29 | val concat : e t list -> e t 30 | val sub : e t -> java_int -> java_int -> e t 31 | val copy : e t -> e t 32 | val fill : e t -> java_int -> java_int -> e -> unit 33 | val blit : e t -> java_int -> e t -> java_int -> java_int -> unit 34 | val to_list : e t -> e list 35 | val of_list : e list -> e t 36 | val iter : (e -> unit) -> e t -> unit 37 | val map : (e -> e) -> e t -> e t 38 | val iteri : (java_int -> e -> unit) -> e t -> unit 39 | val mapi : (java_int -> e -> e) -> e t -> e t 40 | val fold_left : ('a -> e -> 'a) -> 'a -> e t -> 'a 41 | val fold_right : (e -> 'a -> 'a) -> e t -> 'a -> 'a 42 | val of_ocaml : e array -> e t 43 | val to_ocaml : e t -> e array 44 | val to_object : e t -> _'Object java_instance 45 | val of_object : _'Object java_instance -> e t 46 | val equals : e t -> e t -> java_boolean 47 | val hash_code : e t -> java_int 48 | val to_string : e t -> JavaString.t 49 | val null : e t 50 | val is_null : e t -> bool 51 | val is_not_null : e t -> bool 52 | val wrap : e t -> e t option 53 | val unwrap : e t option -> e t 54 | end 55 | --------------------------------------------------------------------------------