TIP 481: Extend size range of various Tcl_Get*() functions

FlightAware bounty program for improvements to Tcl and certain Tcl packages.
Author:         Jan Nijtmans <jan.nijtmans@gmail.com>
State:          Draft
Type:           Project
Vote:           Pending
Created:        27-Oct-2017
Keywords:       Tcl
Tcl-Version:    8.7


This TIP proposes enhancing various C API functions which now have int * parameter, to be used as if they have a size_t * parameter. In addition, a new Tcl_GetValue() function is proposed which can retrieve a signed or unsigned integer from a Tcl_Obj, or a float/double/long double.


In Tcl 9, the range of various functions need to be increased. For example Tcl_GetStringFromObj now is limited to returning 32 bit for the maximum string length. This can be fixed by introducing an internal function Tcl_GetStringFromObj2() which has a size_t * parameter in stead of int *. Tcl_GetStringFromObj will be converted to a macro, which switches between the two possible functions depending on the size of the parameter.

This way, we have a compatibility layer, easing the transition to Tcl 9. Extensions can already start using the extended range, even though it actually doesn't have effect in Tcl 8 yet.




See the tip-481 branch in Tcl's fossil repository https://core.tcl.tk/tcl/timeline?r=tip-481 .