Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/IntObj.3 @ 43

Last change on this file since 43 was 25, checked in by landauf, 16 years ago

added tcl to libs

File size: 6.4 KB
Line 
1'\"
2'\" Copyright (c) 1996-1997 Sun Microsystems, Inc.
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'\" RCS: @(#) $Id: IntObj.3,v 1.14 2007/12/13 15:22:31 dgp Exp $
8'\"
9.so man.macros
10.TH Tcl_IntObj 3 8.5 Tcl "Tcl Library Procedures"
11.BS
12.SH NAME
13Tcl_NewIntObj, Tcl_NewLongObj, Tcl_NewWideIntObj, Tcl_SetIntObj, Tcl_SetLongObj, Tcl_SetWideIntObj, Tcl_GetIntFromObj, Tcl_GetLongFromObj, Tcl_GetWideIntFromObj, Tcl_NewBignumObj, Tcl_SetBignumObj, Tcl_GetBignumFromObj, Tcl_TakeBignumFromObj \- manipulate Tcl objects as integer values
14.SH SYNOPSIS
15.nf
16\fB#include <tcl.h>\fR
17.sp
18Tcl_Obj *
19\fBTcl_NewIntObj\fR(\fIintValue\fR)
20.sp
21Tcl_Obj *
22\fBTcl_NewLongObj\fR(\fIlongValue\fR)
23.sp
24Tcl_Obj *
25\fBTcl_NewWideIntObj\fR(\fIwideValue\fR)
26.sp
27\fBTcl_SetIntObj\fR(\fIobjPtr, intValue\fR)
28.sp
29\fBTcl_SetLongObj\fR(\fIobjPtr, longValue\fR)
30.sp
31\fBTcl_SetWideIntObj\fR(\fIobjPtr, wideValue\fR)
32.sp
33int
34\fBTcl_GetIntFromObj\fR(\fIinterp, objPtr, intPtr\fR)
35.sp
36int
37\fBTcl_GetLongFromObj\fR(\fIinterp, objPtr, longPtr\fR)
38.sp
39int
40\fBTcl_GetWideIntFromObj\fR(\fIinterp, objPtr, widePtr\fR)
41.sp
42.sp
43.VS 8.5
44\fB#include <tclTomMath.h>\fR
45.sp
46Tcl_Obj *
47\fBTcl_NewBignumObj\fR(\fIbigValue\fR)
48.sp
49\fBTcl_SetBignumObj\fR(\fIobjPtr, bigValue\fR)
50.sp
51int
52\fBTcl_GetBignumFromObj\fR(\fIinterp, objPtr, bigValue\fR)
53.sp
54int
55\fBTcl_TakeBignumFromObj\fR(\fIinterp, objPtr, bigValue\fR)
56.sp
57int
58\fBTcl_InitBignumFromDouble\fR(\fIinterp, doubleValue, bigValue\fR)
59.VE 8.5
60.SH ARGUMENTS
61.AS Tcl_WideInt doubleValue in/out
62.AP int intValue in
63Integer value used to initialize or set a Tcl object.
64.AP long longValue in
65Long integer value used to initialize or set a Tcl object.
66.AP Tcl_WideInt wideValue in
67Wide integer value used to initialize or set a Tcl object.
68.AP Tcl_Obj *objPtr in/out
69For \fBTcl_SetIntObj\fR, \fBTcl_SetLongObj\fR, \fBTcl_SetWideIntObj\fR,
70and \fBTcl_SetBignumObj\fR, this points to the object in which to store an
71integral value.  For \fBTcl_GetIntFromObj\fR, \fBTcl_GetLongFromObj\fR,
72\fBTcl_GetWideIntFromObj\fR, \fBTcl_GetBignumFromObj\fR, and
73\fBTcl_TakeBignumFromObj\fR, this refers to the object from which
74to retrieve an integral value.
75.AP Tcl_Interp *interp in/out
76When non-NULL, an error message is left here when integral value
77retrieval fails.
78.AP int *intPtr out
79Points to place to store the integer value retrieved from \fIobjPtr\fR.
80.AP long *longPtr out
81Points to place to store the long integer value retrieved from \fIobjPtr\fR.
82.AP Tcl_WideInt *widePtr out
83Points to place to store the wide integer value retrieved from \fIobjPtr\fR.
84.AP mp_int *bigValue in/out
85.VS 8.5
86Points to a multi-precision integer structure declared by the LibTomMath
87library.
88.VE 8.5
89.AP double doubleValue in
90.VS 8.5
91Double value from which the integer part is determined and
92used to initialize a multi-precision integer value.
93.VE 8.5
94.BE
95
96.SH DESCRIPTION
97.PP
98.VS 8.5
99These procedures are used to create, modify, and read Tcl objects
100that hold integral values. 
101.PP
102The different routines exist to accomodate different integral types in C
103with which values might be exchanged.  The C integral types for which Tcl
104provides value exchange routines are \fBint\fR, \fBlong int\fR,
105\fBTcl_WideInt\fR, and \fBmp_int\fR.  The \fBint\fR and \fBlong int\fR types
106are provided by the C language standard.  The \fBTcl_WideInt\fR type is a
107typedef defined to be whatever signed integral type covers at least the
10864-bit integer range (-9223372036854775808 to 9223372036854775807).  Depending
109on the platform and the C compiler, the actual type might be
110\fBlong int\fR, \fBlong long int\fR, \fBint64\fR, or something else.
111The \fBmp_int\fR type is a multiple-precision integer type defined
112by the LibTomMath multiple-precision integer library. 
113.PP
114The \fBTcl_NewIntObj\fR, \fBTcl_NewLongObj\fR, \fBTcl_NewWideIntObj\fR,
115and \fBTcl_NewBignumObj\fR routines each create and return a new
116Tcl object initialized to the integral value of the argument.  The
117returned Tcl object is unshared.
118.PP
119The \fBTcl_SetIntObj\fR, \fBTcl_SetLongObj\fR, \fBTcl_SetWideIntObj\fR,
120and \fBTcl_SetBignumObj\fR routines each set the value of an existing
121Tcl object pointed to by \fIobjPtr\fR to the integral value provided
122by the other argument.  The \fIobjPtr\fR argument must point to an
123unshared Tcl object.  Any attempt to set the value of a shared Tcl object
124violates Tcl's copy-on-write policy.  Any existing string representation
125or internal representation in the unshared Tcl object will be freed
126as a consequence of setting the new value.
127.PP
128The \fBTcl_GetIntFromObj\fR, \fBTcl_GetLongFromObj\fR,
129\fBTcl_GetWideIntFromObj\fR, \fBTcl_GetBignumFromObj\fR, and
130\fBTcl_TakeBignumFromObj\fR routines attempt to retrieve an integral
131value of the appropriate type from the Tcl object \fIobjPtr\fR.  If the
132attempt succeeds, then \fBTCL_OK\fR is returned, and the value is
133written to the storage provided by the caller.  The attempt might
134fail if \fIobjPtr\fR does not hold an integral value, or if the
135value exceeds the range of the target type.  If the attempt fails,
136then \fBTCL_ERROR\fR is returned, and if \fIinterp\fR is non-NULL,
137an error message is left in \fIinterp\fR.  The \fBTcl_ObjType\fR
138of \fIobjPtr\fR may be changed to make subsequent calls to the
139same routine more efficient. Unlike the other functions,
140\fBTcl_TakeGetBignumFromObj\fR may set the content of the Tcl object
141\fIobjPtr\fR to an empty string in the process of retrieving the
142multiple-precision integer value.
143.PP
144The choice between \fBTcl_GetBignumFromObj\fR and
145\fBTcl_TakeGetBignumFromObj\fR is governed by how the caller will
146continue to use \fIobjPtr\fR.  If after the \fBmp_int\fR value
147is retrieved from \fIobjPtr\fR, the caller will make no more
148use of \fIobjPtr\fR, then using \fBTcl_TakeGetBignumFromObj\fR
149permits Tcl to detect when an unshared \fIobjPtr\fR permits the
150value to be moved instead of copied, which should be more efficient.
151If anything later in the caller requires
152\fIobjPtr\fR to continue to hold the same value, then
153\fBTcl_GetBignumFromObj\fR must be chosen.
154.PP
155The \fBTcl_InitBignumFromDouble\fR routine is a utility procedure
156that extracts the integer part of \fIdoubleValue\fR and stores that
157integer value in the \fBmp_int\fR value \fIbigValue\fR.
158.VE 8.5
159.SH "SEE ALSO"
160Tcl_NewObj, Tcl_DecrRefCount, Tcl_IncrRefCount, Tcl_GetObjResult
161.SH KEYWORDS
162integer, integer object, integer type, internal representation, object, object type, string representation
Note: See TracBrowser for help on using the repository browser.