From d60412b18e4e21f301baa2ac3f3fb7be89655e4b Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 12 Feb 2024 20:40:27 +0100 Subject: refactor(eval): use arena when converting typvals to Object Note: this contains two _temporary_ changes which can be reverted once the Arena vs no-Arena distinction in API wrappers has been removed. Both nlua_push_Object and object_to_vim_take_luaref() has been changed to take the object argument as a pointer. This is not going to be necessary once these are only used with arena (or not at all) allocated Objects. The object_to_vim() variant which leaves luaref untouched might need to stay for a little longer. --- src/nvim/generators/gen_api_dispatch.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/nvim/generators/gen_api_dispatch.lua') diff --git a/src/nvim/generators/gen_api_dispatch.lua b/src/nvim/generators/gen_api_dispatch.lua index c16ea29a01..90ed90d2bc 100644 --- a/src/nvim/generators/gen_api_dispatch.lua +++ b/src/nvim/generators/gen_api_dispatch.lua @@ -845,15 +845,17 @@ exit_0: write_shifted_output(' %s ret = %s(%s);\n', fn.return_type, fn.name, cparams) local ret_type = real_type(fn.return_type) + local ret_mode = (ret_type == 'Object') and '&' or '' if fn.has_lua_imp then -- only push onto the Lua stack if we haven't already write_shifted_output(string.format( [[ if (lua_gettop(lstate) == 0) { - nlua_push_%s(lstate, ret, true); + nlua_push_%s(lstate, %sret, true); } ]], - return_type + return_type, + ret_mode )) elseif string.match(ret_type, '^KeyDict_') then write_shifted_output( @@ -862,7 +864,12 @@ exit_0: ) else local special = (fn.since ~= nil and fn.since < 11) - write_shifted_output(' nlua_push_%s(lstate, ret, %s);\n', return_type, tostring(special)) + write_shifted_output( + ' nlua_push_%s(lstate, %sret, %s);\n', + return_type, + ret_mode, + tostring(special) + ) end -- NOTE: we currently assume err_throw needs nothing from arena -- cgit