|
1 |
|
2 /* ========================== Module _OSA =========================== */ |
|
3 |
|
4 #include "Python.h" |
|
5 |
|
6 |
|
7 |
|
8 #include "pymactoolbox.h" |
|
9 |
|
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"); \ |
|
14 return NULL; \ |
|
15 }} while(0) |
|
16 |
|
17 |
|
18 #if PY_VERSION_HEX < 0x02040000 |
|
19 PyObject *PyMac_GetOSErrException(void); |
|
20 #endif |
|
21 #include <Carbon/Carbon.h> |
|
22 |
|
23 #ifdef USE_TOOLBOX_OBJECT_GLUE |
|
24 extern PyObject *_OSAObj_New(ComponentInstance); |
|
25 extern int _OSAObj_Convert(PyObject *, ComponentInstance *); |
|
26 |
|
27 #define OSAObj_New _OSAObj_New |
|
28 #define OSAObj_Convert _OSAObj_Convert |
|
29 #endif |
|
30 |
|
31 static PyObject *OSA_Error; |
|
32 |
|
33 /* ---------------- Object type OSAComponentInstance ---------------- */ |
|
34 |
|
35 PyTypeObject OSAComponentInstance_Type; |
|
36 |
|
37 #define OSAObj_Check(x) ((x)->ob_type == &OSAComponentInstance_Type || PyObject_TypeCheck((x), &OSAComponentInstance_Type)) |
|
38 |
|
39 typedef struct OSAComponentInstanceObject { |
|
40 PyObject_HEAD |
|
41 ComponentInstance ob_itself; |
|
42 } OSAComponentInstanceObject; |
|
43 |
|
44 PyObject *OSAObj_New(ComponentInstance itself) |
|
45 { |
|
46 OSAComponentInstanceObject *it; |
|
47 if (itself == NULL) { |
|
48 PyErr_SetString(OSA_Error,"NULL ComponentInstance"); |
|
49 return NULL; |
|
50 } |
|
51 it = PyObject_NEW(OSAComponentInstanceObject, &OSAComponentInstance_Type); |
|
52 if (it == NULL) return NULL; |
|
53 it->ob_itself = itself; |
|
54 return (PyObject *)it; |
|
55 } |
|
56 |
|
57 int OSAObj_Convert(PyObject *v, ComponentInstance *p_itself) |
|
58 { |
|
59 |
|
60 if (CmpInstObj_Convert(v, p_itself)) |
|
61 return 1; |
|
62 PyErr_Clear(); |
|
63 |
|
64 if (!OSAObj_Check(v)) |
|
65 { |
|
66 PyErr_SetString(PyExc_TypeError, "OSAComponentInstance required"); |
|
67 return 0; |
|
68 } |
|
69 *p_itself = ((OSAComponentInstanceObject *)v)->ob_itself; |
|
70 return 1; |
|
71 } |
|
72 |
|
73 static void OSAObj_dealloc(OSAComponentInstanceObject *self) |
|
74 { |
|
75 /* Cleanup of self->ob_itself goes here */ |
|
76 self->ob_type->tp_free((PyObject *)self); |
|
77 } |
|
78 |
|
79 static PyObject *OSAObj_OSALoad(OSAComponentInstanceObject *_self, PyObject *_args) |
|
80 { |
|
81 PyObject *_res = NULL; |
|
82 OSAError _err; |
|
83 AEDesc scriptData; |
|
84 long modeFlags; |
|
85 OSAID resultingScriptID; |
|
86 #ifndef OSALoad |
|
87 PyMac_PRECHECK(OSALoad); |
|
88 #endif |
|
89 if (!PyArg_ParseTuple(_args, "O&l", |
|
90 AEDesc_Convert, &scriptData, |
|
91 &modeFlags)) |
|
92 return NULL; |
|
93 _err = OSALoad(_self->ob_itself, |
|
94 &scriptData, |
|
95 modeFlags, |
|
96 &resultingScriptID); |
|
97 if (_err != noErr) return PyMac_Error(_err); |
|
98 _res = Py_BuildValue("l", |
|
99 resultingScriptID); |
|
100 return _res; |
|
101 } |
|
102 |
|
103 static PyObject *OSAObj_OSAStore(OSAComponentInstanceObject *_self, PyObject *_args) |
|
104 { |
|
105 PyObject *_res = NULL; |
|
106 OSAError _err; |
|
107 OSAID scriptID; |
|
108 DescType desiredType; |
|
109 long modeFlags; |
|
110 AEDesc resultingScriptData; |
|
111 #ifndef OSAStore |
|
112 PyMac_PRECHECK(OSAStore); |
|
113 #endif |
|
114 if (!PyArg_ParseTuple(_args, "lO&l", |
|
115 &scriptID, |
|
116 PyMac_GetOSType, &desiredType, |
|
117 &modeFlags)) |
|
118 return NULL; |
|
119 _err = OSAStore(_self->ob_itself, |
|
120 scriptID, |
|
121 desiredType, |
|
122 modeFlags, |
|
123 &resultingScriptData); |
|
124 if (_err != noErr) return PyMac_Error(_err); |
|
125 _res = Py_BuildValue("O&", |
|
126 AEDesc_New, &resultingScriptData); |
|
127 return _res; |
|
128 } |
|
129 |
|
130 static PyObject *OSAObj_OSAExecute(OSAComponentInstanceObject *_self, PyObject *_args) |
|
131 { |
|
132 PyObject *_res = NULL; |
|
133 OSAError _err; |
|
134 OSAID compiledScriptID; |
|
135 OSAID contextID; |
|
136 long modeFlags; |
|
137 OSAID resultingScriptValueID; |
|
138 #ifndef OSAExecute |
|
139 PyMac_PRECHECK(OSAExecute); |
|
140 #endif |
|
141 if (!PyArg_ParseTuple(_args, "lll", |
|
142 &compiledScriptID, |
|
143 &contextID, |
|
144 &modeFlags)) |
|
145 return NULL; |
|
146 _err = OSAExecute(_self->ob_itself, |
|
147 compiledScriptID, |
|
148 contextID, |
|
149 modeFlags, |
|
150 &resultingScriptValueID); |
|
151 if (_err != noErr) return PyMac_Error(_err); |
|
152 _res = Py_BuildValue("l", |
|
153 resultingScriptValueID); |
|
154 return _res; |
|
155 } |
|
156 |
|
157 static PyObject *OSAObj_OSADisplay(OSAComponentInstanceObject *_self, PyObject *_args) |
|
158 { |
|
159 PyObject *_res = NULL; |
|
160 OSAError _err; |
|
161 OSAID scriptValueID; |
|
162 DescType desiredType; |
|
163 long modeFlags; |
|
164 AEDesc resultingText; |
|
165 #ifndef OSADisplay |
|
166 PyMac_PRECHECK(OSADisplay); |
|
167 #endif |
|
168 if (!PyArg_ParseTuple(_args, "lO&l", |
|
169 &scriptValueID, |
|
170 PyMac_GetOSType, &desiredType, |
|
171 &modeFlags)) |
|
172 return NULL; |
|
173 _err = OSADisplay(_self->ob_itself, |
|
174 scriptValueID, |
|
175 desiredType, |
|
176 modeFlags, |
|
177 &resultingText); |
|
178 if (_err != noErr) return PyMac_Error(_err); |
|
179 _res = Py_BuildValue("O&", |
|
180 AEDesc_New, &resultingText); |
|
181 return _res; |
|
182 } |
|
183 |
|
184 static PyObject *OSAObj_OSAScriptError(OSAComponentInstanceObject *_self, PyObject *_args) |
|
185 { |
|
186 PyObject *_res = NULL; |
|
187 OSAError _err; |
|
188 OSType selector; |
|
189 DescType desiredType; |
|
190 AEDesc resultingErrorDescription; |
|
191 #ifndef OSAScriptError |
|
192 PyMac_PRECHECK(OSAScriptError); |
|
193 #endif |
|
194 if (!PyArg_ParseTuple(_args, "O&O&", |
|
195 PyMac_GetOSType, &selector, |
|
196 PyMac_GetOSType, &desiredType)) |
|
197 return NULL; |
|
198 _err = OSAScriptError(_self->ob_itself, |
|
199 selector, |
|
200 desiredType, |
|
201 &resultingErrorDescription); |
|
202 if (_err != noErr) return PyMac_Error(_err); |
|
203 _res = Py_BuildValue("O&", |
|
204 AEDesc_New, &resultingErrorDescription); |
|
205 return _res; |
|
206 } |
|
207 |
|
208 static PyObject *OSAObj_OSADispose(OSAComponentInstanceObject *_self, PyObject *_args) |
|
209 { |
|
210 PyObject *_res = NULL; |
|
211 OSAError _err; |
|
212 OSAID scriptID; |
|
213 #ifndef OSADispose |
|
214 PyMac_PRECHECK(OSADispose); |
|
215 #endif |
|
216 if (!PyArg_ParseTuple(_args, "l", |
|
217 &scriptID)) |
|
218 return NULL; |
|
219 _err = OSADispose(_self->ob_itself, |
|
220 scriptID); |
|
221 if (_err != noErr) return PyMac_Error(_err); |
|
222 Py_INCREF(Py_None); |
|
223 _res = Py_None; |
|
224 return _res; |
|
225 } |
|
226 |
|
227 static PyObject *OSAObj_OSASetScriptInfo(OSAComponentInstanceObject *_self, PyObject *_args) |
|
228 { |
|
229 PyObject *_res = NULL; |
|
230 OSAError _err; |
|
231 OSAID scriptID; |
|
232 OSType selector; |
|
233 long value; |
|
234 #ifndef OSASetScriptInfo |
|
235 PyMac_PRECHECK(OSASetScriptInfo); |
|
236 #endif |
|
237 if (!PyArg_ParseTuple(_args, "lO&l", |
|
238 &scriptID, |
|
239 PyMac_GetOSType, &selector, |
|
240 &value)) |
|
241 return NULL; |
|
242 _err = OSASetScriptInfo(_self->ob_itself, |
|
243 scriptID, |
|
244 selector, |
|
245 value); |
|
246 if (_err != noErr) return PyMac_Error(_err); |
|
247 Py_INCREF(Py_None); |
|
248 _res = Py_None; |
|
249 return _res; |
|
250 } |
|
251 |
|
252 static PyObject *OSAObj_OSAGetScriptInfo(OSAComponentInstanceObject *_self, PyObject *_args) |
|
253 { |
|
254 PyObject *_res = NULL; |
|
255 OSAError _err; |
|
256 OSAID scriptID; |
|
257 OSType selector; |
|
258 long result; |
|
259 #ifndef OSAGetScriptInfo |
|
260 PyMac_PRECHECK(OSAGetScriptInfo); |
|
261 #endif |
|
262 if (!PyArg_ParseTuple(_args, "lO&", |
|
263 &scriptID, |
|
264 PyMac_GetOSType, &selector)) |
|
265 return NULL; |
|
266 _err = OSAGetScriptInfo(_self->ob_itself, |
|
267 scriptID, |
|
268 selector, |
|
269 &result); |
|
270 if (_err != noErr) return PyMac_Error(_err); |
|
271 _res = Py_BuildValue("l", |
|
272 result); |
|
273 return _res; |
|
274 } |
|
275 |
|
276 static PyObject *OSAObj_OSAScriptingComponentName(OSAComponentInstanceObject *_self, PyObject *_args) |
|
277 { |
|
278 PyObject *_res = NULL; |
|
279 OSAError _err; |
|
280 AEDesc resultingScriptingComponentName; |
|
281 #ifndef OSAScriptingComponentName |
|
282 PyMac_PRECHECK(OSAScriptingComponentName); |
|
283 #endif |
|
284 if (!PyArg_ParseTuple(_args, "")) |
|
285 return NULL; |
|
286 _err = OSAScriptingComponentName(_self->ob_itself, |
|
287 &resultingScriptingComponentName); |
|
288 if (_err != noErr) return PyMac_Error(_err); |
|
289 _res = Py_BuildValue("O&", |
|
290 AEDesc_New, &resultingScriptingComponentName); |
|
291 return _res; |
|
292 } |
|
293 |
|
294 static PyObject *OSAObj_OSACompile(OSAComponentInstanceObject *_self, PyObject *_args) |
|
295 { |
|
296 PyObject *_res = NULL; |
|
297 OSAError _err; |
|
298 AEDesc sourceData; |
|
299 long modeFlags; |
|
300 OSAID previousAndResultingScriptID; |
|
301 #ifndef OSACompile |
|
302 PyMac_PRECHECK(OSACompile); |
|
303 #endif |
|
304 if (!PyArg_ParseTuple(_args, "O&l", |
|
305 AEDesc_Convert, &sourceData, |
|
306 &modeFlags)) |
|
307 return NULL; |
|
308 _err = OSACompile(_self->ob_itself, |
|
309 &sourceData, |
|
310 modeFlags, |
|
311 &previousAndResultingScriptID); |
|
312 if (_err != noErr) return PyMac_Error(_err); |
|
313 _res = Py_BuildValue("l", |
|
314 previousAndResultingScriptID); |
|
315 return _res; |
|
316 } |
|
317 |
|
318 static PyObject *OSAObj_OSACopyID(OSAComponentInstanceObject *_self, PyObject *_args) |
|
319 { |
|
320 PyObject *_res = NULL; |
|
321 OSAError _err; |
|
322 OSAID fromID; |
|
323 OSAID toID; |
|
324 #ifndef OSACopyID |
|
325 PyMac_PRECHECK(OSACopyID); |
|
326 #endif |
|
327 if (!PyArg_ParseTuple(_args, "l", |
|
328 &fromID)) |
|
329 return NULL; |
|
330 _err = OSACopyID(_self->ob_itself, |
|
331 fromID, |
|
332 &toID); |
|
333 if (_err != noErr) return PyMac_Error(_err); |
|
334 _res = Py_BuildValue("l", |
|
335 toID); |
|
336 return _res; |
|
337 } |
|
338 |
|
339 static PyObject *OSAObj_OSAGetSource(OSAComponentInstanceObject *_self, PyObject *_args) |
|
340 { |
|
341 PyObject *_res = NULL; |
|
342 OSAError _err; |
|
343 OSAID scriptID; |
|
344 DescType desiredType; |
|
345 AEDesc resultingSourceData; |
|
346 #ifndef OSAGetSource |
|
347 PyMac_PRECHECK(OSAGetSource); |
|
348 #endif |
|
349 if (!PyArg_ParseTuple(_args, "lO&", |
|
350 &scriptID, |
|
351 PyMac_GetOSType, &desiredType)) |
|
352 return NULL; |
|
353 _err = OSAGetSource(_self->ob_itself, |
|
354 scriptID, |
|
355 desiredType, |
|
356 &resultingSourceData); |
|
357 if (_err != noErr) return PyMac_Error(_err); |
|
358 _res = Py_BuildValue("O&", |
|
359 AEDesc_New, &resultingSourceData); |
|
360 return _res; |
|
361 } |
|
362 |
|
363 static PyObject *OSAObj_OSACoerceFromDesc(OSAComponentInstanceObject *_self, PyObject *_args) |
|
364 { |
|
365 PyObject *_res = NULL; |
|
366 OSAError _err; |
|
367 AEDesc scriptData; |
|
368 long modeFlags; |
|
369 OSAID resultingScriptID; |
|
370 #ifndef OSACoerceFromDesc |
|
371 PyMac_PRECHECK(OSACoerceFromDesc); |
|
372 #endif |
|
373 if (!PyArg_ParseTuple(_args, "O&l", |
|
374 AEDesc_Convert, &scriptData, |
|
375 &modeFlags)) |
|
376 return NULL; |
|
377 _err = OSACoerceFromDesc(_self->ob_itself, |
|
378 &scriptData, |
|
379 modeFlags, |
|
380 &resultingScriptID); |
|
381 if (_err != noErr) return PyMac_Error(_err); |
|
382 _res = Py_BuildValue("l", |
|
383 resultingScriptID); |
|
384 return _res; |
|
385 } |
|
386 |
|
387 static PyObject *OSAObj_OSACoerceToDesc(OSAComponentInstanceObject *_self, PyObject *_args) |
|
388 { |
|
389 PyObject *_res = NULL; |
|
390 OSAError _err; |
|
391 OSAID scriptID; |
|
392 DescType desiredType; |
|
393 long modeFlags; |
|
394 AEDesc result; |
|
395 #ifndef OSACoerceToDesc |
|
396 PyMac_PRECHECK(OSACoerceToDesc); |
|
397 #endif |
|
398 if (!PyArg_ParseTuple(_args, "lO&l", |
|
399 &scriptID, |
|
400 PyMac_GetOSType, &desiredType, |
|
401 &modeFlags)) |
|
402 return NULL; |
|
403 _err = OSACoerceToDesc(_self->ob_itself, |
|
404 scriptID, |
|
405 desiredType, |
|
406 modeFlags, |
|
407 &result); |
|
408 if (_err != noErr) return PyMac_Error(_err); |
|
409 _res = Py_BuildValue("O&", |
|
410 AEDesc_New, &result); |
|
411 return _res; |
|
412 } |
|
413 |
|
414 static PyObject *OSAObj_OSASetDefaultTarget(OSAComponentInstanceObject *_self, PyObject *_args) |
|
415 { |
|
416 PyObject *_res = NULL; |
|
417 OSAError _err; |
|
418 AEAddressDesc target; |
|
419 #ifndef OSASetDefaultTarget |
|
420 PyMac_PRECHECK(OSASetDefaultTarget); |
|
421 #endif |
|
422 if (!PyArg_ParseTuple(_args, "O&", |
|
423 AEDesc_Convert, &target)) |
|
424 return NULL; |
|
425 _err = OSASetDefaultTarget(_self->ob_itself, |
|
426 &target); |
|
427 if (_err != noErr) return PyMac_Error(_err); |
|
428 Py_INCREF(Py_None); |
|
429 _res = Py_None; |
|
430 return _res; |
|
431 } |
|
432 |
|
433 static PyObject *OSAObj_OSAStartRecording(OSAComponentInstanceObject *_self, PyObject *_args) |
|
434 { |
|
435 PyObject *_res = NULL; |
|
436 OSAError _err; |
|
437 OSAID compiledScriptToModifyID; |
|
438 #ifndef OSAStartRecording |
|
439 PyMac_PRECHECK(OSAStartRecording); |
|
440 #endif |
|
441 if (!PyArg_ParseTuple(_args, "")) |
|
442 return NULL; |
|
443 _err = OSAStartRecording(_self->ob_itself, |
|
444 &compiledScriptToModifyID); |
|
445 if (_err != noErr) return PyMac_Error(_err); |
|
446 _res = Py_BuildValue("l", |
|
447 compiledScriptToModifyID); |
|
448 return _res; |
|
449 } |
|
450 |
|
451 static PyObject *OSAObj_OSAStopRecording(OSAComponentInstanceObject *_self, PyObject *_args) |
|
452 { |
|
453 PyObject *_res = NULL; |
|
454 OSAError _err; |
|
455 OSAID compiledScriptID; |
|
456 #ifndef OSAStopRecording |
|
457 PyMac_PRECHECK(OSAStopRecording); |
|
458 #endif |
|
459 if (!PyArg_ParseTuple(_args, "l", |
|
460 &compiledScriptID)) |
|
461 return NULL; |
|
462 _err = OSAStopRecording(_self->ob_itself, |
|
463 compiledScriptID); |
|
464 if (_err != noErr) return PyMac_Error(_err); |
|
465 Py_INCREF(Py_None); |
|
466 _res = Py_None; |
|
467 return _res; |
|
468 } |
|
469 |
|
470 static PyObject *OSAObj_OSALoadExecute(OSAComponentInstanceObject *_self, PyObject *_args) |
|
471 { |
|
472 PyObject *_res = NULL; |
|
473 OSAError _err; |
|
474 AEDesc scriptData; |
|
475 OSAID contextID; |
|
476 long modeFlags; |
|
477 OSAID resultingScriptValueID; |
|
478 #ifndef OSALoadExecute |
|
479 PyMac_PRECHECK(OSALoadExecute); |
|
480 #endif |
|
481 if (!PyArg_ParseTuple(_args, "O&ll", |
|
482 AEDesc_Convert, &scriptData, |
|
483 &contextID, |
|
484 &modeFlags)) |
|
485 return NULL; |
|
486 _err = OSALoadExecute(_self->ob_itself, |
|
487 &scriptData, |
|
488 contextID, |
|
489 modeFlags, |
|
490 &resultingScriptValueID); |
|
491 if (_err != noErr) return PyMac_Error(_err); |
|
492 _res = Py_BuildValue("l", |
|
493 resultingScriptValueID); |
|
494 return _res; |
|
495 } |
|
496 |
|
497 static PyObject *OSAObj_OSACompileExecute(OSAComponentInstanceObject *_self, PyObject *_args) |
|
498 { |
|
499 PyObject *_res = NULL; |
|
500 OSAError _err; |
|
501 AEDesc sourceData; |
|
502 OSAID contextID; |
|
503 long modeFlags; |
|
504 OSAID resultingScriptValueID; |
|
505 #ifndef OSACompileExecute |
|
506 PyMac_PRECHECK(OSACompileExecute); |
|
507 #endif |
|
508 if (!PyArg_ParseTuple(_args, "O&ll", |
|
509 AEDesc_Convert, &sourceData, |
|
510 &contextID, |
|
511 &modeFlags)) |
|
512 return NULL; |
|
513 _err = OSACompileExecute(_self->ob_itself, |
|
514 &sourceData, |
|
515 contextID, |
|
516 modeFlags, |
|
517 &resultingScriptValueID); |
|
518 if (_err != noErr) return PyMac_Error(_err); |
|
519 _res = Py_BuildValue("l", |
|
520 resultingScriptValueID); |
|
521 return _res; |
|
522 } |
|
523 |
|
524 static PyObject *OSAObj_OSADoScript(OSAComponentInstanceObject *_self, PyObject *_args) |
|
525 { |
|
526 PyObject *_res = NULL; |
|
527 OSAError _err; |
|
528 AEDesc sourceData; |
|
529 OSAID contextID; |
|
530 DescType desiredType; |
|
531 long modeFlags; |
|
532 AEDesc resultingText; |
|
533 #ifndef OSADoScript |
|
534 PyMac_PRECHECK(OSADoScript); |
|
535 #endif |
|
536 if (!PyArg_ParseTuple(_args, "O&lO&l", |
|
537 AEDesc_Convert, &sourceData, |
|
538 &contextID, |
|
539 PyMac_GetOSType, &desiredType, |
|
540 &modeFlags)) |
|
541 return NULL; |
|
542 _err = OSADoScript(_self->ob_itself, |
|
543 &sourceData, |
|
544 contextID, |
|
545 desiredType, |
|
546 modeFlags, |
|
547 &resultingText); |
|
548 if (_err != noErr) return PyMac_Error(_err); |
|
549 _res = Py_BuildValue("O&", |
|
550 AEDesc_New, &resultingText); |
|
551 return _res; |
|
552 } |
|
553 |
|
554 static PyObject *OSAObj_OSASetCurrentDialect(OSAComponentInstanceObject *_self, PyObject *_args) |
|
555 { |
|
556 PyObject *_res = NULL; |
|
557 OSAError _err; |
|
558 short dialectCode; |
|
559 #ifndef OSASetCurrentDialect |
|
560 PyMac_PRECHECK(OSASetCurrentDialect); |
|
561 #endif |
|
562 if (!PyArg_ParseTuple(_args, "h", |
|
563 &dialectCode)) |
|
564 return NULL; |
|
565 _err = OSASetCurrentDialect(_self->ob_itself, |
|
566 dialectCode); |
|
567 if (_err != noErr) return PyMac_Error(_err); |
|
568 Py_INCREF(Py_None); |
|
569 _res = Py_None; |
|
570 return _res; |
|
571 } |
|
572 |
|
573 static PyObject *OSAObj_OSAGetCurrentDialect(OSAComponentInstanceObject *_self, PyObject *_args) |
|
574 { |
|
575 PyObject *_res = NULL; |
|
576 OSAError _err; |
|
577 short resultingDialectCode; |
|
578 #ifndef OSAGetCurrentDialect |
|
579 PyMac_PRECHECK(OSAGetCurrentDialect); |
|
580 #endif |
|
581 if (!PyArg_ParseTuple(_args, "")) |
|
582 return NULL; |
|
583 _err = OSAGetCurrentDialect(_self->ob_itself, |
|
584 &resultingDialectCode); |
|
585 if (_err != noErr) return PyMac_Error(_err); |
|
586 _res = Py_BuildValue("h", |
|
587 resultingDialectCode); |
|
588 return _res; |
|
589 } |
|
590 |
|
591 static PyObject *OSAObj_OSAAvailableDialects(OSAComponentInstanceObject *_self, PyObject *_args) |
|
592 { |
|
593 PyObject *_res = NULL; |
|
594 OSAError _err; |
|
595 AEDesc resultingDialectInfoList; |
|
596 #ifndef OSAAvailableDialects |
|
597 PyMac_PRECHECK(OSAAvailableDialects); |
|
598 #endif |
|
599 if (!PyArg_ParseTuple(_args, "")) |
|
600 return NULL; |
|
601 _err = OSAAvailableDialects(_self->ob_itself, |
|
602 &resultingDialectInfoList); |
|
603 if (_err != noErr) return PyMac_Error(_err); |
|
604 _res = Py_BuildValue("O&", |
|
605 AEDesc_New, &resultingDialectInfoList); |
|
606 return _res; |
|
607 } |
|
608 |
|
609 static PyObject *OSAObj_OSAGetDialectInfo(OSAComponentInstanceObject *_self, PyObject *_args) |
|
610 { |
|
611 PyObject *_res = NULL; |
|
612 OSAError _err; |
|
613 short dialectCode; |
|
614 OSType selector; |
|
615 AEDesc resultingDialectInfo; |
|
616 #ifndef OSAGetDialectInfo |
|
617 PyMac_PRECHECK(OSAGetDialectInfo); |
|
618 #endif |
|
619 if (!PyArg_ParseTuple(_args, "hO&", |
|
620 &dialectCode, |
|
621 PyMac_GetOSType, &selector)) |
|
622 return NULL; |
|
623 _err = OSAGetDialectInfo(_self->ob_itself, |
|
624 dialectCode, |
|
625 selector, |
|
626 &resultingDialectInfo); |
|
627 if (_err != noErr) return PyMac_Error(_err); |
|
628 _res = Py_BuildValue("O&", |
|
629 AEDesc_New, &resultingDialectInfo); |
|
630 return _res; |
|
631 } |
|
632 |
|
633 static PyObject *OSAObj_OSAAvailableDialectCodeList(OSAComponentInstanceObject *_self, PyObject *_args) |
|
634 { |
|
635 PyObject *_res = NULL; |
|
636 OSAError _err; |
|
637 AEDesc resultingDialectCodeList; |
|
638 #ifndef OSAAvailableDialectCodeList |
|
639 PyMac_PRECHECK(OSAAvailableDialectCodeList); |
|
640 #endif |
|
641 if (!PyArg_ParseTuple(_args, "")) |
|
642 return NULL; |
|
643 _err = OSAAvailableDialectCodeList(_self->ob_itself, |
|
644 &resultingDialectCodeList); |
|
645 if (_err != noErr) return PyMac_Error(_err); |
|
646 _res = Py_BuildValue("O&", |
|
647 AEDesc_New, &resultingDialectCodeList); |
|
648 return _res; |
|
649 } |
|
650 |
|
651 static PyObject *OSAObj_OSAExecuteEvent(OSAComponentInstanceObject *_self, PyObject *_args) |
|
652 { |
|
653 PyObject *_res = NULL; |
|
654 OSAError _err; |
|
655 AppleEvent theAppleEvent; |
|
656 OSAID contextID; |
|
657 long modeFlags; |
|
658 OSAID resultingScriptValueID; |
|
659 #ifndef OSAExecuteEvent |
|
660 PyMac_PRECHECK(OSAExecuteEvent); |
|
661 #endif |
|
662 if (!PyArg_ParseTuple(_args, "O&ll", |
|
663 AEDesc_Convert, &theAppleEvent, |
|
664 &contextID, |
|
665 &modeFlags)) |
|
666 return NULL; |
|
667 _err = OSAExecuteEvent(_self->ob_itself, |
|
668 &theAppleEvent, |
|
669 contextID, |
|
670 modeFlags, |
|
671 &resultingScriptValueID); |
|
672 if (_err != noErr) return PyMac_Error(_err); |
|
673 _res = Py_BuildValue("l", |
|
674 resultingScriptValueID); |
|
675 return _res; |
|
676 } |
|
677 |
|
678 static PyObject *OSAObj_OSADoEvent(OSAComponentInstanceObject *_self, PyObject *_args) |
|
679 { |
|
680 PyObject *_res = NULL; |
|
681 OSAError _err; |
|
682 AppleEvent theAppleEvent; |
|
683 OSAID contextID; |
|
684 long modeFlags; |
|
685 AppleEvent reply; |
|
686 #ifndef OSADoEvent |
|
687 PyMac_PRECHECK(OSADoEvent); |
|
688 #endif |
|
689 if (!PyArg_ParseTuple(_args, "O&ll", |
|
690 AEDesc_Convert, &theAppleEvent, |
|
691 &contextID, |
|
692 &modeFlags)) |
|
693 return NULL; |
|
694 _err = OSADoEvent(_self->ob_itself, |
|
695 &theAppleEvent, |
|
696 contextID, |
|
697 modeFlags, |
|
698 &reply); |
|
699 if (_err != noErr) return PyMac_Error(_err); |
|
700 _res = Py_BuildValue("O&", |
|
701 AEDesc_New, &reply); |
|
702 return _res; |
|
703 } |
|
704 |
|
705 static PyObject *OSAObj_OSAMakeContext(OSAComponentInstanceObject *_self, PyObject *_args) |
|
706 { |
|
707 PyObject *_res = NULL; |
|
708 OSAError _err; |
|
709 AEDesc contextName; |
|
710 OSAID parentContext; |
|
711 OSAID resultingContextID; |
|
712 #ifndef OSAMakeContext |
|
713 PyMac_PRECHECK(OSAMakeContext); |
|
714 #endif |
|
715 if (!PyArg_ParseTuple(_args, "O&l", |
|
716 AEDesc_Convert, &contextName, |
|
717 &parentContext)) |
|
718 return NULL; |
|
719 _err = OSAMakeContext(_self->ob_itself, |
|
720 &contextName, |
|
721 parentContext, |
|
722 &resultingContextID); |
|
723 if (_err != noErr) return PyMac_Error(_err); |
|
724 _res = Py_BuildValue("l", |
|
725 resultingContextID); |
|
726 return _res; |
|
727 } |
|
728 |
|
729 static PyMethodDef OSAObj_methods[] = { |
|
730 {"OSALoad", (PyCFunction)OSAObj_OSALoad, 1, |
|
731 PyDoc_STR("(AEDesc scriptData, long modeFlags) -> (OSAID resultingScriptID)")}, |
|
732 {"OSAStore", (PyCFunction)OSAObj_OSAStore, 1, |
|
733 PyDoc_STR("(OSAID scriptID, DescType desiredType, long modeFlags) -> (AEDesc resultingScriptData)")}, |
|
734 {"OSAExecute", (PyCFunction)OSAObj_OSAExecute, 1, |
|
735 PyDoc_STR("(OSAID compiledScriptID, OSAID contextID, long modeFlags) -> (OSAID resultingScriptValueID)")}, |
|
736 {"OSADisplay", (PyCFunction)OSAObj_OSADisplay, 1, |
|
737 PyDoc_STR("(OSAID scriptValueID, DescType desiredType, long modeFlags) -> (AEDesc resultingText)")}, |
|
738 {"OSAScriptError", (PyCFunction)OSAObj_OSAScriptError, 1, |
|
739 PyDoc_STR("(OSType selector, DescType desiredType) -> (AEDesc resultingErrorDescription)")}, |
|
740 {"OSADispose", (PyCFunction)OSAObj_OSADispose, 1, |
|
741 PyDoc_STR("(OSAID scriptID) -> None")}, |
|
742 {"OSASetScriptInfo", (PyCFunction)OSAObj_OSASetScriptInfo, 1, |
|
743 PyDoc_STR("(OSAID scriptID, OSType selector, long value) -> None")}, |
|
744 {"OSAGetScriptInfo", (PyCFunction)OSAObj_OSAGetScriptInfo, 1, |
|
745 PyDoc_STR("(OSAID scriptID, OSType selector) -> (long result)")}, |
|
746 {"OSAScriptingComponentName", (PyCFunction)OSAObj_OSAScriptingComponentName, 1, |
|
747 PyDoc_STR("() -> (AEDesc resultingScriptingComponentName)")}, |
|
748 {"OSACompile", (PyCFunction)OSAObj_OSACompile, 1, |
|
749 PyDoc_STR("(AEDesc sourceData, long modeFlags) -> (OSAID previousAndResultingScriptID)")}, |
|
750 {"OSACopyID", (PyCFunction)OSAObj_OSACopyID, 1, |
|
751 PyDoc_STR("(OSAID fromID) -> (OSAID toID)")}, |
|
752 {"OSAGetSource", (PyCFunction)OSAObj_OSAGetSource, 1, |
|
753 PyDoc_STR("(OSAID scriptID, DescType desiredType) -> (AEDesc resultingSourceData)")}, |
|
754 {"OSACoerceFromDesc", (PyCFunction)OSAObj_OSACoerceFromDesc, 1, |
|
755 PyDoc_STR("(AEDesc scriptData, long modeFlags) -> (OSAID resultingScriptID)")}, |
|
756 {"OSACoerceToDesc", (PyCFunction)OSAObj_OSACoerceToDesc, 1, |
|
757 PyDoc_STR("(OSAID scriptID, DescType desiredType, long modeFlags) -> (AEDesc result)")}, |
|
758 {"OSASetDefaultTarget", (PyCFunction)OSAObj_OSASetDefaultTarget, 1, |
|
759 PyDoc_STR("(AEAddressDesc target) -> None")}, |
|
760 {"OSAStartRecording", (PyCFunction)OSAObj_OSAStartRecording, 1, |
|
761 PyDoc_STR("() -> (OSAID compiledScriptToModifyID)")}, |
|
762 {"OSAStopRecording", (PyCFunction)OSAObj_OSAStopRecording, 1, |
|
763 PyDoc_STR("(OSAID compiledScriptID) -> None")}, |
|
764 {"OSALoadExecute", (PyCFunction)OSAObj_OSALoadExecute, 1, |
|
765 PyDoc_STR("(AEDesc scriptData, OSAID contextID, long modeFlags) -> (OSAID resultingScriptValueID)")}, |
|
766 {"OSACompileExecute", (PyCFunction)OSAObj_OSACompileExecute, 1, |
|
767 PyDoc_STR("(AEDesc sourceData, OSAID contextID, long modeFlags) -> (OSAID resultingScriptValueID)")}, |
|
768 {"OSADoScript", (PyCFunction)OSAObj_OSADoScript, 1, |
|
769 PyDoc_STR("(AEDesc sourceData, OSAID contextID, DescType desiredType, long modeFlags) -> (AEDesc resultingText)")}, |
|
770 {"OSASetCurrentDialect", (PyCFunction)OSAObj_OSASetCurrentDialect, 1, |
|
771 PyDoc_STR("(short dialectCode) -> None")}, |
|
772 {"OSAGetCurrentDialect", (PyCFunction)OSAObj_OSAGetCurrentDialect, 1, |
|
773 PyDoc_STR("() -> (short resultingDialectCode)")}, |
|
774 {"OSAAvailableDialects", (PyCFunction)OSAObj_OSAAvailableDialects, 1, |
|
775 PyDoc_STR("() -> (AEDesc resultingDialectInfoList)")}, |
|
776 {"OSAGetDialectInfo", (PyCFunction)OSAObj_OSAGetDialectInfo, 1, |
|
777 PyDoc_STR("(short dialectCode, OSType selector) -> (AEDesc resultingDialectInfo)")}, |
|
778 {"OSAAvailableDialectCodeList", (PyCFunction)OSAObj_OSAAvailableDialectCodeList, 1, |
|
779 PyDoc_STR("() -> (AEDesc resultingDialectCodeList)")}, |
|
780 {"OSAExecuteEvent", (PyCFunction)OSAObj_OSAExecuteEvent, 1, |
|
781 PyDoc_STR("(AppleEvent theAppleEvent, OSAID contextID, long modeFlags) -> (OSAID resultingScriptValueID)")}, |
|
782 {"OSADoEvent", (PyCFunction)OSAObj_OSADoEvent, 1, |
|
783 PyDoc_STR("(AppleEvent theAppleEvent, OSAID contextID, long modeFlags) -> (AppleEvent reply)")}, |
|
784 {"OSAMakeContext", (PyCFunction)OSAObj_OSAMakeContext, 1, |
|
785 PyDoc_STR("(AEDesc contextName, OSAID parentContext) -> (OSAID resultingContextID)")}, |
|
786 {NULL, NULL, 0} |
|
787 }; |
|
788 |
|
789 #define OSAObj_getsetlist NULL |
|
790 |
|
791 |
|
792 #define OSAObj_compare NULL |
|
793 |
|
794 #define OSAObj_repr NULL |
|
795 |
|
796 #define OSAObj_hash NULL |
|
797 #define OSAObj_tp_init 0 |
|
798 |
|
799 #define OSAObj_tp_alloc PyType_GenericAlloc |
|
800 |
|
801 static PyObject *OSAObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
|
802 { |
|
803 PyObject *_self; |
|
804 ComponentInstance itself; |
|
805 char *kw[] = {"itself", 0}; |
|
806 |
|
807 if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, OSAObj_Convert, &itself)) return NULL; |
|
808 if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; |
|
809 ((OSAComponentInstanceObject *)_self)->ob_itself = itself; |
|
810 return _self; |
|
811 } |
|
812 |
|
813 #define OSAObj_tp_free PyObject_Del |
|
814 |
|
815 |
|
816 PyTypeObject OSAComponentInstance_Type = { |
|
817 PyObject_HEAD_INIT(NULL) |
|
818 0, /*ob_size*/ |
|
819 "_OSA.OSAComponentInstance", /*tp_name*/ |
|
820 sizeof(OSAComponentInstanceObject), /*tp_basicsize*/ |
|
821 0, /*tp_itemsize*/ |
|
822 /* methods */ |
|
823 (destructor) OSAObj_dealloc, /*tp_dealloc*/ |
|
824 0, /*tp_print*/ |
|
825 (getattrfunc)0, /*tp_getattr*/ |
|
826 (setattrfunc)0, /*tp_setattr*/ |
|
827 (cmpfunc) OSAObj_compare, /*tp_compare*/ |
|
828 (reprfunc) OSAObj_repr, /*tp_repr*/ |
|
829 (PyNumberMethods *)0, /* tp_as_number */ |
|
830 (PySequenceMethods *)0, /* tp_as_sequence */ |
|
831 (PyMappingMethods *)0, /* tp_as_mapping */ |
|
832 (hashfunc) OSAObj_hash, /*tp_hash*/ |
|
833 0, /*tp_call*/ |
|
834 0, /*tp_str*/ |
|
835 PyObject_GenericGetAttr, /*tp_getattro*/ |
|
836 PyObject_GenericSetAttr, /*tp_setattro */ |
|
837 0, /*tp_as_buffer*/ |
|
838 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ |
|
839 0, /*tp_doc*/ |
|
840 0, /*tp_traverse*/ |
|
841 0, /*tp_clear*/ |
|
842 0, /*tp_richcompare*/ |
|
843 0, /*tp_weaklistoffset*/ |
|
844 0, /*tp_iter*/ |
|
845 0, /*tp_iternext*/ |
|
846 OSAObj_methods, /* tp_methods */ |
|
847 0, /*tp_members*/ |
|
848 OSAObj_getsetlist, /*tp_getset*/ |
|
849 0, /*tp_base*/ |
|
850 0, /*tp_dict*/ |
|
851 0, /*tp_descr_get*/ |
|
852 0, /*tp_descr_set*/ |
|
853 0, /*tp_dictoffset*/ |
|
854 OSAObj_tp_init, /* tp_init */ |
|
855 OSAObj_tp_alloc, /* tp_alloc */ |
|
856 OSAObj_tp_new, /* tp_new */ |
|
857 OSAObj_tp_free, /* tp_free */ |
|
858 }; |
|
859 |
|
860 /* -------------- End object type OSAComponentInstance -------------- */ |
|
861 |
|
862 |
|
863 static PyMethodDef OSA_methods[] = { |
|
864 {NULL, NULL, 0} |
|
865 }; |
|
866 |
|
867 |
|
868 |
|
869 |
|
870 void init_OSA(void) |
|
871 { |
|
872 PyObject *m; |
|
873 PyObject *d; |
|
874 |
|
875 |
|
876 |
|
877 /* |
|
878 PyMac_INIT_TOOLBOX_OBJECT_NEW(ComponentInstance, OSAObj_New); |
|
879 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ComponentInstance, OSAObj_Convert); |
|
880 */ |
|
881 |
|
882 |
|
883 m = Py_InitModule("_OSA", OSA_methods); |
|
884 d = PyModule_GetDict(m); |
|
885 OSA_Error = PyMac_GetOSErrException(); |
|
886 if (OSA_Error == NULL || |
|
887 PyDict_SetItemString(d, "Error", OSA_Error) != 0) |
|
888 return; |
|
889 OSAComponentInstance_Type.ob_type = &PyType_Type; |
|
890 if (PyType_Ready(&OSAComponentInstance_Type) < 0) return; |
|
891 Py_INCREF(&OSAComponentInstance_Type); |
|
892 PyModule_AddObject(m, "OSAComponentInstance", (PyObject *)&OSAComponentInstance_Type); |
|
893 /* Backward-compatible name */ |
|
894 Py_INCREF(&OSAComponentInstance_Type); |
|
895 PyModule_AddObject(m, "OSAComponentInstanceType", (PyObject *)&OSAComponentInstance_Type); |
|
896 } |
|
897 |
|
898 /* ======================== End module _OSA ========================= */ |
|
899 |