diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2000-06-02 21:35:07 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2000-06-02 21:35:07 (GMT) |
commit | e79dc76f53dfa18fb08c35f71b049259642c0142 (patch) | |
tree | 2d9cc6228cc713336a01d9ff09571eacff3a2ba0 /Mac/Modules/macosmodule.c | |
parent | 33d1ad28cba273b94c70ffc22deb6c53b0c1b068 (diff) | |
download | cpython-e79dc76f53dfa18fb08c35f71b049259642c0142.zip cpython-e79dc76f53dfa18fb08c35f71b049259642c0142.tar.gz cpython-e79dc76f53dfa18fb08c35f71b049259642c0142.tar.bz2 |
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Macmodule and macosmodule have also been carbonified. Some functionality is still missing there.
Diffstat (limited to 'Mac/Modules/macosmodule.c')
-rw-r--r-- | Mac/Modules/macosmodule.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/Mac/Modules/macosmodule.c b/Mac/Modules/macosmodule.c index ece75c9..4c7f2aa 100644 --- a/Mac/Modules/macosmodule.c +++ b/Mac/Modules/macosmodule.c @@ -31,6 +31,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <Files.h> #include <LowMem.h> #include <Sound.h> +#include <Events.h> static PyObject *MacOS_Error; /* Exception MacOS.Error */ @@ -312,14 +313,14 @@ static char getcrtp_doc[] = "Obsolete, use macfs module"; static PyObject * MacOS_GetCreatorAndType(PyObject *self, PyObject *args) { - Str255 name; + FSSpec fss; FInfo info; PyObject *creator, *type, *res; OSErr err; - if (!PyArg_ParseTuple(args, "O&", PyMac_GetStr255, &name)) + if (!PyArg_ParseTuple(args, "O&", PyMac_GetFSSpec, &fss)) return NULL; - if ((err = GetFInfo(name, 0, &info)) != noErr) + if ((err = FSpGetFInfo(&fss, &info)) != noErr) return PyErr_Mac(MacOS_Error, err); creator = PyString_FromStringAndSize((char *)&info.fdCreator, 4); type = PyString_FromStringAndSize((char *)&info.fdType, 4); @@ -334,19 +335,19 @@ static char setcrtp_doc[] = "Obsolete, use macfs module"; static PyObject * MacOS_SetCreatorAndType(PyObject *self, PyObject *args) { - Str255 name; + FSSpec fss; ResType creator, type; FInfo info; OSErr err; if (!PyArg_ParseTuple(args, "O&O&O&", - PyMac_GetStr255, &name, PyMac_GetOSType, &creator, PyMac_GetOSType, &type)) + PyMac_GetFSSpec, &fss, PyMac_GetOSType, &creator, PyMac_GetOSType, &type)) return NULL; - if ((err = GetFInfo(name, 0, &info)) != noErr) + if ((err = FSpGetFInfo(&fss, &info)) != noErr) return PyErr_Mac(MacOS_Error, err); info.fdCreator = creator; info.fdType = type; - if ((err = SetFInfo(name, 0, &info)) != noErr) + if ((err = FSpSetFInfo(&fss, &info)) != noErr) return PyErr_Mac(MacOS_Error, err); Py_INCREF(Py_None); return Py_None; @@ -413,6 +414,7 @@ MacOS_SetHighLevelEventHandler(self, args) #endif /* USE_STDWIN */ +#ifndef TARGET_API_MAC_CARBON static char accepthle_doc[] = "Get arguments of pending high-level event"; static PyObject * @@ -447,7 +449,7 @@ MacOS_AcceptHighLevelEvent(self, args) free(buf); return res; } - +#endif static char schedparams_doc[] = "Set/return mainloop interrupt check flag, etc"; /* @@ -559,7 +561,9 @@ MacOS_splash(PyObject *self, PyObject *args) DialogPtr olddialog; WindowRef theWindow; CGrafPtr thePort; +#if 0 short xpos, ypos, width, height, swidth, sheight; +#endif if (!PyArg_ParseTuple(args, "|i", &resid)) return NULL; @@ -571,6 +575,7 @@ MacOS_splash(PyObject *self, PyObject *args) if ( curdialog ) { theWindow = GetDialogWindow(curdialog); thePort = GetWindowPort(theWindow); +#if 0 width = thePort->portRect.right - thePort->portRect.left; height = thePort->portRect.bottom - thePort->portRect.top; swidth = qd.screenBits.bounds.right - qd.screenBits.bounds.left; @@ -579,6 +584,7 @@ MacOS_splash(PyObject *self, PyObject *args) ypos = (sheight-height)/5 + LMGetMBarHeight(); MoveWindow(theWindow, xpos, ypos, 0); ShowWindow(theWindow); +#endif DrawDialog(curdialog); } } @@ -622,7 +628,7 @@ static char GetTicks_doc[] = "Return number of ticks since bootup"; static PyObject * MacOS_GetTicks(PyObject *self, PyObject *args) { - return Py_BuildValue("i", (int)LMGetTicks()); + return Py_BuildValue("i", (int)TickCount()); } static char openrf_doc[] = "Open resource fork of a file"; @@ -726,7 +732,9 @@ MacOS_CompactMem(PyObject *self, PyObject *args) } static PyMethodDef MacOS_Methods[] = { +#ifndef TARGET_API_MAC_CARBON {"AcceptHighLevelEvent", MacOS_AcceptHighLevelEvent, 1, accepthle_doc}, +#endif {"GetCreatorAndType", MacOS_GetCreatorAndType, 1, getcrtp_doc}, {"SetCreatorAndType", MacOS_SetCreatorAndType, 1, setcrtp_doc}, #ifdef USE_STDWIN |