summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2013-06-26 08:15:12 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2013-06-26 08:15:12 (GMT)
commit5ef0b5263e63b63ce07add89e153b12971fc3a09 (patch)
tree734cad629ecc9c8e56fcce5c64055c50288fe93b
parentc012287fc892b06388cdc3ac85d0b15bac1cdf50 (diff)
parentf6ed765b4a89bd56c984dfcf2da649499ffd03c0 (diff)
downloadtcl-5ef0b5263e63b63ce07add89e153b12971fc3a09.zip
tcl-5ef0b5263e63b63ce07add89e153b12971fc3a09.tar.gz
tcl-5ef0b5263e63b63ce07add89e153b12971fc3a09.tar.bz2
rebase
-rw-r--r--doc/InitSubSyst.353
-rw-r--r--generic/tcl.h10
-rw-r--r--generic/tclEncoding.c27
-rw-r--r--generic/tclInt.h6
-rw-r--r--unix/Makefile.in6
-rw-r--r--win/Makefile.in4
-rw-r--r--win/makefile.bc4
-rw-r--r--win/makefile.vc4
-rw-r--r--win/tcl.dsp4
9 files changed, 113 insertions, 5 deletions
diff --git a/doc/InitSubSyst.3 b/doc/InitSubSyst.3
new file mode 100644
index 0000000..08b3154
--- /dev/null
+++ b/doc/InitSubSyst.3
@@ -0,0 +1,53 @@
+'\"
+'\" Copyright (c) 2013 Tcl Core Team
+'\"
+'\" See the file "license.terms" for information on usage and redistribution
+'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+'\"
+.so man.macros
+.TH Tcl_InitSubsystems 3 8.6.1 Tcl "Tcl Library Procedures"
+.BS
+.SH NAME
+Tcl_InitSubsystems \- initialize the Tcl library.
+.SH SYNOPSIS
+.nf
+\fB#include <tcl.h>\fR
+.sp
+const char *
+\fBTcl_InitSubsystems\fR(\fIpanicProc\fR)
+.SH ARGUMENTS
+.SH ARGUMENTS
+.AS Tcl_PanicProc *panicProc
+.AP Tcl_PanicProc *panicProc in
+Desired panic function, for error reporting. If NULL, the default
+panicProc is used, which normally writes the message to stderr.
+.BE
+
+.SH DESCRIPTION
+.PP
+The \fBTcl_InitSubsystems\fR procedure initializes the Tcl
+library. This procedure is typically invoked as the very
+first thing in the application's main program.
+.PP
+\fBTcl_InitSubsystems\fR is very similar in use to
+\fBTcl_FindExecutable\fR. It can be used when Tcl is
+used as utility library, no other encodings than utf8,
+iso8859-1 or unicode are used, and no interest exists in the
+value of \fBinfo nameofexecutable\fR. The system encoding will not
+be extracted from the environment, but falls back to iso8859-1.
+.PP
+The return value is the Tcl version.
+.PP
+If \fBTcl_InitSubsystems()\fR is called in code where
+\fBUSE_TCL_STUBS\fR is set, it does one additional thing:
+initialize the Stub table for using Tcl as utility
+library, without needing a Tcl interpreter. For example:
+.CS
+const char *version = Tcl_InitSubSystems(NULL);
+/* At this point, Tcl C API calls without interp are ready for use */
+int major, minor, patch;
+Tcl_GetVersion(&major, &minor, &patch);
+.CE
+This will work as expected, both with and without stubs.
+.SH KEYWORDS
+binary, executable file
diff --git a/generic/tcl.h b/generic/tcl.h
index d47e931..091a5d6 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -2397,6 +2397,8 @@ const char * Tcl_InitStubs(Tcl_Interp *interp, const char *version,
int exact);
const char * TclTomMathInitializeStubs(Tcl_Interp *interp,
const char *version, int epoch, int revision);
+const char * TclInitStubTable(const char *version);
+
/*
* When not using stubs, make it a macro.
@@ -2411,6 +2413,14 @@ const char * TclTomMathInitializeStubs(Tcl_Interp *interp,
* TODO - tommath stubs export goes here!
*/
+/* Tcl_InitSubsystems, see TIP #414 */
+
+EXTERN const char *Tcl_InitSubsystems(Tcl_PanicProc *panicProc);
+#ifdef USE_TCL_STUBS
+#define Tcl_InitSubsystems(panicProc) \
+ TclInitStubTable((Tcl_InitSubsystems)(panicProc))
+#endif
+
/*
* Public functions that are not accessible via the stubs table.
* Tcl_GetMemoryInfo is needed for AOLserver. [Bug 1868171]
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 2cc55d6..8bfb610 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -1411,21 +1411,40 @@ Tcl_UtfToExternal(
/*
*---------------------------------------------------------------------------
*
- * Tcl_FindExecutable --
+ * Tcl_InitSubsystems/Tcl_FindExecutable --
*
- * This function computes the absolute path name of the current
- * application, given its argv[0] value.
+ * This function initializes everything needed for the Tcl library
+ * to be able to operate.
*
* Results:
* None.
*
* Side effects:
* The absolute pathname for the application is computed and stored to be
- * returned later be [info nameofexecutable].
+ * returned later by [info nameofexecutable]. The system encoding is
+ * determined and stored to be returned later by [encoding system]
*
*---------------------------------------------------------------------------
*/
+MODULE_SCOPE const TclStubs tclStubs;
+
+/* Structure returned by Tcl_InitSubsystems, which can be interpreted
+ * as the Tcl version, but also can be used to initialize the stub table. */
+static const TclStubInfoType stubInfo = {
+ TCL_PATCH_LEVEL, &tclStubs
+};
+
#undef Tcl_FindExecutable
+const char *
+Tcl_InitSubsystems(Tcl_PanicProc *panicProc)
+{
+ if (panicProc) {
+ Tcl_SetPanicProc(panicProc);
+ }
+ TclInitSubsystems();
+ return stubInfo.version;
+}
+
void
Tcl_FindExecutable(
const char *argv0) /* The value of the application's argv[0]
diff --git a/generic/tclInt.h b/generic/tclInt.h
index fdd577a..c2d48f7 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -3834,6 +3834,12 @@ MODULE_SCOPE int TclCompileAssembleCmd(Tcl_Interp *interp,
Tcl_Parse *parsePtr, Command *cmdPtr,
struct CompileEnv *envPtr);
+/* Used internally in stub library. */
+typedef struct {
+ char version[12];
+ const TclStubs *stubs;
+} TclStubInfoType;
+
/*
* Functions defined in generic/tclVar.c and currenttly exported only for use
* by the bytecode compiler and engine. Some of these could later be placed in
diff --git a/unix/Makefile.in b/unix/Makefile.in
index f0a729f..5295a45 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -335,7 +335,7 @@ TOMMATH_OBJS = bncore.o bn_reverse.o bn_fast_s_mp_mul_digs.o \
bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o bn_s_mp_add.o \
bn_s_mp_mul_digs.o bn_s_mp_sqr.o bn_s_mp_sub.o
-STUB_LIB_OBJS = tclStubLib.o tclTomMathStubLib.o tclOOStubLib.o ${COMPAT_OBJS}
+STUB_LIB_OBJS = tclStubLib.o tclStubLibTbl.o tclTomMathStubLib.o tclOOStubLib.o ${COMPAT_OBJS}
UNIX_OBJS = tclUnixChan.o tclUnixEvent.o tclUnixFCmd.o \
tclUnixFile.o tclUnixPipe.o tclUnixSock.o \
@@ -470,6 +470,7 @@ OO_SRCS = \
STUB_SRCS = \
$(GENERIC_DIR)/tclStubLib.c \
+ $(GENERIC_DIR)/tclStubLibTbl.c \
$(GENERIC_DIR)/tclTomMathStubLib.c \
$(GENERIC_DIR)/tclOOStubLib.c
@@ -1685,6 +1686,9 @@ Zzutil.o: $(ZLIB_DIR)/zutil.c
tclStubLib.o: $(GENERIC_DIR)/tclStubLib.c
$(CC) -c $(STUB_CC_SWITCHES) $(GENERIC_DIR)/tclStubLib.c
+tclStubLibTbl.o: $(GENERIC_DIR)/tclStubLibTbl.c
+ $(CC) -c $(STUB_CC_SWITCHES) $(GENERIC_DIR)/tclStubLibTbl.c
+
tclTomMathStubLib.o: $(GENERIC_DIR)/tclTomMathStubLib.c
$(CC) -c $(STUB_CC_SWITCHES) $(GENERIC_DIR)/tclTomMathStubLib.c
diff --git a/win/Makefile.in b/win/Makefile.in
index 47f3fdd..d7b25b7 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -385,6 +385,7 @@ REG_OBJS = tclWinReg.$(OBJEXT)
STUB_OBJS = \
tclStubLib.$(OBJEXT) \
+ tclStubLibTbl.$(OBJEXT) \
tclTomMathStubLib.$(OBJEXT) \
tclOOStubLib.$(OBJEXT)
@@ -515,6 +516,9 @@ tclPkgConfig.${OBJEXT}: tclPkgConfig.c
tclStubLib.${OBJEXT}: tclStubLib.c
$(CC) -c $(CC_SWITCHES) -DSTATIC_BUILD @DEPARG@ $(CC_OBJNAME)
+tclStubLibTbl.${OBJEXT}: tclStubLibTbl.c
+ $(CC) -c $(CC_SWITCHES) -DSTATIC_BUILD @DEPARG@ $(CC_OBJNAME)
+
tclTomMathStubLib.${OBJEXT}: tclTomMathStubLib.c
$(CC) -c $(CC_SWITCHES) -DSTATIC_BUILD @DEPARG@ $(CC_OBJNAME)
diff --git a/win/makefile.bc b/win/makefile.bc
index 0b17cea..2726dad 100644
--- a/win/makefile.bc
+++ b/win/makefile.bc
@@ -279,6 +279,7 @@ TCLOBJS = \
TCLSTUBOBJS = \
$(TMPDIR)\tclStubLib.obj \
+ $(TMPDIR)\tclStubLibTbl.obj \
$(TMPDIR)\tclTomMathStubLib.obj \
$(TMPDIR)\tclOOStubLib.obj
@@ -528,6 +529,9 @@ $(TMPDIR)\tclWinDde.obj : $(WINDIR)\tclWinDde.c
$(TMPDIR)\tclStubLib.obj : $(GENERICDIR)\tclStubLib.c
$(cc32) $(TCL_CFLAGS) -DSTATIC_BUILD -o$(TMPDIR)\$@ $?
+$(TMPDIR)\tclStubLibTbl.obj : $(GENERICDIR)\tclStubLibTbl.c
+ $(cc32) $(TCL_CFLAGS) -DSTATIC_BUILD -o$(TMPDIR)\$@ $?
+
$(TMPDIR)\tclTomMathStubLib.obj : $(GENERICDIR)\tclTomMathStubLib.c
$(cc32) $(TCL_CFLAGS) -DSTATIC_BUILD -o$(TMPDIR)\$@ $?
diff --git a/win/makefile.vc b/win/makefile.vc
index cddb253..c24534a 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -450,6 +450,7 @@ TCLOBJS = $(COREOBJS) $(ZLIBOBJS) $(TOMMATHOBJS) $(PLATFORMOBJS)
TCLSTUBOBJS = \
$(TMP_DIR)\tclStubLib.obj \
+ $(TMP_DIR)\tclStubLibTbl.obj \
$(TMP_DIR)\tclTomMathStubLib.obj \
$(TMP_DIR)\tclOOStubLib.obj
@@ -979,6 +980,9 @@ $(TMP_DIR)\tclWinDde.obj: $(WINDIR)\tclWinDde.c
$(TMP_DIR)\tclStubLib.obj: $(GENERICDIR)\tclStubLib.c
$(cc32) $(STUB_CFLAGS) -Zl -DSTATIC_BUILD $(TCL_INCLUDES) -Fo$@ $?
+$(TMP_DIR)\tclStubLibTbl.obj: $(GENERICDIR)\tclStubLibTbl.c
+ $(cc32) $(STUB_CFLAGS) -Zl -DSTATIC_BUILD $(TCL_INCLUDES) -Fo$@ $?
+
$(TMP_DIR)\tclTomMathStubLib.obj: $(GENERICDIR)\tclTomMathStubLib.c
$(cc32) $(STUB_CFLAGS) -Zl -DSTATIC_BUILD $(TCL_INCLUDES) -Fo$@ $?
diff --git a/win/tcl.dsp b/win/tcl.dsp
index 57ec6bf..2708051 100644
--- a/win/tcl.dsp
+++ b/win/tcl.dsp
@@ -1300,6 +1300,10 @@ SOURCE=..\generic\tclStubLib.c
# End Source File
# Begin Source File
+SOURCE=..\generic\tclStubLibTbl.c
+# End Source File
+# Begin Source File
+
SOURCE=..\generic\tclOOStubLib.c
# End Source File
# Begin Source File