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