Tcl_IsSafe, Tcl_MakeSafe, Tcl_CreateSlave, Tcl_GetSlave, Tcl_GetSlaves, Tcl_GetMaster, Tcl_CreateAlias, Tcl_GetAlias, Tcl_GetAliases - manage multiple Tcl interpreters and aliases.
Tcl_CreateSlave(interp, slaveName, isSafe)
Tcl_CreateAlias(slaveInterp, srcCmd, targetInterp, targetCmd, argc, argv)
Tcl_GetAlias(interp, srcCmd, targetInterpPtr, targetCmdPtr, argcPtr, argvPtr)
Tcl_CreateSlave creates a new interpreter as a slave of the given interpreter. It also creates a slave command in the given interpreter which allows the master interpreter to manipulate the slave. The slave interpreter and the slave command have the specified name. If isSafe is 1, the new slave interpreter is made ``safe'' by removing all unsafe functionality. If the creation failed, NULL is returned.
Tcl_IsSafe returns 1 if the given interpreter is ``safe'', 0 otherwise.
Tcl_MakeSafe makes the given interpreter ``safe'' by removing all non-core and core unsafe functionality. Note that if you call this after adding some extension to an interpreter, all traces of that extension will be removed from the interpreter. This operation always succeeds and returns TCL_OK.
Tcl_GetSlave returns a pointer to a slave interpreter of the given interpreter. The slave interpreter is identified by the name specified. If no such slave interpreter exists, NULL is returned.
Tcl_GetMaster returns a pointer to the master interpreter of the given interpreter. If the given interpreter has no master (it is a top-level interpreter) then NULL is returned.
Tcl_GetInterpPath sets the result field in askingInterp to the relative path between askingInterp and slaveInterp; slaveInterp must be a slave of askingInterp. If the computation of the relative path succeeds, TCL_OK is returned, else TCL_ERROR is returned and the result field in askingInterp contains the error message.
Tcl_GetAlias returns information about an alias of a specified name in a given interpreter. Any of the result fields can be NULL, in which case the corresponding datum is not returned. If a result field is non-NULL, the address indicated is set to the corresponding datum. For example, if targetNamePtr is non-NULL it is set to a pointer to the string containing the name of the target command.
In order to map over all slave interpreters, use Tcl_Eval with the command interp slaves and use the value (a Tcl list) deposited in the result field of the interpreter. Similarly, to map over all aliases whose source commands are defined in an interpreter, use Tcl_Eval with the command interp aliases and use the value (a Tcl list) deposited in the result field. Note that the storage of this list belongs to Tcl, so you should copy it before invoking any other Tcl commands in that interpreter.
For a description of the Tcl interface to multiple interpreters, see interp(n).
alias, command, interpreter, master, slave
Table of Contents