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.
This commit is contained in:
bfredl
2024-02-12 20:40:27 +01:00
parent 0a51e7626a
commit d60412b18e
23 changed files with 227 additions and 192 deletions

View File

@@ -22,7 +22,7 @@ local api = cimport('./src/nvim/api/private/helpers.h', './src/nvim/api/private/
describe('vim_to_object', function()
local vim_to_object = function(l)
return obj2lua(api.vim_to_object(lua2typvalt(l)))
return obj2lua(api.vim_to_object(lua2typvalt(l), nil, false))
end
local different_output_test = function(name, input, output)
@@ -92,13 +92,13 @@ describe('vim_to_object', function()
itp('outputs empty list for NULL list', function()
local tt = typvalt('VAR_LIST', { v_list = NULL })
eq(nil, tt.vval.v_list)
eq({ [type_key] = list_type }, obj2lua(api.vim_to_object(tt)))
eq({ [type_key] = list_type }, obj2lua(api.vim_to_object(tt, nil, false)))
end)
itp('outputs empty dict for NULL dict', function()
local tt = typvalt('VAR_DICT', { v_dict = NULL })
eq(nil, tt.vval.v_dict)
eq({}, obj2lua(api.vim_to_object(tt)))
eq({}, obj2lua(api.vim_to_object(tt, nil, false)))
end)
itp('regression: partials in a list', function()
@@ -113,6 +113,6 @@ describe('vim_to_object', function()
}
local list = lua2typvalt(llist)
eq(llist, typvalt2lua(list))
eq({ nil_value, {} }, obj2lua(api.vim_to_object(list)))
eq({ nil_value, {} }, obj2lua(api.vim_to_object(list, nil, false)))
end)
end)