Browse Source

python: make this compatible with pybind11 2.6.

Pybind changed py::module to py::module_ in order to support C++
modules, adapting to that change. It still builds on older versions,
but we're using only the new APIs.
pull/10/head
Vladimír Vondruš 6 years ago
parent
commit
57db13422f
  1. 19
      src/python/corrade/bootstrap.h
  2. 2
      src/python/corrade/containers.cpp
  3. 4
      src/python/corrade/corrade.cpp
  4. 2
      src/python/corrade/pluginmanager.cpp
  5. 46
      src/python/magnum/bootstrap.h
  6. 2
      src/python/magnum/gl.cpp
  7. 28
      src/python/magnum/magnum.cpp
  8. 4
      src/python/magnum/math.cpp
  9. 2
      src/python/magnum/math.matrixdouble.cpp
  10. 2
      src/python/magnum/math.matrixfloat.cpp
  11. 4
      src/python/magnum/math.range.cpp
  12. 2
      src/python/magnum/math.vector.h
  13. 6
      src/python/magnum/math.vectorfloat.cpp
  14. 4
      src/python/magnum/math.vectorintegral.cpp
  15. 6
      src/python/magnum/meshtools.cpp
  16. 2
      src/python/magnum/platform/egl.cpp
  17. 2
      src/python/magnum/platform/glfw.cpp
  18. 2
      src/python/magnum/platform/glx.cpp
  19. 2
      src/python/magnum/platform/sdl2.cpp
  20. 2
      src/python/magnum/platform/wgl.cpp
  21. 4
      src/python/magnum/primitives.cpp
  22. 2
      src/python/magnum/scenegraph.cpp
  23. 4
      src/python/magnum/scenegraph.h
  24. 4
      src/python/magnum/scenegraph.matrix.cpp
  25. 4
      src/python/magnum/scenegraph.trs.cpp
  26. 4
      src/python/magnum/shaders.cpp
  27. 4
      src/python/magnum/trade.cpp

19
src/python/corrade/bootstrap.h

@ -25,7 +25,20 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
namespace pybind11 { class module; } #include <pybind11/detail/common.h> /* for PYBIND11_VERSION_* */
namespace pybind11 {
/* pybind11 2.6 changes py::module to py::module_ to be compatible with C++
modules. In order to be forward-compatible, we use module_ everywhere
and define it as an alias to module on < 2.6 */
#if PYBIND11_VERSION_MAJOR*100 + PYBIND11_VERSION_MINOR >= 206
class module_;
#else
class module;
typedef module module_;
#endif
}
namespace Corrade {} namespace Corrade {}
namespace corrade { namespace corrade {
@ -33,8 +46,8 @@ namespace corrade {
using namespace Corrade; using namespace Corrade;
namespace py = pybind11; namespace py = pybind11;
void containers(py::module& m); void containers(py::module_& m);
void pluginmanager(py::module& m); void pluginmanager(py::module_& m);
} }

2
src/python/corrade/containers.cpp

@ -631,7 +631,7 @@ template<class T> void mutableStridedArrayView4D(py::class_<Containers::StridedA
} }
void containers(py::module& m) { void containers(py::module_& m) {
m.doc() = "Container implementations"; m.doc() = "Container implementations";
py::class_<Containers::ArrayView<const char>, Containers::PyArrayViewHolder<Containers::ArrayView<const char>>> arrayView_{m, py::class_<Containers::ArrayView<const char>, Containers::PyArrayViewHolder<Containers::ArrayView<const char>>> arrayView_{m,

4
src/python/corrade/corrade.cpp

@ -118,11 +118,11 @@ PYBIND11_MODULE(_corrade, m) {
These need to be defined in the order they depend on. */ These need to be defined in the order they depend on. */
#ifdef CORRADE_BUILD_STATIC #ifdef CORRADE_BUILD_STATIC
py::module containers = m.def_submodule("containers"); py::module_ containers = m.def_submodule("containers");
corrade::containers(containers); corrade::containers(containers);
#ifdef Corrade_PluginManager_FOUND #ifdef Corrade_PluginManager_FOUND
py::module pluginmanager = m.def_submodule("pluginmanager"); py::module_ pluginmanager = m.def_submodule("pluginmanager");
corrade::pluginmanager(pluginmanager); corrade::pluginmanager(pluginmanager);
#endif #endif
#endif #endif

2
src/python/corrade/pluginmanager.cpp

@ -34,7 +34,7 @@
namespace corrade { namespace corrade {
void pluginmanager(py::module& m) { void pluginmanager(py::module_& m) {
m.doc() = "Plugin management"; m.doc() = "Plugin management";
py::enum_<PluginManager::LoadState> loadState{m, "LoadState", "Plugin load state"}; py::enum_<PluginManager::LoadState> loadState{m, "LoadState", "Plugin load state"};

46
src/python/magnum/bootstrap.h

@ -26,9 +26,21 @@
*/ */
#include <Python.h> #include <Python.h>
#include <pybind11/detail/common.h> /* for PYBIND11_VERSION_* */
#include <Magnum/Magnum.h> #include <Magnum/Magnum.h>
namespace pybind11 { class module; } namespace pybind11 {
/* pybind11 2.6 changes py::module to py::module_ to be compatible with C++
modules. In order to be forward-compatible, we use module_ everywhere
and define it as an alias to module on < 2.6 */
#if PYBIND11_VERSION_MAJOR*100 + PYBIND11_VERSION_MINOR >= 206
class module_;
#else
class module;
typedef module module_;
#endif
}
namespace Magnum {} namespace Magnum {}
namespace magnum { namespace magnum {
@ -50,26 +62,26 @@ template<class T> struct PyDimensionTraits<3, T> {
static VectorType from(const Math::Vector<3, T>& vec) { return vec; } static VectorType from(const Math::Vector<3, T>& vec) { return vec; }
}; };
void math(py::module& root, py::module& m); void math(py::module_& root, py::module_& m);
void mathVectorFloat(py::module& root, py::module& m); void mathVectorFloat(py::module_& root, py::module_& m);
void mathVectorIntegral(py::module& root, py::module& m); void mathVectorIntegral(py::module_& root, py::module_& m);
void mathMatrixFloat(py::module& root, PyTypeObject* metaclass); void mathMatrixFloat(py::module_& root, PyTypeObject* metaclass);
void mathMatrixDouble(py::module& root, PyTypeObject* metaclass); void mathMatrixDouble(py::module_& root, PyTypeObject* metaclass);
void mathRange(py::module& root, py::module& m); void mathRange(py::module_& root, py::module_& m);
void gl(py::module& m); void gl(py::module_& m);
void meshtools(py::module& m); void meshtools(py::module_& m);
void primitives(py::module& m); void primitives(py::module_& m);
void scenegraph(py::module& m); void scenegraph(py::module_& m);
void shaders(py::module& m); void shaders(py::module_& m);
void trade(py::module& m); void trade(py::module_& m);
namespace platform { namespace platform {
void glfw(py::module& m); void glfw(py::module_& m);
void sdl2(py::module& m); void sdl2(py::module_& m);
void egl(py::module& m); void egl(py::module_& m);
void glx(py::module& m); void glx(py::module_& m);
} }
} }

2
src/python/magnum/gl.cpp

@ -238,7 +238,7 @@ template<UnsignedInt dimensions> void texture(py::class_<GL::Texture<dimensions>
} }
void gl(py::module& m) { void gl(py::module_& m) {
/* /*
Missing APIs: Missing APIs:

28
src/python/magnum/magnum.cpp

@ -153,7 +153,7 @@ template<class T> void imageViewFromMutable(py::class_<T, PyImageViewHolder<T>>&
}), "Construct from a mutable view"); }), "Construct from a mutable view");
} }
void magnum(py::module& m) { void magnum(py::module_& m) {
m.attr("BUILD_STATIC") = m.attr("BUILD_STATIC") =
#ifdef MAGNUM_BUILD_STATIC #ifdef MAGNUM_BUILD_STATIC
true true
@ -335,9 +335,9 @@ PYBIND11_MODULE(_magnum, m) {
m.doc() = "Root Magnum module"; m.doc() = "Root Magnum module";
/* We need ArrayView for images */ /* We need ArrayView for images */
py::module::import("corrade.containers"); py::module_::import("corrade.containers");
py::module math = m.def_submodule("math"); py::module_ math = m.def_submodule("math");
magnum::math(m, math); magnum::math(m, math);
/* These need stuff from math, so need to be called after */ /* These need stuff from math, so need to be called after */
@ -350,59 +350,59 @@ PYBIND11_MODULE(_magnum, m) {
These need to be defined in the order they depend on. */ These need to be defined in the order they depend on. */
#ifdef MAGNUM_BUILD_STATIC #ifdef MAGNUM_BUILD_STATIC
#ifdef Magnum_GL_FOUND #ifdef Magnum_GL_FOUND
py::module gl = m.def_submodule("gl"); py::module_ gl = m.def_submodule("gl");
magnum::gl(gl); magnum::gl(gl);
#endif #endif
#ifdef Magnum_SceneGraph_FOUND #ifdef Magnum_SceneGraph_FOUND
py::module scenegraph = m.def_submodule("scenegraph"); py::module_ scenegraph = m.def_submodule("scenegraph");
magnum::scenegraph(scenegraph); magnum::scenegraph(scenegraph);
#endif #endif
#ifdef Magnum_Trade_FOUND #ifdef Magnum_Trade_FOUND
py::module trade = m.def_submodule("trade"); py::module_ trade = m.def_submodule("trade");
magnum::trade(trade); magnum::trade(trade);
#endif #endif
#ifdef Magnum_MeshTools_FOUND #ifdef Magnum_MeshTools_FOUND
/* Depends on trade and gl */ /* Depends on trade and gl */
py::module meshtools = m.def_submodule("meshtools"); py::module_ meshtools = m.def_submodule("meshtools");
magnum::meshtools(meshtools); magnum::meshtools(meshtools);
#endif #endif
#ifdef Magnum_Primitives_FOUND #ifdef Magnum_Primitives_FOUND
/* Depends on trade */ /* Depends on trade */
py::module primitives = m.def_submodule("primitives"); py::module_ primitives = m.def_submodule("primitives");
magnum::primitives(primitives); magnum::primitives(primitives);
#endif #endif
#ifdef Magnum_Shaders_FOUND #ifdef Magnum_Shaders_FOUND
/* Depends on gl */ /* Depends on gl */
py::module shaders = m.def_submodule("shaders"); py::module_ shaders = m.def_submodule("shaders");
magnum::shaders(shaders); magnum::shaders(shaders);
#endif #endif
/* Keep the doc in sync with platform/__init__.py */ /* Keep the doc in sync with platform/__init__.py */
py::module platform = m.def_submodule("platform"); py::module_ platform = m.def_submodule("platform");
platform.doc() = "Platform-specific application and context creation"; platform.doc() = "Platform-specific application and context creation";
#ifdef Magnum_GlfwApplication_FOUND #ifdef Magnum_GlfwApplication_FOUND
py::module glfw = platform.def_submodule("glfw"); py::module_ glfw = platform.def_submodule("glfw");
magnum::platform::glfw(glfw); magnum::platform::glfw(glfw);
#endif #endif
#ifdef Magnum_Sdl2Application_FOUND #ifdef Magnum_Sdl2Application_FOUND
py::module sdl2 = platform.def_submodule("sdl2"); py::module_ sdl2 = platform.def_submodule("sdl2");
magnum::platform::sdl2(sdl2); magnum::platform::sdl2(sdl2);
#endif #endif
#ifdef Magnum_WindowlessEglApplication_FOUND #ifdef Magnum_WindowlessEglApplication_FOUND
py::module egl = platform.def_submodule("egl"); py::module_ egl = platform.def_submodule("egl");
magnum::platform::egl(egl); magnum::platform::egl(egl);
#endif #endif
#ifdef Magnum_WindowlessGlxApplication_FOUND #ifdef Magnum_WindowlessGlxApplication_FOUND
py::module glx = platform.def_submodule("glx"); py::module_ glx = platform.def_submodule("glx");
magnum::platform::glx(glx); magnum::platform::glx(glx);
#endif #endif
#endif #endif

4
src/python/magnum/math.cpp

@ -236,7 +236,7 @@ template<class U, class T, class ...Args> void convertible(py::class_<T, Args...
c.def(py::init<U>(), "Construct from different underlying type"); c.def(py::init<U>(), "Construct from different underlying type");
} }
template<class T> void quaternion(py::module& m, py::class_<T>& c) { template<class T> void quaternion(py::module_& m, py::class_<T>& c) {
/* /*
Missing APIs: Missing APIs:
@ -410,7 +410,7 @@ PyTypeObject* transformationMatrixMetaclass() {
} }
void math(py::module& root, py::module& m) { void math(py::module_& root, py::module_& m) {
m.doc() = "Math library"; m.doc() = "Math library";
/* Deg, Rad, Degd, Radd */ /* Deg, Rad, Degd, Radd */

2
src/python/magnum/math.matrixdouble.cpp

@ -27,7 +27,7 @@
namespace magnum { namespace magnum {
void mathMatrixDouble(py::module& root, PyTypeObject* const metaclass) { void mathMatrixDouble(py::module_& root, PyTypeObject* const metaclass) {
py::class_<Matrix2x2d> matrix2x2d{root, "Matrix2x2d", "2x2 double matrix", py::buffer_protocol{}}; py::class_<Matrix2x2d> matrix2x2d{root, "Matrix2x2d", "2x2 double matrix", py::buffer_protocol{}};
py::class_<Matrix2x3d> matrix2x3d{root, "Matrix2x3d", "2x3 double matrix", py::buffer_protocol{}}; py::class_<Matrix2x3d> matrix2x3d{root, "Matrix2x3d", "2x3 double matrix", py::buffer_protocol{}};
py::class_<Matrix2x4d> matrix2x4d{root, "Matrix2x4d", "2x4 double matrix", py::buffer_protocol{}}; py::class_<Matrix2x4d> matrix2x4d{root, "Matrix2x4d", "2x4 double matrix", py::buffer_protocol{}};

2
src/python/magnum/math.matrixfloat.cpp

@ -27,7 +27,7 @@
namespace magnum { namespace magnum {
void mathMatrixFloat(py::module& root, PyTypeObject* const metaclass) { void mathMatrixFloat(py::module_& root, PyTypeObject* const metaclass) {
py::class_<Matrix2x2> matrix2x2{root, "Matrix2x2", "2x2 float matrix", py::buffer_protocol{}}; py::class_<Matrix2x2> matrix2x2{root, "Matrix2x2", "2x2 float matrix", py::buffer_protocol{}};
py::class_<Matrix2x3> matrix2x3{root, "Matrix2x3", "2x3 float matrix", py::buffer_protocol{}}; py::class_<Matrix2x3> matrix2x3{root, "Matrix2x3", "2x3 float matrix", py::buffer_protocol{}};
py::class_<Matrix2x4> matrix2x4{root, "Matrix2x4", "2x4 float matrix", py::buffer_protocol{}}; py::class_<Matrix2x4> matrix2x4{root, "Matrix2x4", "2x4 float matrix", py::buffer_protocol{}};

4
src/python/magnum/math.range.cpp

@ -35,7 +35,7 @@ namespace magnum {
namespace { namespace {
template<class T> void range(py::module& m, py::class_<T>& c) { template<class T> void range(py::module_& m, py::class_<T>& c) {
/* /*
Missing APIs: Missing APIs:
@ -318,7 +318,7 @@ template<template<class> class Type, class T, class ...Args> void convertible(py
} }
void mathRange(py::module& root, py::module& m) { void mathRange(py::module_& root, py::module_& m) {
py::class_<Range1D> range1D_{root, "Range1D", "One-dimensional float range"}; py::class_<Range1D> range1D_{root, "Range1D", "One-dimensional float range"};
py::class_<Range2D> range2D_{root, "Range2D", "Two-dimensional float range"}; py::class_<Range2D> range2D_{root, "Range2D", "Two-dimensional float range"};
py::class_<Range3D> range3D_{root, "Range3D", "Three-dimensional float range"}; py::class_<Range3D> range3D_{root, "Range3D", "Three-dimensional float range"};

2
src/python/magnum/math.vector.h

@ -188,7 +188,7 @@ template<class T> bool vectorBufferProtocol(T& self, Py_buffer& buffer, int flag
} }
/* Things common for vectors of all sizes and types */ /* Things common for vectors of all sizes and types */
template<class T> void vector(py::module& m, py::class_<T>& c) { template<class T> void vector(py::module_& m, py::class_<T>& c) {
/* /*
Missing APIs: Missing APIs:

6
src/python/magnum/math.vectorfloat.cpp

@ -29,7 +29,7 @@ namespace magnum {
namespace { namespace {
template<class T> void vectorFloat(py::module& m, py::class_<T>& c) { template<class T> void vectorFloat(py::module_& m, py::class_<T>& c) {
m m
.def("angle", [](const T& a, const T& b) { return Radd(Math::angle(a, b)); }, .def("angle", [](const T& a, const T& b) { return Radd(Math::angle(a, b)); },
"Angle between normalized vectors", py::arg("normalized_a"), py::arg("normalized_b")); "Angle between normalized vectors", py::arg("normalized_a"), py::arg("normalized_b"));
@ -52,7 +52,7 @@ template<class T> void vectorFloat(py::module& m, py::class_<T>& c) {
}, "Vector projected onto a normalized line"); }, "Vector projected onto a normalized line");
} }
template<class T> void vectorsFloat(py::module& m, py::class_<Math::Vector2<T>>& vector2_, py::class_<Math::Vector3<T>>& vector3_, py::class_<Math::Vector4<T>>& vector4_) { template<class T> void vectorsFloat(py::module_& m, py::class_<Math::Vector2<T>>& vector2_, py::class_<Math::Vector3<T>>& vector3_, py::class_<Math::Vector4<T>>& vector4_) {
vector2_.def("aspect_ratio", static_cast<T(Math::Vector2<T>::*)() const>(&Math::Vector2<T>::aspectRatio), vector2_.def("aspect_ratio", static_cast<T(Math::Vector2<T>::*)() const>(&Math::Vector2<T>::aspectRatio),
"Aspect ratio"); "Aspect ratio");
m.def("cross", static_cast<T(*)(const Math::Vector2<T>&, const Math::Vector2<T>&)>(Math::cross), m.def("cross", static_cast<T(*)(const Math::Vector2<T>&, const Math::Vector2<T>&)>(Math::cross),
@ -81,7 +81,7 @@ template<class T> void vectorsFloat(py::module& m, py::class_<Math::Vector2<T>>&
} }
void mathVectorFloat(py::module& root, py::module& m) { void mathVectorFloat(py::module_& root, py::module_& m) {
py::class_<Vector2> vector2{root, "Vector2", "Two-component float vector", py::buffer_protocol{}}; py::class_<Vector2> vector2{root, "Vector2", "Two-component float vector", py::buffer_protocol{}};
py::class_<Vector3> vector3{root, "Vector3", "Threee-component float vector", py::buffer_protocol{}}; py::class_<Vector3> vector3{root, "Vector3", "Threee-component float vector", py::buffer_protocol{}};
py::class_<Vector4> vector4{root, "Vector4", "Four-component float vector", py::buffer_protocol{}}; py::class_<Vector4> vector4{root, "Vector4", "Four-component float vector", py::buffer_protocol{}};

4
src/python/magnum/math.vectorintegral.cpp

@ -81,7 +81,7 @@ template<class T> void vectorIntegral(py::class_<T>& c) {
.def(py::self / Float{}, "Divide an integral vector with a floating-point number"); .def(py::self / Float{}, "Divide an integral vector with a floating-point number");
} }
template<class T> void vectorsIntegral(py::module& m, py::class_<Math::Vector2<T>>& vector2_, py::class_<Math::Vector3<T>>& vector3_, py::class_<Math::Vector4<T>>& vector4_) { template<class T> void vectorsIntegral(py::module_& m, py::class_<Math::Vector2<T>>& vector2_, py::class_<Math::Vector3<T>>& vector3_, py::class_<Math::Vector4<T>>& vector4_) {
everyVector(vector2_); everyVector(vector2_);
vector<Math::Vector2<T>>(m, vector2_); vector<Math::Vector2<T>>(m, vector2_);
vectorIntegral<Math::Vector2<T>>(vector2_); vectorIntegral<Math::Vector2<T>>(vector2_);
@ -107,7 +107,7 @@ template<class T> void vectorsIntegralSigned(py::class_<Math::Vector2<T>>& vecto
} }
void mathVectorIntegral(py::module& root, py::module& m) { void mathVectorIntegral(py::module_& root, py::module_& m) {
py::class_<Vector2i> vector2i{root, "Vector2i", "Two-component signed integer vector", py::buffer_protocol{}}; py::class_<Vector2i> vector2i{root, "Vector2i", "Two-component signed integer vector", py::buffer_protocol{}};
py::class_<Vector3i> vector3i{root, "Vector3i", "Threee-component signed integral vector", py::buffer_protocol{}}; py::class_<Vector3i> vector3i{root, "Vector3i", "Threee-component signed integral vector", py::buffer_protocol{}};
py::class_<Vector4i> vector4i{root, "Vector4i", "Four-component signed integral vector", py::buffer_protocol{}}; py::class_<Vector4i> vector4i{root, "Vector4i", "Four-component signed integral vector", py::buffer_protocol{}};

6
src/python/magnum/meshtools.cpp

@ -33,14 +33,14 @@
namespace magnum { namespace magnum {
void meshtools(py::module& m) { void meshtools(py::module_& m) {
m.doc() = "Mesh tools"; m.doc() = "Mesh tools";
#ifndef MAGNUM_BUILD_STATIC #ifndef MAGNUM_BUILD_STATIC
/* These are a part of the same module in the static build, no need to /* These are a part of the same module in the static build, no need to
import (also can't import because there it's _magnum.*) */ import (also can't import because there it's _magnum.*) */
py::module::import("magnum.gl"); py::module_::import("magnum.gl");
py::module::import("magnum.trade"); py::module_::import("magnum.trade");
#endif #endif
py::enum_<MeshTools::CompileFlag> compileFlag{m, "CompileFlag", "Mesh compilation flags"}; py::enum_<MeshTools::CompileFlag> compileFlag{m, "CompileFlag", "Mesh compilation flags"};

2
src/python/magnum/platform/egl.cpp

@ -35,7 +35,7 @@ namespace {
int argc = 0; int argc = 0;
} }
void egl(py::module& m) { void egl(py::module_& m) {
m.doc() = "EGL-based platform integration"; m.doc() = "EGL-based platform integration";
struct PyWindowlessApplication: Platform::WindowlessApplication { struct PyWindowlessApplication: Platform::WindowlessApplication {

2
src/python/magnum/platform/glfw.cpp

@ -37,7 +37,7 @@ namespace {
int argc = 0; int argc = 0;
} }
void glfw(py::module& m) { void glfw(py::module_& m) {
m.doc() = "GLFW-based platform integration"; m.doc() = "GLFW-based platform integration";
struct PublicizedApplication: Platform::Application { struct PublicizedApplication: Platform::Application {

2
src/python/magnum/platform/glx.cpp

@ -35,7 +35,7 @@ namespace {
int argc = 0; int argc = 0;
} }
void glx(py::module& m) { void glx(py::module_& m) {
m.doc() = "GLX-based platform integration"; m.doc() = "GLX-based platform integration";
struct PyWindowlessApplication: Platform::WindowlessApplication { struct PyWindowlessApplication: Platform::WindowlessApplication {

2
src/python/magnum/platform/sdl2.cpp

@ -37,7 +37,7 @@ namespace {
int argc = 0; int argc = 0;
} }
void sdl2(py::module& m) { void sdl2(py::module_& m) {
m.doc() = "SDL2-based platform integration"; m.doc() = "SDL2-based platform integration";
struct PublicizedApplication: Platform::Application { struct PublicizedApplication: Platform::Application {

2
src/python/magnum/platform/wgl.cpp

@ -35,7 +35,7 @@ namespace {
int argc = 0; int argc = 0;
} }
void wgl(py::module& m) { void wgl(py::module_& m) {
m.doc() = "WGL-based platform integration"; m.doc() = "WGL-based platform integration";
struct PyWindowlessApplication: Platform::WindowlessApplication { struct PyWindowlessApplication: Platform::WindowlessApplication {

4
src/python/magnum/primitives.cpp

@ -46,13 +46,13 @@
namespace magnum { namespace magnum {
void primitives(py::module& m) { void primitives(py::module_& m) {
m.doc() = "Primitive library"; m.doc() = "Primitive library";
#ifndef MAGNUM_BUILD_STATIC #ifndef MAGNUM_BUILD_STATIC
/* These are a part of the same module in the static build, no need to /* These are a part of the same module in the static build, no need to
import (also can't import because there it's _magnum.*) */ import (also can't import because there it's _magnum.*) */
py::module::import("magnum.trade"); py::module_::import("magnum.trade");
#endif #endif
py::enum_<Primitives::CapsuleFlag> capsuleFlags{m, "CapsuleFlags", "Capsule flags"}; py::enum_<Primitives::CapsuleFlag> capsuleFlags{m, "CapsuleFlags", "Capsule flags"};

2
src/python/magnum/scenegraph.cpp

@ -129,7 +129,7 @@ template<UnsignedInt dimensions, class T> void camera(py::class_<SceneGraph::Cam
} }
void scenegraph(py::module& m) { void scenegraph(py::module_& m) {
m.doc() = "Scene graph library"; m.doc() = "Scene graph library";
/* Abstract objects. Returned from feature.object, so need to be registered /* Abstract objects. Returned from feature.object, so need to be registered

4
src/python/magnum/scenegraph.h

@ -159,8 +159,8 @@ template<class Transformation> void objectReflect(py::class_<SceneGraph::Object<
}, "Reflect the object as a local transformation"); }, "Reflect the object as a local transformation");
} }
void scenegraphMatrix(py::module& m); void scenegraphMatrix(py::module_& m);
void scenegraphTrs(py::module& m); void scenegraphTrs(py::module_& m);
} }

4
src/python/magnum/scenegraph.matrix.cpp

@ -30,8 +30,8 @@
namespace magnum { namespace magnum {
void scenegraphMatrix(py::module& m) { void scenegraphMatrix(py::module_& m) {
py::module matrix = m.def_submodule("matrix"); py::module_ matrix = m.def_submodule("matrix");
matrix.doc() = "General matrix-based scene graph implementation"; matrix.doc() = "General matrix-based scene graph implementation";
py::class_<SceneGraph::Scene<SceneGraph::MatrixTransformation2D>> scene2D_{matrix, "Scene2D", "Two-dimensional scene with matrix-based transformation implementation"}; py::class_<SceneGraph::Scene<SceneGraph::MatrixTransformation2D>> scene2D_{matrix, "Scene2D", "Two-dimensional scene with matrix-based transformation implementation"};

4
src/python/magnum/scenegraph.trs.cpp

@ -50,8 +50,8 @@ template<class Transformation> void objectTrs(py::class_<SceneGraph::Object<Tran
} }
void scenegraphTrs(py::module& m) { void scenegraphTrs(py::module_& m) {
py::module matrix = m.def_submodule("trs"); py::module_ matrix = m.def_submodule("trs");
matrix.doc() = "Translation/rotation/scaling-based scene graph implementation"; matrix.doc() = "Translation/rotation/scaling-based scene graph implementation";
py::class_<SceneGraph::Scene<SceneGraph::TranslationRotationScalingTransformation2D>> scene2D_{matrix, "Scene2D", "Two-dimensional scene with TRS-based transformation implementation"}; py::class_<SceneGraph::Scene<SceneGraph::TranslationRotationScalingTransformation2D>> scene2D_{matrix, "Scene2D", "Two-dimensional scene with TRS-based transformation implementation"};

4
src/python/magnum/shaders.cpp

@ -105,13 +105,13 @@ template<UnsignedInt dimensions> void vertexColor(PyNonDestructibleClass<Shaders
} }
void shaders(py::module& m) { void shaders(py::module_& m) {
m.doc() = "Builtin shaders"; m.doc() = "Builtin shaders";
#ifndef MAGNUM_BUILD_STATIC #ifndef MAGNUM_BUILD_STATIC
/* These are a part of the same module in the static build, no need to /* These are a part of the same module in the static build, no need to
import (also can't import because there it's _magnum.*) */ import (also can't import because there it's _magnum.*) */
py::module::import("magnum.gl"); py::module_::import("magnum.gl");
#endif #endif
/* 2D/3D flat shader */ /* 2D/3D flat shader */

4
src/python/magnum/trade.cpp

@ -219,11 +219,11 @@ template<class R, Containers::Optional<R>(Trade::AbstractImporter::*f)(UnsignedI
} }
void trade(py::module& m) { void trade(py::module_& m) {
m.doc() = "Data format exchange"; m.doc() = "Data format exchange";
/* AbstractImporter depends on this */ /* AbstractImporter depends on this */
py::module::import("corrade.pluginmanager"); py::module_::import("corrade.pluginmanager");
py::class_<Trade::MeshData>{m, "MeshData", "Mesh data"} py::class_<Trade::MeshData>{m, "MeshData", "Mesh data"}
.def_property_readonly("primitive", &Trade::MeshData::primitive, "Primitive") .def_property_readonly("primitive", &Trade::MeshData::primitive, "Primitive")

Loading…
Cancel
Save