diff --git a/src/bind.inc.php b/src/bind.inc.php index c89d4d5..939ea87 100644 --- a/src/bind.inc.php +++ b/src/bind.inc.php @@ -283,7 +283,7 @@ function add_twig_support(\Twig\Environment $twig) $twig->addFunction(new \Twig\TwigFunction('has_token', function($o, $token) { - return $o->hasToken($token); + return method_exists($o, 'hasToken') && $o->hasToken($token); } )); $twig->addFunction(new \Twig\TwigFunction('token', diff --git a/tpl/bhl_bind_macro.twig b/tpl/bhl_bind_macro.twig index ace2d6d..b5913e7 100644 --- a/tpl/bhl_bind_macro.twig +++ b/tpl/bhl_bind_macro.twig @@ -321,7 +321,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack {%- for idx, type_item in ret_types -%} {% set ridx = ret_types|length - idx - 1 ~%} { - var dv{{ridx}} = bhl.Val.NewNoReset(frm.vm); + var dv{{ridx}} = bhl.Val.New(frm.vm); {{ _self.native2val(ret_types[ridx], 'v'~ridx, 'dv'~ridx) }}; stack.Push(dv{{ridx}}); } @@ -565,7 +565,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack {%- else -%} {%- if type is instanceof('\\mtgMetaFunc') -%} - {{value}}.SetObj({{native}}, Types.Any) + {{value}}.SetObj({{native}}, Types.Any/*TODO: use real type?*/) {%- endif -%} {%- if type is instanceof('\\mtgArrType') -%} @@ -640,7 +640,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack }, (_vm, itype, n) => { #if !BHL_FRONT - var v = Val.NewNoReset(_vm); + var v = Val.New(_vm); {{ _self.native2val(token(o, 'bhl_native_arr_proxy'), 'n', 'v')}}; return v; #else @@ -890,7 +890,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack {%- endif ~%} { - var dv = bhl.Val.NewNoReset(frm.vm); + var dv = bhl.Val.New(frm.vm); {{ _self.native2val(f.returntype, return_var, 'dv') }}; stack.Push(dv); }