Mercurial > vim
diff src/structs.h @ 21006:ae185f35e256 v8.2.1054
patch 8.2.1054: not so easy to pass a lua function to Vim
Commit: https://github.com/vim/vim/commit/801ab069341c8652680d63c174530fd4feb2911e
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jun 25 19:27:56 2020 +0200
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 25 Jun 2020 19:30:21 +0200 |
parents | 3af71cbcfdbe |
children | d9e0db9b2b99 |
line wrap: on
line diff
--- a/src/structs.h +++ b/src/structs.h @@ -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