gov.llnl.babel.backend.c

Class C


public class C
extends java.lang.Object

Class C contains common C language binding routines shared by the C backend code generators. This class simply collects many common C binding routines into one place.

Field Summary

static String
FUNCTION_RESULT
static String
NULL
static String
RAW_ARRAY_EXT

Method Summary

static String
argComment(Argument arg)
Create a comment to describe the SIDL type for the C signature.
static void
generateArgumentList(LanguageWriterForC writer, Context context, String self, boolean is_interface, SymbolID id, Method method, boolean in_signature, boolean add_type, boolean obj_ptr, String exc_var, boolean do_return, boolean do_indices, boolean do_rarrays)
Generate the method's argument list.
static void
generateArgumentList(LanguageWriterForC writer, Context context, String self, boolean is_interface, SymbolID id, Method method, boolean in_signature, boolean add_type, boolean obj_ptr, boolean do_throws, boolean do_return, boolean do_indices, boolean do_rarrays)
Generate the method's argument list.
static void
generateArguments(LanguageWriterForC writer, Context context, String self, List args, boolean isStatic, String excVar, Type returnType, boolean addType, boolean objPtr, boolean doRaw, boolean deref_inout)
Generate the specified argument list.
static void
generateArguments(LanguageWriterForC writer, Context context, String self, List args, boolean isStatic, boolean doThrows, Type returnType, boolean addType, boolean objPtr, boolean doRaw, boolean deref_inout)
Generate the specified argument list.
static String
getArgumentWithFormal(Argument arg, Context context, boolean objPtr, boolean inStub, boolean isExec)
static String
getDataGetName(SymbolID id)
Convert a symbol name into its private data structure get access function name.
static String
getDataName(SymbolID id)
Convert a symbol name into its private data structure identifier.
static String
getDataSetName(SymbolID id)
Convert a symbol name into its private data structure set access function name.
static String
getDelRefArray(Type arrayType)
static String
getEnsureArray(Type arrayType)
static String
getEnumName(SymbolID id)
Convert a SIDL enumerated type into its symbol name, which is "enum " followed by the symbol name followed by "__enum".
static String
getExceptionType()
static String
getFullMethodName(SymbolID id, String methodName)
Generate the full method name associated with the symbol id and the specified method.
static String
getFullMethodName(SymbolID id, Method method)
Generate the full method name associated with the symbol id and the specified method.
static String
getFullSelfDecl(SymbolID id)
Return the full self declaration (i.e., the type and standard self variable.
static String
getHeaderFile(SymbolID id)
Generate the header filename associated with a symbol identifier.
static String
getImplFCastName(SymbolID sourceid, SymbolID targetid)
Convert a SIDL symbol into the name of its associated remote connector.
static String
getImplFConnectName(SymbolID sourceid, SymbolID targetid)
Convert a SIDL symbol into the name of its associated remote connector.
static String
getImplFGetURLName(SymbolID sourceid, SymbolID targetid)
Convert a SIDL symbol into the name of its associated get URL function.
static String
getImplHeaderFile(SymbolID id)
Generate the implementation header filename associated with a symbol identifier.
static String
getImplSourceFile(SymbolID id)
Generate the implementation source filename associated with a symbol identifier.
static int
getLongestNameLen(Struct strct)
Calculate the maximum name length of struct items.
static String
getMethodImplName(SymbolID id, String methodName)
Generate the impl method's name.
static String
getMethodSkelName(SymbolID id, Method method)
Generate the skel method's name.
static String
getObjectName(SymbolID id)
Convert a SIDL symbol name into its object name -- for the purposes of this package that means convert it into its typedef object name.
static String
getObjectStructName(SymbolID id)
Convert a SIDL symbol name into its object structure name.
static String
getPrivateDestructor(SymbolID id)
Convert a symbol name into its private destructor function name provided by the SkelSource.
static String
getReturnString(Type type, Context context, boolean objPtr, boolean inStub)
static Method
getSExecMethod(Context context)
Creates a Method that represents the static Exec method
static String
getSetEPVName(SymbolID id)
Convert a SIDL symbol into the name of its associated set EPV method, which is the symbol name appended with "__set_epv".
static String
getSetSEPVName(SymbolID id)
Convert a SIDL symbol into the name of its associated set static EPV method, which is the symbol name appended with "__set_sepv".
static String
getSkelFile(SymbolID id)
Generate the skeleton filename associated with a symbol identifier.
static String
getStubFile(SymbolID id)
Generate the stub filename associated with a symbol identifier.
static String
getSymbolName(SymbolID id)
Convert a symbol name into an IOR identifier.
static String
getSymbolObjectPtr(SymbolID id)
Convert a symbol name into an IOR type pointer.
static boolean
methodNeedsSkel(Method method)

Field Details

FUNCTION_RESULT

public static final String FUNCTION_RESULT

NULL

public static final String NULL

RAW_ARRAY_EXT

public static final String RAW_ARRAY_EXT

Method Details

argComment

public static String argComment(Argument arg)
Create a comment to describe the SIDL type for the C signature.
Parameters:
arg - the argument to make a comment from
Returns:
usually this is just the mode as a string. For arrays and rarrays more information is returned.

generateArgumentList

public static void generateArgumentList(LanguageWriterForC writer,
                                        Context context,
                                        String self,
                                        boolean is_interface,
                                        SymbolID id,
                                        Method method,
                                        boolean in_signature,
                                        boolean add_type,
                                        boolean obj_ptr,
                                        String exc_var,
                                        boolean do_return,
                                        boolean do_indices,
                                        boolean do_rarrays)
            throws CodeGenerationException
Generate the method's argument list.
Parameters:
writer - the language writer.
self - the String representing the method's self argument name.
is_interface - the boolean indicating whether working with a class or an interface.
id - the SymbolID of the Extendable whose stub source is being written.
method - the Method whose list is being output.
in_signature - the boolean indicating whether the argument list is being generated in a signature.
add_type - the boolean indicating whether the argument types are to be added.
exc_var - the variable to be used for the exception argument; NULL if no exception argument to be generated.
do_return - the boolean indicating whether the return type is to be added.
do_rarrays - the boolean indicating if special raw array argument handling is needed.
Throws:
CodeGenerationException - this is a catch all exception. It can be caused by I/O trouble or violations of the data type invariants.

generateArgumentList

public static void generateArgumentList(LanguageWriterForC writer,
                                        Context context,
                                        String self,
                                        boolean is_interface,
                                        SymbolID id,
                                        Method method,
                                        boolean in_signature,
                                        boolean add_type,
                                        boolean obj_ptr,
                                        boolean do_throws,
                                        boolean do_return,
                                        boolean do_indices,
                                        boolean do_rarrays)
            throws CodeGenerationException
Generate the method's argument list.
Parameters:
writer - the language writer.
self - the String representing the method's self argument name.
is_interface - the boolean indicating whether working with a class or an interface.
id - the SymbolID of the Extendable whose stub source is being written.
method - the Method whose list is being output.
in_signature - the boolean indicating whether the argument list is being generated in a signature.
add_type - the boolean indicating whether the argument types are to be added.
do_throws - the boolean indicating whether the exception is to be added.
do_return - the boolean indicating whether the return type is to be added.
do_rarrays - the boolean indicating if special raw array argument handling is needed.
Throws:
CodeGenerationException - this is a catch all exception. It can be caused by I/O trouble or violations of the data type invariants.

generateArguments

public static void generateArguments(LanguageWriterForC writer,
                                     Context context,
                                     String self,
                                     List args,
                                     boolean isStatic,
                                     String excVar,
                                     Type returnType,
                                     boolean addType,
                                     boolean objPtr,
                                     boolean doRaw,
                                     boolean deref_inout)
            throws CodeGenerationException
Generate the specified argument list.
Parameters:
writer - the language writer.
self - the String representing the method's self argument name.
args - the basic argument list for the method.
isStatic - the boolean indicating whether the method is static.
excVar - the variable to be used for the exception argument; NULL if no exception argument to be generated.
returnType - the return type of the method OR null if the method return type should not be included.
objPtr - TRUE if the object pointer type should be returned; FALSE otherwise.
doRaw - the boolean indicating if special raw array argument handling is needed.
deref_inout - if true, out and inout arguments are dereferenced in passing. (Used for pre and post hooks)
Throws:
CodeGenerationException - this is a catch all exception. It can be caused by I/O trouble or violations of the data type invariants.

generateArguments

public static void generateArguments(LanguageWriterForC writer,
                                     Context context,
                                     String self,
                                     List args,
                                     boolean isStatic,
                                     boolean doThrows,
                                     Type returnType,
                                     boolean addType,
                                     boolean objPtr,
                                     boolean doRaw,
                                     boolean deref_inout)
            throws CodeGenerationException
Generate the specified argument list.
Parameters:
writer - the language writer.
self - the String representing the method's self argument name.
args - the basic argument list for the method.
isStatic - the boolean indicating whether the method is static.
doThrows - the boolean indicating if an exception argument is to be added.
returnType - the return type of the method OR null if the method return type should not be included.
objPtr - TRUE if the object pointer type should be returned; FALSE otherwise.
doRaw - the boolean indicating if special raw array argument handling is needed.
deref_inout - if true, out and inout arguments are dereferenced in passing. (Used for pre and post hooks)
Throws:
CodeGenerationException - this is a catch all exception. It can be caused by I/O trouble or violations of the data type invariants.

getArgumentWithFormal

public static String getArgumentWithFormal(Argument arg,
                                           Context context,
                                           boolean objPtr,
                                           boolean inStub,
                                           boolean isExec)
            throws CodeGenerationException

getDataGetName

public static String getDataGetName(SymbolID id)
Convert a symbol name into its private data structure get access function name. The function name is the SIDL name with the "." scope separators replaced by underscores followed by "__get_data".
Parameters:
id - the SymbolID of the Symbol.

getDataName

public static String getDataName(SymbolID id)
Convert a symbol name into its private data structure identifier. Unlike the IOR, though, use the typedef version (i.e., no "struct") where the SIDL name with the "." scope separators replaced by underscores is followed by "__data".
Parameters:
id - the SymbolID of the Symbol.

getDataSetName

public static String getDataSetName(SymbolID id)
Convert a symbol name into its private data structure set access function name. The function name is the SIDL name with the "." scope separators replaced by underscores followed by "__set_data".
Parameters:
id - the SymbolID of the Symbol.

getDelRefArray

public static String getDelRefArray(Type arrayType)

getEnsureArray

public static String getEnsureArray(Type arrayType)

getEnumName

public static String getEnumName(SymbolID id)
Convert a SIDL enumerated type into its symbol name, which is "enum " followed by the symbol name followed by "__enum".
Parameters:
id - the SymbolID of the Symbol.

getExceptionType

public static String getExceptionType()

getFullMethodName

public static String getFullMethodName(SymbolID id,
                                       String methodName)
Generate the full method name associated with the symbol id and the specified method. The returned name prepends the symbol name and only one underbar to the method's name.
Parameters:
id - the SymbolID of the Symbol associated with the method.
methodName - the String version of the name of the method whose full name is being built.

getFullMethodName

public static String getFullMethodName(SymbolID id,
                                       Method method)
Generate the full method name associated with the symbol id and the specified method. The returned name prepends the symbol name and only one underbar to the method's name.
Parameters:
id - the SymbolID of the Symbol associated with the method.
method - the Method whose full name is being built.

getFullSelfDecl

public static String getFullSelfDecl(SymbolID id)
Return the full self declaration (i.e., the type and standard self variable.

getHeaderFile

public static String getHeaderFile(SymbolID id)
Generate the header filename associated with a symbol identifier. Replace the "." scope separators in the symbol by underscores and append the suffix ".h".
Parameters:
id - the SymbolID of the Symbol.

getImplFCastName

public static String getImplFCastName(SymbolID sourceid,
                                      SymbolID targetid)
Convert a SIDL symbol into the name of its associated remote connector. This requires both the SybmolID of the class this is being defined in (sourceid) and the SymbolID of the target class to be connected (targetid)

getImplFConnectName

public static String getImplFConnectName(SymbolID sourceid,
                                         SymbolID targetid)
Convert a SIDL symbol into the name of its associated remote connector. This requires both the SybmolID of the class this is being defined in (sourceid) and the SymbolID of the target class to be connected (targetid)

getImplFGetURLName

public static String getImplFGetURLName(SymbolID sourceid,
                                        SymbolID targetid)
Convert a SIDL symbol into the name of its associated get URL function. This requires both the SybmolID of the class this is being defined in (sourceid) and the SymbolID of the target class to be connected (targetid)

getImplHeaderFile

public static String getImplHeaderFile(SymbolID id)
Generate the implementation header filename associated with a symbol identifier. Replace the "." scope separators in the symbol by underscores and append the suffix "_Impl.h".
Parameters:
id - the SymbolID of the Symbol.

getImplSourceFile

public static String getImplSourceFile(SymbolID id)
Generate the implementation source filename associated with a symbol identifier. Replace the "." scope separators in the symbol by underscores and append the suffix "_Impl.c".
Parameters:
id - the SymbolID of the Symbol.

getLongestNameLen

public static int getLongestNameLen(Struct strct)
Calculate the maximum name length of struct items.

getMethodImplName

public static String getMethodImplName(SymbolID id,
                                       String methodName)
Generate the impl method's name.
Parameters:
id - the SymbolID of the Symbol associated with the method.
methodName - the String version of the name of the method whose impl name is being built.

getMethodSkelName

public static String getMethodSkelName(SymbolID id,
                                       Method method)
Generate the skel method's name. In most cases, the skel name is the impl name except when the method has an array with an ordering specification.
Parameters:
id - the SymbolID of the Symbol associated with the method.
method - the method

getObjectName

public static String getObjectName(SymbolID id)
Convert a SIDL symbol name into its object name -- for the purposes of this package that means convert it into its typedef object name. The typedef name is the SIDL symbol name with the "." scope separators replaced by underscores.
Parameters:
id - the SymbolID of the Symbol.

getObjectStructName

public static String getObjectStructName(SymbolID id)
Convert a SIDL symbol name into its object structure name.
Parameters:
id - the SymbolID of the Symbol.

getPrivateDestructor

public static String getPrivateDestructor(SymbolID id)
Convert a symbol name into its private destructor function name provided by the SkelSource.
Parameters:
id - the SymbolID of the Symbol.

getReturnString

public static String getReturnString(Type type,
                                     Context context,
                                     boolean objPtr,
                                     boolean inStub)
            throws CodeGenerationException

getSExecMethod

public static Method getSExecMethod(Context context)
            throws CodeGenerationException
Creates a Method that represents the static Exec method

getSetEPVName

public static String getSetEPVName(SymbolID id)
Convert a SIDL symbol into the name of its associated set EPV method, which is the symbol name appended with "__set_epv".
Parameters:
id - the SymbolID of the Symbol.

getSetSEPVName

public static String getSetSEPVName(SymbolID id)
Convert a SIDL symbol into the name of its associated set static EPV method, which is the symbol name appended with "__set_sepv".
Parameters:
id - the SymbolID of the Symbol.

getSkelFile

public static String getSkelFile(SymbolID id)
Generate the skeleton filename associated with a symbol identifier. Replace the "." scope separators in the symbol by underscores and append the suffix "_Skel.c".
Parameters:
id - the SymbolID of the Symbol.

getStubFile

public static String getStubFile(SymbolID id)
Generate the stub filename associated with a symbol identifier. Replace the "." scope separators in the symbol by underscores and append the suffix "_Stub.c".
Parameters:
id - the SymbolID of the Symbol.

getSymbolName

public static String getSymbolName(SymbolID id)
Convert a symbol name into an IOR identifier. This method replaces the "." scope separators in the symbol by underscores.
Parameters:
id - the SymbolID of the Symbol.

getSymbolObjectPtr

public static String getSymbolObjectPtr(SymbolID id)
Convert a symbol name into an IOR type pointer. This method replaces the "." scope separators in the symbol by underscores.
Parameters:
id - the SymbolID of the Symbol.

methodNeedsSkel

public static boolean methodNeedsSkel(Method method)