3.9. Annex B: Interface to Other Languages

Q: B.1(39-41): Pragma Export
Q: (continued)
Q: (continued)
Q: B.2(12-13): Package Interfaces
Q: (continued)
Q: B.3(63-71): Interfacing with C
Q: (continued)
Q: (continued)
Q: (continued)
Q: (continued)
Q: (continued)
Q: (continued)
Q: (continued)
Q: (continued)
Q: B.4(95-98): Interfacing with COBOL
Q: (continued)
Q: B.5(22-26): Interfacing with FORTRAN
Q: (continued)
Q: (continued)
Q: (continued)

Q: B.1(39-41): Pragma Export

If an implementation supports pragma Export to a given language, then it should also allow the main subprogram to be written in that language. It should support some mechanism for invoking the elaboration of the Ada library units included in the system, and for invoking the finalization of the environment task. On typical systems, the recommended mechanism is to provide two subprograms whose link names are adainit and adafinal. adainit should contain the elaboration code for library units. adafinal should contain the finalization code. These subprograms should have no effect the second and subsequent time they are called.

A: Followed.

Q: (continued)

Automatic elaboration of pre-elaborated packages should be provided when pragma Export is supported.

A: Followed.

Q: (continued)

For each supported convention L other than Intrinsic, an implementation should support Import and Export pragmas for objects of L-compatible types and for subprograms, and pragma Convention for L-eligible types and for subprograms, presuming the other language has corresponding features. Pragma Convention need not be supported for scalar types.

A: Followed.

Q: B.2(12-13): Package Interfaces

For each implementation-defined convention identifier, there should be a child package of package Interfaces with the corresponding name. This package should contain any declarations that would be useful for interfacing to the language (implementation) represented by the convention. Any declarations useful for interfacing to any language on the given hardware architecture should be provided directly in Interfaces.

A: Followed.

Q: (continued)

An implementation supporting an interface to C, COBOL, or FORTRAN should provide the corresponding package or packages described in the following clauses.

A: Not Followed.

Q: B.3(63-71): Interfacing with C

An implementation should support the following interface correspondences between Ada and C.

A: Followed.

Q: (continued)

An Ada procedure corresponds to a void-returning C function.

A: Followed.

Q: (continued)

An Ada function corresponds to a non-void C function.

A: Followed.

Q: (continued)

An Ada in scalar parameter is passed as a scalar argument to a C function.

A: Followed.

Q: (continued)

An Ada in parameter of an access-to-object type with designated type T is passed as a t* argument to a C function, where t is the C type corresponding to the Ada type T.

A: Followed.

Q: (continued)

An Ada access T parameter, or an Ada out or in out parameter of an elementary type T, is passed as a t* argument to a C function, where t is the C type corresponding to the Ada type T. In the case of an elementary out or in out parameter, a pointer to a temporary copy is used to preserve by-copy semantics.

A: Followed.

Q: (continued)

An Ada parameter of a record type T, of any mode, is passed as a t* argument to a C function, where t is the C structure corresponding to the Ada type T.

A: Followed. This convention may be overridden by the use of the C_Pass_By_Copy pragma, or Convention, or by explicitly specifying the mechanism for a given call using an extended import or export pragma.

Q: (continued)

An Ada parameter of an array type with component type T, of any mode, is passed as a t* argument to a C function, where t is the C type corresponding to the Ada type T.

A: Followed.

Q: (continued)

An Ada parameter of an access-to-subprogram type is passed as a pointer to a C function whose prototype corresponds to the designated subprogram's specification.

A: Followed.

Q: B.4(95-98): Interfacing with COBOL

An Ada implementation should support the following interface correspondences between Ada and COBOL.

A: Not Followed. COBOL is not supported by XGC Ada.

Q: (continued)

An Ada access T parameter is passed as a BY REFERENCE data item of the COBOL type corresponding to T.

An Ada in scalar parameter is passed as a BY CONTENT data item of the corresponding COBOL type.

Any other Ada parameter is passed as a BY REFERENCE data item of the COBOL type corresponding to the Ada parameter type; for scalars, a local copy is used if necessary to ensure by-copy semantics.

A: Not applicable. COBOL is not supported by XGC Ada.

Q: B.5(22-26): Interfacing with FORTRAN

An Ada implementation should support the following interface correspondences between Ada and FORTRAN: Followed.

An Ada procedure corresponds to a FORTRAN subroutine.

A: Followed.

Q: (continued)

An Ada function corresponds to a FORTRAN function.

A: Followed.

Q: (continued)

An Ada parameter of an elementary, array, or record type T is passed as a T argument to a FORTRAN procedure, where T is the FORTRAN type corresponding to the Ada type T, and where the INTENT attribute of the corresponding dummy argument matches the Ada formal parameter mode; the FORTRAN implementation's parameter passing conventions are used. For elementary types, a local copy is used if necessary to ensure by-copy semantics.

A: Followed.

Q: (continued)

An Ada parameter of an access-to-subprogram type is passed as a reference to a FORTRAN procedure whose interface corresponds to the designated subprogram's specification.

A: Followed.