summaryrefslogtreecommitdiffstats
path: root/Include/object.h
diff options
context:
space:
mode:
Diffstat (limited to 'Include/object.h')
-rw-r--r--Include/object.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/Include/object.h b/Include/object.h
index 11539ee..3d0da52 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -123,6 +123,11 @@ typedef struct {
#define Py_TYPE(ob) (_PyObject_CAST(ob)->ob_type)
#define Py_SIZE(ob) (_PyVarObject_CAST(ob)->ob_size)
+static inline int _Py_IS_TYPE(PyObject *ob, PyTypeObject *type) {
+ return ob->ob_type == type;
+}
+#define Py_IS_TYPE(ob, type) _Py_IS_TYPE(_PyObject_CAST(ob), type)
+
static inline void _Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt) {
ob->ob_refcnt = refcnt;
}
@@ -211,7 +216,7 @@ PyAPI_FUNC(void*) PyType_GetSlot(PyTypeObject*, int);
/* Generic type check */
PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *);
#define PyObject_TypeCheck(ob, tp) \
- (Py_TYPE(ob) == (tp) || PyType_IsSubtype(Py_TYPE(ob), (tp)))
+ (Py_IS_TYPE(ob, tp) || PyType_IsSubtype(Py_TYPE(ob), (tp)))
PyAPI_DATA(PyTypeObject) PyType_Type; /* built-in 'type' */
PyAPI_DATA(PyTypeObject) PyBaseObject_Type; /* built-in 'object' */
@@ -623,7 +628,7 @@ static inline int _PyType_Check(PyObject *op) {
#define PyType_Check(op) _PyType_Check(_PyObject_CAST(op))
static inline int _PyType_CheckExact(PyObject *op) {
- return (Py_TYPE(op) == &PyType_Type);
+ return Py_IS_TYPE(op, &PyType_Type);
}
#define PyType_CheckExact(op) _PyType_CheckExact(_PyObject_CAST(op))