mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
eval/typval: Make tv_list_item_alloc static
Better write this bit in lua then make reviewers or clint filter out tv_list_item_alloc().
This commit is contained in:
@@ -52,7 +52,7 @@ const char *const tv_empty_string = "";
|
|||||||
/// and specifically set lv_lock.
|
/// and specifically set lv_lock.
|
||||||
///
|
///
|
||||||
/// @return [allocated] new list item.
|
/// @return [allocated] new list item.
|
||||||
listitem_T *tv_list_item_alloc(void)
|
static listitem_T *tv_list_item_alloc(void)
|
||||||
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC
|
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC
|
||||||
{
|
{
|
||||||
return xmalloc(sizeof(listitem_T));
|
return xmalloc(sizeof(listitem_T));
|
||||||
|
@@ -7,7 +7,7 @@ local ffi = helpers.ffi
|
|||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
|
|
||||||
local eval = cimport('./src/nvim/eval.h', './src/nvim/eval/typval.h',
|
local eval = cimport('./src/nvim/eval.h', './src/nvim/eval/typval.h',
|
||||||
'./src/nvim/hashtab.h')
|
'./src/nvim/hashtab.h', './src/nvim/memory.h')
|
||||||
|
|
||||||
local null_string = {[true]='NULL string'}
|
local null_string = {[true]='NULL string'}
|
||||||
local null_list = {[true]='NULL list'}
|
local null_list = {[true]='NULL list'}
|
||||||
@@ -24,10 +24,14 @@ local nil_value = {[true]='nil'}
|
|||||||
|
|
||||||
local lua2typvalt
|
local lua2typvalt
|
||||||
|
|
||||||
|
local function tv_list_item_alloc()
|
||||||
|
return ffi.cast('listitem_T*', eval.xmalloc(ffi.sizeof('listitem_T')))
|
||||||
|
end
|
||||||
|
|
||||||
local function li_alloc(nogc)
|
local function li_alloc(nogc)
|
||||||
local gcfunc = eval.tv_list_item_free
|
local gcfunc = eval.tv_list_item_free
|
||||||
if nogc then gcfunc = nil end
|
if nogc then gcfunc = nil end
|
||||||
local li = ffi.gc(eval.tv_list_item_alloc(), gcfunc)
|
local li = ffi.gc(tv_list_item_alloc(), gcfunc)
|
||||||
li.li_next = nil
|
li.li_next = nil
|
||||||
li.li_prev = nil
|
li.li_prev = nil
|
||||||
li.li_tv = {v_type=eval.VAR_UNKNOWN, v_lock=eval.VAR_UNLOCKED}
|
li.li_tv = {v_type=eval.VAR_UNKNOWN, v_lock=eval.VAR_UNLOCKED}
|
||||||
@@ -41,7 +45,7 @@ local function populate_list(l, lua_l, processed)
|
|||||||
processed[lua_l] = l
|
processed[lua_l] = l
|
||||||
for i = 1, #lua_l do
|
for i = 1, #lua_l do
|
||||||
local item_tv = ffi.gc(lua2typvalt(lua_l[i], processed), nil)
|
local item_tv = ffi.gc(lua2typvalt(lua_l[i], processed), nil)
|
||||||
local item_li = eval.tv_list_item_alloc()
|
local item_li = tv_list_item_alloc()
|
||||||
item_li.li_tv = item_tv
|
item_li.li_tv = item_tv
|
||||||
eval.tv_list_append(l, item_li)
|
eval.tv_list_append(l, item_li)
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user