OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / CELLLINUX64 / util / CELLLINUX64 / man / man3 / Tcl_GetStringResult.3
1 '\"
2 '\" Copyright (c) 1989-1993 The Regents of the University of California.
3 '\" Copyright (c) 1994-1997 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: SetResult.3,v 1.7 2002/01/25 20:40:55 dgp 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.4 2000/08/25 06:18:32 ericm 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 5.5c 11c
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_SetResult 3 8.0 Tcl "Tcl Library Procedures"
247 .BS
248 .SH NAME
249 Tcl_SetObjResult, Tcl_GetObjResult, Tcl_SetResult, Tcl_GetStringResult, Tcl_AppendResult, Tcl_AppendResultVA, Tcl_AppendElement, Tcl_ResetResult, Tcl_FreeResult \- manipulate Tcl result
250 .SH SYNOPSIS
251 .nf
252 \fB#include <tcl.h>\fR
253 .sp
254 \fBTcl_SetObjResult\fR(\fIinterp, objPtr\fR)
255 .sp
256 Tcl_Obj *
257 \fBTcl_GetObjResult\fR(\fIinterp\fR)
258 .sp
259 \fBTcl_SetResult\fR(\fIinterp, string, freeProc\fR)
260 .sp
261 CONST char *
262 \fBTcl_GetStringResult\fR(\fIinterp\fR)
263 .sp
264 \fBTcl_AppendResult\fR(\fIinterp, string, string, ... , \fB(char *) NULL\fR)
265 .sp
266 \fBTcl_AppendResultVA\fR(\fIinterp, argList\fR)
267 .sp
268 \fBTcl_AppendElement\fR(\fIinterp, string\fR)
269 .sp
270 \fBTcl_ResetResult\fR(\fIinterp\fR)
271 .sp
272 \fBTcl_FreeResult\fR(\fIinterp\fR)
273 .SH ARGUMENTS
274 .AS Tcl_FreeProc freeProc
275 .AP Tcl_Interp *interp out
276 Interpreter whose result is to be modified or read.
277 .AP Tcl_Obj *objPtr in
278 Object value to become result for \fIinterp\fR.
279 .AP char *string in
280 String value to become result for \fIinterp\fR or to be
281 appended to the existing result.
282 .AP Tcl_FreeProc *freeProc in
283 Address of procedure to call to release storage at
284 \fIstring\fR, or \fBTCL_STATIC\fR, \fBTCL_DYNAMIC\fR, or
285 \fBTCL_VOLATILE\fR.
286 .AP va_list argList in
287 An argument list which must have been initialised using
288 \fBTCL_VARARGS_START\fR, and cleared using \fBva_end\fR.
289 .BE
290
291 .SH DESCRIPTION
292 .PP
293 The procedures described here are utilities for manipulating the
294 result value in a Tcl interpreter.
295 The interpreter result may be either a Tcl object or a string.
296 For example, \fBTcl_SetObjResult\fR and \fBTcl_SetResult\fR
297 set the interpreter result to, respectively, an object and a string.
298 Similarly, \fBTcl_GetObjResult\fR and \fBTcl_GetStringResult\fR
299 return the interpreter result as an object and as a string.
300 The procedures always keep the string and object forms
301 of the interpreter result consistent.
302 For example, if \fBTcl_SetObjResult\fR is called to set
303 the result to an object,
304 then \fBTcl_GetStringResult\fR is called,
305 it will return the object's string value.
306 .PP
307 \fBTcl_SetObjResult\fR
308 arranges for \fIobjPtr\fR to be the result for \fIinterp\fR,
309 replacing any existing result.
310 The result is left pointing to the object
311 referenced by \fIobjPtr\fR.
312 \fIobjPtr\fR's reference count is incremented
313 since there is now a new reference to it from \fIinterp\fR.
314 The reference count for any old result object
315 is decremented and the old result object is freed if no
316 references to it remain.
317 .PP
318 \fBTcl_GetObjResult\fR returns the result for \fIinterp\fR as an object.
319 The object's reference count is not incremented;
320 if the caller needs to retain a long-term pointer to the object
321 they should use \fBTcl_IncrRefCount\fR to increment its reference count
322 in order to keep it from being freed too early or accidently changed.
323 .PP
324 \fBTcl_SetResult\fR
325 arranges for \fIstring\fR to be the result for the current Tcl
326 command in \fIinterp\fR, replacing any existing result.
327 The \fIfreeProc\fR argument specifies how to manage the storage
328 for the \fIstring\fR argument;
329 it is discussed in the section
330 \fBTHE TCL_FREEPROC ARGUMENT TO TCL_SETRESULT\fR below.
331 If \fIstring\fR is \fBNULL\fR, then \fIfreeProc\fR is ignored
332 and \fBTcl_SetResult\fR
333 re-initializes \fIinterp\fR's result to point to an empty string.
334 .PP
335 \fBTcl_GetStringResult\fR returns the result for \fIinterp\fR as an string.
336 If the result was set to an object by a \fBTcl_SetObjResult\fR call,
337 the object form will be converted to a string and returned.
338 If the object's string representation contains null bytes,
339 this conversion will lose information.
340 For this reason, programmers are encouraged to
341 write their code to use the new object API procedures
342 and to call \fBTcl_GetObjResult\fR instead.
343 .PP
344 \fBTcl_ResetResult\fR clears the result for \fIinterp\fR
345 and leaves the result in its normal empty initialized state.
346 If the result is an object,
347 its reference count is decremented and the result is left
348 pointing to an unshared object representing an empty string.
349 If the result is a dynamically allocated string, its memory is free*d
350 and the result is left as a empty string.
351 \fBTcl_ResetResult\fR also clears the error state managed by
352 \fBTcl_AddErrorInfo\fR, \fBTcl_AddObjErrorInfo\fR,
353 and \fBTcl_SetErrorCode\fR.
354
355 .SH "OLD STRING PROCEDURES"
356 .PP
357 Use of the following procedures is deprecated
358 since they manipulate the Tcl result as a string.
359 Procedures such as \fBTcl_SetObjResult\fR
360 that manipulate the result as an object
361 can be significantly more efficient.
362 .PP
363 \fBTcl_AppendResult\fR makes it easy to build up Tcl results in pieces.
364 It takes each of its \fIstring\fR arguments and appends them in order
365 to the current result associated with \fIinterp\fR.
366 If the result is in its initialized empty state (e.g. a command procedure
367 was just invoked or \fBTcl_ResetResult\fR was just called),
368 then \fBTcl_AppendResult\fR sets the result to the concatenation of
369 its \fIstring\fR arguments.
370 \fBTcl_AppendResult\fR may be called repeatedly as additional pieces
371 of the result are produced.
372 \fBTcl_AppendResult\fR takes care of all the
373 storage management issues associated with managing \fIinterp\fR's
374 result, such as allocating a larger result area if necessary.
375 It also converts the current interpreter result from an object
376 to a string, if necessary, before appending the argument strings.
377 Any number of \fIstring\fR arguments may be passed in a single
378 call; the last argument in the list must be a NULL pointer.
379 .PP
380 \fBTcl_AppendResultVA\fR is the same as \fBTcl_AppendResult\fR except that
381 instead of taking a variable number of arguments it takes an argument list.
382 .PP
383 \fBTcl_AppendElement\fR is similar to \fBTcl_AppendResult\fR in
384 that it allows results to be built up in pieces.
385 However, \fBTcl_AppendElement\fR takes only a single \fIstring\fR
386 argument and it appends that argument to the current result
387 as a proper Tcl list element.
388 \fBTcl_AppendElement\fR adds backslashes or braces if necessary
389 to ensure that \fIinterp\fR's result can be parsed as a list and that
390 \fIstring\fR will be extracted as a single element.
391 Under normal conditions, \fBTcl_AppendElement\fR will add a space
392 character to \fIinterp\fR's result just before adding the new
393 list element, so that the list elements in the result are properly
394 separated.
395 However if the new list element is the first in a list or sub-list
396 (i.e. \fIinterp\fR's current result is empty, or consists of the
397 single character ``{'', or ends in the characters `` {'') then no
398 space is added.
399 .PP
400 \fBTcl_FreeResult\fR performs part of the work
401 of \fBTcl_ResetResult\fR.
402 It frees up the memory associated with \fIinterp\fR's result.
403 It also sets \fIinterp->freeProc\fR to zero, but doesn't
404 change \fIinterp->result\fR or clear error state.
405 \fBTcl_FreeResult\fR is most commonly used when a procedure
406 is about to replace one result value with another.
407
408 .SH "DIRECT ACCESS TO INTERP->RESULT IS DEPRECATED"
409 .PP
410 It used to be legal for programs to
411 directly read and write \fIinterp->result\fR
412 to manipulate the interpreter result.
413 Direct access to \fIinterp->result\fR is now strongly deprecated
414 because it can make the result's string and object forms inconsistent.
415 Programs should always read the result
416 using the procedures \fBTcl_GetObjResult\fR or \fBTcl_GetStringResult\fR,
417 and write the result using \fBTcl_SetObjResult\fR or \fBTcl_SetResult\fR.
418
419 .SH "THE TCL_FREEPROC ARGUMENT TO TCL_SETRESULT"
420 .PP
421 \fBTcl_SetResult\fR's \fIfreeProc\fR argument specifies how 
422 the Tcl system is to manage the storage for the \fIstring\fR argument.
423 If \fBTcl_SetResult\fR or \fBTcl_SetObjResult\fR are called
424 at a time when \fIinterp\fR holds a string result,
425 they do whatever is necessary to dispose of the old string result
426 (see the \fBTcl_Interp\fR manual entry for details on this).
427 .PP
428 If \fIfreeProc\fR is \fBTCL_STATIC\fR it means that \fIstring\fR
429 refers to an area of static storage that is guaranteed not to be
430 modified until at least the next call to \fBTcl_Eval\fR.
431 If \fIfreeProc\fR
432 is \fBTCL_DYNAMIC\fR it means that \fIstring\fR was allocated with a call
433 to \fBTcl_Alloc\fR and is now the property of the Tcl system.
434 \fBTcl_SetResult\fR will arrange for the string's storage to be
435 released by calling \fBTcl_Free\fR when it is no longer needed.
436 If \fIfreeProc\fR is \fBTCL_VOLATILE\fR it means that \fIstring\fR
437 points to an area of memory that is likely to be overwritten when
438 \fBTcl_SetResult\fR returns (e.g. it points to something in a stack frame).
439 In this case \fBTcl_SetResult\fR will make a copy of the string in
440 dynamically allocated storage and arrange for the copy to be the
441 result for the current Tcl command.
442 .PP
443 If \fIfreeProc\fR isn't one of the values \fBTCL_STATIC\fR,
444 \fBTCL_DYNAMIC\fR, and \fBTCL_VOLATILE\fR, then it is the address
445 of a procedure that Tcl should call to free the string.
446 This allows applications to use non-standard storage allocators.
447 When Tcl no longer needs the storage for the string, it will
448 call \fIfreeProc\fR. \fIFreeProc\fR should have arguments and
449 result that match the type \fBTcl_FreeProc\fR:
450 .CS
451 typedef void Tcl_FreeProc(char *\fIblockPtr\fR);
452 .CE
453 When \fIfreeProc\fR is called, its \fIblockPtr\fR will be set to
454 the value of \fIstring\fR passed to \fBTcl_SetResult\fR.
455
456 .SH "SEE ALSO"
457 Tcl_AddErrorInfo, Tcl_CreateObjCommand, Tcl_SetErrorCode, Tcl_Interp
458
459 .SH KEYWORDS
460 append, command, element, list, object, result, return value, interpreter