Commit 908f5540 authored by Davis King's avatar Davis King

Make arrays of points and rectangles constructable with a size in the Python API.

parent 44c06150
...@@ -241,6 +241,7 @@ ensures \n\ ...@@ -241,6 +241,7 @@ ensures \n\
{ {
typedef std::vector<rectangle> type; typedef std::vector<rectangle> type;
py::bind_vector<type>(m, "rectangles", "An array of rectangle objects.") py::bind_vector<type>(m, "rectangles", "An array of rectangle objects.")
.def(py::init<size_t>(), py::arg("initial_size"))
.def("clear", &type::clear) .def("clear", &type::clear)
.def("resize", resize<type>) .def("resize", resize<type>)
.def("extend", extend_vector_with_python_list<rectangle>) .def("extend", extend_vector_with_python_list<rectangle>)
...@@ -250,6 +251,7 @@ ensures \n\ ...@@ -250,6 +251,7 @@ ensures \n\
{ {
typedef std::vector<std::vector<rectangle>> type; typedef std::vector<std::vector<rectangle>> type;
py::bind_vector<type>(m, "rectangless", "An array of arrays of rectangle objects.") py::bind_vector<type>(m, "rectangless", "An array of arrays of rectangle objects.")
.def(py::init<size_t>(), py::arg("initial_size"))
.def("clear", &type::clear) .def("clear", &type::clear)
.def("resize", resize<type>) .def("resize", resize<type>)
.def("extend", extend_vector_with_python_list<rectangle>) .def("extend", extend_vector_with_python_list<rectangle>)
......
...@@ -438,6 +438,7 @@ void bind_vector(py::module& m) ...@@ -438,6 +438,7 @@ void bind_vector(py::module& m)
{ {
typedef std::vector<point> type; typedef std::vector<point> type;
py::bind_vector<type>(m, "points", "An array of point objects.") py::bind_vector<type>(m, "points", "An array of point objects.")
.def(py::init<size_t>(), py::arg("initial_size"))
.def("clear", &type::clear) .def("clear", &type::clear)
.def("resize", resize<type>) .def("resize", resize<type>)
.def("extend", extend_vector_with_python_list<point>) .def("extend", extend_vector_with_python_list<point>)
...@@ -467,6 +468,7 @@ void bind_vector(py::module& m) ...@@ -467,6 +468,7 @@ void bind_vector(py::module& m)
{ {
typedef std::vector<dpoint> type; typedef std::vector<dpoint> type;
py::bind_vector<type>(m, "dpoints", "An array of dpoint objects.") py::bind_vector<type>(m, "dpoints", "An array of dpoint objects.")
.def(py::init<size_t>(), py::arg("initial_size"))
.def("clear", &type::clear) .def("clear", &type::clear)
.def("resize", resize<type>) .def("resize", resize<type>)
.def("extend", extend_vector_with_python_list<dpoint>) .def("extend", extend_vector_with_python_list<dpoint>)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment