TIP 650: New function Tcl_GetWideUIntFromObj()

EuroTcl/OpenACS 11 - 12 JULY 2024, VIENNA
Author:		Jan Nijtmans <[email protected]>
State:		Final
Type:		Project
Vote:		Done
Created:	15-Nov-2022
Tcl-Version:	8.7
Tcl-branch:	tip-650
Vote-Summary:	Accepted 2/0/0
Votes-For:	BG, JN
Votes-Against:	none
Votes-Present:	none


TIP 648 proposes addition of new functions Tcl_NewWideUIntObj and Tcl_SetWideUIntObj but missing the complementary function Tcl_GetWideUIntFromObj. While strictly not necessary as Tcl_GetNumberFromObj can be used for the purpose, that would require the extension writer to be familiar with mp_int manipulation. A Tcl_GetWideUIntFromObj would make extracting Tcl_WideUInt values easier.


The following function will be exported via the stubs table.

int Tcl_GetWideUIntFromObj(
    Tcl_Interp *interp,
    Tcl_Obj *objPtr,
    Tcl_WideUInt *uwidePtr);

If objPtr holds an non-negative integer value that fits in the domain of Tcl_WideUInt, the function returns TCL_OK and stores the value in *uwidePtr. Otherwise (non-integer or negative integer), the function returns TCL_ERROR and stores an error message in interp if it is not NULL.


Implementation is available in the tip-650 branch of the Tcl repository.


This document has been placed in the public domain.