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 *); |
Jack Jansen | 425e9eb | 1995-12-12 15:02:03 +0000 | [diff] [blame] | 18 | extern PyObject *OptResObj_New(Handle); |
| 19 | extern int OptResObj_Convert(PyObject *, Handle *); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 20 | |
| 21 | extern PyObject *WinObj_New(WindowPtr); |
| 22 | extern int WinObj_Convert(PyObject *, WindowPtr *); |
Jack Jansen | 425e9eb | 1995-12-12 15:02:03 +0000 | [diff] [blame] | 23 | extern PyTypeObject Window_Type; |
| 24 | #define WinObj_Check(x) ((x)->ob_type == &Window_Type) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 25 | |
| 26 | extern PyObject *DlgObj_New(DialogPtr); |
| 27 | extern int DlgObj_Convert(PyObject *, DialogPtr *); |
| 28 | extern PyTypeObject Dialog_Type; |
| 29 | #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) |
| 30 | |
| 31 | extern PyObject *MenuObj_New(MenuHandle); |
| 32 | extern int MenuObj_Convert(PyObject *, MenuHandle *); |
| 33 | |
| 34 | extern PyObject *CtlObj_New(ControlHandle); |
| 35 | extern int CtlObj_Convert(PyObject *, ControlHandle *); |
| 36 | |
Jack Jansen | 425e9eb | 1995-12-12 15:02:03 +0000 | [diff] [blame] | 37 | extern PyObject *GrafObj_New(GrafPtr); |
| 38 | extern int GrafObj_Convert(PyObject *, GrafPtr *); |
| 39 | |
| 40 | extern PyObject *BMObj_New(BitMapPtr); |
| 41 | extern int BMObj_Convert(PyObject *, BitMapPtr *); |
| 42 | |
Guido van Rossum | 9bcb641 | 1995-02-05 16:54:27 +0000 | [diff] [blame] | 43 | extern PyObject *WinObj_WhichWindow(WindowPtr); |
| 44 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 45 | #include <Resources.h> |
Jack Jansen | eaf3c9b | 1997-08-15 14:36:45 +0000 | [diff] [blame] | 46 | #include <string.h> |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 47 | |
| 48 | #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */ |
| 49 | |
Jack Jansen | add03b6 | 2000-03-08 16:58:15 +0000 | [diff] [blame^] | 50 | /* Function to dispose a resource, with a "normal" calling sequence */ |
| 51 | static void |
| 52 | PyMac_AutoDisposeHandle(Handle h) |
| 53 | { |
| 54 | DisposeHandle(h); |
| 55 | } |
| 56 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 57 | static PyObject *Res_Error; |
| 58 | |
| 59 | /* ---------------------- Object type Resource ---------------------- */ |
| 60 | |
| 61 | PyTypeObject Resource_Type; |
| 62 | |
| 63 | #define ResObj_Check(x) ((x)->ob_type == &Resource_Type) |
| 64 | |
| 65 | typedef struct ResourceObject { |
| 66 | PyObject_HEAD |
| 67 | Handle ob_itself; |
Jack Jansen | add03b6 | 2000-03-08 16:58:15 +0000 | [diff] [blame^] | 68 | void (*ob_freeit)(Handle ptr); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 69 | } ResourceObject; |
| 70 | |
| 71 | PyObject *ResObj_New(itself) |
Guido van Rossum | 227a423 | 1995-03-10 14:42:57 +0000 | [diff] [blame] | 72 | Handle itself; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 73 | { |
| 74 | ResourceObject *it; |
| 75 | if (itself == NULL) return PyMac_Error(resNotFound); |
| 76 | it = PyObject_NEW(ResourceObject, &Resource_Type); |
| 77 | if (it == NULL) return NULL; |
| 78 | it->ob_itself = itself; |
Jack Jansen | add03b6 | 2000-03-08 16:58:15 +0000 | [diff] [blame^] | 79 | it->ob_freeit = NULL; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 80 | return (PyObject *)it; |
| 81 | } |
| 82 | ResObj_Convert(v, p_itself) |
| 83 | PyObject *v; |
| 84 | Handle *p_itself; |
| 85 | { |
| 86 | if (!ResObj_Check(v)) |
| 87 | { |
Jack Jansen | 2d76c25 | 1999-12-12 22:57:29 +0000 | [diff] [blame] | 88 | PyObject *tmp; |
| 89 | if ( (tmp=PyObject_CallMethod(v, "as_Resource", "")) ) |
| 90 | { |
| 91 | *p_itself = ((ResourceObject *)tmp)->ob_itself; |
| 92 | Py_DECREF(tmp); |
| 93 | return 1; |
| 94 | } |
| 95 | PyErr_Clear(); |
| 96 | } |
| 97 | if (!ResObj_Check(v)) |
| 98 | { |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 99 | PyErr_SetString(PyExc_TypeError, "Resource required"); |
| 100 | return 0; |
| 101 | } |
| 102 | *p_itself = ((ResourceObject *)v)->ob_itself; |
| 103 | return 1; |
| 104 | } |
| 105 | |
| 106 | static void ResObj_dealloc(self) |
| 107 | ResourceObject *self; |
| 108 | { |
Jack Jansen | add03b6 | 2000-03-08 16:58:15 +0000 | [diff] [blame^] | 109 | if (self->ob_freeit && self->ob_itself) |
| 110 | { |
| 111 | self->ob_freeit(self->ob_itself); |
| 112 | } |
| 113 | self->ob_itself = NULL; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 114 | PyMem_DEL(self); |
| 115 | } |
| 116 | |
| 117 | static PyObject *ResObj_HomeResFile(_self, _args) |
| 118 | ResourceObject *_self; |
| 119 | PyObject *_args; |
| 120 | { |
| 121 | PyObject *_res = NULL; |
| 122 | short _rv; |
| 123 | if (!PyArg_ParseTuple(_args, "")) |
| 124 | return NULL; |
| 125 | _rv = HomeResFile(_self->ob_itself); |
| 126 | { |
| 127 | OSErr _err = ResError(); |
| 128 | if (_err != noErr) return PyMac_Error(_err); |
| 129 | } |
| 130 | _res = Py_BuildValue("h", |
| 131 | _rv); |
| 132 | return _res; |
| 133 | } |
| 134 | |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 135 | static PyObject *ResObj_MacLoadResource(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 136 | ResourceObject *_self; |
| 137 | PyObject *_args; |
| 138 | { |
| 139 | PyObject *_res = NULL; |
| 140 | if (!PyArg_ParseTuple(_args, "")) |
| 141 | return NULL; |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 142 | MacLoadResource(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 143 | { |
| 144 | OSErr _err = ResError(); |
| 145 | if (_err != noErr) return PyMac_Error(_err); |
| 146 | } |
| 147 | Py_INCREF(Py_None); |
| 148 | _res = Py_None; |
| 149 | return _res; |
| 150 | } |
| 151 | |
| 152 | static PyObject *ResObj_ReleaseResource(_self, _args) |
| 153 | ResourceObject *_self; |
| 154 | PyObject *_args; |
| 155 | { |
| 156 | PyObject *_res = NULL; |
| 157 | if (!PyArg_ParseTuple(_args, "")) |
| 158 | return NULL; |
| 159 | ReleaseResource(_self->ob_itself); |
| 160 | { |
| 161 | OSErr _err = ResError(); |
| 162 | if (_err != noErr) return PyMac_Error(_err); |
| 163 | } |
| 164 | Py_INCREF(Py_None); |
| 165 | _res = Py_None; |
| 166 | return _res; |
| 167 | } |
| 168 | |
| 169 | static PyObject *ResObj_DetachResource(_self, _args) |
| 170 | ResourceObject *_self; |
| 171 | PyObject *_args; |
| 172 | { |
| 173 | PyObject *_res = NULL; |
| 174 | if (!PyArg_ParseTuple(_args, "")) |
| 175 | return NULL; |
| 176 | DetachResource(_self->ob_itself); |
| 177 | { |
| 178 | OSErr _err = ResError(); |
| 179 | if (_err != noErr) return PyMac_Error(_err); |
| 180 | } |
| 181 | Py_INCREF(Py_None); |
| 182 | _res = Py_None; |
| 183 | return _res; |
| 184 | } |
| 185 | |
| 186 | static PyObject *ResObj_GetResAttrs(_self, _args) |
| 187 | ResourceObject *_self; |
| 188 | PyObject *_args; |
| 189 | { |
| 190 | PyObject *_res = NULL; |
| 191 | short _rv; |
| 192 | if (!PyArg_ParseTuple(_args, "")) |
| 193 | return NULL; |
| 194 | _rv = GetResAttrs(_self->ob_itself); |
| 195 | { |
| 196 | OSErr _err = ResError(); |
| 197 | if (_err != noErr) return PyMac_Error(_err); |
| 198 | } |
| 199 | _res = Py_BuildValue("h", |
| 200 | _rv); |
| 201 | return _res; |
| 202 | } |
| 203 | |
| 204 | static PyObject *ResObj_GetResInfo(_self, _args) |
| 205 | ResourceObject *_self; |
| 206 | PyObject *_args; |
| 207 | { |
| 208 | PyObject *_res = NULL; |
| 209 | short theID; |
| 210 | ResType theType; |
| 211 | Str255 name; |
| 212 | if (!PyArg_ParseTuple(_args, "")) |
| 213 | return NULL; |
| 214 | GetResInfo(_self->ob_itself, |
| 215 | &theID, |
| 216 | &theType, |
| 217 | name); |
| 218 | { |
| 219 | OSErr _err = ResError(); |
| 220 | if (_err != noErr) return PyMac_Error(_err); |
| 221 | } |
| 222 | _res = Py_BuildValue("hO&O&", |
| 223 | theID, |
| 224 | PyMac_BuildOSType, theType, |
| 225 | PyMac_BuildStr255, name); |
| 226 | return _res; |
| 227 | } |
| 228 | |
| 229 | static PyObject *ResObj_SetResInfo(_self, _args) |
| 230 | ResourceObject *_self; |
| 231 | PyObject *_args; |
| 232 | { |
| 233 | PyObject *_res = NULL; |
| 234 | short theID; |
| 235 | Str255 name; |
| 236 | if (!PyArg_ParseTuple(_args, "hO&", |
| 237 | &theID, |
| 238 | PyMac_GetStr255, name)) |
| 239 | return NULL; |
| 240 | SetResInfo(_self->ob_itself, |
| 241 | theID, |
| 242 | name); |
| 243 | { |
| 244 | OSErr _err = ResError(); |
| 245 | if (_err != noErr) return PyMac_Error(_err); |
| 246 | } |
| 247 | Py_INCREF(Py_None); |
| 248 | _res = Py_None; |
| 249 | return _res; |
| 250 | } |
| 251 | |
| 252 | static PyObject *ResObj_AddResource(_self, _args) |
| 253 | ResourceObject *_self; |
| 254 | PyObject *_args; |
| 255 | { |
| 256 | PyObject *_res = NULL; |
| 257 | ResType theType; |
| 258 | short theID; |
| 259 | Str255 name; |
| 260 | if (!PyArg_ParseTuple(_args, "O&hO&", |
| 261 | PyMac_GetOSType, &theType, |
| 262 | &theID, |
| 263 | PyMac_GetStr255, name)) |
| 264 | return NULL; |
| 265 | AddResource(_self->ob_itself, |
| 266 | theType, |
| 267 | theID, |
| 268 | name); |
| 269 | { |
| 270 | OSErr _err = ResError(); |
| 271 | if (_err != noErr) return PyMac_Error(_err); |
| 272 | } |
| 273 | Py_INCREF(Py_None); |
| 274 | _res = Py_None; |
| 275 | return _res; |
| 276 | } |
| 277 | |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 278 | static PyObject *ResObj_GetResourceSizeOnDisk(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 279 | ResourceObject *_self; |
| 280 | PyObject *_args; |
| 281 | { |
| 282 | PyObject *_res = NULL; |
| 283 | long _rv; |
| 284 | if (!PyArg_ParseTuple(_args, "")) |
| 285 | return NULL; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 286 | _rv = GetResourceSizeOnDisk(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 287 | { |
| 288 | OSErr _err = ResError(); |
| 289 | if (_err != noErr) return PyMac_Error(_err); |
| 290 | } |
| 291 | _res = Py_BuildValue("l", |
| 292 | _rv); |
| 293 | return _res; |
| 294 | } |
| 295 | |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 296 | static PyObject *ResObj_GetMaxResourceSize(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 297 | ResourceObject *_self; |
| 298 | PyObject *_args; |
| 299 | { |
| 300 | PyObject *_res = NULL; |
| 301 | long _rv; |
| 302 | if (!PyArg_ParseTuple(_args, "")) |
| 303 | return NULL; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 304 | _rv = GetMaxResourceSize(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 305 | { |
| 306 | OSErr _err = ResError(); |
| 307 | if (_err != noErr) return PyMac_Error(_err); |
| 308 | } |
| 309 | _res = Py_BuildValue("l", |
| 310 | _rv); |
| 311 | return _res; |
| 312 | } |
| 313 | |
| 314 | static PyObject *ResObj_RsrcMapEntry(_self, _args) |
| 315 | ResourceObject *_self; |
| 316 | PyObject *_args; |
| 317 | { |
| 318 | PyObject *_res = NULL; |
| 319 | long _rv; |
| 320 | if (!PyArg_ParseTuple(_args, "")) |
| 321 | return NULL; |
| 322 | _rv = RsrcMapEntry(_self->ob_itself); |
| 323 | { |
| 324 | OSErr _err = ResError(); |
| 325 | if (_err != noErr) return PyMac_Error(_err); |
| 326 | } |
| 327 | _res = Py_BuildValue("l", |
| 328 | _rv); |
| 329 | return _res; |
| 330 | } |
| 331 | |
| 332 | static PyObject *ResObj_SetResAttrs(_self, _args) |
| 333 | ResourceObject *_self; |
| 334 | PyObject *_args; |
| 335 | { |
| 336 | PyObject *_res = NULL; |
| 337 | short attrs; |
| 338 | if (!PyArg_ParseTuple(_args, "h", |
| 339 | &attrs)) |
| 340 | return NULL; |
| 341 | SetResAttrs(_self->ob_itself, |
| 342 | attrs); |
| 343 | { |
| 344 | OSErr _err = ResError(); |
| 345 | if (_err != noErr) return PyMac_Error(_err); |
| 346 | } |
| 347 | Py_INCREF(Py_None); |
| 348 | _res = Py_None; |
| 349 | return _res; |
| 350 | } |
| 351 | |
| 352 | static PyObject *ResObj_ChangedResource(_self, _args) |
| 353 | ResourceObject *_self; |
| 354 | PyObject *_args; |
| 355 | { |
| 356 | PyObject *_res = NULL; |
| 357 | if (!PyArg_ParseTuple(_args, "")) |
| 358 | return NULL; |
| 359 | ChangedResource(_self->ob_itself); |
| 360 | { |
| 361 | OSErr _err = ResError(); |
| 362 | if (_err != noErr) return PyMac_Error(_err); |
| 363 | } |
| 364 | Py_INCREF(Py_None); |
| 365 | _res = Py_None; |
| 366 | return _res; |
| 367 | } |
| 368 | |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 369 | static PyObject *ResObj_RemoveResource(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 370 | ResourceObject *_self; |
| 371 | PyObject *_args; |
| 372 | { |
| 373 | PyObject *_res = NULL; |
| 374 | if (!PyArg_ParseTuple(_args, "")) |
| 375 | return NULL; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 376 | RemoveResource(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 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 PyObject *ResObj_WriteResource(_self, _args) |
| 387 | ResourceObject *_self; |
| 388 | PyObject *_args; |
| 389 | { |
| 390 | PyObject *_res = NULL; |
| 391 | if (!PyArg_ParseTuple(_args, "")) |
| 392 | return NULL; |
| 393 | WriteResource(_self->ob_itself); |
| 394 | { |
| 395 | OSErr _err = ResError(); |
| 396 | if (_err != noErr) return PyMac_Error(_err); |
| 397 | } |
| 398 | Py_INCREF(Py_None); |
| 399 | _res = Py_None; |
| 400 | return _res; |
| 401 | } |
| 402 | |
| 403 | static PyObject *ResObj_SetResourceSize(_self, _args) |
| 404 | ResourceObject *_self; |
| 405 | PyObject *_args; |
| 406 | { |
| 407 | PyObject *_res = NULL; |
| 408 | long newSize; |
| 409 | if (!PyArg_ParseTuple(_args, "l", |
| 410 | &newSize)) |
| 411 | return NULL; |
| 412 | SetResourceSize(_self->ob_itself, |
| 413 | newSize); |
| 414 | { |
| 415 | OSErr _err = ResError(); |
| 416 | if (_err != noErr) return PyMac_Error(_err); |
| 417 | } |
| 418 | Py_INCREF(Py_None); |
| 419 | _res = Py_None; |
| 420 | return _res; |
| 421 | } |
| 422 | |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 423 | static PyObject *ResObj_GetNextFOND(_self, _args) |
| 424 | ResourceObject *_self; |
| 425 | PyObject *_args; |
| 426 | { |
| 427 | PyObject *_res = NULL; |
| 428 | Handle _rv; |
| 429 | if (!PyArg_ParseTuple(_args, "")) |
| 430 | return NULL; |
| 431 | _rv = GetNextFOND(_self->ob_itself); |
| 432 | { |
| 433 | OSErr _err = ResError(); |
| 434 | if (_err != noErr) return PyMac_Error(_err); |
| 435 | } |
| 436 | _res = Py_BuildValue("O&", |
| 437 | ResObj_New, _rv); |
| 438 | return _res; |
| 439 | } |
| 440 | |
Jack Jansen | 1e05402 | 1995-06-18 20:20:27 +0000 | [diff] [blame] | 441 | static PyObject *ResObj_as_Control(_self, _args) |
| 442 | ResourceObject *_self; |
| 443 | PyObject *_args; |
| 444 | { |
| 445 | PyObject *_res = NULL; |
| 446 | |
| 447 | return CtlObj_New((ControlHandle)_self->ob_itself); |
| 448 | |
| 449 | } |
| 450 | |
| 451 | static PyObject *ResObj_as_Menu(_self, _args) |
| 452 | ResourceObject *_self; |
| 453 | PyObject *_args; |
| 454 | { |
| 455 | PyObject *_res = NULL; |
| 456 | |
| 457 | return MenuObj_New((MenuHandle)_self->ob_itself); |
| 458 | |
| 459 | } |
| 460 | |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 461 | static PyObject *ResObj_LoadResource(_self, _args) |
| 462 | ResourceObject *_self; |
| 463 | PyObject *_args; |
| 464 | { |
| 465 | PyObject *_res = NULL; |
| 466 | if (!PyArg_ParseTuple(_args, "")) |
| 467 | return NULL; |
| 468 | LoadResource(_self->ob_itself); |
| 469 | { |
| 470 | OSErr _err = ResError(); |
| 471 | if (_err != noErr) return PyMac_Error(_err); |
| 472 | } |
| 473 | Py_INCREF(Py_None); |
| 474 | _res = Py_None; |
| 475 | return _res; |
| 476 | } |
| 477 | |
Jack Jansen | add03b6 | 2000-03-08 16:58:15 +0000 | [diff] [blame^] | 478 | static PyObject *ResObj_AutoDispose(_self, _args) |
| 479 | ResourceObject *_self; |
| 480 | PyObject *_args; |
| 481 | { |
| 482 | PyObject *_res = NULL; |
| 483 | |
| 484 | int onoff, old = 0; |
| 485 | if (!PyArg_ParseTuple(_args, "i", &onoff)) |
| 486 | return NULL; |
| 487 | if ( _self->ob_freeit ) |
| 488 | old = 1; |
| 489 | if ( onoff ) |
| 490 | _self->ob_freeit = PyMac_AutoDisposeHandle; |
| 491 | else |
| 492 | _self->ob_freeit = NULL; |
| 493 | return Py_BuildValue("i", old); |
| 494 | |
| 495 | } |
| 496 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 497 | static PyMethodDef ResObj_methods[] = { |
| 498 | {"HomeResFile", (PyCFunction)ResObj_HomeResFile, 1, |
| 499 | "() -> (short _rv)"}, |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 500 | {"MacLoadResource", (PyCFunction)ResObj_MacLoadResource, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 501 | "() -> None"}, |
| 502 | {"ReleaseResource", (PyCFunction)ResObj_ReleaseResource, 1, |
| 503 | "() -> None"}, |
| 504 | {"DetachResource", (PyCFunction)ResObj_DetachResource, 1, |
| 505 | "() -> None"}, |
| 506 | {"GetResAttrs", (PyCFunction)ResObj_GetResAttrs, 1, |
| 507 | "() -> (short _rv)"}, |
| 508 | {"GetResInfo", (PyCFunction)ResObj_GetResInfo, 1, |
| 509 | "() -> (short theID, ResType theType, Str255 name)"}, |
| 510 | {"SetResInfo", (PyCFunction)ResObj_SetResInfo, 1, |
| 511 | "(short theID, Str255 name) -> None"}, |
| 512 | {"AddResource", (PyCFunction)ResObj_AddResource, 1, |
| 513 | "(ResType theType, short theID, Str255 name) -> None"}, |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 514 | {"GetResourceSizeOnDisk", (PyCFunction)ResObj_GetResourceSizeOnDisk, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 515 | "() -> (long _rv)"}, |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 516 | {"GetMaxResourceSize", (PyCFunction)ResObj_GetMaxResourceSize, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 517 | "() -> (long _rv)"}, |
| 518 | {"RsrcMapEntry", (PyCFunction)ResObj_RsrcMapEntry, 1, |
| 519 | "() -> (long _rv)"}, |
| 520 | {"SetResAttrs", (PyCFunction)ResObj_SetResAttrs, 1, |
| 521 | "(short attrs) -> None"}, |
| 522 | {"ChangedResource", (PyCFunction)ResObj_ChangedResource, 1, |
| 523 | "() -> None"}, |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 524 | {"RemoveResource", (PyCFunction)ResObj_RemoveResource, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 525 | "() -> None"}, |
| 526 | {"WriteResource", (PyCFunction)ResObj_WriteResource, 1, |
| 527 | "() -> None"}, |
| 528 | {"SetResourceSize", (PyCFunction)ResObj_SetResourceSize, 1, |
| 529 | "(long newSize) -> None"}, |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 530 | {"GetNextFOND", (PyCFunction)ResObj_GetNextFOND, 1, |
| 531 | "() -> (Handle _rv)"}, |
Jack Jansen | 1e05402 | 1995-06-18 20:20:27 +0000 | [diff] [blame] | 532 | {"as_Control", (PyCFunction)ResObj_as_Control, 1, |
| 533 | "Return this resource/handle as a Control"}, |
| 534 | {"as_Menu", (PyCFunction)ResObj_as_Menu, 1, |
| 535 | "Return this resource/handle as a Menu"}, |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 536 | {"LoadResource", (PyCFunction)ResObj_LoadResource, 1, |
| 537 | "() -> None"}, |
Jack Jansen | add03b6 | 2000-03-08 16:58:15 +0000 | [diff] [blame^] | 538 | {"AutoDispose", (PyCFunction)ResObj_AutoDispose, 1, |
| 539 | "(int)->int. Automatically DisposeHandle the object on Python object cleanup"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 540 | {NULL, NULL, 0} |
| 541 | }; |
| 542 | |
| 543 | PyMethodChain ResObj_chain = { ResObj_methods, NULL }; |
| 544 | |
| 545 | static PyObject *ResObj_getattr(self, name) |
| 546 | ResourceObject *self; |
| 547 | char *name; |
| 548 | { |
| 549 | |
| 550 | if (strcmp(name, "size") == 0) |
| 551 | return PyInt_FromLong(GetHandleSize(self->ob_itself)); |
| 552 | if (strcmp(name, "data") == 0) { |
| 553 | PyObject *res; |
| 554 | char state; |
| 555 | state = HGetState(self->ob_itself); |
| 556 | HLock(self->ob_itself); |
| 557 | res = PyString_FromStringAndSize( |
| 558 | *self->ob_itself, |
| 559 | GetHandleSize(self->ob_itself)); |
| 560 | HUnlock(self->ob_itself); |
| 561 | HSetState(self->ob_itself, state); |
| 562 | return res; |
| 563 | } |
| 564 | if (strcmp(name, "__members__") == 0) |
| 565 | return Py_BuildValue("[ss]", "data", "size"); |
| 566 | |
| 567 | return Py_FindMethodInChain(&ResObj_chain, (PyObject *)self, name); |
| 568 | } |
| 569 | |
Jack Jansen | 1e05402 | 1995-06-18 20:20:27 +0000 | [diff] [blame] | 570 | static int |
| 571 | ResObj_setattr(self, name, value) |
| 572 | ResourceObject *self; |
| 573 | char *name; |
| 574 | PyObject *value; |
| 575 | { |
| 576 | char *data; |
| 577 | long size; |
| 578 | |
| 579 | if (strcmp(name, "data") != 0 || value == NULL ) |
| 580 | return -1; |
| 581 | if ( !PyString_Check(value) ) |
| 582 | return -1; |
| 583 | size = PyString_Size(value); |
| 584 | data = PyString_AsString(value); |
| 585 | /* XXXX Do I need the GetState/SetState calls? */ |
| 586 | SetHandleSize(self->ob_itself, size); |
| 587 | if ( MemError()) |
| 588 | return -1; |
| 589 | HLock(self->ob_itself); |
| 590 | memcpy((char *)*self->ob_itself, data, size); |
| 591 | HUnlock(self->ob_itself); |
| 592 | /* XXXX Should I do the Changed call immedeately? */ |
| 593 | return 0; |
| 594 | } |
| 595 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 596 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 597 | #define ResObj_compare NULL |
| 598 | |
| 599 | #define ResObj_repr NULL |
| 600 | |
| 601 | #define ResObj_hash NULL |
| 602 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 603 | PyTypeObject Resource_Type = { |
| 604 | PyObject_HEAD_INIT(&PyType_Type) |
| 605 | 0, /*ob_size*/ |
| 606 | "Resource", /*tp_name*/ |
| 607 | sizeof(ResourceObject), /*tp_basicsize*/ |
| 608 | 0, /*tp_itemsize*/ |
| 609 | /* methods */ |
| 610 | (destructor) ResObj_dealloc, /*tp_dealloc*/ |
| 611 | 0, /*tp_print*/ |
| 612 | (getattrfunc) ResObj_getattr, /*tp_getattr*/ |
| 613 | (setattrfunc) ResObj_setattr, /*tp_setattr*/ |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 614 | (cmpfunc) ResObj_compare, /*tp_compare*/ |
| 615 | (reprfunc) ResObj_repr, /*tp_repr*/ |
| 616 | (PyNumberMethods *)0, /* tp_as_number */ |
| 617 | (PySequenceMethods *)0, /* tp_as_sequence */ |
| 618 | (PyMappingMethods *)0, /* tp_as_mapping */ |
| 619 | (hashfunc) ResObj_hash, /*tp_hash*/ |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 620 | }; |
| 621 | |
| 622 | /* -------------------- End object type Resource -------------------- */ |
| 623 | |
| 624 | |
| 625 | static PyObject *Res_InitResources(_self, _args) |
| 626 | PyObject *_self; |
| 627 | PyObject *_args; |
| 628 | { |
| 629 | PyObject *_res = NULL; |
| 630 | short _rv; |
| 631 | if (!PyArg_ParseTuple(_args, "")) |
| 632 | return NULL; |
| 633 | _rv = InitResources(); |
| 634 | { |
| 635 | OSErr _err = ResError(); |
| 636 | if (_err != noErr) return PyMac_Error(_err); |
| 637 | } |
| 638 | _res = Py_BuildValue("h", |
| 639 | _rv); |
| 640 | return _res; |
| 641 | } |
| 642 | |
| 643 | static PyObject *Res_RsrcZoneInit(_self, _args) |
| 644 | PyObject *_self; |
| 645 | PyObject *_args; |
| 646 | { |
| 647 | PyObject *_res = NULL; |
| 648 | if (!PyArg_ParseTuple(_args, "")) |
| 649 | return NULL; |
| 650 | RsrcZoneInit(); |
| 651 | { |
| 652 | OSErr _err = ResError(); |
| 653 | if (_err != noErr) return PyMac_Error(_err); |
| 654 | } |
| 655 | Py_INCREF(Py_None); |
| 656 | _res = Py_None; |
| 657 | return _res; |
| 658 | } |
| 659 | |
| 660 | static PyObject *Res_CloseResFile(_self, _args) |
| 661 | PyObject *_self; |
| 662 | PyObject *_args; |
| 663 | { |
| 664 | PyObject *_res = NULL; |
| 665 | short refNum; |
| 666 | if (!PyArg_ParseTuple(_args, "h", |
| 667 | &refNum)) |
| 668 | return NULL; |
| 669 | CloseResFile(refNum); |
| 670 | { |
| 671 | OSErr _err = ResError(); |
| 672 | if (_err != noErr) return PyMac_Error(_err); |
| 673 | } |
| 674 | Py_INCREF(Py_None); |
| 675 | _res = Py_None; |
| 676 | return _res; |
| 677 | } |
| 678 | |
| 679 | static PyObject *Res_ResError(_self, _args) |
| 680 | PyObject *_self; |
| 681 | PyObject *_args; |
| 682 | { |
| 683 | PyObject *_res = NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 684 | OSErr _rv; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 685 | if (!PyArg_ParseTuple(_args, "")) |
| 686 | return NULL; |
| 687 | _rv = ResError(); |
| 688 | { |
| 689 | OSErr _err = ResError(); |
| 690 | if (_err != noErr) return PyMac_Error(_err); |
| 691 | } |
| 692 | _res = Py_BuildValue("h", |
| 693 | _rv); |
| 694 | return _res; |
| 695 | } |
| 696 | |
| 697 | static PyObject *Res_CurResFile(_self, _args) |
| 698 | PyObject *_self; |
| 699 | PyObject *_args; |
| 700 | { |
| 701 | PyObject *_res = NULL; |
| 702 | short _rv; |
| 703 | if (!PyArg_ParseTuple(_args, "")) |
| 704 | return NULL; |
| 705 | _rv = CurResFile(); |
| 706 | { |
| 707 | OSErr _err = ResError(); |
| 708 | if (_err != noErr) return PyMac_Error(_err); |
| 709 | } |
| 710 | _res = Py_BuildValue("h", |
| 711 | _rv); |
| 712 | return _res; |
| 713 | } |
| 714 | |
| 715 | static PyObject *Res_CreateResFile(_self, _args) |
| 716 | PyObject *_self; |
| 717 | PyObject *_args; |
| 718 | { |
| 719 | PyObject *_res = NULL; |
| 720 | Str255 fileName; |
| 721 | if (!PyArg_ParseTuple(_args, "O&", |
| 722 | PyMac_GetStr255, fileName)) |
| 723 | return NULL; |
| 724 | CreateResFile(fileName); |
| 725 | { |
| 726 | OSErr _err = ResError(); |
| 727 | if (_err != noErr) return PyMac_Error(_err); |
| 728 | } |
| 729 | Py_INCREF(Py_None); |
| 730 | _res = Py_None; |
| 731 | return _res; |
| 732 | } |
| 733 | |
| 734 | static PyObject *Res_OpenResFile(_self, _args) |
| 735 | PyObject *_self; |
| 736 | PyObject *_args; |
| 737 | { |
| 738 | PyObject *_res = NULL; |
| 739 | short _rv; |
| 740 | Str255 fileName; |
| 741 | if (!PyArg_ParseTuple(_args, "O&", |
| 742 | PyMac_GetStr255, fileName)) |
| 743 | return NULL; |
| 744 | _rv = OpenResFile(fileName); |
| 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_UseResFile(_self, _args) |
| 755 | PyObject *_self; |
| 756 | PyObject *_args; |
| 757 | { |
| 758 | PyObject *_res = NULL; |
| 759 | short refNum; |
| 760 | if (!PyArg_ParseTuple(_args, "h", |
| 761 | &refNum)) |
| 762 | return NULL; |
| 763 | UseResFile(refNum); |
| 764 | { |
| 765 | OSErr _err = ResError(); |
| 766 | if (_err != noErr) return PyMac_Error(_err); |
| 767 | } |
| 768 | Py_INCREF(Py_None); |
| 769 | _res = Py_None; |
| 770 | return _res; |
| 771 | } |
| 772 | |
| 773 | static PyObject *Res_CountTypes(_self, _args) |
| 774 | PyObject *_self; |
| 775 | PyObject *_args; |
| 776 | { |
| 777 | PyObject *_res = NULL; |
| 778 | short _rv; |
| 779 | if (!PyArg_ParseTuple(_args, "")) |
| 780 | return NULL; |
| 781 | _rv = CountTypes(); |
| 782 | { |
| 783 | OSErr _err = ResError(); |
| 784 | if (_err != noErr) return PyMac_Error(_err); |
| 785 | } |
| 786 | _res = Py_BuildValue("h", |
| 787 | _rv); |
| 788 | return _res; |
| 789 | } |
| 790 | |
| 791 | static PyObject *Res_Count1Types(_self, _args) |
| 792 | PyObject *_self; |
| 793 | PyObject *_args; |
| 794 | { |
| 795 | PyObject *_res = NULL; |
| 796 | short _rv; |
| 797 | if (!PyArg_ParseTuple(_args, "")) |
| 798 | return NULL; |
| 799 | _rv = Count1Types(); |
| 800 | { |
| 801 | OSErr _err = ResError(); |
| 802 | if (_err != noErr) return PyMac_Error(_err); |
| 803 | } |
| 804 | _res = Py_BuildValue("h", |
| 805 | _rv); |
| 806 | return _res; |
| 807 | } |
| 808 | |
| 809 | static PyObject *Res_GetIndType(_self, _args) |
| 810 | PyObject *_self; |
| 811 | PyObject *_args; |
| 812 | { |
| 813 | PyObject *_res = NULL; |
| 814 | ResType theType; |
| 815 | short index; |
| 816 | if (!PyArg_ParseTuple(_args, "h", |
| 817 | &index)) |
| 818 | return NULL; |
| 819 | GetIndType(&theType, |
| 820 | index); |
| 821 | { |
| 822 | OSErr _err = ResError(); |
| 823 | if (_err != noErr) return PyMac_Error(_err); |
| 824 | } |
| 825 | _res = Py_BuildValue("O&", |
| 826 | PyMac_BuildOSType, theType); |
| 827 | return _res; |
| 828 | } |
| 829 | |
| 830 | static PyObject *Res_Get1IndType(_self, _args) |
| 831 | PyObject *_self; |
| 832 | PyObject *_args; |
| 833 | { |
| 834 | PyObject *_res = NULL; |
| 835 | ResType theType; |
| 836 | short index; |
| 837 | if (!PyArg_ParseTuple(_args, "h", |
| 838 | &index)) |
| 839 | return NULL; |
| 840 | Get1IndType(&theType, |
| 841 | index); |
| 842 | { |
| 843 | OSErr _err = ResError(); |
| 844 | if (_err != noErr) return PyMac_Error(_err); |
| 845 | } |
| 846 | _res = Py_BuildValue("O&", |
| 847 | PyMac_BuildOSType, theType); |
| 848 | return _res; |
| 849 | } |
| 850 | |
| 851 | static PyObject *Res_SetResLoad(_self, _args) |
| 852 | PyObject *_self; |
| 853 | PyObject *_args; |
| 854 | { |
| 855 | PyObject *_res = NULL; |
| 856 | Boolean load; |
| 857 | if (!PyArg_ParseTuple(_args, "b", |
| 858 | &load)) |
| 859 | return NULL; |
| 860 | SetResLoad(load); |
| 861 | { |
| 862 | OSErr _err = ResError(); |
| 863 | if (_err != noErr) return PyMac_Error(_err); |
| 864 | } |
| 865 | Py_INCREF(Py_None); |
| 866 | _res = Py_None; |
| 867 | return _res; |
| 868 | } |
| 869 | |
| 870 | static PyObject *Res_CountResources(_self, _args) |
| 871 | PyObject *_self; |
| 872 | PyObject *_args; |
| 873 | { |
| 874 | PyObject *_res = NULL; |
| 875 | short _rv; |
| 876 | ResType theType; |
| 877 | if (!PyArg_ParseTuple(_args, "O&", |
| 878 | PyMac_GetOSType, &theType)) |
| 879 | return NULL; |
| 880 | _rv = CountResources(theType); |
| 881 | { |
| 882 | OSErr _err = ResError(); |
| 883 | if (_err != noErr) return PyMac_Error(_err); |
| 884 | } |
| 885 | _res = Py_BuildValue("h", |
| 886 | _rv); |
| 887 | return _res; |
| 888 | } |
| 889 | |
| 890 | static PyObject *Res_Count1Resources(_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 = Count1Resources(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_GetIndResource(_self, _args) |
| 911 | PyObject *_self; |
| 912 | PyObject *_args; |
| 913 | { |
| 914 | PyObject *_res = NULL; |
| 915 | Handle _rv; |
| 916 | ResType theType; |
| 917 | short index; |
| 918 | if (!PyArg_ParseTuple(_args, "O&h", |
| 919 | PyMac_GetOSType, &theType, |
| 920 | &index)) |
| 921 | return NULL; |
| 922 | _rv = GetIndResource(theType, |
| 923 | index); |
| 924 | { |
| 925 | OSErr _err = ResError(); |
| 926 | if (_err != noErr) return PyMac_Error(_err); |
| 927 | } |
| 928 | _res = Py_BuildValue("O&", |
| 929 | ResObj_New, _rv); |
| 930 | return _res; |
| 931 | } |
| 932 | |
| 933 | static PyObject *Res_Get1IndResource(_self, _args) |
| 934 | PyObject *_self; |
| 935 | PyObject *_args; |
| 936 | { |
| 937 | PyObject *_res = NULL; |
| 938 | Handle _rv; |
| 939 | ResType theType; |
| 940 | short index; |
| 941 | if (!PyArg_ParseTuple(_args, "O&h", |
| 942 | PyMac_GetOSType, &theType, |
| 943 | &index)) |
| 944 | return NULL; |
| 945 | _rv = Get1IndResource(theType, |
| 946 | index); |
| 947 | { |
| 948 | OSErr _err = ResError(); |
| 949 | if (_err != noErr) return PyMac_Error(_err); |
| 950 | } |
| 951 | _res = Py_BuildValue("O&", |
| 952 | ResObj_New, _rv); |
| 953 | return _res; |
| 954 | } |
| 955 | |
| 956 | static PyObject *Res_GetResource(_self, _args) |
| 957 | PyObject *_self; |
| 958 | PyObject *_args; |
| 959 | { |
| 960 | PyObject *_res = NULL; |
| 961 | Handle _rv; |
| 962 | ResType theType; |
| 963 | short theID; |
| 964 | if (!PyArg_ParseTuple(_args, "O&h", |
| 965 | PyMac_GetOSType, &theType, |
| 966 | &theID)) |
| 967 | return NULL; |
| 968 | _rv = GetResource(theType, |
| 969 | theID); |
| 970 | { |
| 971 | OSErr _err = ResError(); |
| 972 | if (_err != noErr) return PyMac_Error(_err); |
| 973 | } |
| 974 | _res = Py_BuildValue("O&", |
| 975 | ResObj_New, _rv); |
| 976 | return _res; |
| 977 | } |
| 978 | |
| 979 | static PyObject *Res_Get1Resource(_self, _args) |
| 980 | PyObject *_self; |
| 981 | PyObject *_args; |
| 982 | { |
| 983 | PyObject *_res = NULL; |
| 984 | Handle _rv; |
| 985 | ResType theType; |
| 986 | short theID; |
| 987 | if (!PyArg_ParseTuple(_args, "O&h", |
| 988 | PyMac_GetOSType, &theType, |
| 989 | &theID)) |
| 990 | return NULL; |
| 991 | _rv = Get1Resource(theType, |
| 992 | theID); |
| 993 | { |
| 994 | OSErr _err = ResError(); |
| 995 | if (_err != noErr) return PyMac_Error(_err); |
| 996 | } |
| 997 | _res = Py_BuildValue("O&", |
| 998 | ResObj_New, _rv); |
| 999 | return _res; |
| 1000 | } |
| 1001 | |
| 1002 | static PyObject *Res_GetNamedResource(_self, _args) |
| 1003 | PyObject *_self; |
| 1004 | PyObject *_args; |
| 1005 | { |
| 1006 | PyObject *_res = NULL; |
| 1007 | Handle _rv; |
| 1008 | ResType theType; |
| 1009 | Str255 name; |
| 1010 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 1011 | PyMac_GetOSType, &theType, |
| 1012 | PyMac_GetStr255, name)) |
| 1013 | return NULL; |
| 1014 | _rv = GetNamedResource(theType, |
| 1015 | name); |
| 1016 | { |
| 1017 | OSErr _err = ResError(); |
| 1018 | if (_err != noErr) return PyMac_Error(_err); |
| 1019 | } |
| 1020 | _res = Py_BuildValue("O&", |
| 1021 | ResObj_New, _rv); |
| 1022 | return _res; |
| 1023 | } |
| 1024 | |
| 1025 | static PyObject *Res_Get1NamedResource(_self, _args) |
| 1026 | PyObject *_self; |
| 1027 | PyObject *_args; |
| 1028 | { |
| 1029 | PyObject *_res = NULL; |
| 1030 | Handle _rv; |
| 1031 | ResType theType; |
| 1032 | Str255 name; |
| 1033 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 1034 | PyMac_GetOSType, &theType, |
| 1035 | PyMac_GetStr255, name)) |
| 1036 | return NULL; |
| 1037 | _rv = Get1NamedResource(theType, |
| 1038 | name); |
| 1039 | { |
| 1040 | OSErr _err = ResError(); |
| 1041 | if (_err != noErr) return PyMac_Error(_err); |
| 1042 | } |
| 1043 | _res = Py_BuildValue("O&", |
| 1044 | ResObj_New, _rv); |
| 1045 | return _res; |
| 1046 | } |
| 1047 | |
| 1048 | static PyObject *Res_UniqueID(_self, _args) |
| 1049 | PyObject *_self; |
| 1050 | PyObject *_args; |
| 1051 | { |
| 1052 | PyObject *_res = NULL; |
| 1053 | short _rv; |
| 1054 | ResType theType; |
| 1055 | if (!PyArg_ParseTuple(_args, "O&", |
| 1056 | PyMac_GetOSType, &theType)) |
| 1057 | return NULL; |
| 1058 | _rv = UniqueID(theType); |
| 1059 | { |
| 1060 | OSErr _err = ResError(); |
| 1061 | if (_err != noErr) return PyMac_Error(_err); |
| 1062 | } |
| 1063 | _res = Py_BuildValue("h", |
| 1064 | _rv); |
| 1065 | return _res; |
| 1066 | } |
| 1067 | |
| 1068 | static PyObject *Res_Unique1ID(_self, _args) |
| 1069 | PyObject *_self; |
| 1070 | PyObject *_args; |
| 1071 | { |
| 1072 | PyObject *_res = NULL; |
| 1073 | short _rv; |
| 1074 | ResType theType; |
| 1075 | if (!PyArg_ParseTuple(_args, "O&", |
| 1076 | PyMac_GetOSType, &theType)) |
| 1077 | return NULL; |
| 1078 | _rv = Unique1ID(theType); |
| 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_UpdateResFile(_self, _args) |
| 1089 | PyObject *_self; |
| 1090 | PyObject *_args; |
| 1091 | { |
| 1092 | PyObject *_res = NULL; |
| 1093 | short refNum; |
| 1094 | if (!PyArg_ParseTuple(_args, "h", |
| 1095 | &refNum)) |
| 1096 | return NULL; |
| 1097 | UpdateResFile(refNum); |
| 1098 | { |
| 1099 | OSErr _err = ResError(); |
| 1100 | if (_err != noErr) return PyMac_Error(_err); |
| 1101 | } |
| 1102 | Py_INCREF(Py_None); |
| 1103 | _res = Py_None; |
| 1104 | return _res; |
| 1105 | } |
| 1106 | |
| 1107 | static PyObject *Res_SetResPurge(_self, _args) |
| 1108 | PyObject *_self; |
| 1109 | PyObject *_args; |
| 1110 | { |
| 1111 | PyObject *_res = NULL; |
| 1112 | Boolean install; |
| 1113 | if (!PyArg_ParseTuple(_args, "b", |
| 1114 | &install)) |
| 1115 | return NULL; |
| 1116 | SetResPurge(install); |
| 1117 | { |
| 1118 | OSErr _err = ResError(); |
| 1119 | if (_err != noErr) return PyMac_Error(_err); |
| 1120 | } |
| 1121 | Py_INCREF(Py_None); |
| 1122 | _res = Py_None; |
| 1123 | return _res; |
| 1124 | } |
| 1125 | |
| 1126 | static PyObject *Res_GetResFileAttrs(_self, _args) |
| 1127 | PyObject *_self; |
| 1128 | PyObject *_args; |
| 1129 | { |
| 1130 | PyObject *_res = NULL; |
| 1131 | short _rv; |
| 1132 | short refNum; |
| 1133 | if (!PyArg_ParseTuple(_args, "h", |
| 1134 | &refNum)) |
| 1135 | return NULL; |
| 1136 | _rv = GetResFileAttrs(refNum); |
| 1137 | { |
| 1138 | OSErr _err = ResError(); |
| 1139 | if (_err != noErr) return PyMac_Error(_err); |
| 1140 | } |
| 1141 | _res = Py_BuildValue("h", |
| 1142 | _rv); |
| 1143 | return _res; |
| 1144 | } |
| 1145 | |
| 1146 | static PyObject *Res_SetResFileAttrs(_self, _args) |
| 1147 | PyObject *_self; |
| 1148 | PyObject *_args; |
| 1149 | { |
| 1150 | PyObject *_res = NULL; |
| 1151 | short refNum; |
| 1152 | short attrs; |
| 1153 | if (!PyArg_ParseTuple(_args, "hh", |
| 1154 | &refNum, |
| 1155 | &attrs)) |
| 1156 | return NULL; |
| 1157 | SetResFileAttrs(refNum, |
| 1158 | attrs); |
| 1159 | { |
| 1160 | OSErr _err = ResError(); |
| 1161 | if (_err != noErr) return PyMac_Error(_err); |
| 1162 | } |
| 1163 | Py_INCREF(Py_None); |
| 1164 | _res = Py_None; |
| 1165 | return _res; |
| 1166 | } |
| 1167 | |
| 1168 | static PyObject *Res_OpenRFPerm(_self, _args) |
| 1169 | PyObject *_self; |
| 1170 | PyObject *_args; |
| 1171 | { |
| 1172 | PyObject *_res = NULL; |
| 1173 | short _rv; |
| 1174 | Str255 fileName; |
| 1175 | short vRefNum; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 1176 | SignedByte permission; |
| 1177 | if (!PyArg_ParseTuple(_args, "O&hb", |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1178 | PyMac_GetStr255, fileName, |
| 1179 | &vRefNum, |
| 1180 | &permission)) |
| 1181 | return NULL; |
| 1182 | _rv = OpenRFPerm(fileName, |
| 1183 | vRefNum, |
| 1184 | permission); |
| 1185 | { |
| 1186 | OSErr _err = ResError(); |
| 1187 | if (_err != noErr) return PyMac_Error(_err); |
| 1188 | } |
| 1189 | _res = Py_BuildValue("h", |
| 1190 | _rv); |
| 1191 | return _res; |
| 1192 | } |
| 1193 | |
| 1194 | static PyObject *Res_RGetResource(_self, _args) |
| 1195 | PyObject *_self; |
| 1196 | PyObject *_args; |
| 1197 | { |
| 1198 | PyObject *_res = NULL; |
| 1199 | Handle _rv; |
| 1200 | ResType theType; |
| 1201 | short theID; |
| 1202 | if (!PyArg_ParseTuple(_args, "O&h", |
| 1203 | PyMac_GetOSType, &theType, |
| 1204 | &theID)) |
| 1205 | return NULL; |
| 1206 | _rv = RGetResource(theType, |
| 1207 | theID); |
| 1208 | { |
| 1209 | OSErr _err = ResError(); |
| 1210 | if (_err != noErr) return PyMac_Error(_err); |
| 1211 | } |
| 1212 | _res = Py_BuildValue("O&", |
| 1213 | ResObj_New, _rv); |
| 1214 | return _res; |
| 1215 | } |
| 1216 | |
| 1217 | static PyObject *Res_HOpenResFile(_self, _args) |
| 1218 | PyObject *_self; |
| 1219 | PyObject *_args; |
| 1220 | { |
| 1221 | PyObject *_res = NULL; |
| 1222 | short _rv; |
| 1223 | short vRefNum; |
| 1224 | long dirID; |
| 1225 | Str255 fileName; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 1226 | SignedByte permission; |
| 1227 | if (!PyArg_ParseTuple(_args, "hlO&b", |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1228 | &vRefNum, |
| 1229 | &dirID, |
| 1230 | PyMac_GetStr255, fileName, |
| 1231 | &permission)) |
| 1232 | return NULL; |
| 1233 | _rv = HOpenResFile(vRefNum, |
| 1234 | dirID, |
| 1235 | fileName, |
| 1236 | permission); |
| 1237 | { |
| 1238 | OSErr _err = ResError(); |
| 1239 | if (_err != noErr) return PyMac_Error(_err); |
| 1240 | } |
| 1241 | _res = Py_BuildValue("h", |
| 1242 | _rv); |
| 1243 | return _res; |
| 1244 | } |
| 1245 | |
| 1246 | static PyObject *Res_HCreateResFile(_self, _args) |
| 1247 | PyObject *_self; |
| 1248 | PyObject *_args; |
| 1249 | { |
| 1250 | PyObject *_res = NULL; |
| 1251 | short vRefNum; |
| 1252 | long dirID; |
| 1253 | Str255 fileName; |
| 1254 | if (!PyArg_ParseTuple(_args, "hlO&", |
| 1255 | &vRefNum, |
| 1256 | &dirID, |
| 1257 | PyMac_GetStr255, fileName)) |
| 1258 | return NULL; |
| 1259 | HCreateResFile(vRefNum, |
| 1260 | dirID, |
| 1261 | fileName); |
| 1262 | { |
| 1263 | OSErr _err = ResError(); |
| 1264 | if (_err != noErr) return PyMac_Error(_err); |
| 1265 | } |
| 1266 | Py_INCREF(Py_None); |
| 1267 | _res = Py_None; |
| 1268 | return _res; |
| 1269 | } |
| 1270 | |
| 1271 | static PyObject *Res_FSpOpenResFile(_self, _args) |
| 1272 | PyObject *_self; |
| 1273 | PyObject *_args; |
| 1274 | { |
| 1275 | PyObject *_res = NULL; |
| 1276 | short _rv; |
| 1277 | FSSpec spec; |
| 1278 | SignedByte permission; |
| 1279 | if (!PyArg_ParseTuple(_args, "O&b", |
| 1280 | PyMac_GetFSSpec, &spec, |
| 1281 | &permission)) |
| 1282 | return NULL; |
| 1283 | _rv = FSpOpenResFile(&spec, |
| 1284 | permission); |
| 1285 | { |
| 1286 | OSErr _err = ResError(); |
| 1287 | if (_err != noErr) return PyMac_Error(_err); |
| 1288 | } |
| 1289 | _res = Py_BuildValue("h", |
| 1290 | _rv); |
| 1291 | return _res; |
| 1292 | } |
| 1293 | |
| 1294 | static PyObject *Res_FSpCreateResFile(_self, _args) |
| 1295 | PyObject *_self; |
| 1296 | PyObject *_args; |
| 1297 | { |
| 1298 | PyObject *_res = NULL; |
| 1299 | FSSpec spec; |
| 1300 | OSType creator; |
| 1301 | OSType fileType; |
| 1302 | ScriptCode scriptTag; |
| 1303 | if (!PyArg_ParseTuple(_args, "O&O&O&h", |
| 1304 | PyMac_GetFSSpec, &spec, |
| 1305 | PyMac_GetOSType, &creator, |
| 1306 | PyMac_GetOSType, &fileType, |
| 1307 | &scriptTag)) |
| 1308 | return NULL; |
| 1309 | FSpCreateResFile(&spec, |
| 1310 | creator, |
| 1311 | fileType, |
| 1312 | scriptTag); |
| 1313 | { |
| 1314 | OSErr _err = ResError(); |
| 1315 | if (_err != noErr) return PyMac_Error(_err); |
| 1316 | } |
| 1317 | Py_INCREF(Py_None); |
| 1318 | _res = Py_None; |
| 1319 | return _res; |
| 1320 | } |
| 1321 | |
Guido van Rossum | 9bcb641 | 1995-02-05 16:54:27 +0000 | [diff] [blame] | 1322 | static PyObject *Res_Resource(_self, _args) |
| 1323 | PyObject *_self; |
| 1324 | PyObject *_args; |
| 1325 | { |
| 1326 | PyObject *_res = NULL; |
| 1327 | |
| 1328 | char *buf; |
| 1329 | int len; |
| 1330 | Handle h; |
| 1331 | |
| 1332 | if (!PyArg_ParseTuple(_args, "s#", &buf, &len)) |
| 1333 | return NULL; |
| 1334 | h = NewHandle(len); |
| 1335 | if ( h == NULL ) { |
| 1336 | PyErr_NoMemory(); |
| 1337 | return NULL; |
| 1338 | } |
| 1339 | HLock(h); |
| 1340 | memcpy(*h, buf, len); |
| 1341 | HUnlock(h); |
Jack Jansen | add03b6 | 2000-03-08 16:58:15 +0000 | [diff] [blame^] | 1342 | return ResObj_New(h); |
| 1343 | |
| 1344 | } |
| 1345 | |
| 1346 | static PyObject *Res_Handle(_self, _args) |
| 1347 | PyObject *_self; |
| 1348 | PyObject *_args; |
| 1349 | { |
| 1350 | PyObject *_res = NULL; |
| 1351 | |
| 1352 | char *buf; |
| 1353 | int len; |
| 1354 | Handle h; |
| 1355 | ResourceObject *rv; |
| 1356 | |
| 1357 | if (!PyArg_ParseTuple(_args, "s#", &buf, &len)) |
| 1358 | return NULL; |
| 1359 | h = NewHandle(len); |
| 1360 | if ( h == NULL ) { |
| 1361 | PyErr_NoMemory(); |
| 1362 | return NULL; |
| 1363 | } |
| 1364 | HLock(h); |
| 1365 | memcpy(*h, buf, len); |
| 1366 | HUnlock(h); |
| 1367 | rv = (ResourceObject *)ResObj_New(h); |
| 1368 | rv->ob_freeit = PyMac_AutoDisposeHandle; |
| 1369 | return (PyObject *)rv; |
Guido van Rossum | 9bcb641 | 1995-02-05 16:54:27 +0000 | [diff] [blame] | 1370 | |
| 1371 | } |
| 1372 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1373 | static PyMethodDef Res_methods[] = { |
| 1374 | {"InitResources", (PyCFunction)Res_InitResources, 1, |
| 1375 | "() -> (short _rv)"}, |
| 1376 | {"RsrcZoneInit", (PyCFunction)Res_RsrcZoneInit, 1, |
| 1377 | "() -> None"}, |
| 1378 | {"CloseResFile", (PyCFunction)Res_CloseResFile, 1, |
| 1379 | "(short refNum) -> None"}, |
| 1380 | {"ResError", (PyCFunction)Res_ResError, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1381 | "() -> (OSErr _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1382 | {"CurResFile", (PyCFunction)Res_CurResFile, 1, |
| 1383 | "() -> (short _rv)"}, |
| 1384 | {"CreateResFile", (PyCFunction)Res_CreateResFile, 1, |
| 1385 | "(Str255 fileName) -> None"}, |
| 1386 | {"OpenResFile", (PyCFunction)Res_OpenResFile, 1, |
| 1387 | "(Str255 fileName) -> (short _rv)"}, |
| 1388 | {"UseResFile", (PyCFunction)Res_UseResFile, 1, |
| 1389 | "(short refNum) -> None"}, |
| 1390 | {"CountTypes", (PyCFunction)Res_CountTypes, 1, |
| 1391 | "() -> (short _rv)"}, |
| 1392 | {"Count1Types", (PyCFunction)Res_Count1Types, 1, |
| 1393 | "() -> (short _rv)"}, |
| 1394 | {"GetIndType", (PyCFunction)Res_GetIndType, 1, |
| 1395 | "(short index) -> (ResType theType)"}, |
| 1396 | {"Get1IndType", (PyCFunction)Res_Get1IndType, 1, |
| 1397 | "(short index) -> (ResType theType)"}, |
| 1398 | {"SetResLoad", (PyCFunction)Res_SetResLoad, 1, |
| 1399 | "(Boolean load) -> None"}, |
| 1400 | {"CountResources", (PyCFunction)Res_CountResources, 1, |
| 1401 | "(ResType theType) -> (short _rv)"}, |
| 1402 | {"Count1Resources", (PyCFunction)Res_Count1Resources, 1, |
| 1403 | "(ResType theType) -> (short _rv)"}, |
| 1404 | {"GetIndResource", (PyCFunction)Res_GetIndResource, 1, |
| 1405 | "(ResType theType, short index) -> (Handle _rv)"}, |
| 1406 | {"Get1IndResource", (PyCFunction)Res_Get1IndResource, 1, |
| 1407 | "(ResType theType, short index) -> (Handle _rv)"}, |
| 1408 | {"GetResource", (PyCFunction)Res_GetResource, 1, |
| 1409 | "(ResType theType, short theID) -> (Handle _rv)"}, |
| 1410 | {"Get1Resource", (PyCFunction)Res_Get1Resource, 1, |
| 1411 | "(ResType theType, short theID) -> (Handle _rv)"}, |
| 1412 | {"GetNamedResource", (PyCFunction)Res_GetNamedResource, 1, |
| 1413 | "(ResType theType, Str255 name) -> (Handle _rv)"}, |
| 1414 | {"Get1NamedResource", (PyCFunction)Res_Get1NamedResource, 1, |
| 1415 | "(ResType theType, Str255 name) -> (Handle _rv)"}, |
| 1416 | {"UniqueID", (PyCFunction)Res_UniqueID, 1, |
| 1417 | "(ResType theType) -> (short _rv)"}, |
| 1418 | {"Unique1ID", (PyCFunction)Res_Unique1ID, 1, |
| 1419 | "(ResType theType) -> (short _rv)"}, |
| 1420 | {"UpdateResFile", (PyCFunction)Res_UpdateResFile, 1, |
| 1421 | "(short refNum) -> None"}, |
| 1422 | {"SetResPurge", (PyCFunction)Res_SetResPurge, 1, |
| 1423 | "(Boolean install) -> None"}, |
| 1424 | {"GetResFileAttrs", (PyCFunction)Res_GetResFileAttrs, 1, |
| 1425 | "(short refNum) -> (short _rv)"}, |
| 1426 | {"SetResFileAttrs", (PyCFunction)Res_SetResFileAttrs, 1, |
| 1427 | "(short refNum, short attrs) -> None"}, |
| 1428 | {"OpenRFPerm", (PyCFunction)Res_OpenRFPerm, 1, |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 1429 | "(Str255 fileName, short vRefNum, SignedByte permission) -> (short _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1430 | {"RGetResource", (PyCFunction)Res_RGetResource, 1, |
| 1431 | "(ResType theType, short theID) -> (Handle _rv)"}, |
| 1432 | {"HOpenResFile", (PyCFunction)Res_HOpenResFile, 1, |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 1433 | "(short vRefNum, long dirID, Str255 fileName, SignedByte permission) -> (short _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1434 | {"HCreateResFile", (PyCFunction)Res_HCreateResFile, 1, |
| 1435 | "(short vRefNum, long dirID, Str255 fileName) -> None"}, |
| 1436 | {"FSpOpenResFile", (PyCFunction)Res_FSpOpenResFile, 1, |
| 1437 | "(FSSpec spec, SignedByte permission) -> (short _rv)"}, |
| 1438 | {"FSpCreateResFile", (PyCFunction)Res_FSpCreateResFile, 1, |
| 1439 | "(FSSpec spec, OSType creator, OSType fileType, ScriptCode scriptTag) -> None"}, |
Guido van Rossum | 9bcb641 | 1995-02-05 16:54:27 +0000 | [diff] [blame] | 1440 | {"Resource", (PyCFunction)Res_Resource, 1, |
Jack Jansen | add03b6 | 2000-03-08 16:58:15 +0000 | [diff] [blame^] | 1441 | "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.\nSee also the Handle() docstring.\n"}, |
| 1442 | {"Handle", (PyCFunction)Res_Handle, 1, |
| 1443 | "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"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1444 | {NULL, NULL, 0} |
| 1445 | }; |
| 1446 | |
| 1447 | |
| 1448 | |
| 1449 | |
Jack Jansen | d4c2646 | 1995-08-17 14:35:56 +0000 | [diff] [blame] | 1450 | /* Alternative version of ResObj_New, which returns None for null argument */ |
Jack Jansen | 425e9eb | 1995-12-12 15:02:03 +0000 | [diff] [blame] | 1451 | PyObject *OptResObj_New(itself) |
Jack Jansen | d4c2646 | 1995-08-17 14:35:56 +0000 | [diff] [blame] | 1452 | Handle itself; |
| 1453 | { |
Jack Jansen | d4c2646 | 1995-08-17 14:35:56 +0000 | [diff] [blame] | 1454 | if (itself == NULL) { |
| 1455 | Py_INCREF(Py_None); |
| 1456 | return Py_None; |
| 1457 | } |
| 1458 | return ResObj_New(itself); |
| 1459 | } |
| 1460 | |
Jack Jansen | 425e9eb | 1995-12-12 15:02:03 +0000 | [diff] [blame] | 1461 | OptResObj_Convert(v, p_itself) |
| 1462 | PyObject *v; |
| 1463 | Handle *p_itself; |
| 1464 | { |
Jack Jansen | 2d76c25 | 1999-12-12 22:57:29 +0000 | [diff] [blame] | 1465 | PyObject *tmp; |
| 1466 | |
Jack Jansen | 425e9eb | 1995-12-12 15:02:03 +0000 | [diff] [blame] | 1467 | if ( v == Py_None ) { |
| 1468 | *p_itself = NULL; |
| 1469 | return 1; |
| 1470 | } |
Jack Jansen | 2d76c25 | 1999-12-12 22:57:29 +0000 | [diff] [blame] | 1471 | if (ResObj_Check(v)) |
Jack Jansen | 425e9eb | 1995-12-12 15:02:03 +0000 | [diff] [blame] | 1472 | { |
Jack Jansen | 2d76c25 | 1999-12-12 22:57:29 +0000 | [diff] [blame] | 1473 | *p_itself = ((ResourceObject *)v)->ob_itself; |
| 1474 | return 1; |
Jack Jansen | 425e9eb | 1995-12-12 15:02:03 +0000 | [diff] [blame] | 1475 | } |
Jack Jansen | 2d76c25 | 1999-12-12 22:57:29 +0000 | [diff] [blame] | 1476 | /* If it isn't a resource yet see whether it is convertible */ |
| 1477 | if ( (tmp=PyObject_CallMethod(v, "as_Resource", "")) ) { |
| 1478 | *p_itself = ((ResourceObject *)tmp)->ob_itself; |
| 1479 | Py_DECREF(tmp); |
| 1480 | return 1; |
| 1481 | } |
| 1482 | PyErr_Clear(); |
| 1483 | PyErr_SetString(PyExc_TypeError, "Resource required"); |
| 1484 | return 0; |
Jack Jansen | 425e9eb | 1995-12-12 15:02:03 +0000 | [diff] [blame] | 1485 | } |
| 1486 | |
Jack Jansen | d4c2646 | 1995-08-17 14:35:56 +0000 | [diff] [blame] | 1487 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1488 | void initRes() |
| 1489 | { |
| 1490 | PyObject *m; |
| 1491 | PyObject *d; |
| 1492 | |
| 1493 | |
| 1494 | |
| 1495 | |
| 1496 | |
| 1497 | m = Py_InitModule("Res", Res_methods); |
| 1498 | d = PyModule_GetDict(m); |
| 1499 | Res_Error = PyMac_GetOSErrException(); |
| 1500 | if (Res_Error == NULL || |
| 1501 | PyDict_SetItemString(d, "Error", Res_Error) != 0) |
| 1502 | Py_FatalError("can't initialize Res.Error"); |
Jack Jansen | a755e68 | 1997-09-20 17:40:22 +0000 | [diff] [blame] | 1503 | Resource_Type.ob_type = &PyType_Type; |
| 1504 | Py_INCREF(&Resource_Type); |
| 1505 | if (PyDict_SetItemString(d, "ResourceType", (PyObject *)&Resource_Type) != 0) |
| 1506 | Py_FatalError("can't initialize ResourceType"); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1507 | } |
| 1508 | |
| 1509 | /* ========================= End module Res ========================= */ |
| 1510 | |