File: stooop.man

package info (click to toggle)
tcllib 1.10-dfsg-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 17,708 kB
  • ctags: 6,122
  • sloc: tcl: 106,354; ansic: 9,205; sh: 8,707; xml: 1,766; yacc: 753; makefile: 115; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (233 lines) | stat: -rw-r--r-- 7,913 bytes parent folder | download
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
[comment {-*- tcl -*- doctools manpage}]
[manpage_begin stooop n 4.4.1]
[moddesc   {Simple Tcl Only Object Oriented Programming}]
[titledesc {Object oriented extension.}]
[require Tcl 8.3]
[require stooop [opt 4.4.1]]
[description]
[para]

This package provides commands to extend Tcl in an object oriented
manner, using a familiar C++ like syntax and behaviour. Stooop only
introduces a few new commands: [cmd class], [cmd new], [cmd delete],
[cmd virtual] and [cmd classof]. Along with a few coding conventions,
that is basically all you need to know to use stooop. Stooop is meant
to be as simple to use as possible.

[para]

This manual is very succinct and is to be used as a quick reminder for
the programmer, who should have read the thorough [uri stooop_man.html]
HTML documentation at this point.

[list_begin definitions]


[call [cmd ::stooop::class] [arg {name body}]]

This command creates a class. The body, similar in contents to a Tcl
namespace (which a class actually also is), contains member procedure
definitions. Member procedures can also be defined outside the class
body, by prefixing their name with [const class::], as you would
proceed with namespace procedures.

[list_begin definitions]

[def "[cmd proc] [arg class] \{[const this] [opt [arg {arg arg ...}]]\} [opt "[arg base] \{[opt [arg {arg arg ...}]]\} ..."] [arg body]"]

This is the constructor procedure for the class. It is invoked
following a [cmd new] invocation on the class. It must have the same
name as the class and a first argument named [const this]. Any number
of base classes specifications, including arguments to be passed to
their constructor, are allowed before the actual body of the
procedure.

[def "[cmd proc] ~[arg class] \{[const this]\} [arg body]"]

This is the destructor procedure for the class. It is invoked
following a [cmd delete] invocation. Its name must be the
concatenation of a single [const ~] character followed by the class
name (as in C++). It must have a single argument named [const this].

[def "[cmd proc] [arg name] \{[const this] [opt [arg {arg arg ...}]]\} [arg body]"]

This is a member procedure of the class, as its first argument is
named [const this]. It allows a simple access of member data for the
object referenced by [const this] inside the procedure. For example:

[example {
   set ($this,data) 0
}]

[def "[cmd proc] [arg name] \{[opt [arg {arg arg ...}]]\} [arg body]"]

This is a static (as in C++) member procedure of the class, as its
first argument is not named [const this]. Static (global) class data
can be accessed as in:

[example {
   set (data) 0
}]

[def "[cmd proc] [arg class] \{[const {this copy}]\} [arg body]"]

This is the optional copy procedure for the class. It must have the
same name as the class and exactly 2 arguments named [const this] and
[const copy]. It is invoked following a [cmd new] invocation on an
existing object of the class.

[list_end]


[call [cmd ::stooop::new] [arg class] [opt [arg {arg arg ...}]]]

This command is used to create an object. The first argument is the
class name and is followed by the arguments needed by the
corresponding class constructor. A unique identifier for the object
just created is returned.

[call [cmd ::stooop::delete] [arg object] [opt [arg {object ...}]]]

This command is used to delete one or several objects. It takes one or
more object identifiers as argument(s).

[call [cmd ::stooop::virtual] [const proc] [arg name] \{[const this] [opt [arg {arg arg ...}]]\} [opt [arg {body}]]]

The [cmd virtual] specifier may be used on member procedures to
achieve dynamic binding. A procedure in a base class can then be
redefined (overloaded) in the derived class(es). If the base class
procedure is invoked on an object, it is actually the derived class
procedure which is invoked, if it exists. If the base class procedure
has no body, then it is considered to be a pure virtual and the
derived class procedure is always invoked.

[call [cmd ::stooop::classof] [arg object]]

This command returns the class of the existing object passed as single
parameter.

[call [cmd ::stooop::new] [arg object]]

This command is used to create an object by copying an existing
object. The copy constructor of the corresponding class is invoked if
it exists, otherwise a simple copy of the copied object data members
is performed.

[list_end]

[section DEBUGGING]

[list_begin definitions]

[def {Environment variables}]


[list_begin definitions]

[def [var STOOOPCHECKDATA]]

Setting this variable to any true value will cause stooop to check for
invalid member or class data access.

[def [var STOOOPCHECKPROCEDURES]]

Setting this variable to any true value will cause stooop to check for
invalid member procedure arguments and pure interface classes
instanciation.

[def [var STOOOPCHECKALL]]

Setting this variable to any true value will cause stooop to activate
both procedure and data member checking.

[def [var STOOOPCHECKOBJECTS]]

Setting this variable to any true value will cause stooop to activate
object checking. The following stooop namespace procedures then become
available for debugging: [cmd printObjects], [cmd record] and
[cmd report].

[def [var STOOOPTRACEPROCEDURES]]

Setting this environment variable to either [const stdout],

[const stderr] or a file name, activates procedure tracing. The
stooop library will then output to the specified channel 1 line of
informational text for each member procedure invocation.

[def [var STOOOPTRACEPROCEDURESFORMAT]]

Defines the trace procedures output format. Defaults to
[const {"class: %C, procedure: %p, object: %O, arguments: %a"}].

[def [var STOOOPTRACEDATA]]

Setting this environment variable to either [const stdout],

[const stderr] or a file name, activates data tracing. The stooop
library will then output to the specified channel 1 line of
informational text for each member data access.

[def [var STOOOPTRACEDATAFORMAT]]

Defines the trace data output format. Defaults to 
[const {"class: %C, procedure: %p, array: %A, object: %O, member: %m, operation: %o, value: %v"}].

[def [var STOOOPTRACEDATAOPERATIONS]]

When tracing data output, by default, all read, write and unsetting
accesses are reported, but the user can set this variable to any
combination of the letters [const r], [const w], and [const u] for
more specific tracing (please refer to the [cmd trace] Tcl manual page
for more information).

[def [var STOOOPTRACEALL]]

Setting this environment variable to either [const stdout],

[const stderr] or a file name, enables both procedure and data
tracing.

[list_end]


[call [cmd ::stooop::printObjects] [opt [arg pattern]]]

Prints an ordered list of existing objects, in creation order, oldest
first. Each output line contains the class name, object identifier and
the procedure within which the creation occurred. The optional pattern
argument (as in the Tcl [cmd {string match}] command) can be used to
limit the output to matching class names.

[call [cmd ::stooop::record]]

When invoked, a snapshot of all existing stooop objects is
taken. Reporting can then be used at a later time to see which objects
were created or deleted in the interval.

[call [cmd ::stooop::report] [opt [arg pattern]]]

Prints the created and deleted objects since the [cmd ::stooop::record]
procedure was invoked last. If present, the pattern argument limits
the output to matching class names.

[list_end]

[section EXAMPLES]

Please see the full HTML documentation in [uri stooop_man.html].

[section {BUGS, IDEAS, FEEDBACK}]

This document, and the package it describes, will undoubtedly contain
bugs and other problems.

Please report such in the category [emph stooop] of the
[uri {http://sourceforge.net/tracker/?group_id=12883} {Tcllib SF Trackers}].

Please also report any ideas for enhancements you may have for either
package and/or documentation.


[keywords class {object oriented} object C++]
[manpage_end]