diff options
Diffstat (limited to 'src/libs/xpcom18a4/python/src/PyIID.cpp')
-rw-r--r-- | src/libs/xpcom18a4/python/src/PyIID.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/libs/xpcom18a4/python/src/PyIID.cpp b/src/libs/xpcom18a4/python/src/PyIID.cpp index f24ae20e..9825db88 100644 --- a/src/libs/xpcom18a4/python/src/PyIID.cpp +++ b/src/libs/xpcom18a4/python/src/PyIID.cpp @@ -236,13 +236,14 @@ PyTypeObject *Py_nsIID::GetTypeObject(void) { Py_tp_hash, (void *)(uintptr_t)&Py_nsIID::PyTypeMethod_hash }, { Py_tp_str, (void *)(uintptr_t)&Py_nsIID::PyTypeMethod_str }, { Py_tp_richcompare, (void *)(uintptr_t)&Py_nsIID::PyTypeMethod_richcompare }, + { Py_tp_is_gc, (void *)(uintptr_t)&Py_nsIID::PyTypeMethod_is_gc }, { 0, NULL } /* terminator */ }; PyType_Spec TypeSpec = { /* .name: */ "IID", /* .basicsize: */ sizeof(Py_nsIID), /* .itemsize: */ 0, - /* .flags: */ 0, + /* .flags: */ Py_TPFLAGS_DEFAULT, /* .slots: */ aTypeSlots, }; @@ -319,10 +320,22 @@ Py_nsIID::PyTypeMethod_compare(PyObject *self, PyObject *other) /* static */ PyObject * Py_nsIID::PyTypeMethod_richcompare(PyObject *self, PyObject *other, int op) { + nsIID iid; + if (!Py_nsIID::IIDFromPyObject(other, &iid)) + { + /* Can't do comparison besides equality/inequality if the other object does not contain an IID. */ + if (op == Py_EQ) + Py_RETURN_FALSE; + else if (op == Py_NE) + Py_RETURN_TRUE; + + PyErr_SetString(PyExc_TypeError, "Comparison between different object types is not defined"); + return NULL; + } + PyObject *result = NULL; Py_nsIID *s_iid = (Py_nsIID *)self; - Py_nsIID *o_iid = (Py_nsIID *)other; - int rc = memcmp(&s_iid->m_iid, &o_iid->m_iid, sizeof(s_iid->m_iid)); + int rc = memcmp(&s_iid->m_iid, &iid, sizeof(s_iid->m_iid)); switch (op) { case Py_LT: @@ -408,3 +421,11 @@ Py_nsIID::PyTypeMethod_dealloc(PyObject *ob) { delete (Py_nsIID *)ob; } + +#ifdef Py_LIMITED_API +/* static */ int +Py_nsIID::PyTypeMethod_is_gc(PyObject *self) +{ + return 0; +} +#endif |