Changeset 391 for python/trunk/Mac/Modules/OSATerminology.c
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Mac/Modules/OSATerminology.c
r2 r391 1 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. 2 ** An interface to the application scripting related functions of the OSA API. 5 3 ** 6 ** It should be considered a placeholder, it will probably be replaced 7 ** by a full interface to OpenScripting. 4 ** GetAppTerminology - given an FSSpec/posix path to an application, 5 ** returns its aevt (scripting terminology) resource(s) 6 ** 7 ** GetSysTerminology - returns the AppleScript language component's 8 ** aeut (scripting terminology) resource 9 ** 10 ** Written by Donovan Preston and slightly modified by Jack and HAS. 8 11 */ 9 12 #include "Python.h" … … 16 19 PyOSA_GetAppTerminology(PyObject* self, PyObject* args) 17 20 { 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); 21 AEDesc theDesc = {0,0}; 22 FSSpec fss; 23 ComponentInstance defaultComponent = NULL; 24 SInt16 defaultTerminology = 0; 25 Boolean didLaunch = 0; 26 OSAError err; 27 long modeFlags = 0; 28 29 if (!PyArg_ParseTuple(args, "O&|i", PyMac_GetFSSpec, &fss, &modeFlags)) 30 return NULL; 31 32 /* 33 ** Note that we have to use the AppleScript component here. Who knows why 34 ** OSAGetAppTerminology should require a scripting component in the 35 ** first place, but it does. Note: doesn't work with the generic scripting 36 ** component, which is unfortunate as the AS component is currently very 37 ** slow (~1 sec?) to load, but we just have to live with this. 38 */ 39 defaultComponent = OpenDefaultComponent (kOSAComponentType, 'ascr'); 40 err = GetComponentInstanceError (defaultComponent); 41 if (err) return PyMac_Error(err); 42 err = OSAGetAppTerminology ( 43 defaultComponent, 44 kOSAModeNull, 45 &fss, 46 defaultTerminology, 47 &didLaunch, 48 &theDesc 49 ); 50 if (err) return PyMac_Error(err); 51 return Py_BuildValue("O&i", AEDesc_New, &theDesc, didLaunch); 42 52 } 43 53 … … 45 55 PyOSA_GetSysTerminology(PyObject* self, PyObject* args) 46 56 { 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); 57 AEDesc theDesc = {0,0}; 58 ComponentInstance defaultComponent = NULL; 59 SInt16 defaultTerminology = 0; 60 OSAError err; 61 62 /* Accept any args for sake of backwards compatibility, then ignore them. */ 63 64 defaultComponent = OpenDefaultComponent (kOSAComponentType, 'ascr'); 65 err = GetComponentInstanceError (defaultComponent); 66 if (err) return PyMac_Error(err); 67 err = OSAGetSysTerminology ( 68 defaultComponent, 69 kOSAModeNull, 70 defaultTerminology, 71 &theDesc 72 ); 73 if (err) return PyMac_Error(err); 74 return Py_BuildValue("O&", AEDesc_New, &theDesc); 71 75 } 72 76 #endif /* !__LP64__ */ 73 77 74 /* 78 /* 75 79 * List of methods defined in the module 76 80 */ … … 78 82 { 79 83 #ifndef __LP64__ 80 {"GetAppTerminology",81 82 83 "Get an applications terminology, as an AEDesc object."},84 {"GetSysTerminology",85 86 87 "Get an applications system terminology, as an AEDesc object."},84 {"GetAppTerminology", 85 (PyCFunction) PyOSA_GetAppTerminology, 86 METH_VARARGS, 87 "Get an application's terminology. GetAppTerminology(path) --> AEDesc"}, 88 {"GetSysTerminology", 89 (PyCFunction) PyOSA_GetSysTerminology, 90 METH_VARARGS, 91 "Get the AppleScript language's terminology. GetSysTerminology() --> AEDesc"}, 88 92 #endif /* !__LP64__ */ 89 93 {NULL, (PyCFunction) NULL, 0, NULL} 90 94 }; 91 95 … … 93 97 initOSATerminology(void) 94 98 { 95 if (PyErr_WarnPy3k("In 3.x, OSATerminologyis removed.", 1) < 0)96 97 99 if (PyErr_WarnPy3k("In 3.x, the OSATerminology module is removed.", 1) < 0) 100 return; 101 Py_InitModule("OSATerminology", OSATerminology_methods); 98 102 }
Note:
See TracChangeset
for help on using the changeset viewer.