diff options
| author | Pavel Labath <pavel@labath.sk> | 2020-01-09 14:14:54 +0100 |
|---|---|---|
| committer | Pavel Labath <pavel@labath.sk> | 2020-01-09 14:17:17 +0100 |
| commit | 5c4661b7784115cb330996b3a6461c5927339aef (patch) | |
| tree | c2102bf8d9cccecf919d1e5c6951e02825d1a421 /lldb/include | |
| parent | 4a83f1e171b73b819bcdb486e363b409d25fc629 (diff) | |
| download | bcm5719-llvm-5c4661b7784115cb330996b3a6461c5927339aef.tar.gz bcm5719-llvm-5c4661b7784115cb330996b3a6461c5927339aef.zip | |
[lldb] Modernize OptionValue::SetValueChangedCallback
instead of a function pointer + void*, take a std::function. This
removes a bunch of repetitive, unsafe void* casts.
Diffstat (limited to 'lldb/include')
| -rw-r--r-- | lldb/include/lldb/Interpreter/OptionValue.h | 16 | ||||
| -rw-r--r-- | lldb/include/lldb/Interpreter/OptionValueProperties.h | 3 | ||||
| -rw-r--r-- | lldb/include/lldb/Interpreter/Property.h | 3 | ||||
| -rw-r--r-- | lldb/include/lldb/Target/Process.h | 3 | ||||
| -rw-r--r-- | lldb/include/lldb/Target/Target.h | 29 | ||||
| -rw-r--r-- | lldb/include/lldb/lldb-private-interfaces.h | 2 |
6 files changed, 17 insertions, 39 deletions
diff --git a/lldb/include/lldb/Interpreter/OptionValue.h b/lldb/include/lldb/Interpreter/OptionValue.h index 734c92b4bca..44c7f621a58 100644 --- a/lldb/include/lldb/Interpreter/OptionValue.h +++ b/lldb/include/lldb/Interpreter/OptionValue.h @@ -58,8 +58,7 @@ public: eDumpGroupExport = (eDumpOptionCommand | eDumpOptionName | eDumpOptionValue) }; - OptionValue() - : m_callback(nullptr), m_baton(nullptr), m_value_was_set(false) {} + OptionValue() : m_value_was_set(false) {} virtual ~OptionValue() = default; @@ -304,22 +303,19 @@ public: m_parent_wp = parent_sp; } - void SetValueChangedCallback(OptionValueChangedCallback callback, - void *baton) { - assert(m_callback == nullptr); - m_callback = callback; - m_baton = baton; + void SetValueChangedCallback(std::function<void()> callback) { + assert(!m_callback); + m_callback = std::move(callback); } void NotifyValueChanged() { if (m_callback) - m_callback(m_baton, this); + m_callback(); } protected: lldb::OptionValueWP m_parent_wp; - OptionValueChangedCallback m_callback; - void *m_baton; + std::function<void()> m_callback; bool m_value_was_set; // This can be used to see if a value has been set // by a call to SetValueFromCString(). It is often // handy to know if an option value was set from the diff --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h b/lldb/include/lldb/Interpreter/OptionValueProperties.h index bea2b3c91e0..980f01183ef 100644 --- a/lldb/include/lldb/Interpreter/OptionValueProperties.h +++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h @@ -198,8 +198,7 @@ public: ConstString name); void SetValueChangedCallback(uint32_t property_idx, - OptionValueChangedCallback callback, - void *baton); + std::function<void()> callback); protected: Property *ProtectedGetPropertyAtIndex(uint32_t idx) { diff --git a/lldb/include/lldb/Interpreter/Property.h b/lldb/include/lldb/Interpreter/Property.h index 797aee4be81..76264832705 100644 --- a/lldb/include/lldb/Interpreter/Property.h +++ b/lldb/include/lldb/Interpreter/Property.h @@ -64,8 +64,7 @@ public: uint32_t output_width, bool display_qualified_name) const; - void SetValueChangedCallback(OptionValueChangedCallback callback, - void *baton); + void SetValueChangedCallback(std::function<void()> callback); protected: ConstString m_name; diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 47c5c787040..2ba996d4995 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -85,9 +85,6 @@ public: std::chrono::seconds GetUtilityExpressionTimeout() const; protected: - static void OptionValueChangedCallback(void *baton, - OptionValue *option_value); - Process *m_process; // Can be nullptr for global ProcessProperties }; diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 6f8d60731ac..1e9153c401e 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -209,26 +209,15 @@ public: private: // Callbacks for m_launch_info. - static void Arg0ValueChangedCallback(void *target_property_ptr, - OptionValue *); - static void RunArgsValueChangedCallback(void *target_property_ptr, - OptionValue *); - static void EnvVarsValueChangedCallback(void *target_property_ptr, - OptionValue *); - static void InheritEnvValueChangedCallback(void *target_property_ptr, - OptionValue *); - static void InputPathValueChangedCallback(void *target_property_ptr, - OptionValue *); - static void OutputPathValueChangedCallback(void *target_property_ptr, - OptionValue *); - static void ErrorPathValueChangedCallback(void *target_property_ptr, - OptionValue *); - static void DetachOnErrorValueChangedCallback(void *target_property_ptr, - OptionValue *); - static void DisableASLRValueChangedCallback(void *target_property_ptr, - OptionValue *); - static void DisableSTDIOValueChangedCallback(void *target_property_ptr, - OptionValue *); + void Arg0ValueChangedCallback(); + void RunArgsValueChangedCallback(); + void EnvVarsValueChangedCallback(); + void InputPathValueChangedCallback(); + void OutputPathValueChangedCallback(); + void ErrorPathValueChangedCallback(); + void DetachOnErrorValueChangedCallback(); + void DisableASLRValueChangedCallback(); + void DisableSTDIOValueChangedCallback(); // Member variables. ProcessLaunchInfo m_launch_info; diff --git a/lldb/include/lldb/lldb-private-interfaces.h b/lldb/include/lldb/lldb-private-interfaces.h index 04b78bcc19f..27a2c4c3f27 100644 --- a/lldb/include/lldb/lldb-private-interfaces.h +++ b/lldb/include/lldb/lldb-private-interfaces.h @@ -82,8 +82,6 @@ typedef bool (*BreakpointHitCallback)(void *baton, typedef bool (*WatchpointHitCallback)(void *baton, StoppointCallbackContext *context, lldb::user_id_t watch_id); -typedef void (*OptionValueChangedCallback)(void *baton, - OptionValue *option_value); typedef bool (*ThreadPlanShouldStopHereCallback)( ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, Status &status, void *baton); |

