Debian Codegraph @

doc/BoolObj.3

raw
1 '\"
2 '\" Copyright (c) 1996-1997 Sun Microsystems, Inc.
3 '\" Contributions from Don Porter, NIST, 2005. (not subject to US copyright)
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 .TH Tcl_BooleanObj 3 8.5 Tcl "Tcl Library Procedures"
9 .so man.macros
10 .BS
11 .SH NAME
12 Tcl_NewBooleanObj, Tcl_SetBooleanObj, Tcl_GetBooleanFromObj \- store/retrieve boolean value in a Tcl_Obj
13 .SH SYNOPSIS
14 .nf
15 \fB#include <tcl.h>\fR
16 .sp
17 Tcl_Obj *
18 \fBTcl_NewBooleanObj\fR(\fIintValue\fR)
19 .sp
20 \fBTcl_SetBooleanObj\fR(\fIobjPtr, intValue\fR)
21 .sp
22 int
23 \fBTcl_GetBooleanFromObj\fR(\fIinterp, objPtr, intPtr\fR)
24 .SH ARGUMENTS
25 .AS Tcl_Interp intValue in/out
26 .AP int intValue in
27 Integer value to be stored as a boolean value in a Tcl_Obj.
28 .AP Tcl_Obj *objPtr in/out
29 Points to the Tcl_Obj in which to store, or from which to
30 retrieve a boolean value.
31 .AP Tcl_Interp *interp in/out
32 If a boolean value cannot be retrieved,
33 an error message is left in the interpreter's result value
34 unless \fIinterp\fR is NULL.
35 .AP int *intPtr out
36 Points to place where \fBTcl_GetBooleanFromObj\fR
37 stores the boolean value (0 or 1) obtained from \fIobjPtr\fR.
38 .BE
39
40 .SH DESCRIPTION
41 .PP
42 These procedures are used to pass boolean values to and from
43 Tcl as Tcl_Obj's. When storing a boolean value into a Tcl_Obj,
44 any non-zero integer value in \fIintValue\fR is taken to be
45 the boolean value \fB1\fR, and the integer value \fB0\fR is
46 taken to be the boolean value \fB0\fR.
47 .PP
48 \fBTcl_NewBooleanObj\fR creates a new Tcl_Obj, stores the boolean
49 value \fIintValue\fR in it, and returns a pointer to the new Tcl_Obj.
50 The new Tcl_Obj has reference count of zero.
51 .PP
52 \fBTcl_SetBooleanObj\fR accepts \fIobjPtr\fR, a pointer to
53 an existing Tcl_Obj, and stores in the Tcl_Obj \fI*objPtr\fR
54 the boolean value \fIintValue\fR. This is a write operation
55 on \fI*objPtr\fR, so \fIobjPtr\fR must be unshared. Attempts to
56 write to a shared Tcl_Obj will panic. A successful write
57 of \fIintValue\fR into \fI*objPtr\fR implies the freeing of
58 any former value stored in \fI*objPtr\fR.
59 .PP
60 \fBTcl_GetBooleanFromObj\fR attempts to retrieve a boolean value
61 from the value stored in \fI*objPtr\fR.
62 If \fIobjPtr\fR holds a string value recognized by \fBTcl_GetBoolean\fR,
63 then the recognized boolean value is written at the address given
64 by \fIintPtr\fR.
65 If \fIobjPtr\fR holds any value recognized as
66 a number by Tcl, then if that value is zero a 0 is written at
67 the address given by \fIintPtr\fR and if that
68 value is non-zero a 1 is written at the address given by \fIintPtr\fR.
69 In all cases where a value is written at the address given
70 by \fIintPtr\fR, \fBTcl_GetBooleanFromObj\fR returns \fBTCL_OK\fR.
71 If the value of \fIobjPtr\fR does not meet any of the conditions
72 above, then \fBTCL_ERROR\fR is returned and an error message is
73 left in the interpreter's result unless \fIinterp\fR is NULL.
74 \fBTcl_GetBooleanFromObj\fR may also make changes to the internal
75 fields of \fI*objPtr\fR so that future calls to
76 \fBTcl_GetBooleanFromObj\fR on the same \fIobjPtr\fR can be
77 performed more efficiently.
78 .PP
79 Note that the routines \fBTcl_GetBooleanFromObj\fR and
80 \fBTcl_GetBoolean\fR are not functional equivalents.
81 The set of values for which \fBTcl_GetBooleanFromObj\fR
82 will return \fBTCL_OK\fR is strictly larger than
83 the set of values for which \fBTcl_GetBoolean\fR will do the same.
84 For example, the value
85 .QW 5
86 passed to \fBTcl_GetBooleanFromObj\fR
87 will lead to a \fBTCL_OK\fR return (and the boolean value 1),
88 while the same value passed to \fBTcl_GetBoolean\fR will lead to
89 a \fBTCL_ERROR\fR return.
90
91 .SH "SEE ALSO"
92 Tcl_NewObj, Tcl_IsShared, Tcl_GetBoolean
93
94 .SH KEYWORDS
95 boolean, value