diff options
Diffstat (limited to 'generic/tclStubLib.c')
-rw-r--r-- | generic/tclStubLib.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/generic/tclStubLib.c b/generic/tclStubLib.c index f569820..8f5800d 100644 --- a/generic/tclStubLib.c +++ b/generic/tclStubLib.c @@ -32,20 +32,39 @@ const TclPlatStubs *tclPlatStubsPtr = NULL; const TclIntStubs *tclIntStubsPtr = NULL; const TclIntPlatStubs *tclIntPlatStubsPtr = NULL; +typedef Tcl_Obj *(NewStringObjProc) (const char *bytes, size_t length); + + static const TclStubs * HasStubSupport( Tcl_Interp *interp) { Interp *iPtr = (Interp *) interp; - if (iPtr->stubTable && (iPtr->stubTable->magic == TCL_STUB_MAGIC)) { - return iPtr->stubTable; + if (!iPtr->stubTable) { + /* No stub table at all? Nothing we can do. */ + return NULL; } - - iPtr->result = - (char *)"This interpreter does not support stubs-enabled extensions."; - iPtr->freeProc = TCL_STATIC; - return NULL; + if (iPtr->stubTable->magic != TCL_STUB_MAGIC) { + /* + * We cannot acces interp->result and interp->freeProc + * any more: They will be gone in Tcl 9. In stead, + * assume that the iPtr->stubTable entry from Tcl_Interp + * and the Tcl_NewStringObj() and Tcl_SetObjResult() entries + * in the stub table don't change in Tcl 9. Need to add + * a test-case in Tcl 9 to assure that. + * + * The signature of Tcl_NewStringObj will change: the length + * parameter will be of type size_t. But passing the value + * (size_t)-1 will work, whatever the signature will be. + */ + NewStringObjProc *newStringObj = (NewStringObjProc *) + iPtr->stubTable->tcl_NewStringObj; + iPtr->stubTable->tcl_SetObjResult(interp, newStringObj( + "This extension is compiled for Tcl 8.x", (size_t)-1)); + return NULL; + } + return iPtr->stubTable; } /* |