|
|||||||||
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.java.kernel.JavaCodeGeneratorHelper
public class JavaCodeGeneratorHelper
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 subsitute 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) |
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 | |
---|---|
JavaCodeGeneratorHelper(NamedObj 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 |
_generateTypeConvertVariableDeclaration()
Generate type convert variable declarations. |
private void |
_portVariableDeclaration(java.lang.StringBuffer code,
TypedIOPort port)
|
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. |
JavaCodeGenerator |
getCodeGenerator()
Get the code generator associated with this helper class. |
java.lang.String |
getFunctionInvocation(java.lang.String functionString,
boolean isStatic)
Return the translated token instance function invocation string. |
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. |
java.lang.String |
getNewInvocation(java.lang.String constructorString)
Return the translated new constructor invocation string. |
ParseTreeCodeGenerator |
getParseTreeCodeGenerator()
Return a new parse tree code generator to use with expressions. |
java.lang.String |
getReference(Attribute attribute,
java.lang.String[] channelAndOffset)
Return a reference to the attribute. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.util.Set _includeFiles
private boolean _printedJVMWarning
Constructor Detail |
---|
public JavaCodeGeneratorHelper(NamedObj component)
component
- The actor object for this helper.Method Detail |
---|
public java.lang.String getNewInvocation(java.lang.String constructorString) throws IllegalActionException
getNewInvocation
in class CodeGeneratorHelper
constructorString
- The string within the $new() macro.
IllegalActionException
- The given constructor string is
not well-formed.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 JavaCodeGenerator getCodeGenerator()
getCodeGenerator
in class CodeGeneratorHelper
CodeGeneratorHelper.setCodeGenerator(CodeGenerator)
public java.lang.String getFunctionInvocation(java.lang.String functionString, boolean isStatic) throws IllegalActionException
getFunctionInvocation
in class CodeGeneratorHelper
functionString
- The string within the $tokenFunc() macro.isStatic
- True if the method is static.
IllegalActionException
- The given function string is
not well-formed.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 _generateTypeConvertVariableDeclaration() throws IllegalActionException
IllegalActionException
- If thrown while
getting port information.public java.lang.String getReference(Attribute attribute, java.lang.String[] channelAndOffset) throws IllegalActionException
CodeGeneratorHelper
getReference
in class CodeGeneratorHelper
attribute
- The attribute.channelAndOffset
- The given channel and offset.
IllegalActionException
- If the attribute does not
exist or does not have a value.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.private void _portVariableDeclaration(java.lang.StringBuffer code, TypedIOPort port) throws IllegalActionException
IllegalActionException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |