summaryrefslogtreecommitdiff
path: root/src/structs.h
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-06-25 19:27:56 +0200
committerBram Moolenaar <Bram@vim.org>2020-06-25 19:27:56 +0200
commit801ab069341c8652680d63c174530fd4feb2911e (patch)
treeff8d365fe4c9ea1dbd5b5918b3a58568a77ec18e /src/structs.h
parent832adf9bb8cd39d8e982d8a35ed8a6d39b974494 (diff)
downloadvim-git-801ab069341c8652680d63c174530fd4feb2911e.tar.gz
patch 8.2.1054: not so easy to pass a lua function to Vimv8.2.1054
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)
Diffstat (limited to 'src/structs.h')
-rw-r--r--src/structs.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/structs.h b/src/structs.h
index 395088735..e308ff448 100644
--- 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