~ubuntu-branches/ubuntu/utopic/critcl/utopic

« back to all changes in this revision

Viewing changes to doc/include/class_spec_ivarm.inc

  • Committer: Package Import Robot
  • Author(s): Andrew Shadura
  • Date: 2013-05-11 00:08:06 UTC
  • Revision ID: package-import@ubuntu.com-20130511000806-7hq1zc3fnn0gat79
Tags: upstream-3.1.9
ImportĀ upstreamĀ versionĀ 3.1.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
[list_begin definitions]
 
3
 
 
4
[comment {- - -- --- ----- -------- ------------- ---------------------}]
 
5
[call [cmd insvariable] [arg ctype] [arg name] [opt [arg comment]] \
 
6
     [opt [arg constructor]] [opt [arg destructor]]]
 
7
 
 
8
This command specifies a field in the instance structure of the class.
 
9
 
 
10
Multiple fields can be specified, and are saved in the order
 
11
specified.
 
12
 
 
13
[para] [emph Attention:] Specification of an instance variable
 
14
precludes the use of an external C [cmd type] for the instance
 
15
structure.
 
16
 
 
17
[para] [emph Attention:] Specification of an instance variable
 
18
automatically causes the definition of an instance variable of type
 
19
[const Tcl_Command], and named [const cmd], holding the token of the
 
20
instance command, and the definition of an instance method named
 
21
[const destroy]. This implicit instance variable is managed by the
 
22
system.
 
23
 
 
24
[para] Beyond the basic [arg name] and C type of the new variable the
 
25
definition may also contain a [arg comment] describing it, and C code
 
26
blocks to initialize and release the variable.
 
27
 
 
28
These are effectively local forms of the commands [cmd constructor]
 
29
and [cmd destructor]. Please read their descriptions for details
 
30
regarding the C environment available to the code.
 
31
 
 
32
[para] The comment, if specified will be embedded into the generated C
 
33
code for easier cross-referencing from generated [file .c] file to
 
34
class specification.
 
35
 
 
36
[comment {- - -- --- ----- -------- ------------- ---------------------}]
 
37
[call [cmd method] [arg name] [method command] [arg arguments] \
 
38
        [arg body]]
 
39
 
 
40
This command specifies an instance method and the C code block
 
41
implementing its functionality. This is the first of three forms. The
 
42
method is specified like a [cmd critcl::ccommand], with a fixed set of
 
43
C-level arguments. The [arg body] has to perform everything
 
44
(i.e. argument extraction, checking, result return, and of course the
 
45
actual functionality) by itself.
 
46
 
 
47
[para] For this the [arg body] has access to
 
48
 
 
49
[list_begin definitions]
 
50
[def [var instance]] Pointer to the instance structure.
 
51
[def [var interp]] Pointer to the Tcl interpreter (Tcl_Interp*) the
 
52
instance structure is associated with
 
53
[def [var objc]] The number of method arguments.
 
54
[def [var objv]] The method arguments, as C array of Tcl_Obj pointers.
 
55
[list_end]
 
56
 
 
57
The [arg arguments] of the definition are only a human readable form
 
58
of the method arguments and syntax and are not used in the C code,
 
59
except as comments put into the generated code. Again, it is the
 
60
responsibility of the [arg body] to check the number of arguments,
 
61
extract them, check their types, etc.
 
62
 
 
63
[comment {- - -- --- ----- -------- ------------- ---------------------}]
 
64
[call [cmd method] [arg name] [method proc] [arg arguments] \
 
65
        [arg resulttype] [arg body]]
 
66
 
 
67
This command specifies an instance method and the C code block
 
68
implementing its functionality.  This is the second of three
 
69
forms. The method is specified like a [cmd critcl::cproc].
 
70
 
 
71
Contrary to the first variant here the [arg arguments] are computer
 
72
readable, expected to be in the same format as the [arg arguments] of
 
73
[cmd critcl::cproc]. The same is true for the [arg resulttype].
 
74
 
 
75
The system automatically generates a wrapper doing argument checking
 
76
and conversion, and result conversion, like for [cmd critcl::cproc].
 
77
 
 
78
[para] The [arg body] has access to
 
79
 
 
80
[list_begin definitions]
 
81
[def [var instance]] Pointer to the instance structure.
 
82
[def [var interp]] Pointer to the Tcl interpreter (Tcl_Interp*) the
 
83
instance structure is associated with
 
84
[def ...] All [arg arguments] under their specified names and C types
 
85
as per their definition.
 
86
[list_end]
 
87
 
 
88
[comment {- - -- --- ----- -------- ------------- ---------------------}]
 
89
[call [cmd method] [arg name] [method as] [arg funname] \
 
90
        [opt [arg arg]...]]
 
91
 
 
92
This command specifies an instance method and the C code block
 
93
implementing its functionality. This is the third and last of three
 
94
forms.
 
95
 
 
96
[para] The instance method is implemented by the external function
 
97
[arg funname], i.e. a function which is declared outside of the instance
 
98
code itself, or in a [cmd support] block.
 
99
 
 
100
[para] It is assumed that the first four arguments of that function
 
101
represent the parameters
 
102
 
 
103
[list_begin definitions]
 
104
[def [var instance]] Pointer to the instance structure.
 
105
[def [var interp]] Pointer to the Tcl interpreter (Tcl_Interp*) the
 
106
instance structure is associated with
 
107
[def [var objc]] The number of method arguments.
 
108
[def [var objv]] The method arguments, as C array of Tcl_Obj pointers.
 
109
[list_end]
 
110
 
 
111
Any additional arguments specified will be added after these and are
 
112
passed into the C code as is, i.e. are considered to be C expressions.
 
113
 
 
114
[comment {- - -- --- ----- -------- ------------- ---------------------}]
 
115
[call [cmd method_introspection]]
 
116
 
 
117
This command generates one class- and one instance-method both of
 
118
which will return a list of the instance methods of the class, and
 
119
supporting structures, like the function to compute the information,
 
120
and a class variable caching it.
 
121
 
 
122
[para] The two methods and the class variable are all named
 
123
[const methods].
 
124
 
 
125
[comment {- - -- --- ----- -------- ------------- ---------------------}]
 
126
[list_end]