src/intobject/ops_toint

Source   Edit  

Procs

func absToUInt[U: uint8 | uint16](pyInt: IntObject; x: var U): bool {.cdecl.}
Source   Edit  
func absToUInt[U: uint32 | uint64 | BiggestUInt | uint](pyInt: IntObject;
    x: var U): bool {.cdecl.}

try storing absolute value on x

returns false on overflow

Source   Edit  
proc asLongAndOverflow(vv: IntObject; ovlf: var bool): int {.inline, ...raises: [],
    tags: [], forbids: [].}
PyLong_AsLongAndOverflow Source   Edit  
proc toInt(pyInt: IntObject; overflow: var IntSign): int {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc toInt(pyInt: IntObject; res: var int): bool {....raises: [], tags: [],
    forbids: [].}
returns false on overflow (x not_in int.low..int.high) Source   Edit  
func toInt[T: SomeInteger](x: IntObject): Option[T]
Source   Edit  
proc toSomeSignedInt[I: SomeSignedInt](pyInt: IntObject; overflow: var IntSign): I

if overflow, overflow will be IntSign.Negative or IntSign.Positive (depending the sign of the argument) and result be `-1

Otherwise, overflow will be IntSign.Zero

Source   Edit  
proc toSomeSignedIntUnsafe[T: SomeSignedInt](pyInt: IntObject): T
XXX: the caller should take care of overflow It raises OverflowDefect on non-danger build Source   Edit  
proc toSomeUnsignedInt[U: SomeUnsignedInt](pyInt: IntObject;
    overflow: var IntSign): U
like toSomeSignedInt<#toInt,IntObject,IntSign>_ but for `uint Source   Edit  
proc toUInt(pyInt: IntObject; overflow: var IntSign): uint {....raises: [],
    tags: [], forbids: [].}
like toInt<#toInt,IntObject,IntSign>_ but for `uint Source   Edit  
proc toUInt(pyInt: IntObject; res: var uint): bool {....raises: [], tags: [],
    forbids: [].}
like toInt<#toInt,IntObject,int>_ but for `uint Source   Edit  

Templates

template toIntOrRetOF(vv: IntObject): int
a helper wrapper of PyLong_AsSsize_t return OverflowError for outer function Source   Edit