[Python-checkins] python/dist/src/Mac/Modules OSATerminology.c,1.1,1.2

jackjansen@users.sourceforge.net jackjansen@users.sourceforge.net
2003年3月06日 15:03:03 -0800


Update of /cvsroot/python/python/dist/src/Mac/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv24758
Modified Files:
	OSATerminology.c 
Log Message:
Various tweaks by Jack because of the different module name, adaptation
to the Python style, etc.
Index: OSATerminology.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/OSATerminology.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** OSATerminology.c	6 Mar 2003 23:02:04 -0000	1.1
--- OSATerminology.c	6 Mar 2003 23:02:59 -0000	1.2
***************
*** 1,51 ****
! #include <Python/Python.h>
 #include <Carbon/Carbon.h>
! #include <Python/pymactoolbox.h>
 
! PyObject * PyOSA_GetAppTerminology(PyObject* self, PyObject* args) {
! 	AEDesc temp;
! 	FSSpec tempFSSpec;
! 	
! 	ComponentInstance defaultComponent;
! 	ScriptingComponentSelector theType;
! 	SInt16 defaultTerminology;
! 	Boolean didLaunch;
! 	
 	OSAError err;
 	
! 	PyObject * returnVal;
! 	
! 	if (!PyArg_ParseTuple(args, "O&", PyMac_GetFSSpec, &tempFSSpec)) return NULL;
 	
! defaultComponent = OpenDefaultComponent (kOSAComponentType,
! 					 'ascr');
! //					 kOSAGenericScriptingComponentSubtype);
! 
! err = GetComponentInstanceError (defaultComponent);
! 	printf("OpenDefaultComponent: %d\n", err);
 	err = OSAGetCurrentDialect(defaultComponent, &defaultTerminology);
! 	printf("getcurrentdialect: %d\n", err);
 	err = OSAGetAppTerminology (
 	defaultComponent, 
! 	kOSAModeNull, 
! 	&tempFSSpec, 
 	defaultTerminology, 
 	&didLaunch, 
! 	&temp
 	);
 
! /*	err = ASGetAppTerminology (
 	defaultComponent, 
! 	&tempFSSpec, 
 	defaultTerminology, 
 	&didLaunch, 
! 	&temp
! 	);*/
! 
! 	printf("getappterminology: %d\n", err);
! 
! 	returnVal = Py_BuildValue("O&i",
! 			AEDesc_New, &temp, didLaunch);
! 	return returnVal;
 }
 
--- 1,79 ----
! /*
! ** This module is a one-trick pony: given an FSSpec it gets the aeut
! ** resources. It was written by Donovan Preston and slightly modified
! ** by Jack.
! **
! ** It should be considered a placeholder, it will probably be replaced
! ** by a full interface to OpenScripting.
! */
! #include "Python.h"
! #include "macglue.h"
! 
! #ifdef WITHOUT_FRAMEWORKS
! #include <OpenScripting.h>
! #else
 #include <Carbon/Carbon.h>
! #endif
 
! static PyObject *
! PyOSA_GetAppTerminology(PyObject* self, PyObject* args)
! {
! 	AEDesc theDesc = {0,0};
! 	FSSpec fss;
! 	ComponentInstance defaultComponent = NULL;
! 	SInt16 defaultTerminology = 0;
! 	Boolean didLaunch = 0;
 	OSAError err;
+ 	long modeFlags = 0;
 	
! 	if (!PyArg_ParseTuple(args, "O&|i", PyMac_GetFSSpec, &fss, &modeFlags))
! 		 return NULL;
 	
! 	defaultComponent = OpenDefaultComponent (kOSAComponentType, 'ascr');
! 	err = GetComponentInstanceError (defaultComponent);
! 	if (err) return PyMac_Error(err);
 	err = OSAGetCurrentDialect(defaultComponent, &defaultTerminology);
! 	if (err) return PyMac_Error(err);	
 	err = OSAGetAppTerminology (
 	defaultComponent, 
! 	modeFlags,
! 	&fss, 
 	defaultTerminology, 
 	&didLaunch, 
! 	&theDesc
 	);
+ 	if (err) return PyMac_Error(err);
+ 	return Py_BuildValue("O&i", AEDesc_New, &theDesc, didLaunch);
+ }
 
! static PyObject *
! PyOSA_GetSysTerminology(PyObject* self, PyObject* args)
! {
! 	AEDesc theDesc = {0,0};
! 	FSSpec fss;
! 	ComponentInstance defaultComponent = NULL;
! 	SInt16 defaultTerminology = 0;
! 	Boolean didLaunch = 0;
! 	OSAError err;
! 	long modeFlags = 0;
! 	
! 	if (!PyArg_ParseTuple(args, "O&|i", PyMac_GetFSSpec, &fss, &modeFlags))
! 		 return NULL;
! 	
! 	defaultComponent = OpenDefaultComponent (kOSAComponentType, 'ascr');
! 	err = GetComponentInstanceError (defaultComponent);
! 	if (err) return PyMac_Error(err);
! 	err = OSAGetCurrentDialect(defaultComponent, &defaultTerminology);
! 	if (err) return PyMac_Error(err);	
! 	err = OSAGetAppTerminology (
 	defaultComponent, 
! 	modeFlags,
! 	&fss, 
 	defaultTerminology, 
 	&didLaunch, 
! 	&theDesc
! 	);
! 	if (err) return PyMac_Error(err);
! 	return Py_BuildValue("O&i", AEDesc_New, &theDesc, didLaunch);
 }
 
***************
*** 53,70 ****
 * List of methods defined in the module
 */
! static struct PyMethodDef PyOSA_methods[] =
 {
! {"GetAppTerminology", 
! (PyCFunction) PyOSA_GetAppTerminology,
! METH_VARARGS,
! "Get an applications terminology, as an AEDesc object."},
! 
! {NULL, (PyCFunction) NULL, 0, NULL}
 };
 
 
 void
! initPyOSA(void)
 {
! 	Py_InitModule("PyOSA", PyOSA_methods);
 }
--- 81,101 ----
 * List of methods defined in the module
 */
! static struct PyMethodDef OSATerminology_methods[] =
 {
! 	{"GetAppTerminology", 
! 		(PyCFunction) PyOSA_GetAppTerminology,
! 		METH_VARARGS,
! 		"Get an applications terminology, as an AEDesc object."},
! 	{"GetSysTerminology", 
! 		(PyCFunction) PyOSA_GetSysTerminology,
! 		METH_VARARGS,
! 		"Get an applications system terminology, as an AEDesc object."},
! 	{NULL, (PyCFunction) NULL, 0, NULL}
 };
 
 
 void
! initOSATerminology(void)
 {
! 	Py_InitModule("OSATerminology", OSATerminology_methods);
 }

AltStyle によって変換されたページ (->オリジナル) /