gov.llnl.babel.backend.c
Class C

java.lang.Object
  extended by gov.llnl.babel.backend.c.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 java.lang.String FUNCTION_RESULT
           
static java.lang.String NULL
           
static java.lang.String RAW_ARRAY_EXT
           
 
Constructor Summary
C()
           
 
Method Summary
static java.lang.String argComment(Argument arg)
          Create a comment to describe the SIDL type for the C signature.
static void generateArgumentList(LanguageWriterForC writer, Context context, java.lang.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 generateArgumentList(LanguageWriterForC writer, Context context, java.lang.String self, boolean is_interface, SymbolID id, Method method, boolean in_signature, boolean add_type, boolean obj_ptr, java.lang.String exc_var, boolean do_return, boolean do_indices, boolean do_rarrays)
          Generate the method's argument list.
static void generateArguments(LanguageWriterForC writer, Context context, java.lang.String self, java.util.List args, boolean isStatic, boolean doThrows, Type returnType, boolean addType, boolean objPtr, boolean doRaw, boolean deref_inout)
          Generate the specified argument list.
static void generateArguments(LanguageWriterForC writer, Context context, java.lang.String self, java.util.List args, boolean isStatic, java.lang.String excVar, Type returnType, boolean addType, boolean objPtr, boolean doRaw, boolean deref_inout)
          Generate the specified argument list.
static java.lang.String getArgumentWithFormal(Argument arg, Context context, boolean objPtr, boolean inStub, boolean isExec)
           
static java.lang.String getDataGetName(SymbolID id)
          Convert a symbol name into its private data structure get access function name.
static java.lang.String getDataName(SymbolID id)
          Convert a symbol name into its private data structure identifier.
static java.lang.String getDataSetName(SymbolID id)
          Convert a symbol name into its private data structure set access function name.
static java.lang.String getDelRefArray(Type arrayType)
           
static java.lang.String getEnsureArray(Type arrayType)
           
static java.lang.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 java.lang.String getExceptionType()
           
static java.lang.String getFullMethodName(SymbolID id, Method method)
          Generate the full method name associated with the symbol id and the specified method.
static java.lang.String getFullMethodName(SymbolID id, java.lang.String methodName)
          Generate the full method name associated with the symbol id and the specified method.
static java.lang.String getFullSelfDecl(SymbolID id)
          Return the full self declaration (i.e., the type and standard self variable.
static java.lang.String getHeaderFile(SymbolID id)
          Generate the header filename associated with a symbol identifier.
static java.lang.String getImplFCastName(SymbolID sourceid, SymbolID targetid)
          Convert a SIDL symbol into the name of its associated remote connector.
static java.lang.String getImplFConnectName(SymbolID sourceid, SymbolID targetid)
          Convert a SIDL symbol into the name of its associated remote connector.
static java.lang.String getImplFGetURLName(SymbolID sourceid, SymbolID targetid)
          Convert a SIDL symbol into the name of its associated get URL function.
static java.lang.String getImplHeaderFile(SymbolID id)
          Generate the implementation header filename associated with a symbol identifier.
static java.lang.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 java.lang.String getMethodImplName(SymbolID id, java.lang.String methodName)
          Generate the impl method's name.
static java.lang.String getMethodSkelName(SymbolID id, Method method)
          Generate the skel method's name.
static java.lang.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 java.lang.String getObjectStructName(SymbolID id)
          Convert a SIDL symbol name into its object structure name.
static java.lang.String getPrivateDestructor(SymbolID id)
          Convert a symbol name into its private destructor function name provided by the SkelSource.
static java.lang.String getReturnString(Type type, Context context, boolean objPtr, boolean inStub)
           
static java.lang.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 java.lang.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 Method getSExecMethod(Context context)
          Creates a Method that represents the static Exec method
static java.lang.String getSkelFile(SymbolID id)
          Generate the skeleton filename associated with a symbol identifier.
static java.lang.String getStubFile(SymbolID id)
          Generate the stub filename associated with a symbol identifier.
static java.lang.String getSymbolName(SymbolID id)
          Convert a symbol name into an IOR identifier.
static java.lang.String getSymbolObjectPtr(SymbolID id)
          Convert a symbol name into an IOR type pointer.
static boolean methodNeedsSkel(Method method)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FUNCTION_RESULT

public static final java.lang.String FUNCTION_RESULT
See Also:
Constant Field Values

NULL

public static final java.lang.String NULL
See Also:
Constant Field Values

RAW_ARRAY_EXT

public static final java.lang.String RAW_ARRAY_EXT
See Also:
Constant Field Values
Constructor Detail

C

public C()
Method Detail

getFullSelfDecl

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


getHeaderFile

public static java.lang.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.

getStubFile

public static java.lang.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.

getSkelFile

public static java.lang.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.

getImplHeaderFile

public static java.lang.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 java.lang.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.

getDataName

public static java.lang.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.

getDataGetName

public static java.lang.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.

getDataSetName

public static java.lang.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.

getPrivateDestructor

public static java.lang.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.

getSymbolObjectPtr

public static java.lang.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.

getSymbolName

public static java.lang.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.

getEnumName

public static java.lang.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.

getObjectName

public static java.lang.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 java.lang.String getObjectStructName(SymbolID id)
Convert a SIDL symbol name into its object structure name.

Parameters:
id - the SymbolID of the Symbol.

getLongestNameLen

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


getSetEPVName

public static java.lang.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.

getImplFConnectName

public static java.lang.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)


getImplFCastName

public static java.lang.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)


getImplFGetURLName

public static java.lang.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)


getSetSEPVName

public static java.lang.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.

getMethodImplName

public static java.lang.String getMethodImplName(SymbolID id,
                                                 java.lang.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.

methodNeedsSkel

public static boolean methodNeedsSkel(Method method)

getMethodSkelName

public static java.lang.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

getFullMethodName

public static java.lang.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.

getFullMethodName

public static java.lang.String getFullMethodName(SymbolID id,
                                                 java.lang.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.

getEnsureArray

public static java.lang.String getEnsureArray(Type arrayType)

getDelRefArray

public static java.lang.String getDelRefArray(Type arrayType)

getExceptionType

public static java.lang.String getExceptionType()

getSExecMethod

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

Throws:
CodeGenerationException

generateArgumentList

public static void generateArgumentList(LanguageWriterForC writer,
                                        Context context,
                                        java.lang.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.

generateArgumentList

public static void generateArgumentList(LanguageWriterForC writer,
                                        Context context,
                                        java.lang.String self,
                                        boolean is_interface,
                                        SymbolID id,
                                        Method method,
                                        boolean in_signature,
                                        boolean add_type,
                                        boolean obj_ptr,
                                        java.lang.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.

generateArguments

public static void generateArguments(LanguageWriterForC writer,
                                     Context context,
                                     java.lang.String self,
                                     java.util.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.

argComment

public static java.lang.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.

getReturnString

public static java.lang.String getReturnString(Type type,
                                               Context context,
                                               boolean objPtr,
                                               boolean inStub)
                                        throws CodeGenerationException
Throws:
CodeGenerationException

getArgumentWithFormal

public static java.lang.String getArgumentWithFormal(Argument arg,
                                                     Context context,
                                                     boolean objPtr,
                                                     boolean inStub,
                                                     boolean isExec)
                                              throws CodeGenerationException
Throws:
CodeGenerationException

generateArguments

public static void generateArguments(LanguageWriterForC writer,
                                     Context context,
                                     java.lang.String self,
                                     java.util.List args,
                                     boolean isStatic,
                                     java.lang.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.