refactor(options): make os_oldval and os_newval use OptValData

This commit is contained in:
Famiu Haque
2023-10-14 20:02:42 +06:00
parent af010e23f3
commit f1a58a8dcc
3 changed files with 31 additions and 47 deletions

View File

@@ -17,16 +17,17 @@ typedef enum {
kOptValTypeString,
} OptValType;
typedef union {
// boolean options are actually tri-states because they have a third "None" value.
TriState boolean;
OptInt number;
String string;
} OptValData;
/// Option value
typedef struct {
OptValType type;
union {
// boolean options are actually tri-states because they have a third "None" value.
TriState boolean;
OptInt number;
String string;
} data;
OptValData data;
} OptVal;
/// :set operator types
@@ -46,19 +47,10 @@ typedef struct {
int os_idx;
int os_flags;
/// old value of the option (can be a string, number or a boolean)
union {
const OptInt number;
const bool boolean;
const char *string;
} os_oldval;
/// new value of the option (can be a string, number or a boolean)
union {
const OptInt number;
const bool boolean;
const char *string;
} os_newval;
/// Old value of the option.
OptValData os_oldval;
/// New value of the option.
OptValData os_newval;
/// When set by the called function: Stop processing the option further.
/// Currently only used for boolean options.