summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2013-06-16 20:32:50 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2013-06-16 20:32:50 (GMT)
commit68292a6506ecddc2460b6f47f7589f8ad66a4858 (patch)
treec251d8da4f9bb5384a76cea8c7f48989cb9483c5 /generic
parent8a0b7ecf76ccbad9d6f0e838a17473c0dc0e0148 (diff)
downloadtcl-68292a6506ecddc2460b6f47f7589f8ad66a4858.zip
tcl-68292a6506ecddc2460b6f47f7589f8ad66a4858.tar.gz
tcl-68292a6506ecddc2460b6f47f7589f8ad66a4858.tar.bz2
split off TclInitStubTable() as separate function - which does the actual stub table initialization - previously part of Tcl_InitStubs().
Diffstat (limited to 'generic')
-rw-r--r--generic/tclInt.h8
-rw-r--r--generic/tclStubLib.c27
-rw-r--r--generic/tclStubLibTbl.c69
3 files changed, 80 insertions, 24 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h
index e60b627..1cf0337 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -3831,6 +3831,14 @@ MODULE_SCOPE int TclCompileAssembleCmd(Tcl_Interp *interp,
Tcl_Parse *parsePtr, Command *cmdPtr,
struct CompileEnv *envPtr);
+/* Used internally in stub library. */
+typedef struct {
+ char version[16];
+ ClientData data;
+} TclStubInfoType;
+
+MODULE_SCOPE const char *TclInitStubTable(const char *version);
+
/*
* 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/generic/tclStubLib.c b/generic/tclStubLib.c
index 859cbf9..e617515 100644
--- a/generic/tclStubLib.c
+++ b/generic/tclStubLib.c
@@ -13,16 +13,6 @@
#include "tclInt.h"
-MODULE_SCOPE const TclStubs *tclStubsPtr;
-MODULE_SCOPE const TclPlatStubs *tclPlatStubsPtr;
-MODULE_SCOPE const TclIntStubs *tclIntStubsPtr;
-MODULE_SCOPE const TclIntPlatStubs *tclIntPlatStubsPtr;
-
-const TclStubs *tclStubsPtr = NULL;
-const TclPlatStubs *tclPlatStubsPtr = NULL;
-const TclIntStubs *tclIntStubsPtr = NULL;
-const TclIntPlatStubs *tclIntPlatStubsPtr = NULL;
-
/*
* Use our own isDigit to avoid linking to libc on windows
*/
@@ -58,7 +48,7 @@ Tcl_InitStubs(
{
Interp *iPtr = (Interp *) interp;
const char *actualVersion = NULL;
- ClientData pkgData = NULL;
+ TclStubInfoType stub;
const TclStubs *stubsPtr = iPtr->stubTable;
/*
@@ -73,7 +63,7 @@ Tcl_InitStubs(
return NULL;
}
- actualVersion = stubsPtr->tcl_PkgRequireEx(interp, "Tcl", version, 0, &pkgData);
+ actualVersion = stubsPtr->tcl_PkgRequireEx(interp, "Tcl", version, 0, &stub.data);
if (actualVersion == NULL) {
return NULL;
}
@@ -103,18 +93,7 @@ Tcl_InitStubs(
}
}
}
- tclStubsPtr = (TclStubs *)pkgData;
-
- if (tclStubsPtr->hooks) {
- tclPlatStubsPtr = tclStubsPtr->hooks->tclPlatStubs;
- tclIntStubsPtr = tclStubsPtr->hooks->tclIntStubs;
- tclIntPlatStubsPtr = tclStubsPtr->hooks->tclIntPlatStubs;
- } else {
- tclPlatStubsPtr = NULL;
- tclIntStubsPtr = NULL;
- tclIntPlatStubsPtr = NULL;
- }
-
+ TclInitStubTable(stub.version);
return actualVersion;
}
diff --git a/generic/tclStubLibTbl.c b/generic/tclStubLibTbl.c
new file mode 100644
index 0000000..0ed057f
--- /dev/null
+++ b/generic/tclStubLibTbl.c
@@ -0,0 +1,69 @@
+/*
+ * tclStubLibTbl.c --
+ *
+ * Stub object that will be statically linked into extensions that want
+ * to access Tcl.
+ *
+ * Copyright (c) 1998-1999 by Scriptics Corporation.
+ * Copyright (c) 1998 Paul Duffin.
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+
+#include "tclInt.h"
+
+MODULE_SCOPE const TclStubs *tclStubsPtr;
+MODULE_SCOPE const TclPlatStubs *tclPlatStubsPtr;
+MODULE_SCOPE const TclIntStubs *tclIntStubsPtr;
+MODULE_SCOPE const TclIntPlatStubs *tclIntPlatStubsPtr;
+
+const TclStubs *tclStubsPtr = NULL;
+const TclPlatStubs *tclPlatStubsPtr = NULL;
+const TclIntStubs *tclIntStubsPtr = NULL;
+const TclIntPlatStubs *tclIntPlatStubsPtr = NULL;
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TclInitStubTable --
+ *
+ * Initialize the stub table, using the structure pointed at
+ * by the "version" argument.
+ *
+ * Results:
+ * Outputs the value of the "version" argument.
+ *
+ * Side effects:
+ * Sets the stub table pointers.
+ *
+ *----------------------------------------------------------------------
+ */
+MODULE_SCOPE const char *
+TclInitStubTable(
+ const char *version) /* points to the version field of a
+ TclStubInfoType structure variable. */
+{
+ const TclStubInfoType *ptr = (const TclStubInfoType *) version;
+ tclStubsPtr = (const TclStubs *) ptr->data;
+
+ if (tclStubsPtr->hooks) {
+ tclPlatStubsPtr = tclStubsPtr->hooks->tclPlatStubs;
+ tclIntStubsPtr = tclStubsPtr->hooks->tclIntStubs;
+ tclIntPlatStubsPtr = tclStubsPtr->hooks->tclIntPlatStubs;
+ } else {
+ tclPlatStubsPtr = NULL;
+ tclIntStubsPtr = NULL;
+ tclIntPlatStubsPtr = NULL;
+ }
+ return version;
+}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */