Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Better flag up the oo::Slot class in the docs, add missing method [28d6013ae6] |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | core-8-6-branch |
Files: | files | file ages | folders |
SHA3-256: |
743169db55c6c28e8be1383a62a0dcfe |
User & Date: | dkf 2024-05-23 11:27:05 |
Context
2024-05-23
| ||
13:18 | [154f0982f2] Update createWithNamespace to error on namespace creation failure check-in: 615988e06a user: dkf tags: bug-154f0982f2 | |
11:52 | Fix 2 warnings on Win32 (Thanks, Harald). Some more code cleanup, backported from 8.7) check-in: 73474e33a9 user: jan.nijtmans tags: core-8-6-branch | |
11:27 | Better flag up the oo::Slot class in the docs, add missing method [28d6013ae6] check-in: 743169db55 user: dkf tags: core-8-6-branch | |
2024-05-22
| ||
22:15 | .travis.yml is not used any more check-in: d0923796c9 user: jan.nijtmans tags: core-8-6-branch | |
Changes
Changes to doc/define.n.
1 2 3 4 5 6 7 8 9 10 11 | '\" '\" Copyright (c) 2007 Donal K. Fellows '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" .TH define n 0.3 TclOO "TclOO Commands" .so man.macros .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME | | > > > > > > > < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | '\" '\" Copyright (c) 2007 Donal K. Fellows '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" .TH define n 0.3 TclOO "TclOO Commands" .so man.macros .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME oo::define, oo::objdefine, oo::Slot \- define and configure classes and objects .SH SYNOPSIS .nf package require TclOO \fBoo::define\fI class defScript\fR \fBoo::define\fI class subcommand arg\fR ?\fIarg ...\fR? \fBoo::objdefine\fI object defScript\fR \fBoo::objdefine\fI object subcommand arg\fR ?\fIarg ...\fR? \fBoo::Slot\fR \fIarg...\fR .fi .SH "CLASS HIERARCHY" .nf \fBoo::object\fR \(-> \fBoo::Slot\fR .fi .BE .SH DESCRIPTION The \fBoo::define\fR command is used to control the configuration of classes, and the \fBoo::objdefine\fR command is used to control the configuration of objects (including classes as instance objects), with the configuration being applied to the entity named in the \fIclass\fR or the \fIobject\fR argument. Configuring a class also updates the configuration of all subclasses of the class and all objects that are |
︙ | ︙ | |||
290 291 292 293 294 295 296 | instance are completely disjoint; the list of variable names is just for methods declared by this object. By default, this slot works by appending. .SH "SLOTTED DEFINITIONS" Some of the configurable definitions of a class or object are \fIslotted definitions\fR. This means that the configuration is implemented by a slot object, that is an instance of the class \fBoo::Slot\fR, which manages a list of values (class names, variable names, etc.) that comprises the contents of | > > | | > > > > > > > > > > > > > | | > > > > > > | 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | instance are completely disjoint; the list of variable names is just for methods declared by this object. By default, this slot works by appending. .SH "SLOTTED DEFINITIONS" Some of the configurable definitions of a class or object are \fIslotted definitions\fR. This means that the configuration is implemented by a slot object, that is an instance of the class \fBoo::Slot\fR, which manages a list of values (class names, variable names, etc.) that comprises the contents of the slot. .PP The \fBoo::Slot\fR class defines three operations (as methods) that may be done on the slot: .VE .TP \fIslot\fR \fB\-append\fR ?\fImember ...\fR? .VS This appends the given \fImember\fR elements to the slot definition. .VE .TP \fIslot\fR \fB\-clear\fR .VS This sets the slot definition to the empty list. .VE .TP \fIslot\fR \fB\-set\fR ?\fImember ...\fR? .VS This replaces the slot definition with the given \fImember\fR elements. .PP A consequence of this is that any use of a slot's default operation where the first member argument begins with a hyphen will be an error. One of the above operations should be used explicitly in those circumstances. .PP You only need to make an instance of \fBoo::Slot\fR if you are definining your own slot that behaves like a standard slot. .PP .SS "SLOT IMPLEMENTATION" Internally, slot objects also define a method \fB\-\-default\-operation\fR which is forwarded to the default operation of the slot (thus, for the class .QW \fBvariable\fR slot, this is forwarded to .QW "\fBmy \-append\fR" ), and these methods which provide the implementation interface: .VE .TP \fIslot\fR \fBGet\fR .VS Returns a list that is the current contents of the slot. This method must always be called from a stack frame created by a call to \fBoo::define\fR or \fBoo::objdefine\fR. .VE .TP \fIslot\fR \fBResolve \fIelement\fR .VS This converts an element of the slotted collection into its resolved form; for a simple value, it could just return the value, but for a slot that contains references to commands or classes it should convert those into their fully-qualified forms (so they can be compared with \fBstring equals\fR): that could be done by forwarding to \fBnamespace which\fR or similar. .VE .TP \fIslot\fR \fBSet \fIelementList\fR .VS Sets the contents of the slot to the list \fIelementList\fR and returns the empty string. This method must always be called from a stack frame created by a call to \fBoo::define\fR or \fBoo::objdefine\fR. .PP The implementation of these methods is slot-dependent (and responsible for accessing the correct part of the class or object definition). Slots also have an unknown method handler to tie all these pieces together, and they hide their \fBdestroy\fR method so that it is not invoked inadvertently. It is \fIrecommended\fR that any user changes to the slot mechanism itself be restricted to defining new operations whose names start with a hyphen. .PP Note that slot instances are not expected to contain the storage for the slot they manage; that will be in or attached to the class or object that they manage. Those instances should provide their own implementations of the \fBGet\fR and \fBSet\fR methods (and optionally \fBResolve\fR; that defaults to a do-nothing pass-through). .VE .SH EXAMPLES This example demonstrates how to use both forms of the \fBoo::define\fR and \fBoo::objdefine\fR commands (they work in the same way), as well as illustrating four of the subcommands of them. .PP .CS |
︙ | ︙ |