| 1 |
// |
| 2 |
// SPDX-License-Identifier: BSD-3-Clause |
| 3 |
// Copyright Contributors to the OpenEXR Project. |
| 4 |
// |
| 5 |
|
| 6 |
// clang-format off |
| 7 |
|
| 8 |
#include <Python.h> |
| 9 |
#define BOOST_BIND_GLOBAL_PLACEHOLDERS |
| 10 |
#include <boost/python.hpp> |
| 11 |
#include "PyImath.h" |
| 12 |
#include "PyImathExport.h" |
| 13 |
#include "PyImathBasicTypes.h" |
| 14 |
#include "PyImathFixedArray.h" |
| 15 |
#include "PyImathFixedVArray.h" |
| 16 |
#include "PyImathBufferProtocol.h" |
| 17 |
|
| 18 |
using namespace boost::python; |
| 19 |
|
| 20 |
namespace PyImath { |
| 21 |
|
| 22 |
void |
| 23 |
register_basicTypes() |
| 24 |
{ |
| 25 |
class_<BoolArray> bclass = BoolArray::register_("Fixed length array of bool"); |
| 26 |
add_comparison_functions(bclass); |
| 27 |
|
| 28 |
class_<SignedCharArray> scclass = SignedCharArray::register_("Fixed length array of signed chars"); |
| 29 |
add_arithmetic_math_functions(scclass); |
| 30 |
add_mod_math_functions(scclass); |
| 31 |
add_comparison_functions(scclass); |
| 32 |
add_ordered_comparison_functions(scclass); |
| 33 |
|
| 34 |
class_<UnsignedCharArray> ucclass = UnsignedCharArray::register_("Fixed length array of unsigned chars"); |
| 35 |
add_arithmetic_math_functions(ucclass); |
| 36 |
add_mod_math_functions(ucclass); |
| 37 |
add_comparison_functions(ucclass); |
| 38 |
add_ordered_comparison_functions(ucclass); |
| 39 |
add_buffer_protocol<UnsignedCharArray>(ucclass); |
| 40 |
|
| 41 |
class_<ShortArray> sclass = ShortArray::register_("Fixed length array of shorts"); |
| 42 |
add_arithmetic_math_functions(sclass); |
| 43 |
add_mod_math_functions(sclass); |
| 44 |
add_comparison_functions(sclass); |
| 45 |
add_ordered_comparison_functions(sclass); |
| 46 |
|
| 47 |
class_<UnsignedShortArray> usclass = UnsignedShortArray::register_("Fixed length array of unsigned shorts"); |
| 48 |
add_arithmetic_math_functions(usclass); |
| 49 |
add_mod_math_functions(usclass); |
| 50 |
add_comparison_functions(usclass); |
| 51 |
add_ordered_comparison_functions(usclass); |
| 52 |
|
| 53 |
class_<IntArray> iclass = IntArray::register_("Fixed length array of ints"); |
| 54 |
add_arithmetic_math_functions(iclass); |
| 55 |
add_mod_math_functions(iclass); |
| 56 |
add_comparison_functions(iclass); |
| 57 |
add_ordered_comparison_functions(iclass); |
| 58 |
add_explicit_construction_from_type<float>(iclass); |
| 59 |
add_explicit_construction_from_type<double>(iclass); |
| 60 |
add_buffer_protocol<IntArray>(iclass); |
| 61 |
|
| 62 |
class_<UnsignedIntArray> uiclass = UnsignedIntArray::register_("Fixed length array of unsigned ints"); |
| 63 |
add_arithmetic_math_functions(uiclass); |
| 64 |
add_mod_math_functions(uiclass); |
| 65 |
add_comparison_functions(uiclass); |
| 66 |
add_ordered_comparison_functions(uiclass); |
| 67 |
add_explicit_construction_from_type<float>(uiclass); |
| 68 |
add_explicit_construction_from_type<double>(uiclass); |
| 69 |
|
| 70 |
class_<FloatArray> fclass = FloatArray::register_("Fixed length array of floats"); |
| 71 |
add_arithmetic_math_functions(fclass); |
| 72 |
add_pow_math_functions(fclass); |
| 73 |
add_comparison_functions(fclass); |
| 74 |
add_ordered_comparison_functions(fclass); |
| 75 |
add_explicit_construction_from_type<int>(fclass); |
| 76 |
add_explicit_construction_from_type<double>(fclass); |
| 77 |
add_buffer_protocol<FloatArray>(fclass); |
| 78 |
|
| 79 |
class_<DoubleArray> dclass = DoubleArray::register_("Fixed length array of doubles"); |
| 80 |
add_arithmetic_math_functions(dclass); |
| 81 |
add_pow_math_functions(dclass); |
| 82 |
add_comparison_functions(dclass); |
| 83 |
add_ordered_comparison_functions(dclass); |
| 84 |
add_explicit_construction_from_type<int>(dclass); |
| 85 |
add_explicit_construction_from_type<float>(dclass); |
| 86 |
add_buffer_protocol<DoubleArray>(dclass); |
| 87 |
|
| 88 |
class_<VIntArray> ivclass = VIntArray::register_("Variable fixed length array of ints"); |
| 89 |
class_<VFloatArray> fvclass = VFloatArray::register_("Variable fixed length array of floats"); |
| 90 |
class_<VV2iArray> v2ivclass = VV2iArray::register_("Variable fixed length array of V2i"); |
| 91 |
class_<VV2fArray> v2fvclass = VV2fArray::register_("Variable fixed length array of V2f"); |
| 92 |
// Don't add other functionality until its defined better. |
| 93 |
} |
| 94 |
|
| 95 |
} // namespace PyImath |