Objects/numobjects/intobject/ops

Search:
Group by:
Source   Edit  

Consts

PyLongBaseSet = {0, 2..36}
Source   Edit  

Procs

proc `%`(a, b: PyIntObject): PyObject {.cdecl, ...raises: [], tags: [RootEffect],
                                        forbids: [].}
Source   Edit  
proc `*`(a, b: PyIntObject): PyIntObject {....raises: [], tags: [RootEffect],
    forbids: [].}
Source   Edit  
proc `+`(a, b: PyIntObject): PyIntObject {....raises: [], tags: [RootEffect],
    forbids: [].}
Source   Edit  
proc `-`(a, b: PyIntObject): PyIntObject {....raises: [], tags: [RootEffect],
    forbids: [].}
Source   Edit  
proc `-`(a: PyIntObject): PyIntObject {....raises: [], tags: [RootEffect],
                                        forbids: [].}
Source   Edit  
proc `//`(a, b: PyIntObject): PyObject {.cdecl, ...raises: [], tags: [RootEffect],
    forbids: [].}
long_div Integer division
Note: this may returns ZeroDivisionError
Source   Edit  
proc `<`(a, b: PyIntObject): bool {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc `<`(aa: int; b: PyIntObject): bool {....raises: [], tags: [RootEffect],
    forbids: [].}
Source   Edit  
proc `==`(a, b: PyIntObject): bool {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc abs(self: PyIntObject): PyIntObject {....raises: [], tags: [RootEffect],
    forbids: [].}
Source   Edit  
func absToUInt[U: uint | uint8 | uint16](pyInt: PyIntObject; x: var U): bool {.
    cdecl.}
Source   Edit  
func absToUInt[U: uint32 | uint64 | BiggestUInt](pyInt: PyIntObject; x: var U): bool {.
    cdecl.}

EXT. unstable.

ignore signbit. returns false on overflow

Source   Edit  
proc asLongAndOverflow(vv: PyIntObject; ovlf: var bool): int {.inline,
    ...raises: [], tags: [], forbids: [].}
PyLong_AsLongAndOverflow Source   Edit  
proc divmod(a, b: PyIntObject): tuple[d, m: PyIntObject] {....raises: [ValueError],
    tags: [RootEffect], forbids: [].}
Source   Edit  
proc divmodNonZero(a, b: PyIntObject): tuple[d, m: PyIntObject] {....raises: [],
    tags: [RootEffect], forbids: [].}
export for builtins.divmod Source   Edit  
proc floorDivNonZero(a, b: PyIntObject): PyIntObject {....raises: [],
    tags: [RootEffect], forbids: [].}

long_div Integer division

assuming b is non-zero

Source   Edit  
proc format(i: PyIntObject; base: uint8; s: var string): PyBaseErrorObject {.
    ...raises: [], tags: [RootEffect], forbids: [].}
Source   Edit  
proc fromStr[C: char | Rune](s: openArray[C]): PyIntObject {.
    ...raises: [ValueError].}
This ignores sys.flags.int_max_str_digits Source   Edit  
proc fromStr[C: char | Rune](s: openArray[C]; res: var PyIntObject): int
with base = 0 (a.k.a. support prefix like 0b) and ignore sys.flags.int_max_str_digits Source   Edit  
proc fromStr[C: char](res: var PyIntObject; s: openArray[C]; nParsed: var int): PyBaseErrorObject
Source   Edit  
proc fromStr[C: char](res: var PyIntObject; s: openArray[C]; nParsed: var int;
                      base: int): PyBaseErrorObject
Source   Edit  
proc hash(self: PyIntObject): Hash {.inline, cdecl, ...raises: [], tags: [],
                                     forbids: [].}
Source   Edit  
proc newPyInt(dval: float): PyObject {....raises: [], tags: [RootEffect],
                                       forbids: [].}
Source   Edit  
proc newPyInt[C: char](smallInt: C): PyIntObject
Source   Edit  
proc newPyInt[C: Rune | char](str: openArray[C]): PyIntObject
Source   Edit  
proc pow(a, b: PyIntObject): PyIntObject {....raises: [], tags: [RootEffect],
    forbids: [].}
Source   Edit  
proc PyInt_OverflowCType(ctypeName: string): PyOverflowErrorObject {....raises: [],
    tags: [RootEffect], forbids: [].}
EXT. used to construct OverflowError of PyLong_As<ctypeName> So no need to call PyLong_AsXxx but toSomeXxInt Source   Edit  
proc PyLong_AsSize_t(pyInt: PyIntObject; res: var uint): PyOverflowErrorObject {.
    ...raises: [], tags: [RootEffect], forbids: [].}
Source   Edit  
proc PyLong_AsSize_t(v: PyObject; res: var uint): PyBaseErrorObject {.
    ...raises: [], tags: [RootEffect], forbids: [].}
Source   Edit  
proc PyLong_AsSsize_t(v: PyObject; res: var int): PyBaseErrorObject {.
    ...raises: [], tags: [RootEffect], forbids: [].}
Source   Edit  
proc PyLong_AsSsize_t(vv: PyIntObject; res: var int): PyOverflowErrorObject {.
    ...raises: [], tags: [RootEffect], forbids: [].}
returns nil if not overflow Source   Edit  
proc PyLong_FromString[C: char](s: openArray[C]; nParsed: var int;
                                base: int = 10): PyObject
Source   Edit  
proc toInt(pyInt: PyIntObject; overflow: var IntSign): int {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc toInt(pyInt: PyIntObject; res: var int): bool {....raises: [], tags: [],
    forbids: [].}
returns false on overflow (x not_in int.low..int.high) Source   Edit  
proc toSomeSignedInt[I: SomeSignedInt](pyInt: PyIntObject; 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: PyIntObject): T
XXX: the caller should take care of overflow It raises OverflowDefect on non-danger build Source   Edit  
proc toSomeUnsignedInt[U: SomeUnsignedInt](pyInt: PyIntObject;
    overflow: var IntSign): U
like toSomeSignedInt<#toInt,PyIntObject,IntSign>_ but for `uint Source   Edit  
proc toStringCheckThreshold(a: PyIntObject; v: var string): PyBaseErrorObject {.
    ...raises: [], tags: [RootEffect], forbids: [].}
this respects sys.flags.int_max_str_digits Source   Edit  
proc toUInt(pyInt: PyIntObject; overflow: var IntSign): uint {....raises: [],
    tags: [], forbids: [].}
like toInt<#toInt,PyIntObject,IntSign>_ but for `uint Source   Edit  
proc toUInt(pyInt: PyIntObject; res: var uint): bool {....raises: [], tags: [],
    forbids: [].}
like toInt<#toInt,PyIntObject,int>_ but for `uint Source   Edit  

Methods

method `$`(i: PyIntObject): string {....raises: [], tags: [RootEffect], forbids: [].}
this ignores sys.flags.int_max_str_digits, and may raises OverflowDefect if i contains too many digits Source   Edit  

Templates

template retInvIntCall(strObj: PyObject; base: SomeInteger) {.dirty.}
inner Source   Edit  
template toIntOrRetOF(vv: PyIntObject): int
a helper wrapper of PyLong_AsSsize_t return OverflowError for outer function Source   Edit