aboutsummaryrefslogtreecommitdiffstats
path: root/3rdparty/pybind11/tests/test_sequences_and_iterators.cpp
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2021-01-02 10:15:39 +0100
committerMiodrag Milanovic <mmicko@gmail.com>2021-01-02 10:15:39 +0100
commite76cdab6dd77bad411e6ac9372ee527aff89ef17 (patch)
treee9868f05cf455336d75f33b1312d71034f8fb334 /3rdparty/pybind11/tests/test_sequences_and_iterators.cpp
parentc6cdf30501dcb2da01361229dd66a05dad73a132 (diff)
downloadnextpnr-e76cdab6dd77bad411e6ac9372ee527aff89ef17.tar.gz
nextpnr-e76cdab6dd77bad411e6ac9372ee527aff89ef17.tar.bz2
nextpnr-e76cdab6dd77bad411e6ac9372ee527aff89ef17.zip
Update pybind11 to version 2.6.1
Diffstat (limited to '3rdparty/pybind11/tests/test_sequences_and_iterators.cpp')
-rw-r--r--3rdparty/pybind11/tests/test_sequences_and_iterators.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/3rdparty/pybind11/tests/test_sequences_and_iterators.cpp b/3rdparty/pybind11/tests/test_sequences_and_iterators.cpp
index 87ccf99d..d318052a 100644
--- a/3rdparty/pybind11/tests/test_sequences_and_iterators.cpp
+++ b/3rdparty/pybind11/tests/test_sequences_and_iterators.cpp
@@ -13,6 +13,8 @@
#include <pybind11/operators.h>
#include <pybind11/stl.h>
+#include <algorithm>
+
template<typename T>
class NonZeroIterator {
const T* ptr_;
@@ -81,7 +83,7 @@ TEST_SUBMODULE(sequences_and_iterators, m) {
py::class_<Sliceable>(m,"Sliceable")
.def(py::init<int>())
.def("__getitem__",[](const Sliceable &s, py::slice slice) {
- ssize_t start, stop, step, slicelength;
+ py::ssize_t start, stop, step, slicelength;
if (!slice.compute(s.size, &start, &stop, &step, &slicelength))
throw py::error_already_set();
int istart = static_cast<int>(start);
@@ -198,7 +200,7 @@ TEST_SUBMODULE(sequences_and_iterators, m) {
size_t start, stop, step, slicelength;
if (!slice.compute(s.size(), &start, &stop, &step, &slicelength))
throw py::error_already_set();
- Sequence *seq = new Sequence(slicelength);
+ auto *seq = new Sequence(slicelength);
for (size_t i = 0; i < slicelength; ++i) {
(*seq)[i] = s[start]; start += step;
}
@@ -319,6 +321,9 @@ TEST_SUBMODULE(sequences_and_iterators, m) {
return l;
});
+ // test_sequence_length: check that Python sequences can be converted to py::sequence.
+ m.def("sequence_length", [](py::sequence seq) { return seq.size(); });
+
// Make sure that py::iterator works with std algorithms
m.def("count_none", [](py::object o) {
return std::count_if(o.begin(), o.end(), [](py::handle h) { return h.is_none(); });