MCPcopy Index your code
hub / github.com/apache/fory / py_long_to_integral_range

Function py_long_to_integral_range

python/pyfory/cpp/pyfory.cc:631–645  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

629
630template <typename T>
631static bool py_long_to_integral_range(PyObject *value, const char *type_name,
632 T *out) {
633 int64_t converted = 0;
634 if (!py_long_to_int64(value, &converted)) {
635 return false;
636 }
637 constexpr int64_t k_min = static_cast<int64_t>(std::numeric_limits<T>::min());
638 constexpr int64_t k_max = static_cast<int64_t>(std::numeric_limits<T>::max());
639 if (converted < k_min || converted > k_max) {
640 PyErr_Format(PyExc_OverflowError, "integer out of range for %s", type_name);
641 return false;
642 }
643 *out = static_cast<T>(converted);
644 return true;
645}
646
647template <typename T>
648static bool py_long_to_unsigned_range(PyObject *value, const char *type_name,

Callers

nothing calls this directly

Calls 1

py_long_to_int64Function · 0.85

Tested by

no test coverage detected