diff --git a/tpl/codegen_autobind.twig b/tpl/codegen_autobind.twig index cef4fb3..8716bf7 100644 --- a/tpl/codegen_autobind.twig +++ b/tpl/codegen_autobind.twig @@ -15,28 +15,27 @@ using {{imp}}; namespace bhl { {%- for u in meta.units ~%} - {%- if u.object is instanceof('\\mtgMetaStruct') ~%} + {%- if u.object is instanceof('\\mtgMetaStruct') or u.object is instanceof('\\mtgMetaInterface') ~%} 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 {{register_class}} { public static void Register(Types types) { -{% block register %} - {{ macro.call_reg_units(slice_units(meta.units, 20)) }} +{{ macro.call_reg_units(slice_units(meta.units, 20)) }} +} - {{ macro.assign_global_types(meta.units) }} -{% endblock %} +public static void Setup(Types types) +{ +{{ macro.setup_global_types(meta.units) }} } {{ macro.decl_reg_units(slice_units(meta.units, 20)) }} diff --git a/tpl/macro.twig b/tpl/macro.twig index 94792f4..0b7f009 100644 --- a/tpl/macro.twig +++ b/tpl/macro.twig @@ -703,7 +703,6 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack {% endfor %} ); - ifs.Setup(); {{scope}}.{{o.name|ns_prefix}}Define(ifs); } @@ -1047,17 +1046,21 @@ public partial class Script_{{u.object.name}} { {%- endfor ~%} {%- endmacro -%} -{%- macro assign_global_types(units) ~%} +{%- macro setup_global_types(units) ~%} //assign global static types {%- for u in units -%} - {%- if u.object is instanceof('\\mtgMetaStruct') ~%} + {%- if u.object is instanceof('\\mtgMetaStruct') or u.object is instanceof('\\mtgMetaInterface') ~%} {%- if not has_token(u.object, 'bhl_ecs_component') ~%} { var tmp = types.T("{{u.object.name}}").Get(); if(tmp == null) throw new System.Exception("Type '{{u.object.name}}' not resolved"); - if(tmp is ClassSymbol cs) - cs.Setup(); + {%- if u.object is instanceof('\\mtgMetaStruct') ~%} + (tmp as ClassSymbolNative)?.Setup(); + {%- endif ~%} + {%- if u.object is instanceof('\\mtgMetaInterface') ~%} + (tmp as InterfaceSymbolNative)?.Setup(); + {%- endif ~%} Types_{{u.object.name|norm_name}}.Value = tmp; } {%~ endif ~%}