diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-11-21 23:58:15 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-11-21 23:58:15 (GMT) |
| commit | 62077a6bd15376a91a4390646dc5c28448aa367e (patch) | |
| tree | ba795acd3cf49f1f7fac05e4de275557f5f21841 /generic/tclObj.c | |
| parent | c1e4942181ef1b8b60b89bfe5983b410080cd477 (diff) | |
| parent | 2f3087ea8f42ed192da6b35b4cd230cb74f0fd6a (diff) | |
| download | tcl-62077a6bd15376a91a4390646dc5c28448aa367e.zip tcl-62077a6bd15376a91a4390646dc5c28448aa367e.tar.gz tcl-62077a6bd15376a91a4390646dc5c28448aa367e.tar.bz2 | |
Rebase to 8.7
Diffstat (limited to 'generic/tclObj.c')
| -rw-r--r-- | generic/tclObj.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/generic/tclObj.c b/generic/tclObj.c index e496b1e..714ae71 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -3219,6 +3219,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 @@ -3312,6 +3339,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); + } +} /* *---------------------------------------------------------------------- |
