23 return (PyObject_IsTrue(obj) != 0);
29 PyLongObject* v =
nullptr;
33 if (vv == NULL || !PyLong_Check(vv)) {
34 if (vv != NULL && PyInt_Check(vv)) {
35 return PyInt_AsLong(vv);
40 v =
reinterpret_cast<PyLongObject*
>(vv);
42 i = n ? -Py_SIZE(v) : Py_SIZE(v);
47 x = (x << PyLong_SHIFT) | v->ob_digit[i];
48 if ((x >> PyLong_SHIFT) != prev)
52 return (n ? ((~x)+1) : x);
58 PyLongObject* v =
nullptr;
62 if (vv == NULL || !PyLong_Check(vv)) {
63 if (vv != NULL && PyInt_Check(vv)) {
64 return PyInt_AsLong(vv);
69 v =
reinterpret_cast<PyLongObject*
>(vv);
71 i = n ? -Py_SIZE(v) : Py_SIZE(v);
76 x = (x << PyLong_SHIFT) | v->ob_digit[i];
77 if ((x >> PyLong_SHIFT) != prev)
81 return (n ? ((~x)+1) : x);
87 PyLongObject* v =
nullptr;
91 if (vv == NULL || !PyLong_Check(vv)) {
92 if (vv != NULL && PyInt_Check(vv)) {
93 return PyInt_AsLong(vv);
98 v =
reinterpret_cast<PyLongObject*
>(vv);
100 i = n ? -Py_SIZE(v) : Py_SIZE(v);
105 x = (x << PyLong_SHIFT) | v->ob_digit[i];
106 if ((x >> PyLong_SHIFT) != prev)
110 return (n ? ((~x)+1) : x);
116 PyLongObject* v =
nullptr;
120 if (vv == NULL || !PyLong_Check(vv)) {
121 if (vv != NULL && PyInt_Check(vv)) {
122 return PyInt_AsLong(vv);
127 v =
reinterpret_cast<PyLongObject*
>(vv);
128 n = (Py_SIZE(v) < 0);
129 i = n ? -Py_SIZE(v) : Py_SIZE(v);
134 x = (x << PyLong_SHIFT) | v->ob_digit[i];
135 if ((x >> PyLong_SHIFT) != prev)
139 return (n ? ((~x)+1) : x);
145 PyLongObject* v =
nullptr;
149 if (vv == NULL || !PyLong_Check(vv)) {
150 if (vv != NULL && PyInt_Check(vv)) {
151 return PyInt_AsLong(vv);
156 v =
reinterpret_cast<PyLongObject*
>(vv);
157 n = (Py_SIZE(v) < 0);
158 i = n ? -Py_SIZE(v) : Py_SIZE(v);
163 x = (x << PyLong_SHIFT) | v->ob_digit[i];
164 if ((x >> PyLong_SHIFT) != prev)
168 return (n ? ((~x)+1) : x);
174 PyLongObject* v =
nullptr;
178 if (vv == NULL || !PyLong_Check(vv)) {
179 if (vv != NULL && PyInt_Check(vv)) {
180 return PyInt_AsLong(vv);
185 v =
reinterpret_cast<PyLongObject*
>(vv);
186 n = (Py_SIZE(v) < 0);
187 i = n ? -Py_SIZE(v) : Py_SIZE(v);
192 x = (x << PyLong_SHIFT) | v->ob_digit[i];
193 if ((x >> PyLong_SHIFT) != prev)
197 return (n ? ((~x)+1) : x);
203 PyLongObject* v =
nullptr;
207 if (vv == NULL || !PyLong_Check(vv)) {
208 if (vv != NULL && PyInt_Check(vv)) {
209 return PyInt_AsLong(vv);
214 v =
reinterpret_cast<PyLongObject*
>(vv);
215 n = (Py_SIZE(v) < 0);
216 i = n ? -Py_SIZE(v) : Py_SIZE(v);
221 x = (x << PyLong_SHIFT) | v->ob_digit[i];
222 if ((x >> PyLong_SHIFT) != prev)
226 return (n ? ((~x)+1) : x);
232 #if defined(__i386) || defined(_M_IX86)
233 return PyInt_FromLong(
static_cast<long>(value));
240 if (value <= std::numeric_limits<long>::max())
241 return PyInt_FromLong(
static_cast<long>(value));
250 v = _PyLong_New(ndigits);
251 digit* p = v->ob_digit;
252 #if PY_VERSION_HEX >= 0x030a00f0
253 Py_SET_SIZE(v, ndigits);
255 Py_SIZE(v) = ndigits;
258 *p++ =
static_cast<digit
>(value & PyLong_MASK);
259 value >>= PyLong_SHIFT;
269 #if defined(__i386) || defined(_M_IX86)
270 return PyInt_FromLong(
static_cast<long>(value));
277 if (value <= std::numeric_limits<long>::max())
278 return PyInt_FromLong(
static_cast<long>(value));
287 v = _PyLong_New(ndigits);
288 digit* p = v->ob_digit;
289 #if PY_VERSION_HEX >= 0x030a00f0
290 Py_SET_SIZE(v, ndigits);
292 Py_SIZE(v) = ndigits;
295 *p++ =
static_cast<digit
>(value & PyLong_MASK);
296 value >>= PyLong_SHIFT;
306 return PyInt_FromLong(
static_cast<long>(value));
317 if (value <= std::numeric_limits<long>::max())
318 return PyInt_FromLong(
static_cast<long>(value));
327 v = _PyLong_New(ndigits);
328 digit* p = v->ob_digit;
329 #if PY_VERSION_HEX >= 0x030a00f0
330 Py_SET_SIZE(v, ndigits);
332 Py_SIZE(v) = ndigits;
335 *p++ =
static_cast<digit
>(value & PyLong_MASK);
336 value >>= PyLong_SHIFT;
350 if (value <= std::numeric_limits<long>::max())
351 return PyInt_FromLong(
static_cast<long>(value));
360 v = _PyLong_New(ndigits);
361 digit* p = v->ob_digit;
362 #if PY_VERSION_HEX >= 0x030a00f0
363 Py_SET_SIZE(v, ndigits);
365 Py_SIZE(v) = ndigits;
368 *p++ =
static_cast<digit
>(value & PyLong_MASK);
369 value >>= PyLong_SHIFT;
383 if (value <= std::numeric_limits<long>::max())
384 return PyInt_FromLong(
static_cast<long>(value));
393 v = _PyLong_New(ndigits);
394 digit* p = v->ob_digit;
395 #if PY_VERSION_HEX >= 0x030a00f0
396 Py_SET_SIZE(v, ndigits);
398 Py_SIZE(v) = ndigits;
401 *p++ =
static_cast<digit
>(value & PyLong_MASK);
402 value >>= PyLong_SHIFT;
416 if (value <= std::numeric_limits<long>::max())
417 return PyInt_FromLong(
static_cast<long>(value));
426 v = _PyLong_New(ndigits);
427 digit* p = v->ob_digit;
428 #if PY_VERSION_HEX >= 0x030a00f0
429 Py_SET_SIZE(v, ndigits);
431 Py_SIZE(v) = ndigits;
434 *p++ =
static_cast<digit
>(value & PyLong_MASK);
435 value >>= PyLong_SHIFT;
The exception class used by bindings.
PyObject * PyLong_FromUint(triton::__uint value)
Returns a pyObject from a triton::__uint.
triton::uint64 PyLong_AsUint64(PyObject *vv)
Returns a triton::uint64 from a pyObject.
triton::uint128 PyLong_AsUint128(PyObject *vv)
Returns a triton::uint128 from a pyObject.
PyObject * PyLong_FromUsize(triton::usize value)
Returns a pyObject from a triton::usize.
triton::__uint PyLong_AsUint(PyObject *vv)
Returns a triton::__uint from a pyObject.
PyObject * PyLong_FromUint256(triton::uint256 value)
Returns a pyObject from a triton::uint256.
bool PyLong_AsBool(PyObject *obj)
Returns a bool from a pyObject.
PyObject * PyLong_FromUint512(triton::uint512 value)
Returns a pyObject from a triton::uint512.
triton::uint512 PyLong_AsUint512(PyObject *vv)
Returns a triton::uint512 from a pyObject.
triton::uint256 PyLong_AsUint256(PyObject *vv)
Returns a triton::uint256 from a pyObject.
PyObject * PyLong_FromUint64(triton::uint64 value)
Returns a pyObject from a triton::uint64.
triton::uint32 PyLong_AsUint32(PyObject *vv)
Returns a triton::uint32 from a pyObject.
triton::usize PyLong_AsUsize(PyObject *vv)
Returns a triton::usize from a pyObject.
PyObject * PyLong_FromUint128(triton::uint128 value)
Returns a pyObject from a triton::uint128.
PyObject * PyLong_FromUint32(triton::uint32 value)
Returns a pyObject from a triton::uint32.
std::size_t usize
unsigned MAX_INT 32 or 64 bits according to the CPU.
std::uint64_t uint64
unisgned 64-bits
std::uint32_t uint32
unisgned 32-bits
unsigned long long __uint
unsigned long long if the arch is 64-bits.