gov.llnl.babel.backend.c

Class GenerateServerC

Implemented Interfaces:
CodeGenerator, ContextAware

public class GenerateServerC
extends java.lang.Object
implements CodeGenerator

Class GenerateServerC is the main entry point for the C server-side code generation routines. This class generates the skeleton, implementation header, and implementation source files. It is assumed that all symbols necessary to generate C code are available in the symbol table (call resolveAllReferences before calling this routine).

Constructor Summary

GenerateServerC()
The constructor does nothing interesting.

Method Summary

void
generateCode(Set symbols)
Generate C server-side code for each symbol identifier in the set argument.
Set
getLanguages()
Return the set of language names that this generator supports.
String
getName()
Return the canonical name of this generator.
String
getType()
Return the type of generator.
boolean
getUserSymbolsOnly()
Return true if and only if this code factory should only operate on symbols outside the sidl namespace (i.e., exclude symbols from the sidl runtime library).
void
setContext(Context context)
void
setName(String name)
Set the name of the generator.

Constructor Details

GenerateServerC

public GenerateServerC()
The constructor does nothing interesting. The entry point for the GenerateServerC class is generateCode.

Method Details

generateCode

public void generateCode(Set symbols)
            throws CodeGenerationException
Generate C server-side code for each symbol identifier in the set argument. This routine assumes that all necessary symbol references are available in the symbol table. Files are only generated for class symbol types.
Specified by:
generateCode in interface CodeGenerator
Parameters:
symbols - the set of all symbols to be processed. Server code will be generated for members of this set that are Classes.
Throws:
CodeGenerationException - this is a catch all exception. It can be caused by I/O trouble or violations of the data type invariants.

getLanguages

public Set getLanguages()
Return the set of language names that this generator supports. Normally, there is one one name per generator. However, the C++ generator can be referred to as cxx or c++, so it has two in its set. The names should be lower case. Some examples are "c", "ior", "c++", etc.
Specified by:
getLanguages in interface CodeGenerator
Returns:
a Set of strings. Each string is a language name that this generator supports.

getName

public String getName()
Specified by:
getName in interface CodeGenerator
Returns:
the return value should always be a string in the set returned by CodeGenerator.getLanguages(). It may not be equal to the name given in CodeGenerator.setName(String).

getType

public String getType()
Return the type of generator. Currently, there are three types of generator "stub", "skel" and "ior". "xml" might be added someday.
Specified by:
getType in interface CodeGenerator

getUserSymbolsOnly

public boolean getUserSymbolsOnly()
Return true if and only if this code factory should only operate on symbols outside the sidl namespace (i.e., exclude symbols from the sidl runtime library). This is typically true for C and Python where the stubs for the sidl runtime library are pregenerated. Generally, this should be true for anything other than a stub. Implementors do not need to worry about the special case of generating the sidl runtime library itself.
Specified by:
getUserSymbolsOnly in interface CodeGenerator

setContext

public void setContext(Context context)
Specified by:
setContext in interface ContextAware

setName

public void setName(String name)
            throws CodeGenerationException
Set the name of the generator. This sets the name of the generator as it appeared on the command line. This method should be called at least once before CodeGenerator.getName() is called.
Specified by:
setName in interface CodeGenerator
Parameters:
name - this should be the name that the end user designated for the generator.