public abstract class SmcCodeGenerator extends SmcVisitor
SmcVisitor
super class are left to
this class' subclasses to define.SmcElement
,
SmcVisitor
,
SmcOptions
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
_accessLevel
Used this access keyword for the generated classes.
|
protected java.lang.String |
_appName
Application name.
|
protected java.lang.String |
_appVersion
Application version.
|
protected java.lang.String |
_castType
Use this cast type (C++ only).
|
protected boolean |
_crtpFlag
This flag is true when generated code is template for CRTP.
|
protected int |
_debugLevel
This flag is true when debug output is to be generated.
|
protected boolean |
_genericFlag
This flag is true when reflection is to use a
generic transition map.
|
protected int |
_graphLevel
Generate this much detail in the graph (-graph only).
|
protected int |
_guardCount
The total number of guards to be generated at this time.
|
protected int |
_guardIndex
The guard currently being generated.
|
protected java.lang.String |
_headerDirectory
Place the generated header file in this directory.
|
protected java.lang.String |
_headerSuffix
Place this suffix on the header file.
|
protected java.lang.String |
_indent
Output this indent before generating a line of code.
|
protected boolean |
_java7Flag
This flag is
true when Java 7 generic code is
generated. |
protected boolean |
_noCatchFlag
This flag is true when exceptions are not caught.
|
protected boolean |
_noExceptionFlag
This flag is true when exceptions are not be thrown.
|
protected boolean |
_noStreamsFlag
This flag is true when I/O streams should not be used.
|
protected boolean |
_reflectFlag
This flag is true when reflection is supported.
|
protected boolean |
_serialFlag
This flag is true when serialization is to be generated.
|
protected java.io.PrintStream |
_source
Emit the target source code to this output stream.
|
protected java.lang.String |
_srcDirectory
Write the target source file to this directory.
|
protected java.lang.String |
_srcfileBase
The .sm file's base name.
|
protected int |
_stateStackSize
A value > zero means that a statically-allocated state
stack of fixed-size is used.
|
protected boolean |
_syncFlag
This flag is true when synchronization code is to be
generated.
|
protected java.lang.String |
_targetfileBase
The target file's base name.
|
protected boolean |
_useProtocolFlag
This flag is
true when Objective-C code uses a
protocol instead of a class. |
static int |
DEBUG_LEVEL_0
Output states and transitions.
|
static int |
DEBUG_LEVEL_1
Output states, transitions and all transition, entry and
exit actions.
|
static java.lang.String |
DEFAULT_HEADER_SUFFIX
The default header file suffix is "h".
|
static int |
GRAPH_LEVEL_0
Provide state and transition names only.
|
static int |
GRAPH_LEVEL_1
Provide state and transition names plus transition guards
and actions.
|
static int |
GRAPH_LEVEL_2
Provides state names, entry and exit actions, transition
name and arguments, guards, actions and their action
parameters and pop transition arguments.
|
static int |
NO_DEBUG_OUTPUT
No debug output.
|
static int |
NO_GRAPH_LEVEL
No graphing is done.
|
Modifier | Constructor and Description |
---|---|
protected |
SmcCodeGenerator(net.sf.smc.generator.SmcOptions options,
java.lang.String suffix)
Constructs the target code generator for the given
parameters.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
allNilEndStates(java.util.List<SmcGuard> guards)
Returns
true if each of the transition guards uses
the nil end state. |
static java.lang.String |
escape(java.lang.String s)
Place a backslash escape character in front of backslashes
and doublequotes.
|
protected java.lang.String |
findPath(java.lang.String srcDir,
java.lang.String headerDir)
Returns a relative path from directory
srdDir to
directory headerDir . |
protected boolean |
isLoopback(SmcElement.TransType transType,
java.lang.String endState)
Returns
true if this transition is an
internal loopback or a push transition and
false otherwise. |
protected java.lang.String |
scopeStateName(java.lang.String stateName,
java.lang.String mapName)
Scopes the state name.
|
protected java.lang.String |
scopeStateName(java.lang.String stateName,
java.lang.String mapName,
java.lang.String ifs)
Scopes the state name.
|
void |
setSource(java.io.PrintStream source)
Sets the source code output destination.
|
java.lang.String |
sourceFile(java.lang.String path,
java.lang.String basename,
java.lang.String suffix)
Returns the source file name generated from the
destination directory, base name and suffix using
the source name format.
|
protected final java.lang.String _appName
protected final java.lang.String _appVersion
protected java.io.PrintStream _source
protected final java.lang.String _srcfileBase
protected final java.lang.String _targetfileBase
protected final java.lang.String _srcDirectory
protected final java.lang.String _headerDirectory
protected final java.lang.String _headerSuffix
protected final java.lang.String _castType
protected final int _graphLevel
protected java.lang.String _indent
protected int _guardCount
protected int _guardIndex
protected final boolean _serialFlag
protected final int _debugLevel
protected final boolean _noExceptionFlag
protected final boolean _noCatchFlag
protected final boolean _noStreamsFlag
protected final boolean _crtpFlag
protected final int _stateStackSize
protected final boolean _reflectFlag
protected final boolean _syncFlag
protected final boolean _genericFlag
protected final boolean _java7Flag
true
when Java 7 generic code is
generated. Used with -java and -reflect only.protected final java.lang.String _accessLevel
protected final boolean _useProtocolFlag
true
when Objective-C code uses a
protocol instead of a class.public static final java.lang.String DEFAULT_HEADER_SUFFIX
public static final int NO_DEBUG_OUTPUT
public static final int DEBUG_LEVEL_0
public static final int DEBUG_LEVEL_1
public static final int NO_GRAPH_LEVEL
public static final int GRAPH_LEVEL_0
public static final int GRAPH_LEVEL_1
public static final int GRAPH_LEVEL_2
protected SmcCodeGenerator(net.sf.smc.generator.SmcOptions options, java.lang.String suffix)
options
- The target code generator options.suffix
- the target source file name suffix.public java.lang.String sourceFile(java.lang.String path, java.lang.String basename, java.lang.String suffix)
path
- The destination directory.basename
- The file's basename sans suffix.suffix
- Append this suffix to the file.protected boolean isLoopback(SmcElement.TransType transType, java.lang.String endState)
true
if this transition is an
internal loopback or a push transition and
false
otherwise. If true, then do not perform the
the state exit and entry actions.transType
- the transition type.endState
- entering this state.true
if this transition is an internal
loopback or push transition and false
otherwise.protected boolean allNilEndStates(java.util.List<SmcGuard> guards)
true
if each of the transition guards uses
the nil end state.guards
- check if all this transitions use the nil
end state.true
if each of the transition guards uses
the nil end state.public void setSource(java.io.PrintStream source)
source
- the generated source code output stream.public static java.lang.String escape(java.lang.String s)
s
- Escape this string.protected java.lang.String scopeStateName(java.lang.String stateName, java.lang.String mapName)
stateName
- an absolute or relative state name.mapName
- the current map.protected java.lang.String scopeStateName(java.lang.String stateName, java.lang.String mapName, java.lang.String ifs)
ifs
.stateName
- an absolute or relative state name.mapName
- the current map.ifs
- the map name, state name separator.protected java.lang.String findPath(java.lang.String srcDir, java.lang.String headerDir)
srdDir
to
directory headerDir
. This method assumes that the
two directories are different.srcDir
- the source file directory.headerDir
- the header file directory.srcDir
to
headerDir
.Copyright © 2015. Charles W. Rapp. All Rights Reserved. Use is subject to license terms.