Lines Matching refs:ptr

51     The only requirement for `Derived` is to implement ``PyObject *Derived::ptr() const``.
114 bool is(object_api const& other) const { return derived().ptr() == other.derived().ptr(); }
116 bool is_none() const { return derived().ptr() == Py_None; }
153 int ref_count() const { return static_cast<int>(Py_REFCNT(derived().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; }
327 PyErr_Fetch(&m_type.ptr(), &m_value.ptr(), &m_trace.ptr());
338 void restore() { PyErr_Restore(m_type.release().ptr(), m_value.release().ptr(), m_trace.release().ptr()); }
347 bool matches(handle exc) const { return PyErr_GivenExceptionMatches(m_type.ptr(), exc.ptr()); }
374 template <> inline bool isinstance<object>(handle obj) { return obj.ptr() != nullptr; }
379 const auto result = PyObject_IsInstance(obj.ptr(), type.ptr());
388 return PyObject_HasAttr(obj.ptr(), name.ptr()) == 1;
392 return PyObject_HasAttrString(obj.ptr(), name) == 1;
396 if (PyObject_DelAttr(obj.ptr(), name.ptr()) != 0) { throw error_already_set(); }
400 if (PyObject_DelAttrString(obj.ptr(), name) != 0) { throw error_already_set(); }
404 PyObject *result = PyObject_GetAttr(obj.ptr(), name.ptr());
410 PyObject *result = PyObject_GetAttrString(obj.ptr(), name);
416 if (PyObject *result = PyObject_GetAttr(obj.ptr(), name.ptr())) {
425 if (PyObject *result = PyObject_GetAttrString(obj.ptr(), name)) {
434 if (PyObject_SetAttr(obj.ptr(), name.ptr(), value.ptr()) != 0) { throw error_already_set(); }
438 if (PyObject_SetAttrString(obj.ptr(), name, value.ptr()) != 0) { throw error_already_set(); }
442 auto h = PyObject_Hash(obj.ptr());
453 if (PyInstanceMethod_Check(value.ptr()))
454 value = PyInstanceMethod_GET_FUNCTION(value.ptr());
457 if (PyMethod_Check(value.ptr()))
458 value = PyMethod_GET_FUNCTION(value.ptr());
472 inline handle object_or_cast(PyObject *ptr) { return ptr; }
508 PyObject *ptr() const { return get_cache().ptr(); }
540 PyObject *result = PyObject_GetItem(obj.ptr(), key.ptr());
546 if (PyObject_SetItem(obj.ptr(), key.ptr(), val.ptr()) != 0) { throw error_already_set(); }
554 PyObject *result = PySequence_GetItem(obj.ptr(), static_cast<ssize_t>(index));
561 if (PySequence_SetItem(obj.ptr(), static_cast<ssize_t>(index), val.ptr()) != 0) {
571 PyObject *result = PyList_GetItem(obj.ptr(), static_cast<ssize_t>(index));
578 if (PyList_SetItem(obj.ptr(), static_cast<ssize_t>(index), val.inc_ref().ptr()) != 0) {
588 PyObject *result = PyTuple_GetItem(obj.ptr(), static_cast<ssize_t>(index));
595 if (PyTuple_SetItem(obj.ptr(), static_cast<ssize_t>(index), val.inc_ref().ptr()) != 0) {
659 sequence_fast_readonly(handle obj, ssize_t n) : ptr(PySequence_Fast_ITEMS(obj.ptr()) + n) { }
661 reference dereference() const { return *ptr; }
662 void increment() { ++ptr; }
663 void decrement() { --ptr; }
664 void advance(ssize_t n) { ptr += n; }
665 bool equal(const sequence_fast_readonly &b) const { return ptr == b.ptr; }
666 ssize_t distance_to(const sequence_fast_readonly &b) const { return ptr - b.ptr; }
669 PyObject **ptr;
706 void increment() { if (!PyDict_Next(obj.ptr(), &pos, &key, &value)) { pos = -1; } }
787 static bool check_(handle h) { return h.ptr() != nullptr && CheckFun(h.ptr()); }
793 : Parent(check_(o) ? o.inc_ref().ptr() : ConvertFun(o.ptr()), stolen_t{}) \
796 : Parent(check_(o) ? o.release().ptr() : ConvertFun(o.ptr()), stolen_t{}) \
844 if (m_ptr && !value.ptr()) {
868 friend bool operator==(const iterator &a, const iterator &b) { return a->ptr() == b->ptr(); }
869 friend bool operator!=(const iterator &a, const iterator &b) { return a->ptr() != b->ptr(); }
911 explicit str(handle h) : object(raw_str(h.ptr()), stolen_t{}) { }
922 if (PYBIND11_BYTES_AS_STRING_AND_SIZE(temp.ptr(), &buffer, &length))
986 if (PyUnicode_Check(s.ptr())) {
987 temp = reinterpret_steal<object>(PyUnicode_AsUTF8String(s.ptr()));
993 if (PYBIND11_BYTES_AS_STRING_AND_SIZE(temp.ptr(), &buffer, &length))
998 m_ptr = obj.release().ptr();
1004 if (PYBIND11_BYTES_AS_STRING_AND_SIZE(b.ptr(), &buffer, &length))
1009 m_ptr = obj.release().ptr();
1039 return handle(value ? Py_True : Py_False).inc_ref().ptr();
1116 : object(PyWeakref_NewRef(obj.ptr(), callback.ptr()), stolen_t{}) {
1126 m_ptr = PySlice_New(start.ptr(), stop.ptr(), step.ptr());
1149 capsule(PyObject *ptr, bool is_borrowed) : object(is_borrowed ? object(ptr, borrowed_t{}) : object(ptr, stolen_t{})) { }
1167 void *ptr = PyCapsule_GetPointer(o, nullptr);
1168 destructor(ptr);
1228 void clear() const { PyDict_Clear(ptr()); }
1230 return PyDict_Contains(m_ptr, detail::object_or_cast(std::forward<T>(key)).ptr()) == 1;
1237 return handle(op).inc_ref().ptr();
1266 PyList_Append(m_ptr, detail::object_or_cast(std::forward<T>(val)).ptr());
1270 detail::object_or_cast(std::forward<T>(val)).ptr());
1286 return PySet_Add(m_ptr, detail::object_or_cast(std::forward<T>(val)).ptr()) == 0;
1290 return PySet_Contains(m_ptr, detail::object_or_cast(std::forward<T>(val)).ptr()) == 1;
1299 if (fun && PyCFunction_Check(fun.ptr()))
1334 buf.buf = info.ptr;
1363 ssize_t result = PyObject_Length(h.ptr());
1371 ssize_t result = PyObject_LengthHint(h.ptr(), 0);
1373 ssize_t result = PyObject_Length(h.ptr());
1385 PyObject *str_value = PyObject_Repr(h.ptr());
1396 PyObject *result = PyObject_GetIter(obj.ptr());
1418 return args_proxy(derived().ptr());
1431 handle object_api<D>::get_type() const { return (PyObject *) Py_TYPE(derived().ptr()); }
1435 int rv = PyObject_RichCompareBool(derived().ptr(), other.derived().ptr(), value);
1443 object result = reinterpret_steal<object>(fn(derived().ptr())); \
1444 if (!result.ptr()) \
1453 fn(derived().ptr(), other.derived().ptr())); \
1454 if (!result.ptr()) \