]> granicus.if.org Git - python/commitdiff
Added comments for more entries of the type structure in the example
authorFred Drake <fdrake@acm.org>
Thu, 28 Mar 2002 23:45:22 +0000 (23:45 +0000)
committerFred Drake <fdrake@acm.org>
Thu, 28 Mar 2002 23:45:22 +0000 (23:45 +0000)
type implementation.

Doc/ext/newtypes.tex

index 5371841c046b9bc94c24e0d0f75a18ed0be7984a..15742e322a10764564d9a6755200738a065e4c62 100644 (file)
@@ -152,20 +152,20 @@ Moving on, we come to the crunch --- the type object.
 \begin{verbatim}
 static PyTypeObject noddy_NoddyType = {
     PyObject_HEAD_INIT(NULL)
-    0,
-    "Noddy",
-    sizeof(noddy_NoddyObject),
-    0,
-    noddy_noddy_dealloc, /*tp_dealloc*/
-    0,                   /*tp_print*/
-    0,                   /*tp_getattr*/
-    0,                   /*tp_setattr*/
-    0,                   /*tp_compare*/
-    0,                   /*tp_repr*/
-    0,                   /*tp_as_number*/
-    0,                   /*tp_as_sequence*/
-    0,                   /*tp_as_mapping*/
-    0,                   /*tp_hash */
+    0,                          /* ob_size */
+    "Noddy",                    /* tp_name */
+    sizeof(noddy_NoddyObject),  /* tp_basicsize */
+    0,                          /* tp_itemsize */
+    noddy_noddy_dealloc,        /* tp_dealloc */
+    0,                          /* tp_print */
+    0,                          /* tp_getattr */
+    0,                          /* tp_setattr */
+    0,                          /* tp_compare */
+    0,                          /* tp_repr */
+    0,                          /* tp_as_number */
+    0,                          /* tp_as_sequence */
+    0,                          /* tp_as_mapping */
+    0,                          /* tp_hash */
 };
 \end{verbatim}
 
@@ -194,7 +194,7 @@ conforming C and some compilers complain.  So instead we fill in the
 oppourtunity --- in \cfunction{initnoddy()}.
 
 \begin{verbatim}
-    0,
+    0,                          /* ob_size */
 \end{verbatim}
 
 The \member{ob_size} field of the header is not used; it's presence in
@@ -203,7 +203,7 @@ binary compatibility with extension modules compiled for older
 versions of Python.  Always set this field to zero.
 
 \begin{verbatim}
-    "Noddy",
+    "Noddy",                    /* tp_name */
 \end{verbatim}
 
 The name of our type.  This will appear in the default textual
@@ -217,14 +217,14 @@ TypeError: cannot add type "Noddy" to string
 \end{verbatim}
 
 \begin{verbatim}
-    sizeof(noddy_NoddyObject),
+    sizeof(noddy_NoddyObject),  /* tp_basicsize */
 \end{verbatim}
 
 This is so that Python knows how much memory to allocate when you call
 \cfunction{PyObject_New}.
 
 \begin{verbatim}
-    0,
+    0,                          /* tp_itemsize */
 \end{verbatim}
 
 This has to do with variable length objects like lists and strings.
@@ -236,7 +236,7 @@ implement many of these, but as mentioned above you have to implement
 the deallocation function.
 
 \begin{verbatim}
-    noddy_noddy_dealloc, /*tp_dealloc*/
+    noddy_noddy_dealloc,        /* tp_dealloc */
 \end{verbatim}
 
 From here, all the type methods are \NULL, so I won't go over them yet