diff Python/modsupport.c @ 169:1ed7f6f65983 legacy-trunk

Moved get*doublearg() routines here from mathmodule.c
author Guido van Rossum <guido@python.org>
date Wed, 03 Apr 1991 19:06:26 +0000
parents 853b736a6a9e
children c8a979029df4
line wrap: on
line diff
--- a/Python/modsupport.c	Wed Apr 03 19:06:03 1991 +0000
+++ b/Python/modsupport.c	Wed Apr 03 19:06:26 1991 +0000
@@ -379,3 +379,32 @@
 	}
 	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);
+}