diff --git a/tpl/codegen_autobind.twig b/tpl/codegen_autobind.twig index 472fa60..cef4fb3 100644 --- a/tpl/codegen_autobind.twig +++ b/tpl/codegen_autobind.twig @@ -14,20 +14,27 @@ using {{imp}}; namespace bhl { +{%- for u in meta.units ~%} + {%- if u.object is instanceof('\\mtgMetaStruct') ~%} +static public class Types_{{u.object.name|norm_name}} { + static public IType Value; +} + {%- endif ~%} +{%- endfor ~%} + {% block declare %} #if !BHL_FRONT {{ macro.decl_units(meta.units) }} #endif {% endblock %} -static public class BHL_AutoBindings { +static public class {{register_class}} { public static void Register(Types types) { {% block register %} {{ macro.call_reg_units(slice_units(meta.units, 20)) }} - BHL_Types.Type_GenericArray = Types.Array; {{ macro.assign_global_types(meta.units) }} {% endblock %} } diff --git a/tpl/codegen_types.twig b/tpl/codegen_types.twig deleted file mode 100644 index eee4b88..0000000 --- a/tpl/codegen_types.twig +++ /dev/null @@ -1,16 +0,0 @@ -namespace bhl { - -static public class BHL_Types -{ - static public IType Type_GenericArray; - -{%- for u in meta.units ~%} - {%- if u.object is instanceof('\\mtgMetaStruct') ~%} - static public IType Type_{{u.object.name|norm_name}}; - {%- endif ~%} -{%- endfor ~%} - -} - - -} //namespace bhl diff --git a/tpl/macro.twig b/tpl/macro.twig index 60b654b..11bed7e 100644 --- a/tpl/macro.twig +++ b/tpl/macro.twig @@ -461,7 +461,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack {{_self.native2val(type.value, 'tmp', 'tdv')}}; dvl.lst.Add(tdv); } - {{value}}.SetObj(dvl, BHL_Types.Type_GenericArray); + {{value}}.SetObj(dvl, Types.Array); {%- endif -%} {%- if type is instanceof('\\mtgBuiltinType') -%} @@ -493,7 +493,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack {%- if has_token(type, 'bhl_custom_rw') -%} {{value}}.Encode({{native}}) {%- else -%} - {{value}}.SetObj({{native}}, BHL_Types.Type_{{type.name|norm_name}}) + {{value}}.SetObj({{native}}, Types_{{type.name|norm_name}}.Value) {%- endif -%} {%- endif -%} {%- endif -%} @@ -1046,7 +1046,7 @@ public partial class Script_{{u.object.name}} { throw new System.Exception("Type '{{u.object.name}}' not resolved"); if(tmp is ClassSymbol cs) cs.Setup(); - BHL_Types.Type_{{u.object.name|norm_name}} = tmp; + Types_{{u.object.name|norm_name}}.Value = tmp; } {%~ endif ~%} {%- endif -%}