aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-03-29 23:15:07 +0200
committerGitHub <noreply@github.com>2017-03-29 23:15:07 +0200
commitc60e409471c51864883bd0b874980d0a8857f813 (patch)
tree64444c3f0210461e398654e3d6dd6f00e0091cd9 /src/nvim/api/vim.c
parentc35420558bed0bfa9938ecd1facec88f1df392a5 (diff)
parent46efe14473fa803f84509592cc1e8fca4eb20640 (diff)
downloadrneovim-c60e409471c51864883bd0b874980d0a8857f813.tar.gz
rneovim-c60e409471c51864883bd0b874980d0a8857f813.tar.bz2
rneovim-c60e409471c51864883bd0b874980d0a8857f813.zip
Merge #5119 from ZyX-I/split-eval
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r--src/nvim/api/vim.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 413456c615..975446057c 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -22,6 +22,7 @@
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/eval.h"
+#include "nvim/eval/typval.h"
#include "nvim/option.h"
#include "nvim/syntax.h"
#include "nvim/getchar.h"
@@ -181,19 +182,20 @@ Object nvim_eval(String expr, Error *err)
Object rv = OBJECT_INIT;
// Evaluate the expression
try_start();
- typval_T *expr_result = eval_expr((char_u *)expr.data, NULL);
- if (!expr_result) {
- api_set_error(err, Exception, _("Failed to evaluate expression"));
+ typval_T rettv;
+ if (eval0((char_u *)expr.data, &rettv, NULL, true) == FAIL) {
+ api_set_error(err, Exception, "Failed to evaluate expression");
}
if (!try_end(err)) {
// No errors, convert the result
- rv = vim_to_object(expr_result);
+ rv = vim_to_object(&rettv);
}
- // Free the vim object
- free_tv(expr_result);
+ // Free the Vim object
+ tv_clear(&rettv);
+
return rv;
}
@@ -237,11 +239,11 @@ Object nvim_call_function(String fname, Array args, Error *err)
if (!try_end(err)) {
rv = vim_to_object(&rettv);
}
- clear_tv(&rettv);
+ tv_clear(&rettv);
free_vim_args:
while (i > 0) {
- clear_tv(&vim_args[--i]);
+ tv_clear(&vim_args[--i]);
}
return rv;