diff options
Diffstat (limited to 'Mac/Modules')
29 files changed, 1802 insertions, 1791 deletions
diff --git a/Mac/Modules/ae/_AEmodule.c b/Mac/Modules/ae/_AEmodule.c index 01e4246..68be3bf 100644 --- a/Mac/Modules/ae/_AEmodule.c +++ b/Mac/Modules/ae/_AEmodule.c @@ -34,9 +34,9 @@ AEEventHandlerUPP upp_GenericEventHandler; static pascal Boolean AEIdleProc(EventRecord *theEvent, long *sleepTime, RgnHandle *mouseRgn) { - if ( PyOS_InterruptOccurred() ) - return 1; - return 0; + if ( PyOS_InterruptOccurred() ) + return 1; + return 0; } AEIdleUPP upp_AEIdleProc; @@ -64,6 +64,7 @@ PyObject *AEDesc_New(AEDesc *itself) it->ob_owned = 1; return (PyObject *)it; } + int AEDesc_Convert(PyObject *v, AEDesc *p_itself) { if (!AEDesc_Check(v)) @@ -829,20 +830,20 @@ static PyObject *AEDesc_get_type(AEDescObject *self, void *closure) 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; - + 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_set_data NULL @@ -863,16 +864,16 @@ static PyGetSetDef AEDesc_getsetlist[] = { #define AEDesc_tp_alloc PyType_GenericAlloc -static PyObject *AEDesc_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *AEDesc_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; AEDesc itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, AEDesc_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((AEDescObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, AEDesc_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((AEDescObject *)_self)->ob_itself = itself; + return _self; } #define AEDesc_tp_free PyObject_Del @@ -1383,44 +1384,44 @@ static PyMethodDef AE_methods[] = { static pascal OSErr GenericEventHandler(const AppleEvent *request, AppleEvent *reply, refcontype refcon) { - PyObject *handler = (PyObject *)refcon; - AEDescObject *requestObject, *replyObject; - PyObject *args, *res; - if ((requestObject = (AEDescObject *)AEDesc_New((AppleEvent *)request)) == NULL) { - return -1; - } - if ((replyObject = (AEDescObject *)AEDesc_New(reply)) == NULL) { - Py_DECREF(requestObject); - return -1; - } - if ((args = Py_BuildValue("OO", requestObject, replyObject)) == NULL) { - Py_DECREF(requestObject); - Py_DECREF(replyObject); - return -1; - } - res = PyEval_CallObject(handler, args); - requestObject->ob_itself.descriptorType = 'null'; - requestObject->ob_itself.dataHandle = NULL; - replyObject->ob_itself.descriptorType = 'null'; - replyObject->ob_itself.dataHandle = NULL; - Py_DECREF(args); - if (res == NULL) { - PySys_WriteStderr("Exception in AE event handler function\n"); - PyErr_Print(); - return -1; - } - Py_DECREF(res); - return noErr; + PyObject *handler = (PyObject *)refcon; + AEDescObject *requestObject, *replyObject; + PyObject *args, *res; + if ((requestObject = (AEDescObject *)AEDesc_New((AppleEvent *)request)) == NULL) { + return -1; + } + if ((replyObject = (AEDescObject *)AEDesc_New(reply)) == NULL) { + Py_DECREF(requestObject); + return -1; + } + if ((args = Py_BuildValue("OO", requestObject, replyObject)) == NULL) { + Py_DECREF(requestObject); + Py_DECREF(replyObject); + return -1; + } + res = PyEval_CallObject(handler, args); + requestObject->ob_itself.descriptorType = 'null'; + requestObject->ob_itself.dataHandle = NULL; + replyObject->ob_itself.descriptorType = 'null'; + replyObject->ob_itself.dataHandle = NULL; + Py_DECREF(args); + if (res == NULL) { + PySys_WriteStderr("Exception in AE event handler function\n"); + PyErr_Print(); + return -1; + } + Py_DECREF(res); + return noErr; } PyObject *AEDesc_NewBorrowed(AEDesc *itself) { - PyObject *it; - - it = AEDesc_New(itself); - if (it) - ((AEDescObject *)it)->ob_owned = 0; - return (PyObject *)it; + PyObject *it; + + it = AEDesc_New(itself); + if (it) + ((AEDescObject *)it)->ob_owned = 0; + return (PyObject *)it; } @@ -1432,11 +1433,11 @@ void init_AE(void) - upp_AEIdleProc = NewAEIdleUPP(AEIdleProc); - upp_GenericEventHandler = NewAEEventHandlerUPP(GenericEventHandler); - PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_New); - PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_NewBorrowed); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(AEDesc, AEDesc_Convert); + upp_AEIdleProc = NewAEIdleUPP(AEIdleProc); + upp_GenericEventHandler = NewAEEventHandlerUPP(GenericEventHandler); + PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_New); + PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc *, AEDesc_NewBorrowed); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(AEDesc, AEDesc_Convert); m = Py_InitModule("_AE", AE_methods); diff --git a/Mac/Modules/app/_Appmodule.c b/Mac/Modules/app/_Appmodule.c index df91f8f..3a368bf 100644 --- a/Mac/Modules/app/_Appmodule.c +++ b/Mac/Modules/app/_Appmodule.c @@ -20,7 +20,7 @@ int ThemeButtonDrawInfo_Convert(PyObject *v, ThemeButtonDrawInfo *p_itself) { - return PyArg_Parse(v, "(iHH)", &p_itself->state, &p_itself->value, &p_itself->adornment); + return PyArg_Parse(v, "(iHH)", &p_itself->state, &p_itself->value, &p_itself->adornment); } @@ -45,6 +45,7 @@ PyObject *ThemeDrawingStateObj_New(ThemeDrawingState itself) it->ob_itself = itself; return (PyObject *)it; } + int ThemeDrawingStateObj_Convert(PyObject *v, ThemeDrawingState *p_itself) { if (!ThemeDrawingStateObj_Check(v)) @@ -115,16 +116,16 @@ static PyMethodDef ThemeDrawingStateObj_methods[] = { #define ThemeDrawingStateObj_tp_alloc PyType_GenericAlloc -static PyObject *ThemeDrawingStateObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *ThemeDrawingStateObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; ThemeDrawingState itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, ThemeDrawingStateObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((ThemeDrawingStateObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, ThemeDrawingStateObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((ThemeDrawingStateObject *)_self)->ob_itself = itself; + return _self; } #define ThemeDrawingStateObj_tp_free PyObject_Del diff --git a/Mac/Modules/carbonevt/_CarbonEvtmodule.c b/Mac/Modules/carbonevt/_CarbonEvtmodule.c index 560b470..fee43cc 100755 --- a/Mac/Modules/carbonevt/_CarbonEvtmodule.c +++ b/Mac/Modules/carbonevt/_CarbonEvtmodule.c @@ -30,17 +30,17 @@ PyObject *EventRef_New(EventRef itself); static PyObject* EventTypeSpec_New(EventTypeSpec *in) { - return Py_BuildValue("ll", in->eventClass, in->eventKind); + return Py_BuildValue("ll", in->eventClass, in->eventKind); } static int EventTypeSpec_Convert(PyObject *v, EventTypeSpec *out) { - if (PyArg_Parse(v, "(O&l)", - PyMac_GetOSType, &(out->eventClass), - &(out->eventKind))) - return 1; - return NULL; + if (PyArg_Parse(v, "(O&l)", + PyMac_GetOSType, &(out->eventClass), + &(out->eventKind))) + return 1; + return NULL; } /********** end EventTypeSpec *******/ @@ -51,15 +51,15 @@ EventTypeSpec_Convert(PyObject *v, EventTypeSpec *out) static PyObject* HIPoint_New(HIPoint *in) { - return Py_BuildValue("ff", in->x, in->y); + return Py_BuildValue("ff", in->x, in->y); } static int HIPoint_Convert(PyObject *v, HIPoint *out) { - if (PyArg_ParseTuple(v, "ff", &(out->x), &(out->y))) - return 1; - return NULL; + if (PyArg_ParseTuple(v, "ff", &(out->x), &(out->y))) + return 1; + return NULL; } #endif @@ -70,15 +70,15 @@ HIPoint_Convert(PyObject *v, HIPoint *out) static PyObject* EventHotKeyID_New(EventHotKeyID *in) { - return Py_BuildValue("ll", in->signature, in->id); + return Py_BuildValue("ll", in->signature, in->id); } static int EventHotKeyID_Convert(PyObject *v, EventHotKeyID *out) { - if (PyArg_ParseTuple(v, "ll", &out->signature, &out->id)) - return 1; - return NULL; + if (PyArg_ParseTuple(v, "ll", &out->signature, &out->id)) + return 1; + return NULL; } /********** end EventHotKeyID *******/ @@ -89,27 +89,27 @@ static EventHandlerUPP myEventHandlerUPP; static pascal OSStatus myEventHandler(EventHandlerCallRef handlerRef, EventRef event, void *outPyObject) { - PyObject *retValue; - int status; - - retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&", - EventHandlerCallRef_New, handlerRef, - EventRef_New, event); - if (retValue == NULL) { - PySys_WriteStderr("Error in event handler callback:\n"); - PyErr_Print(); /* this also clears the error */ - status = noErr; /* complain? how? */ - } else { - if (retValue == Py_None) - status = noErr; - else if (PyInt_Check(retValue)) { - status = PyInt_AsLong(retValue); - } else - status = noErr; /* wrong object type, complain? */ - Py_DECREF(retValue); - } - - return status; + PyObject *retValue; + int status; + + retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&", + EventHandlerCallRef_New, handlerRef, + EventRef_New, event); + if (retValue == NULL) { + PySys_WriteStderr("Error in event handler callback:\n"); + PyErr_Print(); /* this also clears the error */ + status = noErr; /* complain? how? */ + } else { + if (retValue == Py_None) + status = noErr; + else if (PyInt_Check(retValue)) { + status = PyInt_AsLong(retValue); + } else + status = noErr; /* wrong object type, complain? */ + Py_DECREF(retValue); + } + + return status; } /******** end myEventHandler ***********/ @@ -136,6 +136,7 @@ PyObject *EventRef_New(EventRef itself) it->ob_itself = itself; return (PyObject *)it; } + int EventRef_Convert(PyObject *v, EventRef *p_itself) { if (!EventRef_Check(v)) @@ -399,16 +400,16 @@ static PyMethodDef EventRef_methods[] = { #define EventRef_tp_alloc PyType_GenericAlloc -static PyObject *EventRef_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *EventRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; EventRef itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, EventRef_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((EventRefObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventRef_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((EventRefObject *)_self)->ob_itself = itself; + return _self; } #define EventRef_tp_free PyObject_Del @@ -480,6 +481,7 @@ PyObject *EventQueueRef_New(EventQueueRef itself) it->ob_itself = itself; return (PyObject *)it; } + int EventQueueRef_Convert(PyObject *v, EventQueueRef *p_itself) { if (!EventQueueRef_Check(v)) @@ -619,16 +621,16 @@ static PyMethodDef EventQueueRef_methods[] = { #define EventQueueRef_tp_alloc PyType_GenericAlloc -static PyObject *EventQueueRef_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *EventQueueRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; EventQueueRef itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, EventQueueRef_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((EventQueueRefObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventQueueRef_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((EventQueueRefObject *)_self)->ob_itself = itself; + return _self; } #define EventQueueRef_tp_free PyObject_Del @@ -700,6 +702,7 @@ PyObject *EventLoopRef_New(EventLoopRef itself) it->ob_itself = itself; return (PyObject *)it; } + int EventLoopRef_Convert(PyObject *v, EventLoopRef *p_itself) { if (!EventLoopRef_Check(v)) @@ -748,16 +751,16 @@ static PyMethodDef EventLoopRef_methods[] = { #define EventLoopRef_tp_alloc PyType_GenericAlloc -static PyObject *EventLoopRef_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *EventLoopRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; EventLoopRef itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, EventLoopRef_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((EventLoopRefObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventLoopRef_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((EventLoopRefObject *)_self)->ob_itself = itself; + return _self; } #define EventLoopRef_tp_free PyObject_Del @@ -829,6 +832,7 @@ PyObject *EventLoopTimerRef_New(EventLoopTimerRef itself) it->ob_itself = itself; return (PyObject *)it; } + int EventLoopTimerRef_Convert(PyObject *v, EventLoopTimerRef *p_itself) { if (!EventLoopTimerRef_Check(v)) @@ -895,16 +899,16 @@ static PyMethodDef EventLoopTimerRef_methods[] = { #define EventLoopTimerRef_tp_alloc PyType_GenericAlloc -static PyObject *EventLoopTimerRef_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *EventLoopTimerRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; EventLoopTimerRef itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, EventLoopTimerRef_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((EventLoopTimerRefObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventLoopTimerRef_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((EventLoopTimerRefObject *)_self)->ob_itself = itself; + return _self; } #define EventLoopTimerRef_tp_free PyObject_Del @@ -978,6 +982,7 @@ PyObject *EventHandlerRef_New(EventHandlerRef itself) it->ob_callback = NULL; return (PyObject *)it; } + int EventHandlerRef_Convert(PyObject *v, EventHandlerRef *p_itself) { if (!EventHandlerRef_Check(v)) @@ -1050,11 +1055,11 @@ static PyObject *EventHandlerRef_RemoveEventHandler(EventHandlerRefObject *_self OSStatus _err; if (_self->ob_itself == NULL) { - PyErr_SetString(CarbonEvents_Error, "Handler has been removed"); - return NULL; + PyErr_SetString(CarbonEvents_Error, "Handler has been removed"); + return NULL; } if (!PyArg_ParseTuple(_args, "")) - return NULL; + return NULL; _err = RemoveEventHandler(_self->ob_itself); if (_err != noErr) return PyMac_Error(_err); _self->ob_itself = NULL; @@ -1087,16 +1092,16 @@ static PyMethodDef EventHandlerRef_methods[] = { #define EventHandlerRef_tp_alloc PyType_GenericAlloc -static PyObject *EventHandlerRef_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *EventHandlerRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; EventHandlerRef itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, EventHandlerRef_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((EventHandlerRefObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventHandlerRef_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((EventHandlerRefObject *)_self)->ob_itself = itself; + return _self; } #define EventHandlerRef_tp_free PyObject_Del @@ -1168,6 +1173,7 @@ PyObject *EventHandlerCallRef_New(EventHandlerCallRef itself) it->ob_itself = itself; return (PyObject *)it; } + int EventHandlerCallRef_Convert(PyObject *v, EventHandlerCallRef *p_itself) { if (!EventHandlerCallRef_Check(v)) @@ -1219,16 +1225,16 @@ static PyMethodDef EventHandlerCallRef_methods[] = { #define EventHandlerCallRef_tp_alloc PyType_GenericAlloc -static PyObject *EventHandlerCallRef_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *EventHandlerCallRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; EventHandlerCallRef itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, EventHandlerCallRef_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((EventHandlerCallRefObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventHandlerCallRef_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((EventHandlerCallRefObject *)_self)->ob_itself = itself; + return _self; } #define EventHandlerCallRef_tp_free PyObject_Del @@ -1300,6 +1306,7 @@ PyObject *EventTargetRef_New(EventTargetRef itself) it->ob_itself = itself; return (PyObject *)it; } + int EventTargetRef_Convert(PyObject *v, EventTargetRef *p_itself) { if (!EventTargetRef_Check(v)) @@ -1340,15 +1347,15 @@ static PyObject *EventTargetRef_InstallEventHandler(EventTargetRefObject *_self, OSStatus _err; if (!PyArg_ParseTuple(_args, "O&O", EventTypeSpec_Convert, &inSpec, &callback)) - return NULL; + return NULL; _err = InstallEventHandler(_self->ob_itself, myEventHandlerUPP, 1, &inSpec, (void *)callback, &outRef); if (_err != noErr) return PyMac_Error(_err); _res = EventHandlerRef_New(outRef); if (_res != NULL) { - ((EventHandlerRefObject*)_res)->ob_callback = callback; - Py_INCREF(callback); + ((EventHandlerRefObject*)_res)->ob_callback = callback; + Py_INCREF(callback); } return _res; } @@ -1373,16 +1380,16 @@ static PyMethodDef EventTargetRef_methods[] = { #define EventTargetRef_tp_alloc PyType_GenericAlloc -static PyObject *EventTargetRef_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *EventTargetRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; EventTargetRef itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, EventTargetRef_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((EventTargetRefObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventTargetRef_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((EventTargetRefObject *)_self)->ob_itself = itself; + return _self; } #define EventTargetRef_tp_free PyObject_Del @@ -1454,6 +1461,7 @@ PyObject *EventHotKeyRef_New(EventHotKeyRef itself) it->ob_itself = itself; return (PyObject *)it; } + int EventHotKeyRef_Convert(PyObject *v, EventHotKeyRef *p_itself) { if (!EventHotKeyRef_Check(v)) @@ -1502,16 +1510,16 @@ static PyMethodDef EventHotKeyRef_methods[] = { #define EventHotKeyRef_tp_alloc PyType_GenericAlloc -static PyObject *EventHotKeyRef_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *EventHotKeyRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; EventHotKeyRef itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, EventHotKeyRef_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((EventHotKeyRefObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventHotKeyRef_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((EventHotKeyRefObject *)_self)->ob_itself = itself; + return _self; } #define EventHotKeyRef_tp_free PyObject_Del diff --git a/Mac/Modules/cf/_CFmodule.c b/Mac/Modules/cf/_CFmodule.c index 04e1624..22e9676 100644 --- a/Mac/Modules/cf/_CFmodule.c +++ b/Mac/Modules/cf/_CFmodule.c @@ -84,19 +84,19 @@ extern int _OptionalCFURLRefObj_Convert(PyObject *, CFURLRef *); PyObject *CFRange_New(CFRange *itself) { - return Py_BuildValue("ll", (long)itself->location, (long)itself->length); + return Py_BuildValue("ll", (long)itself->location, (long)itself->length); } int CFRange_Convert(PyObject *v, CFRange *p_itself) { - long location, length; - - if( !PyArg_ParseTuple(v, "ll", &location, &length) ) - return 0; - p_itself->location = (CFIndex)location; - p_itself->length = (CFIndex)length; - return 1; + long location, length; + + if( !PyArg_ParseTuple(v, "ll", &location, &length) ) + return 0; + p_itself->location = (CFIndex)location; + p_itself->length = (CFIndex)length; + return 1; } /* Optional CFURL argument or None (passed as NULL) */ @@ -104,8 +104,8 @@ int OptionalCFURLRefObj_Convert(PyObject *v, CFURLRef *p_itself) { if ( v == Py_None ) { - p_itself = NULL; - return 1; + p_itself = NULL; + return 1; } return CFURLRefObj_Convert(v, p_itself); } @@ -138,6 +138,7 @@ PyObject *CFTypeRefObj_New(CFTypeRef itself) it->ob_freeit = CFRelease; return (PyObject *)it; } + int CFTypeRefObj_Convert(PyObject *v, CFTypeRef *p_itself) { @@ -322,16 +323,16 @@ static PyObject *CFTypeRefObj_CFPropertyListCreateFromXMLData(CFTypeRefObject *_ CFStringRef errorString; if (!PyArg_ParseTuple(_args, "l", &mutabilityOption)) - return NULL; + return NULL; _rv = CFPropertyListCreateFromXMLData((CFAllocatorRef)NULL, _self->ob_itself, mutabilityOption, &errorString); if (errorString) - CFRelease(errorString); + CFRelease(errorString); if (_rv == NULL) { - PyErr_SetString(PyExc_RuntimeError, "Parse error in XML data"); - return NULL; + PyErr_SetString(PyExc_RuntimeError, "Parse error in XML data"); + return NULL; } _res = Py_BuildValue("O&", CFTypeRefObj_New, _rv); @@ -399,14 +400,14 @@ static int CFTypeRefObj_hash(CFTypeRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } -static int CFTypeRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +static int CFTypeRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) { CFTypeRef itself; char *kw[] = {"itself", 0}; - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) { - ((CFTypeRefObject *)self)->ob_itself = itself; + ((CFTypeRefObject *)_self)->ob_itself = itself; return 0; } return -1; @@ -414,7 +415,7 @@ static int CFTypeRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) #define CFTypeRefObj_tp_alloc PyType_GenericAlloc -static PyObject *CFTypeRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *CFTypeRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { PyObject *self; if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; @@ -500,6 +501,7 @@ PyObject *CFArrayRefObj_New(CFArrayRef itself) it->ob_freeit = CFRelease; return (PyObject *)it; } + int CFArrayRefObj_Convert(PyObject *v, CFArrayRef *p_itself) { @@ -602,21 +604,21 @@ static int CFArrayRefObj_hash(CFArrayRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } -static int CFArrayRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +static int CFArrayRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) { CFArrayRef itself; char *kw[] = {"itself", 0}; - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFArrayRefObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFArrayRefObj_Convert, &itself)) { - ((CFArrayRefObject *)self)->ob_itself = itself; + ((CFArrayRefObject *)_self)->ob_itself = itself; return 0; } /* Any CFTypeRef descendent is allowed as initializer too */ - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) { - ((CFArrayRefObject *)self)->ob_itself = itself; + ((CFArrayRefObject *)_self)->ob_itself = itself; return 0; } return -1; @@ -624,7 +626,7 @@ static int CFArrayRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) #define CFArrayRefObj_tp_alloc PyType_GenericAlloc -static PyObject *CFArrayRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *CFArrayRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { PyObject *self; if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; @@ -710,6 +712,7 @@ PyObject *CFMutableArrayRefObj_New(CFMutableArrayRef itself) it->ob_freeit = CFRelease; return (PyObject *)it; } + int CFMutableArrayRefObj_Convert(PyObject *v, CFMutableArrayRef *p_itself) { @@ -841,21 +844,21 @@ static int CFMutableArrayRefObj_hash(CFMutableArrayRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } -static int CFMutableArrayRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +static int CFMutableArrayRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) { CFMutableArrayRef itself; char *kw[] = {"itself", 0}; - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFMutableArrayRefObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFMutableArrayRefObj_Convert, &itself)) { - ((CFMutableArrayRefObject *)self)->ob_itself = itself; + ((CFMutableArrayRefObject *)_self)->ob_itself = itself; return 0; } /* Any CFTypeRef descendent is allowed as initializer too */ - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) { - ((CFMutableArrayRefObject *)self)->ob_itself = itself; + ((CFMutableArrayRefObject *)_self)->ob_itself = itself; return 0; } return -1; @@ -863,7 +866,7 @@ static int CFMutableArrayRefObj_tp_init(PyObject *self, PyObject *args, PyObject #define CFMutableArrayRefObj_tp_alloc PyType_GenericAlloc -static PyObject *CFMutableArrayRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *CFMutableArrayRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { PyObject *self; if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; @@ -949,6 +952,7 @@ PyObject *CFDictionaryRefObj_New(CFDictionaryRef itself) it->ob_freeit = CFRelease; return (PyObject *)it; } + int CFDictionaryRefObj_Convert(PyObject *v, CFDictionaryRef *p_itself) { @@ -1033,21 +1037,21 @@ static int CFDictionaryRefObj_hash(CFDictionaryRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } -static int CFDictionaryRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +static int CFDictionaryRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) { CFDictionaryRef itself; char *kw[] = {"itself", 0}; - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFDictionaryRefObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFDictionaryRefObj_Convert, &itself)) { - ((CFDictionaryRefObject *)self)->ob_itself = itself; + ((CFDictionaryRefObject *)_self)->ob_itself = itself; return 0; } /* Any CFTypeRef descendent is allowed as initializer too */ - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) { - ((CFDictionaryRefObject *)self)->ob_itself = itself; + ((CFDictionaryRefObject *)_self)->ob_itself = itself; return 0; } return -1; @@ -1055,7 +1059,7 @@ static int CFDictionaryRefObj_tp_init(PyObject *self, PyObject *args, PyObject * #define CFDictionaryRefObj_tp_alloc PyType_GenericAlloc -static PyObject *CFDictionaryRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *CFDictionaryRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { PyObject *self; if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; @@ -1141,6 +1145,7 @@ PyObject *CFMutableDictionaryRefObj_New(CFMutableDictionaryRef itself) it->ob_freeit = CFRelease; return (PyObject *)it; } + int CFMutableDictionaryRefObj_Convert(PyObject *v, CFMutableDictionaryRef *p_itself) { @@ -1209,21 +1214,21 @@ static int CFMutableDictionaryRefObj_hash(CFMutableDictionaryRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } -static int CFMutableDictionaryRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +static int CFMutableDictionaryRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) { CFMutableDictionaryRef itself; char *kw[] = {"itself", 0}; - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFMutableDictionaryRefObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFMutableDictionaryRefObj_Convert, &itself)) { - ((CFMutableDictionaryRefObject *)self)->ob_itself = itself; + ((CFMutableDictionaryRefObject *)_self)->ob_itself = itself; return 0; } /* Any CFTypeRef descendent is allowed as initializer too */ - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) { - ((CFMutableDictionaryRefObject *)self)->ob_itself = itself; + ((CFMutableDictionaryRefObject *)_self)->ob_itself = itself; return 0; } return -1; @@ -1231,7 +1236,7 @@ static int CFMutableDictionaryRefObj_tp_init(PyObject *self, PyObject *args, PyO #define CFMutableDictionaryRefObj_tp_alloc PyType_GenericAlloc -static PyObject *CFMutableDictionaryRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *CFMutableDictionaryRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { PyObject *self; if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; @@ -1317,6 +1322,7 @@ PyObject *CFDataRefObj_New(CFDataRef itself) it->ob_freeit = CFRelease; return (PyObject *)it; } + int CFDataRefObj_Convert(PyObject *v, CFDataRef *p_itself) { @@ -1439,21 +1445,21 @@ static int CFDataRefObj_hash(CFDataRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } -static int CFDataRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +static int CFDataRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) { CFDataRef itself; char *kw[] = {"itself", 0}; - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFDataRefObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFDataRefObj_Convert, &itself)) { - ((CFDataRefObject *)self)->ob_itself = itself; + ((CFDataRefObject *)_self)->ob_itself = itself; return 0; } /* Any CFTypeRef descendent is allowed as initializer too */ - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) { - ((CFDataRefObject *)self)->ob_itself = itself; + ((CFDataRefObject *)_self)->ob_itself = itself; return 0; } return -1; @@ -1461,7 +1467,7 @@ static int CFDataRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) #define CFDataRefObj_tp_alloc PyType_GenericAlloc -static PyObject *CFDataRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *CFDataRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { PyObject *self; if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; @@ -1547,6 +1553,7 @@ PyObject *CFMutableDataRefObj_New(CFMutableDataRef itself) it->ob_freeit = CFRelease; return (PyObject *)it; } + int CFMutableDataRefObj_Convert(PyObject *v, CFMutableDataRef *p_itself) { @@ -1703,21 +1710,21 @@ static int CFMutableDataRefObj_hash(CFMutableDataRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } -static int CFMutableDataRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +static int CFMutableDataRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) { CFMutableDataRef itself; char *kw[] = {"itself", 0}; - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFMutableDataRefObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFMutableDataRefObj_Convert, &itself)) { - ((CFMutableDataRefObject *)self)->ob_itself = itself; + ((CFMutableDataRefObject *)_self)->ob_itself = itself; return 0; } /* Any CFTypeRef descendent is allowed as initializer too */ - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) { - ((CFMutableDataRefObject *)self)->ob_itself = itself; + ((CFMutableDataRefObject *)_self)->ob_itself = itself; return 0; } return -1; @@ -1725,7 +1732,7 @@ static int CFMutableDataRefObj_tp_init(PyObject *self, PyObject *args, PyObject #define CFMutableDataRefObj_tp_alloc PyType_GenericAlloc -static PyObject *CFMutableDataRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *CFMutableDataRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { PyObject *self; if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; @@ -1811,6 +1818,7 @@ PyObject *CFStringRefObj_New(CFStringRef itself) it->ob_freeit = CFRelease; return (PyObject *)it; } + int CFStringRefObj_Convert(PyObject *v, CFStringRef *p_itself) { @@ -1818,19 +1826,19 @@ int CFStringRefObj_Convert(PyObject *v, CFStringRef *p_itself) if (PyString_Check(v)) { char *cStr; if (!PyArg_Parse(v, "es", "ascii", &cStr)) - return NULL; - *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingASCII); - return 1; + return NULL; + *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingASCII); + return 1; } if (PyUnicode_Check(v)) { - /* We use the CF types here, if Python was configured differently that will give an error */ - CFIndex size = PyUnicode_GetSize(v); - UniChar *unichars = PyUnicode_AsUnicode(v); - if (!unichars) return 0; - *p_itself = CFStringCreateWithCharacters((CFAllocatorRef)NULL, unichars, size); - return 1; + /* We use the CF types here, if Python was configured differently that will give an error */ + CFIndex size = PyUnicode_GetSize(v); + UniChar *unichars = PyUnicode_AsUnicode(v); + if (!unichars) return 0; + *p_itself = CFStringCreateWithCharacters((CFAllocatorRef)NULL, unichars, size); + return 1; } - + if (!CFStringRefObj_Check(v)) { @@ -2335,10 +2343,10 @@ static PyObject *CFStringRefObj_CFStringGetString(CFStringRefObject *_self, PyOb if( data == NULL ) return PyErr_NoMemory(); if ( CFStringGetCString(_self->ob_itself, data, size, 0) ) { - _res = (PyObject *)PyString_FromString(data); + _res = (PyObject *)PyString_FromString(data); } else { - PyErr_SetString(PyExc_RuntimeError, "CFStringGetCString could not fit the string"); - _res = NULL; + PyErr_SetString(PyExc_RuntimeError, "CFStringGetCString could not fit the string"); + _res = NULL; } free(data); return _res; @@ -2444,21 +2452,21 @@ static int CFStringRefObj_hash(CFStringRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } -static int CFStringRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +static int CFStringRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) { CFStringRef itself; char *kw[] = {"itself", 0}; - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFStringRefObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFStringRefObj_Convert, &itself)) { - ((CFStringRefObject *)self)->ob_itself = itself; + ((CFStringRefObject *)_self)->ob_itself = itself; return 0; } /* Any CFTypeRef descendent is allowed as initializer too */ - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) { - ((CFStringRefObject *)self)->ob_itself = itself; + ((CFStringRefObject *)_self)->ob_itself = itself; return 0; } return -1; @@ -2466,7 +2474,7 @@ static int CFStringRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds #define CFStringRefObj_tp_alloc PyType_GenericAlloc -static PyObject *CFStringRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *CFStringRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { PyObject *self; if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; @@ -2552,6 +2560,7 @@ PyObject *CFMutableStringRefObj_New(CFMutableStringRef itself) it->ob_freeit = CFRelease; return (PyObject *)it; } + int CFMutableStringRefObj_Convert(PyObject *v, CFMutableStringRef *p_itself) { @@ -2831,21 +2840,21 @@ static int CFMutableStringRefObj_hash(CFMutableStringRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } -static int CFMutableStringRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +static int CFMutableStringRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) { CFMutableStringRef itself; char *kw[] = {"itself", 0}; - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFMutableStringRefObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFMutableStringRefObj_Convert, &itself)) { - ((CFMutableStringRefObject *)self)->ob_itself = itself; + ((CFMutableStringRefObject *)_self)->ob_itself = itself; return 0; } /* Any CFTypeRef descendent is allowed as initializer too */ - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) { - ((CFMutableStringRefObject *)self)->ob_itself = itself; + ((CFMutableStringRefObject *)_self)->ob_itself = itself; return 0; } return -1; @@ -2853,7 +2862,7 @@ static int CFMutableStringRefObj_tp_init(PyObject *self, PyObject *args, PyObjec #define CFMutableStringRefObj_tp_alloc PyType_GenericAlloc -static PyObject *CFMutableStringRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *CFMutableStringRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { PyObject *self; if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; @@ -2939,6 +2948,7 @@ PyObject *CFURLRefObj_New(CFURLRef itself) it->ob_freeit = CFRelease; return (PyObject *)it; } + int CFURLRefObj_Convert(PyObject *v, CFURLRef *p_itself) { @@ -3482,21 +3492,21 @@ static int CFURLRefObj_hash(CFURLRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } -static int CFURLRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +static int CFURLRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) { CFURLRef itself; char *kw[] = {"itself", 0}; - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFURLRefObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFURLRefObj_Convert, &itself)) { - ((CFURLRefObject *)self)->ob_itself = itself; + ((CFURLRefObject *)_self)->ob_itself = itself; return 0; } /* Any CFTypeRef descendent is allowed as initializer too */ - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) { - ((CFURLRefObject *)self)->ob_itself = itself; + ((CFURLRefObject *)_self)->ob_itself = itself; return 0; } return -1; @@ -3504,7 +3514,7 @@ static int CFURLRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) #define CFURLRefObj_tp_alloc PyType_GenericAlloc -static PyObject *CFURLRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *CFURLRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { PyObject *self; if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; @@ -4678,17 +4688,17 @@ static PyObject *CF_toCF(PyObject *_self, PyObject *_args) CFTypeID typeid; if (!PyArg_ParseTuple(_args, "O&", PyCF_Python2CF, &rv)) - return NULL; + return NULL; typeid = CFGetTypeID(rv); if (typeid == CFStringGetTypeID()) - return Py_BuildValue("O&", CFStringRefObj_New, rv); + return Py_BuildValue("O&", CFStringRefObj_New, rv); if (typeid == CFArrayGetTypeID()) - return Py_BuildValue("O&", CFArrayRefObj_New, rv); + return Py_BuildValue("O&", CFArrayRefObj_New, rv); if (typeid == CFDictionaryGetTypeID()) - return Py_BuildValue("O&", CFDictionaryRefObj_New, rv); + return Py_BuildValue("O&", CFDictionaryRefObj_New, rv); if (typeid == CFURLGetTypeID()) - return Py_BuildValue("O&", CFURLRefObj_New, rv); + return Py_BuildValue("O&", CFURLRefObj_New, rv); _res = Py_BuildValue("O&", CFTypeRefObj_New, rv); return _res; @@ -4817,42 +4827,42 @@ static PyMethodDef CF_methods[] = { /* Routines to convert any CF type to/from the corresponding CFxxxObj */ PyObject *CFObj_New(CFTypeRef itself) { - if (itself == NULL) - { - PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); - return NULL; - } - if (CFGetTypeID(itself) == CFArrayGetTypeID()) return CFArrayRefObj_New((CFArrayRef)itself); - if (CFGetTypeID(itself) == CFDictionaryGetTypeID()) return CFDictionaryRefObj_New((CFDictionaryRef)itself); - if (CFGetTypeID(itself) == CFDataGetTypeID()) return CFDataRefObj_New((CFDataRef)itself); - if (CFGetTypeID(itself) == CFStringGetTypeID()) return CFStringRefObj_New((CFStringRef)itself); - if (CFGetTypeID(itself) == CFURLGetTypeID()) return CFURLRefObj_New((CFURLRef)itself); - /* XXXX Or should we use PyCF_CF2Python here?? */ - return CFTypeRefObj_New(itself); + if (itself == NULL) + { + PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); + return NULL; + } + if (CFGetTypeID(itself) == CFArrayGetTypeID()) return CFArrayRefObj_New((CFArrayRef)itself); + if (CFGetTypeID(itself) == CFDictionaryGetTypeID()) return CFDictionaryRefObj_New((CFDictionaryRef)itself); + if (CFGetTypeID(itself) == CFDataGetTypeID()) return CFDataRefObj_New((CFDataRef)itself); + if (CFGetTypeID(itself) == CFStringGetTypeID()) return CFStringRefObj_New((CFStringRef)itself); + if (CFGetTypeID(itself) == CFURLGetTypeID()) return CFURLRefObj_New((CFURLRef)itself); + /* XXXX Or should we use PyCF_CF2Python here?? */ + return CFTypeRefObj_New(itself); } int CFObj_Convert(PyObject *v, CFTypeRef *p_itself) { - if (v == Py_None) { *p_itself = NULL; return 1; } - /* Check for other CF objects here */ - - if (!CFTypeRefObj_Check(v) && - !CFArrayRefObj_Check(v) && - !CFMutableArrayRefObj_Check(v) && - !CFDictionaryRefObj_Check(v) && - !CFMutableDictionaryRefObj_Check(v) && - !CFDataRefObj_Check(v) && - !CFMutableDataRefObj_Check(v) && - !CFStringRefObj_Check(v) && - !CFMutableStringRefObj_Check(v) && - !CFURLRefObj_Check(v) ) - { - /* XXXX Or should we use PyCF_Python2CF here?? */ - PyErr_SetString(PyExc_TypeError, "CF object required"); - return 0; - } - *p_itself = ((CFTypeRefObject *)v)->ob_itself; - return 1; + if (v == Py_None) { *p_itself = NULL; return 1; } + /* Check for other CF objects here */ + + if (!CFTypeRefObj_Check(v) && + !CFArrayRefObj_Check(v) && + !CFMutableArrayRefObj_Check(v) && + !CFDictionaryRefObj_Check(v) && + !CFMutableDictionaryRefObj_Check(v) && + !CFDataRefObj_Check(v) && + !CFMutableDataRefObj_Check(v) && + !CFStringRefObj_Check(v) && + !CFMutableStringRefObj_Check(v) && + !CFURLRefObj_Check(v) ) + { + /* XXXX Or should we use PyCF_Python2CF here?? */ + PyErr_SetString(PyExc_TypeError, "CF object required"); + return 0; + } + *p_itself = ((CFTypeRefObject *)v)->ob_itself; + return 1; } diff --git a/Mac/Modules/cf/cfsupport.py b/Mac/Modules/cf/cfsupport.py index 87b9a6f..800581a 100644 --- a/Mac/Modules/cf/cfsupport.py +++ b/Mac/Modules/cf/cfsupport.py @@ -315,18 +315,18 @@ class MyGlobalObjectDefinition(PEP253Mixin, GlobalObjectDefinition): Output("%s itself;", self.itselftype) Output("char *kw[] = {\"itself\", 0};") Output() - Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"O&\", kw, %s_Convert, &itself))", + Output("if (PyArg_ParseTupleAndKeywords(_args, _kwds, \"O&\", kw, %s_Convert, &itself))", self.prefix) OutLbrace() - Output("((%s *)self)->ob_itself = itself;", self.objecttype) + Output("((%s *)_self)->ob_itself = itself;", self.objecttype) Output("return 0;") OutRbrace() if self.prefix != 'CFTypeRefObj': Output() Output("/* Any CFTypeRef descendent is allowed as initializer too */") - Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"O&\", kw, CFTypeRefObj_Convert, &itself))") + Output("if (PyArg_ParseTupleAndKeywords(_args, _kwds, \"O&\", kw, CFTypeRefObj_Convert, &itself))") OutLbrace() - Output("((%s *)self)->ob_itself = itself;", self.objecttype) + Output("((%s *)_self)->ob_itself = itself;", self.objecttype) Output("return 0;") OutRbrace() Output("return -1;") diff --git a/Mac/Modules/cg/_CGmodule.c b/Mac/Modules/cg/_CGmodule.c index 378bfa4..8115614 100755 --- a/Mac/Modules/cg/_CGmodule.c +++ b/Mac/Modules/cg/_CGmodule.c @@ -26,67 +26,67 @@ extern int GrafObj_Convert(PyObject *, GrafPtr *); PyObject *CGPoint_New(CGPoint *itself) { - return Py_BuildValue("(ff)", - itself->x, - itself->y); + return Py_BuildValue("(ff)", + itself->x, + itself->y); } int CGPoint_Convert(PyObject *v, CGPoint *p_itself) { - if( !PyArg_Parse(v, "(ff)", - &p_itself->x, - &p_itself->y) ) - return 0; - return 1; + if( !PyArg_Parse(v, "(ff)", + &p_itself->x, + &p_itself->y) ) + return 0; + return 1; } PyObject *CGRect_New(CGRect *itself) { - return Py_BuildValue("(ffff)", - itself->origin.x, - itself->origin.y, - itself->size.width, - itself->size.height); + return Py_BuildValue("(ffff)", + itself->origin.x, + itself->origin.y, + itself->size.width, + itself->size.height); } int CGRect_Convert(PyObject *v, CGRect *p_itself) { - if( !PyArg_Parse(v, "(ffff)", - &p_itself->origin.x, - &p_itself->origin.y, - &p_itself->size.width, - &p_itself->size.height) ) - return 0; - return 1; + if( !PyArg_Parse(v, "(ffff)", + &p_itself->origin.x, + &p_itself->origin.y, + &p_itself->size.width, + &p_itself->size.height) ) + return 0; + return 1; } PyObject *CGAffineTransform_New(CGAffineTransform *itself) { - return Py_BuildValue("(ffffff)", - itself->a, - itself->b, - itself->c, - itself->d, - itself->tx, - itself->ty); + return Py_BuildValue("(ffffff)", + itself->a, + itself->b, + itself->c, + itself->d, + itself->tx, + itself->ty); } int CGAffineTransform_Convert(PyObject *v, CGAffineTransform *p_itself) { - if( !PyArg_Parse(v, "(ffffff)", - &p_itself->a, - &p_itself->b, - &p_itself->c, - &p_itself->d, - &p_itself->tx, - &p_itself->ty) ) - return 0; - return 1; + if( !PyArg_Parse(v, "(ffffff)", + &p_itself->a, + &p_itself->b, + &p_itself->c, + &p_itself->d, + &p_itself->tx, + &p_itself->ty) ) + return 0; + return 1; } static PyObject *CG_Error; @@ -110,6 +110,7 @@ PyObject *CGContextRefObj_New(CGContextRef itself) it->ob_itself = itself; return (PyObject *)it; } + int CGContextRefObj_Convert(PyObject *v, CGContextRef *p_itself) { if (!CGContextRefObj_Check(v)) @@ -1191,16 +1192,16 @@ static PyMethodDef CGContextRefObj_methods[] = { #define CGContextRefObj_tp_alloc PyType_GenericAlloc -static PyObject *CGContextRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *CGContextRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; CGContextRef itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CGContextRefObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((CGContextRefObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CGContextRefObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((CGContextRefObject *)_self)->ob_itself = itself; + return _self; } #define CGContextRefObj_tp_free PyObject_Del @@ -1261,11 +1262,11 @@ static PyObject *CG_CreateCGContextForPort(PyObject *_self, PyObject *_args) OSStatus _err; if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port)) - return NULL; + return NULL; _err = CreateCGContextForPort(port, &ctx); if (_err != noErr) - if (_err != noErr) return PyMac_Error(_err); + if (_err != noErr) return PyMac_Error(_err); _res = Py_BuildValue("O&", CGContextRefObj_New, ctx); return _res; diff --git a/Mac/Modules/cm/_Cmmodule.c b/Mac/Modules/cm/_Cmmodule.c index 95a36c0..3c6be6b 100644 --- a/Mac/Modules/cm/_Cmmodule.c +++ b/Mac/Modules/cm/_Cmmodule.c @@ -36,21 +36,21 @@ static PyObject * CmpDesc_New(ComponentDescription *itself) { - return Py_BuildValue("O&O&O&ll", - PyMac_BuildOSType, itself->componentType, - PyMac_BuildOSType, itself->componentSubType, - PyMac_BuildOSType, itself->componentManufacturer, - itself->componentFlags, itself->componentFlagsMask); + return Py_BuildValue("O&O&O&ll", + PyMac_BuildOSType, itself->componentType, + PyMac_BuildOSType, itself->componentSubType, + PyMac_BuildOSType, itself->componentManufacturer, + itself->componentFlags, itself->componentFlagsMask); } static int CmpDesc_Convert(PyObject *v, ComponentDescription *p_itself) { - return PyArg_ParseTuple(v, "O&O&O&ll", - PyMac_GetOSType, &p_itself->componentType, - PyMac_GetOSType, &p_itself->componentSubType, - PyMac_GetOSType, &p_itself->componentManufacturer, - &p_itself->componentFlags, &p_itself->componentFlagsMask); + return PyArg_ParseTuple(v, "O&O&O&ll", + PyMac_GetOSType, &p_itself->componentType, + PyMac_GetOSType, &p_itself->componentSubType, + PyMac_GetOSType, &p_itself->componentManufacturer, + &p_itself->componentFlags, &p_itself->componentFlagsMask); } @@ -71,14 +71,15 @@ PyObject *CmpInstObj_New(ComponentInstance itself) { ComponentInstanceObject *it; if (itself == NULL) { - PyErr_SetString(Cm_Error,"NULL ComponentInstance"); - return NULL; - } + PyErr_SetString(Cm_Error,"NULL ComponentInstance"); + return NULL; + } it = PyObject_NEW(ComponentInstanceObject, &ComponentInstance_Type); if (it == NULL) return NULL; it->ob_itself = itself; return (PyObject *)it; } + int CmpInstObj_Convert(PyObject *v, ComponentInstance *p_itself) { if (!CmpInstObj_Check(v)) @@ -260,16 +261,16 @@ static PyMethodDef CmpInstObj_methods[] = { #define CmpInstObj_tp_alloc PyType_GenericAlloc -static PyObject *CmpInstObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *CmpInstObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; ComponentInstance itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CmpInstObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((ComponentInstanceObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CmpInstObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((ComponentInstanceObject *)_self)->ob_itself = itself; + return _self; } #define CmpInstObj_tp_free PyObject_Del @@ -337,21 +338,22 @@ PyObject *CmpObj_New(Component itself) { ComponentObject *it; if (itself == NULL) { - /* XXXX Or should we return None? */ - PyErr_SetString(Cm_Error,"No such component"); - return NULL; - } + /* XXXX Or should we return None? */ + PyErr_SetString(Cm_Error,"No such component"); + return NULL; + } it = PyObject_NEW(ComponentObject, &Component_Type); if (it == NULL) return NULL; it->ob_itself = itself; return (PyObject *)it; } + int CmpObj_Convert(PyObject *v, Component *p_itself) { if ( v == Py_None ) { - *p_itself = 0; - return 1; - } + *p_itself = 0; + return 1; + } if (!CmpObj_Check(v)) { PyErr_SetString(PyExc_TypeError, "Component required"); @@ -693,16 +695,16 @@ static PyMethodDef CmpObj_methods[] = { #define CmpObj_tp_alloc PyType_GenericAlloc -static PyObject *CmpObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *CmpObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; Component itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CmpObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((ComponentObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CmpObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((ComponentObject *)_self)->ob_itself = itself; + return _self; } #define CmpObj_tp_free PyObject_Del @@ -913,10 +915,10 @@ void init_Cm(void) - PyMac_INIT_TOOLBOX_OBJECT_NEW(Component, CmpObj_New); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Component, CmpObj_Convert); - PyMac_INIT_TOOLBOX_OBJECT_NEW(ComponentInstance, CmpInstObj_New); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ComponentInstance, CmpInstObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(Component, CmpObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Component, CmpObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(ComponentInstance, CmpInstObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ComponentInstance, CmpInstObj_Convert); m = Py_InitModule("_Cm", Cm_methods); diff --git a/Mac/Modules/ctl/_Ctlmodule.c b/Mac/Modules/ctl/_Ctlmodule.c index a7073a6..c6287e0 100644 --- a/Mac/Modules/ctl/_Ctlmodule.c +++ b/Mac/Modules/ctl/_Ctlmodule.c @@ -40,19 +40,19 @@ static PyObject * ControlFontStyle_New(ControlFontStyleRec *itself) { - return Py_BuildValue("hhhhhhO&O&", itself->flags, itself->font, - itself->size, itself->style, itself->mode, itself->just, - QdRGB_New, &itself->foreColor, QdRGB_New, &itself->backColor); + return Py_BuildValue("hhhhhhO&O&", itself->flags, itself->font, + itself->size, itself->style, itself->mode, itself->just, + QdRGB_New, &itself->foreColor, QdRGB_New, &itself->backColor); } #endif static int ControlFontStyle_Convert(PyObject *v, ControlFontStyleRec *itself) { - return PyArg_Parse(v, "(hhhhhhO&O&)", &itself->flags, - &itself->font, &itself->size, &itself->style, &itself->mode, - &itself->just, QdRGB_Convert, &itself->foreColor, - QdRGB_Convert, &itself->backColor); + return PyArg_Parse(v, "(hhhhhhO&O&)", &itself->flags, + &itself->font, &itself->size, &itself->style, &itself->mode, + &itself->just, QdRGB_Convert, &itself->foreColor, + QdRGB_Convert, &itself->backColor); } /* @@ -62,13 +62,13 @@ static PyObject * PyControlID_New(ControlID *itself) { - return Py_BuildValue("O&l", PyMac_BuildOSType, itself->signature, itself->id); + return Py_BuildValue("O&l", PyMac_BuildOSType, itself->signature, itself->id); } static int PyControlID_Convert(PyObject *v, ControlID *itself) { - return PyArg_Parse(v, "(O&l)", PyMac_GetOSType, &itself->signature, &itself->id); + return PyArg_Parse(v, "(O&l)", PyMac_GetOSType, &itself->signature, &itself->id); } /* @@ -77,40 +77,40 @@ PyControlID_Convert(PyObject *v, ControlID *itself) static int DataBrowserTableViewColumnDesc_Convert(PyObject *v, DataBrowserTableViewColumnDesc *itself) { - return PyArg_Parse(v, "(lO&l)", - &itself->propertyID, - PyMac_GetOSType, &itself->propertyType, - &itself->propertyFlags); + return PyArg_Parse(v, "(lO&l)", + &itself->propertyID, + PyMac_GetOSType, &itself->propertyType, + &itself->propertyFlags); } static int ControlButtonContentInfo_Convert(PyObject *v, ControlButtonContentInfo *itself) { - return PyArg_Parse(v, "(hO&)", - &itself->contentType, - OptResObj_Convert, &itself->u.iconSuite); + return PyArg_Parse(v, "(hO&)", + &itself->contentType, + OptResObj_Convert, &itself->u.iconSuite); } static int DataBrowserListViewHeaderDesc_Convert(PyObject *v, DataBrowserListViewHeaderDesc *itself) { - itself->version = kDataBrowserListViewLatestHeaderDesc; - return PyArg_Parse(v, "(HHhO&HO&O&)", - &itself->minimumWidth, - &itself->maximumWidth, - &itself->titleOffset, - CFStringRefObj_Convert, &itself->titleString, - &itself->initialOrder, - ControlFontStyle_Convert, &itself->btnFontStyle, - ControlButtonContentInfo_Convert, &itself->btnContentInfo); + itself->version = kDataBrowserListViewLatestHeaderDesc; + return PyArg_Parse(v, "(HHhO&HO&O&)", + &itself->minimumWidth, + &itself->maximumWidth, + &itself->titleOffset, + CFStringRefObj_Convert, &itself->titleString, + &itself->initialOrder, + ControlFontStyle_Convert, &itself->btnFontStyle, + ControlButtonContentInfo_Convert, &itself->btnContentInfo); } static int DataBrowserListViewColumnDesc_Convert(PyObject *v, DataBrowserListViewColumnDesc *itself) { - return PyArg_Parse(v, "(O&O&)", - DataBrowserTableViewColumnDesc_Convert, &itself->propertyDesc, - DataBrowserListViewHeaderDesc_Convert, &itself->headerBtnDesc); + return PyArg_Parse(v, "(O&O&)", + DataBrowserTableViewColumnDesc_Convert, &itself->propertyDesc, + DataBrowserListViewHeaderDesc_Convert, &itself->headerBtnDesc); } /* TrackControl and HandleControlClick callback support */ @@ -125,8 +125,8 @@ static ControlUserPaneIdleUPP myidleproc_upp; static ControlUserPaneHitTestUPP myhittestproc_upp; static ControlUserPaneTrackingUPP mytrackingproc_upp; -static int settrackfunc(PyObject *); /* forward */ -static void clrtrackfunc(void); /* forward */ +static int settrackfunc(PyObject *); /* forward */ +static void clrtrackfunc(void); /* forward */ static int setcallback(PyObject *, OSType, PyObject *, UniversalProcPtr *); static PyObject *Ctl_Error; @@ -154,6 +154,7 @@ PyObject *CtlObj_New(ControlHandle itself) it->ob_callbackdict = NULL; return (PyObject *)it; } + int CtlObj_Convert(PyObject *v, ControlHandle *p_itself) { if (!CtlObj_Check(v)) @@ -3223,16 +3224,16 @@ static PyObject *CtlObj_DisposeControl(ControlObject *_self, PyObject *_args) { PyObject *_res = NULL; - if (!PyArg_ParseTuple(_args, "")) - return NULL; - if ( _self->ob_itself ) { - SetControlReference(_self->ob_itself, (long)0); /* Make it forget about us */ - DisposeControl(_self->ob_itself); - _self->ob_itself = NULL; - } - Py_INCREF(Py_None); - _res = Py_None; - return _res; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + if ( _self->ob_itself ) { + SetControlReference(_self->ob_itself, (long)0); /* Make it forget about us */ + DisposeControl(_self->ob_itself); + _self->ob_itself = NULL; + } + Py_INCREF(Py_None); + _res = Py_None; + return _res; } @@ -3247,14 +3248,14 @@ static PyObject *CtlObj_TrackControl(ControlObject *_self, PyObject *_args) if (!PyArg_ParseTuple(_args, "O&|O", PyMac_GetPoint, &startPoint, &callback)) - return NULL; + return NULL; if (callback && callback != Py_None) { - if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1) - upp = (ControlActionUPP)-1; - else { - settrackfunc(callback); - upp = mytracker_upp; - } + if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1) + upp = (ControlActionUPP)-1; + else { + settrackfunc(callback); + upp = mytracker_upp; + } } _rv = TrackControl(_self->ob_itself, startPoint, @@ -3280,14 +3281,14 @@ static PyObject *CtlObj_HandleControlClick(ControlObject *_self, PyObject *_args PyMac_GetPoint, &startPoint, &modifiers, &callback)) - return NULL; + return NULL; if (callback && callback != Py_None) { - if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1) - upp = (ControlActionUPP)-1; - else { - settrackfunc(callback); - upp = mytracker_upp; - } + if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1) + upp = (ControlActionUPP)-1; + else { + settrackfunc(callback); + upp = mytracker_upp; + } } _rv = HandleControlClick(_self->ob_itself, startPoint, @@ -3314,16 +3315,16 @@ static PyObject *CtlObj_SetControlData(ControlObject *_self, PyObject *_args) &inPart, PyMac_GetOSType, &inTagName, &buffer, &bufferSize)) - return NULL; + return NULL; _err = SetControlData(_self->ob_itself, - inPart, - inTagName, - bufferSize, + inPart, + inTagName, + bufferSize, buffer); if (_err != noErr) - return PyMac_Error(_err); + return PyMac_Error(_err); _res = Py_None; return _res; @@ -3343,29 +3344,29 @@ static PyObject *CtlObj_GetControlData(ControlObject *_self, PyObject *_args) if (!PyArg_ParseTuple(_args, "hO&", &inPart, PyMac_GetOSType, &inTagName)) - return NULL; + return NULL; /* allocate a buffer for the data */ _err = GetControlDataSize(_self->ob_itself, - inPart, - inTagName, + inPart, + inTagName, &bufferSize); if (_err != noErr) - return PyMac_Error(_err); + return PyMac_Error(_err); buffer = PyMem_NEW(char, bufferSize); if (buffer == NULL) - return PyErr_NoMemory(); + return PyErr_NoMemory(); _err = GetControlData(_self->ob_itself, - inPart, - inTagName, - bufferSize, + inPart, + inTagName, + bufferSize, buffer, &outSize); if (_err != noErr) { - PyMem_DEL(buffer); - return PyMac_Error(_err); + PyMem_DEL(buffer); + return PyMac_Error(_err); } _res = Py_BuildValue("s#", buffer, outSize); PyMem_DEL(buffer); @@ -3386,16 +3387,16 @@ static PyObject *CtlObj_SetControlData_Handle(ControlObject *_self, PyObject *_a &inPart, PyMac_GetOSType, &inTagName, OptResObj_Convert, &buffer)) - return NULL; + return NULL; _err = SetControlData(_self->ob_itself, - inPart, - inTagName, - sizeof(buffer), + inPart, + inTagName, + sizeof(buffer), (Ptr)&buffer); if (_err != noErr) - return PyMac_Error(_err); + return PyMac_Error(_err); _res = Py_None; return _res; @@ -3414,29 +3415,29 @@ static PyObject *CtlObj_GetControlData_Handle(ControlObject *_self, PyObject *_a if (!PyArg_ParseTuple(_args, "hO&", &inPart, PyMac_GetOSType, &inTagName)) - return NULL; + return NULL; /* Check it is handle-sized */ _err = GetControlDataSize(_self->ob_itself, - inPart, - inTagName, + inPart, + inTagName, &bufferSize); if (_err != noErr) - return PyMac_Error(_err); + return PyMac_Error(_err); if (bufferSize != sizeof(Handle)) { - PyErr_SetString(Ctl_Error, "GetControlDataSize() != sizeof(Handle)"); - return NULL; + PyErr_SetString(Ctl_Error, "GetControlDataSize() != sizeof(Handle)"); + return NULL; } _err = GetControlData(_self->ob_itself, - inPart, - inTagName, - sizeof(Handle), + inPart, + inTagName, + sizeof(Handle), (Ptr)&hdl, &bufferSize); if (_err != noErr) { - return PyMac_Error(_err); + return PyMac_Error(_err); } _res = Py_BuildValue("O&", OptResObj_New, hdl); return _res; @@ -3457,18 +3458,18 @@ static PyObject *CtlObj_SetControlData_Callback(ControlObject *_self, PyObject * &inPart, PyMac_GetOSType, &inTagName, &callback)) - return NULL; + return NULL; if ( setcallback((PyObject *)_self, inTagName, callback, &c_callback) < 0 ) - return NULL; + return NULL; _err = SetControlData(_self->ob_itself, - inPart, - inTagName, - sizeof(c_callback), + inPart, + inTagName, + sizeof(c_callback), (Ptr)&c_callback); if (_err != noErr) - return PyMac_Error(_err); + return PyMac_Error(_err); _res = Py_None; return _res; @@ -3848,16 +3849,16 @@ static long CtlObj_hash(ControlObject *self) #define CtlObj_tp_alloc PyType_GenericAlloc -static PyObject *CtlObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *CtlObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; ControlHandle itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CtlObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((ControlObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CtlObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((ControlObject *)_self)->ob_itself = itself; + return _self; } #define CtlObj_tp_free PyObject_Del @@ -5379,26 +5380,26 @@ static PyObject *Ctl_CreateTabsControl(PyObject *_self, PyObject *_args) &size, &direction, &tabArrayObj)) - return NULL; + return NULL; i = PySequence_Length(tabArrayObj); if (i == -1) - return NULL; + return NULL; if (i > MAXTABS) { - PyErr_SetString(Ctl_Error, "Too many tabs"); - return NULL; + PyErr_SetString(Ctl_Error, "Too many tabs"); + return NULL; } numTabs = i; for (i=0; i<numTabs; i++) { - tabEntry = PySequence_GetItem(tabArrayObj, i); - if (tabEntry == NULL) - return NULL; - if (!PyArg_Parse(tabEntry, "(O&O&B)", - ControlButtonContentInfo_Convert, &tabArray[i].icon, - CFStringRefObj_Convert, &tabArray[i].name, - &tabArray[i].enabled - )) - return NULL; + tabEntry = PySequence_GetItem(tabArrayObj, i); + if (tabEntry == NULL) + return NULL; + if (!PyArg_Parse(tabEntry, "(O&O&B)", + ControlButtonContentInfo_Convert, &tabArray[i].icon, + CFStringRefObj_Convert, &tabArray[i].name, + &tabArray[i].enabled + )) + return NULL; } _err = CreateTabsControl(window, @@ -5529,239 +5530,239 @@ static PyMethodDef Ctl_methods[] = { static PyObject * CtlObj_NewUnmanaged(ControlHandle itself) { - ControlObject *it; - if (itself == NULL) return PyMac_Error(resNotFound); - it = PyObject_NEW(ControlObject, &Control_Type); - if (it == NULL) return NULL; - it->ob_itself = itself; - it->ob_callbackdict = NULL; - return (PyObject *)it; + ControlObject *it; + if (itself == NULL) return PyMac_Error(resNotFound); + it = PyObject_NEW(ControlObject, &Control_Type); + if (it == NULL) return NULL; + it->ob_itself = itself; + it->ob_callbackdict = NULL; + return (PyObject *)it; } static PyObject * CtlObj_WhichControl(ControlHandle c) { - PyObject *it; - - if (c == NULL) - it = Py_None; - else { - it = (PyObject *) GetControlReference(c); - /* - ** If the refcon is zero or doesn't point back to the Python object - ** the control is not ours. Return a temporary object. - */ - if (it == NULL || ((ControlObject *)it)->ob_itself != c) - return CtlObj_NewUnmanaged(c); - } - Py_INCREF(it); - return it; + PyObject *it; + + if (c == NULL) + it = Py_None; + else { + it = (PyObject *) GetControlReference(c); + /* + ** If the refcon is zero or doesn't point back to the Python object + ** the control is not ours. Return a temporary object. + */ + if (it == NULL || ((ControlObject *)it)->ob_itself != c) + return CtlObj_NewUnmanaged(c); + } + Py_INCREF(it); + return it; } static int settrackfunc(PyObject *obj) { - if (tracker) { - PyErr_SetString(Ctl_Error, "Tracker function in use"); - return 0; - } - tracker = obj; - Py_INCREF(tracker); - return 1; + if (tracker) { + PyErr_SetString(Ctl_Error, "Tracker function in use"); + return 0; + } + tracker = obj; + Py_INCREF(tracker); + return 1; } static void clrtrackfunc(void) { - Py_XDECREF(tracker); - tracker = 0; + Py_XDECREF(tracker); + tracker = 0; } static pascal void mytracker(ControlHandle ctl, short part) { - PyObject *args, *rv=0; + PyObject *args, *rv=0; - args = Py_BuildValue("(O&i)", CtlObj_WhichControl, ctl, (int)part); - if (args && tracker) { - rv = PyEval_CallObject(tracker, args); - Py_DECREF(args); - } - if (rv) - Py_DECREF(rv); - else { - PySys_WriteStderr("TrackControl or HandleControlClick: exception in tracker function\n"); - PyErr_Print(); - } + args = Py_BuildValue("(O&i)", CtlObj_WhichControl, ctl, (int)part); + if (args && tracker) { + rv = PyEval_CallObject(tracker, args); + Py_DECREF(args); + } + if (rv) + Py_DECREF(rv); + else { + PySys_WriteStderr("TrackControl or HandleControlClick: exception in tracker function\n"); + PyErr_Print(); + } } static int setcallback(PyObject *myself, OSType which, PyObject *callback, UniversalProcPtr *uppp) { - ControlObject *self = (ControlObject *)myself; - char keybuf[9]; - - if ( which == kMyControlActionProcTag ) - *uppp = (UniversalProcPtr)myactionproc_upp; - else if ( which == kControlUserPaneKeyDownProcTag ) - *uppp = (UniversalProcPtr)mykeydownproc_upp; - else if ( which == kControlUserPaneFocusProcTag ) - *uppp = (UniversalProcPtr)myfocusproc_upp; - else if ( which == kControlUserPaneDrawProcTag ) - *uppp = (UniversalProcPtr)mydrawproc_upp; - else if ( which == kControlUserPaneIdleProcTag ) - *uppp = (UniversalProcPtr)myidleproc_upp; - else if ( which == kControlUserPaneHitTestProcTag ) - *uppp = (UniversalProcPtr)myhittestproc_upp; - else if ( which == kControlUserPaneTrackingProcTag ) - *uppp = (UniversalProcPtr)mytrackingproc_upp; - else - return -1; - /* Only now do we test for clearing of the callback: */ - if ( callback == Py_None ) - *uppp = NULL; - /* Create the dict if it doesn't exist yet (so we don't get such a dict for every control) */ - if ( self->ob_callbackdict == NULL ) - if ( (self->ob_callbackdict = PyDict_New()) == NULL ) - return -1; - /* And store the Python callback */ - sprintf(keybuf, "%x", (unsigned)which); - if (PyDict_SetItemString(self->ob_callbackdict, keybuf, callback) < 0) - return -1; - return 0; + ControlObject *self = (ControlObject *)myself; + char keybuf[9]; + + if ( which == kMyControlActionProcTag ) + *uppp = (UniversalProcPtr)myactionproc_upp; + else if ( which == kControlUserPaneKeyDownProcTag ) + *uppp = (UniversalProcPtr)mykeydownproc_upp; + else if ( which == kControlUserPaneFocusProcTag ) + *uppp = (UniversalProcPtr)myfocusproc_upp; + else if ( which == kControlUserPaneDrawProcTag ) + *uppp = (UniversalProcPtr)mydrawproc_upp; + else if ( which == kControlUserPaneIdleProcTag ) + *uppp = (UniversalProcPtr)myidleproc_upp; + else if ( which == kControlUserPaneHitTestProcTag ) + *uppp = (UniversalProcPtr)myhittestproc_upp; + else if ( which == kControlUserPaneTrackingProcTag ) + *uppp = (UniversalProcPtr)mytrackingproc_upp; + else + return -1; + /* Only now do we test for clearing of the callback: */ + if ( callback == Py_None ) + *uppp = NULL; + /* Create the dict if it doesn't exist yet (so we don't get such a dict for every control) */ + if ( self->ob_callbackdict == NULL ) + if ( (self->ob_callbackdict = PyDict_New()) == NULL ) + return -1; + /* And store the Python callback */ + sprintf(keybuf, "%x", (unsigned)which); + if (PyDict_SetItemString(self->ob_callbackdict, keybuf, callback) < 0) + return -1; + return 0; } static PyObject * callcallback(ControlObject *self, OSType which, PyObject *arglist) { - char keybuf[9]; - PyObject *func, *rv; - - sprintf(keybuf, "%x", (unsigned)which); - if ( self->ob_callbackdict == NULL || - (func = PyDict_GetItemString(self->ob_callbackdict, keybuf)) == NULL ) { - PySys_WriteStderr("Control callback %x without callback object\n", (unsigned)which); - return NULL; - } - rv = PyEval_CallObject(func, arglist); - if ( rv == NULL ) { - PySys_WriteStderr("Exception in control callback %x handler\n", (unsigned)which); - PyErr_Print(); - } - return rv; + char keybuf[9]; + PyObject *func, *rv; + + sprintf(keybuf, "%x", (unsigned)which); + if ( self->ob_callbackdict == NULL || + (func = PyDict_GetItemString(self->ob_callbackdict, keybuf)) == NULL ) { + PySys_WriteStderr("Control callback %x without callback object\n", (unsigned)which); + return NULL; + } + rv = PyEval_CallObject(func, arglist); + if ( rv == NULL ) { + PySys_WriteStderr("Exception in control callback %x handler\n", (unsigned)which); + PyErr_Print(); + } + return rv; } static pascal void myactionproc(ControlHandle control, SInt16 part) { - ControlObject *ctl_obj; - PyObject *arglist, *rv; - - ctl_obj = (ControlObject *)CtlObj_WhichControl(control); - arglist = Py_BuildValue("Oh", ctl_obj, part); - rv = callcallback(ctl_obj, kMyControlActionProcTag, arglist); - Py_XDECREF(arglist); - Py_XDECREF(rv); + ControlObject *ctl_obj; + PyObject *arglist, *rv; + + ctl_obj = (ControlObject *)CtlObj_WhichControl(control); + arglist = Py_BuildValue("Oh", ctl_obj, part); + rv = callcallback(ctl_obj, kMyControlActionProcTag, arglist); + Py_XDECREF(arglist); + Py_XDECREF(rv); } static pascal ControlPartCode mykeydownproc(ControlHandle control, SInt16 keyCode, SInt16 charCode, SInt16 modifiers) { - ControlObject *ctl_obj; - PyObject *arglist, *rv; - short c_rv = 0; - - ctl_obj = (ControlObject *)CtlObj_WhichControl(control); - arglist = Py_BuildValue("Ohhh", ctl_obj, keyCode, charCode, modifiers); - rv = callcallback(ctl_obj, kControlUserPaneKeyDownProcTag, arglist); - Py_XDECREF(arglist); - if ( rv ) - if (!PyArg_Parse(rv, "h", &c_rv)) - PyErr_Clear(); - Py_XDECREF(rv); - return (ControlPartCode)c_rv; + ControlObject *ctl_obj; + PyObject *arglist, *rv; + short c_rv = 0; + + ctl_obj = (ControlObject *)CtlObj_WhichControl(control); + arglist = Py_BuildValue("Ohhh", ctl_obj, keyCode, charCode, modifiers); + rv = callcallback(ctl_obj, kControlUserPaneKeyDownProcTag, arglist); + Py_XDECREF(arglist); + if ( rv ) + if (!PyArg_Parse(rv, "h", &c_rv)) + PyErr_Clear(); + Py_XDECREF(rv); + return (ControlPartCode)c_rv; } static pascal ControlPartCode myfocusproc(ControlHandle control, ControlPartCode part) { - ControlObject *ctl_obj; - PyObject *arglist, *rv; - short c_rv = kControlFocusNoPart; - - ctl_obj = (ControlObject *)CtlObj_WhichControl(control); - arglist = Py_BuildValue("Oh", ctl_obj, part); - rv = callcallback(ctl_obj, kControlUserPaneFocusProcTag, arglist); - Py_XDECREF(arglist); - if ( rv ) - if (!PyArg_Parse(rv, "h", &c_rv)) - PyErr_Clear(); - Py_XDECREF(rv); - return (ControlPartCode)c_rv; + ControlObject *ctl_obj; + PyObject *arglist, *rv; + short c_rv = kControlFocusNoPart; + + ctl_obj = (ControlObject *)CtlObj_WhichControl(control); + arglist = Py_BuildValue("Oh", ctl_obj, part); + rv = callcallback(ctl_obj, kControlUserPaneFocusProcTag, arglist); + Py_XDECREF(arglist); + if ( rv ) + if (!PyArg_Parse(rv, "h", &c_rv)) + PyErr_Clear(); + Py_XDECREF(rv); + return (ControlPartCode)c_rv; } static pascal void mydrawproc(ControlHandle control, SInt16 part) { - ControlObject *ctl_obj; - PyObject *arglist, *rv; - - ctl_obj = (ControlObject *)CtlObj_WhichControl(control); - arglist = Py_BuildValue("Oh", ctl_obj, part); - rv = callcallback(ctl_obj, kControlUserPaneDrawProcTag, arglist); - Py_XDECREF(arglist); - Py_XDECREF(rv); + ControlObject *ctl_obj; + PyObject *arglist, *rv; + + ctl_obj = (ControlObject *)CtlObj_WhichControl(control); + arglist = Py_BuildValue("Oh", ctl_obj, part); + rv = callcallback(ctl_obj, kControlUserPaneDrawProcTag, arglist); + Py_XDECREF(arglist); + Py_XDECREF(rv); } static pascal void myidleproc(ControlHandle control) { - ControlObject *ctl_obj; - PyObject *arglist, *rv; - - ctl_obj = (ControlObject *)CtlObj_WhichControl(control); - arglist = Py_BuildValue("O", ctl_obj); - rv = callcallback(ctl_obj, kControlUserPaneIdleProcTag, arglist); - Py_XDECREF(arglist); - Py_XDECREF(rv); + ControlObject *ctl_obj; + PyObject *arglist, *rv; + + ctl_obj = (ControlObject *)CtlObj_WhichControl(control); + arglist = Py_BuildValue("O", ctl_obj); + rv = callcallback(ctl_obj, kControlUserPaneIdleProcTag, arglist); + Py_XDECREF(arglist); + Py_XDECREF(rv); } static pascal ControlPartCode myhittestproc(ControlHandle control, Point where) { - ControlObject *ctl_obj; - PyObject *arglist, *rv; - short c_rv = -1; + ControlObject *ctl_obj; + PyObject *arglist, *rv; + short c_rv = -1; - ctl_obj = (ControlObject *)CtlObj_WhichControl(control); - arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, where); - rv = callcallback(ctl_obj, kControlUserPaneHitTestProcTag, arglist); - Py_XDECREF(arglist); - /* Ignore errors, nothing we can do about them */ - if ( rv ) - if (!PyArg_Parse(rv, "h", &c_rv)) - PyErr_Clear(); - Py_XDECREF(rv); - return (ControlPartCode)c_rv; + ctl_obj = (ControlObject *)CtlObj_WhichControl(control); + arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, where); + rv = callcallback(ctl_obj, kControlUserPaneHitTestProcTag, arglist); + Py_XDECREF(arglist); + /* Ignore errors, nothing we can do about them */ + if ( rv ) + if (!PyArg_Parse(rv, "h", &c_rv)) + PyErr_Clear(); + Py_XDECREF(rv); + return (ControlPartCode)c_rv; } static pascal ControlPartCode mytrackingproc(ControlHandle control, Point startPt, ControlActionUPP actionProc) { - ControlObject *ctl_obj; - PyObject *arglist, *rv; - short c_rv = -1; - - ctl_obj = (ControlObject *)CtlObj_WhichControl(control); - /* We cannot pass the actionProc without lots of work */ - arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, startPt); - rv = callcallback(ctl_obj, kControlUserPaneTrackingProcTag, arglist); - Py_XDECREF(arglist); - if ( rv ) - if (!PyArg_Parse(rv, "h", &c_rv)) - PyErr_Clear(); - Py_XDECREF(rv); - return (ControlPartCode)c_rv; + ControlObject *ctl_obj; + PyObject *arglist, *rv; + short c_rv = -1; + + ctl_obj = (ControlObject *)CtlObj_WhichControl(control); + /* We cannot pass the actionProc without lots of work */ + arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, startPt); + rv = callcallback(ctl_obj, kControlUserPaneTrackingProcTag, arglist); + Py_XDECREF(arglist); + if ( rv ) + if (!PyArg_Parse(rv, "h", &c_rv)) + PyErr_Clear(); + Py_XDECREF(rv); + return (ControlPartCode)c_rv; } diff --git a/Mac/Modules/dlg/_Dlgmodule.c b/Mac/Modules/dlg/_Dlgmodule.c index 19ae1e9..64ddac8 100644 --- a/Mac/Modules/dlg/_Dlgmodule.c +++ b/Mac/Modules/dlg/_Dlgmodule.c @@ -34,55 +34,55 @@ static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog, EventRecord *event, short *itemHit) { - Boolean rv; - PyObject *args, *res; - PyObject *callback = Dlg_FilterProc_callback; - if (callback == NULL) - return 0; /* Default behavior */ - Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */ - args = Py_BuildValue("O&O&", DlgObj_WhichDialog, dialog, PyMac_BuildEventRecord, event); - if (args == NULL) - res = NULL; - else { - res = PyEval_CallObject(callback, args); - Py_DECREF(args); - } - if (res == NULL) { - PySys_WriteStderr("Exception in Dialog Filter\n"); - PyErr_Print(); - *itemHit = -1; /* Fake return item */ - return 1; /* We handled it */ - } - else { - Dlg_FilterProc_callback = callback; - if (PyInt_Check(res)) { - *itemHit = PyInt_AsLong(res); - rv = 1; - } - else - rv = PyObject_IsTrue(res); - } - Py_DECREF(res); - return rv; + Boolean rv; + PyObject *args, *res; + PyObject *callback = Dlg_FilterProc_callback; + if (callback == NULL) + return 0; /* Default behavior */ + Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */ + args = Py_BuildValue("O&O&", DlgObj_WhichDialog, dialog, PyMac_BuildEventRecord, event); + if (args == NULL) + res = NULL; + else { + res = PyEval_CallObject(callback, args); + Py_DECREF(args); + } + if (res == NULL) { + PySys_WriteStderr("Exception in Dialog Filter\n"); + PyErr_Print(); + *itemHit = -1; /* Fake return item */ + return 1; /* We handled it */ + } + else { + Dlg_FilterProc_callback = callback; + if (PyInt_Check(res)) { + *itemHit = PyInt_AsLong(res); + rv = 1; + } + else + rv = PyObject_IsTrue(res); + } + Py_DECREF(res); + return rv; } static ModalFilterUPP Dlg_PassFilterProc(PyObject *callback) { - PyObject *tmp = Dlg_FilterProc_callback; - static ModalFilterUPP UnivFilterUpp = NULL; - - Dlg_FilterProc_callback = NULL; - if (callback == Py_None) { - Py_XDECREF(tmp); - return NULL; - } - Py_INCREF(callback); - Dlg_FilterProc_callback = callback; - Py_XDECREF(tmp); - if ( UnivFilterUpp == NULL ) - UnivFilterUpp = NewModalFilterUPP(&Dlg_UnivFilterProc); - return UnivFilterUpp; + PyObject *tmp = Dlg_FilterProc_callback; + static ModalFilterUPP UnivFilterUpp = NULL; + + Dlg_FilterProc_callback = NULL; + if (callback == Py_None) { + Py_XDECREF(tmp); + return NULL; + } + Py_INCREF(callback); + Dlg_FilterProc_callback = callback; + Py_XDECREF(tmp); + if ( UnivFilterUpp == NULL ) + UnivFilterUpp = NewModalFilterUPP(&Dlg_UnivFilterProc); + return UnivFilterUpp; } static PyObject *Dlg_UserItemProc_callback = NULL; @@ -90,24 +90,24 @@ static PyObject *Dlg_UserItemProc_callback = NULL; static pascal void Dlg_UnivUserItemProc(DialogPtr dialog, short item) { - PyObject *args, *res; - - if (Dlg_UserItemProc_callback == NULL) - return; /* Default behavior */ - Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */ - args = Py_BuildValue("O&h", DlgObj_WhichDialog, dialog, item); - if (args == NULL) - res = NULL; - else { - res = PyEval_CallObject(Dlg_UserItemProc_callback, args); - Py_DECREF(args); - } - if (res == NULL) { - PySys_WriteStderr("Exception in Dialog UserItem proc\n"); - PyErr_Print(); - } - Py_XDECREF(res); - return; + PyObject *args, *res; + + if (Dlg_UserItemProc_callback == NULL) + return; /* Default behavior */ + Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */ + args = Py_BuildValue("O&h", DlgObj_WhichDialog, dialog, item); + if (args == NULL) + res = NULL; + else { + res = PyEval_CallObject(Dlg_UserItemProc_callback, args); + Py_DECREF(args); + } + if (res == NULL) { + PySys_WriteStderr("Exception in Dialog UserItem proc\n"); + PyErr_Print(); + } + Py_XDECREF(res); + return; } #if 0 @@ -146,6 +146,7 @@ PyObject *DlgObj_New(DialogPtr itself) SetWRefCon(GetDialogWindow(itself), (long)it); return (PyObject *)it; } + int DlgObj_Convert(PyObject *v, DialogPtr *p_itself) { if (v == Py_None) { *p_itself = NULL; return 1; } @@ -958,16 +959,16 @@ static int DlgObj_hash(DialogObject *self) #define DlgObj_tp_alloc PyType_GenericAlloc -static PyObject *DlgObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *DlgObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; DialogPtr itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, DlgObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((DialogObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, DlgObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((DialogObject *)_self)->ob_itself = itself; + return _self; } #define DlgObj_tp_free PyObject_Del @@ -1452,28 +1453,28 @@ static PyObject *Dlg_SetUserItemHandler(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - PyObject *new = NULL; - - - if (!PyArg_ParseTuple(_args, "|O", &new)) - return NULL; - - if (Dlg_UserItemProc_callback && new && new != Py_None) { - PyErr_SetString(Dlg_Error, "Another UserItemProc is already installed"); - return NULL; - } - - if (new == NULL || new == Py_None) { - new = NULL; - _res = Py_None; - Py_INCREF(Py_None); - } else { - Py_INCREF(new); - _res = Py_BuildValue("O&", ResObj_New, (Handle)NewUserItemUPP(Dlg_UnivUserItemProc)); - } - - Dlg_UserItemProc_callback = new; - return _res; + PyObject *new = NULL; + + + if (!PyArg_ParseTuple(_args, "|O", &new)) + return NULL; + + if (Dlg_UserItemProc_callback && new && new != Py_None) { + PyErr_SetString(Dlg_Error, "Another UserItemProc is already installed"); + return NULL; + } + + if (new == NULL || new == Py_None) { + new = NULL; + _res = Py_None; + Py_INCREF(Py_None); + } else { + Py_INCREF(new); + _res = Py_BuildValue("O&", ResObj_New, (Handle)NewUserItemUPP(Dlg_UnivUserItemProc)); + } + + Dlg_UserItemProc_callback = new; + return _res; } @@ -1528,9 +1529,9 @@ static PyMethodDef Dlg_methods[] = { WindowPtr DlgObj_ConvertToWindow(PyObject *self) { - if ( DlgObj_Check(self) ) - return GetDialogWindow(((DialogObject *)self)->ob_itself); - return NULL; + if ( DlgObj_Check(self) ) + return GetDialogWindow(((DialogObject *)self)->ob_itself); + return NULL; } #endif /* Return the object corresponding to the dialog, or None */ @@ -1538,29 +1539,29 @@ DlgObj_ConvertToWindow(PyObject *self) PyObject * DlgObj_WhichDialog(DialogPtr d) { - PyObject *it; - - if (d == NULL) { - it = Py_None; - Py_INCREF(it); - } else { - WindowPtr w = GetDialogWindow(d); - - it = (PyObject *) GetWRefCon(w); - if (it == NULL || ((DialogObject *)it)->ob_itself != d || !DlgObj_Check(it)) { + PyObject *it; + + if (d == NULL) { + it = Py_None; + Py_INCREF(it); + } else { + WindowPtr w = GetDialogWindow(d); + + it = (PyObject *) GetWRefCon(w); + if (it == NULL || ((DialogObject *)it)->ob_itself != d || !DlgObj_Check(it)) { #if 0 - /* Should do this, but we don't have an ob_freeit for dialogs yet. */ - it = WinObj_New(w); - ((WindowObject *)it)->ob_freeit = NULL; + /* Should do this, but we don't have an ob_freeit for dialogs yet. */ + it = WinObj_New(w); + ((WindowObject *)it)->ob_freeit = NULL; #else - it = Py_None; - Py_INCREF(it); + it = Py_None; + Py_INCREF(it); #endif - } else { - Py_INCREF(it); - } - } - return it; + } else { + Py_INCREF(it); + } + } + return it; } @@ -1571,9 +1572,9 @@ void init_Dlg(void) - PyMac_INIT_TOOLBOX_OBJECT_NEW(DialogPtr, DlgObj_New); - PyMac_INIT_TOOLBOX_OBJECT_NEW(DialogPtr, DlgObj_WhichDialog); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(DialogPtr, DlgObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(DialogPtr, DlgObj_New); + PyMac_INIT_TOOLBOX_OBJECT_NEW(DialogPtr, DlgObj_WhichDialog); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(DialogPtr, DlgObj_Convert); m = Py_InitModule("_Dlg", Dlg_methods); diff --git a/Mac/Modules/drag/_Dragmodule.c b/Mac/Modules/drag/_Dragmodule.c index a1f743b..180fcab 100644 --- a/Mac/Modules/drag/_Dragmodule.c +++ b/Mac/Modules/drag/_Dragmodule.c @@ -52,15 +52,16 @@ PyObject *DragObj_New(DragRef itself) { DragObjObject *it; if (itself == NULL) { - PyErr_SetString(Drag_Error,"Cannot create null Drag"); - return NULL; - } + PyErr_SetString(Drag_Error,"Cannot create null Drag"); + return NULL; + } it = PyObject_NEW(DragObjObject, &DragObj_Type); if (it == NULL) return NULL; it->ob_itself = itself; it->sendproc = NULL; return (PyObject *)it; } + int DragObj_Convert(PyObject *v, DragRef *p_itself) { if (!DragObj_Check(v)) @@ -743,16 +744,16 @@ static PyMethodDef DragObj_methods[] = { #define DragObj_tp_alloc PyType_GenericAlloc -static PyObject *DragObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *DragObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; DragRef itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, DragObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((DragObjObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, DragObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((DragObjObject *)_self)->ob_itself = itself; + return _self; } #define DragObj_tp_free PyObject_Del @@ -920,15 +921,15 @@ static PyObject *Drag_InstallTrackingHandler(PyObject *_self, PyObject *_args) PyObject *callback; WindowPtr theWindow = NULL; OSErr _err; - + if ( !PyArg_ParseTuple(_args, "O|O&", &callback, WinObj_Convert, &theWindow) ) - return NULL; - Py_INCREF(callback); /* Cannot decref later, too bad */ + return NULL; + Py_INCREF(callback); /* Cannot decref later, too bad */ _err = InstallTrackingHandler(dragglue_TrackingHandlerUPP, theWindow, (void *)callback); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; } @@ -939,15 +940,15 @@ static PyObject *Drag_InstallReceiveHandler(PyObject *_self, PyObject *_args) PyObject *callback; WindowPtr theWindow = NULL; OSErr _err; - + if ( !PyArg_ParseTuple(_args, "O|O&", &callback, WinObj_Convert, &theWindow) ) - return NULL; - Py_INCREF(callback); /* Cannot decref later, too bad */ + return NULL; + Py_INCREF(callback); /* Cannot decref later, too bad */ _err = InstallReceiveHandler(dragglue_ReceiveHandlerUPP, theWindow, (void *)callback); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; } @@ -957,14 +958,14 @@ static PyObject *Drag_RemoveTrackingHandler(PyObject *_self, PyObject *_args) WindowPtr theWindow = NULL; OSErr _err; - + if ( !PyArg_ParseTuple(_args, "|O&", WinObj_Convert, &theWindow) ) - return NULL; + return NULL; _err = RemoveTrackingHandler(dragglue_TrackingHandlerUPP, theWindow); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; } @@ -974,14 +975,14 @@ static PyObject *Drag_RemoveReceiveHandler(PyObject *_self, PyObject *_args) WindowPtr theWindow = NULL; OSErr _err; - + if ( !PyArg_ParseTuple(_args, "|O&", WinObj_Convert, &theWindow) ) - return NULL; + return NULL; _err = RemoveReceiveHandler(dragglue_ReceiveHandlerUPP, theWindow); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; + if (_err != noErr) return PyMac_Error(_err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; } @@ -1013,81 +1014,81 @@ static pascal OSErr dragglue_TrackingHandler(DragTrackingMessage theMessage, WindowPtr theWindow, void *handlerRefCon, DragReference theDrag) { - PyObject *args, *rv; - int i; - - args = Py_BuildValue("hO&O&", theMessage, DragObj_New, theDrag, WinObj_WhichWindow, theWindow); - if ( args == NULL ) - return -1; - rv = PyEval_CallObject((PyObject *)handlerRefCon, args); - Py_DECREF(args); - if ( rv == NULL ) { - PySys_WriteStderr("Drag: Exception in TrackingHandler\n"); - PyErr_Print(); - return -1; - } - i = -1; - if ( rv == Py_None ) - i = 0; - else - PyArg_Parse(rv, "l", &i); - Py_DECREF(rv); - return i; + PyObject *args, *rv; + int i; + + args = Py_BuildValue("hO&O&", theMessage, DragObj_New, theDrag, WinObj_WhichWindow, theWindow); + if ( args == NULL ) + return -1; + rv = PyEval_CallObject((PyObject *)handlerRefCon, args); + Py_DECREF(args); + if ( rv == NULL ) { + PySys_WriteStderr("Drag: Exception in TrackingHandler\n"); + PyErr_Print(); + return -1; + } + i = -1; + if ( rv == Py_None ) + i = 0; + else + PyArg_Parse(rv, "l", &i); + Py_DECREF(rv); + return i; } static pascal OSErr dragglue_ReceiveHandler(WindowPtr theWindow, void *handlerRefCon, DragReference theDrag) { - PyObject *args, *rv; - int i; - - args = Py_BuildValue("O&O&", DragObj_New, theDrag, WinObj_WhichWindow, theWindow); - if ( args == NULL ) - return -1; - rv = PyEval_CallObject((PyObject *)handlerRefCon, args); - Py_DECREF(args); - if ( rv == NULL ) { - PySys_WriteStderr("Drag: Exception in ReceiveHandler\n"); - PyErr_Print(); - return -1; - } - i = -1; - if ( rv == Py_None ) - i = 0; - else - PyArg_Parse(rv, "l", &i); - Py_DECREF(rv); - return i; + PyObject *args, *rv; + int i; + + args = Py_BuildValue("O&O&", DragObj_New, theDrag, WinObj_WhichWindow, theWindow); + if ( args == NULL ) + return -1; + rv = PyEval_CallObject((PyObject *)handlerRefCon, args); + Py_DECREF(args); + if ( rv == NULL ) { + PySys_WriteStderr("Drag: Exception in ReceiveHandler\n"); + PyErr_Print(); + return -1; + } + i = -1; + if ( rv == Py_None ) + i = 0; + else + PyArg_Parse(rv, "l", &i); + Py_DECREF(rv); + return i; } static pascal OSErr dragglue_SendData(FlavorType theType, void *dragSendRefCon, ItemReference theItem, DragReference theDrag) { - DragObjObject *self = (DragObjObject *)dragSendRefCon; - PyObject *args, *rv; - int i; - - if ( self->sendproc == NULL ) - return -1; - args = Py_BuildValue("O&l", PyMac_BuildOSType, theType, theItem); - if ( args == NULL ) - return -1; - rv = PyEval_CallObject(self->sendproc, args); - Py_DECREF(args); - if ( rv == NULL ) { - PySys_WriteStderr("Drag: Exception in SendDataHandler\n"); - PyErr_Print(); - return -1; - } - i = -1; - if ( rv == Py_None ) - i = 0; - else - PyArg_Parse(rv, "l", &i); - Py_DECREF(rv); - return i; + DragObjObject *self = (DragObjObject *)dragSendRefCon; + PyObject *args, *rv; + int i; + + if ( self->sendproc == NULL ) + return -1; + args = Py_BuildValue("O&l", PyMac_BuildOSType, theType, theItem); + if ( args == NULL ) + return -1; + rv = PyEval_CallObject(self->sendproc, args); + Py_DECREF(args); + if ( rv == NULL ) { + PySys_WriteStderr("Drag: Exception in SendDataHandler\n"); + PyErr_Print(); + return -1; + } + i = -1; + if ( rv == Py_None ) + i = 0; + else + PyArg_Parse(rv, "l", &i); + Py_DECREF(rv); + return i; } #if 0 @@ -1115,8 +1116,8 @@ void init_Drag(void) - PyMac_INIT_TOOLBOX_OBJECT_NEW(DragRef, DragObj_New); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(DragRef, DragObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(DragRef, DragObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(DragRef, DragObj_Convert); m = Py_InitModule("_Drag", Drag_methods); diff --git a/Mac/Modules/evt/_Evtmodule.c b/Mac/Modules/evt/_Evtmodule.c index 6d86e51..f7129cf 100644 --- a/Mac/Modules/evt/_Evtmodule.c +++ b/Mac/Modules/evt/_Evtmodule.c @@ -455,7 +455,7 @@ static PyObject *Evt_WaitNextEvent(PyObject *_self, PyObject *_args) &eventMask, &sleep, OptResObj_Convert, &mouseregion)) - return NULL; + return NULL; _rv = WaitNextEvent(eventMask, &theEvent, sleep, diff --git a/Mac/Modules/file/_Filemodule.c b/Mac/Modules/file/_Filemodule.c index c1b4310..c3d1abf 100644 --- a/Mac/Modules/file/_Filemodule.c +++ b/Mac/Modules/file/_Filemodule.c @@ -50,13 +50,13 @@ static int Alias_Convert(PyObject *v, AliasHandle *p_itself); static int UTCDateTime_Convert(PyObject *v, UTCDateTime *ptr) { - return PyArg_Parse(v, "(HlH)", &ptr->highSeconds, &ptr->lowSeconds, &ptr->fraction); + return PyArg_Parse(v, "(HlH)", &ptr->highSeconds, &ptr->lowSeconds, &ptr->fraction); } static PyObject * UTCDateTime_New(UTCDateTime *ptr) { - return Py_BuildValue("(HlH)", ptr->highSeconds, ptr->lowSeconds, ptr->fraction); + return Py_BuildValue("(HlH)", ptr->highSeconds, ptr->lowSeconds, ptr->fraction); } /* @@ -65,21 +65,21 @@ UTCDateTime_New(UTCDateTime *ptr) static int myPyMac_GetOptFSSpecPtr(PyObject *v, FSSpec **spec) { - if (v == Py_None) { - *spec = NULL; - return 1; - } - return PyMac_GetFSSpec(v, *spec); + if (v == Py_None) { + *spec = NULL; + return 1; + } + return PyMac_GetFSSpec(v, *spec); } static int myPyMac_GetOptFSRefPtr(PyObject *v, FSRef **ref) { - if (v == Py_None) { - *ref = NULL; - return 1; - } - return PyMac_GetFSRef(v, *ref); + if (v == Py_None) { + *ref = NULL; + return 1; + } + return PyMac_GetFSRef(v, *ref); } /* @@ -89,7 +89,7 @@ static PyObject * PyMac_BuildHFSUniStr255(HFSUniStr255 *itself) { - return Py_BuildValue("u#", itself->unicode, itself->length); + return Py_BuildValue("u#", itself->unicode, itself->length); } static PyObject *File_Error; @@ -114,6 +114,7 @@ static PyObject *FSCatalogInfo_New(FSCatalogInfo *itself) it->ob_itself = *itself; return (PyObject *)it; } + static int FSCatalogInfo_Convert(PyObject *v, FSCatalogInfo *p_itself) { if (!FSCatalogInfo_Check(v)) @@ -349,43 +350,43 @@ static PyGetSetDef FSCatalogInfo_getsetlist[] = { #define FSCatalogInfo_repr NULL #define FSCatalogInfo_hash NULL -static int FSCatalogInfo_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +static int FSCatalogInfo_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) { static char *kw[] = { - "nodeFlags", - "volume", - "parentDirID", - "nodeID", - "createDate", - "contentModDate", - "atributeModDate", - "accessDate", - "backupDate", - "valence", - "dataLogicalSize", - "dataPhysicalSize", - "rsrcLogicalSize", - "rsrcPhysicalSize", - "sharingFlags", - "userPrivileges" - , 0}; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|HhllO&O&O&O&O&llllllb", kw, &((FSCatalogInfoObject *)self)->ob_itself.nodeFlags, - &((FSCatalogInfoObject *)self)->ob_itself.volume, - &((FSCatalogInfoObject *)self)->ob_itself.parentDirID, - &((FSCatalogInfoObject *)self)->ob_itself.nodeID, - UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.createDate, - UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.contentModDate, - UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.attributeModDate, - UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.accessDate, - UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.backupDate, - &((FSCatalogInfoObject *)self)->ob_itself.valence, - &((FSCatalogInfoObject *)self)->ob_itself.dataLogicalSize, - &((FSCatalogInfoObject *)self)->ob_itself.dataPhysicalSize, - &((FSCatalogInfoObject *)self)->ob_itself.rsrcLogicalSize, - &((FSCatalogInfoObject *)self)->ob_itself.rsrcPhysicalSize, - &((FSCatalogInfoObject *)self)->ob_itself.sharingFlags, - &((FSCatalogInfoObject *)self)->ob_itself.userPrivileges)) + "nodeFlags", + "volume", + "parentDirID", + "nodeID", + "createDate", + "contentModDate", + "atributeModDate", + "accessDate", + "backupDate", + "valence", + "dataLogicalSize", + "dataPhysicalSize", + "rsrcLogicalSize", + "rsrcPhysicalSize", + "sharingFlags", + "userPrivileges" + , 0}; + + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "|HhllO&O&O&O&O&llllllb", kw, &((FSCatalogInfoObject *)_self)->ob_itself.nodeFlags, + &((FSCatalogInfoObject *)_self)->ob_itself.volume, + &((FSCatalogInfoObject *)_self)->ob_itself.parentDirID, + &((FSCatalogInfoObject *)_self)->ob_itself.nodeID, + UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.createDate, + UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.contentModDate, + UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.attributeModDate, + UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.accessDate, + UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.backupDate, + &((FSCatalogInfoObject *)_self)->ob_itself.valence, + &((FSCatalogInfoObject *)_self)->ob_itself.dataLogicalSize, + &((FSCatalogInfoObject *)_self)->ob_itself.dataPhysicalSize, + &((FSCatalogInfoObject *)_self)->ob_itself.rsrcLogicalSize, + &((FSCatalogInfoObject *)_self)->ob_itself.rsrcPhysicalSize, + &((FSCatalogInfoObject *)_self)->ob_itself.sharingFlags, + &((FSCatalogInfoObject *)_self)->ob_itself.userPrivileges)) { return -1; } @@ -394,7 +395,7 @@ static int FSCatalogInfo_tp_init(PyObject *self, PyObject *args, PyObject *kwds) #define FSCatalogInfo_tp_alloc PyType_GenericAlloc -static PyObject *FSCatalogInfo_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *FSCatalogInfo_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { PyObject *self; @@ -473,6 +474,7 @@ static PyObject *FInfo_New(FInfo *itself) it->ob_itself = *itself; return (PyObject *)it; } + static int FInfo_Convert(PyObject *v, FInfo *p_itself) { if (!FInfo_Check(v)) @@ -564,14 +566,14 @@ static PyGetSetDef FInfo_getsetlist[] = { #define FInfo_repr NULL #define FInfo_hash NULL -static int FInfo_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +static int FInfo_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) { FInfo *itself = NULL; static char *kw[] = {"itself", 0}; - if (PyArg_ParseTupleAndKeywords(args, kwds, "|O&", kw, FInfo_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "|O&", kw, FInfo_Convert, &itself)) { - if (itself) memcpy(&((FInfoObject *)self)->ob_itself, itself, sizeof(FInfo)); + if (itself) memcpy(&((FInfoObject *)_self)->ob_itself, itself, sizeof(FInfo)); return 0; } return -1; @@ -579,7 +581,7 @@ static int FInfo_tp_init(PyObject *self, PyObject *args, PyObject *kwds) #define FInfo_tp_alloc PyType_GenericAlloc -static PyObject *FInfo_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *FInfo_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { PyObject *self; @@ -660,6 +662,7 @@ static PyObject *Alias_New(AliasHandle itself) it->ob_freeit = NULL; return (PyObject *)it; } + static int Alias_Convert(PyObject *v, AliasHandle *p_itself) { if (!Alias_Check(v)) @@ -863,14 +866,14 @@ static PyMethodDef Alias_methods[] = { static PyObject *Alias_get_data(AliasObject *self, void *closure) { int size; - PyObject *rv; - - size = GetHandleSize((Handle)self->ob_itself); - HLock((Handle)self->ob_itself); - rv = PyString_FromStringAndSize(*(Handle)self->ob_itself, size); - HUnlock((Handle)self->ob_itself); - return rv; - + PyObject *rv; + + size = GetHandleSize((Handle)self->ob_itself); + HLock((Handle)self->ob_itself); + rv = PyString_FromStringAndSize(*(Handle)self->ob_itself, size); + HUnlock((Handle)self->ob_itself); + return rv; + } #define Alias_set_data NULL @@ -886,7 +889,7 @@ static PyGetSetDef Alias_getsetlist[] = { #define Alias_repr NULL #define Alias_hash NULL -static int Alias_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +static int Alias_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) { AliasHandle itself = NULL; char *rawdata = NULL; @@ -894,7 +897,7 @@ static int Alias_tp_init(PyObject *self, PyObject *args, PyObject *kwds) Handle h; static char *kw[] = {"itself", "rawdata", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O&s#", kw, Alias_Convert, &itself, &rawdata, &rawdatalen)) + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "|O&s#", kw, Alias_Convert, &itself, &rawdata, &rawdatalen)) return -1; if (itself && rawdata) { @@ -916,16 +919,16 @@ static int Alias_tp_init(PyObject *self, PyObject *args, PyObject *kwds) HLock(h); memcpy((char *)*h, rawdata, rawdatalen); HUnlock(h); - ((AliasObject *)self)->ob_itself = (AliasHandle)h; + ((AliasObject *)_self)->ob_itself = (AliasHandle)h; return 0; } - ((AliasObject *)self)->ob_itself = itself; + ((AliasObject *)_self)->ob_itself = itself; return 0; } #define Alias_tp_alloc PyType_GenericAlloc -static PyObject *Alias_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *Alias_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { PyObject *self; @@ -1253,49 +1256,6 @@ static PyObject *FSSpec_IsAliasFile(FSSpecObject *_self, PyObject *_args) return _res; } -static OSErr -_PyMac_GetFullPathname(FSSpec *fss, char *path, int len) -{ - FSRef fsr; - OSErr err; - - *path = '\0'; - err = FSpMakeFSRef(fss, &fsr); - if (err == fnfErr) { - /* FSSpecs can point to non-existing files, fsrefs can't. */ - FSSpec fss2; - int tocopy; - - err = FSMakeFSSpec(fss->vRefNum, fss->parID, "", &fss2); - if (err) - return err; - err = FSpMakeFSRef(&fss2, &fsr); - if (err) - return err; - err = (OSErr)FSRefMakePath(&fsr, path, len-1); - if (err) - return err; - /* This part is not 100% safe: we append the filename part, but - ** I'm not sure that we don't run afoul of the various 8bit - ** encodings here. Will have to look this up at some point... - */ - strcat(path, "/"); - tocopy = fss->name[0]; - if ((strlen(path) + tocopy) >= len) - tocopy = len - strlen(path) - 1; - if (tocopy > 0) - strncat(path, fss->name+1, tocopy); - } - else { - if (err) - return err; - err = (OSErr)FSRefMakePath(&fsr, path, len); - if (err) - return err; - } - return 0; -} - static PyObject *FSSpec_as_pathname(FSSpecObject *_self, PyObject *_args) { PyObject *_res = NULL; @@ -1304,11 +1264,11 @@ static PyObject *FSSpec_as_pathname(FSSpecObject *_self, PyObject *_args) OSErr err; if (!PyArg_ParseTuple(_args, "")) - return NULL; - err = _PyMac_GetFullPathname(&_self->ob_itself, strbuf, sizeof(strbuf)); + return NULL; + err = PyMac_GetFullPathname(&_self->ob_itself, strbuf, sizeof(strbuf)); if ( err ) { - PyMac_Error(err); - return NULL; + PyMac_Error(err); + return NULL; } _res = PyString_FromString(strbuf); return _res; @@ -1320,9 +1280,9 @@ static PyObject *FSSpec_as_tuple(FSSpecObject *_self, PyObject *_args) PyObject *_res = NULL; if (!PyArg_ParseTuple(_args, "")) - return NULL; - _res = Py_BuildValue("(iis#)", _self->ob_itself.vRefNum, _self->ob_itself.parID, - &_self->ob_itself.name[1], _self->ob_itself.name[0]); + return NULL; + _res = Py_BuildValue("(iis#)", _self->ob_itself.vRefNum, _self->ob_itself.parID, + &_self->ob_itself.name[1], _self->ob_itself.name[0]); return _res; } @@ -1384,22 +1344,22 @@ static PyObject * FSSpec_repr(FSSpecObject *self) { char buf[512]; PyOS_snprintf(buf, sizeof(buf), "%s((%d, %ld, '%.*s'))", - self->ob_type->tp_name, - self->ob_itself.vRefNum, - self->ob_itself.parID, - self->ob_itself.name[0], self->ob_itself.name+1); + self->ob_type->tp_name, + self->ob_itself.vRefNum, + self->ob_itself.parID, + self->ob_itself.name[0], self->ob_itself.name+1); return PyString_FromString(buf); } #define FSSpec_hash NULL -static int FSSpec_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +static int FSSpec_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) { PyObject *v = NULL; char *rawdata = NULL; int rawdatalen = 0; static char *kw[] = {"itself", "rawdata", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Os#", kw, &v, &rawdata, &rawdatalen)) + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "|Os#", kw, &v, &rawdata, &rawdatalen)) return -1; if (v && rawdata) { @@ -1418,16 +1378,16 @@ static int FSSpec_tp_init(PyObject *self, PyObject *args, PyObject *kwds) PyErr_SetString(PyExc_TypeError, "FSSpec rawdata incorrect size"); return -1; } - memcpy(&((FSSpecObject *)self)->ob_itself, rawdata, rawdatalen); + memcpy(&((FSSpecObject *)_self)->ob_itself, rawdata, rawdatalen); return 0; } - if (PyMac_GetFSSpec(v, &((FSSpecObject *)self)->ob_itself)) return 0; + if (PyMac_GetFSSpec(v, &((FSSpecObject *)_self)->ob_itself)) return 0; return -1; } #define FSSpec_tp_alloc PyType_GenericAlloc -static PyObject *FSSpec_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *FSSpec_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { PyObject *self; @@ -1857,10 +1817,10 @@ static PyObject *FSRef_FSRefMakePath(FSRefObject *_self, PyObject *_args) UInt32 maxPathSize = MAXPATHNAME; if (!PyArg_ParseTuple(_args, "")) - return NULL; + return NULL; _err = FSRefMakePath(&_self->ob_itself, - path, - maxPathSize); + path, + maxPathSize); if (_err != noErr) return PyMac_Error(_err); _res = Py_BuildValue("s", path); return _res; @@ -1872,7 +1832,7 @@ static PyObject *FSRef_as_pathname(FSRefObject *_self, PyObject *_args) PyObject *_res = NULL; if (!PyArg_ParseTuple(_args, "")) - return NULL; + return NULL; _res = FSRef_FSRefMakePath(_self, _args); return _res; @@ -1936,14 +1896,14 @@ static PyGetSetDef FSRef_getsetlist[] = { #define FSRef_repr NULL #define FSRef_hash NULL -static int FSRef_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +static int FSRef_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) { PyObject *v = NULL; char *rawdata = NULL; int rawdatalen = 0; static char *kw[] = {"itself", "rawdata", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Os#", kw, &v, &rawdata, &rawdatalen)) + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "|Os#", kw, &v, &rawdata, &rawdatalen)) return -1; if (v && rawdata) { @@ -1962,16 +1922,16 @@ static int FSRef_tp_init(PyObject *self, PyObject *args, PyObject *kwds) PyErr_SetString(PyExc_TypeError, "FSRef rawdata incorrect size"); return -1; } - memcpy(&((FSRefObject *)self)->ob_itself, rawdata, rawdatalen); + memcpy(&((FSRefObject *)_self)->ob_itself, rawdata, rawdatalen); return 0; } - if (PyMac_GetFSRef(v, &((FSRefObject *)self)->ob_itself)) return 0; + if (PyMac_GetFSRef(v, &((FSRefObject *)_self)->ob_itself)) return 0; return -1; } #define FSRef_tp_alloc PyType_GenericAlloc -static PyObject *FSRef_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *FSRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { PyObject *self; @@ -3032,13 +2992,13 @@ static PyObject *File_pathname(PyObject *_self, PyObject *_args) PyObject *obj; if (!PyArg_ParseTuple(_args, "O", &obj)) - return NULL; + return NULL; if (PyString_Check(obj)) { - Py_INCREF(obj); - return obj; + Py_INCREF(obj); + return obj; } if (PyUnicode_Check(obj)) - return PyUnicode_AsEncodedString(obj, "utf8", "strict"); + return PyUnicode_AsEncodedString(obj, "utf8", "strict"); _res = PyObject_CallMethod(obj, "as_pathname", NULL); return _res; @@ -3149,86 +3109,86 @@ static PyMethodDef File_methods[] = { int PyMac_GetFSSpec(PyObject *v, FSSpec *spec) { - Str255 path; - short refnum; - long parid; - OSErr err; - FSRef fsr; - - if (FSSpec_Check(v)) { - *spec = ((FSSpecObject *)v)->ob_itself; - return 1; - } - - if (PyArg_Parse(v, "(hlO&)", - &refnum, &parid, PyMac_GetStr255, &path)) { - err = FSMakeFSSpec(refnum, parid, path, spec); - if ( err && err != fnfErr ) { - PyMac_Error(err); - return 0; - } - return 1; - } - PyErr_Clear(); - /* Otherwise we try to go via an FSRef. On OSX we go all the way, - ** on OS9 we accept only a real FSRef object - */ - if ( PyMac_GetFSRef(v, &fsr) ) { - err = FSGetCatalogInfo(&fsr, kFSCatInfoNone, NULL, NULL, spec, NULL); - if (err != noErr) { - PyMac_Error(err); - return 0; - } - return 1; - } - return 0; + Str255 path; + short refnum; + long parid; + OSErr err; + FSRef fsr; + + if (FSSpec_Check(v)) { + *spec = ((FSSpecObject *)v)->ob_itself; + return 1; + } + + if (PyArg_Parse(v, "(hlO&)", + &refnum, &parid, PyMac_GetStr255, &path)) { + err = FSMakeFSSpec(refnum, parid, path, spec); + if ( err && err != fnfErr ) { + PyMac_Error(err); + return 0; + } + return 1; + } + PyErr_Clear(); + /* Otherwise we try to go via an FSRef. On OSX we go all the way, + ** on OS9 we accept only a real FSRef object + */ + if ( PyMac_GetFSRef(v, &fsr) ) { + err = FSGetCatalogInfo(&fsr, kFSCatInfoNone, NULL, NULL, spec, NULL); + if (err != noErr) { + PyMac_Error(err); + return 0; + } + return 1; + } + return 0; } int PyMac_GetFSRef(PyObject *v, FSRef *fsr) { - OSStatus err; - FSSpec fss; - - if (FSRef_Check(v)) { - *fsr = ((FSRefObject *)v)->ob_itself; - return 1; - } - - /* On OSX we now try a pathname */ - if ( PyString_Check(v) || PyUnicode_Check(v)) { - char *path = NULL; - if (!PyArg_Parse(v, "et", Py_FileSystemDefaultEncoding, &path)) - return NULL; - if ( (err=FSPathMakeRef(path, fsr, NULL)) ) { - PyMac_Error(err); - return 0; - } - return 1; - } - /* XXXX Should try unicode here too */ - /* Otherwise we try to go via an FSSpec */ - if (FSSpec_Check(v)) { - fss = ((FSSpecObject *)v)->ob_itself; - if ((err=FSpMakeFSRef(&fss, fsr)) == 0) - return 1; - PyMac_Error(err); - return 0; - } - PyErr_SetString(PyExc_TypeError, "FSRef, FSSpec or pathname required"); - return 0; + OSStatus err; + FSSpec fss; + + if (FSRef_Check(v)) { + *fsr = ((FSRefObject *)v)->ob_itself; + return 1; + } + + /* On OSX we now try a pathname */ + if ( PyString_Check(v) || PyUnicode_Check(v)) { + char *path = NULL; + if (!PyArg_Parse(v, "et", Py_FileSystemDefaultEncoding, &path)) + return 0; + if ( (err=FSPathMakeRef(path, fsr, NULL)) ) { + PyMac_Error(err); + return 0; + } + return 1; + } + /* XXXX Should try unicode here too */ + /* Otherwise we try to go via an FSSpec */ + if (FSSpec_Check(v)) { + fss = ((FSSpecObject *)v)->ob_itself; + if ((err=FSpMakeFSRef(&fss, fsr)) == 0) + return 1; + PyMac_Error(err); + return 0; + } + PyErr_SetString(PyExc_TypeError, "FSRef, FSSpec or pathname required"); + return 0; } extern PyObject * PyMac_BuildFSSpec(FSSpec *spec) { - return FSSpec_New(spec); + return FSSpec_New(spec); } extern PyObject * PyMac_BuildFSRef(FSRef *spec) { - return FSRef_New(spec); + return FSRef_New(spec); } diff --git a/Mac/Modules/file/filesupport.py b/Mac/Modules/file/filesupport.py index dac706d..15ad8a3 100644 --- a/Mac/Modules/file/filesupport.py +++ b/Mac/Modules/file/filesupport.py @@ -254,7 +254,7 @@ PyMac_GetFSRef(PyObject *v, FSRef *fsr) if ( PyString_Check(v) || PyUnicode_Check(v)) { char *path = NULL; if (!PyArg_Parse(v, "et", Py_FileSystemDefaultEncoding, &path)) - return NULL; + return 0; if ( (err=FSPathMakeRef(path, fsr, NULL)) ) { PyMac_Error(err); return 0; @@ -389,22 +389,22 @@ class FSCatalogInfoDefinition(PEP253Mixin, ObjectDefinition): ] # The same info, but in a different form INITFORMAT = "HhllO&O&O&O&O&llllllb" - INITARGS = """&((FSCatalogInfoObject *)self)->ob_itself.nodeFlags, - &((FSCatalogInfoObject *)self)->ob_itself.volume, - &((FSCatalogInfoObject *)self)->ob_itself.parentDirID, - &((FSCatalogInfoObject *)self)->ob_itself.nodeID, - UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.createDate, - UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.contentModDate, - UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.attributeModDate, - UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.accessDate, - UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.backupDate, - &((FSCatalogInfoObject *)self)->ob_itself.valence, - &((FSCatalogInfoObject *)self)->ob_itself.dataLogicalSize, - &((FSCatalogInfoObject *)self)->ob_itself.dataPhysicalSize, - &((FSCatalogInfoObject *)self)->ob_itself.rsrcLogicalSize, - &((FSCatalogInfoObject *)self)->ob_itself.rsrcPhysicalSize, - &((FSCatalogInfoObject *)self)->ob_itself.sharingFlags, - &((FSCatalogInfoObject *)self)->ob_itself.userPrivileges""" + INITARGS = """&((FSCatalogInfoObject *)_self)->ob_itself.nodeFlags, + &((FSCatalogInfoObject *)_self)->ob_itself.volume, + &((FSCatalogInfoObject *)_self)->ob_itself.parentDirID, + &((FSCatalogInfoObject *)_self)->ob_itself.nodeID, + UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.createDate, + UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.contentModDate, + UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.attributeModDate, + UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.accessDate, + UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.backupDate, + &((FSCatalogInfoObject *)_self)->ob_itself.valence, + &((FSCatalogInfoObject *)_self)->ob_itself.dataLogicalSize, + &((FSCatalogInfoObject *)_self)->ob_itself.dataPhysicalSize, + &((FSCatalogInfoObject *)_self)->ob_itself.rsrcLogicalSize, + &((FSCatalogInfoObject *)_self)->ob_itself.rsrcPhysicalSize, + &((FSCatalogInfoObject *)_self)->ob_itself.sharingFlags, + &((FSCatalogInfoObject *)_self)->ob_itself.userPrivileges""" INITNAMES = """ "nodeFlags", "volume", @@ -442,7 +442,7 @@ class FSCatalogInfoDefinition(PEP253Mixin, ObjectDefinition): def output_tp_initBody(self): Output("static char *kw[] = {%s, 0};", self.INITNAMES) Output() - Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|%s\", kw, %s))", + Output("if (!PyArg_ParseTupleAndKeywords(_args, _kwds, \"|%s\", kw, %s))", self.INITFORMAT, self.INITARGS) OutLbrace() Output("return -1;") @@ -498,9 +498,9 @@ class FInfoDefinition(PEP253Mixin, ObjectDefinition): Output("%s *itself = NULL;", self.itselftype) Output("static char *kw[] = {\"itself\", 0};") Output() - Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"|O&\", kw, FInfo_Convert, &itself))") + Output("if (PyArg_ParseTupleAndKeywords(_args, _kwds, \"|O&\", kw, FInfo_Convert, &itself))") OutLbrace() - Output("if (itself) memcpy(&((%s *)self)->ob_itself, itself, sizeof(%s));", + Output("if (itself) memcpy(&((%s *)_self)->ob_itself, itself, sizeof(%s));", self.objecttype, self.itselftype) Output("return 0;") OutRbrace() @@ -540,7 +540,7 @@ class FSSpecDefinition(PEP253Mixin, ObjectDefinition): Output("int rawdatalen = 0;") Output("static char *kw[] = {\"itself\", \"rawdata\", 0};") Output() - Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|Os#\", kw, &v, &rawdata, &rawdatalen))") + Output("if (!PyArg_ParseTupleAndKeywords(_args, _kwds, \"|Os#\", kw, &v, &rawdata, &rawdatalen))") Output("return -1;") Output("if (v && rawdata)") OutLbrace() @@ -560,10 +560,10 @@ class FSSpecDefinition(PEP253Mixin, ObjectDefinition): self.itselftype) Output("return -1;") OutRbrace() - Output("memcpy(&((%s *)self)->ob_itself, rawdata, rawdatalen);", self.objecttype) + Output("memcpy(&((%s *)_self)->ob_itself, rawdata, rawdatalen);", self.objecttype) Output("return 0;") OutRbrace() - Output("if (PyMac_GetFSSpec(v, &((%s *)self)->ob_itself)) return 0;", self.objecttype) + Output("if (PyMac_GetFSSpec(v, &((%s *)_self)->ob_itself)) return 0;", self.objecttype) Output("return -1;") def outputRepr(self): @@ -613,7 +613,7 @@ class FSRefDefinition(PEP253Mixin, ObjectDefinition): Output("int rawdatalen = 0;") Output("static char *kw[] = {\"itself\", \"rawdata\", 0};") Output() - Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|Os#\", kw, &v, &rawdata, &rawdatalen))") + Output("if (!PyArg_ParseTupleAndKeywords(_args, _kwds, \"|Os#\", kw, &v, &rawdata, &rawdatalen))") Output("return -1;") Output("if (v && rawdata)") OutLbrace() @@ -633,10 +633,10 @@ class FSRefDefinition(PEP253Mixin, ObjectDefinition): self.itselftype) Output("return -1;") OutRbrace() - Output("memcpy(&((%s *)self)->ob_itself, rawdata, rawdatalen);", self.objecttype) + Output("memcpy(&((%s *)_self)->ob_itself, rawdata, rawdatalen);", self.objecttype) Output("return 0;") OutRbrace() - Output("if (PyMac_GetFSRef(v, &((%s *)self)->ob_itself)) return 0;", self.objecttype) + Output("if (PyMac_GetFSRef(v, &((%s *)_self)->ob_itself)) return 0;", self.objecttype) Output("return -1;") class AliasDefinition(PEP253Mixin, ObjectDefinition): @@ -689,7 +689,7 @@ class AliasDefinition(PEP253Mixin, ObjectDefinition): Output("Handle h;") Output("static char *kw[] = {\"itself\", \"rawdata\", 0};") Output() - Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&s#\", kw, %s_Convert, &itself, &rawdata, &rawdatalen))", + Output("if (!PyArg_ParseTupleAndKeywords(_args, _kwds, \"|O&s#\", kw, %s_Convert, &itself, &rawdata, &rawdatalen))", self.prefix) Output("return -1;") Output("if (itself && rawdata)") @@ -712,10 +712,10 @@ class AliasDefinition(PEP253Mixin, ObjectDefinition): Output("HLock(h);") Output("memcpy((char *)*h, rawdata, rawdatalen);") Output("HUnlock(h);") - Output("((%s *)self)->ob_itself = (%s)h;", self.objecttype, self.itselftype) + Output("((%s *)_self)->ob_itself = (%s)h;", self.objecttype, self.itselftype) Output("return 0;") OutRbrace() - Output("((%s *)self)->ob_itself = itself;", self.objecttype) + Output("((%s *)_self)->ob_itself = itself;", self.objecttype) Output("return 0;") # Alias methods come in two flavors: those with the alias as arg1 and diff --git a/Mac/Modules/fm/_Fmmodule.c b/Mac/Modules/fm/_Fmmodule.c index 816775d..890af54 100644 --- a/Mac/Modules/fm/_Fmmodule.c +++ b/Mac/Modules/fm/_Fmmodule.c @@ -25,12 +25,12 @@ static PyObject * FMRec_New(FMetricRec *itself) { - return Py_BuildValue("O&O&O&O&O&", - PyMac_BuildFixed, itself->ascent, - PyMac_BuildFixed, itself->descent, - PyMac_BuildFixed, itself->leading, - PyMac_BuildFixed, itself->widMax, - ResObj_New, itself->wTabHandle); + return Py_BuildValue("O&O&O&O&O&", + PyMac_BuildFixed, itself->ascent, + PyMac_BuildFixed, itself->descent, + PyMac_BuildFixed, itself->leading, + PyMac_BuildFixed, itself->widMax, + ResObj_New, itself->wTabHandle); } #if 0 @@ -38,12 +38,12 @@ FMRec_New(FMetricRec *itself) static int FMRec_Convert(PyObject *v, FMetricRec *p_itself) { - return PyArg_ParseTuple(v, "O&O&O&O&O&", - PyMac_GetFixed, &itself->ascent, - PyMac_GetFixed, &itself->descent, - PyMac_GetFixed, &itself->leading, - PyMac_GetFixed, &itself->widMax, - ResObj_Convert, &itself->wTabHandle); + return PyArg_ParseTuple(v, "O&O&O&O&O&", + PyMac_GetFixed, &itself->ascent, + PyMac_GetFixed, &itself->descent, + PyMac_GetFixed, &itself->leading, + PyMac_GetFixed, &itself->widMax, + ResObj_Convert, &itself->wTabHandle); } #endif diff --git a/Mac/Modules/ibcarbon/_IBCarbon.c b/Mac/Modules/ibcarbon/_IBCarbon.c index ce120c3..6baad7c 100644 --- a/Mac/Modules/ibcarbon/_IBCarbon.c +++ b/Mac/Modules/ibcarbon/_IBCarbon.c @@ -34,6 +34,7 @@ PyObject *IBNibRefObj_New(IBNibRef itself) it->ob_itself = itself; return (PyObject *)it; } + int IBNibRefObj_Convert(PyObject *v, IBNibRef *p_itself) { if (!IBNibRefObj_Check(v)) @@ -145,16 +146,16 @@ static PyMethodDef IBNibRefObj_methods[] = { #define IBNibRefObj_tp_alloc PyType_GenericAlloc -static PyObject *IBNibRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *IBNibRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; IBNibRef itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, IBNibRefObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((IBNibRefObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, IBNibRefObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((IBNibRefObject *)_self)->ob_itself = itself; + return _self; } #define IBNibRefObj_tp_free PyObject_Del diff --git a/Mac/Modules/launch/_Launchmodule.c b/Mac/Modules/launch/_Launchmodule.c index 8e0d726..fac55ee 100644 --- a/Mac/Modules/launch/_Launchmodule.c +++ b/Mac/Modules/launch/_Launchmodule.c @@ -27,21 +27,21 @@ PyObject *PyMac_GetOSErrException(void); static int OptCFStringRefObj_Convert(PyObject *v, CFStringRef *spec) { - if (v == Py_None) { - *spec = NULL; - return 1; - } - return CFStringRefObj_Convert(v, spec); + if (v == Py_None) { + *spec = NULL; + return 1; + } + return CFStringRefObj_Convert(v, spec); } PyObject * OptCFStringRefObj_New(CFStringRef it) { - if (it == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return CFStringRefObj_New(it); + if (it == NULL) { + Py_INCREF(Py_None); + return Py_None; + } + return CFStringRefObj_New(it); } /* @@ -50,13 +50,13 @@ OptCFStringRefObj_New(CFStringRef it) PyObject * LSItemInfoRecord_New(LSItemInfoRecord *it) { - return Py_BuildValue("{s:is:O&s:O&s:O&s:O&s:i}", - "flags", it->flags, - "filetype", PyMac_BuildOSType, it->filetype, - "creator", PyMac_BuildOSType, it->creator, - "extension", OptCFStringRefObj_New, it->extension, - "iconFileName", OptCFStringRefObj_New, it->iconFileName, - "kindID", it->kindID); + return Py_BuildValue("{s:is:O&s:O&s:O&s:O&s:i}", + "flags", it->flags, + "filetype", PyMac_BuildOSType, it->filetype, + "creator", PyMac_BuildOSType, it->creator, + "extension", OptCFStringRefObj_New, it->extension, + "iconFileName", OptCFStringRefObj_New, it->iconFileName, + "kindID", it->kindID); } static PyObject *Launch_Error; diff --git a/Mac/Modules/list/_Listmodule.c b/Mac/Modules/list/_Listmodule.c index bfea8a3..21a7f02 100644 --- a/Mac/Modules/list/_Listmodule.c +++ b/Mac/Modules/list/_Listmodule.c @@ -50,9 +50,9 @@ PyObject *ListObj_New(ListHandle itself) { ListObject *it; if (itself == NULL) { - PyErr_SetString(List_Error,"Cannot create null List"); - return NULL; - } + PyErr_SetString(List_Error,"Cannot create null List"); + return NULL; + } it = PyObject_NEW(ListObject, &List_Type); if (it == NULL) return NULL; it->ob_itself = itself; @@ -61,6 +61,7 @@ PyObject *ListObj_New(ListHandle itself) SetListRefCon(itself, (long)it); return (PyObject *)it; } + int ListObj_Convert(PyObject *v, ListHandle *p_itself) { if (!ListObj_Check(v)) @@ -738,16 +739,16 @@ static PyGetSetDef ListObj_getsetlist[] = { #define ListObj_tp_alloc PyType_GenericAlloc -static PyObject *ListObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *ListObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; ListHandle itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, ListObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((ListObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, ListObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((ListObject *)_self)->ob_itself = itself; + return _self; } #define ListObj_tp_free PyObject_Del @@ -826,10 +827,10 @@ static PyObject *List_CreateCustomList(PyObject *_self, PyObject *_args) &hasGrow, &scrollHoriz, &scrollVert)) - return NULL; + return NULL; - /* Carbon applications use the CreateCustomList API */ + /* Carbon applications use the CreateCustomList API */ theSpec.u.userProc = myListDefFunctionUPP; CreateCustomList(&rView, &dataBounds, @@ -845,7 +846,7 @@ static PyObject *List_CreateCustomList(PyObject *_self, PyObject *_args) _res = ListObj_New(outList); if (_res == NULL) - return NULL; + return NULL; Py_INCREF(listDefFunc); ((ListObject*)_res)->ob_ldef_func = listDefFunc; return _res; @@ -1024,7 +1025,7 @@ static PyObject *List_as_List(PyObject *_self, PyObject *_args) Handle h; ListObject *l; if (!PyArg_ParseTuple(_args, "O&", ResObj_Convert, &h)) - return NULL; + return NULL; l = (ListObject *)ListObj_New(as_List(h)); l->ob_must_be_disposed = 0; _res = Py_BuildValue("O", l); @@ -1066,34 +1067,34 @@ static void myListDefFunction(SInt16 message, Cell theCell, SInt16 dataOffset, SInt16 dataLen, - ListHandle theList) + ListHandle theList) { - PyObject *listDefFunc, *args, *rv=NULL; - ListObject *self; - - self = (ListObject*)GetListRefCon(theList); - if (self == NULL || self->ob_itself != theList) - return; /* nothing we can do */ - listDefFunc = self->ob_ldef_func; - if (listDefFunc == NULL) - return; /* nothing we can do */ - args = Py_BuildValue("hbO&O&hhO", message, - selected, - PyMac_BuildRect, cellRect, - PyMac_BuildPoint, theCell, - dataOffset, - dataLen, - self); - if (args != NULL) { - rv = PyEval_CallObject(listDefFunc, args); - Py_DECREF(args); - } - if (rv == NULL) { - PySys_WriteStderr("error in list definition callback:\n"); - PyErr_Print(); - } else { - Py_DECREF(rv); - } + PyObject *listDefFunc, *args, *rv=NULL; + ListObject *self; + + self = (ListObject*)GetListRefCon(theList); + if (self == NULL || self->ob_itself != theList) + return; /* nothing we can do */ + listDefFunc = self->ob_ldef_func; + if (listDefFunc == NULL) + return; /* nothing we can do */ + args = Py_BuildValue("hbO&O&hhO", message, + selected, + PyMac_BuildRect, cellRect, + PyMac_BuildPoint, theCell, + dataOffset, + dataLen, + self); + if (args != NULL) { + rv = PyEval_CallObject(listDefFunc, args); + Py_DECREF(args); + } + if (rv == NULL) { + PySys_WriteStderr("error in list definition callback:\n"); + PyErr_Print(); + } else { + Py_DECREF(rv); + } } diff --git a/Mac/Modules/menu/_Menumodule.c b/Mac/Modules/menu/_Menumodule.c index 8596a9d..e6a7f2f 100644 --- a/Mac/Modules/menu/_Menumodule.c +++ b/Mac/Modules/menu/_Menumodule.c @@ -24,7 +24,7 @@ extern PyObject *_MenuObj_New(MenuHandle); extern int _MenuObj_Convert(PyObject *, MenuHandle *); #define MenuObj_New _MenuObj_New -#define MenuObj_Convert _MenuObj_Convert +#define MenuObj_Convert _MenuObj_Convert #endif #define as_Menu(h) ((MenuHandle)h) @@ -34,21 +34,21 @@ extern int _MenuObj_Convert(PyObject *, MenuHandle *); /* Alternative version of MenuObj_New, which returns None for NULL argument */ PyObject *OptMenuObj_New(MenuRef itself) { - if (itself == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return MenuObj_New(itself); + if (itself == NULL) { + Py_INCREF(Py_None); + return Py_None; + } + return MenuObj_New(itself); } /* Alternative version of MenuObj_Convert, which returns NULL for a None argument */ int OptMenuObj_Convert(PyObject *v, MenuRef *p_itself) { - if ( v == Py_None ) { - *p_itself = NULL; - return 1; - } - return MenuObj_Convert(v, p_itself); + if ( v == Py_None ) { + *p_itself = NULL; + return 1; + } + return MenuObj_Convert(v, p_itself); } static PyObject *Menu_Error; @@ -72,6 +72,7 @@ PyObject *MenuObj_New(MenuHandle itself) it->ob_itself = itself; return (PyObject *)it; } + int MenuObj_Convert(PyObject *v, MenuHandle *p_itself) { if (!MenuObj_Check(v)) @@ -2536,16 +2537,16 @@ static PyMethodDef MenuObj_methods[] = { #define MenuObj_tp_alloc PyType_GenericAlloc -static PyObject *MenuObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *MenuObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; MenuHandle itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, MenuObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((MenuObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, MenuObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((MenuObject *)_self)->ob_itself = itself; + return _self; } #define MenuObj_tp_free PyObject_Del @@ -3445,8 +3446,8 @@ void init_Menu(void) - PyMac_INIT_TOOLBOX_OBJECT_NEW(MenuHandle, MenuObj_New); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(MenuHandle, MenuObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(MenuHandle, MenuObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(MenuHandle, MenuObj_Convert); m = Py_InitModule("_Menu", Menu_methods); diff --git a/Mac/Modules/mlte/_Mltemodule.c b/Mac/Modules/mlte/_Mltemodule.c index 0b37fe1..64ceaf6 100644 --- a/Mac/Modules/mlte/_Mltemodule.c +++ b/Mac/Modules/mlte/_Mltemodule.c @@ -38,14 +38,14 @@ static int TXNFontMenuObj_Convert(PyObject *, TXNFontMenuObject *); static int OptFSSpecPtr_Convert(PyObject *v, FSSpec **p_itself) { - static FSSpec fss; - if (v == Py_None) - { - *p_itself = NULL; - return 1; - } - *p_itself = &fss; - return PyMac_GetFSSpec(v, *p_itself); + static FSSpec fss; + if (v == Py_None) + { + *p_itself = NULL; + return 1; + } + *p_itself = &fss; + return PyMac_GetFSSpec(v, *p_itself); } /* @@ -54,15 +54,15 @@ OptFSSpecPtr_Convert(PyObject *v, FSSpec **p_itself) static int OptRectPtr_Convert(PyObject *v, Rect **p_itself) { - static Rect r; - - if (v == Py_None) - { - *p_itself = NULL; - return 1; - } - *p_itself = &r; - return PyMac_GetRect(v, *p_itself); + static Rect r; + + if (v == Py_None) + { + *p_itself = NULL; + return 1; + } + *p_itself = &r; + return PyMac_GetRect(v, *p_itself); } /* @@ -70,13 +70,13 @@ OptRectPtr_Convert(PyObject *v, Rect **p_itself) */ static int OptGWorldObj_Convert(PyObject *v, GWorldPtr *p_itself) -{ - if (v == Py_None) - { - *p_itself = NULL; - return 1; - } - return GWorldObj_Convert(v, p_itself); +{ + if (v == Py_None) + { + *p_itself = NULL; + return 1; + } + return GWorldObj_Convert(v, p_itself); } @@ -102,6 +102,7 @@ PyObject *TXNObj_New(TXNObject itself) it->ob_itself = itself; return (PyObject *)it; } + int TXNObj_Convert(PyObject *v, TXNObject *p_itself) { if (!TXNObj_Check(v)) @@ -1255,16 +1256,16 @@ static PyMethodDef TXNObj_methods[] = { #define TXNObj_tp_alloc PyType_GenericAlloc -static PyObject *TXNObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *TXNObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; TXNObject itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, TXNObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((TXNObjectObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, TXNObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((TXNObjectObject *)_self)->ob_itself = itself; + return _self; } #define TXNObj_tp_free PyObject_Del @@ -1337,6 +1338,7 @@ PyObject *TXNFontMenuObj_New(TXNFontMenuObject itself) it->ob_itself = itself; return (PyObject *)it; } + int TXNFontMenuObj_Convert(PyObject *v, TXNFontMenuObject *p_itself) { if (!TXNFontMenuObj_Check(v)) @@ -1408,16 +1410,16 @@ static PyMethodDef TXNFontMenuObj_methods[] = { #define TXNFontMenuObj_tp_alloc PyType_GenericAlloc -static PyObject *TXNFontMenuObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *TXNFontMenuObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; TXNFontMenuObject itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, TXNFontMenuObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((TXNFontMenuObjectObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, TXNFontMenuObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((TXNFontMenuObjectObject *)_self)->ob_itself = itself; + return _self; } #define TXNFontMenuObj_tp_free PyObject_Del @@ -1626,7 +1628,7 @@ static PyObject *Mlte_TXNInitTextension(PyObject *_self, PyObject *_args) TXNInitOptions iUsageFlags; PyMac_PRECHECK(TXNInitTextension); if (!PyArg_ParseTuple(_args, "l", &iUsageFlags)) - return NULL; + return NULL; _err = TXNInitTextension(iDefaultFonts, iCountDefaultFonts, iUsageFlags); @@ -1667,7 +1669,7 @@ void init_Mlte(void) - // PyMac_INIT_TOOLBOX_OBJECT_NEW(xxxx); + // PyMac_INIT_TOOLBOX_OBJECT_NEW(xxxx); m = Py_InitModule("_Mlte", Mlte_methods); diff --git a/Mac/Modules/osa/_OSAmodule.c b/Mac/Modules/osa/_OSAmodule.c index b3a2791..fca4f9b 100644 --- a/Mac/Modules/osa/_OSAmodule.c +++ b/Mac/Modules/osa/_OSAmodule.c @@ -45,21 +45,22 @@ PyObject *OSAObj_New(ComponentInstance itself) { OSAComponentInstanceObject *it; if (itself == NULL) { - PyErr_SetString(OSA_Error,"NULL ComponentInstance"); - return NULL; - } + PyErr_SetString(OSA_Error,"NULL ComponentInstance"); + return NULL; + } it = PyObject_NEW(OSAComponentInstanceObject, &OSAComponentInstance_Type); if (it == NULL) return NULL; it->ob_itself = itself; return (PyObject *)it; } + int OSAObj_Convert(PyObject *v, ComponentInstance *p_itself) { - if (CmpInstObj_Convert(v, p_itself)) - return 1; - PyErr_Clear(); - + if (CmpInstObj_Convert(v, p_itself)) + return 1; + PyErr_Clear(); + if (!OSAObj_Check(v)) { PyErr_SetString(PyExc_TypeError, "OSAComponentInstance required"); @@ -1133,16 +1134,16 @@ static PyMethodDef OSAObj_methods[] = { #define OSAObj_tp_alloc PyType_GenericAlloc -static PyObject *OSAObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *OSAObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; ComponentInstance itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, OSAObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((OSAComponentInstanceObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, OSAObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((OSAComponentInstanceObject *)_self)->ob_itself = itself; + return _self; } #define OSAObj_tp_free PyObject_Del @@ -1210,8 +1211,8 @@ void init_OSA(void) /* - PyMac_INIT_TOOLBOX_OBJECT_NEW(ComponentInstance, OSAObj_New); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ComponentInstance, OSAObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(ComponentInstance, OSAObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ComponentInstance, OSAObj_Convert); */ diff --git a/Mac/Modules/qd/_Qdmodule.c b/Mac/Modules/qd/_Qdmodule.c index 86db3c7..118dfc4 100644 --- a/Mac/Modules/qd/_Qdmodule.c +++ b/Mac/Modules/qd/_Qdmodule.c @@ -41,19 +41,19 @@ static PyObject *BMObj_NewCopied(BitMapPtr); PyObject *QdRGB_New(RGBColorPtr itself) { - return Py_BuildValue("lll", (long)itself->red, (long)itself->green, (long)itself->blue); + return Py_BuildValue("lll", (long)itself->red, (long)itself->green, (long)itself->blue); } int QdRGB_Convert(PyObject *v, RGBColorPtr p_itself) { - long red, green, blue; - - if( !PyArg_ParseTuple(v, "lll", &red, &green, &blue) ) - return 0; - p_itself->red = (unsigned short)red; - p_itself->green = (unsigned short)green; - p_itself->blue = (unsigned short)blue; - return 1; + long red, green, blue; + + if( !PyArg_ParseTuple(v, "lll", &red, &green, &blue) ) + return 0; + p_itself->red = (unsigned short)red; + p_itself->green = (unsigned short)green; + p_itself->blue = (unsigned short)blue; + return 1; } /* @@ -63,8 +63,8 @@ static PyObject *QdFI_New(FontInfo *itself) { - return Py_BuildValue("hhhh", itself->ascent, itself->descent, - itself->widMax, itself->leading); + return Py_BuildValue("hhhh", itself->ascent, itself->descent, + itself->widMax, itself->leading); } static PyObject *Qd_Error; @@ -89,6 +89,7 @@ PyObject *GrafObj_New(GrafPtr itself) it->ob_itself = itself; return (PyObject *)it; } + int GrafObj_Convert(PyObject *v, GrafPtr *p_itself) { #if 1 @@ -1310,8 +1311,8 @@ static PyMethodDef GrafObj_methods[] = { 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)); - + return Py_BuildValue("O&", ResObj_New, (Handle)GetPortVisibleRegion(self->ob_itself, h)); + } #define GrafObj_set_visRgn NULL @@ -1319,8 +1320,8 @@ static PyObject *GrafObj_get_visRgn(GrafPortObject *self, void *closure) 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)); - + return Py_BuildValue("O&", ResObj_New, (Handle)GetPortClipRegion(self->ob_itself, h)); + } #define GrafObj_set_clipRgn NULL @@ -1341,16 +1342,16 @@ static PyGetSetDef GrafObj_getsetlist[] = { #define GrafObj_tp_alloc PyType_GenericAlloc -static PyObject *GrafObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *GrafObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; GrafPtr itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, GrafObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((GrafPortObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, GrafObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((GrafPortObject *)_self)->ob_itself = itself; + return _self; } #define GrafObj_tp_free PyObject_Del @@ -1427,6 +1428,7 @@ PyObject *BMObj_New(BitMapPtr itself) it->referred_bitmap = NULL; return (PyObject *)it; } + int BMObj_Convert(PyObject *v, BitMapPtr *p_itself) { if (!BMObj_Check(v)) @@ -1453,7 +1455,7 @@ static PyObject *BMObj_getdata(BitMapObject *_self, PyObject *_args) char *cp; if ( !PyArg_ParseTuple(_args, "ii", &from, &length) ) - return NULL; + return NULL; cp = _self->ob_itself->baseAddr+from; _res = PyString_FromStringAndSize(cp, length); return _res; @@ -1468,7 +1470,7 @@ static PyObject *BMObj_putdata(BitMapObject *_self, PyObject *_args) char *cp, *icp; if ( !PyArg_ParseTuple(_args, "is#", &from, &icp, &length) ) - return NULL; + return NULL; cp = _self->ob_itself->baseAddr+from; memcpy(cp, icp, length); Py_INCREF(Py_None); @@ -1539,16 +1541,16 @@ static PyGetSetDef BMObj_getsetlist[] = { #define BMObj_tp_alloc PyType_GenericAlloc -static PyObject *BMObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *BMObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; BitMapPtr itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, BMObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((BitMapObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, BMObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((BitMapObject *)_self)->ob_itself = itself; + return _self; } #define BMObj_tp_free PyObject_Del @@ -5822,6 +5824,7 @@ static PyObject *Qd_MacDrawText(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; char *textBuf__in__; + int textBuf__len__; int textBuf__in_len__; short firstByte; short byteCount; @@ -5882,6 +5885,7 @@ static PyObject *Qd_TextWidth(PyObject *_self, PyObject *_args) PyObject *_res = NULL; short _rv; char *textBuf__in__; + int textBuf__len__; int textBuf__in_len__; short firstByte; short byteCount; @@ -6467,6 +6471,7 @@ static PyObject *Qd_DrawText(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; char *textBuf__in__; + int textBuf__len__; int textBuf__in_len__; short firstByte; short byteCount; @@ -6499,17 +6504,17 @@ static PyObject *Qd_BitMap(PyObject *_self, PyObject *_args) char *data; if ( !PyArg_ParseTuple(_args, "O!iO&", &PyString_Type, &source, &rowbytes, PyMac_GetRect, - &bounds) ) - return NULL; + &bounds) ) + return NULL; data = PyString_AsString(source); if ((ptr=(BitMap *)malloc(sizeof(BitMap))) == NULL ) - return PyErr_NoMemory(); + return PyErr_NoMemory(); ptr->baseAddr = (Ptr)data; ptr->rowBytes = rowbytes; ptr->bounds = bounds; if ( (_res = BMObj_New(ptr)) == NULL ) { - free(ptr); - return NULL; + free(ptr); + return NULL; } ((BitMapObject *)_res)->referred_object = source; Py_INCREF(source); @@ -6526,16 +6531,16 @@ static PyObject *Qd_RawBitMap(PyObject *_self, PyObject *_args) PyObject *source; if ( !PyArg_ParseTuple(_args, "O!", &PyString_Type, &source) ) - return NULL; + return NULL; if ( PyString_Size(source) != sizeof(BitMap) && PyString_Size(source) != sizeof(PixMap) ) { - PyErr_Format(PyExc_TypeError, - "Argument size was %d, should be %d (sizeof BitMap) or %d (sizeof PixMap)", - PyString_Size(source), sizeof(BitMap), sizeof(PixMap)); - return NULL; + PyErr_Format(PyExc_TypeError, + "Argument size was %d, should be %d (sizeof BitMap) or %d (sizeof PixMap)", + PyString_Size(source), sizeof(BitMap), sizeof(PixMap)); + return NULL; } ptr = (BitMapPtr)PyString_AsString(source); if ( (_res = BMObj_New(ptr)) == NULL ) { - return NULL; + return NULL; } ((BitMapObject *)_res)->referred_object = source; Py_INCREF(source); @@ -7088,15 +7093,15 @@ static PyMethodDef Qd_methods[] = { */ PyObject *BMObj_NewCopied(BitMapPtr itself) { - BitMapObject *it; - BitMapPtr itself_copy; - - if ((itself_copy=(BitMapPtr)malloc(sizeof(BitMap))) == NULL) - return PyErr_NoMemory(); - *itself_copy = *itself; - it = (BitMapObject *)BMObj_New(itself_copy); - it->referred_bitmap = itself_copy; - return (PyObject *)it; + BitMapObject *it; + BitMapPtr itself_copy; + + if ((itself_copy=(BitMapPtr)malloc(sizeof(BitMap))) == NULL) + return PyErr_NoMemory(); + *itself_copy = *itself; + it = (BitMapObject *)BMObj_New(itself_copy); + it->referred_bitmap = itself_copy; + return (PyObject *)it; } @@ -7108,12 +7113,12 @@ void init_Qd(void) - PyMac_INIT_TOOLBOX_OBJECT_NEW(BitMapPtr, BMObj_New); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(BitMapPtr, BMObj_Convert); - PyMac_INIT_TOOLBOX_OBJECT_NEW(GrafPtr, GrafObj_New); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GrafPtr, GrafObj_Convert); - PyMac_INIT_TOOLBOX_OBJECT_NEW(RGBColorPtr, QdRGB_New); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(RGBColor, QdRGB_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(BitMapPtr, BMObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(BitMapPtr, BMObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(GrafPtr, GrafObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GrafPtr, GrafObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(RGBColorPtr, QdRGB_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(RGBColor, QdRGB_Convert); m = Py_InitModule("_Qd", Qd_methods); diff --git a/Mac/Modules/qdoffs/_Qdoffsmodule.c b/Mac/Modules/qdoffs/_Qdoffsmodule.c index 1cb4564..9a77054 100644 --- a/Mac/Modules/qdoffs/_Qdoffsmodule.c +++ b/Mac/Modules/qdoffs/_Qdoffsmodule.c @@ -50,6 +50,7 @@ PyObject *GWorldObj_New(GWorldPtr itself) it->ob_itself = itself; return (PyObject *)it; } + int GWorldObj_Convert(PyObject *v, GWorldPtr *p_itself) { if (!GWorldObj_Check(v)) @@ -134,16 +135,16 @@ static PyMethodDef GWorldObj_methods[] = { #define GWorldObj_tp_alloc PyType_GenericAlloc -static PyObject *GWorldObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *GWorldObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; GWorldPtr itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, GWorldObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((GWorldObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, GWorldObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((GWorldObject *)_self)->ob_itself = itself; + return _self; } #define GWorldObj_tp_free PyObject_Del @@ -605,7 +606,7 @@ static PyObject *Qdoffs_GetPixMapBytes(PyObject *_self, PyObject *_args) char *cp; if ( !PyArg_ParseTuple(_args, "O&ii", ResObj_Convert, &pm, &from, &length) ) - return NULL; + return NULL; cp = GetPixBaseAddr(pm)+from; _res = PyString_FromStringAndSize(cp, length); return _res; @@ -621,7 +622,7 @@ static PyObject *Qdoffs_PutPixMapBytes(PyObject *_self, PyObject *_args) char *cp, *icp; if ( !PyArg_ParseTuple(_args, "O&is#", ResObj_Convert, &pm, &from, &icp, &length) ) - return NULL; + return NULL; cp = GetPixBaseAddr(pm)+from; memcpy(cp, icp, length); Py_INCREF(Py_None); @@ -690,8 +691,8 @@ void init_Qdoffs(void) - PyMac_INIT_TOOLBOX_OBJECT_NEW(GWorldPtr, GWorldObj_New); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GWorldPtr, GWorldObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(GWorldPtr, GWorldObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GWorldPtr, GWorldObj_Convert); m = Py_InitModule("_Qdoffs", Qdoffs_methods); diff --git a/Mac/Modules/qt/_Qtmodule.c b/Mac/Modules/qt/_Qtmodule.c index 50223ec..65cec4b 100644 --- a/Mac/Modules/qt/_Qtmodule.c +++ b/Mac/Modules/qt/_Qtmodule.c @@ -47,45 +47,45 @@ extern int _MediaObj_Convert(PyObject *, Media *); #endif /* Macro to allow us to GetNextInterestingTime without duration */ -#define GetMediaNextInterestingTimeOnly(media, flags, time, rate, rv) GetMediaNextInterestingTime(media, flags, time, rate, rv, NULL) - +#define GetMediaNextInterestingTimeOnly(media, flags, time, rate, rv) GetMediaNextInterestingTime(media, flags, time, rate, rv, NULL) + /* ** Parse/generate time records */ static PyObject * QtTimeRecord_New(TimeRecord *itself) { - if (itself->base) - return Py_BuildValue("O&lO&", PyMac_Buildwide, &itself->value, itself->scale, - TimeBaseObj_New, itself->base); - else - return Py_BuildValue("O&lO", PyMac_Buildwide, &itself->value, itself->scale, - Py_None); + if (itself->base) + return Py_BuildValue("O&lO&", PyMac_Buildwide, &itself->value, itself->scale, + TimeBaseObj_New, itself->base); + else + return Py_BuildValue("O&lO", PyMac_Buildwide, &itself->value, itself->scale, + Py_None); } static int QtTimeRecord_Convert(PyObject *v, TimeRecord *p_itself) { - PyObject *base = NULL; - if( !PyArg_ParseTuple(v, "O&l|O", PyMac_Getwide, &p_itself->value, &p_itself->scale, - &base) ) - return 0; - if ( base == NULL || base == Py_None ) - p_itself->base = NULL; - else - if ( !TimeBaseObj_Convert(base, &p_itself->base) ) - return 0; - return 1; + PyObject *base = NULL; + if( !PyArg_ParseTuple(v, "O&l|O", PyMac_Getwide, &p_itself->value, &p_itself->scale, + &base) ) + return 0; + if ( base == NULL || base == Py_None ) + p_itself->base = NULL; + else + if ( !TimeBaseObj_Convert(base, &p_itself->base) ) + return 0; + return 1; } static int QtMusicMIDIPacket_Convert(PyObject *v, MusicMIDIPacket *p_itself) { - int dummy; - - if( !PyArg_ParseTuple(v, "hls#", &p_itself->length, &p_itself->reserved, p_itself->data, dummy) ) - return 0; - return 1; + int dummy; + + if( !PyArg_ParseTuple(v, "hls#", &p_itself->length, &p_itself->reserved, p_itself->data, dummy) ) + return 0; + return 1; } @@ -108,14 +108,15 @@ PyObject *IdleManagerObj_New(IdleManager itself) { IdleManagerObject *it; if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create IdleManager from NULL pointer"); - return NULL; - } + PyErr_SetString(Qt_Error,"Cannot create IdleManager from NULL pointer"); + return NULL; + } it = PyObject_NEW(IdleManagerObject, &IdleManager_Type); if (it == NULL) return NULL; it->ob_itself = itself; return (PyObject *)it; } + int IdleManagerObj_Convert(PyObject *v, IdleManager *p_itself) { if (v == Py_None) @@ -154,16 +155,16 @@ static PyMethodDef IdleManagerObj_methods[] = { #define IdleManagerObj_tp_alloc PyType_GenericAlloc -static PyObject *IdleManagerObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *IdleManagerObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; IdleManager itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, IdleManagerObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((IdleManagerObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, IdleManagerObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((IdleManagerObject *)_self)->ob_itself = itself; + return _self; } #define IdleManagerObj_tp_free PyObject_Del @@ -231,14 +232,15 @@ PyObject *MovieCtlObj_New(MovieController itself) { MovieControllerObject *it; if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create MovieController from NULL pointer"); - return NULL; - } + PyErr_SetString(Qt_Error,"Cannot create MovieController from NULL pointer"); + return NULL; + } it = PyObject_NEW(MovieControllerObject, &MovieController_Type); if (it == NULL) return NULL; it->ob_itself = itself; return (PyObject *)it; } + int MovieCtlObj_Convert(PyObject *v, MovieController *p_itself) { if (v == Py_None) @@ -1273,16 +1275,16 @@ static PyMethodDef MovieCtlObj_methods[] = { #define MovieCtlObj_tp_alloc PyType_GenericAlloc -static PyObject *MovieCtlObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *MovieCtlObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; MovieController itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, MovieCtlObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((MovieControllerObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, MovieCtlObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((MovieControllerObject *)_self)->ob_itself = itself; + return _self; } #define MovieCtlObj_tp_free PyObject_Del @@ -1350,14 +1352,15 @@ PyObject *TimeBaseObj_New(TimeBase itself) { TimeBaseObject *it; if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create TimeBase from NULL pointer"); - return NULL; - } + PyErr_SetString(Qt_Error,"Cannot create TimeBase from NULL pointer"); + return NULL; + } it = PyObject_NEW(TimeBaseObject, &TimeBase_Type); if (it == NULL) return NULL; it->ob_itself = itself; return (PyObject *)it; } + int TimeBaseObj_Convert(PyObject *v, TimeBase *p_itself) { if (v == Py_None) @@ -1766,16 +1769,16 @@ static PyMethodDef TimeBaseObj_methods[] = { #define TimeBaseObj_tp_alloc PyType_GenericAlloc -static PyObject *TimeBaseObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *TimeBaseObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; TimeBase itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, TimeBaseObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((TimeBaseObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, TimeBaseObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((TimeBaseObject *)_self)->ob_itself = itself; + return _self; } #define TimeBaseObj_tp_free PyObject_Del @@ -1843,14 +1846,15 @@ PyObject *UserDataObj_New(UserData itself) { UserDataObject *it; if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create UserData from NULL pointer"); - return NULL; - } + PyErr_SetString(Qt_Error,"Cannot create UserData from NULL pointer"); + return NULL; + } it = PyObject_NEW(UserDataObject, &UserData_Type); if (it == NULL) return NULL; it->ob_itself = itself; return (PyObject *)it; } + int UserDataObj_Convert(PyObject *v, UserData *p_itself) { if (v == Py_None) @@ -2136,16 +2140,16 @@ static PyMethodDef UserDataObj_methods[] = { #define UserDataObj_tp_alloc PyType_GenericAlloc -static PyObject *UserDataObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *UserDataObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; UserData itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, UserDataObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((UserDataObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, UserDataObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((UserDataObject *)_self)->ob_itself = itself; + return _self; } #define UserDataObj_tp_free PyObject_Del @@ -2213,14 +2217,15 @@ PyObject *MediaObj_New(Media itself) { MediaObject *it; if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create Media from NULL pointer"); - return NULL; - } + PyErr_SetString(Qt_Error,"Cannot create Media from NULL pointer"); + return NULL; + } it = PyObject_NEW(MediaObject, &Media_Type); if (it == NULL) return NULL; it->ob_itself = itself; return (PyObject *)it; } + int MediaObj_Convert(PyObject *v, Media *p_itself) { if (v == Py_None) @@ -3377,16 +3382,16 @@ static PyMethodDef MediaObj_methods[] = { #define MediaObj_tp_alloc PyType_GenericAlloc -static PyObject *MediaObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *MediaObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; Media itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, MediaObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((MediaObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, MediaObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((MediaObject *)_self)->ob_itself = itself; + return _self; } #define MediaObj_tp_free PyObject_Del @@ -3454,14 +3459,15 @@ PyObject *TrackObj_New(Track itself) { TrackObject *it; if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create Track from NULL pointer"); - return NULL; - } + PyErr_SetString(Qt_Error,"Cannot create Track from NULL pointer"); + return NULL; + } it = PyObject_NEW(TrackObject, &Track_Type); if (it == NULL) return NULL; it->ob_itself = itself; return (PyObject *)it; } + int TrackObj_Convert(PyObject *v, Track *p_itself) { if (v == Py_None) @@ -4724,16 +4730,16 @@ static PyMethodDef TrackObj_methods[] = { #define TrackObj_tp_alloc PyType_GenericAlloc -static PyObject *TrackObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *TrackObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; Track itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, TrackObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((TrackObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, TrackObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((TrackObject *)_self)->ob_itself = itself; + return _self; } #define TrackObj_tp_free PyObject_Del @@ -4801,14 +4807,15 @@ PyObject *MovieObj_New(Movie itself) { MovieObject *it; if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create Movie from NULL pointer"); - return NULL; - } + PyErr_SetString(Qt_Error,"Cannot create Movie from NULL pointer"); + return NULL; + } it = PyObject_NEW(MovieObject, &Movie_Type); if (it == NULL) return NULL; it->ob_itself = itself; return (PyObject *)it; } + int MovieObj_Convert(PyObject *v, Movie *p_itself) { if (v == Py_None) @@ -7276,16 +7283,16 @@ static PyMethodDef MovieObj_methods[] = { #define MovieObj_tp_alloc PyType_GenericAlloc -static PyObject *MovieObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *MovieObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; Movie itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, MovieObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((MovieObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, MovieObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((MovieObject *)_self)->ob_itself = itself; + return _self; } #define MovieObj_tp_free PyObject_Del @@ -7353,14 +7360,15 @@ PyObject *SGOutputObj_New(SGOutput itself) { SGOutputObject *it; if (itself == NULL) { - PyErr_SetString(Qt_Error,"Cannot create SGOutput from NULL pointer"); - return NULL; - } + PyErr_SetString(Qt_Error,"Cannot create SGOutput from NULL pointer"); + return NULL; + } it = PyObject_NEW(SGOutputObject, &SGOutput_Type); if (it == NULL) return NULL; it->ob_itself = itself; return (PyObject *)it; } + int SGOutputObj_Convert(PyObject *v, SGOutput *p_itself) { if (v == Py_None) @@ -7399,16 +7407,16 @@ static PyMethodDef SGOutputObj_methods[] = { #define SGOutputObj_tp_alloc PyType_GenericAlloc -static PyObject *SGOutputObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *SGOutputObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; SGOutput itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, SGOutputObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((SGOutputObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, SGOutputObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((SGOutputObject *)_self)->ob_itself = itself; + return _self; } #define SGOutputObj_tp_free PyObject_Del @@ -27993,18 +28001,18 @@ void init_Qt(void) - PyMac_INIT_TOOLBOX_OBJECT_NEW(Track, TrackObj_New); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Track, TrackObj_Convert); - PyMac_INIT_TOOLBOX_OBJECT_NEW(Movie, MovieObj_New); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Movie, MovieObj_Convert); - PyMac_INIT_TOOLBOX_OBJECT_NEW(MovieController, MovieCtlObj_New); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(MovieController, MovieCtlObj_Convert); - PyMac_INIT_TOOLBOX_OBJECT_NEW(TimeBase, TimeBaseObj_New); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(TimeBase, TimeBaseObj_Convert); - PyMac_INIT_TOOLBOX_OBJECT_NEW(UserData, UserDataObj_New); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(UserData, UserDataObj_Convert); - PyMac_INIT_TOOLBOX_OBJECT_NEW(Media, MediaObj_New); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Media, MediaObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(Track, TrackObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Track, TrackObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(Movie, MovieObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Movie, MovieObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(MovieController, MovieCtlObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(MovieController, MovieCtlObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(TimeBase, TimeBaseObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(TimeBase, TimeBaseObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(UserData, UserDataObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(UserData, UserDataObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(Media, MediaObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Media, MediaObj_Convert); m = Py_InitModule("_Qt", Qt_methods); diff --git a/Mac/Modules/res/_Resmodule.c b/Mac/Modules/res/_Resmodule.c index d554a99..9069e9c 100644 --- a/Mac/Modules/res/_Resmodule.c +++ b/Mac/Modules/res/_Resmodule.c @@ -32,7 +32,7 @@ extern int _OptResObj_Convert(PyObject *, Handle *); static void PyMac_AutoDisposeHandle(Handle h) { - DisposeHandle(h); + DisposeHandle(h); } static PyObject *Res_Error; @@ -59,6 +59,7 @@ PyObject *ResObj_New(Handle itself) it->ob_freeit = NULL; return (PyObject *)it; } + int ResObj_Convert(PyObject *v, Handle *p_itself) { if (!ResObj_Check(v)) @@ -455,13 +456,13 @@ static PyObject *ResObj_AutoDispose(ResourceObject *_self, PyObject *_args) int onoff, old = 0; if (!PyArg_ParseTuple(_args, "i", &onoff)) - return NULL; + return NULL; if ( _self->ob_freeit ) - old = 1; + old = 1; if ( onoff ) - _self->ob_freeit = PyMac_AutoDisposeHandle; + _self->ob_freeit = PyMac_AutoDisposeHandle; else - _self->ob_freeit = NULL; + _self->ob_freeit = NULL; _res = Py_BuildValue("i", old); return _res; @@ -514,42 +515,42 @@ static PyMethodDef ResObj_methods[] = { static PyObject *ResObj_get_data(ResourceObject *self, void *closure) { - PyObject *res; - char state; + 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; - + 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; - + 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; } @@ -572,26 +573,26 @@ static PyGetSetDef ResObj_getsetlist[] = { #define ResObj_repr NULL #define ResObj_hash NULL -static int ResObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +static int ResObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) { char *srcdata = NULL; int srclen = 0; Handle itself; char *kw[] = {"itself", 0}; - if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, ResObj_Convert, &itself)) + if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, ResObj_Convert, &itself)) { - ((ResourceObject *)self)->ob_itself = itself; + ((ResourceObject *)_self)->ob_itself = itself; return 0; } PyErr_Clear(); - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|s#", kw, &srcdata, &srclen)) return -1; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "|s#", kw, &srcdata, &srclen)) return -1; if ((itself = NewHandle(srclen)) == NULL) { PyErr_NoMemory(); return 0; } - ((ResourceObject *)self)->ob_itself = itself; + ((ResourceObject *)_self)->ob_itself = itself; if (srclen && srcdata) { HLock(itself); @@ -603,7 +604,7 @@ static int ResObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) #define ResObj_tp_alloc PyType_GenericAlloc -static PyObject *ResObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *ResObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { PyObject *self; if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; @@ -1573,11 +1574,11 @@ static PyObject *Res_Handle(PyObject *_self, PyObject *_args) ResourceObject *rv; if (!PyArg_ParseTuple(_args, "s#", &buf, &len)) - return NULL; + return NULL; h = NewHandle(len); if ( h == NULL ) { - PyErr_NoMemory(); - return NULL; + PyErr_NoMemory(); + return NULL; } HLock(h); memcpy(*h, buf, len); @@ -1679,35 +1680,35 @@ static PyMethodDef Res_methods[] = { /* Alternative version of ResObj_New, which returns None for null argument */ PyObject *OptResObj_New(Handle itself) { - if (itself == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return ResObj_New(itself); + if (itself == NULL) { + Py_INCREF(Py_None); + return Py_None; + } + return ResObj_New(itself); } int OptResObj_Convert(PyObject *v, Handle *p_itself) { - PyObject *tmp; - - if ( v == Py_None ) { - *p_itself = NULL; - return 1; - } - if (ResObj_Check(v)) - { - *p_itself = ((ResourceObject *)v)->ob_itself; - return 1; - } - /* If it isn't a resource yet see whether it is convertible */ - if ( (tmp=PyObject_CallMethod(v, "as_Resource", "")) ) { - *p_itself = ((ResourceObject *)tmp)->ob_itself; - Py_DECREF(tmp); - return 1; - } - PyErr_Clear(); - PyErr_SetString(PyExc_TypeError, "Resource required"); - return 0; + PyObject *tmp; + + if ( v == Py_None ) { + *p_itself = NULL; + return 1; + } + if (ResObj_Check(v)) + { + *p_itself = ((ResourceObject *)v)->ob_itself; + return 1; + } + /* If it isn't a resource yet see whether it is convertible */ + if ( (tmp=PyObject_CallMethod(v, "as_Resource", "")) ) { + *p_itself = ((ResourceObject *)tmp)->ob_itself; + Py_DECREF(tmp); + return 1; + } + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError, "Resource required"); + return 0; } @@ -1718,10 +1719,10 @@ void init_Res(void) - PyMac_INIT_TOOLBOX_OBJECT_NEW(Handle, ResObj_New); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Handle, ResObj_Convert); - PyMac_INIT_TOOLBOX_OBJECT_NEW(Handle, OptResObj_New); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Handle, OptResObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(Handle, ResObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Handle, ResObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(Handle, OptResObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Handle, OptResObj_Convert); m = Py_InitModule("_Res", Res_methods); diff --git a/Mac/Modules/res/ressupport.py b/Mac/Modules/res/ressupport.py index 04a1821..9e42a45 100644 --- a/Mac/Modules/res/ressupport.py +++ b/Mac/Modules/res/ressupport.py @@ -182,20 +182,20 @@ class ResDefinition(PEP253Mixin, GlobalObjectDefinition): Output("%s itself;", self.itselftype); Output("char *kw[] = {\"itself\", 0};") Output() - Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"O&\", kw, %s_Convert, &itself))", + Output("if (PyArg_ParseTupleAndKeywords(_args, _kwds, \"O&\", kw, %s_Convert, &itself))", self.prefix); OutLbrace() - Output("((%s *)self)->ob_itself = itself;", self.objecttype) + Output("((%s *)_self)->ob_itself = itself;", self.objecttype) Output("return 0;") OutRbrace() Output("PyErr_Clear();") - Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|s#\", kw, &srcdata, &srclen)) return -1;") + Output("if (!PyArg_ParseTupleAndKeywords(_args, _kwds, \"|s#\", kw, &srcdata, &srclen)) return -1;") Output("if ((itself = NewHandle(srclen)) == NULL)") OutLbrace() Output("PyErr_NoMemory();") Output("return 0;") OutRbrace() - Output("((%s *)self)->ob_itself = itself;", self.objecttype) + Output("((%s *)_self)->ob_itself = itself;", self.objecttype) # XXXX Output("((%s *)self)->ob_freeit = PyMac_AutoDisposeHandle;") Output("if (srclen && srcdata)") OutLbrace() diff --git a/Mac/Modules/snd/_Sndmodule.c b/Mac/Modules/snd/_Sndmodule.c index 581bf1e..fcaee5f 100644 --- a/Mac/Modules/snd/_Sndmodule.c +++ b/Mac/Modules/snd/_Sndmodule.c @@ -21,16 +21,16 @@ static int SndCmd_Convert(PyObject *v, SndCommand *pc) { - int len; - pc->param1 = 0; - pc->param2 = 0; - if (PyTuple_Check(v)) { - if (PyArg_ParseTuple(v, "h|hl", &pc->cmd, &pc->param1, &pc->param2)) - return 1; - PyErr_Clear(); - return PyArg_ParseTuple(v, "Hhs#", &pc->cmd, &pc->param1, &pc->param2, &len); - } - return PyArg_Parse(v, "H", &pc->cmd); + int len; + pc->param1 = 0; + pc->param2 = 0; + if (PyTuple_Check(v)) { + if (PyArg_ParseTuple(v, "h|hl", &pc->cmd, &pc->param1, &pc->param2)) + return 1; + PyErr_Clear(); + return PyArg_ParseTuple(v, "Hhs#", &pc->cmd, &pc->param1, &pc->param2, &len); + } + return PyArg_Parse(v, "H", &pc->cmd); } static pascal void SndCh_UserRoutine(SndChannelPtr chan, SndCommand *cmd); /* Forward */ @@ -352,9 +352,9 @@ static PyObject *SPBObj_get_error(SPBObject *self, void *closure) 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; + self->ob_completion = v; + Py_INCREF(v); + return 0; return 0; } @@ -1056,62 +1056,62 @@ static PyMethodDef Snd_methods[] = { static int SndCh_CallCallBack(void *arg) { - SndChannelObject *p = (SndChannelObject *)arg; - PyObject *args; - PyObject *res; - args = Py_BuildValue("(O(hhl))", - p, p->ob_cmd.cmd, p->ob_cmd.param1, p->ob_cmd.param2); - res = PyEval_CallObject(p->ob_callback, args); - Py_DECREF(args); - if (res == NULL) - return -1; - Py_DECREF(res); - return 0; + SndChannelObject *p = (SndChannelObject *)arg; + PyObject *args; + PyObject *res; + args = Py_BuildValue("(O(hhl))", + p, p->ob_cmd.cmd, p->ob_cmd.param1, p->ob_cmd.param2); + res = PyEval_CallObject(p->ob_callback, args); + Py_DECREF(args); + if (res == NULL) + return -1; + Py_DECREF(res); + return 0; } /* Routine passed to NewSndChannel -- schedule a call to SndCh_CallCallBack */ static pascal void SndCh_UserRoutine(SndChannelPtr chan, SndCommand *cmd) { - SndChannelObject *p = (SndChannelObject *)(chan->userInfo); - if (p->ob_callback != NULL) { - long A5 = SetA5(p->ob_A5); - p->ob_cmd = *cmd; - Py_AddPendingCall(SndCh_CallCallBack, (void *)p); - SetA5(A5); - } + SndChannelObject *p = (SndChannelObject *)(chan->userInfo); + if (p->ob_callback != NULL) { + long A5 = SetA5(p->ob_A5); + p->ob_cmd = *cmd; + Py_AddPendingCall(SndCh_CallCallBack, (void *)p); + SetA5(A5); + } } /* SPB callbacks - Schedule callbacks to Python */ static int SPB_CallCallBack(void *arg) { - SPBObject *p = (SPBObject *)arg; - PyObject *args; - PyObject *res; - - if ( p->ob_thiscallback == 0 ) return 0; - args = Py_BuildValue("(O)", p); - res = PyEval_CallObject(p->ob_thiscallback, args); - p->ob_thiscallback = 0; - Py_DECREF(args); - if (res == NULL) - return -1; - Py_DECREF(res); - return 0; + SPBObject *p = (SPBObject *)arg; + PyObject *args; + PyObject *res; + + if ( p->ob_thiscallback == 0 ) return 0; + args = Py_BuildValue("(O)", p); + res = PyEval_CallObject(p->ob_thiscallback, args); + p->ob_thiscallback = 0; + Py_DECREF(args); + if (res == NULL) + return -1; + Py_DECREF(res); + return 0; } static pascal void SPB_completion(SPBPtr my_spb) { - SPBObject *p = (SPBObject *)(my_spb->userLong); - - if (p && p->ob_completion) { - long A5 = SetA5(p->ob_A5); - p->ob_thiscallback = p->ob_completion; /* Hope we cannot get two at the same time */ - Py_AddPendingCall(SPB_CallCallBack, (void *)p); - SetA5(A5); - } + SPBObject *p = (SPBObject *)(my_spb->userLong); + + if (p && p->ob_completion) { + long A5 = SetA5(p->ob_A5); + p->ob_thiscallback = p->ob_completion; /* Hope we cannot get two at the same time */ + Py_AddPendingCall(SPB_CallCallBack, (void *)p); + SetA5(A5); + } } diff --git a/Mac/Modules/te/_TEmodule.c b/Mac/Modules/te/_TEmodule.c index 0dd59c6..047b872 100644 --- a/Mac/Modules/te/_TEmodule.c +++ b/Mac/Modules/te/_TEmodule.c @@ -35,21 +35,21 @@ static PyObject * TextStyle_New(TextStylePtr itself) { - return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New, - &itself->tsColor); + return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New, + &itself->tsColor); } static int TextStyle_Convert(PyObject *v, TextStylePtr p_itself) { - long font, face, size; - - if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) ) - return 0; - p_itself->tsFont = (short)font; - p_itself->tsFace = (Style)face; - p_itself->tsSize = (short)size; - return 1; + long font, face, size; + + if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) ) + return 0; + p_itself->tsFont = (short)font; + p_itself->tsFace = (Style)face; + p_itself->tsSize = (short)size; + return 1; } static PyObject *TE_Error; @@ -69,14 +69,15 @@ PyObject *TEObj_New(TEHandle itself) { TEObject *it; if (itself == NULL) { - PyErr_SetString(TE_Error,"Cannot create null TE"); - return NULL; - } + PyErr_SetString(TE_Error,"Cannot create null TE"); + return NULL; + } it = PyObject_NEW(TEObject, &TE_Type); if (it == NULL) return NULL; it->ob_itself = itself; return (PyObject *)it; } + int TEObj_Convert(PyObject *v, TEHandle *p_itself) { if (!TEObj_Check(v)) @@ -983,16 +984,16 @@ static PyGetSetDef TEObj_getsetlist[] = { #define TEObj_tp_alloc PyType_GenericAlloc -static PyObject *TEObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *TEObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; TEHandle itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, TEObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((TEObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, TEObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((TEObject *)_self)->ob_itself = itself; + return _self; } #define TEObj_tp_free PyObject_Del @@ -1307,8 +1308,8 @@ void init_TE(void) - PyMac_INIT_TOOLBOX_OBJECT_NEW(TEHandle, TEObj_New); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(TEHandle, TEObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(TEHandle, TEObj_New); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(TEHandle, TEObj_Convert); m = Py_InitModule("_TE", TE_methods); diff --git a/Mac/Modules/waste/wastemodule.c b/Mac/Modules/waste/wastemodule.c index 53aff83..b8234f0 100644 --- a/Mac/Modules/waste/wastemodule.c +++ b/Mac/Modules/waste/wastemodule.c @@ -38,21 +38,21 @@ static PyObject * TextStyle_New(TextStylePtr itself) { - return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New, - &itself->tsColor); + return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New, + &itself->tsColor); } static int TextStyle_Convert(PyObject *v, TextStylePtr p_itself) { - long font, face, size; - - if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) ) - return 0; - p_itself->tsFont = (short)font; - p_itself->tsFace = (Style)face; - p_itself->tsSize = (short)size; - return 1; + long font, face, size; + + if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) ) + return 0; + p_itself->tsFont = (short)font; + p_itself->tsFace = (Style)face; + p_itself->tsSize = (short)size; + return 1; } /* @@ -62,33 +62,33 @@ static PyObject * RunInfo_New(WERunInfo *itself) { - return Py_BuildValue("llhhO&O&", itself->runStart, itself->runEnd, itself->runHeight, - itself->runAscent, TextStyle_New, &itself->runStyle, WEOObj_New, itself->runObject); + return Py_BuildValue("llhhO&O&", itself->runStart, itself->runEnd, itself->runHeight, + itself->runAscent, TextStyle_New, &itself->runStyle, WEOObj_New, itself->runObject); } /* Conversion of long points and rects */ int LongRect_Convert(PyObject *v, LongRect *r) { - return PyArg_Parse(v, "(llll)", &r->left, &r->top, &r->right, &r->bottom); + return PyArg_Parse(v, "(llll)", &r->left, &r->top, &r->right, &r->bottom); } PyObject * LongRect_New(LongRect *r) { - return Py_BuildValue("(llll)", r->left, r->top, r->right, r->bottom); + return Py_BuildValue("(llll)", r->left, r->top, r->right, r->bottom); } int LongPt_Convert(PyObject *v, LongPt *p) { - return PyArg_Parse(v, "(ll)", &p->h, &p->v); + return PyArg_Parse(v, "(ll)", &p->h, &p->v); } PyObject * LongPt_New(LongPt *p) { - return Py_BuildValue("(ll)", p->h, p->v); + return Py_BuildValue("(ll)", p->h, p->v); } /* Stuff for the callbacks: */ @@ -101,110 +101,110 @@ WEClickObjectUPP upp_click_handler; static OSErr any_handler(WESelector what, WEObjectReference who, PyObject *args, PyObject **rv) { - FlavorType tp; - PyObject *key, *func; - - if ( args == NULL ) return errAECorruptData; - - tp = WEGetObjectType(who); - - if( (key=Py_BuildValue("O&O&", PyMac_BuildOSType, tp, PyMac_BuildOSType, what)) == NULL) - return errAECorruptData; - if( (func = PyDict_GetItem(callbackdict, key)) == NULL ) { - Py_DECREF(key); - return errAEHandlerNotFound; - } - Py_INCREF(func); - *rv = PyEval_CallObject(func, args); - Py_DECREF(func); - Py_DECREF(key); - if ( *rv == NULL ) { - PySys_WriteStderr("--Exception in callback: "); - PyErr_Print(); - return errAEReplyNotArrived; - } - return 0; + FlavorType tp; + PyObject *key, *func; + + if ( args == NULL ) return errAECorruptData; + + tp = WEGetObjectType(who); + + if( (key=Py_BuildValue("O&O&", PyMac_BuildOSType, tp, PyMac_BuildOSType, what)) == NULL) + return errAECorruptData; + if( (func = PyDict_GetItem(callbackdict, key)) == NULL ) { + Py_DECREF(key); + return errAEHandlerNotFound; + } + Py_INCREF(func); + *rv = PyEval_CallObject(func, args); + Py_DECREF(func); + Py_DECREF(key); + if ( *rv == NULL ) { + PySys_WriteStderr("--Exception in callback: "); + PyErr_Print(); + return errAEReplyNotArrived; + } + return 0; } static pascal OSErr my_new_handler(Point *objectSize, WEObjectReference objref) { - PyObject *args=NULL, *rv=NULL; - OSErr err; - - args=Py_BuildValue("(O&)", WEOObj_New, objref); - err = any_handler(weNewHandler, objref, args, &rv); - if (!err) { - if (!PyMac_GetPoint(rv, objectSize) ) - err = errAECoercionFail; - } - if ( args ) { - Py_DECREF(args); - } - if ( rv ) { - Py_DECREF(rv); - } - return err; + PyObject *args=NULL, *rv=NULL; + OSErr err; + + args=Py_BuildValue("(O&)", WEOObj_New, objref); + err = any_handler(weNewHandler, objref, args, &rv); + if (!err) { + if (!PyMac_GetPoint(rv, objectSize) ) + err = errAECoercionFail; + } + if ( args ) { + Py_DECREF(args); + } + if ( rv ) { + Py_DECREF(rv); + } + return err; } static pascal OSErr my_dispose_handler(WEObjectReference objref) { - PyObject *args=NULL, *rv=NULL; - OSErr err; - - args=Py_BuildValue("(O&)", WEOObj_New, objref); - err = any_handler(weDisposeHandler, objref, args, &rv); - if ( args ) { - Py_DECREF(args); - } - if ( rv ) { - Py_DECREF(rv); - } - return err; + PyObject *args=NULL, *rv=NULL; + OSErr err; + + args=Py_BuildValue("(O&)", WEOObj_New, objref); + err = any_handler(weDisposeHandler, objref, args, &rv); + if ( args ) { + Py_DECREF(args); + } + if ( rv ) { + Py_DECREF(rv); + } + return err; } static pascal OSErr my_draw_handler(const Rect *destRect, WEObjectReference objref) { - PyObject *args=NULL, *rv=NULL; - OSErr err; - - args=Py_BuildValue("O&O&", PyMac_BuildRect, destRect, WEOObj_New, objref); - err = any_handler(weDrawHandler, objref, args, &rv); - if ( args ) { - Py_DECREF(args); - } - if ( rv ) { - Py_DECREF(rv); - } - return err; + PyObject *args=NULL, *rv=NULL; + OSErr err; + + args=Py_BuildValue("O&O&", PyMac_BuildRect, destRect, WEOObj_New, objref); + err = any_handler(weDrawHandler, objref, args, &rv); + if ( args ) { + Py_DECREF(args); + } + if ( rv ) { + Py_DECREF(rv); + } + return err; } static pascal Boolean my_click_handler(Point hitPt, EventModifiers modifiers, - unsigned long clickTime, WEObjectReference objref) -{ - PyObject *args=NULL, *rv=NULL; - int retvalue; - OSErr err; - - args=Py_BuildValue("O&llO&", PyMac_BuildPoint, hitPt, - (long)modifiers, (long)clickTime, WEOObj_New, objref); - err = any_handler(weClickHandler, objref, args, &rv); - if (!err) - retvalue = PyInt_AsLong(rv); - else - retvalue = 0; - if ( args ) { - Py_DECREF(args); - } - if ( rv ) { - Py_DECREF(rv); - } - return retvalue; + unsigned long clickTime, WEObjectReference objref) +{ + PyObject *args=NULL, *rv=NULL; + int retvalue; + OSErr err; + + args=Py_BuildValue("O&llO&", PyMac_BuildPoint, hitPt, + (long)modifiers, (long)clickTime, WEOObj_New, objref); + err = any_handler(weClickHandler, objref, args, &rv); + if (!err) + retvalue = PyInt_AsLong(rv); + else + retvalue = 0; + if ( args ) { + Py_DECREF(args); + } + if ( rv ) { + Py_DECREF(rv); + } + return retvalue; } - + static PyObject *waste_Error; @@ -224,14 +224,15 @@ PyObject *WEOObj_New(WEObjectReference itself) { WEOObject *it; if (itself == NULL) { - Py_INCREF(Py_None); - return Py_None; - } + Py_INCREF(Py_None); + return Py_None; + } it = PyObject_NEW(WEOObject, &WEO_Type); if (it == NULL) return NULL; it->ob_itself = itself; return (PyObject *)it; } + int WEOObj_Convert(PyObject *v, WEObjectReference *p_itself) { if (!WEOObj_Check(v)) @@ -400,16 +401,16 @@ static PyMethodDef WEOObj_methods[] = { #define WEOObj_tp_alloc PyType_GenericAlloc -static PyObject *WEOObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *WEOObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; WEObjectReference itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, WEOObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((WEOObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, WEOObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((WEOObject *)_self)->ob_itself = itself; + return _self; } #define WEOObj_tp_free PyObject_Del @@ -477,15 +478,16 @@ PyObject *wasteObj_New(WEReference itself) { wasteObject *it; if (itself == NULL) { - PyErr_SetString(waste_Error,"Cannot create null WE"); - return NULL; - } + PyErr_SetString(waste_Error,"Cannot create null WE"); + return NULL; + } it = PyObject_NEW(wasteObject, &waste_Type); if (it == NULL) return NULL; it->ob_itself = itself; WESetInfo(weRefCon, (void *)&it, itself); return (PyObject *)it; } + int wasteObj_Convert(PyObject *v, WEReference *p_itself) { if (!wasteObj_Check(v)) @@ -2149,16 +2151,16 @@ static PyMethodDef wasteObj_methods[] = { #define wasteObj_tp_alloc PyType_GenericAlloc -static PyObject *wasteObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *wasteObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; WEReference itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, wasteObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((wasteObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, wasteObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((wasteObject *)_self)->ob_itself = itself; + return _self; } #define wasteObj_tp_free PyObject_Del @@ -2418,42 +2420,42 @@ static PyObject *waste_STDObjectHandlers(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - OSErr err; - // install the sample object handlers for pictures and sounds -#define kTypePicture 'PICT' -#define kTypeSound 'snd ' - - if ( !PyArg_ParseTuple(_args, "") ) return NULL; - - if ((err = WEInstallObjectHandler(kTypePicture, weNewHandler, - (UniversalProcPtr) NewWENewObjectProc(HandleNewPicture), NULL)) != noErr) - goto cleanup; - - if ((err = WEInstallObjectHandler(kTypePicture, weDisposeHandler, - (UniversalProcPtr) NewWEDisposeObjectProc(HandleDisposePicture), NULL)) != noErr) - goto cleanup; - - if ((err = WEInstallObjectHandler(kTypePicture, weDrawHandler, - (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawPicture), NULL)) != noErr) - goto cleanup; - - if ((err = WEInstallObjectHandler(kTypeSound, weNewHandler, - (UniversalProcPtr) NewWENewObjectProc(HandleNewSound), NULL)) != noErr) - goto cleanup; - - if ((err = WEInstallObjectHandler(kTypeSound, weDrawHandler, - (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawSound), NULL)) != noErr) - goto cleanup; - - if ((err = WEInstallObjectHandler(kTypeSound, weClickHandler, - (UniversalProcPtr) NewWEClickObjectProc(HandleClickSound), NULL)) != noErr) - goto cleanup; - Py_INCREF(Py_None); - _res = Py_None; - return _res; - + OSErr err; + // install the sample object handlers for pictures and sounds +#define kTypePicture 'PICT' +#define kTypeSound 'snd ' + + if ( !PyArg_ParseTuple(_args, "") ) return NULL; + + if ((err = WEInstallObjectHandler(kTypePicture, weNewHandler, + (UniversalProcPtr) NewWENewObjectProc(HandleNewPicture), NULL)) != noErr) + goto cleanup; + + if ((err = WEInstallObjectHandler(kTypePicture, weDisposeHandler, + (UniversalProcPtr) NewWEDisposeObjectProc(HandleDisposePicture), NULL)) != noErr) + goto cleanup; + + if ((err = WEInstallObjectHandler(kTypePicture, weDrawHandler, + (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawPicture), NULL)) != noErr) + goto cleanup; + + if ((err = WEInstallObjectHandler(kTypeSound, weNewHandler, + (UniversalProcPtr) NewWENewObjectProc(HandleNewSound), NULL)) != noErr) + goto cleanup; + + if ((err = WEInstallObjectHandler(kTypeSound, weDrawHandler, + (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawSound), NULL)) != noErr) + goto cleanup; + + if ((err = WEInstallObjectHandler(kTypeSound, weClickHandler, + (UniversalProcPtr) NewWEClickObjectProc(HandleClickSound), NULL)) != noErr) + goto cleanup; + Py_INCREF(Py_None); + _res = Py_None; + return _res; + cleanup: - return PyMac_Error(err); + return PyMac_Error(err); } @@ -2461,39 +2463,39 @@ static PyObject *waste_WEInstallObjectHandler(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; - OSErr err; - FlavorType objectType; - WESelector selector; - PyObject *py_handler; - UniversalProcPtr handler; - WEReference we = NULL; - PyObject *key; - - - if ( !PyArg_ParseTuple(_args, "O&O&O|O&", - PyMac_GetOSType, &objectType, - PyMac_GetOSType, &selector, - &py_handler, - WEOObj_Convert, &we) ) return NULL; - - if ( selector == weNewHandler ) handler = (UniversalProcPtr)upp_new_handler; - else if ( selector == weDisposeHandler ) handler = (UniversalProcPtr)upp_dispose_handler; - else if ( selector == weDrawHandler ) handler = (UniversalProcPtr)upp_draw_handler; - else if ( selector == weClickHandler ) handler = (UniversalProcPtr)upp_click_handler; - else return PyMac_Error(weUndefinedSelectorErr); - - if ((key = Py_BuildValue("O&O&", - PyMac_BuildOSType, objectType, - PyMac_BuildOSType, selector)) == NULL ) - return NULL; - - PyDict_SetItem(callbackdict, key, py_handler); - - err = WEInstallObjectHandler(objectType, selector, handler, we); - if ( err ) return PyMac_Error(err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; + OSErr err; + FlavorType objectType; + WESelector selector; + PyObject *py_handler; + UniversalProcPtr handler; + WEReference we = NULL; + PyObject *key; + + + if ( !PyArg_ParseTuple(_args, "O&O&O|O&", + PyMac_GetOSType, &objectType, + PyMac_GetOSType, &selector, + &py_handler, + WEOObj_Convert, &we) ) return NULL; + + if ( selector == weNewHandler ) handler = (UniversalProcPtr)upp_new_handler; + else if ( selector == weDisposeHandler ) handler = (UniversalProcPtr)upp_dispose_handler; + else if ( selector == weDrawHandler ) handler = (UniversalProcPtr)upp_draw_handler; + else if ( selector == weClickHandler ) handler = (UniversalProcPtr)upp_click_handler; + else return PyMac_Error(weUndefinedSelectorErr); + + if ((key = Py_BuildValue("O&O&", + PyMac_BuildOSType, objectType, + PyMac_BuildOSType, selector)) == NULL ) + return NULL; + + PyDict_SetItem(callbackdict, key, py_handler); + + err = WEInstallObjectHandler(objectType, selector, handler, we); + if ( err ) return PyMac_Error(err); + Py_INCREF(Py_None); + _res = Py_None; + return _res; } @@ -2535,18 +2537,18 @@ static PyMethodDef waste_methods[] = { PyObject * ExistingwasteObj_New(w) - WEReference w; + WEReference w; { - PyObject *it = NULL; - - if (w == NULL) - it = NULL; - else - WEGetInfo(weRefCon, (void *)&it, w); - if (it == NULL || ((wasteObject *)it)->ob_itself != w) - it = Py_None; - Py_INCREF(it); - return it; + PyObject *it = NULL; + + if (w == NULL) + it = NULL; + else + WEGetInfo(weRefCon, (void *)&it, w); + if (it == NULL || ((wasteObject *)it)->ob_itself != w) + it = Py_None; + Py_INCREF(it); + return it; } @@ -2579,13 +2581,13 @@ void initwaste(void) Py_INCREF(&waste_Type); PyModule_AddObject(m, "wasteType", (PyObject *)&waste_Type); - callbackdict = PyDict_New(); - if (callbackdict == NULL || PyDict_SetItemString(d, "callbacks", callbackdict) != 0) - return; - upp_new_handler = NewWENewObjectProc(my_new_handler); - upp_dispose_handler = NewWEDisposeObjectProc(my_dispose_handler); - upp_draw_handler = NewWEDrawObjectProc(my_draw_handler); - upp_click_handler = NewWEClickObjectProc(my_click_handler); + callbackdict = PyDict_New(); + if (callbackdict == NULL || PyDict_SetItemString(d, "callbacks", callbackdict) != 0) + return; + upp_new_handler = NewWENewObjectProc(my_new_handler); + upp_dispose_handler = NewWEDisposeObjectProc(my_dispose_handler); + upp_draw_handler = NewWEDrawObjectProc(my_draw_handler); + upp_click_handler = NewWEClickObjectProc(my_click_handler); } diff --git a/Mac/Modules/win/_Winmodule.c b/Mac/Modules/win/_Winmodule.c index 2a13182..fa8c52d 100644 --- a/Mac/Modules/win/_Winmodule.c +++ b/Mac/Modules/win/_Winmodule.c @@ -36,7 +36,7 @@ extern int _WinObj_Convert(PyObject *, WindowRef *); static void PyMac_AutoDisposeWindow(WindowPtr w) { - DisposeWindow(w); + DisposeWindow(w); } static PyObject *Win_Error; @@ -69,6 +69,7 @@ PyObject *WinObj_New(WindowPtr itself) } return (PyObject *)it; } + int WinObj_Convert(PyObject *v, WindowPtr *p_itself) { @@ -2309,13 +2310,13 @@ static PyObject *WinObj_AutoDispose(WindowObject *_self, PyObject *_args) int onoff, old = 0; if (!PyArg_ParseTuple(_args, "i", &onoff)) - return NULL; + return NULL; if ( _self->ob_freeit ) - old = 1; + old = 1; if ( onoff ) - _self->ob_freeit = PyMac_AutoDisposeWindow; + _self->ob_freeit = PyMac_AutoDisposeWindow; else - _self->ob_freeit = NULL; + _self->ob_freeit = NULL; _res = Py_BuildValue("i", old); return _res; @@ -2590,16 +2591,16 @@ static int WinObj_hash(WindowObject *self) #define WinObj_tp_alloc PyType_GenericAlloc -static PyObject *WinObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +static PyObject *WinObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) { - PyObject *self; + PyObject *_self; WindowPtr itself; char *kw[] = {"itself", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, WinObj_Convert, &itself)) return NULL; - if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; - ((WindowObject *)self)->ob_itself = itself; - return self; + if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, WinObj_Convert, &itself)) return NULL; + if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((WindowObject *)_self)->ob_itself = itself; + return _self; } #define WinObj_tp_free PyObject_Del @@ -3121,7 +3122,7 @@ static PyObject *Win_WhichWindow(PyObject *_self, PyObject *_args) long ptr; if ( !PyArg_ParseTuple(_args, "i", &ptr) ) - return NULL; + return NULL; _res = WinObj_WhichWindow((WindowPtr)ptr); return _res; @@ -3208,21 +3209,21 @@ static PyMethodDef Win_methods[] = { PyObject * WinObj_WhichWindow(WindowPtr w) { - PyObject *it; - - if (w == NULL) { - it = Py_None; - Py_INCREF(it); - } else { - it = (PyObject *) GetWRefCon(w); - if (it == NULL || !IsPointerValid((Ptr)it) || ((WindowObject *)it)->ob_itself != w || !WinObj_Check(it)) { - it = WinObj_New(w); - ((WindowObject *)it)->ob_freeit = NULL; - } else { - Py_INCREF(it); - } - } - return it; + PyObject *it; + + if (w == NULL) { + it = Py_None; + Py_INCREF(it); + } else { + it = (PyObject *) GetWRefCon(w); + if (it == NULL || !IsPointerValid((Ptr)it) || ((WindowObject *)it)->ob_itself != w || !WinObj_Check(it)) { + it = WinObj_New(w); + ((WindowObject *)it)->ob_freeit = NULL; + } else { + Py_INCREF(it); + } + } + return it; } @@ -3233,9 +3234,9 @@ void init_Win(void) - PyMac_INIT_TOOLBOX_OBJECT_NEW(WindowPtr, WinObj_New); - PyMac_INIT_TOOLBOX_OBJECT_NEW(WindowPtr, WinObj_WhichWindow); - PyMac_INIT_TOOLBOX_OBJECT_CONVERT(WindowPtr, WinObj_Convert); + PyMac_INIT_TOOLBOX_OBJECT_NEW(WindowPtr, WinObj_New); + PyMac_INIT_TOOLBOX_OBJECT_NEW(WindowPtr, WinObj_WhichWindow); + PyMac_INIT_TOOLBOX_OBJECT_CONVERT(WindowPtr, WinObj_Convert); m = Py_InitModule("_Win", Win_methods); |