diff options
| author | jacob1 <jfu614@gmail.com> | 2013-05-17 16:44:25 (GMT) |
|---|---|---|
| committer | jacob1 <jfu614@gmail.com> | 2013-05-17 16:44:25 (GMT) |
| commit | 981f6984c2c0f87d54a9c90f4518c69c9ef02ae0 (patch) | |
| tree | 757bd699a23c1fad61e60700265a25feb1a3042c /generator.py | |
| parent | cbd402d8cb6aa699ffde83a1b5b3c2f4fc51baaf (diff) | |
| parent | 77bf649fb4482c86ac1fd9b3233f062b53226007 (diff) | |
| download | powder-981f6984c2c0f87d54a9c90f4518c69c9ef02ae0.zip powder-981f6984c2c0f87d54a9c90f4518c69c9ef02ae0.tar.gz | |
Merge branch 'HEAD' of git@github.com:FacialTurd/The-Powder-Toy.git
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): |
