From f07d5069d86e31ecf195664850f79fb00c445bd3 Mon Sep 17 00:00:00 2001 From: Jason Lowe-Power Date: Fri, 17 Nov 2017 17:02:05 -0800 Subject: ext: Upgrade PyBind11 to version 2.2.1 This upgrade is necessary for pybind to build with GCC 7.2. We still need to add the patch for stl.h. MSC_FULL_VER change is no longer needed. See https://gem5-review.googlesource.com/c/public/gem5/+/2230 Change-Id: I806729217d022070583994c2dfcaa74476aef30f Signed-off-by: Jason Lowe-Power Reviewed-on: https://gem5-review.googlesource.com/5801 Reviewed-by: Andreas Sandberg Maintainer: Andreas Sandberg --- ext/pybind11/tests/test_stl_binders.cpp | 75 ++++++++++++--------------------- 1 file changed, 27 insertions(+), 48 deletions(-) (limited to 'ext/pybind11/tests/test_stl_binders.cpp') diff --git a/ext/pybind11/tests/test_stl_binders.cpp b/ext/pybind11/tests/test_stl_binders.cpp index f636c0b55..a88b589e1 100644 --- a/ext/pybind11/tests/test_stl_binders.cpp +++ b/ext/pybind11/tests/test_stl_binders.cpp @@ -15,11 +15,6 @@ #include #include -#ifdef _MSC_VER -// We get some really long type names here which causes MSVC to emit warnings -# pragma warning(disable: 4503) // warning C4503: decorated name length exceeded, name was truncated -#endif - class El { public: El() = delete; @@ -59,70 +54,54 @@ template Map *times_ten(int n) { return m; } -struct VStruct { - bool w; - uint32_t x; - double y; - bool z; -}; - -struct VUndeclStruct { //dtype not declared for this version - bool w; - uint32_t x; - double y; - bool z; -}; +TEST_SUBMODULE(stl_binders, m) { + // test_vector_int + py::bind_vector>(m, "VectorInt", py::buffer_protocol()); -test_initializer stl_binder_vector([](py::module &m) { + // test_vector_custom py::class_(m, "El") .def(py::init()); - - py::bind_vector>(m, "VectorUChar", py::buffer_protocol()); - py::bind_vector>(m, "VectorInt", py::buffer_protocol()); - py::bind_vector>(m, "VectorBool"); - py::bind_vector>(m, "VectorEl"); - py::bind_vector>>(m, "VectorVectorEl"); - m.def("create_undeclstruct", [m] () mutable { - py::bind_vector>(m, "VectorUndeclStruct", py::buffer_protocol()); - }); - - try { - py::module::import("numpy"); - } catch (...) { - return; - } - PYBIND11_NUMPY_DTYPE(VStruct, w, x, y, z); - py::class_(m, "VStruct").def_readwrite("x", &VStruct::x); - py::bind_vector>(m, "VectorStruct", py::buffer_protocol()); - m.def("get_vectorstruct", [] {return std::vector {{0, 5, 3.0, 1}, {1, 30, -1e4, 0}};}); -}); - -test_initializer stl_binder_map([](py::module &m) { + // test_map_string_double py::bind_map>(m, "MapStringDouble"); py::bind_map>(m, "UnorderedMapStringDouble"); + // test_map_string_double_const py::bind_map>(m, "MapStringDoubleConst"); py::bind_map>(m, "UnorderedMapStringDoubleConst"); -}); - -test_initializer stl_binder_noncopyable([](py::module &m) { py::class_(m, "ENC") .def(py::init()) .def_readwrite("value", &E_nc::value); + // test_noncopyable_containers py::bind_vector>(m, "VectorENC"); m.def("get_vnc", &one_to_n>, py::return_value_policy::reference); - py::bind_vector>(m, "DequeENC"); m.def("get_dnc", &one_to_n>, py::return_value_policy::reference); - py::bind_map>(m, "MapENC"); m.def("get_mnc", ×_ten>, py::return_value_policy::reference); - py::bind_map>(m, "UmapENC"); m.def("get_umnc", ×_ten>, py::return_value_policy::reference); -}); + + // test_vector_buffer + py::bind_vector>(m, "VectorUChar", py::buffer_protocol()); + // no dtype declared for this version: + struct VUndeclStruct { bool w; uint32_t x; double y; bool z; }; + m.def("create_undeclstruct", [m] () mutable { + py::bind_vector>(m, "VectorUndeclStruct", py::buffer_protocol()); + }); + + // The rest depends on numpy: + try { py::module::import("numpy"); } + catch (...) { return; } + + // test_vector_buffer_numpy + struct VStruct { bool w; uint32_t x; double y; bool z; }; + PYBIND11_NUMPY_DTYPE(VStruct, w, x, y, z); + py::class_(m, "VStruct").def_readwrite("x", &VStruct::x); + py::bind_vector>(m, "VectorStruct", py::buffer_protocol()); + m.def("get_vectorstruct", [] {return std::vector {{0, 5, 3.0, 1}, {1, 30, -1e4, 0}};}); +} -- cgit v1.2.3