transchan(3tcl) | Tcl Built-In Commands | transchan(3tcl) |
transchan - command handler API of channel transforms
cmdPrefix option ?arg arg ...?
The Tcl-level handler for a channel transformation has to be a command with subcommands (termed an ensemble despite not implying that it must be created with namespace ensemble create; this mechanism is not tied to namespace ensemble in any way). Note that cmdPrefix is whatever was specified in the call to chan push, and may consist of multiple arguments; this will be expanded to multiple words in place of the prefix.
Of all the possible subcommands, the handler must support initialize and finalize. Transformations for writable channels must also support write, and transformations for readable channels must also support read.
Note that in the descriptions below cmdPrefix may be more than one word, and handle is the value returned by the chan push call used to create the transformation.
The following subcommands are relevant to all types of channel.
The return value of the subcommand should be a list containing the names of all subcommands supported by this handler. Any error thrown by the subcommand will prevent the creation of the transformation. The thrown error will appear as error thrown by chan push.
These subcommands are used for handling transformations applied to readable channels; though strictly read is optional, it must be supported if any of the others is or the channel will be made non-readable.
In other words, when this method is called the transformation cannot defer the actual transformation operation anymore and has to transform all data waiting in its internal read buffers and return the result of that action.
Note that the result is allowed to be empty, or even less than the data we received; the transformation is not required to transform everything given to it right now. It is allowed to store incoming data in internal buffers and to defer the actual transformation until it has more data.
These subcommands are used for handling transformations applied to writable channels; though strictly write is optional, it must be supported if any of the others is or the channel will be made non-writable.
In other words, when this subcommand is called the transformation cannot defer the actual transformation operation anymore and has to transform all data waiting in its internal write buffers and return the result of that action.
The result returned by the subcommand is taken as the binary data to write to the transformation below this transformation. This can be the base channel as well. Note that the result is allowed to be empty, or less than the data we got; the transformation is not required to transform everything which was written to it right now. It is allowed to store this data in internal buffers and to defer the actual transformation until it has more data.
API, channel, ensemble, prefix, transformation
8.6 | Tcl |