| 1808 | PYBIND11_NAMESPACE_END(detail) |
| 1809 | |
| 1810 | class int_ : public object { |
| 1811 | public: |
| 1812 | PYBIND11_OBJECT_CVT(int_, object, PYBIND11_LONG_CHECK, PyNumber_Long) |
| 1813 | int_() : object(PyLong_FromLong(0), stolen_t{}) {} |
| 1814 | // Allow implicit conversion from C++ integral types: |
| 1815 | template <typename T, detail::enable_if_t<std::is_integral<T>::value, int> = 0> |
| 1816 | // NOLINTNEXTLINE(google-explicit-constructor) |
| 1817 | int_(T value) { |
| 1818 | if (sizeof(T) <= sizeof(long)) { |
| 1819 | if (std::is_signed<T>::value) { |
| 1820 | m_ptr = PyLong_FromLong((long) value); |
| 1821 | } else { |
| 1822 | m_ptr = PyLong_FromUnsignedLong((unsigned long) value); |
| 1823 | } |
| 1824 | } else { |
| 1825 | if (std::is_signed<T>::value) { |
| 1826 | m_ptr = PyLong_FromLongLong((long long) value); |
| 1827 | } else { |
| 1828 | m_ptr = PyLong_FromUnsignedLongLong((unsigned long long) value); |
| 1829 | } |
| 1830 | } |
| 1831 | if (!m_ptr) { |
| 1832 | pybind11_fail("Could not allocate int object!"); |
| 1833 | } |
| 1834 | } |
| 1835 | |
| 1836 | template <typename T, detail::enable_if_t<std::is_integral<T>::value, int> = 0> |
| 1837 | // NOLINTNEXTLINE(google-explicit-constructor) |
| 1838 | operator T() const { |
| 1839 | return std::is_unsigned<T>::value ? detail::as_unsigned<T>(m_ptr) |
| 1840 | : sizeof(T) <= sizeof(long) ? (T) PyLong_AsLong(m_ptr) |
| 1841 | : (T) PYBIND11_LONG_AS_LONGLONG(m_ptr); |
| 1842 | } |
| 1843 | }; |
| 1844 | |
| 1845 | class float_ : public object { |
| 1846 | public: |
no outgoing calls
no test coverage detected