home *** CD-ROM | disk | FTP | other *** search
-
-
-
- TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr((((3333)))) TTTTccccllll (((( )))) TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr((((3333))))
-
-
-
- _________________________________________________________________
-
- NNNNAAAAMMMMEEEE
- Tcl_TraceVar, Tcl_TraceVar2, Tcl_UntraceVar,
- Tcl_UntraceVar2, Tcl_VarTraceInfo, Tcl_VarTraceInfo2 -
- monitor accesses to a variable
-
- SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
- ####iiiinnnncccclllluuuuddddeeee <<<<ttttccccllll....hhhh>>>>
-
- int
- TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr((((_i_n_t_e_r_p, _v_a_r_N_a_m_e, _f_l_a_g_s, _p_r_o_c, _c_l_i_e_n_t_D_a_t_a))))
-
- int
- TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr2222((((_i_n_t_e_r_p, _n_a_m_e_1, _n_a_m_e_2, _f_l_a_g_s, _p_r_o_c, _c_l_i_e_n_t_D_a_t_a))))
-
- TTTTccccllll____UUUUnnnnttttrrrraaaacccceeeeVVVVaaaarrrr((((_i_n_t_e_r_p, _v_a_r_N_a_m_e, _f_l_a_g_s, _p_r_o_c, _c_l_i_e_n_t_D_a_t_a))))
-
- TTTTccccllll____UUUUnnnnttttrrrraaaacccceeeeVVVVaaaarrrr2222((((_i_n_t_e_r_p, _n_a_m_e_1, _n_a_m_e_2, _f_l_a_g_s, _p_r_o_c, _c_l_i_e_n_t_D_a_t_a))))
-
- ClientData
- TTTTccccllll____VVVVaaaarrrrTTTTrrrraaaacccceeeeIIIInnnnffffoooo((((_i_n_t_e_r_p, _v_a_r_N_a_m_e, _f_l_a_g_s, _p_r_o_c, _p_r_e_v_C_l_i_e_n_t_D_a_t_a))))
-
- ClientData
- TTTTccccllll____VVVVaaaarrrrTTTTrrrraaaacccceeeeIIIInnnnffffoooo2222((((_i_n_t_e_r_p, _n_a_m_e_1, _n_a_m_e_2, _f_l_a_g_s, _p_r_o_c, _p_r_e_v_C_l_i_e_n_t_D_a_t_a))))
-
- AAAARRRRGGGGUUUUMMMMEEEENNNNTTTTSSSS
- Tcl_Interp *_i_n_t_e_r_p (in) Interpreter
- containing
- variable.
-
- char *_v_a_r_N_a_m_e (in) Name of
- variable. May
- refer to a
- scalar
- variable, to
- an array
- variable with
- no index, or
- to an array
- variable with
- a
- parenthesized
- index.
-
- int _f_l_a_g_s (in) OR-ed
- combination of
- the values
- TCL_TRACE_READS,
- TCL_TRACE_WRITES,
- and
- TCL_TRACE_UNSETS,
-
-
-
- Page 1 (printed 7/10/95)
-
-
-
-
-
-
- TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr((((3333)))) TTTTccccllll (((( )))) TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr((((3333))))
-
-
-
- and
- TCL_GLOBAL_ONLY.
- Not all flags
- are used by
- all
- procedures.
- See below for
- more
- information.
-
- Tcl_VarTraceProc *_p_r_o_c (in) Procedure to
- invoke
- whenever one
- of the traced
- operations
- occurs.
-
- ClientData _c_l_i_e_n_t_D_a_t_a (in) Arbitrary
- one-word value
- to pass to
- _p_r_o_c.
-
- char *_n_a_m_e_1 (in) Name of scalar
- or array
- variable
- (without array
- index).
-
- char *_n_a_m_e_2 (in) For a trace on
- an element of
- an array,
- gives the
- index of the
- element. For
- traces on
- scalar
- variables or
- on whole
- arrays, is
- NULL.
-
- ClientData _p_r_e_v_C_l_i_e_n_t_D_a_t_a (in) If non-NULL,
- gives last
- value returned
- by
- TTTTccccllll____VVVVaaaarrrrTTTTrrrraaaacccceeeeIIIInnnnffffoooo
- or
- TTTTccccllll____VVVVaaaarrrrTTTTrrrraaaacccceeeeIIIInnnnffffoooo2222,
- so this call
- will return
- information
- about next
-
-
-
- Page 2 (printed 7/10/95)
-
-
-
-
-
-
- TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr((((3333)))) TTTTccccllll (((( )))) TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr((((3333))))
-
-
-
- trace. If
- NULL, this
- call will
- return
- information
- about first
- trace.
- _________________________________________________________________
-
-
- DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
- TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr allows a C procedure to monitor and control
- access to a Tcl variable, so that the C procedure is invoked
- whenever the variable is read or written or unset. If the
- trace is created successfully then TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr returns
- TCL_OK. If an error occurred (e.g. _v_a_r_N_a_m_e specifies an
- element of an array, but the actual variable isn't an array)
- then TCL_ERROR is returned and an error message is left in
- _i_n_t_e_r_p->_r_e_s_u_l_t.
-
- The _f_l_a_g_s argument to TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr indicates when the trace
- procedure is to be invoked and provides information for
- setting up the trace. It consists of an OR-ed combination
- of any of the following values:
-
- TTTTCCCCLLLL____GGGGLLLLOOOOBBBBAAAALLLL____OOOONNNNLLLLYYYY
- Normally, the variable will be looked up at the current
- level of procedure call; if this bit is set then the
- variable will be looked up at global level, ignoring
- any active procedures.
-
- TTTTCCCCLLLL____TTTTRRRRAAAACCCCEEEE____RRRREEEEAAAADDDDSSSS
- Invoke _p_r_o_c whenever an attempt is made to read the
- variable.
-
- TTTTCCCCLLLL____TTTTRRRRAAAACCCCEEEE____WWWWRRRRIIIITTTTEEEESSSS
- Invoke _p_r_o_c whenever an attempt is made to modify the
- variable.
-
- TTTTCCCCLLLL____TTTTRRRRAAAACCCCEEEE____UUUUNNNNSSSSEEEETTTTSSSS
- Invoke _p_r_o_c whenever the variable is unset. A variable
- may be unset either explicitly by an uuuunnnnsssseeeetttt command, or
- implicitly when a procedure returns (its local
- variables are automatically unset) or when the
- interpreter is deleted (all variables are automatically
- unset).
-
- Whenever one of the specified operations occurs on the
- variable, _p_r_o_c will be invoked. It should have arguments
- and result that match the type TTTTccccllll____VVVVaaaarrrrTTTTrrrraaaacccceeeePPPPrrrroooocccc:
- typedef char *Tcl_VarTraceProc(
- ClientData _c_l_i_e_n_t_D_a_t_a,
-
-
-
- Page 3 (printed 7/10/95)
-
-
-
-
-
-
- TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr((((3333)))) TTTTccccllll (((( )))) TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr((((3333))))
-
-
-
- Tcl_Interp *_i_n_t_e_r_p,
- char *_n_a_m_e_1,
- char *_n_a_m_e_2,
- int _f_l_a_g_s);
- The _c_l_i_e_n_t_D_a_t_a and _i_n_t_e_r_p parameters will have the same
- values as those passed to TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr when the trace was
- created. _C_l_i_e_n_t_D_a_t_a typically points to an application-
- specific data structure that describes what to do when _p_r_o_c
- is invoked. _N_a_m_e_1 and _n_a_m_e_2 give the name of the traced
- variable in the normal two-part form (see the description of
- TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr2222 below for details). _F_l_a_g_s is an OR-ed
- combination of bits providing several pieces of information.
- One of the bits TCL_TRACE_READS, TCL_TRACE_WRITES, or
- TCL_TRACE_UNSETS will be set in _f_l_a_g_s to indicate which
- operation is being performed on the variable. The bit
- TCL_GLOBAL_ONLY will be set whenever the variable being
- accessed is a global one not accessible from the current
- level of procedure call: the trace procedure will need to
- pass this flag back to variable-related procedures like
- TTTTccccllll____GGGGeeeettttVVVVaaaarrrr if it attempts to access the variable. The bit
- TCL_TRACE_DESTROYED will be set in _f_l_a_g_s if the trace is
- about to be destroyed; this information may be useful to
- _p_r_o_c so that it can clean up its own internal data
- structures (see the section TCL_TRACE_DESTROYED below for
- more details). Lastly, the bit TCL_INTERP_DESTROYED will be
- set if the entire interpreter is being destroyed. When this
- bit is set, _p_r_o_c must be especially careful in the things it
- does (see the section TCL_INTERP_DESTROYED below). The
- trace procedure's return value should normally be NULL; see
- ERROR RETURNS below for information on other possibilities.
-
- TTTTccccllll____UUUUnnnnttttrrrraaaacccceeeeVVVVaaaarrrr may be used to remove a trace. If the
- variable specified by _i_n_t_e_r_p, _v_a_r_N_a_m_e, and _f_l_a_g_s has a trace
- set with _f_l_a_g_s, _p_r_o_c, and _c_l_i_e_n_t_D_a_t_a, then the corresponding
- trace is removed. If no such trace exists, then the call to
- TTTTccccllll____UUUUnnnnttttrrrraaaacccceeeeVVVVaaaarrrr has no effect. The same bits are valid for
- _f_l_a_g_s as for calls to TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrrssss.
-
- TTTTccccllll____VVVVaaaarrrrTTTTrrrraaaacccceeeeIIIInnnnffffoooo may be used to retrieve information about
- traces set on a given variable. The return value from
- TTTTccccllll____VVVVaaaarrrrTTTTrrrraaaacccceeeeIIIInnnnffffoooo is the _c_l_i_e_n_t_D_a_t_a associated with a
- particular trace. The trace must be on the variable
- specified by the _i_n_t_e_r_p, _v_a_r_N_a_m_e, and _f_l_a_g_s arguments (only
- the TCL_GLOBAL_ONLY bit from _f_l_a_g_s is used; other bits are
- ignored) and its trace procedure must the same as the _p_r_o_c
- argument. If the _p_r_e_v_C_l_i_e_n_t_D_a_t_a argument is NULL then the
- return value corresponds to the first (most recently
- created) matching trace, or NULL if there are no matching
- traces. If the _p_r_e_v_C_l_i_e_n_t_D_a_t_a argument isn't NULL, then it
- should be the return value from a previous call to
- TTTTccccllll____VVVVaaaarrrrTTTTrrrraaaacccceeeeIIIInnnnffffoooo. In this case, the new return value will
- correspond to the next matching trace after the one whose
-
-
-
- Page 4 (printed 7/10/95)
-
-
-
-
-
-
- TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr((((3333)))) TTTTccccllll (((( )))) TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr((((3333))))
-
-
-
- _c_l_i_e_n_t_D_a_t_a matches _p_r_e_v_C_l_i_e_n_t_D_a_t_a, or NULL if no trace
- matches _p_r_e_v_C_l_i_e_n_t_D_a_t_a or if there are no more matching
- traces after it. This mechanism makes it possible to step
- through all of the traces for a given variable that have the
- same _p_r_o_c.
-
-
- TTTTWWWWOOOO----PPPPAAAARRRRTTTT NNNNAAAAMMMMEEEESSSS
- The procedures TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr2222, TTTTccccllll____UUUUnnnnttttrrrraaaacccceeeeVVVVaaaarrrr2222, and
- TTTTccccllll____VVVVaaaarrrrTTTTrrrraaaacccceeeeIIIInnnnffffoooo2222 are identical to TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr,
- TTTTccccllll____UUUUnnnnttttrrrraaaacccceeeeVVVVaaaarrrr, and TTTTccccllll____VVVVaaaarrrrTTTTrrrraaaacccceeeeIIIInnnnffffoooo, respectively, except
- that the name of the variable has already been separated by
- the caller into two parts. _N_a_m_e_1 gives the name of a scalar
- variable or array, and _n_a_m_e_2 gives the name of an element
- within an array. If _n_a_m_e_2 is NULL it means that either the
- variable is a scalar or the trace is to be set on the entire
- array rather than an individual element (see WHOLE-ARRAY
- TRACES below for more information).
-
-
- AAAACCCCCCCCEEEESSSSSSSSIIIINNNNGGGG VVVVAAAARRRRIIIIAAAABBBBLLLLEEEESSSS DDDDUUUURRRRIIIINNNNGGGG TTTTRRRRAAAACCCCEEEESSSS
- During read and write traces, the trace procedure can read,
- write, or unset the traced variable using TTTTccccllll____GGGGeeeettttVVVVaaaarrrr2222,
- TTTTccccllll____SSSSeeeettttVVVVaaaarrrr2222, and other procedures. While _p_r_o_c is executing,
- traces are temporarily disabled for the variable, so that
- calls to TTTTccccllll____GGGGeeeettttVVVVaaaarrrr2222 and TTTTccccllll____SSSSeeeettttVVVVaaaarrrr2222 will not cause _p_r_o_c or
- other trace procedures to be invoked again. Disabling only
- occurs for the variable whose trace procedure is active;
- accesses to other variables will still be traced. However, |
- if a variable is unset during a read or write trace then |
- unset traces will be invoked.
-
- During unset traces the variable has already been completely
- expunged. It is possible for the trace procedure to read or
- write the variable, but this will be a new version of the
- variable. Traces are not disabled during unset traces as
- they are for read and write traces, but existing traces have
- been removed from the variable before any trace procedures
- are invoked. If new traces are set by unset trace
- procedures, these traces will be invoked on accesses to the
- variable by the trace procedures.
-
-
- CCCCAAAALLLLLLLLBBBBAAAACCCCKKKK TTTTIIIIMMMMIIIINNNNGGGG
- When read tracing has been specified for a variable, the
- trace procedure will be invoked whenever the variable's
- value is read. This includes sssseeeetttt Tcl commands, $$$$-notation
- in Tcl commands, and invocations of the TTTTccccllll____GGGGeeeettttVVVVaaaarrrr and
- TTTTccccllll____GGGGeeeettttVVVVaaaarrrr2222 procedures. _P_r_o_c is invoked just before the
- variable's value is returned. It may modify the value of
- the variable to affect what is returned by the traced
- access. If it unsets the variable then the access will |
-
-
-
- Page 5 (printed 7/10/95)
-
-
-
-
-
-
- TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr((((3333)))) TTTTccccllll (((( )))) TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr((((3333))))
-
-
-
- return an error just as if the variable never existed.
-
- When write tracing has been specified for a variable, the
- trace procedure will be invoked whenever the variable's
- value is modified. This includes sssseeeetttt commands, commands
- that modify variables as side effects (such as ccccaaaattttcccchhhh and
- ssssccccaaaannnn), and calls to the TTTTccccllll____SSSSeeeettttVVVVaaaarrrr and TTTTccccllll____SSSSeeeettttVVVVaaaarrrr2222
- procedures). _P_r_o_c will be invoked after the variable's
- value has been modified, but before the new value of the
- variable has been returned. It may modify the value of the
- variable to override the change and to determine the value
- actually returned by the traced access. If it deletes the |
- variable then the traced access will return an empty string.
-
- When unset tracing has been specified, the trace procedure
- will be invoked whenever the variable is destroyed. The
- traces will be called after the variable has been completely
- unset.
-
-
- WWWWHHHHOOOOLLLLEEEE----AAAARRRRRRRRAAAAYYYY TTTTRRRRAAAACCCCEEEESSSS
- If a call to TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr or TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr2222 specifies the
- name of an array variable without an index into the array,
- then the trace will be set on the array as a whole. This
- means that _p_r_o_c will be invoked whenever any element of the
- array is accessed in the ways specified by _f_l_a_g_s. When an
- array is unset, a whole-array trace will be invoked just
- once, with _n_a_m_e_1 equal to the name of the array and _n_a_m_e_2
- NULL; it will not be invoked once for each element.
-
-
- MMMMUUUULLLLTTTTIIIIPPPPLLLLEEEE TTTTRRRRAAAACCCCEEEESSSS
- It is possible for multiple traces to exist on the same
- variable. When this happens, all of the trace procedures
- will be invoked on each access, in order from most-
- recently-created to least-recently-created. When there
- exist whole-array traces for an array as well as traces on
- individual elements, the whole-array traces are invoked
- before the individual-element traces. If a read or write |
- trace unsets the variable then all of the unset traces will |
- be invoked but the remainder of the read and write traces |
- will be skipped.
-
-
- EEEERRRRRRRROOOORRRR RRRREEEETTTTUUUURRRRNNNNSSSS
- Under normal conditions trace procedures should return NULL,
- indicating successful completion. If _p_r_o_c returns a non-
- NULL value it signifies that an error occurred. The return
- value must be a pointer to a static character string
- containing an error message. If a trace procedure returns
- an error, no further traces are invoked for the access and
- the traced access aborts with the given message. Trace
-
-
-
- Page 6 (printed 7/10/95)
-
-
-
-
-
-
- TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr((((3333)))) TTTTccccllll (((( )))) TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr((((3333))))
-
-
-
- procedures can use this facility to make variables read-
- only, for example (but note that the value of the variable
- will already have been modified before the trace procedure
- is called, so the trace procedure will have to restore the
- correct value).
-
- The return value from _p_r_o_c is only used during read and
- write tracing. During unset traces, the return value is
- ignored and all relevant trace procedures will always be
- invoked.
-
-
- RRRREEEESSSSTTTTRRRRIIIICCCCTTTTIIIIOOOONNNNSSSS
- A trace procedure can be called at any time, even when there
- is a partically-formed result in the interpreter's result
- area. If the trace procedure does anything that could
- damage this result (such as calling TTTTccccllll____EEEEvvvvaaaallll) then it must
- save the original values of the interpreter's rrrreeeessssuuuulllltttt and
- ffffrrrreeeeeeeePPPPrrrroooocccc fields and restore them before it returns.
-
-
- UUUUNNNNDDDDEEEEFFFFIIIINNNNEEEEDDDD VVVVAAAARRRRIIIIAAAABBBBLLLLEEEESSSS
- It is legal to set a trace on an undefined variable. The
- variable will still appear to be undefined until the first
- time its value is set. If an undefined variable is traced
- and then unset, the unset will fail with an error (``no such
- variable''), but the trace procedure will still be invoked.
-
-
- TTTTCCCCLLLL____TTTTRRRRAAAACCCCEEEE____DDDDEEEELLLLEEEETTTTEEEEDDDD FFFFLLLLAAAAGGGG
- In an unset callback to _p_r_o_c, the TCL_TRACE_DELETED bit is
- set in _f_l_a_g_s if the trace is being removed as part of the
- deletion. Traces on a variable are always removed whenever
- the variable is deleted; the only time TCL_TRACE_DELETED
- isn't set is for a whole-array trace invoked when only a
- single element of an array is unset.
-
-
- TTTTCCCCLLLL____IIIINNNNTTTTEEEERRRRPPPP____DDDDEEEESSSSTTTTRRRROOOOYYYYEEEEDDDD
- When an interpreter is destroyed, unset traces are called
- for all of its variables. The TCL_INTERP_DESTROYED bit will
- be set in the _f_l_a_g_s argument passed to the trace procedures.
- Trace procedures must be extremely careful in what they do
- if the TCL_INTERP_DESTROYED bit is set. It is not safe for
- the procedures to invoke any Tcl procedures on the
- interpreter, since its state is partially deleted. All that
- trace procedures should do under these circumstances is to
- clean up and free their own internal data structures.
-
-
- BBBBUUUUGGGGSSSS
- Tcl doesn't do any error checking to prevent trace
-
-
-
- Page 7 (printed 7/10/95)
-
-
-
-
-
-
- TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr((((3333)))) TTTTccccllll (((( )))) TTTTccccllll____TTTTrrrraaaacccceeeeVVVVaaaarrrr((((3333))))
-
-
-
- procedures from misusing the interpreter during traces with
- TCL_INTERP_DESTROYED set.
-
-
- KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS
- clientData, trace, variable
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page 8 (printed 7/10/95)
-
-
-
-