diff options
| author | Pavel Labath <pavel@labath.sk> | 2019-04-02 10:18:46 +0000 |
|---|---|---|
| committer | Pavel Labath <pavel@labath.sk> | 2019-04-02 10:18:46 +0000 |
| commit | 4bc0500635436dca11d18f1385ff668eb36307b8 (patch) | |
| tree | 0d677161171629138dfab879ba7e28dfaafc782f /lldb/scripts/interface | |
| parent | 76f2259dde8d5dbafa9283615befd7d002c89f75 (diff) | |
| download | bcm5719-llvm-4bc0500635436dca11d18f1385ff668eb36307b8.tar.gz bcm5719-llvm-4bc0500635436dca11d18f1385ff668eb36307b8.zip | |
Make operator==s consistent between c++ and python APIs
Summary:
modify-python-lldb.py had code to insert python equality operators to
some classes. Some of those classes already had c++ equality operators,
and some didn't.
This makes the situation more consistent, by removing all equality
handilng from modify-python-lldb. Instead, I add c++ operators to
classes where they were missing, and expose them in the swig interface
files so that they are available to python too.
The only tricky case was the SBAddress class, which had an operator==
defined as a free function, which is not handled by swig. This function
cannot be removed without breaking ABI, and we cannot add an extra
operator== member, as that would make equality comparisons ambiguous.
For this class, I define a python __eq__ function by hand and have it
delegate to the operator!=, which I have defined as a member function.
This isn't fully NFC, as the semantics of some equality functions in
python changes slightly, but I believe it changes for the better (e.g.,
previously SBBreakpoint.__eq__ would consider two breakpoints with the
same ID as equal, even if they belonged to different targets; now they
are only equal if they belong to the same target).
Reviewers: jingham, clayborg, zturner
Subscribers: jdoerfert, JDevlieghere, lldb-commits
Differential Revision: https://reviews.llvm.org/D59819
llvm-svn: 357463
Diffstat (limited to 'lldb/scripts/interface')
| -rw-r--r-- | lldb/scripts/interface/SBAddress.i | 9 | ||||
| -rw-r--r-- | lldb/scripts/interface/SBBreakpoint.i | 4 | ||||
| -rw-r--r-- | lldb/scripts/interface/SBFileSpec.i | 4 | ||||
| -rw-r--r-- | lldb/scripts/interface/SBModule.i | 4 | ||||
| -rw-r--r-- | lldb/scripts/interface/SBWatchpoint.i | 4 |
5 files changed, 25 insertions, 0 deletions
diff --git a/lldb/scripts/interface/SBAddress.i b/lldb/scripts/interface/SBAddress.i index dc22e4c3498..18991176105 100644 --- a/lldb/scripts/interface/SBAddress.i +++ b/lldb/scripts/interface/SBAddress.i @@ -64,6 +64,15 @@ public: explicit operator bool() const; + // operator== is a free function, which swig does not handle, so we inject + // our own equality operator here + %pythoncode%{ + def __eq__(self, other): + return not self.__ne__(other) + %} + + bool operator!=(const SBAddress &rhs) const; + void Clear (); diff --git a/lldb/scripts/interface/SBBreakpoint.i b/lldb/scripts/interface/SBBreakpoint.i index d0b6bb91b42..ee9cdc1a7bb 100644 --- a/lldb/scripts/interface/SBBreakpoint.i +++ b/lldb/scripts/interface/SBBreakpoint.i @@ -85,6 +85,10 @@ public: ~SBBreakpoint(); + bool operator==(const lldb::SBBreakpoint &rhs); + + bool operator!=(const lldb::SBBreakpoint &rhs); + break_id_t GetID () const; diff --git a/lldb/scripts/interface/SBFileSpec.i b/lldb/scripts/interface/SBFileSpec.i index de3788ddd2d..1d15454b018 100644 --- a/lldb/scripts/interface/SBFileSpec.i +++ b/lldb/scripts/interface/SBFileSpec.i @@ -42,6 +42,10 @@ public: ~SBFileSpec (); + bool operator==(const SBFileSpec &rhs) const; + + bool operator!=(const SBFileSpec &rhs) const; + bool IsValid() const; diff --git a/lldb/scripts/interface/SBModule.i b/lldb/scripts/interface/SBModule.i index 206324e6198..622052e38d8 100644 --- a/lldb/scripts/interface/SBModule.i +++ b/lldb/scripts/interface/SBModule.i @@ -184,6 +184,10 @@ public: const char * GetUUIDString () const; + bool operator==(const lldb::SBModule &rhs) const; + + bool operator!=(const lldb::SBModule &rhs) const; + lldb::SBSection FindSection (const char *sect_name); diff --git a/lldb/scripts/interface/SBWatchpoint.i b/lldb/scripts/interface/SBWatchpoint.i index e6de8ef30d7..2dff8d130c6 100644 --- a/lldb/scripts/interface/SBWatchpoint.i +++ b/lldb/scripts/interface/SBWatchpoint.i @@ -32,6 +32,10 @@ public: explicit operator bool() const; + bool operator==(const SBWatchpoint &rhs) const; + + bool operator!=(const SBWatchpoint &rhs) const; + SBError GetError(); |

