Commit Graph

13 Commits

Author SHA1 Message Date
Julien Fischer
01061532ab Add short example of Java interface.
samples/java_interface/short_example.m:
    A Java version of the short example.

samples/java_interface/README.md:
    Add an entry for the new example.

samples/c_interface/README.md:
samples/csharp_interface/README.md:
    Fix wording.
2022-01-20 03:42:56 +11:00
Julien Fischer
d8c0de2f38 More samples READMEs.
samples/csharp_interface/README.md:
    Add a README file for this subdirectory.

samples/java_interface/README:
    Rename this file to README.md; convert its contents
    to Markdown.
2022-01-15 23:54:35 +11:00
Julien Fischer
1702444cb1 Style and formatting fixes for Java interface samples.
samples/java_interface/java_calls_mercury/mercury_main.m:
samples/java_interface/mercury_calls_java/java_main_int.m:
samples/java_interface/standalone_java/JavaMain.java:
samples/java_interface/standalone_java/Makefile:
samples/java_interface/standalone_java/mercury_lib.m:
    As above.
2022-01-15 17:04:46 +11:00
Julien Fischer
e67afcbecd Initialise standard library in standalone Java example.
samples/java_interface/standalone_java/JavaMain.java:
     We need to initialise the standard library, otherwise things
     like the stream database won't be set up properly.
2018-11-09 16:48:45 +11:00
Julien Fischer
fbf35c8b22 Minor fixes for the Java interface examples.
samples/java_interface/java_calls_mercury/*.m:
    Use spaces instead of tabs.

    Delete trailing whitespace.

    Fix a cut-and-paste error where exports to C instead of
    Java are referred to.

samples/java_interface/mercury_calls_java/Makefile:
    Fix the compilation options for this example.

samples/java_interface/mercury_calls_java/mercury_main.m:
     Fix formatting.
2016-02-09 21:43:11 +11:00
Zoltan Somogyi
d33273d033 Tell vim not to expand tabs in Makefiles.
This file-specific setting will override a default setting of expandtabs
in $HOME/.vimrc.

*/Makefile:
*/Mmakefile:
    As above.

tests/hard_coded/.gitignore:
    Don't ignore the purity subdir. This ignore must have been left over
    from when purity.m was a test in hard_coded, not hard_coded/purity,
    and it ignored an executable, not a directory.
2015-01-08 22:07:29 +11:00
Paul Bone
21fb0a74fc [java] Run finalisers only if main/2 returns normally
finalisers should be executed only if main/2 returns normally, it does not
throw an exception.  The C backends already do this correctly but the Java
backend did not.  The C# backend has the same bug, this patch does not fix
the C# backend.

java/runtime/MercuryThreadPool.java:
    Add a parameter to the shutdown() method to specify whether the backend
    is aborting.

    In runMain(), run finalisers only if the runtime is exiting normally.

java/runtime/MercuryRuntime.java:
    Add a new finalise() method that takes a parameter allowing standalone
    Java applications to specify whether or not they are aborting when the
    finalise the RTS.

doc/reference_manual.texi:
    Specify the behaviour of finalise directives if main/2 terminates
    with an uncaught exception.

samples/java_interface/standalone_java/JavaMain.java:
    Conform to changes in MercuryRuntime.java.
2015-01-05 16:01:37 +11:00
Julien Fischer
d56411e142 Fix typos in Paul's recent change.
java/runtime/MercuryRuntime.java:
java/runtime/MercuryThreadPool.java:
samples/java_interface/standalone_java/JavaMain.java
	As above.
2014-12-16 14:17:46 +11:00
Paul Bone
8b48c420d7 [java] Make changes following Julien's review of my recent patch
java/runtime/JavaInternal.java:
java/runtime/MercuryRuntime.java:
java/runtime/MercuryThreadPool.java:
samples/java_interface/standalone_java/JavaMain.java:
samples/java_interface/standalone_java/Makefile:
samples/java_interface/standalone_java/mercury_lib.m:
    As above.
2014-12-16 12:45:37 +11:00
Paul Bone
e4a0adf424 [java] The thread pool now works when Mercury is used as a library
The thread pool code used in the Java backend was tied the execution of
main/2.  However if Mercury is used as a library the thread pool won't have
been started and threads created with thread.spawn would not be executed.

This patch makes it possible to start and stop the thread pool independently of
main/2 by calling startup() and shutdown().  These calls are called
implicitly by calling runMain().  The thread pool can also be started on
demand.

This patch also adds the MercuryRuntime class, which now contains methods
that may be called by users' Java code to interact with the Mercury runtime
system, including a new finalise() method.

java/runtime/MercuryThreadPool.java:
    Add startup() method.

    shutdown() method is now public and it's meaning has changed, it now
    requests the shutdown rather than performing it.

    Renamed some variables to make their meanings clearer.

java/runtime/JavaInternal.java:
    Initialise the ThreadPool and MercuryOptions objects on demand.

    Make all members of this class static to avoid confusion.

    Add a private constructor.

java/runtime/MercuryRuntime.java:
    Add methods that can be called by Mercury users to interact with the
    runtime system.  Including a convenient finalise() method that does all
    the finalisation.

samples/java_interface/standalone_java/mercury_lib.m:
samples/java_interface/standalone_java/JavaMain.java:
    Extend the standalone Java example so that it makes use of threads: Add
    a fibs function in Mercury that uses concurrency and therefore starts
    the thread pool; call it from the Java code.

    Use the new finalise() method from the MercuryRuntime class inside of a
    finally block.

samples/java_interface/standalone_java/Makefile:
    Fix a minor error.
2014-12-16 10:16:08 +11:00
Julien Fischer
5d67935553 Add an example of calling Mercury libraries from Java.
In particular, demonstrate how to invoke any module-local finalisers and
retrieve the exit status.

samples/java_interface/standalone_java/Makefile:
samples/java_interface/standalone_java/JavaMain.java:
samples/java_interface/standalone_java/mercury_lib.m:
	As above.

samples/java_interface/README:
	Describe the new directory.
2014-12-08 11:52:15 +11:00
Sebastian Godelet
59ce15323f Fix samples/rot13_concise + libxml compilation error
boehm_gc/.gitignore:
    Ignore .obj files

extras/xml/xml.dtd.m:
extras/xml/xml.parse.m:
    Change the name of functor ('1') in the multiplicity/0 type
    to one. The former name does not (yet) work with the C# grade.

samples/.gitignore:
    Ignore library output and sample executables.

samples/c_interface/standalone_c/.gitignore:
    Ignore mercury_lib_int output files.

samples/c_interface/standalone_c/Makefile:
    chmod 0644.

samples/c_interface/.gitignore:
    Ignore object files and executables.

samples/java_interface/.gitignore:
    Ignore Java class files and executables.

samples/lazy_list/.gitignore:
samples/muz/.gitignore:
samples/rot13/.gitignore:
    Ignore executables.

samples/rot13/rot13_concise.m:
    Update call to index_det to use string.det_index.
    Added comments to clarify type inference.

samples/solutions/.gitignore:
    Ignore executables.

samples/solutions/all_solutions.m:
samples/solutions/n_solutions.m:
samples/solutions/one_solution.m:
samples/solutions/some_solutions.m:
    chmod 0644.

samples/solver_types/.gitignore:
    Ignore executables.

samples/solver_types/sudoku.m:
    Output the solution in a 3x3 grid.
2014-03-11 11:30:00 +11:00
Peter Wang
2f99cd4440 Add examples of Mercury/Java integration.
Branches: main, 10.04

samples/README:
samples/java_interface/README:
samples/java_interface/java_calls_mercury/JavaMain.java:
samples/java_interface/java_calls_mercury/Makefile:
samples/java_interface/java_calls_mercury/java_main_int.m:
samples/java_interface/java_calls_mercury/mercury_lib.m:
samples/java_interface/java_calls_mercury/mercury_main.m:
samples/java_interface/mercury_calls_java/JavaMain.java:
samples/java_interface/mercury_calls_java/Makefile:
samples/java_interface/mercury_calls_java/java_main_int.m:
samples/java_interface/mercury_calls_java/mercury_main.m:
        Add examples of Mercury/Java integration.
2010-07-07 07:43:32 +00:00