Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Mac/Modules/cm/_Cmmodule.c

    r2 r391  
    1010/* Macro to test whether a weak-loaded CFM function exists */
    1111#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL )  {\
    12         PyErr_SetString(PyExc_NotImplementedError, \
    13         "Not available in this shared library/OS version"); \
    14         return NULL; \
     12    PyErr_SetString(PyExc_NotImplementedError, \
     13    "Not available in this shared library/OS version"); \
     14    return NULL; \
    1515    }} while(0)
    1616
     
    3737{
    3838
    39         return Py_BuildValue("O&O&O&ll",
    40                 PyMac_BuildOSType, itself->componentType,
    41                 PyMac_BuildOSType, itself->componentSubType,
    42                 PyMac_BuildOSType, itself->componentManufacturer,
    43                 itself->componentFlags, itself->componentFlagsMask);
     39    return Py_BuildValue("O&O&O&ll",
     40        PyMac_BuildOSType, itself->componentType,
     41        PyMac_BuildOSType, itself->componentSubType,
     42        PyMac_BuildOSType, itself->componentManufacturer,
     43        itself->componentFlags, itself->componentFlagsMask);
    4444}
    4545
     
    4747CmpDesc_Convert(PyObject *v, ComponentDescription *p_itself)
    4848{
    49         return PyArg_ParseTuple(v, "O&O&O&ll",
    50                 PyMac_GetOSType, &p_itself->componentType,
    51                 PyMac_GetOSType, &p_itself->componentSubType,
    52                 PyMac_GetOSType, &p_itself->componentManufacturer,
    53                 &p_itself->componentFlags, &p_itself->componentFlagsMask);
     49    return PyArg_ParseTuple(v, "O&O&O&ll",
     50        PyMac_GetOSType, &p_itself->componentType,
     51        PyMac_GetOSType, &p_itself->componentSubType,
     52        PyMac_GetOSType, &p_itself->componentManufacturer,
     53        &p_itself->componentFlags, &p_itself->componentFlagsMask);
    5454}
    5555
     
    6464
    6565typedef struct ComponentInstanceObject {
    66         PyObject_HEAD
    67         ComponentInstance ob_itself;
     66    PyObject_HEAD
     67    ComponentInstance ob_itself;
    6868} ComponentInstanceObject;
    6969
    7070PyObject *CmpInstObj_New(ComponentInstance itself)
    7171{
    72         ComponentInstanceObject *it;
    73         if (itself == NULL) {
    74                                         PyErr_SetString(Cm_Error,"NULL ComponentInstance");
    75                                         return NULL;
    76                                 }
    77         it = PyObject_NEW(ComponentInstanceObject, &ComponentInstance_Type);
    78         if (it == NULL) return NULL;
    79         it->ob_itself = itself;
    80         return (PyObject *)it;
     72    ComponentInstanceObject *it;
     73    if (itself == NULL) {
     74                                    PyErr_SetString(Cm_Error,"NULL ComponentInstance");
     75                                    return NULL;
     76                            }
     77    it = PyObject_NEW(ComponentInstanceObject, &ComponentInstance_Type);
     78    if (it == NULL) return NULL;
     79    it->ob_itself = itself;
     80    return (PyObject *)it;
    8181}
    8282
    8383int CmpInstObj_Convert(PyObject *v, ComponentInstance *p_itself)
    8484{
    85         if (!CmpInstObj_Check(v))
    86         {
    87                 PyErr_SetString(PyExc_TypeError, "ComponentInstance required");
    88                 return 0;
    89         }
    90         *p_itself = ((ComponentInstanceObject *)v)->ob_itself;
    91         return 1;
     85    if (!CmpInstObj_Check(v))
     86    {
     87        PyErr_SetString(PyExc_TypeError, "ComponentInstance required");
     88        return 0;
     89    }
     90    *p_itself = ((ComponentInstanceObject *)v)->ob_itself;
     91    return 1;
    9292}
    9393
    9494static void CmpInstObj_dealloc(ComponentInstanceObject *self)
    9595{
    96         /* Cleanup of self->ob_itself goes here */
    97         self->ob_type->tp_free((PyObject *)self);
     96    /* Cleanup of self->ob_itself goes here */
     97    self->ob_type->tp_free((PyObject *)self);
    9898}
    9999
    100100static PyObject *CmpInstObj_CloseComponent(ComponentInstanceObject *_self, PyObject *_args)
    101101{
    102         PyObject *_res = NULL;
    103         OSErr _err;
     102    PyObject *_res = NULL;
     103    OSErr _err;
    104104#ifndef CloseComponent
    105         PyMac_PRECHECK(CloseComponent);
    106 #endif
    107         if (!PyArg_ParseTuple(_args, ""))
    108                 return NULL;
    109         _err = CloseComponent(_self->ob_itself);
    110         if (_err != noErr) return PyMac_Error(_err);
    111         Py_INCREF(Py_None);
    112         _res = Py_None;
    113         return _res;
     105    PyMac_PRECHECK(CloseComponent);
     106#endif
     107    if (!PyArg_ParseTuple(_args, ""))
     108        return NULL;
     109    _err = CloseComponent(_self->ob_itself);
     110    if (_err != noErr) return PyMac_Error(_err);
     111    Py_INCREF(Py_None);
     112    _res = Py_None;
     113    return _res;
    114114}
    115115
    116116static PyObject *CmpInstObj_GetComponentInstanceError(ComponentInstanceObject *_self, PyObject *_args)
    117117{
    118         PyObject *_res = NULL;
    119         OSErr _err;
     118    PyObject *_res = NULL;
     119    OSErr _err;
    120120#ifndef GetComponentInstanceError
    121         PyMac_PRECHECK(GetComponentInstanceError);
    122 #endif
    123         if (!PyArg_ParseTuple(_args, ""))
    124                 return NULL;
    125         _err = GetComponentInstanceError(_self->ob_itself);
    126         if (_err != noErr) return PyMac_Error(_err);
    127         Py_INCREF(Py_None);
    128         _res = Py_None;
    129         return _res;
     121    PyMac_PRECHECK(GetComponentInstanceError);
     122#endif
     123    if (!PyArg_ParseTuple(_args, ""))
     124        return NULL;
     125    _err = GetComponentInstanceError(_self->ob_itself);
     126    if (_err != noErr) return PyMac_Error(_err);
     127    Py_INCREF(Py_None);
     128    _res = Py_None;
     129    return _res;
    130130}
    131131
    132132static PyObject *CmpInstObj_SetComponentInstanceError(ComponentInstanceObject *_self, PyObject *_args)
    133133{
    134         PyObject *_res = NULL;
    135         OSErr theError;
     134    PyObject *_res = NULL;
     135    OSErr theError;
    136136#ifndef SetComponentInstanceError
    137         PyMac_PRECHECK(SetComponentInstanceError);
    138 #endif
    139         if (!PyArg_ParseTuple(_args, "h",
    140                               &theError))
    141                 return NULL;
    142         SetComponentInstanceError(_self->ob_itself,
    143                                   theError);
    144         Py_INCREF(Py_None);
    145         _res = Py_None;
    146         return _res;
     137    PyMac_PRECHECK(SetComponentInstanceError);
     138#endif
     139    if (!PyArg_ParseTuple(_args, "h",
     140                          &theError))
     141        return NULL;
     142    SetComponentInstanceError(_self->ob_itself,
     143                              theError);
     144    Py_INCREF(Py_None);
     145    _res = Py_None;
     146    return _res;
    147147}
    148148
    149149static PyObject *CmpInstObj_GetComponentInstanceStorage(ComponentInstanceObject *_self, PyObject *_args)
    150150{
    151         PyObject *_res = NULL;
    152         Handle _rv;
     151    PyObject *_res = NULL;
     152    Handle _rv;
    153153#ifndef GetComponentInstanceStorage
    154         PyMac_PRECHECK(GetComponentInstanceStorage);
    155 #endif
    156         if (!PyArg_ParseTuple(_args, ""))
    157                 return NULL;
    158         _rv = GetComponentInstanceStorage(_self->ob_itself);
    159         _res = Py_BuildValue("O&",
    160                              ResObj_New, _rv);
    161         return _res;
     154    PyMac_PRECHECK(GetComponentInstanceStorage);
     155#endif
     156    if (!PyArg_ParseTuple(_args, ""))
     157        return NULL;
     158    _rv = GetComponentInstanceStorage(_self->ob_itself);
     159    _res = Py_BuildValue("O&",
     160                         ResObj_New, _rv);
     161    return _res;
    162162}
    163163
    164164static PyObject *CmpInstObj_SetComponentInstanceStorage(ComponentInstanceObject *_self, PyObject *_args)
    165165{
    166         PyObject *_res = NULL;
    167         Handle theStorage;
     166    PyObject *_res = NULL;
     167    Handle theStorage;
    168168#ifndef SetComponentInstanceStorage
    169         PyMac_PRECHECK(SetComponentInstanceStorage);
    170 #endif
    171         if (!PyArg_ParseTuple(_args, "O&",
    172                               ResObj_Convert, &theStorage))
    173                 return NULL;
    174         SetComponentInstanceStorage(_self->ob_itself,
    175                                     theStorage);
    176         Py_INCREF(Py_None);
    177         _res = Py_None;
    178         return _res;
     169    PyMac_PRECHECK(SetComponentInstanceStorage);
     170#endif
     171    if (!PyArg_ParseTuple(_args, "O&",
     172                          ResObj_Convert, &theStorage))
     173        return NULL;
     174    SetComponentInstanceStorage(_self->ob_itself,
     175                                theStorage);
     176    Py_INCREF(Py_None);
     177    _res = Py_None;
     178    return _res;
    179179}
    180180
     
    182182static PyObject *CmpInstObj_ComponentFunctionImplemented(ComponentInstanceObject *_self, PyObject *_args)
    183183{
    184         PyObject *_res = NULL;
    185         long _rv;
    186         short ftnNumber;
     184    PyObject *_res = NULL;
     185    long _rv;
     186    short ftnNumber;
    187187#ifndef ComponentFunctionImplemented
    188         PyMac_PRECHECK(ComponentFunctionImplemented);
    189 #endif
    190         if (!PyArg_ParseTuple(_args, "h",
    191                               &ftnNumber))
    192                 return NULL;
    193         _rv = ComponentFunctionImplemented(_self->ob_itself,
    194                                            ftnNumber);
    195         _res = Py_BuildValue("l",
    196                              _rv);
    197         return _res;
     188    PyMac_PRECHECK(ComponentFunctionImplemented);
     189#endif
     190    if (!PyArg_ParseTuple(_args, "h",
     191                          &ftnNumber))
     192        return NULL;
     193    _rv = ComponentFunctionImplemented(_self->ob_itself,
     194                                       ftnNumber);
     195    _res = Py_BuildValue("l",
     196                         _rv);
     197    return _res;
    198198}
    199199
    200200static PyObject *CmpInstObj_GetComponentVersion(ComponentInstanceObject *_self, PyObject *_args)
    201201{
    202         PyObject *_res = NULL;
    203         long _rv;
     202    PyObject *_res = NULL;
     203    long _rv;
    204204#ifndef GetComponentVersion
    205         PyMac_PRECHECK(GetComponentVersion);
    206 #endif
    207         if (!PyArg_ParseTuple(_args, ""))
    208                 return NULL;
    209         _rv = GetComponentVersion(_self->ob_itself);
    210         _res = Py_BuildValue("l",
    211                              _rv);
    212         return _res;
     205    PyMac_PRECHECK(GetComponentVersion);
     206#endif
     207    if (!PyArg_ParseTuple(_args, ""))
     208        return NULL;
     209    _rv = GetComponentVersion(_self->ob_itself);
     210    _res = Py_BuildValue("l",
     211                         _rv);
     212    return _res;
    213213}
    214214
    215215static PyObject *CmpInstObj_ComponentSetTarget(ComponentInstanceObject *_self, PyObject *_args)
    216216{
    217         PyObject *_res = NULL;
    218         long _rv;
    219         ComponentInstance target;
     217    PyObject *_res = NULL;
     218    long _rv;
     219    ComponentInstance target;
    220220#ifndef ComponentSetTarget
    221         PyMac_PRECHECK(ComponentSetTarget);
    222 #endif
    223         if (!PyArg_ParseTuple(_args, "O&",
    224                               CmpInstObj_Convert, &target))
    225                 return NULL;
    226         _rv = ComponentSetTarget(_self->ob_itself,
    227                                  target);
    228         _res = Py_BuildValue("l",
    229                              _rv);
    230         return _res;
     221    PyMac_PRECHECK(ComponentSetTarget);
     222#endif
     223    if (!PyArg_ParseTuple(_args, "O&",
     224                          CmpInstObj_Convert, &target))
     225        return NULL;
     226    _rv = ComponentSetTarget(_self->ob_itself,
     227                             target);
     228    _res = Py_BuildValue("l",
     229                         _rv);
     230    return _res;
    231231}
    232232#endif /* !__LP64__*/
    233233
    234234static PyMethodDef CmpInstObj_methods[] = {
    235         {"CloseComponent", (PyCFunction)CmpInstObj_CloseComponent, 1,
    236         PyDoc_STR("() -> None")},
    237         {"GetComponentInstanceError", (PyCFunction)CmpInstObj_GetComponentInstanceError, 1,
    238         PyDoc_STR("() -> None")},
    239         {"SetComponentInstanceError", (PyCFunction)CmpInstObj_SetComponentInstanceError, 1,
    240         PyDoc_STR("(OSErr theError) -> None")},
    241         {"GetComponentInstanceStorage", (PyCFunction)CmpInstObj_GetComponentInstanceStorage, 1,
    242         PyDoc_STR("() -> (Handle _rv)")},
    243         {"SetComponentInstanceStorage", (PyCFunction)CmpInstObj_SetComponentInstanceStorage, 1,
    244         PyDoc_STR("(Handle theStorage) -> None")},
     235    {"CloseComponent", (PyCFunction)CmpInstObj_CloseComponent, 1,
     236    PyDoc_STR("() -> None")},
     237    {"GetComponentInstanceError", (PyCFunction)CmpInstObj_GetComponentInstanceError, 1,
     238    PyDoc_STR("() -> None")},
     239    {"SetComponentInstanceError", (PyCFunction)CmpInstObj_SetComponentInstanceError, 1,
     240    PyDoc_STR("(OSErr theError) -> None")},
     241    {"GetComponentInstanceStorage", (PyCFunction)CmpInstObj_GetComponentInstanceStorage, 1,
     242    PyDoc_STR("() -> (Handle _rv)")},
     243    {"SetComponentInstanceStorage", (PyCFunction)CmpInstObj_SetComponentInstanceStorage, 1,
     244    PyDoc_STR("(Handle theStorage) -> None")},
    245245#ifndef __LP64__
    246         {"ComponentFunctionImplemented", (PyCFunction)CmpInstObj_ComponentFunctionImplemented, 1,
    247         PyDoc_STR("(short ftnNumber) -> (long _rv)")},
    248         {"GetComponentVersion", (PyCFunction)CmpInstObj_GetComponentVersion, 1,
    249         PyDoc_STR("() -> (long _rv)")},
    250         {"ComponentSetTarget", (PyCFunction)CmpInstObj_ComponentSetTarget, 1,
    251         PyDoc_STR("(ComponentInstance target) -> (long _rv)")},
     246    {"ComponentFunctionImplemented", (PyCFunction)CmpInstObj_ComponentFunctionImplemented, 1,
     247    PyDoc_STR("(short ftnNumber) -> (long _rv)")},
     248    {"GetComponentVersion", (PyCFunction)CmpInstObj_GetComponentVersion, 1,
     249    PyDoc_STR("() -> (long _rv)")},
     250    {"ComponentSetTarget", (PyCFunction)CmpInstObj_ComponentSetTarget, 1,
     251    PyDoc_STR("(ComponentInstance target) -> (long _rv)")},
    252252#endif /* !__LP64__ */
    253         {NULL, NULL, 0}
     253    {NULL, NULL, 0}
    254254};
    255255
     
    268268static PyObject *CmpInstObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
    269269{
    270         PyObject *_self;
    271         ComponentInstance itself;
    272         char *kw[] = {"itself", 0};
    273 
    274         if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CmpInstObj_Convert, &itself)) return NULL;
    275         if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;
    276         ((ComponentInstanceObject *)_self)->ob_itself = itself;
    277         return _self;
     270    PyObject *_self;
     271    ComponentInstance itself;
     272    char *kw[] = {"itself", 0};
     273
     274    if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CmpInstObj_Convert, &itself)) return NULL;
     275    if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;
     276    ((ComponentInstanceObject *)_self)->ob_itself = itself;
     277    return _self;
    278278}
    279279
     
    282282
    283283PyTypeObject ComponentInstance_Type = {
    284         PyObject_HEAD_INIT(NULL)
    285         0, /*ob_size*/
    286         "_Cm.ComponentInstance", /*tp_name*/
    287         sizeof(ComponentInstanceObject), /*tp_basicsize*/
    288         0, /*tp_itemsize*/
    289         /* methods */
    290         (destructor) CmpInstObj_dealloc, /*tp_dealloc*/
    291         0, /*tp_print*/
    292         (getattrfunc)0, /*tp_getattr*/
    293         (setattrfunc)0, /*tp_setattr*/
    294         (cmpfunc) CmpInstObj_compare, /*tp_compare*/
    295         (reprfunc) CmpInstObj_repr, /*tp_repr*/
    296         (PyNumberMethods *)0, /* tp_as_number */
    297         (PySequenceMethods *)0, /* tp_as_sequence */
    298         (PyMappingMethods *)0, /* tp_as_mapping */
    299         (hashfunc) CmpInstObj_hash, /*tp_hash*/
    300         0, /*tp_call*/
    301         0, /*tp_str*/
    302         PyObject_GenericGetAttr, /*tp_getattro*/
    303         PyObject_GenericSetAttr, /*tp_setattro */
    304         0, /*tp_as_buffer*/
    305         Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
    306         0, /*tp_doc*/
    307         0, /*tp_traverse*/
    308         0, /*tp_clear*/
    309         0, /*tp_richcompare*/
    310         0, /*tp_weaklistoffset*/
    311         0, /*tp_iter*/
    312         0, /*tp_iternext*/
    313         CmpInstObj_methods, /* tp_methods */
    314         0, /*tp_members*/
    315         CmpInstObj_getsetlist, /*tp_getset*/
    316         0, /*tp_base*/
    317         0, /*tp_dict*/
    318         0, /*tp_descr_get*/
    319         0, /*tp_descr_set*/
    320         0, /*tp_dictoffset*/
    321         CmpInstObj_tp_init, /* tp_init */
    322         CmpInstObj_tp_alloc, /* tp_alloc */
    323         CmpInstObj_tp_new, /* tp_new */
    324         CmpInstObj_tp_free, /* tp_free */
     284    PyObject_HEAD_INIT(NULL)
     285    0, /*ob_size*/
     286    "_Cm.ComponentInstance", /*tp_name*/
     287    sizeof(ComponentInstanceObject), /*tp_basicsize*/
     288    0, /*tp_itemsize*/
     289    /* methods */
     290    (destructor) CmpInstObj_dealloc, /*tp_dealloc*/
     291    0, /*tp_print*/
     292    (getattrfunc)0, /*tp_getattr*/
     293    (setattrfunc)0, /*tp_setattr*/
     294    (cmpfunc) CmpInstObj_compare, /*tp_compare*/
     295    (reprfunc) CmpInstObj_repr, /*tp_repr*/
     296    (PyNumberMethods *)0, /* tp_as_number */
     297    (PySequenceMethods *)0, /* tp_as_sequence */
     298    (PyMappingMethods *)0, /* tp_as_mapping */
     299    (hashfunc) CmpInstObj_hash, /*tp_hash*/
     300    0, /*tp_call*/
     301    0, /*tp_str*/
     302    PyObject_GenericGetAttr, /*tp_getattro*/
     303    PyObject_GenericSetAttr, /*tp_setattro */
     304    0, /*tp_as_buffer*/
     305    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
     306    0, /*tp_doc*/
     307    0, /*tp_traverse*/
     308    0, /*tp_clear*/
     309    0, /*tp_richcompare*/
     310    0, /*tp_weaklistoffset*/
     311    0, /*tp_iter*/
     312    0, /*tp_iternext*/
     313    CmpInstObj_methods, /* tp_methods */
     314    0, /*tp_members*/
     315    CmpInstObj_getsetlist, /*tp_getset*/
     316    0, /*tp_base*/
     317    0, /*tp_dict*/
     318    0, /*tp_descr_get*/
     319    0, /*tp_descr_set*/
     320    0, /*tp_dictoffset*/
     321    CmpInstObj_tp_init, /* tp_init */
     322    CmpInstObj_tp_alloc, /* tp_alloc */
     323    CmpInstObj_tp_new, /* tp_new */
     324    CmpInstObj_tp_free, /* tp_free */
    325325};
    326326
     
    335335
    336336typedef struct ComponentObject {
    337         PyObject_HEAD
    338         Component ob_itself;
     337    PyObject_HEAD
     338    Component ob_itself;
    339339} ComponentObject;
    340340
    341341PyObject *CmpObj_New(Component itself)
    342342{
    343         ComponentObject *it;
    344         if (itself == NULL) {
    345                                         /* XXXX Or should we return None? */
    346                                         PyErr_SetString(Cm_Error,"No such component");
    347                                         return NULL;
    348                                 }
    349         it = PyObject_NEW(ComponentObject, &Component_Type);
    350         if (it == NULL) return NULL;
    351         it->ob_itself = itself;
    352         return (PyObject *)it;
     343    ComponentObject *it;
     344    if (itself == NULL) {
     345                                    /* XXXX Or should we return None? */
     346                    PyErr_SetString(Cm_Error,"No such component");
     347                    return NULL;
     348                }
     349    it = PyObject_NEW(ComponentObject, &Component_Type);
     350    if (it == NULL) return NULL;
     351    it->ob_itself = itself;
     352    return (PyObject *)it;
    353353}
    354354
    355355int CmpObj_Convert(PyObject *v, Component *p_itself)
    356356{
    357         if ( v == Py_None ) {
    358                                         *p_itself = 0;
    359                                         return 1;
    360                 }
    361         if (!CmpObj_Check(v))
    362         {
    363                 PyErr_SetString(PyExc_TypeError, "Component required");
    364                 return 0;
    365         }
    366         *p_itself = ((ComponentObject *)v)->ob_itself;
    367         return 1;
     357    if ( v == Py_None ) {
     358                                    *p_itself = 0;
     359                                    return 1;
     360        }
     361    if (!CmpObj_Check(v))
     362    {
     363        PyErr_SetString(PyExc_TypeError, "Component required");
     364        return 0;
     365    }
     366    *p_itself = ((ComponentObject *)v)->ob_itself;
     367    return 1;
    368368}
    369369
    370370static void CmpObj_dealloc(ComponentObject *self)
    371371{
    372         /* Cleanup of self->ob_itself goes here */
    373         self->ob_type->tp_free((PyObject *)self);
     372    /* Cleanup of self->ob_itself goes here */
     373    self->ob_type->tp_free((PyObject *)self);
    374374}
    375375
    376376static PyObject *CmpObj_UnregisterComponent(ComponentObject *_self, PyObject *_args)
    377377{
    378         PyObject *_res = NULL;
    379         OSErr _err;
     378    PyObject *_res = NULL;
     379    OSErr _err;
    380380#ifndef UnregisterComponent
    381         PyMac_PRECHECK(UnregisterComponent);
    382 #endif
    383         if (!PyArg_ParseTuple(_args, ""))
    384                 return NULL;
    385         _err = UnregisterComponent(_self->ob_itself);
    386         if (_err != noErr) return PyMac_Error(_err);
    387         Py_INCREF(Py_None);
    388         _res = Py_None;
    389         return _res;
     381    PyMac_PRECHECK(UnregisterComponent);
     382#endif
     383    if (!PyArg_ParseTuple(_args, ""))
     384        return NULL;
     385    _err = UnregisterComponent(_self->ob_itself);
     386    if (_err != noErr) return PyMac_Error(_err);
     387    Py_INCREF(Py_None);
     388    _res = Py_None;
     389    return _res;
    390390}
    391391
    392392static PyObject *CmpObj_GetComponentInfo(ComponentObject *_self, PyObject *_args)
    393393{
    394         PyObject *_res = NULL;
    395         OSErr _err;
    396         ComponentDescription cd;
    397         Handle componentName;
    398         Handle componentInfo;
    399         Handle componentIcon;
     394    PyObject *_res = NULL;
     395    OSErr _err;
     396    ComponentDescription cd;
     397    Handle componentName;
     398    Handle componentInfo;
     399    Handle componentIcon;
    400400#ifndef GetComponentInfo
    401         PyMac_PRECHECK(GetComponentInfo);
    402 #endif
    403         if (!PyArg_ParseTuple(_args, "O&O&O&",
    404                               ResObj_Convert, &componentName,
    405                               ResObj_Convert, &componentInfo,
    406                               ResObj_Convert, &componentIcon))
    407                 return NULL;
    408         _err = GetComponentInfo(_self->ob_itself,
    409                                 &cd,
    410                                 componentName,
    411                                 componentInfo,
    412                                 componentIcon);
    413         if (_err != noErr) return PyMac_Error(_err);
    414         _res = Py_BuildValue("O&",
    415                              CmpDesc_New, &cd);
    416         return _res;
     401    PyMac_PRECHECK(GetComponentInfo);
     402#endif
     403    if (!PyArg_ParseTuple(_args, "O&O&O&",
     404                          ResObj_Convert, &componentName,
     405                          ResObj_Convert, &componentInfo,
     406                          ResObj_Convert, &componentIcon))
     407        return NULL;
     408    _err = GetComponentInfo(_self->ob_itself,
     409                            &cd,
     410                            componentName,
     411                            componentInfo,
     412                            componentIcon);
     413    if (_err != noErr) return PyMac_Error(_err);
     414    _res = Py_BuildValue("O&",
     415                         CmpDesc_New, &cd);
     416    return _res;
    417417}
    418418
    419419static PyObject *CmpObj_OpenComponent(ComponentObject *_self, PyObject *_args)
    420420{
    421         PyObject *_res = NULL;
    422         ComponentInstance _rv;
     421    PyObject *_res = NULL;
     422    ComponentInstance _rv;
    423423#ifndef OpenComponent
    424         PyMac_PRECHECK(OpenComponent);
    425 #endif
    426         if (!PyArg_ParseTuple(_args, ""))
    427                 return NULL;
    428         _rv = OpenComponent(_self->ob_itself);
    429         _res = Py_BuildValue("O&",
    430                              CmpInstObj_New, _rv);
    431         return _res;
     424    PyMac_PRECHECK(OpenComponent);
     425#endif
     426    if (!PyArg_ParseTuple(_args, ""))
     427        return NULL;
     428    _rv = OpenComponent(_self->ob_itself);
     429    _res = Py_BuildValue("O&",
     430                         CmpInstObj_New, _rv);
     431    return _res;
    432432}
    433433
    434434static PyObject *CmpObj_ResolveComponentAlias(ComponentObject *_self, PyObject *_args)
    435435{
    436         PyObject *_res = NULL;
    437         Component _rv;
     436    PyObject *_res = NULL;
     437    Component _rv;
    438438#ifndef ResolveComponentAlias
    439         PyMac_PRECHECK(ResolveComponentAlias);
    440 #endif
    441         if (!PyArg_ParseTuple(_args, ""))
    442                 return NULL;
    443         _rv = ResolveComponentAlias(_self->ob_itself);
    444         _res = Py_BuildValue("O&",
    445                              CmpObj_New, _rv);
    446         return _res;
     439    PyMac_PRECHECK(ResolveComponentAlias);
     440#endif
     441    if (!PyArg_ParseTuple(_args, ""))
     442        return NULL;
     443    _rv = ResolveComponentAlias(_self->ob_itself);
     444    _res = Py_BuildValue("O&",
     445                         CmpObj_New, _rv);
     446    return _res;
    447447}
    448448
    449449static PyObject *CmpObj_GetComponentPublicIndString(ComponentObject *_self, PyObject *_args)
    450450{
    451         PyObject *_res = NULL;
    452         OSErr _err;
    453         Str255 theString;
    454         short strListID;
    455         short index;
     451    PyObject *_res = NULL;
     452    OSErr _err;
     453    Str255 theString;
     454    short strListID;
     455    short index;
    456456#ifndef GetComponentPublicIndString
    457         PyMac_PRECHECK(GetComponentPublicIndString);
    458 #endif
    459         if (!PyArg_ParseTuple(_args, "O&hh",
    460                               PyMac_GetStr255, theString,
    461                               &strListID,
    462                               &index))
    463                 return NULL;
    464         _err = GetComponentPublicIndString(_self->ob_itself,
    465                                            theString,
    466                                            strListID,
    467                                            index);
    468         if (_err != noErr) return PyMac_Error(_err);
    469         Py_INCREF(Py_None);
    470         _res = Py_None;
    471         return _res;
     457    PyMac_PRECHECK(GetComponentPublicIndString);
     458#endif
     459    if (!PyArg_ParseTuple(_args, "O&hh",
     460                          PyMac_GetStr255, theString,
     461                          &strListID,
     462                          &index))
     463        return NULL;
     464    _err = GetComponentPublicIndString(_self->ob_itself,
     465                                       theString,
     466                                       strListID,
     467                                       index);
     468    if (_err != noErr) return PyMac_Error(_err);
     469    Py_INCREF(Py_None);
     470    _res = Py_None;
     471    return _res;
    472472}
    473473
    474474static PyObject *CmpObj_GetComponentRefcon(ComponentObject *_self, PyObject *_args)
    475475{
    476         PyObject *_res = NULL;
    477         long _rv;
     476    PyObject *_res = NULL;
     477    long _rv;
    478478#ifndef GetComponentRefcon
    479         PyMac_PRECHECK(GetComponentRefcon);
    480 #endif
    481         if (!PyArg_ParseTuple(_args, ""))
    482                 return NULL;
    483         _rv = GetComponentRefcon(_self->ob_itself);
    484         _res = Py_BuildValue("l",
    485                              _rv);
    486         return _res;
     479    PyMac_PRECHECK(GetComponentRefcon);
     480#endif
     481    if (!PyArg_ParseTuple(_args, ""))
     482        return NULL;
     483    _rv = GetComponentRefcon(_self->ob_itself);
     484    _res = Py_BuildValue("l",
     485                         _rv);
     486    return _res;
    487487}
    488488
    489489static PyObject *CmpObj_SetComponentRefcon(ComponentObject *_self, PyObject *_args)
    490490{
    491         PyObject *_res = NULL;
    492         long theRefcon;
     491    PyObject *_res = NULL;
     492    long theRefcon;
    493493#ifndef SetComponentRefcon
    494         PyMac_PRECHECK(SetComponentRefcon);
    495 #endif
    496         if (!PyArg_ParseTuple(_args, "l",
    497                               &theRefcon))
    498                 return NULL;
    499         SetComponentRefcon(_self->ob_itself,
    500                            theRefcon);
    501         Py_INCREF(Py_None);
    502         _res = Py_None;
    503         return _res;
     494    PyMac_PRECHECK(SetComponentRefcon);
     495#endif
     496    if (!PyArg_ParseTuple(_args, "l",
     497                          &theRefcon))
     498        return NULL;
     499    SetComponentRefcon(_self->ob_itself,
     500                       theRefcon);
     501    Py_INCREF(Py_None);
     502    _res = Py_None;
     503    return _res;
    504504}
    505505
    506506static PyObject *CmpObj_OpenComponentResFile(ComponentObject *_self, PyObject *_args)
    507507{
    508         PyObject *_res = NULL;
    509         short _rv;
     508    PyObject *_res = NULL;
     509    short _rv;
    510510#ifndef OpenComponentResFile
    511         PyMac_PRECHECK(OpenComponentResFile);
    512 #endif
    513         if (!PyArg_ParseTuple(_args, ""))
    514                 return NULL;
    515         _rv = OpenComponentResFile(_self->ob_itself);
    516         _res = Py_BuildValue("h",
    517                              _rv);
    518         return _res;
     511    PyMac_PRECHECK(OpenComponentResFile);
     512#endif
     513    if (!PyArg_ParseTuple(_args, ""))
     514        return NULL;
     515    _rv = OpenComponentResFile(_self->ob_itself);
     516    _res = Py_BuildValue("h",
     517                         _rv);
     518    return _res;
    519519}
    520520
    521521static PyObject *CmpObj_GetComponentResource(ComponentObject *_self, PyObject *_args)
    522522{
    523         PyObject *_res = NULL;
    524         OSErr _err;
    525         OSType resType;
    526         short resID;
    527         Handle theResource;
     523    PyObject *_res = NULL;
     524    OSErr _err;
     525    OSType resType;
     526    short resID;
     527    Handle theResource;
    528528#ifndef GetComponentResource
    529         PyMac_PRECHECK(GetComponentResource);
    530 #endif
    531         if (!PyArg_ParseTuple(_args, "O&h",
    532                               PyMac_GetOSType, &resType,
    533                               &resID))
    534                 return NULL;
    535         _err = GetComponentResource(_self->ob_itself,
    536                                     resType,
    537                                     resID,
    538                                     &theResource);
    539         if (_err != noErr) return PyMac_Error(_err);
    540         _res = Py_BuildValue("O&",
    541                              ResObj_New, theResource);
    542         return _res;
     529    PyMac_PRECHECK(GetComponentResource);
     530#endif
     531    if (!PyArg_ParseTuple(_args, "O&h",
     532                          PyMac_GetOSType, &resType,
     533                          &resID))
     534        return NULL;
     535    _err = GetComponentResource(_self->ob_itself,
     536                                resType,
     537                                resID,
     538                                &theResource);
     539    if (_err != noErr) return PyMac_Error(_err);
     540    _res = Py_BuildValue("O&",
     541                         ResObj_New, theResource);
     542    return _res;
    543543}
    544544
    545545static PyObject *CmpObj_GetComponentIndString(ComponentObject *_self, PyObject *_args)
    546546{
    547         PyObject *_res = NULL;
    548         OSErr _err;
    549         Str255 theString;
    550         short strListID;
    551         short index;
     547    PyObject *_res = NULL;
     548    OSErr _err;
     549    Str255 theString;
     550    short strListID;
     551    short index;
    552552#ifndef GetComponentIndString
    553         PyMac_PRECHECK(GetComponentIndString);
    554 #endif
    555         if (!PyArg_ParseTuple(_args, "O&hh",
    556                               PyMac_GetStr255, theString,
    557                               &strListID,
    558                               &index))
    559                 return NULL;
    560         _err = GetComponentIndString(_self->ob_itself,
    561                                      theString,
    562                                      strListID,
    563                                      index);
    564         if (_err != noErr) return PyMac_Error(_err);
    565         Py_INCREF(Py_None);
    566         _res = Py_None;
    567         return _res;
     553    PyMac_PRECHECK(GetComponentIndString);
     554#endif
     555    if (!PyArg_ParseTuple(_args, "O&hh",
     556                          PyMac_GetStr255, theString,
     557                          &strListID,
     558                          &index))
     559        return NULL;
     560    _err = GetComponentIndString(_self->ob_itself,
     561                                 theString,
     562                                 strListID,
     563                                 index);
     564    if (_err != noErr) return PyMac_Error(_err);
     565    Py_INCREF(Py_None);
     566    _res = Py_None;
     567    return _res;
    568568}
    569569
    570570static PyObject *CmpObj_CountComponentInstances(ComponentObject *_self, PyObject *_args)
    571571{
    572         PyObject *_res = NULL;
    573         long _rv;
     572    PyObject *_res = NULL;
     573    long _rv;
    574574#ifndef CountComponentInstances
    575         PyMac_PRECHECK(CountComponentInstances);
    576 #endif
    577         if (!PyArg_ParseTuple(_args, ""))
    578                 return NULL;
    579         _rv = CountComponentInstances(_self->ob_itself);
    580         _res = Py_BuildValue("l",
    581                              _rv);
    582         return _res;
     575    PyMac_PRECHECK(CountComponentInstances);
     576#endif
     577    if (!PyArg_ParseTuple(_args, ""))
     578        return NULL;
     579    _rv = CountComponentInstances(_self->ob_itself);
     580    _res = Py_BuildValue("l",
     581                         _rv);
     582    return _res;
    583583}
    584584
    585585static PyObject *CmpObj_SetDefaultComponent(ComponentObject *_self, PyObject *_args)
    586586{
    587         PyObject *_res = NULL;
    588         OSErr _err;
    589         short flags;
     587    PyObject *_res = NULL;
     588    OSErr _err;
     589    short flags;
    590590#ifndef SetDefaultComponent
    591         PyMac_PRECHECK(SetDefaultComponent);
    592 #endif
    593         if (!PyArg_ParseTuple(_args, "h",
    594                               &flags))
    595                 return NULL;
    596         _err = SetDefaultComponent(_self->ob_itself,
    597                                    flags);
    598         if (_err != noErr) return PyMac_Error(_err);
    599         Py_INCREF(Py_None);
    600         _res = Py_None;
    601         return _res;
     591    PyMac_PRECHECK(SetDefaultComponent);
     592#endif
     593    if (!PyArg_ParseTuple(_args, "h",
     594                          &flags))
     595        return NULL;
     596    _err = SetDefaultComponent(_self->ob_itself,
     597                               flags);
     598    if (_err != noErr) return PyMac_Error(_err);
     599    Py_INCREF(Py_None);
     600    _res = Py_None;
     601    return _res;
    602602}
    603603
    604604static PyObject *CmpObj_CaptureComponent(ComponentObject *_self, PyObject *_args)
    605605{
    606         PyObject *_res = NULL;
    607         Component _rv;
    608         Component capturingComponent;
     606    PyObject *_res = NULL;
     607    Component _rv;
     608    Component capturingComponent;
    609609#ifndef CaptureComponent
    610         PyMac_PRECHECK(CaptureComponent);
    611 #endif
    612         if (!PyArg_ParseTuple(_args, "O&",
    613                               CmpObj_Convert, &capturingComponent))
    614                 return NULL;
    615         _rv = CaptureComponent(_self->ob_itself,
    616                                capturingComponent);
    617         _res = Py_BuildValue("O&",
    618                              CmpObj_New, _rv);
    619         return _res;
     610    PyMac_PRECHECK(CaptureComponent);
     611#endif
     612    if (!PyArg_ParseTuple(_args, "O&",
     613                          CmpObj_Convert, &capturingComponent))
     614        return NULL;
     615    _rv = CaptureComponent(_self->ob_itself,
     616                           capturingComponent);
     617    _res = Py_BuildValue("O&",
     618                         CmpObj_New, _rv);
     619    return _res;
    620620}
    621621
    622622static PyObject *CmpObj_UncaptureComponent(ComponentObject *_self, PyObject *_args)
    623623{
    624         PyObject *_res = NULL;
    625         OSErr _err;
     624    PyObject *_res = NULL;
     625    OSErr _err;
    626626#ifndef UncaptureComponent
    627         PyMac_PRECHECK(UncaptureComponent);
    628 #endif
    629         if (!PyArg_ParseTuple(_args, ""))
    630                 return NULL;
    631         _err = UncaptureComponent(_self->ob_itself);
    632         if (_err != noErr) return PyMac_Error(_err);
    633         Py_INCREF(Py_None);
    634         _res = Py_None;
    635         return _res;
     627    PyMac_PRECHECK(UncaptureComponent);
     628#endif
     629    if (!PyArg_ParseTuple(_args, ""))
     630        return NULL;
     631    _err = UncaptureComponent(_self->ob_itself);
     632    if (_err != noErr) return PyMac_Error(_err);
     633    Py_INCREF(Py_None);
     634    _res = Py_None;
     635    return _res;
    636636}
    637637
     
    639639static PyObject *CmpObj_GetComponentIconSuite(ComponentObject *_self, PyObject *_args)
    640640{
    641         PyObject *_res = NULL;
    642         OSErr _err;
    643         Handle iconSuite;
     641    PyObject *_res = NULL;
     642    OSErr _err;
     643    Handle iconSuite;
    644644#ifndef GetComponentIconSuite
    645         PyMac_PRECHECK(GetComponentIconSuite);
    646 #endif
    647         if (!PyArg_ParseTuple(_args, ""))
    648                 return NULL;
    649         _err = GetComponentIconSuite(_self->ob_itself,
    650                                      &iconSuite);
    651         if (_err != noErr) return PyMac_Error(_err);
    652         _res = Py_BuildValue("O&",
    653                              ResObj_New, iconSuite);
    654         return _res;
     645    PyMac_PRECHECK(GetComponentIconSuite);
     646#endif
     647    if (!PyArg_ParseTuple(_args, ""))
     648        return NULL;
     649    _err = GetComponentIconSuite(_self->ob_itself,
     650                                 &iconSuite);
     651    if (_err != noErr) return PyMac_Error(_err);
     652    _res = Py_BuildValue("O&",
     653                         ResObj_New, iconSuite);
     654    return _res;
    655655}
    656656#endif /* !__LP64__ */
    657657
    658658static PyMethodDef CmpObj_methods[] = {
    659         {"UnregisterComponent", (PyCFunction)CmpObj_UnregisterComponent, 1,
    660         PyDoc_STR("() -> None")},
    661         {"GetComponentInfo", (PyCFunction)CmpObj_GetComponentInfo, 1,
    662         PyDoc_STR("(Handle componentName, Handle componentInfo, Handle componentIcon) -> (ComponentDescription cd)")},
    663         {"OpenComponent", (PyCFunction)CmpObj_OpenComponent, 1,
    664         PyDoc_STR("() -> (ComponentInstance _rv)")},
    665         {"ResolveComponentAlias", (PyCFunction)CmpObj_ResolveComponentAlias, 1,
    666         PyDoc_STR("() -> (Component _rv)")},
    667         {"GetComponentPublicIndString", (PyCFunction)CmpObj_GetComponentPublicIndString, 1,
    668         PyDoc_STR("(Str255 theString, short strListID, short index) -> None")},
    669         {"GetComponentRefcon", (PyCFunction)CmpObj_GetComponentRefcon, 1,
    670         PyDoc_STR("() -> (long _rv)")},
    671         {"SetComponentRefcon", (PyCFunction)CmpObj_SetComponentRefcon, 1,
    672         PyDoc_STR("(long theRefcon) -> None")},
    673         {"OpenComponentResFile", (PyCFunction)CmpObj_OpenComponentResFile, 1,
    674         PyDoc_STR("() -> (short _rv)")},
    675         {"GetComponentResource", (PyCFunction)CmpObj_GetComponentResource, 1,
    676         PyDoc_STR("(OSType resType, short resID) -> (Handle theResource)")},
    677         {"GetComponentIndString", (PyCFunction)CmpObj_GetComponentIndString, 1,
    678         PyDoc_STR("(Str255 theString, short strListID, short index) -> None")},
    679         {"CountComponentInstances", (PyCFunction)CmpObj_CountComponentInstances, 1,
    680         PyDoc_STR("() -> (long _rv)")},
    681         {"SetDefaultComponent", (PyCFunction)CmpObj_SetDefaultComponent, 1,
    682         PyDoc_STR("(short flags) -> None")},
    683         {"CaptureComponent", (PyCFunction)CmpObj_CaptureComponent, 1,
    684         PyDoc_STR("(Component capturingComponent) -> (Component _rv)")},
    685         {"UncaptureComponent", (PyCFunction)CmpObj_UncaptureComponent, 1,
    686         PyDoc_STR("() -> None")},
     659    {"UnregisterComponent", (PyCFunction)CmpObj_UnregisterComponent, 1,
     660    PyDoc_STR("() -> None")},
     661    {"GetComponentInfo", (PyCFunction)CmpObj_GetComponentInfo, 1,
     662    PyDoc_STR("(Handle componentName, Handle componentInfo, Handle componentIcon) -> (ComponentDescription cd)")},
     663    {"OpenComponent", (PyCFunction)CmpObj_OpenComponent, 1,
     664    PyDoc_STR("() -> (ComponentInstance _rv)")},
     665    {"ResolveComponentAlias", (PyCFunction)CmpObj_ResolveComponentAlias, 1,
     666    PyDoc_STR("() -> (Component _rv)")},
     667    {"GetComponentPublicIndString", (PyCFunction)CmpObj_GetComponentPublicIndString, 1,
     668    PyDoc_STR("(Str255 theString, short strListID, short index) -> None")},
     669    {"GetComponentRefcon", (PyCFunction)CmpObj_GetComponentRefcon, 1,
     670    PyDoc_STR("() -> (long _rv)")},
     671    {"SetComponentRefcon", (PyCFunction)CmpObj_SetComponentRefcon, 1,
     672    PyDoc_STR("(long theRefcon) -> None")},
     673    {"OpenComponentResFile", (PyCFunction)CmpObj_OpenComponentResFile, 1,
     674    PyDoc_STR("() -> (short _rv)")},
     675    {"GetComponentResource", (PyCFunction)CmpObj_GetComponentResource, 1,
     676    PyDoc_STR("(OSType resType, short resID) -> (Handle theResource)")},
     677    {"GetComponentIndString", (PyCFunction)CmpObj_GetComponentIndString, 1,
     678    PyDoc_STR("(Str255 theString, short strListID, short index) -> None")},
     679    {"CountComponentInstances", (PyCFunction)CmpObj_CountComponentInstances, 1,
     680    PyDoc_STR("() -> (long _rv)")},
     681    {"SetDefaultComponent", (PyCFunction)CmpObj_SetDefaultComponent, 1,
     682    PyDoc_STR("(short flags) -> None")},
     683    {"CaptureComponent", (PyCFunction)CmpObj_CaptureComponent, 1,
     684    PyDoc_STR("(Component capturingComponent) -> (Component _rv)")},
     685    {"UncaptureComponent", (PyCFunction)CmpObj_UncaptureComponent, 1,
     686    PyDoc_STR("() -> None")},
    687687#ifndef __LP64__
    688         {"GetComponentIconSuite", (PyCFunction)CmpObj_GetComponentIconSuite, 1,
    689         PyDoc_STR("() -> (Handle iconSuite)")},
     688    {"GetComponentIconSuite", (PyCFunction)CmpObj_GetComponentIconSuite, 1,
     689    PyDoc_STR("() -> (Handle iconSuite)")},
    690690#endif /* !__LP64__ */
    691         {NULL, NULL, 0}
     691    {NULL, NULL, 0}
    692692};
    693693
     
    706706static PyObject *CmpObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
    707707{
    708         PyObject *_self;
    709         Component itself;
    710         char *kw[] = {"itself", 0};
    711 
    712         if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CmpObj_Convert, &itself)) return NULL;
    713         if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;
    714         ((ComponentObject *)_self)->ob_itself = itself;
    715         return _self;
     708    PyObject *_self;
     709    Component itself;
     710    char *kw[] = {"itself", 0};
     711
     712    if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CmpObj_Convert, &itself)) return NULL;
     713    if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;
     714    ((ComponentObject *)_self)->ob_itself = itself;
     715    return _self;
    716716}
    717717
     
    720720
    721721PyTypeObject Component_Type = {
    722         PyObject_HEAD_INIT(NULL)
    723         0, /*ob_size*/
    724         "_Cm.Component", /*tp_name*/
    725         sizeof(ComponentObject), /*tp_basicsize*/
    726         0, /*tp_itemsize*/
    727         /* methods */
    728         (destructor) CmpObj_dealloc, /*tp_dealloc*/
    729         0, /*tp_print*/
    730         (getattrfunc)0, /*tp_getattr*/
    731         (setattrfunc)0, /*tp_setattr*/
    732         (cmpfunc) CmpObj_compare, /*tp_compare*/
    733         (reprfunc) CmpObj_repr, /*tp_repr*/
    734         (PyNumberMethods *)0, /* tp_as_number */
    735         (PySequenceMethods *)0, /* tp_as_sequence */
    736         (PyMappingMethods *)0, /* tp_as_mapping */
    737         (hashfunc) CmpObj_hash, /*tp_hash*/
    738         0, /*tp_call*/
    739         0, /*tp_str*/
    740         PyObject_GenericGetAttr, /*tp_getattro*/
    741         PyObject_GenericSetAttr, /*tp_setattro */
    742         0, /*tp_as_buffer*/
    743         Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
    744         0, /*tp_doc*/
    745         0, /*tp_traverse*/
    746         0, /*tp_clear*/
    747         0, /*tp_richcompare*/
    748         0, /*tp_weaklistoffset*/
    749         0, /*tp_iter*/
    750         0, /*tp_iternext*/
    751         CmpObj_methods, /* tp_methods */
    752         0, /*tp_members*/
    753         CmpObj_getsetlist, /*tp_getset*/
    754         0, /*tp_base*/
    755         0, /*tp_dict*/
    756         0, /*tp_descr_get*/
    757         0, /*tp_descr_set*/
    758         0, /*tp_dictoffset*/
    759         CmpObj_tp_init, /* tp_init */
    760         CmpObj_tp_alloc, /* tp_alloc */
    761         CmpObj_tp_new, /* tp_new */
    762         CmpObj_tp_free, /* tp_free */
     722    PyObject_HEAD_INIT(NULL)
     723    0, /*ob_size*/
     724    "_Cm.Component", /*tp_name*/
     725    sizeof(ComponentObject), /*tp_basicsize*/
     726    0, /*tp_itemsize*/
     727    /* methods */
     728    (destructor) CmpObj_dealloc, /*tp_dealloc*/
     729    0, /*tp_print*/
     730    (getattrfunc)0, /*tp_getattr*/
     731    (setattrfunc)0, /*tp_setattr*/
     732    (cmpfunc) CmpObj_compare, /*tp_compare*/
     733    (reprfunc) CmpObj_repr, /*tp_repr*/
     734    (PyNumberMethods *)0, /* tp_as_number */
     735    (PySequenceMethods *)0, /* tp_as_sequence */
     736    (PyMappingMethods *)0, /* tp_as_mapping */
     737    (hashfunc) CmpObj_hash, /*tp_hash*/
     738    0, /*tp_call*/
     739    0, /*tp_str*/
     740    PyObject_GenericGetAttr, /*tp_getattro*/
     741    PyObject_GenericSetAttr, /*tp_setattro */
     742    0, /*tp_as_buffer*/
     743    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
     744    0, /*tp_doc*/
     745    0, /*tp_traverse*/
     746    0, /*tp_clear*/
     747    0, /*tp_richcompare*/
     748    0, /*tp_weaklistoffset*/
     749    0, /*tp_iter*/
     750    0, /*tp_iternext*/
     751    CmpObj_methods, /* tp_methods */
     752    0, /*tp_members*/
     753    CmpObj_getsetlist, /*tp_getset*/
     754    0, /*tp_base*/
     755    0, /*tp_dict*/
     756    0, /*tp_descr_get*/
     757    0, /*tp_descr_set*/
     758    0, /*tp_dictoffset*/
     759    CmpObj_tp_init, /* tp_init */
     760    CmpObj_tp_alloc, /* tp_alloc */
     761    CmpObj_tp_new, /* tp_new */
     762    CmpObj_tp_free, /* tp_free */
    763763};
    764764
     
    768768static PyObject *Cm_RegisterComponentResource(PyObject *_self, PyObject *_args)
    769769{
    770         PyObject *_res = NULL;
    771         Component _rv;
    772         ComponentResourceHandle cr;
    773         short global;
     770    PyObject *_res = NULL;
     771    Component _rv;
     772    ComponentResourceHandle cr;
     773    short global;
    774774#ifndef RegisterComponentResource
    775         PyMac_PRECHECK(RegisterComponentResource);
    776 #endif
    777         if (!PyArg_ParseTuple(_args, "O&h",
    778                               ResObj_Convert, &cr,
    779                               &global))
    780                 return NULL;
    781         _rv = RegisterComponentResource(cr,
    782                                         global);
    783         _res = Py_BuildValue("O&",
    784                              CmpObj_New, _rv);
    785         return _res;
     775    PyMac_PRECHECK(RegisterComponentResource);
     776#endif
     777    if (!PyArg_ParseTuple(_args, "O&h",
     778                          ResObj_Convert, &cr,
     779                          &global))
     780        return NULL;
     781    _rv = RegisterComponentResource(cr,
     782                                    global);
     783    _res = Py_BuildValue("O&",
     784                         CmpObj_New, _rv);
     785    return _res;
    786786}
    787787
    788788static PyObject *Cm_FindNextComponent(PyObject *_self, PyObject *_args)
    789789{
    790         PyObject *_res = NULL;
    791         Component _rv;
    792         Component aComponent;
    793         ComponentDescription looking;
     790    PyObject *_res = NULL;
     791    Component _rv;
     792    Component aComponent;
     793    ComponentDescription looking;
    794794#ifndef FindNextComponent
    795         PyMac_PRECHECK(FindNextComponent);
    796 #endif
    797         if (!PyArg_ParseTuple(_args, "O&O&",
    798                               CmpObj_Convert, &aComponent,
    799                               CmpDesc_Convert, &looking))
    800                 return NULL;
    801         _rv = FindNextComponent(aComponent,
    802                                 &looking);
    803         _res = Py_BuildValue("O&",
    804                              CmpObj_New, _rv);
    805         return _res;
     795    PyMac_PRECHECK(FindNextComponent);
     796#endif
     797    if (!PyArg_ParseTuple(_args, "O&O&",
     798                          CmpObj_Convert, &aComponent,
     799                          CmpDesc_Convert, &looking))
     800        return NULL;
     801    _rv = FindNextComponent(aComponent,
     802                            &looking);
     803    _res = Py_BuildValue("O&",
     804                         CmpObj_New, _rv);
     805    return _res;
    806806}
    807807
    808808static PyObject *Cm_CountComponents(PyObject *_self, PyObject *_args)
    809809{
    810         PyObject *_res = NULL;
    811         long _rv;
    812         ComponentDescription looking;
     810    PyObject *_res = NULL;
     811    long _rv;
     812    ComponentDescription looking;
    813813#ifndef CountComponents
    814         PyMac_PRECHECK(CountComponents);
    815 #endif
    816         if (!PyArg_ParseTuple(_args, "O&",
    817                               CmpDesc_Convert, &looking))
    818                 return NULL;
    819         _rv = CountComponents(&looking);
    820         _res = Py_BuildValue("l",
    821                              _rv);
    822         return _res;
     814    PyMac_PRECHECK(CountComponents);
     815#endif
     816    if (!PyArg_ParseTuple(_args, "O&",
     817                          CmpDesc_Convert, &looking))
     818        return NULL;
     819    _rv = CountComponents(&looking);
     820    _res = Py_BuildValue("l",
     821                         _rv);
     822    return _res;
    823823}
    824824
    825825static PyObject *Cm_GetComponentListModSeed(PyObject *_self, PyObject *_args)
    826826{
    827         PyObject *_res = NULL;
    828         long _rv;
     827    PyObject *_res = NULL;
     828    long _rv;
    829829#ifndef GetComponentListModSeed
    830         PyMac_PRECHECK(GetComponentListModSeed);
    831 #endif
    832         if (!PyArg_ParseTuple(_args, ""))
    833                 return NULL;
    834         _rv = GetComponentListModSeed();
    835         _res = Py_BuildValue("l",
    836                              _rv);
    837         return _res;
     830    PyMac_PRECHECK(GetComponentListModSeed);
     831#endif
     832    if (!PyArg_ParseTuple(_args, ""))
     833        return NULL;
     834    _rv = GetComponentListModSeed();
     835    _res = Py_BuildValue("l",
     836                         _rv);
     837    return _res;
    838838}
    839839
    840840static PyObject *Cm_CloseComponentResFile(PyObject *_self, PyObject *_args)
    841841{
    842         PyObject *_res = NULL;
    843         OSErr _err;
    844         short refnum;
     842    PyObject *_res = NULL;
     843    OSErr _err;
     844    short refnum;
    845845#ifndef CloseComponentResFile
    846         PyMac_PRECHECK(CloseComponentResFile);
    847 #endif
    848         if (!PyArg_ParseTuple(_args, "h",
    849                               &refnum))
    850                 return NULL;
    851         _err = CloseComponentResFile(refnum);
    852         if (_err != noErr) return PyMac_Error(_err);
    853         Py_INCREF(Py_None);
    854         _res = Py_None;
    855         return _res;
     846    PyMac_PRECHECK(CloseComponentResFile);
     847#endif
     848    if (!PyArg_ParseTuple(_args, "h",
     849                          &refnum))
     850        return NULL;
     851    _err = CloseComponentResFile(refnum);
     852    if (_err != noErr) return PyMac_Error(_err);
     853    Py_INCREF(Py_None);
     854    _res = Py_None;
     855    return _res;
    856856}
    857857
    858858static PyObject *Cm_OpenDefaultComponent(PyObject *_self, PyObject *_args)
    859859{
    860         PyObject *_res = NULL;
    861         ComponentInstance _rv;
    862         OSType componentType;
    863         OSType componentSubType;
     860    PyObject *_res = NULL;
     861    ComponentInstance _rv;
     862    OSType componentType;
     863    OSType componentSubType;
    864864#ifndef OpenDefaultComponent
    865         PyMac_PRECHECK(OpenDefaultComponent);
    866 #endif
    867         if (!PyArg_ParseTuple(_args, "O&O&",
    868                               PyMac_GetOSType, &componentType,
    869                               PyMac_GetOSType, &componentSubType))
    870                 return NULL;
    871         _rv = OpenDefaultComponent(componentType,
    872                                    componentSubType);
    873         _res = Py_BuildValue("O&",
    874                              CmpInstObj_New, _rv);
    875         return _res;
     865    PyMac_PRECHECK(OpenDefaultComponent);
     866#endif
     867    if (!PyArg_ParseTuple(_args, "O&O&",
     868                          PyMac_GetOSType, &componentType,
     869                          PyMac_GetOSType, &componentSubType))
     870        return NULL;
     871    _rv = OpenDefaultComponent(componentType,
     872                               componentSubType);
     873    _res = Py_BuildValue("O&",
     874                         CmpInstObj_New, _rv);
     875    return _res;
    876876}
    877877
    878878static PyObject *Cm_RegisterComponentResourceFile(PyObject *_self, PyObject *_args)
    879879{
    880         PyObject *_res = NULL;
    881         long _rv;
    882         short resRefNum;
    883         short global;
     880    PyObject *_res = NULL;
     881    long _rv;
     882    short resRefNum;
     883    short global;
    884884#ifndef RegisterComponentResourceFile
    885         PyMac_PRECHECK(RegisterComponentResourceFile);
    886 #endif
    887         if (!PyArg_ParseTuple(_args, "hh",
    888                               &resRefNum,
    889                               &global))
    890                 return NULL;
    891         _rv = RegisterComponentResourceFile(resRefNum,
    892                                             global);
    893         _res = Py_BuildValue("l",
    894                              _rv);
    895         return _res;
     885    PyMac_PRECHECK(RegisterComponentResourceFile);
     886#endif
     887    if (!PyArg_ParseTuple(_args, "hh",
     888                          &resRefNum,
     889                          &global))
     890        return NULL;
     891    _rv = RegisterComponentResourceFile(resRefNum,
     892                                        global);
     893    _res = Py_BuildValue("l",
     894                         _rv);
     895    return _res;
    896896}
    897897
    898898static PyMethodDef Cm_methods[] = {
    899         {"RegisterComponentResource", (PyCFunction)Cm_RegisterComponentResource, 1,
    900         PyDoc_STR("(ComponentResourceHandle cr, short global) -> (Component _rv)")},
    901         {"FindNextComponent", (PyCFunction)Cm_FindNextComponent, 1,
    902         PyDoc_STR("(Component aComponent, ComponentDescription looking) -> (Component _rv)")},
    903         {"CountComponents", (PyCFunction)Cm_CountComponents, 1,
    904         PyDoc_STR("(ComponentDescription looking) -> (long _rv)")},
    905         {"GetComponentListModSeed", (PyCFunction)Cm_GetComponentListModSeed, 1,
    906         PyDoc_STR("() -> (long _rv)")},
    907         {"CloseComponentResFile", (PyCFunction)Cm_CloseComponentResFile, 1,
    908         PyDoc_STR("(short refnum) -> None")},
    909         {"OpenDefaultComponent", (PyCFunction)Cm_OpenDefaultComponent, 1,
    910         PyDoc_STR("(OSType componentType, OSType componentSubType) -> (ComponentInstance _rv)")},
    911         {"RegisterComponentResourceFile", (PyCFunction)Cm_RegisterComponentResourceFile, 1,
    912         PyDoc_STR("(short resRefNum, short global) -> (long _rv)")},
    913         {NULL, NULL, 0}
     899    {"RegisterComponentResource", (PyCFunction)Cm_RegisterComponentResource, 1,
     900    PyDoc_STR("(ComponentResourceHandle cr, short global) -> (Component _rv)")},
     901    {"FindNextComponent", (PyCFunction)Cm_FindNextComponent, 1,
     902    PyDoc_STR("(Component aComponent, ComponentDescription looking) -> (Component _rv)")},
     903    {"CountComponents", (PyCFunction)Cm_CountComponents, 1,
     904    PyDoc_STR("(ComponentDescription looking) -> (long _rv)")},
     905    {"GetComponentListModSeed", (PyCFunction)Cm_GetComponentListModSeed, 1,
     906    PyDoc_STR("() -> (long _rv)")},
     907    {"CloseComponentResFile", (PyCFunction)Cm_CloseComponentResFile, 1,
     908    PyDoc_STR("(short refnum) -> None")},
     909    {"OpenDefaultComponent", (PyCFunction)Cm_OpenDefaultComponent, 1,
     910    PyDoc_STR("(OSType componentType, OSType componentSubType) -> (ComponentInstance _rv)")},
     911    {"RegisterComponentResourceFile", (PyCFunction)Cm_RegisterComponentResourceFile, 1,
     912    PyDoc_STR("(short resRefNum, short global) -> (long _rv)")},
     913    {NULL, NULL, 0}
    914914};
    915915
     
    919919void init_Cm(void)
    920920{
    921         PyObject *m;
    922         PyObject *d;
    923 
    924 
    925 
    926                 PyMac_INIT_TOOLBOX_OBJECT_NEW(Component, CmpObj_New);
    927                 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Component, CmpObj_Convert);
    928                 PyMac_INIT_TOOLBOX_OBJECT_NEW(ComponentInstance, CmpInstObj_New);
    929                 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ComponentInstance, CmpInstObj_Convert);
    930 
    931 
    932         m = Py_InitModule("_Cm", Cm_methods);
    933         d = PyModule_GetDict(m);
    934         Cm_Error = PyMac_GetOSErrException();
    935         if (Cm_Error == NULL ||
    936             PyDict_SetItemString(d, "Error", Cm_Error) != 0)
    937                 return;
    938         ComponentInstance_Type.ob_type = &PyType_Type;
    939         if (PyType_Ready(&ComponentInstance_Type) < 0) return;
    940         Py_INCREF(&ComponentInstance_Type);
    941         PyModule_AddObject(m, "ComponentInstance", (PyObject *)&ComponentInstance_Type);
    942         /* Backward-compatible name */
    943         Py_INCREF(&ComponentInstance_Type);
    944         PyModule_AddObject(m, "ComponentInstanceType", (PyObject *)&ComponentInstance_Type);
    945         Component_Type.ob_type = &PyType_Type;
    946         if (PyType_Ready(&Component_Type) < 0) return;
    947         Py_INCREF(&Component_Type);
    948         PyModule_AddObject(m, "Component", (PyObject *)&Component_Type);
    949         /* Backward-compatible name */
    950         Py_INCREF(&Component_Type);
    951         PyModule_AddObject(m, "ComponentType", (PyObject *)&Component_Type);
     921    PyObject *m;
     922    PyObject *d;
     923
     924
     925
     926        PyMac_INIT_TOOLBOX_OBJECT_NEW(Component, CmpObj_New);
     927        PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Component, CmpObj_Convert);
     928        PyMac_INIT_TOOLBOX_OBJECT_NEW(ComponentInstance, CmpInstObj_New);
     929        PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ComponentInstance, CmpInstObj_Convert);
     930
     931
     932    m = Py_InitModule("_Cm", Cm_methods);
     933    d = PyModule_GetDict(m);
     934    Cm_Error = PyMac_GetOSErrException();
     935    if (Cm_Error == NULL ||
     936        PyDict_SetItemString(d, "Error", Cm_Error) != 0)
     937        return;
     938    ComponentInstance_Type.ob_type = &PyType_Type;
     939    if (PyType_Ready(&ComponentInstance_Type) < 0) return;
     940    Py_INCREF(&ComponentInstance_Type);
     941    PyModule_AddObject(m, "ComponentInstance", (PyObject *)&ComponentInstance_Type);
     942    /* Backward-compatible name */
     943    Py_INCREF(&ComponentInstance_Type);
     944    PyModule_AddObject(m, "ComponentInstanceType", (PyObject *)&ComponentInstance_Type);
     945    Component_Type.ob_type = &PyType_Type;
     946    if (PyType_Ready(&Component_Type) < 0) return;
     947    Py_INCREF(&Component_Type);
     948    PyModule_AddObject(m, "Component", (PyObject *)&Component_Type);
     949    /* Backward-compatible name */
     950    Py_INCREF(&Component_Type);
     951    PyModule_AddObject(m, "ComponentType", (PyObject *)&Component_Type);
    952952}
    953953
Note: See TracChangeset for help on using the changeset viewer.