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

« back to all changes in this revision

Viewing changes to doc/include/using_etclc.inc

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
[subsection {Having both C and Tcl functionality}]
 
2
 
 
3
Often enough only pieces of a package require recoding in C to boost
 
4
the whole system. Or, alternatively, the package in question consists
 
5
of a low-level layer C with a Tcl layer above encoding policies and
 
6
routing to the proper low-level calls, creating a nicer (high-level)
 
7
API to the low-level functionality, etc.
 
8
 
 
9
[para] For all of this we have to be able to write a package which
 
10
contains both C and Tcl, nevermind the fact the C parts are embedded
 
11
in Tcl.
 
12
 
 
13
[para] The easiest way to structure such a package is to have several
 
14
files, each with a different duty. First, a [file .critcl] file
 
15
containing the embedded C, and second one or more [file .tcl] files
 
16
providing the Tcl parts.
 
17
 
 
18
Then use the [cmd critcl::tsources] command in the [file .critcl] file
 
19
to link the two parts together, declaring the [file .tcl] files as
 
20
necessary companions of the C part.
 
21
 
 
22
[example {
 
23
    package require critcl
 
24
 
 
25
    critcl::tsources your-companion.tcl ; # Companion file to use
 
26
 
 
27
    ... embedded C via critcl commands ...
 
28
}]
 
29
 
 
30
With a declaration as shown above the companion file will be
 
31
automatically [cmd source]d when the C parts are made available, thus
 
32
making the Tcl parts available as well.