Convert more METH_OLDARGS & PyArg_Parse()

Please review.
This commit is contained in:
Neal Norwitz 2002-04-02 18:26:33 +00:00
parent 187ae56166
commit b0aaec5706
3 changed files with 69 additions and 69 deletions

View File

@ -104,7 +104,7 @@ cl_CompressImage(PyObject *self, PyObject *args)
char *frameBuffer; char *frameBuffer;
PyObject *compressedBuffer; PyObject *compressedBuffer;
if (!PyArg_Parse(args, "(iiiifs#)", &compressionScheme, if (!PyArg_ParseTuple(args, "iiiifs#", &compressionScheme,
&width, &height, &width, &height,
&originalFormat, &compressionRatio, &frameBuffer, &originalFormat, &compressionRatio, &frameBuffer,
&frameBufferSize)) &frameBufferSize))
@ -149,7 +149,7 @@ cl_DecompressImage(PyObject *self, PyObject *args)
int compressedBufferSize, frameBufferSize; int compressedBufferSize, frameBufferSize;
PyObject *frameBuffer; PyObject *frameBuffer;
if (!PyArg_Parse(args, "(iiiis#)", &compressionScheme, &width, &height, if (!PyArg_ParseTuple(args, "iiiis#", &compressionScheme, &width, &height,
&originalFormat, &compressedBuffer, &originalFormat, &compressedBuffer,
&compressedBufferSize)) &compressedBufferSize))
return NULL; return NULL;
@ -670,7 +670,7 @@ doOpen(PyObject *self, PyObject *args, int (*open_func)(int, CL_Handle *),
int scheme; int scheme;
clobject *new; clobject *new;
if (!PyArg_Parse(args, "i", &scheme)) if (!PyArg_ParseTuple(args, "i", &scheme))
return NULL; return NULL;
new = PyObject_New(clobject, &Cltype); new = PyObject_New(clobject, &Cltype);
@ -711,7 +711,7 @@ cl_QueryScheme(PyObject *self, PyObject *args)
int headerlen; int headerlen;
int scheme; int scheme;
if (!PyArg_Parse(args, "s#", &header, &headerlen)) if (!PyArg_ParseTuple(args, "s#", &header, &headerlen))
return NULL; return NULL;
scheme = clQueryScheme(header); scheme = clQueryScheme(header);
@ -728,7 +728,7 @@ cl_QueryMaxHeaderSize(PyObject *self, PyObject *args)
{ {
int scheme; int scheme;
if (!PyArg_Parse(args, "i", &scheme)) if (!PyArg_ParseTuple(args, "i", &scheme))
return NULL; return NULL;
return PyInt_FromLong(clQueryMaxHeaderSize(scheme)); return PyInt_FromLong(clQueryMaxHeaderSize(scheme));
@ -743,7 +743,7 @@ cl_QueryAlgorithms(PyObject *self, PyObject *args)
PyObject *list; PyObject *list;
int i; int i;
if (!PyArg_Parse(args, "i", &algorithmMediaType)) if (!PyArg_ParseTuple(args, "i", &algorithmMediaType))
return NULL; return NULL;
error_handler_called = 0; error_handler_called = 0;
@ -791,7 +791,7 @@ cl_QuerySchemeFromName(PyObject *self, PyObject *args)
char *name; char *name;
int scheme; int scheme;
if (!PyArg_Parse(args, "(is)", &algorithmMediaType, &name)) if (!PyArg_ParseTuple(args, "is", &algorithmMediaType, &name))
return NULL; return NULL;
error_handler_called = 0; error_handler_called = 0;
@ -810,7 +810,7 @@ cl_GetAlgorithmName(PyObject *self, PyObject *args)
int scheme; int scheme;
char *name; char *name;
if (!PyArg_Parse(args, "i", &scheme)) if (!PyArg_ParseTuple(args, "i", &scheme))
return NULL; return NULL;
name = clGetAlgorithmName(scheme); name = clGetAlgorithmName(scheme);
@ -829,9 +829,9 @@ do_set(PyObject *self, PyObject *args, int (*func)(int, int, int))
float fvalue; float fvalue;
int is_float = 0; int is_float = 0;
if (!PyArg_Parse(args, "(iii)", &scheme, &paramID, &value)) { if (!PyArg_ParseTuple(args, "iii", &scheme, &paramID, &value)) {
PyErr_Clear(); PyErr_Clear();
if (!PyArg_Parse(args, "(iif)", &scheme, &paramID, &fvalue)) { if (!PyArg_ParseTuple(args, "iif", &scheme, &paramID, &fvalue)) {
PyErr_Clear(); PyErr_Clear();
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"bad argument list (format '(iii)' or '(iif)')"); "bad argument list (format '(iii)' or '(iif)')");
@ -884,7 +884,7 @@ cl_SetMax(PyObject *self, PyObject *args)
static PyObject *cl_##name(PyObject *self, PyObject *args) \ static PyObject *cl_##name(PyObject *self, PyObject *args) \
{ \ { \
int x; \ int x; \
if (!PyArg_Parse(args, "i", &x)) return NULL; \ if (!PyArg_ParseTuple(args, "i", &x)) return NULL; \
return Py##handler(CL_##name(x)); \ return Py##handler(CL_##name(x)); \
} }
@ -892,7 +892,7 @@ static PyObject *cl_##name(PyObject *self, PyObject *args) \
static PyObject *cl_##name(PyObject *self, PyObject *args) \ static PyObject *cl_##name(PyObject *self, PyObject *args) \
{ \ { \
int a1, a2; \ int a1, a2; \
if (!PyArg_Parse(args, "(ii)", &a1, &a2)) return NULL; \ if (!PyArg_ParseTuple(args, "ii", &a1, &a2)) return NULL; \
return Py##handler(CL_##name(a1, a2)); \ return Py##handler(CL_##name(a1, a2)); \
} }
@ -926,30 +926,30 @@ cvt_type(PyObject *self, PyObject *args)
#endif #endif
static PyMethodDef cl_methods[] = { static PyMethodDef cl_methods[] = {
{"CompressImage", cl_CompressImage, METH_OLDARGS}, {"CompressImage", cl_CompressImage, METH_VARARGS},
{"DecompressImage", cl_DecompressImage, METH_OLDARGS}, {"DecompressImage", cl_DecompressImage, METH_VARARGS},
{"GetAlgorithmName", cl_GetAlgorithmName, METH_OLDARGS}, {"GetAlgorithmName", cl_GetAlgorithmName, METH_VARARGS},
{"OpenCompressor", cl_OpenCompressor, METH_OLDARGS}, {"OpenCompressor", cl_OpenCompressor, METH_VARARGS},
{"OpenDecompressor", cl_OpenDecompressor, METH_OLDARGS}, {"OpenDecompressor", cl_OpenDecompressor, METH_VARARGS},
{"QueryAlgorithms", cl_QueryAlgorithms, METH_OLDARGS}, {"QueryAlgorithms", cl_QueryAlgorithms, METH_VARARGS},
{"QueryMaxHeaderSize", cl_QueryMaxHeaderSize, METH_OLDARGS}, {"QueryMaxHeaderSize", cl_QueryMaxHeaderSize, METH_VARARGS},
{"QueryScheme", cl_QueryScheme, METH_OLDARGS}, {"QueryScheme", cl_QueryScheme, METH_VARARGS},
{"QuerySchemeFromName", cl_QuerySchemeFromName, METH_OLDARGS}, {"QuerySchemeFromName", cl_QuerySchemeFromName, METH_VARARGS},
{"SetDefault", cl_SetDefault, METH_OLDARGS}, {"SetDefault", cl_SetDefault, METH_VARARGS},
{"SetMax", cl_SetMax, METH_OLDARGS}, {"SetMax", cl_SetMax, METH_VARARGS},
{"SetMin", cl_SetMin, METH_OLDARGS}, {"SetMin", cl_SetMin, METH_VARARGS},
{"BytesPerSample", cl_BytesPerSample, METH_OLDARGS}, {"BytesPerSample", cl_BytesPerSample, METH_VARARGS},
{"BytesPerPixel", cl_BytesPerPixel, METH_OLDARGS}, {"BytesPerPixel", cl_BytesPerPixel, METH_VARARGS},
{"AudioFormatName", cl_AudioFormatName, METH_OLDARGS}, {"AudioFormatName", cl_AudioFormatName, METH_VARARGS},
{"VideoFormatName", cl_VideoFormatName, METH_OLDARGS}, {"VideoFormatName", cl_VideoFormatName, METH_VARARGS},
{"AlgorithmNumber", cl_AlgorithmNumber, METH_OLDARGS}, {"AlgorithmNumber", cl_AlgorithmNumber, METH_VARARGS},
{"AlgorithmType", cl_AlgorithmType, METH_OLDARGS}, {"AlgorithmType", cl_AlgorithmType, METH_VARARGS},
{"Algorithm", cl_Algorithm, METH_OLDARGS}, {"Algorithm", cl_Algorithm, METH_VARARGS},
{"ParamNumber", cl_ParamNumber, METH_OLDARGS}, {"ParamNumber", cl_ParamNumber, METH_VARARGS},
{"ParamType", cl_ParamType, METH_OLDARGS}, {"ParamType", cl_ParamType, METH_VARARGS},
{"ParamID", cl_ParamID, METH_OLDARGS}, {"ParamID", cl_ParamID, METH_VARARGS},
#ifdef CLDEBUG #ifdef CLDEBUG
{"cvt_type", cvt_type, METH_OLDARGS}, {"cvt_type", cvt_type, METH_VARARGS},
#endif #endif
{NULL, NULL} /* Sentinel */ {NULL, NULL} /* Sentinel */
}; };

View File

@ -35,7 +35,7 @@ imageop_crop(PyObject *self, PyObject *args)
int ix, iy, xstep, ystep; int ix, iy, xstep, ystep;
PyObject *rv; PyObject *rv;
if ( !PyArg_Parse(args, "(s#iiiiiii)", &cp, &len, &size, &x, &y, if ( !PyArg_ParseTuple(args, "s#iiiiiii", &cp, &len, &size, &x, &y,
&newx1, &newy1, &newx2, &newy2) ) &newx1, &newy1, &newx2, &newy2) )
return 0; return 0;
@ -90,7 +90,7 @@ imageop_scale(PyObject *self, PyObject *args)
int oix, oiy; int oix, oiy;
PyObject *rv; PyObject *rv;
if ( !PyArg_Parse(args, "(s#iiiii)", if ( !PyArg_ParseTuple(args, "s#iiiii",
&cp, &len, &size, &x, &y, &newx, &newy) ) &cp, &len, &size, &x, &y, &newx, &newy) )
return 0; return 0;
@ -136,7 +136,7 @@ imageop_tovideo(PyObject *self, PyObject *args)
PyObject *rv; PyObject *rv;
if ( !PyArg_Parse(args, "(s#iii)", &cp, &len, &width, &maxx, &maxy) ) if ( !PyArg_ParseTuple(args, "s#iii", &cp, &len, &width, &maxx, &maxy) )
return 0; return 0;
if ( width != 1 && width != 4 ) { if ( width != 1 && width != 4 ) {
@ -190,7 +190,7 @@ imageop_grey2mono(PyObject *self, PyObject *args)
int i, bit; int i, bit;
if ( !PyArg_Parse(args, "(s#iii)", &cp, &len, &x, &y, &tres) ) if ( !PyArg_ParseTuple(args, "s#iii", &cp, &len, &x, &y, &tres) )
return 0; return 0;
if ( x*y != len ) { if ( x*y != len ) {
@ -231,7 +231,7 @@ imageop_grey2grey4(PyObject *self, PyObject *args)
int pos; int pos;
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) ) if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0; return 0;
if ( x*y != len ) { if ( x*y != len ) {
@ -270,7 +270,7 @@ imageop_grey2grey2(PyObject *self, PyObject *args)
int pos; int pos;
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) ) if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0; return 0;
if ( x*y != len ) { if ( x*y != len ) {
@ -308,7 +308,7 @@ imageop_dither2mono(PyObject *self, PyObject *args)
int i, bit; int i, bit;
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) ) if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0; return 0;
if ( x*y != len ) { if ( x*y != len ) {
@ -354,7 +354,7 @@ imageop_dither2grey2(PyObject *self, PyObject *args)
int sum = 0, nvalue; int sum = 0, nvalue;
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) ) if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0; return 0;
if ( x*y != len ) { if ( x*y != len ) {
@ -393,7 +393,7 @@ imageop_mono2grey(PyObject *self, PyObject *args)
PyObject *rv; PyObject *rv;
int i, bit; int i, bit;
if ( !PyArg_Parse(args, "(s#iiii)", &cp, &len, &x, &y, &v0, &v1) ) if ( !PyArg_ParseTuple(args, "s#iiii", &cp, &len, &x, &y, &v0, &v1) )
return 0; return 0;
nlen = x*y; nlen = x*y;
@ -430,7 +430,7 @@ imageop_grey22grey(PyObject *self, PyObject *args)
PyObject *rv; PyObject *rv;
int i, pos, value = 0, nvalue; int i, pos, value = 0, nvalue;
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) ) if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0; return 0;
nlen = x*y; nlen = x*y;
@ -466,7 +466,7 @@ imageop_grey42grey(PyObject *self, PyObject *args)
PyObject *rv; PyObject *rv;
int i, pos, value = 0, nvalue; int i, pos, value = 0, nvalue;
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) ) if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0; return 0;
nlen = x*y; nlen = x*y;
@ -503,7 +503,7 @@ imageop_rgb2rgb8(PyObject *self, PyObject *args)
int i, r, g, b; int i, r, g, b;
Py_UInt32 value, nvalue; Py_UInt32 value, nvalue;
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) ) if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0; return 0;
nlen = x*y; nlen = x*y;
@ -545,7 +545,7 @@ imageop_rgb82rgb(PyObject *self, PyObject *args)
int i, r, g, b; int i, r, g, b;
Py_UInt32 value, nvalue; Py_UInt32 value, nvalue;
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) ) if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0; return 0;
nlen = x*y; nlen = x*y;
@ -586,7 +586,7 @@ imageop_rgb2grey(PyObject *self, PyObject *args)
int i, r, g, b; int i, r, g, b;
Py_UInt32 value, nvalue; Py_UInt32 value, nvalue;
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) ) if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0; return 0;
nlen = x*y; nlen = x*y;
@ -622,7 +622,7 @@ imageop_grey2rgb(PyObject *self, PyObject *args)
int i; int i;
Py_UInt32 value; Py_UInt32 value;
if ( !PyArg_Parse(args, "(s#ii)", &cp, &len, &x, &y) ) if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0; return 0;
nlen = x*y; nlen = x*y;
@ -677,21 +677,21 @@ imageop_mul(object *self, object *args)
*/ */
static PyMethodDef imageop_methods[] = { static PyMethodDef imageop_methods[] = {
{ "crop", imageop_crop, METH_OLDARGS }, { "crop", imageop_crop, METH_VARARGS },
{ "scale", imageop_scale, METH_OLDARGS }, { "scale", imageop_scale, METH_VARARGS },
{ "grey2mono", imageop_grey2mono, METH_OLDARGS }, { "grey2mono", imageop_grey2mono, METH_VARARGS },
{ "grey2grey2", imageop_grey2grey2, METH_OLDARGS }, { "grey2grey2", imageop_grey2grey2, METH_VARARGS },
{ "grey2grey4", imageop_grey2grey4, METH_OLDARGS }, { "grey2grey4", imageop_grey2grey4, METH_VARARGS },
{ "dither2mono", imageop_dither2mono, METH_OLDARGS }, { "dither2mono", imageop_dither2mono, METH_VARARGS },
{ "dither2grey2", imageop_dither2grey2, METH_OLDARGS }, { "dither2grey2", imageop_dither2grey2, METH_VARARGS },
{ "mono2grey", imageop_mono2grey, METH_OLDARGS }, { "mono2grey", imageop_mono2grey, METH_VARARGS },
{ "grey22grey", imageop_grey22grey, METH_OLDARGS }, { "grey22grey", imageop_grey22grey, METH_VARARGS },
{ "grey42grey", imageop_grey42grey, METH_OLDARGS }, { "grey42grey", imageop_grey42grey, METH_VARARGS },
{ "tovideo", imageop_tovideo, METH_OLDARGS }, { "tovideo", imageop_tovideo, METH_VARARGS },
{ "rgb2rgb8", imageop_rgb2rgb8, METH_OLDARGS }, { "rgb2rgb8", imageop_rgb2rgb8, METH_VARARGS },
{ "rgb82rgb", imageop_rgb82rgb, METH_OLDARGS }, { "rgb82rgb", imageop_rgb82rgb, METH_VARARGS },
{ "rgb2grey", imageop_rgb2grey, METH_OLDARGS }, { "rgb2grey", imageop_rgb2grey, METH_VARARGS },
{ "grey2rgb", imageop_grey2rgb, METH_OLDARGS }, { "grey2rgb", imageop_grey2rgb, METH_VARARGS },
{ 0, 0 } { 0, 0 }
}; };

View File

@ -11,7 +11,7 @@ static PyObject *
sgi_nap(PyObject *self, PyObject *args) sgi_nap(PyObject *self, PyObject *args)
{ {
long ticks; long ticks;
if (!PyArg_Parse(args, "l", &ticks)) if (!PyArg_ParseTuple(args, "l:nap", &ticks))
return NULL; return NULL;
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
sginap(ticks); sginap(ticks);
@ -30,7 +30,7 @@ sgi__getpty(PyObject *self, PyObject *args)
int nofork; int nofork;
char *name; char *name;
int fildes; int fildes;
if (!PyArg_Parse(args, "(iii)", &oflag, &mode, &nofork)) if (!PyArg_ParseTuple(args, "iii:_getpty", &oflag, &mode, &nofork))
return NULL; return NULL;
errno = 0; errno = 0;
name = _getpty(&fildes, oflag, (mode_t)mode, nofork); name = _getpty(&fildes, oflag, (mode_t)mode, nofork);
@ -42,8 +42,8 @@ sgi__getpty(PyObject *self, PyObject *args)
} }
static PyMethodDef sgi_methods[] = { static PyMethodDef sgi_methods[] = {
{"nap", sgi_nap, METH_OLDARGS}, {"nap", sgi_nap, METH_VARARGS},
{"_getpty", sgi__getpty, METH_OLDARGS}, {"_getpty", sgi__getpty, METH_VARARGS},
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };