mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Untabify C files. Will watch buildbots.
This commit is contained in:
parent
368ede83d9
commit
c83ea137d7
318 changed files with 198669 additions and 198669 deletions
528
Include/object.h
528
Include/object.h
|
@ -63,9 +63,9 @@ whose size is determined when the object is allocated.
|
|||
|
||||
#ifdef Py_TRACE_REFS
|
||||
/* Define pointers to support a doubly-linked list of all live heap objects. */
|
||||
#define _PyObject_HEAD_EXTRA \
|
||||
struct _object *_ob_next; \
|
||||
struct _object *_ob_prev;
|
||||
#define _PyObject_HEAD_EXTRA \
|
||||
struct _object *_ob_next; \
|
||||
struct _object *_ob_prev;
|
||||
|
||||
#define _PyObject_EXTRA_INIT 0, 0,
|
||||
|
||||
|
@ -75,17 +75,17 @@ whose size is determined when the object is allocated.
|
|||
#endif
|
||||
|
||||
/* PyObject_HEAD defines the initial segment of every PyObject. */
|
||||
#define PyObject_HEAD \
|
||||
_PyObject_HEAD_EXTRA \
|
||||
Py_ssize_t ob_refcnt; \
|
||||
struct _typeobject *ob_type;
|
||||
#define PyObject_HEAD \
|
||||
_PyObject_HEAD_EXTRA \
|
||||
Py_ssize_t ob_refcnt; \
|
||||
struct _typeobject *ob_type;
|
||||
|
||||
#define PyObject_HEAD_INIT(type) \
|
||||
_PyObject_EXTRA_INIT \
|
||||
1, type,
|
||||
#define PyObject_HEAD_INIT(type) \
|
||||
_PyObject_EXTRA_INIT \
|
||||
1, type,
|
||||
|
||||
#define PyVarObject_HEAD_INIT(type, size) \
|
||||
PyObject_HEAD_INIT(type) size,
|
||||
#define PyVarObject_HEAD_INIT(type, size) \
|
||||
PyObject_HEAD_INIT(type) size,
|
||||
|
||||
/* PyObject_VAR_HEAD defines the initial segment of all variable-size
|
||||
* container objects. These end with a declaration of an array with 1
|
||||
|
@ -93,9 +93,9 @@ whose size is determined when the object is allocated.
|
|||
* has room for ob_size elements. Note that ob_size is an element count,
|
||||
* not necessarily a byte count.
|
||||
*/
|
||||
#define PyObject_VAR_HEAD \
|
||||
PyObject_HEAD \
|
||||
Py_ssize_t ob_size; /* Number of items in variable part */
|
||||
#define PyObject_VAR_HEAD \
|
||||
PyObject_HEAD \
|
||||
Py_ssize_t ob_size; /* Number of items in variable part */
|
||||
#define Py_INVALID_SIZE (Py_ssize_t)-1
|
||||
|
||||
/* Nothing is actually declared to be a PyObject, but every pointer to
|
||||
|
@ -104,16 +104,16 @@ whose size is determined when the object is allocated.
|
|||
* in addition, be cast to PyVarObject*.
|
||||
*/
|
||||
typedef struct _object {
|
||||
PyObject_HEAD
|
||||
PyObject_HEAD
|
||||
} PyObject;
|
||||
|
||||
typedef struct {
|
||||
PyObject_VAR_HEAD
|
||||
PyObject_VAR_HEAD
|
||||
} PyVarObject;
|
||||
|
||||
#define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
|
||||
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
|
||||
#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
|
||||
#define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
|
||||
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
|
||||
#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
|
||||
|
||||
/*
|
||||
Type objects contain a string containing the type name (to help somewhat
|
||||
|
@ -162,26 +162,26 @@ typedef Py_ssize_t (*charbufferproc)(PyObject *, Py_ssize_t, char **);
|
|||
|
||||
/* Py3k buffer interface */
|
||||
typedef struct bufferinfo {
|
||||
void *buf;
|
||||
PyObject *obj; /* owned reference */
|
||||
Py_ssize_t len;
|
||||
Py_ssize_t itemsize; /* This is Py_ssize_t so it can be
|
||||
pointed to by strides in simple case.*/
|
||||
int readonly;
|
||||
int ndim;
|
||||
char *format;
|
||||
Py_ssize_t *shape;
|
||||
Py_ssize_t *strides;
|
||||
Py_ssize_t *suboffsets;
|
||||
Py_ssize_t smalltable[2]; /* static store for shape and strides of
|
||||
mono-dimensional buffers. */
|
||||
void *internal;
|
||||
void *buf;
|
||||
PyObject *obj; /* owned reference */
|
||||
Py_ssize_t len;
|
||||
Py_ssize_t itemsize; /* This is Py_ssize_t so it can be
|
||||
pointed to by strides in simple case.*/
|
||||
int readonly;
|
||||
int ndim;
|
||||
char *format;
|
||||
Py_ssize_t *shape;
|
||||
Py_ssize_t *strides;
|
||||
Py_ssize_t *suboffsets;
|
||||
Py_ssize_t smalltable[2]; /* static store for shape and strides of
|
||||
mono-dimensional buffers. */
|
||||
void *internal;
|
||||
} Py_buffer;
|
||||
|
||||
typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
|
||||
typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
|
||||
|
||||
/* Flags for getting buffers */
|
||||
/* Flags for getting buffers */
|
||||
#define PyBUF_SIMPLE 0
|
||||
#define PyBUF_WRITABLE 0x0001
|
||||
/* we used to include an E, backwards compatible alias */
|
||||
|
@ -217,88 +217,88 @@ typedef int (*visitproc)(PyObject *, void *);
|
|||
typedef int (*traverseproc)(PyObject *, visitproc, void *);
|
||||
|
||||
typedef struct {
|
||||
/* For numbers without flag bit Py_TPFLAGS_CHECKTYPES set, all
|
||||
arguments are guaranteed to be of the object's type (modulo
|
||||
coercion hacks -- i.e. if the type's coercion function
|
||||
returns other types, then these are allowed as well). Numbers that
|
||||
have the Py_TPFLAGS_CHECKTYPES flag bit set should check *both*
|
||||
arguments for proper type and implement the necessary conversions
|
||||
in the slot functions themselves. */
|
||||
/* For numbers without flag bit Py_TPFLAGS_CHECKTYPES set, all
|
||||
arguments are guaranteed to be of the object's type (modulo
|
||||
coercion hacks -- i.e. if the type's coercion function
|
||||
returns other types, then these are allowed as well). Numbers that
|
||||
have the Py_TPFLAGS_CHECKTYPES flag bit set should check *both*
|
||||
arguments for proper type and implement the necessary conversions
|
||||
in the slot functions themselves. */
|
||||
|
||||
binaryfunc nb_add;
|
||||
binaryfunc nb_subtract;
|
||||
binaryfunc nb_multiply;
|
||||
binaryfunc nb_divide;
|
||||
binaryfunc nb_remainder;
|
||||
binaryfunc nb_divmod;
|
||||
ternaryfunc nb_power;
|
||||
unaryfunc nb_negative;
|
||||
unaryfunc nb_positive;
|
||||
unaryfunc nb_absolute;
|
||||
inquiry nb_nonzero;
|
||||
unaryfunc nb_invert;
|
||||
binaryfunc nb_lshift;
|
||||
binaryfunc nb_rshift;
|
||||
binaryfunc nb_and;
|
||||
binaryfunc nb_xor;
|
||||
binaryfunc nb_or;
|
||||
coercion nb_coerce;
|
||||
unaryfunc nb_int;
|
||||
unaryfunc nb_long;
|
||||
unaryfunc nb_float;
|
||||
unaryfunc nb_oct;
|
||||
unaryfunc nb_hex;
|
||||
/* Added in release 2.0 */
|
||||
binaryfunc nb_inplace_add;
|
||||
binaryfunc nb_inplace_subtract;
|
||||
binaryfunc nb_inplace_multiply;
|
||||
binaryfunc nb_inplace_divide;
|
||||
binaryfunc nb_inplace_remainder;
|
||||
ternaryfunc nb_inplace_power;
|
||||
binaryfunc nb_inplace_lshift;
|
||||
binaryfunc nb_inplace_rshift;
|
||||
binaryfunc nb_inplace_and;
|
||||
binaryfunc nb_inplace_xor;
|
||||
binaryfunc nb_inplace_or;
|
||||
binaryfunc nb_add;
|
||||
binaryfunc nb_subtract;
|
||||
binaryfunc nb_multiply;
|
||||
binaryfunc nb_divide;
|
||||
binaryfunc nb_remainder;
|
||||
binaryfunc nb_divmod;
|
||||
ternaryfunc nb_power;
|
||||
unaryfunc nb_negative;
|
||||
unaryfunc nb_positive;
|
||||
unaryfunc nb_absolute;
|
||||
inquiry nb_nonzero;
|
||||
unaryfunc nb_invert;
|
||||
binaryfunc nb_lshift;
|
||||
binaryfunc nb_rshift;
|
||||
binaryfunc nb_and;
|
||||
binaryfunc nb_xor;
|
||||
binaryfunc nb_or;
|
||||
coercion nb_coerce;
|
||||
unaryfunc nb_int;
|
||||
unaryfunc nb_long;
|
||||
unaryfunc nb_float;
|
||||
unaryfunc nb_oct;
|
||||
unaryfunc nb_hex;
|
||||
/* Added in release 2.0 */
|
||||
binaryfunc nb_inplace_add;
|
||||
binaryfunc nb_inplace_subtract;
|
||||
binaryfunc nb_inplace_multiply;
|
||||
binaryfunc nb_inplace_divide;
|
||||
binaryfunc nb_inplace_remainder;
|
||||
ternaryfunc nb_inplace_power;
|
||||
binaryfunc nb_inplace_lshift;
|
||||
binaryfunc nb_inplace_rshift;
|
||||
binaryfunc nb_inplace_and;
|
||||
binaryfunc nb_inplace_xor;
|
||||
binaryfunc nb_inplace_or;
|
||||
|
||||
/* Added in release 2.2 */
|
||||
/* The following require the Py_TPFLAGS_HAVE_CLASS flag */
|
||||
binaryfunc nb_floor_divide;
|
||||
binaryfunc nb_true_divide;
|
||||
binaryfunc nb_inplace_floor_divide;
|
||||
binaryfunc nb_inplace_true_divide;
|
||||
/* Added in release 2.2 */
|
||||
/* The following require the Py_TPFLAGS_HAVE_CLASS flag */
|
||||
binaryfunc nb_floor_divide;
|
||||
binaryfunc nb_true_divide;
|
||||
binaryfunc nb_inplace_floor_divide;
|
||||
binaryfunc nb_inplace_true_divide;
|
||||
|
||||
/* Added in release 2.5 */
|
||||
unaryfunc nb_index;
|
||||
/* Added in release 2.5 */
|
||||
unaryfunc nb_index;
|
||||
} PyNumberMethods;
|
||||
|
||||
typedef struct {
|
||||
lenfunc sq_length;
|
||||
binaryfunc sq_concat;
|
||||
ssizeargfunc sq_repeat;
|
||||
ssizeargfunc sq_item;
|
||||
ssizessizeargfunc sq_slice;
|
||||
ssizeobjargproc sq_ass_item;
|
||||
ssizessizeobjargproc sq_ass_slice;
|
||||
objobjproc sq_contains;
|
||||
/* Added in release 2.0 */
|
||||
binaryfunc sq_inplace_concat;
|
||||
ssizeargfunc sq_inplace_repeat;
|
||||
lenfunc sq_length;
|
||||
binaryfunc sq_concat;
|
||||
ssizeargfunc sq_repeat;
|
||||
ssizeargfunc sq_item;
|
||||
ssizessizeargfunc sq_slice;
|
||||
ssizeobjargproc sq_ass_item;
|
||||
ssizessizeobjargproc sq_ass_slice;
|
||||
objobjproc sq_contains;
|
||||
/* Added in release 2.0 */
|
||||
binaryfunc sq_inplace_concat;
|
||||
ssizeargfunc sq_inplace_repeat;
|
||||
} PySequenceMethods;
|
||||
|
||||
typedef struct {
|
||||
lenfunc mp_length;
|
||||
binaryfunc mp_subscript;
|
||||
objobjargproc mp_ass_subscript;
|
||||
lenfunc mp_length;
|
||||
binaryfunc mp_subscript;
|
||||
objobjargproc mp_ass_subscript;
|
||||
} PyMappingMethods;
|
||||
|
||||
typedef struct {
|
||||
readbufferproc bf_getreadbuffer;
|
||||
writebufferproc bf_getwritebuffer;
|
||||
segcountproc bf_getsegcount;
|
||||
charbufferproc bf_getcharbuffer;
|
||||
getbufferproc bf_getbuffer;
|
||||
releasebufferproc bf_releasebuffer;
|
||||
readbufferproc bf_getreadbuffer;
|
||||
writebufferproc bf_getwritebuffer;
|
||||
segcountproc bf_getsegcount;
|
||||
charbufferproc bf_getcharbuffer;
|
||||
getbufferproc bf_getbuffer;
|
||||
releasebufferproc bf_releasebuffer;
|
||||
} PyBufferProcs;
|
||||
|
||||
|
||||
|
@ -322,110 +322,110 @@ typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *);
|
|||
typedef PyObject *(*allocfunc)(struct _typeobject *, Py_ssize_t);
|
||||
|
||||
typedef struct _typeobject {
|
||||
PyObject_VAR_HEAD
|
||||
const char *tp_name; /* For printing, in format "<module>.<name>" */
|
||||
Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */
|
||||
PyObject_VAR_HEAD
|
||||
const char *tp_name; /* For printing, in format "<module>.<name>" */
|
||||
Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */
|
||||
|
||||
/* Methods to implement standard operations */
|
||||
/* Methods to implement standard operations */
|
||||
|
||||
destructor tp_dealloc;
|
||||
printfunc tp_print;
|
||||
getattrfunc tp_getattr;
|
||||
setattrfunc tp_setattr;
|
||||
cmpfunc tp_compare;
|
||||
reprfunc tp_repr;
|
||||
destructor tp_dealloc;
|
||||
printfunc tp_print;
|
||||
getattrfunc tp_getattr;
|
||||
setattrfunc tp_setattr;
|
||||
cmpfunc tp_compare;
|
||||
reprfunc tp_repr;
|
||||
|
||||
/* Method suites for standard classes */
|
||||
/* Method suites for standard classes */
|
||||
|
||||
PyNumberMethods *tp_as_number;
|
||||
PySequenceMethods *tp_as_sequence;
|
||||
PyMappingMethods *tp_as_mapping;
|
||||
PyNumberMethods *tp_as_number;
|
||||
PySequenceMethods *tp_as_sequence;
|
||||
PyMappingMethods *tp_as_mapping;
|
||||
|
||||
/* More standard operations (here for binary compatibility) */
|
||||
/* More standard operations (here for binary compatibility) */
|
||||
|
||||
hashfunc tp_hash;
|
||||
ternaryfunc tp_call;
|
||||
reprfunc tp_str;
|
||||
getattrofunc tp_getattro;
|
||||
setattrofunc tp_setattro;
|
||||
hashfunc tp_hash;
|
||||
ternaryfunc tp_call;
|
||||
reprfunc tp_str;
|
||||
getattrofunc tp_getattro;
|
||||
setattrofunc tp_setattro;
|
||||
|
||||
/* Functions to access object as input/output buffer */
|
||||
PyBufferProcs *tp_as_buffer;
|
||||
/* Functions to access object as input/output buffer */
|
||||
PyBufferProcs *tp_as_buffer;
|
||||
|
||||
/* Flags to define presence of optional/expanded features */
|
||||
long tp_flags;
|
||||
/* Flags to define presence of optional/expanded features */
|
||||
long tp_flags;
|
||||
|
||||
const char *tp_doc; /* Documentation string */
|
||||
const char *tp_doc; /* Documentation string */
|
||||
|
||||
/* Assigned meaning in release 2.0 */
|
||||
/* call function for all accessible objects */
|
||||
traverseproc tp_traverse;
|
||||
/* Assigned meaning in release 2.0 */
|
||||
/* call function for all accessible objects */
|
||||
traverseproc tp_traverse;
|
||||
|
||||
/* delete references to contained objects */
|
||||
inquiry tp_clear;
|
||||
/* delete references to contained objects */
|
||||
inquiry tp_clear;
|
||||
|
||||
/* Assigned meaning in release 2.1 */
|
||||
/* rich comparisons */
|
||||
richcmpfunc tp_richcompare;
|
||||
/* Assigned meaning in release 2.1 */
|
||||
/* rich comparisons */
|
||||
richcmpfunc tp_richcompare;
|
||||
|
||||
/* weak reference enabler */
|
||||
Py_ssize_t tp_weaklistoffset;
|
||||
/* weak reference enabler */
|
||||
Py_ssize_t tp_weaklistoffset;
|
||||
|
||||
/* Added in release 2.2 */
|
||||
/* Iterators */
|
||||
getiterfunc tp_iter;
|
||||
iternextfunc tp_iternext;
|
||||
/* Added in release 2.2 */
|
||||
/* Iterators */
|
||||
getiterfunc tp_iter;
|
||||
iternextfunc tp_iternext;
|
||||
|
||||
/* Attribute descriptor and subclassing stuff */
|
||||
struct PyMethodDef *tp_methods;
|
||||
struct PyMemberDef *tp_members;
|
||||
struct PyGetSetDef *tp_getset;
|
||||
struct _typeobject *tp_base;
|
||||
PyObject *tp_dict;
|
||||
descrgetfunc tp_descr_get;
|
||||
descrsetfunc tp_descr_set;
|
||||
Py_ssize_t tp_dictoffset;
|
||||
initproc tp_init;
|
||||
allocfunc tp_alloc;
|
||||
newfunc tp_new;
|
||||
freefunc tp_free; /* Low-level free-memory routine */
|
||||
inquiry tp_is_gc; /* For PyObject_IS_GC */
|
||||
PyObject *tp_bases;
|
||||
PyObject *tp_mro; /* method resolution order */
|
||||
PyObject *tp_cache;
|
||||
PyObject *tp_subclasses;
|
||||
PyObject *tp_weaklist;
|
||||
destructor tp_del;
|
||||
/* Attribute descriptor and subclassing stuff */
|
||||
struct PyMethodDef *tp_methods;
|
||||
struct PyMemberDef *tp_members;
|
||||
struct PyGetSetDef *tp_getset;
|
||||
struct _typeobject *tp_base;
|
||||
PyObject *tp_dict;
|
||||
descrgetfunc tp_descr_get;
|
||||
descrsetfunc tp_descr_set;
|
||||
Py_ssize_t tp_dictoffset;
|
||||
initproc tp_init;
|
||||
allocfunc tp_alloc;
|
||||
newfunc tp_new;
|
||||
freefunc tp_free; /* Low-level free-memory routine */
|
||||
inquiry tp_is_gc; /* For PyObject_IS_GC */
|
||||
PyObject *tp_bases;
|
||||
PyObject *tp_mro; /* method resolution order */
|
||||
PyObject *tp_cache;
|
||||
PyObject *tp_subclasses;
|
||||
PyObject *tp_weaklist;
|
||||
destructor tp_del;
|
||||
|
||||
/* Type attribute cache version tag. Added in version 2.6 */
|
||||
unsigned int tp_version_tag;
|
||||
/* Type attribute cache version tag. Added in version 2.6 */
|
||||
unsigned int tp_version_tag;
|
||||
|
||||
#ifdef COUNT_ALLOCS
|
||||
/* these must be last and never explicitly initialized */
|
||||
Py_ssize_t tp_allocs;
|
||||
Py_ssize_t tp_frees;
|
||||
Py_ssize_t tp_maxalloc;
|
||||
struct _typeobject *tp_prev;
|
||||
struct _typeobject *tp_next;
|
||||
/* these must be last and never explicitly initialized */
|
||||
Py_ssize_t tp_allocs;
|
||||
Py_ssize_t tp_frees;
|
||||
Py_ssize_t tp_maxalloc;
|
||||
struct _typeobject *tp_prev;
|
||||
struct _typeobject *tp_next;
|
||||
#endif
|
||||
} PyTypeObject;
|
||||
|
||||
|
||||
/* The *real* layout of a type object when allocated on the heap */
|
||||
typedef struct _heaptypeobject {
|
||||
/* Note: there's a dependency on the order of these members
|
||||
in slotptr() in typeobject.c . */
|
||||
PyTypeObject ht_type;
|
||||
PyNumberMethods as_number;
|
||||
PyMappingMethods as_mapping;
|
||||
PySequenceMethods as_sequence; /* as_sequence comes after as_mapping,
|
||||
so that the mapping wins when both
|
||||
the mapping and the sequence define
|
||||
a given operator (e.g. __getitem__).
|
||||
see add_operators() in typeobject.c . */
|
||||
PyBufferProcs as_buffer;
|
||||
PyObject *ht_name, *ht_slots;
|
||||
/* here are optional user slots, followed by the members. */
|
||||
/* Note: there's a dependency on the order of these members
|
||||
in slotptr() in typeobject.c . */
|
||||
PyTypeObject ht_type;
|
||||
PyNumberMethods as_number;
|
||||
PyMappingMethods as_mapping;
|
||||
PySequenceMethods as_sequence; /* as_sequence comes after as_mapping,
|
||||
so that the mapping wins when both
|
||||
the mapping and the sequence define
|
||||
a given operator (e.g. __getitem__).
|
||||
see add_operators() in typeobject.c . */
|
||||
PyBufferProcs as_buffer;
|
||||
PyObject *ht_name, *ht_slots;
|
||||
/* here are optional user slots, followed by the members. */
|
||||
} PyHeapTypeObject;
|
||||
|
||||
/* access macro to the members which are floating "behind" the object */
|
||||
|
@ -436,20 +436,20 @@ typedef struct _heaptypeobject {
|
|||
/* 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_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' */
|
||||
PyAPI_DATA(PyTypeObject) PySuper_Type; /* built-in 'super' */
|
||||
|
||||
#define PyType_Check(op) \
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS)
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS)
|
||||
#define PyType_CheckExact(op) (Py_TYPE(op) == &PyType_Type)
|
||||
|
||||
PyAPI_FUNC(int) PyType_Ready(PyTypeObject *);
|
||||
PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *,
|
||||
PyObject *, PyObject *);
|
||||
PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyObject_LookupSpecial(PyObject *, char *, PyObject **);
|
||||
PyAPI_FUNC(unsigned int) PyType_ClearCache(void);
|
||||
|
@ -479,7 +479,7 @@ PyAPI_FUNC(PyObject *) PyObject_SelfIter(PyObject *);
|
|||
PyAPI_FUNC(PyObject *) _PyObject_NextNotImplemented(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyObject_GenericGetAttr(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_GenericSetAttr(PyObject *,
|
||||
PyObject *, PyObject *);
|
||||
PyObject *, PyObject *);
|
||||
PyAPI_FUNC(long) PyObject_Hash(PyObject *);
|
||||
PyAPI_FUNC(long) PyObject_HashNotImplemented(PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_IsTrue(PyObject *);
|
||||
|
@ -514,7 +514,7 @@ PyAPI_FUNC(long) _Py_HashPointer(void*);
|
|||
#define PyObject_REPR(obj) PyString_AS_STRING(PyObject_Repr(obj))
|
||||
|
||||
/* Flag bits for printing: */
|
||||
#define Py_PRINT_RAW 1 /* No string quotes etc. */
|
||||
#define Py_PRINT_RAW 1 /* No string quotes etc. */
|
||||
|
||||
/*
|
||||
`Type flags (tp_flags)
|
||||
|
@ -607,29 +607,29 @@ manually remove this flag though!
|
|||
#define Py_TPFLAGS_HAVE_NEWBUFFER (1L<<21)
|
||||
|
||||
/* These flags are used to determine if a type is a subclass. */
|
||||
#define Py_TPFLAGS_INT_SUBCLASS (1L<<23)
|
||||
#define Py_TPFLAGS_LONG_SUBCLASS (1L<<24)
|
||||
#define Py_TPFLAGS_LIST_SUBCLASS (1L<<25)
|
||||
#define Py_TPFLAGS_TUPLE_SUBCLASS (1L<<26)
|
||||
#define Py_TPFLAGS_STRING_SUBCLASS (1L<<27)
|
||||
#define Py_TPFLAGS_UNICODE_SUBCLASS (1L<<28)
|
||||
#define Py_TPFLAGS_DICT_SUBCLASS (1L<<29)
|
||||
#define Py_TPFLAGS_BASE_EXC_SUBCLASS (1L<<30)
|
||||
#define Py_TPFLAGS_TYPE_SUBCLASS (1L<<31)
|
||||
#define Py_TPFLAGS_INT_SUBCLASS (1L<<23)
|
||||
#define Py_TPFLAGS_LONG_SUBCLASS (1L<<24)
|
||||
#define Py_TPFLAGS_LIST_SUBCLASS (1L<<25)
|
||||
#define Py_TPFLAGS_TUPLE_SUBCLASS (1L<<26)
|
||||
#define Py_TPFLAGS_STRING_SUBCLASS (1L<<27)
|
||||
#define Py_TPFLAGS_UNICODE_SUBCLASS (1L<<28)
|
||||
#define Py_TPFLAGS_DICT_SUBCLASS (1L<<29)
|
||||
#define Py_TPFLAGS_BASE_EXC_SUBCLASS (1L<<30)
|
||||
#define Py_TPFLAGS_TYPE_SUBCLASS (1L<<31)
|
||||
|
||||
#define Py_TPFLAGS_DEFAULT_EXTERNAL ( \
|
||||
Py_TPFLAGS_HAVE_GETCHARBUFFER | \
|
||||
Py_TPFLAGS_HAVE_SEQUENCE_IN | \
|
||||
Py_TPFLAGS_HAVE_INPLACEOPS | \
|
||||
Py_TPFLAGS_HAVE_RICHCOMPARE | \
|
||||
Py_TPFLAGS_HAVE_WEAKREFS | \
|
||||
Py_TPFLAGS_HAVE_ITER | \
|
||||
Py_TPFLAGS_HAVE_CLASS | \
|
||||
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \
|
||||
Py_TPFLAGS_HAVE_INDEX | \
|
||||
0)
|
||||
Py_TPFLAGS_HAVE_GETCHARBUFFER | \
|
||||
Py_TPFLAGS_HAVE_SEQUENCE_IN | \
|
||||
Py_TPFLAGS_HAVE_INPLACEOPS | \
|
||||
Py_TPFLAGS_HAVE_RICHCOMPARE | \
|
||||
Py_TPFLAGS_HAVE_WEAKREFS | \
|
||||
Py_TPFLAGS_HAVE_ITER | \
|
||||
Py_TPFLAGS_HAVE_CLASS | \
|
||||
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \
|
||||
Py_TPFLAGS_HAVE_INDEX | \
|
||||
0)
|
||||
#define Py_TPFLAGS_DEFAULT_CORE (Py_TPFLAGS_DEFAULT_EXTERNAL | \
|
||||
Py_TPFLAGS_HAVE_VERSION_TAG)
|
||||
Py_TPFLAGS_HAVE_VERSION_TAG)
|
||||
|
||||
#ifdef Py_BUILD_CORE
|
||||
#define Py_TPFLAGS_DEFAULT Py_TPFLAGS_DEFAULT_CORE
|
||||
|
@ -687,32 +687,32 @@ environment the global variable trick is not safe.)
|
|||
#ifdef Py_REF_DEBUG
|
||||
PyAPI_DATA(Py_ssize_t) _Py_RefTotal;
|
||||
PyAPI_FUNC(void) _Py_NegativeRefcount(const char *fname,
|
||||
int lineno, PyObject *op);
|
||||
int lineno, PyObject *op);
|
||||
PyAPI_FUNC(PyObject *) _PyDict_Dummy(void);
|
||||
PyAPI_FUNC(PyObject *) _PySet_Dummy(void);
|
||||
PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void);
|
||||
#define _Py_INC_REFTOTAL _Py_RefTotal++
|
||||
#define _Py_DEC_REFTOTAL _Py_RefTotal--
|
||||
#define _Py_REF_DEBUG_COMMA ,
|
||||
#define _Py_CHECK_REFCNT(OP) \
|
||||
{ if (((PyObject*)OP)->ob_refcnt < 0) \
|
||||
_Py_NegativeRefcount(__FILE__, __LINE__, \
|
||||
(PyObject *)(OP)); \
|
||||
#define _Py_INC_REFTOTAL _Py_RefTotal++
|
||||
#define _Py_DEC_REFTOTAL _Py_RefTotal--
|
||||
#define _Py_REF_DEBUG_COMMA ,
|
||||
#define _Py_CHECK_REFCNT(OP) \
|
||||
{ if (((PyObject*)OP)->ob_refcnt < 0) \
|
||||
_Py_NegativeRefcount(__FILE__, __LINE__, \
|
||||
(PyObject *)(OP)); \
|
||||
}
|
||||
#else
|
||||
#define _Py_INC_REFTOTAL
|
||||
#define _Py_DEC_REFTOTAL
|
||||
#define _Py_REF_DEBUG_COMMA
|
||||
#define _Py_CHECK_REFCNT(OP) /* a semicolon */;
|
||||
#define _Py_CHECK_REFCNT(OP) /* a semicolon */;
|
||||
#endif /* Py_REF_DEBUG */
|
||||
|
||||
#ifdef COUNT_ALLOCS
|
||||
PyAPI_FUNC(void) inc_count(PyTypeObject *);
|
||||
PyAPI_FUNC(void) dec_count(PyTypeObject *);
|
||||
#define _Py_INC_TPALLOCS(OP) inc_count(Py_TYPE(OP))
|
||||
#define _Py_INC_TPFREES(OP) dec_count(Py_TYPE(OP))
|
||||
#define _Py_DEC_TPFREES(OP) Py_TYPE(OP)->tp_frees--
|
||||
#define _Py_COUNT_ALLOCS_COMMA ,
|
||||
#define _Py_INC_TPALLOCS(OP) inc_count(Py_TYPE(OP))
|
||||
#define _Py_INC_TPFREES(OP) dec_count(Py_TYPE(OP))
|
||||
#define _Py_DEC_TPFREES(OP) Py_TYPE(OP)->tp_frees--
|
||||
#define _Py_COUNT_ALLOCS_COMMA ,
|
||||
#else
|
||||
#define _Py_INC_TPALLOCS(OP)
|
||||
#define _Py_INC_TPFREES(OP)
|
||||
|
@ -733,30 +733,30 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
|
|||
/* Without Py_TRACE_REFS, there's little enough to do that we expand code
|
||||
* inline.
|
||||
*/
|
||||
#define _Py_NewReference(op) ( \
|
||||
_Py_INC_TPALLOCS(op) _Py_COUNT_ALLOCS_COMMA \
|
||||
_Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \
|
||||
Py_REFCNT(op) = 1)
|
||||
#define _Py_NewReference(op) ( \
|
||||
_Py_INC_TPALLOCS(op) _Py_COUNT_ALLOCS_COMMA \
|
||||
_Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \
|
||||
Py_REFCNT(op) = 1)
|
||||
|
||||
#define _Py_ForgetReference(op) _Py_INC_TPFREES(op)
|
||||
|
||||
#define _Py_Dealloc(op) ( \
|
||||
_Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA \
|
||||
(*Py_TYPE(op)->tp_dealloc)((PyObject *)(op)))
|
||||
#define _Py_Dealloc(op) ( \
|
||||
_Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA \
|
||||
(*Py_TYPE(op)->tp_dealloc)((PyObject *)(op)))
|
||||
#endif /* !Py_TRACE_REFS */
|
||||
|
||||
#define Py_INCREF(op) ( \
|
||||
_Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \
|
||||
((PyObject*)(op))->ob_refcnt++)
|
||||
#define Py_INCREF(op) ( \
|
||||
_Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \
|
||||
((PyObject*)(op))->ob_refcnt++)
|
||||
|
||||
#define Py_DECREF(op) \
|
||||
do { \
|
||||
if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \
|
||||
--((PyObject*)(op))->ob_refcnt != 0) \
|
||||
_Py_CHECK_REFCNT(op) \
|
||||
else \
|
||||
_Py_Dealloc((PyObject *)(op)); \
|
||||
} while (0)
|
||||
#define Py_DECREF(op) \
|
||||
do { \
|
||||
if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \
|
||||
--((PyObject*)(op))->ob_refcnt != 0) \
|
||||
_Py_CHECK_REFCNT(op) \
|
||||
else \
|
||||
_Py_Dealloc((PyObject *)(op)); \
|
||||
} while (0)
|
||||
|
||||
/* Safely decref `op` and set `op` to NULL, especially useful in tp_clear
|
||||
* and tp_dealloc implementatons.
|
||||
|
@ -792,14 +792,14 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
|
|||
* Python integers aren't currently weakly referencable. Best practice is
|
||||
* to use Py_CLEAR() even if you can't think of a reason for why you need to.
|
||||
*/
|
||||
#define Py_CLEAR(op) \
|
||||
do { \
|
||||
if (op) { \
|
||||
PyObject *_py_tmp = (PyObject *)(op); \
|
||||
(op) = NULL; \
|
||||
Py_DECREF(_py_tmp); \
|
||||
} \
|
||||
} while (0)
|
||||
#define Py_CLEAR(op) \
|
||||
do { \
|
||||
if (op) { \
|
||||
PyObject *_py_tmp = (PyObject *)(op); \
|
||||
(op) = NULL; \
|
||||
Py_DECREF(_py_tmp); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Macros to use in case the object pointer may be NULL: */
|
||||
#define Py_XINCREF(op) do { if ((op) == NULL) ; else Py_INCREF(op); } while (0)
|
||||
|
@ -926,13 +926,13 @@ bracketing the body of its tp_dealloc function with a pair of macros:
|
|||
static void
|
||||
mytype_dealloc(mytype *p)
|
||||
{
|
||||
... declarations go here ...
|
||||
... declarations go here ...
|
||||
|
||||
PyObject_GC_UnTrack(p); // must untrack first
|
||||
Py_TRASHCAN_SAFE_BEGIN(p)
|
||||
... The body of the deallocator goes here, including all calls ...
|
||||
... to Py_DECREF on contained objects. ...
|
||||
Py_TRASHCAN_SAFE_END(p)
|
||||
PyObject_GC_UnTrack(p); // must untrack first
|
||||
Py_TRASHCAN_SAFE_BEGIN(p)
|
||||
... The body of the deallocator goes here, including all calls ...
|
||||
... to Py_DECREF on contained objects. ...
|
||||
Py_TRASHCAN_SAFE_END(p)
|
||||
}
|
||||
|
||||
CAUTION: Never return from the middle of the body! If the body needs to
|
||||
|
@ -962,16 +962,16 @@ PyAPI_DATA(PyObject *) _PyTrash_delete_later;
|
|||
#define PyTrash_UNWIND_LEVEL 50
|
||||
|
||||
#define Py_TRASHCAN_SAFE_BEGIN(op) \
|
||||
if (_PyTrash_delete_nesting < PyTrash_UNWIND_LEVEL) { \
|
||||
++_PyTrash_delete_nesting;
|
||||
/* The body of the deallocator is here. */
|
||||
if (_PyTrash_delete_nesting < PyTrash_UNWIND_LEVEL) { \
|
||||
++_PyTrash_delete_nesting;
|
||||
/* The body of the deallocator is here. */
|
||||
#define Py_TRASHCAN_SAFE_END(op) \
|
||||
--_PyTrash_delete_nesting; \
|
||||
if (_PyTrash_delete_later && _PyTrash_delete_nesting <= 0) \
|
||||
_PyTrash_destroy_chain(); \
|
||||
} \
|
||||
else \
|
||||
_PyTrash_deposit_object((PyObject*)op);
|
||||
--_PyTrash_delete_nesting; \
|
||||
if (_PyTrash_delete_later && _PyTrash_delete_nesting <= 0) \
|
||||
_PyTrash_destroy_chain(); \
|
||||
} \
|
||||
else \
|
||||
_PyTrash_deposit_object((PyObject*)op);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue