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/win | |
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/win')
-rw-r--r-- | Mac/Modules/win/Winmodule.c | 25 | ||||
-rw-r--r-- | Mac/Modules/win/winsupport.py | 27 |
2 files changed, 52 insertions, 0 deletions
diff --git a/Mac/Modules/win/Winmodule.c b/Mac/Modules/win/Winmodule.c index d267248..6a9ded3 100644 --- a/Mac/Modules/win/Winmodule.c +++ b/Mac/Modules/win/Winmodule.c @@ -10,6 +10,16 @@ #include <Windows.h> +#ifdef USE_TOOLBOX_OBJECT_GLUE +extern PyObject *_WinObj_New(WindowRef); +extern PyObject *_WinObj_WhichWindow(WindowRef); +extern int _WinObj_Convert(PyObject *, WindowRef *); + +#define WinObj_New _WinObj_New +#define WinObj_WhichWindow _WinObj_WhichWindow +#define WinObj_Convert _WinObj_Convert +#endif + #if !ACCESSOR_CALLS_ARE_FUNCTIONS /* Carbon calls that we emulate in classic mode */ #define GetWindowSpareFlag(win) (((CWindowPeek)(win))->spareFlag) @@ -65,10 +75,21 @@ WinObj_Convert(v, p_itself) PyObject *v; WindowPtr *p_itself; { +#if 1 + { + DialogRef dlg; + if (DlgObj_Convert(v, &dlg) && dlg) { + *p_itself = GetDialogWindow(dlg); + return 1; + } + PyErr_Clear(); + } +#else if (DlgObj_Check(v)) { *p_itself = DlgObj_ConvertToWindow(v); return 1; } +#endif if (v == Py_None) { *p_itself = NULL; return 1; } if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; } @@ -3057,6 +3078,10 @@ void initWin() + PyMac_INIT_TOOLBOX_OBJECT_NEW(WinObj_New); + PyMac_INIT_TOOLBOX_OBJECT_NEW(WinObj_WhichWindow); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(WinObj_Convert); + m = Py_InitModule("Win", Win_methods); d = PyModule_GetDict(m); diff --git a/Mac/Modules/win/winsupport.py b/Mac/Modules/win/winsupport.py index 0359a91..e55d273 100644 --- a/Mac/Modules/win/winsupport.py +++ b/Mac/Modules/win/winsupport.py @@ -56,6 +56,16 @@ PropertyTag = OSTypeType("PropertyTag") includestuff = includestuff + """ #include <%s>""" % MACHEADERFILE + """ +#ifdef USE_TOOLBOX_OBJECT_GLUE +extern PyObject *_WinObj_New(WindowRef); +extern PyObject *_WinObj_WhichWindow(WindowRef); +extern int _WinObj_Convert(PyObject *, WindowRef *); + +#define WinObj_New _WinObj_New +#define WinObj_WhichWindow _WinObj_WhichWindow +#define WinObj_Convert _WinObj_Convert +#endif + #if !ACCESSOR_CALLS_ARE_FUNCTIONS /* Carbon calls that we emulate in classic mode */ #define GetWindowSpareFlag(win) (((CWindowPeek)(win))->spareFlag) @@ -103,6 +113,12 @@ WinObj_WhichWindow(w) } """ +initstuff = initstuff + """ + PyMac_INIT_TOOLBOX_OBJECT_NEW(WinObj_New); + PyMac_INIT_TOOLBOX_OBJECT_NEW(WinObj_WhichWindow); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(WinObj_Convert); +""" + class MyObjectDefinition(GlobalObjectDefinition): def outputCheckNewArg(self): Output("if (itself == NULL) return PyMac_Error(resNotFound);") @@ -118,10 +134,21 @@ class MyObjectDefinition(GlobalObjectDefinition): Output("it->ob_freeit = PyMac_AutoDisposeWindow;") OutRbrace() def outputCheckConvertArg(self): + Output("#if 1") + OutLbrace() + Output("DialogRef dlg;") + OutLbrace("if (DlgObj_Convert(v, &dlg) && dlg)") + Output("*p_itself = GetDialogWindow(dlg);") + Output("return 1;") + OutRbrace() + Output("PyErr_Clear();") + OutRbrace() + Output("#else") OutLbrace("if (DlgObj_Check(v))") Output("*p_itself = DlgObj_ConvertToWindow(v);") Output("return 1;") OutRbrace() + Output("#endif") Out(""" if (v == Py_None) { *p_itself = NULL; return 1; } if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; } |