comparison 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
comparison
equal deleted inserted replaced
21005:3f0abea9bed2 21006:ae185f35e256
1527 garray_T bv_ga; // growarray with the data 1527 garray_T bv_ga; // growarray with the data
1528 int bv_refcount; // reference count 1528 int bv_refcount; // reference count
1529 char bv_lock; // zero, VAR_LOCKED, VAR_FIXED 1529 char bv_lock; // zero, VAR_LOCKED, VAR_FIXED
1530 }; 1530 };
1531 1531
1532 typedef int (*cfunc_T)(int argcount, typval_T *argvars, typval_T *rettv, void *state);
1533 typedef void (*cfunc_free_T)(void *state);
1534
1532 #if defined(FEAT_EVAL) || defined(PROTO) 1535 #if defined(FEAT_EVAL) || defined(PROTO)
1533 typedef struct funccall_S funccall_T; 1536 typedef struct funccall_S funccall_T;
1534 1537
1535 // values used for "uf_dfunc_idx" 1538 // values used for "uf_dfunc_idx"
1536 typedef enum { 1539 typedef enum {
1560 int *uf_def_arg_idx; // instruction indexes for evaluating 1563 int *uf_def_arg_idx; // instruction indexes for evaluating
1561 // uf_def_args; length: uf_def_args.ga_len + 1 1564 // uf_def_args; length: uf_def_args.ga_len + 1
1562 char_u *uf_va_name; // name from "...name" or NULL 1565 char_u *uf_va_name; // name from "...name" or NULL
1563 type_T *uf_va_type; // type from "...name: type" or NULL 1566 type_T *uf_va_type; // type from "...name: type" or NULL
1564 type_T *uf_func_type; // type of the function, &t_func_any if unknown 1567 type_T *uf_func_type; // type of the function, &t_func_any if unknown
1568 # if defined(FEAT_LUA)
1569 cfunc_T uf_cb; // callback function for cfunc
1570 cfunc_free_T uf_cb_free; // callback function to free cfunc
1571 void *uf_cb_state; // state of uf_cb
1572 # endif
1565 1573
1566 garray_T uf_lines; // function lines 1574 garray_T uf_lines; // function lines
1567 # ifdef FEAT_PROFILE 1575 # ifdef FEAT_PROFILE
1568 int uf_profiling; // TRUE when func is being profiled 1576 int uf_profiling; // TRUE when func is being profiled
1569 int uf_prof_initialized; 1577 int uf_prof_initialized;
1605 #define FC_SANDBOX 0x40 // function defined in the sandbox 1613 #define FC_SANDBOX 0x40 // function defined in the sandbox
1606 #define FC_DEAD 0x80 // function kept only for reference to dfunc 1614 #define FC_DEAD 0x80 // function kept only for reference to dfunc
1607 #define FC_EXPORT 0x100 // "export def Func()" 1615 #define FC_EXPORT 0x100 // "export def Func()"
1608 #define FC_NOARGS 0x200 // no a: variables in lambda 1616 #define FC_NOARGS 0x200 // no a: variables in lambda
1609 #define FC_VIM9 0x400 // defined in vim9 script file 1617 #define FC_VIM9 0x400 // defined in vim9 script file
1618 #define FC_CFUNC 0x800 // defined as Lua C func
1610 1619
1611 #define MAX_FUNC_ARGS 20 // maximum number of function arguments 1620 #define MAX_FUNC_ARGS 20 // maximum number of function arguments
1612 #define VAR_SHORT_LEN 20 // short variable name length 1621 #define VAR_SHORT_LEN 20 // short variable name length
1613 #define FIXVAR_CNT 12 // number of fixed variables 1622 #define FIXVAR_CNT 12 // number of fixed variables
1614 1623