summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-11-17 06:50:42 (GMT)
committerFred Drake <fdrake@acm.org>2001-11-17 06:50:42 (GMT)
commitef6373a4f67d1921443fa8572927ce089e779b96 (patch)
treed04bbedf057acc73d0298653f9bd57990b0fc8ba
parent50ecc15d05837123d34e088863083ee39800a502 (diff)
downloadcpython-ef6373a4f67d1921443fa8572927ce089e779b96.zip
cpython-ef6373a4f67d1921443fa8572927ce089e779b96.tar.gz
cpython-ef6373a4f67d1921443fa8572927ce089e779b96.tar.bz2
Exhibit good form in C code: always provide docstrings in method tables, and
always fill in all slots of table entries. Fixed a few minor markup errors.
-rw-r--r--Doc/ext/embedding.tex7
-rw-r--r--Doc/ext/extending.tex24
-rw-r--r--Doc/ext/newtypes.tex13
3 files changed, 25 insertions, 19 deletions
diff --git a/Doc/ext/embedding.tex b/Doc/ext/embedding.tex
index 90663dc..453a939 100644
--- a/Doc/ext/embedding.tex
+++ b/Doc/ext/embedding.tex
@@ -231,9 +231,10 @@ emb_numargs(PyObject *self, PyObject *args)
return Py_BuildValue("i", numargs);
}
-static PyMethodDef EmbMethods[]={
- {"numargs", emb_numargs, METH_VARARGS},
- {NULL, NULL}
+static PyMethodDef EmbMethods[] = {
+ {"numargs", emb_numargs, METH_VARARGS,
+ "Return the number of arguments received by the process."},
+ {NULL, NULL, 0, NULL}
};
\end{verbatim}
diff --git a/Doc/ext/extending.tex b/Doc/ext/extending.tex
index 6df443c..49a561c 100644
--- a/Doc/ext/extending.tex
+++ b/Doc/ext/extending.tex
@@ -215,7 +215,7 @@ the error checking for now):
\begin{verbatim}
void
-initspam()
+initspam(void)
{
PyObject *m, *d;
@@ -308,9 +308,10 @@ table'':
\begin{verbatim}
static PyMethodDef SpamMethods[] = {
...
- {"system", spam_system, METH_VARARGS},
+ {"system", spam_system, METH_VARARGS,
+ "Execute a shell command."},
...
- {NULL, NULL} /* Sentinel */
+ {NULL, NULL, 0, NULL} /* Sentinel */
};
\end{verbatim}
@@ -340,7 +341,7 @@ the module file:
\begin{verbatim}
void
-initspam()
+initspam(void)
{
(void) Py_InitModule("spam", SpamMethods);
}
@@ -992,12 +993,13 @@ static PyMethodDef keywdarg_methods[] = {
* only take two PyObject* parameters, and keywdarg_parrot() takes
* three.
*/
- {"parrot", (PyCFunction)keywdarg_parrot, METH_VARARGS|METH_KEYWORDS},
- {NULL, NULL} /* sentinel */
+ {"parrot", (PyCFunction)keywdarg_parrot, METH_VARARGS|METH_KEYWORDS,
+ "Print a lovely skit to standard output."},
+ {NULL, NULL, 0, NULL} /* sentinel */
};
void
-initkeywdarg()
+initkeywdarg(void)
{
/* Create the module and add the functions */
Py_InitModule("keywdarg", keywdarg_methods);
@@ -1590,7 +1592,7 @@ the C API pointer array:
\begin{verbatim}
void
-initspam()
+initspam(void)
{
PyObject *m;
static void *PySpam_API[PySpam_API_pointers];
@@ -1614,8 +1616,8 @@ initspam()
}
\end{verbatim}
-Note that \code{PySpam_API} is declared \code{static}; otherwise
-the pointer array would disappear when \code{initspam} terminates!
+Note that \code{PySpam_API} is declared \keyword{static}; otherwise
+the pointer array would disappear when \function{initspam()} terminates!
The bulk of the work is in the header file \file{spammodule.h},
which looks like this:
@@ -1679,7 +1681,7 @@ function:
\begin{verbatim}
void
-initclient()
+initclient(void)
{
PyObject *m;
diff --git a/Doc/ext/newtypes.tex b/Doc/ext/newtypes.tex
index c8f7c6c..17e2b25 100644
--- a/Doc/ext/newtypes.tex
+++ b/Doc/ext/newtypes.tex
@@ -77,8 +77,9 @@ static PyTypeObject noddy_NoddyType = {
};
static PyMethodDef noddy_methods[] = {
- { "new_noddy", noddy_new_noddy, METH_VARARGS },
- {NULL, NULL}
+ {"new_noddy", noddy_new_noddy, METH_VARARGS,
+ "Create a new Noddy object."},
+ {NULL, NULL, 0, NULL}
};
DL_EXPORT(void)
@@ -581,9 +582,11 @@ Here is an example:
\begin{verbatim}
static PyMethodDef newdatatype_methods[] = {
- {"getSize", (PyCFunction)newdatatype_getSize, METH_VARARGS},
- {"setSize", (PyCFunction)newdatatype_setSize, METH_VARARGS},
- {NULL, NULL} /* sentinel */
+ {"getSize", (PyCFunction)newdatatype_getSize, METH_VARARGS,
+ "Return the current size."},
+ {"setSize", (PyCFunction)newdatatype_setSize, METH_VARARGS,
+ "Set the size."},
+ {NULL, NULL, 0, NULL} /* sentinel */
};
static PyObject *