summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2018-01-01 07:01:10 +0100
committerDave Andreoli <dave@gurumeditation.it>2018-01-01 08:37:13 +0100
commit77fba4119b194eba5fb7b242fdeb4cf68e02959e (patch)
treec39ec23ddc06d0f5b19a5a27f94067db20a5f44a
parentb5e3853e9dc4f755072e3e8d20c7c84d30104ad1 (diff)
Pyolian generator: also make the classes visible in the template ctx
-rwxr-xr-xsrc/scripts/pyolian/generator.py31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/scripts/pyolian/generator.py b/src/scripts/pyolian/generator.py
index 5fad2484a5..84290b6bef 100755
--- a/src/scripts/pyolian/generator.py
+++ b/src/scripts/pyolian/generator.py
@@ -50,13 +50,6 @@ except ImportError:
50 import pyratemp 50 import pyratemp
51 51
52 52
53# logging utils
54be_verbose = True
55def ERR(*args): print(*(('PYOLIANGEN ERROR:', ) + args))
56def WRN(*args): print(*(('PYOLIANGEN WARNING:', ) + args))
57def INF(*args): print(*(('PYOLIANGEN ', ) + args))
58
59
60# Use .eo files from the source tree (not the installed ones) 53# Use .eo files from the source tree (not the installed ones)
61script_path = os.path.dirname(os.path.realpath(__file__)) 54script_path = os.path.dirname(os.path.realpath(__file__))
62root_path = os.path.abspath(os.path.join(script_path, '..', '..', '..')) 55root_path = os.path.abspath(os.path.join(script_path, '..', '..', '..'))
@@ -118,6 +111,22 @@ class Template(pyratemp.Template):
118 # Eolian info 111 # Eolian info
119 # 'eolian_version': eolian.__version__, 112 # 'eolian_version': eolian.__version__,
120 # 'eolian_version_info': eolian.__version_info__, 113 # 'eolian_version_info': eolian.__version_info__,
114 # Eolian Classes
115 'Class': eolian.Class,
116 'Part': eolian.Part,
117 'Constructor': eolian.Constructor,
118 'Event': eolian.Event,
119 'Function': eolian.Function,
120 'Function_Parameter': eolian.Function_Parameter,
121 'Implement': eolian.Implement,
122 'Type': eolian.Type,
123 'Typedecl': eolian.Typedecl,
124 'Enum_Type_Field': eolian.Enum_Type_Field,
125 'Struct_Type_Field': eolian.Struct_Type_Field,
126 'Expression': eolian.Expression,
127 'Variable': eolian.Variable,
128 'Declaration': eolian.Declaration,
129 'Documentation': eolian.Documentation,
121 # Eolian Enums 130 # Eolian Enums
122 'Eolian_Function_Type': eolian.Eolian_Function_Type, 131 'Eolian_Function_Type': eolian.Eolian_Function_Type,
123 'Eolian_Parameter_Dir': eolian.Eolian_Parameter_Dir, 132 'Eolian_Parameter_Dir': eolian.Eolian_Parameter_Dir,
@@ -146,7 +155,7 @@ class Template(pyratemp.Template):
146 renderer_class=renderer_class, 155 renderer_class=renderer_class,
147 eval_class=eval_class) 156 eval_class=eval_class)
148 157
149 def render(self, filename=None, cls=None, ns=None, 158 def render(self, filename=None, verbose=True, cls=None, ns=None,
150 struct=None, enum=None, alias=None, **kargs): 159 struct=None, enum=None, alias=None, **kargs):
151 # Build the context for the template 160 # Build the context for the template
152 ctx = {} 161 ctx = {}
@@ -172,9 +181,9 @@ class Template(pyratemp.Template):
172 ctx['enums'] = [ e for e in eolian_db.typedecl_all_enums 181 ctx['enums'] = [ e for e in eolian_db.typedecl_all_enums
173 if e.full_name.startswith(ns + '.') ] 182 if e.full_name.startswith(ns + '.') ]
174 183
175 if filename is not None: 184 if verbose and filename:
176 INF('generating "%s" from template "%s"' % ( 185 print('generating "{}" from template "{}"'.format(
177 filename, self.template_filename)) 186 filename, self.template_filename))
178 187
179 # render with the augmented context 188 # render with the augmented context
180 output = self(**ctx) 189 output = self(**ctx)