diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2001-05-17 21:58:34 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2001-05-17 21:58:34 (GMT) |
commit | 0e04eecdbf8467cf3fe055e41e96fa48507b998c (patch) | |
tree | 0c3373b79a29ab55b8c542fd06ddbc9d78dd9d39 /Mac/Modules/qd/Qdmodule.c | |
parent | 99f9baa33190482784900970fd3e1c76e7cb48d6 (diff) | |
download | cpython-0e04eecdbf8467cf3fe055e41e96fa48507b998c.zip cpython-0e04eecdbf8467cf3fe055e41e96fa48507b998c.tar.gz cpython-0e04eecdbf8467cf3fe055e41e96fa48507b998c.tar.bz2 |
First step in porting MacPython modules to OSX/unix: break all references between modules except for the obj_New() and obj_Convert() routines, the PyArg_Parse and Py_BuildValue helpers.
And these can now be vectored through glue routines (by defining USE_TOOLBOX_OBJECT_GLUE) which will do the necessary imports, whereupon the module's init routine will tell the glue routine about the real conversion routine address and everything is fine again.
Diffstat (limited to 'Mac/Modules/qd/Qdmodule.c')
-rw-r--r-- | Mac/Modules/qd/Qdmodule.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Mac/Modules/qd/Qdmodule.c b/Mac/Modules/qd/Qdmodule.c index 12f44f4..9c3280e 100644 --- a/Mac/Modules/qd/Qdmodule.c +++ b/Mac/Modules/qd/Qdmodule.c @@ -10,6 +10,22 @@ #include <QuickDraw.h> +#ifdef USE_TOOLBOX_OBJECT_GLUE +extern PyObject *_GrafObj_New(GrafPtr); +extern int _GrafObj_Convert(PyObject *, GrafPtr *); +extern PyObject *_BMObj_New(BitMapPtr); +extern int _BMObj_Convert(PyObject *, BitMapPtr *); +extern PyObject *_QdRGB_New(RGBColorPtr); +extern int _QdRGB_Convert(PyObject *, RGBColorPtr *); + +#define GrafObj_New _GrafObj_New +#define GrafObj_Convert _GrafObj_Convert +#define BMObj_New _BMObj_New +#define BMObj_Convert _BMObj_Convert +#define QdRGB_New _QdRGB_New +#define QdRGB_Convert _QdRGB_Convert +#endif + #if !ACCESSOR_CALLS_ARE_FUNCTIONS #define GetPortBitMapForCopyBits(port) ((const struct BitMap *)&((GrafPort *)(port))->portBits) #define GetPortPixMap(port) (((CGrafPtr)(port))->portPixMap) @@ -144,6 +160,16 @@ GrafObj_Convert(v, p_itself) PyObject *v; GrafPtr *p_itself; { +#if 1 + { + WindowRef win; + if (WinObj_Convert(v, &win) && v) { + *p_itself = (GrafPtr)GetWindowPort(win); + return 1; + } + PyErr_Clear(); + } +#else if (DlgObj_Check(v)) { DialogRef dlg = (DialogRef)((GrafPortObject *)v)->ob_itself; *p_itself = (GrafPtr)GetWindowPort(GetDialogWindow(dlg)); @@ -154,6 +180,7 @@ GrafObj_Convert(v, p_itself) *p_itself = (GrafPtr)GetWindowPort(win); return 1; } +#endif if (!GrafObj_Check(v)) { PyErr_SetString(PyExc_TypeError, "GrafPort required"); @@ -6194,6 +6221,13 @@ void initQd() + PyMac_INIT_TOOLBOX_OBJECT_NEW(BMObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(BMObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(GrafObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GrafObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(QdRGB_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(QdRGB_Convert); + m = Py_InitModule("Qd", Qd_methods); d = PyModule_GetDict(m); |