|
|||||||||
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.kernel.util.Attribute
ptolemy.codegen.kernel.CodeGenerator
public class CodeGenerator
Base class for code generator.
Yellow (eal) |
Yellow (eal) |
Nested Class Summary | |
---|---|
private static class |
CodeGenerator.TargetFilter
A FilenameFilter that looks for directories other than CVS. |
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj |
---|
NamedObj.ContainedObjectsIterator |
Field Summary | |
---|---|
protected java.lang.String |
_codeFileName
The name of the file that was written. |
protected static java.lang.String[] |
_commandFlags
The command-line options that are either present or not. |
protected static java.lang.String[][] |
_commandOptions
The command-line options that take arguments. |
protected static java.lang.String |
_commandTemplate
The form of the command line. |
protected static java.lang.String |
_DEFAULT_TARGET
The default target name. |
protected static java.lang.String |
_eol
End of line character. |
protected ExecuteCommands |
_executeCommands
Execute commands to run the generated code. |
private java.util.Map |
_helperStore
A map giving the code generator helpers for each actor. |
protected java.util.Set<java.lang.String> |
_includes
Set of include command line arguments where each element is a string, for example "-I/usr/local/include". |
private int |
_indent
The current indent level when pretty printing code. |
protected static java.lang.String |
_INDENT1
Indent string for indent level 1. |
protected static java.lang.String |
_INDENT2
Indent string for indent level 2. |
protected static java.lang.String |
_INDENT3
Indent string for indent level 3. |
protected java.util.List<java.lang.String> |
_libraries
List of library command line arguments where each element is a string, for example "-L/usr/local/lib". |
private static int |
_LINES_PER_METHOD
Maximum number of lines in initialize(), postfire() and wrapup() methodS. |
protected java.util.List<java.lang.String> |
_macros
A static list of all macros supported by the code generator. |
protected CompositeEntity |
_model
The model we for which we are generating code. |
protected java.util.Set |
_modifiedVariables
A set that contains all variables in the model whose values can be changed during execution. |
protected java.util.HashSet<java.lang.String> |
_newTypesUsed
A HashSet that contains all codegen types referenced in the model. |
private static java.util.List<java.lang.String> |
_parameterNames
List of parameter names seen on the command line. |
private static java.util.List<java.lang.String> |
_parameterValues
List of parameter values seen on the command line. |
protected java.lang.String |
_postfireCode
The postfire code. |
protected static java.util.List |
_primitiveTypes
A list of the primitive types supported by the code generator. |
protected java.lang.String |
_sanitizedModelName
The sanitized model name. |
protected java.util.Set<java.lang.String> |
_tokenFuncUsed
A set that contains all token functions referenced in the model. |
protected java.util.Set<java.lang.String> |
_typeFuncUsed
A set that contains all type-specific functions referenced in the model. |
Parameter |
allowDynamicMultiportReference
If true, then channels in multiports can be dynamically referenced using the $ref macro. |
FileParameter |
codeDirectory
The directory in which to put the generated code. |
Parameter |
compile
If true, then compile the generated code. |
StringParameter |
compileTarget
The name of compile target to be run if the compile parameter is true. |
Parameter |
generateComment
If true, generate comments in the output code; otherwise, no comments is generated. |
Parameter |
generateCpp
If true, the generated code will be C++ instead of C. |
Parameter |
generateEmbeddedCode
If true, then generate code for that uses the reflection for Java and JNI for C and is embedded within the model The default value is false and this parameter is not usually editable by the user. |
StringParameter |
generatorPackage
The name of the package in which to look for helper class code generators. |
Parameter |
inline
If true, generate file with no functions. |
Parameter |
measureTime
If true, generate code to meausre the execution time. |
Parameter |
overwriteFiles
If true, overwrite preexisting files. |
Parameter |
padBuffers
If true, then buffers are padded to powers of two. |
Parameter |
run
If true, then run the generated code. |
Parameter |
sourceLineBinding
If true, then the generated source is bound to the line number and file of the (helper) templates. |
StringParameter |
target
The hardware target for code generation. |
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 | |
---|---|
CodeGenerator(NamedObj container,
java.lang.String name)
Create a new instance of the code generator. |
Method Summary | |
---|---|
protected void |
_addActorIncludeDirectories()
Add include directories specified by the actors in this model. |
protected void |
_addActorLibraries()
Add libraries specified by the actors in this model. |
protected void |
_analyzeTypeConversions()
Analyze the model to find out what connections need to be type converted. |
protected java.io.File |
_codeDirectoryAsFile()
Return the value of the codeDirectory parameter. |
protected int |
_executeCommands()
Execute the compile and run commands in the codeDirectory directory. |
protected java.lang.StringBuffer |
_finalPassOverCode(java.lang.StringBuffer code)
Make a final pass over the generated code. |
protected java.lang.String |
_generateBodyCode()
Generate the body code that lies between variable declaration and wrapup. |
private int |
_generateCode(java.lang.StringBuffer code)
Generate code and append it to the given string buffer. |
protected java.lang.String |
_generateIncludeFiles()
Generate include files. |
protected java.lang.String |
_generatePreinitializeCode()
Generate preinitialize code (if there is any). |
protected java.lang.String |
_generateSharedCode()
Generate code shared by actors, including globally defined data struct types and static methods or variables shared by multiple instances of the same actor type. |
private static java.lang.Class |
_getCodeGeneratorClass(java.lang.String generatorPackageValue)
Get the code generator associated with the generatePackage parameter. |
protected ActorCodeGenerator |
_getHelper(NamedObj component)
Get the code generator helper associated with the given component. |
protected java.lang.Object |
_getHelper(java.lang.Object object)
Get the code generator helper associated with the given object. |
private ActorCodeGenerator |
_getTargetHelper(NamedObj component)
Get the code generator helper associated with target, if any. |
private ActorCodeGenerator |
_instantiateHelper(java.lang.Object component,
java.lang.Class componentClass,
java.lang.String helperClassName)
Instantiate the given code generator helper. |
private ActorCodeGenerator |
_instantiateHelper(java.lang.Object component,
java.lang.String helperClassName)
|
private java.lang.String |
_prettyPrint(java.lang.String line,
java.lang.String blockBegin,
java.lang.String blockEnd)
Pretty print the given line by indenting the line with the current indent level. |
protected java.lang.String |
_printExecutionTime()
Generate the code for printing the execution time since the code generated by _recordStartTime() was called. |
protected long |
_printTimeAndMemory(long startTime,
java.lang.String message)
Print the elapsed time since the specified startTime if the elpsed time is greater than 10 seconds. |
protected java.lang.String |
_recordStartTime()
Generate the code for recording the current time. |
private void |
_sandboxVariableCheck(IllegalActionException ex)
|
private java.lang.String[] |
_splitBody(java.lang.String prefix,
java.lang.String code)
Split the code. |
private void |
_updateParameters(NamedObj model)
Set the parameters in the model stored in _parameterNames to the values given by _parameterValues. |
private void |
_updateTarget()
Update the target parameter choices from the directory named by the generatorPackage parameter. |
protected static java.lang.String |
_usage()
Return a string summarizing the command-line arguments. |
protected java.lang.String |
_writeCode(java.lang.StringBuffer code)
Write the code to a directory named by the codeDirectory parameter, with a file name that is a sanitized version of the model name, and an extension that is the last package of the generatorPackage. |
protected void |
_writeMakefile()
Create a make file to compile the generated code file(s). |
void |
addInclude(java.lang.String includeCommand)
Add an include command line argument the compile command. |
void |
addLibrary(java.lang.String libraryCommand)
Add a library command line argument the compile command. |
void |
addLibraryIfNecessary(java.lang.String libraryCommand)
If the compile command does not yet containe a library, add a library command line argument the compile command. |
void |
attributeChanged(Attribute attribute)
If the attribute is the codeDirectory parameter, then set the base directory of the codeDirectory parameter. |
java.lang.String |
codeGenType(Type ptType)
Get the corresponding type in code generation from the given Ptolemy type. |
java.lang.String |
comment(int indentLevel,
java.lang.String comment)
Return a formatted comment containing the specified string with a specified indent level. |
java.lang.String |
comment(java.lang.String comment)
Return a formatted comment containing the specified string. |
static boolean |
containsCode(java.lang.String code)
Return true if the input contains code. |
java.lang.String |
formatComment(java.lang.String comment)
Return a formatted comment containing the specified string. |
java.lang.String |
generateClosingEntryCode()
Return the closing entry code, if any. |
java.lang.String |
generateClosingExitCode()
Return the closing exit code, if any. |
int |
generateCode()
Generate code and write it to the file specified by the codeDirectory parameter. |
static int |
generateCode(java.lang.String[] args)
Generate code for a model. |
int |
generateCode(java.lang.StringBuffer code)
Generate code. |
java.lang.String |
generateCopyright()
Return the copyright for this code. |
java.lang.String |
generateFireFunctionCode()
Generate The fire function code. |
java.lang.Object |
generateFunctionTable(java.lang.Object[] types,
java.lang.Object[] functions)
Generate the function table. |
java.lang.String |
generateInitializeCode()
Return the code associated with initialization of the containing composite actor. |
java.lang.String |
generateInitializeEntryCode()
Generate the initialization procedure entry point. |
java.lang.String |
generateInitializeExitCode()
Generate the initialization procedure exit point. |
java.lang.String |
generateInitializeProcedureName()
Generate the initialization procedure name. |
java.lang.String |
generateLineInfo(int lineNumber,
java.lang.String filename)
Generate line number and file name information. |
java.lang.String |
generateMainEntryCode()
Generate the main entry point. |
java.lang.String |
generateMainExitCode()
Generate the main exit point. |
java.lang.String |
generatePostfireCode()
Generate into the specified code stream the code associated with postfiring up the container composite actor. |
java.lang.String |
generatePostfireEntryCode()
Generate the postfire procedure entry point. |
java.lang.String |
generatePostfireExitCode()
Generate the postfire procedure exit point. |
java.lang.String |
generatePostfireProcedureName()
Generate the postfire procedure name. |
java.lang.String |
generateTypeConvertCode()
Generate type conversion code. |
java.lang.String |
generateVariableDeclaration()
Generate variable declarations for inputs and outputs and parameters. |
java.lang.String |
generateVariableInitialization()
Generate variable initialization for the referenced parameters. |
java.lang.String |
generateVariableName(NamedObj attribute)
Generate variable name for the given attribute. |
java.lang.String |
generateWrapupCode()
Generate into the specified code stream the code associated with wrapping up the container composite actor. |
java.lang.String |
generateWrapupEntryCode()
Generate the wrapup procedure entry point. |
java.lang.String |
generateWrapupExitCode()
Generate the wrapup procedure exit point. |
java.lang.String |
generateWrapupProcedureName()
Generate the wrapup procedure name. |
java.lang.String |
getCodeFileName()
Return the name of the code file that was written, if any. |
NamedObj |
getComponent()
Return the associated component, which is always the container. |
ExecuteCommands |
getExecuteCommands()
Get the command executor, which can be either non-graphical or graphical. |
java.util.List |
getMacros()
Return a list of macros this code generator supports. |
java.util.Set |
getModifiedVariables()
Return the set of modified variables. |
java.lang.String |
getOutputFilename()
Return the name of the output file. |
boolean |
isPrimitive(java.lang.String cgType)
Determine if the given type is primitive. |
boolean |
isPrimitive(Type ptType)
Determine if the given type is primitive. |
boolean |
isTopLevel()
Test if the containing actor is in the top level. |
static void |
main(java.lang.String[] args)
Generate code for a model. |
static boolean |
parseArg(java.lang.String arg)
Parse a command-line argument. |
static Type |
ptolemyType(java.lang.String cgType)
Return the Ptolemy type that corresponds to the type named by the argument. |
void |
reset()
Reset the code generator. |
void |
setCodeGenerator(CodeGenerator codeGenerator)
This method is used to set the code generator for a helper class. |
void |
setContainer(NamedObj container)
Set the container of this object to be the given container. |
void |
setExecuteCommands(ExecuteCommands executeCommands)
Set the command executor, which can be either non-graphical or graphical. |
java.lang.String[] |
splitLongBody(int linesPerMethod,
java.lang.String prefix,
java.lang.String code)
Split a long function body into multiple functions. |
java.lang.String |
targetType(Type ptType)
Get the corresponding type in C from the given Ptolemy type. |
Methods inherited from class ptolemy.kernel.util.Attribute |
---|
_checkContainer, _getContainedObject, _propagateExistence, clone, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public Parameter allowDynamicMultiportReference
public FileParameter codeDirectory
public Parameter compile
public StringParameter compileTarget
public Parameter generateComment
public Parameter generateCpp
public StringParameter generatorPackage
public Parameter generateEmbeddedCode
public Parameter inline
public Parameter measureTime
public Parameter overwriteFiles
public Parameter padBuffers
public Parameter run
public Parameter sourceLineBinding
public StringParameter target
targets
subdirectory of the directory named by the generatorPackage
parameter. For example, if generatorPackage is
ptolemy.codegen.c
, and if
$PTII/ptolemy/codegen/c/targets/
exists and contains
an iRobot/
directory, and this parameter is set
to iRobot
, then files from
$PTII/ptolemy/codegen/c/targets/iRobot
will be used
to generate code. The default value is the string "default"
which means that the default target for the language is used.
protected java.lang.String _codeFileName
protected static java.lang.String[] _commandFlags
protected static java.lang.String[][] _commandOptions
protected static final java.lang.String _commandTemplate
protected static final java.lang.String _DEFAULT_TARGET
protected static final java.lang.String _eol
protected ExecuteCommands _executeCommands
protected java.util.List<java.lang.String> _libraries
protected static final java.lang.String _INDENT1
StringUtilities.getIndentPrefix(int)
protected static final java.lang.String _INDENT2
StringUtilities.getIndentPrefix(int)
protected static final java.lang.String _INDENT3
StringUtilities.getIndentPrefix(int)
protected java.util.Set<java.lang.String> _includes
protected CompositeEntity _model
protected java.util.Set _modifiedVariables
protected java.util.HashSet<java.lang.String> _newTypesUsed
protected java.util.List<java.lang.String> _macros
protected static java.util.List _primitiveTypes
protected java.lang.String _postfireCode
protected java.lang.String _sanitizedModelName
protected java.util.Set<java.lang.String> _tokenFuncUsed
protected java.util.Set<java.lang.String> _typeFuncUsed
private java.util.Map _helperStore
private int _indent
private static java.util.List<java.lang.String> _parameterNames
private static java.util.List<java.lang.String> _parameterValues
private static int _LINES_PER_METHOD
Constructor Detail |
---|
public CodeGenerator(NamedObj container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of the code generator.
IllegalActionException
- If the super class throws the
exception or error occurs when setting the file path.
NameDuplicationException
- If the super class throws the
exception or an error occurs when setting the file path.Method Detail |
---|
private int _generateCode(java.lang.StringBuffer code) throws KernelException
$HOME
, the name of the
model is Foo
and the generatorPackage
is ptolemy.codegen.c
, then the file that is
written will be $HOME/Foo.c
This method is the main entry point.
code
- The given string buffer.
KernelException
- If the target file cannot be overwritten
or write-to-file throw any exception.public void addInclude(java.lang.String includeCommand)
includeCommand
- The include command, for example
"-I/usr/local/include".public void addLibrary(java.lang.String libraryCommand)
libraryCommand
- The library command, for example
"-L/usr/local/lib".addLibraryIfNecessary(String)
public void addLibraryIfNecessary(java.lang.String libraryCommand)
libraryCommand
- The library command, for example
"-L/usr/local/lib".addLibrary(String)
public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class NamedObj
attribute
- The attribute that changed.
IllegalActionException
- If the change is not acceptable
to this container.public java.lang.String codeGenType(Type ptType)
ptType
- The given Ptolemy type.
IllegalActionException
- Thrown if the given ptolemy cannot
be resolved.public java.lang.String comment(int indentLevel, java.lang.String comment)
comment
- The string to put in the comment.indentLevel
- The indentation level.
public java.lang.String comment(java.lang.String comment)
comment
- The string to put in the comment.
public java.lang.String formatComment(java.lang.String comment)
comment
- The string to put in the comment.
public int generateCode() throws KernelException
KernelException
- If the target file cannot be overwritten
or write-to-file throw any exception.public int generateCode(java.lang.StringBuffer code) throws KernelException
code
- The code buffer into which to generate the code.
KernelException
- If a type conflict occurs or the model
is running.public java.lang.String generateClosingEntryCode()
public java.lang.String generateClosingExitCode()
public java.lang.String generateCopyright()
public java.lang.String generateFireFunctionCode() throws IllegalActionException
IllegalActionException
- If thrown while generating fire code.public java.lang.Object generateFunctionTable(java.lang.Object[] types, java.lang.Object[] functions)
types
- An array of types.functions
- An array of functions.
public java.lang.String generateInitializeCode() throws IllegalActionException
generateInitializeCode
in interface ComponentCodeGenerator
IllegalActionException
- If the helper class for the model
director cannot be found or if an error occurs when the director
helper generates initialize code.public java.lang.String generateInitializeEntryCode() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.public java.lang.String generateInitializeExitCode() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.public java.lang.String generateInitializeProcedureName() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.public java.lang.String generateLineInfo(int lineNumber, java.lang.String filename)
lineNumber
- The line number of the source file or
file containing code blocks.filename
- The name of the source file or file containing
code blocks.
public java.lang.String generateMainEntryCode() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.public java.lang.String generateMainExitCode() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.public java.lang.String generatePostfireCode() throws IllegalActionException
IllegalActionException
- If the helper class for the model
director cannot be found.public java.lang.String generatePostfireEntryCode() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.public java.lang.String generatePostfireExitCode() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.public java.lang.String generatePostfireProcedureName() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.public java.lang.String generateTypeConvertCode() throws IllegalActionException
IllegalActionException
- If an error occurrs when generating
the type conversion code, or if the helper class for the model
director cannot be found, or if an error occurs when the helper
actor generates the type conversion code.public java.lang.String generateVariableDeclaration() throws IllegalActionException
IllegalActionException
- If the helper class for the model
director cannot be found.public java.lang.String generateVariableInitialization() throws IllegalActionException
IllegalActionException
- If the helper class for the model
director cannot be found.public java.lang.String generateVariableName(NamedObj attribute)
attribute
- The attribute to generate variable name for.
public java.lang.String generateWrapupCode() throws IllegalActionException
generateWrapupCode
in interface ComponentCodeGenerator
IllegalActionException
- If the helper class for the model
director cannot be found.public java.lang.String generateWrapupEntryCode() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.public java.lang.String generateWrapupExitCode() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.public java.lang.String generateWrapupProcedureName() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.public java.lang.String getCodeFileName()
public NamedObj getComponent()
getComponent
in interface ComponentCodeGenerator
public ExecuteCommands getExecuteCommands()
setExecuteCommands(ExecuteCommands)
public java.util.List getMacros()
public java.util.Set getModifiedVariables() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.public java.lang.String getOutputFilename() throws IllegalActionException
IllegalActionException
- If there is problem resolving
the string value of the generatorPackage parameter.public boolean isPrimitive(java.lang.String cgType)
cgType
- The given codegen type.
public boolean isPrimitive(Type ptType)
ptType
- The given ptolemy type.
public boolean isTopLevel()
public static Type ptolemyType(java.lang.String cgType)
cgType
- A String naming a type.
public void reset()
public void setCodeGenerator(CodeGenerator codeGenerator)
setCodeGenerator
in interface ComponentCodeGenerator
codeGenerator
- The given code generator.public void setContainer(NamedObj container) throws IllegalActionException, NameDuplicationException
setContainer
in class Attribute
container
- The given container.
IllegalActionException
- If the given container
is not null and not an instance of CompositeEntity.
NameDuplicationException
- If there already exists a
container with the same name.Attribute.getContainer()
public void setExecuteCommands(ExecuteCommands executeCommands)
executeCommands
- The subprocess command executor.getExecuteCommands()
public java.lang.String[] splitLongBody(int linesPerMethod, java.lang.String prefix, java.lang.String code) throws java.io.IOException
In this base class, since we don't know what the target language will be, the first element is the empty string, the second element is the code argument.
linesPerMethod
- The number of lines that should go into
each method.prefix
- The prefix to use when naming functions that
are createdcode
- The method body to be split.
java.io.IOException
- If thrown will reading the code.public java.lang.String targetType(Type ptType)
ptType
- The given Ptolemy type.
protected void _addActorIncludeDirectories() throws IllegalActionException
IllegalActionException
- Never in this base class.protected void _addActorLibraries() throws IllegalActionException
IllegalActionException
- Never in this base class.protected void _analyzeTypeConversions() throws IllegalActionException
IllegalActionException
- If the helper of the
top composite actor is unavailable.protected java.io.File _codeDirectoryAsFile() throws java.io.IOException, IllegalActionException
codeDirectory
parameter.
java.io.IOException
- If the codeDirectory parameter
names a file or a directory cannot be created.
IllegalActionException
- If thrown while reading the
codeDirectory parameter.protected int _executeCommands() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.protected java.lang.StringBuffer _finalPassOverCode(java.lang.StringBuffer code) throws IllegalActionException
code
- The given code to be processed.
IllegalActionException
- If #getOutputFilename() throws it.protected java.lang.String _generateBodyCode() throws IllegalActionException
IllegalActionException
- If there is no director.protected java.lang.String _generateIncludeFiles() throws IllegalActionException
IllegalActionException
- If the helper class for some actor
cannot be found.protected java.lang.String _generatePreinitializeCode() throws IllegalActionException
IllegalActionException
- If the helper class for the model
director cannot be found, or if an error occurs when the director
helper generates preinitialize code.protected java.lang.String _generateSharedCode() throws IllegalActionException
IllegalActionException
- If an error occurrs when generating
the globally shared code, or if the helper class for the model
director cannot be found, or if an error occurs when the helper
actor generates the shared code.protected ActorCodeGenerator _getHelper(NamedObj component) throws IllegalActionException
component
- The given component.
IllegalActionException
- If the helper class cannot be found.protected java.lang.Object _getHelper(java.lang.Object object) throws IllegalActionException
object
- The given object.
IllegalActionException
- If the helper class cannot be found.protected java.lang.String _printExecutionTime()
protected long _printTimeAndMemory(long startTime, java.lang.String message)
startTime
- The start time. Usually set to the value
of (new Date()).getTime()
.message
- A prefix to the printed message.
protected java.lang.String _recordStartTime()
protected java.lang.String _writeCode(java.lang.StringBuffer code) throws IllegalActionException
code
- The StringBuffer containing the code.
IllegalActionException
- If there is a problem reading
a parameter, if there is a problem creating the codeDirectory directory
or if there is a problem writing the code to a file.protected void _writeMakefile() throws IllegalActionException
IllegalActionException
- Not thrown in this base class.private ActorCodeGenerator _getTargetHelper(NamedObj component) throws IllegalActionException
component
- The given component.
IllegalActionException
- If the helper class cannot be found.private ActorCodeGenerator _instantiateHelper(java.lang.Object component, java.lang.String helperClassName) throws IllegalActionException
IllegalActionException
private ActorCodeGenerator _instantiateHelper(java.lang.Object component, java.lang.Class componentClass, java.lang.String helperClassName) throws IllegalActionException
component
- The given component.helperClassName
- The dot separated name of the helper.
IllegalActionException
- If the helper class cannot be found.private java.lang.String _prettyPrint(java.lang.String line, java.lang.String blockBegin, java.lang.String blockEnd)
line
- The given line of code.blockBegin
- The given block begin symbol to match.blockEnd
- The given block end symbol to match.
private java.lang.String[] _splitBody(java.lang.String prefix, java.lang.String code)
private void _updateParameters(NamedObj model)
model
- The model in which to update parameters.private void _updateTarget() throws IllegalActionException
CVS
directory are added as choices.
IllegalActionException
- If the generatorPackage
attribute cannot be read.public static boolean containsCode(java.lang.String code)
code
- The string to check for code.
public static int generateCode(java.lang.String[] args) throws java.lang.Exception
args
- An array of Strings, each element names a MoML file
containing a model.
java.lang.Exception
- If any error occurs.public static void main(java.lang.String[] args) throws java.lang.Exception
For example:
java -classpath $PTII ptolemy.codegen.kernel.CodeGenerator $PTII/ptolemy/codegen/c/actor/lib/test/auto/Ramp.xmlor
$PTII/bin/ptinvoke ptolemy.codegen.kernel.CodeGenerator $PTII/ptolemy/codegen/c/actor/lib/test/auto/Ramp.xml
args
- An array of Strings, each element names a MoML file
containing a model.
java.lang.Exception
- If any error occurs.public static boolean parseArg(java.lang.String arg) throws java.lang.Exception
arg
- The command-line argument to be parsed.
java.lang.Exception
- If something goes wrong.protected static java.lang.String _usage()
private static java.lang.Class _getCodeGeneratorClass(java.lang.String generatorPackageValue) throws IllegalActionException
generatorPackageValue
- The value of the generatorPackage parameter.
IllegalActionException
- If the helper class cannot be found.private void _sandboxVariableCheck(IllegalActionException ex) throws IllegalActionException
IllegalActionException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |