mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-11 08:03:55 +00:00
Backport non-functional test_class_sh_*.cpp changes from PR #5213: 1. To avoid compiler warnings for unused code in the unnamed namespace. 2. To avoid clang-format changes. (#5258)
This commit is contained in:
parent
51a968c954
commit
ec557ff612
@ -50,6 +50,7 @@ PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::FooSmHld)
|
|||||||
namespace pybind11_tests {
|
namespace pybind11_tests {
|
||||||
|
|
||||||
TEST_SUBMODULE(class_sh_shared_ptr_copy_move, m) {
|
TEST_SUBMODULE(class_sh_shared_ptr_copy_move, m) {
|
||||||
|
#if true // Trick to avoid clang-format changes, in support of PR #5213.
|
||||||
namespace py = pybind11;
|
namespace py = pybind11;
|
||||||
|
|
||||||
py::class_<FooShPtr, std::shared_ptr<FooShPtr>>(m, "FooShPtr")
|
py::class_<FooShPtr, std::shared_ptr<FooShPtr>>(m, "FooShPtr")
|
||||||
@ -107,6 +108,7 @@ TEST_SUBMODULE(class_sh_shared_ptr_copy_move, m) {
|
|||||||
l.append(std::move(o));
|
l.append(std::move(o));
|
||||||
return l;
|
return l;
|
||||||
});
|
});
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace pybind11_tests
|
} // namespace pybind11_tests
|
||||||
|
@ -76,11 +76,12 @@ void wrap(py::module_ m, const char *py_class_name) {
|
|||||||
} // namespace class_sh_trampoline_basic
|
} // namespace class_sh_trampoline_basic
|
||||||
} // namespace pybind11_tests
|
} // namespace pybind11_tests
|
||||||
|
|
||||||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::class_sh_trampoline_basic::Abase<0>)
|
using namespace pybind11_tests::class_sh_trampoline_basic;
|
||||||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::class_sh_trampoline_basic::Abase<1>)
|
|
||||||
|
PYBIND11_SMART_HOLDER_TYPE_CASTERS(Abase<0>)
|
||||||
|
PYBIND11_SMART_HOLDER_TYPE_CASTERS(Abase<1>)
|
||||||
|
|
||||||
TEST_SUBMODULE(class_sh_trampoline_basic, m) {
|
TEST_SUBMODULE(class_sh_trampoline_basic, m) {
|
||||||
using namespace pybind11_tests::class_sh_trampoline_basic;
|
|
||||||
wrap<0>(m, "Abase0");
|
wrap<0>(m, "Abase0");
|
||||||
wrap<1>(m, "Abase1");
|
wrap<1>(m, "Abase1");
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace {
|
namespace pybind11_tests {
|
||||||
|
namespace class_sh_trampoline_self_life_support {
|
||||||
|
|
||||||
struct Big5 { // Also known as "rule of five".
|
struct Big5 { // Also known as "rule of five".
|
||||||
std::string history;
|
std::string history;
|
||||||
@ -41,7 +42,10 @@ struct Big5Trampoline : Big5, py::trampoline_self_life_support {
|
|||||||
using Big5::Big5;
|
using Big5::Big5;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace class_sh_trampoline_self_life_support
|
||||||
|
} // namespace pybind11_tests
|
||||||
|
|
||||||
|
using namespace pybind11_tests::class_sh_trampoline_self_life_support;
|
||||||
|
|
||||||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(Big5)
|
PYBIND11_SMART_HOLDER_TYPE_CASTERS(Big5)
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace {
|
namespace pybind11_tests {
|
||||||
|
namespace class_sh_trampoline_shared_from_this {
|
||||||
|
|
||||||
struct Sft : std::enable_shared_from_this<Sft> {
|
struct Sft : std::enable_shared_from_this<Sft> {
|
||||||
std::string history;
|
std::string history;
|
||||||
@ -98,7 +99,10 @@ std::shared_ptr<Sft> make_pure_cpp_sft_shd_ptr(const std::string &history_seed)
|
|||||||
|
|
||||||
std::shared_ptr<Sft> pass_through_shd_ptr(const std::shared_ptr<Sft> &obj) { return obj; }
|
std::shared_ptr<Sft> pass_through_shd_ptr(const std::shared_ptr<Sft> &obj) { return obj; }
|
||||||
|
|
||||||
} // namespace
|
} // namespace class_sh_trampoline_shared_from_this
|
||||||
|
} // namespace pybind11_tests
|
||||||
|
|
||||||
|
using namespace pybind11_tests::class_sh_trampoline_shared_from_this;
|
||||||
|
|
||||||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(Sft)
|
PYBIND11_SMART_HOLDER_TYPE_CASTERS(Sft)
|
||||||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(SftSharedPtrStash)
|
PYBIND11_SMART_HOLDER_TYPE_CASTERS(SftSharedPtrStash)
|
||||||
|
@ -7,7 +7,8 @@
|
|||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace {
|
namespace pybind11_tests {
|
||||||
|
namespace class_sh_trampoline_shared_ptr_cpp_arg {
|
||||||
|
|
||||||
// For testing whether a python subclass of a C++ object dies when the
|
// For testing whether a python subclass of a C++ object dies when the
|
||||||
// last python reference is lost
|
// last python reference is lost
|
||||||
@ -51,7 +52,10 @@ struct SpGoAwayTester {
|
|||||||
std::shared_ptr<SpGoAway> m_obj;
|
std::shared_ptr<SpGoAway> m_obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace class_sh_trampoline_shared_ptr_cpp_arg
|
||||||
|
} // namespace pybind11_tests
|
||||||
|
|
||||||
|
using namespace pybind11_tests::class_sh_trampoline_shared_ptr_cpp_arg;
|
||||||
|
|
||||||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(SpBase)
|
PYBIND11_SMART_HOLDER_TYPE_CASTERS(SpBase)
|
||||||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(SpBaseTester)
|
PYBIND11_SMART_HOLDER_TYPE_CASTERS(SpBaseTester)
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace {
|
namespace pybind11_tests {
|
||||||
|
namespace class_sh_trampoline_unique_ptr {
|
||||||
|
|
||||||
class Class {
|
class Class {
|
||||||
public:
|
public:
|
||||||
@ -30,11 +31,13 @@ private:
|
|||||||
std::uint64_t val_ = 0;
|
std::uint64_t val_ = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace class_sh_trampoline_unique_ptr
|
||||||
|
} // namespace pybind11_tests
|
||||||
|
|
||||||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(Class)
|
PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::class_sh_trampoline_unique_ptr::Class)
|
||||||
|
|
||||||
namespace {
|
namespace pybind11_tests {
|
||||||
|
namespace class_sh_trampoline_unique_ptr {
|
||||||
|
|
||||||
class PyClass : public Class, public py::trampoline_self_life_support {
|
class PyClass : public Class, public py::trampoline_self_life_support {
|
||||||
public:
|
public:
|
||||||
@ -45,9 +48,12 @@ public:
|
|||||||
int foo() const override { PYBIND11_OVERRIDE_PURE(int, Class, foo); }
|
int foo() const override { PYBIND11_OVERRIDE_PURE(int, Class, foo); }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace class_sh_trampoline_unique_ptr
|
||||||
|
} // namespace pybind11_tests
|
||||||
|
|
||||||
TEST_SUBMODULE(class_sh_trampoline_unique_ptr, m) {
|
TEST_SUBMODULE(class_sh_trampoline_unique_ptr, m) {
|
||||||
|
using namespace pybind11_tests::class_sh_trampoline_unique_ptr;
|
||||||
|
|
||||||
py::classh<Class, PyClass>(m, "Class")
|
py::classh<Class, PyClass>(m, "Class")
|
||||||
.def(py::init<>())
|
.def(py::init<>())
|
||||||
.def("set_val", &Class::setVal)
|
.def("set_val", &Class::setVal)
|
||||||
|
@ -46,13 +46,13 @@ struct CppDerivedVirtualOverrider : CppDerived, py::trampoline_self_life_support
|
|||||||
} // namespace class_sh_virtual_py_cpp_mix
|
} // namespace class_sh_virtual_py_cpp_mix
|
||||||
} // namespace pybind11_tests
|
} // namespace pybind11_tests
|
||||||
|
|
||||||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::class_sh_virtual_py_cpp_mix::Base)
|
|
||||||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::class_sh_virtual_py_cpp_mix::CppDerivedPlain)
|
|
||||||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::class_sh_virtual_py_cpp_mix::CppDerived)
|
|
||||||
|
|
||||||
TEST_SUBMODULE(class_sh_virtual_py_cpp_mix, m) {
|
|
||||||
using namespace pybind11_tests::class_sh_virtual_py_cpp_mix;
|
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) {
|
||||||
py::classh<Base, BaseVirtualOverrider>(m, "Base").def(py::init<>()).def("get", &Base::get);
|
py::classh<Base, BaseVirtualOverrider>(m, "Base").def(py::init<>()).def("get", &Base::get);
|
||||||
|
|
||||||
py::classh<CppDerivedPlain, Base>(m, "CppDerivedPlain").def(py::init<>());
|
py::classh<CppDerivedPlain, Base>(m, "CppDerivedPlain").def(py::init<>());
|
||||||
|
Loading…
Reference in New Issue
Block a user