@@ -428,6 +428,7 @@ static void f_test_autochdir(typval_T *argvars, typval_T *rettv);
428428static void f_test_feedinput (typval_T * argvars , typval_T * rettv );
429429static void f_test_option_not_set (typval_T * argvars , typval_T * rettv );
430430static void f_test_override (typval_T * argvars , typval_T * rettv );
431+ static void f_test_refcount (typval_T * argvars , typval_T * rettv );
431432static void f_test_garbagecollect_now (typval_T * argvars , typval_T * rettv );
432433static void f_test_ignore_error (typval_T * argvars , typval_T * rettv );
433434static void f_test_null_blob (typval_T * argvars , typval_T * rettv );
@@ -952,7 +953,7 @@ static struct fst
952953 {"test_feedinput" , 1 , 1 , f_test_feedinput },
953954 {"test_garbagecollect_now" , 0 , 0 , f_test_garbagecollect_now },
954955 {"test_ignore_error" , 1 , 1 , f_test_ignore_error },
955- {"test_null_blob" , 0 , 0 , f_test_null_blob },
956+ {"test_null_blob" , 0 , 0 , f_test_null_blob },
956957#ifdef FEAT_JOB_CHANNEL
957958 {"test_null_channel" , 0 , 0 , f_test_null_channel },
958959#endif
@@ -964,7 +965,8 @@ static struct fst
964965 {"test_null_partial" , 0 , 0 , f_test_null_partial },
965966 {"test_null_string" , 0 , 0 , f_test_null_string },
966967 {"test_option_not_set" , 1 , 1 , f_test_option_not_set },
967- {"test_override" , 2 , 2 , f_test_override },
968+ {"test_override" , 2 , 2 , f_test_override },
969+ {"test_refcount" , 1 , 1 , f_test_refcount },
968970#ifdef FEAT_GUI
969971 {"test_scrollbar" , 3 , 3 , f_test_scrollbar },
970972#endif
@@ -13846,6 +13848,67 @@ f_test_override(typval_T *argvars, typval_T *rettv UNUSED)
1384613848 }
1384713849}
1384813850
13851+ /*
13852+ * "test_refcount({expr})" function
13853+ */
13854+ static void
13855+ f_test_refcount (typval_T * argvars , typval_T * rettv )
13856+ {
13857+ int retval = -1 ;
13858+
13859+ switch (argvars [0 ].v_type )
13860+ {
13861+ case VAR_UNKNOWN :
13862+ case VAR_NUMBER :
13863+ case VAR_FLOAT :
13864+ case VAR_SPECIAL :
13865+ case VAR_STRING :
13866+ break ;
13867+ case VAR_JOB :
13868+ #ifdef FEAT_JOB_CHANNEL
13869+ if (argvars [0 ].vval .v_job != NULL )
13870+ retval = argvars [0 ].vval .v_job -> jv_refcount - 1 ;
13871+ #endif
13872+ break ;
13873+ case VAR_CHANNEL :
13874+ #ifdef FEAT_JOB_CHANNEL
13875+ if (argvars [0 ].vval .v_channel != NULL )
13876+ retval = argvars [0 ].vval .v_channel -> ch_refcount - 1 ;
13877+ #endif
13878+ break ;
13879+ case VAR_FUNC :
13880+ if (argvars [0 ].vval .v_string != NULL )
13881+ {
13882+ ufunc_T * fp ;
13883+
13884+ fp = find_func (argvars [0 ].vval .v_string );
13885+ if (fp != NULL )
13886+ retval = fp -> uf_refcount ;
13887+ }
13888+ break ;
13889+ case VAR_PARTIAL :
13890+ if (argvars [0 ].vval .v_partial != NULL )
13891+ retval = argvars [0 ].vval .v_partial -> pt_refcount - 1 ;
13892+ break ;
13893+ case VAR_BLOB :
13894+ if (argvars [0 ].vval .v_blob != NULL )
13895+ retval = argvars [0 ].vval .v_blob -> bv_refcount - 1 ;
13896+ break ;
13897+ case VAR_LIST :
13898+ if (argvars [0 ].vval .v_list != NULL )
13899+ retval = argvars [0 ].vval .v_list -> lv_refcount - 1 ;
13900+ break ;
13901+ case VAR_DICT :
13902+ if (argvars [0 ].vval .v_dict != NULL )
13903+ retval = argvars [0 ].vval .v_dict -> dv_refcount - 1 ;
13904+ break ;
13905+ }
13906+
13907+ rettv -> v_type = VAR_NUMBER ;
13908+ rettv -> vval .v_number = retval ;
13909+
13910+ }
13911+
1384913912/*
1385013913 * "test_garbagecollect_now()" function
1385113914 */
0 commit comments