Debian Codegraph @

doc/InitStubs.3

raw
1 '\"
2 '\" Copyright (c) 1998-1999 Scriptics Corporation
3 '\"
4 '\" See the file "license.terms" for information on usage and redistribution
5 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6 '\"
7 .TH Tcl_InitStubs 3 8.1 Tcl "Tcl Library Procedures"
8 .so man.macros
9 .BS
10 .SH NAME
11 Tcl_InitStubs \- initialize the Tcl stubs mechanism
12 .SH SYNOPSIS
13 .nf
14 \fB#include <tcl.h>\fR
15 .sp
16 const char *
17 \fBTcl_InitStubs\fR(\fIinterp, version, exact\fR)
18 .fi
19 .SH ARGUMENTS
20 .AS Tcl_Interp *interp
21 .AP Tcl_Interp *interp in
22 Tcl interpreter handle.
23 .AP "const char" *version in
24 A version string, indicating which minimal version of Tcl is accepted.
25 Normally just \fB"8.6"\fR. Or \fB"8.6-"\fR if both 8.6 and 9.0 are accepted.
26 .AP int exact in
27 1 means that only the particular version specified by
28 \fIversion\fR is accepted.
29 0 means that versions newer than \fIversion\fR are also
30 accepted. If the\fIversion\fR ends with \fB-\fR,
31 higher major versions are accepted as well, otherwise
32 the major version must be the same as in \fIversion\fR.
33 Other bits have no effect.
34 .BE
35 .SH INTRODUCTION
36 .PP
37 The Tcl stubs mechanism defines a way to dynamically bind
38 extensions to a particular Tcl implementation at run time.
39 This provides two significant benefits to Tcl users:
40 .IP 1) 5
41 Extensions that use the stubs mechanism can be loaded into
42 multiple versions of Tcl without being recompiled or
43 relinked, as long as the major Tcl version is the same.
44 .IP 2) 5
45 Extensions that use the stubs mechanism can be dynamically
46 loaded into statically-linked Tcl applications.
47 .PP
48 The stubs mechanism accomplishes this by exporting function tables
49 that define an interface to the Tcl API. The extension then accesses
50 the Tcl API through offsets into the function table, so there are no
51 direct references to any of the Tcl library's symbols. This
52 redirection is transparent to the extension, so an extension writer
53 can continue to use all public Tcl functions as documented.
54 .PP
55 The stubs mechanism requires no changes to applications incorporating
56 Tcl interpreters. Only developers creating C-based Tcl extensions
57 need to take steps to use the stubs mechanism with their extensions.
58 .PP
59 Enabling the stubs mechanism for an extension requires the following
60 steps:
61 .IP 1) 5
62 Call \fBTcl_InitStubs\fR in the extension before calling any other
63 Tcl functions.
64 .IP 2) 5
65 Define the \fBUSE_TCL_STUBS\fR symbol. Typically, you would include the
66 \fB\-DUSE_TCL_STUBS\fR flag when compiling the extension.
67 .IP 3) 5
68 Link the extension with the Tcl stubs library instead of the standard
69 Tcl library. For example, to use the Tcl 8.6 ABI on Unix platforms,
70 the library name is \fIlibtclstub8.6.a\fR; on Windows platforms, the
71 library name is \fItclstub86.lib\fR.
72 .PP
73 If the extension also requires the Tk API, it must also call
74 \fBTk_InitStubs\fR to initialize the Tk stubs interface and link
75 with the Tk stubs libraries. See the \fBTk_InitStubs\fR page for
76 more information.
77 .SH DESCRIPTION
78 \fBTcl_InitStubs\fR attempts to initialize the stub table pointers
79 and ensure that the correct version of Tcl is loaded. In addition
80 to an interpreter handle, it accepts as arguments a version number
81 and a Boolean flag indicating whether the extension requires
82 an exact version match or not. If \fIexact\fR is 0, then versions
83 newer than \fIversion\fR are also accepted. If the\fIversion\fR
84 ends with \fB-\fR, higher major versions are accepted as well,
85 otherwise the major version must be the same as in \fIversion\fR.
86 1 means that only the specified \fIversion\fR is accepted.
87 \fIversion\fR can be any construct as described for \fBpackage require\fR
88 (\fBPACKAGE\fR manual page in the section \fBREQUIREMENT\fR).
89 Multiple requirement strings like with \fBpackage require\fR are not supported.
90
91 \fBTcl_InitStubs\fR returns a string containing the actual version
92 of Tcl satisfying the request, or NULL if the Tcl version is not
93 accepted, does not support stubs, or any other error condition occurred.
94 .SH "SEE ALSO"
95 Tk_InitStubs
96 package
97 .SH KEYWORDS
98 stubs