summaryrefslogtreecommitdiffstats
path: root/generic/tclEnsemble.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2016-07-01 14:08:22 (GMT)
committerdgp <dgp@users.sourceforge.net>2016-07-01 14:08:22 (GMT)
commitdc9d79ca409ce43c255fbf0d12b742bdd795a1f7 (patch)
tree52c1cf340bfd8288c36fbf6f4d80cc6a5f4124f9 /generic/tclEnsemble.c
parent433b92a00d44b96abae641511c035fdb9e21f75d (diff)
downloadtcl-dc9d79ca409ce43c255fbf0d12b742bdd795a1f7.zip
tcl-dc9d79ca409ce43c255fbf0d12b742bdd795a1f7.tar.gz
tcl-dc9d79ca409ce43c255fbf0d12b742bdd795a1f7.tar.bz2
Encapsulate the fetching of the ensemble rewrite root, used by [namespace].
Diffstat (limited to 'generic/tclEnsemble.c')
-rw-r--r--generic/tclEnsemble.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c
index fd2fa67..4e06518 100644
--- a/generic/tclEnsemble.c
+++ b/generic/tclEnsemble.c
@@ -2030,6 +2030,40 @@ TclResetRewriteEnsemble(
iPtr->ensembleRewrite.numInsertedObjs = 0;
}
}
+/*
+ *----------------------------------------------------------------------
+ *
+ * TclFetchEnsembleRoot --
+ *
+ * Returns the root of ensemble rewriting, if any.
+ * If no root exists, returns objv instead.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+Tcl_Obj *const *
+TclFetchEnsembleRoot(
+ Tcl_Interp *interp,
+ Tcl_Obj *const *objv,
+ int objc,
+ int *objcPtr)
+{
+ Interp *iPtr = (Interp *) interp;
+
+ if (iPtr->ensembleRewrite.sourceObjs) {
+ *objcPtr = objc + iPtr->ensembleRewrite.numRemovedObjs
+ - iPtr->ensembleRewrite.numInsertedObjs;
+ return iPtr->ensembleRewrite.sourceObjs;
+ }
+ *objcPtr = objc;
+ return objv;
+}
/*
* ----------------------------------------------------------------------