Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 901a41e

Browse files
committed
normalize markup for consistency
1 parent 754a174 commit 901a41e

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

Doc/ext/newtypes.tex

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ \section{The Basics
158158
\end{verbatim}
159159

160160
This is so that Python knows how much memory to allocate when you call
161-
\cfunction{PyObject_New}.
161+
\cfunction{PyObject_New()}.
162162

163163
\begin{verbatim}
164164
0, /* tp_itemsize */
@@ -192,7 +192,7 @@ \section{The Basics
192192
objects. To enable object creation, we have to provide a
193193
\member{tp_new} implementation. In this case, we can just use the
194194
default implementation provided by the API function
195-
\cfunction{PyType_GenericNew}. We'd like to just assign this to the
195+
\cfunction{PyType_GenericNew()}. We'd like to just assign this to the
196196
\member{tp_new} slot, but we can't, for portability sake, On some
197197
platforms or compilers, we can't statically initialize a structure
198198
member with a function defined in another C module, so, instead, we'll
@@ -209,7 +209,7 @@ \section{The Basics
209209
--- that's for a later section!
210210

211211
Everything else in the file should be familiar, except for some code
212-
in \cfunction{initnoddy}:
212+
in \cfunction{initnoddy()}:
213213

214214
\begin{verbatim}
215215
if (PyType_Ready(&noddy_NoddyType) < 0)
@@ -315,7 +315,7 @@ \subsection{Adding data and methods to the Basic example}
315315
\end{verbatim}
316316

317317
This method decrements the reference counts of the two Python
318-
attributes. We use \cfunction{Py_XDECREF} here because the
318+
attributes. We use \cfunction{Py_XDECREF()} here because the
319319
\member{first} and \member{last} members could be \NULL. It then
320320
calls the \member{tp_free} member of the object's type to free the
321321
object's memory. Note that the object's type might not be
@@ -362,14 +362,14 @@ \subsection{Adding data and methods to the Basic example}
362362

363363
The new member is responsible for creating (as opposed to
364364
initializing) objects of the type. It is exposed in Python as the
365-
\method{__new__} method. See the paper titled ``Unifying types and
366-
classes in Python'' for a detailed discussion of the \method{__new__}
365+
\method{__new__()} method. See the paper titled ``Unifying types and
366+
classes in Python'' for a detailed discussion of the \method{__new__()}
367367
method. One reason to implement a new method is to assure the initial
368368
values of instance variables. In this case, we use the new method to
369369
make sure that the initial values of the members \member{first} and
370370
\member{last} are not \NULL. If we didn't care whether the initial
371-
values were \NULL, we could have used \cfunction{PyType_GenericNew} as
372-
our new method, as we did before. \cfunction{PyType_GenericNew}
371+
values were \NULL, we could have used \cfunction{PyType_GenericNew()} as
372+
our new method, as we did before. \cfunction{PyType_GenericNew()}
373373
initializes all of the instance variable members to NULLs.
374374

375375
The new method is a static method that is passed the type being
@@ -422,7 +422,7 @@ \subsection{Adding data and methods to the Basic example}
422422
\end{verbatim}
423423

424424
The \member{tp_init} slot is exposed in Python as the
425-
\method{__init__} method. It is used to initialize an object after
425+
\method{__init__()} method. It is used to initialize an object after
426426
it's created. Unlike the new method, we can't guarantee that the
427427
initializer is called. The initializer isn't called when unpickling
428428
objects and it can be overridden. Our initializer accepts arguments
@@ -550,8 +550,8 @@ \subsection{Adding data and methods to the Basic example}
550550
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
551551
\end{verbatim}
552552

553-
We rename \cfunction{initnoddy} to \cfunction{initnoddy2}
554-
and update the module name passed to \cfunction{Py_InitModule3}.
553+
We rename \cfunction{initnoddy()} to \cfunction{initnoddy2()}
554+
and update the module name passed to \cfunction{Py_InitModule3()}.
555555

556556
Finally, we update our \file{setup.py} file to build the new module:
557557

@@ -661,7 +661,7 @@ \subsection{Providing finer control over data attributes}
661661
With these changes, we can assure that the \member{first} and
662662
\member{last} members are never NULL so we can remove checks for \NULL
663663
values in almost all cases. This means that most of the
664-
\cfunction{Py_XDECREF} calls can be converted to \cfunction{Py_DECREF}
664+
\cfunction{Py_XDECREF()} calls can be converted to \cfunction{Py_DECREF()}
665665
calls. The only place we can't change these calls is in the
666666
deallocator, where there is the possibility that the initialization of
667667
these members failed in the constructor.
@@ -723,8 +723,8 @@ \subsection{Supporting cyclic garbage collection}
723723
\end{verbatim}
724724

725725
For each subobject that can participate in cycles, we need to call the
726-
\cfunction{visit} function, which is passed to the traversal method.
727-
The \cfunction{visit} function takes as arguments the subobject and
726+
\cfunction{visit()} function, which is passed to the traversal method.
727+
The \cfunction{visit()} function takes as arguments the subobject and
728728
the extra argument \var{arg} passed to the traversal method.
729729

730730
We also need to provide a method for clearing any subobjects that can
@@ -751,7 +751,8 @@ \subsection{Supporting cyclic garbage collection}
751751
}
752752
\end{verbatim}
753753

754-
Finally, we add the \constant{Py_TPFLAGS_HAVE_GC} flag to the class flags:
754+
Finally, we add the \constant{Py_TPFLAGS_HAVE_GC} flag to the class
755+
flags:
755756

756757
\begin{verbatim}
757758
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/

0 commit comments

Comments
 (0)