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/res/_Resmodule.c

    r2 r391  
    99/* Macro to test whether a weak-loaded CFM function exists */
    1010#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL )  {\
    11         PyErr_SetString(PyExc_NotImplementedError, \
    12         "Not available in this shared library/OS version"); \
    13         return NULL; \
     11    PyErr_SetString(PyExc_NotImplementedError, \
     12    "Not available in this shared library/OS version"); \
     13    return NULL; \
    1414    }} while(0)
    1515
     
    3232PyMac_AutoDisposeHandle(Handle h)
    3333{
    34         DisposeHandle(h);
     34    DisposeHandle(h);
    3535}
    3636
     
    4444
    4545typedef struct ResourceObject {
    46         PyObject_HEAD
    47         Handle ob_itself;
    48         void (*ob_freeit)(Handle ptr);
     46    PyObject_HEAD
     47    Handle ob_itself;
     48    void (*ob_freeit)(Handle ptr);
    4949} ResourceObject;
    5050
    5151PyObject *ResObj_New(Handle itself)
    5252{
    53         ResourceObject *it;
    54         if (itself == NULL) return PyMac_Error(resNotFound);
    55         it = PyObject_NEW(ResourceObject, &Resource_Type);
    56         if (it == NULL) return NULL;
    57         it->ob_itself = itself;
    58         it->ob_freeit = NULL;
    59         return (PyObject *)it;
     53    ResourceObject *it;
     54    if (itself == NULL) return PyMac_Error(resNotFound);
     55    it = PyObject_NEW(ResourceObject, &Resource_Type);
     56    if (it == NULL) return NULL;
     57    it->ob_itself = itself;
     58    it->ob_freeit = NULL;
     59    return (PyObject *)it;
    6060}
    6161
    6262int ResObj_Convert(PyObject *v, Handle *p_itself)
    6363{
    64         if (!ResObj_Check(v))
    65         {
    66                 PyObject *tmp;
    67                 if ( (tmp=PyObject_CallMethod(v, "as_Resource", "")) )
    68                 {
    69                         *p_itself = ((ResourceObject *)tmp)->ob_itself;
    70                         Py_DECREF(tmp);
    71                         return 1;
    72                 }
    73                 PyErr_Clear();
    74         }
    75         if (!ResObj_Check(v))
    76         {
    77                 PyErr_SetString(PyExc_TypeError, "Resource required");
    78                 return 0;
    79         }
    80         *p_itself = ((ResourceObject *)v)->ob_itself;
    81         return 1;
     64    if (!ResObj_Check(v))
     65    {
     66        PyObject *tmp;
     67        if ( (tmp=PyObject_CallMethod(v, "as_Resource", "")) )
     68        {
     69            *p_itself = ((ResourceObject *)tmp)->ob_itself;
     70            Py_DECREF(tmp);
     71            return 1;
     72        }
     73        PyErr_Clear();
     74    }
     75    if (!ResObj_Check(v))
     76    {
     77        PyErr_SetString(PyExc_TypeError, "Resource required");
     78        return 0;
     79    }
     80    *p_itself = ((ResourceObject *)v)->ob_itself;
     81    return 1;
    8282}
    8383
    8484static void ResObj_dealloc(ResourceObject *self)
    8585{
    86         if (self->ob_freeit && self->ob_itself)
    87         {
    88                 self->ob_freeit(self->ob_itself);
    89         }
    90         self->ob_itself = NULL;
    91         self->ob_type->tp_free((PyObject *)self);
     86    if (self->ob_freeit && self->ob_itself)
     87    {
     88        self->ob_freeit(self->ob_itself);
     89    }
     90    self->ob_itself = NULL;
     91    self->ob_type->tp_free((PyObject *)self);
    9292}
    9393
    9494static PyObject *ResObj_HomeResFile(ResourceObject *_self, PyObject *_args)
    9595{
    96         PyObject *_res = NULL;
    97         short _rv;
     96    PyObject *_res = NULL;
     97    short _rv;
    9898#ifndef HomeResFile
    99         PyMac_PRECHECK(HomeResFile);
    100 #endif
    101         if (!PyArg_ParseTuple(_args, ""))
    102                 return NULL;
    103         _rv = HomeResFile(_self->ob_itself);
    104         {
    105                 OSErr _err = ResError();
    106                 if (_err != noErr) return PyMac_Error(_err);
    107         }
    108         _res = Py_BuildValue("h",
    109                              _rv);
    110         return _res;
     99    PyMac_PRECHECK(HomeResFile);
     100#endif
     101    if (!PyArg_ParseTuple(_args, ""))
     102        return NULL;
     103    _rv = HomeResFile(_self->ob_itself);
     104    {
     105        OSErr _err = ResError();
     106        if (_err != noErr) return PyMac_Error(_err);
     107    }
     108    _res = Py_BuildValue("h",
     109                         _rv);
     110    return _res;
    111111}
    112112
    113113static PyObject *ResObj_MacLoadResource(ResourceObject *_self, PyObject *_args)
    114114{
    115         PyObject *_res = NULL;
     115    PyObject *_res = NULL;
    116116#ifndef MacLoadResource
    117         PyMac_PRECHECK(MacLoadResource);
    118 #endif
    119         if (!PyArg_ParseTuple(_args, ""))
    120                 return NULL;
    121         MacLoadResource(_self->ob_itself);
    122         {
    123                 OSErr _err = ResError();
    124                 if (_err != noErr) return PyMac_Error(_err);
    125         }
    126         Py_INCREF(Py_None);
    127         _res = Py_None;
    128         return _res;
     117    PyMac_PRECHECK(MacLoadResource);
     118#endif
     119    if (!PyArg_ParseTuple(_args, ""))
     120        return NULL;
     121    MacLoadResource(_self->ob_itself);
     122    {
     123        OSErr _err = ResError();
     124        if (_err != noErr) return PyMac_Error(_err);
     125    }
     126    Py_INCREF(Py_None);
     127    _res = Py_None;
     128    return _res;
    129129}
    130130
    131131static PyObject *ResObj_ReleaseResource(ResourceObject *_self, PyObject *_args)
    132132{
    133         PyObject *_res = NULL;
     133    PyObject *_res = NULL;
    134134#ifndef ReleaseResource
    135         PyMac_PRECHECK(ReleaseResource);
    136 #endif
    137         if (!PyArg_ParseTuple(_args, ""))
    138                 return NULL;
    139         ReleaseResource(_self->ob_itself);
    140         {
    141                 OSErr _err = ResError();
    142                 if (_err != noErr) return PyMac_Error(_err);
    143         }
    144         Py_INCREF(Py_None);
    145         _res = Py_None;
    146         return _res;
     135    PyMac_PRECHECK(ReleaseResource);
     136#endif
     137    if (!PyArg_ParseTuple(_args, ""))
     138        return NULL;
     139    ReleaseResource(_self->ob_itself);
     140    {
     141        OSErr _err = ResError();
     142        if (_err != noErr) return PyMac_Error(_err);
     143    }
     144    Py_INCREF(Py_None);
     145    _res = Py_None;
     146    return _res;
    147147}
    148148
    149149static PyObject *ResObj_DetachResource(ResourceObject *_self, PyObject *_args)
    150150{
    151         PyObject *_res = NULL;
     151    PyObject *_res = NULL;
    152152#ifndef DetachResource
    153         PyMac_PRECHECK(DetachResource);
    154 #endif
    155         if (!PyArg_ParseTuple(_args, ""))
    156                 return NULL;
    157         DetachResource(_self->ob_itself);
    158         {
    159                 OSErr _err = ResError();
    160                 if (_err != noErr) return PyMac_Error(_err);
    161         }
    162         Py_INCREF(Py_None);
    163         _res = Py_None;
    164         return _res;
     153    PyMac_PRECHECK(DetachResource);
     154#endif
     155    if (!PyArg_ParseTuple(_args, ""))
     156        return NULL;
     157    DetachResource(_self->ob_itself);
     158    {
     159        OSErr _err = ResError();
     160        if (_err != noErr) return PyMac_Error(_err);
     161    }
     162    Py_INCREF(Py_None);
     163    _res = Py_None;
     164    return _res;
    165165}
    166166
    167167static PyObject *ResObj_GetResAttrs(ResourceObject *_self, PyObject *_args)
    168168{
    169         PyObject *_res = NULL;
    170         short _rv;
     169    PyObject *_res = NULL;
     170    short _rv;
    171171#ifndef GetResAttrs
    172         PyMac_PRECHECK(GetResAttrs);
    173 #endif
    174         if (!PyArg_ParseTuple(_args, ""))
    175                 return NULL;
    176         _rv = GetResAttrs(_self->ob_itself);
    177         {
    178                 OSErr _err = ResError();
    179                 if (_err != noErr) return PyMac_Error(_err);
    180         }
    181         _res = Py_BuildValue("h",
    182                              _rv);
    183         return _res;
     172    PyMac_PRECHECK(GetResAttrs);
     173#endif
     174    if (!PyArg_ParseTuple(_args, ""))
     175        return NULL;
     176    _rv = GetResAttrs(_self->ob_itself);
     177    {
     178        OSErr _err = ResError();
     179        if (_err != noErr) return PyMac_Error(_err);
     180    }
     181    _res = Py_BuildValue("h",
     182                         _rv);
     183    return _res;
    184184}
    185185
    186186static PyObject *ResObj_GetResInfo(ResourceObject *_self, PyObject *_args)
    187187{
    188         PyObject *_res = NULL;
    189         short theID;
    190         ResType theType;
    191         Str255 name;
     188    PyObject *_res = NULL;
     189    short theID;
     190    ResType theType;
     191    Str255 name;
    192192#ifndef GetResInfo
    193         PyMac_PRECHECK(GetResInfo);
    194 #endif
    195         if (!PyArg_ParseTuple(_args, ""))
    196                 return NULL;
    197         GetResInfo(_self->ob_itself,
    198                    &theID,
    199                    &theType,
    200                    name);
    201         {
    202                 OSErr _err = ResError();
    203                 if (_err != noErr) return PyMac_Error(_err);
    204         }
    205         _res = Py_BuildValue("hO&O&",
    206                              theID,
    207                              PyMac_BuildOSType, theType,
    208                              PyMac_BuildStr255, name);
    209         return _res;
     193    PyMac_PRECHECK(GetResInfo);
     194#endif
     195    if (!PyArg_ParseTuple(_args, ""))
     196        return NULL;
     197    GetResInfo(_self->ob_itself,
     198               &theID,
     199               &theType,
     200               name);
     201    {
     202        OSErr _err = ResError();
     203        if (_err != noErr) return PyMac_Error(_err);
     204    }
     205    _res = Py_BuildValue("hO&O&",
     206                         theID,
     207                         PyMac_BuildOSType, theType,
     208                         PyMac_BuildStr255, name);
     209    return _res;
    210210}
    211211
    212212static PyObject *ResObj_SetResInfo(ResourceObject *_self, PyObject *_args)
    213213{
    214         PyObject *_res = NULL;
    215         short theID;
    216         Str255 name;
     214    PyObject *_res = NULL;
     215    short theID;
     216    Str255 name;
    217217#ifndef SetResInfo
    218         PyMac_PRECHECK(SetResInfo);
    219 #endif
    220         if (!PyArg_ParseTuple(_args, "hO&",
    221                               &theID,
    222                               PyMac_GetStr255, name))
    223                 return NULL;
    224         SetResInfo(_self->ob_itself,
    225                    theID,
    226                    name);
    227         {
    228                 OSErr _err = ResError();
    229                 if (_err != noErr) return PyMac_Error(_err);
    230         }
    231         Py_INCREF(Py_None);
    232         _res = Py_None;
    233         return _res;
     218    PyMac_PRECHECK(SetResInfo);
     219#endif
     220    if (!PyArg_ParseTuple(_args, "hO&",
     221                          &theID,
     222                          PyMac_GetStr255, name))
     223        return NULL;
     224    SetResInfo(_self->ob_itself,
     225               theID,
     226               name);
     227    {
     228        OSErr _err = ResError();
     229        if (_err != noErr) return PyMac_Error(_err);
     230    }
     231    Py_INCREF(Py_None);
     232    _res = Py_None;
     233    return _res;
    234234}
    235235
    236236static PyObject *ResObj_AddResource(ResourceObject *_self, PyObject *_args)
    237237{
    238         PyObject *_res = NULL;
    239         ResType theType;
    240         short theID;
    241         Str255 name;
     238    PyObject *_res = NULL;
     239    ResType theType;
     240    short theID;
     241    Str255 name;
    242242#ifndef AddResource
    243         PyMac_PRECHECK(AddResource);
    244 #endif
    245         if (!PyArg_ParseTuple(_args, "O&hO&",
    246                               PyMac_GetOSType, &theType,
    247                               &theID,
    248                               PyMac_GetStr255, name))
    249                 return NULL;
    250         AddResource(_self->ob_itself,
    251                     theType,
    252                     theID,
    253                     name);
    254         {
    255                 OSErr _err = ResError();
    256                 if (_err != noErr) return PyMac_Error(_err);
    257         }
    258         Py_INCREF(Py_None);
    259         _res = Py_None;
    260         return _res;
     243    PyMac_PRECHECK(AddResource);
     244#endif
     245    if (!PyArg_ParseTuple(_args, "O&hO&",
     246                          PyMac_GetOSType, &theType,
     247                          &theID,
     248                          PyMac_GetStr255, name))
     249        return NULL;
     250    AddResource(_self->ob_itself,
     251                theType,
     252                theID,
     253                name);
     254    {
     255        OSErr _err = ResError();
     256        if (_err != noErr) return PyMac_Error(_err);
     257    }
     258    Py_INCREF(Py_None);
     259    _res = Py_None;
     260    return _res;
    261261}
    262262
    263263static PyObject *ResObj_GetResourceSizeOnDisk(ResourceObject *_self, PyObject *_args)
    264264{
    265         PyObject *_res = NULL;
    266         long _rv;
     265    PyObject *_res = NULL;
     266    long _rv;
    267267#ifndef GetResourceSizeOnDisk
    268         PyMac_PRECHECK(GetResourceSizeOnDisk);
    269 #endif
    270         if (!PyArg_ParseTuple(_args, ""))
    271                 return NULL;
    272         _rv = GetResourceSizeOnDisk(_self->ob_itself);
    273         {
    274                 OSErr _err = ResError();
    275                 if (_err != noErr) return PyMac_Error(_err);
    276         }
    277         _res = Py_BuildValue("l",
    278                              _rv);
    279         return _res;
     268    PyMac_PRECHECK(GetResourceSizeOnDisk);
     269#endif
     270    if (!PyArg_ParseTuple(_args, ""))
     271        return NULL;
     272    _rv = GetResourceSizeOnDisk(_self->ob_itself);
     273    {
     274        OSErr _err = ResError();
     275        if (_err != noErr) return PyMac_Error(_err);
     276    }
     277    _res = Py_BuildValue("l",
     278                         _rv);
     279    return _res;
    280280}
    281281
    282282static PyObject *ResObj_GetMaxResourceSize(ResourceObject *_self, PyObject *_args)
    283283{
    284         PyObject *_res = NULL;
    285         long _rv;
     284    PyObject *_res = NULL;
     285    long _rv;
    286286#ifndef GetMaxResourceSize
    287         PyMac_PRECHECK(GetMaxResourceSize);
    288 #endif
    289         if (!PyArg_ParseTuple(_args, ""))
    290                 return NULL;
    291         _rv = GetMaxResourceSize(_self->ob_itself);
    292         {
    293                 OSErr _err = ResError();
    294                 if (_err != noErr) return PyMac_Error(_err);
    295         }
    296         _res = Py_BuildValue("l",
    297                              _rv);
    298         return _res;
     287    PyMac_PRECHECK(GetMaxResourceSize);
     288#endif
     289    if (!PyArg_ParseTuple(_args, ""))
     290        return NULL;
     291    _rv = GetMaxResourceSize(_self->ob_itself);
     292    {
     293        OSErr _err = ResError();
     294        if (_err != noErr) return PyMac_Error(_err);
     295    }
     296    _res = Py_BuildValue("l",
     297                         _rv);
     298    return _res;
    299299}
    300300
    301301static PyObject *ResObj_SetResAttrs(ResourceObject *_self, PyObject *_args)
    302302{
    303         PyObject *_res = NULL;
    304         short attrs;
     303    PyObject *_res = NULL;
     304    short attrs;
    305305#ifndef SetResAttrs
    306         PyMac_PRECHECK(SetResAttrs);
    307 #endif
    308         if (!PyArg_ParseTuple(_args, "h",
    309                               &attrs))
    310                 return NULL;
    311         SetResAttrs(_self->ob_itself,
    312                     attrs);
    313         {
    314                 OSErr _err = ResError();
    315                 if (_err != noErr) return PyMac_Error(_err);
    316         }
    317         Py_INCREF(Py_None);
    318         _res = Py_None;
    319         return _res;
     306    PyMac_PRECHECK(SetResAttrs);
     307#endif
     308    if (!PyArg_ParseTuple(_args, "h",
     309                          &attrs))
     310        return NULL;
     311    SetResAttrs(_self->ob_itself,
     312                attrs);
     313    {
     314        OSErr _err = ResError();
     315        if (_err != noErr) return PyMac_Error(_err);
     316    }
     317    Py_INCREF(Py_None);
     318    _res = Py_None;
     319    return _res;
    320320}
    321321
    322322static PyObject *ResObj_ChangedResource(ResourceObject *_self, PyObject *_args)
    323323{
    324         PyObject *_res = NULL;
     324    PyObject *_res = NULL;
    325325#ifndef ChangedResource
    326         PyMac_PRECHECK(ChangedResource);
    327 #endif
    328         if (!PyArg_ParseTuple(_args, ""))
    329                 return NULL;
    330         ChangedResource(_self->ob_itself);
    331         {
    332                 OSErr _err = ResError();
    333                 if (_err != noErr) return PyMac_Error(_err);
    334         }
    335         Py_INCREF(Py_None);
    336         _res = Py_None;
    337         return _res;
     326    PyMac_PRECHECK(ChangedResource);
     327#endif
     328    if (!PyArg_ParseTuple(_args, ""))
     329        return NULL;
     330    ChangedResource(_self->ob_itself);
     331    {
     332        OSErr _err = ResError();
     333        if (_err != noErr) return PyMac_Error(_err);
     334    }
     335    Py_INCREF(Py_None);
     336    _res = Py_None;
     337    return _res;
    338338}
    339339
    340340static PyObject *ResObj_RemoveResource(ResourceObject *_self, PyObject *_args)
    341341{
    342         PyObject *_res = NULL;
     342    PyObject *_res = NULL;
    343343#ifndef RemoveResource
    344         PyMac_PRECHECK(RemoveResource);
    345 #endif
    346         if (!PyArg_ParseTuple(_args, ""))
    347                 return NULL;
    348         RemoveResource(_self->ob_itself);
    349         {
    350                 OSErr _err = ResError();
    351                 if (_err != noErr) return PyMac_Error(_err);
    352         }
    353         Py_INCREF(Py_None);
    354         _res = Py_None;
    355         return _res;
     344    PyMac_PRECHECK(RemoveResource);
     345#endif
     346    if (!PyArg_ParseTuple(_args, ""))
     347        return NULL;
     348    RemoveResource(_self->ob_itself);
     349    {
     350        OSErr _err = ResError();
     351        if (_err != noErr) return PyMac_Error(_err);
     352    }
     353    Py_INCREF(Py_None);
     354    _res = Py_None;
     355    return _res;
    356356}
    357357
    358358static PyObject *ResObj_WriteResource(ResourceObject *_self, PyObject *_args)
    359359{
    360         PyObject *_res = NULL;
     360    PyObject *_res = NULL;
    361361#ifndef WriteResource
    362         PyMac_PRECHECK(WriteResource);
    363 #endif
    364         if (!PyArg_ParseTuple(_args, ""))
    365                 return NULL;
    366         WriteResource(_self->ob_itself);
    367         {
    368                 OSErr _err = ResError();
    369                 if (_err != noErr) return PyMac_Error(_err);
    370         }
    371         Py_INCREF(Py_None);
    372         _res = Py_None;
    373         return _res;
     362    PyMac_PRECHECK(WriteResource);
     363#endif
     364    if (!PyArg_ParseTuple(_args, ""))
     365        return NULL;
     366    WriteResource(_self->ob_itself);
     367    {
     368        OSErr _err = ResError();
     369        if (_err != noErr) return PyMac_Error(_err);
     370    }
     371    Py_INCREF(Py_None);
     372    _res = Py_None;
     373    return _res;
    374374}
    375375
    376376static PyObject *ResObj_SetResourceSize(ResourceObject *_self, PyObject *_args)
    377377{
    378         PyObject *_res = NULL;
    379         long newSize;
     378    PyObject *_res = NULL;
     379    long newSize;
    380380#ifndef SetResourceSize
    381         PyMac_PRECHECK(SetResourceSize);
    382 #endif
    383         if (!PyArg_ParseTuple(_args, "l",
    384                               &newSize))
    385                 return NULL;
    386         SetResourceSize(_self->ob_itself,
    387                         newSize);
    388         {
    389                 OSErr _err = ResError();
    390                 if (_err != noErr) return PyMac_Error(_err);
    391         }
    392         Py_INCREF(Py_None);
    393         _res = Py_None;
    394         return _res;
     381    PyMac_PRECHECK(SetResourceSize);
     382#endif
     383    if (!PyArg_ParseTuple(_args, "l",
     384                          &newSize))
     385        return NULL;
     386    SetResourceSize(_self->ob_itself,
     387                    newSize);
     388    {
     389        OSErr _err = ResError();
     390        if (_err != noErr) return PyMac_Error(_err);
     391    }
     392    Py_INCREF(Py_None);
     393    _res = Py_None;
     394    return _res;
    395395}
    396396
    397397static PyObject *ResObj_GetNextFOND(ResourceObject *_self, PyObject *_args)
    398398{
    399         PyObject *_res = NULL;
    400         Handle _rv;
     399    PyObject *_res = NULL;
     400    Handle _rv;
    401401#ifndef GetNextFOND
    402         PyMac_PRECHECK(GetNextFOND);
    403 #endif
    404         if (!PyArg_ParseTuple(_args, ""))
    405                 return NULL;
    406         _rv = GetNextFOND(_self->ob_itself);
    407         {
    408                 OSErr _err = ResError();
    409                 if (_err != noErr) return PyMac_Error(_err);
    410         }
    411         _res = Py_BuildValue("O&",
    412                              ResObj_New, _rv);
    413         return _res;
     402    PyMac_PRECHECK(GetNextFOND);
     403#endif
     404    if (!PyArg_ParseTuple(_args, ""))
     405        return NULL;
     406    _rv = GetNextFOND(_self->ob_itself);
     407    {
     408        OSErr _err = ResError();
     409        if (_err != noErr) return PyMac_Error(_err);
     410    }
     411    _res = Py_BuildValue("O&",
     412                         ResObj_New, _rv);
     413    return _res;
    414414}
    415415
     
    417417static PyObject *ResObj_as_Control(ResourceObject *_self, PyObject *_args)
    418418{
    419         PyObject *_res = NULL;
    420 
    421         _res = CtlObj_New((ControlHandle)_self->ob_itself);
    422         return _res;
     419    PyObject *_res = NULL;
     420
     421    _res = CtlObj_New((ControlHandle)_self->ob_itself);
     422    return _res;
    423423
    424424}
     
    426426static PyObject *ResObj_as_Menu(ResourceObject *_self, PyObject *_args)
    427427{
    428         PyObject *_res = NULL;
    429 
    430         _res = MenuObj_New((MenuHandle)_self->ob_itself);
    431         return _res;
     428    PyObject *_res = NULL;
     429
     430    _res = MenuObj_New((MenuHandle)_self->ob_itself);
     431    return _res;
    432432
    433433}
     
    436436static PyObject *ResObj_LoadResource(ResourceObject *_self, PyObject *_args)
    437437{
    438         PyObject *_res = NULL;
     438    PyObject *_res = NULL;
    439439#ifndef LoadResource
    440         PyMac_PRECHECK(LoadResource);
    441 #endif
    442         if (!PyArg_ParseTuple(_args, ""))
    443                 return NULL;
    444         LoadResource(_self->ob_itself);
    445         {
    446                 OSErr _err = ResError();
    447                 if (_err != noErr) return PyMac_Error(_err);
    448         }
    449         Py_INCREF(Py_None);
    450         _res = Py_None;
    451         return _res;
     440    PyMac_PRECHECK(LoadResource);
     441#endif
     442    if (!PyArg_ParseTuple(_args, ""))
     443        return NULL;
     444    LoadResource(_self->ob_itself);
     445    {
     446        OSErr _err = ResError();
     447        if (_err != noErr) return PyMac_Error(_err);
     448    }
     449    Py_INCREF(Py_None);
     450    _res = Py_None;
     451    return _res;
    452452}
    453453
    454454static PyObject *ResObj_AutoDispose(ResourceObject *_self, PyObject *_args)
    455455{
    456         PyObject *_res = NULL;
    457 
    458         int onoff, old = 0;
    459         if (!PyArg_ParseTuple(_args, "i", &onoff))
    460                 return NULL;
    461         if ( _self->ob_freeit )
    462                 old = 1;
    463         if ( onoff )
    464                 _self->ob_freeit = PyMac_AutoDisposeHandle;
    465         else
    466                 _self->ob_freeit = NULL;
    467         _res = Py_BuildValue("i", old);
    468         return _res;
     456    PyObject *_res = NULL;
     457
     458    int onoff, old = 0;
     459    if (!PyArg_ParseTuple(_args, "i", &onoff))
     460        return NULL;
     461    if ( _self->ob_freeit )
     462        old = 1;
     463    if ( onoff )
     464        _self->ob_freeit = PyMac_AutoDisposeHandle;
     465    else
     466        _self->ob_freeit = NULL;
     467    _res = Py_BuildValue("i", old);
     468    return _res;
    469469
    470470}
    471471
    472472static PyMethodDef ResObj_methods[] = {
    473         {"HomeResFile", (PyCFunction)ResObj_HomeResFile, 1,
    474         PyDoc_STR("() -> (short _rv)")},
    475         {"MacLoadResource", (PyCFunction)ResObj_MacLoadResource, 1,
    476         PyDoc_STR("() -> None")},
    477         {"ReleaseResource", (PyCFunction)ResObj_ReleaseResource, 1,
    478         PyDoc_STR("() -> None")},
    479         {"DetachResource", (PyCFunction)ResObj_DetachResource, 1,
    480         PyDoc_STR("() -> None")},
    481         {"GetResAttrs", (PyCFunction)ResObj_GetResAttrs, 1,
    482         PyDoc_STR("() -> (short _rv)")},
    483         {"GetResInfo", (PyCFunction)ResObj_GetResInfo, 1,
    484         PyDoc_STR("() -> (short theID, ResType theType, Str255 name)")},
    485         {"SetResInfo", (PyCFunction)ResObj_SetResInfo, 1,
    486         PyDoc_STR("(short theID, Str255 name) -> None")},
    487         {"AddResource", (PyCFunction)ResObj_AddResource, 1,
    488         PyDoc_STR("(ResType theType, short theID, Str255 name) -> None")},
    489         {"GetResourceSizeOnDisk", (PyCFunction)ResObj_GetResourceSizeOnDisk, 1,
    490         PyDoc_STR("() -> (long _rv)")},
    491         {"GetMaxResourceSize", (PyCFunction)ResObj_GetMaxResourceSize, 1,
    492         PyDoc_STR("() -> (long _rv)")},
    493         {"SetResAttrs", (PyCFunction)ResObj_SetResAttrs, 1,
    494         PyDoc_STR("(short attrs) -> None")},
    495         {"ChangedResource", (PyCFunction)ResObj_ChangedResource, 1,
    496         PyDoc_STR("() -> None")},
    497         {"RemoveResource", (PyCFunction)ResObj_RemoveResource, 1,
    498         PyDoc_STR("() -> None")},
    499         {"WriteResource", (PyCFunction)ResObj_WriteResource, 1,
    500         PyDoc_STR("() -> None")},
    501         {"SetResourceSize", (PyCFunction)ResObj_SetResourceSize, 1,
    502         PyDoc_STR("(long newSize) -> None")},
    503         {"GetNextFOND", (PyCFunction)ResObj_GetNextFOND, 1,
    504         PyDoc_STR("() -> (Handle _rv)")},
     473    {"HomeResFile", (PyCFunction)ResObj_HomeResFile, 1,
     474    PyDoc_STR("() -> (short _rv)")},
     475    {"MacLoadResource", (PyCFunction)ResObj_MacLoadResource, 1,
     476    PyDoc_STR("() -> None")},
     477    {"ReleaseResource", (PyCFunction)ResObj_ReleaseResource, 1,
     478    PyDoc_STR("() -> None")},
     479    {"DetachResource", (PyCFunction)ResObj_DetachResource, 1,
     480    PyDoc_STR("() -> None")},
     481    {"GetResAttrs", (PyCFunction)ResObj_GetResAttrs, 1,
     482    PyDoc_STR("() -> (short _rv)")},
     483    {"GetResInfo", (PyCFunction)ResObj_GetResInfo, 1,
     484    PyDoc_STR("() -> (short theID, ResType theType, Str255 name)")},
     485    {"SetResInfo", (PyCFunction)ResObj_SetResInfo, 1,
     486    PyDoc_STR("(short theID, Str255 name) -> None")},
     487    {"AddResource", (PyCFunction)ResObj_AddResource, 1,
     488    PyDoc_STR("(ResType theType, short theID, Str255 name) -> None")},
     489    {"GetResourceSizeOnDisk", (PyCFunction)ResObj_GetResourceSizeOnDisk, 1,
     490    PyDoc_STR("() -> (long _rv)")},
     491    {"GetMaxResourceSize", (PyCFunction)ResObj_GetMaxResourceSize, 1,
     492    PyDoc_STR("() -> (long _rv)")},
     493    {"SetResAttrs", (PyCFunction)ResObj_SetResAttrs, 1,
     494    PyDoc_STR("(short attrs) -> None")},
     495    {"ChangedResource", (PyCFunction)ResObj_ChangedResource, 1,
     496    PyDoc_STR("() -> None")},
     497    {"RemoveResource", (PyCFunction)ResObj_RemoveResource, 1,
     498    PyDoc_STR("() -> None")},
     499    {"WriteResource", (PyCFunction)ResObj_WriteResource, 1,
     500    PyDoc_STR("() -> None")},
     501    {"SetResourceSize", (PyCFunction)ResObj_SetResourceSize, 1,
     502    PyDoc_STR("(long newSize) -> None")},
     503    {"GetNextFOND", (PyCFunction)ResObj_GetNextFOND, 1,
     504    PyDoc_STR("() -> (Handle _rv)")},
    505505#ifndef __LP64__
    506         {"as_Control", (PyCFunction)ResObj_as_Control, 1,
    507         PyDoc_STR("Return this resource/handle as a Control")},
    508         {"as_Menu", (PyCFunction)ResObj_as_Menu, 1,
    509         PyDoc_STR("Return this resource/handle as a Menu")},
     506    {"as_Control", (PyCFunction)ResObj_as_Control, 1,
     507    PyDoc_STR("Return this resource/handle as a Control")},
     508    {"as_Menu", (PyCFunction)ResObj_as_Menu, 1,
     509    PyDoc_STR("Return this resource/handle as a Menu")},
    510510#endif /* !__LP64__ */
    511         {"LoadResource", (PyCFunction)ResObj_LoadResource, 1,
    512         PyDoc_STR("() -> None")},
    513         {"AutoDispose", (PyCFunction)ResObj_AutoDispose, 1,
    514         PyDoc_STR("(int)->int. Automatically DisposeHandle the object on Python object cleanup")},
    515         {NULL, NULL, 0}
     511    {"LoadResource", (PyCFunction)ResObj_LoadResource, 1,
     512    PyDoc_STR("() -> None")},
     513    {"AutoDispose", (PyCFunction)ResObj_AutoDispose, 1,
     514    PyDoc_STR("(int)->int. Automatically DisposeHandle the object on Python object cleanup")},
     515    {NULL, NULL, 0}
    516516};
    517517
     
    519519{
    520520
    521                     PyObject *res;
    522                     char state;
    523 
    524                     state = HGetState(self->ob_itself);
    525                     HLock(self->ob_itself);
    526                     res = PyString_FromStringAndSize(
    527                             *self->ob_itself,
    528                             GetHandleSize(self->ob_itself));
    529                     HUnlock(self->ob_itself);
    530                     HSetState(self->ob_itself, state);
    531                     return res;
    532                    
     521                    PyObject *res;
     522                    char state;
     523
     524                    state = HGetState(self->ob_itself);
     525                    HLock(self->ob_itself);
     526                    res = PyString_FromStringAndSize(
     527                            *self->ob_itself,
     528                            GetHandleSize(self->ob_itself));
     529                    HUnlock(self->ob_itself);
     530                    HSetState(self->ob_itself, state);
     531                    return res;
     532
    533533}
    534534
     
    536536{
    537537
    538                     char *data;
    539                     long size;
    540 
    541                     if ( v == NULL )
    542                             return -1;
    543                     if ( !PyString_Check(v) )
    544                             return -1;
    545                     size = PyString_Size(v);
    546                     data = PyString_AsString(v);
    547                     /* XXXX Do I need the GetState/SetState calls? */
    548                     SetHandleSize(self->ob_itself, size);
    549                     if ( MemError())
    550                             return -1;
    551                     HLock(self->ob_itself);
    552                     memcpy((char *)*self->ob_itself, data, size);
    553                     HUnlock(self->ob_itself);
    554                     /* XXXX Should I do the Changed call immedeately? */
    555                     return 0;
    556                    
    557         return 0;
     538                    char *data;
     539                    long size;
     540
     541                    if ( v == NULL )
     542                            return -1;
     543                    if ( !PyString_Check(v) )
     544                            return -1;
     545                    size = PyString_Size(v);
     546                    data = PyString_AsString(v);
     547                    /* XXXX Do I need the GetState/SetState calls? */
     548            SetHandleSize(self->ob_itself, size);
     549            if ( MemError())
     550                return -1;
     551            HLock(self->ob_itself);
     552            memcpy((char *)*self->ob_itself, data, size);
     553            HUnlock(self->ob_itself);
     554            /* XXXX Should I do the Changed call immedeately? */
     555            return 0;
     556
     557    return 0;
    558558}
    559559
    560560static PyObject *ResObj_get_size(ResourceObject *self, void *closure)
    561561{
    562         return PyInt_FromLong(GetHandleSize(self->ob_itself));
     562    return PyInt_FromLong(GetHandleSize(self->ob_itself));
    563563}
    564564
     
    566566
    567567static PyGetSetDef ResObj_getsetlist[] = {
    568         {"data", (getter)ResObj_get_data, (setter)ResObj_set_data, "The resource data"},
    569         {"size", (getter)ResObj_get_size, (setter)ResObj_set_size, "The length of the resource data"},
    570         {NULL, NULL, NULL, NULL},
     568    {"data", (getter)ResObj_get_data, (setter)ResObj_set_data, "The resource data"},
     569    {"size", (getter)ResObj_get_size, (setter)ResObj_set_size, "The length of the resource data"},
     570    {NULL, NULL, NULL, NULL},
    571571};
    572572
     
    579579static int ResObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds)
    580580{
    581         char *srcdata = NULL;
    582         int srclen = 0;
    583         Handle itself;
    584         char *kw[] = {"itself", 0};
    585 
    586         if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, ResObj_Convert, &itself))
    587         {
    588                 ((ResourceObject *)_self)->ob_itself = itself;
    589                 return 0;
    590         }
    591         PyErr_Clear();
    592         if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "|s#", kw, &srcdata, &srclen)) return -1;
    593         if ((itself = NewHandle(srclen)) == NULL)
    594         {
    595                 PyErr_NoMemory();
    596                 return 0;
    597         }
    598         ((ResourceObject *)_self)->ob_itself = itself;
    599         if (srclen && srcdata)
    600         {
    601                 HLock(itself);
    602                 memcpy(*itself, srcdata, srclen);
    603                 HUnlock(itself);
    604         }
    605         return 0;
     581    char *srcdata = NULL;
     582    int srclen = 0;
     583    Handle itself;
     584    char *kw[] = {"itself", 0};
     585
     586    if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, ResObj_Convert, &itself))
     587    {
     588        ((ResourceObject *)_self)->ob_itself = itself;
     589        return 0;
     590    }
     591    PyErr_Clear();
     592    if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "|s#", kw, &srcdata, &srclen)) return -1;
     593    if ((itself = NewHandle(srclen)) == NULL)
     594    {
     595        PyErr_NoMemory();
     596        return 0;
     597    }
     598    ((ResourceObject *)_self)->ob_itself = itself;
     599    if (srclen && srcdata)
     600    {
     601        HLock(itself);
     602        memcpy(*itself, srcdata, srclen);
     603        HUnlock(itself);
     604    }
     605    return 0;
    606606}
    607607
     
    610610static PyObject *ResObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
    611611{
    612         PyObject *self;
    613         if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
    614         ((ResourceObject *)self)->ob_itself = NULL;
    615         ((ResourceObject *)self)->ob_freeit = NULL;
    616         return self;
     612    PyObject *self;
     613    if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
     614    ((ResourceObject *)self)->ob_itself = NULL;
     615    ((ResourceObject *)self)->ob_freeit = NULL;
     616    return self;
    617617}
    618618
     
    621621
    622622PyTypeObject Resource_Type = {
    623         PyObject_HEAD_INIT(NULL)
    624         0, /*ob_size*/
    625         "_Res.Resource", /*tp_name*/
    626         sizeof(ResourceObject), /*tp_basicsize*/
    627         0, /*tp_itemsize*/
    628         /* methods */
    629         (destructor) ResObj_dealloc, /*tp_dealloc*/
    630         0, /*tp_print*/
    631         (getattrfunc)0, /*tp_getattr*/
    632         (setattrfunc)0, /*tp_setattr*/
    633         (cmpfunc) ResObj_compare, /*tp_compare*/
    634         (reprfunc) ResObj_repr, /*tp_repr*/
    635         (PyNumberMethods *)0, /* tp_as_number */
    636         (PySequenceMethods *)0, /* tp_as_sequence */
    637         (PyMappingMethods *)0, /* tp_as_mapping */
    638         (hashfunc) ResObj_hash, /*tp_hash*/
    639         0, /*tp_call*/
    640         0, /*tp_str*/
    641         PyObject_GenericGetAttr, /*tp_getattro*/
    642         PyObject_GenericSetAttr, /*tp_setattro */
    643         0, /*tp_as_buffer*/
    644         Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
    645         0, /*tp_doc*/
    646         0, /*tp_traverse*/
    647         0, /*tp_clear*/
    648         0, /*tp_richcompare*/
    649         0, /*tp_weaklistoffset*/
    650         0, /*tp_iter*/
    651         0, /*tp_iternext*/
    652         ResObj_methods, /* tp_methods */
    653         0, /*tp_members*/
    654         ResObj_getsetlist, /*tp_getset*/
    655         0, /*tp_base*/
    656         0, /*tp_dict*/
    657         0, /*tp_descr_get*/
    658         0, /*tp_descr_set*/
    659         0, /*tp_dictoffset*/
    660         ResObj_tp_init, /* tp_init */
    661         ResObj_tp_alloc, /* tp_alloc */
    662         ResObj_tp_new, /* tp_new */
    663         ResObj_tp_free, /* tp_free */
     623    PyObject_HEAD_INIT(NULL)
     624    0, /*ob_size*/
     625    "_Res.Resource", /*tp_name*/
     626    sizeof(ResourceObject), /*tp_basicsize*/
     627    0, /*tp_itemsize*/
     628    /* methods */
     629    (destructor) ResObj_dealloc, /*tp_dealloc*/
     630    0, /*tp_print*/
     631    (getattrfunc)0, /*tp_getattr*/
     632    (setattrfunc)0, /*tp_setattr*/
     633    (cmpfunc) ResObj_compare, /*tp_compare*/
     634    (reprfunc) ResObj_repr, /*tp_repr*/
     635    (PyNumberMethods *)0, /* tp_as_number */
     636    (PySequenceMethods *)0, /* tp_as_sequence */
     637    (PyMappingMethods *)0, /* tp_as_mapping */
     638    (hashfunc) ResObj_hash, /*tp_hash*/
     639    0, /*tp_call*/
     640    0, /*tp_str*/
     641    PyObject_GenericGetAttr, /*tp_getattro*/
     642    PyObject_GenericSetAttr, /*tp_setattro */
     643    0, /*tp_as_buffer*/
     644    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
     645    0, /*tp_doc*/
     646    0, /*tp_traverse*/
     647    0, /*tp_clear*/
     648    0, /*tp_richcompare*/
     649    0, /*tp_weaklistoffset*/
     650    0, /*tp_iter*/
     651    0, /*tp_iternext*/
     652    ResObj_methods, /* tp_methods */
     653    0, /*tp_members*/
     654    ResObj_getsetlist, /*tp_getset*/
     655    0, /*tp_base*/
     656    0, /*tp_dict*/
     657    0, /*tp_descr_get*/
     658    0, /*tp_descr_set*/
     659    0, /*tp_dictoffset*/
     660    ResObj_tp_init, /* tp_init */
     661    ResObj_tp_alloc, /* tp_alloc */
     662    ResObj_tp_new, /* tp_new */
     663    ResObj_tp_free, /* tp_free */
    664664};
    665665
     
    669669static PyObject *Res_CloseResFile(PyObject *_self, PyObject *_args)
    670670{
    671         PyObject *_res = NULL;
    672         short refNum;
     671    PyObject *_res = NULL;
     672    short refNum;
    673673#ifndef CloseResFile
    674         PyMac_PRECHECK(CloseResFile);
    675 #endif
    676         if (!PyArg_ParseTuple(_args, "h",
    677                               &refNum))
    678                 return NULL;
    679         CloseResFile(refNum);
    680         {
    681                 OSErr _err = ResError();
    682                 if (_err != noErr) return PyMac_Error(_err);
    683         }
    684         Py_INCREF(Py_None);
    685         _res = Py_None;
    686         return _res;
     674    PyMac_PRECHECK(CloseResFile);
     675#endif
     676    if (!PyArg_ParseTuple(_args, "h",
     677                          &refNum))
     678        return NULL;
     679    CloseResFile(refNum);
     680    {
     681        OSErr _err = ResError();
     682        if (_err != noErr) return PyMac_Error(_err);
     683    }
     684    Py_INCREF(Py_None);
     685    _res = Py_None;
     686    return _res;
    687687}
    688688
    689689static PyObject *Res_ResError(PyObject *_self, PyObject *_args)
    690690{
    691         PyObject *_res = NULL;
    692         OSErr _err;
     691    PyObject *_res = NULL;
     692    OSErr _err;
    693693#ifndef ResError
    694         PyMac_PRECHECK(ResError);
    695 #endif
    696         if (!PyArg_ParseTuple(_args, ""))
    697                 return NULL;
    698         _err = ResError();
    699         if (_err != noErr) return PyMac_Error(_err);
    700         Py_INCREF(Py_None);
    701         _res = Py_None;
    702         return _res;
     694    PyMac_PRECHECK(ResError);
     695#endif
     696    if (!PyArg_ParseTuple(_args, ""))
     697        return NULL;
     698    _err = ResError();
     699    if (_err != noErr) return PyMac_Error(_err);
     700    Py_INCREF(Py_None);
     701    _res = Py_None;
     702    return _res;
    703703}
    704704
    705705static PyObject *Res_CurResFile(PyObject *_self, PyObject *_args)
    706706{
    707         PyObject *_res = NULL;
    708         short _rv;
     707    PyObject *_res = NULL;
     708    short _rv;
    709709#ifndef CurResFile
    710         PyMac_PRECHECK(CurResFile);
    711 #endif
    712         if (!PyArg_ParseTuple(_args, ""))
    713                 return NULL;
    714         _rv = CurResFile();
    715         {
    716                 OSErr _err = ResError();
    717                 if (_err != noErr) return PyMac_Error(_err);
    718         }
    719         _res = Py_BuildValue("h",
    720                              _rv);
    721         return _res;
     710    PyMac_PRECHECK(CurResFile);
     711#endif
     712    if (!PyArg_ParseTuple(_args, ""))
     713        return NULL;
     714    _rv = CurResFile();
     715    {
     716        OSErr _err = ResError();
     717        if (_err != noErr) return PyMac_Error(_err);
     718    }
     719    _res = Py_BuildValue("h",
     720                         _rv);
     721    return _res;
    722722}
    723723
    724724static PyObject *Res_UseResFile(PyObject *_self, PyObject *_args)
    725725{
    726         PyObject *_res = NULL;
    727         short refNum;
     726    PyObject *_res = NULL;
     727    short refNum;
    728728#ifndef UseResFile
    729         PyMac_PRECHECK(UseResFile);
    730 #endif
    731         if (!PyArg_ParseTuple(_args, "h",
    732                               &refNum))
    733                 return NULL;
    734         UseResFile(refNum);
    735         {
    736                 OSErr _err = ResError();
    737                 if (_err != noErr) return PyMac_Error(_err);
    738         }
    739         Py_INCREF(Py_None);
    740         _res = Py_None;
    741         return _res;
     729    PyMac_PRECHECK(UseResFile);
     730#endif
     731    if (!PyArg_ParseTuple(_args, "h",
     732                          &refNum))
     733        return NULL;
     734    UseResFile(refNum);
     735    {
     736        OSErr _err = ResError();
     737        if (_err != noErr) return PyMac_Error(_err);
     738    }
     739    Py_INCREF(Py_None);
     740    _res = Py_None;
     741    return _res;
    742742}
    743743
    744744static PyObject *Res_CountTypes(PyObject *_self, PyObject *_args)
    745745{
    746         PyObject *_res = NULL;
    747         short _rv;
     746    PyObject *_res = NULL;
     747    short _rv;
    748748#ifndef CountTypes
    749         PyMac_PRECHECK(CountTypes);
    750 #endif
    751         if (!PyArg_ParseTuple(_args, ""))
    752                 return NULL;
    753         _rv = CountTypes();
    754         {
    755                 OSErr _err = ResError();
    756                 if (_err != noErr) return PyMac_Error(_err);
    757         }
    758         _res = Py_BuildValue("h",
    759                              _rv);
    760         return _res;
     749    PyMac_PRECHECK(CountTypes);
     750#endif
     751    if (!PyArg_ParseTuple(_args, ""))
     752        return NULL;
     753    _rv = CountTypes();
     754    {
     755        OSErr _err = ResError();
     756        if (_err != noErr) return PyMac_Error(_err);
     757    }
     758    _res = Py_BuildValue("h",
     759                         _rv);
     760    return _res;
    761761}
    762762
    763763static PyObject *Res_Count1Types(PyObject *_self, PyObject *_args)
    764764{
    765         PyObject *_res = NULL;
    766         short _rv;
     765    PyObject *_res = NULL;
     766    short _rv;
    767767#ifndef Count1Types
    768         PyMac_PRECHECK(Count1Types);
    769 #endif
    770         if (!PyArg_ParseTuple(_args, ""))
    771                 return NULL;
    772         _rv = Count1Types();
    773         {
    774                 OSErr _err = ResError();
    775                 if (_err != noErr) return PyMac_Error(_err);
    776         }
    777         _res = Py_BuildValue("h",
    778                              _rv);
    779         return _res;
     768    PyMac_PRECHECK(Count1Types);
     769#endif
     770    if (!PyArg_ParseTuple(_args, ""))
     771        return NULL;
     772    _rv = Count1Types();
     773    {
     774        OSErr _err = ResError();
     775        if (_err != noErr) return PyMac_Error(_err);
     776    }
     777    _res = Py_BuildValue("h",
     778                         _rv);
     779    return _res;
    780780}
    781781
    782782static PyObject *Res_GetIndType(PyObject *_self, PyObject *_args)
    783783{
    784         PyObject *_res = NULL;
    785         ResType theType;
    786         short index;
     784    PyObject *_res = NULL;
     785    ResType theType;
     786    short index;
    787787#ifndef GetIndType
    788         PyMac_PRECHECK(GetIndType);
    789 #endif
    790         if (!PyArg_ParseTuple(_args, "h",
    791                               &index))
    792                 return NULL;
    793         GetIndType(&theType,
    794                    index);
    795         {
    796                 OSErr _err = ResError();
    797                 if (_err != noErr) return PyMac_Error(_err);
    798         }
    799         _res = Py_BuildValue("O&",
    800                              PyMac_BuildOSType, theType);
    801         return _res;
     788    PyMac_PRECHECK(GetIndType);
     789#endif
     790    if (!PyArg_ParseTuple(_args, "h",
     791                          &index))
     792        return NULL;
     793    GetIndType(&theType,
     794               index);
     795    {
     796        OSErr _err = ResError();
     797        if (_err != noErr) return PyMac_Error(_err);
     798    }
     799    _res = Py_BuildValue("O&",
     800                         PyMac_BuildOSType, theType);
     801    return _res;
    802802}
    803803
    804804static PyObject *Res_Get1IndType(PyObject *_self, PyObject *_args)
    805805{
    806         PyObject *_res = NULL;
    807         ResType theType;
    808         short index;
     806    PyObject *_res = NULL;
     807    ResType theType;
     808    short index;
    809809#ifndef Get1IndType
    810         PyMac_PRECHECK(Get1IndType);
    811 #endif
    812         if (!PyArg_ParseTuple(_args, "h",
    813                               &index))
    814                 return NULL;
    815         Get1IndType(&theType,
    816                     index);
    817         {
    818                 OSErr _err = ResError();
    819                 if (_err != noErr) return PyMac_Error(_err);
    820         }
    821         _res = Py_BuildValue("O&",
    822                              PyMac_BuildOSType, theType);
    823         return _res;
     810    PyMac_PRECHECK(Get1IndType);
     811#endif
     812    if (!PyArg_ParseTuple(_args, "h",
     813                          &index))
     814        return NULL;
     815    Get1IndType(&theType,
     816                index);
     817    {
     818        OSErr _err = ResError();
     819        if (_err != noErr) return PyMac_Error(_err);
     820    }
     821    _res = Py_BuildValue("O&",
     822                         PyMac_BuildOSType, theType);
     823    return _res;
    824824}
    825825
    826826static PyObject *Res_SetResLoad(PyObject *_self, PyObject *_args)
    827827{
    828         PyObject *_res = NULL;
    829         Boolean load;
     828    PyObject *_res = NULL;
     829    Boolean load;
    830830#ifndef SetResLoad
    831         PyMac_PRECHECK(SetResLoad);
    832 #endif
    833         if (!PyArg_ParseTuple(_args, "b",
    834                               &load))
    835                 return NULL;
    836         SetResLoad(load);
    837         {
    838                 OSErr _err = ResError();
    839                 if (_err != noErr) return PyMac_Error(_err);
    840         }
    841         Py_INCREF(Py_None);
    842         _res = Py_None;
    843         return _res;
     831    PyMac_PRECHECK(SetResLoad);
     832#endif
     833    if (!PyArg_ParseTuple(_args, "b",
     834                          &load))
     835        return NULL;
     836    SetResLoad(load);
     837    {
     838        OSErr _err = ResError();
     839        if (_err != noErr) return PyMac_Error(_err);
     840    }
     841    Py_INCREF(Py_None);
     842    _res = Py_None;
     843    return _res;
    844844}
    845845
    846846static PyObject *Res_CountResources(PyObject *_self, PyObject *_args)
    847847{
    848         PyObject *_res = NULL;
    849         short _rv;
    850         ResType theType;
     848    PyObject *_res = NULL;
     849    short _rv;
     850    ResType theType;
    851851#ifndef CountResources
    852         PyMac_PRECHECK(CountResources);
    853 #endif
    854         if (!PyArg_ParseTuple(_args, "O&",
    855                               PyMac_GetOSType, &theType))
    856                 return NULL;
    857         _rv = CountResources(theType);
    858         {
    859                 OSErr _err = ResError();
    860                 if (_err != noErr) return PyMac_Error(_err);
    861         }
    862         _res = Py_BuildValue("h",
    863                              _rv);
    864         return _res;
     852    PyMac_PRECHECK(CountResources);
     853#endif
     854    if (!PyArg_ParseTuple(_args, "O&",
     855                          PyMac_GetOSType, &theType))
     856        return NULL;
     857    _rv = CountResources(theType);
     858    {
     859        OSErr _err = ResError();
     860        if (_err != noErr) return PyMac_Error(_err);
     861    }
     862    _res = Py_BuildValue("h",
     863                         _rv);
     864    return _res;
    865865}
    866866
    867867static PyObject *Res_Count1Resources(PyObject *_self, PyObject *_args)
    868868{
    869         PyObject *_res = NULL;
    870         short _rv;
    871         ResType theType;
     869    PyObject *_res = NULL;
     870    short _rv;
     871    ResType theType;
    872872#ifndef Count1Resources
    873         PyMac_PRECHECK(Count1Resources);
    874 #endif
    875         if (!PyArg_ParseTuple(_args, "O&",
    876                               PyMac_GetOSType, &theType))
    877                 return NULL;
    878         _rv = Count1Resources(theType);
    879         {
    880                 OSErr _err = ResError();
    881                 if (_err != noErr) return PyMac_Error(_err);
    882         }
    883         _res = Py_BuildValue("h",
    884                              _rv);
    885         return _res;
     873    PyMac_PRECHECK(Count1Resources);
     874#endif
     875    if (!PyArg_ParseTuple(_args, "O&",
     876                          PyMac_GetOSType, &theType))
     877        return NULL;
     878    _rv = Count1Resources(theType);
     879    {
     880        OSErr _err = ResError();
     881        if (_err != noErr) return PyMac_Error(_err);
     882    }
     883    _res = Py_BuildValue("h",
     884                         _rv);
     885    return _res;
    886886}
    887887
    888888static PyObject *Res_GetIndResource(PyObject *_self, PyObject *_args)
    889889{
    890         PyObject *_res = NULL;
    891         Handle _rv;
    892         ResType theType;
    893         short index;
     890    PyObject *_res = NULL;
     891    Handle _rv;
     892    ResType theType;
     893    short index;
    894894#ifndef GetIndResource
    895         PyMac_PRECHECK(GetIndResource);
    896 #endif
    897         if (!PyArg_ParseTuple(_args, "O&h",
    898                               PyMac_GetOSType, &theType,
    899                               &index))
    900                 return NULL;
    901         _rv = GetIndResource(theType,
    902                              index);
    903         {
    904                 OSErr _err = ResError();
    905                 if (_err != noErr) return PyMac_Error(_err);
    906         }
    907         _res = Py_BuildValue("O&",
    908                              ResObj_New, _rv);
    909         return _res;
     895    PyMac_PRECHECK(GetIndResource);
     896#endif
     897    if (!PyArg_ParseTuple(_args, "O&h",
     898                          PyMac_GetOSType, &theType,
     899                          &index))
     900        return NULL;
     901    _rv = GetIndResource(theType,
     902                         index);
     903    {
     904        OSErr _err = ResError();
     905        if (_err != noErr) return PyMac_Error(_err);
     906    }
     907    _res = Py_BuildValue("O&",
     908                         ResObj_New, _rv);
     909    return _res;
    910910}
    911911
    912912static PyObject *Res_Get1IndResource(PyObject *_self, PyObject *_args)
    913913{
    914         PyObject *_res = NULL;
    915         Handle _rv;
    916         ResType theType;
    917         short index;
     914    PyObject *_res = NULL;
     915    Handle _rv;
     916    ResType theType;
     917    short index;
    918918#ifndef Get1IndResource
    919         PyMac_PRECHECK(Get1IndResource);
    920 #endif
    921         if (!PyArg_ParseTuple(_args, "O&h",
    922                               PyMac_GetOSType, &theType,
    923                               &index))
    924                 return NULL;
    925         _rv = Get1IndResource(theType,
    926                               index);
    927         {
    928                 OSErr _err = ResError();
    929                 if (_err != noErr) return PyMac_Error(_err);
    930         }
    931         _res = Py_BuildValue("O&",
    932                              ResObj_New, _rv);
    933         return _res;
     919    PyMac_PRECHECK(Get1IndResource);
     920#endif
     921    if (!PyArg_ParseTuple(_args, "O&h",
     922                          PyMac_GetOSType, &theType,
     923                          &index))
     924        return NULL;
     925    _rv = Get1IndResource(theType,
     926                          index);
     927    {
     928        OSErr _err = ResError();
     929        if (_err != noErr) return PyMac_Error(_err);
     930    }
     931    _res = Py_BuildValue("O&",
     932                         ResObj_New, _rv);
     933    return _res;
    934934}
    935935
    936936static PyObject *Res_GetResource(PyObject *_self, PyObject *_args)
    937937{
    938         PyObject *_res = NULL;
    939         Handle _rv;
    940         ResType theType;
    941         short theID;
     938    PyObject *_res = NULL;
     939    Handle _rv;
     940    ResType theType;
     941    short theID;
    942942#ifndef GetResource
    943         PyMac_PRECHECK(GetResource);
    944 #endif
    945         if (!PyArg_ParseTuple(_args, "O&h",
    946                               PyMac_GetOSType, &theType,
    947                               &theID))
    948                 return NULL;
    949         _rv = GetResource(theType,
    950                           theID);
    951         {
    952                 OSErr _err = ResError();
    953                 if (_err != noErr) return PyMac_Error(_err);
    954         }
    955         _res = Py_BuildValue("O&",
    956                              ResObj_New, _rv);
    957         return _res;
     943    PyMac_PRECHECK(GetResource);
     944#endif
     945    if (!PyArg_ParseTuple(_args, "O&h",
     946                          PyMac_GetOSType, &theType,
     947                          &theID))
     948        return NULL;
     949    _rv = GetResource(theType,
     950                      theID);
     951    {
     952        OSErr _err = ResError();
     953        if (_err != noErr) return PyMac_Error(_err);
     954    }
     955    _res = Py_BuildValue("O&",
     956                         ResObj_New, _rv);
     957    return _res;
    958958}
    959959
    960960static PyObject *Res_Get1Resource(PyObject *_self, PyObject *_args)
    961961{
    962         PyObject *_res = NULL;
    963         Handle _rv;
    964         ResType theType;
    965         short theID;
     962    PyObject *_res = NULL;
     963    Handle _rv;
     964    ResType theType;
     965    short theID;
    966966#ifndef Get1Resource
    967         PyMac_PRECHECK(Get1Resource);
    968 #endif
    969         if (!PyArg_ParseTuple(_args, "O&h",
    970                               PyMac_GetOSType, &theType,
    971                               &theID))
    972                 return NULL;
    973         _rv = Get1Resource(theType,
    974                            theID);
    975         {
    976                 OSErr _err = ResError();
    977                 if (_err != noErr) return PyMac_Error(_err);
    978         }
    979         _res = Py_BuildValue("O&",
    980                              ResObj_New, _rv);
    981         return _res;
     967    PyMac_PRECHECK(Get1Resource);
     968#endif
     969    if (!PyArg_ParseTuple(_args, "O&h",
     970                          PyMac_GetOSType, &theType,
     971                          &theID))
     972        return NULL;
     973    _rv = Get1Resource(theType,
     974                       theID);
     975    {
     976        OSErr _err = ResError();
     977        if (_err != noErr) return PyMac_Error(_err);
     978    }
     979    _res = Py_BuildValue("O&",
     980                         ResObj_New, _rv);
     981    return _res;
    982982}
    983983
    984984static PyObject *Res_GetNamedResource(PyObject *_self, PyObject *_args)
    985985{
    986         PyObject *_res = NULL;
    987         Handle _rv;
    988         ResType theType;
    989         Str255 name;
     986    PyObject *_res = NULL;
     987    Handle _rv;
     988    ResType theType;
     989    Str255 name;
    990990#ifndef GetNamedResource
    991         PyMac_PRECHECK(GetNamedResource);
    992 #endif
    993         if (!PyArg_ParseTuple(_args, "O&O&",
    994                               PyMac_GetOSType, &theType,
    995                               PyMac_GetStr255, name))
    996                 return NULL;
    997         _rv = GetNamedResource(theType,
    998                                name);
    999         {
    1000                 OSErr _err = ResError();
    1001                 if (_err != noErr) return PyMac_Error(_err);
    1002         }
    1003         _res = Py_BuildValue("O&",
    1004                              ResObj_New, _rv);
    1005         return _res;
     991    PyMac_PRECHECK(GetNamedResource);
     992#endif
     993    if (!PyArg_ParseTuple(_args, "O&O&",
     994                          PyMac_GetOSType, &theType,
     995                          PyMac_GetStr255, name))
     996        return NULL;
     997    _rv = GetNamedResource(theType,
     998                           name);
     999    {
     1000        OSErr _err = ResError();
     1001        if (_err != noErr) return PyMac_Error(_err);
     1002    }
     1003    _res = Py_BuildValue("O&",
     1004                         ResObj_New, _rv);
     1005    return _res;
    10061006}
    10071007
    10081008static PyObject *Res_Get1NamedResource(PyObject *_self, PyObject *_args)
    10091009{
    1010         PyObject *_res = NULL;
    1011         Handle _rv;
    1012         ResType theType;
    1013         Str255 name;
     1010    PyObject *_res = NULL;
     1011    Handle _rv;
     1012    ResType theType;
     1013    Str255 name;
    10141014#ifndef Get1NamedResource
    1015         PyMac_PRECHECK(Get1NamedResource);
    1016 #endif
    1017         if (!PyArg_ParseTuple(_args, "O&O&",
    1018                               PyMac_GetOSType, &theType,
    1019                               PyMac_GetStr255, name))
    1020                 return NULL;
    1021         _rv = Get1NamedResource(theType,
    1022                                 name);
    1023         {
    1024                 OSErr _err = ResError();
    1025                 if (_err != noErr) return PyMac_Error(_err);
    1026         }
    1027         _res = Py_BuildValue("O&",
    1028                              ResObj_New, _rv);
    1029         return _res;
     1015    PyMac_PRECHECK(Get1NamedResource);
     1016#endif
     1017    if (!PyArg_ParseTuple(_args, "O&O&",
     1018                          PyMac_GetOSType, &theType,
     1019                          PyMac_GetStr255, name))
     1020        return NULL;
     1021    _rv = Get1NamedResource(theType,
     1022                            name);
     1023    {
     1024        OSErr _err = ResError();
     1025        if (_err != noErr) return PyMac_Error(_err);
     1026    }
     1027    _res = Py_BuildValue("O&",
     1028                         ResObj_New, _rv);
     1029    return _res;
    10301030}
    10311031
    10321032static PyObject *Res_UniqueID(PyObject *_self, PyObject *_args)
    10331033{
    1034         PyObject *_res = NULL;
    1035         short _rv;
    1036         ResType theType;
     1034    PyObject *_res = NULL;
     1035    short _rv;
     1036    ResType theType;
    10371037#ifndef UniqueID
    1038         PyMac_PRECHECK(UniqueID);
    1039 #endif
    1040         if (!PyArg_ParseTuple(_args, "O&",
    1041                               PyMac_GetOSType, &theType))
    1042                 return NULL;
    1043         _rv = UniqueID(theType);
    1044         {
    1045                 OSErr _err = ResError();
    1046                 if (_err != noErr) return PyMac_Error(_err);
    1047         }
    1048         _res = Py_BuildValue("h",
    1049                              _rv);
    1050         return _res;
     1038    PyMac_PRECHECK(UniqueID);
     1039#endif
     1040    if (!PyArg_ParseTuple(_args, "O&",
     1041                          PyMac_GetOSType, &theType))
     1042        return NULL;
     1043    _rv = UniqueID(theType);
     1044    {
     1045        OSErr _err = ResError();
     1046        if (_err != noErr) return PyMac_Error(_err);
     1047    }
     1048    _res = Py_BuildValue("h",
     1049                         _rv);
     1050    return _res;
    10511051}
    10521052
    10531053static PyObject *Res_Unique1ID(PyObject *_self, PyObject *_args)
    10541054{
    1055         PyObject *_res = NULL;
    1056         short _rv;
    1057         ResType theType;
     1055    PyObject *_res = NULL;
     1056    short _rv;
     1057    ResType theType;
    10581058#ifndef Unique1ID
    1059         PyMac_PRECHECK(Unique1ID);
    1060 #endif
    1061         if (!PyArg_ParseTuple(_args, "O&",
    1062                               PyMac_GetOSType, &theType))
    1063                 return NULL;
    1064         _rv = Unique1ID(theType);
    1065         {
    1066                 OSErr _err = ResError();
    1067                 if (_err != noErr) return PyMac_Error(_err);
    1068         }
    1069         _res = Py_BuildValue("h",
    1070                              _rv);
    1071         return _res;
     1059    PyMac_PRECHECK(Unique1ID);
     1060#endif
     1061    if (!PyArg_ParseTuple(_args, "O&",
     1062                          PyMac_GetOSType, &theType))
     1063        return NULL;
     1064    _rv = Unique1ID(theType);
     1065    {
     1066        OSErr _err = ResError();
     1067        if (_err != noErr) return PyMac_Error(_err);
     1068    }
     1069    _res = Py_BuildValue("h",
     1070                         _rv);
     1071    return _res;
    10721072}
    10731073
    10741074static PyObject *Res_UpdateResFile(PyObject *_self, PyObject *_args)
    10751075{
    1076         PyObject *_res = NULL;
    1077         short refNum;
     1076    PyObject *_res = NULL;
     1077    short refNum;
    10781078#ifndef UpdateResFile
    1079         PyMac_PRECHECK(UpdateResFile);
    1080 #endif
    1081         if (!PyArg_ParseTuple(_args, "h",
    1082                               &refNum))
    1083                 return NULL;
    1084         UpdateResFile(refNum);
    1085         {
    1086                 OSErr _err = ResError();
    1087                 if (_err != noErr) return PyMac_Error(_err);
    1088         }
    1089         Py_INCREF(Py_None);
    1090         _res = Py_None;
    1091         return _res;
     1079    PyMac_PRECHECK(UpdateResFile);
     1080#endif
     1081    if (!PyArg_ParseTuple(_args, "h",
     1082                          &refNum))
     1083        return NULL;
     1084    UpdateResFile(refNum);
     1085    {
     1086        OSErr _err = ResError();
     1087        if (_err != noErr) return PyMac_Error(_err);
     1088    }
     1089    Py_INCREF(Py_None);
     1090    _res = Py_None;
     1091    return _res;
    10921092}
    10931093
    10941094static PyObject *Res_SetResPurge(PyObject *_self, PyObject *_args)
    10951095{
    1096         PyObject *_res = NULL;
    1097         Boolean install;
     1096    PyObject *_res = NULL;
     1097    Boolean install;
    10981098#ifndef SetResPurge
    1099         PyMac_PRECHECK(SetResPurge);
    1100 #endif
    1101         if (!PyArg_ParseTuple(_args, "b",
    1102                               &install))
    1103                 return NULL;
    1104         SetResPurge(install);
    1105         {
    1106                 OSErr _err = ResError();
    1107                 if (_err != noErr) return PyMac_Error(_err);
    1108         }
    1109         Py_INCREF(Py_None);
    1110         _res = Py_None;
    1111         return _res;
     1099    PyMac_PRECHECK(SetResPurge);
     1100#endif
     1101    if (!PyArg_ParseTuple(_args, "b",
     1102                          &install))
     1103        return NULL;
     1104    SetResPurge(install);
     1105    {
     1106        OSErr _err = ResError();
     1107        if (_err != noErr) return PyMac_Error(_err);
     1108    }
     1109    Py_INCREF(Py_None);
     1110    _res = Py_None;
     1111    return _res;
    11121112}
    11131113
    11141114static PyObject *Res_GetResFileAttrs(PyObject *_self, PyObject *_args)
    11151115{
    1116         PyObject *_res = NULL;
    1117         short _rv;
    1118         short refNum;
     1116    PyObject *_res = NULL;
     1117    short _rv;
     1118    short refNum;
    11191119#ifndef GetResFileAttrs
    1120         PyMac_PRECHECK(GetResFileAttrs);
    1121 #endif
    1122         if (!PyArg_ParseTuple(_args, "h",
    1123                               &refNum))
    1124                 return NULL;
    1125         _rv = GetResFileAttrs(refNum);
    1126         {
    1127                 OSErr _err = ResError();
    1128                 if (_err != noErr) return PyMac_Error(_err);
    1129         }
    1130         _res = Py_BuildValue("h",
    1131                              _rv);
    1132         return _res;
     1120    PyMac_PRECHECK(GetResFileAttrs);
     1121#endif
     1122    if (!PyArg_ParseTuple(_args, "h",
     1123                          &refNum))
     1124        return NULL;
     1125    _rv = GetResFileAttrs(refNum);
     1126    {
     1127        OSErr _err = ResError();
     1128        if (_err != noErr) return PyMac_Error(_err);
     1129    }
     1130    _res = Py_BuildValue("h",
     1131                         _rv);
     1132    return _res;
    11331133}
    11341134
    11351135static PyObject *Res_SetResFileAttrs(PyObject *_self, PyObject *_args)
    11361136{
    1137         PyObject *_res = NULL;
    1138         short refNum;
    1139         short attrs;
     1137    PyObject *_res = NULL;
     1138    short refNum;
     1139    short attrs;
    11401140#ifndef SetResFileAttrs
    1141         PyMac_PRECHECK(SetResFileAttrs);
    1142 #endif
    1143         if (!PyArg_ParseTuple(_args, "hh",
    1144                               &refNum,
    1145                               &attrs))
    1146                 return NULL;
    1147         SetResFileAttrs(refNum,
    1148                         attrs);
    1149         {
    1150                 OSErr _err = ResError();
    1151                 if (_err != noErr) return PyMac_Error(_err);
    1152         }
    1153         Py_INCREF(Py_None);
    1154         _res = Py_None;
    1155         return _res;
     1141    PyMac_PRECHECK(SetResFileAttrs);
     1142#endif
     1143    if (!PyArg_ParseTuple(_args, "hh",
     1144                          &refNum,
     1145                          &attrs))
     1146        return NULL;
     1147    SetResFileAttrs(refNum,
     1148                    attrs);
     1149    {
     1150        OSErr _err = ResError();
     1151        if (_err != noErr) return PyMac_Error(_err);
     1152    }
     1153    Py_INCREF(Py_None);
     1154    _res = Py_None;
     1155    return _res;
    11561156}
    11571157
     
    11591159static PyObject *Res_OpenRFPerm(PyObject *_self, PyObject *_args)
    11601160{
    1161         PyObject *_res = NULL;
    1162         short _rv;
    1163         Str255 fileName;
    1164         short vRefNum;
    1165         SignedByte permission;
     1161    PyObject *_res = NULL;
     1162    short _rv;
     1163    Str255 fileName;
     1164    short vRefNum;
     1165    SignedByte permission;
    11661166#ifndef OpenRFPerm
    1167         PyMac_PRECHECK(OpenRFPerm);
    1168 #endif
    1169         if (!PyArg_ParseTuple(_args, "O&hb",
    1170                               PyMac_GetStr255, fileName,
    1171                               &vRefNum,
    1172                               &permission))
    1173                 return NULL;
    1174         _rv = OpenRFPerm(fileName,
    1175                          vRefNum,
    1176                          permission);
    1177         {
    1178                 OSErr _err = ResError();
    1179                 if (_err != noErr) return PyMac_Error(_err);
    1180         }
    1181         _res = Py_BuildValue("h",
    1182                              _rv);
    1183         return _res;
     1167    PyMac_PRECHECK(OpenRFPerm);
     1168#endif
     1169    if (!PyArg_ParseTuple(_args, "O&hb",
     1170                          PyMac_GetStr255, fileName,
     1171                          &vRefNum,
     1172                          &permission))
     1173        return NULL;
     1174    _rv = OpenRFPerm(fileName,
     1175                     vRefNum,
     1176                     permission);
     1177    {
     1178        OSErr _err = ResError();
     1179        if (_err != noErr) return PyMac_Error(_err);
     1180    }
     1181    _res = Py_BuildValue("h",
     1182                         _rv);
     1183    return _res;
    11841184}
    11851185
    11861186static PyObject *Res_HOpenResFile(PyObject *_self, PyObject *_args)
    11871187{
    1188         PyObject *_res = NULL;
    1189         short _rv;
    1190         short vRefNum;
    1191         long dirID;
    1192         Str255 fileName;
    1193         SignedByte permission;
     1188    PyObject *_res = NULL;
     1189    short _rv;
     1190    short vRefNum;
     1191    long dirID;
     1192    Str255 fileName;
     1193    SignedByte permission;
    11941194#ifndef HOpenResFile
    1195         PyMac_PRECHECK(HOpenResFile);
    1196 #endif
    1197         if (!PyArg_ParseTuple(_args, "hlO&b",
    1198                               &vRefNum,
    1199                               &dirID,
    1200                               PyMac_GetStr255, fileName,
    1201                               &permission))
    1202                 return NULL;
    1203         _rv = HOpenResFile(vRefNum,
    1204                            dirID,
    1205                            fileName,
    1206                            permission);
    1207         {
    1208                 OSErr _err = ResError();
    1209                 if (_err != noErr) return PyMac_Error(_err);
    1210         }
    1211         _res = Py_BuildValue("h",
    1212                              _rv);
    1213         return _res;
     1195    PyMac_PRECHECK(HOpenResFile);
     1196#endif
     1197    if (!PyArg_ParseTuple(_args, "hlO&b",
     1198                          &vRefNum,
     1199                          &dirID,
     1200                          PyMac_GetStr255, fileName,
     1201                          &permission))
     1202        return NULL;
     1203    _rv = HOpenResFile(vRefNum,
     1204                       dirID,
     1205                       fileName,
     1206                       permission);
     1207    {
     1208        OSErr _err = ResError();
     1209        if (_err != noErr) return PyMac_Error(_err);
     1210    }
     1211    _res = Py_BuildValue("h",
     1212                         _rv);
     1213    return _res;
    12141214}
    12151215
    12161216static PyObject *Res_HCreateResFile(PyObject *_self, PyObject *_args)
    12171217{
    1218         PyObject *_res = NULL;
    1219         short vRefNum;
    1220         long dirID;
    1221         Str255 fileName;
     1218    PyObject *_res = NULL;
     1219    short vRefNum;
     1220    long dirID;
     1221    Str255 fileName;
    12221222#ifndef HCreateResFile
    1223         PyMac_PRECHECK(HCreateResFile);
    1224 #endif
    1225         if (!PyArg_ParseTuple(_args, "hlO&",
    1226                               &vRefNum,
    1227                               &dirID,
    1228                               PyMac_GetStr255, fileName))
    1229                 return NULL;
    1230         HCreateResFile(vRefNum,
    1231                        dirID,
    1232                        fileName);
    1233         {
    1234                 OSErr _err = ResError();
    1235                 if (_err != noErr) return PyMac_Error(_err);
    1236         }
    1237         Py_INCREF(Py_None);
    1238         _res = Py_None;
    1239         return _res;
     1223    PyMac_PRECHECK(HCreateResFile);
     1224#endif
     1225    if (!PyArg_ParseTuple(_args, "hlO&",
     1226                          &vRefNum,
     1227                          &dirID,
     1228                          PyMac_GetStr255, fileName))
     1229        return NULL;
     1230    HCreateResFile(vRefNum,
     1231                   dirID,
     1232                   fileName);
     1233    {
     1234        OSErr _err = ResError();
     1235        if (_err != noErr) return PyMac_Error(_err);
     1236    }
     1237    Py_INCREF(Py_None);
     1238    _res = Py_None;
     1239    return _res;
    12401240}
    12411241
    12421242static PyObject *Res_FSpOpenResFile(PyObject *_self, PyObject *_args)
    12431243{
    1244         PyObject *_res = NULL;
    1245         short _rv;
    1246         FSSpec spec;
    1247         SignedByte permission;
     1244    PyObject *_res = NULL;
     1245    short _rv;
     1246    FSSpec spec;
     1247    SignedByte permission;
    12481248#ifndef FSpOpenResFile
    1249         PyMac_PRECHECK(FSpOpenResFile);
    1250 #endif
    1251         if (!PyArg_ParseTuple(_args, "O&b",
    1252                               PyMac_GetFSSpec, &spec,
    1253                               &permission))
    1254                 return NULL;
    1255         _rv = FSpOpenResFile(&spec,
    1256                              permission);
    1257         {
    1258                 OSErr _err = ResError();
    1259                 if (_err != noErr) return PyMac_Error(_err);
    1260         }
    1261         _res = Py_BuildValue("h",
    1262                              _rv);
    1263         return _res;
     1249    PyMac_PRECHECK(FSpOpenResFile);
     1250#endif
     1251    if (!PyArg_ParseTuple(_args, "O&b",
     1252                          PyMac_GetFSSpec, &spec,
     1253                          &permission))
     1254        return NULL;
     1255    _rv = FSpOpenResFile(&spec,
     1256                         permission);
     1257    {
     1258        OSErr _err = ResError();
     1259        if (_err != noErr) return PyMac_Error(_err);
     1260    }
     1261    _res = Py_BuildValue("h",
     1262                         _rv);
     1263    return _res;
    12641264}
    12651265
    12661266static PyObject *Res_FSpCreateResFile(PyObject *_self, PyObject *_args)
    12671267{
    1268         PyObject *_res = NULL;
    1269         FSSpec spec;
    1270         OSType creator;
    1271         OSType fileType;
    1272         ScriptCode scriptTag;
     1268    PyObject *_res = NULL;
     1269    FSSpec spec;
     1270    OSType creator;
     1271    OSType fileType;
     1272    ScriptCode scriptTag;
    12731273#ifndef FSpCreateResFile
    1274         PyMac_PRECHECK(FSpCreateResFile);
    1275 #endif
    1276         if (!PyArg_ParseTuple(_args, "O&O&O&h",
    1277                               PyMac_GetFSSpec, &spec,
    1278                               PyMac_GetOSType, &creator,
    1279                               PyMac_GetOSType, &fileType,
    1280                               &scriptTag))
    1281                 return NULL;
    1282         FSpCreateResFile(&spec,
    1283                          creator,
    1284                          fileType,
    1285                          scriptTag);
    1286         {
    1287                 OSErr _err = ResError();
    1288                 if (_err != noErr) return PyMac_Error(_err);
    1289         }
    1290         Py_INCREF(Py_None);
    1291         _res = Py_None;
    1292         return _res;
     1274    PyMac_PRECHECK(FSpCreateResFile);
     1275#endif
     1276    if (!PyArg_ParseTuple(_args, "O&O&O&h",
     1277                          PyMac_GetFSSpec, &spec,
     1278                          PyMac_GetOSType, &creator,
     1279                          PyMac_GetOSType, &fileType,
     1280                          &scriptTag))
     1281        return NULL;
     1282    FSpCreateResFile(&spec,
     1283                     creator,
     1284                     fileType,
     1285                     scriptTag);
     1286    {
     1287        OSErr _err = ResError();
     1288        if (_err != noErr) return PyMac_Error(_err);
     1289    }
     1290    Py_INCREF(Py_None);
     1291    _res = Py_None;
     1292    return _res;
    12931293}
    12941294#endif /* !__LP64__ */
     
    12961296static PyObject *Res_InsertResourceFile(PyObject *_self, PyObject *_args)
    12971297{
    1298         PyObject *_res = NULL;
    1299         OSErr _err;
    1300         SInt16 refNum;
    1301         RsrcChainLocation where;
     1298    PyObject *_res = NULL;
     1299    OSErr _err;
     1300    SInt16 refNum;
     1301    RsrcChainLocation where;
    13021302#ifndef InsertResourceFile
    1303         PyMac_PRECHECK(InsertResourceFile);
    1304 #endif
    1305         if (!PyArg_ParseTuple(_args, "hh",
    1306                               &refNum,
    1307                               &where))
    1308                 return NULL;
    1309         _err = InsertResourceFile(refNum,
    1310                                   where);
    1311         if (_err != noErr) return PyMac_Error(_err);
    1312         Py_INCREF(Py_None);
    1313         _res = Py_None;
    1314         return _res;
     1303    PyMac_PRECHECK(InsertResourceFile);
     1304#endif
     1305    if (!PyArg_ParseTuple(_args, "hh",
     1306                          &refNum,
     1307                          &where))
     1308        return NULL;
     1309    _err = InsertResourceFile(refNum,
     1310                              where);
     1311    if (_err != noErr) return PyMac_Error(_err);
     1312    Py_INCREF(Py_None);
     1313    _res = Py_None;
     1314    return _res;
    13151315}
    13161316
    13171317static PyObject *Res_DetachResourceFile(PyObject *_self, PyObject *_args)
    13181318{
    1319         PyObject *_res = NULL;
    1320         OSErr _err;
    1321         SInt16 refNum;
     1319    PyObject *_res = NULL;
     1320    OSErr _err;
     1321    SInt16 refNum;
    13221322#ifndef DetachResourceFile
    1323         PyMac_PRECHECK(DetachResourceFile);
    1324 #endif
    1325         if (!PyArg_ParseTuple(_args, "h",
    1326                               &refNum))
    1327                 return NULL;
    1328         _err = DetachResourceFile(refNum);
    1329         if (_err != noErr) return PyMac_Error(_err);
    1330         Py_INCREF(Py_None);
    1331         _res = Py_None;
    1332         return _res;
     1323    PyMac_PRECHECK(DetachResourceFile);
     1324#endif
     1325    if (!PyArg_ParseTuple(_args, "h",
     1326                          &refNum))
     1327        return NULL;
     1328    _err = DetachResourceFile(refNum);
     1329    if (_err != noErr) return PyMac_Error(_err);
     1330    Py_INCREF(Py_None);
     1331    _res = Py_None;
     1332    return _res;
    13331333}
    13341334
     
    13361336static PyObject *Res_FSpResourceFileAlreadyOpen(PyObject *_self, PyObject *_args)
    13371337{
    1338         PyObject *_res = NULL;
    1339         Boolean _rv;
    1340         FSSpec resourceFile;
    1341         Boolean inChain;
    1342         SInt16 refNum;
     1338    PyObject *_res = NULL;
     1339    Boolean _rv;
     1340    FSSpec resourceFile;
     1341    Boolean inChain;
     1342    SInt16 refNum;
    13431343#ifndef FSpResourceFileAlreadyOpen
    1344         PyMac_PRECHECK(FSpResourceFileAlreadyOpen);
    1345 #endif
    1346         if (!PyArg_ParseTuple(_args, "O&",
    1347                               PyMac_GetFSSpec, &resourceFile))
    1348                 return NULL;
    1349         _rv = FSpResourceFileAlreadyOpen(&resourceFile,
    1350                                          &inChain,
    1351                                          &refNum);
    1352         {
    1353                 OSErr _err = ResError();
    1354                 if (_err != noErr) return PyMac_Error(_err);
    1355         }
    1356         _res = Py_BuildValue("bbh",
    1357                              _rv,
    1358                              inChain,
    1359                              refNum);
    1360         return _res;
     1344    PyMac_PRECHECK(FSpResourceFileAlreadyOpen);
     1345#endif
     1346    if (!PyArg_ParseTuple(_args, "O&",
     1347                          PyMac_GetFSSpec, &resourceFile))
     1348        return NULL;
     1349    _rv = FSpResourceFileAlreadyOpen(&resourceFile,
     1350                                     &inChain,
     1351                                     &refNum);
     1352    {
     1353        OSErr _err = ResError();
     1354        if (_err != noErr) return PyMac_Error(_err);
     1355    }
     1356    _res = Py_BuildValue("bbh",
     1357                         _rv,
     1358                         inChain,
     1359                         refNum);
     1360    return _res;
    13611361}
    13621362
    13631363static PyObject *Res_FSpOpenOrphanResFile(PyObject *_self, PyObject *_args)
    13641364{
    1365         PyObject *_res = NULL;
    1366         OSErr _err;
    1367         FSSpec spec;
    1368         SignedByte permission;
    1369         SInt16 refNum;
     1365    PyObject *_res = NULL;
     1366    OSErr _err;
     1367    FSSpec spec;
     1368    SignedByte permission;
     1369    SInt16 refNum;
    13701370#ifndef FSpOpenOrphanResFile
    1371         PyMac_PRECHECK(FSpOpenOrphanResFile);
    1372 #endif
    1373         if (!PyArg_ParseTuple(_args, "O&b",
    1374                               PyMac_GetFSSpec, &spec,
    1375                               &permission))
    1376                 return NULL;
    1377         _err = FSpOpenOrphanResFile(&spec,
    1378                                     permission,
    1379                                     &refNum);
    1380         if (_err != noErr) return PyMac_Error(_err);
    1381         _res = Py_BuildValue("h",
    1382                              refNum);
    1383         return _res;
     1371    PyMac_PRECHECK(FSpOpenOrphanResFile);
     1372#endif
     1373    if (!PyArg_ParseTuple(_args, "O&b",
     1374                          PyMac_GetFSSpec, &spec,
     1375                          &permission))
     1376        return NULL;
     1377    _err = FSpOpenOrphanResFile(&spec,
     1378                                permission,
     1379                                &refNum);
     1380    if (_err != noErr) return PyMac_Error(_err);
     1381    _res = Py_BuildValue("h",
     1382                         refNum);
     1383    return _res;
    13841384}
    13851385
    13861386static PyObject *Res_GetTopResourceFile(PyObject *_self, PyObject *_args)
    13871387{
    1388         PyObject *_res = NULL;
    1389         OSErr _err;
    1390         SInt16 refNum;
     1388    PyObject *_res = NULL;
     1389    OSErr _err;
     1390    SInt16 refNum;
    13911391#ifndef GetTopResourceFile
    1392         PyMac_PRECHECK(GetTopResourceFile);
    1393 #endif
    1394         if (!PyArg_ParseTuple(_args, ""))
    1395                 return NULL;
    1396         _err = GetTopResourceFile(&refNum);
    1397         if (_err != noErr) return PyMac_Error(_err);
    1398         _res = Py_BuildValue("h",
    1399                              refNum);
    1400         return _res;
     1392    PyMac_PRECHECK(GetTopResourceFile);
     1393#endif
     1394    if (!PyArg_ParseTuple(_args, ""))
     1395        return NULL;
     1396    _err = GetTopResourceFile(&refNum);
     1397    if (_err != noErr) return PyMac_Error(_err);
     1398    _res = Py_BuildValue("h",
     1399                         refNum);
     1400    return _res;
    14011401}
    14021402
     
    14041404static PyObject *Res_GetNextResourceFile(PyObject *_self, PyObject *_args)
    14051405{
    1406         PyObject *_res = NULL;
    1407         OSErr _err;
    1408         SInt16 curRefNum;
    1409         SInt16 nextRefNum;
     1406    PyObject *_res = NULL;
     1407    OSErr _err;
     1408    SInt16 curRefNum;
     1409    SInt16 nextRefNum;
    14101410#ifndef GetNextResourceFile
    1411         PyMac_PRECHECK(GetNextResourceFile);
    1412 #endif
    1413         if (!PyArg_ParseTuple(_args, "h",
    1414                               &curRefNum))
    1415                 return NULL;
    1416         _err = GetNextResourceFile(curRefNum,
    1417                                    &nextRefNum);
    1418         if (_err != noErr) return PyMac_Error(_err);
    1419         _res = Py_BuildValue("h",
    1420                              nextRefNum);
    1421         return _res;
     1411    PyMac_PRECHECK(GetNextResourceFile);
     1412#endif
     1413    if (!PyArg_ParseTuple(_args, "h",
     1414                          &curRefNum))
     1415        return NULL;
     1416    _err = GetNextResourceFile(curRefNum,
     1417                               &nextRefNum);
     1418    if (_err != noErr) return PyMac_Error(_err);
     1419    _res = Py_BuildValue("h",
     1420                         nextRefNum);
     1421    return _res;
    14221422}
    14231423#endif /* !__LP64__ */
     
    14251425static PyObject *Res_FSOpenResFile(PyObject *_self, PyObject *_args)
    14261426{
    1427         PyObject *_res = NULL;
    1428         short _rv;
    1429         FSRef ref;
    1430         SignedByte permission;
     1427    PyObject *_res = NULL;
     1428    short _rv;
     1429    FSRef ref;
     1430    SignedByte permission;
    14311431#ifndef FSOpenResFile
    1432         PyMac_PRECHECK(FSOpenResFile);
    1433 #endif
    1434         if (!PyArg_ParseTuple(_args, "O&b",
    1435                               PyMac_GetFSRef, &ref,
    1436                               &permission))
    1437                 return NULL;
    1438         _rv = FSOpenResFile(&ref,
    1439                             permission);
    1440         {
    1441                 OSErr _err = ResError();
    1442                 if (_err != noErr) return PyMac_Error(_err);
    1443         }
    1444         _res = Py_BuildValue("h",
    1445                              _rv);
    1446         return _res;
     1432    PyMac_PRECHECK(FSOpenResFile);
     1433#endif
     1434    if (!PyArg_ParseTuple(_args, "O&b",
     1435                          PyMac_GetFSRef, &ref,
     1436                          &permission))
     1437        return NULL;
     1438    _rv = FSOpenResFile(&ref,
     1439                        permission);
     1440    {
     1441        OSErr _err = ResError();
     1442        if (_err != noErr) return PyMac_Error(_err);
     1443    }
     1444    _res = Py_BuildValue("h",
     1445                         _rv);
     1446    return _res;
    14471447}
    14481448
     
    14511451static PyObject *Res_FSCreateResFile(PyObject *_self, PyObject *_args)
    14521452{
    1453         PyObject *_res = NULL;
    1454         FSRef parentRef;
    1455         UniChar *nameLength__in__;
    1456         UniCharCount nameLength__len__;
    1457         int nameLength__in_len__;
    1458         FSRef newRef;
    1459         FSSpec newSpec;
     1453    PyObject *_res = NULL;
     1454    FSRef parentRef;
     1455    UniChar *nameLength__in__;
     1456    UniCharCount nameLength__len__;
     1457    int nameLength__in_len__;
     1458    FSRef newRef;
     1459    FSSpec newSpec;
    14601460#ifndef FSCreateResFile
    1461         PyMac_PRECHECK(FSCreateResFile);
    1462 #endif
    1463         if (!PyArg_ParseTuple(_args, "O&u#",
    1464                               PyMac_GetFSRef, &parentRef,
    1465                               &nameLength__in__, &nameLength__in_len__))
    1466                 return NULL;
    1467         nameLength__len__ = nameLength__in_len__;
    1468         FSCreateResFile(&parentRef,
    1469                         nameLength__len__, nameLength__in__,
    1470                         0,
    1471                         (FSCatalogInfo *)0,
    1472                         &newRef,
    1473                         &newSpec);
    1474         {
    1475                 OSErr _err = ResError();
    1476                 if (_err != noErr) return PyMac_Error(_err);
    1477         }
    1478         _res = Py_BuildValue("O&O&",
    1479                              PyMac_BuildFSRef, &newRef,
    1480                              PyMac_BuildFSSpec, &newSpec);
    1481         return _res;
     1461    PyMac_PRECHECK(FSCreateResFile);
     1462#endif
     1463    if (!PyArg_ParseTuple(_args, "O&u#",
     1464                          PyMac_GetFSRef, &parentRef,
     1465                          &nameLength__in__, &nameLength__in_len__))
     1466        return NULL;
     1467    nameLength__len__ = nameLength__in_len__;
     1468    FSCreateResFile(&parentRef,
     1469                    nameLength__len__, nameLength__in__,
     1470                    0,
     1471                    (FSCatalogInfo *)0,
     1472                    &newRef,
     1473                    &newSpec);
     1474    {
     1475        OSErr _err = ResError();
     1476        if (_err != noErr) return PyMac_Error(_err);
     1477    }
     1478    _res = Py_BuildValue("O&O&",
     1479                         PyMac_BuildFSRef, &newRef,
     1480                         PyMac_BuildFSSpec, &newSpec);
     1481    return _res;
    14821482}
    14831483
    14841484static PyObject *Res_FSResourceFileAlreadyOpen(PyObject *_self, PyObject *_args)
    14851485{
    1486         PyObject *_res = NULL;
    1487         Boolean _rv;
    1488         FSRef resourceFileRef;
    1489         Boolean inChain;
    1490         SInt16 refNum;
     1486    PyObject *_res = NULL;
     1487    Boolean _rv;
     1488    FSRef resourceFileRef;
     1489    Boolean inChain;
     1490    SInt16 refNum;
    14911491#ifndef FSResourceFileAlreadyOpen
    1492         PyMac_PRECHECK(FSResourceFileAlreadyOpen);
    1493 #endif
    1494         if (!PyArg_ParseTuple(_args, "O&",
    1495                               PyMac_GetFSRef, &resourceFileRef))
    1496                 return NULL;
    1497         _rv = FSResourceFileAlreadyOpen(&resourceFileRef,
    1498                                         &inChain,
    1499                                         &refNum);
    1500         {
    1501                 OSErr _err = ResError();
    1502                 if (_err != noErr) return PyMac_Error(_err);
    1503         }
    1504         _res = Py_BuildValue("bbh",
    1505                              _rv,
    1506                              inChain,
    1507                              refNum);
    1508         return _res;
     1492    PyMac_PRECHECK(FSResourceFileAlreadyOpen);
     1493#endif
     1494    if (!PyArg_ParseTuple(_args, "O&",
     1495                          PyMac_GetFSRef, &resourceFileRef))
     1496        return NULL;
     1497    _rv = FSResourceFileAlreadyOpen(&resourceFileRef,
     1498                                    &inChain,
     1499                                    &refNum);
     1500    {
     1501        OSErr _err = ResError();
     1502        if (_err != noErr) return PyMac_Error(_err);
     1503    }
     1504    _res = Py_BuildValue("bbh",
     1505                         _rv,
     1506                         inChain,
     1507                         refNum);
     1508    return _res;
    15091509}
    15101510
    15111511static PyObject *Res_FSCreateResourceFile(PyObject *_self, PyObject *_args)
    15121512{
    1513         PyObject *_res = NULL;
    1514         OSErr _err;
    1515         FSRef parentRef;
    1516         UniChar *nameLength__in__;
    1517         UniCharCount nameLength__len__;
    1518         int nameLength__in_len__;
    1519         UniChar *forkNameLength__in__;
    1520         UniCharCount forkNameLength__len__;
    1521         int forkNameLength__in_len__;
    1522         FSRef newRef;
    1523         FSSpec newSpec;
     1513    PyObject *_res = NULL;
     1514    OSErr _err;
     1515    FSRef parentRef;
     1516    UniChar *nameLength__in__;
     1517    UniCharCount nameLength__len__;
     1518    int nameLength__in_len__;
     1519    UniChar *forkNameLength__in__;
     1520    UniCharCount forkNameLength__len__;
     1521    int forkNameLength__in_len__;
     1522    FSRef newRef;
     1523    FSSpec newSpec;
    15241524#ifndef FSCreateResourceFile
    1525         PyMac_PRECHECK(FSCreateResourceFile);
    1526 #endif
    1527         if (!PyArg_ParseTuple(_args, "O&u#u#",
    1528                               PyMac_GetFSRef, &parentRef,
    1529                               &nameLength__in__, &nameLength__in_len__,
    1530                               &forkNameLength__in__, &forkNameLength__in_len__))
    1531                 return NULL;
    1532         nameLength__len__ = nameLength__in_len__;
    1533         forkNameLength__len__ = forkNameLength__in_len__;
    1534         _err = FSCreateResourceFile(&parentRef,
    1535                                     nameLength__len__, nameLength__in__,
    1536                                     0,
    1537                                     (FSCatalogInfo *)0,
    1538                                     forkNameLength__len__, forkNameLength__in__,
    1539                                     &newRef,
    1540                                     &newSpec);
    1541         if (_err != noErr) return PyMac_Error(_err);
    1542         _res = Py_BuildValue("O&O&",
    1543                              PyMac_BuildFSRef, &newRef,
    1544                              PyMac_BuildFSSpec, &newSpec);
    1545         return _res;
     1525    PyMac_PRECHECK(FSCreateResourceFile);
     1526#endif
     1527    if (!PyArg_ParseTuple(_args, "O&u#u#",
     1528                          PyMac_GetFSRef, &parentRef,
     1529                          &nameLength__in__, &nameLength__in_len__,
     1530                          &forkNameLength__in__, &forkNameLength__in_len__))
     1531        return NULL;
     1532    nameLength__len__ = nameLength__in_len__;
     1533    forkNameLength__len__ = forkNameLength__in_len__;
     1534    _err = FSCreateResourceFile(&parentRef,
     1535                                nameLength__len__, nameLength__in__,
     1536                                0,
     1537                                (FSCatalogInfo *)0,
     1538                                forkNameLength__len__, forkNameLength__in__,
     1539                                &newRef,
     1540                                &newSpec);
     1541    if (_err != noErr) return PyMac_Error(_err);
     1542    _res = Py_BuildValue("O&O&",
     1543                         PyMac_BuildFSRef, &newRef,
     1544                         PyMac_BuildFSSpec, &newSpec);
     1545    return _res;
    15461546}
    15471547#endif /* __LP64__ */
     
    15491549static PyObject *Res_FSOpenResourceFile(PyObject *_self, PyObject *_args)
    15501550{
    1551         PyObject *_res = NULL;
    1552         OSErr _err;
    1553         FSRef ref;
    1554         UniChar *forkNameLength__in__;
    1555         UniCharCount forkNameLength__len__;
    1556         int forkNameLength__in_len__;
    1557         SignedByte permissions;
    1558         ResFileRefNum refNum;
     1551    PyObject *_res = NULL;
     1552    OSErr _err;
     1553    FSRef ref;
     1554    UniChar *forkNameLength__in__;
     1555    UniCharCount forkNameLength__len__;
     1556    int forkNameLength__in_len__;
     1557    SignedByte permissions;
     1558    ResFileRefNum refNum;
    15591559#ifndef FSOpenResourceFile
    1560         PyMac_PRECHECK(FSOpenResourceFile);
    1561 #endif
    1562         if (!PyArg_ParseTuple(_args, "O&u#b",
    1563                               PyMac_GetFSRef, &ref,
    1564                               &forkNameLength__in__, &forkNameLength__in_len__,
    1565                               &permissions))
    1566                 return NULL;
    1567         forkNameLength__len__ = forkNameLength__in_len__;
    1568         _err = FSOpenResourceFile(&ref,
    1569                                   forkNameLength__len__, forkNameLength__in__,
    1570                                   permissions,
    1571                                   &refNum);
    1572         if (_err != noErr) return PyMac_Error(_err);
    1573         _res = Py_BuildValue("h",
    1574                              refNum);
    1575         return _res;
     1560    PyMac_PRECHECK(FSOpenResourceFile);
     1561#endif
     1562    if (!PyArg_ParseTuple(_args, "O&u#b",
     1563                          PyMac_GetFSRef, &ref,
     1564                          &forkNameLength__in__, &forkNameLength__in_len__,
     1565                          &permissions))
     1566        return NULL;
     1567    forkNameLength__len__ = forkNameLength__in_len__;
     1568    _err = FSOpenResourceFile(&ref,
     1569                              forkNameLength__len__, forkNameLength__in__,
     1570                              permissions,
     1571                              &refNum);
     1572    if (_err != noErr) return PyMac_Error(_err);
     1573    _res = Py_BuildValue("h",
     1574                         refNum);
     1575    return _res;
    15761576}
    15771577
    15781578static PyObject *Res_Handle(PyObject *_self, PyObject *_args)
    15791579{
    1580         PyObject *_res = NULL;
    1581 
    1582         char *buf;
    1583         int len;
    1584         Handle h;
    1585         ResourceObject *rv;
    1586 
    1587         if (!PyArg_ParseTuple(_args, "s#", &buf, &len))
    1588                 return NULL;
    1589         h = NewHandle(len);
    1590         if ( h == NULL ) {
    1591                 PyErr_NoMemory();
    1592                 return NULL;
    1593         }
    1594         HLock(h);
    1595         memcpy(*h, buf, len);
    1596         HUnlock(h);
    1597         rv = (ResourceObject *)ResObj_New(h);
    1598         rv->ob_freeit = PyMac_AutoDisposeHandle;
    1599         _res = (PyObject *)rv;
    1600         return _res;
     1580    PyObject *_res = NULL;
     1581
     1582    char *buf;
     1583    int len;
     1584    Handle h;
     1585    ResourceObject *rv;
     1586
     1587    if (!PyArg_ParseTuple(_args, "s#", &buf, &len))
     1588        return NULL;
     1589    h = NewHandle(len);
     1590    if ( h == NULL ) {
     1591        PyErr_NoMemory();
     1592        return NULL;
     1593    }
     1594    HLock(h);
     1595    memcpy(*h, buf, len);
     1596    HUnlock(h);
     1597    rv = (ResourceObject *)ResObj_New(h);
     1598    rv->ob_freeit = PyMac_AutoDisposeHandle;
     1599    _res = (PyObject *)rv;
     1600    return _res;
    16011601
    16021602}
    16031603
    16041604static PyMethodDef Res_methods[] = {
    1605         {"CloseResFile", (PyCFunction)Res_CloseResFile, 1,
    1606         PyDoc_STR("(short refNum) -> None")},
    1607         {"ResError", (PyCFunction)Res_ResError, 1,
    1608         PyDoc_STR("() -> None")},
    1609         {"CurResFile", (PyCFunction)Res_CurResFile, 1,
    1610         PyDoc_STR("() -> (short _rv)")},
    1611         {"UseResFile", (PyCFunction)Res_UseResFile, 1,
    1612         PyDoc_STR("(short refNum) -> None")},
    1613         {"CountTypes", (PyCFunction)Res_CountTypes, 1,
    1614         PyDoc_STR("() -> (short _rv)")},
    1615         {"Count1Types", (PyCFunction)Res_Count1Types, 1,
    1616         PyDoc_STR("() -> (short _rv)")},
    1617         {"GetIndType", (PyCFunction)Res_GetIndType, 1,
    1618         PyDoc_STR("(short index) -> (ResType theType)")},
    1619         {"Get1IndType", (PyCFunction)Res_Get1IndType, 1,
    1620         PyDoc_STR("(short index) -> (ResType theType)")},
    1621         {"SetResLoad", (PyCFunction)Res_SetResLoad, 1,
    1622         PyDoc_STR("(Boolean load) -> None")},
    1623         {"CountResources", (PyCFunction)Res_CountResources, 1,
    1624         PyDoc_STR("(ResType theType) -> (short _rv)")},
    1625         {"Count1Resources", (PyCFunction)Res_Count1Resources, 1,
    1626         PyDoc_STR("(ResType theType) -> (short _rv)")},
    1627         {"GetIndResource", (PyCFunction)Res_GetIndResource, 1,
    1628         PyDoc_STR("(ResType theType, short index) -> (Handle _rv)")},
    1629         {"Get1IndResource", (PyCFunction)Res_Get1IndResource, 1,
    1630         PyDoc_STR("(ResType theType, short index) -> (Handle _rv)")},
    1631         {"GetResource", (PyCFunction)Res_GetResource, 1,
    1632         PyDoc_STR("(ResType theType, short theID) -> (Handle _rv)")},
    1633         {"Get1Resource", (PyCFunction)Res_Get1Resource, 1,
    1634         PyDoc_STR("(ResType theType, short theID) -> (Handle _rv)")},
    1635         {"GetNamedResource", (PyCFunction)Res_GetNamedResource, 1,
    1636         PyDoc_STR("(ResType theType, Str255 name) -> (Handle _rv)")},
    1637         {"Get1NamedResource", (PyCFunction)Res_Get1NamedResource, 1,
    1638         PyDoc_STR("(ResType theType, Str255 name) -> (Handle _rv)")},
    1639         {"UniqueID", (PyCFunction)Res_UniqueID, 1,
    1640         PyDoc_STR("(ResType theType) -> (short _rv)")},
    1641         {"Unique1ID", (PyCFunction)Res_Unique1ID, 1,
    1642         PyDoc_STR("(ResType theType) -> (short _rv)")},
    1643         {"UpdateResFile", (PyCFunction)Res_UpdateResFile, 1,
    1644         PyDoc_STR("(short refNum) -> None")},
    1645         {"SetResPurge", (PyCFunction)Res_SetResPurge, 1,
    1646         PyDoc_STR("(Boolean install) -> None")},
    1647         {"GetResFileAttrs", (PyCFunction)Res_GetResFileAttrs, 1,
    1648         PyDoc_STR("(short refNum) -> (short _rv)")},
    1649         {"SetResFileAttrs", (PyCFunction)Res_SetResFileAttrs, 1,
    1650         PyDoc_STR("(short refNum, short attrs) -> None")},
     1605    {"CloseResFile", (PyCFunction)Res_CloseResFile, 1,
     1606    PyDoc_STR("(short refNum) -> None")},
     1607    {"ResError", (PyCFunction)Res_ResError, 1,
     1608    PyDoc_STR("() -> None")},
     1609    {"CurResFile", (PyCFunction)Res_CurResFile, 1,
     1610    PyDoc_STR("() -> (short _rv)")},
     1611    {"UseResFile", (PyCFunction)Res_UseResFile, 1,
     1612    PyDoc_STR("(short refNum) -> None")},
     1613    {"CountTypes", (PyCFunction)Res_CountTypes, 1,
     1614    PyDoc_STR("() -> (short _rv)")},
     1615    {"Count1Types", (PyCFunction)Res_Count1Types, 1,
     1616    PyDoc_STR("() -> (short _rv)")},
     1617    {"GetIndType", (PyCFunction)Res_GetIndType, 1,
     1618    PyDoc_STR("(short index) -> (ResType theType)")},
     1619    {"Get1IndType", (PyCFunction)Res_Get1IndType, 1,
     1620    PyDoc_STR("(short index) -> (ResType theType)")},
     1621    {"SetResLoad", (PyCFunction)Res_SetResLoad, 1,
     1622    PyDoc_STR("(Boolean load) -> None")},
     1623    {"CountResources", (PyCFunction)Res_CountResources, 1,
     1624    PyDoc_STR("(ResType theType) -> (short _rv)")},
     1625    {"Count1Resources", (PyCFunction)Res_Count1Resources, 1,
     1626    PyDoc_STR("(ResType theType) -> (short _rv)")},
     1627    {"GetIndResource", (PyCFunction)Res_GetIndResource, 1,
     1628    PyDoc_STR("(ResType theType, short index) -> (Handle _rv)")},
     1629    {"Get1IndResource", (PyCFunction)Res_Get1IndResource, 1,
     1630    PyDoc_STR("(ResType theType, short index) -> (Handle _rv)")},
     1631    {"GetResource", (PyCFunction)Res_GetResource, 1,
     1632    PyDoc_STR("(ResType theType, short theID) -> (Handle _rv)")},
     1633    {"Get1Resource", (PyCFunction)Res_Get1Resource, 1,
     1634    PyDoc_STR("(ResType theType, short theID) -> (Handle _rv)")},
     1635    {"GetNamedResource", (PyCFunction)Res_GetNamedResource, 1,
     1636    PyDoc_STR("(ResType theType, Str255 name) -> (Handle _rv)")},
     1637    {"Get1NamedResource", (PyCFunction)Res_Get1NamedResource, 1,
     1638    PyDoc_STR("(ResType theType, Str255 name) -> (Handle _rv)")},
     1639    {"UniqueID", (PyCFunction)Res_UniqueID, 1,
     1640    PyDoc_STR("(ResType theType) -> (short _rv)")},
     1641    {"Unique1ID", (PyCFunction)Res_Unique1ID, 1,
     1642    PyDoc_STR("(ResType theType) -> (short _rv)")},
     1643    {"UpdateResFile", (PyCFunction)Res_UpdateResFile, 1,
     1644    PyDoc_STR("(short refNum) -> None")},
     1645    {"SetResPurge", (PyCFunction)Res_SetResPurge, 1,
     1646    PyDoc_STR("(Boolean install) -> None")},
     1647    {"GetResFileAttrs", (PyCFunction)Res_GetResFileAttrs, 1,
     1648    PyDoc_STR("(short refNum) -> (short _rv)")},
     1649    {"SetResFileAttrs", (PyCFunction)Res_SetResFileAttrs, 1,
     1650    PyDoc_STR("(short refNum, short attrs) -> None")},
    16511651#ifndef __LP64__
    1652         {"OpenRFPerm", (PyCFunction)Res_OpenRFPerm, 1,
    1653         PyDoc_STR("(Str255 fileName, short vRefNum, SignedByte permission) -> (short _rv)")},
    1654         {"HOpenResFile", (PyCFunction)Res_HOpenResFile, 1,
    1655         PyDoc_STR("(short vRefNum, long dirID, Str255 fileName, SignedByte permission) -> (short _rv)")},
    1656         {"HCreateResFile", (PyCFunction)Res_HCreateResFile, 1,
    1657         PyDoc_STR("(short vRefNum, long dirID, Str255 fileName) -> None")},
    1658         {"FSpOpenResFile", (PyCFunction)Res_FSpOpenResFile, 1,
    1659         PyDoc_STR("(FSSpec spec, SignedByte permission) -> (short _rv)")},
    1660         {"FSpCreateResFile", (PyCFunction)Res_FSpCreateResFile, 1,
    1661         PyDoc_STR("(FSSpec spec, OSType creator, OSType fileType, ScriptCode scriptTag) -> None")},
     1652    {"OpenRFPerm", (PyCFunction)Res_OpenRFPerm, 1,
     1653    PyDoc_STR("(Str255 fileName, short vRefNum, SignedByte permission) -> (short _rv)")},
     1654    {"HOpenResFile", (PyCFunction)Res_HOpenResFile, 1,
     1655    PyDoc_STR("(short vRefNum, long dirID, Str255 fileName, SignedByte permission) -> (short _rv)")},
     1656    {"HCreateResFile", (PyCFunction)Res_HCreateResFile, 1,
     1657    PyDoc_STR("(short vRefNum, long dirID, Str255 fileName) -> None")},
     1658    {"FSpOpenResFile", (PyCFunction)Res_FSpOpenResFile, 1,
     1659    PyDoc_STR("(FSSpec spec, SignedByte permission) -> (short _rv)")},
     1660    {"FSpCreateResFile", (PyCFunction)Res_FSpCreateResFile, 1,
     1661    PyDoc_STR("(FSSpec spec, OSType creator, OSType fileType, ScriptCode scriptTag) -> None")},
    16621662#endif /* !__LP64__ */
    1663         {"InsertResourceFile", (PyCFunction)Res_InsertResourceFile, 1,
    1664         PyDoc_STR("(SInt16 refNum, RsrcChainLocation where) -> None")},
    1665         {"DetachResourceFile", (PyCFunction)Res_DetachResourceFile, 1,
    1666         PyDoc_STR("(SInt16 refNum) -> None")},
     1663    {"InsertResourceFile", (PyCFunction)Res_InsertResourceFile, 1,
     1664    PyDoc_STR("(SInt16 refNum, RsrcChainLocation where) -> None")},
     1665    {"DetachResourceFile", (PyCFunction)Res_DetachResourceFile, 1,
     1666    PyDoc_STR("(SInt16 refNum) -> None")},
    16671667#ifndef __LP64__
    1668         {"FSpResourceFileAlreadyOpen", (PyCFunction)Res_FSpResourceFileAlreadyOpen, 1,
    1669         PyDoc_STR("(FSSpec resourceFile) -> (Boolean _rv, Boolean inChain, SInt16 refNum)")},
    1670         {"FSpOpenOrphanResFile", (PyCFunction)Res_FSpOpenOrphanResFile, 1,
    1671         PyDoc_STR("(FSSpec spec, SignedByte permission) -> (SInt16 refNum)")},
    1672         {"GetTopResourceFile", (PyCFunction)Res_GetTopResourceFile, 1,
    1673         PyDoc_STR("() -> (SInt16 refNum)")},
    1674         {"GetNextResourceFile", (PyCFunction)Res_GetNextResourceFile, 1,
    1675         PyDoc_STR("(SInt16 curRefNum) -> (SInt16 nextRefNum)")},
     1668    {"FSpResourceFileAlreadyOpen", (PyCFunction)Res_FSpResourceFileAlreadyOpen, 1,
     1669    PyDoc_STR("(FSSpec resourceFile) -> (Boolean _rv, Boolean inChain, SInt16 refNum)")},
     1670    {"FSpOpenOrphanResFile", (PyCFunction)Res_FSpOpenOrphanResFile, 1,
     1671    PyDoc_STR("(FSSpec spec, SignedByte permission) -> (SInt16 refNum)")},
     1672    {"GetTopResourceFile", (PyCFunction)Res_GetTopResourceFile, 1,
     1673    PyDoc_STR("() -> (SInt16 refNum)")},
     1674    {"GetNextResourceFile", (PyCFunction)Res_GetNextResourceFile, 1,
     1675    PyDoc_STR("(SInt16 curRefNum) -> (SInt16 nextRefNum)")},
    16761676#endif /* __LP64__ */
    1677         {"FSOpenResFile", (PyCFunction)Res_FSOpenResFile, 1,
    1678         PyDoc_STR("(FSRef ref, SignedByte permission) -> (short _rv)")},
     1677    {"FSOpenResFile", (PyCFunction)Res_FSOpenResFile, 1,
     1678    PyDoc_STR("(FSRef ref, SignedByte permission) -> (short _rv)")},
    16791679#ifndef __LP64__
    1680         {"FSCreateResFile", (PyCFunction)Res_FSCreateResFile, 1,
    1681         PyDoc_STR("(FSRef parentRef, Buffer nameLength) -> (FSRef newRef, FSSpec newSpec)")},
    1682         {"FSResourceFileAlreadyOpen", (PyCFunction)Res_FSResourceFileAlreadyOpen, 1,
    1683         PyDoc_STR("(FSRef resourceFileRef) -> (Boolean _rv, Boolean inChain, SInt16 refNum)")},
    1684         {"FSCreateResourceFile", (PyCFunction)Res_FSCreateResourceFile, 1,
    1685         PyDoc_STR("(FSRef parentRef, Buffer nameLength, Buffer forkNameLength) -> (FSRef newRef, FSSpec newSpec)")},
     1680    {"FSCreateResFile", (PyCFunction)Res_FSCreateResFile, 1,
     1681    PyDoc_STR("(FSRef parentRef, Buffer nameLength) -> (FSRef newRef, FSSpec newSpec)")},
     1682    {"FSResourceFileAlreadyOpen", (PyCFunction)Res_FSResourceFileAlreadyOpen, 1,
     1683    PyDoc_STR("(FSRef resourceFileRef) -> (Boolean _rv, Boolean inChain, SInt16 refNum)")},
     1684    {"FSCreateResourceFile", (PyCFunction)Res_FSCreateResourceFile, 1,
     1685    PyDoc_STR("(FSRef parentRef, Buffer nameLength, Buffer forkNameLength) -> (FSRef newRef, FSSpec newSpec)")},
    16861686#endif /* __LP64__ */
    1687         {"FSOpenResourceFile", (PyCFunction)Res_FSOpenResourceFile, 1,
    1688         PyDoc_STR("(FSRef ref, Buffer forkNameLength, SignedByte permissions) -> (SInt16 refNum)")},
    1689         {"Handle", (PyCFunction)Res_Handle, 1,
    1690         PyDoc_STR("Convert a string to a Handle object.\n\nResource() and Handle() are very similar, but objects created with Handle() are\nby default automatically DisposeHandle()d upon object cleanup. Use AutoDispose()\nto change this.\n")},
    1691         {NULL, NULL, 0}
     1687    {"FSOpenResourceFile", (PyCFunction)Res_FSOpenResourceFile, 1,
     1688    PyDoc_STR("(FSRef ref, Buffer forkNameLength, SignedByte permissions) -> (SInt16 refNum)")},
     1689    {"Handle", (PyCFunction)Res_Handle, 1,
     1690    PyDoc_STR("Convert a string to a Handle object.\n\nResource() and Handle() are very similar, but objects created with Handle() are\nby default automatically DisposeHandle()d upon object cleanup. Use AutoDispose()\nto change this.\n")},
     1691    {NULL, NULL, 0}
    16921692};
    16931693
     
    16971697PyObject *OptResObj_New(Handle itself)
    16981698{
    1699         if (itself == NULL) {
    1700                 Py_INCREF(Py_None);
    1701                 return Py_None;
    1702         }
    1703         return ResObj_New(itself);
     1699    if (itself == NULL) {
     1700        Py_INCREF(Py_None);
     1701        return Py_None;
     1702    }
     1703    return ResObj_New(itself);
    17041704}
    17051705
    17061706int OptResObj_Convert(PyObject *v, Handle *p_itself)
    17071707{
    1708         PyObject *tmp;
    1709 
    1710         if ( v == Py_None ) {
    1711                 *p_itself = NULL;
    1712                 return 1;
    1713         }
    1714         if (ResObj_Check(v))
    1715         {
    1716                 *p_itself = ((ResourceObject *)v)->ob_itself;
    1717                 return 1;
    1718         }
    1719         /* If it isn't a resource yet see whether it is convertible */
    1720         if ( (tmp=PyObject_CallMethod(v, "as_Resource", "")) ) {
    1721                 *p_itself = ((ResourceObject *)tmp)->ob_itself;
    1722                 Py_DECREF(tmp);
    1723                 return 1;
    1724         }
    1725         PyErr_Clear();
    1726         PyErr_SetString(PyExc_TypeError, "Resource required");
    1727         return 0;
     1708    PyObject *tmp;
     1709
     1710    if ( v == Py_None ) {
     1711        *p_itself = NULL;
     1712        return 1;
     1713    }
     1714    if (ResObj_Check(v))
     1715    {
     1716        *p_itself = ((ResourceObject *)v)->ob_itself;
     1717        return 1;
     1718    }
     1719    /* If it isn't a resource yet see whether it is convertible */
     1720    if ( (tmp=PyObject_CallMethod(v, "as_Resource", "")) ) {
     1721        *p_itself = ((ResourceObject *)tmp)->ob_itself;
     1722        Py_DECREF(tmp);
     1723        return 1;
     1724    }
     1725    PyErr_Clear();
     1726    PyErr_SetString(PyExc_TypeError, "Resource required");
     1727    return 0;
    17281728}
    17291729
     
    17311731void init_Res(void)
    17321732{
    1733         PyObject *m;
    1734         PyObject *d;
    1735 
    1736 
    1737 
    1738                 PyMac_INIT_TOOLBOX_OBJECT_NEW(Handle, ResObj_New);
    1739                 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Handle, ResObj_Convert);
    1740                 PyMac_INIT_TOOLBOX_OBJECT_NEW(Handle, OptResObj_New);
    1741                 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Handle, OptResObj_Convert);
    1742 
    1743 
    1744         m = Py_InitModule("_Res", Res_methods);
    1745         d = PyModule_GetDict(m);
    1746         Res_Error = PyMac_GetOSErrException();
    1747         if (Res_Error == NULL ||
    1748             PyDict_SetItemString(d, "Error", Res_Error) != 0)
    1749                 return;
    1750         Resource_Type.ob_type = &PyType_Type;
    1751         if (PyType_Ready(&Resource_Type) < 0) return;
    1752         Py_INCREF(&Resource_Type);
    1753         PyModule_AddObject(m, "Resource", (PyObject *)&Resource_Type);
    1754         /* Backward-compatible name */
    1755         Py_INCREF(&Resource_Type);
    1756         PyModule_AddObject(m, "ResourceType", (PyObject *)&Resource_Type);
     1733    PyObject *m;
     1734    PyObject *d;
     1735
     1736
     1737
     1738        PyMac_INIT_TOOLBOX_OBJECT_NEW(Handle, ResObj_New);
     1739        PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Handle, ResObj_Convert);
     1740        PyMac_INIT_TOOLBOX_OBJECT_NEW(Handle, OptResObj_New);
     1741        PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Handle, OptResObj_Convert);
     1742
     1743
     1744    m = Py_InitModule("_Res", Res_methods);
     1745    d = PyModule_GetDict(m);
     1746    Res_Error = PyMac_GetOSErrException();
     1747    if (Res_Error == NULL ||
     1748        PyDict_SetItemString(d, "Error", Res_Error) != 0)
     1749        return;
     1750    Resource_Type.ob_type = &PyType_Type;
     1751    if (PyType_Ready(&Resource_Type) < 0) return;
     1752    Py_INCREF(&Resource_Type);
     1753    PyModule_AddObject(m, "Resource", (PyObject *)&Resource_Type);
     1754    /* Backward-compatible name */
     1755    Py_INCREF(&Resource_Type);
     1756    PyModule_AddObject(m, "ResourceType", (PyObject *)&Resource_Type);
    17571757}
    17581758
Note: See TracChangeset for help on using the changeset viewer.