Tcl Source Code

Artifact [c868f62b51]
Login

Artifact c868f62b5157d77835c199efff1fd284d1296e31:

Attachment "tcl-stubs-modulescope.diff" to ticket [1819422fff] added by das 2008-04-03 04:40:38.
Index: generic/tcl.decls
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tcl.decls,v
retrieving revision 1.131
diff -u -p -r1.131 tcl.decls
--- generic/tcl.decls	19 Mar 2008 16:56:13 -0000	1.131
+++ generic/tcl.decls	2 Apr 2008 17:02:22 -0000
@@ -2149,35 +2149,9 @@ export {
     void Tcl_Main(int argc, char **argv, Tcl_AppInitProc *appInitProc)
 }
 export {
-    CONST char *Tcl_InitStubs(Tcl_Interp *interp, CONST char *version,
-	int exact)
-}
-export {
-    CONST char *TclTomMathInitializeStubs(Tcl_Interp* interp,
-	CONST char* version, int epoch, int revision)
-}
-export {
     CONST char *Tcl_PkgInitStubsCheck(Tcl_Interp *interp, CONST char *version,
 	int exact)
 }
 export {
     void Tcl_GetMemoryInfo(Tcl_DString *dsPtr)
 }
-
-# Global variables that need to be exported from the tcl shared library.
-
-export {
-    TclStubs *tclStubsPtr                       (fool checkstubs)
-}
-export {
-    TclPlatStubs *tclPlatStubsPtr               (fool checkstubs)
-}
-export {
-    TclIntStubs *tclIntStubsPtr                 (fool checkstubs)
-}
-export {
-    TclIntPlatStubs *tclIntPlatStubsPtr         (fool checkstubs)
-}
-export {
-    TclTomMathStubs* tclTomMathStubsPtr         (fool checkstubs)
-}
Index: generic/tclDecls.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclDecls.h,v
retrieving revision 1.131
diff -u -p -r1.131 tclDecls.h
--- generic/tclDecls.h	1 Apr 2008 16:23:40 -0000	1.131
+++ generic/tclDecls.h	2 Apr 2008 17:02:23 -0000
@@ -3503,14 +3503,14 @@ EXTERN void		Tcl_AppendPrintfToObj (Tcl_
 #endif
 
 typedef struct TclStubHooks {
-    struct TclPlatStubs *tclPlatStubs;
-    struct TclIntStubs *tclIntStubs;
-    struct TclIntPlatStubs *tclIntPlatStubs;
+    CONST struct TclPlatStubs *tclPlatStubs;
+    CONST struct TclIntStubs *tclIntStubs;
+    CONST struct TclIntPlatStubs *tclIntPlatStubs;
 } TclStubHooks;
 
 typedef struct TclStubs {
     int magic;
-    struct TclStubHooks *hooks;
+    CONST struct TclStubHooks *hooks;
 
     int (*tcl_PkgProvideEx) (Tcl_Interp* interp, CONST char* name, CONST char* version, ClientData clientData); /* 0 */
     CONST84_RETURN char * (*tcl_PkgRequireEx) (Tcl_Interp * interp, CONST char * name, CONST char * version, int exact, ClientData * clientDataPtr); /* 1 */
@@ -4143,15 +4143,7 @@ typedef struct TclStubs {
 } TclStubs;
 
 #if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern TclStubs *tclStubsPtr;
-#ifdef __cplusplus
-}
-#endif
-
+EXTERN CONST TclStubs *tclStubsPtr;
 #endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */
 
 #if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS)
Index: generic/tclIntDecls.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIntDecls.h,v
retrieving revision 1.113
diff -u -p -r1.113 tclIntDecls.h
--- generic/tclIntDecls.h	1 Apr 2008 16:23:41 -0000	1.113
+++ generic/tclIntDecls.h	2 Apr 2008 17:02:26 -0000
@@ -1079,7 +1079,7 @@ EXTERN void		TclBackgroundException (Tcl
 
 typedef struct TclIntStubs {
     int magic;
-    struct TclIntStubHooks *hooks;
+    CONST struct TclIntStubHooks *hooks;
 
     void *reserved0;
     void *reserved1;
@@ -1345,15 +1345,7 @@ typedef struct TclIntStubs {
 } TclIntStubs;
 
 #if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern TclIntStubs *tclIntStubsPtr;
-#ifdef __cplusplus
-}
-#endif
-
+EXTERN CONST TclIntStubs *tclIntStubsPtr;
 #endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */
 
 #if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS)
Index: generic/tclIntPlatDecls.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIntPlatDecls.h,v
retrieving revision 1.33
diff -u -p -r1.33 tclIntPlatDecls.h
--- generic/tclIntPlatDecls.h	1 Apr 2008 16:23:41 -0000	1.33
+++ generic/tclIntPlatDecls.h	2 Apr 2008 17:02:26 -0000
@@ -372,7 +372,7 @@ EXTERN int		TclMacOSXMatchType (Tcl_Inte
 
 typedef struct TclIntPlatStubs {
     int magic;
-    struct TclIntPlatStubHooks *hooks;
+    CONST struct TclIntPlatStubHooks *hooks;
 
 #if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */
     void (*tclGetAndDetachPids) (Tcl_Interp * interp, Tcl_Channel chan); /* 0 */
@@ -447,15 +447,7 @@ typedef struct TclIntPlatStubs {
 } TclIntPlatStubs;
 
 #if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern TclIntPlatStubs *tclIntPlatStubsPtr;
-#ifdef __cplusplus
-}
-#endif
-
+EXTERN CONST TclIntPlatStubs *tclIntPlatStubsPtr;
 #endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */
 
 #if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS)
Index: generic/tclPlatDecls.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclPlatDecls.h,v
retrieving revision 1.28
diff -u -p -r1.28 tclPlatDecls.h
--- generic/tclPlatDecls.h	1 Apr 2008 16:23:41 -0000	1.28
+++ generic/tclPlatDecls.h	2 Apr 2008 17:02:27 -0000
@@ -82,7 +82,7 @@ EXTERN int		Tcl_MacOSXOpenVersionedBundl
 
 typedef struct TclPlatStubs {
     int magic;
-    struct TclPlatStubHooks *hooks;
+    CONST struct TclPlatStubHooks *hooks;
 
 #ifdef __WIN32__ /* WIN */
     TCHAR * (*tcl_WinUtfToTChar) (CONST char * str, int len, Tcl_DString * dsPtr); /* 0 */
@@ -95,15 +95,7 @@ typedef struct TclPlatStubs {
 } TclPlatStubs;
 
 #if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern TclPlatStubs *tclPlatStubsPtr;
-#ifdef __cplusplus
-}
-#endif
-
+EXTERN CONST TclPlatStubs *tclPlatStubsPtr;
 #endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */
 
 #if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS)
Index: generic/tclStubInit.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclStubInit.c,v
retrieving revision 1.150
diff -u -p -r1.150 tclStubInit.c
--- generic/tclStubInit.c	23 Jan 2008 17:31:42 -0000	1.150
+++ generic/tclStubInit.c	2 Apr 2008 17:02:27 -0000
@@ -491,7 +491,7 @@ TclTomMathStubs tclTomMathStubs = {
     TclBN_s_mp_sub, /* 60 */
 };
 
-static TclStubHooks tclStubHooks = {
+static const TclStubHooks tclStubHooks = {
     &tclPlatStubs,
     &tclIntStubs,
     &tclIntPlatStubs
Index: generic/tclStubLib.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclStubLib.c,v
retrieving revision 1.23
diff -u -p -r1.23 tclStubLib.c
--- generic/tclStubLib.c	2 Apr 2008 03:37:32 -0000	1.23
+++ generic/tclStubLib.c	2 Apr 2008 17:02:27 -0000
@@ -24,15 +24,17 @@
 
 #include "tclInt.h"
 
-/*
- * Tcl_InitStubs and stub table pointers are built as exported symbols.
- */
-
-TclStubs *tclStubsPtr = NULL;
-TclPlatStubs *tclPlatStubsPtr = NULL;
-TclIntStubs *tclIntStubsPtr = NULL;
-TclIntPlatStubs *tclIntPlatStubsPtr = NULL;
-TclTomMathStubs* tclTomMathStubsPtr = NULL;
+MODULE_SCOPE const TclStubs *tclStubsPtr;
+MODULE_SCOPE const TclPlatStubs *tclPlatStubsPtr;
+MODULE_SCOPE const TclIntStubs *tclIntStubsPtr;
+MODULE_SCOPE const TclIntPlatStubs *tclIntPlatStubsPtr;
+MODULE_SCOPE const TclTomMathStubs* tclTomMathStubsPtr;
+
+const TclStubs *tclStubsPtr = NULL;
+const TclPlatStubs *tclPlatStubsPtr = NULL;
+const TclIntStubs *tclIntStubsPtr = NULL;
+const TclIntPlatStubs *tclIntPlatStubsPtr = NULL;
+const TclTomMathStubs* tclTomMathStubsPtr = NULL;
 
 static TclStubs *
 HasStubSupport(
@@ -77,7 +79,7 @@ static int isDigit(const int c)
  *----------------------------------------------------------------------
  */
 
-CONST char *
+MODULE_SCOPE CONST char *
 Tcl_InitStubs(
     Tcl_Interp *interp,
     CONST char *version,
@@ -159,7 +161,7 @@ Tcl_InitStubs(
  *----------------------------------------------------------------------
  */
 
-CONST char*
+MODULE_SCOPE CONST char*
 TclTomMathInitializeStubs(
     Tcl_Interp* interp,		/* Tcl interpreter */
     CONST char* version,	/* Tcl version needed */
Index: generic/tclTomMathDecls.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclTomMathDecls.h,v
retrieving revision 1.3
diff -u -p -r1.3 tclTomMathDecls.h
--- generic/tclTomMathDecls.h	1 Apr 2008 16:23:42 -0000	1.3
+++ generic/tclTomMathDecls.h	2 Apr 2008 17:02:27 -0000
@@ -455,7 +455,7 @@ EXTERN int		TclBN_s_mp_sub (mp_int* a, m
 
 typedef struct TclTomMathStubs {
     int magic;
-    struct TclTomMathStubHooks *hooks;
+    CONST struct TclTomMathStubHooks *hooks;
 
     int (*tclBN_epoch) (void); /* 0 */
     int (*tclBN_revision) (void); /* 1 */
@@ -521,15 +521,7 @@ typedef struct TclTomMathStubs {
 } TclTomMathStubs;
 
 #if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern TclTomMathStubs *tclTomMathStubsPtr;
-#ifdef __cplusplus
-}
-#endif
-
+EXTERN CONST TclTomMathStubs *tclTomMathStubsPtr;
 #endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */
 
 #if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS)
Index: tools/genStubs.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/tools/genStubs.tcl,v
retrieving revision 1.23
diff -u -p -r1.23 genStubs.tcl
--- tools/genStubs.tcl	1 Apr 2008 16:23:42 -0000	1.23
+++ tools/genStubs.tcl	2 Apr 2008 17:02:28 -0000
@@ -984,13 +984,13 @@ proc genStubs::emitHeader {name} {
 	foreach hook $hooks($name) {
 	    set capHook [string toupper [string index $hook 0]]
 	    append capHook [string range $hook 1 end]
-	    append text "    struct ${capHook}Stubs *${hook}Stubs;\n"
+	    append text "    CONST struct ${capHook}Stubs *${hook}Stubs;\n"
 	}
 	append text "} ${capName}StubHooks;\n"
     }
     append text "\ntypedef struct ${capName}Stubs {\n"
     append text "    int magic;\n"
-    append text "    struct ${capName}StubHooks *hooks;\n\n"
+    append text "    CONST struct ${capName}StubHooks *hooks;\n\n"
 
     emitSlots $name text
 
@@ -998,9 +998,7 @@ proc genStubs::emitHeader {name} {
 
     set upName [string toupper $libraryName]
     append text "\n#if defined(USE_${upName}_STUBS) && !defined(USE_${upName}_STUB_PROCS)\n"
-    append text "\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n"
-    append text "extern ${capName}Stubs *${name}StubsPtr;\n"
-    append text "#ifdef __cplusplus\n}\n#endif\n"
+    append text "EXTERN CONST ${capName}Stubs *${name}StubsPtr;"
     append text "\n#endif /* defined(USE_${upName}_STUBS) && !defined(USE_${upName}_STUB_PROCS) */\n"
 
     emitMacros $name text
@@ -1050,7 +1048,7 @@ proc genStubs::emitInit {name textVar} {
     append capName [string range $name 1 end]
 
     if {[info exists hooks($name)]} {
-	append text "\nstatic ${capName}StubHooks ${name}StubHooks = \{\n"
+	append text "\nstatic const ${capName}StubHooks ${name}StubHooks = \{\n"
 	set sep "    "
 	foreach sub $hooks($name) {
 	    append text $sep "&${sub}Stubs"