From: Arnaud Giersch Date: Tue, 19 Mar 2019 07:45:38 +0000 (+0100) Subject: Use a Mailbox* with Python bindings. X-Git-Tag: v3_22~59 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/59293d52a1b80ddb306c6282fd32624dbd042271?hp=8b70f3150dcf01e62945c62c003712a48114603a Use a Mailbox* with Python bindings. --- diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index 57fb111115..ba89c6ec3b 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -164,23 +164,23 @@ PYBIND11_MODULE(simgrid, m) /* Class Mailbox */ py::class_>(m, "Mailbox", "Mailbox, see :ref:`class s4u::Mailbox `") - .def("__str__", [](Mailbox self) -> const std::string { - return std::string("Mailbox(")+self.get_cname()+")"; + .def("__str__", [](Mailbox* self) -> const std::string { + return std::string("Mailbox(") + self->get_cname() + ")"; }, "Textual representation of the Mailbox`") .def("by_name", &Mailbox::by_name, "Retrieve a Mailbox from its name, see :cpp:func:`simgrid::s4u::Mailbox::by_name()`") .def_property_readonly("name", [](Mailbox* self) -> const std::string { return std::string(self->get_name().c_str()); // Convert from xbt::string because of MC }, "The name of that mailbox, see :cpp:func:`simgrid::s4u::Mailbox::get_name()`") - .def("put", [](Mailbox self, py::object data, int size) { + .def("put", [](Mailbox* self, py::object data, int size) { data.inc_ref(); - self.put(data.ptr(), size); + self->put(data.ptr(), size); }, "Blocking data transmission, see :cpp:func:`void simgrid::s4u::Mailbox::put(void*, uint64_t)`") - .def("put_async", [](Mailbox self, py::object data, int size) -> simgrid::s4u::CommPtr { + .def("put_async", [](Mailbox* self, py::object data, int size) -> simgrid::s4u::CommPtr { data.inc_ref(); - return self.put_async(data.ptr(), size); + return self->put_async(data.ptr(), size); }, "Non-blocking data transmission, see :cpp:func:`void simgrid::s4u::Mailbox::put_async(void*, uint64_t)`") - .def("get", [](Mailbox self) -> py::object { - py::object data = pybind11::reinterpret_steal(pybind11::handle(static_cast(self.get()))); + .def("get", [](Mailbox* self) -> py::object { + py::object data = pybind11::reinterpret_steal(pybind11::handle(static_cast(self->get()))); data.dec_ref(); return data; }, "Blocking data reception, see :cpp:func:`void* simgrid::s4u::Mailbox::get()`");