Move to
Next Prev
Up Top
See also
High Level
Reflection
static
IF Computer > MINERVA > Manual > Reference > MINERVA to Java Interface > High Level

High Level

The MINERVA program metagen generates MINERVA predicates for all constructors and methods of a given Java class.

Predicate names correspond one-to-one to their Java counterparts.

Generated comments document the usage of these predicates.

Using metagen there are 3 steps:

  1. Invoke metagen on the class you want to add to MINERVA
  2. Edit the generated MINERVA source file as desired
  3. Compile

For example, let us assume you want to add pseudo random numbers as provided by the Java class java.util.Random.

Then these three steps become

  1. minerva -l $MINERVA_HOME/extender/metagen java.util.Random > random.min
  2. edit random.min -see below for the generated output- to remove unneeded methods and make an independent MINERVA package to become e.g.
    • :- java_predicates('java.util.Random', [
          % java.util.Random()
          % random_create(-java.util.Random)
          % random_create / 1
        random_create = 'java.util.Random',
          % int nextInt(int)
          % random_nextInt_1(+java.util.Random, +int, -int)
          % random_nextInt_1 / 3
        random_nextInt_1 = nextInt(int)]).
      	
  3. minervac random

This produced a MINERVA object program random.mbc with interface description random.mpk .

Additionally, since MINERVA is a higher level language than Java, you may want to define application level predicates that abstract from the system level creation and handling of the opaque Java objects from your application.

  • Invocation:
    • minerva -l $MINERVA_HOME/extender/metagen my.java.Class
  • Examples:
    • ExamplePrograms/MinervaFeatures/MinervaToJava
    • ExamplePrograms/MinervaFeatures/MinervaToJavaScript
    • ExamplePrograms/Extensions/*

Below is the complete source program as generated by metagen for java.util.Random. The comments document the Java and Prolog names and input/output data types.

java_predicates('java.util.Random', [
    % java.util.Random()
    % random_create(-java.util.Random)
    % random_create / 1
  random_create = 'java.util.Random',
    % java.util.Random(long)
    % random_create_0(+long, -java.util.Random)
    % random_create_0 / 2
  random_create_0 = 'java.util.Random'(long),
    % boolean nextBoolean()
    % random_nextBoolean(+java.util.Random, -boolean)
    % random_nextBoolean / 1
  random_nextBoolean = nextBoolean,
    % void nextBytes(byte[])
    % random_nextBytes(+java.util.Random, +byte[])
    % random_nextBytes / 2
  random_nextBytes = nextBytes([byte]),
    % double nextDouble()
    % random_nextDouble(+java.util.Random, -double)
    % random_nextDouble / 2
  random_nextDouble = nextDouble,
    % float nextFloat()
    % random_nextFloat(+java.util.Random, -float)
    % random_nextFloat / 2
  random_nextFloat = nextFloat,
    % double nextGaussian()
    % random_nextGaussian(+java.util.Random, -double)
    % random_nextGaussian / 2
  random_nextGaussian = nextGaussian,
    % int nextInt()
    % random_nextInt(+java.util.Random, -int)
    % random_nextInt / 2
  random_nextInt = nextInt,
    % int nextInt(int)
    % random_nextInt_1(+java.util.Random, +int, -int)
    % random_nextInt_1 / 3
  random_nextInt_1 = nextInt(int),
    % long nextLong()
    % random_nextLong(+java.util.Random, -long)
    % random_nextLong / 2
  random_nextLong = nextLong,
    % void setSeed(long)
    % random_setSeed(+java.util.Random, +long)
    % random_setSeed / 2
  random_setSeed = setSeed(long)]).

read on...
MINERVA
ifcomputer logo
f
Expert Services on the Web
Language
English
Japanese
Server
USA
Japan
Site Access
Local Index
Local Contents
Site Contents
Site Index
Printer Friendly
For imode
For PDA
Search
document: http://www.ifcomputer.co.jp/MINERVA/Manual/Reference/MinervaToJavaInterface/HighLevel/home_en.html
published 2012/2/6 update 2002/3/20 (c) 1996-2009 IF Computer Japan
IF Computer 5-28-2 Sendagi, Bunkyo-ku Tel +81-3-5814-3352 start (AT) ifcomputer.com
Customer Support Tokyo 113-0022 Japan   http://www.ifcomputer.com
scroll to top managed with ubiCMS