Commit fc58e58c authored by Guido van Rossum's avatar Guido van Rossum

Use getargs() function.

parent 521f81ca
......@@ -22,7 +22,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
/* AL module -- interface to Mark Calows' Auido Library (AL). */
/* AL module -- interface to Mark Callows' Audio Library (AL). */
#include "audio.h"
......@@ -43,6 +43,10 @@ extern typeobject Configtype; /* Forward */
#define is_configobject(v) ((v)->ob_type == &Configtype)
/* Forward */
static int getconfigarg PROTO((object *, ALconfig *));
static int getstrstrconfigarg PROTO((object *, char **, char **, ALconfig *));
static object *
setConfig (self, args, func)
configobject *self;
......@@ -51,7 +55,7 @@ setConfig (self, args, func)
{
long par;
if (!getlongarg(args, &par)) return NULL;
if (!getlongarg (args, &par)) return NULL;
(*func) (self-> ob_config, par);
......@@ -67,7 +71,7 @@ getConfig (self, args, func)
{
long par;
if (!getnoarg(args)) return NULL;
if (!getnoarg (args)) return NULL;
par = (*func) (self-> ob_config);
......@@ -192,7 +196,7 @@ al_closeport (self, args)
portobject *self;
object *args;
{
if (!getnoarg(args)) return NULL;
if (!getnoarg (args)) return NULL;
if (self->ob_port != NULL) {
ALcloseport (self-> ob_port);
......@@ -211,7 +215,7 @@ al_getfd (self, args)
{
int fd;
if (!getnoarg(args)) return NULL;
if (!getnoarg (args)) return NULL;
fd = ALgetfd (self-> ob_port);
......@@ -225,7 +229,7 @@ al_getfilled (self, args)
{
long count;
if (!getnoarg(args)) return NULL;
if (!getnoarg (args)) return NULL;
count = ALgetfilled (self-> ob_port);
......@@ -239,7 +243,7 @@ al_getfillable (self, args)
{
long count;
if (!getnoarg(args)) return NULL;
if (!getnoarg (args)) return NULL;
count = ALgetfillable (self-> ob_port);
......@@ -281,17 +285,16 @@ al_writesamps (self, args)
object *args;
{
long count;
object *v;
char *buf;
int size, width;
ALconfig c;
int width;
if (!getstrarg (args, &v)) return NULL;
if (!getargs (args, "s#", &buf, &size)) return NULL;
c = ALgetconfig(self->ob_port);
width = ALgetwidth(c);
ALfreeconfig(c);
ALwritesamps (self-> ob_port, (void *) getstringvalue(v),
getstringsize(v) / width);
ALwritesamps (self-> ob_port, (void *) buf, (long) size / width);
INCREF (None);
return None;
......@@ -304,7 +307,7 @@ al_getfillpoint (self, args)
{
long count;
if (!getnoarg(args)) return NULL;
if (!getnoarg (args)) return NULL;
count = ALgetfillpoint (self-> ob_port);
......@@ -318,7 +321,7 @@ al_setfillpoint (self, args)
{
long count;
if (!getlongarg(args, &count)) return NULL;
if (!getlongarg (args, &count)) return NULL;
ALsetfillpoint (self-> ob_port, count);
......@@ -333,7 +336,7 @@ al_setconfig (self, args)
{
ALconfig config;
if (!getconfigarg(args, &config)) return NULL;
if (!getconfigarg (args, &config)) return NULL;
ALsetconfig (self-> ob_port, config);
......@@ -348,7 +351,7 @@ al_getconfig (self, args)
{
ALconfig config;
if (!getnoarg(args)) return NULL;
if (!getnoarg (args)) return NULL;
config = ALgetconfig (self-> ob_port);
......@@ -420,13 +423,13 @@ static object *
al_openport (self, args)
object *self, *args;
{
object *name, *dir;
char *name, *dir;
ALport port;
ALconfig config = NULL;
int size;
if (args == NULL || !is_tupleobject(args)) {
err_badarg();
err_badarg ();
return NULL;
}
size = gettuplesize(args);
......@@ -439,11 +442,11 @@ al_openport (self, args)
return NULL;
}
else {
err_badarg();
err_badarg ();
return NULL;
}
port = ALopenport(getstringvalue(name), getstringvalue(dir), config);
port = ALopenport(name, dir, config);
if (port == NULL) {
err_errno(RuntimeError);
......@@ -481,7 +484,7 @@ al_queryparams(self, args)
object *v;
object *w;
if (!getlongarg(args, &device))
if (!getlongarg (args, &device))
return NULL;
length = ALqueryparams(device, PVdummy, 2L);
PVbuffer = NEW(long, length);
......@@ -510,7 +513,7 @@ doParams(args, func, modified)
long length;
int i;
if (!getlongobjectarg(args, &device, &list))
if (!getargs(args, "(lO)", &device, &list))
return NULL;
if (!is_listobject(list)) {
err_badarg();
......@@ -572,31 +575,26 @@ inital()
initmodule("al", al_methods);
}
int
getconfigarg (o, conf)
configobject *o;
static int
getconfigarg(o, conf)
object *o;
ALconfig *conf;
{
if (o == NULL || !is_configobject(o))
return err_badarg ();
*conf = o-> ob_config;
*conf = ((configobject *) o) -> ob_config;
return 1;
}
int
static int
getstrstrconfigarg(v, a, b, c)
object *v;
object **a;
object **b;
char **a;
char **b;
ALconfig *c;
{
if (v == NULL || !is_tupleobject(v) || gettuplesize(v) != 3) {
return err_badarg();
}
return getstrarg(gettupleitem(v, 0), a) &&
getstrarg(gettupleitem(v, 1), b) &&
getconfigarg (gettupleitem (v, 2), c);
object *o;
return getargs(v, "(ssO)", a, b, &o) && getconfigarg(o, c);
}
......@@ -394,7 +394,7 @@ call_forms_INf (func, obj, args)
{
float parameter;
if (!getfloatarg (args, &parameter)) return NULL;
if (!getargs(args, "f", &parameter)) return NULL;
(*func) (obj, parameter);
......@@ -411,7 +411,7 @@ call_forms_INfINf (func, obj, args)
{
float par1, par2;
if (!getfloatfloatarg (args, &par1, &par2)) return NULL;
if (!getargs(args, "(ff)", &par1, &par2)) return NULL;
(*func) (obj, par1, par2);
......@@ -428,7 +428,7 @@ call_forms_INi (func, obj, args)
{
int parameter;
if (!getintarg (args, &parameter)) return NULL;
if (!getintarg(args, &parameter)) return NULL;
(*func) (obj, parameter);
......@@ -443,11 +443,11 @@ call_forms_INc (func, obj, args)
FL_OBJECT *obj;
object *args;
{
object *a;
char *a;
if (!getstrarg (args, &a)) return NULL;
if (!getstrarg(args, &a)) return NULL;
(*func) (obj, getstringvalue(a)[0]);
(*func) (obj, a[0]);
INCREF(None);
return None;
......@@ -460,11 +460,11 @@ call_forms_INstr (func, obj, args)
FL_OBJECT *obj;
object *args;
{
object *a;
char *a;
if (!getstrarg (args, &a)) return NULL;
if (!getstrarg(args, &a)) return NULL;
(*func) (obj, getstringvalue (a));
(*func) (obj, a);
INCREF(None);
return None;
......@@ -478,12 +478,12 @@ call_forms_INiINstr (func, obj, args)
FL_OBJECT *obj;
object *args;
{
object *a;
int b;
char *b;
int a;
if (!getintstrarg (args, &b, &a)) return NULL;
if (!getintstrarg(args, &a, &b)) return NULL;
(*func) (obj, b, getstringvalue (a));
(*func) (obj, a, b);
INCREF(None);
return None;
......@@ -499,7 +499,7 @@ call_forms_INiINi (func, obj, args)
{
int par1, par2;
if (!getintintarg (args, &par1, &par2)) return NULL;
if (!getintintarg(args, &par1, &par2)) return NULL;
(*func) (obj, par1, par2);
......@@ -533,7 +533,7 @@ call_forms_Rstr (func, obj, args)
{
char *str;
if (!getnoarg (args)) return NULL;
if (!getnoarg(args)) return NULL;
str = (*func) (obj);
......@@ -1034,7 +1034,7 @@ set_dial (g, args)
{
float f1, f2, f3;
if (!getfloatfloatfloatarg(args, &f1, &f2, &f3))
if (!getargs(args, "(fff)", &f1, &f2, &f3))
return NULL;
fl_set_dial (g->ob_generic, f1, f2, f3);
INCREF(None);
......@@ -1192,7 +1192,7 @@ set_slider (g, args)
{
float f1, f2, f3;
if (!getfloatfloatfloatarg(args, &f1, &f2, &f3))
if (!args(args, "(fff)", &f1, &f2, &f3))
return NULL;
fl_set_slider (g->ob_generic, f1, f2, f3);
INCREF(None);
......@@ -1402,10 +1402,10 @@ form_show_form(f, args)
object *args;
{
int place, border;
object *name;
if (!getintintstrarg(args, &place, &border, &name))
char *name;
if (!getargs(args, "(iis)", &place, &border, &name))
return NULL;
fl_show_form(f->ob_form, place, border, getstringvalue(name));
fl_show_form(f->ob_form, place, border, name);
INCREF(None);
return None;
}
......@@ -1489,15 +1489,15 @@ generic_add_object(f, args, func, internal_methods)
{
int type;
float x, y, w, h;
object *name;
char *name;
FL_OBJECT *obj;
if (!getintfloatfloatfloatfloatstrarg(args,&type,&x,&y,&w,&h,&name))
if (!getargs(args,"(iffffs)", &type,&x,&y,&w,&h,&name))
return NULL;
fl_addto_form (f-> ob_form);
obj = (*func) (type, x, y, w, h, getstringvalue(name));
obj = (*func) (type, x, y, w, h, name);
fl_end_form();
......@@ -1671,10 +1671,10 @@ form_display_form(f, args)
object *args;
{
int place, border;
object *name;
if (!getintintstrarg(args, &place, &border, &name))
char *name;
if (!getargs(args, "(iis)", &place, &border, &name))
return NULL;
fl_show_form(f->ob_form, place, border, getstringvalue(name));
fl_show_form(f->ob_form, place, border, name);
INCREF(None);
return None;
}
......@@ -1747,7 +1747,7 @@ forms_find_first_or_last(func, f, args)
FL_OBJECT *generic;
genericobject *g;
if (!getintfloatfloatarg(args, &type, &mx, &my)) return NULL;
if (!getargs(args, "(iff)", &type, &mx, &my)) return NULL;
generic = (*func) (f-> ob_form, type, mx, my);
......@@ -1921,7 +1921,7 @@ forms_make_form(dummy, args)
int type;
float w, h;
FL_FORM *form;
if (!getintfloatfloatarg(args, &type, &w, &h))
if (!getargs(args, "(iff)", &type, &w, &h))
return NULL;
form = fl_bgn_form(type, w, h);
if (form == NULL) {
......@@ -2184,7 +2184,7 @@ forms_mapcolor(self, args)
{
int arg0, arg1, arg2, arg3;
if (!getintintintintarg(args, &arg0, &arg1, &arg2, &arg3))
if (!getargs(args, "(iiii)", &arg0, &arg1, &arg2, &arg3))
return NULL;
fl_mapcolor(arg0, (short) arg1, (short) arg2, (short) arg3);
......@@ -2263,12 +2263,11 @@ forms_show_message(f, args)
object *f;
object *args;
{
object *a, *b, *c;
char *a, *b, *c;
if (!getstrstrstrarg(args, &a, &b, &c)) return NULL;
if (!getargs(args, "(sss)", &a, &b, &c)) return NULL;
fl_show_message(
getstringvalue(a), getstringvalue(b), getstringvalue(c));
fl_show_message(a, b, c);
INCREF(None);
return None;
......@@ -2279,13 +2278,12 @@ forms_show_question(f, args)
object *f;
object *args;
{
int ret;
object *a, *b, *c;
int ret;
char *a, *b, *c;
if (!getstrstrstrarg(args, &a, &b, &c)) return NULL;
if (!getargs(args, "(sss)", &a, &b, &c)) return NULL;
ret = fl_show_question(
getstringvalue(a), getstringvalue(b), getstringvalue(c));
ret = fl_show_question(a, b, c);
return newintobject((long) ret);
}
......@@ -2296,11 +2294,11 @@ forms_show_input(f, args)
object *args;
{
char *str;
object *a, *b;
char *a, *b;
if (!getstrstrarg(args, &a, &b)) return NULL;
str = fl_show_input(getstringvalue(a), getstringvalue(b));
str = fl_show_input(a, b);
if (str == NULL) {
INCREF(None);
......@@ -2315,12 +2313,11 @@ forms_file_selector(f, args)
object *args;
{
char *str;
object *a, *b, *c, *d;
char *a, *b, *c, *d;
if (!getstrstrstrstrarg(args, &a, &b, &c, &d)) return NULL;
if (!getargs(args, "(ssss)", &a, &b, &c, &d)) return NULL;
str = fl_show_file_selector(getstringvalue(a), getstringvalue(b),
getstringvalue(c), getstringvalue(d));
str = fl_show_file_selector(a, b, c, d);
if (str == NULL) {
INCREF(None);
......@@ -2420,143 +2417,3 @@ initfl()
fl_init();
#endif /* !FL_V15 */
}
/* Support routines */
int
getintintstrarg(args, a, b, c)
object *args;
int *a, *b;
object **c;
{
if (args == NULL || !is_tupleobject(args) || gettuplesize(args) != 3) {
err_badarg();
return NULL;
}
return getintarg(gettupleitem(args, 0), a) &&
getintarg(gettupleitem(args, 1), b) &&
getstrarg(gettupleitem(args, 2), c);
}
int
getintfloatfloatarg(args, a, b, c)
object *args;
int *a;
float *b, *c;
{
if (args == NULL || !is_tupleobject(args) || gettuplesize(args) != 3) {
err_badarg();
return NULL;
}
return getintarg(gettupleitem(args, 0), a) &&
getfloatarg(gettupleitem(args, 1), b) &&
getfloatarg(gettupleitem(args, 2), c);
}
int
getintintintintarg(args, a, b, c, d)
object *args;
int *a, *b, *c, *d;
{
if (args == NULL || !is_tupleobject(args) || gettuplesize(args) != 4) {
err_badarg();
return NULL;
}
return getintarg(gettupleitem(args, 0), a) &&
getintarg(gettupleitem(args, 1), b) &&
getintarg(gettupleitem(args, 2), c) &&
getintarg(gettupleitem(args, 3), d);
}
int
getfloatarg(args, a)
object *args;
float *a;
{
double x;
if (!getdoublearg(args, &x))
return 0;
*a = x;
return 1;
}
int
getintfloatfloatfloatfloatstrarg(args, type, x, y, w, h, name)
object *args;
int *type;
float *x, *y, *w, *h;
object **name;
{
if (args == NULL || !is_tupleobject(args) || gettuplesize(args) != 6) {
err_badarg();
return NULL;
}
return getintarg(gettupleitem(args, 0), type) &&
getfloatarg(gettupleitem(args, 1), x) &&
getfloatarg(gettupleitem(args, 2), y) &&
getfloatarg(gettupleitem(args, 3), w) &&
getfloatarg(gettupleitem(args, 4), h) &&
getstrarg(gettupleitem(args, 5), name);
}
int
getfloatfloatfloatarg(args, f1, f2, f3)
object *args;
float *f1, *f2, *f3;
{
if (args == NULL || !is_tupleobject(args) || gettuplesize(args) != 3) {
err_badarg();
return NULL;
}
return getfloatarg(gettupleitem(args, 0), f1) &&
getfloatarg(gettupleitem(args, 1), f2) &&
getfloatarg(gettupleitem(args, 2), f3);
}
int
getfloatfloatarg(args, f1, f2)
object *args;
float *f1, *f2;
{
if (args == NULL || !is_tupleobject(args) || gettuplesize(args) != 2) {
err_badarg();
return NULL;
}
return getfloatarg(gettupleitem(args, 0), f1) &&
getfloatarg(gettupleitem(args, 1), f2);
}
int
getstrstrstrarg(v, a, b, c)
object *v;
object **a;
object **b;
object **c;
{
if (v == NULL || !is_tupleobject(v) || gettuplesize(v) != 3) {
return err_badarg();
}
return getstrarg(gettupleitem(v, 0), a) &&
getstrarg(gettupleitem(v, 1), b)&&
getstrarg(gettupleitem(v, 2), c);
}
int
getstrstrstrstrarg(v, a, b, c, d)
object *v;
object **a;
object **b;
object **c;
object **d;
{
if (v == NULL || !is_tupleobject(v) || gettuplesize(v) != 4) {
return err_badarg();
}
return getstrarg(gettupleitem(v, 0), a) &&
getstrarg(gettupleitem(v, 1), b)&&
getstrarg(gettupleitem(v, 2), c) &&
getstrarg(gettupleitem(v, 3),d);
}
This diff is collapsed.
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