mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-11 16:13:53 +00:00
Merge branch 'master' into sh_merge_master
This commit is contained in:
commit
a0a30c4532
@ -522,7 +522,7 @@ struct instance {
|
|||||||
void allocate_layout();
|
void allocate_layout();
|
||||||
|
|
||||||
/// Destroys/deallocates all of the above
|
/// Destroys/deallocates all of the above
|
||||||
void deallocate_layout() const;
|
void deallocate_layout();
|
||||||
|
|
||||||
/// Returns the value_and_holder wrapper for the given type (or the first, if `find_type`
|
/// Returns the value_and_holder wrapper for the given type (or the first, if `find_type`
|
||||||
/// omitted). Returns a default-constructed (with `.inst = nullptr`) object on failure if
|
/// omitted). Returns a default-constructed (with `.inst = nullptr`) object on failure if
|
||||||
|
@ -241,7 +241,8 @@ struct value_and_holder {
|
|||||||
? inst->simple_holder_constructed
|
? inst->simple_holder_constructed
|
||||||
: (inst->nonsimple.status[index] & instance::status_holder_constructed) != 0u;
|
: (inst->nonsimple.status[index] & instance::status_holder_constructed) != 0u;
|
||||||
}
|
}
|
||||||
void set_holder_constructed(bool v = true) const {
|
// NOLINTNEXTLINE(readability-make-member-function-const)
|
||||||
|
void set_holder_constructed(bool v = true) {
|
||||||
if (inst->simple_layout)
|
if (inst->simple_layout)
|
||||||
inst->simple_holder_constructed = v;
|
inst->simple_holder_constructed = v;
|
||||||
else if (v)
|
else if (v)
|
||||||
@ -254,7 +255,8 @@ struct value_and_holder {
|
|||||||
? inst->simple_instance_registered
|
? inst->simple_instance_registered
|
||||||
: ((inst->nonsimple.status[index] & instance::status_instance_registered) != 0);
|
: ((inst->nonsimple.status[index] & instance::status_instance_registered) != 0);
|
||||||
}
|
}
|
||||||
void set_instance_registered(bool v = true) const {
|
// NOLINTNEXTLINE(readability-make-member-function-const)
|
||||||
|
void set_instance_registered(bool v = true) {
|
||||||
if (inst->simple_layout)
|
if (inst->simple_layout)
|
||||||
inst->simple_instance_registered = v;
|
inst->simple_instance_registered = v;
|
||||||
else if (v)
|
else if (v)
|
||||||
@ -397,7 +399,8 @@ PYBIND11_NOINLINE void instance::allocate_layout() {
|
|||||||
owned = true;
|
owned = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PYBIND11_NOINLINE void instance::deallocate_layout() const {
|
// NOLINTNEXTLINE(readability-make-member-function-const)
|
||||||
|
PYBIND11_NOINLINE void instance::deallocate_layout() {
|
||||||
if (!simple_layout)
|
if (!simple_layout)
|
||||||
PyMem_Free(nonsimple.values_and_holders);
|
PyMem_Free(nonsimple.values_and_holders);
|
||||||
}
|
}
|
||||||
|
@ -1393,7 +1393,7 @@ public:
|
|||||||
bool empty() const { return size() == 0; }
|
bool empty() const { return size() == 0; }
|
||||||
detail::dict_iterator begin() const { return {*this, 0}; }
|
detail::dict_iterator begin() const { return {*this, 0}; }
|
||||||
detail::dict_iterator end() const { return {}; }
|
detail::dict_iterator end() const { return {}; }
|
||||||
void clear() const { PyDict_Clear(ptr()); }
|
void clear() /* py-non-const */ { PyDict_Clear(ptr()); }
|
||||||
template <typename T> bool contains(T &&key) const {
|
template <typename T> bool contains(T &&key) const {
|
||||||
return PyDict_Contains(m_ptr, detail::object_or_cast(std::forward<T>(key)).ptr()) == 1;
|
return PyDict_Contains(m_ptr, detail::object_or_cast(std::forward<T>(key)).ptr()) == 1;
|
||||||
}
|
}
|
||||||
@ -1435,10 +1435,10 @@ public:
|
|||||||
detail::item_accessor operator[](handle h) const { return object::operator[](h); }
|
detail::item_accessor operator[](handle h) const { return object::operator[](h); }
|
||||||
detail::list_iterator begin() const { return {*this, 0}; }
|
detail::list_iterator begin() const { return {*this, 0}; }
|
||||||
detail::list_iterator end() const { return {*this, PyList_GET_SIZE(m_ptr)}; }
|
detail::list_iterator end() const { return {*this, PyList_GET_SIZE(m_ptr)}; }
|
||||||
template <typename T> void append(T &&val) const {
|
template <typename T> void append(T &&val) /* py-non-const */ {
|
||||||
PyList_Append(m_ptr, detail::object_or_cast(std::forward<T>(val)).ptr());
|
PyList_Append(m_ptr, detail::object_or_cast(std::forward<T>(val)).ptr());
|
||||||
}
|
}
|
||||||
template <typename T> void insert(size_t index, T &&val) const {
|
template <typename T> void insert(size_t index, T &&val) /* py-non-const */ {
|
||||||
PyList_Insert(m_ptr, static_cast<ssize_t>(index),
|
PyList_Insert(m_ptr, static_cast<ssize_t>(index),
|
||||||
detail::object_or_cast(std::forward<T>(val)).ptr());
|
detail::object_or_cast(std::forward<T>(val)).ptr());
|
||||||
}
|
}
|
||||||
@ -1455,10 +1455,10 @@ public:
|
|||||||
}
|
}
|
||||||
size_t size() const { return (size_t) PySet_Size(m_ptr); }
|
size_t size() const { return (size_t) PySet_Size(m_ptr); }
|
||||||
bool empty() const { return size() == 0; }
|
bool empty() const { return size() == 0; }
|
||||||
template <typename T> bool add(T &&val) const {
|
template <typename T> bool add(T &&val) /* py-non-const */ {
|
||||||
return PySet_Add(m_ptr, detail::object_or_cast(std::forward<T>(val)).ptr()) == 0;
|
return PySet_Add(m_ptr, detail::object_or_cast(std::forward<T>(val)).ptr()) == 0;
|
||||||
}
|
}
|
||||||
void clear() const { PySet_Clear(m_ptr); }
|
void clear() /* py-non-const */ { PySet_Clear(m_ptr); }
|
||||||
template <typename T> bool contains(T &&val) const {
|
template <typename T> bool contains(T &&val) const {
|
||||||
return PySet_Contains(m_ptr, detail::object_or_cast(std::forward<T>(val)).ptr()) == 1;
|
return PySet_Contains(m_ptr, detail::object_or_cast(std::forward<T>(val)).ptr()) == 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user