confparse, conftypes: Replace flags with their new names.

The old names remain as #defines that cause variables to get one or
more flags.

Now every flag-testing function in confparse.c tests exactly one flag.
This commit is contained in:
Nick Mathewson 2019-09-05 11:48:46 -04:00 committed by David Goulet
parent 1b3b6d9f2d
commit 9b571d4729
2 changed files with 50 additions and 38 deletions

View File

@ -531,7 +531,7 @@ config_var_has_flag(const config_var_t *var, uint32_t flag)
static bool
config_var_is_replaced_on_set(const config_var_t *var)
{
return ! config_var_has_flag(var, VTFLAG_CUMULATIVE);
return ! config_var_has_flag(var, CFLG_NOREPLACE);
}
/**
@ -541,7 +541,7 @@ config_var_is_replaced_on_set(const config_var_t *var)
bool
config_var_is_settable(const config_var_t *var)
{
return ! config_var_has_flag(var, CVFLAG_OBSOLETE | VTFLAG_UNSETTABLE);
return ! config_var_has_flag(var, CFLG_NOSET);
}
/**
@ -561,23 +561,6 @@ config_var_is_gettable(const config_var_t *var)
return true;
}
/**
* Return true iff this is variable is "derived" from another -- that is,
* inspecting this variable inspects part of another, and changing this
* variable changes part of another.
*
* Derived variables require special handling in several ways: they do not
* need to be copied independently when we are copying a config object, since
* copying the variable they are derived from copies them too. Similarly,
* they do not need to be compared independently when listing changes, since
* comparing the variable that they are derived from compares them too.
**/
static bool
config_var_is_derived(const config_var_t *var)
{
return config_var_has_flag(var, VTFLAG_CONTAINED);
}
/**
* Return true iff we need to check <b>var</b> for changes when we are
* comparing config options for changes.
@ -589,7 +572,7 @@ config_var_is_derived(const config_var_t *var)
static bool
config_var_should_list_changes(const config_var_t *var)
{
return ! config_var_is_derived(var);
return ! config_var_has_flag(var, CFLG_NOCMP);
}
/**
@ -603,7 +586,7 @@ config_var_should_list_changes(const config_var_t *var)
static bool
config_var_needs_copy(const config_var_t *var)
{
return ! config_var_is_derived(var);
return ! config_var_has_flag(var, CFLG_NOCOPY);
}
/**h
@ -613,7 +596,7 @@ config_var_needs_copy(const config_var_t *var)
bool
config_var_is_listable(const config_var_t *var)
{
return ! config_var_has_flag(var, CVFLAG_INVISIBLE);
return ! config_var_has_flag(var, CFLG_NOLIST);
}
/**
@ -627,7 +610,7 @@ config_var_is_listable(const config_var_t *var)
static bool
config_var_is_dumpable(const config_var_t *var)
{
return ! config_var_has_flag(var, VTFLAG_CONTAINED | CVFLAG_NODUMP);
return ! config_var_has_flag(var, CFLG_NODUMP);
}
/*

View File

@ -131,42 +131,71 @@ typedef struct struct_magic_decl_t {
ptrdiff_t magic_offset;
} struct_magic_decl_t;
/**
* Flag to indicate that an option is obsolete. Any attempt to set or
* fetch this option should produce a warning.
**/
#define CVFLAG_OBSOLETE (1u<<0)
/**
* Flag to indicate that an option is undumpable. An undumpable option is
* never saved to disk. For historical reasons it is prefixed with __ but
* not with ___.
* never saved to disk.
*
* For historical reasons it is prefixed with __ but not with ___.
**/
#define CVFLAG_NODUMP (1u<<1)
#define CFLG_NODUMP (1u<<0)
/**
* Flag to indicate that an option is "invisible". An invisible option
* is always undumpable, and we don't tell the controller about it.
* For historical reasons it is prefixed with ___.
**/
#define CVFLAG_INVISIBLE (1u<<2)
#define CFLG_NOLIST (1u<<1)
/**
* Flag for var_type_def_t.
* Set iff a variable of this type can never be set directly by name.
**/
#define VTFLAG_UNSETTABLE (1u<<3)
#define CFLG_NOSET (1u<<2)
/**
* Flag for var_type_def_t.
* Set iff a variable of this type is always contained in another
* variable, and as such doesn't need to be dumped or copied
* independently.
* Set iff a variable of this type is does not need to be copied when copying
* the structure that contains it.
**/
#define VTFLAG_CONTAINED (1u<<4)
#define CFLG_NOCOPY (1u<<3)
/**
* Flag for var_type_def_t.
* Set iff a variable of this type does not need to be compared when comparing
* two objects that contain it.
**/
#define CFLG_NOCMP (1u<<4)
/**
* Flag for var_type_def_t.
* Set iff a variable of this type can be set more than once without
* destroying older values. Such variables should implement "mark_fragile".
*/
#define VTFLAG_CUMULATIVE (1u<<5)
#define CFLG_NOREPLACE (1u<<5)
/* Aliases for old individual options. These will get removed soon. */
#define CVFLAG_NODUMP CFLG_NODUMP
#define VTFLAG_CUMULATIVE CFLG_NOREPLACE
#define VTFLAG_UNSETTABLE CFLG_NOSET
/**
* Set of flags to make a variable "derived" -- so that inspecting this
* variable inspects part of another, and changing this variable changes part
* of another.
*
* Derived variables require special handling in several ways: they do not
* need to be copied independently when we are copying a config object, since
* copying the variable they are derived from copies them too. Similarly,
* they do not need to be compared independently when listing changes, since
* comparing the variable that they are derived from compares them too.
**/
#define VTFLAG_CONTAINED \
(CFLG_NOCOPY | CFLG_NOCMP | CFLG_NODUMP)
/** Set of options to make a flag invisible. */
#define CVFLAG_INVISIBLE \
(CFLG_NODUMP | CFLG_NOSET | CFLG_NOLIST)
/**
* Set of flags to indicate that a configuration option is obsolete.
**/
#define CVFLAG_OBSOLETE \
(CFLG_NOSET | CFLG_NOLIST | CFLG_NODUMP | CFLG_NOCOPY | CFLG_NOCMP)
/** A variable allowed in the configuration file or on the command line. */
typedef struct config_var_t {