INTERFACING TCL WITH C 239
can’t handle partial statements; for instance, you can’t enter proc
foo { } { on one line and expect to continue it on the next.
You can exit with an end-of-file
Synopsis |
Allocates a new Tcl Interp structure and prepares it to re-ceive a
script.
|
Returns |
|
Synopsis |
|
|
interp — Pointer to the Tcl Interp to delete.
|
Tcl represents data as objects (of type Tcl Obj).
This abstract structure allows Tcl to deal with strings, integers, and
floating point numbers without having to covert between types more than
necessary. Tcl Obj is an abstract datatype, and you should avoid
touching it directly. Tcl supplies functions for creating and accessing
Tcl Obj variables as strings, integers, and doubles. The library can
convert Tcl Obj objects between variable types whenever it needs to;
for
instance, if you create a variable as an integer an then try to access
it as a string, Tcl will perform this conversion behind the scenes.
There is no real limit to the number of variables you can create, but
you should probably think twice about creating more than a few hundred
(it’s rarely necessary and performance could suffer).
codeTcl CreateObjCommand creates a new command and adds it to a given
interpreter2. It takes a pointer to a Tcl Interp, a command name, a
pointer to a handler function, an optional piece of “client data” (an
integer), and a pointer to a cleanup function. Whenever the new command
is called from within Tcl, the interpreter will give control to the
handler function and await a result. It also passes the particular
command’s client data to the handler; this serves no defined purpose, so
you can use it for just about anything. One possible use would be to
allow several commands to use one big handler function. The cleanup
function is optional. Tcl will call it when it’s time to delete a
command from the
interpreter, but this is only useful in a few cases. We’ll generally set
this to NULL.