diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-11-18 17:12:35 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-11-18 17:12:35 (GMT) |
commit | 56b9df62a1c1b096f9dcd04ea18dc8b2d19fc249 (patch) | |
tree | 7487d1f6a10118f5633c7043c27145a53779e88e /generic | |
parent | 2bf2abcb4f1c88fbddc3ce4d5800c438851aaf95 (diff) | |
parent | 3a030386112001a10caf4c697a743b7f2796c9ab (diff) | |
download | tcl-56b9df62a1c1b096f9dcd04ea18dc8b2d19fc249.zip tcl-56b9df62a1c1b096f9dcd04ea18dc8b2d19fc249.tar.gz tcl-56b9df62a1c1b096f9dcd04ea18dc8b2d19fc249.tar.bz2 |
<i>on-hold at Don Porter's request</i>
on_hold_trunk
change stub library to detect - and generate a nice error-message -
when a shared library compiled for Tcl 8.x is attempted to be
loaded in Tcl 9.x: Tcl 9 will not have the iPtr->result field
so we cannot use that any more.
Diffstat (limited to 'generic')
-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; } /* |