Pyolian generator: also make the classes visible in the template ctx
This commit is contained in:
parent
b5e3853e9d
commit
77fba4119b
|
@ -50,13 +50,6 @@ except ImportError:
|
||||||
import pyratemp
|
import pyratemp
|
||||||
|
|
||||||
|
|
||||||
# logging utils
|
|
||||||
be_verbose = True
|
|
||||||
def ERR(*args): print(*(('PYOLIANGEN ERROR:', ) + args))
|
|
||||||
def WRN(*args): print(*(('PYOLIANGEN WARNING:', ) + args))
|
|
||||||
def INF(*args): print(*(('PYOLIANGEN ', ) + args))
|
|
||||||
|
|
||||||
|
|
||||||
# Use .eo files from the source tree (not the installed ones)
|
# Use .eo files from the source tree (not the installed ones)
|
||||||
script_path = os.path.dirname(os.path.realpath(__file__))
|
script_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
root_path = os.path.abspath(os.path.join(script_path, '..', '..', '..'))
|
root_path = os.path.abspath(os.path.join(script_path, '..', '..', '..'))
|
||||||
|
@ -118,6 +111,22 @@ class Template(pyratemp.Template):
|
||||||
# Eolian info
|
# Eolian info
|
||||||
# 'eolian_version': eolian.__version__,
|
# 'eolian_version': eolian.__version__,
|
||||||
# 'eolian_version_info': eolian.__version_info__,
|
# 'eolian_version_info': eolian.__version_info__,
|
||||||
|
# Eolian Classes
|
||||||
|
'Class': eolian.Class,
|
||||||
|
'Part': eolian.Part,
|
||||||
|
'Constructor': eolian.Constructor,
|
||||||
|
'Event': eolian.Event,
|
||||||
|
'Function': eolian.Function,
|
||||||
|
'Function_Parameter': eolian.Function_Parameter,
|
||||||
|
'Implement': eolian.Implement,
|
||||||
|
'Type': eolian.Type,
|
||||||
|
'Typedecl': eolian.Typedecl,
|
||||||
|
'Enum_Type_Field': eolian.Enum_Type_Field,
|
||||||
|
'Struct_Type_Field': eolian.Struct_Type_Field,
|
||||||
|
'Expression': eolian.Expression,
|
||||||
|
'Variable': eolian.Variable,
|
||||||
|
'Declaration': eolian.Declaration,
|
||||||
|
'Documentation': eolian.Documentation,
|
||||||
# Eolian Enums
|
# Eolian Enums
|
||||||
'Eolian_Function_Type': eolian.Eolian_Function_Type,
|
'Eolian_Function_Type': eolian.Eolian_Function_Type,
|
||||||
'Eolian_Parameter_Dir': eolian.Eolian_Parameter_Dir,
|
'Eolian_Parameter_Dir': eolian.Eolian_Parameter_Dir,
|
||||||
|
@ -146,7 +155,7 @@ class Template(pyratemp.Template):
|
||||||
renderer_class=renderer_class,
|
renderer_class=renderer_class,
|
||||||
eval_class=eval_class)
|
eval_class=eval_class)
|
||||||
|
|
||||||
def render(self, filename=None, cls=None, ns=None,
|
def render(self, filename=None, verbose=True, cls=None, ns=None,
|
||||||
struct=None, enum=None, alias=None, **kargs):
|
struct=None, enum=None, alias=None, **kargs):
|
||||||
# Build the context for the template
|
# Build the context for the template
|
||||||
ctx = {}
|
ctx = {}
|
||||||
|
@ -172,9 +181,9 @@ class Template(pyratemp.Template):
|
||||||
ctx['enums'] = [ e for e in eolian_db.typedecl_all_enums
|
ctx['enums'] = [ e for e in eolian_db.typedecl_all_enums
|
||||||
if e.full_name.startswith(ns + '.') ]
|
if e.full_name.startswith(ns + '.') ]
|
||||||
|
|
||||||
if filename is not None:
|
if verbose and filename:
|
||||||
INF('generating "%s" from template "%s"' % (
|
print('generating "{}" from template "{}"'.format(
|
||||||
filename, self.template_filename))
|
filename, self.template_filename))
|
||||||
|
|
||||||
# render with the augmented context
|
# render with the augmented context
|
||||||
output = self(**ctx)
|
output = self(**ctx)
|
||||||
|
|
Loading…
Reference in New Issue