// // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenEXR Project. // // clang-format off #ifndef _PYIMATH_FIXEDARRAY_TRAITS_H #define _PYIMATH_FIXEDARRAY_TRAITS_H #include #include #include #include namespace PyImath { // See https://docs.python.org/2/library/struct.html // // Section 7.3.2.2 // static char PyFmtStr_int[2] = {'i', '\0'}; static char PyFmtStr_float[2] = {'f', '\0'}; static char PyFmtStr_double[2] = {'d', '\0'}; static char PyFmtStr_bool[2] = {'?', '\0'}; static char PyFmtStr_char[2] = {'b', '\0'}; static char PyFmtStr_short[2] = {'h', '\0'}; static char PyFmtStr_long[2] = {'l', '\0'}; static char PyFmtStr_longlong[2] = {'q', '\0'}; static char PyFmtStr_uchar[2] = {'B', '\0'}; static char PyFmtStr_ushort[2] = {'H', '\0'}; static char PyFmtStr_uint[2] = {'I', '\0'}; static char PyFmtStr_ulong[2] = {'L', '\0'}; static char PyFmtStr_ulonglong[2] = {'Q', '\0'}; static char PyFmtStr_half[2] = {'e', '\0'}; template constexpr char* PyFormat(); template <> constexpr char* PyFormat() { return PyFmtStr_int; } template <> constexpr char* PyFormat() { return PyFmtStr_float; } template <> constexpr char* PyFormat() { return PyFmtStr_double; } template <> constexpr char* PyFormat() { return PyFmtStr_bool; } template <> constexpr char* PyFormat() { return PyFmtStr_char; } template <> constexpr char* PyFormat() { return PyFmtStr_short; } template <> constexpr char* PyFormat() { return PyFmtStr_long; } template <> constexpr char* PyFormat() { return PyFmtStr_longlong; } template <> constexpr char* PyFormat() { return PyFmtStr_uchar; } template <> constexpr char* PyFormat() { return PyFmtStr_ushort; } template <> constexpr char* PyFormat() { return PyFmtStr_uint; } template <> constexpr char* PyFormat() { return PyFmtStr_ulong; } template <> constexpr char* PyFormat() { return PyFmtStr_ulonglong; } template <> constexpr char* PyFormat() { return PyFmtStr_half; } template <> constexpr char* PyFormat >() { return PyFmtStr_short; } template <> constexpr char* PyFormat >() { return PyFmtStr_int; } template <> constexpr char* PyFormat >() { return PyFmtStr_long; } template <> constexpr char* PyFormat >() { return PyFmtStr_float; } template <> constexpr char* PyFormat >() { return PyFmtStr_double; } template <> constexpr char* PyFormat >() { return PyFmtStr_short; } template <> constexpr char* PyFormat >() { return PyFmtStr_int; } template <> constexpr char* PyFormat >() { return PyFmtStr_long; } template <> constexpr char* PyFormat >() { return PyFmtStr_float; } template <> constexpr char* PyFormat >() { return PyFmtStr_double; } template <> constexpr char* PyFormat >() { return PyFmtStr_short; } template <> constexpr char* PyFormat >() { return PyFmtStr_int; } template <> constexpr char* PyFormat >() { return PyFmtStr_long; } template <> constexpr char* PyFormat >() { return PyFmtStr_float; } template <> constexpr char* PyFormat >() { return PyFmtStr_double; } template struct FixedArrayWidth { static const Py_ssize_t value; }; template <> struct FixedArrayWidth { static const Py_ssize_t value = 1; }; template <> struct FixedArrayWidth { static const Py_ssize_t value = 1; }; template <> struct FixedArrayWidth { static const Py_ssize_t value = 1; }; template <> struct FixedArrayWidth { static const Py_ssize_t value = 1; }; template <> struct FixedArrayWidth { static const Py_ssize_t value = 1; }; template <> struct FixedArrayWidth { static const Py_ssize_t value = 1; }; template <> struct FixedArrayWidth > { static const Py_ssize_t value = 2; }; template <> struct FixedArrayWidth > { static const Py_ssize_t value = 2; }; template <> struct FixedArrayWidth > { static const Py_ssize_t value = 2; }; template <> struct FixedArrayWidth > { static const Py_ssize_t value = 2; }; template <> struct FixedArrayWidth > { static const Py_ssize_t value = 2; }; template <> struct FixedArrayWidth > { static const Py_ssize_t value = 3; }; template <> struct FixedArrayWidth > { static const Py_ssize_t value = 3; }; template <> struct FixedArrayWidth > { static const Py_ssize_t value = 3; }; template <> struct FixedArrayWidth > { static const Py_ssize_t value = 3; }; template <> struct FixedArrayWidth > { static const Py_ssize_t value = 3; }; template <> struct FixedArrayWidth > { static const Py_ssize_t value = 4; }; template <> struct FixedArrayWidth > { static const Py_ssize_t value = 4; }; template <> struct FixedArrayWidth > { static const Py_ssize_t value = 4; }; template <> struct FixedArrayWidth > { static const Py_ssize_t value = 4; }; template <> struct FixedArrayWidth > { static const Py_ssize_t value = 4; }; template struct FixedArrayDimension { static const Py_ssize_t value; }; template <> struct FixedArrayDimension { static const Py_ssize_t value = 1; }; template <> struct FixedArrayDimension { static const Py_ssize_t value = 1; }; template <> struct FixedArrayDimension { static const Py_ssize_t value = 1; }; template <> struct FixedArrayDimension { static const Py_ssize_t value = 1; }; template <> struct FixedArrayDimension { static const Py_ssize_t value = 1; }; template <> struct FixedArrayDimension { static const Py_ssize_t value = 1; }; template <> struct FixedArrayDimension > { static const Py_ssize_t value = 2; }; template <> struct FixedArrayDimension > { static const Py_ssize_t value = 2; }; template <> struct FixedArrayDimension > { static const Py_ssize_t value = 2; }; template <> struct FixedArrayDimension > { static const Py_ssize_t value = 2; }; template <> struct FixedArrayDimension > { static const Py_ssize_t value = 2; }; template <> struct FixedArrayDimension > { static const Py_ssize_t value = 2; }; template <> struct FixedArrayDimension > { static const Py_ssize_t value = 2; }; template <> struct FixedArrayDimension > { static const Py_ssize_t value = 2; }; template <> struct FixedArrayDimension > { static const Py_ssize_t value = 2; }; template <> struct FixedArrayDimension > { static const Py_ssize_t value = 2; }; template <> struct FixedArrayDimension > { static const Py_ssize_t value = 2; }; template <> struct FixedArrayDimension > { static const Py_ssize_t value = 2; }; template <> struct FixedArrayDimension > { static const Py_ssize_t value = 2; }; template <> struct FixedArrayDimension > { static const Py_ssize_t value = 2; }; template <> struct FixedArrayDimension > { static const Py_ssize_t value = 2; }; template struct FixedArrayAtomicSize { static const Py_ssize_t value; }; template <> struct FixedArrayAtomicSize { static const Py_ssize_t value = sizeof(short); }; template <> struct FixedArrayAtomicSize { static const Py_ssize_t value = sizeof(int); }; template <> struct FixedArrayAtomicSize { static const Py_ssize_t value = sizeof(int); }; template <> struct FixedArrayAtomicSize { static const Py_ssize_t value = sizeof(float); }; template <> struct FixedArrayAtomicSize { static const Py_ssize_t value = sizeof(double); }; template <> struct FixedArrayAtomicSize { static const Py_ssize_t value = sizeof(unsigned char); }; template <> struct FixedArrayAtomicSize > { static const Py_ssize_t value = sizeof(short); }; template <> struct FixedArrayAtomicSize > { static const Py_ssize_t value = sizeof(int); }; template <> struct FixedArrayAtomicSize > { static const Py_ssize_t value = sizeof(int64_t); }; template <> struct FixedArrayAtomicSize > { static const Py_ssize_t value = sizeof(float); }; template <> struct FixedArrayAtomicSize > { static const Py_ssize_t value = sizeof(double); }; template <> struct FixedArrayAtomicSize > { static const Py_ssize_t value = sizeof(short); }; template <> struct FixedArrayAtomicSize > { static const Py_ssize_t value = sizeof(int); }; template <> struct FixedArrayAtomicSize > { static const Py_ssize_t value = sizeof(int64_t); }; template <> struct FixedArrayAtomicSize > { static const Py_ssize_t value = sizeof(float); }; template <> struct FixedArrayAtomicSize > { static const Py_ssize_t value = sizeof(double); }; template <> struct FixedArrayAtomicSize > { static const Py_ssize_t value = sizeof(short); }; template <> struct FixedArrayAtomicSize > { static const Py_ssize_t value = sizeof(int); }; template <> struct FixedArrayAtomicSize > { static const Py_ssize_t value = sizeof(int64_t); }; template <> struct FixedArrayAtomicSize > { static const Py_ssize_t value = sizeof(float); }; template <> struct FixedArrayAtomicSize > { static const Py_ssize_t value = sizeof(double); }; } // namespace #endif