sitelogo
static

MINERVA cooperates with program components written in Java. The program components are declared as "external" and can then be used as MINERVA code itself.

Use this functionality to exploit existing Java libraries and utilities e.g. for networking, graphical user interfaces, multi-media extensions etc.

The interface to access Java functions is realized using a generator. The user declares the interface to a Java function. The generator converts the declarations into an invocation frame for parameter conversions and the function call itself.

A declaration of an external function looks like:

	dynamic_function(
			PredicateName,
			JavaClassName,
			FunctionName(TypeArg1,...,TypeArgN),
			ReturnType).

static_function( PredicateName, JavaClassName, FunctionName(TypeArg1,...,TypeArgN), ReturnType).

Examples:

	dynamic_function(
                button__set_label,	% MINERVA predicate name
                'Button',		% Java class name
                setLabel(string),	% Java method
                void			% Java return type
        ).

static_function( font__get, % MINERVA predicate name 'Font', % Java class name getFont(string), % Java method 'Font' % Java return type ).

The resulting MINERVA predicates are then:

	PredicateName(Object,Arg1,...,ArgN,ReturnArg)
	PredicateName(Object,Arg1,...,ArgN) % for void functions
	PredicateName(Arg1,...,ArgN,ReturnArg) % for static functions
	PredicateName(Arg1,...,ArgN) % for static void functions

respectively.

In our example:

	button__set_label(Button,DisplayText)
and
	font__get(FontName,Font)

Here is a small example of MINERVA to Java interfaces:

dynamic_function(
        get_line_number,
        'java.io.LineNumberInputStream',
        getLineNumber,
        int
    ).

dynamic_function( set_line_number, 'java.io.LineNumberInputStream', setLineNumber(int), void ).

create_instance( create_line_number_input_stream, 'java.io.LineNumberInputStream'('java.io.InputStream') ).

With that it is declared that three predicates should be built. For the dynamic predicates:

int java.io.LineNumberInputStream.getLineName() (Predicate: get_line_number(+LineNumberStream,-LineNumber))

and
	void java.io.LineNumberInputStream.setLineName(int lineno)
		(Predicate: set_line_number(+LineNumberStream,+LineNumber))

The predicate to produce an object 'java.io.LineNumberInputStream':

	create_line_number_input_stream(+Stream, -LineNumberStream)

For static functions there are also interface descriptions. See the ExamplePrograms section for more.


Up read on...
scroll to top managed with ubiCMS