From b032007a3ee9266d2a26475ff16d57e8412cf132 Mon Sep 17 00:00:00 2001 From: welch Date: Fri, 2 Jul 1999 06:05:34 +0000 Subject: Added hook points to the notifier Updated Xt tests to use new Tcl_SetNotifier --- unix/tclUnixNotfy.c | 22 +++++++++++++++++++++- unix/tclXtNotify.c | 44 ++++++++++++++++++++++++++++---------------- unix/tclXtTest.c | 9 ++++++++- 3 files changed, 57 insertions(+), 18 deletions(-) diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c index 5a0d222..4053e4a 100644 --- a/unix/tclUnixNotfy.c +++ b/unix/tclUnixNotfy.c @@ -11,13 +11,15 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixNotfy.c,v 1.4 1999/06/10 04:27:44 stanton Exp $ + * RCS: @(#) $Id: tclUnixNotfy.c,v 1.5 1999/07/02 06:05:34 welch Exp $ */ #include "tclInt.h" #include "tclPort.h" #include +extern TclStubs tclStubs; + /* * This structure is used to keep track of the notifier info for a * a registered file. @@ -336,6 +338,10 @@ Tcl_SetTimer(timePtr) * because the only event loop is via Tcl_DoOneEvent, which passes * timeout values to Tcl_WaitForEvent. */ + + if (tclStubs.tcl_SetTimer != Tcl_SetTimer) { + tclStubs.tcl_SetTimer(timePtr); + } } /* @@ -392,6 +398,11 @@ Tcl_CreateFileHandler(fd, mask, proc, clientData) FileHandler *filePtr; int index, bit; + if (tclStubs.tcl_CreateFileHandler != Tcl_CreateFileHandler) { + tclStubs.tcl_CreateFileHandler(fd, mask, proc, clientData); + return; + } + for (filePtr = tsdPtr->firstFileHandlerPtr; filePtr != NULL; filePtr = filePtr->nextPtr) { if (filePtr->fd == fd) { @@ -461,6 +472,11 @@ Tcl_DeleteFileHandler(fd) unsigned long flags; ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); + if (tclStubs.tcl_DeleteFileHandler != Tcl_DeleteFileHandler) { + tclStubs.tcl_DeleteFileHandler(fd); + return; + } + /* * Find the entry for the given file (and return if there isn't one). */ @@ -632,6 +648,10 @@ Tcl_WaitForEvent(timePtr) #endif ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); + if (tclStubs.tcl_WaitForEvent != Tcl_WaitForEvent) { + return tclStubs.tcl_WaitForEvent(timePtr); + } + /* * Set up the timeout structure. Note that if there are no events to * check for, we return with a negative result rather than blocking diff --git a/unix/tclXtNotify.c b/unix/tclXtNotify.c index 0b5a3b5..31157ff 100644 --- a/unix/tclXtNotify.c +++ b/unix/tclXtNotify.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclXtNotify.c,v 1.3 1999/02/03 02:59:08 stanton Exp $ + * RCS: @(#) $Id: tclXtNotify.c,v 1.4 1999/07/02 06:05:34 welch Exp $ */ #include @@ -79,11 +79,16 @@ static int FileHandlerEventProc _ANSI_ARGS_((Tcl_Event *evPtr, int flags)); static void FileProc _ANSI_ARGS_((caddr_t clientData, int *source, XtInputId *id)); -static void InitNotifier _ANSI_ARGS_((void)); +void InitNotifier _ANSI_ARGS_((void)); static void NotifierExitHandler _ANSI_ARGS_(( ClientData clientData)); static void TimerProc _ANSI_ARGS_((caddr_t clientData, XtIntervalId *id)); +static void CreateFileHandler _ANSI_ARGS_((int fd, int mask, + Tcl_FileProc * proc, ClientData clientData)); +static void DeleteFileHandler _ANSI_ARGS_((int fd)); +static void SetTimer _ANSI_ARGS_((Tcl_Time * timePtr)); +static int WaitForEvent _ANSI_ARGS_((Tcl_Time * timePtr)); /* * Functions defined in this file for use by users of the Xt Notifier: @@ -180,9 +185,10 @@ TclSetAppContext(appContext) *---------------------------------------------------------------------- */ -static void -InitNotifier(void) +void +InitNotifier() { + Tcl_NotifierProcs notifier; /* * Only reinitialize if we are not in exit handling. The notifier * can get reinitialized after its own exit handler has run, because @@ -193,6 +199,12 @@ InitNotifier(void) return; } + notifier.createFileHandlerProc = CreateFileHandler; + notifier.deleteFileHandlerProc = DeleteFileHandler; + notifier.setTimerProc = SetTimer; + notifier.waitForEventProc = WaitForEvent; + Tcl_SetNotifier(¬ifier); + /* * DO NOT create the application context yet; doing so would prevent * external applications from setting it for us to their own ones. @@ -241,7 +253,7 @@ NotifierExitHandler( /* *---------------------------------------------------------------------- * - * Tcl_SetTimer -- + * SetTimer -- * * This procedure sets the current notifier timeout value. * @@ -254,8 +266,8 @@ NotifierExitHandler( *---------------------------------------------------------------------- */ -void -Tcl_SetTimer(timePtr) +static void +SetTimer(timePtr) Tcl_Time *timePtr; /* Timeout value, may be NULL. */ { long timeout; @@ -311,7 +323,7 @@ TimerProc(data, id) /* *---------------------------------------------------------------------- * - * Tcl_CreateFileHandler -- + * CreateFileHandler -- * * This procedure registers a file handler with the Xt notifier. * @@ -325,8 +337,8 @@ TimerProc(data, id) *---------------------------------------------------------------------- */ -void -Tcl_CreateFileHandler(fd, mask, proc, clientData) +static void +CreateFileHandler(fd, mask, proc, clientData) int fd; /* Handle of stream to watch. */ int mask; /* OR'ed combination of TCL_READABLE, * TCL_WRITABLE, and TCL_EXCEPTION: @@ -407,7 +419,7 @@ Tcl_CreateFileHandler(fd, mask, proc, clientData) /* *---------------------------------------------------------------------- * - * Tcl_DeleteFileHandler -- + * DeleteFileHandler -- * * Cancel a previously-arranged callback arrangement for * a file. @@ -421,8 +433,8 @@ Tcl_CreateFileHandler(fd, mask, proc, clientData) *---------------------------------------------------------------------- */ -void -Tcl_DeleteFileHandler(fd) +static void +DeleteFileHandler(fd) int fd; /* Stream id for which to remove * callback procedure. */ { @@ -609,7 +621,7 @@ FileHandlerEventProc(evPtr, flags) /* *---------------------------------------------------------------------- * - * Tcl_WaitForEvent -- + * WaitForEvent -- * * This function is called by Tcl_DoOneEvent to wait for new * events on the message queue. If the block time is 0, then @@ -626,8 +638,8 @@ FileHandlerEventProc(evPtr, flags) *---------------------------------------------------------------------- */ -int -Tcl_WaitForEvent( +static int +WaitForEvent( Tcl_Time *timePtr) /* Maximum block time, or NULL. */ { int timeout; diff --git a/unix/tclXtTest.c b/unix/tclXtTest.c index da45a57..abdcb8d 100644 --- a/unix/tclXtTest.c +++ b/unix/tclXtTest.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclXtTest.c,v 1.3 1999/04/16 00:48:06 stanton Exp $ + * RCS: @(#) $Id: tclXtTest.c,v 1.4 1999/07/02 06:05:34 welch Exp $ */ #include @@ -16,6 +16,8 @@ static int TesteventloopCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int argc, char **argv)); +extern void InitNotifier _ANSI_ARGS_((void)); + /* *---------------------------------------------------------------------- @@ -40,6 +42,11 @@ int Tclxttest_Init(interp) Tcl_Interp *interp; /* Interpreter for application. */ { + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { + return TCL_ERROR; + } + XtToolkitInitialize(); + InitNotifier(); Tcl_CreateCommand(interp, "testeventloop", TesteventloopCmd, (ClientData) 0, (Tcl_CmdDeleteProc *) NULL); return TCL_OK; -- cgit v0.12