mirror of
https://github.com/neovim/neovim.git
synced 2025-11-28 21:20:45 +00:00
eval: Split eval.c into smaller files
This commit is contained in:
@@ -7,7 +7,7 @@ local eq = helpers.eq
|
||||
local neq = helpers.neq
|
||||
local ffi = helpers.ffi
|
||||
|
||||
local decode = cimport('./src/nvim/eval/decode.h', './src/nvim/eval_defs.h',
|
||||
local decode = cimport('./src/nvim/eval/decode.h', './src/nvim/eval/typval.h',
|
||||
'./src/nvim/globals.h', './src/nvim/memory.h',
|
||||
'./src/nvim/message.h')
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ local to_cstr = helpers.to_cstr
|
||||
local ffi = helpers.ffi
|
||||
local eq = helpers.eq
|
||||
|
||||
local eval = cimport('./src/nvim/eval.h', './src/nvim/eval_defs.h',
|
||||
local eval = cimport('./src/nvim/eval.h', './src/nvim/eval/typval.h',
|
||||
'./src/nvim/hashtab.h')
|
||||
|
||||
local null_string = {[true]='NULL string'}
|
||||
@@ -33,7 +33,7 @@ local function li_alloc(nogc)
|
||||
end
|
||||
|
||||
local function list(...)
|
||||
local ret = ffi.gc(eval.list_alloc(), eval.list_unref)
|
||||
local ret = ffi.gc(eval.tv_list_alloc(), eval.tv_list_unref)
|
||||
eq(0, ret.lv_refcount)
|
||||
ret.lv_refcount = 1
|
||||
for i = 1, select('#', ...) do
|
||||
@@ -241,7 +241,7 @@ local typvalt = function(typ, vval)
|
||||
elseif type(typ) == 'string' then
|
||||
typ = eval[typ]
|
||||
end
|
||||
return ffi.gc(ffi.new('typval_T', {v_type=typ, vval=vval}), eval.clear_tv)
|
||||
return ffi.gc(ffi.new('typval_T', {v_type=typ, vval=vval}), eval.tv_clear)
|
||||
end
|
||||
|
||||
local lua2typvalt_type_tab = {
|
||||
@@ -256,14 +256,14 @@ local lua2typvalt_type_tab = {
|
||||
processed[l].lv_refcount = processed[l].lv_refcount + 1
|
||||
return typvalt(eval.VAR_LIST, {v_list=processed[l]})
|
||||
end
|
||||
local lst = eval.list_alloc()
|
||||
local lst = eval.tv_list_alloc()
|
||||
lst.lv_refcount = 1
|
||||
processed[l] = lst
|
||||
local ret = typvalt(eval.VAR_LIST, {v_list=lst})
|
||||
for i = 1, #l do
|
||||
local item_tv = ffi.gc(lua2typvalt(l[i], processed), nil)
|
||||
eval.list_append_tv(lst, item_tv)
|
||||
eval.clear_tv(item_tv)
|
||||
eval.tv_list_append_tv(lst, item_tv)
|
||||
eval.tv_clear(item_tv)
|
||||
end
|
||||
return ret
|
||||
end,
|
||||
@@ -281,7 +281,7 @@ local lua2typvalt_type_tab = {
|
||||
local di = eval.dictitem_alloc(to_cstr(k))
|
||||
local val_tv = ffi.gc(lua2typvalt(v, processed), nil)
|
||||
eval.copy_tv(val_tv, di.di_tv)
|
||||
eval.clear_tv(val_tv)
|
||||
eval.tv_clear(val_tv)
|
||||
eval.dict_add(dct, di)
|
||||
end
|
||||
end
|
||||
@@ -301,7 +301,7 @@ local lua2typvalt_type_tab = {
|
||||
for i, arg in ipairs(l.args) do
|
||||
local arg_tv = ffi.gc(lua2typvalt(arg, processed), nil)
|
||||
eval.copy_tv(arg_tv, argv[i - 1])
|
||||
eval.clear_tv(arg_tv)
|
||||
eval.tv_clear(arg_tv)
|
||||
end
|
||||
end
|
||||
local dict = nil
|
||||
|
||||
@@ -10,7 +10,7 @@ local eval = cimport('./src/nvim/eval.h', './src/nvim/memory.h')
|
||||
|
||||
local eval_expr = function(expr)
|
||||
return ffi.gc(eval.eval_expr(to_cstr(expr), nil), function(tv)
|
||||
eval.clear_tv(tv)
|
||||
eval.tv_clear(tv)
|
||||
eval.xfree(tv)
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ local list_items = eval_helpers.list_items
|
||||
local dict_items = eval_helpers.dict_items
|
||||
local lua2typvalt = eval_helpers.lua2typvalt
|
||||
|
||||
local lib = cimport('./src/nvim/eval_defs.h', './src/nvim/eval.h')
|
||||
local lib = cimport('./src/nvim/eval/typval.h', './src/nvim/eval.h')
|
||||
|
||||
local alloc_log = alloc_log_new()
|
||||
|
||||
@@ -26,7 +26,7 @@ after_each(function()
|
||||
alloc_log:after_each()
|
||||
end)
|
||||
|
||||
describe('clear_tv()', function()
|
||||
describe('tv_clear()', function()
|
||||
itp('successfully frees all lists in [&l [1], *l, *l]', function()
|
||||
local l_inner = {1}
|
||||
local list = {l_inner, l_inner, l_inner}
|
||||
@@ -44,7 +44,7 @@ describe('clear_tv()', function()
|
||||
a.li(lis[3]),
|
||||
})
|
||||
eq(3, list_inner_p.lv_refcount)
|
||||
lib.clear_tv(list_tv)
|
||||
lib.tv_clear(list_tv)
|
||||
alloc_log:check({
|
||||
a.freed(lis_inner[1]),
|
||||
a.freed(list_inner_p),
|
||||
@@ -69,7 +69,7 @@ describe('clear_tv()', function()
|
||||
a.li(lis[3]),
|
||||
})
|
||||
eq(3, list_inner_p.lv_refcount)
|
||||
lib.clear_tv(list_tv)
|
||||
lib.tv_clear(list_tv)
|
||||
alloc_log:check({
|
||||
a.freed(list_inner_p),
|
||||
a.freed(lis[1]),
|
||||
@@ -92,7 +92,7 @@ describe('clear_tv()', function()
|
||||
a.li(lis[2]),
|
||||
})
|
||||
eq(2, dict_inner_p.dv_refcount)
|
||||
lib.clear_tv(list_tv)
|
||||
lib.tv_clear(list_tv)
|
||||
alloc_log:check({
|
||||
a.freed(dict_inner_p),
|
||||
a.freed(lis[1]),
|
||||
@@ -116,7 +116,7 @@ describe('clear_tv()', function()
|
||||
a.li(lis[2]),
|
||||
})
|
||||
eq(2, dict_inner_p.dv_refcount)
|
||||
lib.clear_tv(list_tv)
|
||||
lib.tv_clear(list_tv)
|
||||
alloc_log:check({
|
||||
a.freed(dis.a),
|
||||
a.freed(dict_inner_p),
|
||||
|
||||
Reference in New Issue
Block a user