diff options
author | bfredl <bjorn.linse@gmail.com> | 2024-02-21 12:30:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-21 12:30:28 +0100 |
commit | 09651342e746af38c38f22f3cae6bfb40dade327 (patch) | |
tree | 37548d8d3f4cb673c8f2293a96aa635cdd8917ff /src/nvim/generators/gen_api_dispatch.lua | |
parent | 9bb046d1be5aa9ba0482b2cad050b286d4b78978 (diff) | |
parent | 4fb1739e6f1f06f10165f3c9a7b80a1ec014db3c (diff) | |
download | rneovim-09651342e746af38c38f22f3cae6bfb40dade327.tar.gz rneovim-09651342e746af38c38f22f3cae6bfb40dade327.tar.bz2 rneovim-09651342e746af38c38f22f3cae6bfb40dade327.zip |
Merge pull request #27552 from bfredl/apialloc
refactor(api): make freeing of return-value opt-in instead of opt out.
Diffstat (limited to 'src/nvim/generators/gen_api_dispatch.lua')
-rw-r--r-- | src/nvim/generators/gen_api_dispatch.lua | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/nvim/generators/gen_api_dispatch.lua b/src/nvim/generators/gen_api_dispatch.lua index 90ed90d2bc..c3fc5aa0a3 100644 --- a/src/nvim/generators/gen_api_dispatch.lua +++ b/src/nvim/generators/gen_api_dispatch.lua @@ -60,8 +60,7 @@ local function add_function(fn) fn.parameters[#fn.parameters] = nil end if #fn.parameters ~= 0 and fn.parameters[#fn.parameters][1] == 'arena' then - -- return value is allocated in an arena - fn.arena_return = true + fn.receives_arena = true fn.parameters[#fn.parameters] = nil end end @@ -554,7 +553,7 @@ for i = 1, #functions do table.insert(call_args, a) end - if fn.arena_return then + if fn.receives_arena then table.insert(call_args, 'arena') end @@ -621,8 +620,8 @@ for n, name in ipairs(hashorder) do .. (fn.impl_name or fn.name) .. ', .fast = ' .. tostring(fn.fast) - .. ', .arena_return = ' - .. tostring(not not fn.arena_return) + .. ', .ret_alloc = ' + .. tostring(not not fn.ret_alloc) .. '},\n' ) end @@ -791,7 +790,7 @@ local function process_function(fn) if fn.receives_channel_id then cparams = 'LUA_INTERNAL_CALL, ' .. cparams end - if fn.arena_return then + if fn.receives_arena then cparams = cparams .. '&arena, ' end @@ -839,7 +838,7 @@ exit_0: return_type = fn.return_type end local free_retval = '' - if not fn.arena_return then + if fn.ret_alloc then free_retval = ' api_free_' .. return_type:lower() .. '(ret);' end write_shifted_output(' %s ret = %s(%s);\n', fn.return_type, fn.name, cparams) |