diff options
author | Enrico Granata <egranata@apple.com> | 2013-05-03 01:29:27 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2013-05-03 01:29:27 +0000 |
commit | 0765e3274aab0551fea7678bee565c7d68e0b786 (patch) | |
tree | 4b15cb77dc2ec2f9d2833caa283338b7d5383504 /scripts | |
parent | a828fe30472631280ab10ffbf620cfd244985471 (diff) | |
download | lldb-0765e3274aab0551fea7678bee565c7d68e0b786.tar.gz |
<rdar://problem/11742979>
SWIG is smart enough to recognize that C++ operators == and != mean __eq__ and __ne__ in Python and do the appropriate translation
But it is not smart enough to recognize that mySBObject == None should return False instead of erroring out
The %pythoncode blocks are meant to provide those extra smarts (and they play some SWIG&Python magic to find the right function to call behind the scenes with no risk of typos :-)
Lastly, SBBreakpoint provides an == but never provided a != operator - common courtesy is to provide both
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@180987 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Python/interface/SBBreakpoint.i | 6 | ||||
-rw-r--r-- | scripts/Python/interface/SBBroadcaster.i | 6 | ||||
-rw-r--r-- | scripts/Python/interface/SBCompileUnit.i | 6 | ||||
-rw-r--r-- | scripts/Python/interface/SBDeclaration.i | 6 | ||||
-rw-r--r-- | scripts/Python/interface/SBFunction.i | 6 | ||||
-rw-r--r-- | scripts/Python/interface/SBLineEntry.i | 6 | ||||
-rw-r--r-- | scripts/Python/interface/SBModule.i | 6 | ||||
-rw-r--r-- | scripts/Python/interface/SBSection.i | 6 | ||||
-rw-r--r-- | scripts/Python/interface/SBSymbol.i | 6 | ||||
-rw-r--r-- | scripts/Python/interface/SBTarget.i | 6 | ||||
-rw-r--r-- | scripts/Python/interface/SBThread.i | 6 | ||||
-rw-r--r-- | scripts/Python/interface/SBTypeFilter.i | 6 | ||||
-rw-r--r-- | scripts/Python/interface/SBTypeFormat.i | 8 | ||||
-rw-r--r-- | scripts/Python/interface/SBTypeNameSpecifier.i | 8 | ||||
-rw-r--r-- | scripts/Python/interface/SBTypeSummary.i | 6 | ||||
-rw-r--r-- | scripts/Python/interface/SBTypeSynthetic.i | 6 | ||||
-rw-r--r-- | scripts/Python/python-extensions.swig | 211 |
17 files changed, 309 insertions, 2 deletions
diff --git a/scripts/Python/interface/SBBreakpoint.i b/scripts/Python/interface/SBBreakpoint.i index cf566d2ac..08a1f9684 100644 --- a/scripts/Python/interface/SBBreakpoint.i +++ b/scripts/Python/interface/SBBreakpoint.i @@ -189,6 +189,12 @@ public: bool GetDescription (lldb::SBStream &description); + bool + operator == (const lldb::SBBreakpoint& rhs); + + bool + operator != (const lldb::SBBreakpoint& rhs); + static bool EventIsBreakpointEvent (const lldb::SBEvent &event); diff --git a/scripts/Python/interface/SBBroadcaster.i b/scripts/Python/interface/SBBroadcaster.i index ece38f602..b5e25b6d5 100644 --- a/scripts/Python/interface/SBBroadcaster.i +++ b/scripts/Python/interface/SBBroadcaster.i @@ -57,6 +57,12 @@ public: bool RemoveListener (const lldb::SBListener &listener, uint32_t event_mask = UINT32_MAX); + + bool + operator == (const lldb::SBBroadcaster &rhs) const; + + bool + operator != (const lldb::SBBroadcaster &rhs) const; }; } // namespace lldb diff --git a/scripts/Python/interface/SBCompileUnit.i b/scripts/Python/interface/SBCompileUnit.i index 95d68a640..3bfaf70b9 100644 --- a/scripts/Python/interface/SBCompileUnit.i +++ b/scripts/Python/interface/SBCompileUnit.i @@ -89,6 +89,12 @@ public: bool GetDescription (lldb::SBStream &description); + bool + operator == (const lldb::SBCompileUnit &rhs) const; + + bool + operator != (const lldb::SBCompileUnit &rhs) const; + %pythoncode %{ __swig_getmethods__["file"] = GetFileSpec if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns the same result an lldb object that represents the source file (lldb.SBFileSpec) for the compile unit.''') diff --git a/scripts/Python/interface/SBDeclaration.i b/scripts/Python/interface/SBDeclaration.i index a3709aef9..87e2f8ec6 100644 --- a/scripts/Python/interface/SBDeclaration.i +++ b/scripts/Python/interface/SBDeclaration.i @@ -46,6 +46,12 @@ namespace lldb { void SetColumn (uint32_t column); + bool + operator == (const lldb::SBDeclaration &rhs) const; + + bool + operator != (const lldb::SBDeclaration &rhs) const; + %pythoncode %{ __swig_getmethods__["file"] = GetFileSpec if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''') diff --git a/scripts/Python/interface/SBFunction.i b/scripts/Python/interface/SBFunction.i index 0b4d1f2cb..33cc4481e 100644 --- a/scripts/Python/interface/SBFunction.i +++ b/scripts/Python/interface/SBFunction.i @@ -86,6 +86,12 @@ public: bool GetDescription (lldb::SBStream &description); + bool + operator == (const lldb::SBFunction &rhs) const; + + bool + operator != (const lldb::SBFunction &rhs) const; + %pythoncode %{ def get_instructions_from_current_target (self): return self.GetInstructions (target) diff --git a/scripts/Python/interface/SBLineEntry.i b/scripts/Python/interface/SBLineEntry.i index 0fe4e9191..ff6710952 100644 --- a/scripts/Python/interface/SBLineEntry.i +++ b/scripts/Python/interface/SBLineEntry.i @@ -77,6 +77,12 @@ public: void SetColumn (uint32_t column); + bool + operator == (const lldb::SBLineEntry &rhs) const; + + bool + operator != (const lldb::SBLineEntry &rhs) const; + %pythoncode %{ __swig_getmethods__["file"] = GetFileSpec if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''') diff --git a/scripts/Python/interface/SBModule.i b/scripts/Python/interface/SBModule.i index 6bdc2a0f2..cb970d6af 100644 --- a/scripts/Python/interface/SBModule.i +++ b/scripts/Python/interface/SBModule.i @@ -279,6 +279,12 @@ public: GetVersion (uint32_t *versions, uint32_t num_versions); + bool + operator == (const lldb::SBModule &rhs) const; + + bool + operator != (const lldb::SBModule &rhs) const; + %pythoncode %{ class symbols_access(object): re_compile_type = type(re.compile('.')) diff --git a/scripts/Python/interface/SBSection.i b/scripts/Python/interface/SBSection.i index 94b5800e1..cf41bdf20 100644 --- a/scripts/Python/interface/SBSection.i +++ b/scripts/Python/interface/SBSection.i @@ -90,6 +90,12 @@ public: bool GetDescription (lldb::SBStream &description); + bool + operator == (const lldb::SBSection &rhs); + + bool + operator != (const lldb::SBSection &rhs); + %pythoncode %{ def get_addr(self): return SBAddress(self, 0) diff --git a/scripts/Python/interface/SBSymbol.i b/scripts/Python/interface/SBSymbol.i index a2cec0ec7..f6db14c0e 100644 --- a/scripts/Python/interface/SBSymbol.i +++ b/scripts/Python/interface/SBSymbol.i @@ -62,6 +62,12 @@ public: bool IsSynthetic(); + bool + operator == (const lldb::SBSymbol &rhs) const; + + bool + operator != (const lldb::SBSymbol &rhs) const; + %pythoncode %{ def get_instructions_from_current_target (self): return self.GetInstructions (target) diff --git a/scripts/Python/interface/SBTarget.i b/scripts/Python/interface/SBTarget.i index 8547b7b53..e7dba2a7a 100644 --- a/scripts/Python/interface/SBTarget.i +++ b/scripts/Python/interface/SBTarget.i @@ -742,6 +742,12 @@ public: lldb::addr_t GetStackRedZoneSize(); + bool + operator == (const lldb::SBTarget &rhs) const; + + bool + operator != (const lldb::SBTarget &rhs) const; + lldb::SBValue EvaluateExpression (const char *expr, const lldb::SBExpressionOptions &options); %pythoncode %{ diff --git a/scripts/Python/interface/SBThread.i b/scripts/Python/interface/SBThread.i index 2f3415330..91193df21 100644 --- a/scripts/Python/interface/SBThread.i +++ b/scripts/Python/interface/SBThread.i @@ -202,6 +202,12 @@ public: bool GetStatus (lldb::SBStream &status) const; + bool + operator == (const lldb::SBThread &rhs) const; + + bool + operator != (const lldb::SBThread &rhs) const; + %pythoncode %{ class frames_access(object): '''A helper object that will lazily hand out frames for a thread when supplied an index.''' diff --git a/scripts/Python/interface/SBTypeFilter.i b/scripts/Python/interface/SBTypeFilter.i index fcf45edd6..083dfa843 100644 --- a/scripts/Python/interface/SBTypeFilter.i +++ b/scripts/Python/interface/SBTypeFilter.i @@ -55,6 +55,12 @@ namespace lldb { bool GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); + bool + operator == (lldb::SBTypeFilter &rhs); + + bool + operator != (lldb::SBTypeFilter &rhs); + %pythoncode %{ __swig_getmethods__["options"] = GetOptions __swig_setmethods__["options"] = SetOptions diff --git a/scripts/Python/interface/SBTypeFormat.i b/scripts/Python/interface/SBTypeFormat.i index f9090155b..9d2f1a675 100644 --- a/scripts/Python/interface/SBTypeFormat.i +++ b/scripts/Python/interface/SBTypeFormat.i @@ -46,7 +46,13 @@ namespace lldb { bool GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); - + + bool + operator == (lldb::SBTypeFormat &rhs); + + bool + operator != (lldb::SBTypeFormat &rhs); + %pythoncode %{ __swig_getmethods__["format"] = GetFormat __swig_setmethods__["format"] = SetFormat diff --git a/scripts/Python/interface/SBTypeNameSpecifier.i b/scripts/Python/interface/SBTypeNameSpecifier.i index f9b0e6d79..97d23ca17 100644 --- a/scripts/Python/interface/SBTypeNameSpecifier.i +++ b/scripts/Python/interface/SBTypeNameSpecifier.i @@ -46,7 +46,13 @@ namespace lldb { bool GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); - + + bool + operator == (lldb::SBTypeNameSpecifier &rhs); + + bool + operator != (lldb::SBTypeNameSpecifier &rhs); + %pythoncode %{ __swig_getmethods__["name"] = GetName if _newclass: name = property(GetName, None) diff --git a/scripts/Python/interface/SBTypeSummary.i b/scripts/Python/interface/SBTypeSummary.i index b3dde4234..9d6a0017c 100644 --- a/scripts/Python/interface/SBTypeSummary.i +++ b/scripts/Python/interface/SBTypeSummary.i @@ -69,6 +69,12 @@ namespace lldb { GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); + bool + operator == (lldb::SBTypeSummary &rhs); + + bool + operator != (lldb::SBTypeSummary &rhs); + %pythoncode %{ __swig_getmethods__["options"] = GetOptions __swig_setmethods__["options"] = SetOptions diff --git a/scripts/Python/interface/SBTypeSynthetic.i b/scripts/Python/interface/SBTypeSynthetic.i index fae5c72d3..e040cd55c 100644 --- a/scripts/Python/interface/SBTypeSynthetic.i +++ b/scripts/Python/interface/SBTypeSynthetic.i @@ -57,6 +57,12 @@ namespace lldb { GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); + bool + operator == (lldb::SBTypeSynthetic &rhs); + + bool + operator != (lldb::SBTypeSynthetic &rhs); + %pythoncode %{ __swig_getmethods__["options"] = GetOptions __swig_setmethods__["options"] = SetOptions diff --git a/scripts/Python/python-extensions.swig b/scripts/Python/python-extensions.swig index 1ff078292..8d5715646 100644 --- a/scripts/Python/python-extensions.swig +++ b/scripts/Python/python-extensions.swig @@ -40,6 +40,21 @@ else return PyString_FromString(""); } + + %pythoncode %{ + def __eq__(self, rhs): + if not isinstance(rhs, type(self)): + return False + + return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) + + def __ne__(self, rhs): + if not isinstance(rhs, type(self)): + return True + + return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) + %} + } %extend lldb::SBBreakpointLocation { PyObject *lldb::SBBreakpointLocation::__str__ (){ @@ -55,6 +70,23 @@ return PyString_FromString(""); } } + +%extend lldb::SBBroadcaster { + %pythoncode %{ + def __eq__(self, rhs): + if not isinstance(rhs, type(self)): + return False + + return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) + + def __ne__(self, rhs): + if not isinstance(rhs, type(self)): + return True + + return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) + %} +} + %extend lldb::SBCommandReturnObject { PyObject *lldb::SBCommandReturnObject::__str__ (){ lldb::SBStream description; @@ -95,6 +127,19 @@ else return PyString_FromString(""); } + %pythoncode %{ + def __eq__(self, rhs): + if not isinstance(rhs, type(self)): + return False + + return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) + + def __ne__(self, rhs): + if not isinstance(rhs, type(self)): + return True + + return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) + %} } %extend lldb::SBData { PyObject *lldb::SBData::__str__ (){ @@ -137,6 +182,21 @@ else return PyString_FromString(""); } + + %pythoncode %{ + def __eq__(self, rhs): + if not isinstance(rhs, type(self)): + return False + + return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) + + def __ne__(self, rhs): + if not isinstance(rhs, type(self)): + return True + + return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) + %} + } %extend lldb::SBError { PyObject *lldb::SBError::__str__ (){ @@ -193,6 +253,21 @@ else return PyString_FromString(""); } + + %pythoncode %{ + def __eq__(self, rhs): + if not isinstance(rhs, type(self)): + return False + + return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) + + def __ne__(self, rhs): + if not isinstance(rhs, type(self)): + return True + + return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) + %} + } %extend lldb::SBInstruction { PyObject *lldb::SBInstruction::__str__ (){ @@ -235,6 +310,20 @@ else return PyString_FromString(""); } + + %pythoncode %{ + def __eq__(self, rhs): + if not isinstance(rhs, type(self)): + return False + + return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) + + def __ne__(self, rhs): + if not isinstance(rhs, type(self)): + return True + + return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) + %} } %extend lldb::SBModule { PyObject *lldb::SBModule::__str__ (){ @@ -249,6 +338,20 @@ else return PyString_FromString(""); } + + %pythoncode %{ + def __eq__(self, rhs): + if not isinstance(rhs, type(self)): + return False + + return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) + + def __ne__(self, rhs): + if not isinstance(rhs, type(self)): + return True + + return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) + %} } %extend lldb::SBProcess { PyObject *lldb::SBProcess::__str__ (){ @@ -277,6 +380,20 @@ else return PyString_FromString(""); } + + %pythoncode %{ + def __eq__(self, rhs): + if not isinstance(rhs, type(self)): + return False + + return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) + + def __ne__(self, rhs): + if not isinstance(rhs, type(self)): + return True + + return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) + %} } %extend lldb::SBStream { /* the write() and flush() calls are not part of the SB API proper, and are solely for Python usage @@ -305,6 +422,19 @@ else return PyString_FromString(""); } + %pythoncode %{ + def __eq__(self, rhs): + if not isinstance(rhs, type(self)): + return False + + return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) + + def __ne__(self, rhs): + if not isinstance(rhs, type(self)): + return True + + return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) + %} } %extend lldb::SBSymbolContext { PyObject *lldb::SBSymbolContext::__str__ (){ @@ -334,6 +464,7 @@ return PyString_FromString(""); } } + %extend lldb::SBTarget { PyObject *lldb::SBTarget::__str__ (){ lldb::SBStream description; @@ -347,7 +478,22 @@ else return PyString_FromString(""); } + + %pythoncode %{ + def __eq__(self, rhs): + if not isinstance(rhs, type(self)): + return False + + return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) + + def __ne__(self, rhs): + if not isinstance(rhs, type(self)): + return True + + return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) + %} } + %extend lldb::SBType { PyObject *lldb::SBType::__str__ (){ lldb::SBStream description; @@ -389,6 +535,19 @@ else return PyString_FromString(""); } + %pythoncode %{ + def __eq__(self, rhs): + if not isinstance(rhs, type(self)): + return False + + return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) + + def __ne__(self, rhs): + if not isinstance(rhs, type(self)): + return True + + return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) + %} } %extend lldb::SBTypeFormat { PyObject *lldb::SBTypeFormat::__str__ (){ @@ -431,6 +590,19 @@ else return PyString_FromString(""); } + %pythoncode %{ + def __eq__(self, rhs): + if not isinstance(rhs, type(self)): + return False + + return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) + + def __ne__(self, rhs): + if not isinstance(rhs, type(self)): + return True + + return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) + %} } %extend lldb::SBTypeSummary { PyObject *lldb::SBTypeSummary::__str__ (){ @@ -445,6 +617,19 @@ else return PyString_FromString(""); } + %pythoncode %{ + def __eq__(self, rhs): + if not isinstance(rhs, type(self)): + return False + + return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) + + def __ne__(self, rhs): + if not isinstance(rhs, type(self)): + return True + + return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) + %} } %extend lldb::SBTypeSynthetic { PyObject *lldb::SBTypeSynthetic::__str__ (){ @@ -459,6 +644,19 @@ else return PyString_FromString(""); } + %pythoncode %{ + def __eq__(self, rhs): + if not isinstance(rhs, type(self)): + return False + + return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) + + def __ne__(self, rhs): + if not isinstance(rhs, type(self)): + return True + + return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) + %} } %extend lldb::SBThread { PyObject *lldb::SBThread::__str__ (){ @@ -473,6 +671,19 @@ else return PyString_FromString(""); } + %pythoncode %{ + def __eq__(self, rhs): + if not isinstance(rhs, type(self)): + return False + + return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) + + def __ne__(self, rhs): + if not isinstance(rhs, type(self)): + return True + + return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) + %} } %extend lldb::SBValue { PyObject *lldb::SBValue::__str__ (){ |