Convert from using METH_OLDARGS to METH_NOARGS.

These should be safe.
This commit is contained in:
Neal Norwitz 2002-03-31 14:57:24 +00:00
parent 01b2694acb
commit 50905b557b
3 changed files with 44 additions and 85 deletions

View File

@ -183,13 +183,10 @@ cl_DecompressImage(PyObject *self, PyObject *args)
} }
static PyObject * static PyObject *
doClose(clobject *self, PyObject *args, int (*close_func)(CL_Handle)) doClose(clobject *self, int (*close_func)(CL_Handle))
{ {
CheckCompressor(self); CheckCompressor(self);
if (!PyArg_NoArgs(args))
return NULL;
error_handler_called = 0; error_handler_called = 0;
if ((*close_func)(self->ob_compressorHdl) == FAILURE || if ((*close_func)(self->ob_compressorHdl) == FAILURE ||
error_handler_called) { error_handler_called) {
@ -209,15 +206,15 @@ doClose(clobject *self, PyObject *args, int (*close_func)(CL_Handle))
} }
static PyObject * static PyObject *
clm_CloseCompressor(PyObject *self, PyObject *args) clm_CloseCompressor(PyObject *self)
{ {
return doClose(SELF, args, clCloseCompressor); return doClose(SELF, clCloseCompressor);
} }
static PyObject * static PyObject *
clm_CloseDecompressor(PyObject *self, PyObject *args) clm_CloseDecompressor(PyObject *self)
{ {
return doClose(SELF, args, clCloseDecompressor); return doClose(SELF, clCloseDecompressor);
} }
static PyObject * static PyObject *
@ -479,7 +476,7 @@ clm_GetParamID(PyObject *self, PyObject *args)
} }
static PyObject * static PyObject *
clm_QueryParams(PyObject *self, PyObject *args) clm_QueryParams(PyObject *self)
{ {
int bufferlength; int bufferlength;
int *PVbuffer; int *PVbuffer;
@ -488,9 +485,6 @@ clm_QueryParams(PyObject *self, PyObject *args)
CheckCompressor(SELF); CheckCompressor(SELF);
if (!PyArg_NoArgs(args))
return NULL;
error_handler_called = 0; error_handler_called = 0;
bufferlength = clQueryParams(SELF->ob_compressorHdl, 0, 0); bufferlength = clQueryParams(SELF->ob_compressorHdl, 0, 0);
if (error_handler_called) if (error_handler_called)
@ -574,13 +568,9 @@ clm_GetName(PyObject *self, PyObject *args)
} }
static PyObject * static PyObject *
clm_QuerySchemeFromHandle(PyObject *self, PyObject *args) clm_QuerySchemeFromHandle(PyObject *self)
{ {
CheckCompressor(SELF); CheckCompressor(SELF);
if (!PyArg_NoArgs(args))
return NULL;
return PyInt_FromLong(clQuerySchemeFromHandle(SELF->ob_compressorHdl)); return PyInt_FromLong(clQuerySchemeFromHandle(SELF->ob_compressorHdl));
} }
@ -600,8 +590,8 @@ clm_ReadHeader(PyObject *self, PyObject *args)
} }
static PyMethodDef compressor_methods[] = { static PyMethodDef compressor_methods[] = {
{"close", clm_CloseCompressor, METH_OLDARGS}, /* alias */ {"close", clm_CloseCompressor, METH_NOARGS}, /* alias */
{"CloseCompressor", clm_CloseCompressor, METH_OLDARGS}, {"CloseCompressor", clm_CloseCompressor, METH_NOARGS},
{"Compress", clm_Compress, METH_OLDARGS}, {"Compress", clm_Compress, METH_OLDARGS},
{"GetDefault", clm_GetDefault, METH_OLDARGS}, {"GetDefault", clm_GetDefault, METH_OLDARGS},
{"GetMinMax", clm_GetMinMax, METH_OLDARGS}, {"GetMinMax", clm_GetMinMax, METH_OLDARGS},
@ -609,16 +599,16 @@ static PyMethodDef compressor_methods[] = {
{"GetParam", clm_GetParam, METH_OLDARGS}, {"GetParam", clm_GetParam, METH_OLDARGS},
{"GetParamID", clm_GetParamID, METH_OLDARGS}, {"GetParamID", clm_GetParamID, METH_OLDARGS},
{"GetParams", clm_GetParams, METH_OLDARGS}, {"GetParams", clm_GetParams, METH_OLDARGS},
{"QueryParams", clm_QueryParams, METH_OLDARGS}, {"QueryParams", clm_QueryParams, METH_NOARGS},
{"QuerySchemeFromHandle",clm_QuerySchemeFromHandle, METH_OLDARGS}, {"QuerySchemeFromHandle",clm_QuerySchemeFromHandle, METH_NOARGS},
{"SetParam", clm_SetParam, METH_OLDARGS}, {"SetParam", clm_SetParam, METH_OLDARGS},
{"SetParams", clm_SetParams, METH_OLDARGS}, {"SetParams", clm_SetParams, METH_OLDARGS},
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };
static PyMethodDef decompressor_methods[] = { static PyMethodDef decompressor_methods[] = {
{"close", clm_CloseDecompressor, METH_OLDARGS}, /* alias */ {"close", clm_CloseDecompressor, METH_NOARGS}, /* alias */
{"CloseDecompressor", clm_CloseDecompressor, METH_OLDARGS}, {"CloseDecompressor", clm_CloseDecompressor, METH_NOARGS},
{"Decompress", clm_Decompress, METH_OLDARGS}, {"Decompress", clm_Decompress, METH_OLDARGS},
{"GetDefault", clm_GetDefault, METH_OLDARGS}, {"GetDefault", clm_GetDefault, METH_OLDARGS},
{"GetMinMax", clm_GetMinMax, METH_OLDARGS}, {"GetMinMax", clm_GetMinMax, METH_OLDARGS},
@ -627,8 +617,8 @@ static PyMethodDef decompressor_methods[] = {
{"GetParamID", clm_GetParamID, METH_OLDARGS}, {"GetParamID", clm_GetParamID, METH_OLDARGS},
{"GetParams", clm_GetParams, METH_OLDARGS}, {"GetParams", clm_GetParams, METH_OLDARGS},
{"ReadHeader", clm_ReadHeader, METH_OLDARGS}, {"ReadHeader", clm_ReadHeader, METH_OLDARGS},
{"QueryParams", clm_QueryParams, METH_OLDARGS}, {"QueryParams", clm_QueryParams, METH_NOARGS},
{"QuerySchemeFromHandle",clm_QuerySchemeFromHandle, METH_OLDARGS}, {"QuerySchemeFromHandle",clm_QuerySchemeFromHandle, METH_NOARGS},
{"SetParam", clm_SetParam, METH_OLDARGS}, {"SetParam", clm_SetParam, METH_OLDARGS},
{"SetParams", clm_SetParams, METH_OLDARGS}, {"SetParams", clm_SetParams, METH_OLDARGS},
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */

View File

@ -49,22 +49,18 @@ fh_scalefont(fhobject *self, PyObject *args)
/* XXX fmmakefont */ /* XXX fmmakefont */
static PyObject * static PyObject *
fh_setfont(fhobject *self, PyObject *args) fh_setfont(fhobject *self)
{ {
if (!PyArg_NoArgs(args))
return NULL;
fmsetfont(self->fh_fh); fmsetfont(self->fh_fh);
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
static PyObject * static PyObject *
fh_getfontname(fhobject *self, PyObject *args) fh_getfontname(fhobject *self)
{ {
char fontname[256]; char fontname[256];
int len; int len;
if (!PyArg_NoArgs(args))
return NULL;
len = fmgetfontname(self->fh_fh, sizeof fontname, fontname); len = fmgetfontname(self->fh_fh, sizeof fontname, fontname);
if (len < 0) { if (len < 0) {
PyErr_SetString(PyExc_RuntimeError, "error in fmgetfontname"); PyErr_SetString(PyExc_RuntimeError, "error in fmgetfontname");
@ -74,12 +70,10 @@ fh_getfontname(fhobject *self, PyObject *args)
} }
static PyObject * static PyObject *
fh_getcomment(fhobject *self, PyObject *args) fh_getcomment(fhobject *self)
{ {
char comment[256]; char comment[256];
int len; int len;
if (!PyArg_NoArgs(args))
return NULL;
len = fmgetcomment(self->fh_fh, sizeof comment, comment); len = fmgetcomment(self->fh_fh, sizeof comment, comment);
if (len < 0) { if (len < 0) {
PyErr_SetString(PyExc_RuntimeError, "error in fmgetcomment"); PyErr_SetString(PyExc_RuntimeError, "error in fmgetcomment");
@ -89,11 +83,9 @@ fh_getcomment(fhobject *self, PyObject *args)
} }
static PyObject * static PyObject *
fh_getfontinfo(fhobject *self, PyObject *args) fh_getfontinfo(fhobject *self)
{ {
fmfontinfo info; fmfontinfo info;
if (!PyArg_NoArgs(args))
return NULL;
if (fmgetfontinfo(self->fh_fh, &info) < 0) { if (fmgetfontinfo(self->fh_fh, &info) < 0) {
PyErr_SetString(PyExc_RuntimeError, "error in fmgetfontinfo"); PyErr_SetString(PyExc_RuntimeError, "error in fmgetfontinfo");
return NULL; return NULL;
@ -126,11 +118,11 @@ fh_getstrwidth(fhobject *self, PyObject *args)
} }
static PyMethodDef fh_methods[] = { static PyMethodDef fh_methods[] = {
{"scalefont", (PyCFunction)fh_scalefont, METH_OLDARGS}, {"scalefont", (PyCFunction)fh_scalefont, METH_OLDARGS},
{"setfont", (PyCFunction)fh_setfont, METH_OLDARGS}, {"setfont", (PyCFunction)fh_setfont, METH_NOARGS},
{"getfontname", (PyCFunction)fh_getfontname, METH_OLDARGS}, {"getfontname", (PyCFunction)fh_getfontname, METH_NOARGS},
{"getcomment", (PyCFunction)fh_getcomment, METH_OLDARGS}, {"getcomment", (PyCFunction)fh_getcomment, METH_NOARGS},
{"getfontinfo", (PyCFunction)fh_getfontinfo, METH_OLDARGS}, {"getfontinfo", (PyCFunction)fh_getfontinfo, METH_NOARGS},
#if 0 #if 0
{"getwholemetrics", (PyCFunction)fh_getwholemetrics, METH_OLDARGS}, {"getwholemetrics", (PyCFunction)fh_getwholemetrics, METH_OLDARGS},
#endif #endif
@ -170,10 +162,8 @@ static PyTypeObject Fhtype = {
/* Font Manager functions */ /* Font Manager functions */
static PyObject * static PyObject *
fm_init(PyObject *self, PyObject *args) fm_init(PyObject *self)
{ {
if (!PyArg_NoArgs(args))
return NULL;
fminit(); fminit();
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
@ -224,11 +214,9 @@ clientproc(char *fontname)
} }
static PyObject * static PyObject *
fm_enumerate(PyObject *self, PyObject *args) fm_enumerate(PyObject *self)
{ {
PyObject *res; PyObject *res;
if (!PyArg_NoArgs(args))
return NULL;
fontlist = PyList_New(0); fontlist = PyList_New(0);
if (fontlist == NULL) if (fontlist == NULL)
return NULL; return NULL;
@ -250,20 +238,18 @@ fm_setpath(PyObject *self, PyObject *args)
} }
static PyObject * static PyObject *
fm_fontpath(PyObject *self, PyObject *args) fm_fontpath(PyObject *self)
{ {
if (!PyArg_NoArgs(args))
return NULL;
return PyString_FromString(fmfontpath()); return PyString_FromString(fmfontpath());
} }
static PyMethodDef fm_methods[] = { static PyMethodDef fm_methods[] = {
{"init", fm_init, METH_OLDARGS}, {"init", fm_init, METH_NOARGS},
{"findfont", fm_findfont, METH_OLDARGS}, {"findfont", fm_findfont, METH_OLDARGS},
{"enumerate", fm_enumerate, METH_OLDARGS}, {"enumerate", fm_enumerate, METH_NOARGS},
{"prstr", fm_prstr, METH_OLDARGS}, {"prstr", fm_prstr, METH_OLDARGS},
{"setpath", fm_setpath, METH_OLDARGS}, {"setpath", fm_setpath, METH_OLDARGS},
{"fontpath", fm_fontpath, METH_OLDARGS}, {"fontpath", fm_fontpath, METH_NOARGS},
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };

View File

@ -8,63 +8,46 @@
#include "timing.h" #include "timing.h"
static PyObject * static PyObject *
start_timing(PyObject *self, PyObject *args) start_timing(PyObject *self)
{ {
if (!PyArg_Parse(args, ""))
return NULL;
Py_INCREF(Py_None); Py_INCREF(Py_None);
BEGINTIMING; BEGINTIMING;
return Py_None; return Py_None;
} }
static PyObject * static PyObject *
finish_timing(PyObject *self, PyObject *args) finish_timing(PyObject *self)
{ {
if (!PyArg_Parse(args, ""))
return NULL;
ENDTIMING ENDTIMING
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
static PyObject * static PyObject *
seconds(PyObject *self, PyObject *args) seconds(PyObject *self)
{ {
if (!PyArg_Parse(args, ""))
return NULL;
return PyInt_FromLong(TIMINGS); return PyInt_FromLong(TIMINGS);
} }
static PyObject * static PyObject *
milli(PyObject *self, PyObject *args) milli(PyObject *self)
{ {
if (!PyArg_Parse(args, ""))
return NULL;
return PyInt_FromLong(TIMINGMS); return PyInt_FromLong(TIMINGMS);
} }
static PyObject * static PyObject *
micro(PyObject *self, PyObject *args) micro(PyObject *self)
{ {
if (!PyArg_Parse(args, ""))
return NULL;
return PyInt_FromLong(TIMINGUS); return PyInt_FromLong(TIMINGUS);
} }
static PyMethodDef timing_methods[] = { static PyMethodDef timing_methods[] = {
{"start", start_timing, METH_OLDARGS}, {"start", (PyCFunction)start_timing, METH_NOARGS},
{"finish", finish_timing, METH_OLDARGS}, {"finish", (PyCFunction)finish_timing, METH_NOARGS},
{"seconds", seconds, METH_OLDARGS}, {"seconds", (PyCFunction)seconds, METH_NOARGS},
{"milli", milli, METH_OLDARGS}, {"milli", (PyCFunction)milli, METH_NOARGS},
{"micro", micro, METH_OLDARGS}, {"micro", (PyCFunction)micro, METH_NOARGS},
{NULL, NULL} {NULL, NULL}
}; };