diff options
Diffstat (limited to 'Mac')
-rw-r--r-- | Mac/Lib/toolbox/AEObjects.py | 2 | ||||
-rw-r--r-- | Mac/Lib/toolbox/AERegistry.py | 2 | ||||
-rw-r--r-- | Mac/Lib/toolbox/AppleEvents.py | 2 | ||||
-rw-r--r-- | Mac/Lib/toolbox/Dialogs.py | 2 | ||||
-rw-r--r-- | Mac/Lib/toolbox/Menus.py | 2 | ||||
-rw-r--r-- | Mac/Modules/ae/AEmodule.c | 11 | ||||
-rw-r--r-- | Mac/Modules/ae/aegen.py | 2 | ||||
-rw-r--r-- | Mac/Modules/cm/Cmmodule.c | 3 | ||||
-rw-r--r-- | Mac/Modules/ctl/Ctlmodule.c | 11 | ||||
-rw-r--r-- | Mac/Modules/dlg/Dlgmodule.c | 13 | ||||
-rw-r--r-- | Mac/Modules/dlg/dlggen.py | 2 | ||||
-rw-r--r-- | Mac/Modules/dlg/dlgsupport.py | 8 | ||||
-rw-r--r-- | Mac/Modules/evt/Evtmodule.c | 11 | ||||
-rw-r--r-- | Mac/Modules/list/Listmodule.c | 11 | ||||
-rw-r--r-- | Mac/Modules/menu/Menumodule.c | 11 | ||||
-rw-r--r-- | Mac/Modules/menu/menugen.py | 2 | ||||
-rw-r--r-- | Mac/Modules/qd/Qdmodule.c | 51 | ||||
-rw-r--r-- | Mac/Modules/qd/qdgen.py | 6 | ||||
-rw-r--r-- | Mac/Modules/qd/qdscan.py | 4 | ||||
-rw-r--r-- | Mac/Modules/qd/qdsupport.py | 42 | ||||
-rw-r--r-- | Mac/Modules/qt/Qtmodule.c | 3 | ||||
-rw-r--r-- | Mac/Modules/res/Resmodule.c | 30 | ||||
-rw-r--r-- | Mac/Modules/res/ressupport.py | 19 | ||||
-rw-r--r-- | Mac/Modules/snd/Sndmodule.c | 11 | ||||
-rw-r--r-- | Mac/Modules/win/Winmodule.c | 6 |
25 files changed, 229 insertions, 38 deletions
diff --git a/Mac/Lib/toolbox/AEObjects.py b/Mac/Lib/toolbox/AEObjects.py index 3e1db67..b3ff7d4 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 716c5f8..988a8c8 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 e4668bc..55b5f51 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 c08dac4..ba9ba69 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 be1e810..dede690 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 2d75977..e12c6c8 100644 --- a/Mac/Modules/ae/AEmodule.c +++ b/Mac/Modules/ae/AEmodule.c @@ -14,11 +14,14 @@ #include <Controls.h> 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 <AppleEvents.h> diff --git a/Mac/Modules/ae/aegen.py b/Mac/Modules/ae/aegen.py index 5d3a6e8..896eb78 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 2f44307..fd8b331 100644 --- a/Mac/Modules/cm/Cmmodule.c +++ b/Mac/Modules/cm/Cmmodule.c @@ -14,8 +14,9 @@ #include <Controls.h> 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 3ea6b91..2669113 100644 --- a/Mac/Modules/ctl/Ctlmodule.c +++ b/Mac/Modules/ctl/Ctlmodule.c @@ -14,11 +14,14 @@ #include <Controls.h> 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 <Controls.h> diff --git a/Mac/Modules/dlg/Dlgmodule.c b/Mac/Modules/dlg/Dlgmodule.c index 49f6553..93de3e9 100644 --- a/Mac/Modules/dlg/Dlgmodule.c +++ b/Mac/Modules/dlg/Dlgmodule.c @@ -14,11 +14,14 @@ #include <Controls.h> 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 <Dialogs.h> @@ -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 4319520..3c1e669 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 0b5f082..cd255ef 100644 --- a/Mac/Modules/dlg/dlgsupport.py +++ b/Mac/Modules/dlg/dlgsupport.py @@ -13,11 +13,9 @@ from macsupport import * 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 59858fa..9078e9f 100644 --- a/Mac/Modules/evt/Evtmodule.c +++ b/Mac/Modules/evt/Evtmodule.c @@ -14,11 +14,14 @@ #include <Controls.h> 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 <Events.h> diff --git a/Mac/Modules/list/Listmodule.c b/Mac/Modules/list/Listmodule.c index 747b477..17f20b0 100644 --- a/Mac/Modules/list/Listmodule.c +++ b/Mac/Modules/list/Listmodule.c @@ -14,11 +14,14 @@ #include <Controls.h> 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 <Lists.h> diff --git a/Mac/Modules/menu/Menumodule.c b/Mac/Modules/menu/Menumodule.c index 6c855cd..07e1b88 100644 --- a/Mac/Modules/menu/Menumodule.c +++ b/Mac/Modules/menu/Menumodule.c @@ -14,11 +14,14 @@ #include <Controls.h> 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 <Devices.h> /* Defines OpenDeskAcc in universal headers */ diff --git a/Mac/Modules/menu/menugen.py b/Mac/Modules/menu/menugen.py index 30e43e2..7e27d5c 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 8b03fc2..b076aa4 100644 --- a/Mac/Modules/qd/Qdmodule.c +++ b/Mac/Modules/qd/Qdmodule.c @@ -14,8 +14,9 @@ #include <Controls.h> 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 f58cb03..4410b82 100644 --- a/Mac/Modules/qd/qdgen.py +++ b/Mac/Modules/qd/qdgen.py @@ -423,7 +423,7 @@ f = Function(void, 'CopyBits', (Rect_ptr, 'srcRect', InMode), (Rect_ptr, 'dstRect', InMode), (short, 'mode', InMode), - (RgnHandle, 'maskRgn', InMode), + (OptRgnHandle, 'maskRgn', InMode), ) functions.append(f) @@ -571,7 +571,7 @@ f = Function(void, 'StdBits', (Rect_ptr, 'srcRect', InMode), (Rect_ptr, 'dstRect', InMode), (short, 'mode', InMode), - (RgnHandle, 'maskRgn', InMode), + (OptRgnHandle, 'maskRgn', InMode), ) functions.append(f) @@ -817,7 +817,7 @@ f = Function(void, 'CopyDeepMask', (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 e86895a..1d28ecf 100644 --- a/Mac/Modules/qd/qdscan.py +++ b/Mac/Modules/qd/qdscan.py @@ -127,6 +127,10 @@ class MyScanner(Scanner): [('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 245b6fd..7768f31 100644 --- a/Mac/Modules/qd/qdsupport.py +++ b/Mac/Modules/qd/qdsupport.py @@ -33,6 +33,7 @@ TextThingie = TextThingieClass(None) # 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 @@ class MyGRObjectDefinition(GlobalObjectDefinition): 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 @@ class MyBMObjectDefinition(GlobalObjectDefinition): 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 @@ f = ManualGenerator("BitMap", BitMap_body) 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 6a6533b..ffba461 100644 --- a/Mac/Modules/qt/Qtmodule.c +++ b/Mac/Modules/qt/Qtmodule.c @@ -14,8 +14,9 @@ #include <Controls.h> 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 4e8ed8f..1e3e912 100644 --- a/Mac/Modules/res/Resmodule.c +++ b/Mac/Modules/res/Resmodule.c @@ -14,11 +14,14 @@ #include <Controls.h> 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 <Resources.h> @@ -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 fd4f4e6..8eb6bf4 100644 --- a/Mac/Modules/res/ressupport.py +++ b/Mac/Modules/res/ressupport.py @@ -32,7 +32,7 @@ includestuff = includestuff + """ 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 @@ 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; +} + """ initstuff = initstuff + """ diff --git a/Mac/Modules/snd/Sndmodule.c b/Mac/Modules/snd/Sndmodule.c index 1d91ec9..866ce75 100644 --- a/Mac/Modules/snd/Sndmodule.c +++ b/Mac/Modules/snd/Sndmodule.c @@ -14,11 +14,14 @@ #include <Controls.h> 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 <Sound.h> diff --git a/Mac/Modules/win/Winmodule.c b/Mac/Modules/win/Winmodule.c index 286ef34..afac85f 100644 --- a/Mac/Modules/win/Winmodule.c +++ b/Mac/Modules/win/Winmodule.c @@ -14,8 +14,9 @@ #include <Controls.h> 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 <Windows.h> |