mirror of
https://github.com/pybind/pybind11.git
synced 2024-12-01 01:17:10 +00:00
Add more integer conversions
This commit is contained in:
parent
fa1bfb2ec7
commit
5816d1f36b
@ -278,6 +278,8 @@ PYBIND11_TYPE_CASTER_NUMBER(int32_t, long, PyLong_AsLong, PyLong_FromLong)
|
||||
PYBIND11_TYPE_CASTER_NUMBER(uint32_t, unsigned long, PyLong_AsUnsignedLong, PyLong_FromUnsignedLong)
|
||||
PYBIND11_TYPE_CASTER_NUMBER(int64_t, PY_LONG_LONG, PyLong_AsLongLong_Fixed, PyLong_FromLongLong)
|
||||
PYBIND11_TYPE_CASTER_NUMBER(uint64_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong_Fixed, PyLong_FromUnsignedLongLong)
|
||||
PYBIND11_TYPE_CASTER_NUMBER(long long, PY_LONG_LONG, PyLong_AsLongLong_Fixed, PyLong_FromLongLong)
|
||||
PYBIND11_TYPE_CASTER_NUMBER(unsigned long long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong_Fixed, PyLong_FromUnsignedLongLong)
|
||||
|
||||
#if defined(__APPLE__) // size_t/ssize_t are separate types on Mac OS X
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
|
@ -253,6 +253,9 @@ public:
|
||||
#if !(defined(WIN32) || defined(__i386__)) || defined(_WIN64)
|
||||
int_(ssize_t value) : object(PyLong_FromSsize_t(value), false) { }
|
||||
#endif
|
||||
int_(unsigned value) : object(PyLong_FromUnsignedLong((unsigned long) value), false) { }
|
||||
int_(long long value) : object(PyLong_FromLongLong(value), false) { }
|
||||
int_(unsigned long long value) : object(PyLong_FromUnsignedLongLong(value), false) { }
|
||||
operator int() const { return (int) PyLong_AsLong(m_ptr); }
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user