diff --git a/tpl/bhl_bind_macro.twig b/tpl/bhl_bind_macro.twig index 0069390..e7cf98c 100644 --- a/tpl/bhl_bind_macro.twig +++ b/tpl/bhl_bind_macro.twig @@ -367,8 +367,8 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack {{arg_prefix}}{{arg.name}} = default; {% else %} { - if({{arg_prefix}}{{arg.name}} is IDisposable dsp) - dsp.Dispose(); + if({{arg_prefix}}{{arg.name}} is IValRefcounted rfc) + rfc.Release(); {{arg_prefix}}{{arg.name}} = default; } {% endif %} @@ -427,14 +427,11 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack {# any special case #} {%- if type == 'any' -%} {{native}} = {{value}} - {# bhl functor special case #} - {%- elseif type == "ConfScript" -%} - {{native}}.fct.obj = {{value}}._obj {%- else -%} - {%- if type is instanceof('\\mtgMetaFunc') -%} + {%~ if type is instanceof('\\mtgMetaFunc') -%} {{native}} = (VM.FuncPtr){{value}}._obj; - {{native}}.Retain() + {{native}}.Retain(); {%- endif -%} {%- if type is instanceof('\\mtgArrType') -%} @@ -444,23 +441,21 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack {%~ if type == 'any[]'-%} {{native}} = (ValList){{value}}._obj; - {{native}}.Retain() {%~ else ~%} if({{value}}._obj is ValList vl) { - vl.Retain(); {{native}} = ValList<{{type.value|native_type}}>.New(vl, ((NativeListTypeSymbol<{{type.value|native_type}}>)Types_List_{{type.value|norm_name}}.Value).Val2Native); } - else if({{value}}._obj != null) - {{native}} = (IList<{{type.value|native_type}}>){{value}}._obj; else - throw new Exception("Null value"); + {{native}} = (IList<{{type.value|native_type}}>){{value}}._obj; {%~ endif -%} + {{value}}._refc?.Retain(); + {%- else -%} var _src_arr_type = (ArrayTypeSymbol){{value}}.type; @@ -533,9 +528,6 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack {# any special case #} {%- if type == 'any' -%} {{value}}.SetObj({{native}}, Types.Any) - {# bhl functor special case #} - {%- elseif type == "ConfScript" -%} - {{value}}.obj = {{native}}.fct.obj {%- else -%} {%- if type is instanceof('\\mtgMetaFunc') -%}