summaryrefslogtreecommitdiffstats
path: root/Include/object.h
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2003-03-07 15:13:17 (GMT)
committerGuido van Rossum <guido@python.org>2003-03-07 15:13:17 (GMT)
commite5c691abe3946ddbaa00730b92f3b96f96903f7d (patch)
treeca9cc52c3473970b7068be8aed6ec87f9ee2418c /Include/object.h
parent9e1595e6e4c31ebfecd1c4c9f833e39799560963 (diff)
downloadcpython-e5c691abe3946ddbaa00730b92f3b96f96903f7d.zip
cpython-e5c691abe3946ddbaa00730b92f3b96f96903f7d.tar.gz
cpython-e5c691abe3946ddbaa00730b92f3b96f96903f7d.tar.bz2
- The extended type structure used for heap types (new-style
classes defined by Python code using a class statement) is now exported from object.h as PyHeapTypeObject. (SF patch #696193.)
Diffstat (limited to 'Include/object.h')
-rw-r--r--Include/object.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/Include/object.h b/Include/object.h
index 5e509b4..7b93230 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -327,6 +327,28 @@ typedef struct _typeobject {
} 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 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 *name, *slots;
+ /* here are optional user slots, followed by the members. */
+} PyHeapTypeObject;
+
+/* access macro to the members which are floating "behind" the object */
+#define PyHeapType_GET_MEMBERS(etype) \
+ ((PyMemberDef *)(((char *)etype) + (etype)->type.ob_type->tp_basicsize))
+
+
/* Generic type check */
PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *);
#define PyObject_TypeCheck(ob, tp) \