Mercurial > cpython-lru_cache-weakref
diff Mac/Python/macglue.c @ 8104:93348e5a85a2 legacy-trunk
Added PyMac_{Get,Build}wide. These should support python longints at
some point in the future.
| author | Jack Jansen <jack.jansen@cwi.nl> |
|---|---|
| date | Tue, 21 Apr 1998 15:24:39 +0000 |
| parents | cd11690cb14b |
| children | e2d33c0732bf |
line wrap: on
line diff
--- a/Mac/Python/macglue.c Tue Apr 21 15:23:55 1998 +0000 +++ b/Mac/Python/macglue.c Tue Apr 21 15:24:39 1998 +0000 @@ -1175,3 +1175,26 @@ 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); +}
