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

Skip to content

Commit fa4d5d0

Browse files
committed
Added converters for Fixed
1 parent b7abb18 commit fa4d5d0

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

Mac/Include/macglue.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,6 @@ PyObject *PyMac_BuildPoint(Point); /* Convert Point to PyObject */
8080
int PyMac_GetEventRecord(PyObject *, EventRecord *); /* argument parser for EventRecord */
8181
PyObject *PyMac_BuildEventRecord(EventRecord *); /* Convert EventRecord to PyObject */
8282

83+
int PyMac_GetFixed(PyObject *, Fixed *); /* argument parser for Fixed */
84+
PyObject *PyMac_BuildFixed(Fixed); /* Convert Fixed to PyObject */
8385
void PyMac_InitApplet(void); /* Initialize and run an Applet */

Mac/Python/macglue.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,3 +734,26 @@ PyMac_BuildEventRecord(EventRecord *e)
734734
e->where.v,
735735
e->modifiers);
736736
}
737+
738+
/* Convert Python object to Fixed */
739+
int
740+
PyMac_GetFixed(PyObject *v, Fixed *f)
741+
{
742+
double d;
743+
744+
if( !PyArg_Parse(v, "d", &d))
745+
return 0;
746+
*f = (Fixed)(d * 0x10000);
747+
}
748+
749+
/* Convert a Point to a Python object */
750+
PyObject *
751+
PyMac_BuildFixed(Fixed f)
752+
{
753+
double d;
754+
755+
d = f;
756+
d = d / 0x10000;
757+
return Py_BuildValue("d", d);
758+
}
759+

0 commit comments

Comments
 (0)