From 4be8ded04662cdcbd094dcbb2392c9de3eedc41d Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Tue, 23 May 2023 15:57:36 +0300 Subject: [PATCH] Better support for interface callbacks --- tpl/macro.twig | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tpl/macro.twig b/tpl/macro.twig index 0b7f009..6c18610 100644 --- a/tpl/macro.twig +++ b/tpl/macro.twig @@ -1,6 +1,16 @@ {%- macro reg_func_native(o, scope = 'types.ns', this_prefix = '') ~%} { - var fn = new FuncSymbolNative(new Origin(), "{{o.name|ns_last}}", + var fn = + {{ _self.func_native(o, this_prefix) }} + ; + + {{scope}}.{{o.name|ns_prefix}}Define(fn); + } +{%- endmacro -%} + +{%- macro func_native(o, this_prefix = '') ~%} + + new FuncSymbolNative(new Origin(), "{{o.name|ns_last}}", {%- if has_token(o, 'bhl_coroutine') -%} FuncAttrib.Coro, @@ -38,10 +48,7 @@ {% if o.args %},{% endif %} {{ _self.func_decl_args(o) }} - ); - - {{scope}}.{{o.name|ns_prefix}}Define(fn); - } + ) {%- endmacro -%} {%- macro reg_func_partial(o, scope = 'types.ns') ~%} @@ -698,8 +705,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack var ifs = new InterfaceSymbolNative(new Origin(), "{{o.name|ns_last}}", null {% for m in o.getfuncs %} - , new FuncSymbolNative(new Origin(), "{{m.name}}", {{m.returntype|bhl_type_ref}}, 0, null) - + , {{ _self.func_native(m, '(('~o.name~')stack.PopRelease()._obj).') }} {% endfor %} );