[pywin32-checkins] pywin32/win32/src win32event.i,1.5,1.6
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2005-01-25 07:53:44
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5461/src Modified Files: win32event.i Log Message: Add WaitableTimer functions, and a BOOLAPI_NL return type to optimize lock handling. Index: win32event.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32event.i,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** win32event.i 3 Oct 2002 23:19:36 -0000 1.5 --- win32event.i 25 Jan 2005 07:53:34 -0000 1.6 *************** *** 6,12 **** %{ //#define UNICODE #ifndef MS_WINCE ! #include "winsock2.h" ! #include "mswsock.h" #endif %} --- 6,14 ---- %{ //#define UNICODE + #define _WIN32_WINNT 0x0501 #ifndef MS_WINCE ! #include "windows.h" ! //#include "winsock2.h" ! //#include "mswsock.h" #endif %} *************** *** 15,18 **** --- 17,58 ---- %include "pywin32.i" + %typedef void *NULL_ONLY + + %typemap(python,in) NULL_ONLY { + if ($source != Py_None) { + PyErr_SetString(PyExc_TypeError, "This param must be None"); + return NULL; + } + $target = NULL; + } + + // only seem able to make this work with an incorrect level of + // indirection, and fixing it up inline with a temp. + %typemap(python,in) PTIMERAPCROUTINE *(PTIMERAPCROUTINE temp) { + if ($source != Py_None) { + PyErr_SetString(PyExc_TypeError, "This param must be None"); + return NULL; + } + temp = NULL; + $target = &temp; + } + + // We can get better perf from some of these functions that don't block + // by not releasing the Python lock as part of the call. + %typedef BOOL BOOLAPI_NL + + %typemap(python,out) BOOLAPI_NL { + $target = Py_None; + Py_INCREF(Py_None); + } + + %typemap(python,except) BOOLAPI { + $function + if (!$source) { + $cleanup + return PyWin_SetAPIError("$name"); + } + } + #define WAIT_FAILED WAIT_FAILED *************** *** 61,67 **** #define SYNCHRONIZE SYNCHRONIZE // Windows NT only: Enables use of the event handle in any of the wait functions to wait for the events state to be signaled. ! #if(_WIN32_WINNT >= 0x0400) ! // XXX - WTF? ! //BOOLAPI CancelWaitableTimer(HANDLE handle); #end --- 101,106 ---- #define SYNCHRONIZE SYNCHRONIZE // Windows NT only: Enables use of the event handle in any of the wait functions to wait for the events state to be signaled. ! // @pyswig |CancelWaitableTimer|Cancels a waiting timer. ! BOOLAPI CancelWaitableTimer(PyHANDLE handle); #end *************** *** 95,104 **** #endif // MS_WINCE ! /*PyHANDLE CreateWaitableTimer( SECURITY_ATTRIBUTES *inNullSA, // lpTimerAttributes, // pointer to security attributes BOOL bManualReset, // @pyparm int|bManualReset||flag for manual reset state TCHAR * INPUT_NULLOK // pointer to timer object name ); - */ // GetOverlappedResult --- 134,142 ---- #endif // MS_WINCE ! PyHANDLE CreateWaitableTimer( SECURITY_ATTRIBUTES *inNullSA, // lpTimerAttributes, // pointer to security attributes BOOL bManualReset, // @pyparm int|bManualReset||flag for manual reset state TCHAR * INPUT_NULLOK // pointer to timer object name ); // GetOverlappedResult *************** *** 248,258 **** #endif /* MS_WINCE */ ! /* PyHANDLE OpenWaitableTimer( ! DWORD dwDesiredAccess, // access flag ! BOOL bInheritHandle, // inherit flag ! TCHAR *lpTimerName // pointer to timer object name ! ); ! */ // @pyswig |PulseEvent|Provides a single operation that sets (to signaled) the state of the specified event object and then resets it (to nonsignaled) after releasing the appropriate number of waiting threads. --- 286,295 ---- #endif /* MS_WINCE */ ! //@pyswig handle|OpenWaitableTimer|Opens an existing named waitable timer object PyHANDLE OpenWaitableTimer( ! DWORD dwDesiredAccess, // @pyparm int|desiredAccess||access flag ! BOOL bInheritHandle, // @pyparm bInheritHandle||inherit flag ! TCHAR *lpTimerName // @pyparm string|timerName||pointer to timer object name ! ); // @pyswig |PulseEvent|Provides a single operation that sets (to signaled) the state of the specified event object and then resets it (to nonsignaled) after releasing the appropriate number of waiting threads. *************** *** 262,266 **** // @pyswig |ReleaseMutex|Releases a mutex. ! BOOLAPI ReleaseMutex( PyHANDLE hMutex // @pyparm <o PyHANDLE>|hEvent||handle of mutex object ); --- 299,303 ---- // @pyswig |ReleaseMutex|Releases a mutex. ! BOOLAPI_NL ReleaseMutex( PyHANDLE hMutex // @pyparm <o PyHANDLE>|hEvent||handle of mutex object ); *************** *** 277,292 **** // @pyswig |ResetEvent|Resets an event ! BOOLAPI ResetEvent( PyHANDLE hEvent // @pyparm <o PyHANDLE>|hEvent||handle of event object ); // @pyswig |SetEvent|Sets an event ! BOOLAPI SetEvent( PyHANDLE hEvent // @pyparm <o PyHANDLE>|hEvent||handle of event object ); - // SetWaitableTimer - /* BOOLAPI SignalObjectAndWait( PyHANDLE hObjectToSignal, // handle of object to signal --- 314,335 ---- // @pyswig |ResetEvent|Resets an event ! BOOLAPI_NL ResetEvent( PyHANDLE hEvent // @pyparm <o PyHANDLE>|hEvent||handle of event object ); // @pyswig |SetEvent|Sets an event ! BOOLAPI_NL SetEvent( PyHANDLE hEvent // @pyparm <o PyHANDLE>|hEvent||handle of event object ); + // @pyswig |SetWaitableTimer|Sets a waitable timer. + BOOLAPI_NL SetWaitableTimer( + PyHANDLE hTimer, // @pyparm int|handle||handle to timer + LARGE_INTEGER *INPUT, // @pyparm long|dueTime||timer due time + long lPeriod, // @pyparm int|period||timer interval + PTIMERAPCROUTINE pfnCompletionRoutine, // @pyparm object|func||completion routine - must be None + NULL_ONLY lpArgToCompletionRoutine, // @pyparm object|param||completion routine parameter - must be None + BOOL fResume); // @pyparm bool|resume_state||resume state BOOLAPI SignalObjectAndWait( PyHANDLE hObjectToSignal, // handle of object to signal *************** *** 296,300 **** ); - */ %{ static PyObject *MyWaitForMultipleObjects( --- 339,342 ---- |