2
/* =========================== Module _Cm =========================== */
8
#include "pymactoolbox.h"
10
/* Macro to test whether a weak-loaded CFM function exists */
11
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
12
PyErr_SetString(PyExc_NotImplementedError, \
13
"Not available in this shared library/OS version"); \
18
#include <Carbon/Carbon.h>
20
#ifdef USE_TOOLBOX_OBJECT_GLUE
21
extern PyObject *_CmpObj_New(Component);
22
extern int _CmpObj_Convert(PyObject *, Component *);
23
extern PyObject *_CmpInstObj_New(ComponentInstance);
24
extern int _CmpInstObj_Convert(PyObject *, ComponentInstance *);
26
#define CmpObj_New _CmpObj_New
27
#define CmpObj_Convert _CmpObj_Convert
28
#define CmpInstObj_New _CmpInstObj_New
29
#define CmpInstObj_Convert _CmpInstObj_Convert
33
** Parse/generate ComponentDescriptor records
36
CmpDesc_New(ComponentDescription *itself)
39
return Py_BuildValue("O&O&O&ll",
40
PyMac_BuildOSType, itself->componentType,
41
PyMac_BuildOSType, itself->componentSubType,
42
PyMac_BuildOSType, itself->componentManufacturer,
43
itself->componentFlags, itself->componentFlagsMask);
47
CmpDesc_Convert(PyObject *v, ComponentDescription *p_itself)
49
return PyArg_ParseTuple(v, "O&O&O&ll",
50
PyMac_GetOSType, &p_itself->componentType,
51
PyMac_GetOSType, &p_itself->componentSubType,
52
PyMac_GetOSType, &p_itself->componentManufacturer,
53
&p_itself->componentFlags, &p_itself->componentFlagsMask);
57
static PyObject *Cm_Error;
59
/* ----------------- Object type ComponentInstance ------------------ */
61
PyTypeObject ComponentInstance_Type;
63
#define CmpInstObj_Check(x) ((x)->ob_type == &ComponentInstance_Type || PyObject_TypeCheck((x), &ComponentInstance_Type))
65
typedef struct ComponentInstanceObject {
67
ComponentInstance ob_itself;
68
} ComponentInstanceObject;
70
PyObject *CmpInstObj_New(ComponentInstance itself)
72
ComponentInstanceObject *it;
74
PyErr_SetString(Cm_Error,"NULL ComponentInstance");
77
it = PyObject_NEW(ComponentInstanceObject, &ComponentInstance_Type);
78
if (it == NULL) return NULL;
79
it->ob_itself = itself;
80
return (PyObject *)it;
83
int CmpInstObj_Convert(PyObject *v, ComponentInstance *p_itself)
85
if (!CmpInstObj_Check(v))
87
PyErr_SetString(PyExc_TypeError, "ComponentInstance required");
90
*p_itself = ((ComponentInstanceObject *)v)->ob_itself;
94
static void CmpInstObj_dealloc(ComponentInstanceObject *self)
96
/* Cleanup of self->ob_itself goes here */
97
self->ob_type->tp_free((PyObject *)self);
100
static PyObject *CmpInstObj_CloseComponent(ComponentInstanceObject *_self, PyObject *_args)
102
PyObject *_res = NULL;
104
#ifndef CloseComponent
105
PyMac_PRECHECK(CloseComponent);
107
if (!PyArg_ParseTuple(_args, ""))
109
_err = CloseComponent(_self->ob_itself);
110
if (_err != noErr) return PyMac_Error(_err);
116
static PyObject *CmpInstObj_GetComponentInstanceError(ComponentInstanceObject *_self, PyObject *_args)
118
PyObject *_res = NULL;
120
#ifndef GetComponentInstanceError
121
PyMac_PRECHECK(GetComponentInstanceError);
123
if (!PyArg_ParseTuple(_args, ""))
125
_err = GetComponentInstanceError(_self->ob_itself);
126
if (_err != noErr) return PyMac_Error(_err);
132
static PyObject *CmpInstObj_SetComponentInstanceError(ComponentInstanceObject *_self, PyObject *_args)
134
PyObject *_res = NULL;
136
#ifndef SetComponentInstanceError
137
PyMac_PRECHECK(SetComponentInstanceError);
139
if (!PyArg_ParseTuple(_args, "h",
142
SetComponentInstanceError(_self->ob_itself,
149
static PyObject *CmpInstObj_GetComponentInstanceStorage(ComponentInstanceObject *_self, PyObject *_args)
151
PyObject *_res = NULL;
153
#ifndef GetComponentInstanceStorage
154
PyMac_PRECHECK(GetComponentInstanceStorage);
156
if (!PyArg_ParseTuple(_args, ""))
158
_rv = GetComponentInstanceStorage(_self->ob_itself);
159
_res = Py_BuildValue("O&",
164
static PyObject *CmpInstObj_SetComponentInstanceStorage(ComponentInstanceObject *_self, PyObject *_args)
166
PyObject *_res = NULL;
168
#ifndef SetComponentInstanceStorage
169
PyMac_PRECHECK(SetComponentInstanceStorage);
171
if (!PyArg_ParseTuple(_args, "O&",
172
ResObj_Convert, &theStorage))
174
SetComponentInstanceStorage(_self->ob_itself,
182
static PyObject *CmpInstObj_ComponentFunctionImplemented(ComponentInstanceObject *_self, PyObject *_args)
184
PyObject *_res = NULL;
187
#ifndef ComponentFunctionImplemented
188
PyMac_PRECHECK(ComponentFunctionImplemented);
190
if (!PyArg_ParseTuple(_args, "h",
193
_rv = ComponentFunctionImplemented(_self->ob_itself,
195
_res = Py_BuildValue("l",
200
static PyObject *CmpInstObj_GetComponentVersion(ComponentInstanceObject *_self, PyObject *_args)
202
PyObject *_res = NULL;
204
#ifndef GetComponentVersion
205
PyMac_PRECHECK(GetComponentVersion);
207
if (!PyArg_ParseTuple(_args, ""))
209
_rv = GetComponentVersion(_self->ob_itself);
210
_res = Py_BuildValue("l",
215
static PyObject *CmpInstObj_ComponentSetTarget(ComponentInstanceObject *_self, PyObject *_args)
217
PyObject *_res = NULL;
219
ComponentInstance target;
220
#ifndef ComponentSetTarget
221
PyMac_PRECHECK(ComponentSetTarget);
223
if (!PyArg_ParseTuple(_args, "O&",
224
CmpInstObj_Convert, &target))
226
_rv = ComponentSetTarget(_self->ob_itself,
228
_res = Py_BuildValue("l",
232
#endif /* !__LP64__*/
234
static PyMethodDef CmpInstObj_methods[] = {
235
{"CloseComponent", (PyCFunction)CmpInstObj_CloseComponent, 1,
236
PyDoc_STR("() -> None")},
237
{"GetComponentInstanceError", (PyCFunction)CmpInstObj_GetComponentInstanceError, 1,
238
PyDoc_STR("() -> None")},
239
{"SetComponentInstanceError", (PyCFunction)CmpInstObj_SetComponentInstanceError, 1,
240
PyDoc_STR("(OSErr theError) -> None")},
241
{"GetComponentInstanceStorage", (PyCFunction)CmpInstObj_GetComponentInstanceStorage, 1,
242
PyDoc_STR("() -> (Handle _rv)")},
243
{"SetComponentInstanceStorage", (PyCFunction)CmpInstObj_SetComponentInstanceStorage, 1,
244
PyDoc_STR("(Handle theStorage) -> None")},
246
{"ComponentFunctionImplemented", (PyCFunction)CmpInstObj_ComponentFunctionImplemented, 1,
247
PyDoc_STR("(short ftnNumber) -> (long _rv)")},
248
{"GetComponentVersion", (PyCFunction)CmpInstObj_GetComponentVersion, 1,
249
PyDoc_STR("() -> (long _rv)")},
250
{"ComponentSetTarget", (PyCFunction)CmpInstObj_ComponentSetTarget, 1,
251
PyDoc_STR("(ComponentInstance target) -> (long _rv)")},
252
#endif /* !__LP64__ */
256
#define CmpInstObj_getsetlist NULL
259
#define CmpInstObj_compare NULL
261
#define CmpInstObj_repr NULL
263
#define CmpInstObj_hash NULL
264
#define CmpInstObj_tp_init 0
266
#define CmpInstObj_tp_alloc PyType_GenericAlloc
268
static PyObject *CmpInstObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
271
ComponentInstance itself;
272
char *kw[] = {"itself", 0};
274
if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CmpInstObj_Convert, &itself)) return NULL;
275
if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;
276
((ComponentInstanceObject *)_self)->ob_itself = itself;
280
#define CmpInstObj_tp_free PyObject_Del
283
PyTypeObject ComponentInstance_Type = {
284
PyObject_HEAD_INIT(NULL)
286
"_Cm.ComponentInstance", /*tp_name*/
287
sizeof(ComponentInstanceObject), /*tp_basicsize*/
290
(destructor) CmpInstObj_dealloc, /*tp_dealloc*/
292
(getattrfunc)0, /*tp_getattr*/
293
(setattrfunc)0, /*tp_setattr*/
294
(cmpfunc) CmpInstObj_compare, /*tp_compare*/
295
(reprfunc) CmpInstObj_repr, /*tp_repr*/
296
(PyNumberMethods *)0, /* tp_as_number */
297
(PySequenceMethods *)0, /* tp_as_sequence */
298
(PyMappingMethods *)0, /* tp_as_mapping */
299
(hashfunc) CmpInstObj_hash, /*tp_hash*/
302
PyObject_GenericGetAttr, /*tp_getattro*/
303
PyObject_GenericSetAttr, /*tp_setattro */
305
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
309
0, /*tp_richcompare*/
310
0, /*tp_weaklistoffset*/
313
CmpInstObj_methods, /* tp_methods */
315
CmpInstObj_getsetlist, /*tp_getset*/
321
CmpInstObj_tp_init, /* tp_init */
322
CmpInstObj_tp_alloc, /* tp_alloc */
323
CmpInstObj_tp_new, /* tp_new */
324
CmpInstObj_tp_free, /* tp_free */
327
/* --------------- End object type ComponentInstance ---------------- */
330
/* --------------------- Object type Component ---------------------- */
332
PyTypeObject Component_Type;
334
#define CmpObj_Check(x) ((x)->ob_type == &Component_Type || PyObject_TypeCheck((x), &Component_Type))
336
typedef struct ComponentObject {
341
PyObject *CmpObj_New(Component itself)
344
if (itself == NULL) {
345
/* XXXX Or should we return None? */
346
PyErr_SetString(Cm_Error,"No such component");
349
it = PyObject_NEW(ComponentObject, &Component_Type);
350
if (it == NULL) return NULL;
351
it->ob_itself = itself;
352
return (PyObject *)it;
355
int CmpObj_Convert(PyObject *v, Component *p_itself)
357
if ( v == Py_None ) {
361
if (!CmpObj_Check(v))
363
PyErr_SetString(PyExc_TypeError, "Component required");
366
*p_itself = ((ComponentObject *)v)->ob_itself;
370
static void CmpObj_dealloc(ComponentObject *self)
372
/* Cleanup of self->ob_itself goes here */
373
self->ob_type->tp_free((PyObject *)self);
376
static PyObject *CmpObj_UnregisterComponent(ComponentObject *_self, PyObject *_args)
378
PyObject *_res = NULL;
380
#ifndef UnregisterComponent
381
PyMac_PRECHECK(UnregisterComponent);
383
if (!PyArg_ParseTuple(_args, ""))
385
_err = UnregisterComponent(_self->ob_itself);
386
if (_err != noErr) return PyMac_Error(_err);
392
static PyObject *CmpObj_GetComponentInfo(ComponentObject *_self, PyObject *_args)
394
PyObject *_res = NULL;
396
ComponentDescription cd;
397
Handle componentName;
398
Handle componentInfo;
399
Handle componentIcon;
400
#ifndef GetComponentInfo
401
PyMac_PRECHECK(GetComponentInfo);
403
if (!PyArg_ParseTuple(_args, "O&O&O&",
404
ResObj_Convert, &componentName,
405
ResObj_Convert, &componentInfo,
406
ResObj_Convert, &componentIcon))
408
_err = GetComponentInfo(_self->ob_itself,
413
if (_err != noErr) return PyMac_Error(_err);
414
_res = Py_BuildValue("O&",
419
static PyObject *CmpObj_OpenComponent(ComponentObject *_self, PyObject *_args)
421
PyObject *_res = NULL;
422
ComponentInstance _rv;
423
#ifndef OpenComponent
424
PyMac_PRECHECK(OpenComponent);
426
if (!PyArg_ParseTuple(_args, ""))
428
_rv = OpenComponent(_self->ob_itself);
429
_res = Py_BuildValue("O&",
430
CmpInstObj_New, _rv);
434
static PyObject *CmpObj_ResolveComponentAlias(ComponentObject *_self, PyObject *_args)
436
PyObject *_res = NULL;
438
#ifndef ResolveComponentAlias
439
PyMac_PRECHECK(ResolveComponentAlias);
441
if (!PyArg_ParseTuple(_args, ""))
443
_rv = ResolveComponentAlias(_self->ob_itself);
444
_res = Py_BuildValue("O&",
449
static PyObject *CmpObj_GetComponentPublicIndString(ComponentObject *_self, PyObject *_args)
451
PyObject *_res = NULL;
456
#ifndef GetComponentPublicIndString
457
PyMac_PRECHECK(GetComponentPublicIndString);
459
if (!PyArg_ParseTuple(_args, "O&hh",
460
PyMac_GetStr255, theString,
464
_err = GetComponentPublicIndString(_self->ob_itself,
468
if (_err != noErr) return PyMac_Error(_err);
474
static PyObject *CmpObj_GetComponentRefcon(ComponentObject *_self, PyObject *_args)
476
PyObject *_res = NULL;
478
#ifndef GetComponentRefcon
479
PyMac_PRECHECK(GetComponentRefcon);
481
if (!PyArg_ParseTuple(_args, ""))
483
_rv = GetComponentRefcon(_self->ob_itself);
484
_res = Py_BuildValue("l",
489
static PyObject *CmpObj_SetComponentRefcon(ComponentObject *_self, PyObject *_args)
491
PyObject *_res = NULL;
493
#ifndef SetComponentRefcon
494
PyMac_PRECHECK(SetComponentRefcon);
496
if (!PyArg_ParseTuple(_args, "l",
499
SetComponentRefcon(_self->ob_itself,
506
static PyObject *CmpObj_OpenComponentResFile(ComponentObject *_self, PyObject *_args)
508
PyObject *_res = NULL;
510
#ifndef OpenComponentResFile
511
PyMac_PRECHECK(OpenComponentResFile);
513
if (!PyArg_ParseTuple(_args, ""))
515
_rv = OpenComponentResFile(_self->ob_itself);
516
_res = Py_BuildValue("h",
521
static PyObject *CmpObj_GetComponentResource(ComponentObject *_self, PyObject *_args)
523
PyObject *_res = NULL;
528
#ifndef GetComponentResource
529
PyMac_PRECHECK(GetComponentResource);
531
if (!PyArg_ParseTuple(_args, "O&h",
532
PyMac_GetOSType, &resType,
535
_err = GetComponentResource(_self->ob_itself,
539
if (_err != noErr) return PyMac_Error(_err);
540
_res = Py_BuildValue("O&",
541
ResObj_New, theResource);
545
static PyObject *CmpObj_GetComponentIndString(ComponentObject *_self, PyObject *_args)
547
PyObject *_res = NULL;
552
#ifndef GetComponentIndString
553
PyMac_PRECHECK(GetComponentIndString);
555
if (!PyArg_ParseTuple(_args, "O&hh",
556
PyMac_GetStr255, theString,
560
_err = GetComponentIndString(_self->ob_itself,
564
if (_err != noErr) return PyMac_Error(_err);
570
static PyObject *CmpObj_CountComponentInstances(ComponentObject *_self, PyObject *_args)
572
PyObject *_res = NULL;
574
#ifndef CountComponentInstances
575
PyMac_PRECHECK(CountComponentInstances);
577
if (!PyArg_ParseTuple(_args, ""))
579
_rv = CountComponentInstances(_self->ob_itself);
580
_res = Py_BuildValue("l",
585
static PyObject *CmpObj_SetDefaultComponent(ComponentObject *_self, PyObject *_args)
587
PyObject *_res = NULL;
590
#ifndef SetDefaultComponent
591
PyMac_PRECHECK(SetDefaultComponent);
593
if (!PyArg_ParseTuple(_args, "h",
596
_err = SetDefaultComponent(_self->ob_itself,
598
if (_err != noErr) return PyMac_Error(_err);
604
static PyObject *CmpObj_CaptureComponent(ComponentObject *_self, PyObject *_args)
606
PyObject *_res = NULL;
608
Component capturingComponent;
609
#ifndef CaptureComponent
610
PyMac_PRECHECK(CaptureComponent);
612
if (!PyArg_ParseTuple(_args, "O&",
613
CmpObj_Convert, &capturingComponent))
615
_rv = CaptureComponent(_self->ob_itself,
617
_res = Py_BuildValue("O&",
622
static PyObject *CmpObj_UncaptureComponent(ComponentObject *_self, PyObject *_args)
624
PyObject *_res = NULL;
626
#ifndef UncaptureComponent
627
PyMac_PRECHECK(UncaptureComponent);
629
if (!PyArg_ParseTuple(_args, ""))
631
_err = UncaptureComponent(_self->ob_itself);
632
if (_err != noErr) return PyMac_Error(_err);
639
static PyObject *CmpObj_GetComponentIconSuite(ComponentObject *_self, PyObject *_args)
641
PyObject *_res = NULL;
644
#ifndef GetComponentIconSuite
645
PyMac_PRECHECK(GetComponentIconSuite);
647
if (!PyArg_ParseTuple(_args, ""))
649
_err = GetComponentIconSuite(_self->ob_itself,
651
if (_err != noErr) return PyMac_Error(_err);
652
_res = Py_BuildValue("O&",
653
ResObj_New, iconSuite);
656
#endif /* !__LP64__ */
658
static PyMethodDef CmpObj_methods[] = {
659
{"UnregisterComponent", (PyCFunction)CmpObj_UnregisterComponent, 1,
660
PyDoc_STR("() -> None")},
661
{"GetComponentInfo", (PyCFunction)CmpObj_GetComponentInfo, 1,
662
PyDoc_STR("(Handle componentName, Handle componentInfo, Handle componentIcon) -> (ComponentDescription cd)")},
663
{"OpenComponent", (PyCFunction)CmpObj_OpenComponent, 1,
664
PyDoc_STR("() -> (ComponentInstance _rv)")},
665
{"ResolveComponentAlias", (PyCFunction)CmpObj_ResolveComponentAlias, 1,
666
PyDoc_STR("() -> (Component _rv)")},
667
{"GetComponentPublicIndString", (PyCFunction)CmpObj_GetComponentPublicIndString, 1,
668
PyDoc_STR("(Str255 theString, short strListID, short index) -> None")},
669
{"GetComponentRefcon", (PyCFunction)CmpObj_GetComponentRefcon, 1,
670
PyDoc_STR("() -> (long _rv)")},
671
{"SetComponentRefcon", (PyCFunction)CmpObj_SetComponentRefcon, 1,
672
PyDoc_STR("(long theRefcon) -> None")},
673
{"OpenComponentResFile", (PyCFunction)CmpObj_OpenComponentResFile, 1,
674
PyDoc_STR("() -> (short _rv)")},
675
{"GetComponentResource", (PyCFunction)CmpObj_GetComponentResource, 1,
676
PyDoc_STR("(OSType resType, short resID) -> (Handle theResource)")},
677
{"GetComponentIndString", (PyCFunction)CmpObj_GetComponentIndString, 1,
678
PyDoc_STR("(Str255 theString, short strListID, short index) -> None")},
679
{"CountComponentInstances", (PyCFunction)CmpObj_CountComponentInstances, 1,
680
PyDoc_STR("() -> (long _rv)")},
681
{"SetDefaultComponent", (PyCFunction)CmpObj_SetDefaultComponent, 1,
682
PyDoc_STR("(short flags) -> None")},
683
{"CaptureComponent", (PyCFunction)CmpObj_CaptureComponent, 1,
684
PyDoc_STR("(Component capturingComponent) -> (Component _rv)")},
685
{"UncaptureComponent", (PyCFunction)CmpObj_UncaptureComponent, 1,
686
PyDoc_STR("() -> None")},
688
{"GetComponentIconSuite", (PyCFunction)CmpObj_GetComponentIconSuite, 1,
689
PyDoc_STR("() -> (Handle iconSuite)")},
690
#endif /* !__LP64__ */
694
#define CmpObj_getsetlist NULL
697
#define CmpObj_compare NULL
699
#define CmpObj_repr NULL
701
#define CmpObj_hash NULL
702
#define CmpObj_tp_init 0
704
#define CmpObj_tp_alloc PyType_GenericAlloc
706
static PyObject *CmpObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
710
char *kw[] = {"itself", 0};
712
if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CmpObj_Convert, &itself)) return NULL;
713
if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;
714
((ComponentObject *)_self)->ob_itself = itself;
718
#define CmpObj_tp_free PyObject_Del
721
PyTypeObject Component_Type = {
722
PyObject_HEAD_INIT(NULL)
724
"_Cm.Component", /*tp_name*/
725
sizeof(ComponentObject), /*tp_basicsize*/
728
(destructor) CmpObj_dealloc, /*tp_dealloc*/
730
(getattrfunc)0, /*tp_getattr*/
731
(setattrfunc)0, /*tp_setattr*/
732
(cmpfunc) CmpObj_compare, /*tp_compare*/
733
(reprfunc) CmpObj_repr, /*tp_repr*/
734
(PyNumberMethods *)0, /* tp_as_number */
735
(PySequenceMethods *)0, /* tp_as_sequence */
736
(PyMappingMethods *)0, /* tp_as_mapping */
737
(hashfunc) CmpObj_hash, /*tp_hash*/
740
PyObject_GenericGetAttr, /*tp_getattro*/
741
PyObject_GenericSetAttr, /*tp_setattro */
743
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
747
0, /*tp_richcompare*/
748
0, /*tp_weaklistoffset*/
751
CmpObj_methods, /* tp_methods */
753
CmpObj_getsetlist, /*tp_getset*/
759
CmpObj_tp_init, /* tp_init */
760
CmpObj_tp_alloc, /* tp_alloc */
761
CmpObj_tp_new, /* tp_new */
762
CmpObj_tp_free, /* tp_free */
765
/* ------------------- End object type Component -------------------- */
768
static PyObject *Cm_RegisterComponentResource(PyObject *_self, PyObject *_args)
770
PyObject *_res = NULL;
772
ComponentResourceHandle cr;
774
#ifndef RegisterComponentResource
775
PyMac_PRECHECK(RegisterComponentResource);
777
if (!PyArg_ParseTuple(_args, "O&h",
781
_rv = RegisterComponentResource(cr,
783
_res = Py_BuildValue("O&",
788
static PyObject *Cm_FindNextComponent(PyObject *_self, PyObject *_args)
790
PyObject *_res = NULL;
792
Component aComponent;
793
ComponentDescription looking;
794
#ifndef FindNextComponent
795
PyMac_PRECHECK(FindNextComponent);
797
if (!PyArg_ParseTuple(_args, "O&O&",
798
CmpObj_Convert, &aComponent,
799
CmpDesc_Convert, &looking))
801
_rv = FindNextComponent(aComponent,
803
_res = Py_BuildValue("O&",
808
static PyObject *Cm_CountComponents(PyObject *_self, PyObject *_args)
810
PyObject *_res = NULL;
812
ComponentDescription looking;
813
#ifndef CountComponents
814
PyMac_PRECHECK(CountComponents);
816
if (!PyArg_ParseTuple(_args, "O&",
817
CmpDesc_Convert, &looking))
819
_rv = CountComponents(&looking);
820
_res = Py_BuildValue("l",
825
static PyObject *Cm_GetComponentListModSeed(PyObject *_self, PyObject *_args)
827
PyObject *_res = NULL;
829
#ifndef GetComponentListModSeed
830
PyMac_PRECHECK(GetComponentListModSeed);
832
if (!PyArg_ParseTuple(_args, ""))
834
_rv = GetComponentListModSeed();
835
_res = Py_BuildValue("l",
840
static PyObject *Cm_CloseComponentResFile(PyObject *_self, PyObject *_args)
842
PyObject *_res = NULL;
845
#ifndef CloseComponentResFile
846
PyMac_PRECHECK(CloseComponentResFile);
848
if (!PyArg_ParseTuple(_args, "h",
851
_err = CloseComponentResFile(refnum);
852
if (_err != noErr) return PyMac_Error(_err);
858
static PyObject *Cm_OpenDefaultComponent(PyObject *_self, PyObject *_args)
860
PyObject *_res = NULL;
861
ComponentInstance _rv;
862
OSType componentType;
863
OSType componentSubType;
864
#ifndef OpenDefaultComponent
865
PyMac_PRECHECK(OpenDefaultComponent);
867
if (!PyArg_ParseTuple(_args, "O&O&",
868
PyMac_GetOSType, &componentType,
869
PyMac_GetOSType, &componentSubType))
871
_rv = OpenDefaultComponent(componentType,
873
_res = Py_BuildValue("O&",
874
CmpInstObj_New, _rv);
878
static PyObject *Cm_RegisterComponentResourceFile(PyObject *_self, PyObject *_args)
880
PyObject *_res = NULL;
884
#ifndef RegisterComponentResourceFile
885
PyMac_PRECHECK(RegisterComponentResourceFile);
887
if (!PyArg_ParseTuple(_args, "hh",
891
_rv = RegisterComponentResourceFile(resRefNum,
893
_res = Py_BuildValue("l",
898
static PyMethodDef Cm_methods[] = {
899
{"RegisterComponentResource", (PyCFunction)Cm_RegisterComponentResource, 1,
900
PyDoc_STR("(ComponentResourceHandle cr, short global) -> (Component _rv)")},
901
{"FindNextComponent", (PyCFunction)Cm_FindNextComponent, 1,
902
PyDoc_STR("(Component aComponent, ComponentDescription looking) -> (Component _rv)")},
903
{"CountComponents", (PyCFunction)Cm_CountComponents, 1,
904
PyDoc_STR("(ComponentDescription looking) -> (long _rv)")},
905
{"GetComponentListModSeed", (PyCFunction)Cm_GetComponentListModSeed, 1,
906
PyDoc_STR("() -> (long _rv)")},
907
{"CloseComponentResFile", (PyCFunction)Cm_CloseComponentResFile, 1,
908
PyDoc_STR("(short refnum) -> None")},
909
{"OpenDefaultComponent", (PyCFunction)Cm_OpenDefaultComponent, 1,
910
PyDoc_STR("(OSType componentType, OSType componentSubType) -> (ComponentInstance _rv)")},
911
{"RegisterComponentResourceFile", (PyCFunction)Cm_RegisterComponentResourceFile, 1,
912
PyDoc_STR("(short resRefNum, short global) -> (long _rv)")},
926
PyMac_INIT_TOOLBOX_OBJECT_NEW(Component, CmpObj_New);
927
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Component, CmpObj_Convert);
928
PyMac_INIT_TOOLBOX_OBJECT_NEW(ComponentInstance, CmpInstObj_New);
929
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ComponentInstance, CmpInstObj_Convert);
932
m = Py_InitModule("_Cm", Cm_methods);
933
d = PyModule_GetDict(m);
934
Cm_Error = PyMac_GetOSErrException();
935
if (Cm_Error == NULL ||
936
PyDict_SetItemString(d, "Error", Cm_Error) != 0)
938
ComponentInstance_Type.ob_type = &PyType_Type;
939
if (PyType_Ready(&ComponentInstance_Type) < 0) return;
940
Py_INCREF(&ComponentInstance_Type);
941
PyModule_AddObject(m, "ComponentInstance", (PyObject *)&ComponentInstance_Type);
942
/* Backward-compatible name */
943
Py_INCREF(&ComponentInstance_Type);
944
PyModule_AddObject(m, "ComponentInstanceType", (PyObject *)&ComponentInstance_Type);
945
Component_Type.ob_type = &PyType_Type;
946
if (PyType_Ready(&Component_Type) < 0) return;
947
Py_INCREF(&Component_Type);
948
PyModule_AddObject(m, "Component", (PyObject *)&Component_Type);
949
/* Backward-compatible name */
950
Py_INCREF(&Component_Type);
951
PyModule_AddObject(m, "ComponentType", (PyObject *)&Component_Type);
954
/* ========================= End module _Cm ========================= */