gov.llnl.babel.backend.c
Class ImplSource

java.lang.Object
  extended by gov.llnl.babel.backend.c.ImplSource

public class ImplSource
extends java.lang.Object

Class ImplSource generates a C implementation source to a language writer output stream. The constructor takes a language writer stream and method generateCode generates the implementation header file for the specified symbol to the output stream. The language writer stream is not closed by this object.

The implementation source contains definitions of the non-abstract methods. Unlike most files generated by babel, this file is intended to be edited by the developer. The developer needs to insert the implementation of the class in this file or insert calls to something that implements the class.

The code splicer is used to maintain code the developer has written when overwriting an implementation source file. The splicer stores code fragments from the previous file that can be insert into the new file.


Constructor Summary
ImplSource(LanguageWriterForC writer, CodeSplicer splicer, Context context)
          Create a ImplSource object that will write symbol information to the provided output language writer stream.
 
Method Summary
 void generateCode(Class cls)
          Write C implementation source information for the provided class to the language writer output stream provided in the constructor.
static void generateCode(Class cls, LanguageWriterForC writer, CodeSplicer splicer, Context context)
          This is a convenience utility function that writes the symbol source information into the provided language writer output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImplSource

public ImplSource(LanguageWriterForC writer,
                  CodeSplicer splicer,
                  Context context)
Create a ImplSource object that will write symbol information to the provided output language writer stream. The code splicer object may be used to save state between the old source file and the new source file. If the code splicer object is null, then no state is transferred to the new source file.

Parameters:
writer - the output writer for the new implementation source file. This writer will not be closed by this method.
splicer - If not null, this splicer contains code fragments from a implementation source file that is being overwritten. The new implementation will try to incorporate those fragments into the new file.
Method Detail

generateCode

public static void generateCode(Class cls,
                                LanguageWriterForC writer,
                                CodeSplicer splicer,
                                Context context)
                         throws CodeGenerationException
This is a convenience utility function that writes the symbol source information into the provided language writer output stream. The output stream is not closed on exit.

Parameters:
cls - the class whose implementation source is to be created.
writer - the output writer with which the new file is created.
splicer - If not null, the splicer contains code fragments from a previous implementation source file that is being overwritten. The new implementation will incorporate those fragments into the new file.
Throws:
CodeGenerationException - this is a catch all exception. It can be caused by I/O trouble or violations of the data type invariants.

generateCode

public void generateCode(Class cls)
                  throws CodeGenerationException
Write C implementation source information for the provided class to the language writer output stream provided in the constructor. This method does not close the writer output stream.

Parameters:
cls - the class whose implementation source is to be created.
Throws:
CodeGenerationException - this is a catch all exception. It can be caused by I/O trouble or violations of the data type invariants.