summaryrefslogtreecommitdiffstats
path: root/generic/tclOOMethod.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2016-05-25 17:27:49 (GMT)
committerdgp <dgp@users.sourceforge.net>2016-05-25 17:27:49 (GMT)
commitec75618b67ba6350be88fd617aac6122cecc5250 (patch)
treef6f6adfd05ac35227af0cbee292a655df45cdddb /generic/tclOOMethod.c
parent13a6722593334f23786c8c20f446a8027a8ebe6c (diff)
downloadtcl-ec75618b67ba6350be88fd617aac6122cecc5250.zip
tcl-ec75618b67ba6350be88fd617aac6122cecc5250.tar.gz
tcl-ec75618b67ba6350be88fd617aac6122cecc5250.tar.bz2
Refactor all iPtr->ensembleRewrite setting code into TclInitRewriteEnsemble()
calls. This likely fixes many weird corner case bugs, and definitly makes future development and maintenance easier.
Diffstat (limited to 'generic/tclOOMethod.c')
-rw-r--r--generic/tclOOMethod.c23
1 files changed, 3 insertions, 20 deletions
diff --git a/generic/tclOOMethod.c b/generic/tclOOMethod.c
index b86a203..843f833 100644
--- a/generic/tclOOMethod.c
+++ b/generic/tclOOMethod.c
@@ -732,7 +732,6 @@ InvokeProcedureMethod(
* Now invoke the body of the method.
*/
-//fprintf(stdout, "eh? %p\n", ((Interp *)interp)->ensembleRewrite.sourceObjs); fflush(stdout);
TclNRAddCallback(interp, FinalizePMCall, pmPtr, context, fdPtr, NULL);
return TclNRInterpProcCore(interp, fdPtr->nameObj,
Tcl_ObjectContextSkippedArgs(context), fdPtr->errProc);
@@ -1595,12 +1594,9 @@ InitEnsembleRewrite(
int *lengthPtr) /* Where to write the resulting length of the
* array of rewritten arguments. */
{
- Interp *iPtr = (Interp *) interp;
- int isRootEnsemble = (iPtr->ensembleRewrite.sourceObjs == NULL);
- Tcl_Obj **argObjs;
unsigned len = rewriteLength + objc - toRewrite;
+ Tcl_Obj **argObjs = TclStackAlloc(interp, sizeof(Tcl_Obj *) * len);
- argObjs = TclStackAlloc(interp, sizeof(Tcl_Obj *) * len);
memcpy(argObjs, rewriteObjs, rewriteLength * sizeof(Tcl_Obj *));
memcpy(argObjs + rewriteLength, objv + toRewrite,
sizeof(Tcl_Obj *) * (objc - toRewrite));
@@ -1614,22 +1610,9 @@ InitEnsembleRewrite(
* (and unavoidably).
*/
- if (isRootEnsemble) {
- iPtr->ensembleRewrite.sourceObjs = objv;
- iPtr->ensembleRewrite.numRemovedObjs = toRewrite;
- iPtr->ensembleRewrite.numInsertedObjs = rewriteLength;
- } else {
- int numIns = iPtr->ensembleRewrite.numInsertedObjs;
-
- if (numIns < toRewrite) {
- iPtr->ensembleRewrite.numRemovedObjs += toRewrite - numIns;
- iPtr->ensembleRewrite.numInsertedObjs += rewriteLength - 1;
- } else {
- iPtr->ensembleRewrite.numInsertedObjs +=
- rewriteLength - toRewrite;
- }
+ if (TclInitRewriteEnsemble(interp, toRewrite, rewriteLength, objv)) {
+ TclNRAddCallback(interp, TclClearRootEnsemble, NULL, NULL, NULL, NULL);
}
-
*lengthPtr = len;
return argObjs;
}