MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenImageIO / ParamValue_convert

Function ParamValue_convert

src/python/py_paramvalue.cpp:39–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37
38template <typename BaseType>
39object 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
66object ParamValue_getitem(const ParamValue& self, int n) {
67 if (n >= self.nvalues()) {

Callers 1

ParamValue_getitemFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected