Remove remaining BAKEIN_BREAK in test_class_sh_property.cpp,py and adjust (simplify) the property_cpp_function<...unique_ptr...>::write implementation (all tests pass).

This PR (#5213) at this commit also passes ASAN, MSAN, UBSAN testing with the Google-internal toolchain.
This commit is contained in:
Ralf W. Grosse-Kunstleve 2024-07-12 02:33:30 -07:00
parent 0b14d5bce9
commit d373a082ad
3 changed files with 3 additions and 10 deletions

View File

@ -1771,12 +1771,7 @@ struct property_cpp_function<
template <typename PM, must_be_member_function_pointer<PM> = 0> template <typename PM, must_be_member_function_pointer<PM> = 0>
static cpp_function write(PM pm, const handle &hdl) { static cpp_function write(PM pm, const handle &hdl) {
detail::type_info *tinfo = detail::get_type_info(typeid(T), /*throw_if_missing=*/true); return cpp_function([pm](T &c, D &&value) { c.*pm = std::move(value); }, is_method(hdl));
if (tinfo->default_holder) {
return cpp_function([pm](T &c, D &&value) { c.*pm = std::move(value); },
is_method(hdl));
}
return cpp_function([pm](T &c, const D &value) { c.*pm = value; }, is_method(hdl));
} }
}; };

View File

@ -73,9 +73,9 @@ TEST_SUBMODULE(class_sh_property, m) {
.def_readwrite("m_cptr_readwrite", &Outer::m_cptr) .def_readwrite("m_cptr_readwrite", &Outer::m_cptr)
// .def_readonly("m_uqmp_readonly", &Outer::m_uqmp) // Custom compilation Error. // .def_readonly("m_uqmp_readonly", &Outer::m_uqmp) // Custom compilation Error.
// BAKEIN_BREAK .def_readwrite("m_uqmp_readwrite", &Outer::m_uqmp) .def_readwrite("m_uqmp_readwrite", &Outer::m_uqmp)
// .def_readonly("m_uqcp_readonly", &Outer::m_uqcp) // Custom compilation Error. // .def_readonly("m_uqcp_readonly", &Outer::m_uqcp) // Custom compilation Error.
// BAKEIN_BREAK .def_readwrite("m_uqcp_readwrite", &Outer::m_uqcp) .def_readwrite("m_uqcp_readwrite", &Outer::m_uqcp)
.def_readwrite("m_shmp_readonly", &Outer::m_shmp) .def_readwrite("m_shmp_readonly", &Outer::m_shmp)
.def_readwrite("m_shmp_readwrite", &Outer::m_shmp) .def_readwrite("m_shmp_readwrite", &Outer::m_shmp)

View File

@ -83,7 +83,6 @@ def test_ptr(field_type, num_default, outer_type, m_attr, r_kind):
@pytest.mark.parametrize("m_attr_readwrite", ["m_uqmp_readwrite", "m_uqcp_readwrite"]) @pytest.mark.parametrize("m_attr_readwrite", ["m_uqmp_readwrite", "m_uqcp_readwrite"])
def test_uqp(m_attr_readwrite): def test_uqp(m_attr_readwrite):
pytest.skip(f"BAKEIN_BREAK: {m_attr_readwrite} does not build")
outer = m.Outer() outer = m.Outer()
assert getattr(outer, m_attr_readwrite) is None assert getattr(outer, m_attr_readwrite) is None
field_orig = m.Field() field_orig = m.Field()
@ -136,7 +135,6 @@ def _proxy_dereference(proxy, xxxattr, *args, **kwargs):
@pytest.mark.parametrize("m_attr", ["m_uqmp", "m_uqcp"]) @pytest.mark.parametrize("m_attr", ["m_uqmp", "m_uqcp"])
def test_unique_ptr_field_proxy_poc(m_attr): def test_unique_ptr_field_proxy_poc(m_attr):
m_attr_readwrite = m_attr + "_readwrite" m_attr_readwrite = m_attr + "_readwrite"
pytest.skip(f"BAKEIN_BREAK: {m_attr_readwrite} does not build")
outer = m.Outer() outer = m.Outer()
field_orig = m.Field() field_orig = m.Field()
field_orig.num = 45 field_orig.num = 45