[Python-checkins] python/dist/src/Mac/Modules/carbonevt CarbonEvtscan.py, 1.9, 1.10 CarbonEvtsupport.py, 1.14, 1.15 _CarbonEvtmodule.c, 1.15, 1.16

jackjansen at users.sourceforge.net jackjansen at users.sourceforge.net
Thu Nov 20 08:31:28 EST 2003


Update of /cvsroot/python/python/dist/src/Mac/Modules/carbonevt
In directory sc8-pr-cvs1:/tmp/cvs-serv7692/Mac/Modules/carbonevt
Modified Files:
	CarbonEvtscan.py CarbonEvtsupport.py _CarbonEvtmodule.c 
Log Message:
Got rid of macglue.h, replacing it by pymactoolbox.h where relevant.
Cleaned up various things in the toolbox modules.
Index: CarbonEvtscan.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/carbonevt/CarbonEvtscan.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** CarbonEvtscan.py	15 Aug 2002 21:48:13 -0000	1.9
--- CarbonEvtscan.py	20 Nov 2003 13:30:55 -0000	1.10
***************
*** 85,89 ****
 			"InstallEventHandler",
 			"RemoveEventHandler",
- 			"RunApplicationEventLoop",
 						
 			# Write by hand?
--- 85,88 ----
Index: CarbonEvtsupport.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/carbonevt/CarbonEvtsupport.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** CarbonEvtsupport.py	19 Nov 2003 16:13:23 -0000	1.14
--- CarbonEvtsupport.py	20 Nov 2003 13:30:55 -0000	1.15
***************
*** 74,97 ****
 
 
! includestuff = r"""
 #include <Carbon/Carbon.h>
 
- #include "macglue.h"
- 
- /* Macro to test whether a weak-loaded CFM function exists */
- #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
- 		PyErr_SetString(PyExc_NotImplementedError, \
- 		"Not available in this shared library/OS version"); \
- 		return; \
- 	}} while(0)
- 
- 
- #define USE_MAC_MP_MULTITHREADING 0
- 
- #if USE_MAC_MP_MULTITHREADING
- static PyThreadState *_save;
- static MPCriticalRegionID reentrantLock;
- #endif /* USE_MAC_MP_MULTITHREADING */
- 
 extern int CFStringRef_New(CFStringRef *);
 
--- 74,80 ----
 
 
! includestuff = includestuff + r"""
 #include <Carbon/Carbon.h>
 
 extern int CFStringRef_New(CFStringRef *);
 
***************
*** 169,177 ****
 	int status;
 
- #if USE_MAC_MP_MULTITHREADING
- 	MPEnterCriticalRegion(reentrantLock, kDurationForever);
- 	PyEval_RestoreThread(_save);
- #endif /* USE_MAC_MP_MULTITHREADING */
- 
 	retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&",
 	 EventHandlerCallRef_New, handlerRef,
--- 152,155 ----
***************
*** 191,199 ****
 	}
 
- #if USE_MAC_MP_MULTITHREADING
- 	_save = PyEval_SaveThread();
- 	MPExitCriticalRegion(reentrantLock);
- #endif /* USE_MAC_MP_MULTITHREADING */
- 
 	return status;
 }
--- 169,172 ----
***************
*** 204,208 ****
 
 initstuff = initstuff + """
- PyMac_PRECHECK(NewEventHandlerUPP); /* This can fail if CarbonLib is too old */
 myEventHandlerUPP = NewEventHandlerUPP(myEventHandler);
 """
--- 177,180 ----
***************
*** 335,364 ****
 f.docstring = lambda: "(EventParamName eventName, EventParamType eventType) -> (String eventParamData)"
 EventRefobject.add(f)
- 
- runappeventloop = """
- #if USE_MAC_MP_MULTITHREADING
- if (MPCreateCriticalRegion(&reentrantLock) != noErr) {
- 	PySys_WriteStderr("lock failure\\n");
- 	return NULL;
- }
- _save = PyEval_SaveThread();
- #endif /* USE_MAC_MP_MULTITHREADING */
- 
- RunApplicationEventLoop();
- 
- #if USE_MAC_MP_MULTITHREADING
- PyEval_RestoreThread(_save);
- 
- MPDeleteCriticalRegion(reentrantLock);
- #endif /* USE_MAC_MP_MULTITHREADING */
- 
- Py_INCREF(Py_None);
- _res = Py_None;
- return _res;
- """			
- 
- f = ManualGenerator("RunApplicationEventLoop", runappeventloop);
- f.docstring = lambda: "() -> ()"
- module.add(f)
 
 SetOutputFileName('_CarbonEvtmodule.c')
--- 307,310 ----
Index: _CarbonEvtmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/carbonevt/_CarbonEvtmodule.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** _CarbonEvtmodule.c	19 Nov 2003 16:13:23 -0000	1.15
--- _CarbonEvtmodule.c	20 Nov 2003 13:30:56 -0000	1.16
***************
*** 6,27 ****
 
 
! #include <Carbon/Carbon.h>
! 
! #include "macglue.h"
 
 /* Macro to test whether a weak-loaded CFM function exists */
 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
! 		PyErr_SetString(PyExc_NotImplementedError, \
! 		"Not available in this shared library/OS version"); \
! 		return; \
! 	}} while(0)
! 
 
- #define USE_MAC_MP_MULTITHREADING 0
 
! #if USE_MAC_MP_MULTITHREADING
! static PyThreadState *_save;
! static MPCriticalRegionID reentrantLock;
! #endif /* USE_MAC_MP_MULTITHREADING */
 
 extern int CFStringRef_New(CFStringRef *);
--- 6,20 ----
 
 
! #include "pymactoolbox.h"
 
 /* Macro to test whether a weak-loaded CFM function exists */
 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
! PyErr_SetString(PyExc_NotImplementedError, \
! "Not available in this shared library/OS version"); \
! return NULL; \
! }} while(0)
 
 
! #include <Carbon/Carbon.h>
 
 extern int CFStringRef_New(CFStringRef *);
***************
*** 100,108 ****
 	int status;
 
- #if USE_MAC_MP_MULTITHREADING
- 	MPEnterCriticalRegion(reentrantLock, kDurationForever);
- 	PyEval_RestoreThread(_save);
- #endif /* USE_MAC_MP_MULTITHREADING */
- 
 	retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&",
 	 EventHandlerCallRef_New, handlerRef,
--- 93,96 ----
***************
*** 122,130 ****
 	}
 
- #if USE_MAC_MP_MULTITHREADING
- 	_save = PyEval_SaveThread();
- 	MPExitCriticalRegion(reentrantLock);
- #endif /* USE_MAC_MP_MULTITHREADING */
- 
 	return status;
 }
--- 110,113 ----
***************
*** 1846,1849 ****
--- 1829,1843 ----
 }
 
+ static PyObject *CarbonEvents_RunApplicationEventLoop(PyObject *_self, PyObject *_args)
+ {
+ 	PyObject *_res = NULL;
+ 	if (!PyArg_ParseTuple(_args, ""))
+ 		return NULL;
+ 	RunApplicationEventLoop();
+ 	Py_INCREF(Py_None);
+ 	_res = Py_None;
+ 	return _res;
+ }
+ 
 static PyObject *CarbonEvents_QuitApplicationEventLoop(PyObject *_self, PyObject *_args)
 {
***************
*** 2043,2072 ****
 }
 
- static PyObject *CarbonEvents_RunApplicationEventLoop(PyObject *_self, PyObject *_args)
- {
- 	PyObject *_res = NULL;
- 
- #if USE_MAC_MP_MULTITHREADING
- 	if (MPCreateCriticalRegion(&reentrantLock) != noErr) {
- 		PySys_WriteStderr("lock failure\n");
- 		return NULL;
- 	}
- 	_save = PyEval_SaveThread();
- #endif /* USE_MAC_MP_MULTITHREADING */
- 
- 	RunApplicationEventLoop();
- 
- #if USE_MAC_MP_MULTITHREADING
- 	PyEval_RestoreThread(_save);
- 
- 	MPDeleteCriticalRegion(reentrantLock);
- #endif /* USE_MAC_MP_MULTITHREADING */
- 
- 	Py_INCREF(Py_None);
- 	_res = Py_None;
- 	return _res;
- 
- }
- 
 static PyMethodDef CarbonEvents_methods[] = {
 	{"GetCurrentEventLoop", (PyCFunction)CarbonEvents_GetCurrentEventLoop, 1,
--- 2037,2040 ----
***************
*** 2104,2107 ****
--- 2072,2077 ----
 	{"GetEventDispatcherTarget", (PyCFunction)CarbonEvents_GetEventDispatcherTarget, 1,
 	 PyDoc_STR("() -> (EventTargetRef _rv)")},
+ 	{"RunApplicationEventLoop", (PyCFunction)CarbonEvents_RunApplicationEventLoop, 1,
+ 	 PyDoc_STR("() -> None")},
 	{"QuitApplicationEventLoop", (PyCFunction)CarbonEvents_QuitApplicationEventLoop, 1,
 	 PyDoc_STR("() -> None")},
***************
*** 2128,2133 ****
 	{"RegisterEventHotKey", (PyCFunction)CarbonEvents_RegisterEventHotKey, 1,
 	 PyDoc_STR("(UInt32 inHotKeyCode, UInt32 inHotKeyModifiers, EventHotKeyID inHotKeyID, EventTargetRef inTarget, OptionBits inOptions) -> (EventHotKeyRef outRef)")},
- 	{"RunApplicationEventLoop", (PyCFunction)CarbonEvents_RunApplicationEventLoop, 1,
- 	 PyDoc_STR("() -> ()")},
 	{NULL, NULL, 0}
 };
--- 2098,2101 ----
***************
*** 2143,2147 ****
 
 
- 	PyMac_PRECHECK(NewEventHandlerUPP); /* This can fail if CarbonLib is too old */
 	myEventHandlerUPP = NewEventHandlerUPP(myEventHandler);
 
--- 2111,2114 ----


More information about the Python-checkins mailing list

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