From c12c83e799a79e5d1faa3dc446e1ef322eaa31fd Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 21 Jun 2013 11:53:11 +0000 Subject: Modify internal TclStubInfoType type: use TclStubs * in stead of ClientData, so less type casts are needed in the code. Disadvantage: somewhat more code duplication, but it makes the code much more understandable. --- generic/tclInt.h | 2 +- generic/tclStubLib.c | 27 ++++++++++++++++++++++++--- generic/tclStubLibTbl.c | 15 ++------------- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/generic/tclInt.h b/generic/tclInt.h index 3432b37..c350d15 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -3837,7 +3837,7 @@ MODULE_SCOPE int TclCompileAssembleCmd(Tcl_Interp *interp, /* Used internally in stub library. */ typedef struct { char version[12]; - ClientData data; + const TclStubs *stubs; } TclStubInfoType; MODULE_SCOPE const char *TclInitStubTable(const char *version); diff --git a/generic/tclStubLib.c b/generic/tclStubLib.c index e617515..859cbf9 100644 --- a/generic/tclStubLib.c +++ b/generic/tclStubLib.c @@ -13,6 +13,16 @@ #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 */ @@ -48,7 +58,7 @@ Tcl_InitStubs( { Interp *iPtr = (Interp *) interp; const char *actualVersion = NULL; - TclStubInfoType stub; + ClientData pkgData = NULL; const TclStubs *stubsPtr = iPtr->stubTable; /* @@ -63,7 +73,7 @@ Tcl_InitStubs( return NULL; } - actualVersion = stubsPtr->tcl_PkgRequireEx(interp, "Tcl", version, 0, &stub.data); + actualVersion = stubsPtr->tcl_PkgRequireEx(interp, "Tcl", version, 0, &pkgData); if (actualVersion == NULL) { return NULL; } @@ -93,7 +103,18 @@ Tcl_InitStubs( } } } - TclInitStubTable(stub.version); + 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; + } + return actualVersion; } diff --git a/generic/tclStubLibTbl.c b/generic/tclStubLibTbl.c index 0ed057f..0391502 100644 --- a/generic/tclStubLibTbl.c +++ b/generic/tclStubLibTbl.c @@ -13,17 +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; - - /* *---------------------------------------------------------------------- * @@ -45,8 +34,7 @@ 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; + tclStubsPtr = ((const TclStubInfoType *) version)->stubs; if (tclStubsPtr->hooks) { tclPlatStubsPtr = tclStubsPtr->hooks->tclPlatStubs; @@ -57,6 +45,7 @@ TclInitStubTable( tclIntStubsPtr = NULL; tclIntPlatStubsPtr = NULL; } + return version; } -- cgit v0.12