mirror of
https://github.com/neovim/neovim.git
synced 2025-12-15 19:05:40 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user