summaryrefslogtreecommitdiff
path: root/Include/object.h
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2007-12-19 02:37:44 +0000
committerChristian Heimes <christian@cheimes.de>2007-12-19 02:37:44 +0000
commit313c52225f6d34857203468bc0b431ff46195e1d (patch)
tree1ac4cf6d4292744b963ab4cfe62b4b42e1901ba6 /Include/object.h
parent4550ac1ac308a43c60070fc51dc68d1d054f51b5 (diff)
downloadcpython-313c52225f6d34857203468bc0b431ff46195e1d.tar.gz
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available.
Diffstat (limited to 'Include/object.h')
-rw-r--r--Include/object.h29
1 files changed, 17 insertions, 12 deletions
diff --git a/Include/object.h b/Include/object.h
index daba4b65ff..b434a21fb3 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -111,9 +111,14 @@ typedef struct {
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)
+
+/* B/w compatibility */
+#define Py_Refcnt(ob) Py_REFCNT(op)
+#define Py_Type(op) Py_TYPE(op)
+#define Py_Size(op) Py_SIZE(op)
/*
Type objects contain a string containing the type name (to help somewhat
@@ -370,21 +375,21 @@ typedef struct _heaptypeobject {
/* access macro to the members which are floating "behind" the object */
#define PyHeapType_GET_MEMBERS(etype) \
- ((PyMemberDef *)(((char *)etype) + Py_Type(etype)->tp_basicsize))
+ ((PyMemberDef *)(((char *)etype) + Py_TYPE(etype)->tp_basicsize))
/* 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)
-#define PyType_CheckExact(op) (Py_Type(op) == &PyType_Type)
+ 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);
@@ -619,9 +624,9 @@ PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void);
#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_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)
@@ -646,13 +651,13 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
#define _Py_NewReference(op) ( \
_Py_INC_TPALLOCS(op) _Py_COUNT_ALLOCS_COMMA \
_Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \
- Py_Refcnt(op) = 1)
+ 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)))
+ (*Py_TYPE(op)->tp_dealloc)((PyObject *)(op)))
#endif /* !Py_TRACE_REFS */
#define Py_INCREF(op) ( \