| 37 | |
| 38 | template <typename BaseType> |
| 39 | object ParamValue_convert(const TypeDesc& t, int n, const BaseType* data) { |
| 40 | |
| 41 | switch (t.aggregate) { |
| 42 | case TypeDesc::SCALAR: return object(data[n]); |
| 43 | case TypeDesc::VEC2: return make_tuple(data[n*2], data[n*2+1]); |
| 44 | case TypeDesc::VEC3: return make_tuple(data[n*3], data[n*3+1], |
| 45 | data[n*3+2]); |
| 46 | case TypeDesc::VEC4: return make_tuple(data[n*4], data[n*4+1], |
| 47 | data[n*4+2], data[n*4+3]); |
| 48 | // Bypass the make_tuple argument list size limit by making two |
| 49 | // tuples and adding them. Inefficient, but not likely to be a bottleneck. |
| 50 | // If it turns out we need efficient access to this stuff we should look |
| 51 | // at an array/ctypes interface. |
| 52 | case TypeDesc::MATRIX44: return make_tuple( |
| 53 | data[n*16+0], data[n*16+1], data[n*16+2], data[n*16+3], |
| 54 | data[n*16+4], data[n*16+5], data[n*16+6], data[n*16+7]) + |
| 55 | make_tuple(data[n*16+8], data[n*16+9], data[n*16+10], data[n*16+11], |
| 56 | data[n*16+12], data[n*16+13], data[n*16+14], data[n*16+15]); |
| 57 | default: |
| 58 | PyErr_SetString(PyExc_TypeError, |
| 59 | "Unable to convert ParamValue with unknown TypeDesc"); |
| 60 | throw_error_already_set(); |
| 61 | } |
| 62 | return object(); |
| 63 | |
| 64 | } |
| 65 | |
| 66 | object ParamValue_getitem(const ParamValue& self, int n) { |
| 67 | if (n >= self.nvalues()) { |
no outgoing calls
no test coverage detected