summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorwelch <welch>1999-07-02 06:05:34 (GMT)
committerwelch <welch>1999-07-02 06:05:34 (GMT)
commitb032007a3ee9266d2a26475ff16d57e8412cf132 (patch)
treede5ebe9540617f5e8a6f8ecf7eff5984a4ff95cf /unix
parent4e5672a0727fc2cc1fb70a4674340d1549ac9ca5 (diff)
downloadtcl-b032007a3ee9266d2a26475ff16d57e8412cf132.zip
tcl-b032007a3ee9266d2a26475ff16d57e8412cf132.tar.gz
tcl-b032007a3ee9266d2a26475ff16d57e8412cf132.tar.bz2
Added hook points to the notifier
Updated Xt tests to use new Tcl_SetNotifier
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixNotfy.c22
-rw-r--r--unix/tclXtNotify.c44
-rw-r--r--unix/tclXtTest.c9
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 <signal.h>
+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 <X11/Intrinsic.h>
@@ -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(&notifier);
+
/*
* 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 <X11/Intrinsic.h>
@@ -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;