Fixing bhl_native_prefix codegen for bhl_custom_rw

This commit is contained in:
Pavel Shevaev 2023-08-08 19:38:46 +03:00
parent 12e4ca03e2
commit 30d7ef8fbe
1 changed files with 12 additions and 8 deletions

View File

@ -1,14 +1,14 @@
{%- macro reg_func_native(o, scope = 'types.ns', this_prefix = '') ~%}
{%- macro reg_func_native(o, scope = 'types.ns', this_prefix = '', this_type = null) ~%}
{
var fn =
{{ _self.func_native(o, this_prefix) }}
{{ _self.func_native(o, this_prefix, this_type) }}
;
{{scope}}.{{o.name|ns_prefix}}Define(fn);
}
{%- endmacro -%}
{%- macro func_native(o, this_prefix = '') ~%}
{%- macro func_native(o, this_prefix = '', this_type = null) ~%}
new FuncSymbolNative(new Origin(), "{{o.name|ns_last}}",
@ -23,7 +23,7 @@
#if !BHL_FRONT
delegate(VM.Frame frm, ValStack stack, FuncArgsInfo args_info, ref BHS status) {
{{ _self.read_args2natives(o, '__') }}
{{ _self.read_args2natives(o, '__', this_type) }}
{%~ if o.returntype %}
var return_val =
@ -286,7 +286,11 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack
{% endif %}
{%- endmacro -%}
{%- macro local_native_vars(vars, prefix) -%}
{%- macro local_native_vars(vars, prefix, this_type) -%}
{%- if this_type ~%}
{{this_type|native_type}} {{prefix}}self = default;
{%- endif -%}
{%- for v in vars -%}
{%- if has_token(v, 'bhl_ref_arg') -%}
bhl.Val {{prefix}}{{v.name}} = default;
@ -300,7 +304,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack
{%- macro read_args2natives(o, arg_prefix, this_type = null, declare_locals = true) -%}
{%- if declare_locals -%}
{{ _self.local_native_vars(o.args, arg_prefix) }}
{{ _self.local_native_vars(o.args, arg_prefix, this_type) }}
{%- endif -%}
{# traversing args in reverse order #}
@ -624,7 +628,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack
{% for m in o.getfuncs %}
{% if has_token(m, 'bhl_native_prefix') %}
{{ _self.reg_func_native(m, 'cl', '(('~token_or(o, 'bhl_native_class', o.name)~')stack.PopRelease()._obj).') }}
{{ _self.reg_func_native(m, 'cl', '__self.', o) }}
{% else %}
{{ _self.method_partial(o, m, 'cl') }}
{% endif %}
@ -705,7 +709,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 %}
, {{ _self.func_native(m, '(('~token_or(o, 'bhl_native_class', o.name)~')stack.PopRelease()._obj).') }}
, {{ _self.func_native(m, '__self.', o) }}
{% endfor %}
);