Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 0a07f38233575a3cbe4c53fdc50b24bee4ae7f93
Ticket: 219163ffffffffffffffffffffffffffffffffff
Event loop hook for Tcl
User & Date: nobody on 2000-10-26 05:02:41
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed 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
    
  4. foundin changed to: "obsolete: 8.1b2"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "69. Other"
  10. title changed to: "Event loop hook for Tcl"
  11. type changed to: "RFE"