summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/IntObj.330
-rw-r--r--generic/tcl.decls8
-rw-r--r--generic/tclDecls.h17
-rw-r--r--generic/tclObj.c67
-rw-r--r--generic/tclStubInit.c4
-rw-r--r--generic/tclTest.c26
6 files changed, 109 insertions, 43 deletions
diff --git a/doc/IntObj.3 b/doc/IntObj.3
index 4cd13e6..7cc93c1 100644
--- a/doc/IntObj.3
+++ b/doc/IntObj.3
@@ -8,7 +8,7 @@
.so man.macros
.BS
.SH NAME
-Tcl_NewIntObj, Tcl_NewLongObj, Tcl_NewWideIntObj, Tcl_SetIntObj, Tcl_SetLongObj, Tcl_SetWideIntObj, Tcl_GetIntFromObj, Tcl_GetIntForIndex, Tcl_GetLongFromObj, Tcl_GetWideIntFromObj, Tcl_GetWideUIntFromObj, Tcl_NewBignumObj, Tcl_SetBignumObj, Tcl_GetBignumFromObj, Tcl_TakeBignumFromObj \- manipulate Tcl values as integers
+Tcl_NewIntObj, Tcl_NewLongObj, Tcl_NewWideIntObj, Tcl_NewWideUIntObj, Tcl_SetIntObj, Tcl_SetLongObj, Tcl_SetWideIntObj, Tcl_SetWideUIntObj, Tcl_GetIntFromObj, Tcl_GetIntForIndex, Tcl_GetLongFromObj, Tcl_GetWideIntFromObj, Tcl_GetWideUIntFromObj, Tcl_NewBignumObj, Tcl_SetBignumObj, Tcl_GetBignumFromObj, Tcl_TakeBignumFromObj \- manipulate Tcl values as integers
.SH SYNOPSIS
.nf
\fB#include <tcl.h>\fR
@@ -22,12 +22,17 @@ Tcl_Obj *
Tcl_Obj *
\fBTcl_NewWideIntObj\fR(\fIwideValue\fR)
.sp
+Tcl_Obj *
+\fBTcl_NewWideUIntObj\fR(\fIuwideValue\fR)
+.sp
\fBTcl_SetIntObj\fR(\fIobjPtr, intValue\fR)
.sp
\fBTcl_SetLongObj\fR(\fIobjPtr, longValue\fR)
.sp
\fBTcl_SetWideIntObj\fR(\fIobjPtr, wideValue\fR)
.sp
+\fBTcl_SetWideUIntObj\fR(\fIobjPtr, uwideValue\fR)
+.sp
int
\fBTcl_GetIntFromObj\fR(\fIinterp, objPtr, intPtr\fR)
.sp
@@ -73,8 +78,11 @@ Integer value used to initialize or set a Tcl value.
Long integer value used to initialize or set a Tcl value.
.AP Tcl_WideInt wideValue in
Wide integer value used to initialize or set a Tcl value.
+.AP Tcl_WideUInt uwideValue in
+Unsigned wide integer value used to initialize or set a Tcl value.
.AP Tcl_Obj *objPtr in/out
For \fBTcl_SetIntObj\fR, \fBTcl_SetLongObj\fR, \fBTcl_SetWideIntObj\fR,
+\fBTcl_SetWideUIntObj\fR,
and \fBTcl_SetBignumObj\fR, this points to the value in which to store an
integral value. For \fBTcl_GetIntFromObj\fR, \fBTcl_GetLongFromObj\fR,
\fBTcl_GetWideIntFromObj\fR, \fBTcl_GetBignumFromObj\fR, and
@@ -120,18 +128,18 @@ The \fBmp_int\fR type is a multiple-precision integer type defined
by the LibTomMath multiple-precision integer library.
.PP
The \fBTcl_NewIntObj\fR, \fBTcl_NewLongObj\fR, \fBTcl_NewWideIntObj\fR,
-and \fBTcl_NewBignumObj\fR routines each create and return a new
-Tcl value initialized to the integral value of the argument. The
-returned Tcl value is unshared.
+\fBTcl_NewWideUIntObj\fR, and \fBTcl_NewBignumObj\fR
+routines each create and return a new Tcl value initialized to the
+integral value of the argument. The returned Tcl value is unshared.
.PP
The \fBTcl_SetIntObj\fR, \fBTcl_SetLongObj\fR, \fBTcl_SetWideIntObj\fR,
-and \fBTcl_SetBignumObj\fR routines each set the value of an existing
-Tcl value pointed to by \fIobjPtr\fR to the integral value provided
-by the other argument. The \fIobjPtr\fR argument must point to an
-unshared Tcl value. Any attempt to set the value of a shared Tcl value
-violates Tcl's copy-on-write policy. Any existing string representation
-or internal representation in the unshared Tcl value will be freed
-as a consequence of setting the new value.
+\fBTcl_SetWideUIntObj\fR, and \fBTcl_SetBignumObj\fR
+routines each set the value of an existing Tcl value pointed to by \fIobjPtr\fR
+to the integral value provided by the other argument. The \fIobjPtr\fR
+argument must point to an unshared Tcl value. Any attempt to set the
+value of a shared Tcl value violates Tcl's copy-on-write policy. Any
+existing string representation or internal representation in the unshared
+Tcl value will be freed as a consequence of setting the new value.
.PP
The \fBTcl_GetIntForIndex\fR routine attempts to retrieve an index
value from the Tcl value \fIobjPtr\fR. If the attempt succeeds,
diff --git a/generic/tcl.decls b/generic/tcl.decls
index 641d2b1..5650967 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -2364,6 +2364,14 @@ declare 687 {
int Tcl_UtfNcasecmp(const char *s1, const char *s2, size_t n)
}
+# TIP #648
+declare 688 {
+ Tcl_Obj *Tcl_NewWideUIntObj(Tcl_WideUInt wideValue)
+}
+declare 689 {
+ void Tcl_SetWideUIntObj(Tcl_Obj *objPtr, Tcl_WideUInt uwideValue)
+}
+
# ----- BASELINE -- FOR -- 8.7.0 / 9.0.0 ----- #
declare 690 {
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index d4fee5e..896deed 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -1867,8 +1867,11 @@ EXTERN int Tcl_UtfNcmp(const char *s1, const char *s2, size_t n);
/* 687 */
EXTERN int Tcl_UtfNcasecmp(const char *s1, const char *s2,
size_t n);
-/* Slot 688 is reserved */
-/* Slot 689 is reserved */
+/* 688 */
+EXTERN Tcl_Obj * Tcl_NewWideUIntObj(Tcl_WideUInt wideValue);
+/* 689 */
+EXTERN void Tcl_SetWideUIntObj(Tcl_Obj *objPtr,
+ Tcl_WideUInt uwideValue);
/* 690 */
EXTERN void TclUnusedStubEntry(void);
@@ -2570,8 +2573,8 @@ typedef struct TclStubs {
Tcl_Obj * (*tcl_DStringToObj) (Tcl_DString *dsPtr); /* 685 */
int (*tcl_UtfNcmp) (const char *s1, const char *s2, size_t n); /* 686 */
int (*tcl_UtfNcasecmp) (const char *s1, const char *s2, size_t n); /* 687 */
- void (*reserved688)(void);
- void (*reserved689)(void);
+ Tcl_Obj * (*tcl_NewWideUIntObj) (Tcl_WideUInt wideValue); /* 688 */
+ void (*tcl_SetWideUIntObj) (Tcl_Obj *objPtr, Tcl_WideUInt uwideValue); /* 689 */
void (*tclUnusedStubEntry) (void); /* 690 */
} TclStubs;
@@ -3900,8 +3903,10 @@ extern const TclStubs *tclStubsPtr;
(tclStubsPtr->tcl_UtfNcmp) /* 686 */
#define Tcl_UtfNcasecmp \
(tclStubsPtr->tcl_UtfNcasecmp) /* 687 */
-/* Slot 688 is reserved */
-/* Slot 689 is reserved */
+#define Tcl_NewWideUIntObj \
+ (tclStubsPtr->tcl_NewWideUIntObj) /* 688 */
+#define Tcl_SetWideUIntObj \
+ (tclStubsPtr->tcl_SetWideUIntObj) /* 689 */
#define TclUnusedStubEntry \
(tclStubsPtr->tclUnusedStubEntry) /* 690 */
diff --git a/generic/tclObj.c b/generic/tclObj.c
index e23d900..30634a0 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -2792,6 +2792,33 @@ Tcl_NewWideIntObj(
/*
*----------------------------------------------------------------------
*
+ * Tcl_NewWideUIntObj --
+ *
+ * Results:
+ * The newly created object is returned. This object will have an invalid
+ * string representation. The returned object has ref count 0.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+Tcl_Obj *
+Tcl_NewWideUIntObj(
+ Tcl_WideUInt uwideValue)
+ /* Wide integer used to initialize the new
+ * object. */
+{
+ Tcl_Obj *objPtr;
+
+ TclNewUIntObj(objPtr, uwideValue);
+ return objPtr;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* Tcl_DbNewWideIntObj --
*
* If a client is compiled with TCL_MEM_DEBUG defined, calls to
@@ -2885,6 +2912,46 @@ Tcl_SetWideIntObj(
TclSetIntObj(objPtr, wideValue);
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * Tcl_SetWideUIntObj --
+ *
+ * Modify an object to be a wide integer object or a bignum object
+ * and to have the specified unsigned wide integer value.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The object's old string rep, if any, is freed. Also, any old internal
+ * rep is freed.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+Tcl_SetWideUIntObj(
+ Tcl_Obj *objPtr, /* Object w. internal rep to init. */
+ Tcl_WideUInt uwideValue)
+ /* Wide integer used to initialize the
+ * object's value. */
+{
+ if (Tcl_IsShared(objPtr)) {
+ Tcl_Panic("%s called with shared object", "Tcl_SetWideUIntObj");
+ }
+
+ if (uwideValue > WIDE_MAX) {
+ mp_int bignumValue;
+ if (mp_init_u64(&bignumValue, uwideValue) != MP_OKAY) {
+ Tcl_Panic("%s: memory overflow", "Tcl_SetWideUIntObj");
+ }
+ TclSetBignumInternalRep(objPtr, &bignumValue);
+ } {
+ TclSetIntObj(objPtr, (Tcl_WideInt)uwideValue);
+ }
+}
/*
*----------------------------------------------------------------------
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c
index fc0f6fa..3504bf7 100644
--- a/generic/tclStubInit.c
+++ b/generic/tclStubInit.c
@@ -1491,8 +1491,8 @@ const TclStubs tclStubs = {
Tcl_DStringToObj, /* 685 */
Tcl_UtfNcmp, /* 686 */
Tcl_UtfNcasecmp, /* 687 */
- 0, /* 688 */
- 0, /* 689 */
+ Tcl_NewWideUIntObj, /* 688 */
+ Tcl_SetWideUIntObj, /* 689 */
TclUnusedStubEntry, /* 690 */
};
diff --git a/generic/tclTest.c b/generic/tclTest.c
index d8fbb00..d04b715 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -22,11 +22,6 @@
# define USE_TCL_STUBS
#endif
#include "tclInt.h"
-#ifdef TCL_WITH_EXTERNAL_TOMMATH
-# include "tommath.h"
-#else
-# include "tclTomMath.h"
-#endif
#include "tclOO.h"
#include <math.h>
@@ -3436,29 +3431,12 @@ TestlinkCmd(
tmp = Tcl_NewWideIntObj(longVar);
Tcl_AppendElement(interp, Tcl_GetString(tmp));
Tcl_DecrRefCount(tmp);
-#ifdef TCL_WIDE_INT_IS_LONG
- if (ulongVar > WIDE_MAX) {
- mp_int bignumValue;
- if (mp_init_u64(&bignumValue, ulongVar) != MP_OKAY) {
- Tcl_Panic("%s: memory overflow", "Tcl_SetWideUIntObj");
- }
- tmp = Tcl_NewBignumObj(&bignumValue);
- } else
-#endif /* TCL_WIDE_INT_IS_LONG */
- tmp = Tcl_NewWideIntObj((Tcl_WideInt)ulongVar);
+ tmp = Tcl_NewWideUIntObj(ulongVar);
Tcl_AppendElement(interp, Tcl_GetString(tmp));
Tcl_DecrRefCount(tmp);
Tcl_PrintDouble(NULL, (double)floatVar, buffer);
Tcl_AppendElement(interp, buffer);
- if (uwideVar > WIDE_MAX) {
- mp_int bignumValue;
- if (mp_init_u64(&bignumValue, uwideVar) != MP_OKAY) {
- Tcl_Panic("%s: memory overflow", "Tcl_SetWideUIntObj");
- }
- tmp = Tcl_NewBignumObj(&bignumValue);
- } else {
- tmp = Tcl_NewWideIntObj((Tcl_WideInt)uwideVar);
- }
+ tmp = Tcl_NewWideUIntObj(uwideVar);
Tcl_AppendElement(interp, Tcl_GetString(tmp));
Tcl_DecrRefCount(tmp);
} else if (strcmp(argv[1], "set") == 0) {