comparison src/structs.h @ 7943:e875f0fbd9c0 v7.4.1267

commit https://github.com/vim/vim/commit/a03f23351588f04276469cd7742b7ec655bb604b Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 6 18:09:59 2016 +0100 patch 7.4.1267 Problem: Easy to miss handling all types of variables. Solution: Change the variable type into an enum.
author Christian Brabandt <cb@256bit.org>
date Sat, 06 Feb 2016 18:15:04 +0100
parents 98a96e0ca73b
children b74549818500
comparison
equal deleted inserted replaced
7942:5d117679edcd 7943:e875f0fbd9c0
1109 typedef double float_T; 1109 typedef double float_T;
1110 1110
1111 typedef struct listvar_S list_T; 1111 typedef struct listvar_S list_T;
1112 typedef struct dictvar_S dict_T; 1112 typedef struct dictvar_S dict_T;
1113 1113
1114 typedef enum
1115 {
1116 VAR_UNKNOWN = 0,
1117 VAR_NUMBER, /* "v_number" is used */
1118 VAR_STRING, /* "v_string" is used */
1119 VAR_FUNC, /* "v_string" is function name */
1120 VAR_LIST, /* "v_list" is used */
1121 VAR_DICT, /* "v_dict" is used */
1122 VAR_FLOAT, /* "v_float" is used */
1123 VAR_SPECIAL /* "v_number" is used */
1124 } vartype_T;
1125
1114 /* 1126 /*
1115 * Structure to hold an internal variable without a name. 1127 * Structure to hold an internal variable without a name.
1116 */ 1128 */
1117 typedef struct 1129 typedef struct
1118 { 1130 {
1119 char v_type; /* see below: VAR_NUMBER, VAR_STRING, etc. */ 1131 vartype_T v_type;
1120 char v_lock; /* see below: VAR_LOCKED, VAR_FIXED */ 1132 char v_lock; /* see below: VAR_LOCKED, VAR_FIXED */
1121 union 1133 union
1122 { 1134 {
1123 varnumber_T v_number; /* number value */ 1135 varnumber_T v_number; /* number value */
1124 #ifdef FEAT_FLOAT 1136 #ifdef FEAT_FLOAT
1127 char_u *v_string; /* string value (can be NULL!) */ 1139 char_u *v_string; /* string value (can be NULL!) */
1128 list_T *v_list; /* list value (can be NULL!) */ 1140 list_T *v_list; /* list value (can be NULL!) */
1129 dict_T *v_dict; /* dict value (can be NULL!) */ 1141 dict_T *v_dict; /* dict value (can be NULL!) */
1130 } vval; 1142 } vval;
1131 } typval_T; 1143 } typval_T;
1132
1133 /* Values for "v_type". */
1134 #define VAR_UNKNOWN 0
1135 #define VAR_NUMBER 1 /* "v_number" is used */
1136 #define VAR_STRING 2 /* "v_string" is used */
1137 #define VAR_FUNC 3 /* "v_string" is function name */
1138 #define VAR_LIST 4 /* "v_list" is used */
1139 #define VAR_DICT 5 /* "v_dict" is used */
1140 #define VAR_FLOAT 6 /* "v_float" is used */
1141 #define VAR_SPECIAL 7 /* "v_number" is used */
1142 1144
1143 /* Values for "dv_scope". */ 1145 /* Values for "dv_scope". */
1144 #define VAR_SCOPE 1 /* a:, v:, s:, etc. scope dictionaries */ 1146 #define VAR_SCOPE 1 /* a:, v:, s:, etc. scope dictionaries */
1145 #define VAR_DEF_SCOPE 2 /* l:, g: scope dictionaries: here funcrefs are not 1147 #define VAR_DEF_SCOPE 2 /* l:, g: scope dictionaries: here funcrefs are not
1146 allowed to mask existing functions */ 1148 allowed to mask existing functions */