From 6914a229a038206341ae1fea46393965a555ca9a Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Tue, 9 May 2017 19:22:53 +0100 Subject: ext: Upgrade PyBind11 to version 2.1.1 Change-Id: I16870dec402d661295f9d013dc23e362b2b2c169 Signed-off-by: Andreas Sandberg Reviewed-by: Curtis Dunham Reviewed-on: https://gem5-review.googlesource.com/3225 Reviewed-by: Jason Lowe-Power --- ext/pybind11/tests/test_stl_binders.cpp | 37 +++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 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 b9b56c15d..f636c0b55 100644 --- a/ext/pybind11/tests/test_stl_binders.cpp +++ b/ext/pybind11/tests/test_stl_binders.cpp @@ -10,10 +10,16 @@ #include "pybind11_tests.h" #include +#include #include #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; @@ -53,17 +59,45 @@ 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_initializer stl_binder_vector([](py::module &m) { py::class_(m, "El") .def(py::init()); - py::bind_vector>(m, "VectorInt"); + 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) { @@ -92,4 +126,3 @@ test_initializer stl_binder_noncopyable([](py::module &m) { py::bind_map>(m, "UmapENC"); m.def("get_umnc", ×_ten>, py::return_value_policy::reference); }); - -- cgit v1.2.3