patch 8.1.1803: all builtin functions are global
Problem: All builtin functions are global.
Solution: Add the method call operator ->. Implemented for a limited number
of functions.
diff --git a/src/userfunc.c b/src/userfunc.c
index 9d2063b..8e834a3 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -1431,10 +1431,9 @@
{
funcexe_T funcexe;
- funcexe.argv_func = NULL;
+ vim_memset(&funcexe, 0, sizeof(funcexe));
funcexe.firstline = curwin->w_cursor.lnum;
funcexe.lastline = curwin->w_cursor.lnum;
- funcexe.doesrange = NULL;
funcexe.evaluate = TRUE;
funcexe.partial = partial;
funcexe.selfdict = selfdict;
@@ -1555,7 +1554,10 @@
/*
* User defined function.
*/
- if (partial != NULL && partial->pt_func != NULL)
+ if (funcexe->basetv != NULL)
+ // TODO: support User function: base->Method()
+ fp = NULL;
+ else if (partial != NULL && partial->pt_func != NULL)
fp = partial->pt_func;
else
fp = find_func(rfname);
@@ -1625,6 +1627,14 @@
}
}
}
+ else if (funcexe->basetv != NULL)
+ {
+ /*
+ * Find the method name in the table, call its implementation.
+ */
+ error = call_internal_method(fname, argcount, argvars, rettv,
+ funcexe->basetv);
+ }
else
{
/*
@@ -2715,7 +2725,7 @@
translated_function_exists(char_u *name)
{
if (builtin_function(name, -1))
- return find_internal_func(name) >= 0;
+ return has_internal_func(name);
return find_func(name) != NULL;
}
@@ -3084,7 +3094,7 @@
if (*startarg != '(')
{
- semsg(_("E107: Missing parentheses: %s"), eap->arg);
+ semsg(_(e_missingparen), eap->arg);
goto end;
}
@@ -3120,7 +3130,7 @@
}
arg = startarg;
- funcexe.argv_func = NULL;
+ vim_memset(&funcexe, 0, sizeof(funcexe));
funcexe.firstline = eap->line1;
funcexe.lastline = eap->line2;
funcexe.doesrange = &doesrange;