OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / HP / util / HP / man / man3 / Tcl_Interp.3
1 '\"
2 '\" Copyright (c) 1989-1993 The Regents of the University of California.
3 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4 '\"
5 '\" See the file "license.terms" for information on usage and redistribution
6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7 '\" 
8 '\" RCS: @(#) $Id: Interp.3,v 1.3 2000/04/14 23:01:51 hobbs Exp $
9 '\" 
10 '\" The definitions below are for supplemental macros used in Tcl/Tk
11 '\" manual entries.
12 '\"
13 '\" .AP type name in/out ?indent?
14 '\"     Start paragraph describing an argument to a library procedure.
15 '\"     type is type of argument (int, etc.), in/out is either "in", "out",
16 '\"     or "in/out" to describe whether procedure reads or modifies arg,
17 '\"     and indent is equivalent to second arg of .IP (shouldn't ever be
18 '\"     needed;  use .AS below instead)
19 '\"
20 '\" .AS ?type? ?name?
21 '\"     Give maximum sizes of arguments for setting tab stops.  Type and
22 '\"     name are examples of largest possible arguments that will be passed
23 '\"     to .AP later.  If args are omitted, default tab stops are used.
24 '\"
25 '\" .BS
26 '\"     Start box enclosure.  From here until next .BE, everything will be
27 '\"     enclosed in one large box.
28 '\"
29 '\" .BE
30 '\"     End of box enclosure.
31 '\"
32 '\" .CS
33 '\"     Begin code excerpt.
34 '\"
35 '\" .CE
36 '\"     End code excerpt.
37 '\"
38 '\" .VS ?version? ?br?
39 '\"     Begin vertical sidebar, for use in marking newly-changed parts
40 '\"     of man pages.  The first argument is ignored and used for recording
41 '\"     the version when the .VS was added, so that the sidebars can be
42 '\"     found and removed when they reach a certain age.  If another argument
43 '\"     is present, then a line break is forced before starting the sidebar.
44 '\"
45 '\" .VE
46 '\"     End of vertical sidebar.
47 '\"
48 '\" .DS
49 '\"     Begin an indented unfilled display.
50 '\"
51 '\" .DE
52 '\"     End of indented unfilled display.
53 '\"
54 '\" .SO
55 '\"     Start of list of standard options for a Tk widget.  The
56 '\"     options follow on successive lines, in four columns separated
57 '\"     by tabs.
58 '\"
59 '\" .SE
60 '\"     End of list of standard options for a Tk widget.
61 '\"
62 '\" .OP cmdName dbName dbClass
63 '\"     Start of description of a specific option.  cmdName gives the
64 '\"     option's name as specified in the class command, dbName gives
65 '\"     the option's name in the option database, and dbClass gives
66 '\"     the option's class in the option database.
67 '\"
68 '\" .UL arg1 arg2
69 '\"     Print arg1 underlined, then print arg2 normally.
70 '\"
71 '\" RCS: @(#) $Id: man.macros,v 1.3 1999/04/16 00:46:35 stanton Exp $
72 '\"
73 '\"     # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
74 .if t .wh -1.3i ^B
75 .nr ^l \n(.l
76 .ad b
77 '\"     # Start an argument description
78 .de AP
79 .ie !"\\$4"" .TP \\$4
80 .el \{\
81 .   ie !"\\$2"" .TP \\n()Cu
82 .   el          .TP 15
83 .\}
84 .ta \\n()Au \\n()Bu
85 .ie !"\\$3"" \{\
86 \&\\$1  \\fI\\$2\\fP    (\\$3)
87 .\".b
88 .\}
89 .el \{\
90 .br
91 .ie !"\\$2"" \{\
92 \&\\$1  \\fI\\$2\\fP
93 .\}
94 .el \{\
95 \&\\fI\\$1\\fP
96 .\}
97 .\}
98 ..
99 '\"     # define tabbing values for .AP
100 .de AS
101 .nr )A 10n
102 .if !"\\$1"" .nr )A \\w'\\$1'u+3n
103 .nr )B \\n()Au+15n
104 .\"
105 .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
106 .nr )C \\n()Bu+\\w'(in/out)'u+2n
107 ..
108 .AS Tcl_Interp Tcl_CreateInterp in/out
109 '\"     # BS - start boxed text
110 '\"     # ^y = starting y location
111 '\"     # ^b = 1
112 .de BS
113 .br
114 .mk ^y
115 .nr ^b 1u
116 .if n .nf
117 .if n .ti 0
118 .if n \l'\\n(.lu\(ul'
119 .if n .fi
120 ..
121 '\"     # BE - end boxed text (draw box now)
122 .de BE
123 .nf
124 .ti 0
125 .mk ^t
126 .ie n \l'\\n(^lu\(ul'
127 .el \{\
128 .\"     Draw four-sided box normally, but don't draw top of
129 .\"     box if the box started on an earlier page.
130 .ie !\\n(^b-1 \{\
131 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
132 .\}
133 .el \}\
134 \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
135 .\}
136 .\}
137 .fi
138 .br
139 .nr ^b 0
140 ..
141 '\"     # VS - start vertical sidebar
142 '\"     # ^Y = starting y location
143 '\"     # ^v = 1 (for troff;  for nroff this doesn't matter)
144 .de VS
145 .if !"\\$2"" .br
146 .mk ^Y
147 .ie n 'mc \s12\(br\s0
148 .el .nr ^v 1u
149 ..
150 '\"     # VE - end of vertical sidebar
151 .de VE
152 .ie n 'mc
153 .el \{\
154 .ev 2
155 .nf
156 .ti 0
157 .mk ^t
158 \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
159 .sp -1
160 .fi
161 .ev
162 .\}
163 .nr ^v 0
164 ..
165 '\"     # Special macro to handle page bottom:  finish off current
166 '\"     # box/sidebar if in box/sidebar mode, then invoked standard
167 '\"     # page bottom macro.
168 .de ^B
169 .ev 2
170 'ti 0
171 'nf
172 .mk ^t
173 .if \\n(^b \{\
174 .\"     Draw three-sided box if this is the box's first page,
175 .\"     draw two sides but no top otherwise.
176 .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
177 .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
178 .\}
179 .if \\n(^v \{\
180 .nr ^x \\n(^tu+1v-\\n(^Yu
181 \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
182 .\}
183 .bp
184 'fi
185 .ev
186 .if \\n(^b \{\
187 .mk ^y
188 .nr ^b 2
189 .\}
190 .if \\n(^v \{\
191 .mk ^Y
192 .\}
193 ..
194 '\"     # DS - begin display
195 .de DS
196 .RS
197 .nf
198 .sp
199 ..
200 '\"     # DE - end display
201 .de DE
202 .fi
203 .RE
204 .sp
205 ..
206 '\"     # SO - start of list of standard options
207 .de SO
208 .SH "STANDARD OPTIONS"
209 .LP
210 .nf
211 .ta 4c 8c 12c
212 .ft B
213 ..
214 '\"     # SE - end of list of standard options
215 .de SE
216 .fi
217 .ft R
218 .LP
219 See the \\fBoptions\\fR manual entry for details on the standard options.
220 ..
221 '\"     # OP - start of full description for a single option
222 .de OP
223 .LP
224 .nf
225 .ta 4c
226 Command-Line Name:      \\fB\\$1\\fR
227 Database Name:  \\fB\\$2\\fR
228 Database Class: \\fB\\$3\\fR
229 .fi
230 .IP
231 ..
232 '\"     # CS - begin code excerpt
233 .de CS
234 .RS
235 .nf
236 .ta .25i .5i .75i 1i
237 ..
238 '\"     # CE - end code excerpt
239 .de CE
240 .fi
241 .RE
242 ..
243 .de UL
244 \\$1\l'|0\(ul'\\$2
245 ..
246 .TH Tcl_Interp 3 7.5 Tcl "Tcl Library Procedures"
247 .BS
248 .SH NAME
249 Tcl_Interp \- client-visible fields of interpreter structures
250 .SH SYNOPSIS
251 .nf
252 \fB#include <tcl.h>\fR
253 .sp
254 typedef struct {
255         char *\fIresult\fR;
256         Tcl_FreeProc *\fIfreeProc\fR;
257         int \fIerrorLine\fR;
258 } Tcl_Interp;
259
260 typedef void Tcl_FreeProc(char *\fIblockPtr\fR);
261 .BE
262
263 .SH DESCRIPTION
264 .PP
265 The \fBTcl_CreateInterp\fR procedure returns a pointer to a Tcl_Interp
266 structure.  This pointer is then passed into other Tcl procedures
267 to process commands in the interpreter and perform other operations
268 on the interpreter.  Interpreter structures contain many many fields
269 that are used by Tcl, but only three that may be accessed by
270 clients:  \fIresult\fR, \fIfreeProc\fR, and \fIerrorLine\fR.
271 .PP
272 The \fIresult\fR and \fIfreeProc\fR fields are used to return
273 results or error messages from commands.
274 This information is returned by command procedures back to \fBTcl_Eval\fR,
275 and by \fBTcl_Eval\fR back to its callers.
276 The \fIresult\fR field points to the string that represents the
277 result or error message, and the \fIfreeProc\fR field tells how
278 to dispose of the storage for the string when it isn't needed anymore.
279 The easiest way for command procedures to manipulate these
280 fields is to call procedures like \fBTcl_SetResult\fR
281 or \fBTcl_AppendResult\fR;  they
282 will hide all the details of managing the fields.
283 The description below is for those procedures that manipulate the
284 fields directly.
285 .PP
286 Whenever a command procedure returns, it must ensure
287 that the \fIresult\fR field of its interpreter points to the string
288 being returned by the command.
289 The \fIresult\fR field must always point to a valid string.
290 If a command wishes to return no result then \fIinterp->result\fR
291 should point to an empty string.
292 Normally, results are assumed to be statically allocated,
293 which means that the contents will not change before the next time
294 \fBTcl_Eval\fR is called or some other command procedure is invoked.
295 .VS
296 In this case, the \fIfreeProc\fR field must be zero.
297 Alternatively, a command procedure may dynamically
298 allocate its return value (e.g. using \fBTcl_Alloc\fR)
299 and store a pointer to it in \fIinterp->result\fR.
300 In this case, the command procedure must also set \fIinterp->freeProc\fR
301 to the address of a procedure that can free the value, or \fBTCL_DYNAMIC\fR
302 if the storage was allocated directly by Tcl or by a call to
303 \fBTcl_Alloc\fR. 
304 .VE
305 If \fIinterp->freeProc\fR is non-zero, then Tcl will call \fIfreeProc\fR
306 to free the space pointed to by \fIinterp->result\fR before it
307 invokes the next command.
308 If a client procedure overwrites \fIinterp->result\fR when
309 \fIinterp->freeProc\fR is non-zero, then it is responsible for calling
310 \fIfreeProc\fR to free the old \fIinterp->result\fR (the \fBTcl_FreeResult\fR
311 macro should be used for this purpose).
312 .PP
313 \fIFreeProc\fR should have arguments and result that match the
314 \fBTcl_FreeProc\fR declaration above:  it receives a single
315 argument which is a pointer to the result value to free.
316 .VS
317 In most applications \fBTCL_DYNAMIC\fR is the only non-zero value ever
318 used for \fIfreeProc\fR.
319 .VE
320 However, an application may store a different procedure address
321 in \fIfreeProc\fR in order to use an alternate memory allocator
322 or in order to do other cleanup when the result memory is freed.
323 .PP
324 As part of processing each command, \fBTcl_Eval\fR initializes
325 \fIinterp->result\fR
326 and \fIinterp->freeProc\fR just before calling the command procedure for
327 the command.  The \fIfreeProc\fR field will be initialized to zero,
328 and \fIinterp->result\fR will point to an empty string.  Commands that
329 do not return any value can simply leave the fields alone.
330 Furthermore, the empty string pointed to by \fIresult\fR is actually
331 part of an array of \fBTCL_RESULT_SIZE\fR characters (approximately 200).
332 If a command wishes to return a short string, it can simply copy
333 it to the area pointed to by \fIinterp->result\fR.  Or, it can use
334 the sprintf procedure to generate a short result string at the location
335 pointed to by \fIinterp->result\fR.
336 .PP
337 It is a general convention in Tcl-based applications that the result
338 of an interpreter is normally in the initialized state described
339 in the previous paragraph.
340 Procedures that manipulate an interpreter's result (e.g. by
341 returning an error) will generally assume that the result
342 has been initialized when the procedure is called.
343 If such a procedure is to be called after the result has been
344 changed, then \fBTcl_ResetResult\fR should be called first to
345 reset the result to its initialized state.  The direct use of
346 \fIinterp->result\fR is strongly deprecated (see \fBTcl_SetResult\fR).
347 .PP
348 The \fIerrorLine\fR
349 field is valid only after \fBTcl_Eval\fR returns
350 a \fBTCL_ERROR\fR return code.  In this situation the \fIerrorLine\fR
351 field identifies the line number of the command being executed when
352 the error occurred.  The line numbers are relative to the command
353 being executed:  1 means the first line of the command passed to
354 \fBTcl_Eval\fR, 2 means the second line, and so on.
355 The \fIerrorLine\fR field is typically used in conjunction with
356 \fBTcl_AddErrorInfo\fR to report information about where an error
357 occurred.
358 \fIErrorLine\fR should not normally be modified except by \fBTcl_Eval\fR.
359
360 .SH KEYWORDS
361 free, initialized, interpreter, malloc, result