Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 1 | |
| 2 | /* =========================== Module Cm ============================ */ |
| 3 | |
| 4 | #include "Python.h" |
| 5 | |
| 6 | |
| 7 | |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 8 | #include "macglue.h" |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 9 | #include "pymactoolbox.h" |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 10 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 11 | #ifdef WITHOUT_FRAMEWORKS |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 12 | #include <Components.h> |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 13 | #else |
| 14 | #include <Carbon/Carbon.h> |
| 15 | #endif |
| 16 | |
Jack Jansen | 0e04eec | 2001-05-17 21:58:34 +0000 | [diff] [blame] | 17 | #ifdef USE_TOOLBOX_OBJECT_GLUE |
| 18 | extern PyObject *_CmpObj_New(Component); |
| 19 | extern int _CmpObj_Convert(PyObject *, Component *); |
| 20 | extern PyObject *_CmpInstObj_New(ComponentInstance); |
| 21 | extern int _CmpInstObj_Convert(PyObject *, ComponentInstance *); |
| 22 | |
| 23 | #define CmpObj_New _CmpObj_New |
| 24 | #define CmpObj_Convert _CmpObj_Convert |
| 25 | #define CmpInstObj_New _CmpInstObj_New |
| 26 | #define CmpInstObj_Convert _CmpInstObj_Convert |
| 27 | #endif |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 28 | |
| 29 | /* |
| 30 | ** Parse/generate ComponentDescriptor records |
| 31 | */ |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 32 | static PyObject * |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 33 | CmpDesc_New(ComponentDescription *itself) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 34 | { |
| 35 | |
| 36 | return Py_BuildValue("O&O&O&ll", |
| 37 | PyMac_BuildOSType, itself->componentType, |
| 38 | PyMac_BuildOSType, itself->componentSubType, |
| 39 | PyMac_BuildOSType, itself->componentManufacturer, |
| 40 | itself->componentFlags, itself->componentFlagsMask); |
| 41 | } |
| 42 | |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 43 | static int |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 44 | CmpDesc_Convert(PyObject *v, ComponentDescription *p_itself) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 45 | { |
| 46 | return PyArg_ParseTuple(v, "O&O&O&ll", |
| 47 | PyMac_GetOSType, &p_itself->componentType, |
| 48 | PyMac_GetOSType, &p_itself->componentSubType, |
| 49 | PyMac_GetOSType, &p_itself->componentManufacturer, |
| 50 | &p_itself->componentFlags, &p_itself->componentFlagsMask); |
| 51 | } |
| 52 | |
| 53 | |
| 54 | static PyObject *Cm_Error; |
| 55 | |
| 56 | /* ----------------- Object type ComponentInstance ------------------ */ |
| 57 | |
| 58 | PyTypeObject ComponentInstance_Type; |
| 59 | |
| 60 | #define CmpInstObj_Check(x) ((x)->ob_type == &ComponentInstance_Type) |
| 61 | |
| 62 | typedef struct ComponentInstanceObject { |
| 63 | PyObject_HEAD |
| 64 | ComponentInstance ob_itself; |
| 65 | } ComponentInstanceObject; |
| 66 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 67 | PyObject *CmpInstObj_New(ComponentInstance itself) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 68 | { |
| 69 | ComponentInstanceObject *it; |
| 70 | if (itself == NULL) { |
| 71 | PyErr_SetString(Cm_Error,"NULL ComponentInstance"); |
| 72 | return NULL; |
| 73 | } |
| 74 | it = PyObject_NEW(ComponentInstanceObject, &ComponentInstance_Type); |
| 75 | if (it == NULL) return NULL; |
| 76 | it->ob_itself = itself; |
| 77 | return (PyObject *)it; |
| 78 | } |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 79 | CmpInstObj_Convert(PyObject *v, ComponentInstance *p_itself) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 80 | { |
| 81 | if (!CmpInstObj_Check(v)) |
| 82 | { |
| 83 | PyErr_SetString(PyExc_TypeError, "ComponentInstance required"); |
| 84 | return 0; |
| 85 | } |
| 86 | *p_itself = ((ComponentInstanceObject *)v)->ob_itself; |
| 87 | return 1; |
| 88 | } |
| 89 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 90 | static void CmpInstObj_dealloc(ComponentInstanceObject *self) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 91 | { |
| 92 | /* Cleanup of self->ob_itself goes here */ |
| 93 | PyMem_DEL(self); |
| 94 | } |
| 95 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 96 | static PyObject *CmpInstObj_CloseComponent(ComponentInstanceObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 97 | { |
| 98 | PyObject *_res = NULL; |
| 99 | OSErr _err; |
| 100 | if (!PyArg_ParseTuple(_args, "")) |
| 101 | return NULL; |
| 102 | _err = CloseComponent(_self->ob_itself); |
| 103 | if (_err != noErr) return PyMac_Error(_err); |
| 104 | Py_INCREF(Py_None); |
| 105 | _res = Py_None; |
| 106 | return _res; |
| 107 | } |
| 108 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 109 | static PyObject *CmpInstObj_GetComponentInstanceError(ComponentInstanceObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 110 | { |
| 111 | PyObject *_res = NULL; |
| 112 | OSErr _err; |
| 113 | if (!PyArg_ParseTuple(_args, "")) |
| 114 | return NULL; |
| 115 | _err = GetComponentInstanceError(_self->ob_itself); |
| 116 | if (_err != noErr) return PyMac_Error(_err); |
| 117 | Py_INCREF(Py_None); |
| 118 | _res = Py_None; |
| 119 | return _res; |
| 120 | } |
| 121 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 122 | static PyObject *CmpInstObj_SetComponentInstanceError(ComponentInstanceObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 123 | { |
| 124 | PyObject *_res = NULL; |
| 125 | OSErr theError; |
| 126 | if (!PyArg_ParseTuple(_args, "h", |
| 127 | &theError)) |
| 128 | return NULL; |
| 129 | SetComponentInstanceError(_self->ob_itself, |
| 130 | theError); |
| 131 | Py_INCREF(Py_None); |
| 132 | _res = Py_None; |
| 133 | return _res; |
| 134 | } |
| 135 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 136 | static PyObject *CmpInstObj_GetComponentInstanceStorage(ComponentInstanceObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 137 | { |
| 138 | PyObject *_res = NULL; |
| 139 | Handle _rv; |
| 140 | if (!PyArg_ParseTuple(_args, "")) |
| 141 | return NULL; |
| 142 | _rv = GetComponentInstanceStorage(_self->ob_itself); |
| 143 | _res = Py_BuildValue("O&", |
| 144 | ResObj_New, _rv); |
| 145 | return _res; |
| 146 | } |
| 147 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 148 | static PyObject *CmpInstObj_SetComponentInstanceStorage(ComponentInstanceObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 149 | { |
| 150 | PyObject *_res = NULL; |
| 151 | Handle theStorage; |
| 152 | if (!PyArg_ParseTuple(_args, "O&", |
| 153 | ResObj_Convert, &theStorage)) |
| 154 | return NULL; |
| 155 | SetComponentInstanceStorage(_self->ob_itself, |
| 156 | theStorage); |
| 157 | Py_INCREF(Py_None); |
| 158 | _res = Py_None; |
| 159 | return _res; |
| 160 | } |
| 161 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 162 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 8d929ae | 2000-06-21 22:07:06 +0000 | [diff] [blame] | 163 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 164 | static PyObject *CmpInstObj_GetComponentInstanceA5(ComponentInstanceObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 165 | { |
| 166 | PyObject *_res = NULL; |
| 167 | long _rv; |
| 168 | if (!PyArg_ParseTuple(_args, "")) |
| 169 | return NULL; |
| 170 | _rv = GetComponentInstanceA5(_self->ob_itself); |
| 171 | _res = Py_BuildValue("l", |
| 172 | _rv); |
| 173 | return _res; |
| 174 | } |
Jack Jansen | 8d929ae | 2000-06-21 22:07:06 +0000 | [diff] [blame] | 175 | #endif |
| 176 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 177 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 178 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 179 | static PyObject *CmpInstObj_SetComponentInstanceA5(ComponentInstanceObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 180 | { |
| 181 | PyObject *_res = NULL; |
| 182 | long theA5; |
| 183 | if (!PyArg_ParseTuple(_args, "l", |
| 184 | &theA5)) |
| 185 | return NULL; |
| 186 | SetComponentInstanceA5(_self->ob_itself, |
| 187 | theA5); |
| 188 | Py_INCREF(Py_None); |
| 189 | _res = Py_None; |
| 190 | return _res; |
| 191 | } |
Jack Jansen | 8d929ae | 2000-06-21 22:07:06 +0000 | [diff] [blame] | 192 | #endif |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 193 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 194 | static PyObject *CmpInstObj_ComponentFunctionImplemented(ComponentInstanceObject *_self, PyObject *_args) |
Jack Jansen | 4a8c54e | 1997-02-24 13:56:59 +0000 | [diff] [blame] | 195 | { |
| 196 | PyObject *_res = NULL; |
| 197 | long _rv; |
| 198 | short ftnNumber; |
| 199 | if (!PyArg_ParseTuple(_args, "h", |
| 200 | &ftnNumber)) |
| 201 | return NULL; |
| 202 | _rv = ComponentFunctionImplemented(_self->ob_itself, |
| 203 | ftnNumber); |
| 204 | _res = Py_BuildValue("l", |
| 205 | _rv); |
| 206 | return _res; |
| 207 | } |
| 208 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 209 | static PyObject *CmpInstObj_GetComponentVersion(ComponentInstanceObject *_self, PyObject *_args) |
Jack Jansen | 4a8c54e | 1997-02-24 13:56:59 +0000 | [diff] [blame] | 210 | { |
| 211 | PyObject *_res = NULL; |
| 212 | long _rv; |
| 213 | if (!PyArg_ParseTuple(_args, "")) |
| 214 | return NULL; |
| 215 | _rv = GetComponentVersion(_self->ob_itself); |
| 216 | _res = Py_BuildValue("l", |
| 217 | _rv); |
| 218 | return _res; |
| 219 | } |
| 220 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 221 | static PyObject *CmpInstObj_ComponentSetTarget(ComponentInstanceObject *_self, PyObject *_args) |
Jack Jansen | 4a8c54e | 1997-02-24 13:56:59 +0000 | [diff] [blame] | 222 | { |
| 223 | PyObject *_res = NULL; |
| 224 | long _rv; |
| 225 | ComponentInstance target; |
| 226 | if (!PyArg_ParseTuple(_args, "O&", |
| 227 | CmpInstObj_Convert, &target)) |
| 228 | return NULL; |
| 229 | _rv = ComponentSetTarget(_self->ob_itself, |
| 230 | target); |
| 231 | _res = Py_BuildValue("l", |
| 232 | _rv); |
| 233 | return _res; |
| 234 | } |
| 235 | |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 236 | static PyMethodDef CmpInstObj_methods[] = { |
| 237 | {"CloseComponent", (PyCFunction)CmpInstObj_CloseComponent, 1, |
| 238 | "() -> None"}, |
| 239 | {"GetComponentInstanceError", (PyCFunction)CmpInstObj_GetComponentInstanceError, 1, |
| 240 | "() -> None"}, |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 241 | {"SetComponentInstanceError", (PyCFunction)CmpInstObj_SetComponentInstanceError, 1, |
| 242 | "(OSErr theError) -> None"}, |
| 243 | {"GetComponentInstanceStorage", (PyCFunction)CmpInstObj_GetComponentInstanceStorage, 1, |
| 244 | "() -> (Handle _rv)"}, |
| 245 | {"SetComponentInstanceStorage", (PyCFunction)CmpInstObj_SetComponentInstanceStorage, 1, |
| 246 | "(Handle theStorage) -> None"}, |
Jack Jansen | 8d929ae | 2000-06-21 22:07:06 +0000 | [diff] [blame] | 247 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 248 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 249 | {"GetComponentInstanceA5", (PyCFunction)CmpInstObj_GetComponentInstanceA5, 1, |
| 250 | "() -> (long _rv)"}, |
Jack Jansen | 8d929ae | 2000-06-21 22:07:06 +0000 | [diff] [blame] | 251 | #endif |
| 252 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 253 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 254 | {"SetComponentInstanceA5", (PyCFunction)CmpInstObj_SetComponentInstanceA5, 1, |
| 255 | "(long theA5) -> None"}, |
Jack Jansen | 8d929ae | 2000-06-21 22:07:06 +0000 | [diff] [blame] | 256 | #endif |
Jack Jansen | 4a8c54e | 1997-02-24 13:56:59 +0000 | [diff] [blame] | 257 | {"ComponentFunctionImplemented", (PyCFunction)CmpInstObj_ComponentFunctionImplemented, 1, |
| 258 | "(short ftnNumber) -> (long _rv)"}, |
| 259 | {"GetComponentVersion", (PyCFunction)CmpInstObj_GetComponentVersion, 1, |
| 260 | "() -> (long _rv)"}, |
| 261 | {"ComponentSetTarget", (PyCFunction)CmpInstObj_ComponentSetTarget, 1, |
| 262 | "(ComponentInstance target) -> (long _rv)"}, |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 263 | {NULL, NULL, 0} |
| 264 | }; |
| 265 | |
| 266 | PyMethodChain CmpInstObj_chain = { CmpInstObj_methods, NULL }; |
| 267 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 268 | static PyObject *CmpInstObj_getattr(ComponentInstanceObject *self, char *name) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 269 | { |
| 270 | return Py_FindMethodInChain(&CmpInstObj_chain, (PyObject *)self, name); |
| 271 | } |
| 272 | |
| 273 | #define CmpInstObj_setattr NULL |
| 274 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 275 | #define CmpInstObj_compare NULL |
| 276 | |
| 277 | #define CmpInstObj_repr NULL |
| 278 | |
| 279 | #define CmpInstObj_hash NULL |
| 280 | |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 281 | PyTypeObject ComponentInstance_Type = { |
| 282 | PyObject_HEAD_INIT(&PyType_Type) |
| 283 | 0, /*ob_size*/ |
| 284 | "ComponentInstance", /*tp_name*/ |
| 285 | sizeof(ComponentInstanceObject), /*tp_basicsize*/ |
| 286 | 0, /*tp_itemsize*/ |
| 287 | /* methods */ |
| 288 | (destructor) CmpInstObj_dealloc, /*tp_dealloc*/ |
| 289 | 0, /*tp_print*/ |
| 290 | (getattrfunc) CmpInstObj_getattr, /*tp_getattr*/ |
| 291 | (setattrfunc) CmpInstObj_setattr, /*tp_setattr*/ |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 292 | (cmpfunc) CmpInstObj_compare, /*tp_compare*/ |
| 293 | (reprfunc) CmpInstObj_repr, /*tp_repr*/ |
| 294 | (PyNumberMethods *)0, /* tp_as_number */ |
| 295 | (PySequenceMethods *)0, /* tp_as_sequence */ |
| 296 | (PyMappingMethods *)0, /* tp_as_mapping */ |
| 297 | (hashfunc) CmpInstObj_hash, /*tp_hash*/ |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 298 | }; |
| 299 | |
| 300 | /* --------------- End object type ComponentInstance ---------------- */ |
| 301 | |
| 302 | |
| 303 | /* --------------------- Object type Component ---------------------- */ |
| 304 | |
| 305 | PyTypeObject Component_Type; |
| 306 | |
| 307 | #define CmpObj_Check(x) ((x)->ob_type == &Component_Type) |
| 308 | |
| 309 | typedef struct ComponentObject { |
| 310 | PyObject_HEAD |
| 311 | Component ob_itself; |
| 312 | } ComponentObject; |
| 313 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 314 | PyObject *CmpObj_New(Component itself) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 315 | { |
| 316 | ComponentObject *it; |
| 317 | if (itself == NULL) { |
| 318 | /* XXXX Or should we return None? */ |
| 319 | PyErr_SetString(Cm_Error,"No such component"); |
| 320 | return NULL; |
| 321 | } |
| 322 | it = PyObject_NEW(ComponentObject, &Component_Type); |
| 323 | if (it == NULL) return NULL; |
| 324 | it->ob_itself = itself; |
| 325 | return (PyObject *)it; |
| 326 | } |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 327 | CmpObj_Convert(PyObject *v, Component *p_itself) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 328 | { |
| 329 | if ( v == Py_None ) { |
| 330 | *p_itself = 0; |
| 331 | return 1; |
| 332 | } |
| 333 | if (!CmpObj_Check(v)) |
| 334 | { |
| 335 | PyErr_SetString(PyExc_TypeError, "Component required"); |
| 336 | return 0; |
| 337 | } |
| 338 | *p_itself = ((ComponentObject *)v)->ob_itself; |
| 339 | return 1; |
| 340 | } |
| 341 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 342 | static void CmpObj_dealloc(ComponentObject *self) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 343 | { |
| 344 | /* Cleanup of self->ob_itself goes here */ |
| 345 | PyMem_DEL(self); |
| 346 | } |
| 347 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 348 | static PyObject *CmpObj_UnregisterComponent(ComponentObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 349 | { |
| 350 | PyObject *_res = NULL; |
| 351 | OSErr _err; |
| 352 | if (!PyArg_ParseTuple(_args, "")) |
| 353 | return NULL; |
| 354 | _err = UnregisterComponent(_self->ob_itself); |
| 355 | if (_err != noErr) return PyMac_Error(_err); |
| 356 | Py_INCREF(Py_None); |
| 357 | _res = Py_None; |
| 358 | return _res; |
| 359 | } |
| 360 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 361 | static PyObject *CmpObj_GetComponentInfo(ComponentObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 362 | { |
| 363 | PyObject *_res = NULL; |
| 364 | OSErr _err; |
| 365 | ComponentDescription cd; |
| 366 | Handle componentName; |
| 367 | Handle componentInfo; |
| 368 | Handle componentIcon; |
| 369 | if (!PyArg_ParseTuple(_args, "O&O&O&", |
| 370 | ResObj_Convert, &componentName, |
| 371 | ResObj_Convert, &componentInfo, |
| 372 | ResObj_Convert, &componentIcon)) |
| 373 | return NULL; |
| 374 | _err = GetComponentInfo(_self->ob_itself, |
| 375 | &cd, |
| 376 | componentName, |
| 377 | componentInfo, |
| 378 | componentIcon); |
| 379 | if (_err != noErr) return PyMac_Error(_err); |
| 380 | _res = Py_BuildValue("O&", |
| 381 | CmpDesc_New, &cd); |
| 382 | return _res; |
| 383 | } |
| 384 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 385 | static PyObject *CmpObj_OpenComponent(ComponentObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 386 | { |
| 387 | PyObject *_res = NULL; |
| 388 | ComponentInstance _rv; |
| 389 | if (!PyArg_ParseTuple(_args, "")) |
| 390 | return NULL; |
| 391 | _rv = OpenComponent(_self->ob_itself); |
| 392 | _res = Py_BuildValue("O&", |
| 393 | CmpInstObj_New, _rv); |
| 394 | return _res; |
| 395 | } |
| 396 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 397 | static PyObject *CmpObj_GetComponentRefcon(ComponentObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 398 | { |
| 399 | PyObject *_res = NULL; |
| 400 | long _rv; |
| 401 | if (!PyArg_ParseTuple(_args, "")) |
| 402 | return NULL; |
| 403 | _rv = GetComponentRefcon(_self->ob_itself); |
| 404 | _res = Py_BuildValue("l", |
| 405 | _rv); |
| 406 | return _res; |
| 407 | } |
| 408 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 409 | static PyObject *CmpObj_SetComponentRefcon(ComponentObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 410 | { |
| 411 | PyObject *_res = NULL; |
| 412 | long theRefcon; |
| 413 | if (!PyArg_ParseTuple(_args, "l", |
| 414 | &theRefcon)) |
| 415 | return NULL; |
| 416 | SetComponentRefcon(_self->ob_itself, |
| 417 | theRefcon); |
| 418 | Py_INCREF(Py_None); |
| 419 | _res = Py_None; |
| 420 | return _res; |
| 421 | } |
| 422 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 423 | static PyObject *CmpObj_OpenComponentResFile(ComponentObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 424 | { |
| 425 | PyObject *_res = NULL; |
| 426 | short _rv; |
| 427 | if (!PyArg_ParseTuple(_args, "")) |
| 428 | return NULL; |
| 429 | _rv = OpenComponentResFile(_self->ob_itself); |
| 430 | _res = Py_BuildValue("h", |
| 431 | _rv); |
| 432 | return _res; |
| 433 | } |
| 434 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 435 | static PyObject *CmpObj_GetComponentResource(ComponentObject *_self, PyObject *_args) |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 436 | { |
| 437 | PyObject *_res = NULL; |
| 438 | OSErr _err; |
| 439 | OSType resType; |
| 440 | short resID; |
| 441 | Handle theResource; |
| 442 | if (!PyArg_ParseTuple(_args, "O&h", |
| 443 | PyMac_GetOSType, &resType, |
| 444 | &resID)) |
| 445 | return NULL; |
| 446 | _err = GetComponentResource(_self->ob_itself, |
| 447 | resType, |
| 448 | resID, |
| 449 | &theResource); |
| 450 | if (_err != noErr) return PyMac_Error(_err); |
| 451 | _res = Py_BuildValue("O&", |
| 452 | ResObj_New, theResource); |
| 453 | return _res; |
| 454 | } |
| 455 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 456 | static PyObject *CmpObj_GetComponentIndString(ComponentObject *_self, PyObject *_args) |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 457 | { |
| 458 | PyObject *_res = NULL; |
| 459 | OSErr _err; |
| 460 | Str255 theString; |
| 461 | short strListID; |
| 462 | short index; |
| 463 | if (!PyArg_ParseTuple(_args, "O&hh", |
| 464 | PyMac_GetStr255, theString, |
| 465 | &strListID, |
| 466 | &index)) |
| 467 | return NULL; |
| 468 | _err = GetComponentIndString(_self->ob_itself, |
| 469 | theString, |
| 470 | strListID, |
| 471 | index); |
| 472 | if (_err != noErr) return PyMac_Error(_err); |
| 473 | Py_INCREF(Py_None); |
| 474 | _res = Py_None; |
| 475 | return _res; |
| 476 | } |
| 477 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 478 | static PyObject *CmpObj_ResolveComponentAlias(ComponentObject *_self, PyObject *_args) |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 479 | { |
| 480 | PyObject *_res = NULL; |
| 481 | Component _rv; |
| 482 | if (!PyArg_ParseTuple(_args, "")) |
| 483 | return NULL; |
| 484 | _rv = ResolveComponentAlias(_self->ob_itself); |
| 485 | _res = Py_BuildValue("O&", |
| 486 | CmpObj_New, _rv); |
| 487 | return _res; |
| 488 | } |
| 489 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 490 | static PyObject *CmpObj_CountComponentInstances(ComponentObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 491 | { |
| 492 | PyObject *_res = NULL; |
| 493 | long _rv; |
| 494 | if (!PyArg_ParseTuple(_args, "")) |
| 495 | return NULL; |
| 496 | _rv = CountComponentInstances(_self->ob_itself); |
| 497 | _res = Py_BuildValue("l", |
| 498 | _rv); |
| 499 | return _res; |
| 500 | } |
| 501 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 502 | static PyObject *CmpObj_SetDefaultComponent(ComponentObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 503 | { |
| 504 | PyObject *_res = NULL; |
| 505 | OSErr _err; |
| 506 | short flags; |
| 507 | if (!PyArg_ParseTuple(_args, "h", |
| 508 | &flags)) |
| 509 | return NULL; |
| 510 | _err = SetDefaultComponent(_self->ob_itself, |
| 511 | flags); |
| 512 | if (_err != noErr) return PyMac_Error(_err); |
| 513 | Py_INCREF(Py_None); |
| 514 | _res = Py_None; |
| 515 | return _res; |
| 516 | } |
| 517 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 518 | static PyObject *CmpObj_CaptureComponent(ComponentObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 519 | { |
| 520 | PyObject *_res = NULL; |
| 521 | Component _rv; |
| 522 | Component capturingComponent; |
| 523 | if (!PyArg_ParseTuple(_args, "O&", |
| 524 | CmpObj_Convert, &capturingComponent)) |
| 525 | return NULL; |
| 526 | _rv = CaptureComponent(_self->ob_itself, |
| 527 | capturingComponent); |
| 528 | _res = Py_BuildValue("O&", |
| 529 | CmpObj_New, _rv); |
| 530 | return _res; |
| 531 | } |
| 532 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 533 | static PyObject *CmpObj_UncaptureComponent(ComponentObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 534 | { |
| 535 | PyObject *_res = NULL; |
| 536 | OSErr _err; |
| 537 | if (!PyArg_ParseTuple(_args, "")) |
| 538 | return NULL; |
| 539 | _err = UncaptureComponent(_self->ob_itself); |
| 540 | if (_err != noErr) return PyMac_Error(_err); |
| 541 | Py_INCREF(Py_None); |
| 542 | _res = Py_None; |
| 543 | return _res; |
| 544 | } |
| 545 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 546 | static PyObject *CmpObj_GetComponentIconSuite(ComponentObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 547 | { |
| 548 | PyObject *_res = NULL; |
| 549 | OSErr _err; |
| 550 | Handle iconSuite; |
| 551 | if (!PyArg_ParseTuple(_args, "")) |
| 552 | return NULL; |
| 553 | _err = GetComponentIconSuite(_self->ob_itself, |
| 554 | &iconSuite); |
| 555 | if (_err != noErr) return PyMac_Error(_err); |
| 556 | _res = Py_BuildValue("O&", |
| 557 | ResObj_New, iconSuite); |
| 558 | return _res; |
| 559 | } |
| 560 | |
| 561 | static PyMethodDef CmpObj_methods[] = { |
| 562 | {"UnregisterComponent", (PyCFunction)CmpObj_UnregisterComponent, 1, |
| 563 | "() -> None"}, |
| 564 | {"GetComponentInfo", (PyCFunction)CmpObj_GetComponentInfo, 1, |
| 565 | "(Handle componentName, Handle componentInfo, Handle componentIcon) -> (ComponentDescription cd)"}, |
| 566 | {"OpenComponent", (PyCFunction)CmpObj_OpenComponent, 1, |
| 567 | "() -> (ComponentInstance _rv)"}, |
| 568 | {"GetComponentRefcon", (PyCFunction)CmpObj_GetComponentRefcon, 1, |
| 569 | "() -> (long _rv)"}, |
| 570 | {"SetComponentRefcon", (PyCFunction)CmpObj_SetComponentRefcon, 1, |
| 571 | "(long theRefcon) -> None"}, |
| 572 | {"OpenComponentResFile", (PyCFunction)CmpObj_OpenComponentResFile, 1, |
| 573 | "() -> (short _rv)"}, |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 574 | {"GetComponentResource", (PyCFunction)CmpObj_GetComponentResource, 1, |
| 575 | "(OSType resType, short resID) -> (Handle theResource)"}, |
| 576 | {"GetComponentIndString", (PyCFunction)CmpObj_GetComponentIndString, 1, |
| 577 | "(Str255 theString, short strListID, short index) -> None"}, |
| 578 | {"ResolveComponentAlias", (PyCFunction)CmpObj_ResolveComponentAlias, 1, |
| 579 | "() -> (Component _rv)"}, |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 580 | {"CountComponentInstances", (PyCFunction)CmpObj_CountComponentInstances, 1, |
| 581 | "() -> (long _rv)"}, |
| 582 | {"SetDefaultComponent", (PyCFunction)CmpObj_SetDefaultComponent, 1, |
| 583 | "(short flags) -> None"}, |
| 584 | {"CaptureComponent", (PyCFunction)CmpObj_CaptureComponent, 1, |
| 585 | "(Component capturingComponent) -> (Component _rv)"}, |
| 586 | {"UncaptureComponent", (PyCFunction)CmpObj_UncaptureComponent, 1, |
| 587 | "() -> None"}, |
| 588 | {"GetComponentIconSuite", (PyCFunction)CmpObj_GetComponentIconSuite, 1, |
| 589 | "() -> (Handle iconSuite)"}, |
| 590 | {NULL, NULL, 0} |
| 591 | }; |
| 592 | |
| 593 | PyMethodChain CmpObj_chain = { CmpObj_methods, NULL }; |
| 594 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 595 | static PyObject *CmpObj_getattr(ComponentObject *self, char *name) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 596 | { |
| 597 | return Py_FindMethodInChain(&CmpObj_chain, (PyObject *)self, name); |
| 598 | } |
| 599 | |
| 600 | #define CmpObj_setattr NULL |
| 601 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 602 | #define CmpObj_compare NULL |
| 603 | |
| 604 | #define CmpObj_repr NULL |
| 605 | |
| 606 | #define CmpObj_hash NULL |
| 607 | |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 608 | PyTypeObject Component_Type = { |
| 609 | PyObject_HEAD_INIT(&PyType_Type) |
| 610 | 0, /*ob_size*/ |
| 611 | "Component", /*tp_name*/ |
| 612 | sizeof(ComponentObject), /*tp_basicsize*/ |
| 613 | 0, /*tp_itemsize*/ |
| 614 | /* methods */ |
| 615 | (destructor) CmpObj_dealloc, /*tp_dealloc*/ |
| 616 | 0, /*tp_print*/ |
| 617 | (getattrfunc) CmpObj_getattr, /*tp_getattr*/ |
| 618 | (setattrfunc) CmpObj_setattr, /*tp_setattr*/ |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 619 | (cmpfunc) CmpObj_compare, /*tp_compare*/ |
| 620 | (reprfunc) CmpObj_repr, /*tp_repr*/ |
| 621 | (PyNumberMethods *)0, /* tp_as_number */ |
| 622 | (PySequenceMethods *)0, /* tp_as_sequence */ |
| 623 | (PyMappingMethods *)0, /* tp_as_mapping */ |
| 624 | (hashfunc) CmpObj_hash, /*tp_hash*/ |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 625 | }; |
| 626 | |
| 627 | /* ------------------- End object type Component -------------------- */ |
| 628 | |
| 629 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 630 | static PyObject *Cm_RegisterComponentResource(PyObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 631 | { |
| 632 | PyObject *_res = NULL; |
| 633 | Component _rv; |
Jack Jansen | 4a8c54e | 1997-02-24 13:56:59 +0000 | [diff] [blame] | 634 | ComponentResourceHandle cr; |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 635 | short global; |
| 636 | if (!PyArg_ParseTuple(_args, "O&h", |
Jack Jansen | 4a8c54e | 1997-02-24 13:56:59 +0000 | [diff] [blame] | 637 | ResObj_Convert, &cr, |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 638 | &global)) |
| 639 | return NULL; |
Jack Jansen | 4a8c54e | 1997-02-24 13:56:59 +0000 | [diff] [blame] | 640 | _rv = RegisterComponentResource(cr, |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 641 | global); |
| 642 | _res = Py_BuildValue("O&", |
| 643 | CmpObj_New, _rv); |
| 644 | return _res; |
| 645 | } |
| 646 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 647 | static PyObject *Cm_FindNextComponent(PyObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 648 | { |
| 649 | PyObject *_res = NULL; |
| 650 | Component _rv; |
| 651 | Component aComponent; |
| 652 | ComponentDescription looking; |
| 653 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 654 | CmpObj_Convert, &aComponent, |
| 655 | CmpDesc_Convert, &looking)) |
| 656 | return NULL; |
| 657 | _rv = FindNextComponent(aComponent, |
| 658 | &looking); |
| 659 | _res = Py_BuildValue("O&", |
| 660 | CmpObj_New, _rv); |
| 661 | return _res; |
| 662 | } |
| 663 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 664 | static PyObject *Cm_CountComponents(PyObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 665 | { |
| 666 | PyObject *_res = NULL; |
| 667 | long _rv; |
| 668 | ComponentDescription looking; |
| 669 | if (!PyArg_ParseTuple(_args, "O&", |
| 670 | CmpDesc_Convert, &looking)) |
| 671 | return NULL; |
| 672 | _rv = CountComponents(&looking); |
| 673 | _res = Py_BuildValue("l", |
| 674 | _rv); |
| 675 | return _res; |
| 676 | } |
| 677 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 678 | static PyObject *Cm_GetComponentListModSeed(PyObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 679 | { |
| 680 | PyObject *_res = NULL; |
| 681 | long _rv; |
| 682 | if (!PyArg_ParseTuple(_args, "")) |
| 683 | return NULL; |
| 684 | _rv = GetComponentListModSeed(); |
| 685 | _res = Py_BuildValue("l", |
| 686 | _rv); |
| 687 | return _res; |
| 688 | } |
| 689 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 690 | static PyObject *Cm_CloseComponentResFile(PyObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 691 | { |
| 692 | PyObject *_res = NULL; |
| 693 | OSErr _err; |
| 694 | short refnum; |
| 695 | if (!PyArg_ParseTuple(_args, "h", |
| 696 | &refnum)) |
| 697 | return NULL; |
| 698 | _err = CloseComponentResFile(refnum); |
| 699 | if (_err != noErr) return PyMac_Error(_err); |
| 700 | Py_INCREF(Py_None); |
| 701 | _res = Py_None; |
| 702 | return _res; |
| 703 | } |
| 704 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 705 | static PyObject *Cm_OpenDefaultComponent(PyObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 706 | { |
| 707 | PyObject *_res = NULL; |
| 708 | ComponentInstance _rv; |
| 709 | OSType componentType; |
| 710 | OSType componentSubType; |
| 711 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 712 | PyMac_GetOSType, &componentType, |
| 713 | PyMac_GetOSType, &componentSubType)) |
| 714 | return NULL; |
| 715 | _rv = OpenDefaultComponent(componentType, |
| 716 | componentSubType); |
| 717 | _res = Py_BuildValue("O&", |
| 718 | CmpInstObj_New, _rv); |
| 719 | return _res; |
| 720 | } |
| 721 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 722 | static PyObject *Cm_RegisterComponentResourceFile(PyObject *_self, PyObject *_args) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 723 | { |
| 724 | PyObject *_res = NULL; |
| 725 | long _rv; |
| 726 | short resRefNum; |
| 727 | short global; |
| 728 | if (!PyArg_ParseTuple(_args, "hh", |
| 729 | &resRefNum, |
| 730 | &global)) |
| 731 | return NULL; |
| 732 | _rv = RegisterComponentResourceFile(resRefNum, |
| 733 | global); |
| 734 | _res = Py_BuildValue("l", |
| 735 | _rv); |
| 736 | return _res; |
| 737 | } |
| 738 | |
| 739 | static PyMethodDef Cm_methods[] = { |
| 740 | {"RegisterComponentResource", (PyCFunction)Cm_RegisterComponentResource, 1, |
Jack Jansen | 4a8c54e | 1997-02-24 13:56:59 +0000 | [diff] [blame] | 741 | "(ComponentResourceHandle cr, short global) -> (Component _rv)"}, |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 742 | {"FindNextComponent", (PyCFunction)Cm_FindNextComponent, 1, |
| 743 | "(Component aComponent, ComponentDescription looking) -> (Component _rv)"}, |
| 744 | {"CountComponents", (PyCFunction)Cm_CountComponents, 1, |
| 745 | "(ComponentDescription looking) -> (long _rv)"}, |
| 746 | {"GetComponentListModSeed", (PyCFunction)Cm_GetComponentListModSeed, 1, |
| 747 | "() -> (long _rv)"}, |
| 748 | {"CloseComponentResFile", (PyCFunction)Cm_CloseComponentResFile, 1, |
| 749 | "(short refnum) -> None"}, |
| 750 | {"OpenDefaultComponent", (PyCFunction)Cm_OpenDefaultComponent, 1, |
| 751 | "(OSType componentType, OSType componentSubType) -> (ComponentInstance _rv)"}, |
| 752 | {"RegisterComponentResourceFile", (PyCFunction)Cm_RegisterComponentResourceFile, 1, |
| 753 | "(short resRefNum, short global) -> (long _rv)"}, |
| 754 | {NULL, NULL, 0} |
| 755 | }; |
| 756 | |
| 757 | |
| 758 | |
| 759 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 760 | void initCm(void) |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 761 | { |
| 762 | PyObject *m; |
| 763 | PyObject *d; |
| 764 | |
| 765 | |
| 766 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 767 | PyMac_INIT_TOOLBOX_OBJECT_NEW(Component, CmpObj_New); |
| 768 | PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Component, CmpObj_Convert); |
| 769 | PyMac_INIT_TOOLBOX_OBJECT_NEW(ComponentInstance, CmpInstObj_New); |
| 770 | PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ComponentInstance, CmpInstObj_Convert); |
Jack Jansen | 0e04eec | 2001-05-17 21:58:34 +0000 | [diff] [blame] | 771 | |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 772 | |
| 773 | m = Py_InitModule("Cm", Cm_methods); |
| 774 | d = PyModule_GetDict(m); |
| 775 | Cm_Error = PyMac_GetOSErrException(); |
| 776 | if (Cm_Error == NULL || |
| 777 | PyDict_SetItemString(d, "Error", Cm_Error) != 0) |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 778 | return; |
Jack Jansen | a755e68 | 1997-09-20 17:40:22 +0000 | [diff] [blame] | 779 | ComponentInstance_Type.ob_type = &PyType_Type; |
| 780 | Py_INCREF(&ComponentInstance_Type); |
| 781 | if (PyDict_SetItemString(d, "ComponentInstanceType", (PyObject *)&ComponentInstance_Type) != 0) |
| 782 | Py_FatalError("can't initialize ComponentInstanceType"); |
| 783 | Component_Type.ob_type = &PyType_Type; |
| 784 | Py_INCREF(&Component_Type); |
| 785 | if (PyDict_SetItemString(d, "ComponentType", (PyObject *)&Component_Type) != 0) |
| 786 | Py_FatalError("can't initialize ComponentType"); |
Jack Jansen | b996856 | 1995-11-30 15:03:09 +0000 | [diff] [blame] | 787 | } |
| 788 | |
| 789 | /* ========================= End module Cm ========================== */ |
| 790 | |