From a3f88d4db4a6ab8ecb53d2af028e402075e0a567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 18 Jan 2023 18:55:35 +0100 Subject: [PATCH] python: adapt to std::string removal in the GL library. I really need to figure out the String[View] -> py::string conversion, this is awful. --- src/python/magnum/gl.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/python/magnum/gl.cpp b/src/python/magnum/gl.cpp index 35ddd00..533f481 100644 --- a/src/python/magnum/gl.cpp +++ b/src/python/magnum/gl.cpp @@ -26,6 +26,7 @@ #include #include /* for Mesh.buffers */ #include +#include #include #include #include @@ -454,7 +455,13 @@ void gl(py::module_& m) { /* Interface */ .def_property_readonly("id", &GL::Shader::id, "OpenGL shader ID") .def_property_readonly("type", &GL::Shader::type, "Shader type") - .def_property_readonly("sources", &GL::Shader::sources, "Shader sources") + .def_property_readonly("sources", [](GL::Shader& self) { + /** @todo find a way to go directly to python's str */ + std::vector out; + for(const Containers::StringView& i: self.sources()) + out.push_back(i); + return out; + }, "Shader sources") /* Using lambdas to avoid method chaining leaking to Python */ .def("add_source", [](GL::Shader& self, std::string source) { self.addSource(std::move(source)); @@ -496,7 +503,11 @@ void gl(py::module_& m) { /* Public interface */ .def_property_readonly("id", &GL::AbstractShaderProgram::id, "OpenGL program ID") - .def("validate", &GL::AbstractShaderProgram::validate, "Validate program") + .def("validate", [](GL::AbstractShaderProgram& self) { + const Containers::Pair out = self.validate(); + /** @todo find a way to go directly to python's str */ + return std::make_pair(out.first(), std::string{out.second()}); + }, "Validate program") .def("draw", [](GL::AbstractShaderProgram& self, GL::Mesh& mesh) { self.draw(mesh); }, "Draw a mesh")