Skip to content
Tcl Source Code History Of Ticket 218407
Login

History Of Ticket 218407

Artifacts Associated With Ticket 218407

  1. Ticket change [e8c4d20d0b] (rid 104702) by nobody on 2000-10-26 00:57:12:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 5340 RFE
      Version: 8.3.1
      SubmitDate: '2000-05-03'
      LastModified: '2000-05-17'
      Severity: SER
      Status: Closed
      Submitter: techsupp
      ChangedBy: hobbs
      OS: All
      FixedDate: '2000-10-25'
      ClosedDate: '2000-05-17'
      
      
      Name:
      
      Jan Nijtmans
      
      
      Comments:
      
      The upcoming plus-patches for 8.3.1 will contain this enhancement.
      
      
      DesiredBehavior:
      
      Currently it is impossuble under Windows to export global variables from Dll's.
      
      This patch adds support to the Stubs implementation fully fixing this.
      
      
      The basic  idea is to adapting genStubs.tcl such that it can handle global
      
      variables as well as functions in the same way: Let the Stub table contain
      
      pointers to the actual locations which are addressed indrectly through macros.
      
      The supplied patches give the best demonstration how to use it.
      
      Even when not using Stubs, global variables are safe to be used, because
      
      the __declspec(dllexport) attribute is supported by the latest versions of
      
      VC++ and gcc. As a demonstration, see the modifications to tclTest.c below.
      
      That's a lot simpler, isn't it?
      
      
      Patch:
      
      *** generic/tclInt.decls.origFri Mar 31 10:52:04 2000
      
      --- generic/tclInt.declsTue May  2 20:15:40 2000
      
      ***************
      
      *** 602,607 ****
      
      --- 602,616 ----
      
            int TclpMatchFilesTypes(Tcl_Interp *interp, char *separators, \
      
            Tcl_DString *dirPtr, char *pattern, char *tail, GlobTypeData *types)
      
        }
      
      + declare 161 generic {
      
      +     TclPlatformType tclPlatform
      
      + }
      
      + declare 162 generic {
      
      +     char *tclExecutableName
      
      + }
      
      + declare 163 generic {
      
      +     char *tclNativeExecutableName
      
      + }
      
      
        ##############################################################################
      
      
      *** generic/tclIntDecls.h.origTue May  2 20:16:18 2000
      
      --- generic/tclIntDecls.hTue May  2 20:20:01 2000
      
      ***************
      
      *** 529,534 ****
      
      --- 529,540 ----
      
        char * separators, Tcl_DString * dirPtr, 
      
        char * pattern, char * tail, 
      
        GlobTypeData * types));
      
      + /* 161 */
      
      + EXTERN TclPlatformTypetclPlatform;
      
      + /* 162 */
      
      + EXTERN char *tclExecutableName;
      
      + /* 163 */
      
      + EXTERN char *tclNativeExecutableName;
      
      
        typedef struct TclIntStubs {
      
            int magic;
      
      ***************
      
      *** 727,732 ****
      
      --- 733,741 ----
      
            void (*tclSetStartupScriptFileName) _ANSI_ARGS_((char * filename)); /* 158 */
      
            char * (*tclGetStartupScriptFileName) _ANSI_ARGS_((void)); /* 159 */
      
            int (*tclpMatchFilesTypes) _ANSI_ARGS_((Tcl_Interp * interp, char * separators, Tcl_DString * dirPtr, char * pattern, char * tail, GlobTypeData * types)); /* 160 */
      
      +     TclPlatformType *tclPlatform_; /* 161 */
      
      +     char * *tclExecutableName_; /* 162 */
      
      +     char * *tclNativeExecutableName_; /* 163 */
      
        } TclIntStubs;
      
      
        #ifdef __cplusplus
      
      ***************
      
      *** 1379,1384 ****
      
      --- 1388,1405 ----
      
        #ifndef TclpMatchFilesTypes
      
        #define TclpMatchFilesTypes \
      
        (tclIntStubsPtr->tclpMatchFilesTypes) /* 160 */
      
      + #endif
      
      + #ifndef tclPlatform
      
      + #define tclPlatform \
      
      + (*tclIntStubsPtr->tclPlatform_) /* 161 */
      
      + #endif
      
      + #ifndef tclExecutableName
      
      + #define tclExecutableName \
      
      + (*tclIntStubsPtr->tclExecutableName_) /* 162 */
      
      + #endif
      
      + #ifndef tclNativeExecutableName
      
      + #define tclNativeExecutableName \
      
      + (*tclIntStubsPtr->tclNativeExecutableName_) /* 163 */
      
        #endif
      
      
        #endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */
      
      *** generic/tclStubInit.c.origTue May  2 20:16:53 2000
      
      --- generic/tclStubInit.cTue May  2 20:20:07 2000
      
      ***************
      
      *** 236,241 ****
      
      --- 236,244 ----
      
            TclSetStartupScriptFileName, /* 158 */
      
            TclGetStartupScriptFileName, /* 159 */
      
            TclpMatchFilesTypes, /* 160 */
      
      +     &tclPlatform, /* 161 */
      
      +     &tclExecutableName, /* 162 */
      
      +     &tclNativeExecutableName, /* 163 */
      
        };
      
      
        TclIntPlatStubs tclIntPlatStubs = {
      
      *** generic/tclTest.c.origTue May  2 20:21:48 2000
      
      --- generic/tclTest.cTue May  2 20:23:29 2000
      
      ***************
      
      *** 1768,1780 ****
      
            char **argv;/* Argument strings. */
      
        {
      
            static char *platformStrings[] = { "unix", "mac", "windows" };
      
      -     TclPlatformType *platform;
      
      - 
      
      - #ifdef __WIN32__
      
      -     platform = TclWinGetPlatform();
      
      - #else
      
      -     platform = &tclPlatform;
      
      - #endif
      
      
            if (argc != 1) {
      
                Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
      
      --- 1768,1773 ----
      
      ***************
      
      *** 1782,1788 ****
      
                return TCL_ERROR;
      
            }
      
      
      !     Tcl_AppendResult(interp, platformStrings[*platform], NULL);
      
            return TCL_OK;
      
        }
      
        
      
      --- 1775,1781 ----
      
                return TCL_ERROR;
      
            }
      
      
      !     Tcl_AppendResult(interp, platformStrings[tclPlatform], NULL);
      
            return TCL_OK;
      
        }
      
        
      
      ***************
      
      *** 2909,2921 ****
      
            char **argv;/* Argument strings. */
      
        {
      
            size_t length;
      
      -     TclPlatformType *platform;
      
      - 
      
      - #ifdef __WIN32__
      
      -     platform = TclWinGetPlatform();
      
      - #else
      
      -     platform = &tclPlatform;
      
      - #endif
      
      
            if (argc != 2) {
      
                Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
      
      --- 2902,2907 ----
      
      ***************
      
      *** 2925,2935 ****
      
      
            length = strlen(argv[1]);
      
            if (strncmp(argv[1], "unix", length) == 0) {
      
      ! *platform = TCL_PLATFORM_UNIX;
      
            } else if (strncmp(argv[1], "mac", length) == 0) {
      
      ! *platform = TCL_PLATFORM_MAC;
      
            } else if (strncmp(argv[1], "windows", length) == 0) {
      
      ! *platform = TCL_PLATFORM_WINDOWS;
      
            } else {
      
                Tcl_AppendResult(interp, "unsupported platform: should be one of ",
      
        "unix, mac, or windows", (char *) NULL);
      
      --- 2911,2921 ----
      
      
            length = strlen(argv[1]);
      
            if (strncmp(argv[1], "unix", length) == 0) {
      
      ! tclPlatform = TCL_PLATFORM_UNIX;
      
            } else if (strncmp(argv[1], "mac", length) == 0) {
      
      ! tclPlatform = TCL_PLATFORM_MAC;
      
            } else if (strncmp(argv[1], "windows", length) == 0) {
      
      ! tclPlatform = TCL_PLATFORM_WINDOWS;
      
            } else {
      
                Tcl_AppendResult(interp, "unsupported platform: should be one of ",
      
        "unix, mac, or windows", (char *) NULL);
      
      *** tools/genStubs.tcl.origThu Jun 10 06:29:01 1999
      
      --- tools/genStubs.tclTue May  2 20:15:40 2000
      
      ***************
      
      *** 267,274 ****
      
      
        proc genStubs::parseDecl {decl} {
      
            if {![regexp {^(.*)\((.*)\)$} $decl all prefix args]} {
      
      ! puts stderr "Malformed declaration: $decl"
      
      ! return
      
            }
      
            set prefix [string trim $prefix]
      
            if {![regexp {^(.+[ ][*]*)([^ *]+)$} $prefix all rtype fname]} {
      
      --- 267,274 ----
      
      
        proc genStubs::parseDecl {decl} {
      
            if {![regexp {^(.*)\((.*)\)$} $decl all prefix args]} {
      
      ! set prefix $decl
      
      ! set args {}
      
            }
      
            set prefix [string trim $prefix]
      
            if {![regexp {^(.+[ ][*]*)([^ *]+)$} $prefix all rtype fname]} {
      
      ***************
      
      *** 276,281 ****
      
      --- 276,284 ----
      
        return
      
            }
      
            set rtype [string trim $rtype]
      
      +     if {$args == ""} {
      
      + return [list $rtype $fname {}]
      
      +     }
      
            foreach arg [split $args ,] {
      
        lappend argList [string trim $arg]
      
            }
      
      ***************
      
      *** 357,362 ****
      
      --- 360,371 ----
      
        append line " "
      
        set pad 0
      
            }
      
      +     if {$args == ""} {
      
      + append line $fname
      
      + append text $line
      
      + append text ";\n"
      
      + return $text
      
      +     }
      
            append line "$fname _ANSI_ARGS_("
      
      
            set arg1 [lindex $args 0]
      
      ***************
      
      *** 412,417 ****
      
      --- 421,432 ----
      
            append lfname [string range $fname 1 end]
      
      
            set text "#ifndef $fname\n#define $fname"
      
      + 
      
      +     if {$args == ""} {
      
      + append text " \\\n\t(*${name}StubsPtr->${lfname}_)"
      
      + append text " /* $index */\n#endif\n"
      
      + return $text
      
      +     }
      
            set arg1 [lindex $args 0]
      
            set argList ""
      
            switch -exact $arg1 {
      
      ***************
      
      *** 518,523 ****
      
      --- 533,543 ----
      
            append lfname [string range $fname 1 end]
      
      
            set text "    "
      
      +     if {$args == ""} {
      
      + append lfname _
      
      + append text $rtype " *" $lfname "; /* $index */\n"
      
      + return $text
      
      +     }
      
            append text $rtype " (*" $lfname ") _ANSI_ARGS_("
      
      
            set arg1 [lindex $args 0]
      
      ***************
      
      *** 557,563 ****
      
        #Returns the formatted declaration string.
      
      
        proc genStubs::makeInit {name decl index} {
      
      !     append text "    " [lindex $decl 1] ", /* " $index " */\n"
      
            return $text
      
        }
      
      
      --- 577,587 ----
      
        #Returns the formatted declaration string.
      
      
        proc genStubs::makeInit {name decl index} {
      
      !     if {[lindex $decl 2] == ""} {
      
      ! append text "    &" [lindex $decl 1] ", /* " $index " */\n"
      
      !     } else {
      
      ! append text "    " [lindex $decl 1] ", /* " $index " */\n"
      
      !     }
      
            return $text
      
        }
      
      
      PatchFiles:
      
      tclInt.decls tclIntDecls.h tclStubInit.c tclTest.c genStubs.tcl
      
      
      
      
      We shouldn't open up global vars like this.  Instead accessor
      functions should be used. 
      -- 05/17/2000 hobbs
      
    4. foundin initialized to: "obsolete: 8.3.1"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "69. Other"
    10. title initialized to: "Support for global variables in Stubs"
    11. type initialized to: "RFE"
  2. Ticket change [b5a4c401d0] (rid 125280) by welch on 2000-10-26 08:21:18:

    1. closedate changed to: "2000-10-26T01:21:18"
    2. closer changed to: "welch"
    3. priority changed to: "2"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"
  3. Ticket change [c7fa8477d6] (rid 122032) by dgp on 2001-04-20 02:13:02:

    1. foundin changed to: "None"
    2. status changed to: "Open"
    3. subsystem changed to: "None"
  4. Ticket change [07a00364c1] (rid 89434) by dgp on 2001-04-20 02:16:37:

    1. closedate changed to: "2001-04-19T19:16:37"
    2. closer changed to: "dgp"
    3. status changed to: "Closed"