From d8c72c3e998888fafeba80db7e005e3be51a9c5d Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Fri, 15 Nov 2024 16:17:13 +0300 Subject: [PATCH] Adding Release() codegen for func ptrs for passed args disposing --- tpl/bhl_bind_macro.twig | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 ~%}