|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.codegen.kernel.CodeGeneratorHelper
ptolemy.codegen.c.kernel.CCodeGeneratorHelper
public class CCodeGeneratorHelper
Base class for C code generator helper.
Actor helpers extend this class and optionally define the generateFireCode(), generateInitializeCode(), generatePrefireCode(), generatePostfireCode(), generatePreinitializeCode(), and generateWrapupCode() methods.
In derived classes, these methods, if present, make actor specific changes to
the corresponding code. If these methods are not present, then the parent
class will automatically read the corresponding .c file and substitute in the
corresponding code block. For example, generateInitializeCode() reads the
initBlock
, processes the macros and adds the resulting code
block to the output.
For a complete list of methods to define, see
CodeGeneratorHelper
.
For further details, see $PTII/ptolemy/codegen/README.html
Red (cxh) |
Yellow (cxh) |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ptolemy.codegen.kernel.CodeGeneratorHelper |
---|
CodeGeneratorHelper.Channel, CodeGeneratorHelper.VariableScope |
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj |
---|
NamedObj.ContainedObjectsIterator |
Field Summary | |
---|---|
private java.util.Set |
_includeFiles
The set of header files that needed to be included. |
private boolean |
_printedJVMWarning
True if we have printed the JVM warning. |
Fields inherited from class ptolemy.codegen.kernel.CodeGeneratorHelper |
---|
_codeGenerator, _codeStream, _eol, _INDENT1, _INDENT2, _parseTreeCodeGenerator, _portConversions, _referencedParameters |
Fields inherited from class ptolemy.kernel.util.NamedObj |
---|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Constructor Summary | |
---|---|
CCodeGeneratorHelper(java.lang.Object component)
Create a new instance of the C code generator helper. |
Method Summary | |
---|---|
protected java.lang.String |
_generateInputVariableDeclaration()
Generate input variable declarations. |
protected java.lang.String |
_generateOutputVariableDeclaration()
Generate output variable declarations. |
protected java.lang.String |
_generateReferencedParameterDeclaration()
Generate referenced parameter declarations. |
protected java.lang.String |
_generateTypeConvertStatement(CodeGeneratorHelper.Channel source,
CodeGeneratorHelper.Channel sink,
int offset)
Generate the type conversion statement for the particular offset of the two given channels. |
protected java.lang.String |
_generateTypeConvertVariableDeclaration()
Generate type convert variable declarations. |
protected java.lang.String |
_getFireFunctionArguments()
Return the prototype for fire functions. |
protected java.lang.String |
_replaceMacro(java.lang.String macro,
java.lang.String parameter)
Return the replacement string of the given macro. |
java.lang.String |
generateVariableDeclaration()
Generate variable declarations for inputs and outputs and parameters. |
CCodeGenerator |
getCodeGenerator()
Get the code generator associated with this helper class. |
java.util.Set |
getHeaderFiles()
Get the files needed by the code generated from this helper class. |
java.util.Set |
getJVMHeaderFiles()
Get the header files needed to compile with the jvm library. |
ParseTreeCodeGenerator |
getParseTreeCodeGenerator()
Return a new parse tree code generator to use with expressions. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private final java.util.Set _includeFiles
private boolean _printedJVMWarning
Constructor Detail |
---|
public CCodeGeneratorHelper(java.lang.Object component)
component
- The actor object for this helper.Method Detail |
---|
public ParseTreeCodeGenerator getParseTreeCodeGenerator()
getParseTreeCodeGenerator
in class CodeGeneratorHelper
public java.lang.String generateVariableDeclaration() throws IllegalActionException
generateVariableDeclaration
in interface ActorCodeGenerator
generateVariableDeclaration
in class CodeGeneratorHelper
IllegalActionException
- If the helper class for the model
director cannot be found.public CCodeGenerator getCodeGenerator()
getCodeGenerator
in class CodeGeneratorHelper
CodeGeneratorHelper.setCodeGenerator(CodeGenerator)
public java.util.Set getHeaderFiles() throws IllegalActionException
getHeaderFiles
in interface ActorCodeGenerator
getHeaderFiles
in class CodeGeneratorHelper
IllegalActionException
- Not Thrown in this base class.public java.util.Set getJVMHeaderFiles() throws IllegalActionException
IllegalActionException
- Not Thrown in this subclass.protected java.lang.String _generateInputVariableDeclaration() throws IllegalActionException
IllegalActionException
- If thrown while getting port
information.protected java.lang.String _generateOutputVariableDeclaration() throws IllegalActionException
IllegalActionException
- If thrown while getting port
information.protected java.lang.String _generateReferencedParameterDeclaration() throws IllegalActionException
IllegalActionException
- If thrown while getting modified
variable information.protected java.lang.String _generateTypeConvertStatement(CodeGeneratorHelper.Channel source, CodeGeneratorHelper.Channel sink, int offset) throws IllegalActionException
_generateTypeConvertStatement
in class CodeGeneratorHelper
source
- The given source channel.sink
- The given sink channel.offset
- The given offset.
IllegalActionException
- If there is a problem getting the
helpers for the ports or if the conversion cannot be handled.protected java.lang.String _generateTypeConvertVariableDeclaration() throws IllegalActionException
IllegalActionException
- If thrown while getting port
information.protected java.lang.String _getFireFunctionArguments()
_getFireFunctionArguments
in class CodeGeneratorHelper
protected java.lang.String _replaceMacro(java.lang.String macro, java.lang.String parameter) throws IllegalActionException
CodeGeneratorHelper
_replaceMacro
in class CodeGeneratorHelper
macro
- The given macro.parameter
- The given parameter to the macro.
IllegalActionException
- Thrown if the given macro or parameter
is not valid.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |