Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame^] | 1 | |
| 2 | /* =========================== Module Res =========================== */ |
| 3 | |
| 4 | #include "Python.h" |
| 5 | |
| 6 | |
| 7 | |
| 8 | #define SystemSevenOrLater 1 |
| 9 | |
| 10 | #include "macglue.h" |
| 11 | #include <Memory.h> |
| 12 | #include <Dialogs.h> |
| 13 | #include <Menus.h> |
| 14 | #include <Controls.h> |
| 15 | |
| 16 | extern PyObject *ResObj_New(Handle); |
| 17 | extern int ResObj_Convert(PyObject *, Handle *); |
| 18 | |
| 19 | extern PyObject *WinObj_New(WindowPtr); |
| 20 | extern int WinObj_Convert(PyObject *, WindowPtr *); |
| 21 | |
| 22 | extern PyObject *DlgObj_New(DialogPtr); |
| 23 | extern int DlgObj_Convert(PyObject *, DialogPtr *); |
| 24 | extern PyTypeObject Dialog_Type; |
| 25 | #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) |
| 26 | |
| 27 | extern PyObject *MenuObj_New(MenuHandle); |
| 28 | extern int MenuObj_Convert(PyObject *, MenuHandle *); |
| 29 | |
| 30 | extern PyObject *CtlObj_New(ControlHandle); |
| 31 | extern int CtlObj_Convert(PyObject *, ControlHandle *); |
| 32 | |
| 33 | #include <Resources.h> |
| 34 | |
| 35 | #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */ |
| 36 | |
| 37 | static PyObject *Res_Error; |
| 38 | |
| 39 | /* ---------------------- Object type Resource ---------------------- */ |
| 40 | |
| 41 | PyTypeObject Resource_Type; |
| 42 | |
| 43 | #define ResObj_Check(x) ((x)->ob_type == &Resource_Type) |
| 44 | |
| 45 | typedef struct ResourceObject { |
| 46 | PyObject_HEAD |
| 47 | Handle ob_itself; |
| 48 | } ResourceObject; |
| 49 | |
| 50 | PyObject *ResObj_New(itself) |
| 51 | const Handle itself; |
| 52 | { |
| 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 | return (PyObject *)it; |
| 59 | } |
| 60 | ResObj_Convert(v, p_itself) |
| 61 | PyObject *v; |
| 62 | Handle *p_itself; |
| 63 | { |
| 64 | if (!ResObj_Check(v)) |
| 65 | { |
| 66 | PyErr_SetString(PyExc_TypeError, "Resource required"); |
| 67 | return 0; |
| 68 | } |
| 69 | *p_itself = ((ResourceObject *)v)->ob_itself; |
| 70 | return 1; |
| 71 | } |
| 72 | |
| 73 | static void ResObj_dealloc(self) |
| 74 | ResourceObject *self; |
| 75 | { |
| 76 | /* Cleanup of self->ob_itself goes here */ |
| 77 | PyMem_DEL(self); |
| 78 | } |
| 79 | |
| 80 | static PyObject *ResObj_HomeResFile(_self, _args) |
| 81 | ResourceObject *_self; |
| 82 | PyObject *_args; |
| 83 | { |
| 84 | PyObject *_res = NULL; |
| 85 | short _rv; |
| 86 | if (!PyArg_ParseTuple(_args, "")) |
| 87 | return NULL; |
| 88 | _rv = HomeResFile(_self->ob_itself); |
| 89 | { |
| 90 | OSErr _err = ResError(); |
| 91 | if (_err != noErr) return PyMac_Error(_err); |
| 92 | } |
| 93 | _res = Py_BuildValue("h", |
| 94 | _rv); |
| 95 | return _res; |
| 96 | } |
| 97 | |
| 98 | static PyObject *ResObj_LoadResource(_self, _args) |
| 99 | ResourceObject *_self; |
| 100 | PyObject *_args; |
| 101 | { |
| 102 | PyObject *_res = NULL; |
| 103 | if (!PyArg_ParseTuple(_args, "")) |
| 104 | return NULL; |
| 105 | LoadResource(_self->ob_itself); |
| 106 | { |
| 107 | OSErr _err = ResError(); |
| 108 | if (_err != noErr) return PyMac_Error(_err); |
| 109 | } |
| 110 | Py_INCREF(Py_None); |
| 111 | _res = Py_None; |
| 112 | return _res; |
| 113 | } |
| 114 | |
| 115 | static PyObject *ResObj_ReleaseResource(_self, _args) |
| 116 | ResourceObject *_self; |
| 117 | PyObject *_args; |
| 118 | { |
| 119 | PyObject *_res = NULL; |
| 120 | if (!PyArg_ParseTuple(_args, "")) |
| 121 | return NULL; |
| 122 | ReleaseResource(_self->ob_itself); |
| 123 | { |
| 124 | OSErr _err = ResError(); |
| 125 | if (_err != noErr) return PyMac_Error(_err); |
| 126 | } |
| 127 | Py_INCREF(Py_None); |
| 128 | _res = Py_None; |
| 129 | return _res; |
| 130 | } |
| 131 | |
| 132 | static PyObject *ResObj_DetachResource(_self, _args) |
| 133 | ResourceObject *_self; |
| 134 | PyObject *_args; |
| 135 | { |
| 136 | PyObject *_res = NULL; |
| 137 | if (!PyArg_ParseTuple(_args, "")) |
| 138 | return NULL; |
| 139 | DetachResource(_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; |
| 147 | } |
| 148 | |
| 149 | static PyObject *ResObj_GetResAttrs(_self, _args) |
| 150 | ResourceObject *_self; |
| 151 | PyObject *_args; |
| 152 | { |
| 153 | PyObject *_res = NULL; |
| 154 | short _rv; |
| 155 | if (!PyArg_ParseTuple(_args, "")) |
| 156 | return NULL; |
| 157 | _rv = GetResAttrs(_self->ob_itself); |
| 158 | { |
| 159 | OSErr _err = ResError(); |
| 160 | if (_err != noErr) return PyMac_Error(_err); |
| 161 | } |
| 162 | _res = Py_BuildValue("h", |
| 163 | _rv); |
| 164 | return _res; |
| 165 | } |
| 166 | |
| 167 | static PyObject *ResObj_GetResInfo(_self, _args) |
| 168 | ResourceObject *_self; |
| 169 | PyObject *_args; |
| 170 | { |
| 171 | PyObject *_res = NULL; |
| 172 | short theID; |
| 173 | ResType theType; |
| 174 | Str255 name; |
| 175 | if (!PyArg_ParseTuple(_args, "")) |
| 176 | return NULL; |
| 177 | GetResInfo(_self->ob_itself, |
| 178 | &theID, |
| 179 | &theType, |
| 180 | name); |
| 181 | { |
| 182 | OSErr _err = ResError(); |
| 183 | if (_err != noErr) return PyMac_Error(_err); |
| 184 | } |
| 185 | _res = Py_BuildValue("hO&O&", |
| 186 | theID, |
| 187 | PyMac_BuildOSType, theType, |
| 188 | PyMac_BuildStr255, name); |
| 189 | return _res; |
| 190 | } |
| 191 | |
| 192 | static PyObject *ResObj_SetResInfo(_self, _args) |
| 193 | ResourceObject *_self; |
| 194 | PyObject *_args; |
| 195 | { |
| 196 | PyObject *_res = NULL; |
| 197 | short theID; |
| 198 | Str255 name; |
| 199 | if (!PyArg_ParseTuple(_args, "hO&", |
| 200 | &theID, |
| 201 | PyMac_GetStr255, name)) |
| 202 | return NULL; |
| 203 | SetResInfo(_self->ob_itself, |
| 204 | theID, |
| 205 | name); |
| 206 | { |
| 207 | OSErr _err = ResError(); |
| 208 | if (_err != noErr) return PyMac_Error(_err); |
| 209 | } |
| 210 | Py_INCREF(Py_None); |
| 211 | _res = Py_None; |
| 212 | return _res; |
| 213 | } |
| 214 | |
| 215 | static PyObject *ResObj_AddResource(_self, _args) |
| 216 | ResourceObject *_self; |
| 217 | PyObject *_args; |
| 218 | { |
| 219 | PyObject *_res = NULL; |
| 220 | ResType theType; |
| 221 | short theID; |
| 222 | Str255 name; |
| 223 | if (!PyArg_ParseTuple(_args, "O&hO&", |
| 224 | PyMac_GetOSType, &theType, |
| 225 | &theID, |
| 226 | PyMac_GetStr255, name)) |
| 227 | return NULL; |
| 228 | AddResource(_self->ob_itself, |
| 229 | theType, |
| 230 | theID, |
| 231 | name); |
| 232 | { |
| 233 | OSErr _err = ResError(); |
| 234 | if (_err != noErr) return PyMac_Error(_err); |
| 235 | } |
| 236 | Py_INCREF(Py_None); |
| 237 | _res = Py_None; |
| 238 | return _res; |
| 239 | } |
| 240 | |
| 241 | static PyObject *ResObj_SizeResource(_self, _args) |
| 242 | ResourceObject *_self; |
| 243 | PyObject *_args; |
| 244 | { |
| 245 | PyObject *_res = NULL; |
| 246 | long _rv; |
| 247 | if (!PyArg_ParseTuple(_args, "")) |
| 248 | return NULL; |
| 249 | _rv = SizeResource(_self->ob_itself); |
| 250 | { |
| 251 | OSErr _err = ResError(); |
| 252 | if (_err != noErr) return PyMac_Error(_err); |
| 253 | } |
| 254 | _res = Py_BuildValue("l", |
| 255 | _rv); |
| 256 | return _res; |
| 257 | } |
| 258 | |
| 259 | static PyObject *ResObj_MaxSizeRsrc(_self, _args) |
| 260 | ResourceObject *_self; |
| 261 | PyObject *_args; |
| 262 | { |
| 263 | PyObject *_res = NULL; |
| 264 | long _rv; |
| 265 | if (!PyArg_ParseTuple(_args, "")) |
| 266 | return NULL; |
| 267 | _rv = MaxSizeRsrc(_self->ob_itself); |
| 268 | { |
| 269 | OSErr _err = ResError(); |
| 270 | if (_err != noErr) return PyMac_Error(_err); |
| 271 | } |
| 272 | _res = Py_BuildValue("l", |
| 273 | _rv); |
| 274 | return _res; |
| 275 | } |
| 276 | |
| 277 | static PyObject *ResObj_RsrcMapEntry(_self, _args) |
| 278 | ResourceObject *_self; |
| 279 | PyObject *_args; |
| 280 | { |
| 281 | PyObject *_res = NULL; |
| 282 | long _rv; |
| 283 | if (!PyArg_ParseTuple(_args, "")) |
| 284 | return NULL; |
| 285 | _rv = RsrcMapEntry(_self->ob_itself); |
| 286 | { |
| 287 | OSErr _err = ResError(); |
| 288 | if (_err != noErr) return PyMac_Error(_err); |
| 289 | } |
| 290 | _res = Py_BuildValue("l", |
| 291 | _rv); |
| 292 | return _res; |
| 293 | } |
| 294 | |
| 295 | static PyObject *ResObj_SetResAttrs(_self, _args) |
| 296 | ResourceObject *_self; |
| 297 | PyObject *_args; |
| 298 | { |
| 299 | PyObject *_res = NULL; |
| 300 | short attrs; |
| 301 | if (!PyArg_ParseTuple(_args, "h", |
| 302 | &attrs)) |
| 303 | return NULL; |
| 304 | SetResAttrs(_self->ob_itself, |
| 305 | attrs); |
| 306 | { |
| 307 | OSErr _err = ResError(); |
| 308 | if (_err != noErr) return PyMac_Error(_err); |
| 309 | } |
| 310 | Py_INCREF(Py_None); |
| 311 | _res = Py_None; |
| 312 | return _res; |
| 313 | } |
| 314 | |
| 315 | static PyObject *ResObj_ChangedResource(_self, _args) |
| 316 | ResourceObject *_self; |
| 317 | PyObject *_args; |
| 318 | { |
| 319 | PyObject *_res = NULL; |
| 320 | if (!PyArg_ParseTuple(_args, "")) |
| 321 | return NULL; |
| 322 | ChangedResource(_self->ob_itself); |
| 323 | { |
| 324 | OSErr _err = ResError(); |
| 325 | if (_err != noErr) return PyMac_Error(_err); |
| 326 | } |
| 327 | Py_INCREF(Py_None); |
| 328 | _res = Py_None; |
| 329 | return _res; |
| 330 | } |
| 331 | |
| 332 | static PyObject *ResObj_RmveResource(_self, _args) |
| 333 | ResourceObject *_self; |
| 334 | PyObject *_args; |
| 335 | { |
| 336 | PyObject *_res = NULL; |
| 337 | if (!PyArg_ParseTuple(_args, "")) |
| 338 | return NULL; |
| 339 | RmveResource(_self->ob_itself); |
| 340 | { |
| 341 | OSErr _err = ResError(); |
| 342 | if (_err != noErr) return PyMac_Error(_err); |
| 343 | } |
| 344 | Py_INCREF(Py_None); |
| 345 | _res = Py_None; |
| 346 | return _res; |
| 347 | } |
| 348 | |
| 349 | static PyObject *ResObj_WriteResource(_self, _args) |
| 350 | ResourceObject *_self; |
| 351 | PyObject *_args; |
| 352 | { |
| 353 | PyObject *_res = NULL; |
| 354 | if (!PyArg_ParseTuple(_args, "")) |
| 355 | return NULL; |
| 356 | WriteResource(_self->ob_itself); |
| 357 | { |
| 358 | OSErr _err = ResError(); |
| 359 | if (_err != noErr) return PyMac_Error(_err); |
| 360 | } |
| 361 | Py_INCREF(Py_None); |
| 362 | _res = Py_None; |
| 363 | return _res; |
| 364 | } |
| 365 | |
| 366 | static PyObject *ResObj_SetResourceSize(_self, _args) |
| 367 | ResourceObject *_self; |
| 368 | PyObject *_args; |
| 369 | { |
| 370 | PyObject *_res = NULL; |
| 371 | long newSize; |
| 372 | if (!PyArg_ParseTuple(_args, "l", |
| 373 | &newSize)) |
| 374 | return NULL; |
| 375 | SetResourceSize(_self->ob_itself, |
| 376 | newSize); |
| 377 | { |
| 378 | OSErr _err = ResError(); |
| 379 | if (_err != noErr) return PyMac_Error(_err); |
| 380 | } |
| 381 | Py_INCREF(Py_None); |
| 382 | _res = Py_None; |
| 383 | return _res; |
| 384 | } |
| 385 | |
| 386 | static PyMethodDef ResObj_methods[] = { |
| 387 | {"HomeResFile", (PyCFunction)ResObj_HomeResFile, 1, |
| 388 | "() -> (short _rv)"}, |
| 389 | {"LoadResource", (PyCFunction)ResObj_LoadResource, 1, |
| 390 | "() -> None"}, |
| 391 | {"ReleaseResource", (PyCFunction)ResObj_ReleaseResource, 1, |
| 392 | "() -> None"}, |
| 393 | {"DetachResource", (PyCFunction)ResObj_DetachResource, 1, |
| 394 | "() -> None"}, |
| 395 | {"GetResAttrs", (PyCFunction)ResObj_GetResAttrs, 1, |
| 396 | "() -> (short _rv)"}, |
| 397 | {"GetResInfo", (PyCFunction)ResObj_GetResInfo, 1, |
| 398 | "() -> (short theID, ResType theType, Str255 name)"}, |
| 399 | {"SetResInfo", (PyCFunction)ResObj_SetResInfo, 1, |
| 400 | "(short theID, Str255 name) -> None"}, |
| 401 | {"AddResource", (PyCFunction)ResObj_AddResource, 1, |
| 402 | "(ResType theType, short theID, Str255 name) -> None"}, |
| 403 | {"SizeResource", (PyCFunction)ResObj_SizeResource, 1, |
| 404 | "() -> (long _rv)"}, |
| 405 | {"MaxSizeRsrc", (PyCFunction)ResObj_MaxSizeRsrc, 1, |
| 406 | "() -> (long _rv)"}, |
| 407 | {"RsrcMapEntry", (PyCFunction)ResObj_RsrcMapEntry, 1, |
| 408 | "() -> (long _rv)"}, |
| 409 | {"SetResAttrs", (PyCFunction)ResObj_SetResAttrs, 1, |
| 410 | "(short attrs) -> None"}, |
| 411 | {"ChangedResource", (PyCFunction)ResObj_ChangedResource, 1, |
| 412 | "() -> None"}, |
| 413 | {"RmveResource", (PyCFunction)ResObj_RmveResource, 1, |
| 414 | "() -> None"}, |
| 415 | {"WriteResource", (PyCFunction)ResObj_WriteResource, 1, |
| 416 | "() -> None"}, |
| 417 | {"SetResourceSize", (PyCFunction)ResObj_SetResourceSize, 1, |
| 418 | "(long newSize) -> None"}, |
| 419 | {NULL, NULL, 0} |
| 420 | }; |
| 421 | |
| 422 | PyMethodChain ResObj_chain = { ResObj_methods, NULL }; |
| 423 | |
| 424 | static PyObject *ResObj_getattr(self, name) |
| 425 | ResourceObject *self; |
| 426 | char *name; |
| 427 | { |
| 428 | |
| 429 | if (strcmp(name, "size") == 0) |
| 430 | return PyInt_FromLong(GetHandleSize(self->ob_itself)); |
| 431 | if (strcmp(name, "data") == 0) { |
| 432 | PyObject *res; |
| 433 | char state; |
| 434 | state = HGetState(self->ob_itself); |
| 435 | HLock(self->ob_itself); |
| 436 | res = PyString_FromStringAndSize( |
| 437 | *self->ob_itself, |
| 438 | GetHandleSize(self->ob_itself)); |
| 439 | HUnlock(self->ob_itself); |
| 440 | HSetState(self->ob_itself, state); |
| 441 | return res; |
| 442 | } |
| 443 | if (strcmp(name, "__members__") == 0) |
| 444 | return Py_BuildValue("[ss]", "data", "size"); |
| 445 | |
| 446 | return Py_FindMethodInChain(&ResObj_chain, (PyObject *)self, name); |
| 447 | } |
| 448 | |
| 449 | #define ResObj_setattr NULL |
| 450 | |
| 451 | PyTypeObject Resource_Type = { |
| 452 | PyObject_HEAD_INIT(&PyType_Type) |
| 453 | 0, /*ob_size*/ |
| 454 | "Resource", /*tp_name*/ |
| 455 | sizeof(ResourceObject), /*tp_basicsize*/ |
| 456 | 0, /*tp_itemsize*/ |
| 457 | /* methods */ |
| 458 | (destructor) ResObj_dealloc, /*tp_dealloc*/ |
| 459 | 0, /*tp_print*/ |
| 460 | (getattrfunc) ResObj_getattr, /*tp_getattr*/ |
| 461 | (setattrfunc) ResObj_setattr, /*tp_setattr*/ |
| 462 | }; |
| 463 | |
| 464 | /* -------------------- End object type Resource -------------------- */ |
| 465 | |
| 466 | |
| 467 | static PyObject *Res_InitResources(_self, _args) |
| 468 | PyObject *_self; |
| 469 | PyObject *_args; |
| 470 | { |
| 471 | PyObject *_res = NULL; |
| 472 | short _rv; |
| 473 | if (!PyArg_ParseTuple(_args, "")) |
| 474 | return NULL; |
| 475 | _rv = InitResources(); |
| 476 | { |
| 477 | OSErr _err = ResError(); |
| 478 | if (_err != noErr) return PyMac_Error(_err); |
| 479 | } |
| 480 | _res = Py_BuildValue("h", |
| 481 | _rv); |
| 482 | return _res; |
| 483 | } |
| 484 | |
| 485 | static PyObject *Res_RsrcZoneInit(_self, _args) |
| 486 | PyObject *_self; |
| 487 | PyObject *_args; |
| 488 | { |
| 489 | PyObject *_res = NULL; |
| 490 | if (!PyArg_ParseTuple(_args, "")) |
| 491 | return NULL; |
| 492 | RsrcZoneInit(); |
| 493 | { |
| 494 | OSErr _err = ResError(); |
| 495 | if (_err != noErr) return PyMac_Error(_err); |
| 496 | } |
| 497 | Py_INCREF(Py_None); |
| 498 | _res = Py_None; |
| 499 | return _res; |
| 500 | } |
| 501 | |
| 502 | static PyObject *Res_CloseResFile(_self, _args) |
| 503 | PyObject *_self; |
| 504 | PyObject *_args; |
| 505 | { |
| 506 | PyObject *_res = NULL; |
| 507 | short refNum; |
| 508 | if (!PyArg_ParseTuple(_args, "h", |
| 509 | &refNum)) |
| 510 | return NULL; |
| 511 | CloseResFile(refNum); |
| 512 | { |
| 513 | OSErr _err = ResError(); |
| 514 | if (_err != noErr) return PyMac_Error(_err); |
| 515 | } |
| 516 | Py_INCREF(Py_None); |
| 517 | _res = Py_None; |
| 518 | return _res; |
| 519 | } |
| 520 | |
| 521 | static PyObject *Res_ResError(_self, _args) |
| 522 | PyObject *_self; |
| 523 | PyObject *_args; |
| 524 | { |
| 525 | PyObject *_res = NULL; |
| 526 | short _rv; |
| 527 | if (!PyArg_ParseTuple(_args, "")) |
| 528 | return NULL; |
| 529 | _rv = ResError(); |
| 530 | { |
| 531 | OSErr _err = ResError(); |
| 532 | if (_err != noErr) return PyMac_Error(_err); |
| 533 | } |
| 534 | _res = Py_BuildValue("h", |
| 535 | _rv); |
| 536 | return _res; |
| 537 | } |
| 538 | |
| 539 | static PyObject *Res_CurResFile(_self, _args) |
| 540 | PyObject *_self; |
| 541 | PyObject *_args; |
| 542 | { |
| 543 | PyObject *_res = NULL; |
| 544 | short _rv; |
| 545 | if (!PyArg_ParseTuple(_args, "")) |
| 546 | return NULL; |
| 547 | _rv = CurResFile(); |
| 548 | { |
| 549 | OSErr _err = ResError(); |
| 550 | if (_err != noErr) return PyMac_Error(_err); |
| 551 | } |
| 552 | _res = Py_BuildValue("h", |
| 553 | _rv); |
| 554 | return _res; |
| 555 | } |
| 556 | |
| 557 | static PyObject *Res_CreateResFile(_self, _args) |
| 558 | PyObject *_self; |
| 559 | PyObject *_args; |
| 560 | { |
| 561 | PyObject *_res = NULL; |
| 562 | Str255 fileName; |
| 563 | if (!PyArg_ParseTuple(_args, "O&", |
| 564 | PyMac_GetStr255, fileName)) |
| 565 | return NULL; |
| 566 | CreateResFile(fileName); |
| 567 | { |
| 568 | OSErr _err = ResError(); |
| 569 | if (_err != noErr) return PyMac_Error(_err); |
| 570 | } |
| 571 | Py_INCREF(Py_None); |
| 572 | _res = Py_None; |
| 573 | return _res; |
| 574 | } |
| 575 | |
| 576 | static PyObject *Res_OpenResFile(_self, _args) |
| 577 | PyObject *_self; |
| 578 | PyObject *_args; |
| 579 | { |
| 580 | PyObject *_res = NULL; |
| 581 | short _rv; |
| 582 | Str255 fileName; |
| 583 | if (!PyArg_ParseTuple(_args, "O&", |
| 584 | PyMac_GetStr255, fileName)) |
| 585 | return NULL; |
| 586 | _rv = OpenResFile(fileName); |
| 587 | { |
| 588 | OSErr _err = ResError(); |
| 589 | if (_err != noErr) return PyMac_Error(_err); |
| 590 | } |
| 591 | _res = Py_BuildValue("h", |
| 592 | _rv); |
| 593 | return _res; |
| 594 | } |
| 595 | |
| 596 | static PyObject *Res_UseResFile(_self, _args) |
| 597 | PyObject *_self; |
| 598 | PyObject *_args; |
| 599 | { |
| 600 | PyObject *_res = NULL; |
| 601 | short refNum; |
| 602 | if (!PyArg_ParseTuple(_args, "h", |
| 603 | &refNum)) |
| 604 | return NULL; |
| 605 | UseResFile(refNum); |
| 606 | { |
| 607 | OSErr _err = ResError(); |
| 608 | if (_err != noErr) return PyMac_Error(_err); |
| 609 | } |
| 610 | Py_INCREF(Py_None); |
| 611 | _res = Py_None; |
| 612 | return _res; |
| 613 | } |
| 614 | |
| 615 | static PyObject *Res_CountTypes(_self, _args) |
| 616 | PyObject *_self; |
| 617 | PyObject *_args; |
| 618 | { |
| 619 | PyObject *_res = NULL; |
| 620 | short _rv; |
| 621 | if (!PyArg_ParseTuple(_args, "")) |
| 622 | return NULL; |
| 623 | _rv = CountTypes(); |
| 624 | { |
| 625 | OSErr _err = ResError(); |
| 626 | if (_err != noErr) return PyMac_Error(_err); |
| 627 | } |
| 628 | _res = Py_BuildValue("h", |
| 629 | _rv); |
| 630 | return _res; |
| 631 | } |
| 632 | |
| 633 | static PyObject *Res_Count1Types(_self, _args) |
| 634 | PyObject *_self; |
| 635 | PyObject *_args; |
| 636 | { |
| 637 | PyObject *_res = NULL; |
| 638 | short _rv; |
| 639 | if (!PyArg_ParseTuple(_args, "")) |
| 640 | return NULL; |
| 641 | _rv = Count1Types(); |
| 642 | { |
| 643 | OSErr _err = ResError(); |
| 644 | if (_err != noErr) return PyMac_Error(_err); |
| 645 | } |
| 646 | _res = Py_BuildValue("h", |
| 647 | _rv); |
| 648 | return _res; |
| 649 | } |
| 650 | |
| 651 | static PyObject *Res_GetIndType(_self, _args) |
| 652 | PyObject *_self; |
| 653 | PyObject *_args; |
| 654 | { |
| 655 | PyObject *_res = NULL; |
| 656 | ResType theType; |
| 657 | short index; |
| 658 | if (!PyArg_ParseTuple(_args, "h", |
| 659 | &index)) |
| 660 | return NULL; |
| 661 | GetIndType(&theType, |
| 662 | index); |
| 663 | { |
| 664 | OSErr _err = ResError(); |
| 665 | if (_err != noErr) return PyMac_Error(_err); |
| 666 | } |
| 667 | _res = Py_BuildValue("O&", |
| 668 | PyMac_BuildOSType, theType); |
| 669 | return _res; |
| 670 | } |
| 671 | |
| 672 | static PyObject *Res_Get1IndType(_self, _args) |
| 673 | PyObject *_self; |
| 674 | PyObject *_args; |
| 675 | { |
| 676 | PyObject *_res = NULL; |
| 677 | ResType theType; |
| 678 | short index; |
| 679 | if (!PyArg_ParseTuple(_args, "h", |
| 680 | &index)) |
| 681 | return NULL; |
| 682 | Get1IndType(&theType, |
| 683 | index); |
| 684 | { |
| 685 | OSErr _err = ResError(); |
| 686 | if (_err != noErr) return PyMac_Error(_err); |
| 687 | } |
| 688 | _res = Py_BuildValue("O&", |
| 689 | PyMac_BuildOSType, theType); |
| 690 | return _res; |
| 691 | } |
| 692 | |
| 693 | static PyObject *Res_SetResLoad(_self, _args) |
| 694 | PyObject *_self; |
| 695 | PyObject *_args; |
| 696 | { |
| 697 | PyObject *_res = NULL; |
| 698 | Boolean load; |
| 699 | if (!PyArg_ParseTuple(_args, "b", |
| 700 | &load)) |
| 701 | return NULL; |
| 702 | SetResLoad(load); |
| 703 | { |
| 704 | OSErr _err = ResError(); |
| 705 | if (_err != noErr) return PyMac_Error(_err); |
| 706 | } |
| 707 | Py_INCREF(Py_None); |
| 708 | _res = Py_None; |
| 709 | return _res; |
| 710 | } |
| 711 | |
| 712 | static PyObject *Res_CountResources(_self, _args) |
| 713 | PyObject *_self; |
| 714 | PyObject *_args; |
| 715 | { |
| 716 | PyObject *_res = NULL; |
| 717 | short _rv; |
| 718 | ResType theType; |
| 719 | if (!PyArg_ParseTuple(_args, "O&", |
| 720 | PyMac_GetOSType, &theType)) |
| 721 | return NULL; |
| 722 | _rv = CountResources(theType); |
| 723 | { |
| 724 | OSErr _err = ResError(); |
| 725 | if (_err != noErr) return PyMac_Error(_err); |
| 726 | } |
| 727 | _res = Py_BuildValue("h", |
| 728 | _rv); |
| 729 | return _res; |
| 730 | } |
| 731 | |
| 732 | static PyObject *Res_Count1Resources(_self, _args) |
| 733 | PyObject *_self; |
| 734 | PyObject *_args; |
| 735 | { |
| 736 | PyObject *_res = NULL; |
| 737 | short _rv; |
| 738 | ResType theType; |
| 739 | if (!PyArg_ParseTuple(_args, "O&", |
| 740 | PyMac_GetOSType, &theType)) |
| 741 | return NULL; |
| 742 | _rv = Count1Resources(theType); |
| 743 | { |
| 744 | OSErr _err = ResError(); |
| 745 | if (_err != noErr) return PyMac_Error(_err); |
| 746 | } |
| 747 | _res = Py_BuildValue("h", |
| 748 | _rv); |
| 749 | return _res; |
| 750 | } |
| 751 | |
| 752 | static PyObject *Res_GetIndResource(_self, _args) |
| 753 | PyObject *_self; |
| 754 | PyObject *_args; |
| 755 | { |
| 756 | PyObject *_res = NULL; |
| 757 | Handle _rv; |
| 758 | ResType theType; |
| 759 | short index; |
| 760 | if (!PyArg_ParseTuple(_args, "O&h", |
| 761 | PyMac_GetOSType, &theType, |
| 762 | &index)) |
| 763 | return NULL; |
| 764 | _rv = GetIndResource(theType, |
| 765 | index); |
| 766 | { |
| 767 | OSErr _err = ResError(); |
| 768 | if (_err != noErr) return PyMac_Error(_err); |
| 769 | } |
| 770 | _res = Py_BuildValue("O&", |
| 771 | ResObj_New, _rv); |
| 772 | return _res; |
| 773 | } |
| 774 | |
| 775 | static PyObject *Res_Get1IndResource(_self, _args) |
| 776 | PyObject *_self; |
| 777 | PyObject *_args; |
| 778 | { |
| 779 | PyObject *_res = NULL; |
| 780 | Handle _rv; |
| 781 | ResType theType; |
| 782 | short index; |
| 783 | if (!PyArg_ParseTuple(_args, "O&h", |
| 784 | PyMac_GetOSType, &theType, |
| 785 | &index)) |
| 786 | return NULL; |
| 787 | _rv = Get1IndResource(theType, |
| 788 | index); |
| 789 | { |
| 790 | OSErr _err = ResError(); |
| 791 | if (_err != noErr) return PyMac_Error(_err); |
| 792 | } |
| 793 | _res = Py_BuildValue("O&", |
| 794 | ResObj_New, _rv); |
| 795 | return _res; |
| 796 | } |
| 797 | |
| 798 | static PyObject *Res_GetResource(_self, _args) |
| 799 | PyObject *_self; |
| 800 | PyObject *_args; |
| 801 | { |
| 802 | PyObject *_res = NULL; |
| 803 | Handle _rv; |
| 804 | ResType theType; |
| 805 | short theID; |
| 806 | if (!PyArg_ParseTuple(_args, "O&h", |
| 807 | PyMac_GetOSType, &theType, |
| 808 | &theID)) |
| 809 | return NULL; |
| 810 | _rv = GetResource(theType, |
| 811 | theID); |
| 812 | { |
| 813 | OSErr _err = ResError(); |
| 814 | if (_err != noErr) return PyMac_Error(_err); |
| 815 | } |
| 816 | _res = Py_BuildValue("O&", |
| 817 | ResObj_New, _rv); |
| 818 | return _res; |
| 819 | } |
| 820 | |
| 821 | static PyObject *Res_Get1Resource(_self, _args) |
| 822 | PyObject *_self; |
| 823 | PyObject *_args; |
| 824 | { |
| 825 | PyObject *_res = NULL; |
| 826 | Handle _rv; |
| 827 | ResType theType; |
| 828 | short theID; |
| 829 | if (!PyArg_ParseTuple(_args, "O&h", |
| 830 | PyMac_GetOSType, &theType, |
| 831 | &theID)) |
| 832 | return NULL; |
| 833 | _rv = Get1Resource(theType, |
| 834 | theID); |
| 835 | { |
| 836 | OSErr _err = ResError(); |
| 837 | if (_err != noErr) return PyMac_Error(_err); |
| 838 | } |
| 839 | _res = Py_BuildValue("O&", |
| 840 | ResObj_New, _rv); |
| 841 | return _res; |
| 842 | } |
| 843 | |
| 844 | static PyObject *Res_GetNamedResource(_self, _args) |
| 845 | PyObject *_self; |
| 846 | PyObject *_args; |
| 847 | { |
| 848 | PyObject *_res = NULL; |
| 849 | Handle _rv; |
| 850 | ResType theType; |
| 851 | Str255 name; |
| 852 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 853 | PyMac_GetOSType, &theType, |
| 854 | PyMac_GetStr255, name)) |
| 855 | return NULL; |
| 856 | _rv = GetNamedResource(theType, |
| 857 | name); |
| 858 | { |
| 859 | OSErr _err = ResError(); |
| 860 | if (_err != noErr) return PyMac_Error(_err); |
| 861 | } |
| 862 | _res = Py_BuildValue("O&", |
| 863 | ResObj_New, _rv); |
| 864 | return _res; |
| 865 | } |
| 866 | |
| 867 | static PyObject *Res_Get1NamedResource(_self, _args) |
| 868 | PyObject *_self; |
| 869 | PyObject *_args; |
| 870 | { |
| 871 | PyObject *_res = NULL; |
| 872 | Handle _rv; |
| 873 | ResType theType; |
| 874 | Str255 name; |
| 875 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 876 | PyMac_GetOSType, &theType, |
| 877 | PyMac_GetStr255, name)) |
| 878 | return NULL; |
| 879 | _rv = Get1NamedResource(theType, |
| 880 | name); |
| 881 | { |
| 882 | OSErr _err = ResError(); |
| 883 | if (_err != noErr) return PyMac_Error(_err); |
| 884 | } |
| 885 | _res = Py_BuildValue("O&", |
| 886 | ResObj_New, _rv); |
| 887 | return _res; |
| 888 | } |
| 889 | |
| 890 | static PyObject *Res_UniqueID(_self, _args) |
| 891 | PyObject *_self; |
| 892 | PyObject *_args; |
| 893 | { |
| 894 | PyObject *_res = NULL; |
| 895 | short _rv; |
| 896 | ResType theType; |
| 897 | if (!PyArg_ParseTuple(_args, "O&", |
| 898 | PyMac_GetOSType, &theType)) |
| 899 | return NULL; |
| 900 | _rv = UniqueID(theType); |
| 901 | { |
| 902 | OSErr _err = ResError(); |
| 903 | if (_err != noErr) return PyMac_Error(_err); |
| 904 | } |
| 905 | _res = Py_BuildValue("h", |
| 906 | _rv); |
| 907 | return _res; |
| 908 | } |
| 909 | |
| 910 | static PyObject *Res_Unique1ID(_self, _args) |
| 911 | PyObject *_self; |
| 912 | PyObject *_args; |
| 913 | { |
| 914 | PyObject *_res = NULL; |
| 915 | short _rv; |
| 916 | ResType theType; |
| 917 | if (!PyArg_ParseTuple(_args, "O&", |
| 918 | PyMac_GetOSType, &theType)) |
| 919 | return NULL; |
| 920 | _rv = Unique1ID(theType); |
| 921 | { |
| 922 | OSErr _err = ResError(); |
| 923 | if (_err != noErr) return PyMac_Error(_err); |
| 924 | } |
| 925 | _res = Py_BuildValue("h", |
| 926 | _rv); |
| 927 | return _res; |
| 928 | } |
| 929 | |
| 930 | static PyObject *Res_UpdateResFile(_self, _args) |
| 931 | PyObject *_self; |
| 932 | PyObject *_args; |
| 933 | { |
| 934 | PyObject *_res = NULL; |
| 935 | short refNum; |
| 936 | if (!PyArg_ParseTuple(_args, "h", |
| 937 | &refNum)) |
| 938 | return NULL; |
| 939 | UpdateResFile(refNum); |
| 940 | { |
| 941 | OSErr _err = ResError(); |
| 942 | if (_err != noErr) return PyMac_Error(_err); |
| 943 | } |
| 944 | Py_INCREF(Py_None); |
| 945 | _res = Py_None; |
| 946 | return _res; |
| 947 | } |
| 948 | |
| 949 | static PyObject *Res_SetResPurge(_self, _args) |
| 950 | PyObject *_self; |
| 951 | PyObject *_args; |
| 952 | { |
| 953 | PyObject *_res = NULL; |
| 954 | Boolean install; |
| 955 | if (!PyArg_ParseTuple(_args, "b", |
| 956 | &install)) |
| 957 | return NULL; |
| 958 | SetResPurge(install); |
| 959 | { |
| 960 | OSErr _err = ResError(); |
| 961 | if (_err != noErr) return PyMac_Error(_err); |
| 962 | } |
| 963 | Py_INCREF(Py_None); |
| 964 | _res = Py_None; |
| 965 | return _res; |
| 966 | } |
| 967 | |
| 968 | static PyObject *Res_GetResFileAttrs(_self, _args) |
| 969 | PyObject *_self; |
| 970 | PyObject *_args; |
| 971 | { |
| 972 | PyObject *_res = NULL; |
| 973 | short _rv; |
| 974 | short refNum; |
| 975 | if (!PyArg_ParseTuple(_args, "h", |
| 976 | &refNum)) |
| 977 | return NULL; |
| 978 | _rv = GetResFileAttrs(refNum); |
| 979 | { |
| 980 | OSErr _err = ResError(); |
| 981 | if (_err != noErr) return PyMac_Error(_err); |
| 982 | } |
| 983 | _res = Py_BuildValue("h", |
| 984 | _rv); |
| 985 | return _res; |
| 986 | } |
| 987 | |
| 988 | static PyObject *Res_SetResFileAttrs(_self, _args) |
| 989 | PyObject *_self; |
| 990 | PyObject *_args; |
| 991 | { |
| 992 | PyObject *_res = NULL; |
| 993 | short refNum; |
| 994 | short attrs; |
| 995 | if (!PyArg_ParseTuple(_args, "hh", |
| 996 | &refNum, |
| 997 | &attrs)) |
| 998 | return NULL; |
| 999 | SetResFileAttrs(refNum, |
| 1000 | attrs); |
| 1001 | { |
| 1002 | OSErr _err = ResError(); |
| 1003 | if (_err != noErr) return PyMac_Error(_err); |
| 1004 | } |
| 1005 | Py_INCREF(Py_None); |
| 1006 | _res = Py_None; |
| 1007 | return _res; |
| 1008 | } |
| 1009 | |
| 1010 | static PyObject *Res_OpenRFPerm(_self, _args) |
| 1011 | PyObject *_self; |
| 1012 | PyObject *_args; |
| 1013 | { |
| 1014 | PyObject *_res = NULL; |
| 1015 | short _rv; |
| 1016 | Str255 fileName; |
| 1017 | short vRefNum; |
| 1018 | char permission; |
| 1019 | if (!PyArg_ParseTuple(_args, "O&hc", |
| 1020 | PyMac_GetStr255, fileName, |
| 1021 | &vRefNum, |
| 1022 | &permission)) |
| 1023 | return NULL; |
| 1024 | _rv = OpenRFPerm(fileName, |
| 1025 | vRefNum, |
| 1026 | permission); |
| 1027 | { |
| 1028 | OSErr _err = ResError(); |
| 1029 | if (_err != noErr) return PyMac_Error(_err); |
| 1030 | } |
| 1031 | _res = Py_BuildValue("h", |
| 1032 | _rv); |
| 1033 | return _res; |
| 1034 | } |
| 1035 | |
| 1036 | static PyObject *Res_RGetResource(_self, _args) |
| 1037 | PyObject *_self; |
| 1038 | PyObject *_args; |
| 1039 | { |
| 1040 | PyObject *_res = NULL; |
| 1041 | Handle _rv; |
| 1042 | ResType theType; |
| 1043 | short theID; |
| 1044 | if (!PyArg_ParseTuple(_args, "O&h", |
| 1045 | PyMac_GetOSType, &theType, |
| 1046 | &theID)) |
| 1047 | return NULL; |
| 1048 | _rv = RGetResource(theType, |
| 1049 | theID); |
| 1050 | { |
| 1051 | OSErr _err = ResError(); |
| 1052 | if (_err != noErr) return PyMac_Error(_err); |
| 1053 | } |
| 1054 | _res = Py_BuildValue("O&", |
| 1055 | ResObj_New, _rv); |
| 1056 | return _res; |
| 1057 | } |
| 1058 | |
| 1059 | static PyObject *Res_HOpenResFile(_self, _args) |
| 1060 | PyObject *_self; |
| 1061 | PyObject *_args; |
| 1062 | { |
| 1063 | PyObject *_res = NULL; |
| 1064 | short _rv; |
| 1065 | short vRefNum; |
| 1066 | long dirID; |
| 1067 | Str255 fileName; |
| 1068 | char permission; |
| 1069 | if (!PyArg_ParseTuple(_args, "hlO&c", |
| 1070 | &vRefNum, |
| 1071 | &dirID, |
| 1072 | PyMac_GetStr255, fileName, |
| 1073 | &permission)) |
| 1074 | return NULL; |
| 1075 | _rv = HOpenResFile(vRefNum, |
| 1076 | dirID, |
| 1077 | fileName, |
| 1078 | permission); |
| 1079 | { |
| 1080 | OSErr _err = ResError(); |
| 1081 | if (_err != noErr) return PyMac_Error(_err); |
| 1082 | } |
| 1083 | _res = Py_BuildValue("h", |
| 1084 | _rv); |
| 1085 | return _res; |
| 1086 | } |
| 1087 | |
| 1088 | static PyObject *Res_HCreateResFile(_self, _args) |
| 1089 | PyObject *_self; |
| 1090 | PyObject *_args; |
| 1091 | { |
| 1092 | PyObject *_res = NULL; |
| 1093 | short vRefNum; |
| 1094 | long dirID; |
| 1095 | Str255 fileName; |
| 1096 | if (!PyArg_ParseTuple(_args, "hlO&", |
| 1097 | &vRefNum, |
| 1098 | &dirID, |
| 1099 | PyMac_GetStr255, fileName)) |
| 1100 | return NULL; |
| 1101 | HCreateResFile(vRefNum, |
| 1102 | dirID, |
| 1103 | fileName); |
| 1104 | { |
| 1105 | OSErr _err = ResError(); |
| 1106 | if (_err != noErr) return PyMac_Error(_err); |
| 1107 | } |
| 1108 | Py_INCREF(Py_None); |
| 1109 | _res = Py_None; |
| 1110 | return _res; |
| 1111 | } |
| 1112 | |
| 1113 | static PyObject *Res_FSpOpenResFile(_self, _args) |
| 1114 | PyObject *_self; |
| 1115 | PyObject *_args; |
| 1116 | { |
| 1117 | PyObject *_res = NULL; |
| 1118 | short _rv; |
| 1119 | FSSpec spec; |
| 1120 | SignedByte permission; |
| 1121 | if (!PyArg_ParseTuple(_args, "O&b", |
| 1122 | PyMac_GetFSSpec, &spec, |
| 1123 | &permission)) |
| 1124 | return NULL; |
| 1125 | _rv = FSpOpenResFile(&spec, |
| 1126 | permission); |
| 1127 | { |
| 1128 | OSErr _err = ResError(); |
| 1129 | if (_err != noErr) return PyMac_Error(_err); |
| 1130 | } |
| 1131 | _res = Py_BuildValue("h", |
| 1132 | _rv); |
| 1133 | return _res; |
| 1134 | } |
| 1135 | |
| 1136 | static PyObject *Res_FSpCreateResFile(_self, _args) |
| 1137 | PyObject *_self; |
| 1138 | PyObject *_args; |
| 1139 | { |
| 1140 | PyObject *_res = NULL; |
| 1141 | FSSpec spec; |
| 1142 | OSType creator; |
| 1143 | OSType fileType; |
| 1144 | ScriptCode scriptTag; |
| 1145 | if (!PyArg_ParseTuple(_args, "O&O&O&h", |
| 1146 | PyMac_GetFSSpec, &spec, |
| 1147 | PyMac_GetOSType, &creator, |
| 1148 | PyMac_GetOSType, &fileType, |
| 1149 | &scriptTag)) |
| 1150 | return NULL; |
| 1151 | FSpCreateResFile(&spec, |
| 1152 | creator, |
| 1153 | fileType, |
| 1154 | scriptTag); |
| 1155 | { |
| 1156 | OSErr _err = ResError(); |
| 1157 | if (_err != noErr) return PyMac_Error(_err); |
| 1158 | } |
| 1159 | Py_INCREF(Py_None); |
| 1160 | _res = Py_None; |
| 1161 | return _res; |
| 1162 | } |
| 1163 | |
| 1164 | static PyMethodDef Res_methods[] = { |
| 1165 | {"InitResources", (PyCFunction)Res_InitResources, 1, |
| 1166 | "() -> (short _rv)"}, |
| 1167 | {"RsrcZoneInit", (PyCFunction)Res_RsrcZoneInit, 1, |
| 1168 | "() -> None"}, |
| 1169 | {"CloseResFile", (PyCFunction)Res_CloseResFile, 1, |
| 1170 | "(short refNum) -> None"}, |
| 1171 | {"ResError", (PyCFunction)Res_ResError, 1, |
| 1172 | "() -> (short _rv)"}, |
| 1173 | {"CurResFile", (PyCFunction)Res_CurResFile, 1, |
| 1174 | "() -> (short _rv)"}, |
| 1175 | {"CreateResFile", (PyCFunction)Res_CreateResFile, 1, |
| 1176 | "(Str255 fileName) -> None"}, |
| 1177 | {"OpenResFile", (PyCFunction)Res_OpenResFile, 1, |
| 1178 | "(Str255 fileName) -> (short _rv)"}, |
| 1179 | {"UseResFile", (PyCFunction)Res_UseResFile, 1, |
| 1180 | "(short refNum) -> None"}, |
| 1181 | {"CountTypes", (PyCFunction)Res_CountTypes, 1, |
| 1182 | "() -> (short _rv)"}, |
| 1183 | {"Count1Types", (PyCFunction)Res_Count1Types, 1, |
| 1184 | "() -> (short _rv)"}, |
| 1185 | {"GetIndType", (PyCFunction)Res_GetIndType, 1, |
| 1186 | "(short index) -> (ResType theType)"}, |
| 1187 | {"Get1IndType", (PyCFunction)Res_Get1IndType, 1, |
| 1188 | "(short index) -> (ResType theType)"}, |
| 1189 | {"SetResLoad", (PyCFunction)Res_SetResLoad, 1, |
| 1190 | "(Boolean load) -> None"}, |
| 1191 | {"CountResources", (PyCFunction)Res_CountResources, 1, |
| 1192 | "(ResType theType) -> (short _rv)"}, |
| 1193 | {"Count1Resources", (PyCFunction)Res_Count1Resources, 1, |
| 1194 | "(ResType theType) -> (short _rv)"}, |
| 1195 | {"GetIndResource", (PyCFunction)Res_GetIndResource, 1, |
| 1196 | "(ResType theType, short index) -> (Handle _rv)"}, |
| 1197 | {"Get1IndResource", (PyCFunction)Res_Get1IndResource, 1, |
| 1198 | "(ResType theType, short index) -> (Handle _rv)"}, |
| 1199 | {"GetResource", (PyCFunction)Res_GetResource, 1, |
| 1200 | "(ResType theType, short theID) -> (Handle _rv)"}, |
| 1201 | {"Get1Resource", (PyCFunction)Res_Get1Resource, 1, |
| 1202 | "(ResType theType, short theID) -> (Handle _rv)"}, |
| 1203 | {"GetNamedResource", (PyCFunction)Res_GetNamedResource, 1, |
| 1204 | "(ResType theType, Str255 name) -> (Handle _rv)"}, |
| 1205 | {"Get1NamedResource", (PyCFunction)Res_Get1NamedResource, 1, |
| 1206 | "(ResType theType, Str255 name) -> (Handle _rv)"}, |
| 1207 | {"UniqueID", (PyCFunction)Res_UniqueID, 1, |
| 1208 | "(ResType theType) -> (short _rv)"}, |
| 1209 | {"Unique1ID", (PyCFunction)Res_Unique1ID, 1, |
| 1210 | "(ResType theType) -> (short _rv)"}, |
| 1211 | {"UpdateResFile", (PyCFunction)Res_UpdateResFile, 1, |
| 1212 | "(short refNum) -> None"}, |
| 1213 | {"SetResPurge", (PyCFunction)Res_SetResPurge, 1, |
| 1214 | "(Boolean install) -> None"}, |
| 1215 | {"GetResFileAttrs", (PyCFunction)Res_GetResFileAttrs, 1, |
| 1216 | "(short refNum) -> (short _rv)"}, |
| 1217 | {"SetResFileAttrs", (PyCFunction)Res_SetResFileAttrs, 1, |
| 1218 | "(short refNum, short attrs) -> None"}, |
| 1219 | {"OpenRFPerm", (PyCFunction)Res_OpenRFPerm, 1, |
| 1220 | "(Str255 fileName, short vRefNum, char permission) -> (short _rv)"}, |
| 1221 | {"RGetResource", (PyCFunction)Res_RGetResource, 1, |
| 1222 | "(ResType theType, short theID) -> (Handle _rv)"}, |
| 1223 | {"HOpenResFile", (PyCFunction)Res_HOpenResFile, 1, |
| 1224 | "(short vRefNum, long dirID, Str255 fileName, char permission) -> (short _rv)"}, |
| 1225 | {"HCreateResFile", (PyCFunction)Res_HCreateResFile, 1, |
| 1226 | "(short vRefNum, long dirID, Str255 fileName) -> None"}, |
| 1227 | {"FSpOpenResFile", (PyCFunction)Res_FSpOpenResFile, 1, |
| 1228 | "(FSSpec spec, SignedByte permission) -> (short _rv)"}, |
| 1229 | {"FSpCreateResFile", (PyCFunction)Res_FSpCreateResFile, 1, |
| 1230 | "(FSSpec spec, OSType creator, OSType fileType, ScriptCode scriptTag) -> None"}, |
| 1231 | {NULL, NULL, 0} |
| 1232 | }; |
| 1233 | |
| 1234 | |
| 1235 | |
| 1236 | |
| 1237 | |
| 1238 | void initRes() |
| 1239 | { |
| 1240 | PyObject *m; |
| 1241 | PyObject *d; |
| 1242 | |
| 1243 | |
| 1244 | |
| 1245 | |
| 1246 | |
| 1247 | m = Py_InitModule("Res", Res_methods); |
| 1248 | d = PyModule_GetDict(m); |
| 1249 | Res_Error = PyMac_GetOSErrException(); |
| 1250 | if (Res_Error == NULL || |
| 1251 | PyDict_SetItemString(d, "Error", Res_Error) != 0) |
| 1252 | Py_FatalError("can't initialize Res.Error"); |
| 1253 | } |
| 1254 | |
| 1255 | /* ========================= End module Res ========================= */ |
| 1256 | |