1 | /*
|
---|
2 | ** This module is a one-trick pony: given an FSSpec it gets the aeut
|
---|
3 | ** resources. It was written by Donovan Preston and slightly modified
|
---|
4 | ** by Jack.
|
---|
5 | **
|
---|
6 | ** It should be considered a placeholder, it will probably be replaced
|
---|
7 | ** by a full interface to OpenScripting.
|
---|
8 | */
|
---|
9 | #include "Python.h"
|
---|
10 | #include "pymactoolbox.h"
|
---|
11 |
|
---|
12 | #include <Carbon/Carbon.h>
|
---|
13 |
|
---|
14 | #ifndef __LP64__
|
---|
15 | static PyObject *
|
---|
16 | PyOSA_GetAppTerminology(PyObject* self, PyObject* args)
|
---|
17 | {
|
---|
18 | AEDesc theDesc = {0,0};
|
---|
19 | FSSpec fss;
|
---|
20 | ComponentInstance defaultComponent = NULL;
|
---|
21 | SInt16 defaultTerminology = 0;
|
---|
22 | Boolean didLaunch = 0;
|
---|
23 | OSAError err;
|
---|
24 | long modeFlags = 0;
|
---|
25 |
|
---|
26 | if (!PyArg_ParseTuple(args, "O&|i", PyMac_GetFSSpec, &fss, &modeFlags))
|
---|
27 | return NULL;
|
---|
28 |
|
---|
29 | defaultComponent = OpenDefaultComponent (kOSAComponentType, 'ascr');
|
---|
30 | err = GetComponentInstanceError (defaultComponent);
|
---|
31 | if (err) return PyMac_Error(err);
|
---|
32 | err = OSAGetAppTerminology (
|
---|
33 | defaultComponent,
|
---|
34 | modeFlags,
|
---|
35 | &fss,
|
---|
36 | defaultTerminology,
|
---|
37 | &didLaunch,
|
---|
38 | &theDesc
|
---|
39 | );
|
---|
40 | if (err) return PyMac_Error(err);
|
---|
41 | return Py_BuildValue("O&i", AEDesc_New, &theDesc, didLaunch);
|
---|
42 | }
|
---|
43 |
|
---|
44 | static PyObject *
|
---|
45 | PyOSA_GetSysTerminology(PyObject* self, PyObject* args)
|
---|
46 | {
|
---|
47 | AEDesc theDesc = {0,0};
|
---|
48 | FSSpec fss;
|
---|
49 | ComponentInstance defaultComponent = NULL;
|
---|
50 | SInt16 defaultTerminology = 0;
|
---|
51 | Boolean didLaunch = 0;
|
---|
52 | OSAError err;
|
---|
53 | long modeFlags = 0;
|
---|
54 |
|
---|
55 | if (!PyArg_ParseTuple(args, "O&|i", PyMac_GetFSSpec, &fss, &modeFlags))
|
---|
56 | return NULL;
|
---|
57 |
|
---|
58 | defaultComponent = OpenDefaultComponent (kOSAComponentType, 'ascr');
|
---|
59 | err = GetComponentInstanceError (defaultComponent);
|
---|
60 | if (err) return PyMac_Error(err);
|
---|
61 | err = OSAGetAppTerminology (
|
---|
62 | defaultComponent,
|
---|
63 | modeFlags,
|
---|
64 | &fss,
|
---|
65 | defaultTerminology,
|
---|
66 | &didLaunch,
|
---|
67 | &theDesc
|
---|
68 | );
|
---|
69 | if (err) return PyMac_Error(err);
|
---|
70 | return Py_BuildValue("O&i", AEDesc_New, &theDesc, didLaunch);
|
---|
71 | }
|
---|
72 | #endif /* !__LP64__ */
|
---|
73 |
|
---|
74 | /*
|
---|
75 | * List of methods defined in the module
|
---|
76 | */
|
---|
77 | static struct PyMethodDef OSATerminology_methods[] =
|
---|
78 | {
|
---|
79 | #ifndef __LP64__
|
---|
80 | {"GetAppTerminology",
|
---|
81 | (PyCFunction) PyOSA_GetAppTerminology,
|
---|
82 | METH_VARARGS,
|
---|
83 | "Get an applications terminology, as an AEDesc object."},
|
---|
84 | {"GetSysTerminology",
|
---|
85 | (PyCFunction) PyOSA_GetSysTerminology,
|
---|
86 | METH_VARARGS,
|
---|
87 | "Get an applications system terminology, as an AEDesc object."},
|
---|
88 | #endif /* !__LP64__ */
|
---|
89 | {NULL, (PyCFunction) NULL, 0, NULL}
|
---|
90 | };
|
---|
91 |
|
---|
92 | void
|
---|
93 | initOSATerminology(void)
|
---|
94 | {
|
---|
95 | if (PyErr_WarnPy3k("In 3.x, OSATerminology is removed.", 1) < 0)
|
---|
96 | return;
|
---|
97 | Py_InitModule("OSATerminology", OSATerminology_methods);
|
---|
98 | }
|
---|