mirror of
https://github.com/pybind/pybind11.git
synced 2026-06-29 19:07:03 +00:00
[smart_holder] Simplification: Enable smart_holder functionality unconditionally. (#5531)
* git merge --squash purge_internals_versions_4_5
* Remove PYBIND11_HAS_INTERNALS_WITH_SMART_HOLDER_SUPPORT, set PYBIND11_INTERNALS_VERSION 7
* Remove all uses of PYBIND11_SMART_HOLDER_ENABLED under include/pybind11
* Remove obsolete PYBIND11_ACTUALLY_USING_SMART_HOLDER_AS_DEFAULT macro.
* Remove PYBIND11_SMART_HOLDER_ENABLED in ubench/holder_comparison.cpp
* Remove all uses of PYBIND11_SMART_HOLDER_ENABLED under tests/
* Remove `#define PYBIND11_SMART_HOLDER_ENABLED`
* Remove all uses of PYBIND11_SMART_HOLDER_TYPE_CASTERS under tests/
* Remove all uses of PYBIND11_TYPE_CASTER_BASE_HOLDER under tests/
* Add missing `#include <cstdint>`
Example error message (🐍 3.11 • ubuntu-latest • x64, GNU 13.3.0):
```
include/pybind11/detail/value_and_holder.h:56:52: error: ‘uint8_t’ is not a member of ‘std’; did you mean ‘wint_t’?
56 | inst->nonsimple.status[index] &= (std::uint8_t) ~instance::status_holder_constructed;
| ^~~~~~~
```
* Change PYBIND11_INTERNALS_VERSION to 106: It will be changed to 7 in a follow-on PR that actually changes the internals.
This commit is contained in:
committed by
GitHub
parent
dc37cba85d
commit
5ab036bf08
@@ -31,8 +31,6 @@ int get_from_cpp_plainc_ptr(const Base *b) { return b->get() + 4000; }
|
||||
|
||||
int get_from_cpp_unique_ptr(std::unique_ptr<Base> b) { return b->get() + 5000; }
|
||||
|
||||
#ifdef PYBIND11_SMART_HOLDER_ENABLED
|
||||
|
||||
struct BaseVirtualOverrider : Base, py::trampoline_self_life_support {
|
||||
using Base::Base;
|
||||
|
||||
@@ -45,24 +43,12 @@ struct CppDerivedVirtualOverrider : CppDerived, py::trampoline_self_life_support
|
||||
int get() const override { PYBIND11_OVERRIDE(int, CppDerived, get); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace class_sh_virtual_py_cpp_mix
|
||||
} // namespace pybind11_tests
|
||||
|
||||
using namespace pybind11_tests::class_sh_virtual_py_cpp_mix;
|
||||
|
||||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(Base)
|
||||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(CppDerivedPlain)
|
||||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(CppDerived)
|
||||
|
||||
TEST_SUBMODULE(class_sh_virtual_py_cpp_mix, m) {
|
||||
m.attr("defined_PYBIND11_SMART_HOLDER_ENABLED") =
|
||||
#ifndef PYBIND11_SMART_HOLDER_ENABLED
|
||||
false;
|
||||
#else
|
||||
true;
|
||||
|
||||
py::classh<Base, BaseVirtualOverrider>(m, "Base").def(py::init<>()).def("get", &Base::get);
|
||||
|
||||
py::classh<CppDerivedPlain, Base>(m, "CppDerivedPlain").def(py::init<>());
|
||||
@@ -71,5 +57,4 @@ TEST_SUBMODULE(class_sh_virtual_py_cpp_mix, m) {
|
||||
|
||||
m.def("get_from_cpp_plainc_ptr", get_from_cpp_plainc_ptr, py::arg("b"));
|
||||
m.def("get_from_cpp_unique_ptr", get_from_cpp_unique_ptr, py::arg("b"));
|
||||
#endif // PYBIND11_SMART_HOLDER_ENABLED
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user