Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.
COPYING.LIB:
Add a special linking exception to the LGPL.
*:
Update references to COPYING.LIB.
Clean up some minor errors that have accumulated in copyright
messages.
Branches: main
Add a new calling convention for Mercury procedures exported to Java with
`:- pragma foreign_export'. When the procedure has multiple output arguments,
require the caller to pass instances of a `Ref<T>' class which contain a field
to hold the output value. This is more verbose than returning an `Object[]'
array, and requires extra memory allocations, but is more type-safe. Another
advantage is that the Ref arguments will appear at the same positions as the
output arguments in the Mercury procedure.
The new convention must be enabled with `--java-export-ref-out'. The plan is
to enable it by default in the future.
compiler/options.m:
doc/reference_manual.texi:
Add the option.
compiler/ml_proc_gen.m:
When the option is set, disable `--det-copy-out' and generate the
function parameters assuming pass-by-reference for outputs.
Only use the new convention when necessary.
compiler/mlds_to_java.m:
Make the code to generate the exported forwarding methods account for
`mlds_ptr_type' parameters. These are converted to `Ref<T>' arguments.
java/runtime/Ref.java:
Add the reference class.