aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2016-09-04 02:50:50 +0300
committerZyX <kp-pav@yandex.ru>2017-03-29 10:08:05 +0300
commit5df35297f832b3247c18253c916be6066c603739 (patch)
treed991830be05ace5b0b92ca8a0ff49eeb3e72dc60
parentc8e63a8db84e9d9f7bd855085a87d93631504fc7 (diff)
downloadrneovim-5df35297f832b3247c18253c916be6066c603739.tar.gz
rneovim-5df35297f832b3247c18253c916be6066c603739.tar.bz2
rneovim-5df35297f832b3247c18253c916be6066c603739.zip
eval: Remove eval_expr() completely
-rw-r--r--runtime/doc/if_pyth.txt5
-rw-r--r--src/nvim/eval.c17
-rw-r--r--test/unit/eval/tricks_spec.lua22
3 files changed, 13 insertions, 31 deletions
diff --git a/runtime/doc/if_pyth.txt b/runtime/doc/if_pyth.txt
index f2a7d91bb7..6321175420 100644
--- a/runtime/doc/if_pyth.txt
+++ b/runtime/doc/if_pyth.txt
@@ -181,11 +181,6 @@ vim.eval(str) *python-eval*
# string.atoi() to convert to
# 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*
Like |python-eval|, but returns special objects described in
|python-bindeval-objects|. These python objects let you modify (|List|
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 3a0075e48a..51ffa8887d 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -1178,23 +1178,6 @@ int get_spellword(list_T *list, const char **pp)
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".
// Uses argv[argc] for the function arguments. Only Number and String
diff --git a/test/unit/eval/tricks_spec.lua b/test/unit/eval/tricks_spec.lua
index 7f0a445f2c..54029734fb 100644
--- a/test/unit/eval/tricks_spec.lua
+++ b/test/unit/eval/tricks_spec.lua
@@ -6,13 +6,17 @@ local to_cstr = helpers.to_cstr
local ffi = helpers.ffi
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)
- return ffi.gc(eval.eval_expr(to_cstr(expr), nil), function(tv)
- eval.tv_clear(tv)
- eval.xfree(tv)
- end)
+local eval0 = function(expr)
+ local tv = ffi.gc(ffi.new('typval_T', {v_type=eval.VAR_UNKNOWN}),
+ eval.tv_clear)
+ if eval.eval0(to_cstr(expr), tv, nil, true) == 0 then
+ return nil
+ else
+ return tv
+ end
end
describe('NULL typval_T', function()
@@ -25,19 +29,19 @@ describe('NULL typval_T', function()
while os.getenv(unexistent_env) ~= nil do
unexistent_env = unexistent_env .. '_XXX'
end
- local rettv = eval_expr('$' .. unexistent_env)
+ local rettv = eval0('$' .. unexistent_env)
eq(eval.VAR_STRING, rettv.v_type)
eq(nil, rettv.vval.v_string)
end)
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(nil, rettv.vval.v_list)
end)
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(nil, rettv.vval.v_dict)
end)