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}
\begin{verbatim}
void
-initspam()
+initspam(void)
{
PyObject *m, *d;
\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}
\begin{verbatim}
void
-initspam()
+initspam(void)
{
(void) Py_InitModule("spam", SpamMethods);
}
* 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);
\begin{verbatim}
void
-initspam()
+initspam(void)
{
PyObject *m;
static void *PySpam_API[PySpam_API_pointers];
}
\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:
\begin{verbatim}
void
-initclient()
+initclient(void)
{
PyObject *m;
};
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)
\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 *