summaryrefslogtreecommitdiffstats
path: root/Mac/Python
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1998-04-21 15:24:39 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1998-04-21 15:24:39 (GMT)
commitd58cd630eb79bdd13f5ac00d7044e0273d2dbd61 (patch)
tree9062445dd75077f3d7caa887eeed9cd807fdc8c5 /Mac/Python
parent1c4e61462720b441467ab41c62d0c37143af45e7 (diff)
downloadcpython-d58cd630eb79bdd13f5ac00d7044e0273d2dbd61.zip
cpython-d58cd630eb79bdd13f5ac00d7044e0273d2dbd61.tar.gz
cpython-d58cd630eb79bdd13f5ac00d7044e0273d2dbd61.tar.bz2
Added PyMac_{Get,Build}wide. These should support python longints at
some point in the future.
Diffstat (limited to 'Mac/Python')
-rw-r--r--Mac/Python/macglue.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/Mac/Python/macglue.c b/Mac/Python/macglue.c
index 838e27e..ac1bbbf 100644
--- a/Mac/Python/macglue.c
+++ b/Mac/Python/macglue.c
@@ -1175,3 +1175,26 @@ PyMac_BuildFixed(Fixed f)
return Py_BuildValue("d", d);
}
+/* Convert wide to/from Python int or (hi, lo) tuple. XXXX Should use Python longs */
+int
+PyMac_Getwide(PyObject *v, wide *rv)
+{
+ if (PyInt_Check(v)) {
+ rv->hi = 0;
+ rv->lo = PyInt_AsLong(v);
+ if( rv->lo & 0x80000000 )
+ rv->hi = -1;
+ return 1;
+ }
+ return PyArg_Parse(v, "(ll)", &rv->hi, &rv->lo);
+}
+
+
+PyObject *
+PyMac_Buildwide(wide w)
+{
+ if ( (w.hi == 0 && (w.lo & 0x80000000) == 0) ||
+ (w.hi == -1 && (w.lo & 0x80000000) ) )
+ return PyInt_FromLong(w.lo);
+ return Py_BuildValue("(ll)", w.hi, w.lo);
+}