aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r--src/nvim/api/vim.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 3fd1f57ace..511c87f408 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;
}
@@ -238,11 +240,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;
@@ -439,7 +441,7 @@ Object nvim_get_vvar(String name, Error *err)
///
/// @param name Option name
/// @param[out] err Error details, if any
-/// @return Option value
+/// @return Option value (global)
Object nvim_get_option(String name, Error *err)
FUNC_API_SINCE(1)
{