aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval_defs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/eval_defs.h')
-rw-r--r--src/nvim/eval_defs.h61
1 files changed, 39 insertions, 22 deletions
diff --git a/src/nvim/eval_defs.h b/src/nvim/eval_defs.h
index cdad1f3197..56833f97d8 100644
--- a/src/nvim/eval_defs.h
+++ b/src/nvim/eval_defs.h
@@ -16,38 +16,55 @@ typedef double float_T;
typedef struct listvar_S list_T;
typedef struct dictvar_S dict_T;
-/*
- * Structure to hold an internal variable without a name.
- */
+/// Special variable values
+typedef enum {
+ kSpecialVarNull, ///< v:null
+ kSpecialVarNone, ///< v:none
+ kSpecialVarFalse, ///< v:false
+ kSpecialVarTrue, ///< v:true
+} SpecialVarValue;
+
+/// Structure that holds an internal variable value
typedef struct {
- char v_type; /* see below: VAR_NUMBER, VAR_STRING, etc. */
- char v_lock; /* see below: VAR_LOCKED, VAR_FIXED */
+ VarType v_type; ///< Variable type.
+ VarLockStatus v_lock; ///< Variable lock status.
union {
- varnumber_T v_number; /* number value */
- float_T v_float; /* floating number value */
- char_u *v_string; /* string value (can be NULL!) */
- list_T *v_list; /* list value (can be NULL!) */
- dict_T *v_dict; /* dict value (can be NULL!) */
- } vval;
+ varnumber_T v_number; ///< Number, for VAR_NUMBER.
+ SpecialVarValue v_special; ///< Special value, for VAR_SPECIAL.
+ float_T v_float; ///< Floating-point number, for VAR_FLOAT.
+ 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.
+ } vval; ///< Actual value.
} typval_T;
-/* Values for "v_type". */
-#define VAR_UNKNOWN 0
-#define VAR_NUMBER 1 /* "v_number" is used */
-#define VAR_STRING 2 /* "v_string" is used */
-#define VAR_FUNC 3 /* "v_string" is function name */
-#define VAR_LIST 4 /* "v_list" is used */
-#define VAR_DICT 5 /* "v_dict" is used */
-#define VAR_FLOAT 6 /* "v_float" is used */
+/// VimL variable types, for use in typval_T.v_type
+///
+/// @warning Numbers are part of the user API (returned by type()), so they must
+/// not be changed.
+typedef enum {
+ VAR_UNKNOWN = 0, ///< Unknown (unspecified) value.
+ VAR_NUMBER = 1, ///< Number, .v_number is used.
+ VAR_STRING = 2, ///< String, .v_string is used.
+ VAR_FUNC = 3, ///< Function referene, .v_string is used for function name.
+ VAR_LIST = 4, ///< List, .v_list is used.
+ VAR_DICT = 5, ///< Dictionary, .v_dict is used.
+ VAR_FLOAT = 6, ///< Floating-point value, .v_float is used.
+ VAR_SPECIAL = 7, ///< Special value (true, false, null, none), .v_special
+ ///< is used.
+} VarType;
/* Values for "dv_scope". */
#define VAR_SCOPE 1 /* a:, v:, s:, etc. scope dictionaries */
#define VAR_DEF_SCOPE 2 /* l:, g: scope dictionaries: here funcrefs are not
allowed to mask existing functions */
-/* Values for "v_lock". */
-#define VAR_LOCKED 1 /* locked with lock(), can use unlock() */
-#define VAR_FIXED 2 /* locked forever */
+/// Variable lock status for typval_T.v_lock
+typedef enum {
+ VAR_UNLOCKED = 0, ///< Not locked.
+ VAR_LOCKED, ///< User lock, can be unlocked.
+ VAR_FIXED, ///< Locked forever.
+} VarLockStatus;
/*
* Structure to hold an item of a list: an internal variable without a name.