Artifacts Associated With Ticket 219163
Ticket change [0a07f38233] (rid 113745) by nobody on 2000-10-26 05:02:41:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
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 - foundin initialized to: "obsolete: 8.1b2"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "69. Other"
- title initialized to: "Event loop hook for Tcl"
- type initialized to: "RFE"
Ticket change [228dc18d26] (rid 130768) by hobbs on 2000-11-17 07:12:05:
- closedate changed to: "2000-11-17T00:12:05"
- closer changed to: "hobbs"
- foundin changed to: "obsolete: 8.4a2"
- icomment:
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.
- login: "hobbs"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "hobbs"
Ticket change [465e0f93a1] (rid 99504) by dgp on 2001-04-20 02:55:20:
- foundin changed to: "None"
- status changed to: "Open"
- subsystem changed to: "None"
Ticket change [322c4bd9d1] (rid 93563) by dgp on 2001-04-20 02:55:56:
- closedate changed to: "2001-04-19T19:55:56"
- closer changed to: "dgp"
- status changed to: "Closed"
- subsystem changed to: "50. Embedding Support"