summaryrefslogtreecommitdiffstats
path: root/generic/tclTrace.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2018-04-17 20:29:02 (GMT)
committerdgp <dgp@users.sourceforge.net>2018-04-17 20:29:02 (GMT)
commit6b8039a9524bb88679e0d837a5345f26c8654a52 (patch)
treedb8891383d98e5fb6a29ef1996ddb12d90bb0a89 /generic/tclTrace.c
parent62ea5e49a10037bf3a3896a933db4951ff0b15bc (diff)
downloadtcl-6b8039a9524bb88679e0d837a5345f26c8654a52.zip
tcl-6b8039a9524bb88679e0d837a5345f26c8654a52.tar.gz
tcl-6b8039a9524bb88679e0d837a5345f26c8654a52.tar.bz2
Refactor array trace handling into a common routine TclCheckArrayTraces().
Diffstat (limited to 'generic/tclTrace.c')
-rw-r--r--generic/tclTrace.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/generic/tclTrace.c b/generic/tclTrace.c
index 958399a..d48761b 100644
--- a/generic/tclTrace.c
+++ b/generic/tclTrace.c
@@ -2478,6 +2478,47 @@ TclVarTraceExists(
/*
*----------------------------------------------------------------------
*
+ * TclCheckArrayTraces --
+ *
+ * This function is invoked to when we operate on an array variable,
+ * to allow any array traces to fire.
+ *
+ * Results:
+ * Returns TCL_OK to indicate normal operation. Returns TCL_ERROR if
+ * invocation of a trace function indicated an error. When TCL_ERROR is
+ * returned, then error information is left in interp.
+ *
+ * Side effects:
+ * Almost anything can happen, depending on trace; this function itself
+ * doesn't have any side effects.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TclCheckArrayTraces(
+ Tcl_Interp *interp,
+ Var *varPtr,
+ Var *arrayPtr,
+ Tcl_Obj *name,
+ int index)
+{
+ int code = TCL_OK;
+
+ if (varPtr && (varPtr->flags & VAR_TRACED_ARRAY)
+ && (TclIsVarArray(varPtr) || TclIsVarUndefined(varPtr))) {
+ Interp *iPtr = (Interp *)interp;
+
+ code = TclObjCallVarTraces(iPtr, arrayPtr, varPtr, name, NULL,
+ (TCL_NAMESPACE_ONLY|TCL_GLOBAL_ONLY| TCL_TRACE_ARRAY),
+ /* leaveErrMsg */ 1, index);
+ }
+ return code;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TclCallVarTraces --
*
* This function is invoked to find and invoke relevant trace functions