#include "nsd.h"Data Structures | |
| struct | EvalData |
| struct | LoopData |
Defines | |
| #define | NUM_ARGS 9 |
| #define | STATIC_LIST_SIZE 4 |
Functions | |
| int | NsTclForObjCmd (ClientData arg, Tcl_Interp *interp, int objc, objv) |
| int | NsTclWhileObjCmd (ClientData arg, Tcl_Interp *interp, int objc, objv) |
| int | NsTclForeachObjCmd (ClientData arg, Tcl_Interp *interp, int objc, objv) |
| int | NsTclLoopCtlObjCmd (ClientData arg, Tcl_Interp *interp, int objc, objv) |
| #define NUM_ARGS 9 |
| #define STATIC_LIST_SIZE 4 |
| int NsTclForeachObjCmd | ( | ClientData | arg, | |
| Tcl_Interp * | interp, | |||
| int | objc, | |||
| objv | ||||
| ) |
Argument objects.
i selects a value list
Number of loop iterations
v selects a loop variable
Count of value lists
We copy the argument object pointers into a local array to avoid the problem that "objv" might become invalid. It is a pointer into the evaluation stack and that stack might be grown and reallocated if the loop body requires a large amount of stack space.
Array of value list indices
# loop variables per list
Array of var name lists
Array of value list sizes
Array of value lists
Create the object argument array "argObjv". Make sure argObjv is large enough to hold the objc arguments.
Manage numList parallel value lists. argvList[i] is a value list counted by argcList[i] varvList[i] is the list of variables associated with the value list varcList[i] is the number of variables associated with the value list index[i] is the current pointer into the value list argvList[i]
Break up the value lists and variable lists into elements
Iterate maxj times through the lists in parallel If some value lists run out of values, set loop vars to ""
Refetch the list members; we assume that the sizes are the same, but the array of elements might be different if the internal rep of the objects has been lost and recreated (it is too difficult to accurately tell when this happens, which can lead to some wierd crashes, like Bug #494348...)
empty string
| interp | Pointer to NsInterp. |
| objc | Current interpreter. |
| int NsTclForObjCmd | ( | ClientData | arg, | |
| Tcl_Interp * | interp, | |||
| int | objc, | |||
| objv | ||||
| ) |
Argument objects.
We need to reset the result before passing it off to Tcl_ExprBooleanObj. Otherwise, any error message will be appended to the result of the last evaluation.
| interp | Pointer to NsInterp. |
| objc | Current interpreter. |
| int NsTclLoopCtlObjCmd | ( | ClientData | arg, | |
| Tcl_Interp * | interp, | |||
| int | objc, | |||
| objv | ||||
| ) |
Argument objects.
Handle the list and install commands and verify arguments first.
All other commands require a loop id arg.
NB: Silence warning.
Info format is: {loop id} {thread id} {start time} {status} {command args}
Queue new script to eval.
Wait for result.
| interp | Pointer to NsInterp. |
| objc | Current interpreter. |
| int NsTclWhileObjCmd | ( | ClientData | arg, | |
| Tcl_Interp * | interp, | |||
| int | objc, | |||
| objv | ||||
| ) |
Argument objects.
| interp | Pointer to NsInterp. |
| objc | Current interpreter. |
1.5.1