mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 05:32:28 +08:00
<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 llvm-svn: 180987
This commit is contained in:
@@ -37,6 +37,9 @@ public:
|
||||
bool
|
||||
operator == (const lldb::SBBreakpoint& rhs);
|
||||
|
||||
bool
|
||||
operator != (const lldb::SBBreakpoint& rhs);
|
||||
|
||||
break_id_t
|
||||
GetID () const;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.''')
|
||||
|
||||
@@ -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.''')
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.''')
|
||||
|
||||
@@ -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('.'))
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 %{
|
||||
|
||||
@@ -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.'''
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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__ (){
|
||||
|
||||
@@ -100,6 +100,14 @@ SBBreakpoint::operator == (const lldb::SBBreakpoint& rhs)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
SBBreakpoint::operator != (const lldb::SBBreakpoint& rhs)
|
||||
{
|
||||
if (m_opaque_sp && rhs.m_opaque_sp)
|
||||
return m_opaque_sp.get() != rhs.m_opaque_sp.get();
|
||||
return (m_opaque_sp && !rhs.m_opaque_sp) || (rhs.m_opaque_sp && !m_opaque_sp);
|
||||
}
|
||||
|
||||
break_id_t
|
||||
SBBreakpoint::GetID () const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user