diff --git a/tpl/bhl_bind_macro.twig b/tpl/bhl_bind_macro.twig index 2e8e87b..0069390 100644 --- a/tpl/bhl_bind_macro.twig +++ b/tpl/bhl_bind_macro.twig @@ -379,6 +379,10 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack {{arg_prefix}}{{arg.name}} = default; {% endif %} + {%- if arg.type is instanceof('\\mtgMetaFunc') -%} + {{arg_prefix}}{{arg.name}}?.Release(); + {{arg_prefix}}{{arg.name}} = default; + {% endif %} {%- endfor ~%} {%- endmacro -%} @@ -425,11 +429,12 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack {{native}} = {{value}} {# bhl functor special case #} {%- elseif type == "ConfScript" -%} - {{native}}.fct.obj = {{value}}.obj + {{native}}.fct.obj = {{value}}._obj {%- else -%} {%- if type is instanceof('\\mtgMetaFunc') -%} - {{native}} = (VM.FuncPtr){{value}}.obj;{{native}}.Retain() + {{native}} = (VM.FuncPtr){{value}}._obj; + {{native}}.Retain() {%- endif -%} {%- if type is instanceof('\\mtgArrType') -%} @@ -439,7 +444,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack {%~ if type == 'any[]'-%} {{native}} = (ValList){{value}}._obj; - {{native}}.Retain(); + {{native}}.Retain() {%~ else ~%}