summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-09-13 10:49:06 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-09-13 10:49:06 (GMT)
commit8cb023658d6e613c6a76db26b0b5568b6e0b2bb6 (patch)
treeed6601ca235b6f240172b0c9bc21eca657eb53b8
parente1dec685e9bda26a664969e11607fabc328c582c (diff)
downloadtcl-8cb023658d6e613c6a76db26b0b5568b6e0b2bb6.zip
tcl-8cb023658d6e613c6a76db26b0b5568b6e0b2bb6.tar.gz
tcl-8cb023658d6e613c6a76db26b0b5568b6e0b2bb6.tar.bz2
Fix [Bug 1026903] by storing what ensemble the ensemble is cached for.
-rw-r--r--ChangeLog7
-rw-r--r--generic/tclNamesp.c9
-rw-r--r--tests/namespace.test13
3 files changed, 26 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 8daf379..f55b12e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-09-13 Donal K. Fellows <donal.k.fellows@man.ac.uk>
+
+ * generic/tclNamesp.c (NsEnsembleImplementationCmd): Add token
+ field to internal rep of EnsembleCmdRep structure so that we can
+ check it to see if the subcommand object is really being used with
+ the same ensemble. [Bug 1026903]
+
2004-09-11 Kevin B. Kenny <kennykb@acm.org>
* generic/tclClock.c (TclMktimeObjCmd): Corrected a bad check
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index 75ba1ce..1ad687c 100644
--- a/generic/tclNamesp.c
+++ b/generic/tclNamesp.c
@@ -21,7 +21,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclNamesp.c,v 1.52 2004/09/10 18:19:15 dgp Exp $
+ * RCS: @(#) $Id: tclNamesp.c,v 1.53 2004/09/13 10:49:19 dkf Exp $
*/
#include "tclInt.h"
@@ -156,6 +156,8 @@ typedef struct EnsembleCmdRep {
int epoch; /* Used to confirm when the data in this
* really structure matches up with the
* ensemble. */
+ Tcl_Command token; /* Reference to the comamnd for which this
+ * structure is a cache of the resolution. */
char *fullSubcmdName; /* The full (local) name of the subcommand,
* allocated with ckalloc(). */
Tcl_Obj *realPrefixObj; /* Object containing the prefix words of the
@@ -4863,7 +4865,8 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
EnsembleCmdRep *ensembleCmd = (EnsembleCmdRep *)
objv[1]->internalRep.otherValuePtr;
if (ensembleCmd->nsPtr == ensemblePtr->nsPtr &&
- ensembleCmd->epoch == ensemblePtr->epoch) {
+ ensembleCmd->epoch == ensemblePtr->epoch &&
+ ensembleCmd->token == ensemblePtr->token) {
prefixObj = ensembleCmd->realPrefixObj;
Tcl_IncrRefCount(prefixObj);
goto runResultingSubcommand;
@@ -5160,6 +5163,7 @@ MakeCachedEnsembleCommand(objPtr, ensemblePtr, subcommandName, prefixObjPtr)
*/
ensembleCmd->nsPtr = ensemblePtr->nsPtr;
ensembleCmd->epoch = ensemblePtr->epoch;
+ ensembleCmd->token = ensemblePtr->token;
ensemblePtr->nsPtr->refCount++;
ensembleCmd->realPrefixObj = prefixObjPtr;
length = strlen(subcommandName)+1;
@@ -5582,6 +5586,7 @@ DupEnsembleCmdRep(objPtr, copyPtr)
copyPtr->internalRep.otherValuePtr = (VOID *) ensembleCopy;
ensembleCopy->nsPtr = ensembleCmd->nsPtr;
ensembleCopy->epoch = ensembleCmd->epoch;
+ ensembleCopy->token = ensembleCmd->token;
ensembleCopy->nsPtr->refCount++;
ensembleCopy->realPrefixObj = ensembleCmd->realPrefixObj;
Tcl_IncrRefCount(ensembleCopy->realPrefixObj);
diff --git a/tests/namespace.test b/tests/namespace.test
index 7e5cd6d..6338316 100644
--- a/tests/namespace.test
+++ b/tests/namespace.test
@@ -11,7 +11,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: namespace.test,v 1.36 2004/09/09 17:09:35 dgp Exp $
+# RCS: @(#) $Id: namespace.test,v 1.37 2004/09/13 10:49:19 dkf Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -1879,6 +1879,17 @@ test namespace-48.3 {ensembles and namespace import: config} {
set result
} {::foo 1 {"boo" is not an ensemble command} 1 {unknown command "spong"}}
+test namespace-49.1 {ensemble subcommand caching} -body {
+ namespace ens cre -command a -map {b {lappend result 1}}
+ namespace ens cre -command c -map {b {lappend result 2}}
+ proc x {} {a b; c b; a b; c b}
+ x
+} -result {1 2 1 2} -cleanup {
+ rename a {}
+ rename c {}
+ rename x {}
+}
+
# cleanup
catch {rename cmd1 {}}
catch {unset l}