mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
bpo-39573: Convert Py_TYPE() to a static inline function (GH-20290)
This commit is contained in:
parent
e50883ccc4
commit
ad3252bad9
4 changed files with 37 additions and 12 deletions
|
@ -121,9 +121,13 @@ typedef struct {
|
|||
#define _PyVarObject_CAST(op) ((PyVarObject*)(op))
|
||||
|
||||
#define Py_REFCNT(ob) (_PyObject_CAST(ob)->ob_refcnt)
|
||||
#define Py_TYPE(ob) (_PyObject_CAST(ob)->ob_type)
|
||||
#define Py_SIZE(ob) (_PyVarObject_CAST(ob)->ob_size)
|
||||
|
||||
static inline PyTypeObject* _Py_TYPE(const PyObject *ob) {
|
||||
return ob->ob_type;
|
||||
}
|
||||
#define Py_TYPE(ob) _Py_TYPE(_PyObject_CAST_CONST(ob))
|
||||
|
||||
static inline int _Py_IS_TYPE(const PyObject *ob, const PyTypeObject *type) {
|
||||
return ob->ob_type == type;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue