From dbd5701d736a151d29fee4658228e16876626f47 Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Fri, 29 Nov 2002 23:40:48 +0000 Subject: Converted the Carbon modules to use PEP252-style objects, with descriptors in stead of manual getattr hooks to get at attributes of the objects. For Qd I have in stead gotten rid of most of the attribute access in favor of the carbon-style accessor methods (with the exception of visRgn, to be done later), and of the Carbon.Qd.qd global object, for which accessor functions are also available. For List I have fixed the fact that various methods were incorrectly generated as functions. CF is untouched: PEP252 doesn't allow "poor-mans-inheritance" with basechain, so it will have to wait for PEP253 support. --- Mac/Modules/ae/_AEmodule.c | 102 +- Mac/Modules/ae/aesupport.py | 79 +- Mac/Modules/alias/_Aliasmodule.c | 30 +- Mac/Modules/alias/aliassupport.py | 2 +- Mac/Modules/app/_Appmodule.c | 30 +- Mac/Modules/app/appsupport.py | 2 +- Mac/Modules/carbonevt/CarbonEvtsupport.py | 7 +- Mac/Modules/carbonevt/_CarbonEvtmodule.c | 240 +- Mac/Modules/cg/_CGmodule.c | 30 +- Mac/Modules/cg/cgsupport.py | 2 +- Mac/Modules/cm/_Cmmodule.c | 60 +- Mac/Modules/cm/cmsupport.py | 4 +- Mac/Modules/ctl/_Ctlmodule.c | 30 +- Mac/Modules/ctl/ctlsupport.py | 2 +- Mac/Modules/dlg/_Dlgmodule.c | 30 +- Mac/Modules/dlg/dlgsupport.py | 2 +- Mac/Modules/drag/_Dragmodule.c | 30 +- Mac/Modules/drag/dragsupport.py | 2 +- Mac/Modules/evt/evtsupport.py | 17 - Mac/Modules/help/helpsupport.py | 2 +- Mac/Modules/ibcarbon/IBCarbonsupport.py | 4 +- Mac/Modules/ibcarbon/_IBCarbon.c | 30 +- Mac/Modules/icn/icnsupport.py | 2 +- Mac/Modules/list/_Listmodule.c | 414 ++- Mac/Modules/list/listscan.py | 2 +- Mac/Modules/list/listsupport.py | 58 +- Mac/Modules/menu/_Menumodule.c | 30 +- Mac/Modules/menu/menusupport.py | 2 +- Mac/Modules/mlte/_Mltemodule.c | 60 +- Mac/Modules/mlte/mltesupport.py | 4 +- Mac/Modules/qd/_Qdmodule.c | 5728 ++++++++++++++--------------- Mac/Modules/qd/qdscan.py | 6 + Mac/Modules/qd/qdsupport.py | 314 +- Mac/Modules/qdoffs/_Qdoffsmodule.c | 30 +- Mac/Modules/qdoffs/qdoffssupport.py | 2 +- Mac/Modules/qt/_Qtmodule.c | 180 +- Mac/Modules/qt/qtsupport.py | 12 +- Mac/Modules/res/_Resmodule.c | 114 +- Mac/Modules/res/ressupport.py | 92 +- Mac/Modules/scrap/scrapsupport.py | 2 +- Mac/Modules/snd/_Sndmodule.c | 138 +- Mac/Modules/snd/sndsupport.py | 82 +- Mac/Modules/te/_TEmodule.c | 198 +- Mac/Modules/te/tesupport.py | 125 +- Mac/Modules/waste/wastemodule.c | 60 +- Mac/Modules/waste/wastesupport.py | 4 +- Mac/Modules/win/_Winmodule.c | 30 +- Mac/Modules/win/winsupport.py | 2 +- 48 files changed, 4184 insertions(+), 4244 deletions(-) diff --git a/Mac/Modules/ae/_AEmodule.c b/Mac/Modules/ae/_AEmodule.c index 0d8b802186..db8239c1ce 100644 --- a/Mac/Modules/ae/_AEmodule.c +++ b/Mac/Modules/ae/_AEmodule.c @@ -20,6 +20,9 @@ }} while(0) +#ifndef PyDoc_STR +#define PyDoc_STR(x) (x) +#endif #ifdef WITHOUT_FRAMEWORKS #include #include @@ -35,7 +38,13 @@ extern int _AEDesc_Convert(PyObject *, AEDesc *); #define AEDesc_Convert _AEDesc_Convert #endif -static pascal OSErr GenericEventHandler(); /* Forward */ +#if UNIVERSAL_INTERFACES_VERSION >= 0x0340 +typedef long refcontype; +#else +typedef unsigned long refcontype; +#endif + +static pascal OSErr GenericEventHandler(const AppleEvent *request, AppleEvent *reply, refcontype refcon); /* Forward */ AEEventHandlerUPP upp_GenericEventHandler; @@ -820,46 +829,40 @@ static PyMethodDef AEDesc_methods[] = { {NULL, NULL, 0} }; -PyMethodChain AEDesc_chain = { AEDesc_methods, NULL }; - -static PyObject *AEDesc_getattr(AEDescObject *self, char *name) +static PyObject *AEDesc_get_type(AEDescObject *self, void *closure) { + return PyMac_BuildOSType(self->ob_itself.descriptorType); +} - if (strcmp(name, "type") == 0) - return PyMac_BuildOSType(self->ob_itself.descriptorType); - if (strcmp(name, "data") == 0) { - PyObject *res; -#if !TARGET_API_MAC_CARBON - char state; - state = HGetState(self->ob_itself.dataHandle); - HLock(self->ob_itself.dataHandle); - res = PyString_FromStringAndSize( - *self->ob_itself.dataHandle, - 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) - return Py_BuildValue("[ss]", "data", "type"); +#define AEDesc_set_type NULL - return Py_FindMethodInChain(&AEDesc_chain, (PyObject *)self, name); +static PyObject *AEDesc_get_data(AEDescObject *self, void *closure) +{ + + PyObject *res; + 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); + return res; + } -#define AEDesc_setattr NULL +#define AEDesc_set_data NULL + +static PyGetSetDef AEDesc_getsetlist[] = { + {"type", (getter)AEDesc_get_type, (setter)AEDesc_set_type, "Type of this AEDesc"}, + {"data", (getter)AEDesc_get_data, (setter)AEDesc_set_data, "The raw data in this AEDesc"}, + {NULL, NULL, NULL, NULL}, +}; + #define AEDesc_compare NULL @@ -876,14 +879,31 @@ PyTypeObject AEDesc_Type = { /* methods */ (destructor) AEDesc_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) AEDesc_getattr, /*tp_getattr*/ - (setattrfunc) AEDesc_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) AEDesc_compare, /*tp_compare*/ (reprfunc) AEDesc_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) AEDesc_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + AEDesc_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + AEDesc_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* --------------------- End object type AEDesc --------------------- */ @@ -1350,12 +1370,6 @@ static PyMethodDef AE_methods[] = { -#if UNIVERSAL_INTERFACES_VERSION >= 0x0340 -typedef long refcontype; -#else -typedef unsigned long refcontype; -#endif - static pascal OSErr GenericEventHandler(const AppleEvent *request, AppleEvent *reply, refcontype refcon) { diff --git a/Mac/Modules/ae/aesupport.py b/Mac/Modules/ae/aesupport.py index 8ecaeda3cb..e6c4efee75 100644 --- a/Mac/Modules/ae/aesupport.py +++ b/Mac/Modules/ae/aesupport.py @@ -82,6 +82,9 @@ AEMethod = OSErrWeakLinkMethodGenerator includestuff = includestuff + """ +#ifndef PyDoc_STR +#define PyDoc_STR(x) (x) +#endif #ifdef WITHOUT_FRAMEWORKS #include #include @@ -97,7 +100,13 @@ extern int _AEDesc_Convert(PyObject *, AEDesc *); #define AEDesc_Convert _AEDesc_Convert #endif -static pascal OSErr GenericEventHandler(); /* Forward */ +#if UNIVERSAL_INTERFACES_VERSION >= 0x0340 +typedef long refcontype; +#else +typedef unsigned long refcontype; +#endif + +static pascal OSErr GenericEventHandler(const AppleEvent *request, AppleEvent *reply, refcontype refcon); /* Forward */ AEEventHandlerUPP upp_GenericEventHandler; @@ -118,12 +127,6 @@ AEIdleUPP upp_AEIdleProc; """ finalstuff = finalstuff + """ -#if UNIVERSAL_INTERFACES_VERSION >= 0x0340 -typedef long refcontype; -#else -typedef unsigned long refcontype; -#endif - static pascal OSErr GenericEventHandler(const AppleEvent *request, AppleEvent *reply, refcontype refcon) { @@ -171,7 +174,32 @@ initstuff = initstuff + """ module = MacModule('_AE', 'AE', includestuff, finalstuff, initstuff) -class AEDescDefinition(GlobalObjectDefinition): +class AEDescDefinition(PEP252Mixin, GlobalObjectDefinition): + getsetlist = [( + 'type', + 'return PyMac_BuildOSType(self->ob_itself.descriptorType);', + None, + 'Type of this AEDesc' + ), ( + 'data', + """ + PyObject *res; + 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); + return res; + """, + None, + 'The raw data in this AEDesc' + )] def __init__(self, name, prefix = None, itselftype = None): GlobalObjectDefinition.__init__(self, name, prefix or name, itselftype or name) @@ -180,41 +208,6 @@ class AEDescDefinition(GlobalObjectDefinition): def outputFreeIt(self, name): Output("AEDisposeDesc(&%s);", name) - def outputGetattrHook(self): - Output(""" -if (strcmp(name, "type") == 0) - return PyMac_BuildOSType(self->ob_itself.descriptorType); -if (strcmp(name, "data") == 0) { - PyObject *res; -#if !TARGET_API_MAC_CARBON - char state; - state = HGetState(self->ob_itself.dataHandle); - HLock(self->ob_itself.dataHandle); - res = PyString_FromStringAndSize( - *self->ob_itself.dataHandle, - 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) - return Py_BuildValue("[ss]", "data", "type"); -""") - - aedescobject = AEDescDefinition('AEDesc') module.addobject(aedescobject) diff --git a/Mac/Modules/alias/_Aliasmodule.c b/Mac/Modules/alias/_Aliasmodule.c index 7b30d0586d..91e0f282b6 100644 --- a/Mac/Modules/alias/_Aliasmodule.c +++ b/Mac/Modules/alias/_Aliasmodule.c @@ -95,14 +95,7 @@ static PyMethodDef AliasObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain AliasObj_chain = { AliasObj_methods, NULL }; - -static PyObject *AliasObj_getattr(AliasObject *self, char *name) -{ - return Py_FindMethodInChain(&AliasObj_chain, (PyObject *)self, name); -} - -#define AliasObj_setattr NULL +#define AliasObj_getsetlist NULL #define AliasObj_compare NULL @@ -119,14 +112,31 @@ PyTypeObject Alias_Type = { /* methods */ (destructor) AliasObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) AliasObj_getattr, /*tp_getattr*/ - (setattrfunc) AliasObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) AliasObj_compare, /*tp_compare*/ (reprfunc) AliasObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) AliasObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + AliasObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + AliasObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* --------------------- End object type Alias ---------------------- */ diff --git a/Mac/Modules/alias/aliassupport.py b/Mac/Modules/alias/aliassupport.py index 932eed79d4..7fd6f84e40 100644 --- a/Mac/Modules/alias/aliassupport.py +++ b/Mac/Modules/alias/aliassupport.py @@ -72,7 +72,7 @@ execfile(string.lower(MODPREFIX) + 'typetest.py') # Create the generator groups and link them module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) -class AliasDefinition(GlobalObjectDefinition): +class AliasDefinition(PEP252Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("if (itself == NULL) return PyMac_Error(resNotFound);") diff --git a/Mac/Modules/app/_Appmodule.c b/Mac/Modules/app/_Appmodule.c index e5362c9b9f..da6c33924d 100644 --- a/Mac/Modules/app/_Appmodule.c +++ b/Mac/Modules/app/_Appmodule.c @@ -113,14 +113,7 @@ static PyMethodDef ThemeDrawingStateObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain ThemeDrawingStateObj_chain = { ThemeDrawingStateObj_methods, NULL }; - -static PyObject *ThemeDrawingStateObj_getattr(ThemeDrawingStateObject *self, char *name) -{ - return Py_FindMethodInChain(&ThemeDrawingStateObj_chain, (PyObject *)self, name); -} - -#define ThemeDrawingStateObj_setattr NULL +#define ThemeDrawingStateObj_getsetlist NULL #define ThemeDrawingStateObj_compare NULL @@ -137,14 +130,31 @@ PyTypeObject ThemeDrawingState_Type = { /* methods */ (destructor) ThemeDrawingStateObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) ThemeDrawingStateObj_getattr, /*tp_getattr*/ - (setattrfunc) ThemeDrawingStateObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) ThemeDrawingStateObj_compare, /*tp_compare*/ (reprfunc) ThemeDrawingStateObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) ThemeDrawingStateObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + ThemeDrawingStateObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + ThemeDrawingStateObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* --------------- End object type ThemeDrawingState ---------------- */ diff --git a/Mac/Modules/app/appsupport.py b/Mac/Modules/app/appsupport.py index a9cdf76f3d..b6545efccb 100644 --- a/Mac/Modules/app/appsupport.py +++ b/Mac/Modules/app/appsupport.py @@ -94,7 +94,7 @@ int ThemeButtonDrawInfo_Convert(PyObject *v, ThemeButtonDrawInfo *p_itself) """ -class MyObjectDefinition(GlobalObjectDefinition): +class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition): pass ## def outputCheckNewArg(self): ## Output("if (itself == NULL) return PyMac_Error(resNotFound);") diff --git a/Mac/Modules/carbonevt/CarbonEvtsupport.py b/Mac/Modules/carbonevt/CarbonEvtsupport.py index cbaca2a461..e3ac5f5d11 100644 --- a/Mac/Modules/carbonevt/CarbonEvtsupport.py +++ b/Mac/Modules/carbonevt/CarbonEvtsupport.py @@ -215,7 +215,7 @@ module = MacModule('_CarbonEvt', 'CarbonEvents', includestuff, finalstuff, inits -class EventHandlerRefObjectDefinition(GlobalObjectDefinition): +class EventHandlerRefObjectDefinition(PEP252Mixin, GlobalObjectDefinition): def outputStructMembers(self): Output("%s ob_itself;", self.itselftype) Output("PyObject *ob_callback;") @@ -227,12 +227,15 @@ class EventHandlerRefObjectDefinition(GlobalObjectDefinition): Output("RemoveEventHandler(self->ob_itself);") Output("Py_DECREF(self->ob_callback);") OutRbrace() + +class MyGlobalObjectDefinition(PEP252Mixin, GlobalObjectDefinition): + pass for typ in RefObjectTypes: if typ == 'EventHandlerRef': EventHandlerRefobject = EventHandlerRefObjectDefinition('EventHandlerRef') else: - execstr = typ + 'object = GlobalObjectDefinition(typ)' + execstr = typ + 'object = MyGlobalObjectDefinition(typ)' exec execstr module.addobject(eval(typ + 'object')) diff --git a/Mac/Modules/carbonevt/_CarbonEvtmodule.c b/Mac/Modules/carbonevt/_CarbonEvtmodule.c index 9ef572cfc2..05ad7fb6e3 100755 --- a/Mac/Modules/carbonevt/_CarbonEvtmodule.c +++ b/Mac/Modules/carbonevt/_CarbonEvtmodule.c @@ -408,14 +408,7 @@ static PyMethodDef EventRef_methods[] = { {NULL, NULL, 0} }; -PyMethodChain EventRef_chain = { EventRef_methods, NULL }; - -static PyObject *EventRef_getattr(EventRefObject *self, char *name) -{ - return Py_FindMethodInChain(&EventRef_chain, (PyObject *)self, name); -} - -#define EventRef_setattr NULL +#define EventRef_getsetlist NULL #define EventRef_compare NULL @@ -432,14 +425,31 @@ PyTypeObject EventRef_Type = { /* methods */ (destructor) EventRef_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) EventRef_getattr, /*tp_getattr*/ - (setattrfunc) EventRef_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) EventRef_compare, /*tp_compare*/ (reprfunc) EventRef_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) EventRef_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + EventRef_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + EventRef_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* -------------------- End object type EventRef -------------------- */ @@ -591,14 +601,7 @@ static PyMethodDef EventQueueRef_methods[] = { {NULL, NULL, 0} }; -PyMethodChain EventQueueRef_chain = { EventQueueRef_methods, NULL }; - -static PyObject *EventQueueRef_getattr(EventQueueRefObject *self, char *name) -{ - return Py_FindMethodInChain(&EventQueueRef_chain, (PyObject *)self, name); -} - -#define EventQueueRef_setattr NULL +#define EventQueueRef_getsetlist NULL #define EventQueueRef_compare NULL @@ -615,14 +618,31 @@ PyTypeObject EventQueueRef_Type = { /* methods */ (destructor) EventQueueRef_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) EventQueueRef_getattr, /*tp_getattr*/ - (setattrfunc) EventQueueRef_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) EventQueueRef_compare, /*tp_compare*/ (reprfunc) EventQueueRef_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) EventQueueRef_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + EventQueueRef_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + EventQueueRef_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* ----------------- End object type EventQueueRef ------------------ */ @@ -683,14 +703,7 @@ static PyMethodDef EventLoopRef_methods[] = { {NULL, NULL, 0} }; -PyMethodChain EventLoopRef_chain = { EventLoopRef_methods, NULL }; - -static PyObject *EventLoopRef_getattr(EventLoopRefObject *self, char *name) -{ - return Py_FindMethodInChain(&EventLoopRef_chain, (PyObject *)self, name); -} - -#define EventLoopRef_setattr NULL +#define EventLoopRef_getsetlist NULL #define EventLoopRef_compare NULL @@ -707,14 +720,31 @@ PyTypeObject EventLoopRef_Type = { /* methods */ (destructor) EventLoopRef_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) EventLoopRef_getattr, /*tp_getattr*/ - (setattrfunc) EventLoopRef_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) EventLoopRef_compare, /*tp_compare*/ (reprfunc) EventLoopRef_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) EventLoopRef_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + EventLoopRef_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + EventLoopRef_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* ------------------ End object type EventLoopRef ------------------ */ @@ -793,14 +823,7 @@ static PyMethodDef EventLoopTimerRef_methods[] = { {NULL, NULL, 0} }; -PyMethodChain EventLoopTimerRef_chain = { EventLoopTimerRef_methods, NULL }; - -static PyObject *EventLoopTimerRef_getattr(EventLoopTimerRefObject *self, char *name) -{ - return Py_FindMethodInChain(&EventLoopTimerRef_chain, (PyObject *)self, name); -} - -#define EventLoopTimerRef_setattr NULL +#define EventLoopTimerRef_getsetlist NULL #define EventLoopTimerRef_compare NULL @@ -817,14 +840,31 @@ PyTypeObject EventLoopTimerRef_Type = { /* methods */ (destructor) EventLoopTimerRef_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) EventLoopTimerRef_getattr, /*tp_getattr*/ - (setattrfunc) EventLoopTimerRef_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) EventLoopTimerRef_compare, /*tp_compare*/ (reprfunc) EventLoopTimerRef_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) EventLoopTimerRef_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + EventLoopTimerRef_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + EventLoopTimerRef_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* --------------- End object type EventLoopTimerRef ---------------- */ @@ -948,14 +988,7 @@ static PyMethodDef EventHandlerRef_methods[] = { {NULL, NULL, 0} }; -PyMethodChain EventHandlerRef_chain = { EventHandlerRef_methods, NULL }; - -static PyObject *EventHandlerRef_getattr(EventHandlerRefObject *self, char *name) -{ - return Py_FindMethodInChain(&EventHandlerRef_chain, (PyObject *)self, name); -} - -#define EventHandlerRef_setattr NULL +#define EventHandlerRef_getsetlist NULL #define EventHandlerRef_compare NULL @@ -972,14 +1005,31 @@ PyTypeObject EventHandlerRef_Type = { /* methods */ (destructor) EventHandlerRef_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) EventHandlerRef_getattr, /*tp_getattr*/ - (setattrfunc) EventHandlerRef_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) EventHandlerRef_compare, /*tp_compare*/ (reprfunc) EventHandlerRef_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) EventHandlerRef_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + EventHandlerRef_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + EventHandlerRef_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* ---------------- End object type EventHandlerRef ----------------- */ @@ -1043,14 +1093,7 @@ static PyMethodDef EventHandlerCallRef_methods[] = { {NULL, NULL, 0} }; -PyMethodChain EventHandlerCallRef_chain = { EventHandlerCallRef_methods, NULL }; - -static PyObject *EventHandlerCallRef_getattr(EventHandlerCallRefObject *self, char *name) -{ - return Py_FindMethodInChain(&EventHandlerCallRef_chain, (PyObject *)self, name); -} - -#define EventHandlerCallRef_setattr NULL +#define EventHandlerCallRef_getsetlist NULL #define EventHandlerCallRef_compare NULL @@ -1067,14 +1110,31 @@ PyTypeObject EventHandlerCallRef_Type = { /* methods */ (destructor) EventHandlerCallRef_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) EventHandlerCallRef_getattr, /*tp_getattr*/ - (setattrfunc) EventHandlerCallRef_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) EventHandlerCallRef_compare, /*tp_compare*/ (reprfunc) EventHandlerCallRef_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) EventHandlerCallRef_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + EventHandlerCallRef_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + EventHandlerCallRef_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* -------------- End object type EventHandlerCallRef --------------- */ @@ -1160,14 +1220,7 @@ static PyMethodDef EventTargetRef_methods[] = { {NULL, NULL, 0} }; -PyMethodChain EventTargetRef_chain = { EventTargetRef_methods, NULL }; - -static PyObject *EventTargetRef_getattr(EventTargetRefObject *self, char *name) -{ - return Py_FindMethodInChain(&EventTargetRef_chain, (PyObject *)self, name); -} - -#define EventTargetRef_setattr NULL +#define EventTargetRef_getsetlist NULL #define EventTargetRef_compare NULL @@ -1184,14 +1237,31 @@ PyTypeObject EventTargetRef_Type = { /* methods */ (destructor) EventTargetRef_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) EventTargetRef_getattr, /*tp_getattr*/ - (setattrfunc) EventTargetRef_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) EventTargetRef_compare, /*tp_compare*/ (reprfunc) EventTargetRef_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) EventTargetRef_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + EventTargetRef_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + EventTargetRef_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* ----------------- End object type EventTargetRef ----------------- */ @@ -1252,14 +1322,7 @@ static PyMethodDef EventHotKeyRef_methods[] = { {NULL, NULL, 0} }; -PyMethodChain EventHotKeyRef_chain = { EventHotKeyRef_methods, NULL }; - -static PyObject *EventHotKeyRef_getattr(EventHotKeyRefObject *self, char *name) -{ - return Py_FindMethodInChain(&EventHotKeyRef_chain, (PyObject *)self, name); -} - -#define EventHotKeyRef_setattr NULL +#define EventHotKeyRef_getsetlist NULL #define EventHotKeyRef_compare NULL @@ -1276,14 +1339,31 @@ PyTypeObject EventHotKeyRef_Type = { /* methods */ (destructor) EventHotKeyRef_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) EventHotKeyRef_getattr, /*tp_getattr*/ - (setattrfunc) EventHotKeyRef_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) EventHotKeyRef_compare, /*tp_compare*/ (reprfunc) EventHotKeyRef_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) EventHotKeyRef_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + EventHotKeyRef_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + EventHotKeyRef_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* ----------------- End object type EventHotKeyRef ----------------- */ diff --git a/Mac/Modules/cg/_CGmodule.c b/Mac/Modules/cg/_CGmodule.c index 069889aa68..b475d681fa 100755 --- a/Mac/Modules/cg/_CGmodule.c +++ b/Mac/Modules/cg/_CGmodule.c @@ -1266,14 +1266,7 @@ static PyMethodDef CGContextRefObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain CGContextRefObj_chain = { CGContextRefObj_methods, NULL }; - -static PyObject *CGContextRefObj_getattr(CGContextRefObject *self, char *name) -{ - return Py_FindMethodInChain(&CGContextRefObj_chain, (PyObject *)self, name); -} - -#define CGContextRefObj_setattr NULL +#define CGContextRefObj_getsetlist NULL #define CGContextRefObj_compare NULL @@ -1290,14 +1283,31 @@ PyTypeObject CGContextRef_Type = { /* methods */ (destructor) CGContextRefObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) CGContextRefObj_getattr, /*tp_getattr*/ - (setattrfunc) CGContextRefObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) CGContextRefObj_compare, /*tp_compare*/ (reprfunc) CGContextRefObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) CGContextRefObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + CGContextRefObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + CGContextRefObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* ------------------ End object type CGContextRef ------------------ */ diff --git a/Mac/Modules/cg/cgsupport.py b/Mac/Modules/cg/cgsupport.py index d090685534..ca347f764b 100755 --- a/Mac/Modules/cg/cgsupport.py +++ b/Mac/Modules/cg/cgsupport.py @@ -250,7 +250,7 @@ CGPathDrawingMode = int CGContextRef = OpaqueByValueType("CGContextRef", "CGContextRefObj") -class MyObjectDefinition(GlobalObjectDefinition): +class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition): def outputStructMembers(self): ObjectDefinition.outputStructMembers(self) def outputCleanupStructMembers(self): diff --git a/Mac/Modules/cm/_Cmmodule.c b/Mac/Modules/cm/_Cmmodule.c index 8ea72f043e..5aaa79fe71 100644 --- a/Mac/Modules/cm/_Cmmodule.c +++ b/Mac/Modules/cm/_Cmmodule.c @@ -305,14 +305,7 @@ static PyMethodDef CmpInstObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain CmpInstObj_chain = { CmpInstObj_methods, NULL }; - -static PyObject *CmpInstObj_getattr(ComponentInstanceObject *self, char *name) -{ - return Py_FindMethodInChain(&CmpInstObj_chain, (PyObject *)self, name); -} - -#define CmpInstObj_setattr NULL +#define CmpInstObj_getsetlist NULL #define CmpInstObj_compare NULL @@ -329,14 +322,31 @@ PyTypeObject ComponentInstance_Type = { /* methods */ (destructor) CmpInstObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) CmpInstObj_getattr, /*tp_getattr*/ - (setattrfunc) CmpInstObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) CmpInstObj_compare, /*tp_compare*/ (reprfunc) CmpInstObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) CmpInstObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + CmpInstObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + CmpInstObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* --------------- End object type ComponentInstance ---------------- */ @@ -701,14 +711,7 @@ static PyMethodDef CmpObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain CmpObj_chain = { CmpObj_methods, NULL }; - -static PyObject *CmpObj_getattr(ComponentObject *self, char *name) -{ - return Py_FindMethodInChain(&CmpObj_chain, (PyObject *)self, name); -} - -#define CmpObj_setattr NULL +#define CmpObj_getsetlist NULL #define CmpObj_compare NULL @@ -725,14 +728,31 @@ PyTypeObject Component_Type = { /* methods */ (destructor) CmpObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) CmpObj_getattr, /*tp_getattr*/ - (setattrfunc) CmpObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) CmpObj_compare, /*tp_compare*/ (reprfunc) CmpObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) CmpObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + CmpObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + CmpObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* ------------------- End object type Component -------------------- */ diff --git a/Mac/Modules/cm/cmsupport.py b/Mac/Modules/cm/cmsupport.py index 0cf7fa118a..ee6c3426bc 100644 --- a/Mac/Modules/cm/cmsupport.py +++ b/Mac/Modules/cm/cmsupport.py @@ -79,14 +79,14 @@ ComponentResult = Type("ComponentResult", "l") ComponentResourceHandle = OpaqueByValueType("ComponentResourceHandle", "ResObj") -class MyCIObjectDefinition(GlobalObjectDefinition): +class MyCIObjectDefinition(PEP252Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("""if (itself == NULL) { PyErr_SetString(Cm_Error,"NULL ComponentInstance"); return NULL; }""") -class MyCObjectDefinition(GlobalObjectDefinition): +class MyCObjectDefinition(PEP252Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("""if (itself == NULL) { /* XXXX Or should we return None? */ diff --git a/Mac/Modules/ctl/_Ctlmodule.c b/Mac/Modules/ctl/_Ctlmodule.c index 0f88370236..aa0af9e0fb 100644 --- a/Mac/Modules/ctl/_Ctlmodule.c +++ b/Mac/Modules/ctl/_Ctlmodule.c @@ -4543,14 +4543,7 @@ static PyMethodDef CtlObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain CtlObj_chain = { CtlObj_methods, NULL }; - -static PyObject *CtlObj_getattr(ControlObject *self, char *name) -{ - return Py_FindMethodInChain(&CtlObj_chain, (PyObject *)self, name); -} - -#define CtlObj_setattr NULL +#define CtlObj_getsetlist NULL static int CtlObj_compare(ControlObject *self, ControlObject *other) { @@ -4587,14 +4580,31 @@ PyTypeObject Control_Type = { /* methods */ (destructor) CtlObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) CtlObj_getattr, /*tp_getattr*/ - (setattrfunc) CtlObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) CtlObj_compare, /*tp_compare*/ (reprfunc) CtlObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) CtlObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + CtlObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + CtlObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* -------------------- End object type Control --------------------- */ diff --git a/Mac/Modules/ctl/ctlsupport.py b/Mac/Modules/ctl/ctlsupport.py index bf3c91d8ba..6053f9316c 100644 --- a/Mac/Modules/ctl/ctlsupport.py +++ b/Mac/Modules/ctl/ctlsupport.py @@ -490,7 +490,7 @@ PyMac_INIT_TOOLBOX_OBJECT_NEW(ControlHandle, CtlObj_New); PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ControlHandle, CtlObj_Convert); """ -class MyObjectDefinition(ObjectIdentityMixin, GlobalObjectDefinition): +class MyObjectDefinition(PEP252Mixin, ObjectIdentityMixin, GlobalObjectDefinition): def outputStructMembers(self): GlobalObjectDefinition.outputStructMembers(self) Output("PyObject *ob_callbackdict;") diff --git a/Mac/Modules/dlg/_Dlgmodule.c b/Mac/Modules/dlg/_Dlgmodule.c index 6651622688..c35d7a649c 100644 --- a/Mac/Modules/dlg/_Dlgmodule.c +++ b/Mac/Modules/dlg/_Dlgmodule.c @@ -964,14 +964,7 @@ static PyMethodDef DlgObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain DlgObj_chain = { DlgObj_methods, NULL }; - -static PyObject *DlgObj_getattr(DialogObject *self, char *name) -{ - return Py_FindMethodInChain(&DlgObj_chain, (PyObject *)self, name); -} - -#define DlgObj_setattr NULL +#define DlgObj_getsetlist NULL static int DlgObj_compare(DialogObject *self, DialogObject *other) { @@ -996,14 +989,31 @@ PyTypeObject Dialog_Type = { /* methods */ (destructor) DlgObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) DlgObj_getattr, /*tp_getattr*/ - (setattrfunc) DlgObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) DlgObj_compare, /*tp_compare*/ (reprfunc) DlgObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) DlgObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + DlgObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + DlgObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* --------------------- End object type Dialog --------------------- */ diff --git a/Mac/Modules/dlg/dlgsupport.py b/Mac/Modules/dlg/dlgsupport.py index 2146906027..bf40a2c708 100644 --- a/Mac/Modules/dlg/dlgsupport.py +++ b/Mac/Modules/dlg/dlgsupport.py @@ -201,7 +201,7 @@ initstuff = initstuff + """ # Define a class which specializes our object definition -class MyObjectDefinition(GlobalObjectDefinition): +class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition): def __init__(self, name, prefix = None, itselftype = None): GlobalObjectDefinition.__init__(self, name, prefix, itselftype) ## This won't work in Carbon, so we disable it for all MacPythons:-( diff --git a/Mac/Modules/drag/_Dragmodule.c b/Mac/Modules/drag/_Dragmodule.c index 1e1dc8bb3a..b6354f4366 100644 --- a/Mac/Modules/drag/_Dragmodule.c +++ b/Mac/Modules/drag/_Dragmodule.c @@ -740,14 +740,7 @@ static PyMethodDef DragObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain DragObj_chain = { DragObj_methods, NULL }; - -static PyObject *DragObj_getattr(DragObjObject *self, char *name) -{ - return Py_FindMethodInChain(&DragObj_chain, (PyObject *)self, name); -} - -#define DragObj_setattr NULL +#define DragObj_getsetlist NULL #define DragObj_compare NULL @@ -764,14 +757,31 @@ PyTypeObject DragObj_Type = { /* methods */ (destructor) DragObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) DragObj_getattr, /*tp_getattr*/ - (setattrfunc) DragObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) DragObj_compare, /*tp_compare*/ (reprfunc) DragObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) DragObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + DragObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + DragObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* -------------------- End object type DragObj --------------------- */ diff --git a/Mac/Modules/drag/dragsupport.py b/Mac/Modules/drag/dragsupport.py index 1eaa28e0a2..3d2e76fee0 100644 --- a/Mac/Modules/drag/dragsupport.py +++ b/Mac/Modules/drag/dragsupport.py @@ -183,7 +183,7 @@ dragglue_DrawingUPP = NewDragDrawingUPP(dragglue_Drawing); #endif """ -class MyObjectDefinition(GlobalObjectDefinition): +class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("""if (itself == NULL) { PyErr_SetString(Drag_Error,"Cannot create null Drag"); diff --git a/Mac/Modules/evt/evtsupport.py b/Mac/Modules/evt/evtsupport.py index c05a3ed200..7dd7258a8f 100644 --- a/Mac/Modules/evt/evtsupport.py +++ b/Mac/Modules/evt/evtsupport.py @@ -43,25 +43,10 @@ includestuff = includestuff + """ """ -class MyObjectDefinition(GlobalObjectDefinition): - def outputCheckNewArg(self): - Output("if (itself == NULL) return PyMac_Error(resNotFound);") - def outputCheckConvertArg(self): - OutLbrace("if (DlgObj_Check(v))") - Output("*p_itself = ((WindowObject *)v)->ob_itself;") - Output("return 1;") - OutRbrace() - Out(""" - if (v == Py_None) { *p_itself = NULL; return 1; } - if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; } - """) - # From here on it's basically all boiler plate... # Create the generator groups and link them module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) -##object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE) -##module.addobject(object) # Create the generator classes used to populate the lists Function = OSErrWeakLinkFunctionGenerator @@ -69,7 +54,6 @@ Function = OSErrWeakLinkFunctionGenerator # Create and populate the lists functions = [] -##methods = [] execfile(INPUTFILE) # Move TickCount here, for convenience @@ -80,7 +64,6 @@ functions.append(f) # add the populated lists to the generator groups # (in a different wordl the scan program would generate this) for f in functions: module.add(f) -##for f in methods: object.add(f) WaitNextEvent_body = """ Boolean _rv; diff --git a/Mac/Modules/help/helpsupport.py b/Mac/Modules/help/helpsupport.py index 34b687198a..b59fe225cd 100644 --- a/Mac/Modules/help/helpsupport.py +++ b/Mac/Modules/help/helpsupport.py @@ -46,7 +46,7 @@ includestuff = includestuff + """ #endif """ -class MyObjectDefinition(GlobalObjectDefinition): +class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("if (itself == NULL) return PyMac_Error(resNotFound);") def outputCheckConvertArg(self): diff --git a/Mac/Modules/ibcarbon/IBCarbonsupport.py b/Mac/Modules/ibcarbon/IBCarbonsupport.py index a7bd3e910e..f948c53dd9 100644 --- a/Mac/Modules/ibcarbon/IBCarbonsupport.py +++ b/Mac/Modules/ibcarbon/IBCarbonsupport.py @@ -31,11 +31,11 @@ initstuff = """ module = MacModule('_IBCarbon', 'IBCarbon', includestuff, finalstuff, initstuff) -class CFReleaserObject(GlobalObjectDefinition): +class CFReleaserObject(PEP252Mixin, GlobalObjectDefinition): def outputFreeIt(self, name): Output("CFRelease(%s);" % name) -class CFNibDesc(GlobalObjectDefinition): +class CFNibDesc(PEP252Mixin, GlobalObjectDefinition): def outputFreeIt(self, name): Output("DisposeNibReference(%s);" % name) diff --git a/Mac/Modules/ibcarbon/_IBCarbon.c b/Mac/Modules/ibcarbon/_IBCarbon.c index fdddd849fb..eb9b4c9e7b 100644 --- a/Mac/Modules/ibcarbon/_IBCarbon.c +++ b/Mac/Modules/ibcarbon/_IBCarbon.c @@ -140,14 +140,7 @@ static PyMethodDef IBNibRefObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain IBNibRefObj_chain = { IBNibRefObj_methods, NULL }; - -static PyObject *IBNibRefObj_getattr(IBNibRefObject *self, char *name) -{ - return Py_FindMethodInChain(&IBNibRefObj_chain, (PyObject *)self, name); -} - -#define IBNibRefObj_setattr NULL +#define IBNibRefObj_getsetlist NULL #define IBNibRefObj_compare NULL @@ -164,14 +157,31 @@ PyTypeObject IBNibRef_Type = { /* methods */ (destructor) IBNibRefObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) IBNibRefObj_getattr, /*tp_getattr*/ - (setattrfunc) IBNibRefObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) IBNibRefObj_compare, /*tp_compare*/ (reprfunc) IBNibRefObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) IBNibRefObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + IBNibRefObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + IBNibRefObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* -------------------- End object type IBNibRef -------------------- */ diff --git a/Mac/Modules/icn/icnsupport.py b/Mac/Modules/icn/icnsupport.py index 242428e581..5d71bab30f 100644 --- a/Mac/Modules/icn/icnsupport.py +++ b/Mac/Modules/icn/icnsupport.py @@ -54,7 +54,7 @@ includestuff = includestuff + """ """ -class MyObjectDefinition(GlobalObjectDefinition): +class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("if (itself == NULL) return PyMac_Error(resNotFound);") def outputCheckConvertArg(self): diff --git a/Mac/Modules/list/_Listmodule.c b/Mac/Modules/list/_Listmodule.c index 99805b6b6b..559f543610 100644 --- a/Mac/Modules/list/_Listmodule.c +++ b/Mac/Modules/list/_Listmodule.c @@ -542,6 +542,138 @@ static PyObject *ListObj_LGetCellDataLocation(ListObject *_self, PyObject *_args return _res; } +static PyObject *ListObj_GetListPort(ListObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + CGrafPtr _rv; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = GetListPort(_self->ob_itself); + _res = Py_BuildValue("O&", + GrafObj_New, _rv); + return _res; +} + +static PyObject *ListObj_GetListVerticalScrollBar(ListObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + ControlHandle _rv; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = GetListVerticalScrollBar(_self->ob_itself); + _res = Py_BuildValue("O&", + CtlObj_New, _rv); + return _res; +} + +static PyObject *ListObj_GetListHorizontalScrollBar(ListObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + ControlHandle _rv; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = GetListHorizontalScrollBar(_self->ob_itself); + _res = Py_BuildValue("O&", + CtlObj_New, _rv); + return _res; +} + +static PyObject *ListObj_GetListActive(ListObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + Boolean _rv; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = GetListActive(_self->ob_itself); + _res = Py_BuildValue("b", + _rv); + return _res; +} + +static PyObject *ListObj_GetListClickTime(ListObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + SInt32 _rv; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = GetListClickTime(_self->ob_itself); + _res = Py_BuildValue("l", + _rv); + return _res; +} + +static PyObject *ListObj_GetListRefCon(ListObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + SInt32 _rv; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = GetListRefCon(_self->ob_itself); + _res = Py_BuildValue("l", + _rv); + return _res; +} + +static PyObject *ListObj_GetListDefinition(ListObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + Handle _rv; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = GetListDefinition(_self->ob_itself); + _res = Py_BuildValue("O&", + ResObj_New, _rv); + return _res; +} + +static PyObject *ListObj_GetListUserHandle(ListObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + Handle _rv; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = GetListUserHandle(_self->ob_itself); + _res = Py_BuildValue("O&", + ResObj_New, _rv); + return _res; +} + +static PyObject *ListObj_GetListDataHandle(ListObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + DataHandle _rv; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = GetListDataHandle(_self->ob_itself); + _res = Py_BuildValue("O&", + ResObj_New, _rv); + return _res; +} + +static PyObject *ListObj_GetListFlags(ListObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + OptionBits _rv; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = GetListFlags(_self->ob_itself); + _res = Py_BuildValue("l", + _rv); + return _res; +} + +static PyObject *ListObj_GetListSelectionFlags(ListObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + OptionBits _rv; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = GetListSelectionFlags(_self->ob_itself); + _res = Py_BuildValue("l", + _rv); + return _res; +} + static PyObject *ListObj_as_Resource(ListObject *_self, PyObject *_args) { PyObject *_res = NULL; @@ -601,48 +733,73 @@ static PyMethodDef ListObj_methods[] = { PyDoc_STR("(Point theCell) -> None")}, {"LGetCellDataLocation", (PyCFunction)ListObj_LGetCellDataLocation, 1, PyDoc_STR("(Point theCell) -> (short offset, short len)")}, + {"GetListPort", (PyCFunction)ListObj_GetListPort, 1, + PyDoc_STR("() -> (CGrafPtr _rv)")}, + {"GetListVerticalScrollBar", (PyCFunction)ListObj_GetListVerticalScrollBar, 1, + PyDoc_STR("() -> (ControlHandle _rv)")}, + {"GetListHorizontalScrollBar", (PyCFunction)ListObj_GetListHorizontalScrollBar, 1, + PyDoc_STR("() -> (ControlHandle _rv)")}, + {"GetListActive", (PyCFunction)ListObj_GetListActive, 1, + PyDoc_STR("() -> (Boolean _rv)")}, + {"GetListClickTime", (PyCFunction)ListObj_GetListClickTime, 1, + PyDoc_STR("() -> (SInt32 _rv)")}, + {"GetListRefCon", (PyCFunction)ListObj_GetListRefCon, 1, + PyDoc_STR("() -> (SInt32 _rv)")}, + {"GetListDefinition", (PyCFunction)ListObj_GetListDefinition, 1, + PyDoc_STR("() -> (Handle _rv)")}, + {"GetListUserHandle", (PyCFunction)ListObj_GetListUserHandle, 1, + PyDoc_STR("() -> (Handle _rv)")}, + {"GetListDataHandle", (PyCFunction)ListObj_GetListDataHandle, 1, + PyDoc_STR("() -> (DataHandle _rv)")}, + {"GetListFlags", (PyCFunction)ListObj_GetListFlags, 1, + PyDoc_STR("() -> (OptionBits _rv)")}, + {"GetListSelectionFlags", (PyCFunction)ListObj_GetListSelectionFlags, 1, + PyDoc_STR("() -> (OptionBits _rv)")}, {"as_Resource", (PyCFunction)ListObj_as_Resource, 1, PyDoc_STR("() -> (Handle _rv)")}, {NULL, NULL, 0} }; -PyMethodChain ListObj_chain = { ListObj_methods, NULL }; +static PyObject *ListObj_get_listFlags(ListObject *self, void *closure) +{ + return Py_BuildValue("l", (long)GetListFlags(self->ob_itself) & 0xff); +} -static PyObject *ListObj_getattr(ListObject *self, char *name) +static int ListObj_set_listFlags(ListObject *self, PyObject *v, void *closure) { - { - if ( strcmp(name, "listFlags") == 0 ) - return Py_BuildValue("l", (long)GetListFlags(self->ob_itself) & 0xff); - if ( strcmp(name, "selFlags") == 0 ) - return Py_BuildValue("l", (long)GetListSelectionFlags(self->ob_itself) & 0xff); - if ( strcmp(name, "cellSize") == 0 ) - return Py_BuildValue("O&", PyMac_BuildPoint, (*self->ob_itself)->cellSize); - } - return Py_FindMethodInChain(&ListObj_chain, (PyObject *)self, name); + if (!PyArg_Parse(v, "B", &(*self->ob_itself)->listFlags)) return -1; + return 0; } -static int -ListObj_setattr(ListObject *self, char *name, PyObject *value) +static PyObject *ListObj_get_selFlags(ListObject *self, void *closure) { - long intval; - int err = 0; - - if ( value == NULL ) { - PyErr_SetString(PyExc_AttributeError, "Cannot delete attribute"); - return -1; - } - if (strcmp(name, "listFlags") == 0 ) - err = PyArg_Parse(value, "B", &(*self->ob_itself)->listFlags); - else if (strcmp(name, "selFlags") == 0 ) - err = PyArg_Parse(value, "B", &(*self->ob_itself)->selFlags); - else if (strcmp(name, "cellSize") == 0 ) - err = PyArg_Parse(value, "O&", PyMac_GetPoint, &(*self->ob_itself)->cellSize); - else - PyErr_SetString(PyExc_AttributeError, "No such attribute"); - if (err) return 0; - else return -1; + return Py_BuildValue("l", (long)GetListSelectionFlags(self->ob_itself) & 0xff); +} + +static int ListObj_set_selFlags(ListObject *self, PyObject *v, void *closure) +{ + if (!PyArg_Parse(v, "B", &(*self->ob_itself)->selFlags)) return -1; + return 0; +} + +static PyObject *ListObj_get_cellSize(ListObject *self, void *closure) +{ + return Py_BuildValue("O&", PyMac_BuildPoint, (*self->ob_itself)->cellSize); +} + +static int ListObj_set_cellSize(ListObject *self, PyObject *v, void *closure) +{ + if (!PyArg_Parse(v, "O&", PyMac_GetPoint, &(*self->ob_itself)->cellSize)) return -1; + return 0; } +static PyGetSetDef ListObj_getsetlist[] = { + {"listFlags", (getter)ListObj_get_listFlags, (setter)ListObj_set_listFlags, NULL}, + {"selFlags", (getter)ListObj_get_selFlags, (setter)ListObj_set_selFlags, NULL}, + {"cellSize", (getter)ListObj_get_cellSize, (setter)ListObj_set_cellSize, NULL}, + {NULL, NULL, NULL, NULL}, +}; + #define ListObj_compare NULL @@ -659,14 +816,31 @@ PyTypeObject List_Type = { /* methods */ (destructor) ListObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) ListObj_getattr, /*tp_getattr*/ - (setattrfunc) ListObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) ListObj_compare, /*tp_compare*/ (reprfunc) ListObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) ListObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + ListObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + ListObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* ---------------------- End object type List ---------------------- */ @@ -783,160 +957,6 @@ static PyObject *List_LNew(PyObject *_self, PyObject *_args) return _res; } -static PyObject *List_GetListPort(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - CGrafPtr _rv; - ListHandle list; - if (!PyArg_ParseTuple(_args, "O&", - ListObj_Convert, &list)) - return NULL; - _rv = GetListPort(list); - _res = Py_BuildValue("O&", - GrafObj_New, _rv); - return _res; -} - -static PyObject *List_GetListVerticalScrollBar(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - ControlHandle _rv; - ListHandle list; - if (!PyArg_ParseTuple(_args, "O&", - ListObj_Convert, &list)) - return NULL; - _rv = GetListVerticalScrollBar(list); - _res = Py_BuildValue("O&", - CtlObj_New, _rv); - return _res; -} - -static PyObject *List_GetListHorizontalScrollBar(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - ControlHandle _rv; - ListHandle list; - if (!PyArg_ParseTuple(_args, "O&", - ListObj_Convert, &list)) - return NULL; - _rv = GetListHorizontalScrollBar(list); - _res = Py_BuildValue("O&", - CtlObj_New, _rv); - return _res; -} - -static PyObject *List_GetListActive(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - Boolean _rv; - ListHandle list; - if (!PyArg_ParseTuple(_args, "O&", - ListObj_Convert, &list)) - return NULL; - _rv = GetListActive(list); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *List_GetListClickTime(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - SInt32 _rv; - ListHandle list; - if (!PyArg_ParseTuple(_args, "O&", - ListObj_Convert, &list)) - return NULL; - _rv = GetListClickTime(list); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *List_GetListRefCon(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - SInt32 _rv; - ListHandle list; - if (!PyArg_ParseTuple(_args, "O&", - ListObj_Convert, &list)) - return NULL; - _rv = GetListRefCon(list); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *List_GetListDefinition(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - Handle _rv; - ListHandle list; - if (!PyArg_ParseTuple(_args, "O&", - ListObj_Convert, &list)) - return NULL; - _rv = GetListDefinition(list); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *List_GetListUserHandle(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - Handle _rv; - ListHandle list; - if (!PyArg_ParseTuple(_args, "O&", - ListObj_Convert, &list)) - return NULL; - _rv = GetListUserHandle(list); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *List_GetListDataHandle(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - DataHandle _rv; - ListHandle list; - if (!PyArg_ParseTuple(_args, "O&", - ListObj_Convert, &list)) - return NULL; - _rv = GetListDataHandle(list); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *List_GetListFlags(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - OptionBits _rv; - ListHandle list; - if (!PyArg_ParseTuple(_args, "O&", - ListObj_Convert, &list)) - return NULL; - _rv = GetListFlags(list); - _res = Py_BuildValue("l", - _rv); - return _res; -} - -static PyObject *List_GetListSelectionFlags(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - OptionBits _rv; - ListHandle list; - if (!PyArg_ParseTuple(_args, "O&", - ListObj_Convert, &list)) - return NULL; - _rv = GetListSelectionFlags(list); - _res = Py_BuildValue("l", - _rv); - return _res; -} - static PyObject *List_SetListViewBounds(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; @@ -1085,28 +1105,6 @@ static PyMethodDef List_methods[] = { PyDoc_STR("(Rect rView, Rect dataBounds, Point cellSize, ListDefSpec theSpec, WindowPtr theWindow, Boolean drawIt, Boolean hasGrow, Boolean scrollHoriz, Boolean scrollVert) -> (ListHandle outList)")}, {"LNew", (PyCFunction)List_LNew, 1, PyDoc_STR("(Rect rView, Rect dataBounds, Point cSize, short theProc, WindowPtr theWindow, Boolean drawIt, Boolean hasGrow, Boolean scrollHoriz, Boolean scrollVert) -> (ListHandle _rv)")}, - {"GetListPort", (PyCFunction)List_GetListPort, 1, - PyDoc_STR("(ListHandle list) -> (CGrafPtr _rv)")}, - {"GetListVerticalScrollBar", (PyCFunction)List_GetListVerticalScrollBar, 1, - PyDoc_STR("(ListHandle list) -> (ControlHandle _rv)")}, - {"GetListHorizontalScrollBar", (PyCFunction)List_GetListHorizontalScrollBar, 1, - PyDoc_STR("(ListHandle list) -> (ControlHandle _rv)")}, - {"GetListActive", (PyCFunction)List_GetListActive, 1, - PyDoc_STR("(ListHandle list) -> (Boolean _rv)")}, - {"GetListClickTime", (PyCFunction)List_GetListClickTime, 1, - PyDoc_STR("(ListHandle list) -> (SInt32 _rv)")}, - {"GetListRefCon", (PyCFunction)List_GetListRefCon, 1, - PyDoc_STR("(ListHandle list) -> (SInt32 _rv)")}, - {"GetListDefinition", (PyCFunction)List_GetListDefinition, 1, - PyDoc_STR("(ListHandle list) -> (Handle _rv)")}, - {"GetListUserHandle", (PyCFunction)List_GetListUserHandle, 1, - PyDoc_STR("(ListHandle list) -> (Handle _rv)")}, - {"GetListDataHandle", (PyCFunction)List_GetListDataHandle, 1, - PyDoc_STR("(ListHandle list) -> (DataHandle _rv)")}, - {"GetListFlags", (PyCFunction)List_GetListFlags, 1, - PyDoc_STR("(ListHandle list) -> (OptionBits _rv)")}, - {"GetListSelectionFlags", (PyCFunction)List_GetListSelectionFlags, 1, - PyDoc_STR("(ListHandle list) -> (OptionBits _rv)")}, {"SetListViewBounds", (PyCFunction)List_SetListViewBounds, 1, PyDoc_STR("(ListHandle list, Rect view) -> None")}, {"SetListPort", (PyCFunction)List_SetListPort, 1, diff --git a/Mac/Modules/list/listscan.py b/Mac/Modules/list/listscan.py index d835a688be..66cb2adf5d 100644 --- a/Mac/Modules/list/listscan.py +++ b/Mac/Modules/list/listscan.py @@ -31,7 +31,7 @@ class MyScanner(Scanner): if arglist: t, n, m = arglist[-1] # This is non-functional today - if t == OBJECT and m == "InMode": + if t in ('ListHandle', 'ListRef') and m == "InMode": classname = "Method" listname = "methods" return classname, listname diff --git a/Mac/Modules/list/listsupport.py b/Mac/Modules/list/listsupport.py index 23a2a840b1..87ed702e50 100644 --- a/Mac/Modules/list/listsupport.py +++ b/Mac/Modules/list/listsupport.py @@ -137,41 +137,23 @@ class ListMethodGenerator(MethodGenerator): FunctionGenerator.parseArgumentList(self, args) self.argumentList.append(self.itself) -getattrHookCode = """{ - if ( strcmp(name, "listFlags") == 0 ) - return Py_BuildValue("l", (long)GetListFlags(self->ob_itself) & 0xff); - if ( strcmp(name, "selFlags") == 0 ) - return Py_BuildValue("l", (long)GetListSelectionFlags(self->ob_itself) & 0xff); - if ( strcmp(name, "cellSize") == 0 ) - return Py_BuildValue("O&", PyMac_BuildPoint, (*self->ob_itself)->cellSize); -}""" - -setattrCode = """ -static int -ListObj_setattr(ListObject *self, char *name, PyObject *value) -{ - long intval; - int err = 0; - - if ( value == NULL ) { - PyErr_SetString(PyExc_AttributeError, "Cannot delete attribute"); - return -1; - } - if (strcmp(name, "listFlags") == 0 ) - err = PyArg_Parse(value, "B", &(*self->ob_itself)->listFlags); - else if (strcmp(name, "selFlags") == 0 ) - err = PyArg_Parse(value, "B", &(*self->ob_itself)->selFlags); - else if (strcmp(name, "cellSize") == 0 ) - err = PyArg_Parse(value, "O&", PyMac_GetPoint, &(*self->ob_itself)->cellSize); - else - PyErr_SetString(PyExc_AttributeError, "No such attribute"); - if (err) return 0; - else return -1; -} -""" - - -class MyObjectDefinition(GlobalObjectDefinition): +class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition): + getsetlist = [( + 'listFlags', + 'return Py_BuildValue("l", (long)GetListFlags(self->ob_itself) & 0xff);', + 'if (!PyArg_Parse(v, "B", &(*self->ob_itself)->listFlags)) return -1;', + None, + ), ( + 'selFlags', + 'return Py_BuildValue("l", (long)GetListSelectionFlags(self->ob_itself) & 0xff);', + 'if (!PyArg_Parse(v, "B", &(*self->ob_itself)->selFlags)) return -1;', + None, + ), ( + 'cellSize', + 'return Py_BuildValue("O&", PyMac_BuildPoint, (*self->ob_itself)->cellSize);', + 'if (!PyArg_Parse(v, "O&", PyMac_GetPoint, &(*self->ob_itself)->cellSize)) return -1;', + None + )] def outputStructMembers(self): ObjectDefinition.outputStructMembers(self) @@ -201,12 +183,6 @@ class MyObjectDefinition(GlobalObjectDefinition): Output("SetListRefCon(self->ob_itself, (long)0);") Output("if (self->ob_must_be_disposed && %s) LDispose(%s);", itselfname, itselfname) - def outputGetattrHook(self): - Output(getattrHookCode) - - def outputSetattr(self): - Output(setattrCode) - # From here on it's basically all boiler plate... finalstuff = finalstuff + """ diff --git a/Mac/Modules/menu/_Menumodule.c b/Mac/Modules/menu/_Menumodule.c index bf860fe483..517e08a658 100644 --- a/Mac/Modules/menu/_Menumodule.c +++ b/Mac/Modules/menu/_Menumodule.c @@ -3000,14 +3000,7 @@ static PyMethodDef MenuObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain MenuObj_chain = { MenuObj_methods, NULL }; - -static PyObject *MenuObj_getattr(MenuObject *self, char *name) -{ - return Py_FindMethodInChain(&MenuObj_chain, (PyObject *)self, name); -} - -#define MenuObj_setattr NULL +#define MenuObj_getsetlist NULL #define MenuObj_compare NULL @@ -3024,14 +3017,31 @@ PyTypeObject Menu_Type = { /* methods */ (destructor) MenuObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) MenuObj_getattr, /*tp_getattr*/ - (setattrfunc) MenuObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) MenuObj_compare, /*tp_compare*/ (reprfunc) MenuObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) MenuObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + MenuObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + MenuObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* ---------------------- End object type Menu ---------------------- */ diff --git a/Mac/Modules/menu/menusupport.py b/Mac/Modules/menu/menusupport.py index b96bc21f2f..1f218265cd 100644 --- a/Mac/Modules/menu/menusupport.py +++ b/Mac/Modules/menu/menusupport.py @@ -98,7 +98,7 @@ initstuff = initstuff + """ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(MenuHandle, MenuObj_Convert); """ -class MyObjectDefinition(GlobalObjectDefinition): +class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition): pass # Create the generator groups and link them diff --git a/Mac/Modules/mlte/_Mltemodule.c b/Mac/Modules/mlte/_Mltemodule.c index 38cb4f210a..84b61303c2 100644 --- a/Mac/Modules/mlte/_Mltemodule.c +++ b/Mac/Modules/mlte/_Mltemodule.c @@ -1295,14 +1295,7 @@ static PyMethodDef TXNObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain TXNObj_chain = { TXNObj_methods, NULL }; - -static PyObject *TXNObj_getattr(TXNObjectObject *self, char *name) -{ - return Py_FindMethodInChain(&TXNObj_chain, (PyObject *)self, name); -} - -#define TXNObj_setattr NULL +#define TXNObj_getsetlist NULL #define TXNObj_compare NULL @@ -1319,14 +1312,31 @@ PyTypeObject TXNObject_Type = { /* methods */ (destructor) TXNObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) TXNObj_getattr, /*tp_getattr*/ - (setattrfunc) TXNObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) TXNObj_compare, /*tp_compare*/ (reprfunc) TXNObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) TXNObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + TXNObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + TXNObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* ------------------- End object type TXNObject -------------------- */ @@ -1411,14 +1421,7 @@ static PyMethodDef TXNFontMenuObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain TXNFontMenuObj_chain = { TXNFontMenuObj_methods, NULL }; - -static PyObject *TXNFontMenuObj_getattr(TXNFontMenuObjectObject *self, char *name) -{ - return Py_FindMethodInChain(&TXNFontMenuObj_chain, (PyObject *)self, name); -} - -#define TXNFontMenuObj_setattr NULL +#define TXNFontMenuObj_getsetlist NULL #define TXNFontMenuObj_compare NULL @@ -1435,14 +1438,31 @@ PyTypeObject TXNFontMenuObject_Type = { /* methods */ (destructor) TXNFontMenuObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) TXNFontMenuObj_getattr, /*tp_getattr*/ - (setattrfunc) TXNFontMenuObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) TXNFontMenuObj_compare, /*tp_compare*/ (reprfunc) TXNFontMenuObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) TXNFontMenuObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + TXNFontMenuObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + TXNFontMenuObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* --------------- End object type TXNFontMenuObject ---------------- */ diff --git a/Mac/Modules/mlte/mltesupport.py b/Mac/Modules/mlte/mltesupport.py index a238145ec2..e9df43fbbe 100644 --- a/Mac/Modules/mlte/mltesupport.py +++ b/Mac/Modules/mlte/mltesupport.py @@ -136,11 +136,11 @@ execfile("mltetypetest.py") # Our (opaque) objects -class TXNObjDefinition(GlobalObjectDefinition): +class TXNObjDefinition(PEP252Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("if (itself == NULL) return PyMac_Error(resNotFound);") -class TXNFontMenuObjDefinition(GlobalObjectDefinition): +class TXNFontMenuObjDefinition(PEP252Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("if (itself == NULL) return PyMac_Error(resNotFound);") diff --git a/Mac/Modules/qd/_Qdmodule.c b/Mac/Modules/qd/_Qdmodule.c index 1084031d57..7ee2e981e6 100644 --- a/Mac/Modules/qd/_Qdmodule.c +++ b/Mac/Modules/qd/_Qdmodule.c @@ -205,1318 +205,1289 @@ static void GrafObj_dealloc(GrafPortObject *self) PyObject_Del(self); } -static PyMethodDef GrafObj_methods[] = { - {NULL, NULL, 0} -}; - -PyMethodChain GrafObj_chain = { GrafObj_methods, NULL }; - -static PyObject *GrafObj_getattr(GrafPortObject *self, char *name) -{ -#if !ACCESSOR_CALLS_ARE_FUNCTIONS - - { CGrafPtr itself_color = (CGrafPtr)self->ob_itself; - - if ( strcmp(name, "data") == 0 ) - return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(GrafPort)); - - if ( (itself_color->portVersion&0xc000) == 0xc000 ) { - /* Color-only attributes */ - - if ( strcmp(name, "portBits") == 0 ) - /* XXXX Do we need HLock() stuff here?? */ - return BMObj_New((BitMapPtr)*itself_color->portPixMap); - if ( strcmp(name, "grafVars") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->visRgn); - if ( strcmp(name, "chExtra") == 0 ) - return Py_BuildValue("h", itself_color->chExtra); - if ( strcmp(name, "pnLocHFrac") == 0 ) - return Py_BuildValue("h", itself_color->pnLocHFrac); - if ( strcmp(name, "bkPixPat") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->bkPixPat); - if ( strcmp(name, "rgbFgColor") == 0 ) - return Py_BuildValue("O&", QdRGB_New, &itself_color->rgbFgColor); - if ( strcmp(name, "rgbBkColor") == 0 ) - return Py_BuildValue("O&", QdRGB_New, &itself_color->rgbBkColor); - if ( strcmp(name, "pnPixPat") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->pnPixPat); - if ( strcmp(name, "fillPixPat") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->fillPixPat); - } else { - /* Mono-only attributes */ - if ( strcmp(name, "portBits") == 0 ) - return BMObj_New(&self->ob_itself->portBits); - if ( strcmp(name, "bkPat") == 0 ) - return Py_BuildValue("s#", (char *)&self->ob_itself->bkPat, sizeof(Pattern)); - if ( strcmp(name, "fillPat") == 0 ) - return Py_BuildValue("s#", (char *)&self->ob_itself->fillPat, sizeof(Pattern)); - if ( strcmp(name, "pnPat") == 0 ) - return Py_BuildValue("s#", (char *)&self->ob_itself->pnPat, sizeof(Pattern)); - } - /* - ** Accessible for both color/mono windows. - ** portVersion is really color-only, but we put it here - ** for convenience - */ - if ( strcmp(name, "portVersion") == 0 ) - return Py_BuildValue("h", itself_color->portVersion); - if ( strcmp(name, "device") == 0 ) - return PyInt_FromLong((long)self->ob_itself->device); - if ( strcmp(name, "portRect") == 0 ) - return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect); - if ( strcmp(name, "visRgn") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->visRgn); - if ( strcmp(name, "clipRgn") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->clipRgn); - if ( strcmp(name, "pnLoc") == 0 ) - return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnLoc); - if ( strcmp(name, "pnSize") == 0 ) - return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnSize); - if ( strcmp(name, "pnMode") == 0 ) - return Py_BuildValue("h", self->ob_itself->pnMode); - if ( strcmp(name, "pnVis") == 0 ) - return Py_BuildValue("h", self->ob_itself->pnVis); - if ( strcmp(name, "txFont") == 0 ) - return Py_BuildValue("h", self->ob_itself->txFont); - if ( strcmp(name, "txFace") == 0 ) - return Py_BuildValue("h", (short)self->ob_itself->txFace); - if ( strcmp(name, "txMode") == 0 ) - return Py_BuildValue("h", self->ob_itself->txMode); - if ( strcmp(name, "txSize") == 0 ) - return Py_BuildValue("h", self->ob_itself->txSize); - if ( strcmp(name, "spExtra") == 0 ) - return Py_BuildValue("O&", PyMac_BuildFixed, self->ob_itself->spExtra); - /* XXXX Add more, as needed */ - /* This one is so we can compare grafports: */ - if ( strcmp(name, "_id") == 0 ) - return Py_BuildValue("l", (long)self->ob_itself); - } -#else - - { CGrafPtr itself_color = (CGrafPtr)self->ob_itself; - if ( strcmp(name, "portBits") == 0 ) - return BMObj_New((BitMapPtr)GetPortBitMapForCopyBits(itself_color)); - if ( strcmp(name, "chExtra") == 0 ) - return Py_BuildValue("h", GetPortChExtra(itself_color)); - if ( strcmp(name, "pnLocHFrac") == 0 ) - return Py_BuildValue("h", GetPortFracHPenLocation(itself_color)); - if ( strcmp(name, "bkPixPat") == 0 ) { - PixPatHandle h=0; - return Py_BuildValue("O&", ResObj_New, (Handle)GetPortBackPixPat(itself_color, h)); - } - if ( strcmp(name, "rgbFgColor") == 0 ) { - RGBColor c; - return Py_BuildValue("O&", QdRGB_New, GetPortForeColor(itself_color, &c)); - } - if ( strcmp(name, "rgbBkColor") == 0 ) { - RGBColor c; - return Py_BuildValue("O&", QdRGB_New, GetPortBackColor(itself_color, &c)); - } - if ( strcmp(name, "pnPixPat") == 0 ) { - PixPatHandle h=NewPixPat(); /* XXXX wrong dispose routine */ - - return Py_BuildValue("O&", ResObj_New, (Handle)GetPortPenPixPat(itself_color, h)); - } - if ( strcmp(name, "fillPixPat") == 0 ) { - PixPatHandle h=NewPixPat(); /* XXXX wrong dispose routine */ - return Py_BuildValue("O&", ResObj_New, (Handle)GetPortFillPixPat(itself_color, h)); - } - if ( strcmp(name, "portRect") == 0 ) { - Rect r; - return Py_BuildValue("O&", PyMac_BuildRect, GetPortBounds(itself_color, &r)); - } - if ( strcmp(name, "visRgn") == 0 ) { - RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */ - return Py_BuildValue("O&", ResObj_New, (Handle)GetPortVisibleRegion(itself_color, h)); - } - if ( strcmp(name, "clipRgn") == 0 ) { - RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */ - return Py_BuildValue("O&", ResObj_New, (Handle)GetPortClipRegion(itself_color, h)); - } - if ( strcmp(name, "pnLoc") == 0 ) { - Point p; - return Py_BuildValue("O&", PyMac_BuildPoint, *GetPortPenLocation(itself_color, &p)); - } - if ( strcmp(name, "pnSize") == 0 ) { - Point p; - return Py_BuildValue("O&", PyMac_BuildPoint, *GetPortPenSize(itself_color, &p)); - } - if ( strcmp(name, "pnMode") == 0 ) - return Py_BuildValue("h", GetPortPenMode(itself_color)); - if ( strcmp(name, "pnVis") == 0 ) - return Py_BuildValue("h", GetPortPenVisibility(itself_color)); - if ( strcmp(name, "txFont") == 0 ) - return Py_BuildValue("h", GetPortTextFont(itself_color)); - if ( strcmp(name, "txFace") == 0 ) - return Py_BuildValue("h", (short)GetPortTextFace(itself_color)); - if ( strcmp(name, "txMode") == 0 ) - return Py_BuildValue("h", GetPortTextMode(itself_color)); - if ( strcmp(name, "txSize") == 0 ) - return Py_BuildValue("h", GetPortTextSize(itself_color)); - if ( strcmp(name, "spExtra") == 0 ) - return Py_BuildValue("O&", PyMac_BuildFixed, GetPortSpExtra(itself_color)); - /* XXXX Add more, as needed */ - /* This one is so we can compare grafports: */ - if ( strcmp(name, "_id") == 0 ) - return Py_BuildValue("l", (long)self->ob_itself); - } -#endif - return Py_FindMethodInChain(&GrafObj_chain, (PyObject *)self, name); -} - -#define GrafObj_setattr NULL - -#define GrafObj_compare NULL - -#define GrafObj_repr NULL - -#define GrafObj_hash NULL - -PyTypeObject GrafPort_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "_Qd.GrafPort", /*tp_name*/ - sizeof(GrafPortObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) GrafObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) GrafObj_getattr, /*tp_getattr*/ - (setattrfunc) GrafObj_setattr, /*tp_setattr*/ - (cmpfunc) GrafObj_compare, /*tp_compare*/ - (reprfunc) GrafObj_repr, /*tp_repr*/ - (PyNumberMethods *)0, /* tp_as_number */ - (PySequenceMethods *)0, /* tp_as_sequence */ - (PyMappingMethods *)0, /* tp_as_mapping */ - (hashfunc) GrafObj_hash, /*tp_hash*/ -}; - -/* -------------------- End object type GrafPort -------------------- */ - - -/* ----------------------- Object type BitMap ----------------------- */ - -PyTypeObject BitMap_Type; - -#define BMObj_Check(x) ((x)->ob_type == &BitMap_Type) - -typedef struct BitMapObject { - PyObject_HEAD - BitMapPtr ob_itself; - PyObject *referred_object; - BitMap *referred_bitmap; -} BitMapObject; - -PyObject *BMObj_New(BitMapPtr itself) -{ - BitMapObject *it; - if (itself == NULL) return PyMac_Error(resNotFound); - it = PyObject_NEW(BitMapObject, &BitMap_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - it->referred_object = NULL; - it->referred_bitmap = NULL; - return (PyObject *)it; -} -int BMObj_Convert(PyObject *v, BitMapPtr *p_itself) +static PyObject *GrafObj_MacSetPort(GrafPortObject *_self, PyObject *_args) { - if (!BMObj_Check(v)) - { - PyErr_SetString(PyExc_TypeError, "BitMap required"); - return 0; - } - *p_itself = ((BitMapObject *)v)->ob_itself; - return 1; + PyObject *_res = NULL; +#ifndef MacSetPort + PyMac_PRECHECK(MacSetPort); +#endif + if (!PyArg_ParseTuple(_args, "")) + return NULL; + MacSetPort(_self->ob_itself); + Py_INCREF(Py_None); + _res = Py_None; + return _res; } -static void BMObj_dealloc(BitMapObject *self) -{ - Py_XDECREF(self->referred_object); - if (self->referred_bitmap) free(self->referred_bitmap); - PyObject_Del(self); -} +#if TARGET_API_MAC_CARBON -static PyObject *BMObj_getdata(BitMapObject *_self, PyObject *_args) +static PyObject *GrafObj_IsValidPort(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - - int from, length; - char *cp; - - if ( !PyArg_ParseTuple(_args, "ii", &from, &length) ) + Boolean _rv; +#ifndef IsValidPort + PyMac_PRECHECK(IsValidPort); +#endif + if (!PyArg_ParseTuple(_args, "")) return NULL; - cp = _self->ob_itself->baseAddr+from; - _res = PyString_FromStringAndSize(cp, length); + _rv = IsValidPort(_self->ob_itself); + _res = Py_BuildValue("b", + _rv); return _res; - } +#endif -static PyObject *BMObj_putdata(BitMapObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortPixMap(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - - int from, length; - char *cp, *icp; - - if ( !PyArg_ParseTuple(_args, "is#", &from, &icp, &length) ) + PixMapHandle _rv; +#ifndef GetPortPixMap + PyMac_PRECHECK(GetPortPixMap); +#endif + if (!PyArg_ParseTuple(_args, "")) return NULL; - cp = _self->ob_itself->baseAddr+from; - memcpy(cp, icp, length); - Py_INCREF(Py_None); - _res = Py_None; + _rv = GetPortPixMap(_self->ob_itself); + _res = Py_BuildValue("O&", + ResObj_New, _rv); return _res; - -} - -static PyMethodDef BMObj_methods[] = { - {"getdata", (PyCFunction)BMObj_getdata, 1, - PyDoc_STR("(int start, int size) -> string. Return bytes from the bitmap")}, - {"putdata", (PyCFunction)BMObj_putdata, 1, - PyDoc_STR("(int start, string data). Store bytes into the bitmap")}, - {NULL, NULL, 0} -}; - -PyMethodChain BMObj_chain = { BMObj_methods, NULL }; - -static PyObject *BMObj_getattr(BitMapObject *self, char *name) -{ - if ( strcmp(name, "baseAddr") == 0 ) - return PyInt_FromLong((long)self->ob_itself->baseAddr); - if ( strcmp(name, "rowBytes") == 0 ) - return PyInt_FromLong((long)self->ob_itself->rowBytes); - 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); -} - -#define BMObj_setattr NULL - -#define BMObj_compare NULL - -#define BMObj_repr NULL - -#define BMObj_hash NULL - -PyTypeObject BitMap_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "_Qd.BitMap", /*tp_name*/ - sizeof(BitMapObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) BMObj_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) BMObj_getattr, /*tp_getattr*/ - (setattrfunc) BMObj_setattr, /*tp_setattr*/ - (cmpfunc) BMObj_compare, /*tp_compare*/ - (reprfunc) BMObj_repr, /*tp_repr*/ - (PyNumberMethods *)0, /* tp_as_number */ - (PySequenceMethods *)0, /* tp_as_sequence */ - (PyMappingMethods *)0, /* tp_as_mapping */ - (hashfunc) BMObj_hash, /*tp_hash*/ -}; - -/* --------------------- End object type BitMap --------------------- */ - - -/* ------------------ Object type QDGlobalsAccess ------------------- */ - -static PyTypeObject QDGlobalsAccess_Type; - -#define QDGA_Check(x) ((x)->ob_type == &QDGlobalsAccess_Type) - -typedef struct QDGlobalsAccessObject { - PyObject_HEAD -} QDGlobalsAccessObject; - -static PyObject *QDGA_New(void) -{ - QDGlobalsAccessObject *it; - it = PyObject_NEW(QDGlobalsAccessObject, &QDGlobalsAccess_Type); - if (it == NULL) return NULL; - return (PyObject *)it; -} - -static void QDGA_dealloc(QDGlobalsAccessObject *self) -{ - PyObject_Del(self); } -static PyMethodDef QDGA_methods[] = { - {NULL, NULL, 0} -}; - -static PyMethodChain QDGA_chain = { QDGA_methods, NULL }; - -static PyObject *QDGA_getattr(QDGlobalsAccessObject *self, char *name) +static PyObject *GrafObj_GetPortBitMapForCopyBits(GrafPortObject *_self, PyObject *_args) { -#if !ACCESSOR_CALLS_ARE_FUNCTIONS - - if ( strcmp(name, "arrow") == 0 ) - return PyString_FromStringAndSize((char *)&qd.arrow, sizeof(qd.arrow)); - if ( strcmp(name, "black") == 0 ) - return PyString_FromStringAndSize((char *)&qd.black, sizeof(qd.black)); - if ( strcmp(name, "white") == 0 ) - return PyString_FromStringAndSize((char *)&qd.white, sizeof(qd.white)); - if ( strcmp(name, "gray") == 0 ) - return PyString_FromStringAndSize((char *)&qd.gray, sizeof(qd.gray)); - if ( strcmp(name, "ltGray") == 0 ) - return PyString_FromStringAndSize((char *)&qd.ltGray, sizeof(qd.ltGray)); - if ( strcmp(name, "dkGray") == 0 ) - return PyString_FromStringAndSize((char *)&qd.dkGray, sizeof(qd.dkGray)); - if ( strcmp(name, "screenBits") == 0 ) - return BMObj_New(&qd.screenBits); - if ( strcmp(name, "thePort") == 0 ) - return GrafObj_New(qd.thePort); - if ( strcmp(name, "randSeed") == 0 ) - return Py_BuildValue("l", &qd.randSeed); - -#else - - if ( strcmp(name, "arrow") == 0 ) { - Cursor rv; - GetQDGlobalsArrow(&rv); - return PyString_FromStringAndSize((char *)&rv, sizeof(rv)); - } - if ( strcmp(name, "black") == 0 ) { - Pattern rv; - GetQDGlobalsBlack(&rv); - return PyString_FromStringAndSize((char *)&rv, sizeof(rv)); - } - if ( strcmp(name, "white") == 0 ) { - Pattern rv; - GetQDGlobalsWhite(&rv); - return PyString_FromStringAndSize((char *)&rv, sizeof(rv)); - } - if ( strcmp(name, "gray") == 0 ) { - Pattern rv; - GetQDGlobalsGray(&rv); - return PyString_FromStringAndSize((char *)&rv, sizeof(rv)); - } - if ( strcmp(name, "ltGray") == 0 ) { - Pattern rv; - GetQDGlobalsLightGray(&rv); - return PyString_FromStringAndSize((char *)&rv, sizeof(rv)); - } - if ( strcmp(name, "dkGray") == 0 ) { - Pattern rv; - GetQDGlobalsDarkGray(&rv); - return PyString_FromStringAndSize((char *)&rv, sizeof(rv)); - } - if ( strcmp(name, "screenBits") == 0 ) { - BitMap rv; - GetQDGlobalsScreenBits(&rv); - return BMObj_NewCopied(&rv); - } - if ( strcmp(name, "thePort") == 0 ) - return GrafObj_New(GetQDGlobalsThePort()); - if ( strcmp(name, "randSeed") == 0 ) - return Py_BuildValue("l", GetQDGlobalsRandomSeed()); - + PyObject *_res = NULL; + const BitMap * _rv; +#ifndef GetPortBitMapForCopyBits + PyMac_PRECHECK(GetPortBitMapForCopyBits); #endif - return Py_FindMethodInChain(&QDGA_chain, (PyObject *)self, name); + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = GetPortBitMapForCopyBits(_self->ob_itself); + _res = Py_BuildValue("O&", + BMObj_New, _rv); + return _res; } -#define QDGA_setattr NULL - -#define QDGA_compare NULL - -#define QDGA_repr NULL - -#define QDGA_hash NULL - -static PyTypeObject QDGlobalsAccess_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "_Qd.QDGlobalsAccess", /*tp_name*/ - sizeof(QDGlobalsAccessObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor) QDGA_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) QDGA_getattr, /*tp_getattr*/ - (setattrfunc) QDGA_setattr, /*tp_setattr*/ - (cmpfunc) QDGA_compare, /*tp_compare*/ - (reprfunc) QDGA_repr, /*tp_repr*/ - (PyNumberMethods *)0, /* tp_as_number */ - (PySequenceMethods *)0, /* tp_as_sequence */ - (PyMappingMethods *)0, /* tp_as_mapping */ - (hashfunc) QDGA_hash, /*tp_hash*/ -}; - -/* ---------------- End object type QDGlobalsAccess ----------------- */ - - -static PyObject *Qd_MacSetPort(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortBounds(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - GrafPtr port; -#ifndef MacSetPort - PyMac_PRECHECK(MacSetPort); + Rect rect; +#ifndef GetPortBounds + PyMac_PRECHECK(GetPortBounds); #endif - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - MacSetPort(port); - Py_INCREF(Py_None); - _res = Py_None; + GetPortBounds(_self->ob_itself, + &rect); + _res = Py_BuildValue("O&", + PyMac_BuildRect, &rect); return _res; } -static PyObject *Qd_GetPort(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortForeColor(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - GrafPtr port; -#ifndef GetPort - PyMac_PRECHECK(GetPort); + RGBColor foreColor; +#ifndef GetPortForeColor + PyMac_PRECHECK(GetPortForeColor); #endif if (!PyArg_ParseTuple(_args, "")) return NULL; - GetPort(&port); + GetPortForeColor(_self->ob_itself, + &foreColor); _res = Py_BuildValue("O&", - GrafObj_New, port); + QdRGB_New, &foreColor); return _res; } -static PyObject *Qd_GrafDevice(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortBackColor(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - short device; -#ifndef GrafDevice - PyMac_PRECHECK(GrafDevice); + RGBColor backColor; +#ifndef GetPortBackColor + PyMac_PRECHECK(GetPortBackColor); #endif - if (!PyArg_ParseTuple(_args, "h", - &device)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - GrafDevice(device); - Py_INCREF(Py_None); - _res = Py_None; + GetPortBackColor(_self->ob_itself, + &backColor); + _res = Py_BuildValue("O&", + QdRGB_New, &backColor); return _res; } -static PyObject *Qd_SetPortBits(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortOpColor(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - BitMapPtr bm; -#ifndef SetPortBits - PyMac_PRECHECK(SetPortBits); + RGBColor opColor; +#ifndef GetPortOpColor + PyMac_PRECHECK(GetPortOpColor); #endif - if (!PyArg_ParseTuple(_args, "O&", - BMObj_Convert, &bm)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - SetPortBits(bm); - Py_INCREF(Py_None); - _res = Py_None; + GetPortOpColor(_self->ob_itself, + &opColor); + _res = Py_BuildValue("O&", + QdRGB_New, &opColor); return _res; } -static PyObject *Qd_PortSize(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortHiliteColor(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - short width; - short height; -#ifndef PortSize - PyMac_PRECHECK(PortSize); + RGBColor hiliteColor; +#ifndef GetPortHiliteColor + PyMac_PRECHECK(GetPortHiliteColor); #endif - if (!PyArg_ParseTuple(_args, "hh", - &width, - &height)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - PortSize(width, - height); - Py_INCREF(Py_None); - _res = Py_None; + GetPortHiliteColor(_self->ob_itself, + &hiliteColor); + _res = Py_BuildValue("O&", + QdRGB_New, &hiliteColor); return _res; } -static PyObject *Qd_MovePortTo(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortTextFont(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - short leftGlobal; - short topGlobal; -#ifndef MovePortTo - PyMac_PRECHECK(MovePortTo); + short _rv; +#ifndef GetPortTextFont + PyMac_PRECHECK(GetPortTextFont); #endif - if (!PyArg_ParseTuple(_args, "hh", - &leftGlobal, - &topGlobal)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - MovePortTo(leftGlobal, - topGlobal); - Py_INCREF(Py_None); - _res = Py_None; + _rv = GetPortTextFont(_self->ob_itself); + _res = Py_BuildValue("h", + _rv); return _res; } -static PyObject *Qd_SetOrigin(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortTextFace(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - short h; - short v; -#ifndef SetOrigin - PyMac_PRECHECK(SetOrigin); + Style _rv; +#ifndef GetPortTextFace + PyMac_PRECHECK(GetPortTextFace); #endif - if (!PyArg_ParseTuple(_args, "hh", - &h, - &v)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - SetOrigin(h, - v); - Py_INCREF(Py_None); - _res = Py_None; + _rv = GetPortTextFace(_self->ob_itself); + _res = Py_BuildValue("b", + _rv); return _res; } -static PyObject *Qd_SetClip(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortTextMode(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle rgn; -#ifndef SetClip - PyMac_PRECHECK(SetClip); + short _rv; +#ifndef GetPortTextMode + PyMac_PRECHECK(GetPortTextMode); #endif - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &rgn)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - SetClip(rgn); - Py_INCREF(Py_None); - _res = Py_None; + _rv = GetPortTextMode(_self->ob_itself); + _res = Py_BuildValue("h", + _rv); return _res; } -static PyObject *Qd_GetClip(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortTextSize(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle rgn; -#ifndef GetClip - PyMac_PRECHECK(GetClip); + short _rv; +#ifndef GetPortTextSize + PyMac_PRECHECK(GetPortTextSize); #endif - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &rgn)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - GetClip(rgn); - Py_INCREF(Py_None); - _res = Py_None; + _rv = GetPortTextSize(_self->ob_itself); + _res = Py_BuildValue("h", + _rv); return _res; } -static PyObject *Qd_ClipRect(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortChExtra(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; -#ifndef ClipRect - PyMac_PRECHECK(ClipRect); + short _rv; +#ifndef GetPortChExtra + PyMac_PRECHECK(GetPortChExtra); #endif - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - ClipRect(&r); - Py_INCREF(Py_None); - _res = Py_None; + _rv = GetPortChExtra(_self->ob_itself); + _res = Py_BuildValue("h", + _rv); return _res; } -static PyObject *Qd_BackPat(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortFracHPenLocation(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - Pattern *pat__in__; - int pat__in_len__; -#ifndef BackPat - PyMac_PRECHECK(BackPat); + short _rv; +#ifndef GetPortFracHPenLocation + PyMac_PRECHECK(GetPortFracHPenLocation); #endif - if (!PyArg_ParseTuple(_args, "s#", - (char **)&pat__in__, &pat__in_len__)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - if (pat__in_len__ != sizeof(Pattern)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); - goto pat__error__; - } - BackPat(pat__in__); - Py_INCREF(Py_None); - _res = Py_None; - pat__error__: ; + _rv = GetPortFracHPenLocation(_self->ob_itself); + _res = Py_BuildValue("h", + _rv); return _res; } -static PyObject *Qd_InitCursor(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortSpExtra(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; -#ifndef InitCursor - PyMac_PRECHECK(InitCursor); + Fixed _rv; +#ifndef GetPortSpExtra + PyMac_PRECHECK(GetPortSpExtra); #endif if (!PyArg_ParseTuple(_args, "")) return NULL; - InitCursor(); - Py_INCREF(Py_None); - _res = Py_None; + _rv = GetPortSpExtra(_self->ob_itself); + _res = Py_BuildValue("O&", + PyMac_BuildFixed, _rv); return _res; } -static PyObject *Qd_MacSetCursor(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortPenVisibility(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - Cursor *crsr__in__; - int crsr__in_len__; -#ifndef MacSetCursor - PyMac_PRECHECK(MacSetCursor); + short _rv; +#ifndef GetPortPenVisibility + PyMac_PRECHECK(GetPortPenVisibility); #endif - if (!PyArg_ParseTuple(_args, "s#", - (char **)&crsr__in__, &crsr__in_len__)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - if (crsr__in_len__ != sizeof(Cursor)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Cursor)"); - goto crsr__error__; - } - MacSetCursor(crsr__in__); - Py_INCREF(Py_None); - _res = Py_None; - crsr__error__: ; + _rv = GetPortPenVisibility(_self->ob_itself); + _res = Py_BuildValue("h", + _rv); return _res; } -static PyObject *Qd_HideCursor(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortVisibleRegion(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; -#ifndef HideCursor - PyMac_PRECHECK(HideCursor); + RgnHandle _rv; + RgnHandle visRgn; +#ifndef GetPortVisibleRegion + PyMac_PRECHECK(GetPortVisibleRegion); #endif - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &visRgn)) return NULL; - HideCursor(); - Py_INCREF(Py_None); - _res = Py_None; + _rv = GetPortVisibleRegion(_self->ob_itself, + visRgn); + _res = Py_BuildValue("O&", + ResObj_New, _rv); return _res; } -static PyObject *Qd_MacShowCursor(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortClipRegion(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; -#ifndef MacShowCursor - PyMac_PRECHECK(MacShowCursor); + RgnHandle _rv; + RgnHandle clipRgn; +#ifndef GetPortClipRegion + PyMac_PRECHECK(GetPortClipRegion); #endif - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &clipRgn)) return NULL; - MacShowCursor(); - Py_INCREF(Py_None); - _res = Py_None; + _rv = GetPortClipRegion(_self->ob_itself, + clipRgn); + _res = Py_BuildValue("O&", + ResObj_New, _rv); return _res; } -static PyObject *Qd_ObscureCursor(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortBackPixPat(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; -#ifndef ObscureCursor - PyMac_PRECHECK(ObscureCursor); + PixPatHandle _rv; + PixPatHandle backPattern; +#ifndef GetPortBackPixPat + PyMac_PRECHECK(GetPortBackPixPat); #endif - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &backPattern)) return NULL; - ObscureCursor(); - Py_INCREF(Py_None); - _res = Py_None; + _rv = GetPortBackPixPat(_self->ob_itself, + backPattern); + _res = Py_BuildValue("O&", + ResObj_New, _rv); return _res; } -static PyObject *Qd_HidePen(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortPenPixPat(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; -#ifndef HidePen - PyMac_PRECHECK(HidePen); + PixPatHandle _rv; + PixPatHandle penPattern; +#ifndef GetPortPenPixPat + PyMac_PRECHECK(GetPortPenPixPat); #endif - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &penPattern)) return NULL; - HidePen(); - Py_INCREF(Py_None); - _res = Py_None; + _rv = GetPortPenPixPat(_self->ob_itself, + penPattern); + _res = Py_BuildValue("O&", + ResObj_New, _rv); return _res; } -static PyObject *Qd_ShowPen(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortFillPixPat(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; -#ifndef ShowPen - PyMac_PRECHECK(ShowPen); + PixPatHandle _rv; + PixPatHandle fillPattern; +#ifndef GetPortFillPixPat + PyMac_PRECHECK(GetPortFillPixPat); #endif - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &fillPattern)) return NULL; - ShowPen(); - Py_INCREF(Py_None); - _res = Py_None; + _rv = GetPortFillPixPat(_self->ob_itself, + fillPattern); + _res = Py_BuildValue("O&", + ResObj_New, _rv); return _res; } -static PyObject *Qd_GetPen(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortPenSize(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - Point pt; -#ifndef GetPen - PyMac_PRECHECK(GetPen); -#endif - if (!PyArg_ParseTuple(_args, "")) + Point penSize; +#ifndef GetPortPenSize + PyMac_PRECHECK(GetPortPenSize); +#endif + if (!PyArg_ParseTuple(_args, "O&", + PyMac_GetPoint, &penSize)) return NULL; - GetPen(&pt); + GetPortPenSize(_self->ob_itself, + &penSize); _res = Py_BuildValue("O&", - PyMac_BuildPoint, pt); + PyMac_BuildPoint, penSize); return _res; } -static PyObject *Qd_GetPenState(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortPenMode(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - PenState pnState__out__; -#ifndef GetPenState - PyMac_PRECHECK(GetPenState); + SInt32 _rv; +#ifndef GetPortPenMode + PyMac_PRECHECK(GetPortPenMode); #endif if (!PyArg_ParseTuple(_args, "")) return NULL; - GetPenState(&pnState__out__); - _res = Py_BuildValue("s#", - (char *)&pnState__out__, (int)sizeof(PenState)); + _rv = GetPortPenMode(_self->ob_itself); + _res = Py_BuildValue("l", + _rv); return _res; } -static PyObject *Qd_SetPenState(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_GetPortPenLocation(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - PenState *pnState__in__; - int pnState__in_len__; -#ifndef SetPenState - PyMac_PRECHECK(SetPenState); + Point penLocation; +#ifndef GetPortPenLocation + PyMac_PRECHECK(GetPortPenLocation); #endif - if (!PyArg_ParseTuple(_args, "s#", - (char **)&pnState__in__, &pnState__in_len__)) + if (!PyArg_ParseTuple(_args, "O&", + PyMac_GetPoint, &penLocation)) return NULL; - if (pnState__in_len__ != sizeof(PenState)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(PenState)"); - goto pnState__error__; - } - SetPenState(pnState__in__); - Py_INCREF(Py_None); - _res = Py_None; - pnState__error__: ; + GetPortPenLocation(_self->ob_itself, + &penLocation); + _res = Py_BuildValue("O&", + PyMac_BuildPoint, penLocation); return _res; } -static PyObject *Qd_PenSize(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_IsPortRegionBeingDefined(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - short width; - short height; -#ifndef PenSize - PyMac_PRECHECK(PenSize); + Boolean _rv; +#ifndef IsPortRegionBeingDefined + PyMac_PRECHECK(IsPortRegionBeingDefined); #endif - if (!PyArg_ParseTuple(_args, "hh", - &width, - &height)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - PenSize(width, - height); - Py_INCREF(Py_None); - _res = Py_None; + _rv = IsPortRegionBeingDefined(_self->ob_itself); + _res = Py_BuildValue("b", + _rv); return _res; } -static PyObject *Qd_PenMode(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_IsPortPictureBeingDefined(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - short mode; -#ifndef PenMode - PyMac_PRECHECK(PenMode); + Boolean _rv; +#ifndef IsPortPictureBeingDefined + PyMac_PRECHECK(IsPortPictureBeingDefined); #endif - if (!PyArg_ParseTuple(_args, "h", - &mode)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - PenMode(mode); - Py_INCREF(Py_None); - _res = Py_None; + _rv = IsPortPictureBeingDefined(_self->ob_itself); + _res = Py_BuildValue("b", + _rv); return _res; } -static PyObject *Qd_PenPat(PyObject *_self, PyObject *_args) +#if TARGET_API_MAC_CARBON + +static PyObject *GrafObj_IsPortPolyBeingDefined(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - Pattern *pat__in__; - int pat__in_len__; -#ifndef PenPat - PyMac_PRECHECK(PenPat); + Boolean _rv; +#ifndef IsPortPolyBeingDefined + PyMac_PRECHECK(IsPortPolyBeingDefined); #endif - if (!PyArg_ParseTuple(_args, "s#", - (char **)&pat__in__, &pat__in_len__)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - if (pat__in_len__ != sizeof(Pattern)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); - goto pat__error__; - } - PenPat(pat__in__); - Py_INCREF(Py_None); - _res = Py_None; - pat__error__: ; + _rv = IsPortPolyBeingDefined(_self->ob_itself); + _res = Py_BuildValue("b", + _rv); return _res; } +#endif -static PyObject *Qd_PenNormal(PyObject *_self, PyObject *_args) +#if TARGET_API_MAC_CARBON + +static PyObject *GrafObj_IsPortOffscreen(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; -#ifndef PenNormal - PyMac_PRECHECK(PenNormal); + Boolean _rv; +#ifndef IsPortOffscreen + PyMac_PRECHECK(IsPortOffscreen); #endif if (!PyArg_ParseTuple(_args, "")) return NULL; - PenNormal(); - Py_INCREF(Py_None); - _res = Py_None; + _rv = IsPortOffscreen(_self->ob_itself); + _res = Py_BuildValue("b", + _rv); return _res; } +#endif -static PyObject *Qd_MoveTo(PyObject *_self, PyObject *_args) +#if TARGET_API_MAC_CARBON + +static PyObject *GrafObj_IsPortColor(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - short h; - short v; -#ifndef MoveTo - PyMac_PRECHECK(MoveTo); + Boolean _rv; +#ifndef IsPortColor + PyMac_PRECHECK(IsPortColor); #endif - if (!PyArg_ParseTuple(_args, "hh", - &h, - &v)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - MoveTo(h, - v); - Py_INCREF(Py_None); - _res = Py_None; + _rv = IsPortColor(_self->ob_itself); + _res = Py_BuildValue("b", + _rv); return _res; } +#endif -static PyObject *Qd_Move(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_SetPortBounds(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - short dh; - short dv; -#ifndef Move - PyMac_PRECHECK(Move); + Rect rect; +#ifndef SetPortBounds + PyMac_PRECHECK(SetPortBounds); #endif - if (!PyArg_ParseTuple(_args, "hh", - &dh, - &dv)) + if (!PyArg_ParseTuple(_args, "O&", + PyMac_GetRect, &rect)) return NULL; - Move(dh, - dv); + SetPortBounds(_self->ob_itself, + &rect); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_MacLineTo(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_SetPortOpColor(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - short h; - short v; -#ifndef MacLineTo - PyMac_PRECHECK(MacLineTo); + RGBColor opColor; +#ifndef SetPortOpColor + PyMac_PRECHECK(SetPortOpColor); #endif - if (!PyArg_ParseTuple(_args, "hh", - &h, - &v)) + if (!PyArg_ParseTuple(_args, "O&", + QdRGB_Convert, &opColor)) return NULL; - MacLineTo(h, - v); + SetPortOpColor(_self->ob_itself, + &opColor); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_Line(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_SetPortVisibleRegion(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - short dh; - short dv; -#ifndef Line - PyMac_PRECHECK(Line); + RgnHandle visRgn; +#ifndef SetPortVisibleRegion + PyMac_PRECHECK(SetPortVisibleRegion); #endif - if (!PyArg_ParseTuple(_args, "hh", - &dh, - &dv)) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &visRgn)) return NULL; - Line(dh, - dv); + SetPortVisibleRegion(_self->ob_itself, + visRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_ForeColor(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_SetPortClipRegion(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - long color; -#ifndef ForeColor - PyMac_PRECHECK(ForeColor); + RgnHandle clipRgn; +#ifndef SetPortClipRegion + PyMac_PRECHECK(SetPortClipRegion); #endif - if (!PyArg_ParseTuple(_args, "l", - &color)) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &clipRgn)) return NULL; - ForeColor(color); + SetPortClipRegion(_self->ob_itself, + clipRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_BackColor(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_SetPortPenPixPat(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - long color; -#ifndef BackColor - PyMac_PRECHECK(BackColor); + PixPatHandle penPattern; +#ifndef SetPortPenPixPat + PyMac_PRECHECK(SetPortPenPixPat); #endif - if (!PyArg_ParseTuple(_args, "l", - &color)) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &penPattern)) return NULL; - BackColor(color); + SetPortPenPixPat(_self->ob_itself, + penPattern); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_ColorBit(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_SetPortFillPixPat(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - short whichBit; -#ifndef ColorBit - PyMac_PRECHECK(ColorBit); + PixPatHandle penPattern; +#ifndef SetPortFillPixPat + PyMac_PRECHECK(SetPortFillPixPat); #endif - if (!PyArg_ParseTuple(_args, "h", - &whichBit)) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &penPattern)) return NULL; - ColorBit(whichBit); + SetPortFillPixPat(_self->ob_itself, + penPattern); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_MacSetRect(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_SetPortBackPixPat(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; - short left; - short top; - short right; - short bottom; -#ifndef MacSetRect - PyMac_PRECHECK(MacSetRect); + PixPatHandle backPattern; +#ifndef SetPortBackPixPat + PyMac_PRECHECK(SetPortBackPixPat); #endif - if (!PyArg_ParseTuple(_args, "hhhh", - &left, - &top, - &right, - &bottom)) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &backPattern)) return NULL; - MacSetRect(&r, - left, - top, - right, - bottom); - _res = Py_BuildValue("O&", - PyMac_BuildRect, &r); + SetPortBackPixPat(_self->ob_itself, + backPattern); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_MacOffsetRect(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_SetPortPenSize(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; - short dh; - short dv; -#ifndef MacOffsetRect - PyMac_PRECHECK(MacOffsetRect); + Point penSize; +#ifndef SetPortPenSize + PyMac_PRECHECK(SetPortPenSize); #endif - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &dh, - &dv)) + if (!PyArg_ParseTuple(_args, "O&", + PyMac_GetPoint, &penSize)) return NULL; - MacOffsetRect(&r, - dh, - dv); - _res = Py_BuildValue("O&", - PyMac_BuildRect, &r); + SetPortPenSize(_self->ob_itself, + penSize); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_MacInsetRect(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_SetPortPenMode(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; - short dh; - short dv; -#ifndef MacInsetRect - PyMac_PRECHECK(MacInsetRect); + SInt32 penMode; +#ifndef SetPortPenMode + PyMac_PRECHECK(SetPortPenMode); #endif - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &dh, - &dv)) + if (!PyArg_ParseTuple(_args, "l", + &penMode)) return NULL; - MacInsetRect(&r, - dh, - dv); - _res = Py_BuildValue("O&", - PyMac_BuildRect, &r); + SetPortPenMode(_self->ob_itself, + penMode); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_SectRect(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_SetPortFracHPenLocation(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - Boolean _rv; - Rect src1; - Rect src2; - Rect dstRect; -#ifndef SectRect - PyMac_PRECHECK(SectRect); + short pnLocHFrac; +#ifndef SetPortFracHPenLocation + PyMac_PRECHECK(SetPortFracHPenLocation); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetRect, &src1, - PyMac_GetRect, &src2)) + if (!PyArg_ParseTuple(_args, "h", + &pnLocHFrac)) return NULL; - _rv = SectRect(&src1, - &src2, - &dstRect); - _res = Py_BuildValue("bO&", - _rv, - PyMac_BuildRect, &dstRect); + SetPortFracHPenLocation(_self->ob_itself, + pnLocHFrac); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_MacUnionRect(PyObject *_self, PyObject *_args) +#if TARGET_API_MAC_CARBON + +static PyObject *GrafObj_DisposePort(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect src1; - Rect src2; - Rect dstRect; -#ifndef MacUnionRect - PyMac_PRECHECK(MacUnionRect); +#ifndef DisposePort + PyMac_PRECHECK(DisposePort); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetRect, &src1, - PyMac_GetRect, &src2)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - MacUnionRect(&src1, - &src2, - &dstRect); - _res = Py_BuildValue("O&", - PyMac_BuildRect, &dstRect); + DisposePort(_self->ob_itself); + Py_INCREF(Py_None); + _res = Py_None; return _res; } +#endif -static PyObject *Qd_MacEqualRect(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_QDIsPortBuffered(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; - Rect rect1; - Rect rect2; -#ifndef MacEqualRect - PyMac_PRECHECK(MacEqualRect); +#ifndef QDIsPortBuffered + PyMac_PRECHECK(QDIsPortBuffered); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetRect, &rect1, - PyMac_GetRect, &rect2)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - _rv = MacEqualRect(&rect1, - &rect2); + _rv = QDIsPortBuffered(_self->ob_itself); _res = Py_BuildValue("b", _rv); return _res; } -static PyObject *Qd_EmptyRect(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_QDIsPortBufferDirty(GrafPortObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; - Rect r; -#ifndef EmptyRect - PyMac_PRECHECK(EmptyRect); +#ifndef QDIsPortBufferDirty + PyMac_PRECHECK(QDIsPortBufferDirty); #endif - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - _rv = EmptyRect(&r); + _rv = QDIsPortBufferDirty(_self->ob_itself); _res = Py_BuildValue("b", _rv); return _res; } -static PyObject *Qd_MacFrameRect(PyObject *_self, PyObject *_args) +static PyObject *GrafObj_QDFlushPortBuffer(GrafPortObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + RgnHandle region; +#ifndef QDFlushPortBuffer + PyMac_PRECHECK(QDFlushPortBuffer); +#endif + if (!PyArg_ParseTuple(_args, "O&", + OptResObj_Convert, ®ion)) + return NULL; + QDFlushPortBuffer(_self->ob_itself, + region); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +#if TARGET_API_MAC_CARBON + +static PyObject *GrafObj_QDGetDirtyRegion(GrafPortObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + OSStatus _err; + RgnHandle rgn; +#ifndef QDGetDirtyRegion + PyMac_PRECHECK(QDGetDirtyRegion); +#endif + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &rgn)) + return NULL; + _err = QDGetDirtyRegion(_self->ob_itself, + rgn); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} +#endif + +#if TARGET_API_MAC_CARBON + +static PyObject *GrafObj_QDSetDirtyRegion(GrafPortObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + OSStatus _err; + RgnHandle rgn; +#ifndef QDSetDirtyRegion + PyMac_PRECHECK(QDSetDirtyRegion); +#endif + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &rgn)) + return NULL; + _err = QDSetDirtyRegion(_self->ob_itself, + rgn); + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} +#endif + +static PyMethodDef GrafObj_methods[] = { + {"MacSetPort", (PyCFunction)GrafObj_MacSetPort, 1, + PyDoc_STR("() -> None")}, + +#if TARGET_API_MAC_CARBON + {"IsValidPort", (PyCFunction)GrafObj_IsValidPort, 1, + PyDoc_STR("() -> (Boolean _rv)")}, +#endif + {"GetPortPixMap", (PyCFunction)GrafObj_GetPortPixMap, 1, + PyDoc_STR("() -> (PixMapHandle _rv)")}, + {"GetPortBitMapForCopyBits", (PyCFunction)GrafObj_GetPortBitMapForCopyBits, 1, + PyDoc_STR("() -> (const BitMap * _rv)")}, + {"GetPortBounds", (PyCFunction)GrafObj_GetPortBounds, 1, + PyDoc_STR("() -> (Rect rect)")}, + {"GetPortForeColor", (PyCFunction)GrafObj_GetPortForeColor, 1, + PyDoc_STR("() -> (RGBColor foreColor)")}, + {"GetPortBackColor", (PyCFunction)GrafObj_GetPortBackColor, 1, + PyDoc_STR("() -> (RGBColor backColor)")}, + {"GetPortOpColor", (PyCFunction)GrafObj_GetPortOpColor, 1, + PyDoc_STR("() -> (RGBColor opColor)")}, + {"GetPortHiliteColor", (PyCFunction)GrafObj_GetPortHiliteColor, 1, + PyDoc_STR("() -> (RGBColor hiliteColor)")}, + {"GetPortTextFont", (PyCFunction)GrafObj_GetPortTextFont, 1, + PyDoc_STR("() -> (short _rv)")}, + {"GetPortTextFace", (PyCFunction)GrafObj_GetPortTextFace, 1, + PyDoc_STR("() -> (Style _rv)")}, + {"GetPortTextMode", (PyCFunction)GrafObj_GetPortTextMode, 1, + PyDoc_STR("() -> (short _rv)")}, + {"GetPortTextSize", (PyCFunction)GrafObj_GetPortTextSize, 1, + PyDoc_STR("() -> (short _rv)")}, + {"GetPortChExtra", (PyCFunction)GrafObj_GetPortChExtra, 1, + PyDoc_STR("() -> (short _rv)")}, + {"GetPortFracHPenLocation", (PyCFunction)GrafObj_GetPortFracHPenLocation, 1, + PyDoc_STR("() -> (short _rv)")}, + {"GetPortSpExtra", (PyCFunction)GrafObj_GetPortSpExtra, 1, + PyDoc_STR("() -> (Fixed _rv)")}, + {"GetPortPenVisibility", (PyCFunction)GrafObj_GetPortPenVisibility, 1, + PyDoc_STR("() -> (short _rv)")}, + {"GetPortVisibleRegion", (PyCFunction)GrafObj_GetPortVisibleRegion, 1, + PyDoc_STR("(RgnHandle visRgn) -> (RgnHandle _rv)")}, + {"GetPortClipRegion", (PyCFunction)GrafObj_GetPortClipRegion, 1, + PyDoc_STR("(RgnHandle clipRgn) -> (RgnHandle _rv)")}, + {"GetPortBackPixPat", (PyCFunction)GrafObj_GetPortBackPixPat, 1, + PyDoc_STR("(PixPatHandle backPattern) -> (PixPatHandle _rv)")}, + {"GetPortPenPixPat", (PyCFunction)GrafObj_GetPortPenPixPat, 1, + PyDoc_STR("(PixPatHandle penPattern) -> (PixPatHandle _rv)")}, + {"GetPortFillPixPat", (PyCFunction)GrafObj_GetPortFillPixPat, 1, + PyDoc_STR("(PixPatHandle fillPattern) -> (PixPatHandle _rv)")}, + {"GetPortPenSize", (PyCFunction)GrafObj_GetPortPenSize, 1, + PyDoc_STR("(Point penSize) -> (Point penSize)")}, + {"GetPortPenMode", (PyCFunction)GrafObj_GetPortPenMode, 1, + PyDoc_STR("() -> (SInt32 _rv)")}, + {"GetPortPenLocation", (PyCFunction)GrafObj_GetPortPenLocation, 1, + PyDoc_STR("(Point penLocation) -> (Point penLocation)")}, + {"IsPortRegionBeingDefined", (PyCFunction)GrafObj_IsPortRegionBeingDefined, 1, + PyDoc_STR("() -> (Boolean _rv)")}, + {"IsPortPictureBeingDefined", (PyCFunction)GrafObj_IsPortPictureBeingDefined, 1, + PyDoc_STR("() -> (Boolean _rv)")}, + +#if TARGET_API_MAC_CARBON + {"IsPortPolyBeingDefined", (PyCFunction)GrafObj_IsPortPolyBeingDefined, 1, + PyDoc_STR("() -> (Boolean _rv)")}, +#endif + +#if TARGET_API_MAC_CARBON + {"IsPortOffscreen", (PyCFunction)GrafObj_IsPortOffscreen, 1, + PyDoc_STR("() -> (Boolean _rv)")}, +#endif + +#if TARGET_API_MAC_CARBON + {"IsPortColor", (PyCFunction)GrafObj_IsPortColor, 1, + PyDoc_STR("() -> (Boolean _rv)")}, +#endif + {"SetPortBounds", (PyCFunction)GrafObj_SetPortBounds, 1, + PyDoc_STR("(Rect rect) -> None")}, + {"SetPortOpColor", (PyCFunction)GrafObj_SetPortOpColor, 1, + PyDoc_STR("(RGBColor opColor) -> None")}, + {"SetPortVisibleRegion", (PyCFunction)GrafObj_SetPortVisibleRegion, 1, + PyDoc_STR("(RgnHandle visRgn) -> None")}, + {"SetPortClipRegion", (PyCFunction)GrafObj_SetPortClipRegion, 1, + PyDoc_STR("(RgnHandle clipRgn) -> None")}, + {"SetPortPenPixPat", (PyCFunction)GrafObj_SetPortPenPixPat, 1, + PyDoc_STR("(PixPatHandle penPattern) -> None")}, + {"SetPortFillPixPat", (PyCFunction)GrafObj_SetPortFillPixPat, 1, + PyDoc_STR("(PixPatHandle penPattern) -> None")}, + {"SetPortBackPixPat", (PyCFunction)GrafObj_SetPortBackPixPat, 1, + PyDoc_STR("(PixPatHandle backPattern) -> None")}, + {"SetPortPenSize", (PyCFunction)GrafObj_SetPortPenSize, 1, + PyDoc_STR("(Point penSize) -> None")}, + {"SetPortPenMode", (PyCFunction)GrafObj_SetPortPenMode, 1, + PyDoc_STR("(SInt32 penMode) -> None")}, + {"SetPortFracHPenLocation", (PyCFunction)GrafObj_SetPortFracHPenLocation, 1, + PyDoc_STR("(short pnLocHFrac) -> None")}, + +#if TARGET_API_MAC_CARBON + {"DisposePort", (PyCFunction)GrafObj_DisposePort, 1, + PyDoc_STR("() -> None")}, +#endif + {"QDIsPortBuffered", (PyCFunction)GrafObj_QDIsPortBuffered, 1, + PyDoc_STR("() -> (Boolean _rv)")}, + {"QDIsPortBufferDirty", (PyCFunction)GrafObj_QDIsPortBufferDirty, 1, + PyDoc_STR("() -> (Boolean _rv)")}, + {"QDFlushPortBuffer", (PyCFunction)GrafObj_QDFlushPortBuffer, 1, + PyDoc_STR("(RgnHandle region) -> None")}, + +#if TARGET_API_MAC_CARBON + {"QDGetDirtyRegion", (PyCFunction)GrafObj_QDGetDirtyRegion, 1, + PyDoc_STR("(RgnHandle rgn) -> None")}, +#endif + +#if TARGET_API_MAC_CARBON + {"QDSetDirtyRegion", (PyCFunction)GrafObj_QDSetDirtyRegion, 1, + PyDoc_STR("(RgnHandle rgn) -> None")}, +#endif + {NULL, NULL, 0} +}; + +static PyObject *GrafObj_get_visRgn(GrafPortObject *self, void *closure) +{ + RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */ + return Py_BuildValue("O&", ResObj_New, (Handle)GetPortVisibleRegion(self->ob_itself, h)); + +} + +#define GrafObj_set_visRgn NULL + +static PyObject *GrafObj_get_clipRgn(GrafPortObject *self, void *closure) +{ + RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */ + return Py_BuildValue("O&", ResObj_New, (Handle)GetPortClipRegion(self->ob_itself, h)); + +} + +#define GrafObj_set_clipRgn NULL + +static PyGetSetDef GrafObj_getsetlist[] = { + {"visRgn", (getter)GrafObj_get_visRgn, (setter)GrafObj_set_visRgn, "Convenience attribute: return a copy of the visible region"}, + {"clipRgn", (getter)GrafObj_get_clipRgn, (setter)GrafObj_set_clipRgn, "Convenience attribute: return a copy of the clipping region"}, + {NULL, NULL, NULL, NULL}, +}; + + +#define GrafObj_compare NULL + +#define GrafObj_repr NULL + +#define GrafObj_hash NULL + +PyTypeObject GrafPort_Type = { + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "_Qd.GrafPort", /*tp_name*/ + sizeof(GrafPortObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + /* methods */ + (destructor) GrafObj_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ + (cmpfunc) GrafObj_compare, /*tp_compare*/ + (reprfunc) GrafObj_repr, /*tp_repr*/ + (PyNumberMethods *)0, /* tp_as_number */ + (PySequenceMethods *)0, /* tp_as_sequence */ + (PyMappingMethods *)0, /* tp_as_mapping */ + (hashfunc) GrafObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + GrafObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + GrafObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ +}; + +/* -------------------- End object type GrafPort -------------------- */ + + +/* ----------------------- Object type BitMap ----------------------- */ + +PyTypeObject BitMap_Type; + +#define BMObj_Check(x) ((x)->ob_type == &BitMap_Type) + +typedef struct BitMapObject { + PyObject_HEAD + BitMapPtr ob_itself; + PyObject *referred_object; + BitMap *referred_bitmap; +} BitMapObject; + +PyObject *BMObj_New(BitMapPtr itself) +{ + BitMapObject *it; + if (itself == NULL) return PyMac_Error(resNotFound); + it = PyObject_NEW(BitMapObject, &BitMap_Type); + if (it == NULL) return NULL; + it->ob_itself = itself; + it->referred_object = NULL; + it->referred_bitmap = NULL; + return (PyObject *)it; +} +int BMObj_Convert(PyObject *v, BitMapPtr *p_itself) +{ + if (!BMObj_Check(v)) + { + PyErr_SetString(PyExc_TypeError, "BitMap required"); + return 0; + } + *p_itself = ((BitMapObject *)v)->ob_itself; + return 1; +} + +static void BMObj_dealloc(BitMapObject *self) +{ + Py_XDECREF(self->referred_object); + if (self->referred_bitmap) free(self->referred_bitmap); + PyObject_Del(self); +} + +static PyObject *BMObj_getdata(BitMapObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + + int from, length; + char *cp; + + if ( !PyArg_ParseTuple(_args, "ii", &from, &length) ) + return NULL; + cp = _self->ob_itself->baseAddr+from; + _res = PyString_FromStringAndSize(cp, length); + return _res; + +} + +static PyObject *BMObj_putdata(BitMapObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + + int from, length; + char *cp, *icp; + + if ( !PyArg_ParseTuple(_args, "is#", &from, &icp, &length) ) + return NULL; + cp = _self->ob_itself->baseAddr+from; + memcpy(cp, icp, length); + Py_INCREF(Py_None); + _res = Py_None; + return _res; + +} + +static PyMethodDef BMObj_methods[] = { + {"getdata", (PyCFunction)BMObj_getdata, 1, + PyDoc_STR("(int start, int size) -> string. Return bytes from the bitmap")}, + {"putdata", (PyCFunction)BMObj_putdata, 1, + PyDoc_STR("(int start, string data). Store bytes into the bitmap")}, + {NULL, NULL, 0} +}; + +static PyObject *BMObj_get_baseAddr(BitMapObject *self, void *closure) +{ + return PyInt_FromLong((long)self->ob_itself->baseAddr); +} + +#define BMObj_set_baseAddr NULL + +static PyObject *BMObj_get_rowBytes(BitMapObject *self, void *closure) +{ + return PyInt_FromLong((long)self->ob_itself->rowBytes); +} + +#define BMObj_set_rowBytes NULL + +static PyObject *BMObj_get_bounds(BitMapObject *self, void *closure) +{ + return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds); +} + +#define BMObj_set_bounds NULL + +static PyObject *BMObj_get_bitmap_data(BitMapObject *self, void *closure) +{ + return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap)); +} + +#define BMObj_set_bitmap_data NULL + +static PyObject *BMObj_get_pixmap_data(BitMapObject *self, void *closure) +{ + return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap)); +} + +#define BMObj_set_pixmap_data NULL + +static PyGetSetDef BMObj_getsetlist[] = { + {"baseAddr", (getter)BMObj_get_baseAddr, (setter)BMObj_set_baseAddr, NULL}, + {"rowBytes", (getter)BMObj_get_rowBytes, (setter)BMObj_set_rowBytes, NULL}, + {"bounds", (getter)BMObj_get_bounds, (setter)BMObj_set_bounds, NULL}, + {"bitmap_data", (getter)BMObj_get_bitmap_data, (setter)BMObj_set_bitmap_data, NULL}, + {"pixmap_data", (getter)BMObj_get_pixmap_data, (setter)BMObj_set_pixmap_data, NULL}, + {NULL, NULL, NULL, NULL}, +}; + + +#define BMObj_compare NULL + +#define BMObj_repr NULL + +#define BMObj_hash NULL + +PyTypeObject BitMap_Type = { + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "_Qd.BitMap", /*tp_name*/ + sizeof(BitMapObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + /* methods */ + (destructor) BMObj_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ + (cmpfunc) BMObj_compare, /*tp_compare*/ + (reprfunc) BMObj_repr, /*tp_repr*/ + (PyNumberMethods *)0, /* tp_as_number */ + (PySequenceMethods *)0, /* tp_as_sequence */ + (PyMappingMethods *)0, /* tp_as_mapping */ + (hashfunc) BMObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + BMObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + BMObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ +}; + +/* --------------------- End object type BitMap --------------------- */ + + +static PyObject *Qd_GetPort(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; -#ifndef MacFrameRect - PyMac_PRECHECK(MacFrameRect); + GrafPtr port; +#ifndef GetPort + PyMac_PRECHECK(GetPort); #endif - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - MacFrameRect(&r); - Py_INCREF(Py_None); - _res = Py_None; + GetPort(&port); + _res = Py_BuildValue("O&", + GrafObj_New, port); return _res; } -static PyObject *Qd_PaintRect(PyObject *_self, PyObject *_args) +static PyObject *Qd_GrafDevice(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; -#ifndef PaintRect - PyMac_PRECHECK(PaintRect); + short device; +#ifndef GrafDevice + PyMac_PRECHECK(GrafDevice); #endif - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) + if (!PyArg_ParseTuple(_args, "h", + &device)) return NULL; - PaintRect(&r); + GrafDevice(device); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_EraseRect(PyObject *_self, PyObject *_args) +static PyObject *Qd_SetPortBits(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; -#ifndef EraseRect - PyMac_PRECHECK(EraseRect); + BitMapPtr bm; +#ifndef SetPortBits + PyMac_PRECHECK(SetPortBits); #endif if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) + BMObj_Convert, &bm)) return NULL; - EraseRect(&r); + SetPortBits(bm); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_MacInvertRect(PyObject *_self, PyObject *_args) +static PyObject *Qd_PortSize(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; -#ifndef MacInvertRect - PyMac_PRECHECK(MacInvertRect); + short width; + short height; +#ifndef PortSize + PyMac_PRECHECK(PortSize); #endif - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) + if (!PyArg_ParseTuple(_args, "hh", + &width, + &height)) return NULL; - MacInvertRect(&r); + PortSize(width, + height); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_MacFillRect(PyObject *_self, PyObject *_args) +static PyObject *Qd_MovePortTo(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; - Pattern *pat__in__; - int pat__in_len__; -#ifndef MacFillRect - PyMac_PRECHECK(MacFillRect); + short leftGlobal; + short topGlobal; +#ifndef MovePortTo + PyMac_PRECHECK(MovePortTo); #endif - if (!PyArg_ParseTuple(_args, "O&s#", - PyMac_GetRect, &r, - (char **)&pat__in__, &pat__in_len__)) + if (!PyArg_ParseTuple(_args, "hh", + &leftGlobal, + &topGlobal)) return NULL; - if (pat__in_len__ != sizeof(Pattern)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); - goto pat__error__; - } - MacFillRect(&r, - pat__in__); + MovePortTo(leftGlobal, + topGlobal); Py_INCREF(Py_None); _res = Py_None; - pat__error__: ; return _res; } -static PyObject *Qd_FrameOval(PyObject *_self, PyObject *_args) +static PyObject *Qd_SetOrigin(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; -#ifndef FrameOval - PyMac_PRECHECK(FrameOval); + short h; + short v; +#ifndef SetOrigin + PyMac_PRECHECK(SetOrigin); #endif - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) + if (!PyArg_ParseTuple(_args, "hh", + &h, + &v)) return NULL; - FrameOval(&r); + SetOrigin(h, + v); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_PaintOval(PyObject *_self, PyObject *_args) +static PyObject *Qd_SetClip(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; -#ifndef PaintOval - PyMac_PRECHECK(PaintOval); + RgnHandle rgn; +#ifndef SetClip + PyMac_PRECHECK(SetClip); #endif if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) + ResObj_Convert, &rgn)) return NULL; - PaintOval(&r); + SetClip(rgn); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_EraseOval(PyObject *_self, PyObject *_args) +static PyObject *Qd_GetClip(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; -#ifndef EraseOval - PyMac_PRECHECK(EraseOval); + RgnHandle rgn; +#ifndef GetClip + PyMac_PRECHECK(GetClip); #endif if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &r)) + ResObj_Convert, &rgn)) return NULL; - EraseOval(&r); + GetClip(rgn); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_InvertOval(PyObject *_self, PyObject *_args) +static PyObject *Qd_ClipRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; -#ifndef InvertOval - PyMac_PRECHECK(InvertOval); +#ifndef ClipRect + PyMac_PRECHECK(ClipRect); #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetRect, &r)) return NULL; - InvertOval(&r); + ClipRect(&r); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_FillOval(PyObject *_self, PyObject *_args) +static PyObject *Qd_BackPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; Pattern *pat__in__; int pat__in_len__; -#ifndef FillOval - PyMac_PRECHECK(FillOval); +#ifndef BackPat + PyMac_PRECHECK(BackPat); #endif - if (!PyArg_ParseTuple(_args, "O&s#", - PyMac_GetRect, &r, + if (!PyArg_ParseTuple(_args, "s#", (char **)&pat__in__, &pat__in_len__)) return NULL; if (pat__in_len__ != sizeof(Pattern)) @@ -1524,704 +1495,596 @@ static PyObject *Qd_FillOval(PyObject *_self, PyObject *_args) PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); goto pat__error__; } - FillOval(&r, - pat__in__); + BackPat(pat__in__); Py_INCREF(Py_None); _res = Py_None; pat__error__: ; return _res; } -static PyObject *Qd_FrameRoundRect(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - Rect r; - short ovalWidth; - short ovalHeight; -#ifndef FrameRoundRect - PyMac_PRECHECK(FrameRoundRect); -#endif - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &ovalWidth, - &ovalHeight)) - return NULL; - FrameRoundRect(&r, - ovalWidth, - ovalHeight); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_PaintRoundRect(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - Rect r; - short ovalWidth; - short ovalHeight; -#ifndef PaintRoundRect - PyMac_PRECHECK(PaintRoundRect); -#endif - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &ovalWidth, - &ovalHeight)) - return NULL; - PaintRoundRect(&r, - ovalWidth, - ovalHeight); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_EraseRoundRect(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - Rect r; - short ovalWidth; - short ovalHeight; -#ifndef EraseRoundRect - PyMac_PRECHECK(EraseRoundRect); -#endif - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &ovalWidth, - &ovalHeight)) - return NULL; - EraseRoundRect(&r, - ovalWidth, - ovalHeight); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *Qd_InvertRoundRect(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - Rect r; - short ovalWidth; - short ovalHeight; -#ifndef InvertRoundRect - PyMac_PRECHECK(InvertRoundRect); +static PyObject *Qd_InitCursor(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; +#ifndef InitCursor + PyMac_PRECHECK(InitCursor); #endif - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &ovalWidth, - &ovalHeight)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - InvertRoundRect(&r, - ovalWidth, - ovalHeight); + InitCursor(); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_FillRoundRect(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacSetCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; - short ovalWidth; - short ovalHeight; - Pattern *pat__in__; - int pat__in_len__; -#ifndef FillRoundRect - PyMac_PRECHECK(FillRoundRect); + Cursor *crsr__in__; + int crsr__in_len__; +#ifndef MacSetCursor + PyMac_PRECHECK(MacSetCursor); #endif - if (!PyArg_ParseTuple(_args, "O&hhs#", - PyMac_GetRect, &r, - &ovalWidth, - &ovalHeight, - (char **)&pat__in__, &pat__in_len__)) + if (!PyArg_ParseTuple(_args, "s#", + (char **)&crsr__in__, &crsr__in_len__)) return NULL; - if (pat__in_len__ != sizeof(Pattern)) + if (crsr__in_len__ != sizeof(Cursor)) { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); - goto pat__error__; + PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Cursor)"); + goto crsr__error__; } - FillRoundRect(&r, - ovalWidth, - ovalHeight, - pat__in__); + MacSetCursor(crsr__in__); Py_INCREF(Py_None); _res = Py_None; - pat__error__: ; + crsr__error__: ; return _res; } -static PyObject *Qd_FrameArc(PyObject *_self, PyObject *_args) +static PyObject *Qd_HideCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; - short startAngle; - short arcAngle; -#ifndef FrameArc - PyMac_PRECHECK(FrameArc); +#ifndef HideCursor + PyMac_PRECHECK(HideCursor); #endif - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &startAngle, - &arcAngle)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - FrameArc(&r, - startAngle, - arcAngle); + HideCursor(); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_PaintArc(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacShowCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; - short startAngle; - short arcAngle; -#ifndef PaintArc - PyMac_PRECHECK(PaintArc); +#ifndef MacShowCursor + PyMac_PRECHECK(MacShowCursor); #endif - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &startAngle, - &arcAngle)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - PaintArc(&r, - startAngle, - arcAngle); + MacShowCursor(); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_EraseArc(PyObject *_self, PyObject *_args) +static PyObject *Qd_ObscureCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; - short startAngle; - short arcAngle; -#ifndef EraseArc - PyMac_PRECHECK(EraseArc); +#ifndef ObscureCursor + PyMac_PRECHECK(ObscureCursor); #endif - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &startAngle, - &arcAngle)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - EraseArc(&r, - startAngle, - arcAngle); + ObscureCursor(); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_InvertArc(PyObject *_self, PyObject *_args) +static PyObject *Qd_HidePen(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; - short startAngle; - short arcAngle; -#ifndef InvertArc - PyMac_PRECHECK(InvertArc); +#ifndef HidePen + PyMac_PRECHECK(HidePen); #endif - if (!PyArg_ParseTuple(_args, "O&hh", - PyMac_GetRect, &r, - &startAngle, - &arcAngle)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - InvertArc(&r, - startAngle, - arcAngle); + HidePen(); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_FillArc(PyObject *_self, PyObject *_args) +static PyObject *Qd_ShowPen(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; - short startAngle; - short arcAngle; - Pattern *pat__in__; - int pat__in_len__; -#ifndef FillArc - PyMac_PRECHECK(FillArc); +#ifndef ShowPen + PyMac_PRECHECK(ShowPen); #endif - if (!PyArg_ParseTuple(_args, "O&hhs#", - PyMac_GetRect, &r, - &startAngle, - &arcAngle, - (char **)&pat__in__, &pat__in_len__)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - if (pat__in_len__ != sizeof(Pattern)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); - goto pat__error__; - } - FillArc(&r, - startAngle, - arcAngle, - pat__in__); + ShowPen(); Py_INCREF(Py_None); _res = Py_None; - pat__error__: ; return _res; } -static PyObject *Qd_NewRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_GetPen(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle _rv; -#ifndef NewRgn - PyMac_PRECHECK(NewRgn); + Point pt; +#ifndef GetPen + PyMac_PRECHECK(GetPen); #endif if (!PyArg_ParseTuple(_args, "")) return NULL; - _rv = NewRgn(); + GetPen(&pt); _res = Py_BuildValue("O&", - ResObj_New, _rv); + PyMac_BuildPoint, pt); return _res; } -static PyObject *Qd_OpenRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_GetPenState(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; -#ifndef OpenRgn - PyMac_PRECHECK(OpenRgn); + PenState pnState__out__; +#ifndef GetPenState + PyMac_PRECHECK(GetPenState); #endif if (!PyArg_ParseTuple(_args, "")) return NULL; - OpenRgn(); - Py_INCREF(Py_None); - _res = Py_None; + GetPenState(&pnState__out__); + _res = Py_BuildValue("s#", + (char *)&pnState__out__, (int)sizeof(PenState)); return _res; } -static PyObject *Qd_CloseRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_SetPenState(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle dstRgn; -#ifndef CloseRgn - PyMac_PRECHECK(CloseRgn); + PenState *pnState__in__; + int pnState__in_len__; +#ifndef SetPenState + PyMac_PRECHECK(SetPenState); #endif - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &dstRgn)) + if (!PyArg_ParseTuple(_args, "s#", + (char **)&pnState__in__, &pnState__in_len__)) return NULL; - CloseRgn(dstRgn); + if (pnState__in_len__ != sizeof(PenState)) + { + PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(PenState)"); + goto pnState__error__; + } + SetPenState(pnState__in__); Py_INCREF(Py_None); _res = Py_None; + pnState__error__: ; return _res; } -static PyObject *Qd_BitMapToRegion(PyObject *_self, PyObject *_args) +static PyObject *Qd_PenSize(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - OSErr _err; - RgnHandle region; - BitMapPtr bMap; -#ifndef BitMapToRegion - PyMac_PRECHECK(BitMapToRegion); + short width; + short height; +#ifndef PenSize + PyMac_PRECHECK(PenSize); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, ®ion, - BMObj_Convert, &bMap)) + if (!PyArg_ParseTuple(_args, "hh", + &width, + &height)) return NULL; - _err = BitMapToRegion(region, - bMap); - if (_err != noErr) return PyMac_Error(_err); + PenSize(width, + height); Py_INCREF(Py_None); _res = Py_None; return _res; } -#if TARGET_API_MAC_CARBON - -static PyObject *Qd_RgnToHandle(PyObject *_self, PyObject *_args) +static PyObject *Qd_PenMode(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle region; - Handle flattenedRgnDataHdl; -#ifndef RgnToHandle - PyMac_PRECHECK(RgnToHandle); + short mode; +#ifndef PenMode + PyMac_PRECHECK(PenMode); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, ®ion, - ResObj_Convert, &flattenedRgnDataHdl)) + if (!PyArg_ParseTuple(_args, "h", + &mode)) return NULL; - RgnToHandle(region, - flattenedRgnDataHdl); + PenMode(mode); Py_INCREF(Py_None); _res = Py_None; return _res; } -#endif -static PyObject *Qd_DisposeRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_PenPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle rgn; -#ifndef DisposeRgn - PyMac_PRECHECK(DisposeRgn); + Pattern *pat__in__; + int pat__in_len__; +#ifndef PenPat + PyMac_PRECHECK(PenPat); #endif - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &rgn)) + if (!PyArg_ParseTuple(_args, "s#", + (char **)&pat__in__, &pat__in_len__)) return NULL; - DisposeRgn(rgn); + if (pat__in_len__ != sizeof(Pattern)) + { + PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); + goto pat__error__; + } + PenPat(pat__in__); Py_INCREF(Py_None); _res = Py_None; + pat__error__: ; return _res; } -static PyObject *Qd_MacCopyRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_PenNormal(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle srcRgn; - RgnHandle dstRgn; -#ifndef MacCopyRgn - PyMac_PRECHECK(MacCopyRgn); +#ifndef PenNormal + PyMac_PRECHECK(PenNormal); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &srcRgn, - ResObj_Convert, &dstRgn)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - MacCopyRgn(srcRgn, - dstRgn); + PenNormal(); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_SetEmptyRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_MoveTo(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle rgn; -#ifndef SetEmptyRgn - PyMac_PRECHECK(SetEmptyRgn); + short h; + short v; +#ifndef MoveTo + PyMac_PRECHECK(MoveTo); #endif - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &rgn)) + if (!PyArg_ParseTuple(_args, "hh", + &h, + &v)) return NULL; - SetEmptyRgn(rgn); + MoveTo(h, + v); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_MacSetRectRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_Move(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle rgn; - short left; - short top; - short right; - short bottom; -#ifndef MacSetRectRgn - PyMac_PRECHECK(MacSetRectRgn); + short dh; + short dv; +#ifndef Move + PyMac_PRECHECK(Move); #endif - if (!PyArg_ParseTuple(_args, "O&hhhh", - ResObj_Convert, &rgn, - &left, - &top, - &right, - &bottom)) + if (!PyArg_ParseTuple(_args, "hh", + &dh, + &dv)) return NULL; - MacSetRectRgn(rgn, - left, - top, - right, - bottom); + Move(dh, + dv); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_RectRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacLineTo(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle rgn; - Rect r; -#ifndef RectRgn - PyMac_PRECHECK(RectRgn); + short h; + short v; +#ifndef MacLineTo + PyMac_PRECHECK(MacLineTo); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &rgn, - PyMac_GetRect, &r)) + if (!PyArg_ParseTuple(_args, "hh", + &h, + &v)) return NULL; - RectRgn(rgn, - &r); + MacLineTo(h, + v); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_MacOffsetRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_Line(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle rgn; short dh; short dv; -#ifndef MacOffsetRgn - PyMac_PRECHECK(MacOffsetRgn); +#ifndef Line + PyMac_PRECHECK(Line); #endif - if (!PyArg_ParseTuple(_args, "O&hh", - ResObj_Convert, &rgn, + if (!PyArg_ParseTuple(_args, "hh", &dh, &dv)) return NULL; - MacOffsetRgn(rgn, - dh, - dv); + Line(dh, + dv); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_InsetRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_ForeColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle rgn; - short dh; - short dv; -#ifndef InsetRgn - PyMac_PRECHECK(InsetRgn); + long color; +#ifndef ForeColor + PyMac_PRECHECK(ForeColor); #endif - if (!PyArg_ParseTuple(_args, "O&hh", - ResObj_Convert, &rgn, - &dh, - &dv)) + if (!PyArg_ParseTuple(_args, "l", + &color)) return NULL; - InsetRgn(rgn, - dh, - dv); + ForeColor(color); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_SectRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_BackColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle srcRgnA; - RgnHandle srcRgnB; - RgnHandle dstRgn; -#ifndef SectRgn - PyMac_PRECHECK(SectRgn); + long color; +#ifndef BackColor + PyMac_PRECHECK(BackColor); #endif - if (!PyArg_ParseTuple(_args, "O&O&O&", - ResObj_Convert, &srcRgnA, - ResObj_Convert, &srcRgnB, - ResObj_Convert, &dstRgn)) + if (!PyArg_ParseTuple(_args, "l", + &color)) return NULL; - SectRgn(srcRgnA, - srcRgnB, - dstRgn); + BackColor(color); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_MacUnionRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_ColorBit(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle srcRgnA; - RgnHandle srcRgnB; - RgnHandle dstRgn; -#ifndef MacUnionRgn - PyMac_PRECHECK(MacUnionRgn); + short whichBit; +#ifndef ColorBit + PyMac_PRECHECK(ColorBit); #endif - if (!PyArg_ParseTuple(_args, "O&O&O&", - ResObj_Convert, &srcRgnA, - ResObj_Convert, &srcRgnB, - ResObj_Convert, &dstRgn)) + if (!PyArg_ParseTuple(_args, "h", + &whichBit)) return NULL; - MacUnionRgn(srcRgnA, - srcRgnB, - dstRgn); + ColorBit(whichBit); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_DiffRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacSetRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle srcRgnA; - RgnHandle srcRgnB; - RgnHandle dstRgn; -#ifndef DiffRgn - PyMac_PRECHECK(DiffRgn); + Rect r; + short left; + short top; + short right; + short bottom; +#ifndef MacSetRect + PyMac_PRECHECK(MacSetRect); #endif - if (!PyArg_ParseTuple(_args, "O&O&O&", - ResObj_Convert, &srcRgnA, - ResObj_Convert, &srcRgnB, - ResObj_Convert, &dstRgn)) + if (!PyArg_ParseTuple(_args, "hhhh", + &left, + &top, + &right, + &bottom)) return NULL; - DiffRgn(srcRgnA, - srcRgnB, - dstRgn); - Py_INCREF(Py_None); - _res = Py_None; + MacSetRect(&r, + left, + top, + right, + bottom); + _res = Py_BuildValue("O&", + PyMac_BuildRect, &r); return _res; } -static PyObject *Qd_MacXorRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacOffsetRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle srcRgnA; - RgnHandle srcRgnB; - RgnHandle dstRgn; -#ifndef MacXorRgn - PyMac_PRECHECK(MacXorRgn); + Rect r; + short dh; + short dv; +#ifndef MacOffsetRect + PyMac_PRECHECK(MacOffsetRect); #endif - if (!PyArg_ParseTuple(_args, "O&O&O&", - ResObj_Convert, &srcRgnA, - ResObj_Convert, &srcRgnB, - ResObj_Convert, &dstRgn)) + if (!PyArg_ParseTuple(_args, "O&hh", + PyMac_GetRect, &r, + &dh, + &dv)) return NULL; - MacXorRgn(srcRgnA, - srcRgnB, - dstRgn); - Py_INCREF(Py_None); - _res = Py_None; + MacOffsetRect(&r, + dh, + dv); + _res = Py_BuildValue("O&", + PyMac_BuildRect, &r); + return _res; +} + +static PyObject *Qd_MacInsetRect(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + Rect r; + short dh; + short dv; +#ifndef MacInsetRect + PyMac_PRECHECK(MacInsetRect); +#endif + if (!PyArg_ParseTuple(_args, "O&hh", + PyMac_GetRect, &r, + &dh, + &dv)) + return NULL; + MacInsetRect(&r, + dh, + dv); + _res = Py_BuildValue("O&", + PyMac_BuildRect, &r); + return _res; +} + +static PyObject *Qd_SectRect(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + Boolean _rv; + Rect src1; + Rect src2; + Rect dstRect; +#ifndef SectRect + PyMac_PRECHECK(SectRect); +#endif + if (!PyArg_ParseTuple(_args, "O&O&", + PyMac_GetRect, &src1, + PyMac_GetRect, &src2)) + return NULL; + _rv = SectRect(&src1, + &src2, + &dstRect); + _res = Py_BuildValue("bO&", + _rv, + PyMac_BuildRect, &dstRect); return _res; } -static PyObject *Qd_RectInRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacUnionRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Boolean _rv; - Rect r; - RgnHandle rgn; -#ifndef RectInRgn - PyMac_PRECHECK(RectInRgn); + Rect src1; + Rect src2; + Rect dstRect; +#ifndef MacUnionRect + PyMac_PRECHECK(MacUnionRect); #endif if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetRect, &r, - ResObj_Convert, &rgn)) + PyMac_GetRect, &src1, + PyMac_GetRect, &src2)) return NULL; - _rv = RectInRgn(&r, - rgn); - _res = Py_BuildValue("b", - _rv); + MacUnionRect(&src1, + &src2, + &dstRect); + _res = Py_BuildValue("O&", + PyMac_BuildRect, &dstRect); return _res; } -static PyObject *Qd_MacEqualRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacEqualRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; - RgnHandle rgnA; - RgnHandle rgnB; -#ifndef MacEqualRgn - PyMac_PRECHECK(MacEqualRgn); + Rect rect1; + Rect rect2; +#ifndef MacEqualRect + PyMac_PRECHECK(MacEqualRect); #endif if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &rgnA, - ResObj_Convert, &rgnB)) + PyMac_GetRect, &rect1, + PyMac_GetRect, &rect2)) return NULL; - _rv = MacEqualRgn(rgnA, - rgnB); + _rv = MacEqualRect(&rect1, + &rect2); _res = Py_BuildValue("b", _rv); return _res; } -static PyObject *Qd_EmptyRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_EmptyRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; - RgnHandle rgn; -#ifndef EmptyRgn - PyMac_PRECHECK(EmptyRgn); + Rect r; +#ifndef EmptyRect + PyMac_PRECHECK(EmptyRect); #endif if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &rgn)) + PyMac_GetRect, &r)) return NULL; - _rv = EmptyRgn(rgn); + _rv = EmptyRect(&r); _res = Py_BuildValue("b", _rv); return _res; } -static PyObject *Qd_MacFrameRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacFrameRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle rgn; -#ifndef MacFrameRgn - PyMac_PRECHECK(MacFrameRgn); + Rect r; +#ifndef MacFrameRect + PyMac_PRECHECK(MacFrameRect); #endif if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &rgn)) + PyMac_GetRect, &r)) return NULL; - MacFrameRgn(rgn); + MacFrameRect(&r); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_MacPaintRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_PaintRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle rgn; -#ifndef MacPaintRgn - PyMac_PRECHECK(MacPaintRgn); + Rect r; +#ifndef PaintRect + PyMac_PRECHECK(PaintRect); #endif if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &rgn)) + PyMac_GetRect, &r)) return NULL; - MacPaintRgn(rgn); + PaintRect(&r); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_EraseRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_EraseRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle rgn; -#ifndef EraseRgn - PyMac_PRECHECK(EraseRgn); + Rect r; +#ifndef EraseRect + PyMac_PRECHECK(EraseRect); #endif if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &rgn)) + PyMac_GetRect, &r)) return NULL; - EraseRgn(rgn); + EraseRect(&r); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_MacInvertRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacInvertRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle rgn; -#ifndef MacInvertRgn - PyMac_PRECHECK(MacInvertRgn); + Rect r; +#ifndef MacInvertRect + PyMac_PRECHECK(MacInvertRect); #endif if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &rgn)) + PyMac_GetRect, &r)) return NULL; - MacInvertRgn(rgn); + MacInvertRect(&r); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_MacFillRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacFillRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle rgn; + Rect r; Pattern *pat__in__; int pat__in_len__; -#ifndef MacFillRgn - PyMac_PRECHECK(MacFillRgn); +#ifndef MacFillRect + PyMac_PRECHECK(MacFillRect); #endif if (!PyArg_ParseTuple(_args, "O&s#", - ResObj_Convert, &rgn, + PyMac_GetRect, &r, (char **)&pat__in__, &pat__in_len__)) return NULL; if (pat__in_len__ != sizeof(Pattern)) @@ -2229,2561 +2092,2637 @@ static PyObject *Qd_MacFillRgn(PyObject *_self, PyObject *_args) PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); goto pat__error__; } - MacFillRgn(rgn, - pat__in__); + MacFillRect(&r, + pat__in__); Py_INCREF(Py_None); _res = Py_None; pat__error__: ; return _res; } -static PyObject *Qd_ScrollRect(PyObject *_self, PyObject *_args) +static PyObject *Qd_FrameOval(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Rect r; - short dh; - short dv; - RgnHandle updateRgn; -#ifndef ScrollRect - PyMac_PRECHECK(ScrollRect); +#ifndef FrameOval + PyMac_PRECHECK(FrameOval); #endif - if (!PyArg_ParseTuple(_args, "O&hhO&", - PyMac_GetRect, &r, - &dh, - &dv, - ResObj_Convert, &updateRgn)) + if (!PyArg_ParseTuple(_args, "O&", + PyMac_GetRect, &r)) return NULL; - ScrollRect(&r, - dh, - dv, - updateRgn); + FrameOval(&r); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_CopyBits(PyObject *_self, PyObject *_args) +static PyObject *Qd_PaintOval(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - BitMapPtr srcBits; - BitMapPtr dstBits; - Rect srcRect; - Rect dstRect; - short mode; - RgnHandle maskRgn; -#ifndef CopyBits - PyMac_PRECHECK(CopyBits); + Rect r; +#ifndef PaintOval + PyMac_PRECHECK(PaintOval); #endif - if (!PyArg_ParseTuple(_args, "O&O&O&O&hO&", - BMObj_Convert, &srcBits, - BMObj_Convert, &dstBits, - PyMac_GetRect, &srcRect, - PyMac_GetRect, &dstRect, - &mode, - OptResObj_Convert, &maskRgn)) + if (!PyArg_ParseTuple(_args, "O&", + PyMac_GetRect, &r)) return NULL; - CopyBits(srcBits, - dstBits, - &srcRect, - &dstRect, - mode, - maskRgn); + PaintOval(&r); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_CopyMask(PyObject *_self, PyObject *_args) +static PyObject *Qd_EraseOval(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - BitMapPtr srcBits; - BitMapPtr maskBits; - BitMapPtr dstBits; - Rect srcRect; - Rect maskRect; - Rect dstRect; -#ifndef CopyMask - PyMac_PRECHECK(CopyMask); + Rect r; +#ifndef EraseOval + PyMac_PRECHECK(EraseOval); #endif - if (!PyArg_ParseTuple(_args, "O&O&O&O&O&O&", - BMObj_Convert, &srcBits, - BMObj_Convert, &maskBits, - BMObj_Convert, &dstBits, - PyMac_GetRect, &srcRect, - PyMac_GetRect, &maskRect, - PyMac_GetRect, &dstRect)) + if (!PyArg_ParseTuple(_args, "O&", + PyMac_GetRect, &r)) return NULL; - CopyMask(srcBits, - maskBits, - dstBits, - &srcRect, - &maskRect, - &dstRect); + EraseOval(&r); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_OpenPicture(PyObject *_self, PyObject *_args) +static PyObject *Qd_InvertOval(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PicHandle _rv; - Rect picFrame; -#ifndef OpenPicture - PyMac_PRECHECK(OpenPicture); + Rect r; +#ifndef InvertOval + PyMac_PRECHECK(InvertOval); +#endif + if (!PyArg_ParseTuple(_args, "O&", + PyMac_GetRect, &r)) + return NULL; + InvertOval(&r); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *Qd_FillOval(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + Rect r; + Pattern *pat__in__; + int pat__in_len__; +#ifndef FillOval + PyMac_PRECHECK(FillOval); +#endif + if (!PyArg_ParseTuple(_args, "O&s#", + PyMac_GetRect, &r, + (char **)&pat__in__, &pat__in_len__)) + return NULL; + if (pat__in_len__ != sizeof(Pattern)) + { + PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); + goto pat__error__; + } + FillOval(&r, + pat__in__); + Py_INCREF(Py_None); + _res = Py_None; + pat__error__: ; + return _res; +} + +static PyObject *Qd_FrameRoundRect(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + Rect r; + short ovalWidth; + short ovalHeight; +#ifndef FrameRoundRect + PyMac_PRECHECK(FrameRoundRect); #endif - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &picFrame)) + if (!PyArg_ParseTuple(_args, "O&hh", + PyMac_GetRect, &r, + &ovalWidth, + &ovalHeight)) return NULL; - _rv = OpenPicture(&picFrame); - _res = Py_BuildValue("O&", - ResObj_New, _rv); + FrameRoundRect(&r, + ovalWidth, + ovalHeight); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_PicComment(PyObject *_self, PyObject *_args) +static PyObject *Qd_PaintRoundRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - short kind; - short dataSize; - Handle dataHandle; -#ifndef PicComment - PyMac_PRECHECK(PicComment); + Rect r; + short ovalWidth; + short ovalHeight; +#ifndef PaintRoundRect + PyMac_PRECHECK(PaintRoundRect); #endif - if (!PyArg_ParseTuple(_args, "hhO&", - &kind, - &dataSize, - ResObj_Convert, &dataHandle)) + if (!PyArg_ParseTuple(_args, "O&hh", + PyMac_GetRect, &r, + &ovalWidth, + &ovalHeight)) return NULL; - PicComment(kind, - dataSize, - dataHandle); + PaintRoundRect(&r, + ovalWidth, + ovalHeight); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_ClosePicture(PyObject *_self, PyObject *_args) +static PyObject *Qd_EraseRoundRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; -#ifndef ClosePicture - PyMac_PRECHECK(ClosePicture); + Rect r; + short ovalWidth; + short ovalHeight; +#ifndef EraseRoundRect + PyMac_PRECHECK(EraseRoundRect); #endif - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&hh", + PyMac_GetRect, &r, + &ovalWidth, + &ovalHeight)) return NULL; - ClosePicture(); + EraseRoundRect(&r, + ovalWidth, + ovalHeight); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_DrawPicture(PyObject *_self, PyObject *_args) +static PyObject *Qd_InvertRoundRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PicHandle myPicture; - Rect dstRect; -#ifndef DrawPicture - PyMac_PRECHECK(DrawPicture); + Rect r; + short ovalWidth; + short ovalHeight; +#ifndef InvertRoundRect + PyMac_PRECHECK(InvertRoundRect); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &myPicture, - PyMac_GetRect, &dstRect)) + if (!PyArg_ParseTuple(_args, "O&hh", + PyMac_GetRect, &r, + &ovalWidth, + &ovalHeight)) return NULL; - DrawPicture(myPicture, - &dstRect); + InvertRoundRect(&r, + ovalWidth, + ovalHeight); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_KillPicture(PyObject *_self, PyObject *_args) +static PyObject *Qd_FillRoundRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PicHandle myPicture; -#ifndef KillPicture - PyMac_PRECHECK(KillPicture); + Rect r; + short ovalWidth; + short ovalHeight; + Pattern *pat__in__; + int pat__in_len__; +#ifndef FillRoundRect + PyMac_PRECHECK(FillRoundRect); #endif - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &myPicture)) + if (!PyArg_ParseTuple(_args, "O&hhs#", + PyMac_GetRect, &r, + &ovalWidth, + &ovalHeight, + (char **)&pat__in__, &pat__in_len__)) return NULL; - KillPicture(myPicture); + if (pat__in_len__ != sizeof(Pattern)) + { + PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); + goto pat__error__; + } + FillRoundRect(&r, + ovalWidth, + ovalHeight, + pat__in__); Py_INCREF(Py_None); _res = Py_None; + pat__error__: ; return _res; } -static PyObject *Qd_OpenPoly(PyObject *_self, PyObject *_args) +static PyObject *Qd_FrameArc(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PolyHandle _rv; -#ifndef OpenPoly - PyMac_PRECHECK(OpenPoly); + Rect r; + short startAngle; + short arcAngle; +#ifndef FrameArc + PyMac_PRECHECK(FrameArc); #endif - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&hh", + PyMac_GetRect, &r, + &startAngle, + &arcAngle)) return NULL; - _rv = OpenPoly(); - _res = Py_BuildValue("O&", - ResObj_New, _rv); + FrameArc(&r, + startAngle, + arcAngle); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_ClosePoly(PyObject *_self, PyObject *_args) +static PyObject *Qd_PaintArc(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; -#ifndef ClosePoly - PyMac_PRECHECK(ClosePoly); + Rect r; + short startAngle; + short arcAngle; +#ifndef PaintArc + PyMac_PRECHECK(PaintArc); #endif - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&hh", + PyMac_GetRect, &r, + &startAngle, + &arcAngle)) return NULL; - ClosePoly(); + PaintArc(&r, + startAngle, + arcAngle); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_KillPoly(PyObject *_self, PyObject *_args) +static PyObject *Qd_EraseArc(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PolyHandle poly; -#ifndef KillPoly - PyMac_PRECHECK(KillPoly); + Rect r; + short startAngle; + short arcAngle; +#ifndef EraseArc + PyMac_PRECHECK(EraseArc); #endif - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &poly)) + if (!PyArg_ParseTuple(_args, "O&hh", + PyMac_GetRect, &r, + &startAngle, + &arcAngle)) return NULL; - KillPoly(poly); + EraseArc(&r, + startAngle, + arcAngle); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_OffsetPoly(PyObject *_self, PyObject *_args) +static PyObject *Qd_InvertArc(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PolyHandle poly; - short dh; - short dv; -#ifndef OffsetPoly - PyMac_PRECHECK(OffsetPoly); + Rect r; + short startAngle; + short arcAngle; +#ifndef InvertArc + PyMac_PRECHECK(InvertArc); #endif if (!PyArg_ParseTuple(_args, "O&hh", - ResObj_Convert, &poly, - &dh, - &dv)) + PyMac_GetRect, &r, + &startAngle, + &arcAngle)) return NULL; - OffsetPoly(poly, - dh, - dv); + InvertArc(&r, + startAngle, + arcAngle); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_FramePoly(PyObject *_self, PyObject *_args) +static PyObject *Qd_FillArc(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PolyHandle poly; -#ifndef FramePoly - PyMac_PRECHECK(FramePoly); + Rect r; + short startAngle; + short arcAngle; + Pattern *pat__in__; + int pat__in_len__; +#ifndef FillArc + PyMac_PRECHECK(FillArc); #endif - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &poly)) + if (!PyArg_ParseTuple(_args, "O&hhs#", + PyMac_GetRect, &r, + &startAngle, + &arcAngle, + (char **)&pat__in__, &pat__in_len__)) return NULL; - FramePoly(poly); + if (pat__in_len__ != sizeof(Pattern)) + { + PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); + goto pat__error__; + } + FillArc(&r, + startAngle, + arcAngle, + pat__in__); Py_INCREF(Py_None); _res = Py_None; + pat__error__: ; return _res; } -static PyObject *Qd_PaintPoly(PyObject *_self, PyObject *_args) +static PyObject *Qd_NewRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PolyHandle poly; -#ifndef PaintPoly - PyMac_PRECHECK(PaintPoly); + RgnHandle _rv; +#ifndef NewRgn + PyMac_PRECHECK(NewRgn); #endif - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &poly)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - PaintPoly(poly); - Py_INCREF(Py_None); - _res = Py_None; + _rv = NewRgn(); + _res = Py_BuildValue("O&", + ResObj_New, _rv); return _res; } -static PyObject *Qd_ErasePoly(PyObject *_self, PyObject *_args) +static PyObject *Qd_OpenRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PolyHandle poly; -#ifndef ErasePoly - PyMac_PRECHECK(ErasePoly); +#ifndef OpenRgn + PyMac_PRECHECK(OpenRgn); #endif - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &poly)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - ErasePoly(poly); + OpenRgn(); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_InvertPoly(PyObject *_self, PyObject *_args) +static PyObject *Qd_CloseRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PolyHandle poly; -#ifndef InvertPoly - PyMac_PRECHECK(InvertPoly); + RgnHandle dstRgn; +#ifndef CloseRgn + PyMac_PRECHECK(CloseRgn); #endif if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &poly)) + ResObj_Convert, &dstRgn)) return NULL; - InvertPoly(poly); + CloseRgn(dstRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_FillPoly(PyObject *_self, PyObject *_args) +static PyObject *Qd_BitMapToRegion(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PolyHandle poly; - Pattern *pat__in__; - int pat__in_len__; -#ifndef FillPoly - PyMac_PRECHECK(FillPoly); + OSErr _err; + RgnHandle region; + BitMapPtr bMap; +#ifndef BitMapToRegion + PyMac_PRECHECK(BitMapToRegion); #endif - if (!PyArg_ParseTuple(_args, "O&s#", - ResObj_Convert, &poly, - (char **)&pat__in__, &pat__in_len__)) + if (!PyArg_ParseTuple(_args, "O&O&", + ResObj_Convert, ®ion, + BMObj_Convert, &bMap)) return NULL; - if (pat__in_len__ != sizeof(Pattern)) - { - PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); - goto pat__error__; - } - FillPoly(poly, - pat__in__); + _err = BitMapToRegion(region, + bMap); + if (_err != noErr) return PyMac_Error(_err); Py_INCREF(Py_None); _res = Py_None; - pat__error__: ; return _res; } -static PyObject *Qd_SetPt(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - Point pt; - short h; - short v; -#ifndef SetPt - PyMac_PRECHECK(SetPt); -#endif - if (!PyArg_ParseTuple(_args, "hh", - &h, - &v)) - return NULL; - SetPt(&pt, - h, - v); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, pt); - return _res; -} +#if TARGET_API_MAC_CARBON -static PyObject *Qd_LocalToGlobal(PyObject *_self, PyObject *_args) +static PyObject *Qd_RgnToHandle(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Point pt; -#ifndef LocalToGlobal - PyMac_PRECHECK(LocalToGlobal); + RgnHandle region; + Handle flattenedRgnDataHdl; +#ifndef RgnToHandle + PyMac_PRECHECK(RgnToHandle); #endif - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetPoint, &pt)) + if (!PyArg_ParseTuple(_args, "O&O&", + ResObj_Convert, ®ion, + ResObj_Convert, &flattenedRgnDataHdl)) return NULL; - LocalToGlobal(&pt); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, pt); + RgnToHandle(region, + flattenedRgnDataHdl); + Py_INCREF(Py_None); + _res = Py_None; return _res; } +#endif -static PyObject *Qd_GlobalToLocal(PyObject *_self, PyObject *_args) +static PyObject *Qd_DisposeRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Point pt; -#ifndef GlobalToLocal - PyMac_PRECHECK(GlobalToLocal); + RgnHandle rgn; +#ifndef DisposeRgn + PyMac_PRECHECK(DisposeRgn); #endif if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetPoint, &pt)) + ResObj_Convert, &rgn)) return NULL; - GlobalToLocal(&pt); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, pt); + DisposeRgn(rgn); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_Random(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacCopyRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - short _rv; -#ifndef Random - PyMac_PRECHECK(Random); + RgnHandle srcRgn; + RgnHandle dstRgn; +#ifndef MacCopyRgn + PyMac_PRECHECK(MacCopyRgn); #endif - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&O&", + ResObj_Convert, &srcRgn, + ResObj_Convert, &dstRgn)) return NULL; - _rv = Random(); - _res = Py_BuildValue("h", - _rv); + MacCopyRgn(srcRgn, + dstRgn); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_MacGetPixel(PyObject *_self, PyObject *_args) +static PyObject *Qd_SetEmptyRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Boolean _rv; - short h; - short v; -#ifndef MacGetPixel - PyMac_PRECHECK(MacGetPixel); + RgnHandle rgn; +#ifndef SetEmptyRgn + PyMac_PRECHECK(SetEmptyRgn); #endif - if (!PyArg_ParseTuple(_args, "hh", - &h, - &v)) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &rgn)) return NULL; - _rv = MacGetPixel(h, - v); - _res = Py_BuildValue("b", - _rv); + SetEmptyRgn(rgn); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_ScalePt(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacSetRectRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Point pt; - Rect srcRect; - Rect dstRect; -#ifndef ScalePt - PyMac_PRECHECK(ScalePt); + RgnHandle rgn; + short left; + short top; + short right; + short bottom; +#ifndef MacSetRectRgn + PyMac_PRECHECK(MacSetRectRgn); #endif - if (!PyArg_ParseTuple(_args, "O&O&O&", - PyMac_GetPoint, &pt, - PyMac_GetRect, &srcRect, - PyMac_GetRect, &dstRect)) + if (!PyArg_ParseTuple(_args, "O&hhhh", + ResObj_Convert, &rgn, + &left, + &top, + &right, + &bottom)) return NULL; - ScalePt(&pt, - &srcRect, - &dstRect); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, pt); + MacSetRectRgn(rgn, + left, + top, + right, + bottom); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_MapPt(PyObject *_self, PyObject *_args) +static PyObject *Qd_RectRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Point pt; - Rect srcRect; - Rect dstRect; -#ifndef MapPt - PyMac_PRECHECK(MapPt); + RgnHandle rgn; + Rect r; +#ifndef RectRgn + PyMac_PRECHECK(RectRgn); #endif - if (!PyArg_ParseTuple(_args, "O&O&O&", - PyMac_GetPoint, &pt, - PyMac_GetRect, &srcRect, - PyMac_GetRect, &dstRect)) + if (!PyArg_ParseTuple(_args, "O&O&", + ResObj_Convert, &rgn, + PyMac_GetRect, &r)) return NULL; - MapPt(&pt, - &srcRect, - &dstRect); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, pt); + RectRgn(rgn, + &r); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_MapRect(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacOffsetRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; - Rect srcRect; - Rect dstRect; -#ifndef MapRect - PyMac_PRECHECK(MapRect); + RgnHandle rgn; + short dh; + short dv; +#ifndef MacOffsetRgn + PyMac_PRECHECK(MacOffsetRgn); #endif - if (!PyArg_ParseTuple(_args, "O&O&O&", - PyMac_GetRect, &r, - PyMac_GetRect, &srcRect, - PyMac_GetRect, &dstRect)) + if (!PyArg_ParseTuple(_args, "O&hh", + ResObj_Convert, &rgn, + &dh, + &dv)) return NULL; - MapRect(&r, - &srcRect, - &dstRect); - _res = Py_BuildValue("O&", - PyMac_BuildRect, &r); + MacOffsetRgn(rgn, + dh, + dv); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_MapRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_InsetRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; RgnHandle rgn; - Rect srcRect; - Rect dstRect; -#ifndef MapRgn - PyMac_PRECHECK(MapRgn); + short dh; + short dv; +#ifndef InsetRgn + PyMac_PRECHECK(InsetRgn); #endif - if (!PyArg_ParseTuple(_args, "O&O&O&", + if (!PyArg_ParseTuple(_args, "O&hh", ResObj_Convert, &rgn, - PyMac_GetRect, &srcRect, - PyMac_GetRect, &dstRect)) + &dh, + &dv)) return NULL; - MapRgn(rgn, - &srcRect, - &dstRect); + InsetRgn(rgn, + dh, + dv); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_MapPoly(PyObject *_self, PyObject *_args) +static PyObject *Qd_SectRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PolyHandle poly; - Rect srcRect; - Rect dstRect; -#ifndef MapPoly - PyMac_PRECHECK(MapPoly); + RgnHandle srcRgnA; + RgnHandle srcRgnB; + RgnHandle dstRgn; +#ifndef SectRgn + PyMac_PRECHECK(SectRgn); #endif if (!PyArg_ParseTuple(_args, "O&O&O&", - ResObj_Convert, &poly, - PyMac_GetRect, &srcRect, - PyMac_GetRect, &dstRect)) + ResObj_Convert, &srcRgnA, + ResObj_Convert, &srcRgnB, + ResObj_Convert, &dstRgn)) return NULL; - MapPoly(poly, - &srcRect, - &dstRect); + SectRgn(srcRgnA, + srcRgnB, + dstRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_StdBits(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacUnionRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - BitMapPtr srcBits; - Rect srcRect; - Rect dstRect; - short mode; - RgnHandle maskRgn; -#ifndef StdBits - PyMac_PRECHECK(StdBits); + RgnHandle srcRgnA; + RgnHandle srcRgnB; + RgnHandle dstRgn; +#ifndef MacUnionRgn + PyMac_PRECHECK(MacUnionRgn); #endif - if (!PyArg_ParseTuple(_args, "O&O&O&hO&", - BMObj_Convert, &srcBits, - PyMac_GetRect, &srcRect, - PyMac_GetRect, &dstRect, - &mode, - OptResObj_Convert, &maskRgn)) + if (!PyArg_ParseTuple(_args, "O&O&O&", + ResObj_Convert, &srcRgnA, + ResObj_Convert, &srcRgnB, + ResObj_Convert, &dstRgn)) return NULL; - StdBits(srcBits, - &srcRect, - &dstRect, - mode, - maskRgn); + MacUnionRgn(srcRgnA, + srcRgnB, + dstRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_AddPt(PyObject *_self, PyObject *_args) +static PyObject *Qd_DiffRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Point src; - Point dst; -#ifndef AddPt - PyMac_PRECHECK(AddPt); + RgnHandle srcRgnA; + RgnHandle srcRgnB; + RgnHandle dstRgn; +#ifndef DiffRgn + PyMac_PRECHECK(DiffRgn); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetPoint, &src, - PyMac_GetPoint, &dst)) + if (!PyArg_ParseTuple(_args, "O&O&O&", + ResObj_Convert, &srcRgnA, + ResObj_Convert, &srcRgnB, + ResObj_Convert, &dstRgn)) return NULL; - AddPt(src, - &dst); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, dst); + DiffRgn(srcRgnA, + srcRgnB, + dstRgn); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_EqualPt(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacXorRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Boolean _rv; - Point pt1; - Point pt2; -#ifndef EqualPt - PyMac_PRECHECK(EqualPt); + RgnHandle srcRgnA; + RgnHandle srcRgnB; + RgnHandle dstRgn; +#ifndef MacXorRgn + PyMac_PRECHECK(MacXorRgn); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetPoint, &pt1, - PyMac_GetPoint, &pt2)) + if (!PyArg_ParseTuple(_args, "O&O&O&", + ResObj_Convert, &srcRgnA, + ResObj_Convert, &srcRgnB, + ResObj_Convert, &dstRgn)) return NULL; - _rv = EqualPt(pt1, - pt2); - _res = Py_BuildValue("b", - _rv); + MacXorRgn(srcRgnA, + srcRgnB, + dstRgn); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_MacPtInRect(PyObject *_self, PyObject *_args) +static PyObject *Qd_RectInRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; - Point pt; Rect r; -#ifndef MacPtInRect - PyMac_PRECHECK(MacPtInRect); + RgnHandle rgn; +#ifndef RectInRgn + PyMac_PRECHECK(RectInRgn); #endif if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetPoint, &pt, - PyMac_GetRect, &r)) + PyMac_GetRect, &r, + ResObj_Convert, &rgn)) return NULL; - _rv = MacPtInRect(pt, - &r); + _rv = RectInRgn(&r, + rgn); _res = Py_BuildValue("b", _rv); return _res; } -static PyObject *Qd_Pt2Rect(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacEqualRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Point pt1; - Point pt2; - Rect dstRect; -#ifndef Pt2Rect - PyMac_PRECHECK(Pt2Rect); + Boolean _rv; + RgnHandle rgnA; + RgnHandle rgnB; +#ifndef MacEqualRgn + PyMac_PRECHECK(MacEqualRgn); #endif if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetPoint, &pt1, - PyMac_GetPoint, &pt2)) + ResObj_Convert, &rgnA, + ResObj_Convert, &rgnB)) return NULL; - Pt2Rect(pt1, - pt2, - &dstRect); - _res = Py_BuildValue("O&", - PyMac_BuildRect, &dstRect); + _rv = MacEqualRgn(rgnA, + rgnB); + _res = Py_BuildValue("b", + _rv); return _res; } -static PyObject *Qd_PtToAngle(PyObject *_self, PyObject *_args) +static PyObject *Qd_EmptyRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; - Point pt; - short angle; -#ifndef PtToAngle - PyMac_PRECHECK(PtToAngle); + Boolean _rv; + RgnHandle rgn; +#ifndef EmptyRgn + PyMac_PRECHECK(EmptyRgn); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetRect, &r, - PyMac_GetPoint, &pt)) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &rgn)) return NULL; - PtToAngle(&r, - pt, - &angle); - _res = Py_BuildValue("h", - angle); + _rv = EmptyRgn(rgn); + _res = Py_BuildValue("b", + _rv); return _res; } -static PyObject *Qd_SubPt(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacFrameRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Point src; - Point dst; -#ifndef SubPt - PyMac_PRECHECK(SubPt); + RgnHandle rgn; +#ifndef MacFrameRgn + PyMac_PRECHECK(MacFrameRgn); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetPoint, &src, - PyMac_GetPoint, &dst)) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &rgn)) return NULL; - SubPt(src, - &dst); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, dst); + MacFrameRgn(rgn); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_PtInRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacPaintRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Boolean _rv; - Point pt; RgnHandle rgn; -#ifndef PtInRgn - PyMac_PRECHECK(PtInRgn); +#ifndef MacPaintRgn + PyMac_PRECHECK(MacPaintRgn); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetPoint, &pt, + if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &rgn)) return NULL; - _rv = PtInRgn(pt, - rgn); - _res = Py_BuildValue("b", - _rv); + MacPaintRgn(rgn); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_NewPixMap(PyObject *_self, PyObject *_args) +static PyObject *Qd_EraseRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PixMapHandle _rv; -#ifndef NewPixMap - PyMac_PRECHECK(NewPixMap); + RgnHandle rgn; +#ifndef EraseRgn + PyMac_PRECHECK(EraseRgn); #endif - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &rgn)) return NULL; - _rv = NewPixMap(); - _res = Py_BuildValue("O&", - ResObj_New, _rv); + EraseRgn(rgn); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_DisposePixMap(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacInvertRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PixMapHandle pm; -#ifndef DisposePixMap - PyMac_PRECHECK(DisposePixMap); + RgnHandle rgn; +#ifndef MacInvertRgn + PyMac_PRECHECK(MacInvertRgn); #endif if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &pm)) + ResObj_Convert, &rgn)) return NULL; - DisposePixMap(pm); + MacInvertRgn(rgn); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_CopyPixMap(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacFillRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PixMapHandle srcPM; - PixMapHandle dstPM; -#ifndef CopyPixMap - PyMac_PRECHECK(CopyPixMap); + RgnHandle rgn; + Pattern *pat__in__; + int pat__in_len__; +#ifndef MacFillRgn + PyMac_PRECHECK(MacFillRgn); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &srcPM, - ResObj_Convert, &dstPM)) + if (!PyArg_ParseTuple(_args, "O&s#", + ResObj_Convert, &rgn, + (char **)&pat__in__, &pat__in_len__)) return NULL; - CopyPixMap(srcPM, - dstPM); + if (pat__in_len__ != sizeof(Pattern)) + { + PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); + goto pat__error__; + } + MacFillRgn(rgn, + pat__in__); Py_INCREF(Py_None); _res = Py_None; + pat__error__: ; return _res; } -static PyObject *Qd_NewPixPat(PyObject *_self, PyObject *_args) +static PyObject *Qd_ScrollRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PixPatHandle _rv; -#ifndef NewPixPat - PyMac_PRECHECK(NewPixPat); + Rect r; + short dh; + short dv; + RgnHandle updateRgn; +#ifndef ScrollRect + PyMac_PRECHECK(ScrollRect); #endif - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&hhO&", + PyMac_GetRect, &r, + &dh, + &dv, + ResObj_Convert, &updateRgn)) return NULL; - _rv = NewPixPat(); - _res = Py_BuildValue("O&", - ResObj_New, _rv); + ScrollRect(&r, + dh, + dv, + updateRgn); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_DisposePixPat(PyObject *_self, PyObject *_args) +static PyObject *Qd_CopyBits(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PixPatHandle pp; -#ifndef DisposePixPat - PyMac_PRECHECK(DisposePixPat); + BitMapPtr srcBits; + BitMapPtr dstBits; + Rect srcRect; + Rect dstRect; + short mode; + RgnHandle maskRgn; +#ifndef CopyBits + PyMac_PRECHECK(CopyBits); #endif - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &pp)) + if (!PyArg_ParseTuple(_args, "O&O&O&O&hO&", + BMObj_Convert, &srcBits, + BMObj_Convert, &dstBits, + PyMac_GetRect, &srcRect, + PyMac_GetRect, &dstRect, + &mode, + OptResObj_Convert, &maskRgn)) return NULL; - DisposePixPat(pp); + CopyBits(srcBits, + dstBits, + &srcRect, + &dstRect, + mode, + maskRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_CopyPixPat(PyObject *_self, PyObject *_args) +static PyObject *Qd_CopyMask(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PixPatHandle srcPP; - PixPatHandle dstPP; -#ifndef CopyPixPat - PyMac_PRECHECK(CopyPixPat); + BitMapPtr srcBits; + BitMapPtr maskBits; + BitMapPtr dstBits; + Rect srcRect; + Rect maskRect; + Rect dstRect; +#ifndef CopyMask + PyMac_PRECHECK(CopyMask); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &srcPP, - ResObj_Convert, &dstPP)) + if (!PyArg_ParseTuple(_args, "O&O&O&O&O&O&", + BMObj_Convert, &srcBits, + BMObj_Convert, &maskBits, + BMObj_Convert, &dstBits, + PyMac_GetRect, &srcRect, + PyMac_GetRect, &maskRect, + PyMac_GetRect, &dstRect)) return NULL; - CopyPixPat(srcPP, - dstPP); + CopyMask(srcBits, + maskBits, + dstBits, + &srcRect, + &maskRect, + &dstRect); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_PenPixPat(PyObject *_self, PyObject *_args) +static PyObject *Qd_OpenPicture(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PixPatHandle pp; -#ifndef PenPixPat - PyMac_PRECHECK(PenPixPat); + PicHandle _rv; + Rect picFrame; +#ifndef OpenPicture + PyMac_PRECHECK(OpenPicture); #endif if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &pp)) + PyMac_GetRect, &picFrame)) return NULL; - PenPixPat(pp); - Py_INCREF(Py_None); - _res = Py_None; + _rv = OpenPicture(&picFrame); + _res = Py_BuildValue("O&", + ResObj_New, _rv); return _res; } -static PyObject *Qd_BackPixPat(PyObject *_self, PyObject *_args) +static PyObject *Qd_PicComment(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PixPatHandle pp; -#ifndef BackPixPat - PyMac_PRECHECK(BackPixPat); + short kind; + short dataSize; + Handle dataHandle; +#ifndef PicComment + PyMac_PRECHECK(PicComment); #endif - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &pp)) + if (!PyArg_ParseTuple(_args, "hhO&", + &kind, + &dataSize, + ResObj_Convert, &dataHandle)) return NULL; - BackPixPat(pp); + PicComment(kind, + dataSize, + dataHandle); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_GetPixPat(PyObject *_self, PyObject *_args) +static PyObject *Qd_ClosePicture(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PixPatHandle _rv; - short patID; -#ifndef GetPixPat - PyMac_PRECHECK(GetPixPat); +#ifndef ClosePicture + PyMac_PRECHECK(ClosePicture); #endif - if (!PyArg_ParseTuple(_args, "h", - &patID)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - _rv = GetPixPat(patID); - _res = Py_BuildValue("O&", - ResObj_New, _rv); + ClosePicture(); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_MakeRGBPat(PyObject *_self, PyObject *_args) +static PyObject *Qd_DrawPicture(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PixPatHandle pp; - RGBColor myColor; -#ifndef MakeRGBPat - PyMac_PRECHECK(MakeRGBPat); + PicHandle myPicture; + Rect dstRect; +#ifndef DrawPicture + PyMac_PRECHECK(DrawPicture); #endif if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &pp, - QdRGB_Convert, &myColor)) + ResObj_Convert, &myPicture, + PyMac_GetRect, &dstRect)) return NULL; - MakeRGBPat(pp, - &myColor); + DrawPicture(myPicture, + &dstRect); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_FillCRect(PyObject *_self, PyObject *_args) +static PyObject *Qd_KillPicture(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; - PixPatHandle pp; -#ifndef FillCRect - PyMac_PRECHECK(FillCRect); + PicHandle myPicture; +#ifndef KillPicture + PyMac_PRECHECK(KillPicture); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetRect, &r, - ResObj_Convert, &pp)) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &myPicture)) return NULL; - FillCRect(&r, - pp); + KillPicture(myPicture); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_FillCOval(PyObject *_self, PyObject *_args) +static PyObject *Qd_OpenPoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; - PixPatHandle pp; -#ifndef FillCOval - PyMac_PRECHECK(FillCOval); + PolyHandle _rv; +#ifndef OpenPoly + PyMac_PRECHECK(OpenPoly); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetRect, &r, - ResObj_Convert, &pp)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - FillCOval(&r, - pp); - Py_INCREF(Py_None); - _res = Py_None; + _rv = OpenPoly(); + _res = Py_BuildValue("O&", + ResObj_New, _rv); return _res; } -static PyObject *Qd_FillCRoundRect(PyObject *_self, PyObject *_args) +static PyObject *Qd_ClosePoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; - short ovalWidth; - short ovalHeight; - PixPatHandle pp; -#ifndef FillCRoundRect - PyMac_PRECHECK(FillCRoundRect); +#ifndef ClosePoly + PyMac_PRECHECK(ClosePoly); #endif - if (!PyArg_ParseTuple(_args, "O&hhO&", - PyMac_GetRect, &r, - &ovalWidth, - &ovalHeight, - ResObj_Convert, &pp)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - FillCRoundRect(&r, - ovalWidth, - ovalHeight, - pp); + ClosePoly(); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_FillCArc(PyObject *_self, PyObject *_args) +static PyObject *Qd_KillPoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect r; - short startAngle; - short arcAngle; - PixPatHandle pp; -#ifndef FillCArc - PyMac_PRECHECK(FillCArc); + PolyHandle poly; +#ifndef KillPoly + PyMac_PRECHECK(KillPoly); #endif - if (!PyArg_ParseTuple(_args, "O&hhO&", - PyMac_GetRect, &r, - &startAngle, - &arcAngle, - ResObj_Convert, &pp)) - return NULL; - FillCArc(&r, - startAngle, - arcAngle, - pp); + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &poly)) + return NULL; + KillPoly(poly); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_FillCRgn(PyObject *_self, PyObject *_args) +static PyObject *Qd_OffsetPoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle rgn; - PixPatHandle pp; -#ifndef FillCRgn - PyMac_PRECHECK(FillCRgn); + PolyHandle poly; + short dh; + short dv; +#ifndef OffsetPoly + PyMac_PRECHECK(OffsetPoly); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &rgn, - ResObj_Convert, &pp)) + if (!PyArg_ParseTuple(_args, "O&hh", + ResObj_Convert, &poly, + &dh, + &dv)) return NULL; - FillCRgn(rgn, - pp); + OffsetPoly(poly, + dh, + dv); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_FillCPoly(PyObject *_self, PyObject *_args) +static PyObject *Qd_FramePoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; PolyHandle poly; - PixPatHandle pp; -#ifndef FillCPoly - PyMac_PRECHECK(FillCPoly); +#ifndef FramePoly + PyMac_PRECHECK(FramePoly); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - ResObj_Convert, &poly, - ResObj_Convert, &pp)) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &poly)) return NULL; - FillCPoly(poly, - pp); + FramePoly(poly); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_RGBForeColor(PyObject *_self, PyObject *_args) +static PyObject *Qd_PaintPoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RGBColor color; -#ifndef RGBForeColor - PyMac_PRECHECK(RGBForeColor); + PolyHandle poly; +#ifndef PaintPoly + PyMac_PRECHECK(PaintPoly); #endif if (!PyArg_ParseTuple(_args, "O&", - QdRGB_Convert, &color)) + ResObj_Convert, &poly)) return NULL; - RGBForeColor(&color); + PaintPoly(poly); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_RGBBackColor(PyObject *_self, PyObject *_args) +static PyObject *Qd_ErasePoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RGBColor color; -#ifndef RGBBackColor - PyMac_PRECHECK(RGBBackColor); + PolyHandle poly; +#ifndef ErasePoly + PyMac_PRECHECK(ErasePoly); #endif if (!PyArg_ParseTuple(_args, "O&", - QdRGB_Convert, &color)) + ResObj_Convert, &poly)) return NULL; - RGBBackColor(&color); + ErasePoly(poly); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_SetCPixel(PyObject *_self, PyObject *_args) +static PyObject *Qd_InvertPoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - short h; - short v; - RGBColor cPix; -#ifndef SetCPixel - PyMac_PRECHECK(SetCPixel); + PolyHandle poly; +#ifndef InvertPoly + PyMac_PRECHECK(InvertPoly); #endif - if (!PyArg_ParseTuple(_args, "hhO&", - &h, - &v, - QdRGB_Convert, &cPix)) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &poly)) return NULL; - SetCPixel(h, - v, - &cPix); + InvertPoly(poly); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_SetPortPix(PyObject *_self, PyObject *_args) +static PyObject *Qd_FillPoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PixMapHandle pm; -#ifndef SetPortPix - PyMac_PRECHECK(SetPortPix); + PolyHandle poly; + Pattern *pat__in__; + int pat__in_len__; +#ifndef FillPoly + PyMac_PRECHECK(FillPoly); #endif - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &pm)) + if (!PyArg_ParseTuple(_args, "O&s#", + ResObj_Convert, &poly, + (char **)&pat__in__, &pat__in_len__)) return NULL; - SetPortPix(pm); + if (pat__in_len__ != sizeof(Pattern)) + { + PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)"); + goto pat__error__; + } + FillPoly(poly, + pat__in__); Py_INCREF(Py_None); _res = Py_None; + pat__error__: ; return _res; } -static PyObject *Qd_GetCPixel(PyObject *_self, PyObject *_args) +static PyObject *Qd_SetPt(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; + Point pt; short h; short v; - RGBColor cPix; -#ifndef GetCPixel - PyMac_PRECHECK(GetCPixel); +#ifndef SetPt + PyMac_PRECHECK(SetPt); #endif if (!PyArg_ParseTuple(_args, "hh", &h, &v)) return NULL; - GetCPixel(h, - v, - &cPix); + SetPt(&pt, + h, + v); _res = Py_BuildValue("O&", - QdRGB_New, &cPix); + PyMac_BuildPoint, pt); return _res; } -static PyObject *Qd_GetForeColor(PyObject *_self, PyObject *_args) +static PyObject *Qd_LocalToGlobal(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RGBColor color; -#ifndef GetForeColor - PyMac_PRECHECK(GetForeColor); + Point pt; +#ifndef LocalToGlobal + PyMac_PRECHECK(LocalToGlobal); #endif - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&", + PyMac_GetPoint, &pt)) return NULL; - GetForeColor(&color); + LocalToGlobal(&pt); _res = Py_BuildValue("O&", - QdRGB_New, &color); + PyMac_BuildPoint, pt); return _res; } -static PyObject *Qd_GetBackColor(PyObject *_self, PyObject *_args) +static PyObject *Qd_GlobalToLocal(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RGBColor color; -#ifndef GetBackColor - PyMac_PRECHECK(GetBackColor); + Point pt; +#ifndef GlobalToLocal + PyMac_PRECHECK(GlobalToLocal); #endif - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&", + PyMac_GetPoint, &pt)) return NULL; - GetBackColor(&color); + GlobalToLocal(&pt); _res = Py_BuildValue("O&", - QdRGB_New, &color); + PyMac_BuildPoint, pt); return _res; } -static PyObject *Qd_OpColor(PyObject *_self, PyObject *_args) +static PyObject *Qd_Random(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RGBColor color; -#ifndef OpColor - PyMac_PRECHECK(OpColor); + short _rv; +#ifndef Random + PyMac_PRECHECK(Random); #endif - if (!PyArg_ParseTuple(_args, "O&", - QdRGB_Convert, &color)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - OpColor(&color); - Py_INCREF(Py_None); - _res = Py_None; + _rv = Random(); + _res = Py_BuildValue("h", + _rv); return _res; } -static PyObject *Qd_HiliteColor(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacGetPixel(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RGBColor color; -#ifndef HiliteColor - PyMac_PRECHECK(HiliteColor); + Boolean _rv; + short h; + short v; +#ifndef MacGetPixel + PyMac_PRECHECK(MacGetPixel); #endif - if (!PyArg_ParseTuple(_args, "O&", - QdRGB_Convert, &color)) + if (!PyArg_ParseTuple(_args, "hh", + &h, + &v)) return NULL; - HiliteColor(&color); - Py_INCREF(Py_None); - _res = Py_None; + _rv = MacGetPixel(h, + v); + _res = Py_BuildValue("b", + _rv); return _res; } -static PyObject *Qd_DisposeCTable(PyObject *_self, PyObject *_args) +static PyObject *Qd_ScalePt(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CTabHandle cTable; -#ifndef DisposeCTable - PyMac_PRECHECK(DisposeCTable); + Point pt; + Rect srcRect; + Rect dstRect; +#ifndef ScalePt + PyMac_PRECHECK(ScalePt); #endif - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &cTable)) + if (!PyArg_ParseTuple(_args, "O&O&O&", + PyMac_GetPoint, &pt, + PyMac_GetRect, &srcRect, + PyMac_GetRect, &dstRect)) return NULL; - DisposeCTable(cTable); - Py_INCREF(Py_None); - _res = Py_None; + ScalePt(&pt, + &srcRect, + &dstRect); + _res = Py_BuildValue("O&", + PyMac_BuildPoint, pt); return _res; } -static PyObject *Qd_GetCTable(PyObject *_self, PyObject *_args) +static PyObject *Qd_MapPt(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CTabHandle _rv; - short ctID; -#ifndef GetCTable - PyMac_PRECHECK(GetCTable); + Point pt; + Rect srcRect; + Rect dstRect; +#ifndef MapPt + PyMac_PRECHECK(MapPt); #endif - if (!PyArg_ParseTuple(_args, "h", - &ctID)) + if (!PyArg_ParseTuple(_args, "O&O&O&", + PyMac_GetPoint, &pt, + PyMac_GetRect, &srcRect, + PyMac_GetRect, &dstRect)) return NULL; - _rv = GetCTable(ctID); + MapPt(&pt, + &srcRect, + &dstRect); _res = Py_BuildValue("O&", - ResObj_New, _rv); + PyMac_BuildPoint, pt); return _res; } -static PyObject *Qd_GetCCursor(PyObject *_self, PyObject *_args) +static PyObject *Qd_MapRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CCrsrHandle _rv; - short crsrID; -#ifndef GetCCursor - PyMac_PRECHECK(GetCCursor); -#endif - if (!PyArg_ParseTuple(_args, "h", - &crsrID)) + Rect r; + Rect srcRect; + Rect dstRect; +#ifndef MapRect + PyMac_PRECHECK(MapRect); +#endif + if (!PyArg_ParseTuple(_args, "O&O&O&", + PyMac_GetRect, &r, + PyMac_GetRect, &srcRect, + PyMac_GetRect, &dstRect)) return NULL; - _rv = GetCCursor(crsrID); + MapRect(&r, + &srcRect, + &dstRect); _res = Py_BuildValue("O&", - ResObj_New, _rv); + PyMac_BuildRect, &r); return _res; } -static PyObject *Qd_SetCCursor(PyObject *_self, PyObject *_args) +static PyObject *Qd_MapRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CCrsrHandle cCrsr; -#ifndef SetCCursor - PyMac_PRECHECK(SetCCursor); + RgnHandle rgn; + Rect srcRect; + Rect dstRect; +#ifndef MapRgn + PyMac_PRECHECK(MapRgn); #endif - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &cCrsr)) + if (!PyArg_ParseTuple(_args, "O&O&O&", + ResObj_Convert, &rgn, + PyMac_GetRect, &srcRect, + PyMac_GetRect, &dstRect)) return NULL; - SetCCursor(cCrsr); + MapRgn(rgn, + &srcRect, + &dstRect); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_AllocCursor(PyObject *_self, PyObject *_args) +static PyObject *Qd_MapPoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; -#ifndef AllocCursor - PyMac_PRECHECK(AllocCursor); + PolyHandle poly; + Rect srcRect; + Rect dstRect; +#ifndef MapPoly + PyMac_PRECHECK(MapPoly); #endif - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&O&O&", + ResObj_Convert, &poly, + PyMac_GetRect, &srcRect, + PyMac_GetRect, &dstRect)) return NULL; - AllocCursor(); + MapPoly(poly, + &srcRect, + &dstRect); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_DisposeCCursor(PyObject *_self, PyObject *_args) +static PyObject *Qd_StdBits(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CCrsrHandle cCrsr; -#ifndef DisposeCCursor - PyMac_PRECHECK(DisposeCCursor); + BitMapPtr srcBits; + Rect srcRect; + Rect dstRect; + short mode; + RgnHandle maskRgn; +#ifndef StdBits + PyMac_PRECHECK(StdBits); #endif - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &cCrsr)) + if (!PyArg_ParseTuple(_args, "O&O&O&hO&", + BMObj_Convert, &srcBits, + PyMac_GetRect, &srcRect, + PyMac_GetRect, &dstRect, + &mode, + OptResObj_Convert, &maskRgn)) return NULL; - DisposeCCursor(cCrsr); + StdBits(srcBits, + &srcRect, + &dstRect, + mode, + maskRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_GetMaxDevice(PyObject *_self, PyObject *_args) +static PyObject *Qd_AddPt(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - GDHandle _rv; - Rect globalRect; -#ifndef GetMaxDevice - PyMac_PRECHECK(GetMaxDevice); + Point src; + Point dst; +#ifndef AddPt + PyMac_PRECHECK(AddPt); #endif - if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetRect, &globalRect)) + if (!PyArg_ParseTuple(_args, "O&O&", + PyMac_GetPoint, &src, + PyMac_GetPoint, &dst)) return NULL; - _rv = GetMaxDevice(&globalRect); + AddPt(src, + &dst); _res = Py_BuildValue("O&", - ResObj_New, _rv); + PyMac_BuildPoint, dst); return _res; } -static PyObject *Qd_GetCTSeed(PyObject *_self, PyObject *_args) +static PyObject *Qd_EqualPt(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - long _rv; -#ifndef GetCTSeed - PyMac_PRECHECK(GetCTSeed); + Boolean _rv; + Point pt1; + Point pt2; +#ifndef EqualPt + PyMac_PRECHECK(EqualPt); #endif - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&O&", + PyMac_GetPoint, &pt1, + PyMac_GetPoint, &pt2)) return NULL; - _rv = GetCTSeed(); - _res = Py_BuildValue("l", + _rv = EqualPt(pt1, + pt2); + _res = Py_BuildValue("b", _rv); return _res; } -static PyObject *Qd_GetDeviceList(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - GDHandle _rv; -#ifndef GetDeviceList - PyMac_PRECHECK(GetDeviceList); -#endif - if (!PyArg_ParseTuple(_args, "")) - return NULL; - _rv = GetDeviceList(); - _res = Py_BuildValue("O&", - ResObj_New, _rv); - return _res; -} - -static PyObject *Qd_GetMainDevice(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacPtInRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - GDHandle _rv; -#ifndef GetMainDevice - PyMac_PRECHECK(GetMainDevice); + Boolean _rv; + Point pt; + Rect r; +#ifndef MacPtInRect + PyMac_PRECHECK(MacPtInRect); #endif - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&O&", + PyMac_GetPoint, &pt, + PyMac_GetRect, &r)) return NULL; - _rv = GetMainDevice(); - _res = Py_BuildValue("O&", - ResObj_New, _rv); + _rv = MacPtInRect(pt, + &r); + _res = Py_BuildValue("b", + _rv); return _res; } -static PyObject *Qd_GetNextDevice(PyObject *_self, PyObject *_args) +static PyObject *Qd_Pt2Rect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - GDHandle _rv; - GDHandle curDevice; -#ifndef GetNextDevice - PyMac_PRECHECK(GetNextDevice); + Point pt1; + Point pt2; + Rect dstRect; +#ifndef Pt2Rect + PyMac_PRECHECK(Pt2Rect); #endif - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &curDevice)) + if (!PyArg_ParseTuple(_args, "O&O&", + PyMac_GetPoint, &pt1, + PyMac_GetPoint, &pt2)) return NULL; - _rv = GetNextDevice(curDevice); + Pt2Rect(pt1, + pt2, + &dstRect); _res = Py_BuildValue("O&", - ResObj_New, _rv); + PyMac_BuildRect, &dstRect); return _res; } -static PyObject *Qd_TestDeviceAttribute(PyObject *_self, PyObject *_args) +static PyObject *Qd_PtToAngle(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Boolean _rv; - GDHandle gdh; - short attribute; -#ifndef TestDeviceAttribute - PyMac_PRECHECK(TestDeviceAttribute); + Rect r; + Point pt; + short angle; +#ifndef PtToAngle + PyMac_PRECHECK(PtToAngle); #endif - if (!PyArg_ParseTuple(_args, "O&h", - ResObj_Convert, &gdh, - &attribute)) + if (!PyArg_ParseTuple(_args, "O&O&", + PyMac_GetRect, &r, + PyMac_GetPoint, &pt)) return NULL; - _rv = TestDeviceAttribute(gdh, - attribute); - _res = Py_BuildValue("b", - _rv); + PtToAngle(&r, + pt, + &angle); + _res = Py_BuildValue("h", + angle); return _res; } -static PyObject *Qd_SetDeviceAttribute(PyObject *_self, PyObject *_args) +static PyObject *Qd_SubPt(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - GDHandle gdh; - short attribute; - Boolean value; -#ifndef SetDeviceAttribute - PyMac_PRECHECK(SetDeviceAttribute); + Point src; + Point dst; +#ifndef SubPt + PyMac_PRECHECK(SubPt); #endif - if (!PyArg_ParseTuple(_args, "O&hb", - ResObj_Convert, &gdh, - &attribute, - &value)) + if (!PyArg_ParseTuple(_args, "O&O&", + PyMac_GetPoint, &src, + PyMac_GetPoint, &dst)) return NULL; - SetDeviceAttribute(gdh, - attribute, - value); - Py_INCREF(Py_None); - _res = Py_None; + SubPt(src, + &dst); + _res = Py_BuildValue("O&", + PyMac_BuildPoint, dst); return _res; } -static PyObject *Qd_InitGDevice(PyObject *_self, PyObject *_args) +static PyObject *Qd_PtInRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - short qdRefNum; - long mode; - GDHandle gdh; -#ifndef InitGDevice - PyMac_PRECHECK(InitGDevice); + Boolean _rv; + Point pt; + RgnHandle rgn; +#ifndef PtInRgn + PyMac_PRECHECK(PtInRgn); #endif - if (!PyArg_ParseTuple(_args, "hlO&", - &qdRefNum, - &mode, - ResObj_Convert, &gdh)) + if (!PyArg_ParseTuple(_args, "O&O&", + PyMac_GetPoint, &pt, + ResObj_Convert, &rgn)) return NULL; - InitGDevice(qdRefNum, - mode, - gdh); - Py_INCREF(Py_None); - _res = Py_None; + _rv = PtInRgn(pt, + rgn); + _res = Py_BuildValue("b", + _rv); return _res; } -static PyObject *Qd_NewGDevice(PyObject *_self, PyObject *_args) +static PyObject *Qd_NewPixMap(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - GDHandle _rv; - short refNum; - long mode; -#ifndef NewGDevice - PyMac_PRECHECK(NewGDevice); + PixMapHandle _rv; +#ifndef NewPixMap + PyMac_PRECHECK(NewPixMap); #endif - if (!PyArg_ParseTuple(_args, "hl", - &refNum, - &mode)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - _rv = NewGDevice(refNum, - mode); + _rv = NewPixMap(); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } -static PyObject *Qd_DisposeGDevice(PyObject *_self, PyObject *_args) +static PyObject *Qd_DisposePixMap(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - GDHandle gdh; -#ifndef DisposeGDevice - PyMac_PRECHECK(DisposeGDevice); + PixMapHandle pm; +#ifndef DisposePixMap + PyMac_PRECHECK(DisposePixMap); #endif if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &gdh)) + ResObj_Convert, &pm)) return NULL; - DisposeGDevice(gdh); + DisposePixMap(pm); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_SetGDevice(PyObject *_self, PyObject *_args) +static PyObject *Qd_CopyPixMap(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - GDHandle gd; -#ifndef SetGDevice - PyMac_PRECHECK(SetGDevice); + PixMapHandle srcPM; + PixMapHandle dstPM; +#ifndef CopyPixMap + PyMac_PRECHECK(CopyPixMap); #endif - if (!PyArg_ParseTuple(_args, "O&", - ResObj_Convert, &gd)) + if (!PyArg_ParseTuple(_args, "O&O&", + ResObj_Convert, &srcPM, + ResObj_Convert, &dstPM)) return NULL; - SetGDevice(gd); + CopyPixMap(srcPM, + dstPM); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_GetGDevice(PyObject *_self, PyObject *_args) +static PyObject *Qd_NewPixPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - GDHandle _rv; -#ifndef GetGDevice - PyMac_PRECHECK(GetGDevice); + PixPatHandle _rv; +#ifndef NewPixPat + PyMac_PRECHECK(NewPixPat); #endif if (!PyArg_ParseTuple(_args, "")) return NULL; - _rv = GetGDevice(); + _rv = NewPixPat(); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } -static PyObject *Qd_Color2Index(PyObject *_self, PyObject *_args) +static PyObject *Qd_DisposePixPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - long _rv; - RGBColor myColor; -#ifndef Color2Index - PyMac_PRECHECK(Color2Index); + PixPatHandle pp; +#ifndef DisposePixPat + PyMac_PRECHECK(DisposePixPat); #endif if (!PyArg_ParseTuple(_args, "O&", - QdRGB_Convert, &myColor)) + ResObj_Convert, &pp)) return NULL; - _rv = Color2Index(&myColor); - _res = Py_BuildValue("l", - _rv); + DisposePixPat(pp); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_Index2Color(PyObject *_self, PyObject *_args) +static PyObject *Qd_CopyPixPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - long index; - RGBColor aColor; -#ifndef Index2Color - PyMac_PRECHECK(Index2Color); + PixPatHandle srcPP; + PixPatHandle dstPP; +#ifndef CopyPixPat + PyMac_PRECHECK(CopyPixPat); #endif - if (!PyArg_ParseTuple(_args, "l", - &index)) + if (!PyArg_ParseTuple(_args, "O&O&", + ResObj_Convert, &srcPP, + ResObj_Convert, &dstPP)) return NULL; - Index2Color(index, - &aColor); - _res = Py_BuildValue("O&", - QdRGB_New, &aColor); + CopyPixPat(srcPP, + dstPP); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_InvertColor(PyObject *_self, PyObject *_args) +static PyObject *Qd_PenPixPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RGBColor myColor; -#ifndef InvertColor - PyMac_PRECHECK(InvertColor); + PixPatHandle pp; +#ifndef PenPixPat + PyMac_PRECHECK(PenPixPat); #endif - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &pp)) return NULL; - InvertColor(&myColor); - _res = Py_BuildValue("O&", - QdRGB_New, &myColor); + PenPixPat(pp); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_RealColor(PyObject *_self, PyObject *_args) +static PyObject *Qd_BackPixPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Boolean _rv; - RGBColor color; -#ifndef RealColor - PyMac_PRECHECK(RealColor); + PixPatHandle pp; +#ifndef BackPixPat + PyMac_PRECHECK(BackPixPat); #endif if (!PyArg_ParseTuple(_args, "O&", - QdRGB_Convert, &color)) + ResObj_Convert, &pp)) return NULL; - _rv = RealColor(&color); - _res = Py_BuildValue("b", - _rv); + BackPixPat(pp); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_GetSubTable(PyObject *_self, PyObject *_args) +static PyObject *Qd_GetPixPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CTabHandle myColors; - short iTabRes; - CTabHandle targetTbl; -#ifndef GetSubTable - PyMac_PRECHECK(GetSubTable); + PixPatHandle _rv; + short patID; +#ifndef GetPixPat + PyMac_PRECHECK(GetPixPat); #endif - if (!PyArg_ParseTuple(_args, "O&hO&", - ResObj_Convert, &myColors, - &iTabRes, - ResObj_Convert, &targetTbl)) + if (!PyArg_ParseTuple(_args, "h", + &patID)) return NULL; - GetSubTable(myColors, - iTabRes, - targetTbl); - Py_INCREF(Py_None); - _res = Py_None; + _rv = GetPixPat(patID); + _res = Py_BuildValue("O&", + ResObj_New, _rv); return _res; } -static PyObject *Qd_MakeITable(PyObject *_self, PyObject *_args) +static PyObject *Qd_MakeRGBPat(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CTabHandle cTabH; - ITabHandle iTabH; - short res; -#ifndef MakeITable - PyMac_PRECHECK(MakeITable); + PixPatHandle pp; + RGBColor myColor; +#ifndef MakeRGBPat + PyMac_PRECHECK(MakeRGBPat); #endif - if (!PyArg_ParseTuple(_args, "O&O&h", - ResObj_Convert, &cTabH, - ResObj_Convert, &iTabH, - &res)) + if (!PyArg_ParseTuple(_args, "O&O&", + ResObj_Convert, &pp, + QdRGB_Convert, &myColor)) return NULL; - MakeITable(cTabH, - iTabH, - res); + MakeRGBPat(pp, + &myColor); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_SetClientID(PyObject *_self, PyObject *_args) +static PyObject *Qd_FillCRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - short id; -#ifndef SetClientID - PyMac_PRECHECK(SetClientID); + Rect r; + PixPatHandle pp; +#ifndef FillCRect + PyMac_PRECHECK(FillCRect); #endif - if (!PyArg_ParseTuple(_args, "h", - &id)) + if (!PyArg_ParseTuple(_args, "O&O&", + PyMac_GetRect, &r, + ResObj_Convert, &pp)) return NULL; - SetClientID(id); + FillCRect(&r, + pp); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_ProtectEntry(PyObject *_self, PyObject *_args) +static PyObject *Qd_FillCOval(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - short index; - Boolean protect; -#ifndef ProtectEntry - PyMac_PRECHECK(ProtectEntry); + Rect r; + PixPatHandle pp; +#ifndef FillCOval + PyMac_PRECHECK(FillCOval); #endif - if (!PyArg_ParseTuple(_args, "hb", - &index, - &protect)) + if (!PyArg_ParseTuple(_args, "O&O&", + PyMac_GetRect, &r, + ResObj_Convert, &pp)) return NULL; - ProtectEntry(index, - protect); + FillCOval(&r, + pp); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_ReserveEntry(PyObject *_self, PyObject *_args) +static PyObject *Qd_FillCRoundRect(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - short index; - Boolean reserve; -#ifndef ReserveEntry - PyMac_PRECHECK(ReserveEntry); + Rect r; + short ovalWidth; + short ovalHeight; + PixPatHandle pp; +#ifndef FillCRoundRect + PyMac_PRECHECK(FillCRoundRect); #endif - if (!PyArg_ParseTuple(_args, "hb", - &index, - &reserve)) + if (!PyArg_ParseTuple(_args, "O&hhO&", + PyMac_GetRect, &r, + &ovalWidth, + &ovalHeight, + ResObj_Convert, &pp)) return NULL; - ReserveEntry(index, - reserve); + FillCRoundRect(&r, + ovalWidth, + ovalHeight, + pp); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_QDError(PyObject *_self, PyObject *_args) +static PyObject *Qd_FillCArc(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - short _rv; -#ifndef QDError - PyMac_PRECHECK(QDError); + Rect r; + short startAngle; + short arcAngle; + PixPatHandle pp; +#ifndef FillCArc + PyMac_PRECHECK(FillCArc); #endif - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "O&hhO&", + PyMac_GetRect, &r, + &startAngle, + &arcAngle, + ResObj_Convert, &pp)) return NULL; - _rv = QDError(); - _res = Py_BuildValue("h", - _rv); + FillCArc(&r, + startAngle, + arcAngle, + pp); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_CopyDeepMask(PyObject *_self, PyObject *_args) +static PyObject *Qd_FillCRgn(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - BitMapPtr srcBits; - BitMapPtr maskBits; - BitMapPtr dstBits; - Rect srcRect; - Rect maskRect; - Rect dstRect; - short mode; - RgnHandle maskRgn; -#ifndef CopyDeepMask - PyMac_PRECHECK(CopyDeepMask); + RgnHandle rgn; + PixPatHandle pp; +#ifndef FillCRgn + PyMac_PRECHECK(FillCRgn); #endif - if (!PyArg_ParseTuple(_args, "O&O&O&O&O&O&hO&", - BMObj_Convert, &srcBits, - BMObj_Convert, &maskBits, - BMObj_Convert, &dstBits, - PyMac_GetRect, &srcRect, - PyMac_GetRect, &maskRect, - PyMac_GetRect, &dstRect, - &mode, - OptResObj_Convert, &maskRgn)) + if (!PyArg_ParseTuple(_args, "O&O&", + ResObj_Convert, &rgn, + ResObj_Convert, &pp)) return NULL; - CopyDeepMask(srcBits, - maskBits, - dstBits, - &srcRect, - &maskRect, - &dstRect, - mode, - maskRgn); + FillCRgn(rgn, + pp); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_GetPattern(PyObject *_self, PyObject *_args) +static PyObject *Qd_FillCPoly(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PatHandle _rv; - short patternID; -#ifndef GetPattern - PyMac_PRECHECK(GetPattern); + PolyHandle poly; + PixPatHandle pp; +#ifndef FillCPoly + PyMac_PRECHECK(FillCPoly); #endif - if (!PyArg_ParseTuple(_args, "h", - &patternID)) + if (!PyArg_ParseTuple(_args, "O&O&", + ResObj_Convert, &poly, + ResObj_Convert, &pp)) return NULL; - _rv = GetPattern(patternID); - _res = Py_BuildValue("O&", - ResObj_New, _rv); + FillCPoly(poly, + pp); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_MacGetCursor(PyObject *_self, PyObject *_args) +static PyObject *Qd_RGBForeColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CursHandle _rv; - short cursorID; -#ifndef MacGetCursor - PyMac_PRECHECK(MacGetCursor); + RGBColor color; +#ifndef RGBForeColor + PyMac_PRECHECK(RGBForeColor); #endif - if (!PyArg_ParseTuple(_args, "h", - &cursorID)) + if (!PyArg_ParseTuple(_args, "O&", + QdRGB_Convert, &color)) return NULL; - _rv = MacGetCursor(cursorID); - _res = Py_BuildValue("O&", - ResObj_New, _rv); + RGBForeColor(&color); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_GetPicture(PyObject *_self, PyObject *_args) +static PyObject *Qd_RGBBackColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PicHandle _rv; - short pictureID; -#ifndef GetPicture - PyMac_PRECHECK(GetPicture); + RGBColor color; +#ifndef RGBBackColor + PyMac_PRECHECK(RGBBackColor); #endif - if (!PyArg_ParseTuple(_args, "h", - &pictureID)) + if (!PyArg_ParseTuple(_args, "O&", + QdRGB_Convert, &color)) return NULL; - _rv = GetPicture(pictureID); - _res = Py_BuildValue("O&", - ResObj_New, _rv); + RGBBackColor(&color); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_DeltaPoint(PyObject *_self, PyObject *_args) +static PyObject *Qd_SetCPixel(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - long _rv; - Point ptA; - Point ptB; -#ifndef DeltaPoint - PyMac_PRECHECK(DeltaPoint); + short h; + short v; + RGBColor cPix; +#ifndef SetCPixel + PyMac_PRECHECK(SetCPixel); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetPoint, &ptA, - PyMac_GetPoint, &ptB)) + if (!PyArg_ParseTuple(_args, "hhO&", + &h, + &v, + QdRGB_Convert, &cPix)) return NULL; - _rv = DeltaPoint(ptA, - ptB); - _res = Py_BuildValue("l", - _rv); + SetCPixel(h, + v, + &cPix); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_ShieldCursor(PyObject *_self, PyObject *_args) +static PyObject *Qd_SetPortPix(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Rect shieldRect; - Point offsetPt; -#ifndef ShieldCursor - PyMac_PRECHECK(ShieldCursor); + PixMapHandle pm; +#ifndef SetPortPix + PyMac_PRECHECK(SetPortPix); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - PyMac_GetRect, &shieldRect, - PyMac_GetPoint, &offsetPt)) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &pm)) return NULL; - ShieldCursor(&shieldRect, - offsetPt); + SetPortPix(pm); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_ScreenRes(PyObject *_self, PyObject *_args) +static PyObject *Qd_GetCPixel(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - short scrnHRes; - short scrnVRes; -#ifndef ScreenRes - PyMac_PRECHECK(ScreenRes); + short h; + short v; + RGBColor cPix; +#ifndef GetCPixel + PyMac_PRECHECK(GetCPixel); #endif - if (!PyArg_ParseTuple(_args, "")) + if (!PyArg_ParseTuple(_args, "hh", + &h, + &v)) return NULL; - ScreenRes(&scrnHRes, - &scrnVRes); - _res = Py_BuildValue("hh", - scrnHRes, - scrnVRes); + GetCPixel(h, + v, + &cPix); + _res = Py_BuildValue("O&", + QdRGB_New, &cPix); return _res; } -static PyObject *Qd_GetIndPattern(PyObject *_self, PyObject *_args) +static PyObject *Qd_GetForeColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Pattern thePat__out__; - short patternListID; - short index; -#ifndef GetIndPattern - PyMac_PRECHECK(GetIndPattern); + RGBColor color; +#ifndef GetForeColor + PyMac_PRECHECK(GetForeColor); #endif - if (!PyArg_ParseTuple(_args, "hh", - &patternListID, - &index)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - GetIndPattern(&thePat__out__, - patternListID, - index); - _res = Py_BuildValue("s#", - (char *)&thePat__out__, (int)sizeof(Pattern)); + GetForeColor(&color); + _res = Py_BuildValue("O&", + QdRGB_New, &color); return _res; } -static PyObject *Qd_SlopeFromAngle(PyObject *_self, PyObject *_args) +static PyObject *Qd_GetBackColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Fixed _rv; - short angle; -#ifndef SlopeFromAngle - PyMac_PRECHECK(SlopeFromAngle); + RGBColor color; +#ifndef GetBackColor + PyMac_PRECHECK(GetBackColor); #endif - if (!PyArg_ParseTuple(_args, "h", - &angle)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - _rv = SlopeFromAngle(angle); + GetBackColor(&color); _res = Py_BuildValue("O&", - PyMac_BuildFixed, _rv); + QdRGB_New, &color); return _res; } -static PyObject *Qd_AngleFromSlope(PyObject *_self, PyObject *_args) +static PyObject *Qd_OpColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - short _rv; - Fixed slope; -#ifndef AngleFromSlope - PyMac_PRECHECK(AngleFromSlope); + RGBColor color; +#ifndef OpColor + PyMac_PRECHECK(OpColor); #endif if (!PyArg_ParseTuple(_args, "O&", - PyMac_GetFixed, &slope)) + QdRGB_Convert, &color)) return NULL; - _rv = AngleFromSlope(slope); - _res = Py_BuildValue("h", - _rv); + OpColor(&color); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -#if TARGET_API_MAC_CARBON - -static PyObject *Qd_IsValidPort(PyObject *_self, PyObject *_args) +static PyObject *Qd_HiliteColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Boolean _rv; - CGrafPtr port; -#ifndef IsValidPort - PyMac_PRECHECK(IsValidPort); + RGBColor color; +#ifndef HiliteColor + PyMac_PRECHECK(HiliteColor); #endif if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + QdRGB_Convert, &color)) return NULL; - _rv = IsValidPort(port); - _res = Py_BuildValue("b", - _rv); + HiliteColor(&color); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -#endif -static PyObject *Qd_GetPortPixMap(PyObject *_self, PyObject *_args) +static PyObject *Qd_DisposeCTable(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PixMapHandle _rv; - CGrafPtr port; -#ifndef GetPortPixMap - PyMac_PRECHECK(GetPortPixMap); + CTabHandle cTable; +#ifndef DisposeCTable + PyMac_PRECHECK(DisposeCTable); #endif if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + ResObj_Convert, &cTable)) return NULL; - _rv = GetPortPixMap(port); - _res = Py_BuildValue("O&", - ResObj_New, _rv); + DisposeCTable(cTable); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_GetPortBitMapForCopyBits(PyObject *_self, PyObject *_args) +static PyObject *Qd_GetCTable(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - const BitMap * _rv; - CGrafPtr port; -#ifndef GetPortBitMapForCopyBits - PyMac_PRECHECK(GetPortBitMapForCopyBits); + CTabHandle _rv; + short ctID; +#ifndef GetCTable + PyMac_PRECHECK(GetCTable); #endif - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + if (!PyArg_ParseTuple(_args, "h", + &ctID)) return NULL; - _rv = GetPortBitMapForCopyBits(port); + _rv = GetCTable(ctID); _res = Py_BuildValue("O&", - BMObj_New, _rv); + ResObj_New, _rv); return _res; } -static PyObject *Qd_GetPortBounds(PyObject *_self, PyObject *_args) +static PyObject *Qd_GetCCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CGrafPtr port; - Rect rect; -#ifndef GetPortBounds - PyMac_PRECHECK(GetPortBounds); + CCrsrHandle _rv; + short crsrID; +#ifndef GetCCursor + PyMac_PRECHECK(GetCCursor); #endif - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + if (!PyArg_ParseTuple(_args, "h", + &crsrID)) return NULL; - GetPortBounds(port, - &rect); + _rv = GetCCursor(crsrID); _res = Py_BuildValue("O&", - PyMac_BuildRect, &rect); + ResObj_New, _rv); return _res; } -static PyObject *Qd_GetPortForeColor(PyObject *_self, PyObject *_args) +static PyObject *Qd_SetCCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CGrafPtr port; - RGBColor foreColor; -#ifndef GetPortForeColor - PyMac_PRECHECK(GetPortForeColor); + CCrsrHandle cCrsr; +#ifndef SetCCursor + PyMac_PRECHECK(SetCCursor); #endif if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + ResObj_Convert, &cCrsr)) return NULL; - GetPortForeColor(port, - &foreColor); - _res = Py_BuildValue("O&", - QdRGB_New, &foreColor); + SetCCursor(cCrsr); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_GetPortBackColor(PyObject *_self, PyObject *_args) +static PyObject *Qd_AllocCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CGrafPtr port; - RGBColor backColor; -#ifndef GetPortBackColor - PyMac_PRECHECK(GetPortBackColor); +#ifndef AllocCursor + PyMac_PRECHECK(AllocCursor); #endif - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - GetPortBackColor(port, - &backColor); - _res = Py_BuildValue("O&", - QdRGB_New, &backColor); + AllocCursor(); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_GetPortOpColor(PyObject *_self, PyObject *_args) +static PyObject *Qd_DisposeCCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CGrafPtr port; - RGBColor opColor; -#ifndef GetPortOpColor - PyMac_PRECHECK(GetPortOpColor); + CCrsrHandle cCrsr; +#ifndef DisposeCCursor + PyMac_PRECHECK(DisposeCCursor); #endif if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + ResObj_Convert, &cCrsr)) return NULL; - GetPortOpColor(port, - &opColor); - _res = Py_BuildValue("O&", - QdRGB_New, &opColor); + DisposeCCursor(cCrsr); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_GetPortHiliteColor(PyObject *_self, PyObject *_args) +static PyObject *Qd_GetMaxDevice(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CGrafPtr port; - RGBColor hiliteColor; -#ifndef GetPortHiliteColor - PyMac_PRECHECK(GetPortHiliteColor); + GDHandle _rv; + Rect globalRect; +#ifndef GetMaxDevice + PyMac_PRECHECK(GetMaxDevice); #endif if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + PyMac_GetRect, &globalRect)) return NULL; - GetPortHiliteColor(port, - &hiliteColor); + _rv = GetMaxDevice(&globalRect); _res = Py_BuildValue("O&", - QdRGB_New, &hiliteColor); + ResObj_New, _rv); return _res; } -static PyObject *Qd_GetPortTextFont(PyObject *_self, PyObject *_args) +static PyObject *Qd_GetCTSeed(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - short _rv; - CGrafPtr port; -#ifndef GetPortTextFont - PyMac_PRECHECK(GetPortTextFont); + long _rv; +#ifndef GetCTSeed + PyMac_PRECHECK(GetCTSeed); #endif - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - _rv = GetPortTextFont(port); - _res = Py_BuildValue("h", + _rv = GetCTSeed(); + _res = Py_BuildValue("l", _rv); return _res; } -static PyObject *Qd_GetPortTextFace(PyObject *_self, PyObject *_args) +static PyObject *Qd_GetDeviceList(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Style _rv; - CGrafPtr port; -#ifndef GetPortTextFace - PyMac_PRECHECK(GetPortTextFace); + GDHandle _rv; +#ifndef GetDeviceList + PyMac_PRECHECK(GetDeviceList); #endif - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - _rv = GetPortTextFace(port); - _res = Py_BuildValue("b", - _rv); + _rv = GetDeviceList(); + _res = Py_BuildValue("O&", + ResObj_New, _rv); return _res; } -static PyObject *Qd_GetPortTextMode(PyObject *_self, PyObject *_args) +static PyObject *Qd_GetMainDevice(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - short _rv; - CGrafPtr port; -#ifndef GetPortTextMode - PyMac_PRECHECK(GetPortTextMode); + GDHandle _rv; +#ifndef GetMainDevice + PyMac_PRECHECK(GetMainDevice); #endif - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - _rv = GetPortTextMode(port); - _res = Py_BuildValue("h", - _rv); + _rv = GetMainDevice(); + _res = Py_BuildValue("O&", + ResObj_New, _rv); return _res; } -static PyObject *Qd_GetPortTextSize(PyObject *_self, PyObject *_args) +static PyObject *Qd_GetNextDevice(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - short _rv; - CGrafPtr port; -#ifndef GetPortTextSize - PyMac_PRECHECK(GetPortTextSize); + GDHandle _rv; + GDHandle curDevice; +#ifndef GetNextDevice + PyMac_PRECHECK(GetNextDevice); #endif if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + ResObj_Convert, &curDevice)) return NULL; - _rv = GetPortTextSize(port); - _res = Py_BuildValue("h", - _rv); + _rv = GetNextDevice(curDevice); + _res = Py_BuildValue("O&", + ResObj_New, _rv); return _res; } -static PyObject *Qd_GetPortChExtra(PyObject *_self, PyObject *_args) +static PyObject *Qd_TestDeviceAttribute(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - short _rv; - CGrafPtr port; -#ifndef GetPortChExtra - PyMac_PRECHECK(GetPortChExtra); + Boolean _rv; + GDHandle gdh; + short attribute; +#ifndef TestDeviceAttribute + PyMac_PRECHECK(TestDeviceAttribute); #endif - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + if (!PyArg_ParseTuple(_args, "O&h", + ResObj_Convert, &gdh, + &attribute)) return NULL; - _rv = GetPortChExtra(port); - _res = Py_BuildValue("h", + _rv = TestDeviceAttribute(gdh, + attribute); + _res = Py_BuildValue("b", _rv); return _res; } -static PyObject *Qd_GetPortFracHPenLocation(PyObject *_self, PyObject *_args) +static PyObject *Qd_SetDeviceAttribute(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - short _rv; - CGrafPtr port; -#ifndef GetPortFracHPenLocation - PyMac_PRECHECK(GetPortFracHPenLocation); + GDHandle gdh; + short attribute; + Boolean value; +#ifndef SetDeviceAttribute + PyMac_PRECHECK(SetDeviceAttribute); #endif - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + if (!PyArg_ParseTuple(_args, "O&hb", + ResObj_Convert, &gdh, + &attribute, + &value)) return NULL; - _rv = GetPortFracHPenLocation(port); - _res = Py_BuildValue("h", - _rv); + SetDeviceAttribute(gdh, + attribute, + value); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_GetPortSpExtra(PyObject *_self, PyObject *_args) +static PyObject *Qd_InitGDevice(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Fixed _rv; - CGrafPtr port; -#ifndef GetPortSpExtra - PyMac_PRECHECK(GetPortSpExtra); + short qdRefNum; + long mode; + GDHandle gdh; +#ifndef InitGDevice + PyMac_PRECHECK(InitGDevice); #endif - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + if (!PyArg_ParseTuple(_args, "hlO&", + &qdRefNum, + &mode, + ResObj_Convert, &gdh)) return NULL; - _rv = GetPortSpExtra(port); - _res = Py_BuildValue("O&", - PyMac_BuildFixed, _rv); + InitGDevice(qdRefNum, + mode, + gdh); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_GetPortPenVisibility(PyObject *_self, PyObject *_args) +static PyObject *Qd_NewGDevice(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - short _rv; - CGrafPtr port; -#ifndef GetPortPenVisibility - PyMac_PRECHECK(GetPortPenVisibility); + GDHandle _rv; + short refNum; + long mode; +#ifndef NewGDevice + PyMac_PRECHECK(NewGDevice); #endif - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + if (!PyArg_ParseTuple(_args, "hl", + &refNum, + &mode)) return NULL; - _rv = GetPortPenVisibility(port); - _res = Py_BuildValue("h", - _rv); + _rv = NewGDevice(refNum, + mode); + _res = Py_BuildValue("O&", + ResObj_New, _rv); return _res; } -static PyObject *Qd_GetPortVisibleRegion(PyObject *_self, PyObject *_args) +static PyObject *Qd_DisposeGDevice(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle _rv; - CGrafPtr port; - RgnHandle visRgn; -#ifndef GetPortVisibleRegion - PyMac_PRECHECK(GetPortVisibleRegion); + GDHandle gdh; +#ifndef DisposeGDevice + PyMac_PRECHECK(DisposeGDevice); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - GrafObj_Convert, &port, - ResObj_Convert, &visRgn)) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &gdh)) return NULL; - _rv = GetPortVisibleRegion(port, - visRgn); - _res = Py_BuildValue("O&", - ResObj_New, _rv); + DisposeGDevice(gdh); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_GetPortClipRegion(PyObject *_self, PyObject *_args) +static PyObject *Qd_SetGDevice(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - RgnHandle _rv; - CGrafPtr port; - RgnHandle clipRgn; -#ifndef GetPortClipRegion - PyMac_PRECHECK(GetPortClipRegion); + GDHandle gd; +#ifndef SetGDevice + PyMac_PRECHECK(SetGDevice); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - GrafObj_Convert, &port, - ResObj_Convert, &clipRgn)) + if (!PyArg_ParseTuple(_args, "O&", + ResObj_Convert, &gd)) return NULL; - _rv = GetPortClipRegion(port, - clipRgn); - _res = Py_BuildValue("O&", - ResObj_New, _rv); + SetGDevice(gd); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_GetPortBackPixPat(PyObject *_self, PyObject *_args) +static PyObject *Qd_GetGDevice(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PixPatHandle _rv; - CGrafPtr port; - PixPatHandle backPattern; -#ifndef GetPortBackPixPat - PyMac_PRECHECK(GetPortBackPixPat); + GDHandle _rv; +#ifndef GetGDevice + PyMac_PRECHECK(GetGDevice); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - GrafObj_Convert, &port, - ResObj_Convert, &backPattern)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - _rv = GetPortBackPixPat(port, - backPattern); + _rv = GetGDevice(); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; } -static PyObject *Qd_GetPortPenPixPat(PyObject *_self, PyObject *_args) +static PyObject *Qd_Color2Index(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PixPatHandle _rv; - CGrafPtr port; - PixPatHandle penPattern; -#ifndef GetPortPenPixPat - PyMac_PRECHECK(GetPortPenPixPat); + long _rv; + RGBColor myColor; +#ifndef Color2Index + PyMac_PRECHECK(Color2Index); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - GrafObj_Convert, &port, - ResObj_Convert, &penPattern)) + if (!PyArg_ParseTuple(_args, "O&", + QdRGB_Convert, &myColor)) return NULL; - _rv = GetPortPenPixPat(port, - penPattern); - _res = Py_BuildValue("O&", - ResObj_New, _rv); + _rv = Color2Index(&myColor); + _res = Py_BuildValue("l", + _rv); return _res; } -static PyObject *Qd_GetPortFillPixPat(PyObject *_self, PyObject *_args) +static PyObject *Qd_Index2Color(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PixPatHandle _rv; - CGrafPtr port; - PixPatHandle fillPattern; -#ifndef GetPortFillPixPat - PyMac_PRECHECK(GetPortFillPixPat); + long index; + RGBColor aColor; +#ifndef Index2Color + PyMac_PRECHECK(Index2Color); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - GrafObj_Convert, &port, - ResObj_Convert, &fillPattern)) + if (!PyArg_ParseTuple(_args, "l", + &index)) return NULL; - _rv = GetPortFillPixPat(port, - fillPattern); + Index2Color(index, + &aColor); _res = Py_BuildValue("O&", - ResObj_New, _rv); + QdRGB_New, &aColor); return _res; } -static PyObject *Qd_GetPortPenSize(PyObject *_self, PyObject *_args) +static PyObject *Qd_InvertColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CGrafPtr port; - Point penSize; -#ifndef GetPortPenSize - PyMac_PRECHECK(GetPortPenSize); + RGBColor myColor; +#ifndef InvertColor + PyMac_PRECHECK(InvertColor); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - GrafObj_Convert, &port, - PyMac_GetPoint, &penSize)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - GetPortPenSize(port, - &penSize); + InvertColor(&myColor); _res = Py_BuildValue("O&", - PyMac_BuildPoint, penSize); + QdRGB_New, &myColor); return _res; } -static PyObject *Qd_GetPortPenMode(PyObject *_self, PyObject *_args) +static PyObject *Qd_RealColor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - SInt32 _rv; - CGrafPtr port; -#ifndef GetPortPenMode - PyMac_PRECHECK(GetPortPenMode); + Boolean _rv; + RGBColor color; +#ifndef RealColor + PyMac_PRECHECK(RealColor); #endif if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + QdRGB_Convert, &color)) return NULL; - _rv = GetPortPenMode(port); - _res = Py_BuildValue("l", + _rv = RealColor(&color); + _res = Py_BuildValue("b", _rv); return _res; } -static PyObject *Qd_GetPortPenLocation(PyObject *_self, PyObject *_args) +static PyObject *Qd_GetSubTable(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CGrafPtr port; - Point penLocation; -#ifndef GetPortPenLocation - PyMac_PRECHECK(GetPortPenLocation); + CTabHandle myColors; + short iTabRes; + CTabHandle targetTbl; +#ifndef GetSubTable + PyMac_PRECHECK(GetSubTable); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - GrafObj_Convert, &port, - PyMac_GetPoint, &penLocation)) + if (!PyArg_ParseTuple(_args, "O&hO&", + ResObj_Convert, &myColors, + &iTabRes, + ResObj_Convert, &targetTbl)) return NULL; - GetPortPenLocation(port, - &penLocation); - _res = Py_BuildValue("O&", - PyMac_BuildPoint, penLocation); + GetSubTable(myColors, + iTabRes, + targetTbl); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_IsPortRegionBeingDefined(PyObject *_self, PyObject *_args) +static PyObject *Qd_MakeITable(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Boolean _rv; - CGrafPtr port; -#ifndef IsPortRegionBeingDefined - PyMac_PRECHECK(IsPortRegionBeingDefined); + CTabHandle cTabH; + ITabHandle iTabH; + short res; +#ifndef MakeITable + PyMac_PRECHECK(MakeITable); #endif - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + if (!PyArg_ParseTuple(_args, "O&O&h", + ResObj_Convert, &cTabH, + ResObj_Convert, &iTabH, + &res)) return NULL; - _rv = IsPortRegionBeingDefined(port); - _res = Py_BuildValue("b", - _rv); + MakeITable(cTabH, + iTabH, + res); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -static PyObject *Qd_IsPortPictureBeingDefined(PyObject *_self, PyObject *_args) +static PyObject *Qd_SetClientID(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Boolean _rv; - CGrafPtr port; -#ifndef IsPortPictureBeingDefined - PyMac_PRECHECK(IsPortPictureBeingDefined); + short id; +#ifndef SetClientID + PyMac_PRECHECK(SetClientID); #endif - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + if (!PyArg_ParseTuple(_args, "h", + &id)) return NULL; - _rv = IsPortPictureBeingDefined(port); - _res = Py_BuildValue("b", - _rv); + SetClientID(id); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -#if TARGET_API_MAC_CARBON - -static PyObject *Qd_IsPortPolyBeingDefined(PyObject *_self, PyObject *_args) +static PyObject *Qd_ProtectEntry(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Boolean _rv; - CGrafPtr port; -#ifndef IsPortPolyBeingDefined - PyMac_PRECHECK(IsPortPolyBeingDefined); + short index; + Boolean protect; +#ifndef ProtectEntry + PyMac_PRECHECK(ProtectEntry); #endif - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + if (!PyArg_ParseTuple(_args, "hb", + &index, + &protect)) return NULL; - _rv = IsPortPolyBeingDefined(port); - _res = Py_BuildValue("b", - _rv); + ProtectEntry(index, + protect); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -#endif - -#if TARGET_API_MAC_CARBON -static PyObject *Qd_IsPortOffscreen(PyObject *_self, PyObject *_args) +static PyObject *Qd_ReserveEntry(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Boolean _rv; - CGrafPtr port; -#ifndef IsPortOffscreen - PyMac_PRECHECK(IsPortOffscreen); + short index; + Boolean reserve; +#ifndef ReserveEntry + PyMac_PRECHECK(ReserveEntry); #endif - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + if (!PyArg_ParseTuple(_args, "hb", + &index, + &reserve)) return NULL; - _rv = IsPortOffscreen(port); - _res = Py_BuildValue("b", - _rv); + ReserveEntry(index, + reserve); + Py_INCREF(Py_None); + _res = Py_None; return _res; } -#endif - -#if TARGET_API_MAC_CARBON -static PyObject *Qd_IsPortColor(PyObject *_self, PyObject *_args) +static PyObject *Qd_QDError(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - Boolean _rv; - CGrafPtr port; -#ifndef IsPortColor - PyMac_PRECHECK(IsPortColor); + short _rv; +#ifndef QDError + PyMac_PRECHECK(QDError); #endif - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - _rv = IsPortColor(port); - _res = Py_BuildValue("b", + _rv = QDError(); + _res = Py_BuildValue("h", _rv); return _res; } -#endif -static PyObject *Qd_SetPortBounds(PyObject *_self, PyObject *_args) +static PyObject *Qd_CopyDeepMask(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CGrafPtr port; - Rect rect; -#ifndef SetPortBounds - PyMac_PRECHECK(SetPortBounds); + BitMapPtr srcBits; + BitMapPtr maskBits; + BitMapPtr dstBits; + Rect srcRect; + Rect maskRect; + Rect dstRect; + short mode; + RgnHandle maskRgn; +#ifndef CopyDeepMask + PyMac_PRECHECK(CopyDeepMask); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - GrafObj_Convert, &port, - PyMac_GetRect, &rect)) + if (!PyArg_ParseTuple(_args, "O&O&O&O&O&O&hO&", + BMObj_Convert, &srcBits, + BMObj_Convert, &maskBits, + BMObj_Convert, &dstBits, + PyMac_GetRect, &srcRect, + PyMac_GetRect, &maskRect, + PyMac_GetRect, &dstRect, + &mode, + OptResObj_Convert, &maskRgn)) return NULL; - SetPortBounds(port, - &rect); + CopyDeepMask(srcBits, + maskBits, + dstBits, + &srcRect, + &maskRect, + &dstRect, + mode, + maskRgn); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_SetPortOpColor(PyObject *_self, PyObject *_args) +static PyObject *Qd_GetPattern(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CGrafPtr port; - RGBColor opColor; -#ifndef SetPortOpColor - PyMac_PRECHECK(SetPortOpColor); + PatHandle _rv; + short patternID; +#ifndef GetPattern + PyMac_PRECHECK(GetPattern); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - GrafObj_Convert, &port, - QdRGB_Convert, &opColor)) + if (!PyArg_ParseTuple(_args, "h", + &patternID)) return NULL; - SetPortOpColor(port, - &opColor); - Py_INCREF(Py_None); - _res = Py_None; + _rv = GetPattern(patternID); + _res = Py_BuildValue("O&", + ResObj_New, _rv); return _res; } -static PyObject *Qd_SetPortVisibleRegion(PyObject *_self, PyObject *_args) +static PyObject *Qd_MacGetCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CGrafPtr port; - RgnHandle visRgn; -#ifndef SetPortVisibleRegion - PyMac_PRECHECK(SetPortVisibleRegion); -#endif - if (!PyArg_ParseTuple(_args, "O&O&", - GrafObj_Convert, &port, - ResObj_Convert, &visRgn)) + CursHandle _rv; + short cursorID; +#ifndef MacGetCursor + PyMac_PRECHECK(MacGetCursor); +#endif + if (!PyArg_ParseTuple(_args, "h", + &cursorID)) return NULL; - SetPortVisibleRegion(port, - visRgn); - Py_INCREF(Py_None); - _res = Py_None; + _rv = MacGetCursor(cursorID); + _res = Py_BuildValue("O&", + ResObj_New, _rv); return _res; } -static PyObject *Qd_SetPortClipRegion(PyObject *_self, PyObject *_args) +static PyObject *Qd_GetPicture(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CGrafPtr port; - RgnHandle clipRgn; -#ifndef SetPortClipRegion - PyMac_PRECHECK(SetPortClipRegion); + PicHandle _rv; + short pictureID; +#ifndef GetPicture + PyMac_PRECHECK(GetPicture); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - GrafObj_Convert, &port, - ResObj_Convert, &clipRgn)) + if (!PyArg_ParseTuple(_args, "h", + &pictureID)) return NULL; - SetPortClipRegion(port, - clipRgn); - Py_INCREF(Py_None); - _res = Py_None; + _rv = GetPicture(pictureID); + _res = Py_BuildValue("O&", + ResObj_New, _rv); return _res; } -static PyObject *Qd_SetPortPenPixPat(PyObject *_self, PyObject *_args) +static PyObject *Qd_DeltaPoint(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CGrafPtr port; - PixPatHandle penPattern; -#ifndef SetPortPenPixPat - PyMac_PRECHECK(SetPortPenPixPat); + long _rv; + Point ptA; + Point ptB; +#ifndef DeltaPoint + PyMac_PRECHECK(DeltaPoint); #endif if (!PyArg_ParseTuple(_args, "O&O&", - GrafObj_Convert, &port, - ResObj_Convert, &penPattern)) + PyMac_GetPoint, &ptA, + PyMac_GetPoint, &ptB)) return NULL; - SetPortPenPixPat(port, - penPattern); - Py_INCREF(Py_None); - _res = Py_None; + _rv = DeltaPoint(ptA, + ptB); + _res = Py_BuildValue("l", + _rv); return _res; } -static PyObject *Qd_SetPortFillPixPat(PyObject *_self, PyObject *_args) +static PyObject *Qd_ShieldCursor(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CGrafPtr port; - PixPatHandle penPattern; -#ifndef SetPortFillPixPat - PyMac_PRECHECK(SetPortFillPixPat); + Rect shieldRect; + Point offsetPt; +#ifndef ShieldCursor + PyMac_PRECHECK(ShieldCursor); #endif if (!PyArg_ParseTuple(_args, "O&O&", - GrafObj_Convert, &port, - ResObj_Convert, &penPattern)) + PyMac_GetRect, &shieldRect, + PyMac_GetPoint, &offsetPt)) return NULL; - SetPortFillPixPat(port, - penPattern); + ShieldCursor(&shieldRect, + offsetPt); Py_INCREF(Py_None); _res = Py_None; return _res; } -static PyObject *Qd_SetPortBackPixPat(PyObject *_self, PyObject *_args) +static PyObject *Qd_ScreenRes(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CGrafPtr port; - PixPatHandle backPattern; -#ifndef SetPortBackPixPat - PyMac_PRECHECK(SetPortBackPixPat); + short scrnHRes; + short scrnVRes; +#ifndef ScreenRes + PyMac_PRECHECK(ScreenRes); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - GrafObj_Convert, &port, - ResObj_Convert, &backPattern)) + if (!PyArg_ParseTuple(_args, "")) return NULL; - SetPortBackPixPat(port, - backPattern); - Py_INCREF(Py_None); - _res = Py_None; + ScreenRes(&scrnHRes, + &scrnVRes); + _res = Py_BuildValue("hh", + scrnHRes, + scrnVRes); return _res; } -static PyObject *Qd_SetPortPenSize(PyObject *_self, PyObject *_args) +static PyObject *Qd_GetIndPattern(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CGrafPtr port; - Point penSize; -#ifndef SetPortPenSize - PyMac_PRECHECK(SetPortPenSize); + Pattern thePat__out__; + short patternListID; + short index; +#ifndef GetIndPattern + PyMac_PRECHECK(GetIndPattern); #endif - if (!PyArg_ParseTuple(_args, "O&O&", - GrafObj_Convert, &port, - PyMac_GetPoint, &penSize)) + if (!PyArg_ParseTuple(_args, "hh", + &patternListID, + &index)) return NULL; - SetPortPenSize(port, - penSize); - Py_INCREF(Py_None); - _res = Py_None; + GetIndPattern(&thePat__out__, + patternListID, + index); + _res = Py_BuildValue("s#", + (char *)&thePat__out__, (int)sizeof(Pattern)); return _res; } -static PyObject *Qd_SetPortPenMode(PyObject *_self, PyObject *_args) +static PyObject *Qd_SlopeFromAngle(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CGrafPtr port; - SInt32 penMode; -#ifndef SetPortPenMode - PyMac_PRECHECK(SetPortPenMode); + Fixed _rv; + short angle; +#ifndef SlopeFromAngle + PyMac_PRECHECK(SlopeFromAngle); #endif - if (!PyArg_ParseTuple(_args, "O&l", - GrafObj_Convert, &port, - &penMode)) + if (!PyArg_ParseTuple(_args, "h", + &angle)) return NULL; - SetPortPenMode(port, - penMode); - Py_INCREF(Py_None); - _res = Py_None; + _rv = SlopeFromAngle(angle); + _res = Py_BuildValue("O&", + PyMac_BuildFixed, _rv); return _res; } -static PyObject *Qd_SetPortFracHPenLocation(PyObject *_self, PyObject *_args) +static PyObject *Qd_AngleFromSlope(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - CGrafPtr port; - short pnLocHFrac; -#ifndef SetPortFracHPenLocation - PyMac_PRECHECK(SetPortFracHPenLocation); + short _rv; + Fixed slope; +#ifndef AngleFromSlope + PyMac_PRECHECK(AngleFromSlope); #endif - if (!PyArg_ParseTuple(_args, "O&h", - GrafObj_Convert, &port, - &pnLocHFrac)) + if (!PyArg_ParseTuple(_args, "O&", + PyMac_GetFixed, &slope)) return NULL; - SetPortFracHPenLocation(port, - pnLocHFrac); - Py_INCREF(Py_None); - _res = Py_None; + _rv = AngleFromSlope(slope); + _res = Py_BuildValue("h", + _rv); return _res; } @@ -5054,25 +4993,6 @@ static PyObject *Qd_CreateNewPort(PyObject *_self, PyObject *_args) #if TARGET_API_MAC_CARBON -static PyObject *Qd_DisposePort(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - CGrafPtr port; -#ifndef DisposePort - PyMac_PRECHECK(DisposePort); -#endif - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) - return NULL; - DisposePort(port); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} -#endif - -#if TARGET_API_MAC_CARBON - static PyObject *Qd_SetQDError(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; @@ -5090,107 +5010,6 @@ static PyObject *Qd_SetQDError(PyObject *_self, PyObject *_args) } #endif -static PyObject *Qd_QDIsPortBuffered(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - Boolean _rv; - CGrafPtr port; -#ifndef QDIsPortBuffered - PyMac_PRECHECK(QDIsPortBuffered); -#endif - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) - return NULL; - _rv = QDIsPortBuffered(port); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Qd_QDIsPortBufferDirty(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - Boolean _rv; - CGrafPtr port; -#ifndef QDIsPortBufferDirty - PyMac_PRECHECK(QDIsPortBufferDirty); -#endif - if (!PyArg_ParseTuple(_args, "O&", - GrafObj_Convert, &port)) - return NULL; - _rv = QDIsPortBufferDirty(port); - _res = Py_BuildValue("b", - _rv); - return _res; -} - -static PyObject *Qd_QDFlushPortBuffer(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - CGrafPtr port; - RgnHandle region; -#ifndef QDFlushPortBuffer - PyMac_PRECHECK(QDFlushPortBuffer); -#endif - if (!PyArg_ParseTuple(_args, "O&O&", - GrafObj_Convert, &port, - OptResObj_Convert, ®ion)) - return NULL; - QDFlushPortBuffer(port, - region); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -#if TARGET_API_MAC_CARBON - -static PyObject *Qd_QDGetDirtyRegion(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - OSStatus _err; - CGrafPtr port; - RgnHandle rgn; -#ifndef QDGetDirtyRegion - PyMac_PRECHECK(QDGetDirtyRegion); -#endif - if (!PyArg_ParseTuple(_args, "O&O&", - GrafObj_Convert, &port, - ResObj_Convert, &rgn)) - return NULL; - _err = QDGetDirtyRegion(port, - rgn); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} -#endif - -#if TARGET_API_MAC_CARBON - -static PyObject *Qd_QDSetDirtyRegion(PyObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - OSStatus _err; - CGrafPtr port; - RgnHandle rgn; -#ifndef QDSetDirtyRegion - PyMac_PRECHECK(QDSetDirtyRegion); -#endif - if (!PyArg_ParseTuple(_args, "O&O&", - GrafObj_Convert, &port, - ResObj_Convert, &rgn)) - return NULL; - _err = QDSetDirtyRegion(port, - rgn); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} -#endif - static PyObject *Qd_LMGetScrVRes(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; @@ -6461,8 +6280,6 @@ static PyObject *Qd_RawBitMap(PyObject *_self, PyObject *_args) } static PyMethodDef Qd_methods[] = { - {"MacSetPort", (PyCFunction)Qd_MacSetPort, 1, - PyDoc_STR("(GrafPtr port) -> None")}, {"GetPort", (PyCFunction)Qd_GetPort, 1, PyDoc_STR("() -> (GrafPtr port)")}, {"GrafDevice", (PyCFunction)Qd_GrafDevice, 1, @@ -6826,96 +6643,6 @@ static PyMethodDef Qd_methods[] = { PyDoc_STR("(short angle) -> (Fixed _rv)")}, {"AngleFromSlope", (PyCFunction)Qd_AngleFromSlope, 1, PyDoc_STR("(Fixed slope) -> (short _rv)")}, - -#if TARGET_API_MAC_CARBON - {"IsValidPort", (PyCFunction)Qd_IsValidPort, 1, - PyDoc_STR("(CGrafPtr port) -> (Boolean _rv)")}, -#endif - {"GetPortPixMap", (PyCFunction)Qd_GetPortPixMap, 1, - PyDoc_STR("(CGrafPtr port) -> (PixMapHandle _rv)")}, - {"GetPortBitMapForCopyBits", (PyCFunction)Qd_GetPortBitMapForCopyBits, 1, - PyDoc_STR("(CGrafPtr port) -> (const BitMap * _rv)")}, - {"GetPortBounds", (PyCFunction)Qd_GetPortBounds, 1, - PyDoc_STR("(CGrafPtr port) -> (Rect rect)")}, - {"GetPortForeColor", (PyCFunction)Qd_GetPortForeColor, 1, - PyDoc_STR("(CGrafPtr port) -> (RGBColor foreColor)")}, - {"GetPortBackColor", (PyCFunction)Qd_GetPortBackColor, 1, - PyDoc_STR("(CGrafPtr port) -> (RGBColor backColor)")}, - {"GetPortOpColor", (PyCFunction)Qd_GetPortOpColor, 1, - PyDoc_STR("(CGrafPtr port) -> (RGBColor opColor)")}, - {"GetPortHiliteColor", (PyCFunction)Qd_GetPortHiliteColor, 1, - PyDoc_STR("(CGrafPtr port) -> (RGBColor hiliteColor)")}, - {"GetPortTextFont", (PyCFunction)Qd_GetPortTextFont, 1, - PyDoc_STR("(CGrafPtr port) -> (short _rv)")}, - {"GetPortTextFace", (PyCFunction)Qd_GetPortTextFace, 1, - PyDoc_STR("(CGrafPtr port) -> (Style _rv)")}, - {"GetPortTextMode", (PyCFunction)Qd_GetPortTextMode, 1, - PyDoc_STR("(CGrafPtr port) -> (short _rv)")}, - {"GetPortTextSize", (PyCFunction)Qd_GetPortTextSize, 1, - PyDoc_STR("(CGrafPtr port) -> (short _rv)")}, - {"GetPortChExtra", (PyCFunction)Qd_GetPortChExtra, 1, - PyDoc_STR("(CGrafPtr port) -> (short _rv)")}, - {"GetPortFracHPenLocation", (PyCFunction)Qd_GetPortFracHPenLocation, 1, - PyDoc_STR("(CGrafPtr port) -> (short _rv)")}, - {"GetPortSpExtra", (PyCFunction)Qd_GetPortSpExtra, 1, - PyDoc_STR("(CGrafPtr port) -> (Fixed _rv)")}, - {"GetPortPenVisibility", (PyCFunction)Qd_GetPortPenVisibility, 1, - PyDoc_STR("(CGrafPtr port) -> (short _rv)")}, - {"GetPortVisibleRegion", (PyCFunction)Qd_GetPortVisibleRegion, 1, - PyDoc_STR("(CGrafPtr port, RgnHandle visRgn) -> (RgnHandle _rv)")}, - {"GetPortClipRegion", (PyCFunction)Qd_GetPortClipRegion, 1, - PyDoc_STR("(CGrafPtr port, RgnHandle clipRgn) -> (RgnHandle _rv)")}, - {"GetPortBackPixPat", (PyCFunction)Qd_GetPortBackPixPat, 1, - PyDoc_STR("(CGrafPtr port, PixPatHandle backPattern) -> (PixPatHandle _rv)")}, - {"GetPortPenPixPat", (PyCFunction)Qd_GetPortPenPixPat, 1, - PyDoc_STR("(CGrafPtr port, PixPatHandle penPattern) -> (PixPatHandle _rv)")}, - {"GetPortFillPixPat", (PyCFunction)Qd_GetPortFillPixPat, 1, - PyDoc_STR("(CGrafPtr port, PixPatHandle fillPattern) -> (PixPatHandle _rv)")}, - {"GetPortPenSize", (PyCFunction)Qd_GetPortPenSize, 1, - PyDoc_STR("(CGrafPtr port, Point penSize) -> (Point penSize)")}, - {"GetPortPenMode", (PyCFunction)Qd_GetPortPenMode, 1, - PyDoc_STR("(CGrafPtr port) -> (SInt32 _rv)")}, - {"GetPortPenLocation", (PyCFunction)Qd_GetPortPenLocation, 1, - PyDoc_STR("(CGrafPtr port, Point penLocation) -> (Point penLocation)")}, - {"IsPortRegionBeingDefined", (PyCFunction)Qd_IsPortRegionBeingDefined, 1, - PyDoc_STR("(CGrafPtr port) -> (Boolean _rv)")}, - {"IsPortPictureBeingDefined", (PyCFunction)Qd_IsPortPictureBeingDefined, 1, - PyDoc_STR("(CGrafPtr port) -> (Boolean _rv)")}, - -#if TARGET_API_MAC_CARBON - {"IsPortPolyBeingDefined", (PyCFunction)Qd_IsPortPolyBeingDefined, 1, - PyDoc_STR("(CGrafPtr port) -> (Boolean _rv)")}, -#endif - -#if TARGET_API_MAC_CARBON - {"IsPortOffscreen", (PyCFunction)Qd_IsPortOffscreen, 1, - PyDoc_STR("(CGrafPtr port) -> (Boolean _rv)")}, -#endif - -#if TARGET_API_MAC_CARBON - {"IsPortColor", (PyCFunction)Qd_IsPortColor, 1, - PyDoc_STR("(CGrafPtr port) -> (Boolean _rv)")}, -#endif - {"SetPortBounds", (PyCFunction)Qd_SetPortBounds, 1, - PyDoc_STR("(CGrafPtr port, Rect rect) -> None")}, - {"SetPortOpColor", (PyCFunction)Qd_SetPortOpColor, 1, - PyDoc_STR("(CGrafPtr port, RGBColor opColor) -> None")}, - {"SetPortVisibleRegion", (PyCFunction)Qd_SetPortVisibleRegion, 1, - PyDoc_STR("(CGrafPtr port, RgnHandle visRgn) -> None")}, - {"SetPortClipRegion", (PyCFunction)Qd_SetPortClipRegion, 1, - PyDoc_STR("(CGrafPtr port, RgnHandle clipRgn) -> None")}, - {"SetPortPenPixPat", (PyCFunction)Qd_SetPortPenPixPat, 1, - PyDoc_STR("(CGrafPtr port, PixPatHandle penPattern) -> None")}, - {"SetPortFillPixPat", (PyCFunction)Qd_SetPortFillPixPat, 1, - PyDoc_STR("(CGrafPtr port, PixPatHandle penPattern) -> None")}, - {"SetPortBackPixPat", (PyCFunction)Qd_SetPortBackPixPat, 1, - PyDoc_STR("(CGrafPtr port, PixPatHandle backPattern) -> None")}, - {"SetPortPenSize", (PyCFunction)Qd_SetPortPenSize, 1, - PyDoc_STR("(CGrafPtr port, Point penSize) -> None")}, - {"SetPortPenMode", (PyCFunction)Qd_SetPortPenMode, 1, - PyDoc_STR("(CGrafPtr port, SInt32 penMode) -> None")}, - {"SetPortFracHPenLocation", (PyCFunction)Qd_SetPortFracHPenLocation, 1, - PyDoc_STR("(CGrafPtr port, short pnLocHFrac) -> None")}, {"GetPixBounds", (PyCFunction)Qd_GetPixBounds, 1, PyDoc_STR("(PixMapHandle pixMap) -> (Rect bounds)")}, {"GetPixDepth", (PyCFunction)Qd_GetPixDepth, 1, @@ -6955,30 +6682,9 @@ static PyMethodDef Qd_methods[] = { PyDoc_STR("() -> (CGrafPtr _rv)")}, #endif -#if TARGET_API_MAC_CARBON - {"DisposePort", (PyCFunction)Qd_DisposePort, 1, - PyDoc_STR("(CGrafPtr port) -> None")}, -#endif - #if TARGET_API_MAC_CARBON {"SetQDError", (PyCFunction)Qd_SetQDError, 1, PyDoc_STR("(OSErr err) -> None")}, -#endif - {"QDIsPortBuffered", (PyCFunction)Qd_QDIsPortBuffered, 1, - PyDoc_STR("(CGrafPtr port) -> (Boolean _rv)")}, - {"QDIsPortBufferDirty", (PyCFunction)Qd_QDIsPortBufferDirty, 1, - PyDoc_STR("(CGrafPtr port) -> (Boolean _rv)")}, - {"QDFlushPortBuffer", (PyCFunction)Qd_QDFlushPortBuffer, 1, - PyDoc_STR("(CGrafPtr port, RgnHandle region) -> None")}, - -#if TARGET_API_MAC_CARBON - {"QDGetDirtyRegion", (PyCFunction)Qd_QDGetDirtyRegion, 1, - PyDoc_STR("(CGrafPtr port, RgnHandle rgn) -> None")}, -#endif - -#if TARGET_API_MAC_CARBON - {"QDSetDirtyRegion", (PyCFunction)Qd_QDSetDirtyRegion, 1, - PyDoc_STR("(CGrafPtr port, RgnHandle rgn) -> None")}, #endif {"LMGetScrVRes", (PyCFunction)Qd_LMGetScrVRes, 1, PyDoc_STR("() -> (SInt16 _rv)")}, @@ -7172,20 +6878,6 @@ void init_Qd(void) Py_INCREF(&BitMap_Type); if (PyDict_SetItemString(d, "BitMapType", (PyObject *)&BitMap_Type) != 0) Py_FatalError("can't initialize BitMapType"); - QDGlobalsAccess_Type.ob_type = &PyType_Type; - Py_INCREF(&QDGlobalsAccess_Type); - if (PyDict_SetItemString(d, "QDGlobalsAccessType", (PyObject *)&QDGlobalsAccess_Type) != 0) - Py_FatalError("can't initialize QDGlobalsAccessType"); - - { - PyObject *o; - - o = QDGA_New(); - if (o == NULL || PyDict_SetItemString(d, "qd", o) != 0) - return; - } - - } /* ========================= End module _Qd ========================= */ diff --git a/Mac/Modules/qd/qdscan.py b/Mac/Modules/qd/qdscan.py index 4c69ab0543..15f5f921fb 100644 --- a/Mac/Modules/qd/qdscan.py +++ b/Mac/Modules/qd/qdscan.py @@ -53,6 +53,12 @@ class MyScanner(Scanner): listname = "functions" if arglist: t, n, m = arglist[0] + if t in ('GrafPtr', 'CGrafPtr') and m == 'InMode': + classname = "Method" + listname = "gr_methods" + elif t == 'BitMapPtr' and m == 'InMode': + classname = "Method" + listname = "bm_methods" ## elif t == "PolyHandle" and m == "InMode": ## classname = "Method" ## listname = "p_methods" diff --git a/Mac/Modules/qd/qdsupport.py b/Mac/Modules/qd/qdsupport.py index 73c87d118e..c668e95db6 100644 --- a/Mac/Modules/qd/qdsupport.py +++ b/Mac/Modules/qd/qdsupport.py @@ -211,15 +211,7 @@ PyObject *BMObj_NewCopied(BitMapPtr itself) """ -variablestuff = """ -{ - PyObject *o; - - o = QDGA_New(); - if (o == NULL || PyDict_SetItemString(d, "qd", o) != 0) - return; -} -""" +variablestuff = "" initstuff = initstuff + """ PyMac_INIT_TOOLBOX_OBJECT_NEW(BitMapPtr, BMObj_New); @@ -244,7 +236,22 @@ initstuff = initstuff + """ ## def outputFreeIt(self, itselfname): ## Output("KillPoly(%s);", itselfname) -class MyGRObjectDefinition(GlobalObjectDefinition): +class MyGRObjectDefinition(PEP252Mixin, GlobalObjectDefinition): + getsetlist = [ + ('visRgn', + """RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */ + return Py_BuildValue("O&", ResObj_New, (Handle)GetPortVisibleRegion(self->ob_itself, h)); + """, + None, + "Convenience attribute: return a copy of the visible region" + ), ( + 'clipRgn', + """RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */ + return Py_BuildValue("O&", ResObj_New, (Handle)GetPortClipRegion(self->ob_itself, h)); + """, + None, + "Convenience attribute: return a copy of the clipping region" + )] def outputCheckNewArg(self): Output("if (itself == NULL) return PyMac_Error(resNotFound);") def outputCheckConvertArg(self): @@ -269,157 +276,35 @@ class MyGRObjectDefinition(GlobalObjectDefinition): Output("return 1;") OutRbrace() Output("#endif") - def outputGetattrHook(self): - Output("#if !ACCESSOR_CALLS_ARE_FUNCTIONS") - Output(""" - { CGrafPtr itself_color = (CGrafPtr)self->ob_itself; - - if ( strcmp(name, "data") == 0 ) - return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(GrafPort)); - - if ( (itself_color->portVersion&0xc000) == 0xc000 ) { - /* Color-only attributes */ - - if ( strcmp(name, "portBits") == 0 ) - /* XXXX Do we need HLock() stuff here?? */ - return BMObj_New((BitMapPtr)*itself_color->portPixMap); - if ( strcmp(name, "grafVars") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->visRgn); - if ( strcmp(name, "chExtra") == 0 ) - return Py_BuildValue("h", itself_color->chExtra); - if ( strcmp(name, "pnLocHFrac") == 0 ) - return Py_BuildValue("h", itself_color->pnLocHFrac); - if ( strcmp(name, "bkPixPat") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->bkPixPat); - if ( strcmp(name, "rgbFgColor") == 0 ) - return Py_BuildValue("O&", QdRGB_New, &itself_color->rgbFgColor); - if ( strcmp(name, "rgbBkColor") == 0 ) - return Py_BuildValue("O&", QdRGB_New, &itself_color->rgbBkColor); - if ( strcmp(name, "pnPixPat") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->pnPixPat); - if ( strcmp(name, "fillPixPat") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->fillPixPat); - } else { - /* Mono-only attributes */ - if ( strcmp(name, "portBits") == 0 ) - return BMObj_New(&self->ob_itself->portBits); - if ( strcmp(name, "bkPat") == 0 ) - return Py_BuildValue("s#", (char *)&self->ob_itself->bkPat, sizeof(Pattern)); - if ( strcmp(name, "fillPat") == 0 ) - return Py_BuildValue("s#", (char *)&self->ob_itself->fillPat, sizeof(Pattern)); - if ( strcmp(name, "pnPat") == 0 ) - return Py_BuildValue("s#", (char *)&self->ob_itself->pnPat, sizeof(Pattern)); - } - /* - ** Accessible for both color/mono windows. - ** portVersion is really color-only, but we put it here - ** for convenience - */ - if ( strcmp(name, "portVersion") == 0 ) - return Py_BuildValue("h", itself_color->portVersion); - if ( strcmp(name, "device") == 0 ) - return PyInt_FromLong((long)self->ob_itself->device); - if ( strcmp(name, "portRect") == 0 ) - return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect); - if ( strcmp(name, "visRgn") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->visRgn); - if ( strcmp(name, "clipRgn") == 0 ) - return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->clipRgn); - if ( strcmp(name, "pnLoc") == 0 ) - return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnLoc); - if ( strcmp(name, "pnSize") == 0 ) - return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnSize); - if ( strcmp(name, "pnMode") == 0 ) - return Py_BuildValue("h", self->ob_itself->pnMode); - if ( strcmp(name, "pnVis") == 0 ) - return Py_BuildValue("h", self->ob_itself->pnVis); - if ( strcmp(name, "txFont") == 0 ) - return Py_BuildValue("h", self->ob_itself->txFont); - if ( strcmp(name, "txFace") == 0 ) - return Py_BuildValue("h", (short)self->ob_itself->txFace); - if ( strcmp(name, "txMode") == 0 ) - return Py_BuildValue("h", self->ob_itself->txMode); - if ( strcmp(name, "txSize") == 0 ) - return Py_BuildValue("h", self->ob_itself->txSize); - if ( strcmp(name, "spExtra") == 0 ) - return Py_BuildValue("O&", PyMac_BuildFixed, self->ob_itself->spExtra); - /* XXXX Add more, as needed */ - /* This one is so we can compare grafports: */ - if ( strcmp(name, "_id") == 0 ) - return Py_BuildValue("l", (long)self->ob_itself); - }""") - Output("#else") - Output(""" - { CGrafPtr itself_color = (CGrafPtr)self->ob_itself; - if ( strcmp(name, "portBits") == 0 ) - return BMObj_New((BitMapPtr)GetPortBitMapForCopyBits(itself_color)); - if ( strcmp(name, "chExtra") == 0 ) - return Py_BuildValue("h", GetPortChExtra(itself_color)); - if ( strcmp(name, "pnLocHFrac") == 0 ) - return Py_BuildValue("h", GetPortFracHPenLocation(itself_color)); - if ( strcmp(name, "bkPixPat") == 0 ) { - PixPatHandle h=0; - return Py_BuildValue("O&", ResObj_New, (Handle)GetPortBackPixPat(itself_color, h)); - } - if ( strcmp(name, "rgbFgColor") == 0 ) { - RGBColor c; - return Py_BuildValue("O&", QdRGB_New, GetPortForeColor(itself_color, &c)); - } - if ( strcmp(name, "rgbBkColor") == 0 ) { - RGBColor c; - return Py_BuildValue("O&", QdRGB_New, GetPortBackColor(itself_color, &c)); - } - if ( strcmp(name, "pnPixPat") == 0 ) { - PixPatHandle h=NewPixPat(); /* XXXX wrong dispose routine */ - - return Py_BuildValue("O&", ResObj_New, (Handle)GetPortPenPixPat(itself_color, h)); - } - if ( strcmp(name, "fillPixPat") == 0 ) { - PixPatHandle h=NewPixPat(); /* XXXX wrong dispose routine */ - return Py_BuildValue("O&", ResObj_New, (Handle)GetPortFillPixPat(itself_color, h)); - } - if ( strcmp(name, "portRect") == 0 ) { - Rect r; - return Py_BuildValue("O&", PyMac_BuildRect, GetPortBounds(itself_color, &r)); - } - if ( strcmp(name, "visRgn") == 0 ) { - RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */ - return Py_BuildValue("O&", ResObj_New, (Handle)GetPortVisibleRegion(itself_color, h)); - } - if ( strcmp(name, "clipRgn") == 0 ) { - RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */ - return Py_BuildValue("O&", ResObj_New, (Handle)GetPortClipRegion(itself_color, h)); - } - if ( strcmp(name, "pnLoc") == 0 ) { - Point p; - return Py_BuildValue("O&", PyMac_BuildPoint, *GetPortPenLocation(itself_color, &p)); - } - if ( strcmp(name, "pnSize") == 0 ) { - Point p; - return Py_BuildValue("O&", PyMac_BuildPoint, *GetPortPenSize(itself_color, &p)); - } - if ( strcmp(name, "pnMode") == 0 ) - return Py_BuildValue("h", GetPortPenMode(itself_color)); - if ( strcmp(name, "pnVis") == 0 ) - return Py_BuildValue("h", GetPortPenVisibility(itself_color)); - if ( strcmp(name, "txFont") == 0 ) - return Py_BuildValue("h", GetPortTextFont(itself_color)); - if ( strcmp(name, "txFace") == 0 ) - return Py_BuildValue("h", (short)GetPortTextFace(itself_color)); - if ( strcmp(name, "txMode") == 0 ) - return Py_BuildValue("h", GetPortTextMode(itself_color)); - if ( strcmp(name, "txSize") == 0 ) - return Py_BuildValue("h", GetPortTextSize(itself_color)); - if ( strcmp(name, "spExtra") == 0 ) - return Py_BuildValue("O&", PyMac_BuildFixed, GetPortSpExtra(itself_color)); - /* XXXX Add more, as needed */ - /* This one is so we can compare grafports: */ - if ( strcmp(name, "_id") == 0 ) - return Py_BuildValue("l", (long)self->ob_itself); - }""") - Output("#endif") -class MyBMObjectDefinition(GlobalObjectDefinition): +class MyBMObjectDefinition(PEP252Mixin, GlobalObjectDefinition): + getsetlist = [ + ( + 'baseAddr', + 'return PyInt_FromLong((long)self->ob_itself->baseAddr);', + None, + None + ), ( + 'rowBytes', + 'return PyInt_FromLong((long)self->ob_itself->rowBytes);', + None, + None + ), ( + 'bounds', + 'return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds);', + None, + None + ), ( + 'bitmap_data', + 'return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap));', + None, + None + ), ( + 'pixmap_data', + 'return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap));', + None, + None + )] def outputCheckNewArg(self): Output("if (itself == NULL) return PyMac_Error(resNotFound);") def outputStructMembers(self): @@ -434,104 +319,7 @@ class MyBMObjectDefinition(GlobalObjectDefinition): Output("it->referred_bitmap = NULL;") def outputCleanupStructMembers(self): Output("Py_XDECREF(self->referred_object);") - Output("if (self->referred_bitmap) free(self->referred_bitmap);") - def outputGetattrHook(self): - Output("""if ( strcmp(name, "baseAddr") == 0 ) - return PyInt_FromLong((long)self->ob_itself->baseAddr); - if ( strcmp(name, "rowBytes") == 0 ) - return PyInt_FromLong((long)self->ob_itself->rowBytes); - 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)); - """) - -# This object is instanciated once, and will access qd globals. -class QDGlobalsAccessObjectDefinition(ObjectDefinition): - def outputStructMembers(self): - pass - def outputNew(self): - Output() - Output("%sPyObject *%s_New(void)", self.static, self.prefix) - OutLbrace() - Output("%s *it;", self.objecttype) - Output("it = PyObject_NEW(%s, &%s);", self.objecttype, self.typename) - Output("if (it == NULL) return NULL;") - Output("return (PyObject *)it;") - OutRbrace() - def outputConvert(self): - pass - def outputCleanupStructMembers(self): - pass - - def outputGetattrHook(self): - Output("#if !ACCESSOR_CALLS_ARE_FUNCTIONS") - Output(""" - if ( strcmp(name, "arrow") == 0 ) - return PyString_FromStringAndSize((char *)&qd.arrow, sizeof(qd.arrow)); - if ( strcmp(name, "black") == 0 ) - return PyString_FromStringAndSize((char *)&qd.black, sizeof(qd.black)); - if ( strcmp(name, "white") == 0 ) - return PyString_FromStringAndSize((char *)&qd.white, sizeof(qd.white)); - if ( strcmp(name, "gray") == 0 ) - return PyString_FromStringAndSize((char *)&qd.gray, sizeof(qd.gray)); - if ( strcmp(name, "ltGray") == 0 ) - return PyString_FromStringAndSize((char *)&qd.ltGray, sizeof(qd.ltGray)); - if ( strcmp(name, "dkGray") == 0 ) - return PyString_FromStringAndSize((char *)&qd.dkGray, sizeof(qd.dkGray)); - if ( strcmp(name, "screenBits") == 0 ) - return BMObj_New(&qd.screenBits); - if ( strcmp(name, "thePort") == 0 ) - return GrafObj_New(qd.thePort); - if ( strcmp(name, "randSeed") == 0 ) - return Py_BuildValue("l", &qd.randSeed); - """) - Output("#else") - Output(""" - if ( strcmp(name, "arrow") == 0 ) { - Cursor rv; - GetQDGlobalsArrow(&rv); - return PyString_FromStringAndSize((char *)&rv, sizeof(rv)); - } - if ( strcmp(name, "black") == 0 ) { - Pattern rv; - GetQDGlobalsBlack(&rv); - return PyString_FromStringAndSize((char *)&rv, sizeof(rv)); - } - if ( strcmp(name, "white") == 0 ) { - Pattern rv; - GetQDGlobalsWhite(&rv); - return PyString_FromStringAndSize((char *)&rv, sizeof(rv)); - } - if ( strcmp(name, "gray") == 0 ) { - Pattern rv; - GetQDGlobalsGray(&rv); - return PyString_FromStringAndSize((char *)&rv, sizeof(rv)); - } - if ( strcmp(name, "ltGray") == 0 ) { - Pattern rv; - GetQDGlobalsLightGray(&rv); - return PyString_FromStringAndSize((char *)&rv, sizeof(rv)); - } - if ( strcmp(name, "dkGray") == 0 ) { - Pattern rv; - GetQDGlobalsDarkGray(&rv); - return PyString_FromStringAndSize((char *)&rv, sizeof(rv)); - } - if ( strcmp(name, "screenBits") == 0 ) { - BitMap rv; - GetQDGlobalsScreenBits(&rv); - return BMObj_NewCopied(&rv); - } - if ( strcmp(name, "thePort") == 0 ) - return GrafObj_New(GetQDGlobalsThePort()); - if ( strcmp(name, "randSeed") == 0 ) - return Py_BuildValue("l", GetQDGlobalsRandomSeed()); - """) - Output("#endif") + Output("if (self->referred_bitmap) free(self->referred_bitmap);") # Create the generator groups and link them module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff, variablestuff) @@ -543,8 +331,6 @@ gr_object = MyGRObjectDefinition("GrafPort", "GrafObj", "GrafPtr") module.addobject(gr_object) bm_object = MyBMObjectDefinition("BitMap", "BMObj", "BitMapPtr") module.addobject(bm_object) -qd_object = QDGlobalsAccessObjectDefinition("QDGlobalsAccess", "QDGA", "XXXX") -module.addobject(qd_object) # Create the generator classes used to populate the lists @@ -553,15 +339,17 @@ Method = OSErrWeakLinkMethodGenerator # Create and populate the lists functions = [] -methods = [] +gr_methods = [] +bm_methods = [] +#methods = [] execfile(INPUTFILE) execfile(EXTRAFILE) # add the populated lists to the generator groups # (in a different wordl the scan program would generate this) for f in functions: module.add(f) -##for f in r_methods: r_object.add(f) -##for f in po_methods: po_object.add(f) +for f in gr_methods: gr_object.add(f) +for f in bm_methods: bm_object.add(f) # Manual generator: get data out of a bitmap getdata_body = """ diff --git a/Mac/Modules/qdoffs/_Qdoffsmodule.c b/Mac/Modules/qdoffs/_Qdoffsmodule.c index c75daac2ab..9804b71cc0 100644 --- a/Mac/Modules/qdoffs/_Qdoffsmodule.c +++ b/Mac/Modules/qdoffs/_Qdoffsmodule.c @@ -131,14 +131,7 @@ static PyMethodDef GWorldObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain GWorldObj_chain = { GWorldObj_methods, NULL }; - -static PyObject *GWorldObj_getattr(GWorldObject *self, char *name) -{ - return Py_FindMethodInChain(&GWorldObj_chain, (PyObject *)self, name); -} - -#define GWorldObj_setattr NULL +#define GWorldObj_getsetlist NULL #define GWorldObj_compare NULL @@ -155,14 +148,31 @@ PyTypeObject GWorld_Type = { /* methods */ (destructor) GWorldObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) GWorldObj_getattr, /*tp_getattr*/ - (setattrfunc) GWorldObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) GWorldObj_compare, /*tp_compare*/ (reprfunc) GWorldObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) GWorldObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + GWorldObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + GWorldObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* --------------------- End object type GWorld --------------------- */ diff --git a/Mac/Modules/qdoffs/qdoffssupport.py b/Mac/Modules/qdoffs/qdoffssupport.py index 057f0a96ce..11ce8fdc94 100644 --- a/Mac/Modules/qdoffs/qdoffssupport.py +++ b/Mac/Modules/qdoffs/qdoffssupport.py @@ -57,7 +57,7 @@ initstuff = initstuff + """ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GWorldPtr, GWorldObj_Convert); """ -class MyObjectDefinition(GlobalObjectDefinition): +class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("if (itself == NULL) return PyMac_Error(resNotFound);") ## def outputInitStructMembers(self): diff --git a/Mac/Modules/qt/_Qtmodule.c b/Mac/Modules/qt/_Qtmodule.c index 687aaeee7e..47ec3d9793 100644 --- a/Mac/Modules/qt/_Qtmodule.c +++ b/Mac/Modules/qt/_Qtmodule.c @@ -1090,14 +1090,7 @@ static PyMethodDef MovieCtlObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain MovieCtlObj_chain = { MovieCtlObj_methods, NULL }; - -static PyObject *MovieCtlObj_getattr(MovieControllerObject *self, char *name) -{ - return Py_FindMethodInChain(&MovieCtlObj_chain, (PyObject *)self, name); -} - -#define MovieCtlObj_setattr NULL +#define MovieCtlObj_getsetlist NULL #define MovieCtlObj_compare NULL @@ -1114,14 +1107,31 @@ PyTypeObject MovieController_Type = { /* methods */ (destructor) MovieCtlObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) MovieCtlObj_getattr, /*tp_getattr*/ - (setattrfunc) MovieCtlObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) MovieCtlObj_compare, /*tp_compare*/ (reprfunc) MovieCtlObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) MovieCtlObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + MovieCtlObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + MovieCtlObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* ---------------- End object type MovieController ----------------- */ @@ -1541,14 +1551,7 @@ static PyMethodDef TimeBaseObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain TimeBaseObj_chain = { TimeBaseObj_methods, NULL }; - -static PyObject *TimeBaseObj_getattr(TimeBaseObject *self, char *name) -{ - return Py_FindMethodInChain(&TimeBaseObj_chain, (PyObject *)self, name); -} - -#define TimeBaseObj_setattr NULL +#define TimeBaseObj_getsetlist NULL #define TimeBaseObj_compare NULL @@ -1565,14 +1568,31 @@ PyTypeObject TimeBase_Type = { /* methods */ (destructor) TimeBaseObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) TimeBaseObj_getattr, /*tp_getattr*/ - (setattrfunc) TimeBaseObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) TimeBaseObj_compare, /*tp_compare*/ (reprfunc) TimeBaseObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) TimeBaseObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + TimeBaseObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + TimeBaseObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* -------------------- End object type TimeBase -------------------- */ @@ -1845,14 +1865,7 @@ static PyMethodDef UserDataObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain UserDataObj_chain = { UserDataObj_methods, NULL }; - -static PyObject *UserDataObj_getattr(UserDataObject *self, char *name) -{ - return Py_FindMethodInChain(&UserDataObj_chain, (PyObject *)self, name); -} - -#define UserDataObj_setattr NULL +#define UserDataObj_getsetlist NULL #define UserDataObj_compare NULL @@ -1869,14 +1882,31 @@ PyTypeObject UserData_Type = { /* methods */ (destructor) UserDataObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) UserDataObj_getattr, /*tp_getattr*/ - (setattrfunc) UserDataObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) UserDataObj_compare, /*tp_compare*/ (reprfunc) UserDataObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) UserDataObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + UserDataObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + UserDataObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* -------------------- End object type UserData -------------------- */ @@ -3020,14 +3050,7 @@ static PyMethodDef MediaObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain MediaObj_chain = { MediaObj_methods, NULL }; - -static PyObject *MediaObj_getattr(MediaObject *self, char *name) -{ - return Py_FindMethodInChain(&MediaObj_chain, (PyObject *)self, name); -} - -#define MediaObj_setattr NULL +#define MediaObj_getsetlist NULL #define MediaObj_compare NULL @@ -3044,14 +3067,31 @@ PyTypeObject Media_Type = { /* methods */ (destructor) MediaObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) MediaObj_getattr, /*tp_getattr*/ - (setattrfunc) MediaObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) MediaObj_compare, /*tp_compare*/ (reprfunc) MediaObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) MediaObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + MediaObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + MediaObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* --------------------- End object type Media ---------------------- */ @@ -4301,14 +4341,7 @@ static PyMethodDef TrackObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain TrackObj_chain = { TrackObj_methods, NULL }; - -static PyObject *TrackObj_getattr(TrackObject *self, char *name) -{ - return Py_FindMethodInChain(&TrackObj_chain, (PyObject *)self, name); -} - -#define TrackObj_setattr NULL +#define TrackObj_getsetlist NULL #define TrackObj_compare NULL @@ -4325,14 +4358,31 @@ PyTypeObject Track_Type = { /* methods */ (destructor) TrackObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) TrackObj_getattr, /*tp_getattr*/ - (setattrfunc) TrackObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) TrackObj_compare, /*tp_compare*/ (reprfunc) TrackObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) TrackObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + TrackObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + TrackObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* --------------------- End object type Track ---------------------- */ @@ -6722,14 +6772,7 @@ static PyMethodDef MovieObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain MovieObj_chain = { MovieObj_methods, NULL }; - -static PyObject *MovieObj_getattr(MovieObject *self, char *name) -{ - return Py_FindMethodInChain(&MovieObj_chain, (PyObject *)self, name); -} - -#define MovieObj_setattr NULL +#define MovieObj_getsetlist NULL #define MovieObj_compare NULL @@ -6746,14 +6789,31 @@ PyTypeObject Movie_Type = { /* methods */ (destructor) MovieObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) MovieObj_getattr, /*tp_getattr*/ - (setattrfunc) MovieObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) MovieObj_compare, /*tp_compare*/ (reprfunc) MovieObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) MovieObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + MovieObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + MovieObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* --------------------- End object type Movie ---------------------- */ diff --git a/Mac/Modules/qt/qtsupport.py b/Mac/Modules/qt/qtsupport.py index c6525c0894..8160a3094d 100644 --- a/Mac/Modules/qt/qtsupport.py +++ b/Mac/Modules/qt/qtsupport.py @@ -181,7 +181,7 @@ QTFloatSingle = Type("QTFloatSingle", "f") dummyshortptr = FakeType('(short *)0') dummyStringPtr = FakeType('(StringPtr)0') -class MovieObjectDefinition(GlobalObjectDefinition): +class MovieObjectDefinition(PEP252Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("""if (itself == NULL) { PyErr_SetString(Qt_Error,"Cannot create null Movie"); @@ -190,7 +190,7 @@ class MovieObjectDefinition(GlobalObjectDefinition): def outputFreeIt(self, itselfname): Output("DisposeMovie(%s);", itselfname) -class TrackObjectDefinition(GlobalObjectDefinition): +class TrackObjectDefinition(PEP252Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("""if (itself == NULL) { PyErr_SetString(Qt_Error,"Cannot create null Track"); @@ -199,7 +199,7 @@ class TrackObjectDefinition(GlobalObjectDefinition): def outputFreeIt(self, itselfname): Output("DisposeMovieTrack(%s);", itselfname) -class MediaObjectDefinition(GlobalObjectDefinition): +class MediaObjectDefinition(PEP252Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("""if (itself == NULL) { PyErr_SetString(Qt_Error,"Cannot create null Media"); @@ -208,7 +208,7 @@ class MediaObjectDefinition(GlobalObjectDefinition): def outputFreeIt(self, itselfname): Output("DisposeTrackMedia(%s);", itselfname) -class UserDataObjectDefinition(GlobalObjectDefinition): +class UserDataObjectDefinition(PEP252Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("""if (itself == NULL) { PyErr_SetString(Qt_Error,"Cannot create null UserData"); @@ -217,7 +217,7 @@ class UserDataObjectDefinition(GlobalObjectDefinition): def outputFreeIt(self, itselfname): Output("DisposeUserData(%s);", itselfname) -class TimeBaseObjectDefinition(GlobalObjectDefinition): +class TimeBaseObjectDefinition(PEP252Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("""if (itself == NULL) { PyErr_SetString(Qt_Error,"Cannot create null TimeBase"); @@ -226,7 +226,7 @@ class TimeBaseObjectDefinition(GlobalObjectDefinition): ## def outputFreeIt(self, itselfname): ## Output("DisposeTimeBase(%s);", itselfname) -class MovieCtlObjectDefinition(GlobalObjectDefinition): +class MovieCtlObjectDefinition(PEP252Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("""if (itself == NULL) { PyErr_SetString(Qt_Error,"Cannot create null MovieController"); diff --git a/Mac/Modules/res/_Resmodule.c b/Mac/Modules/res/_Resmodule.c index 421b9d7c82..1884230f3f 100644 --- a/Mac/Modules/res/_Resmodule.c +++ b/Mac/Modules/res/_Resmodule.c @@ -551,54 +551,61 @@ static PyMethodDef ResObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain ResObj_chain = { ResObj_methods, NULL }; - -static PyObject *ResObj_getattr(ResourceObject *self, char *name) -{ - - if (strcmp(name, "size") == 0) - return PyInt_FromLong(GetHandleSize(self->ob_itself)); - if (strcmp(name, "data") == 0) { - PyObject *res; - char state; - state = HGetState(self->ob_itself); - HLock(self->ob_itself); - res = PyString_FromStringAndSize( - *self->ob_itself, - GetHandleSize(self->ob_itself)); - HUnlock(self->ob_itself); - HSetState(self->ob_itself, state); - return res; - } - if (strcmp(name, "__members__") == 0) - return Py_BuildValue("[ss]", "data", "size"); - - return Py_FindMethodInChain(&ResObj_chain, (PyObject *)self, name); +static PyObject *ResObj_get_data(ResourceObject *self, void *closure) +{ + + PyObject *res; + char state; + + state = HGetState(self->ob_itself); + HLock(self->ob_itself); + res = PyString_FromStringAndSize( + *self->ob_itself, + GetHandleSize(self->ob_itself)); + HUnlock(self->ob_itself); + HSetState(self->ob_itself, state); + return res; + +} + +static int ResObj_set_data(ResourceObject *self, PyObject *v, void *closure) +{ + + char *data; + long size; + + if ( v == NULL ) + return -1; + if ( !PyString_Check(v) ) + return -1; + size = PyString_Size(v); + data = PyString_AsString(v); + /* XXXX Do I need the GetState/SetState calls? */ + SetHandleSize(self->ob_itself, size); + if ( MemError()) + return -1; + HLock(self->ob_itself); + memcpy((char *)*self->ob_itself, data, size); + HUnlock(self->ob_itself); + /* XXXX Should I do the Changed call immedeately? */ + return 0; + + return 0; } -static int -ResObj_setattr(ResourceObject *self, char *name, PyObject *value) +static PyObject *ResObj_get_size(ResourceObject *self, void *closure) { - char *data; - long size; - - if (strcmp(name, "data") != 0 || value == NULL ) - return -1; - if ( !PyString_Check(value) ) - return -1; - size = PyString_Size(value); - data = PyString_AsString(value); - /* XXXX Do I need the GetState/SetState calls? */ - SetHandleSize(self->ob_itself, size); - if ( MemError()) - return -1; - HLock(self->ob_itself); - memcpy((char *)*self->ob_itself, data, size); - HUnlock(self->ob_itself); - /* XXXX Should I do the Changed call immedeately? */ - return 0; + return PyInt_FromLong(GetHandleSize(self->ob_itself)); } +#define ResObj_set_size NULL + +static PyGetSetDef ResObj_getsetlist[] = { + {"data", (getter)ResObj_get_data, (setter)ResObj_set_data, "The resource data"}, + {"size", (getter)ResObj_get_size, (setter)ResObj_set_size, "The length of the resource data"}, + {NULL, NULL, NULL, NULL}, +}; + #define ResObj_compare NULL @@ -615,14 +622,31 @@ PyTypeObject Resource_Type = { /* methods */ (destructor) ResObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) ResObj_getattr, /*tp_getattr*/ - (setattrfunc) ResObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) ResObj_compare, /*tp_compare*/ (reprfunc) ResObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) ResObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + ResObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + ResObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* -------------------- End object type Resource -------------------- */ diff --git a/Mac/Modules/res/ressupport.py b/Mac/Modules/res/ressupport.py index c0bfc8ac18..8f6cb8dc55 100644 --- a/Mac/Modules/res/ressupport.py +++ b/Mac/Modules/res/ressupport.py @@ -100,51 +100,49 @@ initstuff = initstuff + """ module = MacModule('_Res', 'Res', includestuff, finalstuff, initstuff) -getattrHookCode = """ -if (strcmp(name, "size") == 0) - return PyInt_FromLong(GetHandleSize(self->ob_itself)); -if (strcmp(name, "data") == 0) { - PyObject *res; - char state; - state = HGetState(self->ob_itself); - HLock(self->ob_itself); - res = PyString_FromStringAndSize( - *self->ob_itself, - GetHandleSize(self->ob_itself)); - HUnlock(self->ob_itself); - HSetState(self->ob_itself, state); - return res; -} -if (strcmp(name, "__members__") == 0) - return Py_BuildValue("[ss]", "data", "size"); -""" - -setattrCode = """ -static int -ResObj_setattr(ResourceObject *self, char *name, PyObject *value) -{ - char *data; - long size; +class ResDefinition(PEP252Mixin, GlobalObjectDefinition): + getsetlist = [ + ('data', + """ + PyObject *res; + char state; + + state = HGetState(self->ob_itself); + HLock(self->ob_itself); + res = PyString_FromStringAndSize( + *self->ob_itself, + GetHandleSize(self->ob_itself)); + HUnlock(self->ob_itself); + HSetState(self->ob_itself, state); + return res; + """, + """ + char *data; + long size; - if (strcmp(name, "data") != 0 || value == NULL ) - return -1; - if ( !PyString_Check(value) ) - return -1; - size = PyString_Size(value); - data = PyString_AsString(value); - /* XXXX Do I need the GetState/SetState calls? */ - SetHandleSize(self->ob_itself, size); - if ( MemError()) - return -1; - HLock(self->ob_itself); - memcpy((char *)*self->ob_itself, data, size); - HUnlock(self->ob_itself); - /* XXXX Should I do the Changed call immedeately? */ - return 0; -} -""" - -class ResDefinition(GlobalObjectDefinition): + if ( v == NULL ) + return -1; + if ( !PyString_Check(v) ) + return -1; + size = PyString_Size(v); + data = PyString_AsString(v); + /* XXXX Do I need the GetState/SetState calls? */ + SetHandleSize(self->ob_itself, size); + if ( MemError()) + return -1; + HLock(self->ob_itself); + memcpy((char *)*self->ob_itself, data, size); + HUnlock(self->ob_itself); + /* XXXX Should I do the Changed call immedeately? */ + return 0; + """, + 'The resource data' + ), ( + 'size', + 'return PyInt_FromLong(GetHandleSize(self->ob_itself));', + None, + 'The length of the resource data' + )] def outputCheckNewArg(self): Output("if (itself == NULL) return PyMac_Error(resNotFound);") @@ -163,12 +161,6 @@ class ResDefinition(GlobalObjectDefinition): Output("PyErr_Clear();") OutRbrace() - def outputGetattrHook(self): - Output(getattrHookCode) - - def outputSetattr(self): - Output(setattrCode) - def outputStructMembers(self): GlobalObjectDefinition.outputStructMembers(self) Output("void (*ob_freeit)(%s ptr);", self.itselftype) diff --git a/Mac/Modules/scrap/scrapsupport.py b/Mac/Modules/scrap/scrapsupport.py index 57d7578a63..43fcb46f6b 100644 --- a/Mac/Modules/scrap/scrapsupport.py +++ b/Mac/Modules/scrap/scrapsupport.py @@ -55,7 +55,7 @@ ScrapFlavorFlags = Type('ScrapFlavorFlags', 'l') #ScrapFlavorInfo = OpaqueType('ScrapFlavorInfo', 'ScrapFlavorInfo') putscrapbuffer = FixedInputBufferType('void *') -class MyObjectDefinition(GlobalObjectDefinition): +class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition): pass # Create the generator groups and link them diff --git a/Mac/Modules/snd/_Sndmodule.c b/Mac/Modules/snd/_Sndmodule.c index 7ce479971c..412ae9db88 100644 --- a/Mac/Modules/snd/_Sndmodule.c +++ b/Mac/Modules/snd/_Sndmodule.c @@ -300,14 +300,8 @@ static PyMethodDef SndCh_methods[] = { {NULL, NULL, 0} }; -static PyMethodChain SndCh_chain = { SndCh_methods, NULL }; +#define SndCh_getsetlist NULL -static PyObject *SndCh_getattr(SndChannelObject *self, char *name) -{ - return Py_FindMethodInChain(&SndCh_chain, (PyObject *)self, name); -} - -#define SndCh_setattr NULL #define SndCh_compare NULL @@ -324,14 +318,31 @@ static PyTypeObject SndChannel_Type = { /* methods */ (destructor) SndCh_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) SndCh_getattr, /*tp_getattr*/ - (setattrfunc) SndCh_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) SndCh_compare, /*tp_compare*/ (reprfunc) SndCh_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) SndCh_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + SndCh_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + SndCh_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* ------------------- End object type SndChannel ------------------- */ @@ -391,52 +402,66 @@ static PyMethodDef SPBObj_methods[] = { {NULL, NULL, 0} }; -static PyMethodChain SPBObj_chain = { SPBObj_methods, NULL }; +static PyObject *SPBObj_get_inRefNum(SPBObject *self, void *closure) +{ + return Py_BuildValue("l", self->ob_spb.inRefNum); +} -static PyObject *SPBObj_getattr(SPBObject *self, char *name) +static int SPBObj_set_inRefNum(SPBObject *self, PyObject *v, void *closure) { + return -1 + PyArg_Parse(v, "l", &self->ob_spb.inRefNum); + return 0; +} - if (strcmp(name, "inRefNum") == 0) - return Py_BuildValue("l", self->ob_spb.inRefNum); - else if (strcmp(name, "count") == 0) - return Py_BuildValue("l", self->ob_spb.count); - else if (strcmp(name, "milliseconds") == 0) - return Py_BuildValue("l", self->ob_spb.milliseconds); - else if (strcmp(name, "error") == 0) - return Py_BuildValue("h", self->ob_spb.error); - return Py_FindMethodInChain(&SPBObj_chain, (PyObject *)self, name); +static PyObject *SPBObj_get_count(SPBObject *self, void *closure) +{ + return Py_BuildValue("l", self->ob_spb.count); } -static int SPBObj_setattr(SPBObject *self, char *name, PyObject *value) +static int SPBObj_set_count(SPBObject *self, PyObject *v, void *closure) { + return -1 + PyArg_Parse(v, "l", &self->ob_spb.count); + return 0; +} - int rv = 0; - - if (strcmp(name, "inRefNum") == 0) - rv = PyArg_Parse(value, "l", &self->ob_spb.inRefNum); - else if (strcmp(name, "count") == 0) - rv = PyArg_Parse(value, "l", &self->ob_spb.count); - else if (strcmp(name, "milliseconds") == 0) - rv = PyArg_Parse(value, "l", &self->ob_spb.milliseconds); - else if (strcmp(name, "buffer") == 0) - rv = PyArg_Parse(value, "w#", &self->ob_spb.bufferPtr, &self->ob_spb.bufferLength); - else if (strcmp(name, "completionRoutine") == 0) { - self->ob_spb.completionRoutine = NewSICompletionUPP(SPB_completion); - self->ob_completion = value; - Py_INCREF(value); - rv = 1; -#if !TARGET_API_MAC_CARBON - } else if (strcmp(name, "interruptRoutine") == 0) { - self->ob_spb.completionRoutine = NewSIInterruptUPP(SPB_interrupt); - self->ob_interrupt = value; - Py_INCREF(value); - rv = 1; -#endif - } - if ( rv ) return 0; - else return -1; +static PyObject *SPBObj_get_milliseconds(SPBObject *self, void *closure) +{ + return Py_BuildValue("l", self->ob_spb.milliseconds); } +static int SPBObj_set_milliseconds(SPBObject *self, PyObject *v, void *closure) +{ + return -1 + PyArg_Parse(v, "l", &self->ob_spb.milliseconds); + return 0; +} + +static PyObject *SPBObj_get_error(SPBObject *self, void *closure) +{ + return Py_BuildValue("h", self->ob_spb.error); +} + +#define SPBObj_set_error NULL + +#define SPBObj_get_completionRoutine NULL + +static int SPBObj_set_completionRoutine(SPBObject *self, PyObject *v, void *closure) +{ + self->ob_spb.completionRoutine = NewSICompletionUPP(SPB_completion); + self->ob_completion = v; + Py_INCREF(v); + return 0; + return 0; +} + +static PyGetSetDef SPBObj_getsetlist[] = { + {"inRefNum", (getter)SPBObj_get_inRefNum, (setter)SPBObj_set_inRefNum, NULL}, + {"count", (getter)SPBObj_get_count, (setter)SPBObj_set_count, NULL}, + {"milliseconds", (getter)SPBObj_get_milliseconds, (setter)SPBObj_set_milliseconds, NULL}, + {"error", (getter)SPBObj_get_error, (setter)SPBObj_set_error, NULL}, + {"completionRoutine", (getter)SPBObj_get_completionRoutine, (setter)SPBObj_set_completionRoutine, NULL}, +}; + + #define SPBObj_compare NULL #define SPBObj_repr NULL @@ -452,14 +477,31 @@ static PyTypeObject SPB_Type = { /* methods */ (destructor) SPBObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) SPBObj_getattr, /*tp_getattr*/ - (setattrfunc) SPBObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) SPBObj_compare, /*tp_compare*/ (reprfunc) SPBObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) SPBObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + SPBObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + SPBObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* ---------------------- End object type SPB ----------------------- */ diff --git a/Mac/Modules/snd/sndsupport.py b/Mac/Modules/snd/sndsupport.py index 47c17cebe0..073f612ed9 100644 --- a/Mac/Modules/snd/sndsupport.py +++ b/Mac/Modules/snd/sndsupport.py @@ -211,7 +211,7 @@ SPB_interrupt(SPBPtr my_spb) # create the module and object definition and link them -class SndObjectDefinition(ObjectDefinition): +class SndObjectDefinition(PEP252Mixin, ObjectDefinition): def outputStructMembers(self): ObjectDefinition.outputStructMembers(self) @@ -237,7 +237,37 @@ class SndObjectDefinition(ObjectDefinition): # -class SpbObjectDefinition(ObjectDefinition): +class SpbObjectDefinition(PEP252Mixin, ObjectDefinition): + getsetlist = [ + ( + 'inRefNum', + 'return Py_BuildValue("l", self->ob_spb.inRefNum);', + 'return -1 + PyArg_Parse(v, "l", &self->ob_spb.inRefNum);', + None, + ), ( + 'count', + 'return Py_BuildValue("l", self->ob_spb.count);', + 'return -1 + PyArg_Parse(v, "l", &self->ob_spb.count);', + None + ), ( + 'milliseconds', + 'return Py_BuildValue("l", self->ob_spb.milliseconds);', + 'return -1 + PyArg_Parse(v, "l", &self->ob_spb.milliseconds);', + None, + ), ( + 'error', + 'return Py_BuildValue("h", self->ob_spb.error);', + None, + None + ), ( + 'completionRoutine', + None, + """self->ob_spb.completionRoutine = NewSICompletionUPP(SPB_completion); + self->ob_completion = v; + Py_INCREF(v); + return 0;""", + None, + )] def outputStructMembers(self): Output("/* Members used to implement callbacks: */") @@ -286,54 +316,6 @@ class SpbObjectDefinition(ObjectDefinition): Output("*p_itself = &((%s *)v)->ob_spb;", self.objecttype) Output("return 1;") OutRbrace() - - def outputSetattr(self): - Output() - Output("static int %s_setattr(%s *self, char *name, PyObject *value)", - self.prefix, self.objecttype) - OutLbrace() - self.outputSetattrBody() - OutRbrace() - - def outputSetattrBody(self): - Output(""" - int rv = 0; - - if (strcmp(name, "inRefNum") == 0) - rv = PyArg_Parse(value, "l", &self->ob_spb.inRefNum); - else if (strcmp(name, "count") == 0) - rv = PyArg_Parse(value, "l", &self->ob_spb.count); - else if (strcmp(name, "milliseconds") == 0) - rv = PyArg_Parse(value, "l", &self->ob_spb.milliseconds); - else if (strcmp(name, "buffer") == 0) - rv = PyArg_Parse(value, "w#", &self->ob_spb.bufferPtr, &self->ob_spb.bufferLength); - else if (strcmp(name, "completionRoutine") == 0) { - self->ob_spb.completionRoutine = NewSICompletionUPP(SPB_completion); - self->ob_completion = value; - Py_INCREF(value); - rv = 1; -#if !TARGET_API_MAC_CARBON - } else if (strcmp(name, "interruptRoutine") == 0) { - self->ob_spb.completionRoutine = NewSIInterruptUPP(SPB_interrupt); - self->ob_interrupt = value; - Py_INCREF(value); - rv = 1; -#endif - } - if ( rv ) return 0; - else return -1;""") - - def outputGetattrHook(self): - Output(""" - if (strcmp(name, "inRefNum") == 0) - return Py_BuildValue("l", self->ob_spb.inRefNum); - else if (strcmp(name, "count") == 0) - return Py_BuildValue("l", self->ob_spb.count); - else if (strcmp(name, "milliseconds") == 0) - return Py_BuildValue("l", self->ob_spb.milliseconds); - else if (strcmp(name, "error") == 0) - return Py_BuildValue("h", self->ob_spb.error);""") - sndobject = SndObjectDefinition('SndChannel', 'SndCh', 'SndChannelPtr') diff --git a/Mac/Modules/te/_TEmodule.c b/Mac/Modules/te/_TEmodule.c index 1788620da4..a89826b588 100644 --- a/Mac/Modules/te/_TEmodule.c +++ b/Mac/Modules/te/_TEmodule.c @@ -850,52 +850,137 @@ static PyMethodDef TEObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain TEObj_chain = { TEObj_methods, NULL }; - -static PyObject *TEObj_getattr(TEObject *self, char *name) -{ - - if( strcmp(name, "destRect") == 0 ) - return Py_BuildValue("O&", PyMac_BuildRect, - &(*self->ob_itself)->destRect); - if( strcmp(name, "viewRect") == 0 ) - return Py_BuildValue("O&", PyMac_BuildRect, - &(*self->ob_itself)->viewRect); - if( strcmp(name, "selRect") == 0 ) - return Py_BuildValue("O&", PyMac_BuildRect, - &(*self->ob_itself)->selRect); - if( strcmp(name, "lineHeight") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->lineHeight); - if( strcmp(name, "fontAscent") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->fontAscent); - if( strcmp(name, "selPoint") == 0 ) - return Py_BuildValue("O&", PyMac_BuildPoint, - (*self->ob_itself)->selPoint); - if( strcmp(name, "selStart") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->selStart); - if( strcmp(name, "selEnd") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->selEnd); - if( strcmp(name, "active") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->active); - if( strcmp(name, "just") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->just); - if( strcmp(name, "teLength") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->teLength); - if( strcmp(name, "txFont") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->txFont); - if( strcmp(name, "txFace") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->txFace); - if( strcmp(name, "txMode") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->txMode); - if( strcmp(name, "txSize") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->txSize); - if( strcmp(name, "nLines") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->nLines); - - return Py_FindMethodInChain(&TEObj_chain, (PyObject *)self, name); -} - -#define TEObj_setattr NULL +static PyObject *TEObj_get_destRect(TEObject *self, void *closure) +{ + return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->destRect); +} + +#define TEObj_set_destRect NULL + +static PyObject *TEObj_get_viewRect(TEObject *self, void *closure) +{ + return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->viewRect); +} + +#define TEObj_set_viewRect NULL + +static PyObject *TEObj_get_selRect(TEObject *self, void *closure) +{ + return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->selRect); +} + +#define TEObj_set_selRect NULL + +static PyObject *TEObj_get_lineHeight(TEObject *self, void *closure) +{ + return Py_BuildValue("h", (*self->ob_itself)->lineHeight); +} + +#define TEObj_set_lineHeight NULL + +static PyObject *TEObj_get_fontAscent(TEObject *self, void *closure) +{ + return Py_BuildValue("h", (*self->ob_itself)->fontAscent); +} + +#define TEObj_set_fontAscent NULL + +static PyObject *TEObj_get_selPoint(TEObject *self, void *closure) +{ + return Py_BuildValue("O&", PyMac_BuildPoint, (*self->ob_itself)->selPoint); +} + +#define TEObj_set_selPoint NULL + +static PyObject *TEObj_get_selStart(TEObject *self, void *closure) +{ + return Py_BuildValue("h", (*self->ob_itself)->selStart); +} + +#define TEObj_set_selStart NULL + +static PyObject *TEObj_get_selEnd(TEObject *self, void *closure) +{ + return Py_BuildValue("h", (*self->ob_itself)->selEnd); +} + +#define TEObj_set_selEnd NULL + +static PyObject *TEObj_get_active(TEObject *self, void *closure) +{ + return Py_BuildValue("h", (*self->ob_itself)->active); +} + +#define TEObj_set_active NULL + +static PyObject *TEObj_get_just(TEObject *self, void *closure) +{ + return Py_BuildValue("h", (*self->ob_itself)->just); +} + +#define TEObj_set_just NULL + +static PyObject *TEObj_get_teLength(TEObject *self, void *closure) +{ + return Py_BuildValue("h", (*self->ob_itself)->teLength); +} + +#define TEObj_set_teLength NULL + +static PyObject *TEObj_get_txFont(TEObject *self, void *closure) +{ + return Py_BuildValue("h", (*self->ob_itself)->txFont); +} + +#define TEObj_set_txFont NULL + +static PyObject *TEObj_get_txFace(TEObject *self, void *closure) +{ + return Py_BuildValue("h", (*self->ob_itself)->txFace); +} + +#define TEObj_set_txFace NULL + +static PyObject *TEObj_get_txMode(TEObject *self, void *closure) +{ + return Py_BuildValue("h", (*self->ob_itself)->txMode); +} + +#define TEObj_set_txMode NULL + +static PyObject *TEObj_get_txSize(TEObject *self, void *closure) +{ + return Py_BuildValue("h", (*self->ob_itself)->txSize); +} + +#define TEObj_set_txSize NULL + +static PyObject *TEObj_get_nLines(TEObject *self, void *closure) +{ + return Py_BuildValue("h", (*self->ob_itself)->nLines); +} + +#define TEObj_set_nLines NULL + +static PyGetSetDef TEObj_getsetlist[] = { + {"destRect", (getter)TEObj_get_destRect, (setter)TEObj_set_destRect, "Destination rectangle"}, + {"viewRect", (getter)TEObj_get_viewRect, (setter)TEObj_set_viewRect, "Viewing rectangle"}, + {"selRect", (getter)TEObj_get_selRect, (setter)TEObj_set_selRect, "Selection rectangle"}, + {"lineHeight", (getter)TEObj_get_lineHeight, (setter)TEObj_set_lineHeight, "Height of a line"}, + {"fontAscent", (getter)TEObj_get_fontAscent, (setter)TEObj_set_fontAscent, "Ascent of a line"}, + {"selPoint", (getter)TEObj_get_selPoint, (setter)TEObj_set_selPoint, "Selection Point"}, + {"selStart", (getter)TEObj_get_selStart, (setter)TEObj_set_selStart, "Start of selection"}, + {"selEnd", (getter)TEObj_get_selEnd, (setter)TEObj_set_selEnd, "End of selection"}, + {"active", (getter)TEObj_get_active, (setter)TEObj_set_active, "TBD"}, + {"just", (getter)TEObj_get_just, (setter)TEObj_set_just, "Justification"}, + {"teLength", (getter)TEObj_get_teLength, (setter)TEObj_set_teLength, "TBD"}, + {"txFont", (getter)TEObj_get_txFont, (setter)TEObj_set_txFont, "Current font"}, + {"txFace", (getter)TEObj_get_txFace, (setter)TEObj_set_txFace, "Current font variant"}, + {"txMode", (getter)TEObj_get_txMode, (setter)TEObj_set_txMode, "Current text-drawing mode"}, + {"txSize", (getter)TEObj_get_txSize, (setter)TEObj_set_txSize, "Current font size"}, + {"nLines", (getter)TEObj_get_nLines, (setter)TEObj_set_nLines, "TBD"}, +}; + #define TEObj_compare NULL @@ -912,14 +997,31 @@ PyTypeObject TE_Type = { /* methods */ (destructor) TEObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) TEObj_getattr, /*tp_getattr*/ - (setattrfunc) TEObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) TEObj_compare, /*tp_compare*/ (reprfunc) TEObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) TEObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + TEObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + TEObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* ----------------------- End object type TE ----------------------- */ diff --git a/Mac/Modules/te/tesupport.py b/Mac/Modules/te/tesupport.py index a77250c656..f11e7182b3 100644 --- a/Mac/Modules/te/tesupport.py +++ b/Mac/Modules/te/tesupport.py @@ -93,7 +93,91 @@ class TEMethodGenerator(OSErrWeakLinkMethodGenerator): -class MyObjectDefinition(GlobalObjectDefinition): +class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition): + # Attributes that can be set. + getsetlist = [ + ( + 'destRect', + 'return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->destRect);', + None, + 'Destination rectangle' + ), ( + 'viewRect', + 'return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->viewRect);', + None, + 'Viewing rectangle' + ), ( + 'selRect', + 'return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->selRect);', + None, + 'Selection rectangle' + ), ( + 'lineHeight', + 'return Py_BuildValue("h", (*self->ob_itself)->lineHeight);', + None, + 'Height of a line' + ), ( + 'fontAscent', + 'return Py_BuildValue("h", (*self->ob_itself)->fontAscent);', + None, + 'Ascent of a line' + ), ( + "selPoint", + 'return Py_BuildValue("O&", PyMac_BuildPoint, (*self->ob_itself)->selPoint);', + None, + 'Selection Point' + ), ( + 'selStart', + 'return Py_BuildValue("h", (*self->ob_itself)->selStart);', + None, + 'Start of selection' + ), ( + 'selEnd', + 'return Py_BuildValue("h", (*self->ob_itself)->selEnd);', + None, + 'End of selection' + ), ( + 'active', + 'return Py_BuildValue("h", (*self->ob_itself)->active);', + None, + 'TBD' + ), ( + 'just', + 'return Py_BuildValue("h", (*self->ob_itself)->just);', + None, + 'Justification' + ), ( + 'teLength', + 'return Py_BuildValue("h", (*self->ob_itself)->teLength);', + None, + 'TBD' + ), ( + 'txFont', + 'return Py_BuildValue("h", (*self->ob_itself)->txFont);', + None, + 'Current font' + ), ( + 'txFace', + 'return Py_BuildValue("h", (*self->ob_itself)->txFace);', + None, + 'Current font variant' + ), ( + 'txMode', + 'return Py_BuildValue("h", (*self->ob_itself)->txMode);', + None, + 'Current text-drawing mode' + ), ( + 'txSize', + 'return Py_BuildValue("h", (*self->ob_itself)->txSize);', + None, + 'Current font size' + ), ( + 'nLines', + 'return Py_BuildValue("h", (*self->ob_itself)->nLines);', + None, + 'TBD' + )] + def outputCheckNewArg(self): Output("""if (itself == NULL) { PyErr_SetString(TE_Error,"Cannot create null TE"); @@ -102,45 +186,6 @@ class MyObjectDefinition(GlobalObjectDefinition): def outputFreeIt(self, itselfname): Output("TEDispose(%s);", itselfname) - def outputGetattrHook(self): - Output(""" - if( strcmp(name, "destRect") == 0 ) - return Py_BuildValue("O&", PyMac_BuildRect, - &(*self->ob_itself)->destRect); - if( strcmp(name, "viewRect") == 0 ) - return Py_BuildValue("O&", PyMac_BuildRect, - &(*self->ob_itself)->viewRect); - if( strcmp(name, "selRect") == 0 ) - return Py_BuildValue("O&", PyMac_BuildRect, - &(*self->ob_itself)->selRect); - if( strcmp(name, "lineHeight") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->lineHeight); - if( strcmp(name, "fontAscent") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->fontAscent); - if( strcmp(name, "selPoint") == 0 ) - return Py_BuildValue("O&", PyMac_BuildPoint, - (*self->ob_itself)->selPoint); - if( strcmp(name, "selStart") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->selStart); - if( strcmp(name, "selEnd") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->selEnd); - if( strcmp(name, "active") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->active); - if( strcmp(name, "just") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->just); - if( strcmp(name, "teLength") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->teLength); - if( strcmp(name, "txFont") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->txFont); - if( strcmp(name, "txFace") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->txFace); - if( strcmp(name, "txMode") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->txMode); - if( strcmp(name, "txSize") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->txSize); - if( strcmp(name, "nLines") == 0 ) - return Py_BuildValue("h", (*self->ob_itself)->nLines); - """) # From here on it's basically all boiler plate... diff --git a/Mac/Modules/waste/wastemodule.c b/Mac/Modules/waste/wastemodule.c index e50107452c..93f8aa5ed2 100644 --- a/Mac/Modules/waste/wastemodule.c +++ b/Mac/Modules/waste/wastemodule.c @@ -384,14 +384,7 @@ static PyMethodDef WEOObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain WEOObj_chain = { WEOObj_methods, NULL }; - -static PyObject *WEOObj_getattr(WEOObject *self, char *name) -{ - return Py_FindMethodInChain(&WEOObj_chain, (PyObject *)self, name); -} - -#define WEOObj_setattr NULL +#define WEOObj_getsetlist NULL #define WEOObj_compare NULL @@ -408,14 +401,31 @@ PyTypeObject WEO_Type = { /* methods */ (destructor) WEOObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) WEOObj_getattr, /*tp_getattr*/ - (setattrfunc) WEOObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) WEOObj_compare, /*tp_compare*/ (reprfunc) WEOObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) WEOObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + WEOObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + WEOObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* ---------------------- End object type WEO ----------------------- */ @@ -2096,14 +2106,7 @@ static PyMethodDef wasteObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain wasteObj_chain = { wasteObj_methods, NULL }; - -static PyObject *wasteObj_getattr(wasteObject *self, char *name) -{ - return Py_FindMethodInChain(&wasteObj_chain, (PyObject *)self, name); -} - -#define wasteObj_setattr NULL +#define wasteObj_getsetlist NULL #define wasteObj_compare NULL @@ -2120,14 +2123,31 @@ PyTypeObject waste_Type = { /* methods */ (destructor) wasteObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) wasteObj_getattr, /*tp_getattr*/ - (setattrfunc) wasteObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) wasteObj_compare, /*tp_compare*/ (reprfunc) wasteObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) wasteObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + wasteObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + wasteObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* --------------------- End object type waste ---------------------- */ diff --git a/Mac/Modules/waste/wastesupport.py b/Mac/Modules/waste/wastesupport.py index 674f9f94f0..b9c1bfbf93 100644 --- a/Mac/Modules/waste/wastesupport.py +++ b/Mac/Modules/waste/wastesupport.py @@ -277,7 +277,7 @@ class WEMethodGenerator(OSErrMethodGenerator): -class WEObjectDefinition(GlobalObjectDefinition): +class WEObjectDefinition(PEP252Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("""if (itself == NULL) { PyErr_SetString(waste_Error,"Cannot create null WE"); @@ -289,7 +289,7 @@ class WEObjectDefinition(GlobalObjectDefinition): def outputFreeIt(self, itselfname): Output("WEDispose(%s);", itselfname) -class WEOObjectDefinition(GlobalObjectDefinition): +class WEOObjectDefinition(PEP252Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("""if (itself == NULL) { Py_INCREF(Py_None); diff --git a/Mac/Modules/win/_Winmodule.c b/Mac/Modules/win/_Winmodule.c index 0685c260c0..60ff824839 100644 --- a/Mac/Modules/win/_Winmodule.c +++ b/Mac/Modules/win/_Winmodule.c @@ -2926,14 +2926,7 @@ static PyMethodDef WinObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain WinObj_chain = { WinObj_methods, NULL }; - -static PyObject *WinObj_getattr(WindowObject *self, char *name) -{ - return Py_FindMethodInChain(&WinObj_chain, (PyObject *)self, name); -} - -#define WinObj_setattr NULL +#define WinObj_getsetlist NULL static int WinObj_compare(WindowObject *self, WindowObject *other) { @@ -2963,14 +2956,31 @@ PyTypeObject Window_Type = { /* methods */ (destructor) WinObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) WinObj_getattr, /*tp_getattr*/ - (setattrfunc) WinObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) WinObj_compare, /*tp_compare*/ (reprfunc) WinObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) WinObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 0, /*outputHook_tp_as_buffer*/ + 0, /*outputHook_tp_flags*/ + 0, /*outputHook_tp_doc*/ + 0, /*outputHook_tp_traverse*/ + 0, /*outputHook_tp_clear*/ + 0, /*outputHook_tp_richcompare*/ + 0, /*outputHook_tp_weaklistoffset*/ + 0, /*outputHook_tp_iter*/ + 0, /*outputHook_tp_iternext*/ + WinObj_methods, /* tp_methods */ + 0, /*outputHook_tp_members*/ + WinObj_getsetlist, /*tp_getset*/ + 0, /*outputHook_tp_base*/ }; /* --------------------- End object type Window --------------------- */ diff --git a/Mac/Modules/win/winsupport.py b/Mac/Modules/win/winsupport.py index bcd5119bc9..ba7fe14f06 100644 --- a/Mac/Modules/win/winsupport.py +++ b/Mac/Modules/win/winsupport.py @@ -128,7 +128,7 @@ initstuff = initstuff + """ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(WindowPtr, WinObj_Convert); """ -class MyObjectDefinition(GlobalObjectDefinition): +class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("if (itself == NULL) return PyMac_Error(resNotFound);") def outputStructMembers(self): -- cgit v1.2.1