diff options
Diffstat (limited to 'Doc/ext')
-rw-r--r-- | Doc/ext/newtypes.tex | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/Doc/ext/newtypes.tex b/Doc/ext/newtypes.tex index 5371841..15742e3 100644 --- a/Doc/ext/newtypes.tex +++ b/Doc/ext/newtypes.tex @@ -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 |