mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
PEP 3123: Provide forward compatibility with Python 3.0, while keeping
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and PyVarObject_HEAD_INIT.
This commit is contained in:
parent
b1994b4a5d
commit
6819210b9e
129 changed files with 1090 additions and 1250 deletions
|
@ -154,9 +154,9 @@ PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
|
|||
/* Macros trading binary compatibility for speed. See also pymem.h.
|
||||
Note that these macros expect non-NULL object pointers.*/
|
||||
#define PyObject_INIT(op, typeobj) \
|
||||
( (op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
|
||||
( Py_Type(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
|
||||
#define PyObject_INIT_VAR(op, typeobj, size) \
|
||||
( (op)->ob_size = (size), PyObject_INIT((op), (typeobj)) )
|
||||
( Py_Size(op) = (size), PyObject_INIT((op), (typeobj)) )
|
||||
|
||||
#define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize )
|
||||
|
||||
|
@ -231,8 +231,8 @@ PyAPI_FUNC(Py_ssize_t) PyGC_Collect(void);
|
|||
#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC)
|
||||
|
||||
/* Test if an object has a GC head */
|
||||
#define PyObject_IS_GC(o) (PyType_IS_GC((o)->ob_type) && \
|
||||
((o)->ob_type->tp_is_gc == NULL || (o)->ob_type->tp_is_gc(o)))
|
||||
#define PyObject_IS_GC(o) (PyType_IS_GC(Py_Type(o)) && \
|
||||
(Py_Type(o)->tp_is_gc == NULL || Py_Type(o)->tp_is_gc(o)))
|
||||
|
||||
PyAPI_FUNC(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, Py_ssize_t);
|
||||
#define PyObject_GC_Resize(type, op, n) \
|
||||
|
@ -328,7 +328,7 @@ PyAPI_FUNC(void) PyObject_GC_Del(void *);
|
|||
&& ((t)->tp_weaklistoffset > 0))
|
||||
|
||||
#define PyObject_GET_WEAKREFS_LISTPTR(o) \
|
||||
((PyObject **) (((char *) (o)) + (o)->ob_type->tp_weaklistoffset))
|
||||
((PyObject **) (((char *) (o)) + Py_Type(o)->tp_weaklistoffset))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue