summaryrefslogtreecommitdiffstats
path: root/generic/tclStubLib.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclStubLib.c')
-rw-r--r--generic/tclStubLib.c69
1 files changed, 62 insertions, 7 deletions
diff --git a/generic/tclStubLib.c b/generic/tclStubLib.c
index 39e94c8..ff899c0 100644
--- a/generic/tclStubLib.c
+++ b/generic/tclStubLib.c
@@ -12,16 +12,16 @@
*/
#include "tclInt.h"
-#include "tclPort.h"
TclStubs *tclStubsPtr = NULL;
TclPlatStubs *tclPlatStubsPtr = NULL;
TclIntStubs *tclIntStubsPtr = NULL;
TclIntPlatStubs *tclIntPlatStubsPtr = NULL;
+TclTomMathStubs* tclTomMathStubsPtr = NULL;
static TclStubs *
-HasStubSupport(interp)
- Tcl_Interp *interp;
+HasStubSupport(
+ Tcl_Interp *interp)
{
Interp *iPtr = (Interp *) interp;
@@ -61,10 +61,10 @@ static int isDigit(const int c)
*/
#undef Tcl_InitStubs
CONST char *
-Tcl_InitStubs(interp, version, exact)
- Tcl_Interp *interp;
- CONST char *version;
- int exact;
+Tcl_InitStubs(
+ Tcl_Interp *interp,
+ CONST char *version,
+ int exact)
{
CONST char *actualVersion = NULL;
TclStubs *stubsPtr;
@@ -126,6 +126,61 @@ Tcl_InitStubs(interp, version, exact)
}
/*
+ *----------------------------------------------------------------------
+ *
+ * TclTomMathInitStubs --
+ *
+ * Initializes the Stubs table for Tcl's subset of libtommath
+ *
+ * Results:
+ * Returns a standard Tcl result.
+ *
+ * This procedure should not be called directly, but rather through
+ * the TclTomMath_InitStubs macro, to insure that the Stubs table
+ * matches the header files used in compilation.
+ *
+ *----------------------------------------------------------------------
+ */
+
+#undef TclTomMathInitializeStubs
+
+CONST char*
+TclTomMathInitializeStubs(
+ Tcl_Interp* interp, /* Tcl interpreter */
+ CONST char* version, /* Tcl version needed */
+ int epoch, /* Stubs table epoch from the header files */
+ int revision /* Stubs table revision number from the
+ * header files */
+) {
+ int exact = 0;
+ const char* packageName = "tcl::tommath";
+ const char* errMsg = NULL;
+ ClientData pkgClientData = NULL;
+ const char* actualVersion =
+ tclStubsPtr->tcl_PkgRequireEx(interp, packageName, version, exact, &pkgClientData);
+ TclTomMathStubs* stubsPtr = (TclTomMathStubs*) pkgClientData;
+ if (actualVersion == NULL) {
+ return NULL;
+ }
+ if (pkgClientData == NULL) {
+ errMsg = "missing stub table pointer";
+ } else if ((stubsPtr->tclBN_epoch)() != epoch) {
+ errMsg = "epoch number mismatch";
+ } else if ((stubsPtr->tclBN_revision)() != revision) {
+ errMsg = "requires a later revision";
+ } else {
+ tclTomMathStubsPtr = stubsPtr;
+ return actualVersion;
+ }
+ tclStubsPtr->tcl_ResetResult(interp);
+ tclStubsPtr->tcl_AppendResult(interp, "error loading ", packageName,
+ " (requested version ", version,
+ ", actual version ", actualVersion,
+ "): ", errMsg, NULL);
+ return NULL;
+}
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4