diff --git a/tpl/bhl_bind_macro.twig b/tpl/bhl_bind_macro.twig index 3a1d016..427446d 100644 --- a/tpl/bhl_bind_macro.twig +++ b/tpl/bhl_bind_macro.twig @@ -1,18 +1,18 @@ -{%- macro reg_func_native(o, scope = 'types.ns', this_prefix = '', this_type = null, fname = null) ~%} +{%- macro reg_func_native(o, local_fn_name, scope = 'types.ns', this_prefix = '', this_type = null, fname = null) ~%} { - {{ _self.func_native_local_fn(o, o.name|ns_last, this_prefix, this_type) }} + {{ _self.func_native_local_fn(o, local_fn_name, this_prefix, this_type) }} var fn = - {{ _self.func_native(o, fname ? fname|trim('"') : o.name|ns_last, this_prefix, this_type) }} + {{ _self.func_native(o, local_fn_name, fname ? fname|trim('"') : o.name|ns_last, this_prefix, this_type) }} ; {{scope}}.{{o.name|ns_prefix}}Define(fn); } {%- endmacro -%} -{%- macro func_native_local_fn(o, fname, this_prefix = '', this_type = null) ~%} +{%- macro func_native_local_fn(o, local_fn_name, this_prefix = '', this_type = null) ~%} #if !BHL_FRONT - static bhl.Coroutine fn_{{fname|trim('"')}}(VM.Frame frm, ValStack stack, FuncArgsInfo args_info, ref BHS status) { + static bhl.Coroutine {{local_fn_name}}(VM.Frame frm, ValStack stack, FuncArgsInfo args_info, ref BHS status) { {{ _self.read_args2natives(o, '__', this_type) }} @@ -38,7 +38,7 @@ #endif {%- endmacro -%} -{%- macro func_native(o, fname, this_prefix = '', this_type = null) ~%} +{%- macro func_native(o, local_fn_name, fname, this_prefix = '', this_type = null) ~%} new FuncSymbolNative(new Origin(), "{{fname|trim('"')}}", @@ -57,7 +57,7 @@ {{ count_default_args(o) }}, #if !BHL_FRONT - fn_{{o.name|ns_last}} + {{local_fn_name}} #else null #endif @@ -70,7 +70,7 @@ {%- macro reg_func_partial(o, scope = 'types.ns') ~%} { #if !BHL_FRONT - static bhl.Coroutine fn_{{o.name|ns_last}}(VM.Frame frm, ValStack stack, FuncArgsInfo args_info, ref BHS status) { + static bhl.Coroutine fn_{{o.name|norm_name}}(VM.Frame frm, ValStack stack, FuncArgsInfo args_info, ref BHS status) { {% if has_token(o, 'bhl_coroutine') -%} var coro = CoroutinePool.New(frm.vm); coro.Init(frm, stack, args_info); @@ -96,7 +96,7 @@ {{o.returntype|bhl_type_ref}}, {{ count_default_args(o) }}, #if !BHL_FRONT - fn_{{o.name|ns_last}} + fn_{{o.name|norm_name}} #else null #endif @@ -167,7 +167,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack { #if !BHL_FRONT - static bhl.Coroutine m_{{m.name|norm_name}}(VM.Frame frm, ValStack stack, FuncArgsInfo args_info, ref BHS status) { + static bhl.Coroutine m_{{o.name|norm_name}}_{{m.name}}(VM.Frame frm, ValStack stack, FuncArgsInfo args_info, ref BHS status) { {% if has_token(m, 'bhl_coroutine') -%} var coro = CoroutinePool.New(frm.vm); coro.Init(frm, stack, args_info); @@ -193,7 +193,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack {{ m.returntype|bhl_type_ref }}, {{ count_default_args(m) }}, #if !BHL_FRONT - m_{{m.name|norm_name}} + m_{{o.name|norm_name}}_{{m.name}} #else null #endif @@ -207,7 +207,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack {% if has_token(m, 'bhl_bin_op') ~%} { #if !BHL_FRONT - static bhl.Coroutine m_{{m.name|ns_last}}(VM.Frame frm, ValStack stack, FuncArgsInfo args_info, ref BHS status) { + static bhl.Coroutine m_{{o.name|norm_name}}_{{m.name}}(VM.Frame frm, ValStack stack, FuncArgsInfo args_info, ref BHS status) { var args = Script_{{o.name|norm_name}}.Method_{{m.name}}.ReadArgs(frm, stack, args_info); Script_{{o.name|norm_name}}.Method_{{m.name}}.Exec(frm, args {{_self.out_results(m)}}); @@ -223,7 +223,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack {{ m.returntype|bhl_type_ref }}, {{ count_default_args(m) }}, #if !BHL_FRONT - m_{{m.name|ns_last}} + m_{{o.name|norm_name}}_{{m.name}} #else null #endif @@ -675,7 +675,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack { {% if not has_token(o, 'bhl_no_new') ~%} - static void ctor_{{o.name|ns_last}}(VM.Frame frm, ref Val v, IType type) { + static void ctor_{{o.name|norm_name}}(VM.Frame frm, ref Val v, IType type) { #if !BHL_FRONT var o = new {{token_or(o, 'bhl_native_class', o.name)}}({{token_or(o, 'bhl_native_class_params', '')}}); @@ -710,7 +710,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack //constructor is not allowed creator: null {% else ~%} - creator: ctor_{{o.name|ns_last}} + creator: ctor_{{o.name|norm_name}} {% endif ~%} #if !BHL_FRONT , native_type: typeof({{token_or(o, 'bhl_native_class', o.name)}}) @@ -736,12 +736,12 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack {% for m in o.getfuncs %} {% if has_token(m, 'bhl_native_prefix') %} {% if has_token(m, 'bhl_static') %} - {{ _self.reg_func_native(m, 'cl', '') }} + {{ _self.reg_func_native(m, o.name|norm_name ~ '_' ~ m.name, 'cl', '') }} {% else %} - {{ _self.reg_func_native(m, 'cl', '__self.', o) }} + {{ _self.reg_func_native(m, o.name|norm_name ~ '_' ~ m.name, 'cl', '__self.', o) }} {% endif %} {% if has_token(m, 'bhl_bin_op') %} - {{ _self.reg_func_native(m, 'cl', '', null, token(m, 'bhl_bin_op')) }} + {{ _self.reg_func_native(m, o.name|norm_name ~ '_' ~ m.name, 'cl', '', null, token(m, 'bhl_bin_op')) }} {% endif %} {% else %} {{ _self.method_partial(o, m, 'cl') }} @@ -758,7 +758,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack { {% if token_or(f, 'bhl_get', 1) != 0 ~%} - static void get_{{f.name}}(VM.Frame frm, Val ctx, ref Val v, FieldSymbol fld) { + static void get_{{o.name|norm_name}}_{{f.name}}(VM.Frame frm, Val ctx, ref Val v, FieldSymbol fld) { #if !BHL_FRONT {%~ if has_token(o, 'bhl_custom_rw') ~%} {{class}} f = new {{class}}(); @@ -782,7 +782,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack {%- endif ~%} {% if token_or(f, 'bhl_set', 1) != 0 ~%} - static void set_{{f.name}}(VM.Frame frm, ref Val ctx, Val v, FieldSymbol fld) { + static void set_{{o.name|norm_name}}_{{f.name}}(VM.Frame frm, ref Val ctx, Val v, FieldSymbol fld) { #if !BHL_FRONT {%~ if has_token(o, 'bhl_custom_rw') ~%} {{class}} f = new {{class}}(); @@ -814,7 +814,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack cl.Define(new FieldSymbol(new Origin(), "{{f.name}}", {{f.type|bhl_type_ref}}, {% if token_or(f, 'bhl_get', 1) != 0 ~%} //getter - get_{{f.name}} + get_{{o.name|norm_name}}_{{f.name}} {%- else ~%} //getter not allowed null @@ -822,7 +822,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack , {% if token_or(f, 'bhl_set', 1) != 0 ~%} //setter - set_{{f.name}} + set_{{o.name|norm_name}}_{{f.name}} {%- else ~%} //setter not allowed null @@ -849,7 +849,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack #endif , funcs: new FuncSymbol[] { {% for m in o.getfuncs %} - {{ _self.func_native(m, m.name, '__self.', o) }}, + {{ _self.func_native(m, o.name|norm_name ~ '_' ~ m.name, m.name, '__self.', o) }}, {% endfor %} } ); @@ -927,7 +927,7 @@ public partial class Script_{{u.object.name}} { {%- if u.object is instanceof('\\mtgMetaFunc') -%} {%- if has_token(u.object, 'bhl_native_prefix') -%} - {{ _self.reg_func_native(u.object) }} + {{ _self.reg_func_native(u.object, 'fn_' ~ u.object.name|norm_name) }} {%- else -%} {{ _self.reg_func_partial(u.object) }} {%- endif -%}