Lines Matching defs:m_ptr

179     handle(PyObject *ptr) : m_ptr(ptr) { } // Allow implicit conversion from PyObject*
182 PyObject *ptr() const { return m_ptr; }
183 PyObject *&ptr() { return m_ptr; }
190 const handle& inc_ref() const & { Py_XINCREF(m_ptr); return *this; }
197 const handle& dec_ref() const & { Py_XDECREF(m_ptr); return *this; }
205 explicit operator bool() const { return m_ptr != nullptr; }
211 bool operator==(const handle &h) const { return m_ptr == h.m_ptr; }
213 bool operator!=(const handle &h) const { return m_ptr != h.m_ptr; }
215 bool check() const { return m_ptr != nullptr; }
217 PyObject *m_ptr = nullptr;
238 object(object &&other) noexcept { m_ptr = other.m_ptr; other.m_ptr = nullptr; }
248 PyObject *tmp = m_ptr;
249 m_ptr = nullptr;
256 m_ptr = other.m_ptr;
262 handle temp(m_ptr);
263 m_ptr = other.m_ptr;
264 other.m_ptr = nullptr;
786 bool check() const { return m_ptr != nullptr && (bool) CheckFun(m_ptr); } \
794 { if (!m_ptr) throw error_already_set(); } \
797 { if (!m_ptr) throw error_already_set(); } \
844 if (m_ptr && !value.ptr()) {
873 value = reinterpret_steal<object>(PyIter_Next(m_ptr));
894 if (!m_ptr) pybind11_fail("Could not allocate string object!");
900 if (!m_ptr) pybind11_fail("Could not allocate string object!");
915 if (PyUnicode_Check(m_ptr)) {
916 temp = reinterpret_steal<object>(PyUnicode_AsUTF8String(m_ptr));
962 if (!m_ptr) pybind11_fail("Could not allocate bytes object!");
967 if (!m_ptr) pybind11_fail("Could not allocate bytes object!");
978 if (PYBIND11_BYTES_AS_STRING_AND_SIZE(m_ptr, &buffer, &length))
998 m_ptr = obj.release().ptr();
1009 m_ptr = obj.release().ptr();
1032 operator bool() const { return m_ptr && PyLong_AsLong(m_ptr) != 0; }
1075 m_ptr = PyLong_FromLong((long) value);
1077 m_ptr = PyLong_FromUnsignedLong((unsigned long) value);
1080 m_ptr = PyLong_FromLongLong((long long) value);
1082 m_ptr = PyLong_FromUnsignedLongLong((unsigned long long) value);
1084 if (!m_ptr) pybind11_fail("Could not allocate int object!");
1091 ? detail::as_unsigned<T>(m_ptr)
1093 ? (T) PyLong_AsLong(m_ptr)
1094 : (T) PYBIND11_LONG_AS_LONGLONG(m_ptr);
1103 if (!m_ptr) pybind11_fail("Could not allocate float object!");
1106 if (!m_ptr) pybind11_fail("Could not allocate float object!");
1108 operator float() const { return (float) PyFloat_AsDouble(m_ptr); }
1109 operator double() const { return (double) PyFloat_AsDouble(m_ptr); }
1117 if (!m_ptr) pybind11_fail("Could not allocate weak reference!");
1126 m_ptr = PySlice_New(start.ptr(), stop.ptr(), step.ptr());
1127 if (!m_ptr) pybind11_fail("Could not allocate slice object!");
1131 return PySlice_GetIndicesEx((PYBIND11_SLICE_OBJECT *) m_ptr,
1138 return PySlice_GetIndicesEx((PYBIND11_SLICE_OBJECT *) m_ptr,
1153 if (!m_ptr)
1160 if (!m_ptr)
1165 m_ptr = PyCapsule_New(const_cast<void *>(value), nullptr, [](PyObject *o) {
1171 if (!m_ptr)
1174 if (PyCapsule_SetContext(m_ptr, (void *) destructor) != 0)
1179 m_ptr = PyCapsule_New(reinterpret_cast<void *>(destructor), nullptr, [](PyObject *o) {
1184 if (!m_ptr)
1190 T * result = static_cast<T *>(PyCapsule_GetPointer(m_ptr, name));
1195 const char *name() const { return PyCapsule_GetName(m_ptr); }
1202 if (!m_ptr) pybind11_fail("Could not allocate tuple object!");
1204 size_t size() const { return (size_t) PyTuple_Size(m_ptr); }
1209 detail::tuple_iterator end() const { return {*this, PyTuple_GET_SIZE(m_ptr)}; }
1216 if (!m_ptr) pybind11_fail("Could not allocate dict object!");
1224 size_t size() const { return (size_t) PyDict_Size(m_ptr); }
1230 return PyDict_Contains(m_ptr, detail::object_or_cast(std::forward<T>(key)).ptr()) == 1;
1245 size_t size() const { return (size_t) PySequence_Size(m_ptr); }
1250 detail::sequence_iterator end() const { return {*this, PySequence_Size(m_ptr)}; }
1257 if (!m_ptr) pybind11_fail("Could not allocate list object!");
1259 size_t size() const { return (size_t) PyList_Size(m_ptr); }
1264 detail::list_iterator end() const { return {*this, PyList_GET_SIZE(m_ptr)}; }
1266 PyList_Append(m_ptr, detail::object_or_cast(std::forward<T>(val)).ptr());
1269 PyList_Insert(m_ptr, static_cast<ssize_t>(index),
1281 if (!m_ptr) pybind11_fail("Could not allocate set object!");
1283 size_t size() const { return (size_t) PySet_Size(m_ptr); }
1286 return PySet_Add(m_ptr, detail::object_or_cast(std::forward<T>(val)).ptr()) == 0;
1288 void clear() const { PySet_Clear(m_ptr); }
1290 return PySet_Contains(m_ptr, detail::object_or_cast(std::forward<T>(val)).ptr()) == 1;
1298 handle fun = detail::get_function(m_ptr);
1319 if (PyObject_GetBuffer(m_ptr, view, flags) != 0) {
1351 m_ptr = PyMemoryView_FromBuffer(&buf);
1352 if (!m_ptr)