Class PythonGenerator
java.lang.Object
edu.nps.moves.dis7.source.generator.pdus.Generator
edu.nps.moves.dis7.source.generator.pdus.PythonGenerator
Constructor, not fully implemented.
- Author:
- DMcG
-
Field Summary
FieldsModifier and TypeFieldDescriptionStandard python indent is four spacesProperties of interestProperties of interestFields inherited from class edu.nps.moves.dis7.source.generator.pdus.Generator
classDescriptions, directory, languageProperties
-
Constructor Summary
ConstructorsConstructorDescriptionPythonGenerator(Map<String,GeneratedClass> pClassDescriptions, Properties pythonProperties)
Given the input object, something of an abstract syntax tree, this generates a source code file in the Python language.It has ivars, getters, setters, and serialization/deserialization methods.Warning: only partially implemented. -
Method Summary
Modifier and TypeMethodDescriptionPython doesn't like forward-declaring classes, so a subclass must be declared after its superclass.This reorders the list of classes so that this is the case.void
writeClass(PrintWriter printWriter, GeneratedClass aClass)
Create custom outputvoid
writeClassComments(PrintWriter printWriter, GeneratedClass aClass)
Create custom outputvoid
Overridden by the subclasses to generate the code specific to that language.void
writeFlagMethods(PrintWriter pw, GeneratedClass aClass)
Some fields have integers with bit fields defined, eg an integer where bits 0-2 represent some value, while bits 3-4 represent another value, and so on.void
writeLicense(PrintWriter printWriter)
Create outputvoid
writeMarshal(PrintWriter pw, GeneratedClass aClass)
The method that writes out the python marshalling codevoid
writeUnmarshal(PrintWriter printWriter, GeneratedClass aClass)
Create custom methodMethods inherited from class edu.nps.moves.dis7.source.generator.pdus.Generator
createDirectory, getBitsToShift, getDirectory, initialCap, initialLower, setDirectory
-
Field Details
-
INDENT
Standard python indent is four spaces -
marshalTypes
Properties of interest -
unmarshalTypes
Properties of interest
-
-
Constructor Details
-
PythonGenerator
public PythonGenerator(Map<String,GeneratedClass> pClassDescriptions, Properties pythonProperties)Given the input object, something of an abstract syntax tree, this generates a source code file in the Python language.It has ivars, getters, setters, and serialization/deserialization methods.Warning: only partially implemented.- Parameters:
pClassDescriptions
- String Map of class descriptionspythonProperties
- special language properties
-
-
Method Details
-
writeClasses
public void writeClasses()Description copied from class:Generator
Overridden by the subclasses to generate the code specific to that language.- Specified by:
writeClasses
in classGenerator
-
writeClass
Create custom output- Parameters:
printWriter
- outputaClass
- class of interest
-
writeMarshal
The method that writes out the python marshalling code- Parameters:
pw
- PrintWriteraClass
- of interest
-
writeUnmarshal
Create custom method- Parameters:
printWriter
- outputaClass
- class of interest
-
writeClassComments
Create custom output- Parameters:
printWriter
- outputaClass
- class of interest
-
writeFlagMethods
Some fields have integers with bit fields defined, eg an integer where bits 0-2 represent some value, while bits 3-4 represent another value, and so on. This writes accessor and mutator methods for those fields.- Parameters:
pw
- PrintWriteraClass
- of interest
-
writeLicense
Create output- Parameters:
printWriter
- output
-
sortClasses
Python doesn't like forward-declaring classes, so a subclass must be declared after its superclass.This reorders the list of classes so that this is the case. This re-creates the semantic class inheritance tree structure, then traverses the tree in preorder fashion to ensure that a base class is written before a subclass. The implementation is a little wonky in places.- Returns:
- sorted List of classes
-