ext: Updated Pybind11 to version 2.4.1.
This updates Pybind11 from version 2.2.1 to version 2.4.1. This fixes
warning/error received when "<experiment/optional>" is used when
compiling using c++14 with clang. It should be noted that
"ext/pybind11/include/pybind11/std.h" has been changed to include a fix
added by commit ba42457254. This is
necessary to avoid build errors.
Built: Linux (gcc, c++11) and MacOS (clang, c++14).
Tested: Ran quick tests for X86, ARM, and RISC-V.
Deprecates: https://gem5-review.googlesource.com/c/public/gem5/+/21019
Change-Id: Ie9783511cb6be50136076a55330e645f4f36d075
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21119
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -10,10 +10,27 @@
|
||||
#include "pybind11_tests.h"
|
||||
#include "constructor_stats.h"
|
||||
#include "local_bindings.h"
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4324) // warning C4324: structure was padded due to alignment specifier
|
||||
#endif
|
||||
|
||||
// test_brace_initialization
|
||||
struct NoBraceInitialization {
|
||||
NoBraceInitialization(std::vector<int> v) : vec{std::move(v)} {}
|
||||
template <typename T>
|
||||
NoBraceInitialization(std::initializer_list<T> l) : vec(l) {}
|
||||
|
||||
std::vector<int> vec;
|
||||
};
|
||||
|
||||
TEST_SUBMODULE(class_, m) {
|
||||
// test_instance
|
||||
struct NoConstructor {
|
||||
NoConstructor() = default;
|
||||
NoConstructor(const NoConstructor &) = default;
|
||||
NoConstructor(NoConstructor &&) = default;
|
||||
static NoConstructor *new_instance() {
|
||||
auto *ptr = new NoConstructor();
|
||||
print_created(ptr, "via new_instance");
|
||||
@@ -82,7 +99,12 @@ TEST_SUBMODULE(class_, m) {
|
||||
m.def("dog_bark", [](const Dog &dog) { return dog.bark(); });
|
||||
|
||||
// test_automatic_upcasting
|
||||
struct BaseClass { virtual ~BaseClass() {} };
|
||||
struct BaseClass {
|
||||
BaseClass() = default;
|
||||
BaseClass(const BaseClass &) = default;
|
||||
BaseClass(BaseClass &&) = default;
|
||||
virtual ~BaseClass() {}
|
||||
};
|
||||
struct DerivedClass1 : BaseClass { };
|
||||
struct DerivedClass2 : BaseClass { };
|
||||
|
||||
@@ -291,6 +313,12 @@ TEST_SUBMODULE(class_, m) {
|
||||
.def(py::init<int, const std::string &>())
|
||||
.def_readwrite("field1", &BraceInitialization::field1)
|
||||
.def_readwrite("field2", &BraceInitialization::field2);
|
||||
// We *don't* want to construct using braces when the given constructor argument maps to a
|
||||
// constructor, because brace initialization could go to the wrong place (in particular when
|
||||
// there is also an `initializer_list<T>`-accept constructor):
|
||||
py::class_<NoBraceInitialization>(m, "NoBraceInitialization")
|
||||
.def(py::init<std::vector<int>>())
|
||||
.def_readonly("vec", &NoBraceInitialization::vec);
|
||||
|
||||
// test_reentrant_implicit_conversion_failure
|
||||
// #1035: issue with runaway reentrant implicit conversion
|
||||
@@ -302,6 +330,43 @@ TEST_SUBMODULE(class_, m) {
|
||||
.def(py::init<const BogusImplicitConversion &>());
|
||||
|
||||
py::implicitly_convertible<int, BogusImplicitConversion>();
|
||||
|
||||
// test_qualname
|
||||
// #1166: nested class docstring doesn't show nested name
|
||||
// Also related: tests that __qualname__ is set properly
|
||||
struct NestBase {};
|
||||
struct Nested {};
|
||||
py::class_<NestBase> base(m, "NestBase");
|
||||
base.def(py::init<>());
|
||||
py::class_<Nested>(base, "Nested")
|
||||
.def(py::init<>())
|
||||
.def("fn", [](Nested &, int, NestBase &, Nested &) {})
|
||||
.def("fa", [](Nested &, int, NestBase &, Nested &) {},
|
||||
"a"_a, "b"_a, "c"_a);
|
||||
base.def("g", [](NestBase &, Nested &) {});
|
||||
base.def("h", []() { return NestBase(); });
|
||||
|
||||
// test_error_after_conversion
|
||||
// The second-pass path through dispatcher() previously didn't
|
||||
// remember which overload was used, and would crash trying to
|
||||
// generate a useful error message
|
||||
|
||||
struct NotRegistered {};
|
||||
struct StringWrapper { std::string str; };
|
||||
m.def("test_error_after_conversions", [](int) {});
|
||||
m.def("test_error_after_conversions",
|
||||
[](StringWrapper) -> NotRegistered { return {}; });
|
||||
py::class_<StringWrapper>(m, "StringWrapper").def(py::init<std::string>());
|
||||
py::implicitly_convertible<std::string, StringWrapper>();
|
||||
|
||||
#if defined(PYBIND11_CPP17)
|
||||
struct alignas(1024) Aligned {
|
||||
std::uintptr_t ptr() const { return (uintptr_t) this; }
|
||||
};
|
||||
py::class_<Aligned>(m, "Aligned")
|
||||
.def(py::init<>())
|
||||
.def("ptr", &Aligned::ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <int N> class BreaksBase { public: virtual ~BreaksBase() = default; };
|
||||
|
||||
Reference in New Issue
Block a user