01: /*
02: * VarTraceTest.java --
03: *
04: * This class is used to test the variable trace Interp interfaces.
05: *
06: * Copyright (c) 1997 by Sun Microsystems, Inc.
07: *
08: * See the file "license.terms" for information on usage and redistribution
09: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10: *
11: * RCS: @(#) $Id: VarTraceTest.java,v 1.1 1999/05/10 04:09:03 dejong Exp $
12: */
13:
14: package tests;
15:
16: import tcl.lang.*;
17:
18: public class VarTraceTest implements VarTrace {
19:
20: public String script;
21:
22: public StringBuffer varsCalled = new StringBuffer();
23:
24: public VarTraceTest(String s) {
25: script = s;
26: }
27:
28: /*
29: *----------------------------------------------------------------------
30: *
31: * traceProc --
32: *
33: * This function gets called when a variable is accessed.
34: *
35: * Results:
36: * None.
37: *
38: * Side effects:
39: * The traceProc can cause arbitrary side effects. If a
40: * TclException is thrown, error message is stored in the result
41: * of the interpreter.
42: *
43: *----------------------------------------------------------------------
44: */
45:
46: public void traceProc(Interp interp, // Current interpreter.
47: String part1, // First part of the variable name.
48: String part2, // Second part of the var name. May be null.
49: int flags) // TCL.TRACE_READS, TCL.TRACE_WRITES or
50: // TCL.TRACE_UNSETS (exactly one of these
51: // bits will be set.)
52: throws TclException // The traceProc may throw a TclException
53: // to indicate an error during the trace.
54: {
55: varsCalled.append(part1 + "(" + part2 + ") ");
56:
57: if (script.length() != 0) {
58: interp.eval(script);
59: }
60: }
61:
62: } // end VarTraceTest
|