1
0
forked from aniani/vim

patch 8.2.1054: not so easy to pass a lua function to Vim

Problem:    Not so easy to pass a lua function to Vim.
Solution:   Convert a Lua function and closure to a Vim funcref. (Prabir
            Shrestha, closes #6246)
This commit is contained in:
Bram Moolenaar
2020-06-25 19:27:56 +02:00
parent 832adf9bb8
commit 801ab06934
7 changed files with 213 additions and 1 deletions

View File

@@ -1529,6 +1529,9 @@ struct blobvar_S
char bv_lock; // zero, VAR_LOCKED, VAR_FIXED
};
typedef int (*cfunc_T)(int argcount, typval_T *argvars, typval_T *rettv, void *state);
typedef void (*cfunc_free_T)(void *state);
#if defined(FEAT_EVAL) || defined(PROTO)
typedef struct funccall_S funccall_T;
@@ -1562,6 +1565,11 @@ typedef struct
char_u *uf_va_name; // name from "...name" or NULL
type_T *uf_va_type; // type from "...name: type" or NULL
type_T *uf_func_type; // type of the function, &t_func_any if unknown
# if defined(FEAT_LUA)
cfunc_T uf_cb; // callback function for cfunc
cfunc_free_T uf_cb_free; // callback function to free cfunc
void *uf_cb_state; // state of uf_cb
# endif
garray_T uf_lines; // function lines
# ifdef FEAT_PROFILE
@@ -1607,6 +1615,7 @@ typedef struct
#define FC_EXPORT 0x100 // "export def Func()"
#define FC_NOARGS 0x200 // no a: variables in lambda
#define FC_VIM9 0x400 // defined in vim9 script file
#define FC_CFUNC 0x800 // defined as Lua C func
#define MAX_FUNC_ARGS 20 // maximum number of function arguments
#define VAR_SHORT_LEN 20 // short variable name length