Make the global feature set an instance variable

Allow it to be inlined.
This commit is contained in:
ridiculousfish 2020-09-12 17:35:21 -07:00
parent 1c43030d79
commit 6e11750479
2 changed files with 10 additions and 7 deletions

View file

@ -6,12 +6,10 @@
#include "wcstringutil.h"
features_t::features_t() = default;
/// The set of features applying to this instance.
static features_t global_features;
const features_t &fish_features() { return global_features; }
features_t &mutable_fish_features() { return global_features; }
features_t features_t::global_features;
const features_t::metadata_t features_t::metadata[features_t::flag_count] = {
{stderr_nocaret, L"stderr-nocaret", L"3.0", L"^ no longer redirects stderr"},

View file

@ -64,19 +64,24 @@ class features_t {
/// Return the metadata for a particular name, or nullptr if not found.
static const struct metadata_t *metadata_for(const wchar_t *name);
/// The singleton shared feature set.
static features_t global_features;
private:
features_t();
/// Values for the flags.
bool values[flag_count] = {};
};
/// Return the global set of features for fish. This is const to prevent accidental mutation.
const features_t &fish_features();
inline const features_t &fish_features() { return features_t::global_features; }
/// Perform a feature test on the global set of features.
inline bool feature_test(features_t::flag_t f) { return fish_features().test(f); }
/// Return the global set of features for fish, but mutable. In general fish features should be set
/// at startup only.
features_t &mutable_fish_features();
inline features_t &mutable_fish_features() { return features_t::global_features; }
#endif