Contents | Prev | Next | Index
All Java classes and its members, as generated by Pascal, can be imported and accessed by third party Java software as long as they stick to the naming conventions and parameter passing rules which are described below.
A Canterbury Pascal program or unit is compiled into a single Java class file of the same name. Each record or class type declared in the Pascal program or unit is mapped to separate Java class, using the name <program-name>_<class-name>.
Example: Given the Pascal unit
program Example;
....
type MYREC = record .... end;
....
end.
the Pascal compiler generates the following 2 files:
Pascal procedures are mapped to corresponding class methods in the Java output class. Canterbury Pascal supports class definitions with field and method members similar to Borland Object Pascal. If a Pascal method is declared with the VIRTUAL or OVERRIDE keyword then it is mapped to a normal virtual Java method of the same name. If the Pascal method is declared with the CLASS keyword then it is mapped to a Java static method of the same name. Otherwise, if it is a static Pascal method (the default) then it is mapped to a virtual Java method, but its name is changed to the unique identifier <class-name>_<method-name>, e.g. a method called 'Foo' in class 'AnyClass' becomes a Java method of the name 'AnyClass_Foo'.
Value parameters for procedures and methods are directly mapped to Java's value parameters using the corresponding Java types. If they are of structured types then the called method creates local copies. Variable parameters which are structured are mapped to Java reference parameters. Unstructured variable parameters are passed by reference using arrays of one element. For example, in order to pass a Java value xval of type double to a Pascal procedure whose formal type is declared as a VAR-parameter, the following Java code is required:
double xval = 3.1415;
double[] px = new double[1];
px[0] = xval;
<pascal-unit-id>.<pascal-proc-id>( px );
xval = px[0];
The following 2 tables list all value and variable parameter types for Pascal and their corresponding Java equivalents:
Pascal value parameter
Java parameter
CHAR char BOOLEAN boolean SHORTINT byte BYTE byte SMALLINT short WORD short LONGINT int LONGWORD int INTEGER int CARDINAL int SYSTEM.HUGEINT long SINGLE float DOUBLE double <enumeration-type-id> int POINTER java.lang.Object STRING java.lang.StringBuffer <record-type-id> <record-type-id> <class-type-id> <unit-id>_<class-type-id> <array-type-id> <element-type-id>[]<...>[] <set-type-id> byte[] <pointer-type-id> <pointee record-type-id> or <element-type-id>[]<...>[]
Pascal variable parameter
Java parameter
CHAR char[] BOOLEAN boolean[] SHORTINT byte[] BYTE byte[] SMALLINT short[] WORD short[] LONGINT int[] LONGWORD int[] INTEGER int[] CARDINAL int[] SYSTEM.HUGEINT long[] SINGLE float[] DOUBLE double[] <enumeration-type-id> int[] POINTER java.lang.Object[] STRING java.lang.StringBuffer <record-type-id> <record-type-id> <class-type-id> <unit-id>_<class-type-id> <array-type-id> <element-type>[]<...>[] <set-type-id> byte[] <pointer-type-id> <Java signature of pointee type>[] untyped java.lang.Object
Contents | Prev | Next | Index
Canterbury Pascal for JVM (Last documentation update
Sep 02, 2004)
Copyright © 1999-2004 J.Neuhoff - mhccorp.com
. All rights reserved.
Please send any comments or corrections to
neuhoff@mhccorp.com