Browse Source

Adapt to Corrade changes.

pull/9/head
Vladimír Vondruš 6 years ago
parent
commit
86bac39471
  1. 2
      src/Corrade/Python.h
  2. 8
      src/python/corrade/containers.cpp
  3. 2
      src/python/corrade/pluginmanager.h
  4. 8
      src/python/magnum/math.vector.h

2
src/Corrade/Python.h

@ -92,7 +92,7 @@ template<template<class> class T, class U> T<U>& pyObjectHolderFor(U& obj) {
implemented on the client side instead of patching pybind itself */
template<class, bool> struct PyNonDestructibleBaseDeleter;
template<class T> struct PyNonDestructibleBaseDeleter<T, false> {
void operator()(T*) { CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ }
void operator()(T*) { CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ }
};
template<class T> struct PyNonDestructibleBaseDeleter<T, true> {
void operator()(T* ptr) { delete ptr; }

8
src/python/corrade/containers.cpp

@ -254,25 +254,25 @@ template<> Containers::Array<char> bytes(Containers::StridedArrayView<4, const c
/* Getting a runtime tuple index. Ugh. */
template<class T> const T& dimensionsTupleGet(const typename DimensionsTuple<1, T>::Type& tuple, std::size_t i) {
if(i == 0) return std::get<0>(tuple);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
}
template<class T> const T& dimensionsTupleGet(const typename DimensionsTuple<2, T>::Type& tuple, std::size_t i) {
if(i == 0) return std::get<0>(tuple);
if(i == 1) return std::get<1>(tuple);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
}
template<class T> const T& dimensionsTupleGet(const typename DimensionsTuple<3, T>::Type& tuple, std::size_t i) {
if(i == 0) return std::get<0>(tuple);
if(i == 1) return std::get<1>(tuple);
if(i == 2) return std::get<2>(tuple);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
}
template<class T> const T& dimensionsTupleGet(const typename DimensionsTuple<4, T>::Type& tuple, std::size_t i) {
if(i == 0) return std::get<0>(tuple);
if(i == 1) return std::get<1>(tuple);
if(i == 2) return std::get<2>(tuple);
if(i == 3) return std::get<3>(tuple);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
}
template<class T> bool stridedArrayViewBufferProtocol(T& self, Py_buffer& buffer, int flags) {

2
src/python/corrade/pluginmanager.h

@ -41,7 +41,7 @@ namespace Corrade { namespace PluginManager {
template<class T> struct PyPluginHolder: std::unique_ptr<T> {
explicit PyPluginHolder(T*) {
/* Pybind needs this signature, but it should never be called */
CORRADE_ASSERT_UNREACHABLE();
CORRADE_INTERNAL_ASSERT_UNREACHABLE();
}
explicit PyPluginHolder(T* object, pybind11::object manager) noexcept: std::unique_ptr<T>{object}, manager{std::move(manager)} {}

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

@ -59,21 +59,21 @@ template<class U, class T> void initFromBuffer(T& out, const Py_buffer& buffer)
template<class T> void initFromBuffer(typename std::enable_if<std::is_floating_point<typename T::Type>::value, T>::type& out, const Py_buffer& buffer) {
if(buffer.format[0] == 'f') initFromBuffer<Float>(out, buffer);
else if(buffer.format[0] == 'd') initFromBuffer<Double>(out, buffer);
else CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
}
/* Signed integral init */
template<class T> void initFromBuffer(typename std::enable_if<std::is_integral<typename T::Type>::value && std::is_signed<typename T::Type>::value, T>::type& out, const Py_buffer& buffer) {
if(buffer.format[0] == 'i') initFromBuffer<Int>(out, buffer);
else if(buffer.format[0] == 'l') initFromBuffer<Long>(out, buffer);
else CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
}
/* Unsigned integral init */
template<class T> void initFromBuffer(typename std::enable_if<std::is_integral<typename T::Type>::value && std::is_unsigned<typename T::Type>::value, T>::type& out, const Py_buffer& buffer) {
if(buffer.format[0] == 'I') initFromBuffer<UnsignedInt>(out, buffer);
else if(buffer.format[0] == 'L') initFromBuffer<UnsignedLong>(out, buffer);
else CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
}
/* Things that have to be defined for both VectorN and Color so they construct
@ -259,7 +259,7 @@ template<class T> void vector(py::module& m, py::class_<T>& c) {
else if(name.size() == 3) return py::cast(out.xyz());
else if(name.size() == 2) return py::cast(out.xy());
/* this should be handled by the x/y/z/w/r/g/b/a properties instead */
else CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
}, "Vector swizzle")
.def("__setattr__", [](T& self, py::str nameO, py::object valueO) {
std::string name = py::cast<std::string>(nameO);

Loading…
Cancel
Save