diff options
author | Abseil Team <absl-team@google.com> | 2020-02-21T20·51-0800 |
---|---|---|
committer | CJ Johnson <johnsoncj@google.com> | 2020-02-21T20·56-0500 |
commit | b69c7d880caddfc25bf348dbcfe9d45fdd8bc6e6 (patch) | |
tree | 0ceef2d75071fdfdf7a47c2978a4df5b422001ed /absl/flags/internal/flag.h | |
parent | 2a5633fc077a58528cdbfe78720f3f6bfdc6044d (diff) |
Export of internal Abseil changes
-- 00f5301405423005d9129935c05f20155536cc1a by CJ Johnson <johnsoncj@google.com>: Removes usage of std::aligned_storage from Abseil implementation details PiperOrigin-RevId: 296492301 -- fc11d15f91764612fba080669d2381dc181df52b by Abseil Team <absl-team@google.com>: Fix absl::bind_front documentation. PiperOrigin-RevId: 296482945 -- 0164c595c129c46bf21ae74eba5399a1da5f140b by Gennadiy Rozental <rogeeff@google.com>: Automated g4 rollback of changelist 296320700. PiperOrigin-RevId: 296439968 -- 1eb295700758ca0894d872b2de7c675b4ad679af by Abseil Team <absl-team@google.com>: Removes duplicate comments. PiperOrigin-RevId: 296433214 -- c30c01caae02d2fa4ef783d988de6bebb9757c39 by Derek Mauro <dmauro@google.com>: Merge GitHub #621: Add RISCV support to GetProgramCounter() Fixes #621 PiperOrigin-RevId: 296351174 -- 95d4498167596fd7543e025bdfe9a8da9e2ca3c8 by Abseil Team <absl-team@google.com>: Automated g4 rollback of changelist 296320700. PiperOrigin-RevId: 296348701 -- b193f0543e0cec54dddb2ed51f45dc489c8d06d5 by Gennadiy Rozental <rogeeff@google.com>: Change TryParse interface to return managed value. In addition introduce companion StoreValue routine which consumes pointer to source value and stores the value inside of FlagImpl. In a follow up CL we will change StoreValue implementation to behave differently depending on "value storage kind". We also rename default_src_ to default_value_. PiperOrigin-RevId: 296320700 -- 57e942b485d12912a0a8d0d0b35fa2a62847020f by Derek Mauro <dmauro@google.com>: Merge GitHub #622 * Add missing #ifdef conditionals for ABSL_HAVE_VDSO_SUPPORT PiperOrigin-RevId: 296272830 GitOrigin-RevId: 00f5301405423005d9129935c05f20155536cc1a Change-Id: I1b05eeaf1280f95fb0a2c5f3654995a87c792893
Diffstat (limited to 'absl/flags/internal/flag.h')
-rw-r--r-- | absl/flags/internal/flag.h | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/absl/flags/internal/flag.h b/absl/flags/internal/flag.h index ec6734870c7e..c1beda8ebc00 100644 --- a/absl/flags/internal/flag.h +++ b/absl/flags/internal/flag.h @@ -363,7 +363,7 @@ struct DynValueDeleter { if (op != nullptr) Delete(op, ptr); } - const FlagOpFn op; + FlagOpFn op; }; class FlagImpl { @@ -380,7 +380,7 @@ class FlagImpl { on_command_line_(false), counter_(0), callback_(nullptr), - default_src_(default_value_gen), + default_value_(default_value_gen), data_guard_{} {} // Constant access methods @@ -392,10 +392,6 @@ class FlagImpl { std::string DefaultValue() const ABSL_LOCKS_EXCLUDED(*DataGuard()); std::string CurrentValue() const ABSL_LOCKS_EXCLUDED(*DataGuard()); void Read(void* dst) const ABSL_LOCKS_EXCLUDED(*DataGuard()); - // Attempts to parse supplied `value` std::string. If parsing is successful, then - // it replaces `dst` with the new value. - bool TryParse(void** dst, absl::string_view value, std::string* err) const - ABSL_EXCLUSIVE_LOCKS_REQUIRED(*DataGuard()); template <typename T, typename std::enable_if< !IsAtomicFlagTypeTrait<T>::value, int>::type = 0> @@ -466,8 +462,15 @@ class FlagImpl { // Returns heap allocated value of type T initialized with default value. std::unique_ptr<void, DynValueDeleter> MakeInitValue() const ABSL_EXCLUSIVE_LOCKS_REQUIRED(*DataGuard()); - // Lazy initialization of the Flag's data. + // Flag initialization called via absl::call_once. void Init(); + // Attempts to parse supplied `value` std::string. If parsing is successful, + // returns new value. Otherwsie returns nullptr. + std::unique_ptr<void, DynValueDeleter> TryParse(absl::string_view value, + std::string* err) const + ABSL_EXCLUSIVE_LOCKS_REQUIRED(*DataGuard()); + // Stores the flag value based on the pointer to the source. + void StoreValue(const void* src) ABSL_EXCLUSIVE_LOCKS_REQUIRED(*DataGuard()); FlagHelpKind HelpSourceKind() const { return static_cast<FlagHelpKind>(help_source_kind_); @@ -511,7 +514,7 @@ class FlagImpl { // Mutable flag's state (guarded by `data_guard_`). - // If def_kind_ == kDynamicValue, default_src_ holds a dynamically allocated + // If def_kind_ == kDynamicValue, default_value_ holds a dynamically allocated // value. uint8_t def_kind_ : 1 ABSL_GUARDED_BY(*DataGuard()); // Has this flag's value been modified? @@ -527,7 +530,7 @@ class FlagImpl { // value specified in ABSL_FLAG or pointer to the dynamically set default // value via SetCommandLineOptionWithMode. def_kind_ is used to distinguish // these two cases. - FlagDefaultSrc default_src_ ABSL_GUARDED_BY(*DataGuard()); + FlagDefaultSrc default_value_ ABSL_GUARDED_BY(*DataGuard()); // Current Flag Value FlagValue value_; @@ -542,8 +545,8 @@ class FlagImpl { }; /////////////////////////////////////////////////////////////////////////////// -// The "unspecified" implementation of Flag object parameterized by the -// flag's value type. +// The Flag object parameterized by the flag's value type. This class implements +// flag reflection handle interface. template <typename T> class Flag final : public flags_internal::CommandLineFlag { |