File: api_stdat_cproc.inc

package info (click to toggle)
critcl 3.3.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,680 kB
  • sloc: ansic: 41,058; tcl: 12,090; sh: 7,230; pascal: 3,456; asm: 3,058; ada: 1,681; cpp: 1,001; cs: 879; makefile: 333; perl: 104; xml: 95; f90: 10
file content (369 lines) | stat: -rw-r--r-- 11,801 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
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
[comment {-*- mode: tcl ; fill-column: 90 -*-}]
[comment {
    Standard argument types for use with cproc and cclass methods.
}]


Before going into the details first a quick overview:

[include atypes_table.inc]

And now the details:

[list_begin definitions]
[comment {% % %% %%% %%%%% %%%%%%%% %%%%%%%%%%%%%}]

[def Tcl_Interp*]

[strong Attention]: This is a [strong special] argument type. It can
[strong only] be used by the [strong first] argument of a function.
Any other argument using it will cause critcl to throw an error.

[para] When used, the argument will contain a reference to the current
interpreter that the function body may use. Furthermore the argument
will [strong not] be an argument of the Tcl command for the function.

[para] This is useful when the function has to do more than simply
returning a value. Examples would be setting up error messages on
failure, or querying the interpreter for variables and other data.

[def Tcl_Obj*]
[def object]

The function takes an argument of type [type Tcl_Obj*].
No argument checking is done.
The Tcl level word is passed to the argument as-is.

Note that this value must be treated as [strong read-only] (except for
hidden changes to its intrep, i.e. [term shimmering]).

[comment {% % %% %%% %%%%% %%%%%%%% %%%%%%%%%%%%%}]
[def pstring]

The function takes an argument of type [type critcl_pstring]
containing the original [type Tcl_Obj*] reference of the Tcl argument,
plus the length of the string and a pointer to the character array.

[example {
typedef struct critcl_pstring {
    Tcl_Obj*    o;
    const char* s;
    int         len;
} critcl_pstring;
}]

Note the [strong const]. The string is [strong read-only]. Any
modification can have arbitrary effects, from pulling out the rug
under the script because of string value and internal representation
not matching anymore, up to crashes anytime later.

[comment {% % %% %%% %%%%% %%%%%%%% %%%%%%%%%%%%%}]
[def list]
[def {[]}]
[def {[*]}]

The function takes an argument of type [type critcl_list] containing the original [type Tcl_Obj*]
reference of the Tcl argument, plus the length of the Tcl list and a pointer to the array of the
list elements.

[example {
typedef struct critcl_list {
    Tcl_Obj*        o;
    Tcl_Obj* const* v;
    int             c;
} critcl_list;
}]

The Tcl argument must be convertible to [type List], an error is thrown otherwise.

[para] Note the [strong const]. The list is [strong read-only].  Any modification can have arbitrary
effects, from pulling out the rug under the script because of string value and internal
representation not matching anymore, up to crashes anytime later.

[para] Further note that the system understands a number of more complex syntactical forms which all
translate into forms of lists under the hood, as described by the following points.

[comment {% % %% %%% %%%%% %%%%%%%% %%%%%%%%%%%%%}]
[def {[N]}]

A [term list] type with additional checks limiting the length to [const N], an integer
number greater than zero.

[comment {% % %% %%% %%%%% %%%%%%%% %%%%%%%%%%%%%}]
[def {[]type}]
[def {type[]}]

A [term list] type whose elements all have to be convertible for [term type]. All known
types, including user-defined, are allowed, except for [type list] and derivates. In other
words, multi-dimensional lists are not supported.

[para] The function will take a structure argument of the general form

[example {
typedef struct critcl_list_... {
    Tcl_Obj* o;
    int      c;
    (Ctype)* v;
} critcl_list_...;
}]

where [const (Ctype)] represents the C type for values of type [type type].

[comment {% % %% %%% %%%%% %%%%%%%% %%%%%%%%%%%%%}]
[def {[N]type}]
[def {type[N]}]

These are [type list] types combining the elements of [example {[N]}] and
[example {[]type}].

[para] As an example, the specification of [example {int[3] a}] describes argument [arg a]
as a list of exactly 3 elements, all of which have to be of type [type int].

[para] Note that this example can also be written in the more C-like form of
[example {int a[3]}]. The system will translate this internally to the first shown form.

[comment {% % %% %%% %%%%% %%%%%%%% %%%%%%%%%%%%%}]
[def bytes]

This is the [emph new] and usable [type ByteArray] type.

[para] The function takes an argument of type [type critcl_bytes]
containing the original [type Tcl_Obj*] reference of the Tcl argument,
plus the length of the byte array and a pointer to the byte data.

[example {
typedef struct critcl_bytes {
    Tcl_Obj*             o;
    const unsigned char* s;
    int                len;
} critcl_list;
}]

The Tcl argument must be convertible to [type ByteArray], an error is
thrown otherwise.

[para] Note the [strong const]. The bytes are [strong read-only].  Any
modification can have arbitrary effects, from pulling out the rug
under the script because of string value and internal representation
not matching anymore, up to crashes anytime later.

[comment {% % %% %%% %%%%% %%%%%%%% %%%%%%%%%%%%%}]
[def char*]

The function takes an argument of type [type {const char*}].
The string representation of the Tcl argument is passed in.

[para] Note the [strong const]. The string is [strong read-only]. Any
modification can have arbitrary effects, from pulling out the rug
under the script because of string value and internal representation
not matching anymore, up to crashes anytime later.

[comment {% % %% %%% %%%%% %%%%%%%% %%%%%%%%%%%%%}]
[def double]

The function takes an argument of type [type double].

The Tcl argument must be convertible to [type Double], an error is thrown otherwise.

[def {double > N}]
[def {double >= N}]
[def {double < N}]
[def {double <= N}]

These are variants of [term double] above, restricting the argument value to the shown relation.

An error is thrown for Tcl arguments outside of the specified range.

[para] The limiter [arg N] has to be a constant floating point value.

[para] It is possible to use multiple limiters.

For example [term {double > A > B <= C}].

The system will fuse them to a single upper/lower limit (or both).

[para] The system will reject limits describing an empty range of values, or a range containing only
a single value.

[comment {% % %% %%% %%%%% %%%%%%%% %%%%%%%%%%%%%}]
[def float]

The function takes an argument of type [type float].

The Tcl argument must be convertible to [type Double], an error is thrown otherwise.

[def {float > N}]
[def {float >= N}]
[def {float < N}]
[def {float <= N}]

These are variants of [term float] above, restricting the argument value to the shown relation.

An error is thrown for Tcl arguments outside of the specified range.

[para] The limiter [arg N] has to be a constant floating point value.

[para] It is possible to use multiple limiters.

For example [term {float > A > B <= C}].

The system will fuse them to a single upper/lower limit (or both).

[para] The system will reject limits describing an empty range of values, or a range containing only
a single value.

[comment {% % %% %%% %%%%% %%%%%%%% %%%%%%%%%%%%%}]
[def boolean]
[def bool]

The function takes an argument of type [type int].

The Tcl argument must be convertible to [type Boolean], an error is
thrown otherwise.

[comment {% % %% %%% %%%%% %%%%%%%% %%%%%%%%%%%%%}]
[def channel]

The function takes an argument of type [type Tcl_Channel].

The Tcl argument must be convertible to type [type Channel], an error
is thrown otherwise.

The channel is further assumed to be [strong {already registered}]
with the interpreter.

[comment {% % %% %%% %%%%% %%%%%%%% %%%%%%%%%%%%%}]
[def unshared-channel]

This type is an extension of [type channel] above.

All of the information above applies.

[para] Beyond that the channel must not be shared by multiple
interpreters, an error is thrown otherwise.

[comment {% % %% %%% %%%%% %%%%%%%% %%%%%%%%%%%%%}]
[def take-channel]

This type is an extension of [type unshared-channel] above.

All of the information above applies.

[para] Beyond that the code removes the channel from the current
interpreter without closing it, and disables all pre-existing event
handling for it.

[para] With this the function takes full ownership of the channel in
question, taking it away from the interpreter invoking it. It is then
responsible for the lifecycle of the channel, up to and including
closing it.

[para] Should the system the function is a part of wish to return
control of the channel back to the interpeter it then has to use the
result type [type return-channel]. This will undo the registration
changes made by this argument type.

[strong Note] however that the removal of pre-existing event handling
done here cannot be undone.

[para] [strong Attention] Removal from the interpreter without closing
the channel is effected by incrementing the channel's reference count
without providing an interpreter, before decrementing the same for the
current interpreter. This leaves the overall reference count intact
without causing Tcl to close it when it is removed from the
interpreter structures. At this point the channel is effectively a
globally-owned part of the system not associated with any interpreter.

[para] The complementary result type then runs this sequence in
reverse. And if the channel is never returned to Tcl either the
function or the system it is a part of have to unregister the global
reference when they are done with it.

[comment {% % %% %%% %%%%% %%%%%%%% %%%%%%%%%%%%%}]
[def int]

The function takes an argument of type [type int].

The Tcl argument must be convertible to [type Int], an error is thrown otherwise.

[def {int > N}]
[def {int >= N}]
[def {int < N}]
[def {int <= N}]

These are variants of [term int] above, restricting the argument value to the shown
relation.

An error is thrown for Tcl arguments outside of the specified range.

[para] The limiter [arg N] has to be a constant integer value.

[para] It is possible to use multiple limiters.

For example [term {int > A > B <= C}].

The system will fuse them to a single upper/lower limit (or both).

[para] The system will reject limits describing an empty range of values, or a range
containing only a single value.

[comment {% % %% %%% %%%%% %%%%%%%% %%%%%%%%%%%%%}]
[def long]

The function takes an argument of type [type {long int}].

The Tcl argument must be convertible to [type Long], an error is thrown otherwise.

[def {long > N}]
[def {long >= N}]
[def {long < N}]
[def {long <= N}]

These are variants of [term long] above, restricting the argument value to the shown
relation.

An error is thrown for Tcl arguments outside of the specified range.

[para] The limiter [arg N] has to be a constant integer value.

[para] It is possible to use multiple limiters.

For example [term {long > A > B <= C}].

The system will fuse them to a single upper/lower limit (or both).

[para] The system will reject limits describing an empty range of values, or a range
containing only a single value.

[comment {% % %% %%% %%%%% %%%%%%%% %%%%%%%%%%%%%}]
[def wideint]

The function takes an argument of type [type Tcl_WideInt].

The Tcl argument must be convertible to [type WideInt], an error is thrown otherwise.

[def {wideint > N}]
[def {wideint >= N}]
[def {wideint < N}]
[def {wideint <= N}]

These are variants of [term wideint] above, restricting the argument value to the shown
relation.

An error is thrown for Tcl arguments outside of the specified range.

[para] The limiter [arg N] has to be a constant integer value.

[para] It is possible to use multiple limiters.

For example [term {wideint > A > B <= C}].

The system will fuse them to a single upper/lower limit (or both).

[para] The system will reject limits describing an empty range of values, or a range
containing only a single value.

[comment {% % %% %%% %%%%% %%%%%%%% %%%%%%%%%%%%%}]
[def void*]

[list_end]