mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 09:53:36 +00:00
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.
33 lines
1.0 KiB
Mathematica
33 lines
1.0 KiB
Mathematica
% This module java_main_int defines a Mercury predicate java_main which acts as an
|
|
% interface to the Java method java_main(), which is defined in JavaMain.java.
|
|
|
|
% This source file is hereby placed in the public domain.
|
|
|
|
:- module java_main_int.
|
|
|
|
:- interface.
|
|
:- import_module io.
|
|
|
|
% Since the java_main() function has side effects, we declare the corresponding
|
|
% Mercury predicate as one that takes an io.state pair. If we didn't do
|
|
% this, the Mercury compiler might optimize away calls to it!
|
|
|
|
:- pred java_main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
% Import the Java class containing the method java_main.
|
|
% As usual for Java, this is not necessary; you may also fully qualify the
|
|
% method at the call site.
|
|
:- pragma foreign_decl("Java", "import my_package.JavaMain;").
|
|
|
|
% Define the Mercury predicate java_main to call the Java method java_main.
|
|
%
|
|
:- pragma foreign_proc("Java",
|
|
java_main(IO0::di, IO::uo),
|
|
[may_call_mercury, promise_pure],
|
|
"
|
|
JavaMain.java_main();
|
|
IO = IO0;
|
|
").
|