Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d58cd63

Browse files
committed
Added PyMac_{Get,Build}wide. These should support python longints at
some point in the future.
1 parent 1c4e614 commit d58cd63

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Mac/Python/macglue.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,3 +1175,26 @@ PyMac_BuildFixed(Fixed f)
11751175
return Py_BuildValue("d", d);
11761176
}
11771177

1178+
/* Convert wide to/from Python int or (hi, lo) tuple. XXXX Should use Python longs */
1179+
int
1180+
PyMac_Getwide(PyObject *v, wide *rv)
1181+
{
1182+
if (PyInt_Check(v)) {
1183+
rv->hi = 0;
1184+
rv->lo = PyInt_AsLong(v);
1185+
if( rv->lo & 0x80000000 )
1186+
rv->hi = -1;
1187+
return 1;
1188+
}
1189+
return PyArg_Parse(v, "(ll)", &rv->hi, &rv->lo);
1190+
}
1191+
1192+
1193+
PyObject *
1194+
PyMac_Buildwide(wide w)
1195+
{
1196+
if ( (w.hi == 0 && (w.lo & 0x80000000) == 0) ||
1197+
(w.hi == -1 && (w.lo & 0x80000000) ) )
1198+
return PyInt_FromLong(w.lo);
1199+
return Py_BuildValue("(ll)", w.hi, w.lo);
1200+
}

0 commit comments

Comments
 (0)