Kaydet (Commit) bf92f465 authored tarafından Georg Brandl's avatar Georg Brandl

Convert more modules to METH_VARARGS.

üst 96a8c395
......@@ -35,7 +35,7 @@ gestalt_gestalt(PyObject *self, PyObject *args)
OSErr iErr;
OSType selector;
long response;
if (!PyArg_Parse(args, "O&", PyMac_GetOSType, &selector))
if (!PyArg_ParseTuple(args, "O&", PyMac_GetOSType, &selector))
return NULL;
iErr = Gestalt ( selector, &response );
if (iErr != 0)
......@@ -44,7 +44,7 @@ gestalt_gestalt(PyObject *self, PyObject *args)
}
static struct PyMethodDef gestalt_methods[] = {
{"gestalt", gestalt_gestalt},
{"gestalt", gestalt_gestalt, METH_VARARGS},
{NULL, NULL} /* Sentinel */
};
......
......@@ -148,22 +148,21 @@ releaseobjects(FL_FORM *form)
static PyObject *
generic_set_call_back(genericobject *g, PyObject *args)
{
if (args == NULL) {
if (PyTuple_GET_SIZE(args) == 0) {
Py_XDECREF(g->ob_callback);
Py_XDECREF(g->ob_callback_arg);
g->ob_callback = NULL;
g->ob_callback_arg = NULL;
}
else {
if (!PyTuple_Check(args) || PyTuple_Size(args) != 2) {
PyErr_BadArgument();
return NULL;
}
PyObject *a, *b;
if (!PyArg_UnpackTuple(args, "set_call_back", 2, 2, &a, &b)
return NULL;
Py_XDECREF(g->ob_callback);
Py_XDECREF(g->ob_callback_arg);
g->ob_callback = PyTuple_GetItem(args, 0);
g->ob_callback = a;
Py_INCREF(g->ob_callback);
g->ob_callback_arg = PyTuple_GetItem(args, 1);
g->ob_callback_arg = b;
Py_INCREF(g->ob_callback_arg);
}
Py_INCREF(Py_None);
......@@ -250,7 +249,7 @@ generic_set_object_shortcut(genericobject *g, PyObject *args)
}
static PyMethodDef generic_methods[] = {
{"set_call_back", (PyCFunction)generic_set_call_back, METH_OLDARGS},
{"set_call_back", (PyCFunction)generic_set_call_back, METH_VARARGS},
{"delete_object", (PyCFunction)generic_delete_object, METH_NOARGS},
{"show_object", (PyCFunction)generic_show_object, METH_NOARGS},
{"hide_object", (PyCFunction)generic_hide_object, METH_NOARGS},
......@@ -261,7 +260,7 @@ static PyMethodDef generic_methods[] = {
#endif
{"activate_object", (PyCFunction)generic_activate_object, METH_NOARGS},
{"deactivate_object", (PyCFunction)generic_deactivate_object, METH_NOARGS},
{"set_object_shortcut", (PyCFunction)generic_set_object_shortcut, METH_OLDARGS},
{"set_object_shortcut", (PyCFunction)generic_set_object_shortcut, METH_VARARGS},
{NULL, NULL} /* sentinel */
};
......
......@@ -277,12 +277,8 @@ PyDoc_STRVAR(math_log_doc,
If the base not specified, returns the natural logarithm (base e) of x.");
static PyObject *
math_log10(PyObject *self, PyObject *args)
math_log10(PyObject *self, PyObject *arg)
{
PyObject *arg;
if (!PyArg_UnpackTuple(args, "log10", 1, 1, &arg))
return NULL;
return loghelper(args, log10, "d:log10", arg);
}
......@@ -332,7 +328,7 @@ static PyMethodDef math_methods[] = {
{"hypot", math_hypot, METH_VARARGS, math_hypot_doc},
{"ldexp", math_ldexp, METH_VARARGS, math_ldexp_doc},
{"log", math_log, METH_VARARGS, math_log_doc},
{"log10", math_log10, METH_VARARGS, math_log10_doc},
{"log10", math_log10, METH_O, math_log10_doc},
{"modf", math_modf, METH_VARARGS, math_modf_doc},
{"pow", math_pow, METH_VARARGS, math_pow_doc},
{"radians", math_radians, METH_VARARGS, math_radians_doc},
......
......@@ -108,8 +108,8 @@ sp_handle_dealloc(sp_handle_object* self)
}
static PyMethodDef sp_handle_methods[] = {
{"Detach", (PyCFunction) sp_handle_detach, 1},
{"Close", (PyCFunction) sp_handle_close, 1},
{"Detach", (PyCFunction) sp_handle_detach, METH_VARARGS},
{"Close", (PyCFunction) sp_handle_close, METH_VARARGS},
{NULL, NULL}
};
......
......@@ -9,7 +9,7 @@ ex_foo(PyObject *self, PyObject *args)
}
static PyMethodDef example_methods[] = {
{"foo", ex_foo, 1, "foo() doc string"},
{"foo", ex_foo, METH_VARARGS, "foo() doc string"},
{NULL, NULL}
};
......
......@@ -1073,12 +1073,10 @@ marshal_dump(PyObject *self, PyObject *args)
}
static PyObject *
marshal_load(PyObject *self, PyObject *args)
marshal_load(PyObject *self, PyObject *f)
{
RFILE rf;
PyObject *f, *result;
if (!PyArg_ParseTuple(args, "O:load", &f))
return NULL;
PyObject *result;
if (!PyFile_Check(f)) {
PyErr_SetString(PyExc_TypeError,
"marshal.load() arg must be file");
......@@ -1121,7 +1119,7 @@ marshal_loads(PyObject *self, PyObject *args)
static PyMethodDef marshal_methods[] = {
{"dump", marshal_dump, METH_VARARGS},
{"load", marshal_load, METH_VARARGS},
{"load", marshal_load, METH_O},
{"dumps", marshal_dumps, METH_VARARGS},
{"loads", marshal_loads, METH_VARARGS},
{NULL, NULL} /* sentinel */
......
......@@ -31,39 +31,50 @@ static PyObject *riscos_oserror(void)
/* RISCOS file commands */
static PyObject *riscos_remove(PyObject *self,PyObject *args)
{ char *path1;
if (!PyArg_Parse(args, "s", &path1)) return NULL;
static PyObject *
riscos_remove(PyObject *self, PyObject *args)
{
char *path1;
if (!PyArg_ParseTuple(args, "s:remove", &path1)) return NULL;
if (remove(path1)) return PyErr_SetFromErrno(PyExc_OSError);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *riscos_rename(PyObject *self,PyObject *args)
{ char *path1, *path2;
if (!PyArg_Parse(args, "(ss)", &path1, &path2)) return NULL;
static PyObject *
riscos_rename(PyObject *self, PyObject *args)
{
char *path1, *path2;
if (!PyArg_ParseTuple(args, "ss:rename", &path1, &path2))
return NULL;
if (rename(path1,path2)) return PyErr_SetFromErrno(PyExc_OSError);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *riscos_system(PyObject *self,PyObject *args)
{ char *command;
if (!PyArg_Parse(args, "s", &command)) return NULL;
static PyObject *
riscos_system(PyObject *self, PyObject *args)
{
char *command;
if (!PyArg_ParseTuple(args, "s:system", &command)) return NULL;
return PyInt_FromLong(system(command));
}
static PyObject *riscos_chdir(PyObject *self,PyObject *args)
{ char *path;
if (!PyArg_Parse(args, "s", &path)) return NULL;
static PyObject *
riscos_chdir(PyObject *self, PyObject *args)
{
char *path;
if (!PyArg_ParseTuple(args, "s:chdir", &path)) return NULL;
e=xosfscontrol_dir(path);
if(e) return riscos_oserror();
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *canon(char *path)
{ int len;
static PyObject *
canon(char *path)
{
int len;
PyObject *obj;
char *buf;
e=xosfscontrol_canonicalise_path(path,0,0,0,0,&len);
......@@ -78,32 +89,39 @@ static PyObject *canon(char *path)
return riscos_oserror();
}
static PyObject *riscos_getcwd(PyObject *self,PyObject *args)
{ if(!PyArg_NoArgs(args)) return NULL;
return canon("@");
static PyObject *
riscos_getcwd(PyObject *self, PyObject *unused)
{
return canon("@");
}
static PyObject *riscos_expand(PyObject *self,PyObject *args)
{ char *path;
if (!PyArg_Parse(args, "s", &path)) return NULL;
static PyObject *
riscos_expand(PyObject *self, PyObject *args)
{
char *path;
if (!PyArg_ParseTuple(args, "s:expand", &path)) return NULL;
return canon(path);
}
static PyObject *riscos_mkdir(PyObject *self,PyObject *args)
{ char *path;
int mode;
if (!PyArg_ParseTuple(args, "s|i", &path, &mode)) return NULL;
e=xosfile_create_dir(path,0);
if(e) return riscos_oserror();
static PyObject *
riscos_mkdir(PyObject *self, PyObject *args)
{
char *path;
int mode;
if (!PyArg_ParseTuple(args, "s|i:mkdir", &path, &mode)) return NULL;
e=xosfile_create_dir(path,0);
if(e) return riscos_oserror();
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *riscos_listdir(PyObject *self,PyObject *args)
{ char *path,buf[256];
PyObject *d, *v;
int c=0,count;
if (!PyArg_Parse(args, "s", &path)) return NULL;
static PyObject *
riscos_listdir(PyObject *self, PyObject *args)
{
char *path,buf[256];
PyObject *d, *v;
int c=0,count;
if (!PyArg_ParseTuple(args, "s:listdir", &path)) return NULL;
d=PyList_New(0);
if(!d) return NULL;
for(;;)
......@@ -158,14 +176,15 @@ static PyStructSequence_Desc stat_result_desc = {
static PyTypeObject StatResultType;
static PyObject *riscos_stat(PyObject *self,PyObject *args)
static PyObject *
riscos_stat(PyObject *self, PyObject *args)
{
PyObject *v;
char *path;
int ob,len;
bits t=0;
bits ld,ex,at,ft,mode;
if (!PyArg_Parse(args, "s", &path)) return NULL;
if (!PyArg_ParseTuple(args, "s:stat", &path)) return NULL;
e=xosfile_read_stamped_no_path(path,&ob,&ld,&ex,&len,&at,&ft);
if(e) return riscos_oserror();
switch (ob)
......@@ -207,13 +226,15 @@ static PyObject *riscos_stat(PyObject *self,PyObject *args)
return v;
}
static PyObject *riscos_chmod(PyObject *self,PyObject *args)
{ char *path;
bits mode;
bits attr;
attr=(mode&0x700)>>8;
attr|=(mode&7)<<4;
if (!PyArg_Parse(args, "(si)", &path,(int*)&mode)) return NULL;
static PyObject *
riscos_chmod(PyObject *self,PyObject *args)
{
char *path;
bits mode;
bits attr;
attr=(mode&0x700)>>8;
attr|=(mode&7)<<4;
if (!PyArg_ParseTuple(args, "si:chmod", &path,(int*)&mode)) return NULL;
e=xosfile_write_attr(path,attr);
if(e) return riscos_oserror();
Py_INCREF(Py_None);
......@@ -221,7 +242,8 @@ static PyObject *riscos_chmod(PyObject *self,PyObject *args)
}
static PyObject *riscos_utime(PyObject *self,PyObject *args)
static PyObject *
riscos_utime(PyObject *self, PyObject *args)
{
char *path;
long atime, mtime;
......@@ -274,35 +296,42 @@ static PyObject *riscos_utime(PyObject *self,PyObject *args)
return Py_None;
}
static PyObject *riscos_settype(PyObject *self,PyObject *args)
{ char *path,*name;
int type;
if (!PyArg_Parse(args, "(si)", &path,&type))
{ PyErr_Clear();
if (!PyArg_Parse(args, "(ss)", &path,&name)) return NULL;
static PyObject *
riscos_settype(PyObject *self, PyObject *args)
{
char *path,*name;
int type;
if (!PyArg_ParseTuple(args, "si:settype", &path,&type))
{
PyErr_Clear();
if (!PyArg_ParseTuple(args, "ss:settype", &path,&name)) return NULL;
e=xosfscontrol_file_type_from_string(name,(bits*)&type);
if(e) return riscos_oserror();
}
e=xosfile_set_type(path,type);
if(e) return riscos_oserror();
e=xosfile_set_type(path,type);
if(e) return riscos_oserror();
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *riscos_getenv(PyObject *self,PyObject *args)
{ char *name,*value;
if(!PyArg_Parse(args,"s",&name)) return NULL;
static PyObject *
riscos_getenv(PyObject *self, PyObject *args)
{
char *name,*value;
if(!PyArg_ParseTuple(args,"s:getenv",&name)) return NULL;
value=getenv(name);
if(value) return PyString_FromString(value);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *riscos_putenv(PyObject *self,PyObject *args)
{ char *name,*value;
static PyObject *
riscos_putenv(PyObject *self, PyObject *args)
{
char *name,*value;
int len;
os_var_type type=os_VARTYPE_LITERAL_STRING;
if(!PyArg_ParseTuple(args,"ss|i",&name,&value,&type)) return NULL;
if(!PyArg_ParseTuple(args,"ss|i:putenv",&name,&value,&type)) return NULL;
if(type!=os_VARTYPE_STRING&&type!=os_VARTYPE_MACRO&&type!=os_VARTYPE_EXPANDED
&&type!=os_VARTYPE_LITERAL_STRING)
return riscos_error("Bad putenv type");
......@@ -315,22 +344,26 @@ static PyObject *riscos_putenv(PyObject *self,PyObject *args)
return Py_None;
}
static PyObject *riscos_delenv(PyObject *self,PyObject *args)
{ char *name;
if(!PyArg_Parse(args,"s",&name)) return NULL;
static PyObject *
riscos_delenv(PyObject *self, PyObject *args)
{
char *name;
if(!PyArg_ParseTuple(args,"s:delenv",&name)) return NULL;
e=xos_set_var_val(name,NULL,-1,0,0,0,0);
if(e) return riscos_oserror();
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *riscos_getenvdict(PyObject *self,PyObject *args)
{ PyObject *dict;
static PyObject *
riscos_getenvdict(PyObject *self, PyObject *args)
{
PyObject *dict;
char value[257];
char *which="*";
int size;
char *context=NULL;
if(!PyArg_ParseTuple(args,"|s",&which)) return NULL;
if(!PyArg_ParseTuple(args,"|s:getenvdict",&which)) return NULL;
dict = PyDict_New();
if (!dict) return NULL;
/* XXX This part ignores errors */
......@@ -348,25 +381,25 @@ static PyObject *riscos_getenvdict(PyObject *self,PyObject *args)
static PyMethodDef riscos_methods[] = {
{"unlink", riscos_remove},
{"remove", riscos_remove},
{"rename", riscos_rename},
{"system", riscos_system},
{"rmdir", riscos_remove},
{"chdir", riscos_chdir},
{"getcwd", riscos_getcwd},
{"expand", riscos_expand},
{"mkdir", riscos_mkdir,1},
{"listdir", riscos_listdir},
{"stat", riscos_stat},
{"lstat", riscos_stat},
{"chmod", riscos_chmod},
{"utime", riscos_utime},
{"settype", riscos_settype},
{"getenv", riscos_getenv},
{"putenv", riscos_putenv},
{"delenv", riscos_delenv},
{"getenvdict", riscos_getenvdict,1},
{"unlink", riscos_remove, METH_VARARGS},
{"remove", riscos_remove, METH_VARARGS},
{"rename", riscos_rename, METH_VARARGS},
{"system", riscos_system, METH_VARARGS},
{"rmdir", riscos_remove, METH_VARARGS},
{"chdir", riscos_chdir, METH_VARARGS},
{"getcwd", riscos_getcwd, METH_NOARGS},
{"expand", riscos_expand, METH_VARARGS},
{"mkdir", riscos_mkdir, METH_VARARGS},
{"listdir", riscos_listdir, METH_VARARGS},
{"stat", riscos_stat, METH_VARARGS},
{"lstat", riscos_stat, METH_VARARGS},
{"chmod", riscos_chmod, METH_VARARGS},
{"utime", riscos_utime, METH_VARARGS},
{"settype", riscos_settype, METH_VARARGS},
{"getenv", riscos_getenv, METH_VARARGS},
{"putenv", riscos_putenv, METH_VARARGS},
{"delenv", riscos_delenv, METH_VARARGS},
{"getenvdict", riscos_getenvdict, METH_VARARGS},
{NULL, NULL} /* Sentinel */
};
......
......@@ -552,14 +552,14 @@ Read count bytes from given address.";
static PyMethodDef SwiMethods[]=
{ { "swi", swi_swi,1},
{ "block", PyBlock_New,1},
{ "register", PyRegister,1},
{ "string", swi_string,METH_VARARGS, swi_string__doc__},
{ "integer", swi_integer,METH_VARARGS, swi_integer__doc__},
{ "integers", swi_integers,METH_VARARGS, swi_integers__doc__},
{ "tuples", swi_tuples,METH_VARARGS, swi_tuples__doc__},
{ "tuple", swi_tuple,METH_VARARGS, swi_tuple__doc__},
{ { "swi", swi_swi, METH_VARARGS},
{ "block", PyBlock_New, METH_VARARGS},
{ "register", PyRegister, METH_VARARGS},
{ "string", swi_string, METH_VARARGS, swi_string__doc__},
{ "integer", swi_integer, METH_VARARGS, swi_integer__doc__},
{ "integers", swi_integers, METH_VARARGS, swi_integers__doc__},
{ "tuples", swi_tuples, METH_VARARGS, swi_tuples__doc__},
{ "tuple", swi_tuple, METH_VARARGS, swi_tuple__doc__},
{ NULL,NULL,0,NULL} /* Sentinel */
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment