From 521e45f2a8c0619335288accdda0f0aaa1fc6513 Mon Sep 17 00:00:00 2001 From: Michael Ennen Date: Mon, 24 Oct 2016 23:53:07 -0700 Subject: vim-patch:7.4.1559 Problem: Passing cookie to a callback is clumsy. Solution: Change function() to take arguments and return a partial. https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710 --- src/nvim/eval_defs.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/nvim/eval_defs.h') diff --git a/src/nvim/eval_defs.h b/src/nvim/eval_defs.h index 91d544074f..a33ac10e61 100644 --- a/src/nvim/eval_defs.h +++ b/src/nvim/eval_defs.h @@ -15,6 +15,7 @@ typedef double float_T; typedef struct listvar_S list_T; typedef struct dictvar_S dict_T; +typedef struct partial_S partial_T; /// Special variable values typedef enum { @@ -35,7 +36,8 @@ typedef enum { VAR_UNKNOWN = 0, ///< Unknown (unspecified) value. VAR_NUMBER, ///< Number, .v_number is used. VAR_STRING, ///< String, .v_string is used. - VAR_FUNC, ///< Function referene, .v_string is used for function name. + VAR_FUNC, ///< Function reference, .v_string is used as function name. + VAR_PARTIAL, ///< Partial, .v_partial is used. VAR_LIST, ///< List, .v_list is used. VAR_DICT, ///< Dictionary, .v_dict is used. VAR_FLOAT, ///< Floating-point value, .v_float is used. @@ -54,6 +56,7 @@ typedef struct { char_u *v_string; ///< String, for VAR_STRING and VAR_FUNC, can be NULL. list_T *v_list; ///< List for VAR_LIST, can be NULL. dict_T *v_dict; ///< Dictionary for VAR_DICT, can be NULL. + partial_T *v_partial; ///< Closure: function with args. } vval; ///< Actual value. } typval_T; @@ -144,6 +147,14 @@ struct dictvar_S { QUEUE watchers; ///< Dictionary key watchers set by user code. }; +struct partial_S { + int pt_refcount; ///< Reference count. + char_u *pt_name; ///< Function name. + int pt_argc; ///< Number of arguments. + typval_T *pt_argv; ///< Arguments in allocated array. + dict_T *pt_dict; ///< Dict for "self". +}; + // structure used for explicit stack while garbage collecting hash tables typedef struct ht_stack_S { hashtab_T *ht; -- cgit From c82dc7a6fd4987fee72320133579b008815b28d1 Mon Sep 17 00:00:00 2001 From: Michael Ennen Date: Fri, 28 Oct 2016 12:38:36 -0700 Subject: vim-patch:7.4.1836 Problem: When using a partial on a dictionary it always gets bound to that dictionary. Solution: Make a difference between binding a function to a dictionary explicitly or automatically. https://github.com/vim/vim/commit/1d429610bf9e99a6252be8abbc910d6667e4d1da --- src/nvim/eval_defs.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/eval_defs.h') diff --git a/src/nvim/eval_defs.h b/src/nvim/eval_defs.h index a33ac10e61..74d0782356 100644 --- a/src/nvim/eval_defs.h +++ b/src/nvim/eval_defs.h @@ -150,6 +150,8 @@ struct dictvar_S { struct partial_S { int pt_refcount; ///< Reference count. char_u *pt_name; ///< Function name. + bool pt_auto; ///< when true the partial was created for using + ///< dict.member in handle_subscript(). int pt_argc; ///< Number of arguments. typval_T *pt_argv; ///< Arguments in allocated array. dict_T *pt_dict; ///< Dict for "self". -- cgit From a21c687661eac61702fe492264a3c9036bc62f41 Mon Sep 17 00:00:00 2001 From: Michael Ennen Date: Sat, 29 Oct 2016 14:55:53 -0700 Subject: Fixes. --- src/nvim/eval_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval_defs.h') diff --git a/src/nvim/eval_defs.h b/src/nvim/eval_defs.h index 74d0782356..f478d19ca1 100644 --- a/src/nvim/eval_defs.h +++ b/src/nvim/eval_defs.h @@ -37,12 +37,12 @@ typedef enum { VAR_NUMBER, ///< Number, .v_number is used. VAR_STRING, ///< String, .v_string is used. VAR_FUNC, ///< Function reference, .v_string is used as function name. - VAR_PARTIAL, ///< Partial, .v_partial is used. VAR_LIST, ///< List, .v_list is used. VAR_DICT, ///< Dictionary, .v_dict is used. VAR_FLOAT, ///< Floating-point value, .v_float is used. VAR_SPECIAL, ///< Special value (true, false, null), .v_special ///< is used. + VAR_PARTIAL, ///< Partial, .v_partial is used. } VarType; /// Structure that holds an internal variable value -- cgit