vim-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.
ac92e25a33

- Note that to *exactly* port hunk @@ -7376,18 +7444,19 from
  handle_subscript(), we need the :scriptversion patches (I have an open
  PR for those, but this patch works fine without them anyway).
- Port call_internal_func() from v7.4.2058.
- Adjust some error messages in tests, as they rely on the Blob patches.
- Add a modeline to test_method.vim.

Ignore the global_functions and base_method tables and prefer the
current GPerf implementation. Instead, add an extra base_arg field to
VimLFuncDef that holds the number of the argument to use as the base
(1-indexed, so that 0 may be used to refer to functions that cannot be
used as methods).

This also means we support using any argument as a base from the get-go,
rather than just the first (Vim includes this ability in future patches,
however).

To mark a function as usable as a method, use the "base" key as
described in eval.lua.
This commit is contained in:
Sean Dewar
2021-08-05 19:46:42 +01:00
parent 4042ae5a2b
commit e6be6c307a
10 changed files with 299 additions and 53 deletions

View File

@@ -5,6 +5,9 @@
-- args Number of arguments, list with maximum and minimum number of arguments
-- or list with a minimum number of arguments only. Defaults to zero
-- arguments.
-- base For methods: the argument to use as the base argument (1-indexed):
-- base->method()
-- Defaults to zero (function cannot be used as a method).
-- func Name of the C function which implements the VimL function. Defaults to
-- `f_{funcname}`.
@@ -16,7 +19,7 @@ return {
funcs={
abs={args=1},
acos={args=1, func="float_op_wrapper", data="&acos"}, -- WJMc
add={args=2},
add={args=2, base=1},
['and']={args=2},
api_info={},
append={args=2},
@@ -73,10 +76,10 @@ return {
complete_check={},
complete_info={args={0, 1}},
confirm={args={1, 4}},
copy={args=1},
copy={args=1, base=1},
cos={args=1, func="float_op_wrapper", data="&cos"},
cosh={args=1, func="float_op_wrapper", data="&cosh"},
count={args={2, 4}},
count={args={2, 4}, base=1},
cscope_connection={args={0, 3}},
ctxget={args={0, 1}},
ctxpop={},
@@ -93,7 +96,7 @@ return {
did_filetype={},
diff_filler={args=1},
diff_hlID={args=2},
empty={args=1},
empty={args=1, base=1},
environ={},
escape={args=2},
eval={args=1},
@@ -105,12 +108,12 @@ return {
exp={args=1, func="float_op_wrapper", data="&exp"},
expand={args={1, 3}},
expandcmd={args=1},
extend={args={2, 3}},
extend={args={2, 3}, base=1},
feedkeys={args={1, 2}},
file_readable={args=1, func='f_filereadable'}, -- obsolete
filereadable={args=1},
filewritable={args=1},
filter={args=2},
filter={args=2, base=1},
finddir={args={1, 3}},
findfile={args={1, 3}},
flatten={args={1, 2}},
@@ -128,7 +131,7 @@ return {
funcref={args={1, 3}},
['function']={args={1, 3}},
garbagecollect={args={0, 1}},
get={args={2, 3}},
get={args={2, 3}, base=1},
getbufinfo={args={0, 1}},
getbufline={args={2, 3}},
getbufvar={args={2, 3}},
@@ -187,14 +190,14 @@ return {
hostname={},
iconv={args=3},
indent={args=1},
index={args={2, 4}},
index={args={2, 4}, base=1},
input={args={1, 3}},
inputdialog={args={1, 3}},
inputlist={args=1},
inputrestore={},
inputsave={},
inputsecret={args={1, 2}},
insert={args={2, 3}},
insert={args={2, 3}, base=1},
interrupt={args=0},
invert={args=1},
isdirectory={args=1},
@@ -202,7 +205,7 @@ return {
islocked={args=1},
isnan={args=1},
id={args=1},
items={args=1},
items={args=1, base=1},
jobclose={args={1, 2}, func="f_chanclose"},
jobpid={args=1},
jobresize={args=3},
@@ -210,12 +213,12 @@ return {
jobstart={args={1, 2}},
jobstop={args=1},
jobwait={args={1, 2}},
join={args={1, 2}},
join={args={1, 2}, base=1},
json_decode={args=1},
json_encode={args=1},
keys={args=1},
keys={args=1, base=1},
last_buffer_nr={}, -- obsolete
len={args=1},
len={args=1, base=1},
libcall={args=3},
libcallnr={args=3},
line={args={1, 2}},
@@ -226,7 +229,7 @@ return {
log={args=1, func="float_op_wrapper", data="&log"},
log10={args=1, func="float_op_wrapper", data="&log10"},
luaeval={args={1, 2}},
map={args=2},
map={args=2, base=1},
maparg={args={1, 4}},
mapcheck={args={1, 3}},
match={args={2, 4}},
@@ -238,9 +241,9 @@ return {
matchlist={args={2, 4}},
matchstr={args={2, 4}},
matchstrpos={args={2,4}},
max={args=1},
max={args=1, base=1},
menu_get={args={1, 2}},
min={args=1},
min={args=1, base=1},
mkdir={args={1, 3}},
mode={args={0, 1}},
msgpackdump={args=1},
@@ -270,11 +273,11 @@ return {
reltime={args={0, 2}},
reltimefloat={args=1},
reltimestr={args=1},
remove={args={2, 3}},
remove={args={2, 3}, base=1},
rename={args=2},
['repeat']={args=2},
['repeat']={args=2, base=1},
resolve={args=1},
reverse={args=1},
reverse={args=1, base=1},
round={args=1, func="float_op_wrapper", data="&round"},
rpcnotify={args=varargs(2)},
rpcrequest={args=varargs(2)},
@@ -327,7 +330,7 @@ return {
sin={args=1, func="float_op_wrapper", data="&sin"},
sinh={args=1, func="float_op_wrapper", data="&sinh"},
sockconnect={args={2,3}},
sort={args={1, 3}},
sort={args={1, 3}, base=1},
soundfold={args=1},
stdioopen={args=1},
spellbadword={args={0, 1}},
@@ -344,7 +347,7 @@ return {
strftime={args={1, 2}},
strgetchar={args={2, 2}},
stridx={args={2, 3}},
string={args=1},
string={args=1, base=1},
strlen={args=1},
strpart={args={2, 4}},
strptime={args=2},
@@ -383,11 +386,11 @@ return {
tr={args=3},
trim={args={1,3}},
trunc={args=1, func="float_op_wrapper", data="&trunc"},
type={args=1},
type={args=1, base=1},
undofile={args=1},
undotree={},
uniq={args={1, 3}},
values={args=1},
uniq={args={1, 3}, base=1},
values={args=1, base=1},
virtcol={args=1},
visualmode={args={0, 1}},
wait={args={2,3}},