mirror of
https://github.com/neovim/neovim.git
synced 2025-09-15 15:58:17 +00:00
eval: Remove eval_expr() completely
This commit is contained in:
@@ -181,11 +181,6 @@ vim.eval(str) *python-eval*
|
|||||||
# string.atoi() to convert to
|
# string.atoi() to convert to
|
||||||
# a number.
|
# a number.
|
||||||
|
|
||||||
:py tagList = vim.eval('taglist("eval_expr")')
|
|
||||||
< The latter will return a python list of python dicts, for instance:
|
|
||||||
[{'cmd': '/^eval_expr(arg, nextcmd)$/', 'static': 0, 'name':
|
|
||||||
'eval_expr', 'kind': 'f', 'filename': './src/eval.c'}]
|
|
||||||
|
|
||||||
vim.bindeval(str) *python-bindeval*
|
vim.bindeval(str) *python-bindeval*
|
||||||
Like |python-eval|, but returns special objects described in
|
Like |python-eval|, but returns special objects described in
|
||||||
|python-bindeval-objects|. These python objects let you modify (|List|
|
|python-bindeval-objects|. These python objects let you modify (|List|
|
||||||
|
@@ -1178,23 +1178,6 @@ int get_spellword(list_T *list, const char **pp)
|
|||||||
return tv_get_number(&li->li_tv);
|
return tv_get_number(&li->li_tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Top level evaluation function.
|
|
||||||
* Returns an allocated typval_T with the result.
|
|
||||||
* Returns NULL when there is an error.
|
|
||||||
*/
|
|
||||||
typval_T *eval_expr(char_u *arg, char_u **nextcmd)
|
|
||||||
{
|
|
||||||
typval_T *tv = xmalloc(sizeof(typval_T));
|
|
||||||
|
|
||||||
if (eval0(arg, tv, nextcmd, TRUE) == FAIL) {
|
|
||||||
xfree(tv);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tv;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Call some vimL function and return the result in "*rettv".
|
// Call some vimL function and return the result in "*rettv".
|
||||||
// Uses argv[argc] for the function arguments. Only Number and String
|
// Uses argv[argc] for the function arguments. Only Number and String
|
||||||
|
@@ -6,13 +6,17 @@ local to_cstr = helpers.to_cstr
|
|||||||
local ffi = helpers.ffi
|
local ffi = helpers.ffi
|
||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
|
|
||||||
local eval = cimport('./src/nvim/eval.h', './src/nvim/memory.h')
|
local eval = cimport('./src/nvim/eval.h', './src/nvim/eval/typval.h',
|
||||||
|
'./src/nvim/memory.h')
|
||||||
|
|
||||||
local eval_expr = function(expr)
|
local eval0 = function(expr)
|
||||||
return ffi.gc(eval.eval_expr(to_cstr(expr), nil), function(tv)
|
local tv = ffi.gc(ffi.new('typval_T', {v_type=eval.VAR_UNKNOWN}),
|
||||||
eval.tv_clear(tv)
|
eval.tv_clear)
|
||||||
eval.xfree(tv)
|
if eval.eval0(to_cstr(expr), tv, nil, true) == 0 then
|
||||||
end)
|
return nil
|
||||||
|
else
|
||||||
|
return tv
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe('NULL typval_T', function()
|
describe('NULL typval_T', function()
|
||||||
@@ -25,19 +29,19 @@ describe('NULL typval_T', function()
|
|||||||
while os.getenv(unexistent_env) ~= nil do
|
while os.getenv(unexistent_env) ~= nil do
|
||||||
unexistent_env = unexistent_env .. '_XXX'
|
unexistent_env = unexistent_env .. '_XXX'
|
||||||
end
|
end
|
||||||
local rettv = eval_expr('$' .. unexistent_env)
|
local rettv = eval0('$' .. unexistent_env)
|
||||||
eq(eval.VAR_STRING, rettv.v_type)
|
eq(eval.VAR_STRING, rettv.v_type)
|
||||||
eq(nil, rettv.vval.v_string)
|
eq(nil, rettv.vval.v_string)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
itp('is produced by v:_null_list', function()
|
itp('is produced by v:_null_list', function()
|
||||||
local rettv = eval_expr('v:_null_list')
|
local rettv = eval0('v:_null_list')
|
||||||
eq(eval.VAR_LIST, rettv.v_type)
|
eq(eval.VAR_LIST, rettv.v_type)
|
||||||
eq(nil, rettv.vval.v_list)
|
eq(nil, rettv.vval.v_list)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
itp('is produced by v:_null_dict', function()
|
itp('is produced by v:_null_dict', function()
|
||||||
local rettv = eval_expr('v:_null_dict')
|
local rettv = eval0('v:_null_dict')
|
||||||
eq(eval.VAR_DICT, rettv.v_type)
|
eq(eval.VAR_DICT, rettv.v_type)
|
||||||
eq(nil, rettv.vval.v_dict)
|
eq(nil, rettv.vval.v_dict)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user