summaryrefslogtreecommitdiffstats
path: root/src/evalvars.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-06-07 14:50:50 +0200
committerBram Moolenaar <Bram@vim.org>2020-06-07 14:50:50 +0200
commita9c010494767e43a51c443cac35ebc80d0831d0b (patch)
tree9997eec6cd7eb6da640de26c0ab5d6637ccbbcce /src/evalvars.c
parente928366de5deca359fad779a4f740db703296302 (diff)
patch 8.2.0918: duplicate code for evaluating expression argumentv8.2.0918
Problem: Duplicate code for evaluating expression argument. Solution: Merge the code and make the use more flexible.
Diffstat (limited to 'src/evalvars.c')
-rw-r--r--src/evalvars.c75
1 files changed, 0 insertions, 75 deletions
diff --git a/src/evalvars.c b/src/evalvars.c
index 84e9a7a9c2..8b3ce2e903 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -3811,79 +3811,4 @@ free_callback(callback_T *callback)
callback->cb_name = NULL;
}
-/*
- * Process a function argument that can be a string expression or a function
- * reference.
- * "tv" must remain valid until calling evalarg_clean()!
- * Returns FAIL when the argument is invalid.
- */
- int
-evalarg_get(typval_T *tv, evalarg_T *eva)
-{
- if (tv->v_type == VAR_STRING
- || tv->v_type == VAR_NUMBER
- || tv->v_type == VAR_BOOL
- || tv->v_type == VAR_SPECIAL)
- {
- eva->eva_string = tv_get_string_buf(tv, eva->eva_buf);
- return OK;
- }
-
- eva->eva_callback = get_callback(tv);
- return eva->eva_callback.cb_name == NULL ? FAIL : OK;
-}
-
-/*
- * Return whether "eva" has a valid expression or callback.
- */
- int
-evalarg_valid(evalarg_T *eva)
-{
- return eva->eva_string != NULL || eva->eva_callback.cb_name != NULL;
-}
-
-/*
- * Invoke the expression or callback "eva" and return the result in "tv".
- * Returns FAIL if something failed
- */
- int
-evalarg_call(evalarg_T *eva, typval_T *tv)
-{
- typval_T argv[1];
-
- if (eva->eva_string != NULL)
- return eval0(eva->eva_string, tv, NULL, EVAL_EVALUATE);
-
- argv[0].v_type = VAR_UNKNOWN;
- return call_callback(&eva->eva_callback, -1, tv, 0, argv);
-}
-
-/*
- * Like evalarg_call(), but just return TRUE of FALSE.
- * Sets "error" to TRUE if evaluation failed.
- */
- int
-evalarg_call_bool(evalarg_T *eva, int *error)
-{
- typval_T tv;
- int r;
-
- if (evalarg_call(eva, &tv) == FAIL)
- {
- *error = TRUE;
- return FALSE;
- }
- r = tv_get_number(&tv);
- clear_tv(&tv);
- *error = FALSE;
- return r;
-}
-
- void
-evalarg_clean(evalarg_T *eva)
-{
- if (eva->eva_string == NULL)
- free_callback(&eva->eva_callback);
-}
-
#endif // FEAT_EVAL