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

« back to all changes in this revision

Viewing changes to embedded/www/files/critcl_iassoc.html

  • 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
<html><head>
 
3
<title>critcl::iassoc - C Runtime In Tcl (CriTcl)</title>
 
4
<style type="text/css"><!--
 
5
    HTML {
 
6
        background:     #FFFFFF;
 
7
        color:          black;
 
8
    }
 
9
    BODY {
 
10
        background:     #FFFFFF;
 
11
        color:          black;
 
12
    }
 
13
    DIV.doctools {
 
14
        margin-left:    10%;
 
15
        margin-right:   10%;
 
16
    }
 
17
    DIV.doctools H1,DIV.doctools H2 {
 
18
        margin-left:    -5%;
 
19
    }
 
20
    H1, H2, H3, H4 {
 
21
        margin-top:     1em;
 
22
        font-family:    sans-serif;
 
23
        font-size:      large;
 
24
        color:          #005A9C;
 
25
        background:     transparent;
 
26
        text-align:             left;
 
27
    }
 
28
    H1.title {
 
29
        text-align: center;
 
30
    }
 
31
    UL,OL {
 
32
        margin-right: 0em;
 
33
        margin-top: 3pt;
 
34
        margin-bottom: 3pt;
 
35
    }
 
36
    UL LI {
 
37
        list-style: disc;
 
38
    }
 
39
    OL LI {
 
40
        list-style: decimal;
 
41
    }
 
42
    DT {
 
43
        padding-top:    1ex;
 
44
    }
 
45
    UL.toc,UL.toc UL, UL.toc UL UL {
 
46
        font:           normal 12pt/14pt sans-serif;
 
47
        list-style:     none;
 
48
    }
 
49
    LI.section, LI.subsection {
 
50
        list-style:     none;
 
51
        margin-left:    0em;
 
52
        text-indent:    0em;
 
53
        padding:        0em;
 
54
    }
 
55
    PRE {
 
56
        display:        block;
 
57
        font-family:    monospace;
 
58
        white-space:    pre;
 
59
        margin:         0%;
 
60
        padding-top:    0.5ex;
 
61
        padding-bottom: 0.5ex;
 
62
        padding-left:   1ex;
 
63
        padding-right:  1ex;
 
64
        width:          100%;
 
65
    }
 
66
    PRE.example {
 
67
        color:          black;
 
68
        background:     #f5dcb3;
 
69
        border:         1px solid black;
 
70
    }
 
71
    UL.requirements LI, UL.syntax LI {
 
72
        list-style:     none;
 
73
        margin-left:    0em;
 
74
        text-indent:    0em;
 
75
        padding:        0em;
 
76
    }
 
77
    DIV.synopsis {
 
78
        color:          black;
 
79
        background:     #80ffff;
 
80
        border:         1px solid black;
 
81
        font-family:    serif;
 
82
        margin-top:     1em;
 
83
        margin-bottom:  1em;
 
84
    }
 
85
    UL.syntax {
 
86
        margin-top:     1em;
 
87
        border-top:     1px solid black;
 
88
    }
 
89
    UL.requirements {
 
90
        margin-bottom:  1em;
 
91
        border-bottom:  1px solid black;
 
92
    }
 
93
--></style>
 
94
</head>
 
95
<! -- Generated from file '/home/aku/Projects/Packages/Critcl/dev-master/embedded/www/files/critcl_iassoc.html' by tcllib/doctools with format 'html'
 
96
   -->
 
97
<! -- Copyright &copy; 2011-2012 Andreas Kupries
 
98
   -->
 
99
<! -- CVS: $Id$ critcl::iassoc.n
 
100
   -->
 
101
<body><div class="doctools">
 
102
<hr> [
 
103
  <a href="../toc.html">Table Of Contents</a>
 
104
| <a href="../index.html">Keyword Index</a>
 
105
] <hr>
 
106
<h1 class="title">critcl::iassoc(n) 1 doc &quot;C Runtime In Tcl (CriTcl)&quot;</h1>
 
107
<div id="name" class="section"><h2><a name="name">Name</a></h2>
 
108
<p>critcl::iassoc - CriTcl Utilities: Tcl Interp Associations</p>
 
109
</div>
 
110
<div id="toc" class="section"><h2><a name="toc">Table Of Contents</a></h2>
 
111
<ul class="toc">
 
112
<li class="section"><a href="#toc">Table Of Contents</a></li>
 
113
<li class="section"><a href="#synopsis">Synopsis</a></li>
 
114
<li class="section"><a href="#section1">Description</a></li>
 
115
<li class="section"><a href="#section2">API</a></li>
 
116
<li class="section"><a href="#section3">Example</a></li>
 
117
<li class="section"><a href="#section4">Authors</a></li>
 
118
<li class="section"><a href="#section5">Bugs, Ideas, Feedback</a></li>
 
119
<li class="section"><a href="#keywords">Keywords</a></li>
 
120
<li class="section"><a href="#category">Category</a></li>
 
121
<li class="section"><a href="#copyright">Copyright</a></li>
 
122
</ul>
 
123
</div>
 
124
<div id="synopsis" class="section"><h2><a name="synopsis">Synopsis</a></h2>
 
125
<div class="synopsis">
 
126
<ul class="requirements">
 
127
<li>package require <b class="pkgname">Tcl 8.4</b></li>
 
128
<li>package require <b class="pkgname">critcl <span class="opt">?3.1?</span></b></li>
 
129
<li>package require <b class="pkgname">critcl::iassoc <span class="opt">?1?</span></b></li>
 
130
</ul>
 
131
<ul class="syntax">
 
132
<li><a href="#1"><b class="cmd">::critcl::iassoc::def</b> <i class="arg">name</i> <i class="arg">arguments</i> <i class="arg">struct</i> <i class="arg">constructor</i> <i class="arg">destructor</i></a></li>
 
133
</ul>
 
134
</div>
 
135
</div>
 
136
<div id="section1" class="section"><h2><a name="section1">Description</a></h2>
 
137
<p>Welcome to the <i class="term">C Runtime In Tcl</i>, <i class="term"><a href="critcl_pkg.html">CriTcl</a></i> for short, a
 
138
system to build C extension packages for Tcl on the fly, from C code
 
139
embedded within Tcl scripts, for all who wish to make their code go
 
140
faster.</p>
 
141
<p>This document is the reference manpage for the <b class="package">critcl::iassoc</b>
 
142
package. This package provides convenience commands for advanced
 
143
functionality built on top of the critcl core.</p>
 
144
<p>With it a user wishing to associate some data with a Tcl
 
145
interpreter via Tcl's <b class="function">Tcl_(Get|Set)AssocData()</b> APIs can now
 
146
concentrate on the data itself, while all the necessary boilerplate
 
147
around it is managed by this package.</p>
 
148
<p>Its intended audience are mainly developers wishing to write
 
149
Tcl packages with embedded C code.</p>
 
150
<p>This package resides in the Core Package Layer of CriTcl.</p>
 
151
<p><img alt="arch_core" src="../image/arch_core.png"></p>
 
152
</div>
 
153
<div id="section2" class="section"><h2><a name="section2">API</a></h2>
 
154
<dl class="definitions">
 
155
<dt><a name="1"><b class="cmd">::critcl::iassoc::def</b> <i class="arg">name</i> <i class="arg">arguments</i> <i class="arg">struct</i> <i class="arg">constructor</i> <i class="arg">destructor</i></a></dt>
 
156
<dd><p>This command defines a C function with the given <i class="arg">name</i> which
 
157
provides access to a structure associated with a Tcl interpreter.</p>
 
158
<p>The C code code fragment <i class="arg">struct</i> defines the elements of
 
159
said structure, whereas the fragments <i class="arg">constructor</i> and
 
160
<i class="arg">destructor</i> are C code blocks executed to initialize and release
 
161
any dynamically allocated parts of this structure, when needed. Note
 
162
that the structure itself is managed by the system.</p>
 
163
<p>The new function takes a <b class="const">Tcl_Interp*</b> pointer refering
 
164
to the interpreter whose structure we wish to obtain as the first
 
165
argument, plus the specified <i class="arg">arguments</i> and returns a pointer to
 
166
the associated structure, of type &quot;<i class="arg">name</i>_data&quot; (see below).</p>
 
167
<p>The <i class="arg">arguments</i> are a dictionary-like list of C types and
 
168
identifiers specifying additional arguments for the accessor function,
 
169
and, indirectly, the <i class="arg">constructor</i> C code block. This is useful
 
170
for the supplication of initialization values, or the return of more
 
171
complex error information in case of a construction failure.</p>
 
172
<p>The C types associated with the structure are derived from
 
173
<i class="arg">name</i>, with &quot;<i class="arg">name</i>_data__&quot; the type of the structure itself,
 
174
and &quot;<i class="arg">name</i>_data&quot; representing a pointer to the structure.
 
175
The C code blocks can rely on the following C environments:</p>
 
176
<dl class="definitions">
 
177
<dt><i class="arg">constructor</i></dt>
 
178
<dd><dl class="definitions">
 
179
<dt><b class="variable">data</b></dt>
 
180
<dd><p>Pointer to the structure (type: <i class="arg">name</i>_data) to
 
181
initialize.</p></dd>
 
182
<dt><b class="variable">interp</b></dt>
 
183
<dd><p>Pointer to the Tcl interpreter (type: Tcl_Interp*)
 
184
the new structure will be associated with.</p></dd>
 
185
<dt>error</dt>
 
186
<dd><p>A C code label the constructor can jump to should it have
 
187
to signal a construction failure. It is the responsibility of the
 
188
constructor to release any fields already initialized before jumping
 
189
to this label.</p></dd>
 
190
<dt>...</dt>
 
191
<dd><p>The names of the constructor arguments specified with
 
192
<i class="arg">arguments</i>.</p></dd>
 
193
</dl></dd>
 
194
<dt><i class="arg">destructor</i></dt>
 
195
<dd><dl class="definitions">
 
196
<dt><b class="variable">data</b></dt>
 
197
<dd><p>Pointer to the structure being released.</p></dd>
 
198
<dt><b class="variable">interp</b></dt>
 
199
<dd><p>Pointer to the Tcl interpreter the structure
 
200
belonged to.</p></dd>
 
201
</dl></dd>
 
202
</dl></dd>
 
203
</dl>
 
204
</div>
 
205
<div id="section3" class="section"><h2><a name="section3">Example</a></h2>
 
206
<p>The example shown below is the specification of a simple interpreter-associated
 
207
counter. The full example, with meta data and other incidentals, can be found
 
208
in the directory &quot;<b class="file">examples/queue</b>&quot; of the critcl source
 
209
distribution/repository.</p>
 
210
<pre class="example">
 
211
package require Tcl 8.4
 
212
package require critcl 3.1
 
213
critcl::buildrequirement {
 
214
    package require critcl::iassoc
 
215
}
 
216
critcl::iassoc::def icounter {} {
 
217
    int counter; /* The counter variable */
 
218
} {
 
219
    data-&gt;counter = 0;
 
220
} {
 
221
    /* Nothing to release */
 
222
}
 
223
critcl::ccode {
 
224
    ... function (...)
 
225
    {
 
226
         /* Access to the data ... */
 
227
         icounter_data D = icounter (interp /* ... any declared arguments, here, none */);
 
228
         ... D-&gt;counter ...
 
229
    }
 
230
}
 
231
# or, of course, 'cproc's, 'ccommand's etc.
 
232
package provide icounter 1
 
233
</pre>
 
234
</div>
 
235
<div id="section4" class="section"><h2><a name="section4">Authors</a></h2>
 
236
<p>Andreas Kupries</p>
 
237
</div>
 
238
<div id="section5" class="section"><h2><a name="section5">Bugs, Ideas, Feedback</a></h2>
 
239
<p>This document, and the package it describes, will undoubtedly contain
 
240
bugs and other problems.
 
241
Please report such at <a href="https://github.com/andreas-kupries/critcl">https://github.com/andreas-kupries/critcl</a>.
 
242
Please also report any ideas for enhancements you may have for either
 
243
package and/or documentation.</p>
 
244
</div>
 
245
<div id="keywords" class="section"><h2><a name="keywords">Keywords</a></h2>
 
246
<p><a href="../index.html#key8">C code</a>, <a href="../index.html#key3">Embedded C Code</a>, <a href="../index.html#key15">Tcl Interp Association</a>, <a href="../index.html#key6">code generator</a>, <a href="../index.html#key0">compile &amp; run</a>, <a href="../index.html#key10">compiler</a>, <a href="../index.html#key1">dynamic code generation</a>, <a href="../index.html#key2">dynamic compilation</a>, <a href="../index.html#key9">generate package</a>, <a href="../index.html#key4">linker</a>, <a href="../index.html#key5">on demand compilation</a>, <a href="../index.html#key7">on-the-fly compilation</a>, <a href="../index.html#key14">singleton</a></p>
 
247
</div>
 
248
<div id="category" class="section"><h2><a name="category">Category</a></h2>
 
249
<p>Glueing/Embedded C code</p>
 
250
</div>
 
251
<div id="copyright" class="section"><h2><a name="copyright">Copyright</a></h2>
 
252
<p>Copyright &copy; 2011-2012 Andreas Kupries</p>
 
253
</div>
 
254
</div></body></html>