From c41f264a1dba68c89b4a224a70e3a5783f7fa879 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Tue, 24 Jun 2025 17:55:48 -0400 Subject: Remove implicit conversions from Confidence to underlying type, these can cause bugs and also issues with C++20 --- binaryninjaapi.h | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 48f11f24..3cdb1498 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -366,6 +366,24 @@ namespace BinaryNinja { T* GetPtr() const { return m_obj; } }; + template + bool operator==(T* a, const Ref& b) + { + return a == b.GetPtr(); + } + + template + bool operator!=(T* a, const Ref& b) + { + return a != b.GetPtr(); + } + + template + bool operator<(T* a, const Ref& b) + { + return a < b.GetPtr(); + } + /*! \ingroup refcount */ @@ -389,8 +407,26 @@ namespace BinaryNinja { T* GetPtr() const { return m_obj; } }; + template + bool operator==(T* a, const CallbackRef& b) + { + return a == b.GetPtr(); + } + + template + bool operator!=(T* a, const CallbackRef& b) + { + return a != b.GetPtr(); + } + + template + bool operator<(T* a, const CallbackRef& b) + { + return a < b.GetPtr(); + } + /*! - \ingroup confidence + \ingroup confidence */ class ConfidenceBase { @@ -499,8 +535,6 @@ namespace BinaryNinja { Confidence(const Confidence>& v) : ConfidenceBase(v.m_confidence), m_value(v.m_value) {} - operator Ref() const { return m_value; } - operator T*() const { return m_value.GetPtr(); } T* operator->() const { return m_value.GetPtr(); } bool operator!() const { return !m_value; } @@ -4281,7 +4315,7 @@ namespace BinaryNinja { struct DataVariable { DataVariable() {} - DataVariable(uint64_t a, Type* t, bool d) : address(a), type(t), autoDiscovered(d) {} + DataVariable(uint64_t a, const Confidence>& t, bool d) : address(a), type(t), autoDiscovered(d) {} uint64_t address; Confidence> type; -- cgit v1.3.1