| 1 |
'\" |
| 2 |
'\" Generated from file 'critcl_package\&.man' by tcllib/doctools with format 'nroff' |
| 3 |
'\" Copyright (c) Jean-Claude Wippler |
| 4 |
'\" Copyright (c) Steve Landers |
| 5 |
'\" Copyright (c) 2011-2024 Andreas Kupries |
| 6 |
'\" |
| 7 |
.TH "critcl_package" n 3\&.3\&.1 doc "C Runtime In Tcl (CriTcl)" |
| 8 |
.\" The -*- nroff -*- definitions below are for supplemental macros used |
| 9 |
.\" in Tcl/Tk manual entries. |
| 10 |
.\" |
| 11 |
.\" .AP type name in/out ?indent? |
| 12 |
.\" Start paragraph describing an argument to a library procedure. |
| 13 |
.\" type is type of argument (int, etc.), in/out is either "in", "out", |
| 14 |
.\" or "in/out" to describe whether procedure reads or modifies arg, |
| 15 |
.\" and indent is equivalent to second arg of .IP (shouldn't ever be |
| 16 |
.\" needed; use .AS below instead) |
| 17 |
.\" |
| 18 |
.\" .AS ?type? ?name? |
| 19 |
.\" Give maximum sizes of arguments for setting tab stops. Type and |
| 20 |
.\" name are examples of largest possible arguments that will be passed |
| 21 |
.\" to .AP later. If args are omitted, default tab stops are used. |
| 22 |
.\" |
| 23 |
.\" .BS |
| 24 |
.\" Start box enclosure. From here until next .BE, everything will be |
| 25 |
.\" enclosed in one large box. |
| 26 |
.\" |
| 27 |
.\" .BE |
| 28 |
.\" End of box enclosure. |
| 29 |
.\" |
| 30 |
.\" .CS |
| 31 |
.\" Begin code excerpt. |
| 32 |
.\" |
| 33 |
.\" .CE |
| 34 |
.\" End code excerpt. |
| 35 |
.\" |
| 36 |
.\" .VS ?version? ?br? |
| 37 |
.\" Begin vertical sidebar, for use in marking newly-changed parts |
| 38 |
.\" of man pages. The first argument is ignored and used for recording |
| 39 |
.\" the version when the .VS was added, so that the sidebars can be |
| 40 |
.\" found and removed when they reach a certain age. If another argument |
| 41 |
.\" is present, then a line break is forced before starting the sidebar. |
| 42 |
.\" |
| 43 |
.\" .VE |
| 44 |
.\" End of vertical sidebar. |
| 45 |
.\" |
| 46 |
.\" .DS |
| 47 |
.\" Begin an indented unfilled display. |
| 48 |
.\" |
| 49 |
.\" .DE |
| 50 |
.\" End of indented unfilled display. |
| 51 |
.\" |
| 52 |
.\" .SO ?manpage? |
| 53 |
.\" Start of list of standard options for a Tk widget. The manpage |
| 54 |
.\" argument defines where to look up the standard options; if |
| 55 |
.\" omitted, defaults to "options". The options follow on successive |
| 56 |
.\" lines, in three columns separated by tabs. |
| 57 |
.\" |
| 58 |
.\" .SE |
| 59 |
.\" End of list of standard options for a Tk widget. |
| 60 |
.\" |
| 61 |
.\" .OP cmdName dbName dbClass |
| 62 |
.\" Start of description of a specific option. cmdName gives the |
| 63 |
.\" option's name as specified in the class command, dbName gives |
| 64 |
.\" the option's name in the option database, and dbClass gives |
| 65 |
.\" the option's class in the option database. |
| 66 |
.\" |
| 67 |
.\" .UL arg1 arg2 |
| 68 |
.\" Print arg1 underlined, then print arg2 normally. |
| 69 |
.\" |
| 70 |
.\" .QW arg1 ?arg2? |
| 71 |
.\" Print arg1 in quotes, then arg2 normally (for trailing punctuation). |
| 72 |
.\" |
| 73 |
.\" .PQ arg1 ?arg2? |
| 74 |
.\" Print an open parenthesis, arg1 in quotes, then arg2 normally |
| 75 |
.\" (for trailing punctuation) and then a closing parenthesis. |
| 76 |
.\" |
| 77 |
.\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. |
| 78 |
.if t .wh -1.3i ^B |
| 79 |
.nr ^l \n(.l |
| 80 |
.ad b |
| 81 |
.\" # Start an argument description |
| 82 |
.de AP |
| 83 |
.ie !"\\$4"" .TP \\$4 |
| 84 |
.el \{\ |
| 85 |
. ie !"\\$2"" .TP \\n()Cu |
| 86 |
. el .TP 15 |
| 87 |
.\} |
| 88 |
.ta \\n()Au \\n()Bu |
| 89 |
.ie !"\\$3"" \{\ |
| 90 |
\&\\$1 \\fI\\$2\\fP (\\$3) |
| 91 |
.\".b |
| 92 |
.\} |
| 93 |
.el \{\ |
| 94 |
.br |
| 95 |
.ie !"\\$2"" \{\ |
| 96 |
\&\\$1 \\fI\\$2\\fP |
| 97 |
.\} |
| 98 |
.el \{\ |
| 99 |
\&\\fI\\$1\\fP |
| 100 |
.\} |
| 101 |
.\} |
| 102 |
.. |
| 103 |
.\" # define tabbing values for .AP |
| 104 |
.de AS |
| 105 |
.nr )A 10n |
| 106 |
.if !"\\$1"" .nr )A \\w'\\$1'u+3n |
| 107 |
.nr )B \\n()Au+15n |
| 108 |
.\" |
| 109 |
.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n |
| 110 |
.nr )C \\n()Bu+\\w'(in/out)'u+2n |
| 111 |
.. |
| 112 |
.AS Tcl_Interp Tcl_CreateInterp in/out |
| 113 |
.\" # BS - start boxed text |
| 114 |
.\" # ^y = starting y location |
| 115 |
.\" # ^b = 1 |
| 116 |
.de BS |
| 117 |
.br |
| 118 |
.mk ^y |
| 119 |
.nr ^b 1u |
| 120 |
.if n .nf |
| 121 |
.if n .ti 0 |
| 122 |
.if n \l'\\n(.lu\(ul' |
| 123 |
.if n .fi |
| 124 |
.. |
| 125 |
.\" # BE - end boxed text (draw box now) |
| 126 |
.de BE |
| 127 |
.nf |
| 128 |
.ti 0 |
| 129 |
.mk ^t |
| 130 |
.ie n \l'\\n(^lu\(ul' |
| 131 |
.el \{\ |
| 132 |
.\" Draw four-sided box normally, but don't draw top of |
| 133 |
.\" box if the box started on an earlier page. |
| 134 |
.ie !\\n(^b-1 \{\ |
| 135 |
\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' |
| 136 |
.\} |
| 137 |
.el \}\ |
| 138 |
\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' |
| 139 |
.\} |
| 140 |
.\} |
| 141 |
.fi |
| 142 |
.br |
| 143 |
.nr ^b 0 |
| 144 |
.. |
| 145 |
.\" # VS - start vertical sidebar |
| 146 |
.\" # ^Y = starting y location |
| 147 |
.\" # ^v = 1 (for troff; for nroff this doesn't matter) |
| 148 |
.de VS |
| 149 |
.if !"\\$2"" .br |
| 150 |
.mk ^Y |
| 151 |
.ie n 'mc \s12\(br\s0 |
| 152 |
.el .nr ^v 1u |
| 153 |
.. |
| 154 |
.\" # VE - end of vertical sidebar |
| 155 |
.de VE |
| 156 |
.ie n 'mc |
| 157 |
.el \{\ |
| 158 |
.ev 2 |
| 159 |
.nf |
| 160 |
.ti 0 |
| 161 |
.mk ^t |
| 162 |
\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' |
| 163 |
.sp -1 |
| 164 |
.fi |
| 165 |
.ev |
| 166 |
.\} |
| 167 |
.nr ^v 0 |
| 168 |
.. |
| 169 |
.\" # Special macro to handle page bottom: finish off current |
| 170 |
.\" # box/sidebar if in box/sidebar mode, then invoked standard |
| 171 |
.\" # page bottom macro. |
| 172 |
.de ^B |
| 173 |
.ev 2 |
| 174 |
'ti 0 |
| 175 |
'nf |
| 176 |
.mk ^t |
| 177 |
.if \\n(^b \{\ |
| 178 |
.\" Draw three-sided box if this is the box's first page, |
| 179 |
.\" draw two sides but no top otherwise. |
| 180 |
.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c |
| 181 |
.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c |
| 182 |
.\} |
| 183 |
.if \\n(^v \{\ |
| 184 |
.nr ^x \\n(^tu+1v-\\n(^Yu |
| 185 |
\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c |
| 186 |
.\} |
| 187 |
.bp |
| 188 |
'fi |
| 189 |
.ev |
| 190 |
.if \\n(^b \{\ |
| 191 |
.mk ^y |
| 192 |
.nr ^b 2 |
| 193 |
.\} |
| 194 |
.if \\n(^v \{\ |
| 195 |
.mk ^Y |
| 196 |
.\} |
| 197 |
.. |
| 198 |
.\" # DS - begin display |
| 199 |
.de DS |
| 200 |
.RS |
| 201 |
.nf |
| 202 |
.sp |
| 203 |
.. |
| 204 |
.\" # DE - end display |
| 205 |
.de DE |
| 206 |
.fi |
| 207 |
.RE |
| 208 |
.sp |
| 209 |
.. |
| 210 |
.\" # SO - start of list of standard options |
| 211 |
.de SO |
| 212 |
'ie '\\$1'' .ds So \\fBoptions\\fR |
| 213 |
'el .ds So \\fB\\$1\\fR |
| 214 |
.SH "STANDARD OPTIONS" |
| 215 |
.LP |
| 216 |
.nf |
| 217 |
.ta 5.5c 11c |
| 218 |
.ft B |
| 219 |
.. |
| 220 |
.\" # SE - end of list of standard options |
| 221 |
.de SE |
| 222 |
.fi |
| 223 |
.ft R |
| 224 |
.LP |
| 225 |
See the \\*(So manual entry for details on the standard options. |
| 226 |
.. |
| 227 |
.\" # OP - start of full description for a single option |
| 228 |
.de OP |
| 229 |
.LP |
| 230 |
.nf |
| 231 |
.ta 4c |
| 232 |
Command-Line Name: \\fB\\$1\\fR |
| 233 |
Database Name: \\fB\\$2\\fR |
| 234 |
Database Class: \\fB\\$3\\fR |
| 235 |
.fi |
| 236 |
.IP |
| 237 |
.. |
| 238 |
.\" # CS - begin code excerpt |
| 239 |
.de CS |
| 240 |
.RS |
| 241 |
.nf |
| 242 |
.ta .25i .5i .75i 1i |
| 243 |
.. |
| 244 |
.\" # CE - end code excerpt |
| 245 |
.de CE |
| 246 |
.fi |
| 247 |
.RE |
| 248 |
.. |
| 249 |
.\" # UL - underline word |
| 250 |
.de UL |
| 251 |
\\$1\l'|0\(ul'\\$2 |
| 252 |
.. |
| 253 |
.\" # QW - apply quotation marks to word |
| 254 |
.de QW |
| 255 |
.ie '\\*(lq'"' ``\\$1''\\$2 |
| 256 |
.\"" fix emacs highlighting |
| 257 |
.el \\*(lq\\$1\\*(rq\\$2 |
| 258 |
.. |
| 259 |
.\" # PQ - apply parens and quotation marks to word |
| 260 |
.de PQ |
| 261 |
.ie '\\*(lq'"' (``\\$1''\\$2)\\$3 |
| 262 |
.\"" fix emacs highlighting |
| 263 |
.el (\\*(lq\\$1\\*(rq\\$2)\\$3 |
| 264 |
.. |
| 265 |
.\" # QR - quoted range |
| 266 |
.de QR |
| 267 |
.ie '\\*(lq'"' ``\\$1''\\-``\\$2''\\$3 |
| 268 |
.\"" fix emacs highlighting |
| 269 |
.el \\*(lq\\$1\\*(rq\\-\\*(lq\\$2\\*(rq\\$3 |
| 270 |
.. |
| 271 |
.\" # MT - "empty" string |
| 272 |
.de MT |
| 273 |
.QW "" |
| 274 |
.. |
| 275 |
.BS |
| 276 |
.SH NAME |
| 277 |
critcl_package \- CriTcl Package Reference |
| 278 |
.SH SYNOPSIS |
| 279 |
package require \fBTcl 8\&.6\fR |
| 280 |
.sp |
| 281 |
package require \fBcritcl ?3\&.3\&.1?\fR |
| 282 |
.sp |
| 283 |
package require \fBplatform ?1\&.0\&.2?\fR |
| 284 |
.sp |
| 285 |
package require \fBmd5 ?2?\fR |
| 286 |
.sp |
| 287 |
\fB::critcl::ccode\fR \fIfragment\fR |
| 288 |
.sp |
| 289 |
\fB::critcl::ccommand\fR \fItclname\fR \fIcname\fR |
| 290 |
.sp |
| 291 |
\fB::critcl::ccommand\fR \fItclname\fR \fIarguments\fR \fIbody\fR ?\fIoption\fR \fIvalue\fR\&.\&.\&.? |
| 292 |
.sp |
| 293 |
\fB::critcl::cdata\fR \fItclname\fR \fIdata\fR |
| 294 |
.sp |
| 295 |
\fB::critcl::cconst\fR \fItclname\fR \fIresulttype\fR \fIvalue\fR |
| 296 |
.sp |
| 297 |
\fB::critcl::cdefines\fR \fIlist of glob patterns\fR ?\fInamespace\fR? |
| 298 |
.sp |
| 299 |
\fB::critcl::cproc\fR \fIname\fR \fIarguments\fR \fIresulttype\fR \fIbody\fR ?\fIoption\fR \fIvalue\fR\&.\&.\&.? |
| 300 |
.sp |
| 301 |
\fB::critcl::cproc\fR \fIname\fR \fIarguments\fR \fIresulttype\fR |
| 302 |
.sp |
| 303 |
\fB::critcl::cinit\fR \fItext\fR \fIexternals\fR |
| 304 |
.sp |
| 305 |
\fB::critcl::include\fR \fIpath\fR |
| 306 |
.sp |
| 307 |
\fB::critcl::api\fR \fBimport\fR \fIname\fR \fIversion\fR |
| 308 |
.sp |
| 309 |
\fB::critcl::api\fR \fBfunction\fR \fIresulttype\fR \fIname\fR \fIarguments\fR |
| 310 |
.sp |
| 311 |
\fB::critcl::api\fR \fBheader\fR ?\fIglob pattern\fR\&.\&.\&.? |
| 312 |
.sp |
| 313 |
\fB::critcl::api\fR \fBextheader\fR ?\fIfile\fR\&.\&.\&.? |
| 314 |
.sp |
| 315 |
\fB::critcl::license\fR \fIauthor\fR ?\fItext\fR\&.\&.\&.? |
| 316 |
.sp |
| 317 |
\fB::critcl::summary\fR \fItext\fR |
| 318 |
.sp |
| 319 |
\fB::critcl::description\fR \fItext\fR |
| 320 |
.sp |
| 321 |
\fB::critcl::subject\fR ?\fIkey\fR\&.\&.\&.? |
| 322 |
.sp |
| 323 |
\fB::critcl::meta\fR \fIkey\fR ?\fIword\fR\&.\&.\&.? |
| 324 |
.sp |
| 325 |
\fB::critcl::meta?\fR \fIkey\fR |
| 326 |
.sp |
| 327 |
\fB::critcl::buildrequirement\fR \fIscript\fR |
| 328 |
.sp |
| 329 |
\fB::critcl::cheaders\fR ?\fIarg\fR\&.\&.\&.? |
| 330 |
.sp |
| 331 |
\fB::critcl::csources\fR ?\fIglob pattern\fR\&.\&.\&.? |
| 332 |
.sp |
| 333 |
\fB::critcl::clibraries\fR ?\fIglob pattern\fR\&.\&.\&.? |
| 334 |
.sp |
| 335 |
\fB::critcl::source\fR \fIglob pattern\fR |
| 336 |
.sp |
| 337 |
\fB::critcl::tsources\fR \fIglob pattern\fR\&.\&.\&. |
| 338 |
.sp |
| 339 |
\fB::critcl::owns\fR \fIglob pattern\fR\&.\&.\&. |
| 340 |
.sp |
| 341 |
\fB::critcl::cflags\fR ?\fIarg\fR\&.\&.\&.? |
| 342 |
.sp |
| 343 |
\fB::critcl::ldflags\fR ?\fIarg\fR\&.\&.\&.? |
| 344 |
.sp |
| 345 |
\fB::critcl::framework\fR ?\fIarg\fR\&.\&.\&.? |
| 346 |
.sp |
| 347 |
\fB::critcl::tcl\fR \fIversion\fR |
| 348 |
.sp |
| 349 |
\fB::critcl::tk\fR |
| 350 |
.sp |
| 351 |
\fB::critcl::preload\fR \fIlib\fR\&.\&.\&. |
| 352 |
.sp |
| 353 |
\fB::critcl::debug\fR \fIarea\fR\&.\&.\&. |
| 354 |
.sp |
| 355 |
\fB::critcl::check\fR ?\fIlabel\fR? \fItext\fR |
| 356 |
.sp |
| 357 |
\fB::critcl::checklink\fR ?\fIlabel\fR? \fItext\fR |
| 358 |
.sp |
| 359 |
\fB::critcl::msg\fR ?\fB-nonewline\fR? \fImsg\fR |
| 360 |
.sp |
| 361 |
\fB::critcl::print\fR ?\fB-nonewline\fR? ?\fIchan\fR? \fImsg\fR |
| 362 |
.sp |
| 363 |
\fB::critcl::compiled\fR |
| 364 |
.sp |
| 365 |
\fB::critcl::compiling\fR |
| 366 |
.sp |
| 367 |
\fB::critcl::done\fR |
| 368 |
.sp |
| 369 |
\fB::critcl::failed\fR |
| 370 |
.sp |
| 371 |
\fB::critcl::load\fR |
| 372 |
.sp |
| 373 |
\fB::critcl::config\fR \fIoption\fR ?\fIval\fR? |
| 374 |
.sp |
| 375 |
\fB::critcl::cache\fR ?path? |
| 376 |
.sp |
| 377 |
\fB::critcl::clean_cache\fR ?\fIpattern\fR\&.\&.\&.? |
| 378 |
.sp |
| 379 |
\fB::critcl::readconfig\fR \fIpath\fR |
| 380 |
.sp |
| 381 |
\fB::critcl::showconfig\fR ?\fIchan\fR? |
| 382 |
.sp |
| 383 |
\fB::critcl::showallconfig\fR ?\fIchan\fR? |
| 384 |
.sp |
| 385 |
\fB::critcl::chooseconfig\fR \fItarget\fR ?\fInomatcherr\fR? |
| 386 |
.sp |
| 387 |
\fB::critcl::setconfig\fR \fItarget\fR |
| 388 |
.sp |
| 389 |
\fB::critcl::actualtarget\fR |
| 390 |
.sp |
| 391 |
\fB::critcl::buildforpackage\fR ?\fIflag\fR? |
| 392 |
.sp |
| 393 |
\fB::critcl::cnothingtodo\fR \fIfile\fR |
| 394 |
.sp |
| 395 |
\fB::critcl::cresults\fR ?\fIfile\fR? |
| 396 |
.sp |
| 397 |
\fB::critcl::crosscheck\fR |
| 398 |
.sp |
| 399 |
\fB::critcl::error\fR \fImsg\fR |
| 400 |
.sp |
| 401 |
\fB::critcl::knowntargets\fR |
| 402 |
.sp |
| 403 |
\fB::critcl::sharedlibext\fR |
| 404 |
.sp |
| 405 |
\fB::critcl::targetconfig\fR |
| 406 |
.sp |
| 407 |
\fB::critcl::buildplatform\fR |
| 408 |
.sp |
| 409 |
\fB::critcl::targetplatform\fR |
| 410 |
.sp |
| 411 |
\fB::critcl::cobjects\fR ?\fIglob pattern\fR\&.\&.\&.? |
| 412 |
.sp |
| 413 |
\fB::critcl::scan\fR \fIpath\fR |
| 414 |
.sp |
| 415 |
\fB::critcl::name2c\fR \fIname\fR |
| 416 |
.sp |
| 417 |
\fB::critcl::argnames\fR \fIarguments\fR |
| 418 |
.sp |
| 419 |
\fB::critcl::argcnames\fR \fIarguments\fR |
| 420 |
.sp |
| 421 |
\fB::critcl::argcsignature\fR \fIarguments\fR |
| 422 |
.sp |
| 423 |
\fB::critcl::argvardecls\fR \fIarguments\fR |
| 424 |
.sp |
| 425 |
\fB::critcl::argconversion\fR \fIarguments\fR ?\fIn\fR? |
| 426 |
.sp |
| 427 |
\fB::critcl::argoptional\fR \fIarguments\fR |
| 428 |
.sp |
| 429 |
\fB::critcl::argdefaults\fR \fIarguments\fR |
| 430 |
.sp |
| 431 |
\fB::critcl::argsupport\fR \fIarguments\fR |
| 432 |
.sp |
| 433 |
\fB::critcl::userconfig\fR \fBdefine\fR \fIname\fR \fIdescription\fR \fItype\fR ?\fIdefault\fR? |
| 434 |
.sp |
| 435 |
\fB::critcl::userconfig\fR \fBquery\fR \fIname\fR |
| 436 |
.sp |
| 437 |
\fB::critcl::userconfig\fR \fBset\fR \fIname\fR \fIvalue\fR |
| 438 |
.sp |
| 439 |
\fB::critcl::at::caller\fR |
| 440 |
.sp |
| 441 |
\fB::critcl::at::caller\fR \fIoffset\fR |
| 442 |
.sp |
| 443 |
\fB::critcl::at::caller\fR \fIoffset\fR \fIlevel\fR |
| 444 |
.sp |
| 445 |
\fB::critcl::at::here\fR |
| 446 |
.sp |
| 447 |
\fB::critcl::at::get*\fR |
| 448 |
.sp |
| 449 |
\fB::critcl::at::get\fR |
| 450 |
.sp |
| 451 |
\fB::critcl::at::=\fR \fIfile\fR \fIline\fR |
| 452 |
.sp |
| 453 |
\fB::critcl::at::incr\fR \fIn\fR\&.\&.\&. |
| 454 |
.sp |
| 455 |
\fB::critcl::at::incrt\fR \fIstr\fR\&.\&.\&. |
| 456 |
.sp |
| 457 |
\fB::critcl::at::caller!\fR |
| 458 |
.sp |
| 459 |
\fB::critcl::at::caller!\fR \fIoffset\fR |
| 460 |
.sp |
| 461 |
\fB::critcl::at::caller!\fR \fIoffset\fR \fIlevel\fR |
| 462 |
.sp |
| 463 |
\fB::critcl::at::here!\fR |
| 464 |
.sp |
| 465 |
\fB::critcl::collect_begin\fR |
| 466 |
.sp |
| 467 |
\fB::critcl::collect_end\fR |
| 468 |
.sp |
| 469 |
\fB::critcl::collect\fR \fIscript\fR |
| 470 |
.sp |
| 471 |
\fB::critcl::make\fR \fIpath\fR \fIcontents\fR |
| 472 |
.sp |
| 473 |
\fB::preload\fR \fIlibrary\fR |
| 474 |
.sp |
| 475 |
.BE |
| 476 |
.SH DESCRIPTION |
| 477 |
.PP |
| 478 |
Be welcome to the \fIC Runtime In Tcl\fR (short: \fICriTcl\fR), a system for embedding and using C |
| 479 |
code from within \fITcl\fR [http://core\&.tcl-lang\&.org/tcl] scripts\&. |
| 480 |
.PP |
| 481 |
The \fBcritcl\fR package is the core of the system\&. For an overview of the |
| 482 |
complete system, see \fIIntroduction To CriTcl\fR\&. For the usage of the |
| 483 |
standalone \fBcritcl\fR program, see \fICriTcl Application\fR\&. |
| 484 |
This core package maybe be used to embed C code into Tcl scripts\&. It also |
| 485 |
provides access to the internals that other parts of the core use and which |
| 486 |
are of interest to those wishing to understand the internal workings of the |
| 487 |
core and of the API it provides to the \fICriTcl Application\fR\&. These |
| 488 |
advanced sections are marked as such so that those simply wishing to use the |
| 489 |
package can skip them\&. |
| 490 |
.PP |
| 491 |
This package resides in the Core Package Layer of CriTcl\&. |
| 492 |
.PP |
| 493 |
.PS |
| 494 |
.nf |
| 495 |
+----------------+ |
| 496 |
|Applications | |
| 497 |
| critcl | |
| 498 |
| critcl::app | |
| 499 |
+----------------+ |
| 500 |
|
| 501 |
*================* |
| 502 |
|Core Packages | |
| 503 |
| critcl | |
| 504 |
| critcl::util | |
| 505 |
*================* |
| 506 |
|
| 507 |
+----------------+ |
| 508 |
|Support Packages| |
| 509 |
| stubs::* | |
| 510 |
| md5, platform | |
| 511 |
| \&.\&.\&. | |
| 512 |
+----------------+ |
| 513 |
|
| 514 |
.fi |
| 515 |
.PE |
| 516 |
.PP |
| 517 |
.SH API |
| 518 |
A short note ahead of the documentation: Instead of repeatedly talking |
| 519 |
about |
| 520 |
"a Tcl script with embbedded C code", or |
| 521 |
"a Tcl script containing CriTcl commands", |
| 522 |
we call such a script a \fICriTcl script\fR\&. A file containing a |
| 523 |
\fICriTcl script\fR usually has the extension \fB\&.tcl\fR or \fB\&.critcl\fR\&. |
| 524 |
.SS "EMBEDDED C CODE" |
| 525 |
The following commands append C code fragments to the current module\&. Fragments |
| 526 |
appear in the module in the order they are appended, so the earlier fragments |
| 527 |
(variables, functions, macros, etc\&.) are visible to later fragments\&. |
| 528 |
.TP |
| 529 |
\fB::critcl::ccode\fR \fIfragment\fR |
| 530 |
Appends the C code in \fIfragment\fR to the current module and returns the |
| 531 |
empty string\&. |
| 532 |
See \fBRuntime Behaviour\fR\&. |
| 533 |
.TP |
| 534 |
\fB::critcl::ccommand\fR \fItclname\fR \fIcname\fR |
| 535 |
As documented below, except that \fIcname\fR is the name of a C function |
| 536 |
that already exists\&. |
| 537 |
.TP |
| 538 |
\fB::critcl::ccommand\fR \fItclname\fR \fIarguments\fR \fIbody\fR ?\fIoption\fR \fIvalue\fR\&.\&.\&.? |
| 539 |
Appends the code to create a Tcl command named \fItclname\fR and a |
| 540 |
corresponding C function whose body is \fIbody\fR and which behaves as |
| 541 |
documented for Tcl's own |
| 542 |
\fITcl_CreateObjCommand\fR [https://www\&.tcl-lang\&.org/man/tcl/TclLib/CrtObjCmd\&.htm]\&. |
| 543 |
.sp |
| 544 |
\fIaguments\fR is a list of zero to four names for the standard arguments |
| 545 |
\fBclientdata\fR, \fBinterp\fR, \fBobjc\fR, and \fBobjv\fR\&. The |
| 546 |
standard default names are used in place of any missing names\&. |
| 547 |
This is a more low-level way than \fBcritcl::cproc\fR to define a command, as |
| 548 |
processing of the items in \fBobjv\fR is left to the author, affording |
| 549 |
complete control over the handling of the arguments to the command\&. |
| 550 |
See section \fBRuntime Behaviour\fR\&. |
| 551 |
.sp |
| 552 |
Returns the empty string\&. |
| 553 |
.sp |
| 554 |
Each \fIoption\fR may be one of: |
| 555 |
.RS |
| 556 |
.TP |
| 557 |
\fB-clientdata\fR \fIc-expression\fR |
| 558 |
Provides the client data for the new command\&. \fBNULL\fR by default\&. |
| 559 |
.TP |
| 560 |
\fB-delproc\fR \fIc-expression\fR |
| 561 |
Provides a function pointer of type \fITcl_CmdDeleteProc\fR [https://www\&.tcl-lang\&.org/man/tcl/TclLib/CrtObjCmd\&.htm] as the deletion function for the new command\&. \fBNULL\fR by default\&. |
| 562 |
.TP |
| 563 |
\fB-cname\fR \fIboolean\fR |
| 564 |
If \fBfalse\fR (the default), a name for the corresponding C function is |
| 565 |
automatically derived from the fully-qualified \fItclname\fR\&. Otherwise, name |
| 566 |
of the C function is the last component of \fItclname\fR\&. |
| 567 |
.RE |
| 568 |
.TP |
| 569 |
\fB::critcl::cdata\fR \fItclname\fR \fIdata\fR |
| 570 |
Appends the code to create a new Tcl command named \fItclname\fR which returns |
| 571 |
\fIdata\fR as a \fBByteArray\fR result\&. |
| 572 |
.sp |
| 573 |
Returns the empty string\&. |
| 574 |
.TP |
| 575 |
\fB::critcl::cconst\fR \fItclname\fR \fIresulttype\fR \fIvalue\fR |
| 576 |
Appends the code to create a new Tcl command named \fItclname\fR which returns |
| 577 |
the constant \fIvalue\fR having the Tcl type \fIresulttype\fR\&. \fIvalue\fR can |
| 578 |
be a C macro or a function \fIcall\fR (including the parentheses) to any |
| 579 |
visible C function that does not take arguments\&. |
| 580 |
Unlike \fBcritcl::cdata\fR, \fIresulttype\fR can be any type known to |
| 581 |
\fBcritcl::cproc\fR\&. |
| 582 |
Its semantics are equivalent to: |
| 583 |
.CS |
| 584 |
|
| 585 |
|
| 586 |
cproc $tclname {} $resulttype "return $value ;" |
| 587 |
|
| 588 |
.CE |
| 589 |
.sp |
| 590 |
This is more efficient than \fBcritcl::cproc\fR since there is no |
| 591 |
C function generated\&. |
| 592 |
.sp |
| 593 |
Returns the empty string\&. |
| 594 |
.TP |
| 595 |
\fB::critcl::cdefines\fR \fIlist of glob patterns\fR ?\fInamespace\fR? |
| 596 |
Arranges for \fIC enum\fR and \fI#define\fR values that match one of the |
| 597 |
patterns in \fIglob patterns\fR to be created in the namespace |
| 598 |
\fInamespace\fR, each variable having the same as the corresponding C item\&. |
| 599 |
The default namespace is the global namespace\&. A pattern that matches nothing |
| 600 |
is ignored\&. |
| 601 |
.sp |
| 602 |
The Tcl variables are created when the module is compiled, using the |
| 603 |
preprocessor in order to properly find all matching C definitions\&. |
| 604 |
.sp |
| 605 |
Produces no C code\&. The desired C definitions must already exist\&. |
| 606 |
.TP |
| 607 |
\fB::critcl::cproc\fR \fIname\fR \fIarguments\fR \fIresulttype\fR \fIbody\fR ?\fIoption\fR \fIvalue\fR\&.\&.\&.? |
| 608 |
Appends a function having \fIbody\fR as its body, another shim function to |
| 609 |
perform the needed conversions, and the code to create a corresponding Tcl |
| 610 |
command named \fItclname\fR\&. Unlike \fBcritcl::ccommand\fR the arguments and |
| 611 |
result are typed, and CriTcl generates the code to convert between Tcl_Obj |
| 612 |
values and C data types\&. |
| 613 |
See also \fBRuntime Behaviour\fR\&. |
| 614 |
.sp |
| 615 |
Returns the empty string\&. |
| 616 |
.sp |
| 617 |
.RS |
| 618 |
.TP |
| 619 |
string \fIoption\fR |
| 620 |
Each may be one of: |
| 621 |
.RS |
| 622 |
.TP |
| 623 |
\fB-cname\fR \fIboolean\fR |
| 624 |
If \fBfalse\fR (the default), a name for the corresponding C function is |
| 625 |
automatically derived from the fully-qualified \fItclname\fR\&. Otherwise, name |
| 626 |
of the C function is the last component of \fItclname\fR\&. |
| 627 |
.TP |
| 628 |
\fB-pass-cdata\fR \fIboolean\fR |
| 629 |
If \fBfalse\fR (the default), the shim function performing the conversion to |
| 630 |
and from Tcl level does not pass the ClientData as the first argument to |
| 631 |
the function\&. |
| 632 |
.TP |
| 633 |
\fB-arg-offset\fR \fIint\fR |
| 634 |
A non-negative integer, \fB0\fR by default, indicating the number of hidden |
| 635 |
arguments preceding the actual procedure arguments\&. Used by higher-order code |
| 636 |
generators where there are prefix arguments which are not directly seen by the |
| 637 |
function but which influence argument counting and extraction\&. |
| 638 |
.RE |
| 639 |
.TP |
| 640 |
string \fIresulttype\fR |
| 641 |
May be a predefined or a custom type\&. |
| 642 |
See \fICriTcl cproc Type Reference\fR for the full list of predefined types and how to |
| 643 |
extend them\&. |
| 644 |
Unless otherwise noted, the Tcl return code is always \fBTCL_OK\fR\&. |
| 645 |
.TP |
| 646 |
list \fIarguments\fR |
| 647 |
Is a multi-dictionary where each key is an |
| 648 |
argument type and its value is the argument name\&. |
| 649 |
For example: |
| 650 |
.CS |
| 651 |
|
| 652 |
int x int y |
| 653 |
.CE |
| 654 |
.sp |
| 655 |
Each argument name must be a valid C identifier\&. |
| 656 |
.sp |
| 657 |
If the name is a list containing two items, the first item is the name |
| 658 |
and the second item is the default value\&. A limited form of variadic arguments |
| 659 |
can be accomplished using such default values\&. |
| 660 |
For example: |
| 661 |
.CS |
| 662 |
|
| 663 |
int {x 1} |
| 664 |
.CE |
| 665 |
.IP |
| 666 |
Here \fIx\fR is an optional argument of type \fBint\fR with a default |
| 667 |
value of \fB1\fR\&. |
| 668 |
.sp |
| 669 |
Argument conversion is completely bypassed when the argument is not |
| 670 |
provided, so a custom converter doing validation does not get the chance to |
| 671 |
validate the default value\&. In this case, the value should be checked in the |
| 672 |
body of the function\&. |
| 673 |
.sp |
| 674 |
Each argument type may be a predefined or custom type\&. |
| 675 |
See \fICriTcl cproc Type Reference\fR for the full list of predefined types and how to |
| 676 |
extend them\&. |
| 677 |
.RE |
| 678 |
.TP |
| 679 |
\fB::critcl::cproc\fR \fIname\fR \fIarguments\fR \fIresulttype\fR |
| 680 |
As documented below, but used when the C function named \fIname\fR already |
| 681 |
exists\&. |
| 682 |
.TP |
| 683 |
\fB::critcl::cinit\fR \fItext\fR \fIexternals\fR |
| 684 |
Appends the C code in \fItext\fR and \fIexternals\fR, but only after all the |
| 685 |
other fragments appended by the previously-listed commands regardless of their |
| 686 |
placement in the \fICriTcl script\fR relative to this command\&. Thus, all |
| 687 |
their content is visible\&. See also \fBRuntime Behaviour\fR\&. |
| 688 |
.sp |
| 689 |
The C code in \fItext\fR is placed into the body of the initialization |
| 690 |
function of the shared library backing the \fICriTcl script\fR, and is |
| 691 |
executed when this library is loaded into the interpreter\&. It has access to |
| 692 |
the variable \fBTcl_Interp* interp\fR referencing the Tcl interpreter currently |
| 693 |
being initialized\&. |
| 694 |
.sp |
| 695 |
\fIexternals\fR is placed outside and just before the initialization |
| 696 |
function, making it a good place for any external symbols required by |
| 697 |
initialization function, but which should not be accessible by any other parts |
| 698 |
of the C code\&. |
| 699 |
.sp |
| 700 |
Calls to this command are cumulative\&. |
| 701 |
.sp |
| 702 |
Returns the empty string\&. |
| 703 |
.TP |
| 704 |
\fB::critcl::include\fR \fIpath\fR |
| 705 |
This command is a convenient shorthand for |
| 706 |
.CS |
| 707 |
|
| 708 |
|
| 709 |
critcl::code { |
| 710 |
#include <${path}> |
| 711 |
} |
| 712 |
|
| 713 |
.CE |
| 714 |
.PP |
| 715 |
.SS "STUBS TABLE MANAGEMENT" |
| 716 |
CriTcl versions 3 and later provide \fBcritcl::api\fR to create and manipulate |
| 717 |
stubs tables, Tcl's dynamic linking mechanism handling the resolution of |
| 718 |
symbols between C extensions\&. |
| 719 |
See \fIhttp://wiki\&.tcl-lang\&.org/285\fR |
| 720 |
for an introduction, and section \fBStubs Tables\fR |
| 721 |
for the details of CriTcl's particular variant\&. |
| 722 |
.PP |
| 723 |
Importing stubs tables, i\&.e\&. APIs, from another extension: |
| 724 |
.TP |
| 725 |
\fB::critcl::api\fR \fBimport\fR \fIname\fR \fIversion\fR |
| 726 |
Adds the following include directives into the \fICriTcl script\fR |
| 727 |
\fIand\fR each of its companion "\fI\&.c\fR" files: |
| 728 |
.RS |
| 729 |
.IP [1] |
| 730 |
#include <\fBname\fR/\fBname\fRDecls\&.h> |
| 731 |
.IP [2] |
| 732 |
#include <\fBname\fR/\fBname\fRStubLib\&.h> |
| 733 |
.RE |
| 734 |
.IP |
| 735 |
Returns an error if "\fI\fBname\fR\fR" isn't in the search path for the |
| 736 |
compiler\&. See \fBcritcl::cheaders\fR and the critcl application's \fB-I\fR |
| 737 |
and \fB-includedir\fR options\&. |
| 738 |
.sp |
| 739 |
\fIImportant:\fR If \fBname\fR is a fully-qualified name in a |
| 740 |
non-global namespace, e\&.g\&. |
| 741 |
"c::stack", the namespace separators "::" are converted into underscores |
| 742 |
("_") in path names, C code, etc\&. |
| 743 |
.sp |
| 744 |
\fBname\fR/\fBname\fRDecls\&.h contains the stubs table type declarations, |
| 745 |
mapping macros, etc\&., and may include package-specific headers\&. See |
| 746 |
\fBcritcl::api header\fR, below\&. An \fI#include\fR directive is added at |
| 747 |
the beginning of the generated code for \fICriTcl script\fR and at the |
| 748 |
beginning of each of its companion "\fI\&.c\fR" files\&. |
| 749 |
.sp |
| 750 |
\fBname\fR/\fBname\fRStubLib\&.h contains the stubs table variable |
| 751 |
definition and the function to initialize it\&. An \fI#include\fR directive |
| 752 |
for it is added to the initialization code for the \fICriTcl script\fR , |
| 753 |
along with a call to the initializer function\&. |
| 754 |
.sp |
| 755 |
If "\fI\fBname\fR/\fBname\fR\&.decls\fR" accompanies |
| 756 |
\fBname\fR/\fBname\fRDecls\&.h, it should contain the external representation of |
| 757 |
the stubs table used to generate the headers\&. The file is read and the internal |
| 758 |
representation of the stubs table returned for use by the importing package\&. |
| 759 |
Otherwise, the empy string is returned\&. |
| 760 |
.sp |
| 761 |
One possible use would be the automatic generation of C code |
| 762 |
calling on the functions listed in the imported API\&. |
| 763 |
.sp |
| 764 |
When generating a TEA package the names of the imported APIs |
| 765 |
are used to declare \fBconfigure\fR options with which the user can |
| 766 |
declare a non-standard directory for the headers of the API\&. Any API |
| 767 |
\fBname\fR is translated into a single configure option |
| 768 |
\fB--with-\fBname\fR-include\fR\&. |
| 769 |
.PP |
| 770 |
.PP |
| 771 |
Declaration and export of a stubs table, i\&.e\&. API, for |
| 772 |
the \fICriTcl script\fR: |
| 773 |
.TP |
| 774 |
\fB::critcl::api\fR \fBfunction\fR \fIresulttype\fR \fIname\fR \fIarguments\fR |
| 775 |
Adds to the public API of the \fICriTcl script\fR the signature |
| 776 |
for the function named \fIname\fR and having the signature specified by |
| 777 |
\fIarguments\fR and \fIresulttype\fR\&. Code is generated for a "\fI\&.decls\fR" |
| 778 |
file, the corresponding public headers, and a stubs table usable by |
| 779 |
\fBcritcl::api import\fR\&. |
| 780 |
.sp |
| 781 |
\fIarguments\fR is a multidict where each key is an argument type and its |
| 782 |
value is the argument name, and \fIresulttype\fR is a C type\&. |
| 783 |
.TP |
| 784 |
\fB::critcl::api\fR \fBheader\fR ?\fIglob pattern\fR\&.\&.\&.? |
| 785 |
Each file matching a \fIglob pattern\fR is copied into the directory |
| 786 |
containing the generated headers, and an \fI#include\fR directive for it is |
| 787 |
added to "\fIDecls\&.h\fR" for the \fICriTcl script\fR\&. |
| 788 |
Returns an error if a \fIglob pattern\fR matches nothing\&. |
| 789 |
.sp |
| 790 |
A pattern for a relative path is resolved relative to the directory |
| 791 |
containing the \fICriTcl script\fR\&. |
| 792 |
.TP |
| 793 |
\fB::critcl::api\fR \fBextheader\fR ?\fIfile\fR\&.\&.\&.? |
| 794 |
Like \fB::critcl::api header\fR, but each \fIfile\fR should exist in the |
| 795 |
external development environment\&. An \fI#include\fR directive is added to |
| 796 |
"\fI\fBfoo\fRDecls\&.h\fR", but \fIfile\fR is not copied to the package header |
| 797 |
directory\&. \fIfile\fR is not a glob pattern as CriTcl has no context, |
| 798 |
i\&.e directory, in which to expand such patterns\&. |
| 799 |
.PP |
| 800 |
As with the headers for an imported API, an \fI#include\fR directive is |
| 801 |
added to the generated code for the \fICriTcl script\fR and to |
| 802 |
each companion "\fI\&.c\fR" file\&. |
| 803 |
.PP |
| 804 |
In "compile & run" mode the generated header files and any companion |
| 805 |
headers are placed in the \fBResult Cache\fR subdirectory for the |
| 806 |
\fICriTcl script\fR\&. This directory is added to the include search path of |
| 807 |
any other package importing this API and and building in mode "compile & run"\&. |
| 808 |
.PP |
| 809 |
In "generate package" mode \fB-includedir\fR specifies the |
| 810 |
subdirectory in the package to place the generated headers in\&. This |
| 811 |
directory is added to the search paths for header files, ensuring that a |
| 812 |
package importing an API finds it if the package exporting that API used the |
| 813 |
same setting for \fB-includedir\fR\&. |
| 814 |
.PP |
| 815 |
In "generate TEA" mode the static scanner recognizes |
| 816 |
\fBcritcl::api header\fR as a source of companion files\&. |
| 817 |
It also uses data from calls to \fBcritcl::api import\fR to |
| 818 |
add support for \fB--with-\fBfoo\fR-include\fR options into the |
| 819 |
generated "\fIconfigure(\&.in)\fR" so that a user may specify custom |
| 820 |
locations for the headers of any imported API\&. |
| 821 |
.SS "PACKAGE META DATA" |
| 822 |
CriTcl versions 3 and later can create TEApot meta-data to be placed into |
| 823 |
"\fIteapot\&.txt\fR" in a format suitable for use by the |
| 824 |
\fITEApot tools\fR [http://docs\&.activestate\&.com/activetcl/8\&.5/tpm/toc\&.html]\&. |
| 825 |
.PP |
| 826 |
In version 2, some meta data support was already present through |
| 827 |
\fB::critcl::license\fR, but this was only used to generate "\fIlicense\&.txt\fR"\&. |
| 828 |
.TP |
| 829 |
\fB::critcl::license\fR \fIauthor\fR ?\fItext\fR\&.\&.\&.? |
| 830 |
Ignored in "compile & run" mode\&. |
| 831 |
.sp |
| 832 |
In "generate package" mode provides information about the author of the |
| 833 |
package and the license for the package\&. |
| 834 |
.sp |
| 835 |
\fItext\fR arguments are concatenated to form the text of the license, which is |
| 836 |
written to "\fIlicense\&.terms\fR" in the same directory as "\fIpkgIndex\&.tcl\fR"\&. |
| 837 |
If no \fItext\fR is provided the license is read from "\fIlicense\&.terms\fR" |
| 838 |
in the same directory as the \fICriTcl script\fR\&. |
| 839 |
.sp |
| 840 |
This information takes precedence over any information specified through |
| 841 |
the generic API \fB::critcl::meta\fR\&. It is additionally placed |
| 842 |
into the meta data file "\fIteapot\&.txt\fR" under the keys \fIas::author\fR and |
| 843 |
\fIlicense\fR\&. |
| 844 |
.TP |
| 845 |
\fB::critcl::summary\fR \fItext\fR |
| 846 |
Ignored in "compile & run" mode\&. |
| 847 |
.sp |
| 848 |
In "generate package" mode places a short, preferably one-line description of |
| 849 |
the package into the meta data file "\fIteapot\&.txt\fR" under the key |
| 850 |
\fIsummary\fR\&. This information takes precedence over information specified |
| 851 |
through the generic API \fB::critcl::meta\fR\&. |
| 852 |
.TP |
| 853 |
\fB::critcl::description\fR \fItext\fR |
| 854 |
Ignored in "compile & run" mode\&. |
| 855 |
.sp |
| 856 |
In "generate package" mode places a longer description of the package into the |
| 857 |
meta data file "\fIteapot\&.txt\fR", under the key \fIdescription\fR\&. The data |
| 858 |
specified by this command takes precedence over any information specified |
| 859 |
through the generic API \fB::critcl::meta\fR\&. |
| 860 |
.TP |
| 861 |
\fB::critcl::subject\fR ?\fIkey\fR\&.\&.\&.? |
| 862 |
Ignored in "compile & run" mode\&. |
| 863 |
.sp |
| 864 |
In "generate package" mode places each \fIkey\fR into the meta data file |
| 865 |
"\fIteapot\&.txt\fR", under the key \fIsubject\fR\&. This information takes |
| 866 |
precedence over any information specified through the generic API |
| 867 |
\fB::critcl::meta\fR\&. |
| 868 |
.sp |
| 869 |
Calls to this command are cumulative\&. |
| 870 |
.TP |
| 871 |
\fB::critcl::meta\fR \fIkey\fR ?\fIword\fR\&.\&.\&.? |
| 872 |
Provides arbitrary meta data outside of the following reserved keys: |
| 873 |
\fIas::author\fR, |
| 874 |
\fIas::build::date\fR, |
| 875 |
\fIdescription\fR, |
| 876 |
\fIlicense\fR, |
| 877 |
\fIname\fR, |
| 878 |
\fIplatform\fR, |
| 879 |
\fIrequire\fR |
| 880 |
\fIsubject\fR, |
| 881 |
\fIsummary\fR, and |
| 882 |
\fIversion\fR, |
| 883 |
Its behaviour is like \fB::critcl::subject\fR in that it treats all |
| 884 |
keys as list of words, with each call providing one or more words for |
| 885 |
the key, and multiple calls extending the data for an existing key, if |
| 886 |
not reserved\&. |
| 887 |
.sp |
| 888 |
While it is possible to declare information for one of the |
| 889 |
reserved keys with this command such data is ignored when the final |
| 890 |
meta data is assembled and written\&. |
| 891 |
.sp |
| 892 |
Use the commands |
| 893 |
\fB::critcl::license\fR, |
| 894 |
\fB::critcl::summary\fR, |
| 895 |
\fB::critcl::description\fR |
| 896 |
\fB::critcl::subject\fR, |
| 897 |
\fBpackage require\fR, and |
| 898 |
\fBpackage provide\fR |
| 899 |
to declare data for the reserved keys\&. |
| 900 |
.sp |
| 901 |
The information for the reserved keys |
| 902 |
\fIas::build::date\fR and |
| 903 |
\fIplatform\fR |
| 904 |
is automatically generated by \fBcritcl\fR itself\&. |
| 905 |
.TP |
| 906 |
\fB::critcl::meta?\fR \fIkey\fR |
| 907 |
Returns the value in the metadata associated with \fIkey\fR\&. |
| 908 |
.sp |
| 909 |
Used primarily to retrieve the name of the package |
| 910 |
from within utility packages having to adapt C code templates to their |
| 911 |
environment\&. For example, \fBcritcl::class\fR uses does this\&. |
| 912 |
.TP |
| 913 |
\fB::critcl::buildrequirement\fR \fIscript\fR |
| 914 |
Provides control over the capturing of dependencies declared via |
| 915 |
\fBpackage require\fR\&. \fIscript\fR is evaluated and any dependencies |
| 916 |
declared within are ignored, i\&.e\&. not recorded in the meta data\&. |
| 917 |
.PP |
| 918 |
.SS "CONTROL & INTERFACE" |
| 919 |
These commands control the details of compilation and linking a |
| 920 |
\fICriTcl script\fR\&. The information is used only to compile/link the |
| 921 |
object for the \fICriTcl script\fR\&. For example, information for |
| 922 |
"\fIFOO\&.tcl\fR" is kept separate from information for "\fIBAR\&.tcl\fR"\&. |
| 923 |
.TP |
| 924 |
\fB::critcl::cheaders\fR ?\fIarg\fR\&.\&.\&.? |
| 925 |
Provides additional header locations\&. |
| 926 |
.sp |
| 927 |
Each argument is a glob pattern\&. If an argument begins with \fB-\fR |
| 928 |
it is an argument to the compiler\&. Otherwise the parent directory of each |
| 929 |
matching path is a directory to be searched for header files\&. Returns an |
| 930 |
error if a pattern matches no files\&. |
| 931 |
A pattern for a relative path is resolved relative to the directory |
| 932 |
containing the \fICriTcl script\fR\&. |
| 933 |
.sp |
| 934 |
\fB#include\fR lines are not automatically generated for matching |
| 935 |
header files\&. Use \fBcritcl::include\fR or \fBcritcl::ccode\fR as necessary to |
| 936 |
add them\&. |
| 937 |
.sp |
| 938 |
Calls to this command are cumulative\&. |
| 939 |
.TP |
| 940 |
\fB::critcl::csources\fR ?\fIglob pattern\fR\&.\&.\&.? |
| 941 |
Matching paths become inputs to the compilation of the current object |
| 942 |
along with the sources for the current \fICriTcl script\fR\&. Returns an |
| 943 |
error if no paths match a pattern\&. |
| 944 |
A pattern for a relative path is resolved relative to the directory |
| 945 |
containing the \fICriTcl script\fR\&. |
| 946 |
.sp |
| 947 |
Calls to this command are cumulative\&. |
| 948 |
.TP |
| 949 |
\fB::critcl::clibraries\fR ?\fIglob pattern\fR\&.\&.\&.? |
| 950 |
provides the link step with additional libraries and library locations\&. |
| 951 |
A \fIglob pattern\fR that begins with \fB-\fR is added as an argument to |
| 952 |
the linker\&. Otherwise matching files are linked into the shared library\&. |
| 953 |
Returns an error if no paths match a pattern\&. |
| 954 |
A pattern for a relative path is resolved relative to the directory |
| 955 |
containing the \fICriTcl script\fR\&. |
| 956 |
.sp |
| 957 |
Calls to this command are cumulative\&. |
| 958 |
.TP |
| 959 |
\fB::critcl::source\fR \fIglob pattern\fR |
| 960 |
Evaluates as scripts the files matching each \fIglob pattern\fR\&. Returns an |
| 961 |
error if there are no matching files\&. |
| 962 |
A pattern for a relative path is resolved relative to the directory |
| 963 |
containing the \fICriTcl script\fR\&. |
| 964 |
.TP |
| 965 |
\fB::critcl::tsources\fR \fIglob pattern\fR\&.\&.\&. |
| 966 |
Provides the information about additional Tcl script files to source when the |
| 967 |
shared library is loaded\&. |
| 968 |
.sp |
| 969 |
Matching paths are made available to the generated shared library when |
| 970 |
it is loaded for the current \fICriTcl script\fR\&. Returns an error if a |
| 971 |
pattern matches no files\&. |
| 972 |
A pattern for a relative path is resolved relative to the directory |
| 973 |
containing the \fICriTcl script\fR\&. |
| 974 |
.sp |
| 975 |
Calls to this command are cumulative\&. |
| 976 |
.sp |
| 977 |
After the shared library has been loaded, the declared files are sourced |
| 978 |
in the same order that they were provided as arguments\&. |
| 979 |
.TP |
| 980 |
\fB::critcl::owns\fR \fIglob pattern\fR\&.\&.\&. |
| 981 |
Ignored in "compile and run" and "generate package" modes\&. |
| 982 |
In "generate TEA" mode each file matching a \fIglob pattern\fR is a file to |
| 983 |
be included in the TEA extension but that could not be ascertained as such from |
| 984 |
previous commands like \fBcritcl::csources\fR and \fBcritcl::tsources\fR, |
| 985 |
either because of they were specified dynamically or because they were directly |
| 986 |
sourced\&. |
| 987 |
.TP |
| 988 |
\fB::critcl::cflags\fR ?\fIarg\fR\&.\&.\&.? |
| 989 |
.sp |
| 990 |
Each \fIarg\fR is an argument to the compiler\&. |
| 991 |
.sp |
| 992 |
Calls to this command are cumulative\&. |
| 993 |
.TP |
| 994 |
\fB::critcl::ldflags\fR ?\fIarg\fR\&.\&.\&.? |
| 995 |
.sp |
| 996 |
Each \fIarg\fR is an argument to the linker\&. |
| 997 |
.sp |
| 998 |
Calls to this command are cumulative\&. |
| 999 |
.TP |
| 1000 |
\fB::critcl::framework\fR ?\fIarg\fR\&.\&.\&.? |
| 1001 |
Each \fIarg\fR is the name of a framework to link on MacOS X\&. This command is |
| 1002 |
ignored if OS X is not the target so that frameworks can be specified |
| 1003 |
unconditionally\&. |
| 1004 |
.sp |
| 1005 |
Calls to this command are cumulative\&. |
| 1006 |
.TP |
| 1007 |
\fB::critcl::tcl\fR \fIversion\fR |
| 1008 |
Specifies the minimum version of the Tcl runtime |
| 1009 |
to compile and link the package for\&. The default is \fB8\&.4\fR\&. |
| 1010 |
.TP |
| 1011 |
\fB::critcl::tk\fR |
| 1012 |
Arranges to include the Tk headers and link to the Tk stubs\&. |
| 1013 |
.TP |
| 1014 |
\fB::critcl::preload\fR \fIlib\fR\&.\&.\&. |
| 1015 |
Arranges for the external shared library \fIlib\fR to be loaded |
| 1016 |
before the shared library for the \fICriTcl script\fR is loaded\&. |
| 1017 |
.sp |
| 1018 |
Calls to this command are cumulative\&. |
| 1019 |
.sp |
| 1020 |
Each library \fIFOO\fR is searched for in the directories listed below, in the order |
| 1021 |
listed\&. The search stops at the first existing path\&. |
| 1022 |
Additional notes: |
| 1023 |
.RS |
| 1024 |
.IP \(bu |
| 1025 |
\fBplatform\fR is the placeholder for the target platform of the package\&. |
| 1026 |
.IP \(bu |
| 1027 |
The extension "\fI\&.so\fR" is the placeholder for whatever actual extension is used by the target platform for its shared libraries\&. |
| 1028 |
.IP \(bu |
| 1029 |
The search is relative to the current working directory\&. |
| 1030 |
.RE |
| 1031 |
.IP |
| 1032 |
And now the paths, depending on the exact form of the library name: |
| 1033 |
.RS |
| 1034 |
.TP |
| 1035 |
FOO |
| 1036 |
.RS |
| 1037 |
.IP [1] |
| 1038 |
FOO\&.so |
| 1039 |
.IP [2] |
| 1040 |
FOO/FOO\&.so |
| 1041 |
.IP [3] |
| 1042 |
FOO/\fBplatform\fR/FOO\&.so |
| 1043 |
.RE |
| 1044 |
.TP |
| 1045 |
PATH/FOO |
| 1046 |
The exact set searched depends on the existence of |
| 1047 |
directory "\fIPATH/FOO\fR"\&. If it exists, critcl searches |
| 1048 |
.RS |
| 1049 |
.IP [1] |
| 1050 |
FOO\&.so |
| 1051 |
.IP [2] |
| 1052 |
PATH/FOO/FOO\&.so |
| 1053 |
.IP [3] |
| 1054 |
PATH/FOO/\fBplatform\fR/FOO\&.so |
| 1055 |
.RE |
| 1056 |
.IP |
| 1057 |
Otherwise it searches |
| 1058 |
.RS |
| 1059 |
.IP [1] |
| 1060 |
FOO\&.so |
| 1061 |
.IP [2] |
| 1062 |
PATH/FOO\&.so |
| 1063 |
.IP [3] |
| 1064 |
PATH/\fBplatform\fR/FOO\&.so |
| 1065 |
.RE |
| 1066 |
.IP |
| 1067 |
instead\&. |
| 1068 |
.TP |
| 1069 |
/PATH/FOO |
| 1070 |
Even when specifying FOO with an absolute path the first path searched |
| 1071 |
is relative to the current working directory\&. |
| 1072 |
.RS |
| 1073 |
.IP [1] |
| 1074 |
FOO\&.so |
| 1075 |
.IP [2] |
| 1076 |
/PATH/FOO\&.so |
| 1077 |
.IP [3] |
| 1078 |
/PATH/\fBplatform\fR/FOO\&.so |
| 1079 |
.RE |
| 1080 |
.RE |
| 1081 |
.IP |
| 1082 |
For developers who want to understand or modify the internals of the |
| 1083 |
\fBcritcl\fR package, \fBPreloading functionality\fR explains how |
| 1084 |
preloading is implemented\&. |
| 1085 |
.TP |
| 1086 |
\fB::critcl::debug\fR \fIarea\fR\&.\&.\&. |
| 1087 |
Specifies what debugging features to activate\&. Internally each area is translated into |
| 1088 |
area-specific flags for the compiler which are then handed over to |
| 1089 |
\fBcritcl::cflags\fR\&. |
| 1090 |
.RS |
| 1091 |
.TP |
| 1092 |
\fBmemory\fR |
| 1093 |
Specifies Tcl memory debugging\&. |
| 1094 |
.TP |
| 1095 |
\fBsymbols\fR |
| 1096 |
Specifies compilation and linking with debugging symbols for use by a debugger |
| 1097 |
or other tool\&. |
| 1098 |
.TP |
| 1099 |
\fBall\fR |
| 1100 |
Specifies all available debugging\&. |
| 1101 |
.RE |
| 1102 |
.PP |
| 1103 |
.SS INTROSPECTION |
| 1104 |
The following commands control compilation and linking\&. |
| 1105 |
.TP |
| 1106 |
\fB::critcl::check\fR ?\fIlabel\fR? \fItext\fR |
| 1107 |
Returns a \fBtrue\fR if the C code in \fItext\fR compiles sucessfully, and |
| 1108 |
\fBfalse\fR otherwise\&. Used to check for availability of features in the |
| 1109 |
build environment\&. |
| 1110 |
If provided, \fIlabel\fR is used to uniquely mark the results in the generated |
| 1111 |
log\&. |
| 1112 |
.TP |
| 1113 |
\fB::critcl::checklink\fR ?\fIlabel\fR? \fItext\fR |
| 1114 |
Like \fBcritcl::check\fR but also links the compiled objects, returning |
| 1115 |
\fBtrue\fR if the link is successful and \fBfalse\fR otherwise\&. |
| 1116 |
If specified, \fIlabel\fR is used to uniquely mark the results in the generated |
| 1117 |
log\&. |
| 1118 |
.TP |
| 1119 |
\fB::critcl::msg\fR ?\fB-nonewline\fR? \fImsg\fR |
| 1120 |
Scripts using \fBcritcl::check\fR and \fBcritcl::checklink\fR can use this |
| 1121 |
command to report results\&. Does nothing in \fIcompile & run\fR mode\&. Tools |
| 1122 |
like the \fICriTcl Aplication\fR may redefine this command to implement |
| 1123 |
their own message reporting\&. For example, \fBcritcl::app\fR and any |
| 1124 |
packages built on it print messages to \fIstdout\fR\&. |
| 1125 |
.TP |
| 1126 |
\fB::critcl::print\fR ?\fB-nonewline\fR? ?\fIchan\fR? \fImsg\fR |
| 1127 |
Used by the CriTcl internals to report activity\&. By default, effectively the |
| 1128 |
same thing as \fB::puts\fR\&. Tools directly using either the CriTcl package or |
| 1129 |
the CriTcl application package may redefine this procedure to implement their |
| 1130 |
own output functionality\&. |
| 1131 |
.sp |
| 1132 |
For example, the newest revisions of |
| 1133 |
\fIKettle\fR [https://chiselapp\&.com/user/andreas_kupries/repository/Kettle/index] |
| 1134 |
use this to highlight build warnings\&. |
| 1135 |
.TP |
| 1136 |
\fB::critcl::compiled\fR |
| 1137 |
Returns \fBtrue\fR if the current \fICriTcl script\fR is already compiled |
| 1138 |
and \fBfalse\fR otherwise\&. |
| 1139 |
.sp |
| 1140 |
Enables a \fICriTcl script\fR used as its own Tcl companion file (see |
| 1141 |
\fBcritcl::tsources\fR) to distinguish between being sourced for compilation in |
| 1142 |
\fIcompile & run\fR mode and being sourced from either the result of |
| 1143 |
\fIgenerate package\fR mode or during the load phase of |
| 1144 |
\fIcompile & run\fR mode\&. |
| 1145 |
The result is \fBfalse\fR in the first case and \fBtrue\fR in the later two |
| 1146 |
cases\&. |
| 1147 |
.TP |
| 1148 |
\fB::critcl::compiling\fR |
| 1149 |
Returns \fBtrue\fR if a working C compiler is available and \fBfalse\fR |
| 1150 |
otherwise\&. |
| 1151 |
.TP |
| 1152 |
\fB::critcl::done\fR |
| 1153 |
Returns \fBtrue\fR when \fICriTcl script\fR has been built and |
| 1154 |
\fBfalse\fR otherwise\&. Only useful from within a \fICriTcl script\fR\&. |
| 1155 |
Enables the Tcl parts of a \fICriTcl script\fR to distinguish between |
| 1156 |
\fIprebuilt package\fR mode and \fIcompile & run\fR mode\&. |
| 1157 |
.sp |
| 1158 |
See also \fBModes Of Operation/Use\fR\&. |
| 1159 |
.TP |
| 1160 |
\fB::critcl::failed\fR |
| 1161 |
Returns \fBtrue\fR if the \fICriTcl script\fR could not be built, and |
| 1162 |
\fBfalse\fR otherwise\&. Forces the building of the package if it hasn't |
| 1163 |
already been done, but not its loading\&. Thus, a \fICriTcl script\fR can |
| 1164 |
check itself for availability of the compiled components\&. Only useful from |
| 1165 |
within a \fICriTcl script\fR\&. |
| 1166 |
.TP |
| 1167 |
\fB::critcl::load\fR |
| 1168 |
Like \fBcritcl::failed\fR except that it also forces the loading of the |
| 1169 |
generated shared library, and that it returns \fBtrue\fR on success and |
| 1170 |
\fBfalse\fR on failure\&. Thus, a \fICriTcl script\fR can check itself for |
| 1171 |
availability of the compiled components\&. Only useful from within a |
| 1172 |
\fICriTcl script\fR\&. |
| 1173 |
.PP |
| 1174 |
.SS "BUILD MANAGEMENT" |
| 1175 |
The following command manages global settings, i\&.e\&. configuration options which |
| 1176 |
are independent of any \fICriTcl script\fR\&. |
| 1177 |
.PP |
| 1178 |
This command should not be needed to write a \fICriTcl script\fR\&. It is |
| 1179 |
a management command which is only useful to the \fICriTcl Application\fR |
| 1180 |
or similar tools\&. |
| 1181 |
.TP |
| 1182 |
\fB::critcl::config\fR \fIoption\fR ?\fIval\fR? |
| 1183 |
Sets and returns the following global configuration options: |
| 1184 |
.RS |
| 1185 |
.TP |
| 1186 |
\fBforce\fR bool |
| 1187 |
When \fBfalse\fR (the default), the C files are not built if there is a |
| 1188 |
cached shared library\&. |
| 1189 |
.TP |
| 1190 |
\fBlines\fR bool |
| 1191 |
When \fBtrue\fR (the default), #line directives are embedded into the |
| 1192 |
generated C code\&. |
| 1193 |
.sp |
| 1194 |
This facility requires the use of a tclsh that provides |
| 1195 |
\fBinfo frame\fR\&. Otherwise, no \fI#line\fR directives are emitted\&. The |
| 1196 |
command is supported by Tcl 8\&.5 and higher\&. It is also supported by |
| 1197 |
Tcl 8\&.4 provided that it was compiled with the define |
| 1198 |
\fB-DTCL_TIP280\fR\&. An example of such is ActiveState's ActiveTcl\&. |
| 1199 |
.sp |
| 1200 |
Developers of higher-level packages generating their own C |
| 1201 |
code, either directly or indirectly through critcl, should |
| 1202 |
also read section \fBAdvanced: Location management\fR to see how |
| 1203 |
critcl helps them in generating their directives\&. |
| 1204 |
Examples of such packages come with critcl itself\&. See |
| 1205 |
\fBcritcl::iassoc\fR and \fBcritcl::class\fR\&. |
| 1206 |
.TP |
| 1207 |
\fBtrace\fR bool |
| 1208 |
When \fBfalse\fR (the default), no code tracing the entry and exit of |
| 1209 |
CriTcl-backed commands in the \fICriTcl script\fR is inserted\&. Insertion of |
| 1210 |
such code implicitly activates the tracing facility in general\&. See |
| 1211 |
\fBcritcl::cutil\fR\&. |
| 1212 |
.TP |
| 1213 |
\fBI\fR path |
| 1214 |
A single global include path to use for all files\&. Not set by default\&. |
| 1215 |
.TP |
| 1216 |
\fBcombine\fR enum |
| 1217 |
.RS |
| 1218 |
.TP |
| 1219 |
\fBdynamic\fR (the default) |
| 1220 |
Object files have the suffix \fB_pic\fR\&. |
| 1221 |
.TP |
| 1222 |
\fBstatic\fR |
| 1223 |
Object files have the suffix \fB_stub\fR\&. |
| 1224 |
.TP |
| 1225 |
\fBstandalone\fR |
| 1226 |
Object files have no suffix, and the generated C files are compiled |
| 1227 |
without using Tcl/Tk stubs\&. The result are object files usable for |
| 1228 |
static linking into a \fIbig shell\fR\&. |
| 1229 |
.RE |
| 1230 |
.TP |
| 1231 |
\fBlanguage\fR string |
| 1232 |
.TP |
| 1233 |
\fBkeepsrc\fR bool |
| 1234 |
When \fBfalse\fR (the default), the generated "\fI\&.c\fR" |
| 1235 |
files are deleted after the "\fI\&.o\fR" files have been built\&. |
| 1236 |
.TP |
| 1237 |
\fBoutdir\fR directory |
| 1238 |
The directory where to place a generated shared library\&. By default, it is |
| 1239 |
placed into the \fBResult Cache\fR\&. |
| 1240 |
.RE |
| 1241 |
.PP |
| 1242 |
.SS "RESULT CACHE MANAGEMENT" |
| 1243 |
The following commands control the \fBResult Cache\fR\&. |
| 1244 |
These commands are not needed to simply write a \fICriTcl script\fR\&. |
| 1245 |
.TP |
| 1246 |
\fB::critcl::cache\fR ?path? |
| 1247 |
Sets and returns the path to the directory for the package's result cache\&. |
| 1248 |
.sp |
| 1249 |
The default location is |
| 1250 |
"\fI~/\&.critcl/[platform::generic]\fR" and usually does not |
| 1251 |
require any changes\&. |
| 1252 |
.TP |
| 1253 |
\fB::critcl::clean_cache\fR ?\fIpattern\fR\&.\&.\&.? |
| 1254 |
Cleans the result cache, i\&.e\&. removes any and all files |
| 1255 |
and directories in it\&. If one or more patterns are specified then only |
| 1256 |
the files and directories matching them are removed\&. |
| 1257 |
.PP |
| 1258 |
.SS "BUILD CONFIGURATION" |
| 1259 |
The following commands manage the build configuration, i\&.e\&. the per-platform |
| 1260 |
information about compilers, linkers, and their commandline options\&. |
| 1261 |
These commands are not needed to simply write a \fICriTcl script\fR\&. |
| 1262 |
.TP |
| 1263 |
\fB::critcl::readconfig\fR \fIpath\fR |
| 1264 |
Reads the build configuration file at \fIpath\fR and configures the package |
| 1265 |
using the information for the target platform\&. |
| 1266 |
.TP |
| 1267 |
\fB::critcl::showconfig\fR ?\fIchan\fR? |
| 1268 |
Converts the active build configuration into a human-readable string and |
| 1269 |
returns it, or if \fIchan\fR is provided prints the result to that channel\&. |
| 1270 |
.TP |
| 1271 |
\fB::critcl::showallconfig\fR ?\fIchan\fR? |
| 1272 |
Converts the set of all known build configurations from the currently active |
| 1273 |
build configuration file last set with \fBcritcl::readconfig\fR into a string |
| 1274 |
and returns it, or if \fIchan\fR is provided, prints it to that channel\&. |
| 1275 |
.TP |
| 1276 |
\fB::critcl::chooseconfig\fR \fItarget\fR ?\fInomatcherr\fR? |
| 1277 |
Matches \fItarget\fR against all known targets, returning a list containing |
| 1278 |
all the matching ones\&. This search is first done on an exact basis, and then |
| 1279 |
via glob matching\&. If no known target matches the argument the default is to |
| 1280 |
return an empty list\&. However, if the boolean \fInomatcherr\fR is specified and |
| 1281 |
set an error is thrown using \fBcritcl::error\fR instead\&. |
| 1282 |
.TP |
| 1283 |
\fB::critcl::setconfig\fR \fItarget\fR |
| 1284 |
Configures the package to use the settings of \fItarget\fR\&. |
| 1285 |
.PP |
| 1286 |
.SS "TOOL API" |
| 1287 |
The following commands provide tools like |
| 1288 |
\fICriTcl Application\fR or similar with |
| 1289 |
deeper access to the package's internals\&. |
| 1290 |
These commands are not needed to simply write a \fICriTcl script\fR\&. |
| 1291 |
.TP |
| 1292 |
\fB::critcl::actualtarget\fR |
| 1293 |
Returns the platform identifier for the target platform, i\&.e\&. the platform to |
| 1294 |
build for\&. Unlike \fB::critcl::targetplatform\fR this is the true target, with |
| 1295 |
any cross-compilation information resolved\&. |
| 1296 |
.TP |
| 1297 |
\fB::critcl::buildforpackage\fR ?\fIflag\fR? |
| 1298 |
Signals whether the next file is to be built for inclusion into a package\&. If |
| 1299 |
not specified the \fIflag\fR defaults to \fBtrue\fR, i\&.e\&. building for a |
| 1300 |
package\&. This disables a number of things in the backend, namely the linking of |
| 1301 |
that file into a shared library and the loading of that library\&. It is expected |
| 1302 |
that the build results are later wrapped into a larger collection\&. |
| 1303 |
.TP |
| 1304 |
\fB::critcl::cnothingtodo\fR \fIfile\fR |
| 1305 |
Checks whether there is anything to build for \fIfile\fR\&. |
| 1306 |
.TP |
| 1307 |
\fB::critcl::cresults\fR ?\fIfile\fR? |
| 1308 |
Returns information about building \fIfile\fR, or \fBinfo script\fR If |
| 1309 |
\fIfile\fR is not provided\&. |
| 1310 |
The result in question is a dictionary containing the following items: |
| 1311 |
.RS |
| 1312 |
.TP |
| 1313 |
\fBclibraries\fR |
| 1314 |
A list of external shared libraries and/or directories needed to link |
| 1315 |
\fIfile\fR\&. |
| 1316 |
.TP |
| 1317 |
\fBldflags\fR |
| 1318 |
A list of linker flags needed to link \fIfile\fR\&. |
| 1319 |
.TP |
| 1320 |
\fBlicense\fR |
| 1321 |
The text of the license for the package \fIfile\fR is located in\&. |
| 1322 |
.TP |
| 1323 |
\fBmintcl\fR |
| 1324 |
The minimum version of Tcl required by the package \fIfile\fR |
| 1325 |
is in to run successfully\&. A proper Tcl version number\&. |
| 1326 |
.TP |
| 1327 |
\fBobjects\fR |
| 1328 |
A list of object files to link into \fIfile\fR\&. |
| 1329 |
.TP |
| 1330 |
\fBpreload\fR |
| 1331 |
A list of libraries to be preloaded in order to sucessfully load and use |
| 1332 |
\fIfile\fR\&. |
| 1333 |
.TP |
| 1334 |
\fBtk\fR |
| 1335 |
\fBtrue\fR if \fIfile\fR requires Tk and \fBfalse\fR otherwise\&. |
| 1336 |
.TP |
| 1337 |
\fBtsources\fR |
| 1338 |
A list of companion "\fI\&.tcl\fR" files to source in order to load and use the |
| 1339 |
\fICriTcl script\fR \fIfile\fR\&. |
| 1340 |
.TP |
| 1341 |
\fBlog\fR |
| 1342 |
The full build log generated by the compiler/linker, including command |
| 1343 |
line data from critcl, and other things\&. |
| 1344 |
.TP |
| 1345 |
\fBexl\fR |
| 1346 |
The raw build log generated by the compiler/linker\&. Contains the output |
| 1347 |
generated by the invoked applications\&. |
| 1348 |
.RE |
| 1349 |
.TP |
| 1350 |
\fB::critcl::crosscheck\fR |
| 1351 |
Determines whether the package is configured for cross-compilation and prints a |
| 1352 |
message to the standard error channel if so\&. |
| 1353 |
.TP |
| 1354 |
\fB::critcl::error\fR \fImsg\fR |
| 1355 |
Used to report internal errors\&. The default implementation simply returns the |
| 1356 |
error\&. Tools like the \fICriTcl Application\fR are allowed to redefine |
| 1357 |
this procedure to perform their own way of error reporting\&. There is |
| 1358 |
one constraint they are not allowed to change: The procedure must |
| 1359 |
\fInot return\fR to the caller\&. |
| 1360 |
.TP |
| 1361 |
\fB::critcl::knowntargets\fR |
| 1362 |
Returns a list of the identifiers of all targets |
| 1363 |
found during the last invocation of \fBcritcl::readconfig\fR\&. |
| 1364 |
.TP |
| 1365 |
\fB::critcl::sharedlibext\fR |
| 1366 |
Returns the file extension for shared libraries on the target platform\&. |
| 1367 |
.TP |
| 1368 |
\fB::critcl::targetconfig\fR |
| 1369 |
Returns the identifier of the target to build for, as specified by either the |
| 1370 |
user or the system\&. |
| 1371 |
.TP |
| 1372 |
\fB::critcl::buildplatform\fR |
| 1373 |
Returns the identifier of the build platform, i\&.e\&. where the package is running |
| 1374 |
on\&. |
| 1375 |
.TP |
| 1376 |
\fB::critcl::targetplatform\fR |
| 1377 |
Returns the identifier of the target platform, |
| 1378 |
i\&.e\&. the platform to compile for\&. In contrast to |
| 1379 |
\fB::critcl::actualtarget\fR this may be the name of a |
| 1380 |
cross-compilation target\&. |
| 1381 |
.TP |
| 1382 |
\fB::critcl::cobjects\fR ?\fIglob pattern\fR\&.\&.\&.? |
| 1383 |
Like \fB::critcl::clibraries\fR, but instead of matching libraries, each |
| 1384 |
\fIglob pattern\fR matches object files to be linked into the |
| 1385 |
shared object (at compile time, not runtime)\&. If a \fIglob pattern\fR matches |
| 1386 |
nothing an error is returned\&. |
| 1387 |
Not listed in \fBControl & Interface\fR because it is of no use to |
| 1388 |
package writers\&. Only tools like the \fICriTcl Application\fR need it\&. |
| 1389 |
.sp |
| 1390 |
A pattern for a relative path is resolved relative to the directory |
| 1391 |
containing the \fICriTcl script\fR\&. |
| 1392 |
.sp |
| 1393 |
Calls to this command are cumulative\&. |
| 1394 |
.TP |
| 1395 |
\fB::critcl::scan\fR \fIpath\fR |
| 1396 |
The main entry point to CriTcl's static code scanner\&. Used by tools to |
| 1397 |
implement processing modes like the assembly of a directory hierarchy |
| 1398 |
containing a TEA-lookalike buildystem, etc\&. |
| 1399 |
.sp |
| 1400 |
Scans \fIpath\fR and returns a dictionary containing the following items: |
| 1401 |
.RS |
| 1402 |
.TP |
| 1403 |
version |
| 1404 |
Package version\&. |
| 1405 |
.TP |
| 1406 |
org |
| 1407 |
Author(ing organization)\&. |
| 1408 |
.TP |
| 1409 |
files |
| 1410 |
List of the companion files, relative to the directory of the input |
| 1411 |
file\&. |
| 1412 |
.RE |
| 1413 |
.TP |
| 1414 |
\fB::critcl::name2c\fR \fIname\fR |
| 1415 |
Given the Tcl-level identifier \fIname\fR, returns a list containing the |
| 1416 |
following details of its conversion to C: |
| 1417 |
.RS |
| 1418 |
.IP \(bu |
| 1419 |
Tcl namespace prefix |
| 1420 |
.IP \(bu |
| 1421 |
C namespace prefix |
| 1422 |
.IP \(bu |
| 1423 |
Tcl base name |
| 1424 |
.IP \(bu |
| 1425 |
C base name |
| 1426 |
.RE |
| 1427 |
.sp |
| 1428 |
For use by utilities that provide Tcl commands without going through |
| 1429 |
standard commands like \fBcritcl::ccommand\fR or \fBcritcl::cproc\fR\&. |
| 1430 |
\fBcritcl::class\fR does this\&. |
| 1431 |
.PP |
| 1432 |
.SS "ADVANCED: EMBEDDED C CODE" |
| 1433 |
For advanced use, the following commands used by \fBcritcl::cproc\fR itself are |
| 1434 |
exposed\&. |
| 1435 |
.TP |
| 1436 |
\fB::critcl::argnames\fR \fIarguments\fR |
| 1437 |
Given an argument declaration as documented for \fBcritcl::cproc\fR, returns a list of the corresponding user-visible names\&. |
| 1438 |
.TP |
| 1439 |
\fB::critcl::argcnames\fR \fIarguments\fR |
| 1440 |
Given an argument declaration as documented for \fBcritcl::cproc\fR, returns a list of the corresponding C variable names for the |
| 1441 |
user-visible names\&. The names returned here match the names used in the |
| 1442 |
declarations and code returned by \fB::critcl::argvardecls\fR and |
| 1443 |
\fB::critcl::argconversion\fR\&. |
| 1444 |
.TP |
| 1445 |
\fB::critcl::argcsignature\fR \fIarguments\fR |
| 1446 |
Given an argument declaration as documented for \fBcritcl::cproc\fR, returns a list of the corresponding C parameter declarations\&. |
| 1447 |
.TP |
| 1448 |
\fB::critcl::argvardecls\fR \fIarguments\fR |
| 1449 |
Given an argument declaration as documented for \fBcritcl::cproc\fR, returns a list of the corresponding C variable declarations\&. |
| 1450 |
The names used in these declarations match the names returned by |
| 1451 |
\fB::critcl::argcnames\fR\&. |
| 1452 |
.TP |
| 1453 |
\fB::critcl::argconversion\fR \fIarguments\fR ?\fIn\fR? |
| 1454 |
Given an argument declaration as documented for \fBcritcl::cproc\fR, returns a list of C code fragments converting the user visible |
| 1455 |
arguments found in the declaration from Tcl_Obj* to C types\&. The names used in |
| 1456 |
these statements match the names returned by \fB::critcl::argcnames\fR\&. |
| 1457 |
.sp |
| 1458 |
The generated code assumes that the procedure arguments start |
| 1459 |
at index \fIn\fR of the \fBobjv\fR array\&. The default is \fB1\fR\&. |
| 1460 |
.TP |
| 1461 |
\fB::critcl::argoptional\fR \fIarguments\fR |
| 1462 |
Given an argument declaration as documented for \fBcritcl::cproc\fR, returns a list of boolean values indicating which arguments |
| 1463 |
are optional (\fBtrue\fR), and which are not (\fBfalse\fR)\&. |
| 1464 |
.TP |
| 1465 |
\fB::critcl::argdefaults\fR \fIarguments\fR |
| 1466 |
Given an argument declaration as documented for \fBcritcl::cproc\fR, returns a list containing the default values for all optional |
| 1467 |
arguments\&. |
| 1468 |
.TP |
| 1469 |
\fB::critcl::argsupport\fR \fIarguments\fR |
| 1470 |
Given an argument declaration as documented for \fBcritcl::cproc\fR, returns a list of C code fragments needed to define the |
| 1471 |
necessary supporting types\&. |
| 1472 |
.PP |
| 1473 |
.SS "CUSTOM BUILD CONFIGURATION" |
| 1474 |
This package provides one command for the management of |
| 1475 |
package-specific, i\&.e\&. developer-specified custom build configuration |
| 1476 |
options\&. |
| 1477 |
.TP |
| 1478 |
\fB::critcl::userconfig\fR \fBdefine\fR \fIname\fR \fIdescription\fR \fItype\fR ?\fIdefault\fR? |
| 1479 |
This command defines custom build configuration option, with |
| 1480 |
\fIdescription\fR, \fItype\fR and optional \fIdefault\fR value\&. |
| 1481 |
.sp |
| 1482 |
The type can be either \fBbool\fR, or a list of values\&. |
| 1483 |
.RS |
| 1484 |
.IP [1] |
| 1485 |
For \fBbool\fR the default value, if specified, must be a |
| 1486 |
boolean\&. If it is not specified it defaults to \fBtrue\fR\&. |
| 1487 |
.IP [2] |
| 1488 |
For a list of values the default value, if specified, must be a |
| 1489 |
value found in this list\&. If it is not specified it defaults to the |
| 1490 |
first value of the list\&. |
| 1491 |
.RE |
| 1492 |
.sp |
| 1493 |
The \fIdescription\fR serves as in-code documentation of the |
| 1494 |
meaning of the option and is otherwise ignored\&. When generating a TEA |
| 1495 |
wrapper the description is used for the \fBconfigure\fR option |
| 1496 |
derived from the option declared by the command\&. |
| 1497 |
.sp |
| 1498 |
A boolean option \fBFOO\fR are translated into a pair of |
| 1499 |
configure options, \fB--enable-\fBFOO\fR\fR and |
| 1500 |
\fB--disable-\fBFOO\fR\fR, whereas an option whose \fItype\fR is a |
| 1501 |
list of values is translated into a single configure option |
| 1502 |
\fB--with-\fBFOO\fR\fR\&. |
| 1503 |
.TP |
| 1504 |
\fB::critcl::userconfig\fR \fBquery\fR \fIname\fR |
| 1505 |
This command queries the database of custom build configuration option |
| 1506 |
for the current "\fI\&.critcl\fR" file and returns the chosen value\&. |
| 1507 |
This may be the default if no value was set via |
| 1508 |
\fB::critcl::userconfig set\fR\&. |
| 1509 |
.sp |
| 1510 |
It is at this point that definitions and set values are brought |
| 1511 |
together, with the latter validated against the definition\&. |
| 1512 |
.TP |
| 1513 |
\fB::critcl::userconfig\fR \fBset\fR \fIname\fR \fIvalue\fR |
| 1514 |
This command is for use by a tool, like the \fBcritcl\fR application, |
| 1515 |
to specify values for custom build configuration options\&. |
| 1516 |
.sp |
| 1517 |
At the time this command is used only the association between |
| 1518 |
option name and value is recorded, and nothing else is done\&. This |
| 1519 |
behaviour is necessary as the system may not know if an option of the |
| 1520 |
specified name exists when the command is invoked, nor its type\&. |
| 1521 |
.sp |
| 1522 |
Any and all validation is defered to when the value of an |
| 1523 |
option is asked for via \fB::critcl::userconfig query\fR\&. |
| 1524 |
.sp |
| 1525 |
This means that it is possible to set values for any option we |
| 1526 |
like, and the value will take effect only if such an option is both |
| 1527 |
defined and used later on\&. |
| 1528 |
.PP |
| 1529 |
.SS "ADVANCED: LOCATION MANAGEMENT" |
| 1530 |
First a small introduction for whose asking themselves |
| 1531 |
\'what is location management' ? |
| 1532 |
.PP |
| 1533 |
By default critcl embeds \fI#line\fR directives into the |
| 1534 |
generated C code so that any errors, warnings and notes found by the C |
| 1535 |
compiler during compilation will refer to the "\fI\&.critcl\fR" file the |
| 1536 |
faulty code comes from, instead of the generated "\fI\&.c\fR" file\&. |
| 1537 |
.PP |
| 1538 |
This facility requires the use of a tclsh that provides |
| 1539 |
\fBinfo frame\fR\&. Otherwise, no \fI#line\fR directives are emitted\&. The |
| 1540 |
command is supported by Tcl 8\&.5 and higher\&. It is also supported by |
| 1541 |
Tcl 8\&.4 provided that it was compiled with the define |
| 1542 |
\fB-DTCL_TIP280\fR\&. An example of such is ActiveState's ActiveTcl\&. |
| 1543 |
.PP |
| 1544 |
Most users will not care about this feature beyond simply |
| 1545 |
wanting it to work and getting proper code references when reading |
| 1546 |
compiler output\&. |
| 1547 |
.PP |
| 1548 |
Developers of higher-level packages generating their own C code |
| 1549 |
however should care about this, to ensure that their generated code |
| 1550 |
contains proper references as well\&. Especially as this is key to |
| 1551 |
separating bugs concerning code generated by the package itself and |
| 1552 |
bug in the user's code going into the package, if any\&. |
| 1553 |
.PP |
| 1554 |
Examples of such packages come with critcl itself, see the |
| 1555 |
implementation of packages \fBcritcl::iassoc\fR and |
| 1556 |
\fBcritcl::class\fR\&. |
| 1557 |
.PP |
| 1558 |
To help such developers eight commands are provided to manage |
| 1559 |
such \fIlocation\fR information\&. These are listed below\&. |
| 1560 |
.PP |
| 1561 |
A main concept is that they all operate on a single |
| 1562 |
\fIstored location\fR, setting, returning and clearing it\&. |
| 1563 |
Note that this location information is completely independent of the |
| 1564 |
generation of \fI#line\fR directives within critcl itself\&. |
| 1565 |
.TP |
| 1566 |
\fB::critcl::at::caller\fR |
| 1567 |
This command stores the location of the caller of the current |
| 1568 |
procedure as a tuple of file name and linenumber\&. Any previously |
| 1569 |
stored location is overwritten\&. |
| 1570 |
The result of the command is the empty string\&. |
| 1571 |
.TP |
| 1572 |
\fB::critcl::at::caller\fR \fIoffset\fR |
| 1573 |
As above, the stored line number is modified by the specified |
| 1574 |
offset\&. In essence an implicit call of \fBcritcl::at::incr\fR\&. |
| 1575 |
.TP |
| 1576 |
\fB::critcl::at::caller\fR \fIoffset\fR \fIlevel\fR |
| 1577 |
As above, but the level the location information is taken from is |
| 1578 |
modified as well\&. Level \fB0\fR is the caller, \fB-1\fR its |
| 1579 |
caller, etc\&. |
| 1580 |
.TP |
| 1581 |
\fB::critcl::at::here\fR |
| 1582 |
This command stores the current location in the current procedure as a |
| 1583 |
tuple of file name and linenumber\&. Any previously stored location is |
| 1584 |
overwritten\&. |
| 1585 |
The result of the command is the empty string\&. |
| 1586 |
.sp |
| 1587 |
In terms of \fB::critcl::at::caller\fR this is equivalent to |
| 1588 |
.CS |
| 1589 |
|
| 1590 |
|
| 1591 |
critcl::at::caller 0 1 |
| 1592 |
|
| 1593 |
.CE |
| 1594 |
.TP |
| 1595 |
\fB::critcl::at::get*\fR |
| 1596 |
This command takes the stored location and returns a formatted |
| 1597 |
\fI#line\fR directive ready for embedding into some C code\&. The |
| 1598 |
stored location is left untouched\&. |
| 1599 |
Note that the directive contains its own closing newline\&. |
| 1600 |
.sp |
| 1601 |
For proper nesting and use it is recommended that such |
| 1602 |
directives are always added to the beginning of a code fragment\&. This |
| 1603 |
way, should deeper layers add their own directives these will come |
| 1604 |
before ours and thus be inactive\&. End result is that the outermost |
| 1605 |
layer generating a directive will 'win', i\&.e\&. have its directive |
| 1606 |
used\&. As it should be\&. |
| 1607 |
.TP |
| 1608 |
\fB::critcl::at::get\fR |
| 1609 |
This command is like the above, except that it also clears the stored |
| 1610 |
location\&. |
| 1611 |
.TP |
| 1612 |
\fB::critcl::at::=\fR \fIfile\fR \fIline\fR |
| 1613 |
This command allows the caller to set the stored location to anything |
| 1614 |
they want, outside of critcl's control\&. |
| 1615 |
The result of the command is the empty string\&. |
| 1616 |
.TP |
| 1617 |
\fB::critcl::at::incr\fR \fIn\fR\&.\&.\&. |
| 1618 |
.TP |
| 1619 |
\fB::critcl::at::incrt\fR \fIstr\fR\&.\&.\&. |
| 1620 |
These commands allow the user to modify the line number of the stored |
| 1621 |
location, changing it incrementally\&. The increment is specified as |
| 1622 |
either a series of integer numbers (\fBincr\fR), or a series of |
| 1623 |
strings to consider (\fBincrt\fR)\&. In case of the latter the delta is |
| 1624 |
the number of lines endings found in the strings\&. |
| 1625 |
.TP |
| 1626 |
\fB::critcl::at::caller!\fR |
| 1627 |
.TP |
| 1628 |
\fB::critcl::at::caller!\fR \fIoffset\fR |
| 1629 |
.TP |
| 1630 |
\fB::critcl::at::caller!\fR \fIoffset\fR \fIlevel\fR |
| 1631 |
.TP |
| 1632 |
\fB::critcl::at::here!\fR |
| 1633 |
These are convenience commands combining \fBcaller\fR and \fBhere\fR |
| 1634 |
with \fBget\fR\&. I\&.e\&. they store the location and immediately return it |
| 1635 |
formatted as proper \fI#line\fR directive\&. Also note that after their |
| 1636 |
use the stored location is cleared\&. |
| 1637 |
.PP |
| 1638 |
.SS "ADVANCED: DIVERSIONS" |
| 1639 |
Diversions are for higher-level packages generating their own C code, |
| 1640 |
to make their use of critcl's commands generating |
| 1641 |
\fBEmbedded C Code\fR easier\&. |
| 1642 |
.PP |
| 1643 |
These commands normally generate all of their C code for the |
| 1644 |
current "\fI\&.critcl\fR" file, which may not be what is wanted by a |
| 1645 |
higher-level package\&. |
| 1646 |
.PP |
| 1647 |
With a diversion the generator output can be redirected into |
| 1648 |
memory and from there on then handled and processed as the caller |
| 1649 |
desires before it is committed to an actual "\fI\&.c\fR" file\&. |
| 1650 |
.PP |
| 1651 |
An example of such a package comes with critcl itself, see the |
| 1652 |
implementation of package \fBcritcl::class\fR\&. |
| 1653 |
.PP |
| 1654 |
To help such developers three commands are provided to manage |
| 1655 |
diversions and the collection of C code in memory\&. These are: |
| 1656 |
.TP |
| 1657 |
\fB::critcl::collect_begin\fR |
| 1658 |
This command starts the diversion of C code collection into memory\&. |
| 1659 |
.sp |
| 1660 |
The result of the command is the empty string\&. |
| 1661 |
.sp |
| 1662 |
Multiple calls are allowed, with each call opening a new |
| 1663 |
nesting level of diversion\&. |
| 1664 |
.TP |
| 1665 |
\fB::critcl::collect_end\fR |
| 1666 |
This command end the diversion of C code collection into memory and |
| 1667 |
returns the collected C code\&. |
| 1668 |
.sp |
| 1669 |
If multiple levels of diversion are open the call only closes |
| 1670 |
and returns the data from the last level\&. |
| 1671 |
.sp |
| 1672 |
The command will throw an error if no diversion is active, |
| 1673 |
indicating a mismatch in the pairing of \fBcollect_begin\fR and |
| 1674 |
\fBcollect_end\fR\&. |
| 1675 |
.TP |
| 1676 |
\fB::critcl::collect\fR \fIscript\fR |
| 1677 |
This is a convenience command which runs the \fIscript\fR under |
| 1678 |
diversion and returns the collected C code, ensuring the correct |
| 1679 |
pairing of \fBcollect_begin\fR and \fBcollect_end\fR\&. |
| 1680 |
.PP |
| 1681 |
.SS "ADVANCED: FILE GENERATION" |
| 1682 |
While file generation is related to the diversions explained in the |
| 1683 |
previous section they are not the same\&. |
| 1684 |
Even so, like diversions this feature is for higher-level packages |
| 1685 |
generating their own C code\&. |
| 1686 |
.PP |
| 1687 |
Three examples of utility packages using this facility comes |
| 1688 |
with critcl itself\&. |
| 1689 |
See the implementations of packages \fBcritcl::literals\fR, |
| 1690 |
\fBcritcl::bitmap\fR, and \fBcritcl::enum\fR\&. |
| 1691 |
.PP |
| 1692 |
When splitting a package implementation into pieces it is often |
| 1693 |
sensible to have a number of pure C companion files containing |
| 1694 |
low-level code, yet these files may require information about the code |
| 1695 |
in the main "\fI\&.critcl\fR" file\&. Such declarations are normally not |
| 1696 |
exportable and using the stub table support does not make sense, as |
| 1697 |
this is completely internal to the package\&. |
| 1698 |
.PP |
| 1699 |
With the file generation command below the main "\fI\&.critcl\fR" |
| 1700 |
file can generate any number of header files for the C companions to |
| 1701 |
pick up\&. |
| 1702 |
.TP |
| 1703 |
\fB::critcl::make\fR \fIpath\fR \fIcontents\fR |
| 1704 |
This command creates the file \fIpath\fR in a location where the C |
| 1705 |
companion files of the package are able to pick it up by simple |
| 1706 |
inclusion of \fIpath\fR during their compilation, without interfering |
| 1707 |
with the outer system at all\&. |
| 1708 |
.sp |
| 1709 |
The generated file will contain the specified \fIcontents\fR\&. |
| 1710 |
.PP |
| 1711 |
.SH CONCEPTS |
| 1712 |
.SS "MODES OF OPERATION/USE" |
| 1713 |
CriTcl can be used in three different modes of operation, called |
| 1714 |
.IP [1] |
| 1715 |
\fICompile & Run\fR, and |
| 1716 |
.IP [2] |
| 1717 |
\fIGenerate Package\fR |
| 1718 |
.IP [3] |
| 1719 |
\fIGenerate TEA Package\fR |
| 1720 |
.PP |
| 1721 |
\fICompile & Run\fR was the original mode and is the default for |
| 1722 |
\fIcritcl_pkg\fR\&. Collects the C fragments from the |
| 1723 |
\fICriTcl script\fR, builds them as needed, and caches the results to |
| 1724 |
improve load times later\&. |
| 1725 |
.PP |
| 1726 |
The second mode, \fIGenerate Package\fR, was introduced to enable |
| 1727 |
the creation of (prebuilt) deliverable packages which do not depend on |
| 1728 |
the existence of a build system, i\&.e\&. C compiler, on the target |
| 1729 |
machine\&. |
| 1730 |
This was originally done through the experimental \fBCritbind\fR tool, |
| 1731 |
and is now handled by the \fICriTcl Application\fR, also named |
| 1732 |
\fBcritcl\fR\&. |
| 1733 |
.PP |
| 1734 |
Newly introduced with CriTcl version 3 is |
| 1735 |
\fIGenerate TEA Package\fR\&. This mode constructs a directory |
| 1736 |
hierarchy from the package which can later be built like a regular TEA |
| 1737 |
package, i\&.e\&. using |
| 1738 |
.CS |
| 1739 |
|
| 1740 |
|
| 1741 |
\&.\&.\&./configure --prefix \&.\&.\&. |
| 1742 |
make all isntall |
| 1743 |
|
| 1744 |
.CE |
| 1745 |
.PP |
| 1746 |
Regarding the caching of results please read the section about |
| 1747 |
the \fBResult Cache\fR fore more details\&. |
| 1748 |
.SS "RUNTIME BEHAVIOUR" |
| 1749 |
The default behaviour of critcl, the package is to defer the |
| 1750 |
compilation, linking, and loading of any C code as much as possible, |
| 1751 |
given that this is an expensive operation, mainly in the time |
| 1752 |
required\&. |
| 1753 |
In other words, the C code embedded into a "\fI\&.critcl\fR" file is |
| 1754 |
built only when the first C command or procedure it provides is |
| 1755 |
invoked\&. |
| 1756 |
This part of the system uses standard functionality built into the Tcl |
| 1757 |
core, i\&.e\&. the \fBauto_index\fR variable to map from commands to |
| 1758 |
scripts providing them and the \fBunknown\fR command using this |
| 1759 |
information when the command is needed\&. |
| 1760 |
.PP |
| 1761 |
A \fIlimitation\fR of this behaviour is that it is not |
| 1762 |
possible to just use \fBinfo commands\fR check for the existence of |
| 1763 |
a critcl defined command\&. It is also necessary to search in the |
| 1764 |
\fBauto_index\fR array, in case it has not been build yet\&. |
| 1765 |
.PP |
| 1766 |
This behaviour can be changed by using the control command |
| 1767 |
\fBcritcl::load\fR\&. When invoked, the building, including loading of |
| 1768 |
the result, is forced\&. After this command has been invoked for a |
| 1769 |
"\fI\&.critcl\fR" file further definition of C code in this file is not |
| 1770 |
allowed any longer\&. |
| 1771 |
.SS "FILE MAPPING" |
| 1772 |
Each "\fI\&.critcl\fR" file is backed by a single private "\fI\&.c\fR" file |
| 1773 |
containing that code, plus the boilerplate necessary for its |
| 1774 |
compilation and linking as a single shared library\&. |
| 1775 |
.PP |
| 1776 |
The \fBEmbedded C Code\fR |
| 1777 |
fragments appear in that file in the exact same order they were |
| 1778 |
defined in the "\fI\&.critcl\fR" file, with one exception\&. The C code |
| 1779 |
provided via \fBcritcl::cinit\fR is put after all other fragments\&. |
| 1780 |
In other words all fragments have access to the symbols defined by |
| 1781 |
earlier fragments, and the \fBcritcl::cinit\fR fragment has access to |
| 1782 |
all, regardless of its placement in the "\fI\&.critcl\fR" file\&. |
| 1783 |
.PP |
| 1784 |
Note: A \fIlimitation\fR of the current system is the near |
| 1785 |
impossibility of C level access between different critcl-based |
| 1786 |
packages\&. The issue is not the necessity of writing and sharing the |
| 1787 |
proper \fBextern\fR statements, but that the management (export and |
| 1788 |
import) of package-specific stubs-tables is not supported\&. This means |
| 1789 |
that dependent parts have to be forcibly loaded before their user, |
| 1790 |
with all that entails\&. See section \fBRuntime Behaviour\fR for |
| 1791 |
the relevant critcl limitation, and remember that many older platforms |
| 1792 |
do not support the necessary resolution of symbols, the reason why |
| 1793 |
stubs were invented for Tcl in the first place\&. |
| 1794 |
.SS "RESULT CACHE" |
| 1795 |
The compilation of C code is time-consuming \fBcritcl\fR not only |
| 1796 |
defers it as much as possible, as described in section |
| 1797 |
\fBRuntime Behaviour\fR, but also caches the results\&. |
| 1798 |
.PP |
| 1799 |
This means that on the first use of a "\fI\&.critcl\fR" file |
| 1800 |
"\fIFOO\&.tcl\fR" the resulting object file and shared library are saved |
| 1801 |
into the cache, and on future uses of the same file reused, |
| 1802 |
i\&.e\&. loaded directly without requiring compilation, provided that the |
| 1803 |
contents of "\fIFOO\&.tcl\fR" did not change\&. |
| 1804 |
.PP |
| 1805 |
The change detection is based MD5 hashes\&. A single hash is |
| 1806 |
computed for each "\fI\&.critcl\fR" file, based on hashes for all C code |
| 1807 |
fragments and configuration options, i\&.e\&. everything which affects the |
| 1808 |
resulting binary\&. |
| 1809 |
.PP |
| 1810 |
As long as the input file doesn't change as per the hash a |
| 1811 |
previously built shared library found in the cache is reused, |
| 1812 |
bypassing the compilation and link stages\&. |
| 1813 |
.PP |
| 1814 |
The command to manage the cache are found in section |
| 1815 |
\fBResult Cache Management\fR\&. |
| 1816 |
Note however that they are useful only to tools based on the package, |
| 1817 |
like the \fICriTcl Application\fR\&. Package writers have no need |
| 1818 |
of them\&. |
| 1819 |
.PP |
| 1820 |
As a last note, the default directory for the cache is chosen |
| 1821 |
based on the chosen build target\&. This means that the cache can be put |
| 1822 |
on a shared (network) filesystem without having to fear interference |
| 1823 |
between machines of different architectures\&. |
| 1824 |
.SS "PRELOADING FUNCTIONALITY" |
| 1825 |
The audience of this section are developers wishing to understand |
| 1826 |
and possibly modify the internals of critcl package and application\&. |
| 1827 |
Package writers can skip this section\&. |
| 1828 |
.PP |
| 1829 |
It explains how the preloading of external libraries is realized\&. |
| 1830 |
.PP |
| 1831 |
Whenever a package declares libraries for preloading critcl will build |
| 1832 |
a supporting shared library providing a Tcl package named "preload"\&. |
| 1833 |
This package is not distributed separately, but as part of the package |
| 1834 |
requiring the preload functionality\&. |
| 1835 |
This support package exports a single Tcl command |
| 1836 |
.TP |
| 1837 |
\fB::preload\fR \fIlibrary\fR |
| 1838 |
which is invoked once per libraries to preload, with the absolute path |
| 1839 |
of that \fIlibrary\fR\&. The command then loads the \fIlibrary\fR\&. |
| 1840 |
.sp |
| 1841 |
On windows the command will further use the Tcl command |
| 1842 |
\fB::critcl::runtime::precopy\fR to copy the \fIlibrary\fR to the |
| 1843 |
disk, should its path be in a virtual filesystem which doesn't |
| 1844 |
directly support the loading of a shared library from it\&. |
| 1845 |
.PP |
| 1846 |
The command \fB::critcl::runtime::precopy\fR is provided by the file |
| 1847 |
"\fIcritcl-rt\&.tcl\fR" in the generated package, as is the command |
| 1848 |
\fB::critcl::runtime::loadlib\fR which generates the |
| 1849 |
\fIifneeded script\fR expected by Tcl's package management\&. This |
| 1850 |
generated ifneeded script contains the invocations of \fB::preload\fR\&. |
| 1851 |
.PP |
| 1852 |
The C code for the supporting library is found in the file |
| 1853 |
"\fIcritcl_c/preload\&.c\fR", which is part of the \fBcritcl\fR |
| 1854 |
package\&. |
| 1855 |
.PP |
| 1856 |
The Tcl code for the supporting runtime "\fIcritcl-rt\&.tcl\fR" is found |
| 1857 |
in the file "\fIruntime\&.tcl\fR", which is part of the |
| 1858 |
\fBcritcl::app\fR package\&. |
| 1859 |
.SS "CONFIGURATION INTERNALS" |
| 1860 |
The audience of this section are developers wishing to understand |
| 1861 |
and possibly modify the internals of critcl package and application\&. |
| 1862 |
Package writers can skip this section\&. |
| 1863 |
.PP |
| 1864 |
It explains the syntax of configuration files and the configuration |
| 1865 |
keys used by \fBcritcl\fR to configure its build backend, i\&.e\&. how |
| 1866 |
this part of the system accesses compiler, linker, etc\&. |
| 1867 |
.PP |
| 1868 |
It is recommended to open the file containing the standard |
| 1869 |
configurations ("\fIpath/to/critcl/Config\fR") in the editor of your |
| 1870 |
choice when reading this section of the documentation, using it as an |
| 1871 |
extended set of examples going beyond the simple defaults shown here\&. |
| 1872 |
.PP |
| 1873 |
First, the keys and the meaning of their values, plus examples drawn |
| 1874 |
from the standard configurations distributed with the package\&. |
| 1875 |
Note that when writing a custom configuration it is not necessary to |
| 1876 |
specify all the keys listed below, but only those whose default values |
| 1877 |
are wrong or insufficient for the platform in question\&. |
| 1878 |
.TP |
| 1879 |
version |
| 1880 |
The command to print the compiler version number\&. |
| 1881 |
Defaults to |
| 1882 |
.CS |
| 1883 |
|
| 1884 |
gcc -v |
| 1885 |
.CE |
| 1886 |
.TP |
| 1887 |
compile |
| 1888 |
The command to compile a single C source file to an object file\&. |
| 1889 |
Defaults to |
| 1890 |
.CS |
| 1891 |
|
| 1892 |
gcc -c -fPIC |
| 1893 |
.CE |
| 1894 |
.TP |
| 1895 |
debug_memory |
| 1896 |
The list of flags for the compiler to enable memory debugging in |
| 1897 |
Tcl\&. |
| 1898 |
Defaults to |
| 1899 |
.CS |
| 1900 |
|
| 1901 |
-DTCL_MEM_DEBUG |
| 1902 |
.CE |
| 1903 |
.TP |
| 1904 |
debug_symbols |
| 1905 |
The list of flags for the compiler to add symbols to the object files |
| 1906 |
and the resulting library\&. |
| 1907 |
Defaults to |
| 1908 |
.CS |
| 1909 |
|
| 1910 |
-g |
| 1911 |
.CE |
| 1912 |
.TP |
| 1913 |
include |
| 1914 |
The compiler flag to add an include directory\&. |
| 1915 |
Defaults to |
| 1916 |
.CS |
| 1917 |
|
| 1918 |
-I |
| 1919 |
.CE |
| 1920 |
.TP |
| 1921 |
tclstubs |
| 1922 |
The compiler flag to set USE_TCL_STUBS\&. |
| 1923 |
Defaults to |
| 1924 |
.CS |
| 1925 |
|
| 1926 |
-DUSE_TCL_STUBS |
| 1927 |
.CE |
| 1928 |
.TP |
| 1929 |
tkstubs |
| 1930 |
The compiler flag to set USE_TK_STUBS\&. |
| 1931 |
Defaults to |
| 1932 |
.CS |
| 1933 |
|
| 1934 |
-DUSE_TK_STUBS |
| 1935 |
.CE |
| 1936 |
.TP |
| 1937 |
threadflags |
| 1938 |
The list of compiler flags to enable a threaded build\&. |
| 1939 |
Defaults to |
| 1940 |
.CS |
| 1941 |
|
| 1942 |
|
| 1943 |
-DUSE_THREAD_ALLOC=1 -D_REENTRANT=1 -D_THREAD_SAFE=1 |
| 1944 |
-DHAVE_PTHREAD_ATTR_SETSTACKSIZE=1 -DHAVE_READDIR_R=1 |
| 1945 |
-DTCL_THREADS=1 |
| 1946 |
|
| 1947 |
.CE |
| 1948 |
.IP\&. |
| 1949 |
.TP |
| 1950 |
noassert |
| 1951 |
The compiler flag to turn off assertions in Tcl code\&. |
| 1952 |
Defaults to |
| 1953 |
.CS |
| 1954 |
|
| 1955 |
-DNDEBUG |
| 1956 |
.CE |
| 1957 |
.TP |
| 1958 |
optimize |
| 1959 |
The compiler flag to specify optimization level\&. |
| 1960 |
Defaults to |
| 1961 |
.CS |
| 1962 |
|
| 1963 |
-O2 |
| 1964 |
.CE |
| 1965 |
.TP |
| 1966 |
output |
| 1967 |
The compiler flags to set the output file of a compilation\&. |
| 1968 |
Defaults to |
| 1969 |
.CS |
| 1970 |
|
| 1971 |
-o [list $outfile] |
| 1972 |
.CE |
| 1973 |
.sp |
| 1974 |
\fINOTE\fR the use of Tcl commands and variables here\&. At the |
| 1975 |
time \fBcritcl\fR uses the value of this key the value of the |
| 1976 |
referenced variable is substituted into it\&. The named variable is the |
| 1977 |
only variable whose value is defined for this substitution\&. |
| 1978 |
.TP |
| 1979 |
object |
| 1980 |
The file extension for object files on the platform\&. |
| 1981 |
Defaults to |
| 1982 |
.CS |
| 1983 |
|
| 1984 |
\&.o |
| 1985 |
.CE |
| 1986 |
.TP |
| 1987 |
preproc_define |
| 1988 |
The command to preprocess a C source file without compiling it, but |
| 1989 |
leaving #define's in the output\&. Defaults to |
| 1990 |
.CS |
| 1991 |
|
| 1992 |
gcc -E -dM |
| 1993 |
.CE |
| 1994 |
.TP |
| 1995 |
preproc_enum |
| 1996 |
See \fBpreproc_define\fR, except that #define's are not left in the |
| 1997 |
output\&. Defaults to |
| 1998 |
.CS |
| 1999 |
|
| 2000 |
gcc -E |
| 2001 |
.CE |
| 2002 |
.TP |
| 2003 |
link |
| 2004 |
The command to link one or more object files and create a shared |
| 2005 |
library\&. Defaults to |
| 2006 |
.CS |
| 2007 |
|
| 2008 |
gcc -shared |
| 2009 |
.CE |
| 2010 |
.TP |
| 2011 |
link_preload |
| 2012 |
The list of linker flags to use when dependent libraries are |
| 2013 |
pre-loaded\&. Defaults to |
| 2014 |
.CS |
| 2015 |
|
| 2016 |
--unresolved-symbols=ignore-in-shared-libs |
| 2017 |
.CE |
| 2018 |
.TP |
| 2019 |
strip |
| 2020 |
The flag to tell the linker to strip symbols from the shared library\&. |
| 2021 |
Defaults to |
| 2022 |
.CS |
| 2023 |
|
| 2024 |
-Wl,-s |
| 2025 |
.CE |
| 2026 |
.TP |
| 2027 |
ldoutput |
| 2028 |
Like \fBoutput\fR, but for the linker\&. |
| 2029 |
Defaults to the value of \fBoutput\fR\&. |
| 2030 |
.TP |
| 2031 |
link_debug |
| 2032 |
The list of linker flags needed to build a shared library with |
| 2033 |
symbols\&. Defaults to the empty string\&. |
| 2034 |
One platform requiring this are all variants of Windows, which uses |
| 2035 |
.CS |
| 2036 |
|
| 2037 |
-debug:full -debugtype:cv |
| 2038 |
.CE |
| 2039 |
.TP |
| 2040 |
link_release |
| 2041 |
The list of linker flags needed to build a shared library without |
| 2042 |
symbols, i\&.e\&. a regular build\&. Defaults to the empty string\&. |
| 2043 |
One platform requiring this are all variants of Windows, which uses |
| 2044 |
.CS |
| 2045 |
|
| 2046 |
-release -opt:ref -opt:icf,3 -ws:aggressive |
| 2047 |
.CE |
| 2048 |
.TP |
| 2049 |
sharedlibext |
| 2050 |
The file extension for shared library files on the platform\&. |
| 2051 |
Defaults to |
| 2052 |
.CS |
| 2053 |
|
| 2054 |
[info sharedlibextension] |
| 2055 |
.CE |
| 2056 |
.TP |
| 2057 |
platform |
| 2058 |
The identifier of the platform used in generated packages\&. |
| 2059 |
Defaults to |
| 2060 |
.CS |
| 2061 |
|
| 2062 |
[platform::generic] |
| 2063 |
.CE |
| 2064 |
.TP |
| 2065 |
target |
| 2066 |
The presence of this key marks the configuration as a |
| 2067 |
cross-compilation target and the value is the actual platform |
| 2068 |
identifier of the target\&. No default\&. |
| 2069 |
.PP |
| 2070 |
.PP |
| 2071 |
The syntax expected from configuration files is governed by the rules below\&. |
| 2072 |
Again, it is recommended to open the file containing the standard |
| 2073 |
configurations ("\fIpath/to/critcl/Config\fR") in the editor of your |
| 2074 |
choice when reading this section of the documentation, using it as an |
| 2075 |
extended set of examples for the syntax> |
| 2076 |
.IP [1] |
| 2077 |
Each logical line of the configuration file consists of one or |
| 2078 |
more physical lines\&. In case of the latter the physical lines have to |
| 2079 |
follow each other and all but the first must be marked by a trailing |
| 2080 |
backslash\&. This is the same marker for \fIcontinuation lines\fR as |
| 2081 |
used by Tcl itself\&. |
| 2082 |
.IP [2] |
| 2083 |
A (logical) line starting with the character "#" (modulo |
| 2084 |
whitespace) is a comment which runs until the end of the line, and is |
| 2085 |
otherwise ignored\&. |
| 2086 |
.IP [3] |
| 2087 |
A (logical) line starting with the word "if" (modulo |
| 2088 |
whitespace) is interpreted as Tcl's \fBif\fR command and executed as |
| 2089 |
such\&. I\&.e\&. this command has to follow Tcl's syntax for the command, |
| 2090 |
which may stretch across multiple logical lines\&. The command will be |
| 2091 |
run in a save interpreter\&. |
| 2092 |
.IP [4] |
| 2093 |
A (logical) line starting with the word "set" (modulo |
| 2094 |
whitespace) is interpreted as Tcl's \fBset\fR command and executed as |
| 2095 |
such\&. I\&.e\&. this command has to follow Tcl's syntax for the command, |
| 2096 |
which may stretch across multiple logical lines\&. The command will be |
| 2097 |
run in a save interpreter\&. |
| 2098 |
.IP [5] |
| 2099 |
A line of the form "\fIplatform\fR \fBvariable\fR \fIvalue\fR" |
| 2100 |
defines a platform specific configuration variable and value\&. |
| 2101 |
The \fBvariable\fR has to be the name of one of the configuration keys |
| 2102 |
listed earlier in this section, and the \fIplatform\fR string |
| 2103 |
identifies the platform the setting is for\&. All settings with the same |
| 2104 |
identification string form the \fIconfiguration block\fR for this |
| 2105 |
platform\&. |
| 2106 |
.IP [6] |
| 2107 |
A line of the special form |
| 2108 |
"\fIplatform\fR \fBwhen\fR \fIexpression\fR" |
| 2109 |
marks the \fIplatform\fR and all the settings in its |
| 2110 |
\fIconfiguration block\fR as conditional on the \fIexpression\fR\&. |
| 2111 |
.sp |
| 2112 |
If the build platform is not a prefix of \fIplatform\fR, |
| 2113 |
nor vice versa the whole block is ignored\&. |
| 2114 |
Otherwise the \fIexpression\fR is evaluated via \fBexpr\fR, in the |
| 2115 |
same safe interpreter used to run any \fBset\fR and \fBif\fR commands |
| 2116 |
found in the configuration file (see above)\&. |
| 2117 |
.sp |
| 2118 |
If the expression evaluates to \fBtrue\fR this configuration block |
| 2119 |
is considered to be the build platform fo the host and chosen as the |
| 2120 |
default configuration\&. |
| 2121 |
An large example of of this feature is the handling of OS X found in |
| 2122 |
the standard configuration file, where it selects the architectures to |
| 2123 |
build based on the version of the operating system, the available SDK, |
| 2124 |
etc\&. I\&.e\&. it chooses whether the output is universal or not, and |
| 2125 |
whether it is old-style (ix86 + ppc) versus new-style (ix86 32+64) of |
| 2126 |
universality\&. |
| 2127 |
.IP [7] |
| 2128 |
A line of the special form |
| 2129 |
"\fIplatform\fR \fBcopy\fR \fIsourceplatform\fR" |
| 2130 |
copies the configuration variables and values currently defined in the |
| 2131 |
\fIconfiguration block\fR for \fIsourceplatform\fR to that of |
| 2132 |
\fIplatform\fR, overwriting existing values, and creating missing |
| 2133 |
ones\&. Variables of \fIplatform\fR not defined by by \fIsourceplatform\fR |
| 2134 |
are not touched\&. |
| 2135 |
.sp |
| 2136 |
The copied values can be overridden later in the configuration |
| 2137 |
file\&. Multiple \fBcopy\fR lines may exist for a platform and be |
| 2138 |
intermixed with normal configuration definitions\&. Only the last definition of a |
| 2139 |
variable is used\&. |
| 2140 |
.IP [8] |
| 2141 |
At last, a line of the form "\fBvariable\fR \fIvalue\fR" |
| 2142 |
defines a default configuration variable and value\&. |
| 2143 |
.PP |
| 2144 |
.SS "STUBS TABLES" This section is for developers of extensions not based on critcl, yet |
| 2145 |
also wishing to interface with stubs as they are understood and used |
| 2146 |
by critcl, either by exporting their own stubs table to a |
| 2147 |
critcl-based extension, or importing a stubs table of a critcl-based |
| 2148 |
extension into their own\&. |
| 2149 |
.PP |
| 2150 |
To this end we describe the stubs table information of a |
| 2151 |
package \fBfoo\fR\&. |
| 2152 |
.IP [1] |
| 2153 |
Note that the differences in the capitalization of "foo", |
| 2154 |
"Foo", "FOO", etc\&. below demonstrate how to capitalize the actual |
| 2155 |
package name in each context\&. |
| 2156 |
.IP [2] |
| 2157 |
All relevant files must be available in a sub-directory |
| 2158 |
"\fIfoo\fR" which can be found on the include search paths\&. |
| 2159 |
.IP [3] |
| 2160 |
The above directory may contain a file "\fIfoo\&.decls\fR"\&. If |
| 2161 |
present it is assumed to contain the external representation |
| 2162 |
of the stubs table the headers mentioned in the following |
| 2163 |
items are based on\&. |
| 2164 |
.sp |
| 2165 |
critcl is able to use such a file to give the importing package |
| 2166 |
programmatic access to the imported API, for automatic code |
| 2167 |
generation and the like\&. |
| 2168 |
.IP [4] |
| 2169 |
The above directory must contain a header file |
| 2170 |
"\fIfooDecls\&.h\fR"\&. This file \fIdeclares\fR the exported API\&. |
| 2171 |
It is used by both exporting and importing packages\&. It is usually |
| 2172 |
generated and must contain (in the order specified): |
| 2173 |
.RS |
| 2174 |
.IP [1] |
| 2175 |
the declarations of the exported, i\&.e\&. public, functions of |
| 2176 |
\fBfoo\fR, |
| 2177 |
.IP [2] |
| 2178 |
the declaration of structure "FooStubs" for the stub table, |
| 2179 |
.IP [3] |
| 2180 |
the C preprocessor macros which route the invocations of the |
| 2181 |
public functions through the stubs table\&. |
| 2182 |
.sp |
| 2183 |
These macros must be defined if, and only if, the C preprocessor |
| 2184 |
macro USE_FOO_STUBS is defined\&. Package \fBfoo\fR does not |
| 2185 |
define this macro, as it is allowed to use the exported |
| 2186 |
functions directly\&. All importing packages however must define |
| 2187 |
this macro, to ensure that they do \fInot\fR use any of the |
| 2188 |
exported functions directly, but only through the stubs table\&. |
| 2189 |
.IP [4] |
| 2190 |
If the exported functions need additional types for their proper |
| 2191 |
declaration then these types should be put into a separate |
| 2192 |
header file (of arbitrary name) and "\fIfooDecls\&.h\fR" should |
| 2193 |
contain an #include directive to this header at the top\&. |
| 2194 |
.RE |
| 2195 |
.sp |
| 2196 |
A very reduced, yet also complete example, from a package for |
| 2197 |
low-level random number generator functions can be found at the end of |
| 2198 |
this section\&. |
| 2199 |
.IP [5] |
| 2200 |
The above directory must contain a header file |
| 2201 |
"\fIfooStubLib\&.h\fR"\&. This file \fIdefines\fR everything needed to use |
| 2202 |
the API of \fBfoo\fR\&. Consequently it is used only by importing |
| 2203 |
packages\&. It is usually generated and must contain (in the order |
| 2204 |
specified): |
| 2205 |
.RS |
| 2206 |
.IP [1] |
| 2207 |
An #include directive for "\fItcl\&.h\fR", with USE_TCL_STUBS |
| 2208 |
surely defined\&. |
| 2209 |
.IP [2] |
| 2210 |
An #include directive for "\fIfooDecls\&.h\fR", with USE_FOO_STUBS |
| 2211 |
surely defined\&. |
| 2212 |
.IP [3] |
| 2213 |
A \fIdefinition\fR of the stubs table variable, i\&.e\&. |
| 2214 |
.CS |
| 2215 |
|
| 2216 |
const FooStubs* fooStubsPtr; |
| 2217 |
.CE |
| 2218 |
.IP [4] |
| 2219 |
A \fIdefinition\fR of the stubs initializer function, like |
| 2220 |
.CS |
| 2221 |
|
| 2222 |
char * |
| 2223 |
Foo_InitStubs(Tcl_Interp *interp, CONST char *version, int exact) |
| 2224 |
{ |
| 2225 |
/* |
| 2226 |
* Boiler plate C code initalizing the stubs table variable, |
| 2227 |
* i\&.e\&. "fooStubsPtr"\&. |
| 2228 |
*/ |
| 2229 |
|
| 2230 |
CONST char *actualVersion; |
| 2231 |
|
| 2232 |
actualVersion = Tcl_PkgRequireEx(interp, "foo", version, |
| 2233 |
exact, (ClientData *) &fooStubsPtr); |
| 2234 |
|
| 2235 |
if (!actualVersion) { |
| 2236 |
return NULL; |
| 2237 |
} |
| 2238 |
|
| 2239 |
if (!fooStubsPtr) { |
| 2240 |
Tcl_SetResult(interp, |
| 2241 |
"This implementation of Foo does not support stubs", |
| 2242 |
TCL_STATIC); |
| 2243 |
return NULL; |
| 2244 |
} |
| 2245 |
|
| 2246 |
return (char*) actualVersion; |
| 2247 |
} |
| 2248 |
.CE |
| 2249 |
.RE |
| 2250 |
.IP |
| 2251 |
This header file must be included by an importing package |
| 2252 |
\fIexactly once\fR, so that it contains only one definition of both |
| 2253 |
stubs table and stubs initializer function\&. |
| 2254 |
.sp |
| 2255 |
The importing package's initialization function must further |
| 2256 |
contain a statement like |
| 2257 |
.CS |
| 2258 |
|
| 2259 |
if (!Foo_InitStubs (ip, "1", 0)) { |
| 2260 |
return TCL_ERROR; |
| 2261 |
} |
| 2262 |
.CE |
| 2263 |
.IP |
| 2264 |
which invokes \fBfoo\fR's stubs initializer function to set the |
| 2265 |
local stub table up\&. |
| 2266 |
.sp |
| 2267 |
For a complete example of such a header file see below, at the |
| 2268 |
end of this section\&. |
| 2269 |
.IP [6] |
| 2270 |
The last item above, about "\fIfooStubLib\&.h\fR" \fIdiffers\fR |
| 2271 |
from the regular stub stable system used by Tcl\&. The regular |
| 2272 |
system assumes that a static library "\fIlibfoostub\&.a\fR" was |
| 2273 |
installed by package \fBfoo\fR, and links it\&. |
| 2274 |
.sp |
| 2275 |
IMVHO critcl's approach is simpler, using \fIonly\fR header |
| 2276 |
files found in a single location, vs\&. header files and static |
| 2277 |
library found in multiple, different locations\&. |
| 2278 |
.sp |
| 2279 |
A second simplification is that we avoid having to extend |
| 2280 |
critcl's compiler backend with settings for the creation of |
| 2281 |
static libraries\&. |
| 2282 |
.PP |
| 2283 |
Below is a complete set of example header files, reduced, yet still |
| 2284 |
complete, from a package for low-level random number generator |
| 2285 |
functions: |
| 2286 |
.TP |
| 2287 |
"\fIrngDecls\&.h\fR": |
| 2288 |
.CS |
| 2289 |
|
| 2290 |
|
| 2291 |
#ifndef rng_DECLS_H |
| 2292 |
#define rng_DECLS_H |
| 2293 |
|
| 2294 |
#include <tcl\&.h> |
| 2295 |
|
| 2296 |
/* |
| 2297 |
* Exported function declarations: |
| 2298 |
*/ |
| 2299 |
|
| 2300 |
/* 0 */ |
| 2301 |
EXTERN void rng_bernoulli(double p, int*v); |
| 2302 |
|
| 2303 |
typedef struct RngStubs { |
| 2304 |
int magic; |
| 2305 |
const struct RngStubHooks *hooks; |
| 2306 |
|
| 2307 |
void (*rng_bernoulli) (double p, int*v); /* 0 */ |
| 2308 |
} RngStubs; |
| 2309 |
|
| 2310 |
#ifdef __cplusplus |
| 2311 |
extern "C" { |
| 2312 |
#endif |
| 2313 |
extern const RngStubs *rngStubsPtr; |
| 2314 |
#ifdef __cplusplus |
| 2315 |
} |
| 2316 |
#endif |
| 2317 |
|
| 2318 |
#if defined(USE_RNG_STUBS) |
| 2319 |
|
| 2320 |
/* |
| 2321 |
* Inline function declarations: |
| 2322 |
*/ |
| 2323 |
|
| 2324 |
#define rng_bernoulli (rngStubsPtr->rng_bernoulli) /* 0 */ |
| 2325 |
|
| 2326 |
#endif /* defined(USE_RNG_STUBS) */ |
| 2327 |
#endif /* rng_DECLS_H */ |
| 2328 |
|
| 2329 |
|
| 2330 |
.CE |
| 2331 |
.TP |
| 2332 |
"\fIrngStubLib\&.h\fR": |
| 2333 |
.CS |
| 2334 |
|
| 2335 |
|
| 2336 |
/* |
| 2337 |
* rngStubLib\&.c -- |
| 2338 |
* |
| 2339 |
* Stub object that will be statically linked into extensions that wish |
| 2340 |
* to access rng\&. |
| 2341 |
*/ |
| 2342 |
|
| 2343 |
#ifndef USE_TCL_STUBS |
| 2344 |
#define USE_TCL_STUBS |
| 2345 |
#endif |
| 2346 |
#undef USE_TCL_STUB_PROCS |
| 2347 |
|
| 2348 |
#include <tcl\&.h> |
| 2349 |
|
| 2350 |
#ifndef USE_RNG_STUBS |
| 2351 |
#define USE_RNG_STUBS |
| 2352 |
#endif |
| 2353 |
#undef USE_RNG_STUB_PROCS |
| 2354 |
|
| 2355 |
#include "rngDecls\&.h" |
| 2356 |
|
| 2357 |
/* |
| 2358 |
* Ensure that Rng_InitStubs is built as an exported symbol\&. The other stub |
| 2359 |
* functions should be built as non-exported symbols\&. |
| 2360 |
*/ |
| 2361 |
|
| 2362 |
#undef TCL_STORAGE_CLASS |
| 2363 |
#define TCL_STORAGE_CLASS DLLEXPORT |
| 2364 |
|
| 2365 |
const RngStubs* rngStubsPtr; |
| 2366 |
|
| 2367 |
/* |
| 2368 |
*---------------------------------------------------------------------- |
| 2369 |
* |
| 2370 |
* Rng_InitStubs -- |
| 2371 |
* |
| 2372 |
* Checks that the correct version of Rng is loaded and that it |
| 2373 |
* supports stubs\&. It then initialises the stub table pointers\&. |
| 2374 |
* |
| 2375 |
* Results: |
| 2376 |
* The actual version of Rng that satisfies the request, or |
| 2377 |
* NULL to indicate that an error occurred\&. |
| 2378 |
* |
| 2379 |
* Side effects: |
| 2380 |
* Sets the stub table pointers\&. |
| 2381 |
* |
| 2382 |
*---------------------------------------------------------------------- |
| 2383 |
*/ |
| 2384 |
|
| 2385 |
#ifdef Rng_InitStubs |
| 2386 |
#undef Rng_InitStubs |
| 2387 |
#endif |
| 2388 |
|
| 2389 |
char * |
| 2390 |
Rng_InitStubs(Tcl_Interp *interp, CONST char *version, int exact) |
| 2391 |
{ |
| 2392 |
CONST char *actualVersion; |
| 2393 |
|
| 2394 |
actualVersion = Tcl_PkgRequireEx(interp, "rng", version, |
| 2395 |
exact, (ClientData *) &rngStubsPtr); |
| 2396 |
if (!actualVersion) { |
| 2397 |
return NULL; |
| 2398 |
} |
| 2399 |
|
| 2400 |
if (!rngStubsPtr) { |
| 2401 |
Tcl_SetResult(interp, |
| 2402 |
"This implementation of Rng does not support stubs", |
| 2403 |
TCL_STATIC); |
| 2404 |
return NULL; |
| 2405 |
} |
| 2406 |
|
| 2407 |
return (char*) actualVersion; |
| 2408 |
} |
| 2409 |
|
| 2410 |
.CE |
| 2411 |
.PP |
| 2412 |
.SH EXAMPLES |
| 2413 |
See section "Embedding C" in \fIUsing CriTcl\fR\&. |
| 2414 |
.SH AUTHORS |
| 2415 |
Jean Claude Wippler, Steve Landers, Andreas Kupries |
| 2416 |
.SH "BUGS, IDEAS, FEEDBACK" |
| 2417 |
This document, and the package it describes, will undoubtedly contain |
| 2418 |
bugs and other problems\&. |
| 2419 |
Please report them at \fIhttps://github\&.com/andreas-kupries/critcl/issues\fR\&. |
| 2420 |
Ideas for enhancements you may have for either package, application, |
| 2421 |
and/or the documentation are also very welcome and should be reported |
| 2422 |
at \fIhttps://github\&.com/andreas-kupries/critcl/issues\fR as well\&. |
| 2423 |
.SH KEYWORDS |
| 2424 |
C code, Embedded C Code, calling C code from Tcl, code generator, compile & run, compiler, dynamic code generation, dynamic compilation, generate package, linker, on demand compilation, on-the-fly compilation |
| 2425 |
.SH CATEGORY |
| 2426 |
Glueing/Embedded C code |
| 2427 |
.SH COPYRIGHT |
| 2428 |
.nf |
| 2429 |
Copyright (c) Jean-Claude Wippler |
| 2430 |
Copyright (c) Steve Landers |
| 2431 |
Copyright (c) 2011-2024 Andreas Kupries |
| 2432 |
|
| 2433 |
.fi |