From e79dc76f53dfa18fb08c35f71b049259642c0142 Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Fri, 2 Jun 2000 21:35:07 +0000 Subject: 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. --- Mac/Lib/lib-toolbox/AEDataModel.py | 2 +- Mac/Lib/lib-toolbox/AEObjects.py | 2 +- Mac/Lib/lib-toolbox/AERegistry.py | 2 +- Mac/Lib/lib-toolbox/AppleEvents.py | 2 +- Mac/Lib/lib-toolbox/Controls.py | 2 +- Mac/Lib/lib-toolbox/Dialogs.py | 2 +- Mac/Lib/lib-toolbox/Menus.py | 2 +- Mac/Lib/lib-toolbox/QuickDraw.py | 4 +- Mac/Lib/lib-toolbox/Resources.py | 2 +- Mac/Lib/lib-toolbox/Windows.py | 2 +- Mac/Modules/Nav.c | 13 +- Mac/Modules/ae/AEmodule.c | 16 ++- Mac/Modules/ae/aesupport.py | 16 ++- Mac/Modules/ctl/Ctlmodule.c | 236 ++++++++++++++++++++++++++++++++++--- Mac/Modules/ctl/ctlscan.py | 23 ++-- Mac/Modules/ctl/ctlsupport.py | 22 ++-- Mac/Modules/dlg/Dlgmodule.c | 14 ++- Mac/Modules/dlg/dlgscan.py | 6 + Mac/Modules/dlg/dlgsupport.py | 7 +- Mac/Modules/macconfig.c | 9 +- Mac/Modules/macfsmodule.c | 4 + Mac/Modules/macmodule.c | 18 +++ Mac/Modules/macosmodule.c | 26 ++-- Mac/Modules/macspeechmodule.c | 5 + Mac/Modules/menu/Menumodule.c | 72 +++++++++++ Mac/Modules/menu/menuedit.py | 1 + Mac/Modules/menu/menuscan.py | 17 +++ Mac/Modules/qd/Qdmodule.c | 4 + Mac/Modules/qd/qdsupport.py | 4 + Mac/Modules/res/Resmodule.c | 36 ++++++ Mac/Modules/res/resscan.py | 11 ++ Mac/Modules/win/Winmodule.c | 171 +++++++++++++++++++-------- Mac/Modules/win/winedit.py | 16 +-- Mac/Modules/win/winscan.py | 25 +++- Mac/Modules/win/winsupport.py | 2 + 35 files changed, 667 insertions(+), 129 deletions(-) diff --git a/Mac/Lib/lib-toolbox/AEDataModel.py b/Mac/Lib/lib-toolbox/AEDataModel.py index f49134f..c68b67c 100644 --- a/Mac/Lib/lib-toolbox/AEDataModel.py +++ b/Mac/Lib/lib-toolbox/AEDataModel.py @@ -1,4 +1,4 @@ -# Generated from 'flap:CodeWarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:AEDataModel.h' +# Generated from 'Macintosh HD:SWDev:Codewarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:AEDataModel.h' def FOUR_CHAR_CODE(x): return x typeBoolean = FOUR_CHAR_CODE('bool') diff --git a/Mac/Lib/lib-toolbox/AEObjects.py b/Mac/Lib/lib-toolbox/AEObjects.py index 048e0d2..974c836 100644 --- a/Mac/Lib/lib-toolbox/AEObjects.py +++ b/Mac/Lib/lib-toolbox/AEObjects.py @@ -1,4 +1,4 @@ -# Generated from 'flap:CodeWarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:AEObjects.h' +# Generated from 'Macintosh HD:SWDev:Codewarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:AEObjects.h' def FOUR_CHAR_CODE(x): return x kAEAND = FOUR_CHAR_CODE('AND ') diff --git a/Mac/Lib/lib-toolbox/AERegistry.py b/Mac/Lib/lib-toolbox/AERegistry.py index 72b5167..f314ec5 100644 --- a/Mac/Lib/lib-toolbox/AERegistry.py +++ b/Mac/Lib/lib-toolbox/AERegistry.py @@ -1,4 +1,4 @@ -# Generated from 'flap:CodeWarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:AERegistry.h' +# Generated from 'Macintosh HD:SWDev:Codewarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:AERegistry.h' def FOUR_CHAR_CODE(x): return x from AEDataModel import * diff --git a/Mac/Lib/lib-toolbox/AppleEvents.py b/Mac/Lib/lib-toolbox/AppleEvents.py index d4bec69..9f9c499 100644 --- a/Mac/Lib/lib-toolbox/AppleEvents.py +++ b/Mac/Lib/lib-toolbox/AppleEvents.py @@ -1,4 +1,4 @@ -# Generated from 'flap:CodeWarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:AppleEvents.h' +# Generated from 'Macintosh HD:SWDev:Codewarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:AppleEvents.h' def FOUR_CHAR_CODE(x): return x from AEDataModel import * diff --git a/Mac/Lib/lib-toolbox/Controls.py b/Mac/Lib/lib-toolbox/Controls.py index 18a9eb4..3d16b02 100644 --- a/Mac/Lib/lib-toolbox/Controls.py +++ b/Mac/Lib/lib-toolbox/Controls.py @@ -1,4 +1,4 @@ -# Generated from 'flap:CodeWarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:Controls.h' +# Generated from 'Macintosh HD:SWDev:Codewarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:Controls.h' def FOUR_CHAR_CODE(x): return x from TextEdit import * diff --git a/Mac/Lib/lib-toolbox/Dialogs.py b/Mac/Lib/lib-toolbox/Dialogs.py index 2367135..5c7f6eb 100644 --- a/Mac/Lib/lib-toolbox/Dialogs.py +++ b/Mac/Lib/lib-toolbox/Dialogs.py @@ -1,4 +1,4 @@ -# Generated from 'flap:CodeWarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:Dialogs.h' +# Generated from 'Macintosh HD:SWDev:Codewarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:Dialogs.h' def FOUR_CHAR_CODE(x): return x gestaltDialogMgrAttr = FOUR_CHAR_CODE('dlog') diff --git a/Mac/Lib/lib-toolbox/Menus.py b/Mac/Lib/lib-toolbox/Menus.py index 8ac0085..a89abac 100644 --- a/Mac/Lib/lib-toolbox/Menus.py +++ b/Mac/Lib/lib-toolbox/Menus.py @@ -1,4 +1,4 @@ -# Generated from 'flap:CodeWarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:Menus.h' +# Generated from 'Macintosh HD:SWDev:Codewarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:Menus.h' def FOUR_CHAR_CODE(x): return x gestaltMenuMgrAttr = FOUR_CHAR_CODE('menu') diff --git a/Mac/Lib/lib-toolbox/QuickDraw.py b/Mac/Lib/lib-toolbox/QuickDraw.py index 1159e58..a8ce68c 100644 --- a/Mac/Lib/lib-toolbox/QuickDraw.py +++ b/Mac/Lib/lib-toolbox/QuickDraw.py @@ -1,4 +1,4 @@ -# Generated from 'flap:CodeWarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:QuickDraw.h' +# Generated from 'Macintosh HD:SWDev:Codewarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:QuickDraw.h' def FOUR_CHAR_CODE(x): return x @@ -141,7 +141,7 @@ kUYVY422PixelFormat = FOUR_CHAR_CODE('UYVY') kYUV211PixelFormat = FOUR_CHAR_CODE('Y211') kCursorImageMajorVersion = 0x0001 kCursorImageMinorVersion = 0x0000 -# Generated from 'flap:CodeWarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:QuickDrawText.h' +# Generated from 'Macintosh HD:SWDev:Codewarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:QuickDrawText.h' def FOUR_CHAR_CODE(x): return x diff --git a/Mac/Lib/lib-toolbox/Resources.py b/Mac/Lib/lib-toolbox/Resources.py index 0549e9a..922fe71 100644 --- a/Mac/Lib/lib-toolbox/Resources.py +++ b/Mac/Lib/lib-toolbox/Resources.py @@ -1,4 +1,4 @@ -# Generated from 'flap:CodeWarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:Resources.h' +# Generated from 'Macintosh HD:SWDev:Codewarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:Resources.h' resSysHeap = 64 resPurgeable = 32 diff --git a/Mac/Lib/lib-toolbox/Windows.py b/Mac/Lib/lib-toolbox/Windows.py index 3152ed5..7d4fa7a 100644 --- a/Mac/Lib/lib-toolbox/Windows.py +++ b/Mac/Lib/lib-toolbox/Windows.py @@ -1,4 +1,4 @@ -# Generated from 'flap:CodeWarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:MacWindows.h' +# Generated from 'Macintosh HD:SWDev:Codewarrior Pro 5:Metrowerks CodeWarrior:MacOS Support:Universal:Interfaces:CIncludes:MacWindows.h' def FOUR_CHAR_CODE(x): return x kAlertWindowClass = 1L diff --git a/Mac/Modules/Nav.c b/Mac/Modules/Nav.c index a7bc45c..85fae41 100644 --- a/Mac/Modules/Nav.c +++ b/Mac/Modules/Nav.c @@ -323,6 +323,8 @@ navrr_getattr(self, name) navrrobject *self; char *name; { + FSSpec fss; + if( strcmp(name, "__members__") == 0 ) return Py_BuildValue("sssssss", "version", "validRecord", "replacing", "isStationery", "translationNeeded", "selection", "fileTranslation"); @@ -355,7 +357,16 @@ navrr_getattr(self, name) PyErr_Mac(ErrorObject, err); return NULL; } - rvitem = PyMac_BuildFSSpec((FSSpec *)*desc.dataHandle); +#ifdef TARGET_API_MAC_CARBON + if (err=AEGetDescData(&desc, &fss, sizeof(FSSpec))) { + Py_DECREF(rv); + PyErr_Mac(ErrorObject, err); + return NULL; + } +#else + memcpy((void *)&fss, (void *)*desc.dataHandle, sizeof(FSSpec)); +#endif + rvitem = PyMac_BuildFSSpec(&fss); PyList_SetItem(rv, i, rvitem); AEDisposeDesc(&desc); } diff --git a/Mac/Modules/ae/AEmodule.c b/Mac/Modules/ae/AEmodule.c index 5bb7f9c..d540197 100644 --- a/Mac/Modules/ae/AEmodule.c +++ b/Mac/Modules/ae/AEmodule.c @@ -795,6 +795,7 @@ static PyObject *AEDesc_getattr(self, name) return PyMac_BuildOSType(self->ob_itself.descriptorType); if (strcmp(name, "data") == 0) { PyObject *res; +#ifndef TARGET_API_MAC_CARBON char state; state = HGetState(self->ob_itself.dataHandle); HLock(self->ob_itself.dataHandle); @@ -803,6 +804,19 @@ static PyObject *AEDesc_getattr(self, name) GetHandleSize(self->ob_itself.dataHandle)); HUnlock(self->ob_itself.dataHandle); HSetState(self->ob_itself.dataHandle, state); +#else + Size size; + char *ptr; + OSErr err; + + size = AEGetDescDataSize(&self->ob_itself); + if ( (res = PyString_FromStringAndSize(NULL, size)) == NULL ) + return NULL; + if ( (ptr = PyString_AsString(res)) == NULL ) + return NULL; + if ( (err=AEGetDescData(&self->ob_itself, ptr, size)) < 0 ) + return PyMac_Error(err); +#endif return res; } if (strcmp(name, "__members__") == 0) @@ -1145,7 +1159,7 @@ static PyMethodDef AE_methods[] = { static pascal OSErr -GenericEventHandler(AppleEvent *request, AppleEvent *reply, long refcon) +GenericEventHandler(const AppleEvent *request, AppleEvent *reply, unsigned long refcon) { PyObject *handler = (PyObject *)refcon; AEDescObject *requestObject, *replyObject; diff --git a/Mac/Modules/ae/aesupport.py b/Mac/Modules/ae/aesupport.py index 3695037..953b490 100644 --- a/Mac/Modules/ae/aesupport.py +++ b/Mac/Modules/ae/aesupport.py @@ -126,7 +126,7 @@ AEIdleUPP upp_AEIdleProc; finalstuff = finalstuff + """ static pascal OSErr -GenericEventHandler(AppleEvent *request, AppleEvent *reply, long refcon) +GenericEventHandler(const AppleEvent *request, AppleEvent *reply, unsigned long refcon) { PyObject *handler = (PyObject *)refcon; AEDescObject *requestObject, *replyObject; @@ -178,6 +178,7 @@ if (strcmp(name, "type") == 0) return PyMac_BuildOSType(self->ob_itself.descriptorType); if (strcmp(name, "data") == 0) { PyObject *res; +#ifndef TARGET_API_MAC_CARBON char state; state = HGetState(self->ob_itself.dataHandle); HLock(self->ob_itself.dataHandle); @@ -186,6 +187,19 @@ if (strcmp(name, "data") == 0) { GetHandleSize(self->ob_itself.dataHandle)); HUnlock(self->ob_itself.dataHandle); HSetState(self->ob_itself.dataHandle, state); +#else + Size size; + char *ptr; + OSErr err; + + size = AEGetDescDataSize(&self->ob_itself); + if ( (res = PyString_FromStringAndSize(NULL, size)) == NULL ) + return NULL; + if ( (ptr = PyString_AsString(res)) == NULL ) + return NULL; + if ( (err=AEGetDescData(&self->ob_itself, ptr, size)) < 0 ) + return PyMac_Error(err); +#endif return res; } if (strcmp(name, "__members__") == 0) diff --git a/Mac/Modules/ctl/Ctlmodule.c b/Mac/Modules/ctl/Ctlmodule.c index 3cdf377..37f8c5a 100644 --- a/Mac/Modules/ctl/Ctlmodule.c +++ b/Mac/Modules/ctl/Ctlmodule.c @@ -46,8 +46,11 @@ extern PyObject *WinObj_WhichWindow(WindowPtr); #define as_Control(h) ((ControlHandle)h) #define as_Resource(ctl) ((Handle)ctl) +#ifdef TARGET_API_MAC_CARBON +#define GetControlRect(ctl, rectp) GetControlBounds(ctl, rectp) +#else #define GetControlRect(ctl, rectp) (*(rectp) = ((*(ctl))->contrlRect)) - +#endif #define resNotFound -192 /* Can't include because of Python's "errors.h" */ extern PyObject *CtlObj_WhichControl(ControlHandle); /* Forward */ @@ -85,10 +88,12 @@ ControlFontStyle_Convert(v, itself) /* TrackControl and HandleControlClick callback support */ static PyObject *tracker; static ControlActionUPP mytracker_upp; +#ifndef TARGET_API_MAC_CARBON_NOTYET static ControlUserPaneDrawUPP mydrawproc_upp; static ControlUserPaneIdleUPP myidleproc_upp; static ControlUserPaneHitTestUPP myhittestproc_upp; static ControlUserPaneTrackingUPP mytrackingproc_upp; +#endif extern int settrackfunc(PyObject *); /* forward */ extern void clrtrackfunc(void); /* forward */ @@ -730,18 +735,19 @@ static PyObject *CtlObj_RemoveControlProperty(_self, _args) PyObject *_args; { PyObject *_res = NULL; - OSStatus _rv; + OSStatus _err; OSType propertyCreator; OSType propertyTag; if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &propertyCreator, PyMac_GetOSType, &propertyTag)) return NULL; - _rv = RemoveControlProperty(_self->ob_itself, - propertyCreator, - propertyTag); - _res = Py_BuildValue("l", - _rv); + _err = RemoveControlProperty(_self->ob_itself, + propertyCreator, + propertyTag); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; return _res; } @@ -750,18 +756,19 @@ static PyObject *CtlObj_GetControlRegion(_self, _args) PyObject *_args; { PyObject *_res = NULL; - OSStatus _rv; + OSStatus _err; ControlPartCode inPart; RgnHandle outRegion; if (!PyArg_ParseTuple(_args, "hO&", &inPart, ResObj_Convert, &outRegion)) return NULL; - _rv = GetControlRegion(_self->ob_itself, - inPart, - outRegion); - _res = Py_BuildValue("l", - _rv); + _err = GetControlRegion(_self->ob_itself, + inPart, + outRegion); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; return _res; } @@ -809,6 +816,8 @@ static PyObject *CtlObj_GetControlReference(_self, _args) return _res; } +#ifndef TARGET_API_MAC_CARBON + static PyObject *CtlObj_GetAuxiliaryControlRecord(_self, _args) ControlObject *_self; PyObject *_args; @@ -825,6 +834,9 @@ static PyObject *CtlObj_GetAuxiliaryControlRecord(_self, _args) ResObj_New, acHndl); return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *CtlObj_SetControlColor(_self, _args) ControlObject *_self; @@ -841,6 +853,151 @@ static PyObject *CtlObj_SetControlColor(_self, _args) _res = Py_None; return _res; } +#endif + +static PyObject *CtlObj_GetBevelButtonMenuValue(_self, _args) + ControlObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSErr _err; + SInt16 outValue; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _err = GetBevelButtonMenuValue(_self->ob_itself, + &outValue); + if (_err != noErr) return PyMac_Error(_err); + _res = Py_BuildValue("h", + outValue); + return _res; +} + +static PyObject *CtlObj_SetBevelButtonMenuValue(_self, _args) + ControlObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSErr _err; + SInt16 inValue; + if (!PyArg_ParseTuple(_args, "h", + &inValue)) + return NULL; + _err = SetBevelButtonMenuValue(_self->ob_itself, + inValue); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *CtlObj_GetBevelButtonMenuHandle(_self, _args) + ControlObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSErr _err; + MenuHandle outHandle; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _err = GetBevelButtonMenuHandle(_self->ob_itself, + &outHandle); + if (_err != noErr) return PyMac_Error(_err); + _res = Py_BuildValue("O&", + MenuObj_New, outHandle); + return _res; +} + +static PyObject *CtlObj_SetBevelButtonTransform(_self, _args) + ControlObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSErr _err; + IconTransformType transform; + if (!PyArg_ParseTuple(_args, "h", + &transform)) + return NULL; + _err = SetBevelButtonTransform(_self->ob_itself, + transform); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *CtlObj_SetImageWellTransform(_self, _args) + ControlObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSErr _err; + IconTransformType inTransform; + if (!PyArg_ParseTuple(_args, "h", + &inTransform)) + return NULL; + _err = SetImageWellTransform(_self->ob_itself, + inTransform); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *CtlObj_GetTabContentRect(_self, _args) + ControlObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSErr _err; + Rect outContentRect; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _err = GetTabContentRect(_self->ob_itself, + &outContentRect); + if (_err != noErr) return PyMac_Error(_err); + _res = Py_BuildValue("O&", + PyMac_BuildRect, &outContentRect); + return _res; +} + +static PyObject *CtlObj_SetTabEnabled(_self, _args) + ControlObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSErr _err; + SInt16 inTabToHilite; + Boolean inEnabled; + if (!PyArg_ParseTuple(_args, "hb", + &inTabToHilite, + &inEnabled)) + return NULL; + _err = SetTabEnabled(_self->ob_itself, + inTabToHilite, + inEnabled); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *CtlObj_SetDisclosureTriangleLastValue(_self, _args) + ControlObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + OSErr _err; + SInt16 inValue; + if (!PyArg_ParseTuple(_args, "h", + &inValue)) + return NULL; + _err = SetDisclosureTriangleLastValue(_self->ob_itself, + inValue); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} static PyObject *CtlObj_SendControlMessage(_self, _args) ControlObject *_self; @@ -1276,6 +1433,8 @@ static PyObject *CtlObj_GetControlDataHandle(_self, _args) } +#ifndef TARGET_API_MAC_CARBON_NOTYET + static PyObject *CtlObj_SetControlDataCallback(_self, _args) ControlObject *_self; PyObject *_args; @@ -1308,6 +1467,9 @@ static PyObject *CtlObj_SetControlDataCallback(_self, _args) return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON_NOTYET static PyObject *CtlObj_GetPopupData(_self, _args) ControlObject *_self; @@ -1328,6 +1490,9 @@ static PyObject *CtlObj_GetPopupData(_self, _args) return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON_NOTYET static PyObject *CtlObj_SetPopupData(_self, _args) ControlObject *_self; @@ -1352,6 +1517,7 @@ static PyObject *CtlObj_SetPopupData(_self, _args) return Py_None; } +#endif static PyMethodDef CtlObj_methods[] = { {"HiliteControl", (PyCFunction)CtlObj_HiliteControl, 1, @@ -1427,19 +1593,41 @@ static PyMethodDef CtlObj_methods[] = { {"IsValidControlHandle", (PyCFunction)CtlObj_IsValidControlHandle, 1, "() -> (Boolean _rv)"}, {"RemoveControlProperty", (PyCFunction)CtlObj_RemoveControlProperty, 1, - "(OSType propertyCreator, OSType propertyTag) -> (OSStatus _rv)"}, + "(OSType propertyCreator, OSType propertyTag) -> None"}, {"GetControlRegion", (PyCFunction)CtlObj_GetControlRegion, 1, - "(ControlPartCode inPart, RgnHandle outRegion) -> (OSStatus _rv)"}, + "(ControlPartCode inPart, RgnHandle outRegion) -> None"}, {"GetControlVariant", (PyCFunction)CtlObj_GetControlVariant, 1, "() -> (ControlVariant _rv)"}, {"SetControlReference", (PyCFunction)CtlObj_SetControlReference, 1, "(SInt32 data) -> None"}, {"GetControlReference", (PyCFunction)CtlObj_GetControlReference, 1, "() -> (SInt32 _rv)"}, + +#ifndef TARGET_API_MAC_CARBON {"GetAuxiliaryControlRecord", (PyCFunction)CtlObj_GetAuxiliaryControlRecord, 1, "() -> (Boolean _rv, AuxCtlHandle acHndl)"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"SetControlColor", (PyCFunction)CtlObj_SetControlColor, 1, "(CCTabHandle newColorTable) -> None"}, +#endif + {"GetBevelButtonMenuValue", (PyCFunction)CtlObj_GetBevelButtonMenuValue, 1, + "() -> (SInt16 outValue)"}, + {"SetBevelButtonMenuValue", (PyCFunction)CtlObj_SetBevelButtonMenuValue, 1, + "(SInt16 inValue) -> None"}, + {"GetBevelButtonMenuHandle", (PyCFunction)CtlObj_GetBevelButtonMenuHandle, 1, + "() -> (MenuHandle outHandle)"}, + {"SetBevelButtonTransform", (PyCFunction)CtlObj_SetBevelButtonTransform, 1, + "(IconTransformType transform) -> None"}, + {"SetImageWellTransform", (PyCFunction)CtlObj_SetImageWellTransform, 1, + "(IconTransformType inTransform) -> None"}, + {"GetTabContentRect", (PyCFunction)CtlObj_GetTabContentRect, 1, + "() -> (Rect outContentRect)"}, + {"SetTabEnabled", (PyCFunction)CtlObj_SetTabEnabled, 1, + "(SInt16 inTabToHilite, Boolean inEnabled) -> None"}, + {"SetDisclosureTriangleLastValue", (PyCFunction)CtlObj_SetDisclosureTriangleLastValue, 1, + "(SInt16 inValue) -> None"}, {"SendControlMessage", (PyCFunction)CtlObj_SendControlMessage, 1, "(SInt16 inMessage, SInt32 inParam) -> (SInt32 _rv)"}, {"EmbedControl", (PyCFunction)CtlObj_EmbedControl, 1, @@ -1476,12 +1664,21 @@ static PyMethodDef CtlObj_methods[] = { "(ResObj) -> None"}, {"GetControlDataHandle", (PyCFunction)CtlObj_GetControlDataHandle, 1, "(part, type) -> ResObj"}, + +#ifndef TARGET_API_MAC_CARBON_NOTYET {"SetControlDataCallback", (PyCFunction)CtlObj_SetControlDataCallback, 1, "(callbackfunc) -> None"}, +#endif + +#ifndef TARGET_API_MAC_CARBON_NOTYET {"GetPopupData", (PyCFunction)CtlObj_GetPopupData, 1, NULL}, +#endif + +#ifndef TARGET_API_MAC_CARBON_NOTYET {"SetPopupData", (PyCFunction)CtlObj_SetPopupData, 1, NULL}, +#endif {NULL, NULL, 0} }; @@ -1954,9 +2151,7 @@ clrtrackfunc() } static pascal void -mytracker(ctl, part) - ControlHandle ctl; - short part; +mytracker(ControlHandle ctl, short part) { PyObject *args, *rv=0; @@ -1971,6 +2166,7 @@ mytracker(ctl, part) PySys_WriteStderr("TrackControl or HandleControlClick: exception in tracker function\n"); } +#ifndef TARGET_API_MAC_CARBON_NOTYET static int setcallback(self, which, callback, uppp) ControlObject *self; @@ -2086,7 +2282,7 @@ mytrackingproc(ControlHandle control, Point startPt, ControlActionUPP actionProc Py_XDECREF(rv); return (ControlPartCode)c_rv; } - +#endif void initCtl() @@ -2097,10 +2293,12 @@ void initCtl() mytracker_upp = NewControlActionProc(mytracker); +#ifndef TARGET_API_MAC_CARBON_NOTYET mydrawproc_upp = NewControlUserPaneDrawProc(mydrawproc); myidleproc_upp = NewControlUserPaneIdleProc(myidleproc); myhittestproc_upp = NewControlUserPaneHitTestProc(myhittestproc); mytrackingproc_upp = NewControlUserPaneTrackingProc(mytrackingproc); +#endif m = Py_InitModule("Ctl", Ctl_methods); diff --git a/Mac/Modules/ctl/ctlscan.py b/Mac/Modules/ctl/ctlscan.py index 63d32f3..0f46c0e 100644 --- a/Mac/Modules/ctl/ctlscan.py +++ b/Mac/Modules/ctl/ctlscan.py @@ -48,17 +48,17 @@ class MyScanner(Scanner): 'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition 'kControlProgressBarIndeterminateTag', # ditto # The following are unavailable for static 68k (appearance manager) - 'GetBevelButtonMenuValue', - 'SetBevelButtonMenuValue', - 'GetBevelButtonMenuHandle', - 'SetBevelButtonTransform', +## 'GetBevelButtonMenuValue', +## 'SetBevelButtonMenuValue', +## 'GetBevelButtonMenuHandle', +## 'SetBevelButtonTransform', 'SetBevelButtonGraphicAlignment', 'SetBevelButtonTextAlignment', 'SetBevelButtonTextPlacement', - 'SetImageWellTransform', - 'GetTabContentRect', - 'SetTabEnabled', - 'SetDisclosureTriangleLastValue', +## 'SetImageWellTransform', +## 'GetTabContentRect', +## 'SetTabEnabled', +## 'SetDisclosureTriangleLastValue', ## # Unavailable in CW Pro 3 libraries ## 'SetUpControlTextColor', ## # Unavailable in Jack's CW Pro 5.1 libraries @@ -79,6 +79,13 @@ class MyScanner(Scanner): 'GetControlPropertySize', ] + def makegreylist(self): + return [ + ('#ifndef TARGET_API_MAC_CARBON', [ + 'GetAuxiliaryControlRecord', + 'SetControlColor', + ])] + def makeblacklisttypes(self): return [ 'ProcPtr', diff --git a/Mac/Modules/ctl/ctlsupport.py b/Mac/Modules/ctl/ctlsupport.py index f2d4be1..a8c2d64 100644 --- a/Mac/Modules/ctl/ctlsupport.py +++ b/Mac/Modules/ctl/ctlsupport.py @@ -46,8 +46,11 @@ includestuff = includestuff + """ #define as_Control(h) ((ControlHandle)h) #define as_Resource(ctl) ((Handle)ctl) +#ifdef TARGET_API_MAC_CARBON +#define GetControlRect(ctl, rectp) GetControlBounds(ctl, rectp) +#else #define GetControlRect(ctl, rectp) (*(rectp) = ((*(ctl))->contrlRect)) - +#endif #define resNotFound -192 /* Can't include because of Python's "errors.h" */ extern PyObject *CtlObj_WhichControl(ControlHandle); /* Forward */ @@ -85,10 +88,12 @@ ControlFontStyle_Convert(v, itself) /* TrackControl and HandleControlClick callback support */ static PyObject *tracker; static ControlActionUPP mytracker_upp; +#ifndef TARGET_API_MAC_CARBON_NOTYET static ControlUserPaneDrawUPP mydrawproc_upp; static ControlUserPaneIdleUPP myidleproc_upp; static ControlUserPaneHitTestUPP myhittestproc_upp; static ControlUserPaneTrackingUPP mytrackingproc_upp; +#endif extern int settrackfunc(PyObject *); /* forward */ extern void clrtrackfunc(void); /* forward */ @@ -147,9 +152,7 @@ clrtrackfunc() } static pascal void -mytracker(ctl, part) - ControlHandle ctl; - short part; +mytracker(ControlHandle ctl, short part) { PyObject *args, *rv=0; @@ -164,6 +167,7 @@ mytracker(ctl, part) PySys_WriteStderr("TrackControl or HandleControlClick: exception in tracker function\\n"); } +#ifndef TARGET_API_MAC_CARBON_NOTYET static int setcallback(self, which, callback, uppp) ControlObject *self; @@ -279,15 +283,17 @@ mytrackingproc(ControlHandle control, Point startPt, ControlActionUPP actionProc Py_XDECREF(rv); return (ControlPartCode)c_rv; } - +#endif """ initstuff = initstuff + """ mytracker_upp = NewControlActionProc(mytracker); +#ifndef TARGET_API_MAC_CARBON_NOTYET mydrawproc_upp = NewControlUserPaneDrawProc(mydrawproc); myidleproc_upp = NewControlUserPaneIdleProc(myidleproc); myhittestproc_upp = NewControlUserPaneHitTestProc(myhittestproc); mytrackingproc_upp = NewControlUserPaneTrackingProc(mytrackingproc); +#endif """ class MyObjectDefinition(ObjectIdentityMixin, GlobalObjectDefinition): @@ -564,7 +570,7 @@ _res = Py_None; return _res; """ -f = ManualGenerator("SetControlDataCallback", setcontroldatacallback_body); +f = ManualGenerator("SetControlDataCallback", setcontroldatacallback_body, condition="#ifndef TARGET_API_MAC_CARBON_NOTYET"); f.docstring = lambda: "(callbackfunc) -> None" object.add(f) @@ -582,7 +588,7 @@ _res = Py_BuildValue("O&i", MenuObj_New, (*hdl)->mHandle, (int)(*hdl)->mID); HUnlock((Handle)hdl); return _res; """ -f = ManualGenerator("GetPopupData", getpopupdata_body) +f = ManualGenerator("GetPopupData", getpopupdata_body, condition="#ifndef TARGET_API_MAC_CARBON_NOTYET") object.add(f) setpopupdata_body = """ @@ -602,7 +608,7 @@ hdl = (PopupPrivateDataHandle)(*_self->ob_itself)->contrlData; Py_INCREF(Py_None); return Py_None; """ -f = ManualGenerator("SetPopupData", setpopupdata_body) +f = ManualGenerator("SetPopupData", setpopupdata_body, condition="#ifndef TARGET_API_MAC_CARBON_NOTYET") object.add(f) diff --git a/Mac/Modules/dlg/Dlgmodule.c b/Mac/Modules/dlg/Dlgmodule.c index fbbadd8..15f61f5 100644 --- a/Mac/Modules/dlg/Dlgmodule.c +++ b/Mac/Modules/dlg/Dlgmodule.c @@ -154,7 +154,7 @@ PyObject *DlgObj_New(itself) it = PyObject_NEW(DialogObject, &Dialog_Type); if (it == NULL) return NULL; it->ob_itself = itself; - SetWRefCon(itself, (long)it); + SetWRefCon(GetDialogWindow(itself), (long)it); return (PyObject *)it; } DlgObj_Convert(v, p_itself) @@ -692,12 +692,12 @@ static PyObject *DlgObj_GetDialogWindow(_self, _args) PyObject *_args; { PyObject *_res = NULL; - DialogPtr _rv; + WindowPtr _rv; if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = GetDialogWindow(_self->ob_itself); _res = Py_BuildValue("O&", - WinObj_WhichWindow, _rv); + WinObj_New, _rv); return _res; } @@ -743,6 +743,8 @@ static PyObject *DlgObj_GetDialogKeyboardFocusItem(_self, _args) return _res; } +#ifndef TARGET_API_MAC_CARBON + static PyObject *DlgObj_SetGrafPortOfDialog(_self, _args) DialogObject *_self; PyObject *_args; @@ -755,6 +757,7 @@ static PyObject *DlgObj_SetGrafPortOfDialog(_self, _args) _res = Py_None; return _res; } +#endif static PyMethodDef DlgObj_methods[] = { {"DrawDialog", (PyCFunction)DlgObj_DrawDialog, 1, @@ -814,15 +817,18 @@ static PyMethodDef DlgObj_methods[] = { {"GetModalDialogEventMask", (PyCFunction)DlgObj_GetModalDialogEventMask, 1, "() -> (EventMask outMask)"}, {"GetDialogWindow", (PyCFunction)DlgObj_GetDialogWindow, 1, - "() -> (DialogPtr _rv)"}, + "() -> (WindowPtr _rv)"}, {"GetDialogDefaultItem", (PyCFunction)DlgObj_GetDialogDefaultItem, 1, "() -> (SInt16 _rv)"}, {"GetDialogCancelItem", (PyCFunction)DlgObj_GetDialogCancelItem, 1, "() -> (SInt16 _rv)"}, {"GetDialogKeyboardFocusItem", (PyCFunction)DlgObj_GetDialogKeyboardFocusItem, 1, "() -> (SInt16 _rv)"}, + +#ifndef TARGET_API_MAC_CARBON {"SetGrafPortOfDialog", (PyCFunction)DlgObj_SetGrafPortOfDialog, 1, "() -> None"}, +#endif {NULL, NULL, 0} }; diff --git a/Mac/Modules/dlg/dlgscan.py b/Mac/Modules/dlg/dlgscan.py index eb5bbfe..a9d6fc4 100644 --- a/Mac/Modules/dlg/dlgscan.py +++ b/Mac/Modules/dlg/dlgscan.py @@ -55,6 +55,12 @@ class MyScanner(Scanner): 'GetDialogControlNotificationProc', ] + def makegreylist(self): + return [ + ('#ifndef TARGET_API_MAC_CARBON', [ + 'SetGrafPortOfDialog', + ])] + def makeblacklisttypes(self): return [ "AlertStdAlertParamPtr", # Too much work, for now diff --git a/Mac/Modules/dlg/dlgsupport.py b/Mac/Modules/dlg/dlgsupport.py index 4c44722..78b6be2 100644 --- a/Mac/Modules/dlg/dlgsupport.py +++ b/Mac/Modules/dlg/dlgsupport.py @@ -129,7 +129,7 @@ class MyObjectDefinition(GlobalObjectDefinition): self.basechain = "&WinObj_chain" def outputInitStructMembers(self): GlobalObjectDefinition.outputInitStructMembers(self) - Output("SetWRefCon(itself, (long)it);") + Output("SetWRefCon(GetDialogWindow(itself), (long)it);") def outputCheckNewArg(self): Output("if (itself == NULL) return Py_None;") def outputCheckConvertArg(self): @@ -160,7 +160,7 @@ for f in methods: object.add(f) # Some methods that are currently macro's in C, but will be real routines # in MacOS 8. -f = Method(ExistingDialogPtr, 'GetDialogWindow', (DialogRef, 'dialog', InMode)) +f = Method(WindowPtr, 'GetDialogWindow', (DialogRef, 'dialog', InMode)) object.add(f) f = Method(SInt16, 'GetDialogDefaultItem', (DialogRef, 'dialog', InMode)) object.add(f) @@ -168,7 +168,8 @@ f = Method(SInt16, 'GetDialogCancelItem', (DialogRef, 'dialog', InMode)) object.add(f) f = Method(SInt16, 'GetDialogKeyboardFocusItem', (DialogRef, 'dialog', InMode)) object.add(f) -f = Method(void, 'SetGrafPortOfDialog', (DialogRef, 'dialog', InMode)) +f = Method(void, 'SetGrafPortOfDialog', (DialogRef, 'dialog', InMode), + condition='#ifndef TARGET_API_MAC_CARBON') object.add(f) setuseritembody = """ diff --git a/Mac/Modules/macconfig.c b/Mac/Modules/macconfig.c index 5306764..9dc15c0 100644 --- a/Mac/Modules/macconfig.c +++ b/Mac/Modules/macconfig.c @@ -115,7 +115,6 @@ extern void initTE(); extern void initColorPicker(); extern void initPrinting(); extern void initDrag(); -extern void initNav(); #endif #ifdef USE_CORE_TOOLBOX extern void initCtl(); @@ -124,6 +123,7 @@ extern void initMenu(); extern void initQd(); extern void initRes(); extern void initWin(); +extern void initNav(); #endif #ifdef USE_QT extern void initCm(); @@ -225,6 +225,7 @@ struct _inittab _PyImport_Inittab[] = { {"Ctl", initCtl}, {"Dlg", initDlg}, {"Menu", initMenu}, + {"Nav", initNav}, {"Qd", initQd}, {"Win", initWin}, {"Res", initRes}, @@ -234,7 +235,6 @@ struct _inittab _PyImport_Inittab[] = { {"App", initApp}, {"Evt", initEvt}, {"Fm", initFm}, - {"Help", initHelp}, {"Icn", initIcn}, {"List", initList}, {"Snd", initSnd}, @@ -242,9 +242,11 @@ struct _inittab _PyImport_Inittab[] = { {"Scrap", initScrap}, {"TE", initTE}, {"ColorPicker", initColorPicker}, +#ifndef TARGET_API_MAC_CARBON + {"Help", initHelp}, {"Printing", initPrinting}, +#endif {"Drag", initDrag}, - {"Nav", initNav}, #endif #ifdef USE_QT {"Cm", initCm}, @@ -302,4 +304,3 @@ struct _inittab _PyImport_Inittab[] = { /* Sentinel */ {0, 0} }; - diff --git a/Mac/Modules/macfsmodule.c b/Mac/Modules/macfsmodule.c index 0db4022..13dde93 100644 --- a/Mac/Modules/macfsmodule.c +++ b/Mac/Modules/macfsmodule.c @@ -713,6 +713,7 @@ mfs_ResolveAliasFile(self, args) return Py_BuildValue("Oii", newmfssobject(&fss), (int)isfolder, (int)wasaliased); } +#ifndef TARGET_API_MAC_CARBON static PyObject * mfs_StandardGetFile(self, args) PyObject *self; /* Not used */ @@ -803,6 +804,7 @@ mfs_SetFolder(self, args) LMSetCurDirStore(spec.parID); return (PyObject *)newmfssobject(&ospec); } +#endif static PyObject * mfs_FSSpec(self, args) @@ -950,11 +952,13 @@ mfs_NewAliasMinimalFromFullPath(self, args) static struct PyMethodDef mfs_methods[] = { {"ResolveAliasFile", mfs_ResolveAliasFile, 1}, +#ifndef TARGET_API_MAC_CARBON {"StandardGetFile", mfs_StandardGetFile, 1}, {"PromptGetFile", mfs_PromptGetFile, 1}, {"StandardPutFile", mfs_StandardPutFile, 1}, {"GetDirectory", mfs_GetDirectory, 1}, {"SetFolder", mfs_SetFolder, 1}, +#endif {"FSSpec", mfs_FSSpec, 1}, {"RawFSSpec", mfs_RawFSSpec, 1}, {"RawAlias", mfs_RawAlias, 1}, diff --git a/Mac/Modules/macmodule.c b/Mac/Modules/macmodule.c index c2224f0..74c1243 100644 --- a/Mac/Modules/macmodule.c +++ b/Mac/Modules/macmodule.c @@ -42,7 +42,11 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #undef S_ISREG #endif /* THINK_C */ +#ifndef TARGET_API_MAC_CARBON_NOTYET +/* XXXX Skip for Carbon, for now */ #include "macstat.h" +#endif + #ifdef USE_GUSI /* Remove defines from macstat.h */ #undef S_IFMT @@ -58,7 +62,9 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #else /* USE_GUSI */ +#ifndef TARGET_API_MAC_CARBON_NOTYET #define stat macstat +#endif #endif /* USE_GUSI */ #ifdef USE_GUSI2 @@ -70,6 +76,10 @@ int sync(void); #else #define mode_t int #include +#ifdef _POSIX +#include +#include +#endif #endif /* Optional routines, for some compiler/runtime combinations */ @@ -264,6 +274,7 @@ mac_fdopen(self, args) } #endif +#ifndef TARGET_API_MAC_CARBON static PyObject * mac_getbootvol(self, args) PyObject *self; @@ -279,6 +290,7 @@ mac_getbootvol(self, args) return mac_error(); return PyString_FromString(res); } +#endif static PyObject * mac_getcwd(self, args) @@ -502,6 +514,7 @@ mac_fstat(self, args) } #endif /* WEHAVE_FSTAT */ +#ifndef TARGET_API_MAC_CARBON_NOTYET static PyObject * mac_xstat(self, args) PyObject *self; @@ -543,6 +556,7 @@ mac_xstat(self, args) mst.st_creator, 4, mst.st_type, 4); } +#endif static PyObject * mac_sync(self, args) @@ -610,7 +624,9 @@ static struct PyMethodDef mac_methods[] = { #ifdef WEHAVE_FSTAT {"fstat", mac_fstat}, #endif +#ifndef TARGET_API_MAC_CARBON {"getbootvol", mac_getbootvol}, /* non-standard */ +#endif {"getcwd", mac_getcwd}, {"listdir", mac_listdir, 0}, {"lseek", mac_lseek}, @@ -620,7 +636,9 @@ static struct PyMethodDef mac_methods[] = { {"rename", mac_rename}, {"rmdir", mac_rmdir}, {"stat", mac_stat}, +#ifndef TARGET_API_MAC_CARBON_NOTYET {"xstat", mac_xstat}, +#endif {"sync", mac_sync}, {"remove", mac_unlink}, {"unlink", mac_unlink}, 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 #include #include +#include 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 diff --git a/Mac/Modules/macspeechmodule.c b/Mac/Modules/macspeechmodule.c index d0ee465..accb7b2 100644 --- a/Mac/Modules/macspeechmodule.c +++ b/Mac/Modules/macspeechmodule.c @@ -29,9 +29,14 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "Speech.h" #ifdef __MWERKS__ +#define OLDP2C 1 #include +#ifndef c2pstr #define c2pstr C2PStr +#endif +#ifndef p2cstr #define p2cstr P2CStr +#endif #else #include "pascal.h" #endif /* __MWERKS__ */ diff --git a/Mac/Modules/menu/Menumodule.c b/Mac/Modules/menu/Menumodule.c index e40ace7..0044c67 100644 --- a/Mac/Modules/menu/Menumodule.c +++ b/Mac/Modules/menu/Menumodule.c @@ -118,6 +118,8 @@ static PyObject *MenuObj_CalcMenuSize(_self, _args) return _res; } +#ifndef TARGET_API_MAC_CARBON + static PyObject *MenuObj_CountMItems(_self, _args) MenuObject *_self; PyObject *_args; @@ -131,6 +133,7 @@ static PyObject *MenuObj_CountMItems(_self, _args) _rv); return _res; } +#endif static PyObject *MenuObj_GetMenuFont(_self, _args) MenuObject *_self; @@ -410,6 +413,8 @@ static PyObject *MenuObj_MacInsertMenu(_self, _args) return _res; } +#ifndef TARGET_API_MAC_CARBON + static PyObject *MenuObj_CheckItem(_self, _args) MenuObject *_self; PyObject *_args; @@ -428,6 +433,7 @@ static PyObject *MenuObj_CheckItem(_self, _args) _res = Py_None; return _res; } +#endif static PyObject *MenuObj_SetMenuItemText(_self, _args) MenuObject *_self; @@ -614,6 +620,8 @@ static PyObject *MenuObj_GetItemStyle(_self, _args) return _res; } +#ifndef TARGET_API_MAC_CARBON + static PyObject *MenuObj_DisableItem(_self, _args) MenuObject *_self; PyObject *_args; @@ -629,6 +637,9 @@ static PyObject *MenuObj_DisableItem(_self, _args) _res = Py_None; return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *MenuObj_EnableItem(_self, _args) MenuObject *_self; @@ -645,6 +656,7 @@ static PyObject *MenuObj_EnableItem(_self, _args) _res = Py_None; return _res; } +#endif static PyObject *MenuObj_SetMenuItemCommandID(_self, _args) MenuObject *_self; @@ -939,6 +951,8 @@ static PyObject *MenuObj_GetMenuItemRefCon(_self, _args) return _res; } +#ifndef TARGET_API_MAC_CARBON + static PyObject *MenuObj_SetMenuItemRefCon2(_self, _args) MenuObject *_self; PyObject *_args; @@ -959,6 +973,9 @@ static PyObject *MenuObj_SetMenuItemRefCon2(_self, _args) _res = Py_None; return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *MenuObj_GetMenuItemRefCon2(_self, _args) MenuObject *_self; @@ -979,6 +996,7 @@ static PyObject *MenuObj_GetMenuItemRefCon2(_self, _args) outRefCon2); return _res; } +#endif static PyObject *MenuObj_SetMenuItemKeyGlyph(_self, _args) MenuObject *_self; @@ -1189,8 +1207,11 @@ static PyMethodDef MenuObj_methods[] = { "() -> None"}, {"CalcMenuSize", (PyCFunction)MenuObj_CalcMenuSize, 1, "() -> None"}, + +#ifndef TARGET_API_MAC_CARBON {"CountMItems", (PyCFunction)MenuObj_CountMItems, 1, "() -> (short _rv)"}, +#endif {"GetMenuFont", (PyCFunction)MenuObj_GetMenuFont, 1, "() -> (SInt16 outFontID, UInt16 outFontSize)"}, {"SetMenuFont", (PyCFunction)MenuObj_SetMenuFont, 1, @@ -1221,8 +1242,11 @@ static PyMethodDef MenuObj_methods[] = { "(short top, short left, short popUpItem) -> (long _rv)"}, {"MacInsertMenu", (PyCFunction)MenuObj_MacInsertMenu, 1, "(short beforeID) -> None"}, + +#ifndef TARGET_API_MAC_CARBON {"CheckItem", (PyCFunction)MenuObj_CheckItem, 1, "(short item, Boolean checked) -> None"}, +#endif {"SetMenuItemText", (PyCFunction)MenuObj_SetMenuItemText, 1, "(short item, Str255 itemString) -> None"}, {"GetMenuItemText", (PyCFunction)MenuObj_GetMenuItemText, 1, @@ -1243,10 +1267,16 @@ static PyMethodDef MenuObj_methods[] = { "(short item, StyleParameter chStyle) -> None"}, {"GetItemStyle", (PyCFunction)MenuObj_GetItemStyle, 1, "(short item) -> (Style chStyle)"}, + +#ifndef TARGET_API_MAC_CARBON {"DisableItem", (PyCFunction)MenuObj_DisableItem, 1, "(short item) -> None"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"EnableItem", (PyCFunction)MenuObj_EnableItem, 1, "(short item) -> None"}, +#endif {"SetMenuItemCommandID", (PyCFunction)MenuObj_SetMenuItemCommandID, 1, "(SInt16 inItem, UInt32 inCommandID) -> None"}, {"GetMenuItemCommandID", (PyCFunction)MenuObj_GetMenuItemCommandID, 1, @@ -1275,10 +1305,16 @@ static PyMethodDef MenuObj_methods[] = { "(SInt16 inItem, UInt32 inRefCon) -> None"}, {"GetMenuItemRefCon", (PyCFunction)MenuObj_GetMenuItemRefCon, 1, "(SInt16 inItem) -> (UInt32 outRefCon)"}, + +#ifndef TARGET_API_MAC_CARBON {"SetMenuItemRefCon2", (PyCFunction)MenuObj_SetMenuItemRefCon2, 1, "(SInt16 inItem, UInt32 inRefCon2) -> None"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"GetMenuItemRefCon2", (PyCFunction)MenuObj_GetMenuItemRefCon2, 1, "(SInt16 inItem) -> (UInt32 outRefCon2)"}, +#endif {"SetMenuItemKeyGlyph", (PyCFunction)MenuObj_SetMenuItemKeyGlyph, 1, "(SInt16 inItem, SInt16 inGlyph) -> None"}, {"GetMenuItemKeyGlyph", (PyCFunction)MenuObj_GetMenuItemKeyGlyph, 1, @@ -1345,6 +1381,8 @@ PyTypeObject Menu_Type = { /* ---------------------- End object type Menu ---------------------- */ +#ifndef TARGET_API_MAC_CARBON + static PyObject *Menu_InitProcMenu(_self, _args) PyObject *_self; PyObject *_args; @@ -1359,6 +1397,9 @@ static PyObject *Menu_InitProcMenu(_self, _args) _res = Py_None; return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *Menu_InitMenus(_self, _args) PyObject *_self; @@ -1372,6 +1413,7 @@ static PyObject *Menu_InitMenus(_self, _args) _res = Py_None; return _res; } +#endif static PyObject *Menu_NewMenu(_self, _args) PyObject *_self; @@ -1614,6 +1656,8 @@ static PyObject *Menu_ClearMenuBar(_self, _args) return _res; } +#ifndef TARGET_API_MAC_CARBON + static PyObject *Menu_SetMenuFlash(_self, _args) PyObject *_self; PyObject *_args; @@ -1628,6 +1672,7 @@ static PyObject *Menu_SetMenuFlash(_self, _args) _res = Py_None; return _res; } +#endif static PyObject *Menu_FlashMenuBar(_self, _args) PyObject *_self; @@ -1644,6 +1689,8 @@ static PyObject *Menu_FlashMenuBar(_self, _args) return _res; } +#ifndef TARGET_API_MAC_CARBON + static PyObject *Menu_SystemEdit(_self, _args) PyObject *_self; PyObject *_args; @@ -1659,6 +1706,9 @@ static PyObject *Menu_SystemEdit(_self, _args) _rv); return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *Menu_SystemMenu(_self, _args) PyObject *_self; @@ -1674,6 +1724,7 @@ static PyObject *Menu_SystemMenu(_self, _args) _res = Py_None; return _res; } +#endif static PyObject *Menu_IsMenuBarVisible(_self, _args) PyObject *_self; @@ -1764,6 +1815,8 @@ static PyObject *Menu_IsShowContextualMenuClick(_self, _args) return _res; } +#ifndef TARGET_API_MAC_CARBON + static PyObject *Menu_OpenDeskAcc(_self, _args) PyObject *_self; PyObject *_args; @@ -1778,6 +1831,7 @@ static PyObject *Menu_OpenDeskAcc(_self, _args) _res = Py_None; return _res; } +#endif static PyObject *Menu_as_Menu(_self, _args) PyObject *_self; @@ -1840,10 +1894,16 @@ static PyObject *Menu_DrawMenuBar(_self, _args) } static PyMethodDef Menu_methods[] = { + +#ifndef TARGET_API_MAC_CARBON {"InitProcMenu", (PyCFunction)Menu_InitProcMenu, 1, "(short resID) -> None"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"InitMenus", (PyCFunction)Menu_InitMenus, 1, "() -> None"}, +#endif {"NewMenu", (PyCFunction)Menu_NewMenu, 1, "(short menuID, Str255 menuTitle) -> (MenuHandle _rv)"}, {"MacGetMenu", (PyCFunction)Menu_MacGetMenu, 1, @@ -1876,14 +1936,23 @@ static PyMethodDef Menu_methods[] = { "(short menuID) -> None"}, {"ClearMenuBar", (PyCFunction)Menu_ClearMenuBar, 1, "() -> None"}, + +#ifndef TARGET_API_MAC_CARBON {"SetMenuFlash", (PyCFunction)Menu_SetMenuFlash, 1, "(short count) -> None"}, +#endif {"FlashMenuBar", (PyCFunction)Menu_FlashMenuBar, 1, "(short menuID) -> None"}, + +#ifndef TARGET_API_MAC_CARBON {"SystemEdit", (PyCFunction)Menu_SystemEdit, 1, "(short editCmd) -> (Boolean _rv)"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"SystemMenu", (PyCFunction)Menu_SystemMenu, 1, "(long menuResult) -> None"}, +#endif {"IsMenuBarVisible", (PyCFunction)Menu_IsMenuBarVisible, 1, "() -> (Boolean _rv)"}, {"ShowMenuBar", (PyCFunction)Menu_ShowMenuBar, 1, @@ -1896,8 +1965,11 @@ static PyMethodDef Menu_methods[] = { "() -> None"}, {"IsShowContextualMenuClick", (PyCFunction)Menu_IsShowContextualMenuClick, 1, "(EventRecord inEvent) -> (Boolean _rv)"}, + +#ifndef TARGET_API_MAC_CARBON {"OpenDeskAcc", (PyCFunction)Menu_OpenDeskAcc, 1, "(Str255 name) -> None"}, +#endif {"as_Menu", (PyCFunction)Menu_as_Menu, 1, "(Handle h) -> (MenuHandle _rv)"}, {"GetMenu", (PyCFunction)Menu_GetMenu, 1, diff --git a/Mac/Modules/menu/menuedit.py b/Mac/Modules/menu/menuedit.py index 5409663..f4b5756 100644 --- a/Mac/Modules/menu/menuedit.py +++ b/Mac/Modules/menu/menuedit.py @@ -1,5 +1,6 @@ f = Function(void, 'OpenDeskAcc', (Str255, 'name', InMode), + condition='#ifndef TARGET_API_MAC_CARBON' ) functions.append(f) diff --git a/Mac/Modules/menu/menuscan.py b/Mac/Modules/menu/menuscan.py index fa87ba3..2275683 100644 --- a/Mac/Modules/menu/menuscan.py +++ b/Mac/Modules/menu/menuscan.py @@ -40,6 +40,23 @@ class MyScanner(Scanner): "RemoveMenuItemProperty", ] + def makegreylist(self): + return [ + ('#ifndef TARGET_API_MAC_CARBON', [ + 'GetMenuItemRefCon2', + 'SetMenuItemRefCon2', + 'EnableItem', + 'DisableItem', + 'CheckItem', + 'CountMItems', + 'OpenDeskAcc', + 'SystemEdit', + 'SystemMenu', + 'SetMenuFlash', + 'InitMenus', + 'InitProcMenu', + ])] + def makeblacklisttypes(self): return [ 'MCTableHandle', diff --git a/Mac/Modules/qd/Qdmodule.c b/Mac/Modules/qd/Qdmodule.c index 299c9ca..a5e6871 100644 --- a/Mac/Modules/qd/Qdmodule.c +++ b/Mac/Modules/qd/Qdmodule.c @@ -141,6 +141,7 @@ static PyObject *GrafObj_getattr(self, name) GrafPortObject *self; char *name; { +#ifndef TARGET_API_MAC_CARBON { CGrafPtr itself_color = (CGrafPtr)self->ob_itself; @@ -218,6 +219,7 @@ static PyObject *GrafObj_getattr(self, name) if ( strcmp(name, "_id") == 0 ) return Py_BuildValue("l", (long)self->ob_itself); } +#endif return Py_FindMethodInChain(&GrafObj_chain, (PyObject *)self, name); } @@ -424,6 +426,7 @@ static PyObject *QDGA_getattr(self, name) QDGlobalsAccessObject *self; char *name; { +#ifndef TARGET_API_MAC_CARBON if ( strcmp(name, "arrow") == 0 ) return PyString_FromStringAndSize((char *)&qd.arrow, sizeof(qd.arrow)); @@ -444,6 +447,7 @@ static PyObject *QDGA_getattr(self, name) if ( strcmp(name, "randSeed") == 0 ) return Py_BuildValue("l", &qd.randSeed); +#endif return Py_FindMethodInChain(&QDGA_chain, (PyObject *)self, name); } diff --git a/Mac/Modules/qd/qdsupport.py b/Mac/Modules/qd/qdsupport.py index 33e8832..671b359 100644 --- a/Mac/Modules/qd/qdsupport.py +++ b/Mac/Modules/qd/qdsupport.py @@ -132,6 +132,7 @@ class MyGRObjectDefinition(GlobalObjectDefinition): Output("return 1;") OutRbrace() def outputGetattrHook(self): + Output("#ifndef TARGET_API_MAC_CARBON") Output(""" { CGrafPtr itself_color = (CGrafPtr)self->ob_itself; @@ -209,6 +210,7 @@ class MyGRObjectDefinition(GlobalObjectDefinition): if ( strcmp(name, "_id") == 0 ) return Py_BuildValue("l", (long)self->ob_itself); }""") + Output("#endif") class MyBMObjectDefinition(GlobalObjectDefinition): def outputCheckNewArg(self): @@ -259,6 +261,7 @@ class QDGlobalsAccessObjectDefinition(ObjectDefinition): pass def outputGetattrHook(self): + Output("#ifndef TARGET_API_MAC_CARBON") Output(""" if ( strcmp(name, "arrow") == 0 ) return PyString_FromStringAndSize((char *)&qd.arrow, sizeof(qd.arrow)); @@ -279,6 +282,7 @@ class QDGlobalsAccessObjectDefinition(ObjectDefinition): if ( strcmp(name, "randSeed") == 0 ) return Py_BuildValue("l", &qd.randSeed); """) + Output("#endif") # Create the generator groups and link them module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff, variablestuff) diff --git a/Mac/Modules/res/Resmodule.c b/Mac/Modules/res/Resmodule.c index d0495e5..6db002f 100644 --- a/Mac/Modules/res/Resmodule.c +++ b/Mac/Modules/res/Resmodule.c @@ -311,6 +311,8 @@ static PyObject *ResObj_GetMaxResourceSize(_self, _args) return _res; } +#ifndef TARGET_API_MAC_CARBON + static PyObject *ResObj_RsrcMapEntry(_self, _args) ResourceObject *_self; PyObject *_args; @@ -328,6 +330,7 @@ static PyObject *ResObj_RsrcMapEntry(_self, _args) _rv); return _res; } +#endif static PyObject *ResObj_SetResAttrs(_self, _args) ResourceObject *_self; @@ -515,8 +518,11 @@ static PyMethodDef ResObj_methods[] = { "() -> (long _rv)"}, {"GetMaxResourceSize", (PyCFunction)ResObj_GetMaxResourceSize, 1, "() -> (long _rv)"}, + +#ifndef TARGET_API_MAC_CARBON {"RsrcMapEntry", (PyCFunction)ResObj_RsrcMapEntry, 1, "() -> (long _rv)"}, +#endif {"SetResAttrs", (PyCFunction)ResObj_SetResAttrs, 1, "(short attrs) -> None"}, {"ChangedResource", (PyCFunction)ResObj_ChangedResource, 1, @@ -622,6 +628,8 @@ PyTypeObject Resource_Type = { /* -------------------- End object type Resource -------------------- */ +#ifndef TARGET_API_MAC_CARBON + static PyObject *Res_InitResources(_self, _args) PyObject *_self; PyObject *_args; @@ -639,6 +647,9 @@ static PyObject *Res_InitResources(_self, _args) _rv); return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *Res_RsrcZoneInit(_self, _args) PyObject *_self; @@ -656,6 +667,7 @@ static PyObject *Res_RsrcZoneInit(_self, _args) _res = Py_None; return _res; } +#endif static PyObject *Res_CloseResFile(_self, _args) PyObject *_self; @@ -712,6 +724,8 @@ static PyObject *Res_CurResFile(_self, _args) return _res; } +#ifndef TARGET_API_MAC_CARBON + static PyObject *Res_CreateResFile(_self, _args) PyObject *_self; PyObject *_args; @@ -730,6 +744,9 @@ static PyObject *Res_CreateResFile(_self, _args) _res = Py_None; return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *Res_OpenResFile(_self, _args) PyObject *_self; @@ -750,6 +767,7 @@ static PyObject *Res_OpenResFile(_self, _args) _rv); return _res; } +#endif static PyObject *Res_UseResFile(_self, _args) PyObject *_self; @@ -1191,6 +1209,8 @@ static PyObject *Res_OpenRFPerm(_self, _args) return _res; } +#ifndef TARGET_API_MAC_CARBON + static PyObject *Res_RGetResource(_self, _args) PyObject *_self; PyObject *_args; @@ -1213,6 +1233,7 @@ static PyObject *Res_RGetResource(_self, _args) ResObj_New, _rv); return _res; } +#endif static PyObject *Res_HOpenResFile(_self, _args) PyObject *_self; @@ -1371,20 +1392,32 @@ static PyObject *Res_Handle(_self, _args) } static PyMethodDef Res_methods[] = { + +#ifndef TARGET_API_MAC_CARBON {"InitResources", (PyCFunction)Res_InitResources, 1, "() -> (short _rv)"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"RsrcZoneInit", (PyCFunction)Res_RsrcZoneInit, 1, "() -> None"}, +#endif {"CloseResFile", (PyCFunction)Res_CloseResFile, 1, "(short refNum) -> None"}, {"ResError", (PyCFunction)Res_ResError, 1, "() -> (OSErr _rv)"}, {"CurResFile", (PyCFunction)Res_CurResFile, 1, "() -> (short _rv)"}, + +#ifndef TARGET_API_MAC_CARBON {"CreateResFile", (PyCFunction)Res_CreateResFile, 1, "(Str255 fileName) -> None"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"OpenResFile", (PyCFunction)Res_OpenResFile, 1, "(Str255 fileName) -> (short _rv)"}, +#endif {"UseResFile", (PyCFunction)Res_UseResFile, 1, "(short refNum) -> None"}, {"CountTypes", (PyCFunction)Res_CountTypes, 1, @@ -1427,8 +1460,11 @@ static PyMethodDef Res_methods[] = { "(short refNum, short attrs) -> None"}, {"OpenRFPerm", (PyCFunction)Res_OpenRFPerm, 1, "(Str255 fileName, short vRefNum, SignedByte permission) -> (short _rv)"}, + +#ifndef TARGET_API_MAC_CARBON {"RGetResource", (PyCFunction)Res_RGetResource, 1, "(ResType theType, short theID) -> (Handle _rv)"}, +#endif {"HOpenResFile", (PyCFunction)Res_HOpenResFile, 1, "(short vRefNum, long dirID, Str255 fileName, SignedByte permission) -> (short _rv)"}, {"HCreateResFile", (PyCFunction)Res_HCreateResFile, 1, diff --git a/Mac/Modules/res/resscan.py b/Mac/Modules/res/resscan.py index efb538c..18499e3 100644 --- a/Mac/Modules/res/resscan.py +++ b/Mac/Modules/res/resscan.py @@ -47,6 +47,17 @@ class ResourcesScanner(Scanner): ## "SizeResource", # GetResourceSizeOnDisk ## "MaxSizeRsrc", # GetMaxResourceSize ] + + def makegreylist(self): + return [ + ('#ifndef TARGET_API_MAC_CARBON', [ + 'RGetResource', + 'OpenResFile', + 'CreateResFile', + 'RsrcZoneInit', + 'InitResources', + 'RsrcMapEntry', + ])] def makerepairinstructions(self): return [ diff --git a/Mac/Modules/win/Winmodule.c b/Mac/Modules/win/Winmodule.c index 9542447..a03d493 100644 --- a/Mac/Modules/win/Winmodule.c +++ b/Mac/Modules/win/Winmodule.c @@ -78,10 +78,12 @@ WinObj_Convert(v, p_itself) PyObject *v; WindowPtr *p_itself; { +#ifndef TARGET_API_MAC_CARBON if (DlgObj_Check(v)) { *p_itself = ((WindowObject *)v)->ob_itself; return 1; } +#endif if (v == Py_None) { *p_itself = NULL; return 1; } if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; } @@ -102,19 +104,6 @@ static void WinObj_dealloc(self) PyMem_DEL(self); } -static PyObject *WinObj_MacCloseWindow(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - MacCloseWindow(_self->ob_itself); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - static PyObject *WinObj_GetWindowOwnerCount(_self, _args) WindowObject *_self; PyObject *_args; @@ -181,6 +170,8 @@ static PyObject *WinObj_GetWindowAttributes(_self, _args) return _res; } +#ifndef TARGET_API_MAC_CARBON + static PyObject *WinObj_SetWinColor(_self, _args) WindowObject *_self; PyObject *_args; @@ -196,6 +187,7 @@ static PyObject *WinObj_SetWinColor(_self, _args) _res = Py_None; return _res; } +#endif static PyObject *WinObj_SetWindowContentColor(_self, _args) WindowObject *_self; @@ -280,6 +272,8 @@ static PyObject *WinObj_ClipAbove(_self, _args) return _res; } +#ifndef TARGET_API_MAC_CARBON + static PyObject *WinObj_SaveOld(_self, _args) WindowObject *_self; PyObject *_args; @@ -292,6 +286,9 @@ static PyObject *WinObj_SaveOld(_self, _args) _res = Py_None; return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *WinObj_DrawNew(_self, _args) WindowObject *_self; @@ -308,6 +305,7 @@ static PyObject *WinObj_DrawNew(_self, _args) _res = Py_None; return _res; } +#endif static PyObject *WinObj_PaintOne(_self, _args) WindowObject *_self; @@ -713,7 +711,7 @@ static PyObject *WinObj_GetWindowProxyFSSpec(_self, _args) &outFile); if (_err != noErr) return PyMac_Error(_err); _res = Py_BuildValue("O&", - PyMac_BuildFSSpec, &outFile); + PyMac_BuildFSSpec, outFile); return _res; } @@ -1319,6 +1317,8 @@ static PyObject *WinObj_TrackGoAway(_self, _args) return _res; } +#ifndef TARGET_API_MAC_CARBON + static PyObject *WinObj_GetAuxWin(_self, _args) WindowObject *_self; PyObject *_args; @@ -1335,6 +1335,7 @@ static PyObject *WinObj_GetAuxWin(_self, _args) ResObj_New, awHndl); return _res; } +#endif static PyObject *WinObj_GetWindowPort(_self, _args) WindowObject *_self; @@ -1435,6 +1436,8 @@ static PyObject *WinObj_GetWindowGoAwayFlag(_self, _args) return _res; } +#ifndef TARGET_API_MAC_CARBON + static PyObject *WinObj_GetWindowZoomFlag(_self, _args) WindowObject *_self; PyObject *_args; @@ -1448,6 +1451,9 @@ static PyObject *WinObj_GetWindowZoomFlag(_self, _args) _rv); return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *WinObj_GetWindowStructureRgn(_self, _args) WindowObject *_self; @@ -1464,6 +1470,9 @@ static PyObject *WinObj_GetWindowStructureRgn(_self, _args) _res = Py_None; return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *WinObj_GetWindowContentRgn(_self, _args) WindowObject *_self; @@ -1480,6 +1489,9 @@ static PyObject *WinObj_GetWindowContentRgn(_self, _args) _res = Py_None; return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *WinObj_GetWindowUpdateRgn(_self, _args) WindowObject *_self; @@ -1496,6 +1508,9 @@ static PyObject *WinObj_GetWindowUpdateRgn(_self, _args) _res = Py_None; return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *WinObj_GetWindowTitleWidth(_self, _args) WindowObject *_self; @@ -1510,6 +1525,7 @@ static PyObject *WinObj_GetWindowTitleWidth(_self, _args) _rv); return _res; } +#endif static PyObject *WinObj_GetNextWindow(_self, _args) WindowObject *_self; @@ -1587,35 +1603,7 @@ static PyObject *WinObj_SetWindowUserState(_self, _args) return _res; } -static PyObject *WinObj_GetWindowDataHandle(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle _rv; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetWindowDataHandle(_self->ob_itself); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *WinObj_SetWindowDataHandle(_self, _args) - WindowObject *_self; - PyObject *_args; -{ - PyObject *_res = NULL; - Handle data; - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &data)) - return NULL; - SetWindowDataHandle(_self->ob_itself, - data); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} +#ifndef TARGET_API_MAC_CARBON static PyObject *WinObj_CloseWindow(_self, _args) WindowObject *_self; @@ -1629,6 +1617,7 @@ static PyObject *WinObj_CloseWindow(_self, _args) _res = Py_None; return _res; } +#endif static PyObject *WinObj_MoveWindow(_self, _args) WindowObject *_self; @@ -1666,8 +1655,6 @@ static PyObject *WinObj_ShowWindow(_self, _args) } static PyMethodDef WinObj_methods[] = { - {"MacCloseWindow", (PyCFunction)WinObj_MacCloseWindow, 1, - "() -> None"}, {"GetWindowOwnerCount", (PyCFunction)WinObj_GetWindowOwnerCount, 1, "() -> (UInt32 outCount)"}, {"CloneWindow", (PyCFunction)WinObj_CloneWindow, 1, @@ -1676,8 +1663,11 @@ static PyMethodDef WinObj_methods[] = { "() -> (WindowClass outClass)"}, {"GetWindowAttributes", (PyCFunction)WinObj_GetWindowAttributes, 1, "() -> (WindowAttributes outAttributes)"}, + +#ifndef TARGET_API_MAC_CARBON {"SetWinColor", (PyCFunction)WinObj_SetWinColor, 1, "(WCTabHandle newColorTable) -> None"}, +#endif {"SetWindowContentColor", (PyCFunction)WinObj_SetWindowContentColor, 1, "() -> (RGBColor color)"}, {"GetWindowContentColor", (PyCFunction)WinObj_GetWindowContentColor, 1, @@ -1688,10 +1678,16 @@ static PyMethodDef WinObj_methods[] = { "(PixPatHandle pixPat) -> None"}, {"ClipAbove", (PyCFunction)WinObj_ClipAbove, 1, "() -> None"}, + +#ifndef TARGET_API_MAC_CARBON {"SaveOld", (PyCFunction)WinObj_SaveOld, 1, "() -> None"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"DrawNew", (PyCFunction)WinObj_DrawNew, 1, "(Boolean update) -> None"}, +#endif {"PaintOne", (PyCFunction)WinObj_PaintOne, 1, "(RgnHandle clobberedRgn) -> None"}, {"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1, @@ -1810,8 +1806,11 @@ static PyMethodDef WinObj_methods[] = { "(Point thePt, short partCode) -> (Boolean _rv)"}, {"TrackGoAway", (PyCFunction)WinObj_TrackGoAway, 1, "(Point thePt) -> (Boolean _rv)"}, + +#ifndef TARGET_API_MAC_CARBON {"GetAuxWin", (PyCFunction)WinObj_GetAuxWin, 1, "() -> (Boolean _rv, AuxWinHandle awHndl)"}, +#endif {"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1, "() -> (CGrafPtr _rv)"}, {"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1, @@ -1826,16 +1825,31 @@ static PyMethodDef WinObj_methods[] = { "() -> (Boolean _rv)"}, {"GetWindowGoAwayFlag", (PyCFunction)WinObj_GetWindowGoAwayFlag, 1, "() -> (Boolean _rv)"}, + +#ifndef TARGET_API_MAC_CARBON {"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1, "() -> (Boolean _rv)"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"GetWindowStructureRgn", (PyCFunction)WinObj_GetWindowStructureRgn, 1, "(RgnHandle r) -> None"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"GetWindowContentRgn", (PyCFunction)WinObj_GetWindowContentRgn, 1, "(RgnHandle r) -> None"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"GetWindowUpdateRgn", (PyCFunction)WinObj_GetWindowUpdateRgn, 1, "(RgnHandle r) -> None"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1, "() -> (short _rv)"}, +#endif {"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1, "() -> (WindowPtr _rv)"}, {"GetWindowStandardState", (PyCFunction)WinObj_GetWindowStandardState, 1, @@ -1846,12 +1860,11 @@ static PyMethodDef WinObj_methods[] = { "(Rect r) -> None"}, {"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1, "(Rect r) -> None"}, - {"GetWindowDataHandle", (PyCFunction)WinObj_GetWindowDataHandle, 1, - "() -> (Handle _rv)"}, - {"SetWindowDataHandle", (PyCFunction)WinObj_SetWindowDataHandle, 1, - "(Handle data) -> None"}, + +#ifndef TARGET_API_MAC_CARBON {"CloseWindow", (PyCFunction)WinObj_CloseWindow, 1, "() -> None"}, +#endif {"MoveWindow", (PyCFunction)WinObj_MoveWindow, 1, "(short hGlobal, short vGlobal, Boolean front) -> None"}, {"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1, @@ -2110,6 +2123,8 @@ static PyObject *Win_FrontNonFloatingWindow(_self, _args) return _res; } +#ifndef TARGET_API_MAC_CARBON + static PyObject *Win_SetDeskCPat(_self, _args) PyObject *_self; PyObject *_args; @@ -2124,6 +2139,7 @@ static PyObject *Win_SetDeskCPat(_self, _args) _res = Py_None; return _res; } +#endif static PyObject *Win_CheckUpdate(_self, _args) PyObject *_self; @@ -2174,6 +2190,8 @@ static PyObject *Win_FrontWindow(_self, _args) return _res; } +#ifndef TARGET_API_MAC_CARBON + static PyObject *Win_InitWindows(_self, _args) PyObject *_self; PyObject *_args; @@ -2186,6 +2204,9 @@ static PyObject *Win_InitWindows(_self, _args) _res = Py_None; return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *Win_GetWMgrPort(_self, _args) PyObject *_self; @@ -2200,6 +2221,9 @@ static PyObject *Win_GetWMgrPort(_self, _args) GrafObj_New, wPort); return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *Win_GetCWMgrPort(_self, _args) PyObject *_self; @@ -2214,6 +2238,9 @@ static PyObject *Win_GetCWMgrPort(_self, _args) GrafObj_New, wMgrCPort); return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON_NOTYET static PyObject *Win_IsValidWindowPtr(_self, _args) PyObject *_self; @@ -2230,6 +2257,9 @@ static PyObject *Win_IsValidWindowPtr(_self, _args) _rv); return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *Win_InitFloatingWindows(_self, _args) PyObject *_self; @@ -2245,6 +2275,9 @@ static PyObject *Win_InitFloatingWindows(_self, _args) _res = Py_None; return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *Win_InvalRect(_self, _args) PyObject *_self; @@ -2260,6 +2293,9 @@ static PyObject *Win_InvalRect(_self, _args) _res = Py_None; return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *Win_InvalRgn(_self, _args) PyObject *_self; @@ -2275,6 +2311,9 @@ static PyObject *Win_InvalRgn(_self, _args) _res = Py_None; return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *Win_ValidRect(_self, _args) PyObject *_self; @@ -2290,6 +2329,9 @@ static PyObject *Win_ValidRect(_self, _args) _res = Py_None; return _res; } +#endif + +#ifndef TARGET_API_MAC_CARBON static PyObject *Win_ValidRgn(_self, _args) PyObject *_self; @@ -2305,6 +2347,7 @@ static PyObject *Win_ValidRgn(_self, _args) _res = Py_None; return _res; } +#endif static PyObject *Win_CollapseAllWindows(_self, _args) PyObject *_self; @@ -2410,32 +2453,62 @@ static PyMethodDef Win_methods[] = { "() -> (Boolean _rv)"}, {"FrontNonFloatingWindow", (PyCFunction)Win_FrontNonFloatingWindow, 1, "() -> (WindowPtr _rv)"}, + +#ifndef TARGET_API_MAC_CARBON {"SetDeskCPat", (PyCFunction)Win_SetDeskCPat, 1, "(PixPatHandle deskPixPat) -> None"}, +#endif {"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1, "() -> (Boolean _rv, EventRecord theEvent)"}, {"MacFindWindow", (PyCFunction)Win_MacFindWindow, 1, "(Point thePoint) -> (short _rv, WindowPtr window)"}, {"FrontWindow", (PyCFunction)Win_FrontWindow, 1, "() -> (WindowPtr _rv)"}, + +#ifndef TARGET_API_MAC_CARBON {"InitWindows", (PyCFunction)Win_InitWindows, 1, "() -> None"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1, "() -> (GrafPtr wPort)"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1, "() -> (CGrafPtr wMgrCPort)"}, +#endif + +#ifndef TARGET_API_MAC_CARBON_NOTYET {"IsValidWindowPtr", (PyCFunction)Win_IsValidWindowPtr, 1, "(GrafPtr grafPort) -> (Boolean _rv)"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"InitFloatingWindows", (PyCFunction)Win_InitFloatingWindows, 1, "() -> None"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"InvalRect", (PyCFunction)Win_InvalRect, 1, "(Rect badRect) -> None"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"InvalRgn", (PyCFunction)Win_InvalRgn, 1, "(RgnHandle badRgn) -> None"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"ValidRect", (PyCFunction)Win_ValidRect, 1, "(Rect goodRect) -> None"}, +#endif + +#ifndef TARGET_API_MAC_CARBON {"ValidRgn", (PyCFunction)Win_ValidRgn, 1, "(RgnHandle goodRgn) -> None"}, +#endif {"CollapseAllWindows", (PyCFunction)Win_CollapseAllWindows, 1, "(Boolean collapse) -> None"}, {"PinRect", (PyCFunction)Win_PinRect, 1, diff --git a/Mac/Modules/win/winedit.py b/Mac/Modules/win/winedit.py index 6a81b9b..bf43a43 100644 --- a/Mac/Modules/win/winedit.py +++ b/Mac/Modules/win/winedit.py @@ -40,29 +40,34 @@ methods.append(f) f = Method(Boolean, 'GetWindowZoomFlag', (WindowRef, 'theWindow', InMode), + condition='#ifndef TARGET_API_MAC_CARBON' ) methods.append(f) f = Method(void, 'GetWindowStructureRgn', (WindowRef, 'theWindow', InMode), (RgnHandle, 'r', InMode), + condition='#ifndef TARGET_API_MAC_CARBON' ) methods.append(f) f = Method(void, 'GetWindowContentRgn', (WindowRef, 'theWindow', InMode), (RgnHandle, 'r', InMode), + condition='#ifndef TARGET_API_MAC_CARBON' ) methods.append(f) f = Method(void, 'GetWindowUpdateRgn', (WindowRef, 'theWindow', InMode), (RgnHandle, 'r', InMode), + condition='#ifndef TARGET_API_MAC_CARBON' ) methods.append(f) f = Method(short, 'GetWindowTitleWidth', (WindowRef, 'theWindow', InMode), + condition='#ifndef TARGET_API_MAC_CARBON' ) methods.append(f) @@ -96,20 +101,11 @@ f = Method(void, 'SetWindowUserState', ) methods.append(f) -f = Method(Handle, 'GetWindowDataHandle', - (WindowRef, 'theWindow', InMode), -) -methods.append(f) -f = Method(void, 'SetWindowDataHandle', - (WindowRef, 'theWindow', InMode), - (Handle, 'data', InMode), -) -methods.append(f) - # These have Mac prefixed to their name in the 3.1 universal headers, # so we add the old/real names by hand. f = Method(void, 'CloseWindow', (WindowPtr, 'theWindow', InMode), + condition='#ifndef TARGET_API_MAC_CARBON' ) methods.append(f) diff --git a/Mac/Modules/win/winscan.py b/Mac/Modules/win/winscan.py index 22f0d1a..b0f0fb3 100644 --- a/Mac/Modules/win/winscan.py +++ b/Mac/Modules/win/winscan.py @@ -41,10 +41,33 @@ class MyScanner(Scanner): 'GetWindowProperty', 'GetWindowPropertySize', 'RemoveWindowProperty', + 'MacCloseWindow', # Constants with funny definitions 'kMouseUpOutOfSlop', ] - + + def makegreylist(self): + return [ + ('#ifndef TARGET_API_MAC_CARBON', [ + 'GetAuxWin', + 'GetWindowDataHandle', + 'SaveOld', + 'DrawNew', + 'SetWinColor', + 'SetDeskCPat', + 'InitWindows', + 'InitFloatingWindows', + 'GetWMgrPort', + 'GetCWMgrPort', + 'ValidRgn', # Use versions with Window in their name + 'ValidRect', + 'InvalRgn', + 'InvalRect', + ]), + ('#ifndef TARGET_API_MAC_CARBON_NOTYET', [ + 'IsValidWindowPtr', + ])] + def makeblacklisttypes(self): return [ 'ProcPtr', diff --git a/Mac/Modules/win/winsupport.py b/Mac/Modules/win/winsupport.py index a6104d8..cc1c750 100644 --- a/Mac/Modules/win/winsupport.py +++ b/Mac/Modules/win/winsupport.py @@ -87,10 +87,12 @@ class MyObjectDefinition(GlobalObjectDefinition): GlobalObjectDefinition.outputInitStructMembers(self) Output("SetWRefCon(itself, (long)it);") def outputCheckConvertArg(self): + Output("#ifndef TARGET_API_MAC_CARBON") OutLbrace("if (DlgObj_Check(v))") Output("*p_itself = ((WindowObject *)v)->ob_itself;") 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; } -- cgit v0.12