File 'base/oo.tcl' (part of 'Pool_Base')

Written by
Andreas Kupries
Description
This OO system is rooted in Sam Shen work (SNTL, tkinspect) and was modified and enhanced by myself. The version here is a complete rewrite, taking advantage of the namespace features in tcl 8.x. No code of Sams work remained, all bugs found will be mine.
Depends on
Tcl


::pool::oo::support::AfterCons (script)

Special procedure. Allows constructors the registration of code which will be executed after completion of object initialization. This allows f.e. the redefinition of a value in an instance variable by a derived class and yet have the superclass react to the changed value. The megawidget base class (widget) uses this feature.
Argument: script The tcl code to execute after object initialization.

::pool::oo::support::BuildSuperclassChain (class)

Part of ::pool::oo::support::FixReferences. Computes the order used for calling the constructors of the given class. This information will be used by the chaining methods too.
Argument: class The name of the class to complete.

::pool::oo::support::Check ()

Checks the specification just read in.

::pool::oo::support::Compile (name args)

The class compiler. Transforms the class definition into a tcl script.
Argument: name The name of the class to define.
Argument: args The definition of the class. The last argument is always interpreted as script containing member-, option- and method- definitions. Before this a list of superclasses can be specified. This list must start with a colon (:).
Returns: A tcl script whose evaluation will install the class in the system.

::pool::oo::support::Dump ()

Write the read specification into a string.

::pool::oo::support::DumpAutoload ()

Write the information enabling this class to get access to its superclasses by autoloading, and making it available for its own autoloading too.

::pool::oo::support::DumpHeader ()

Write an explanatory header into the string containing the translated class.

::pool::oo::support::DumpInit ()

Write the specified global initialization code into the result string, without changes.

::pool::oo::support::DumpMethods ()

Writes the declared methods into the translation. Modifies them to call the runtime support to get access to instance and class variables.

::pool::oo::support::DumpNamespaceDefinition ()

Write the definition of the namespace describing the read class.

::pool::oo::support::DumpRuntimeIntegration ()

Write out the commands linking a #sourced class to its superclasses, allowing creation of instances, etc.

::pool::oo::support::FixMethods (class)

Part of ::pool::oo::support::FixReferences. Imports all methods in all superclasses (immediate and! indirect) into this class. Methods already known to this class are imported nevertheless, but prefixed with the name of the defining class.
Argument: class The name of the class to complete.

::pool::oo::support::FixOptions (class)

Part of ::pool::oo::support::FixReferences. Assumes that the option and alias definitions are complete. Converts them into an array usable by the 'getopt' subsystem. Information used during construction and 'configure' is stored in an easier accessible way too.
Argument: class The name of the class to complete.

::pool::oo::support::FixReferences (class)

This procedure is called after setting up the namespace of a class and the loading of all superclasses. It imports superclass definitions (instance variables, options, option aliases) into the new class, thus completing its installation. Additional operations:
Determine order of constructor/destructor sequences. This information will be used by the chaining methods too (see ::pool::oo::support::chainToDerived and ::pool::oo::support::chainToSuper).
Import superclass methods into the class, add the class names as prefix if necessary.
Convert the completed option information into a definition array usable by the base/getopt.tcl subsystem.
Argument: class The name of the class to complete.

::pool::oo::support::GetObject (n)

Determines the name of the object calling a particular method. 'namespace current' is of no help here as all methods are imported into the object namespace. They execute in their defining namespace, and not the object. Because of this we are forced to look at the call stack ('info level') and the method names used there.
Argument: n The relative stack level to start with (must be negative). Usually -1 (for the standard methods), -1 in special cases (SetupVars).

::pool::oo::support::ImportOptionAliases (class)

Part of ::pool::oo::support::FixReferences. Imports all option aliases defined by all immediate superclasses into the given class. Reports collisions as errors.
Argument: class The name of the class to complete.

::pool::oo::support::ImportOptions (class)

Part of ::pool::oo::support::FixReferences. Imports all options defined by all immediate superclasses into the given class. Reports collisions as errors.
Argument: class The name of the class to complete.

::pool::oo::support::ImportVariables (class)

Part of ::pool::oo::support::FixReferences. Imports all instance variables defined by all immediate superclasses into the given class. Reports collisions as errors.
Argument: class The name of the class to complete.

::pool::oo::support::New (class object args)

Runtime support for creating instances of a class. The system will create an alias x for each class x resolving into 'New x'.
Argument: class The name of the class the instance shall be created for. Automatically supplied to the procedure by the instance constructor alias.
Argument: object The name of the new object.
Argument: args Initial object configuration, as <option,value>-pairs.
Returns: The name of the object, = object.

::pool::oo::support::Puts (args)

The procedure used by all dump-procedures to write something into the translation. Has the same interface as the builtin 'puts', but writes into an internal string.
Argument: args Specification of the things to write, see the description of the builtin 'puts' for more.

::pool::oo::support::PutsArray (varName data)

Convenience procedure to write the contents of an array (even an empty one) into the translation. Built upon ::pool::oo::support::Puts.
Argument: varName The name of the variable to create
Argument: data The contents of the array to write, usable for 'array set'.

::pool::oo::support::ResetCompiler ()

Clears out the internal state of the compiler

::pool::oo::support::SetupOptions (oSpace object optDef optInfo legalopts arglist)

Called during object construction to initialize the options of the new object. Does it in three steps: The initial configuration is processed first, then the re#source database queried for the missing parts (only if Tk present), then the defaults given in the class specification for anything yet missing.
Argument: oSpace The namespace representing the new object.
Argument: object The name of the new object.
Argument: optDef The name of the array containing the option definitions usable by the 'getopt'-system.
Argument: optInfo The name of the array containing information to use during access to the re#source database.
Argument: legalopts A list containing the names of all options defined fro the class.
Argument: arglist A list of <option,value>-pairs. Contains the initial configuration given by the object creator.

::pool::oo::support::SetupVars (class)

This procedure is called by *all* methods of class as their first command to get immediate access to the instance and class variables of the class.
Argument: class The name of the class the method was defined by. Only its instance and class variables are made accessible to the method. Because of this a superclass method has no immediate access to the instance variables of its derived classes.

::pool::oo::support::alias (alias option)

Declares an alias of an option of the current class. This procedure is immediately accessible to the class specification, without the namespace prefix.
Argument: alias The name of the new alias, without starting '-'.
Argument: option The name of the referenced option, without starting '-'.

::pool::oo::support::cget (option)

Standard method of all objects. Retrieves the current value of the specified option.
Argument: option The name of the option to retrieve.
Returns: The current value of the option.

::pool::oo::support::chain (method args)

Standard method of all objects. Calls the nearest definition of method in one of the superclasses of the object. The search follows the same order used to call destructors (the class, then the superclasses).
Argument: method The name of the method to call.
Argument: args The arguments to give to the method in the calls.

::pool::oo::support::chainToDerived (method args)

Standard method of all objects. Calls not only the specified method, but all its definitions in superclasses as well. Follows the same order used to call constructors (the superclasses, then the class).
Argument: method The name of the method to call.
Argument: args The arguments to give to the method in all calls.

::pool::oo::support::chainToSuper (method args)

Standard method of all objects. Calls not only the specified method, but all its definitions in superclasses as well. Follows the same order used to call destructors (the class, then the superclasses).
Argument: method The name of the method to call.
Argument: args The arguments to give to the method in all calls.

::pool::oo::support::class (name args)

Main entrypoint of the OO system. Compiles the given class definition into tcl code and interprets it afterward, thus installing the class in the running interpreter. The 'gen_cls' application redefines this procedure into a pure compiler and dumps its result into a file. This precompilation should save time on startup.
Argument: name The name of the class to define.
Argument: args The definition of the class. The last argument is always interpreted as script containing member-, option- and method- definitions. Before this a list of superclasses can be specified. This list must start with a colon (:).

::pool::oo::support::classvar (args)

Declare a class variable of the current class. This procedure is immediately accessible to the class specification, without the namespace prefix.
Notes: Class variables and their values are stored as part of the namespace describing the class. To avoid clashes with the internal variables required by the runtime system the latter will start with an underscore ('_') and userdefined variables are disallowed to do so.
Methods of the class get immediate access to the defined class variables (via upvar).
Argument: args The variable specification. May start with '-array' to signal that we are talking about an array. This is followed by the name of the variable. At last an initial value can be given. In case of an array this value has to be in a form understood by 'array set'.

::pool::oo::support::config (args)

A shorthand for ::pool::oo::support::config.
Argument: args See ::pool::oo::support::config.

::pool::oo::support::configure (args)

Standard method of all objects. Used to retrieve and manipulate the values of the options associated to the object. Three forms of calling this method are allowed.
Without arguments the system will retrieve the values of *all* options and return them in a list suitable for 'array set', with the option names as keys.
A single argument will be interpreted as the name of an option and its value will be retrieved. In this mode the functionality is equal to ::pool::oo::support::cget.
The last mode is invoked by calling the method with an even number of argument, these will be interpreted as pairs of options and their values. The system will reconfigure the object according to the really changed options and their associated action methos, but only if all specified values are legal.
Argument: args See desscription.
Returns: See description.

::pool::oo::support::constructor (body)

Declares the constructor of the current class.
Argument: body The body of the constructor procedure.

::pool::oo::support::delete ()

Standard method of all objects. Destroys the object invoking it.

::pool::oo::support::destructor (body)

Declares the destructor of the current class.
Argument: body The body of the destructor procedure.

::pool::oo::support::init (code)

Declares global initialization code which will be copied verbatim into the generated script. This procedure is immediately accessible to the class specification, without the namespace prefix.
Argument: code The tcl code to copy into the translation.

::pool::oo::support::method (name arguments body)

Declares a method of the current class. This procedure is immediately accessible to the class specification, without the namespace prefix. It has the same arguments as the builtin 'proc'.
Argument: name The name of the new method.
Argument: arguments List of formal arguments
Argument: body The script to execute upon calling the method.

::pool::oo::support::oinfo (what args)

Standard method of all objects. Allows retrieval of various meta information about the object and its class.
Argument: what The name of the subcommand to execute. Specifies the information requested by the user.
Argument: args Information dependent additional selector data.
Returns: a string containing the requested information.

::pool::oo::support::option (name args)

Declares an option of the current class. This procedure is immediately accessible to the class specification, without the namespace prefix.
Argument: name The name of the new option, without starting '-'.
Argument: args The description of the option, in the form of <option,value>-pairs. Known parameters are -class, -action, -default and -type.
'-class' defaults to the name of the option, with the first character capitalized. The value is used as class specification during access to the re#source database via 'option get'.
'-action' is optional. If specified it is interpreted as the name of the method to call after the option was changed via the standard method 'configure'.
'-default' is optional, it defines the default value to use if the option value was not specified during construction.
'-type' defaults to ::pool::getopt::notype, it is interpreted as the name of a procedure checking the legality of a value given to the option. Please note, I said 'procedure', *not* 'method'!

::pool::oo::support::var (args)

Declare a member variable of the current class. This procedure is immediately accessible to the class specification, without the namespace prefix.
Notes: Methods of the class get immediate access to the defined member variables (via upvar). In case of a class having options the array variable 'opt' will be specified automatically by the system. It will always contain the values associated to them.
Argument: args The variable specification. May start with '-array' to signal that we are talking about an array. This is followed by the name of the variable. At last an initial value can be given. In case of an array this value has to be in a form understood by 'array set'.


Generated by AutoDoc 2.4 at 09/14/2000, invoked by Andreas Kupries