This class generates the C code that sits between a FORTRAN client and
the internal object representation (IOR) of a sidl object/interface.
For each method, this generates a C function that will be called from
FORTRAN. This C function massages the arguments from Fortran, calls
the IOR, massages the out values from the IOR call, and returns the
outgoing values to the Fortran caller.
charCheck
public static final String charCheck(Context context)
An #ifdef
to check whether character argument should be
treated like strings.
comma
public static boolean comma(LanguageWriter writer,
boolean needComma)
Write a comma and newline to writer
iff
needComma
is true
. This always returns
false
.
writer
- the device to which the comma should be output.needComma
- If true
, this method will write a
comma followed by a newline; otherwise, this
method takes no action.
false
is always returned.
convertRarrayToArray
public static List convertRarrayToArray(List args,
Context context)
Convert any rarray arguments to normal array arguments.
declareArgument
public static boolean declareArgument(LanguageWriter writer,
String argName,
Type argType,
boolean needComma,
Context context)
throws CodeGenerationException
Write an argument declaration in C for an argument being passed in from
a FORTRAN caller or from C to a FORTRAN subroutine.
writer
- the place where the code is generated.argName
- the formal name of the argument.argType
- the type of the argument.needComma
- whether a comma is needed or not.
true
means a comma is needed before
the next argument; false
means a comma
is not needed.
extendArgs
public static List extendArgs(SymbolID selfId,
Method m,
Context context,
boolean indices)
throws CodeGenerationException
Add extra arguments to the original argument list of a method as needed
for the self pointer, the return value and the exception argument.
This makes these implicit arguments explicit and prevents having each
of these be a special case throughout the code.
selfId
- the name of the class/interface who owns the method.m
- the method whose argument list will be extended.indices
- If true, get the argument list including rarray
indices. Should be true for places that support rarrays.
extendedReferences
public static Set extendedReferences(Extendable ext,
Context context)
throws CodeGenerationException
Generate the expanded set of referenced SymbolID
's. This
includes sidl.BaseException
if any of the methods throws
an exception.
ext
- the class or interface to generate includes for.
generateCode
public void generateCode(Symbol symbol)
throws CodeGenerationException
Generate a C file to provide FORTRAN stubs for a sidl
object/interface. The stubs allow FORTRAN clients to make calls on
objects and interfaces or static methods. No stub code is generated
enumerated types and packages. Outside clients typically use
generateCode
instead of calling this method
directly.
symbol
- the symbol for which stubs will be generated.
CodeGenerationException
- a catch all exception to indicate problems during the code generation
phase of the sidl processing.
generateCode
public static void generateCode(Symbol ext,
LanguageWriter writer,
Context context)
throws CodeGenerationException
Generate a C file to provide FORTRAN stubs for a sidl
object/interface. The stubs allow FORTRAN clients to make calls on
objects and interfaces or static methods. No stub code is generated
enumerated types and packages.
ext
- the symbol for which stubs will be generated.writer
- the output device where the stub should be written.
CodeGenerationException
- a catch all exception to indicate problems during the code generation
phase of the sidl processing.
generateEnum
public void generateEnum(Enumeration enm)
throws CodeGenerationException
Generate a FORTRAN include file containing integer constants for the
members of an enumerated type.
enm
- an enumeration object to provide an include file for.
CodeGenerationException
- a catch all exception to indicate problems during the code generation
phase of the sidl processing.
generateIncludes
public static void generateIncludes(LanguageWriterForC writer,
Extendable ext,
Context context)
throws CodeGenerationException
Generate a sequence of #include
preprocessor directives
required by the stub.
writer
- the output device where output is sent.ext
- the class or interface to generate includes for.
generateMethodSymbol
public static void generateMethodSymbol(LanguageWriter writer,
String methodName,
Context context)
Generate the compiler independent form of the function name.
writer
- the place where the symbol is writtenmethodName
- the potentially mixed case form of the function
name.
generateSignature
public static void generateSignature(LanguageWriter writer,
String methodName,
List arguments,
Context context)
throws CodeGenerationException
Generate the C signature for a FORTRAN subroutine to be called from C
or for a C function to be called from FORTRAN. This uses a set of
preprocessor macros to handle the conventions of the FORTRAN compiler.
writer
- the place where the signature is written.methodName
- the name of the function.arguments
- a list of Argument
objects.
generateSupers
public static void generateSupers(Class cls,
LanguageWriter writer,
Context context)
throws CodeGenerationException
This is a convenience utility function specifically for the generation
of super "Stub" functions in the Impl files.
The output stream is not closed on exit. A code
generation exception is thrown if an error is detected.
cls
- The class in which these supers are to be generatedwriter
- the output writer to which the stub source will
be written. This will not be closed.
CodeGenerationException
- this is a catch all exception. It can be caused by I/O trouble or
violations of the data type invariants.
hasProxy
public static boolean hasProxy(Type t)
Return true
iff the type present requires a proxy. A
proxy is required when the FORTRAN types is not directly compatible
with the C type for a particular sidl type.
t
- the sidl type description
true
means that t
requires a proxy;
false
means that t
does not require a
proxy.
isPointer
public static boolean isPointer(Type t)
Return true
if a particular sidl type is implemented using
a pointer type.
t
- the sidl type description.
true
means the type is implemented using a pointer
type; false
means the type is not implemented using a
pointer type.