mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 06:00:51 +00:00
Parametrize code generation actions from the command line
This commit is contained in:
@@ -2,10 +2,11 @@ This folder contains Python code to generate C++ type information based on an
|
|||||||
Express schema. In particular is has only been tested using recent version of
|
Express schema. In particular is has only been tested using recent version of
|
||||||
the IFC schema and will most likely fail on any other Express schema.
|
the IFC schema and will most likely fail on any other Express schema.
|
||||||
|
|
||||||
The code can be invoked in the following way and results in two header files
|
The code can be invoked in the following way and results in several code outputs
|
||||||
and a single implementation file named according to the schema name in the
|
named according to the schema name in the Express file. A python 3 interpreter
|
||||||
Express file. A python 3 interpreter with the pyparsing [1] library is required.
|
with the pyparsing [1] library is required.
|
||||||
|
|
||||||
$ python bootstrap.py express.bnf > express_parser.py && python express_parser.py IFC2X3_TC1.exp
|
$ python bootstrap.py express.bnf > express_parser.py
|
||||||
|
$ python express_parser.py IFC2X3_TC1.exp header implementation schema_class definitions
|
||||||
|
|
||||||
[1] http://pyparsing.wikispaces.com/Download+and+Installation
|
[1] http://pyparsing.wikispaces.com/Download+and+Installation
|
||||||
|
|||||||
@@ -198,15 +198,10 @@ else:
|
|||||||
with open(cache_file, "wb") as f:
|
with open(cache_file, "wb") as f:
|
||||||
pickle.dump(mapping, f, protocol=0)
|
pickle.dump(mapping, f, protocol=0)
|
||||||
|
|
||||||
import header
|
import importlib
|
||||||
import implementation
|
for output in sys.argv[2:]:
|
||||||
import schema_class
|
mdl = importlib.import_module(output)
|
||||||
import definitions
|
mdl.Generator(mapping).emit()
|
||||||
|
|
||||||
header.Header(mapping).emit()
|
|
||||||
implementation.Implementation(mapping).emit()
|
|
||||||
schema_class.SchemaClass(mapping).emit()
|
|
||||||
definitions.Definitions(mapping).emit()
|
|
||||||
|
|
||||||
sys.stdout.write(schema.name)
|
sys.stdout.write(schema.name)
|
||||||
"""%('\n '.join(statements)))
|
"""%('\n '.join(statements)))
|
||||||
|
|||||||
@@ -64,3 +64,5 @@ class Definitions(codegen.Base):
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return self.str
|
return self.str
|
||||||
|
|
||||||
|
Generator = Definitions
|
||||||
|
|||||||
@@ -145,3 +145,5 @@ class Header(codegen.Base):
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return self.str
|
return self.str
|
||||||
|
|
||||||
|
Generator = Header
|
||||||
|
|||||||
@@ -257,3 +257,6 @@ class Implementation(codegen.Base):
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return self.str
|
return self.str
|
||||||
|
|
||||||
|
|
||||||
|
Generator = Implementation
|
||||||
|
|||||||
Reference in New Issue
Block a user