diff --git a/src/Corrade/Containers/StridedArrayViewPythonBindings.h b/src/Corrade/Containers/StridedArrayViewPythonBindings.h index db3b874..7252ebb 100644 --- a/src/Corrade/Containers/StridedArrayViewPythonBindings.h +++ b/src/Corrade/Containers/StridedArrayViewPythonBindings.h @@ -34,26 +34,26 @@ namespace Implementation { /* For maintainability please keep in the same order as https://docs.python.org/3/library/struct.html#format-characters */ -template constexpr const char* formatString() { +template constexpr const char* pythonFormatString() { static_assert(sizeof(T) == 0, "format string unknown for this type, supply it explicitly"); return {}; } /* Representing bytes as unsigned. Not using 'c' because then it behaves differently from bytes/bytearray, where you can do `a[0] = ord('A')`. */ -template<> constexpr const char* formatString() { return "B"; } -template<> constexpr const char* formatString() { return "b"; } -template<> constexpr const char* formatString() { return "B"; } -template<> constexpr const char* formatString() { return "h"; } -template<> constexpr const char* formatString() { return "H"; } -template<> constexpr const char* formatString() { return "i"; } -template<> constexpr const char* formatString() { return "I"; } +template<> constexpr const char* pythonFormatString() { return "B"; } +template<> constexpr const char* pythonFormatString() { return "b"; } +template<> constexpr const char* pythonFormatString() { return "B"; } +template<> constexpr const char* pythonFormatString() { return "h"; } +template<> constexpr const char* pythonFormatString() { return "H"; } +template<> constexpr const char* pythonFormatString() { return "i"; } +template<> constexpr const char* pythonFormatString() { return "I"; } /* *not* l / L, that's 4 bytes in Python */ -template<> constexpr const char* formatString() { return "q"; } -template<> constexpr const char* formatString() { return "Q"; } +template<> constexpr const char* pythonFormatString() { return "q"; } +template<> constexpr const char* pythonFormatString() { return "Q"; } /** @todo how to represent std::size_t? conflicts with uint32_t/uint64_t above */ /** @todo half? take from Magnum? */ -template<> constexpr const char* formatString() { return "f"; } -template<> constexpr const char* formatString() { return "d"; } +template<> constexpr const char* pythonFormatString() { return "f"; } +template<> constexpr const char* pythonFormatString() { return "d"; } template struct PyStridedArrayViewSetItem; template struct PyStridedArrayViewSetItem { @@ -77,7 +77,7 @@ template class PyStridedArrayView: public StridedA format, choosing bytes for safety. */ /*implicit*/ PyStridedArrayView(): format{"B"}, getitem{} {} - template explicit PyStridedArrayView(const StridedArrayView& view): PyStridedArrayView{view, Implementation::formatString::type>(), sizeof(U)} {} + template explicit PyStridedArrayView(const StridedArrayView& view): PyStridedArrayView{view, Implementation::pythonFormatString::type>(), sizeof(U)} {} template explicit PyStridedArrayView(const StridedArrayView& view, const char* format, std::size_t itemsize): PyStridedArrayView{ arrayCast(view), diff --git a/src/python/corrade/containers.cpp b/src/python/corrade/containers.cpp index 83a7f26..64efe03 100644 --- a/src/python/corrade/containers.cpp +++ b/src/python/corrade/containers.cpp @@ -77,7 +77,7 @@ template bool arrayViewBufferProtocol(T& self, Py_buffer& buffer, int f buffer.buf = const_cast::type*>(self.data()); buffer.readonly = std::is_const::value; if((flags & PyBUF_FORMAT) == PyBUF_FORMAT) - buffer.format = const_cast(Containers::Implementation::formatString::type>()); + buffer.format = const_cast(Containers::Implementation::pythonFormatString::type>()); if(flags != PyBUF_SIMPLE) { /* The view is immutable (can't change its size after it has been constructed), so referencing the size directly is okay */ diff --git a/src/python/corrade/test/test_stridedarrayview.cpp b/src/python/corrade/test/test_stridedarrayview.cpp index b758d39..4cb4175 100644 --- a/src/python/corrade/test/test_stridedarrayview.cpp +++ b/src/python/corrade/test/test_stridedarrayview.cpp @@ -32,10 +32,10 @@ #include "Corrade/Containers/StridedArrayViewPythonBindings.h" namespace Corrade { namespace Containers { namespace Implementation { - template<> constexpr const char* formatString>() { + template<> constexpr const char* pythonFormatString>() { return "ddd"; } - template<> constexpr const char* formatString>() { + template<> constexpr const char* pythonFormatString>() { return "Qf"; } }}}