summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-01-27 16:45:55 (GMT)
committerGuido van Rossum <guido@python.org>1992-01-27 16:45:55 (GMT)
commitfc58e58cb784fcc002fd233a8799f4b804457637 (patch)
tree4f0ffc3e3bb59cf0c544cc415ed372101f69e573
parent521f81ca26ee5b00d8cc6bda920a8bf3248a2bdd (diff)
downloadcpython-fc58e58cb784fcc002fd233a8799f4b804457637.zip
cpython-fc58e58cb784fcc002fd233a8799f4b804457637.tar.gz
cpython-fc58e58cb784fcc002fd233a8799f4b804457637.tar.bz2
Use getargs() function.
-rw-r--r--Modules/almodule.c70
-rw-r--r--Modules/flmodule.c225
-rw-r--r--Modules/stdwinmodule.c276
3 files changed, 198 insertions, 373 deletions
diff --git a/Modules/almodule.c b/Modules/almodule.c
index 806ad75..e6ba1b0 100644
--- a/Modules/almodule.c
+++ b/Modules/almodule.c
@@ -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);
}
diff --git a/Modules/flmodule.c b/Modules/flmodule.c
index 9237371..1fd9a2c 100644
--- a/Modules/flmodule.c
+++ b/Modules/flmodule.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);
-
-}
diff --git a/Modules/stdwinmodule.c b/Modules/stdwinmodule.c
index 179cfe8..5556f03 100644
--- a/Modules/stdwinmodule.c
+++ b/Modules/stdwinmodule.c
@@ -98,32 +98,17 @@ extern typeobject Menutype; /* Really static, forward */
/* Strongly stdwin-specific argument handlers */
static int
-getmousedetail(v, ep)
- object *v;
- EVENT *ep;
-{
- if (v == NULL || !is_tupleobject(v) || gettuplesize(v) != 4)
- return err_badarg();
- return getintintarg(gettupleitem(v, 0),
- &ep->u.where.h, &ep->u.where.v) &&
- getintarg(gettupleitem(v, 1), &ep->u.where.clicks) &&
- getintarg(gettupleitem(v, 2), &ep->u.where.button) &&
- getintarg(gettupleitem(v, 3), &ep->u.where.mask);
-}
-
-static int
getmenudetail(v, ep)
object *v;
EVENT *ep;
{
- object *mp;
- if (v == NULL || !is_tupleobject(v) || gettuplesize(v) != 2)
- return err_badarg();
- mp = gettupleitem(v, 0);
- if (mp == NULL || !is_menuobject(mp))
+ menuobject *mp;
+ if (!getargs(v, "(Oi)", &mp, &ep->u.m.item))
+ return 0;
+ if (!is_menuobject(mp))
return err_badarg();
- ep->u.m.id = ((menuobject *)mp) -> m_id;
- return getintarg(gettupleitem(v, 1), &ep->u.m.item);
+ ep->u.m.id = mp->m_id;
+ return 1;
}
static int
@@ -133,24 +118,22 @@ geteventarg(v, ep)
{
object *wp, *detail;
int a[4];
- if (v == NULL || !is_tupleobject(v) || gettuplesize(v) != 3)
- return err_badarg();
- if (!getintarg(gettupleitem(v, 0), &ep->type))
+ if (!getargs(v, "(iOO)", &ep->type, &wp, &detail))
return 0;
- wp = gettupleitem(v, 1);
- if (wp == None)
+ if (is_windowobject(wp))
+ ep->window = ((windowobject *)wp) -> w_win;
+ else if (wp == None)
ep->window = NULL;
- else if (wp == NULL || !is_windowobject(wp))
- return err_badarg();
else
- ep->window = ((windowobject *)wp) -> w_win;
- detail = gettupleitem(v, 2);
- switch (ep->type) {
- case WE_CHAR:
- if (!is_stringobject(detail) || getstringsize(detail) != 1)
return err_badarg();
- ep->u.character = getstringvalue(detail)[0];
- return 1;
+ switch (ep->type) {
+ case WE_CHAR: {
+ char c;
+ if (!getargs(detail, "c", &c))
+ return 0;
+ ep->u.character = c;
+ return 1;
+ }
case WE_COMMAND:
return getintarg(detail, &ep->u.command);
case WE_DRAW:
@@ -164,7 +147,11 @@ geteventarg(v, ep)
case WE_MOUSE_DOWN:
case WE_MOUSE_UP:
case WE_MOUSE_MOVE:
- return getmousedetail(detail, ep);
+ return getargs(detail, "((ii)iii)",
+ &ep->u.where.h, &ep->u.where.v,
+ &ep->u.where.clicks,
+ &ep->u.where.button,
+ &ep->u.where.mask);
case WE_MENU:
return getmenudetail(detail, ep);
default:
@@ -561,11 +548,11 @@ drawing_text(dp, args)
drawingobject *dp;
object *args;
{
- int a[2];
- object *s;
- if (!getpointstrarg(args, a, &s))
+ int h, v, size;
+ char *text;
+ if (!getargs(args, "((ii)s#)", &h, &v, &text, &size))
return NULL;
- wdrawtext(a[0], a[1], getstringvalue(s), (int)getstringsize(s));
+ wdrawtext(h, v, text, size);
INCREF(None);
return None;
}
@@ -597,11 +584,11 @@ drawing_textwidth(dp, args)
drawingobject *dp;
object *args;
{
- object *s;
- if (!getstrarg(args, &s))
+ char *text;
+ int size;
+ if (!getargs(args, "s#", &text, &size))
return NULL;
- return newintobject(
- (long)wtextwidth(getstringvalue(s), (int)getstringsize(s)));
+ return newintobject((long)wtextwidth(text, size));
}
static object *
@@ -609,12 +596,11 @@ drawing_textbreak(dp, args)
drawingobject *dp;
object *args;
{
- object *s;
- int a;
- if (!getstrintarg(args, &s, &a))
+ char *text;
+ int size, width;
+ if (!getargs(args, "(s#i)", &text, &size, &width))
return NULL;
- return newintobject(
- (long)wtextbreak(getstringvalue(s), (int)getstringsize(s), a));
+ return newintobject((long)wtextbreak(text, size, width));
}
static object *
@@ -622,53 +608,46 @@ drawing_setfont(self, args)
drawingobject *self;
object *args;
{
- object *font, *style;
- int size;
- if (args == NULL) {
- err_badarg();
- return NULL;
- }
- if (is_stringobject(args)) {
- font = args;
- style = NULL;
- size = 0;
+ char *font;
+ char style = '\0';
+ int size = 0;
+ if (args == NULL || !is_tupleobject(args)) {
+ if (!getargs(args, "z", font))
+ return NULL;
}
- else if (is_tupleobject(args)) {
+ else {
int n = gettuplesize(args);
if (n == 2) {
- if (!getstrintarg(args, &font, &size))
+ if (!getargs(args, "(zi)", &font, &size))
return NULL;
- style = NULL;
}
- else if (!getstrstrintarg(args, &font, &style, &size))
- return NULL;
- }
- else {
- err_badarg();
- return NULL;
- }
- wsetfont(getstringvalue(font));
- if (style != NULL) {
- switch (*getstringvalue(style)) {
- case 'b':
- wsetbold();
- break;
- case 'i':
- wsetitalic();
- break;
- case 'o':
- wsetbolditalic();
- break;
- case 'u':
- wsetunderline();
- break;
- default:
- wsetplain();
- break;
+ else if (!getargs(args, "(zic)", &font, &size, &style)) {
+ err_clear();
+ if (!getargs(args, "(zci)", &font, &style, &size))
+ return NULL;
}
}
+ if (font != NULL)
+ wsetfont(font);
if (size != 0)
wsetsize(size);
+ switch (style) {
+ case 'b':
+ wsetbold();
+ break;
+ case 'i':
+ wsetitalic();
+ break;
+ case 'o':
+ wsetbolditalic();
+ break;
+ case 'u':
+ wsetunderline();
+ break;
+ case 'p':
+ wsetplain();
+ break;
+ }
INCREF(None);
return None;
}
@@ -990,10 +969,10 @@ text_replace(self, args)
textobject *self;
object *args;
{
- object *text;
+ char *text;
if (!getstrarg(args, &text))
return NULL;
- tereplace(self->t_text, getstringvalue(text));
+ tereplace(self->t_text, text);
INCREF(None);
return None;
}
@@ -1029,16 +1008,15 @@ text_settext(self, args)
textobject *self;
object *args;
{
- object *text;
+ char *text;
char *buf;
int size;
- if (!getstrarg(args, &text))
+ if (!getargs(args, "s#", &text, &size))
return NULL;
- size = getstringsize(text);
if ((buf = NEW(char, size)) == NULL) {
return err_nomem();
}
- memcpy(buf, getstringvalue(text), size);
+ memcpy(buf, text, size);
tesetbuf(self->t_text, buf, size); /* Becomes owner of buffer */
INCREF(None);
return None;
@@ -1143,9 +1121,10 @@ typeobject Texttype = {
#define MAXNMENU 200 /* Max #menus we allow */
static menuobject *menulist[MAXNMENU];
+static menuobject *newmenuobject PROTO((char *));
static menuobject *
newmenuobject(title)
- object *title;
+ char *title;
{
int id;
MENU *menu;
@@ -1158,7 +1137,7 @@ newmenuobject(title)
err_setstr(StdwinError, "creating too many menus");
return NULL;
}
- menu = wmenucreate(id + IDOFFSET, getstringvalue(title));
+ menu = wmenucreate(id + IDOFFSET, title);
if (menu == NULL)
return (menuobject *) err_nomem();
mp = NEWOBJ(menuobject, &Menutype);
@@ -1214,24 +1193,17 @@ menu_additem(self, args)
menuobject *self;
object *args;
{
- object *text;
- int shortcut;
+ char *text;
+ int shortcut = -1;
if (is_tupleobject(args)) {
- object *v;
- if (!getstrstrarg(args, &text, &v))
- return NULL;
- if (getstringsize(v) != 1) {
- err_badarg();
- return NULL;
- }
- shortcut = *getstringvalue(v) & 0xff;
- }
- else {
- if (!getstrarg(args, &text))
+ char c;
+ if (!getargs(args, "(sc)", &text, &c))
return NULL;
- shortcut = -1;
+ shortcut = c;
}
- wmenuadditem(self->m_menu, getstringvalue(text), shortcut);
+ else if (!getstrarg(args, &text))
+ return NULL;
+ wmenuadditem(self->m_menu, text, shortcut);
INCREF(None);
return None;
}
@@ -1242,10 +1214,10 @@ menu_setitem(self, args)
object *args;
{
int index;
- object *text;
+ char *text;
if (!getintstrarg(args, &index, &text))
return NULL;
- wmenusetitem(self->m_menu, index, getstringvalue(text));
+ wmenusetitem(self->m_menu, index, text);
INCREF(None);
return None;
}
@@ -1507,18 +1479,6 @@ window_scroll(wp, args)
}
static object *
-window_setactive(wp, args)
- windowobject *wp;
- object *args;
-{
- if (!getnoarg(args))
- return NULL;
- wsetactive(wp->w_win);
- INCREF(None);
- return None;
-}
-
-static object *
window_setdocsize(wp, args)
windowobject *wp;
object *args;
@@ -1550,7 +1510,7 @@ window_settitle(wp, args)
object *args;
{
object *title;
- if (!getstrarg(args, &title))
+ if (!getStrarg(args, &title))
return NULL;
DECREF(wp->w_title);
INCREF(title);
@@ -1592,7 +1552,7 @@ window_menucreate(self, args)
object *args;
{
menuobject *mp;
- object *title;
+ char *title;
if (!getstrarg(args, &title))
return NULL;
wmenusetdeflocal(1);
@@ -1621,13 +1581,11 @@ window_setselection(self, args)
windowobject *self;
object *args;
{
- int sel;
- object *str;
- int ok;
- if (!getintstrarg(args, &sel, &str))
+ int sel, size, ok;
+ char *text;
+ if (!getargs(args, "(is#)", &sel, &text, &size))
return NULL;
- ok = wsetselection(self->w_win, sel,
- getstringvalue(str), (int)getstringsize(str));
+ ok = wsetselection(self->w_win, sel, text, size);
return newintobject(ok);
}
@@ -1636,11 +1594,11 @@ window_setwincursor(self, args)
windowobject *self;
object *args;
{
- object *str;
+ char *name;
CURSOR *c;
- if (!getstrarg(args, &str))
+ if (!getstrarg(args, &name))
return NULL;
- c = wfetchcursor(getstringvalue(str));
+ c = wfetchcursor(name);
if (c == NULL) {
err_setstr(StdwinError, "no such cursor");
return NULL;
@@ -1650,6 +1608,18 @@ window_setwincursor(self, args)
return None;
}
+static object *
+window_setactive(self, args)
+ windowobject *self;
+ object *args;
+{
+ if (!getnoarg(args))
+ return NULL;
+ wsetactive(self->w_win);
+ INCREF(None);
+ return None;
+}
+
#ifdef CWI_HACKS
static object *
window_getxwindowid(self, args)
@@ -1754,7 +1724,7 @@ stdwin_open(sw, args)
int tag;
object *title;
windowobject *wp;
- if (!getstrarg(args, &title))
+ if (!getStrarg(args, &title))
return NULL;
for (tag = 0; tag < MAXNWIN; tag++) {
if (windowlist[tag] == NULL)
@@ -1988,7 +1958,7 @@ stdwin_menucreate(self, args)
object *self;
object *args;
{
- object *title;
+ char *title;
if (!getstrarg(args, &title))
return NULL;
wmenusetdeflocal(0);
@@ -2000,14 +1970,14 @@ stdwin_askfile(self, args)
object *self;
object *args;
{
- object *prompt, *dflt;
+ char *prompt, *dflt;
int new, ret;
char buf[256];
if (!getstrstrintarg(args, &prompt, &dflt, &new))
return NULL;
- strncpy(buf, getstringvalue(dflt), sizeof buf);
+ strncpy(buf, dflt, sizeof buf);
buf[sizeof buf - 1] = '\0';
- ret = waskfile(getstringvalue(prompt), buf, sizeof buf, new);
+ ret = waskfile(prompt, buf, sizeof buf, new);
if (!ret) {
err_set(KeyboardInterrupt);
return NULL;
@@ -2020,11 +1990,11 @@ stdwin_askync(self, args)
object *self;
object *args;
{
- object *prompt;
+ char *prompt;
int new, ret;
if (!getstrintarg(args, &prompt, &new))
return NULL;
- ret = waskync(getstringvalue(prompt), new);
+ ret = waskync(prompt, new);
if (ret < 0) {
err_set(KeyboardInterrupt);
return NULL;
@@ -2037,14 +2007,14 @@ stdwin_askstr(self, args)
object *self;
object *args;
{
- object *prompt, *dflt;
+ char *prompt, *dflt;
int ret;
char buf[256];
if (!getstrstrarg(args, &prompt, &dflt))
return NULL;
- strncpy(buf, getstringvalue(dflt), sizeof buf);
+ strncpy(buf, dflt, sizeof buf);
buf[sizeof buf - 1] = '\0';
- ret = waskstr(getstringvalue(prompt), buf, sizeof buf);
+ ret = waskstr(prompt, buf, sizeof buf);
if (!ret) {
err_set(KeyboardInterrupt);
return NULL;
@@ -2057,10 +2027,10 @@ stdwin_message(self, args)
object *self;
object *args;
{
- object *msg;
+ char *msg;
if (!getstrarg(args, &msg))
return NULL;
- wmessage(getstringvalue(msg));
+ wmessage(msg);
INCREF(None);
return None;
}
@@ -2082,11 +2052,11 @@ stdwin_setcutbuffer(self, args)
object *self;
object *args;
{
- int i;
- object *str;
- if (!getintstrarg(args, &i, &str))
+ int i, size;
+ char *str;
+ if (!getargs(args, "(is#)", &i, &str, &size))
return NULL;
- wsetcutbuffer(i, getstringvalue(str), getstringsize(str));
+ wsetcutbuffer(i, str, size);
INCREF(None);
return None;
}
@@ -2166,10 +2136,10 @@ stdwin_fetchcolor(self, args)
object *self;
object *args;
{
- object *colorname;
+ char *colorname;
if (!getstrarg(args, &colorname))
return NULL;
- return newintobject((long)wfetchcolor(getstringvalue(colorname)));
+ return newintobject((long)wfetchcolor(colorname));
}
static object *