diff --git a/Mac/Lib/toolbox/AEObjects.py b/Mac/Lib/toolbox/AEObjects.py index 3e1db671d2e..b3ff7d448c1 100644 --- a/Mac/Lib/toolbox/AEObjects.py +++ b/Mac/Lib/toolbox/AEObjects.py @@ -1,4 +1,4 @@ -# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:AEObjects.h' +# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:AEObjects.h' kAEAND = 'AND ' kAEOR = 'OR ' diff --git a/Mac/Lib/toolbox/AERegistry.py b/Mac/Lib/toolbox/AERegistry.py index 716c5f837f9..988a8c8e27c 100644 --- a/Mac/Lib/toolbox/AERegistry.py +++ b/Mac/Lib/toolbox/AERegistry.py @@ -1,4 +1,4 @@ -# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:AERegistry.h' +# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:AERegistry.h' cAEList = 'list' cApplication = 'capp' diff --git a/Mac/Lib/toolbox/AppleEvents.py b/Mac/Lib/toolbox/AppleEvents.py index e4668bcc7a7..55b5f51eff0 100644 --- a/Mac/Lib/toolbox/AppleEvents.py +++ b/Mac/Lib/toolbox/AppleEvents.py @@ -1,4 +1,4 @@ -# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:AppleEvents.h' +# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:AppleEvents.h' typeBoolean = 'bool' typeChar = 'TEXT' diff --git a/Mac/Lib/toolbox/Dialogs.py b/Mac/Lib/toolbox/Dialogs.py index c08dac40e5c..ba9ba69cc47 100644 --- a/Mac/Lib/toolbox/Dialogs.py +++ b/Mac/Lib/toolbox/Dialogs.py @@ -1,4 +1,4 @@ -# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:Dialogs.h' +# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Dialogs.h' ctrlItem = 4 btnCtrl = 0 diff --git a/Mac/Lib/toolbox/Menus.py b/Mac/Lib/toolbox/Menus.py index be1e8104bbd..dede690457a 100644 --- a/Mac/Lib/toolbox/Menus.py +++ b/Mac/Lib/toolbox/Menus.py @@ -1,4 +1,4 @@ -# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:Menus.h' +# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Menus.h' noMark = 0 mDrawMsg = 0 diff --git a/Mac/Modules/ae/AEmodule.c b/Mac/Modules/ae/AEmodule.c index 2d759770d6b..e12c6c87abc 100644 --- a/Mac/Modules/ae/AEmodule.c +++ b/Mac/Modules/ae/AEmodule.c @@ -14,11 +14,14 @@ #include extern PyObject *ResObj_New(Handle); -extern PyObject *ResObj_OptNew(Handle); extern int ResObj_Convert(PyObject *, Handle *); +extern PyObject *OptResObj_New(Handle); +extern int OptResObj_Convert(PyObject *, Handle *); extern PyObject *WinObj_New(WindowPtr); extern int WinObj_Convert(PyObject *, WindowPtr *); +extern PyTypeObject Window_Type; +#define WinObj_Check(x) ((x)->ob_type == &Window_Type) extern PyObject *DlgObj_New(DialogPtr); extern int DlgObj_Convert(PyObject *, DialogPtr *); @@ -31,6 +34,12 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *); extern PyObject *CtlObj_New(ControlHandle); extern int CtlObj_Convert(PyObject *, ControlHandle *); +extern PyObject *GrafObj_New(GrafPtr); +extern int GrafObj_Convert(PyObject *, GrafPtr *); + +extern PyObject *BMObj_New(BitMapPtr); +extern int BMObj_Convert(PyObject *, BitMapPtr *); + extern PyObject *WinObj_WhichWindow(WindowPtr); #include diff --git a/Mac/Modules/ae/aegen.py b/Mac/Modules/ae/aegen.py index 5d3a6e88793..896eb7880a7 100644 --- a/Mac/Modules/ae/aegen.py +++ b/Mac/Modules/ae/aegen.py @@ -1,4 +1,4 @@ -# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:AppleEvents.h' +# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:AppleEvents.h' f = AEFunction(OSErr, 'AECreateDesc', (DescType, 'typeCode', InMode), diff --git a/Mac/Modules/cm/Cmmodule.c b/Mac/Modules/cm/Cmmodule.c index 2f44307ff2b..fd8b331029b 100644 --- a/Mac/Modules/cm/Cmmodule.c +++ b/Mac/Modules/cm/Cmmodule.c @@ -14,8 +14,9 @@ #include extern PyObject *ResObj_New(Handle); -extern PyObject *ResObj_OptNew(Handle); extern int ResObj_Convert(PyObject *, Handle *); +extern PyObject *OptResObj_New(Handle); +extern int OptResObj_Convert(PyObject *, Handle *); extern PyObject *WinObj_New(WindowPtr); extern int WinObj_Convert(PyObject *, WindowPtr *); diff --git a/Mac/Modules/ctl/Ctlmodule.c b/Mac/Modules/ctl/Ctlmodule.c index 3ea6b91a229..2669113724f 100644 --- a/Mac/Modules/ctl/Ctlmodule.c +++ b/Mac/Modules/ctl/Ctlmodule.c @@ -14,11 +14,14 @@ #include extern PyObject *ResObj_New(Handle); -extern PyObject *ResObj_OptNew(Handle); extern int ResObj_Convert(PyObject *, Handle *); +extern PyObject *OptResObj_New(Handle); +extern int OptResObj_Convert(PyObject *, Handle *); extern PyObject *WinObj_New(WindowPtr); extern int WinObj_Convert(PyObject *, WindowPtr *); +extern PyTypeObject Window_Type; +#define WinObj_Check(x) ((x)->ob_type == &Window_Type) extern PyObject *DlgObj_New(DialogPtr); extern int DlgObj_Convert(PyObject *, DialogPtr *); @@ -31,6 +34,12 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *); extern PyObject *CtlObj_New(ControlHandle); extern int CtlObj_Convert(PyObject *, ControlHandle *); +extern PyObject *GrafObj_New(GrafPtr); +extern int GrafObj_Convert(PyObject *, GrafPtr *); + +extern PyObject *BMObj_New(BitMapPtr); +extern int BMObj_Convert(PyObject *, BitMapPtr *); + extern PyObject *WinObj_WhichWindow(WindowPtr); #include diff --git a/Mac/Modules/dlg/Dlgmodule.c b/Mac/Modules/dlg/Dlgmodule.c index 49f65538ca4..93de3e950a5 100644 --- a/Mac/Modules/dlg/Dlgmodule.c +++ b/Mac/Modules/dlg/Dlgmodule.c @@ -14,11 +14,14 @@ #include extern PyObject *ResObj_New(Handle); -extern PyObject *ResObj_OptNew(Handle); extern int ResObj_Convert(PyObject *, Handle *); +extern PyObject *OptResObj_New(Handle); +extern int OptResObj_Convert(PyObject *, Handle *); extern PyObject *WinObj_New(WindowPtr); extern int WinObj_Convert(PyObject *, WindowPtr *); +extern PyTypeObject Window_Type; +#define WinObj_Check(x) ((x)->ob_type == &Window_Type) extern PyObject *DlgObj_New(DialogPtr); extern int DlgObj_Convert(PyObject *, DialogPtr *); @@ -31,6 +34,12 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *); extern PyObject *CtlObj_New(ControlHandle); extern int CtlObj_Convert(PyObject *, ControlHandle *); +extern PyObject *GrafObj_New(GrafPtr); +extern int GrafObj_Convert(PyObject *, GrafPtr *); + +extern PyObject *BMObj_New(BitMapPtr); +extern int BMObj_Convert(PyObject *, BitMapPtr *); + extern PyObject *WinObj_WhichWindow(WindowPtr); #include @@ -192,7 +201,7 @@ static PyObject *DlgObj_GetDialogItem(_self, _args) &box); _res = Py_BuildValue("hO&O&", itemType, - ResObj_OptNew, item, + OptResObj_New, item, PyMac_BuildRect, &box); return _res; } diff --git a/Mac/Modules/dlg/dlggen.py b/Mac/Modules/dlg/dlggen.py index 431952085c4..3c1e66969dd 100644 --- a/Mac/Modules/dlg/dlggen.py +++ b/Mac/Modules/dlg/dlggen.py @@ -1,4 +1,4 @@ -# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:Dialogs.h' +# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Dialogs.h' f = Function(DialogRef, 'NewDialog', (NullStorage, 'wStorage', InMode), diff --git a/Mac/Modules/dlg/dlgsupport.py b/Mac/Modules/dlg/dlgsupport.py index 0b5f08264f9..cd255ef446b 100644 --- a/Mac/Modules/dlg/dlgsupport.py +++ b/Mac/Modules/dlg/dlgsupport.py @@ -13,11 +13,9 @@ DialogPtr = OpaqueByValueType("DialogPtr", "DlgObj") DialogRef = DialogPtr -# XXXX There must be a more elegant way to do this. An OptHandle is -# either a handle or None (in case NULL is passed in). This is needed -# for GetDialogItem(). -OptHandle = OpaqueByValueType("Handle", "ResObj") -OptHandle.new = "ResObj_OptNew" +# An OptHandle is either a handle or None (in case NULL is passed in). +# This is needed for GetDialogItem(). +OptHandle = OpaqueByValueType("Handle", "OptResObj") ModalFilterProcPtr = InputOnlyType("PyObject*", "O") ModalFilterProcPtr.passInput = lambda name: "NewModalFilterProc(Dlg_PassFilterProc(%s))" % name diff --git a/Mac/Modules/evt/Evtmodule.c b/Mac/Modules/evt/Evtmodule.c index 59858fa3334..9078e9f5f97 100644 --- a/Mac/Modules/evt/Evtmodule.c +++ b/Mac/Modules/evt/Evtmodule.c @@ -14,11 +14,14 @@ #include extern PyObject *ResObj_New(Handle); -extern PyObject *ResObj_OptNew(Handle); extern int ResObj_Convert(PyObject *, Handle *); +extern PyObject *OptResObj_New(Handle); +extern int OptResObj_Convert(PyObject *, Handle *); extern PyObject *WinObj_New(WindowPtr); extern int WinObj_Convert(PyObject *, WindowPtr *); +extern PyTypeObject Window_Type; +#define WinObj_Check(x) ((x)->ob_type == &Window_Type) extern PyObject *DlgObj_New(DialogPtr); extern int DlgObj_Convert(PyObject *, DialogPtr *); @@ -31,6 +34,12 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *); extern PyObject *CtlObj_New(ControlHandle); extern int CtlObj_Convert(PyObject *, ControlHandle *); +extern PyObject *GrafObj_New(GrafPtr); +extern int GrafObj_Convert(PyObject *, GrafPtr *); + +extern PyObject *BMObj_New(BitMapPtr); +extern int BMObj_Convert(PyObject *, BitMapPtr *); + extern PyObject *WinObj_WhichWindow(WindowPtr); #include diff --git a/Mac/Modules/list/Listmodule.c b/Mac/Modules/list/Listmodule.c index 747b477352a..17f20b04f0a 100644 --- a/Mac/Modules/list/Listmodule.c +++ b/Mac/Modules/list/Listmodule.c @@ -14,11 +14,14 @@ #include extern PyObject *ResObj_New(Handle); -extern PyObject *ResObj_OptNew(Handle); extern int ResObj_Convert(PyObject *, Handle *); +extern PyObject *OptResObj_New(Handle); +extern int OptResObj_Convert(PyObject *, Handle *); extern PyObject *WinObj_New(WindowPtr); extern int WinObj_Convert(PyObject *, WindowPtr *); +extern PyTypeObject Window_Type; +#define WinObj_Check(x) ((x)->ob_type == &Window_Type) extern PyObject *DlgObj_New(DialogPtr); extern int DlgObj_Convert(PyObject *, DialogPtr *); @@ -31,6 +34,12 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *); extern PyObject *CtlObj_New(ControlHandle); extern int CtlObj_Convert(PyObject *, ControlHandle *); +extern PyObject *GrafObj_New(GrafPtr); +extern int GrafObj_Convert(PyObject *, GrafPtr *); + +extern PyObject *BMObj_New(BitMapPtr); +extern int BMObj_Convert(PyObject *, BitMapPtr *); + extern PyObject *WinObj_WhichWindow(WindowPtr); #include diff --git a/Mac/Modules/menu/Menumodule.c b/Mac/Modules/menu/Menumodule.c index 6c855cd4563..07e1b8803ea 100644 --- a/Mac/Modules/menu/Menumodule.c +++ b/Mac/Modules/menu/Menumodule.c @@ -14,11 +14,14 @@ #include extern PyObject *ResObj_New(Handle); -extern PyObject *ResObj_OptNew(Handle); extern int ResObj_Convert(PyObject *, Handle *); +extern PyObject *OptResObj_New(Handle); +extern int OptResObj_Convert(PyObject *, Handle *); extern PyObject *WinObj_New(WindowPtr); extern int WinObj_Convert(PyObject *, WindowPtr *); +extern PyTypeObject Window_Type; +#define WinObj_Check(x) ((x)->ob_type == &Window_Type) extern PyObject *DlgObj_New(DialogPtr); extern int DlgObj_Convert(PyObject *, DialogPtr *); @@ -31,6 +34,12 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *); extern PyObject *CtlObj_New(ControlHandle); extern int CtlObj_Convert(PyObject *, ControlHandle *); +extern PyObject *GrafObj_New(GrafPtr); +extern int GrafObj_Convert(PyObject *, GrafPtr *); + +extern PyObject *BMObj_New(BitMapPtr); +extern int BMObj_Convert(PyObject *, BitMapPtr *); + extern PyObject *WinObj_WhichWindow(WindowPtr); #include /* Defines OpenDeskAcc in universal headers */ diff --git a/Mac/Modules/menu/menugen.py b/Mac/Modules/menu/menugen.py index 30e43e2e923..7e27d5c52c2 100644 --- a/Mac/Modules/menu/menugen.py +++ b/Mac/Modules/menu/menugen.py @@ -1,4 +1,4 @@ -# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:Menus.h' +# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Menus.h' f = Function(short, 'GetMBarHeight', ) diff --git a/Mac/Modules/qd/Qdmodule.c b/Mac/Modules/qd/Qdmodule.c index 8b03fc2b7e8..b076aa48e84 100644 --- a/Mac/Modules/qd/Qdmodule.c +++ b/Mac/Modules/qd/Qdmodule.c @@ -14,8 +14,9 @@ #include extern PyObject *ResObj_New(Handle); -extern PyObject *ResObj_OptNew(Handle); extern int ResObj_Convert(PyObject *, Handle *); +extern PyObject *OptResObj_New(Handle); +extern int OptResObj_Convert(PyObject *, Handle *); extern PyObject *WinObj_New(WindowPtr); extern int WinObj_Convert(PyObject *, WindowPtr *); @@ -130,8 +131,15 @@ static PyObject *GrafObj_getattr(self, name) { if ( strcmp(name, "device") == 0 ) return PyInt_FromLong((long)self->ob_itself->device); - if ( strcmp(name, "portBits") == 0 ) - return BMObj_New(&self->ob_itself->portBits); + if ( strcmp(name, "portBits") == 0 ) { + CGrafPtr itself_color = (CGrafPtr)self->ob_itself; + + if ( (itself_color->portVersion&0xc000) == 0xc000 ) + /* XXXX Do we need HLock() stuff here?? */ + return BMObj_New((BitMapPtr)*itself_color->portPixMap); + else + return BMObj_New(&self->ob_itself->portBits); + } if ( strcmp(name, "portRect") == 0 ) return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect); /* XXXX Add more, as needed */ @@ -220,6 +228,10 @@ static PyObject *BMObj_getattr(self, name) if ( strcmp(name, "bounds") == 0 ) return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds); /* XXXX Add more, as needed */ + if ( strcmp(name, "bitmap_data") == 0 ) + return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap)); + if ( strcmp(name, "pixmap_data") == 0 ) + return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap)); return Py_FindMethodInChain(&BMObj_chain, (PyObject *)self, name); } @@ -1525,7 +1537,7 @@ static PyObject *Qd_CopyBits(_self, _args) PyMac_GetRect, &srcRect, PyMac_GetRect, &dstRect, &mode, - ResObj_Convert, &maskRgn)) + OptResObj_Convert, &maskRgn)) return NULL; CopyBits(srcBits, dstBits, @@ -1978,7 +1990,7 @@ static PyObject *Qd_StdBits(_self, _args) PyMac_GetRect, &srcRect, PyMac_GetRect, &dstRect, &mode, - ResObj_Convert, &maskRgn)) + OptResObj_Convert, &maskRgn)) return NULL; StdBits(srcBits, &srcRect, @@ -2721,7 +2733,7 @@ static PyObject *Qd_CopyDeepMask(_self, _args) PyMac_GetRect, &maskRect, PyMac_GetRect, &dstRect, &mode, - ResObj_Convert, &maskRgn)) + OptResObj_Convert, &maskRgn)) return NULL; CopyDeepMask(srcBits, maskBits, @@ -3071,6 +3083,31 @@ static PyObject *Qd_BitMap(_self, _args) } +static PyObject *Qd_RawBitMap(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + + BitMap *ptr; + PyObject *source; + + if ( !PyArg_ParseTuple(_args, "O!", &PyString_Type, &source) ) + return NULL; + if ( PyString_Size(source) != sizeof(BitMap) && PyString_Size(source) != sizeof(PixMap) ) { + PyErr_BadArgument(); + return NULL; + } + ptr = (BitMapPtr)PyString_AsString(source); + if ( (_res = BMObj_New(ptr)) == NULL ) { + return NULL; + } + ((BitMapObject *)_res)->referred_object = source; + Py_INCREF(source); + return _res; + +} + static PyMethodDef Qd_methods[] = { {"SetPort", (PyCFunction)Qd_SetPort, 1, "(GrafPtr port) -> None"}, @@ -3394,6 +3431,8 @@ static PyMethodDef Qd_methods[] = { "(Fixed extra) -> None"}, {"BitMap", (PyCFunction)Qd_BitMap, 1, "Take (string, int, Rect) argument and create BitMap"}, + {"RawBitMap", (PyCFunction)Qd_RawBitMap, 1, + "Take string BitMap and turn into BitMap object"}, {NULL, NULL, 0} }; diff --git a/Mac/Modules/qd/qdgen.py b/Mac/Modules/qd/qdgen.py index f58cb03f155..4410b82cb29 100644 --- a/Mac/Modules/qd/qdgen.py +++ b/Mac/Modules/qd/qdgen.py @@ -423,7 +423,7 @@ (Rect_ptr, 'srcRect', InMode), (Rect_ptr, 'dstRect', InMode), (short, 'mode', InMode), - (RgnHandle, 'maskRgn', InMode), + (OptRgnHandle, 'maskRgn', InMode), ) functions.append(f) @@ -571,7 +571,7 @@ (Rect_ptr, 'srcRect', InMode), (Rect_ptr, 'dstRect', InMode), (short, 'mode', InMode), - (RgnHandle, 'maskRgn', InMode), + (OptRgnHandle, 'maskRgn', InMode), ) functions.append(f) @@ -817,7 +817,7 @@ (Rect_ptr, 'maskRect', InMode), (Rect_ptr, 'dstRect', InMode), (short, 'mode', InMode), - (RgnHandle, 'maskRgn', InMode), + (OptRgnHandle, 'maskRgn', InMode), ) functions.append(f) diff --git a/Mac/Modules/qd/qdscan.py b/Mac/Modules/qd/qdscan.py index e86895a1c5a..1d28ecf4d16 100644 --- a/Mac/Modules/qd/qdscan.py +++ b/Mac/Modules/qd/qdscan.py @@ -127,6 +127,10 @@ def makerepairinstructions(self): [('Rect', 'r', 'InOutMode'), ('Rect_ptr', 'srcRect', 'InMode'), ('Rect_ptr', 'dstRect', 'InMode')]), + + # CopyBits and friends + ([('RgnHandle', 'maskRgn', 'InMode')], + [('OptRgnHandle', 'maskRgn', 'InMode')]), ] diff --git a/Mac/Modules/qd/qdsupport.py b/Mac/Modules/qd/qdsupport.py index 245b6fd1a16..7768f319b63 100644 --- a/Mac/Modules/qd/qdsupport.py +++ b/Mac/Modules/qd/qdsupport.py @@ -33,6 +33,7 @@ def getargsCheck(self, name): # These are temporary! RgnHandle = OpaqueByValueType("RgnHandle", "ResObj") +OptRgnHandle = OpaqueByValueType("RgnHandle", "OptResObj") PicHandle = OpaqueByValueType("PicHandle", "ResObj") PolyHandle = OpaqueByValueType("PolyHandle", "ResObj") PixMapHandle = OpaqueByValueType("PixMapHandle", "ResObj") @@ -101,8 +102,15 @@ def outputCheckConvertArg(self): def outputGetattrHook(self): Output("""if ( strcmp(name, "device") == 0 ) return PyInt_FromLong((long)self->ob_itself->device); - if ( strcmp(name, "portBits") == 0 ) - return BMObj_New(&self->ob_itself->portBits); + if ( strcmp(name, "portBits") == 0 ) { + CGrafPtr itself_color = (CGrafPtr)self->ob_itself; + + if ( (itself_color->portVersion&0xc000) == 0xc000 ) + /* XXXX Do we need HLock() stuff here?? */ + return BMObj_New((BitMapPtr)*itself_color->portPixMap); + else + return BMObj_New(&self->ob_itself->portBits); + } if ( strcmp(name, "portRect") == 0 ) return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect); /* XXXX Add more, as needed */ @@ -132,6 +140,10 @@ def outputGetattrHook(self): if ( strcmp(name, "bounds") == 0 ) return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds); /* XXXX Add more, as needed */ + if ( strcmp(name, "bitmap_data") == 0 ) + return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap)); + if ( strcmp(name, "pixmap_data") == 0 ) + return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap)); """) # Create the generator groups and link them @@ -195,6 +207,32 @@ def outputGetattrHook(self): f.docstring = lambda: """Take (string, int, Rect) argument and create BitMap""" module.add(f) +# +# And again, for turning a correctly-formatted structure into the object +# +RawBitMap_body = """ +BitMap *ptr; +PyObject *source; + +if ( !PyArg_ParseTuple(_args, "O!", &PyString_Type, &source) ) + return NULL; +if ( PyString_Size(source) != sizeof(BitMap) && PyString_Size(source) != sizeof(PixMap) ) { + PyErr_BadArgument(); + return NULL; +} +ptr = (BitMapPtr)PyString_AsString(source); +if ( (_res = BMObj_New(ptr)) == NULL ) { + return NULL; +} +((BitMapObject *)_res)->referred_object = source; +Py_INCREF(source); +return _res; +""" + +f = ManualGenerator("RawBitMap", RawBitMap_body) +f.docstring = lambda: """Take string BitMap and turn into BitMap object""" +module.add(f) + # generate output (open the output file as late as possible) SetOutputFileName(OUTPUTFILE) module.generate() diff --git a/Mac/Modules/qt/Qtmodule.c b/Mac/Modules/qt/Qtmodule.c index 6a6533be0aa..ffba461dd9a 100644 --- a/Mac/Modules/qt/Qtmodule.c +++ b/Mac/Modules/qt/Qtmodule.c @@ -14,8 +14,9 @@ #include extern PyObject *ResObj_New(Handle); -extern PyObject *ResObj_OptNew(Handle); extern int ResObj_Convert(PyObject *, Handle *); +extern PyObject *OptResObj_New(Handle); +extern int OptResObj_Convert(PyObject *, Handle *); extern PyObject *WinObj_New(WindowPtr); extern int WinObj_Convert(PyObject *, WindowPtr *); diff --git a/Mac/Modules/res/Resmodule.c b/Mac/Modules/res/Resmodule.c index 4e8ed8f0c57..1e3e9127ac5 100644 --- a/Mac/Modules/res/Resmodule.c +++ b/Mac/Modules/res/Resmodule.c @@ -14,11 +14,14 @@ #include extern PyObject *ResObj_New(Handle); -extern PyObject *ResObj_OptNew(Handle); extern int ResObj_Convert(PyObject *, Handle *); +extern PyObject *OptResObj_New(Handle); +extern int OptResObj_Convert(PyObject *, Handle *); extern PyObject *WinObj_New(WindowPtr); extern int WinObj_Convert(PyObject *, WindowPtr *); +extern PyTypeObject Window_Type; +#define WinObj_Check(x) ((x)->ob_type == &Window_Type) extern PyObject *DlgObj_New(DialogPtr); extern int DlgObj_Convert(PyObject *, DialogPtr *); @@ -31,6 +34,12 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *); extern PyObject *CtlObj_New(ControlHandle); extern int CtlObj_Convert(PyObject *, ControlHandle *); +extern PyObject *GrafObj_New(GrafPtr); +extern int GrafObj_Convert(PyObject *, GrafPtr *); + +extern PyObject *BMObj_New(BitMapPtr); +extern int BMObj_Convert(PyObject *, BitMapPtr *); + extern PyObject *WinObj_WhichWindow(WindowPtr); #include @@ -1333,7 +1342,7 @@ static PyMethodDef Res_methods[] = { /* Alternative version of ResObj_New, which returns None for null argument */ -PyObject *ResObj_OptNew(itself) +PyObject *OptResObj_New(itself) Handle itself; { ResourceObject *it; @@ -1344,6 +1353,23 @@ PyObject *ResObj_OptNew(itself) return ResObj_New(itself); } +OptResObj_Convert(v, p_itself) + PyObject *v; + Handle *p_itself; +{ + if ( v == Py_None ) { + *p_itself = NULL; + return 1; + } + if (!ResObj_Check(v)) + { + PyErr_SetString(PyExc_TypeError, "Resource required"); + return 0; + } + *p_itself = ((ResourceObject *)v)->ob_itself; + return 1; +} + void initRes() diff --git a/Mac/Modules/res/ressupport.py b/Mac/Modules/res/ressupport.py index fd4f4e631fb..8eb6bf4fb4e 100644 --- a/Mac/Modules/res/ressupport.py +++ b/Mac/Modules/res/ressupport.py @@ -32,7 +32,7 @@ class ResMethod(ResMixIn, MethodGenerator): pass finalstuff = finalstuff + """ /* Alternative version of ResObj_New, which returns None for null argument */ -PyObject *ResObj_OptNew(itself) +PyObject *OptResObj_New(itself) Handle itself; { ResourceObject *it; @@ -43,6 +43,23 @@ class ResMethod(ResMixIn, MethodGenerator): pass return ResObj_New(itself); } +OptResObj_Convert(v, p_itself) + PyObject *v; + Handle *p_itself; +{ + if ( v == Py_None ) { + *p_itself = NULL; + return 1; + } + if (!ResObj_Check(v)) + { + PyErr_SetString(PyExc_TypeError, "Resource required"); + return 0; + } + *p_itself = ((ResourceObject *)v)->ob_itself; + return 1; +} + """ initstuff = initstuff + """ diff --git a/Mac/Modules/snd/Sndmodule.c b/Mac/Modules/snd/Sndmodule.c index 1d91ec90d2d..866ce75794c 100644 --- a/Mac/Modules/snd/Sndmodule.c +++ b/Mac/Modules/snd/Sndmodule.c @@ -14,11 +14,14 @@ #include extern PyObject *ResObj_New(Handle); -extern PyObject *ResObj_OptNew(Handle); extern int ResObj_Convert(PyObject *, Handle *); +extern PyObject *OptResObj_New(Handle); +extern int OptResObj_Convert(PyObject *, Handle *); extern PyObject *WinObj_New(WindowPtr); extern int WinObj_Convert(PyObject *, WindowPtr *); +extern PyTypeObject Window_Type; +#define WinObj_Check(x) ((x)->ob_type == &Window_Type) extern PyObject *DlgObj_New(DialogPtr); extern int DlgObj_Convert(PyObject *, DialogPtr *); @@ -31,6 +34,12 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *); extern PyObject *CtlObj_New(ControlHandle); extern int CtlObj_Convert(PyObject *, ControlHandle *); +extern PyObject *GrafObj_New(GrafPtr); +extern int GrafObj_Convert(PyObject *, GrafPtr *); + +extern PyObject *BMObj_New(BitMapPtr); +extern int BMObj_Convert(PyObject *, BitMapPtr *); + extern PyObject *WinObj_WhichWindow(WindowPtr); #include diff --git a/Mac/Modules/win/Winmodule.c b/Mac/Modules/win/Winmodule.c index 286ef34b128..afac85f3215 100644 --- a/Mac/Modules/win/Winmodule.c +++ b/Mac/Modules/win/Winmodule.c @@ -14,8 +14,9 @@ #include extern PyObject *ResObj_New(Handle); -extern PyObject *ResObj_OptNew(Handle); extern int ResObj_Convert(PyObject *, Handle *); +extern PyObject *OptResObj_New(Handle); +extern int OptResObj_Convert(PyObject *, Handle *); extern PyObject *WinObj_New(WindowPtr); extern int WinObj_Convert(PyObject *, WindowPtr *); @@ -36,6 +37,9 @@ extern int CtlObj_Convert(PyObject *, ControlHandle *); extern PyObject *GrafObj_New(GrafPtr); extern int GrafObj_Convert(PyObject *, GrafPtr *); +extern PyObject *BMObj_New(BitMapPtr); +extern int BMObj_Convert(PyObject *, BitMapPtr *); + extern PyObject *WinObj_WhichWindow(WindowPtr); #include diff --git a/Tools/bgen/bgen/macsupport.py b/Tools/bgen/bgen/macsupport.py index c3788b29d4b..0f21b3fcf62 100644 --- a/Tools/bgen/bgen/macsupport.py +++ b/Tools/bgen/bgen/macsupport.py @@ -99,8 +99,9 @@ def errorCheck(self, name): #include extern PyObject *ResObj_New(Handle); -extern PyObject *ResObj_OptNew(Handle); extern int ResObj_Convert(PyObject *, Handle *); +extern PyObject *OptResObj_New(Handle); +extern int OptResObj_Convert(PyObject *, Handle *); extern PyObject *WinObj_New(WindowPtr); extern int WinObj_Convert(PyObject *, WindowPtr *);