|
2001-04-20
| ||
| 02:55 | • Closed ticket [219163ffff]: Event loop hook for Tcl plus 3 other changes artifact: 322c4bd9d1 user: dgp | |
| 02:55 | • Open ticket [219163ffff]. artifact: 465e0f93a1 user: dgp | |
|
2000-11-17
| ||
| 07:12 | • Closed ticket [219163ffff]. artifact: 228dc18d26 user: hobbs | |
|
2000-10-26
| ||
| 05:02 | • New ticket [219163ffff]. artifact: 0a07f38233 user: nobody | |
Event loop hook for Tcl
Closed / Fixed219163ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 05:02:41
OriginalBugID: 1525 RFE
Version: 8.1b2
SubmitDate: '1999-03-18'
LastModified: '1999-11-16'
Severity: MED
Status: Assigned
Submitter: pat
ChangedBy: hobbs
RelatedBugIDs: 2074
OS: Other
Machine: NA
FixedDate: '2000-10-25'
ClosedDate: '2000-10-25'
Name:
Jan Nijtmans
DesiredBehavior:
Currently Tcl doesn't have a main loop like Tk does. This means
that if a Tcl-only application needs to process events, the only
way is to put an "vwait dummyvar" at the end of the script. This
solution is not ideal, but in the pre-stub period there hardly
was another way.
Here is a simple implementation of a Tcl_MainLoop() function.
Normally this is a no-op, but Stubs allow other extensions to
register their own event loops. Tk would be the first candidate
to do so. There is already a slot reserved in the stub table
(188) for this functionality.
Patch:
*** generic/tcl.decls.origWed Mar 17 22:55:40 1999
--- generic/tcl.declsWed Mar 17 22:55:45 1999
***************
*** 655,666 ****
declare 187 generic {
int Tcl_LinkVar(Tcl_Interp *interp, char *varName, char *addr, int type)
}
!
! # This slot is reserved for use by the plus patch:
! # declare 188 generic {
! # Tcl_MainLoop
! # }
!
declare 189 generic {
Tcl_Channel Tcl_MakeFileChannel(ClientData handle, int mode)
}
--- 655,663 ----
declare 187 generic {
int Tcl_LinkVar(Tcl_Interp *interp, char *varName, char *addr, int type)
}
! declare 188 generic {
! void Tcl_MainLoop(void)
! }
declare 189 generic {
Tcl_Channel Tcl_MakeFileChannel(ClientData handle, int mode)
}
*** generic/tclDecls.h.origWed Mar 17 22:55:40 1999
--- generic/tclDecls.hWed Mar 17 22:55:45 1999
***************
*** 588,594 ****
/* 187 */
EXTERN intTcl_LinkVar _ANSI_ARGS_((Tcl_Interp * interp,
char * varName, char * addr, int type));
! /* Slot 188 is reserved */
/* 189 */
EXTERN Tcl_ChannelTcl_MakeFileChannel _ANSI_ARGS_((ClientData handle,
int mode));
--- 588,595 ----
/* 187 */
EXTERN intTcl_LinkVar _ANSI_ARGS_((Tcl_Interp * interp,
char * varName, char * addr, int type));
! /* 188 */
! EXTERN voidTcl_MainLoop _ANSI_ARGS_((void));
/* 189 */
EXTERN Tcl_ChannelTcl_MakeFileChannel _ANSI_ARGS_((ClientData handle,
int mode));
***************
*** 1271,1277 ****
int (*tcl_IsSafe) _ANSI_ARGS_((Tcl_Interp * interp)); /* 185 */
char * (*tcl_JoinPath) _ANSI_ARGS_((int argc, char ** argv, Tcl_DString * resultPtr)); /* 186 */
int (*tcl_LinkVar) _ANSI_ARGS_((Tcl_Interp * interp, char * varName, char * addr, int type)); /* 187 */
! void *reserved188;
Tcl_Channel (*tcl_MakeFileChannel) _ANSI_ARGS_((ClientData handle, int mode)); /* 189 */
int (*tcl_MakeSafe) _ANSI_ARGS_((Tcl_Interp * interp)); /* 190 */
Tcl_Channel (*tcl_MakeTcpClientChannel) _ANSI_ARGS_((ClientData tcpSocket)); /* 191 */
--- 1272,1278 ----
int (*tcl_IsSafe) _ANSI_ARGS_((Tcl_Interp * interp)); /* 185 */
char * (*tcl_JoinPath) _ANSI_ARGS_((int argc, char ** argv, Tcl_DString * resultPtr)); /* 186 */
int (*tcl_LinkVar) _ANSI_ARGS_((Tcl_Interp * interp, char * varName, char * addr, int type)); /* 187 */
! void (*tcl_MainLoop) _ANSI_ARGS_((void)); /* 188 */
Tcl_Channel (*tcl_MakeFileChannel) _ANSI_ARGS_((ClientData handle, int mode)); /* 189 */
int (*tcl_MakeSafe) _ANSI_ARGS_((Tcl_Interp * interp)); /* 190 */
Tcl_Channel (*tcl_MakeTcpClientChannel) _ANSI_ARGS_((ClientData tcpSocket)); /* 191 */
***************
*** 2194,2200 ****
#define Tcl_LinkVar(interp, varName, addr, type) \
(tclStubsPtr->tcl_LinkVar)(interp, varName, addr, type) /* 187 */
#endif
! /* Slot 188 is reserved */
#ifndef Tcl_MakeFileChannel
#define Tcl_MakeFileChannel(handle, mode) \
(tclStubsPtr->tcl_MakeFileChannel)(handle, mode) /* 189 */
--- 2195,2204 ----
#define Tcl_LinkVar(interp, varName, addr, type) \
(tclStubsPtr->tcl_LinkVar)(interp, varName, addr, type) /* 187 */
#endif
! #ifndef Tcl_MainLoop
! #define Tcl_MainLoop() \
! (tclStubsPtr->tcl_MainLoop)() /* 188 */
! #endif
#ifndef Tcl_MakeFileChannel
#define Tcl_MakeFileChannel(handle, mode) \
(tclStubsPtr->tcl_MakeFileChannel)(handle, mode) /* 189 */
*** generic/tclMain.c.origWed Mar 17 22:55:40 1999
--- generic/tclMain.cWed Mar 17 22:56:42 1999
***************
*** 18,23 ****
--- 18,25 ----
# undef TCL_STORAGE_CLASS
# define TCL_STORAGE_CLASS DLLEXPORT
+ extern TclStubs tclStubs;
+
/*
* The following code ensures that tclLink.c is linked whenever
* Tcl is linked. Without this code there's no reference to the
***************
*** 267,275 ****
--- 269,306 ----
*/
done:
+ if (exitCode == 0) {
+ Tcl_MainLoop();
+ }
if (commandPtr != NULL) {
Tcl_DecrRefCount(commandPtr);
}
sprintf(buffer, "exit %d", exitCode);
Tcl_Eval(interp, buffer);
+ }
+
+
+ /*
+ *---------------------------------------------------------------
+ *
+ * Tcl_MainLoop --
+ *
+ *Do nothing, unless a package replaced the main loop function.
+ *
+ * Results:
+ *None.
+ *
+ * Side effects:
+ *Arbitrary; depends on handlers for events.
+ *
+ *---------------------------------------------------------------
+ */
+
+ void
+ Tcl_MainLoop()
+ {
+ if (tclStubs.tcl_MainLoop != Tcl_MainLoop) {
+ tclStubs.tcl_MainLoop();
+ tclStubs.tcl_MainLoop = Tcl_MainLoop;
+ }
}
PatchFiles:
tcl.decls tclDecls.h tclMain.c
The first half of this is in 8.2, but not the C func.
-- 08/20/1999 hobbs
hobbsplain2000-11-17 07:12:05
This was handled in 8.4a2 with the new Tcl_SetMainLoop function (implemented with a mix of this, JCW's metakit work, and blended together). Tk does take advantage of this as well with 8.4a2.
dgp Open ticket [219163ffff].
[History diff]2001-04-20 02:55:20
dgp Closed ticket [219163ffff].
[History diff]2001-04-20 02:55:56
Log in (anonymous is fine) to add a comment.