diff options
| author | jacob1 <jfu614@gmail.com> | 2013-05-17 00:04:39 (GMT) |
|---|---|---|
| committer | jacob1 <jfu614@gmail.com> | 2013-05-17 00:04:39 (GMT) |
| commit | 7b6ded50dca6df5dfe2b22eb47de966e02878284 (patch) | |
| tree | 1606c21a619b3da1cd21d08471f2a713660104ad /generator.py | |
| parent | fd97e923f3f8409346723a9924761c9e21bb79d3 (diff) | |
| download | powder-7b6ded50dca6df5dfe2b22eb47de966e02878284.zip powder-7b6ded50dca6df5dfe2b22eb47de966e02878284.tar.gz | |
rename GRAV back to PGRV, fix formatting in generator, remove useless file
Diffstat (limited to 'generator.py')
| -rw-r--r-- | generator.py | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/generator.py b/generator.py index 952b6fa..30a4c23 100644 --- a/generator.py +++ b/generator.py @@ -92,13 +92,13 @@ public: virtual ~{0}(); {2} }}; - """.format(className, elementBase, string.join(classMembers, "\n\t")) +""".format(className, elementBase, string.join(classMembers, "\n\t")) elementHeader += """ std::vector<Element> GetElements(); #endif - """ +""" elementContent = """#include "ElementClasses.h" @@ -122,7 +122,7 @@ std::vector<Element> GetElements() elementContent += """return elements; } - """; +"""; outputPath, outputFile = os.path.split(outputH) if not os.path.exists(outputPath): @@ -140,11 +140,13 @@ def generateTools(toolFiles, outputCpp, outputH): toolClasses = {} toolHeader = """#ifndef TOOLCLASSES_H - #define TOOLCLASSES_H - #include <vector> - #include "simulation/Tools.h" - #include "simulation/tools/SimTool.h" - """ +#define TOOLCLASSES_H + +#include <vector> + +#include "simulation/tools/SimTool.h" + +""" directives = [] @@ -176,34 +178,36 @@ def generateTools(toolFiles, outputCpp, outputH): toolClasses[d[1]].append(string.join(d[2:], " ")+";") for className, classMembers in toolClasses.items(): - toolHeader += """class {0}: public SimTool - {{ - public: - {0}(); - virtual ~{0}(); - virtual int Perform(Simulation * sim, Particle * cpart, int x, int y, float strength); - {1} - }}; - """.format(className, string.join(classMembers, "\n")) + toolHeader += """ +class {0}: public SimTool +{{ +public: + {0}(); + virtual ~{0}(); + virtual int Perform(Simulation * sim, Particle * cpart, int x, int y, float strength); +}}; +""".format(className, string.join(classMembers, "\n")) - toolHeader += """std::vector<SimTool*> GetTools(); - #endif - """ + toolHeader += """ +std::vector<SimTool*> GetTools(); + +#endif +""" toolContent = """#include "ToolClasses.h" - std::vector<SimTool*> GetTools() - { - std::vector<SimTool*> tools; - """; +std::vector<SimTool*> GetTools() +{ + std::vector<SimTool*> tools; +"""; toolIDs = sorted(classDirectives, key=lambda directive: directive[3]) for d in toolIDs: toolContent += """ tools.push_back(new %s()); - """ % (d[1]) +""" % (d[1]) toolContent += """ return tools; - } - """; +} +"""; outputPath, outputFile = os.path.split(outputH) if not os.path.exists(outputPath): |
