From 3be5b3421c90806bf1cd24317c6d46414e8ecc32 Mon Sep 17 00:00:00 2001 From: wrenge Date: Tue, 16 Jan 2024 14:37:20 +0300 Subject: [PATCH] Add support for list element set --- tpl/bhl_bind_macro.twig | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tpl/bhl_bind_macro.twig b/tpl/bhl_bind_macro.twig index 1479947..3c79e8c 100644 --- a/tpl/bhl_bind_macro.twig +++ b/tpl/bhl_bind_macro.twig @@ -582,6 +582,31 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack ); cl.Define(fn); } + { + var fn = new FuncSymbolNative(new Origin(), "Set", Types.Void, + delegate(VM.Frame frm, ValStack stack, FuncArgsInfo args_info, ref BHS status) + { +#if !BHL_FRONT + var index = stack.Pop(); + var val = stack.Pop(); + var val_lst = stack.Pop(); + + {#TODO: get rid of replace hack below#} + {{('var ' ~ _self.val2native(token(o, 'bhl_native_arr_proxy'), 'val', 'tmp'))|replace({'tmp = tmp' : '', 'var var' : 'var'})}}; + var lst = ((List<{{token(o, 'bhl_native_arr_proxy')|native_type}}>)val_lst.obj); + lst[(int)index._num] = tmp; + + val.Release(); + index.Release(); + val_lst.Release(); +#endif + return null; + }, + new FuncArgSymbol("v", {{token(o, 'bhl_native_arr_proxy')|bhl_type_ref}}), + new FuncArgSymbol("idx", Types.Int) + ); + cl.Define(fn); + } cl.Setup(); {{scope}}.Define(cl); }