Moved get*doublearg() routines here from mathmodule.c

This commit is contained in:
Guido van Rossum 1991-04-03 19:06:26 +00:00
parent 5b7f945bc3
commit 7a904edcbf
1 changed files with 29 additions and 0 deletions

View File

@ -379,3 +379,32 @@ getshortlistarg(args, a, n)
} }
return 1; return 1;
} }
int
getdoublearg(args, px)
register object *args;
double *px;
{
if (args == NULL)
return err_badarg();
if (is_floatobject(args)) {
*px = getfloatvalue(args);
return 1;
}
if (is_intobject(args)) {
*px = getintvalue(args);
return 1;
}
return err_badarg();
}
int
get2doublearg(args, px, py)
register object *args;
double *px, *py;
{
if (args == NULL || !is_tupleobject(args) || gettuplesize(args) != 2)
return err_badarg();
return getdoublearg(gettupleitem(args, 0), px) &&
getdoublearg(gettupleitem(args, 1), py);
}