Fix various __eq__ and __ne__ operators to also allow comparisons to None.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@18650 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2003-01-10 00:04:55 +00:00
parent d45ca1a3fd
commit 026525162c
3 changed files with 93 additions and 19 deletions

View File

@@ -365,12 +365,25 @@ public:
PyTuple_SetItem(rv, 2, PyInt_FromLong(blue));
return rv;
}
bool __eq__(const wxColour& o) { return *self == o; }
bool __ne__(const wxColour& o) { return *self != o; }
bool __eq__(PyObject* obj) {
wxColour tmp;
wxColour* ptr = &tmp;
if (obj == Py_None) return FALSE;
if (! wxColour_helper(obj, &ptr)) return FALSE;
return *self == *ptr;
}
bool __ne__(PyObject* obj) {
wxColour tmp;
wxColour* ptr = &tmp;
if (obj == Py_None) return TRUE;
if (! wxColour_helper(obj, &ptr)) return TRUE;
return *self != *ptr;
}
}
%pragma(python) addtoclass = "asTuple = Get
def __str__(self): return str(self.asTuple())
def __repr__(self): return str(self.asTuple())
def __repr__(self): return 'wxColour: ' + str(self.asTuple())
def __nonzero__(self): return self.Ok()
"