I am currently reviewing the new interp impl, the one part
of this patch that bothers me are the changes in
src/jacl/tcl/lang/CatchCmd.java:
--- CatchCmd.java 1998/10/14 21:09:18 1.1.1.1
+++ CatchCmd.java 2000/08/19 22:21:19
@@ -38,11 +38,13 @@
TclObject result;
int code = TCL.OK;
+ interp.nestLevel++;
try {
interp.eval(argv[1], 0);
} catch (TclException e) {
code = e.getCompletionCode();
}
+ interp.nestLevel--;
result = interp.getResult();
@@ -55,6 +57,7 @@
}
}
+ interp.returnCode = TCL.OK;
interp.setResult(TclInteger.newInstance(code));
}
}
There C implementation (Tcl_CatchObjCmd) does not
have anything like this:
Tcl_CatchObjCmd(dummy, interp, objc, objv)
ClientData dummy; /* Not used. */
Tcl_Interp *interp; /* Current interpreter. */
int objc; /* Number of arguments. */
Tcl_Obj *CONST objv[]; /* Argument objects. */
{
Tcl_Obj *varNamePtr = NULL;
int result;
if ((objc != 2) && (objc != 3)) {
Tcl_WrongNumArgs(interp, 1, objv, "command ?varName?");
return TCL_ERROR;
}
/*
* Save a pointer to the variable name object, if any, in case the
* Tcl_EvalObj reallocates the bytecode interpreter's evaluation
* stack rendering objv invalid.
*/
if (objc == 3) {
varNamePtr = objv[2];
}
result = Tcl_EvalObjEx(interp, objv[1], 0);
if (objc == 3) {
if (Tcl_ObjSetVar2(interp, varNamePtr, NULL,
Tcl_GetObjResult(interp), 0) == NULL) {
Tcl_ResetResult(interp);
Tcl_AppendToObj(Tcl_GetObjResult(interp),
"couldn't save command result in variable", -1);
return TCL_ERROR;
}
}
/*
* Set the interpreter's object result to an integer object holding the
* integer Tcl_EvalObj result. Note that we don't bother generating a
* string representation. We reset the interpreter's object result
* to an unshared empty object and then set it to be an integer object.
*/
Tcl_ResetResult(interp);
Tcl_SetIntObj(Tcl_GetObjResult(interp), result);
return TCL_OK;
}
Why incr the nest level?
I would also rather just call interp.resetResult()
instead of using TCL.OK, what would the implications
of that be?
Mo DeJong
Red Hat Inc
----------------------------------------------------------------
The TclJava mailing list is sponsored by Scriptics Corporation.
To subscribe: send mail to [EMAIL PROTECTED]
with the word SUBSCRIBE as the subject.
To unsubscribe: send mail to [EMAIL PROTECTED]
with the word UNSUBSCRIBE as the subject.
To send to the list, send email to '[EMAIL PROTECTED]'.
An archive is available at http://www.mail-archive.com/[email protected]