PageRenderTime 58ms CodeModel.GetById 21ms app.highlight 33ms RepoModel.GetById 1ms app.codeStats 0ms

/src/pyglue/PyColorSpace.cpp

http://github.com/imageworks/OpenColorIO
C++ | 477 lines | 395 code | 47 blank | 35 comment | 24 complexity | 4e6c4cc627c5083bb82d348a16ab9c06 MD5 | raw file
  1/*
  2Copyright (c) 2003-2010 Sony Pictures Imageworks Inc., et al.
  3All Rights Reserved.
  4
  5Redistribution and use in source and binary forms, with or without
  6modification, are permitted provided that the following conditions are
  7met:
  8* Redistributions of source code must retain the above copyright
  9  notice, this list of conditions and the following disclaimer.
 10* Redistributions in binary form must reproduce the above copyright
 11  notice, this list of conditions and the following disclaimer in the
 12  documentation and/or other materials provided with the distribution.
 13* Neither the name of Sony Pictures Imageworks nor the names of its
 14  contributors may be used to endorse or promote products derived from
 15  this software without specific prior written permission.
 16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 17"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 18LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 19A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 20OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 21SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 22LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 23DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 24THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 26OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 27*/
 28
 29#include <Python.h>
 30#include <OpenColorIO/OpenColorIO.h>
 31
 32#include "PyUtil.h"
 33#include "PyDoc.h"
 34
 35OCIO_NAMESPACE_ENTER
 36{
 37    
 38    PyObject * BuildConstPyColorSpace(ConstColorSpaceRcPtr colorSpace)
 39    {
 40        return BuildConstPyOCIO<PyOCIO_ColorSpace, ColorSpaceRcPtr,
 41            ConstColorSpaceRcPtr>(colorSpace, PyOCIO_ColorSpaceType);
 42    }
 43    
 44    PyObject * BuildEditablePyColorSpace(ColorSpaceRcPtr colorSpace)
 45    {
 46        return BuildEditablePyOCIO<PyOCIO_ColorSpace, ColorSpaceRcPtr,
 47            ConstColorSpaceRcPtr>(colorSpace, PyOCIO_ColorSpaceType);
 48    }
 49    
 50    bool IsPyColorSpace(PyObject * pyobject)
 51    {
 52        return IsPyOCIOType(pyobject, PyOCIO_ColorSpaceType);
 53    }
 54    
 55    bool IsPyColorSpaceEditable(PyObject * pyobject)
 56    {
 57        return IsPyEditable<PyOCIO_ColorSpace>(pyobject, PyOCIO_ColorSpaceType);
 58    }
 59    
 60    ConstColorSpaceRcPtr GetConstColorSpace(PyObject * pyobject, bool allowCast)
 61    {
 62        return GetConstPyOCIO<PyOCIO_ColorSpace, ConstColorSpaceRcPtr>(pyobject,
 63            PyOCIO_ColorSpaceType, allowCast);
 64    }
 65    
 66    ColorSpaceRcPtr GetEditableColorSpace(PyObject * pyobject)
 67    {
 68        return GetEditablePyOCIO<PyOCIO_ColorSpace, ColorSpaceRcPtr>(pyobject,
 69            PyOCIO_ColorSpaceType);
 70    }
 71    
 72    namespace
 73    {
 74        
 75        ///////////////////////////////////////////////////////////////////////
 76        ///
 77        
 78        int PyOCIO_ColorSpace_init(PyOCIO_ColorSpace * self, PyObject * args, PyObject * kwds);
 79        void PyOCIO_ColorSpace_delete(PyOCIO_ColorSpace * self, PyObject * args);
 80        PyObject * PyOCIO_ColorSpace_isEditable(PyObject * self);
 81        PyObject * PyOCIO_ColorSpace_createEditableCopy(PyObject * self);
 82        PyObject * PyOCIO_ColorSpace_getName(PyObject * self);
 83        PyObject * PyOCIO_ColorSpace_setName(PyObject * self, PyObject * args);
 84        PyObject * PyOCIO_ColorSpace_getFamily(PyObject * self);
 85        PyObject * PyOCIO_ColorSpace_setFamily(PyObject * self, PyObject * args);
 86        PyObject * PyOCIO_ColorSpace_getEqualityGroup(PyObject * self);
 87        PyObject * PyOCIO_ColorSpace_setEqualityGroup(PyObject * self, PyObject * args);
 88        PyObject * PyOCIO_ColorSpace_getDescription(PyObject * self);
 89        PyObject * PyOCIO_ColorSpace_setDescription(PyObject * self, PyObject * args);
 90        PyObject * PyOCIO_ColorSpace_getBitDepth(PyObject * self);
 91        PyObject * PyOCIO_ColorSpace_setBitDepth(PyObject * self, PyObject * args);
 92        PyObject * PyOCIO_ColorSpace_isData(PyObject * self);
 93        PyObject * PyOCIO_ColorSpace_setIsData(PyObject * self, PyObject * args);
 94        PyObject * PyOCIO_ColorSpace_getAllocation(PyObject * self);
 95        PyObject * PyOCIO_ColorSpace_setAllocation(PyObject * self, PyObject * args );
 96        PyObject * PyOCIO_ColorSpace_getAllocationVars(PyObject * self);
 97        PyObject * PyOCIO_ColorSpace_setAllocationVars(PyObject * self,  PyObject * args);
 98        PyObject * PyOCIO_ColorSpace_getTransform(PyObject * self, PyObject * args);
 99        PyObject * PyOCIO_ColorSpace_setTransform(PyObject * self, PyObject * args);
100        
101        ///////////////////////////////////////////////////////////////////////
102        ///
103        
104        PyMethodDef PyOCIO_ColorSpace_methods[] = {
105            { "isEditable",
106            (PyCFunction) PyOCIO_ColorSpace_isEditable, METH_NOARGS, COLORSPACE_ISEDITABLE__DOC__ },
107            { "createEditableCopy",
108            (PyCFunction) PyOCIO_ColorSpace_createEditableCopy, METH_NOARGS, COLORSPACE_CREATEEDITABLECOPY__DOC__ },
109            { "getName",
110            (PyCFunction) PyOCIO_ColorSpace_getName, METH_NOARGS, COLORSPACE_GETNAME__DOC__ },
111            { "setName",
112            PyOCIO_ColorSpace_setName, METH_VARARGS, COLORSPACE_SETNAME__DOC__ },
113            { "getFamily",
114            (PyCFunction) PyOCIO_ColorSpace_getFamily, METH_NOARGS, COLORSPACE_GETFAMILY__DOC__ },
115            { "setFamily",
116            PyOCIO_ColorSpace_setFamily, METH_VARARGS, COLORSPACE_SETFAMILY__DOC__ },
117            { "getEqualityGroup",
118            (PyCFunction) PyOCIO_ColorSpace_getEqualityGroup, METH_NOARGS, COLORSPACE_GETEQUALITYGROUP__DOC__ },
119            { "setEqualityGroup",
120            PyOCIO_ColorSpace_setEqualityGroup, METH_VARARGS, COLORSPACE_SETEQUALITYGROUP__DOC__ },
121            { "getDescription",
122            (PyCFunction) PyOCIO_ColorSpace_getDescription, METH_NOARGS, COLORSPACE_GETDESCRIPTION__DOC__ },
123            { "setDescription",
124            PyOCIO_ColorSpace_setDescription, METH_VARARGS, COLORSPACE_SETDESCRIPTION__DOC__ },
125            { "getBitDepth",
126            (PyCFunction) PyOCIO_ColorSpace_getBitDepth, METH_NOARGS, COLORSPACE_GETBITDEPTH__DOC__ },
127            { "setBitDepth",
128            PyOCIO_ColorSpace_setBitDepth, METH_VARARGS, COLORSPACE_SETBITDEPTH__DOC__ },
129            { "isData",
130            (PyCFunction) PyOCIO_ColorSpace_isData, METH_NOARGS, COLORSPACE_ISDATA__DOC__ },
131            { "setIsData",
132            PyOCIO_ColorSpace_setIsData, METH_VARARGS, COLORSPACE_SETISDATA__DOC__ },
133            { "getAllocation",
134            (PyCFunction) PyOCIO_ColorSpace_getAllocation, METH_NOARGS, COLORSPACE_GETALLOCATION__DOC__ },
135            { "setAllocation",
136            PyOCIO_ColorSpace_setAllocation, METH_VARARGS, COLORSPACE_SETALLOCATION__DOC__ },
137            { "getAllocationVars",
138            (PyCFunction) PyOCIO_ColorSpace_getAllocationVars, METH_NOARGS, COLORSPACE_GETALLOCATIONVARS__DOC__ },
139            { "setAllocationVars",
140            PyOCIO_ColorSpace_setAllocationVars, METH_VARARGS, COLORSPACE_SETALLOCATIONVARS__DOC__ },
141            { "getTransform",
142            PyOCIO_ColorSpace_getTransform, METH_VARARGS, COLORSPACE_GETTRANSFORM__DOC__ },
143            { "setTransform",
144            PyOCIO_ColorSpace_setTransform, METH_VARARGS, COLORSPACE_SETTRANSFORM__DOC__ },
145            { NULL, NULL, 0, NULL }
146        };
147    }
148    
149    ///////////////////////////////////////////////////////////////////////////
150    ///
151    
152    PyTypeObject PyOCIO_ColorSpaceType = {
153        PyVarObject_HEAD_INIT(NULL, 0)              //ob_size 
154        "OCIO.ColorSpace",                          //tp_name
155        sizeof(PyOCIO_ColorSpace),                  //tp_basicsize
156        0,                                          //tp_itemsize
157        (destructor)PyOCIO_ColorSpace_delete,       //tp_dealloc
158        0,                                          //tp_print
159        0,                                          //tp_getattr
160        0,                                          //tp_setattr
161        0,                                          //tp_compare
162        0,                                          //tp_repr
163        0,                                          //tp_as_number
164        0,                                          //tp_as_sequence
165        0,                                          //tp_as_mapping
166        0,                                          //tp_hash 
167        0,                                          //tp_call
168        0,                                          //tp_str
169        0,                                          //tp_getattro
170        0,                                          //tp_setattro
171        0,                                          //tp_as_buffer
172        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,   //tp_flags
173        COLORSPACE__DOC__,                          //tp_doc 
174        0,                                          //tp_traverse 
175        0,                                          //tp_clear 
176        0,                                          //tp_richcompare 
177        0,                                          //tp_weaklistoffset 
178        0,                                          //tp_iter 
179        0,                                          //tp_iternext 
180        PyOCIO_ColorSpace_methods,                  //tp_methods 
181        0,                                          //tp_members 
182        0,                                          //tp_getset 
183        0,                                          //tp_base 
184        0,                                          //tp_dict 
185        0,                                          //tp_descr_get 
186        0,                                          //tp_descr_set 
187        0,                                          //tp_dictoffset 
188        (initproc) PyOCIO_ColorSpace_init,          //tp_init 
189        0,                                          //tp_alloc 
190        0,                                          //tp_new 
191        0,                                          //tp_free
192        0,                                          //tp_is_gc
193    };
194    
195    namespace
196    {
197        
198        ///////////////////////////////////////////////////////////////////////
199        ///
200        
201        int PyOCIO_ColorSpace_init(PyOCIO_ColorSpace * self, PyObject * args, PyObject * kwds)
202        {
203            OCIO_PYTRY_ENTER()
204            
205            ColorSpaceRcPtr ptr = ColorSpace::Create();
206            int ret = BuildPyObject<PyOCIO_ColorSpace, ConstColorSpaceRcPtr, ColorSpaceRcPtr>(self, ptr);
207            
208            char* name = NULL;
209            char* family = NULL;
210            char* equalityGroup = NULL;
211            char* description = NULL;
212            char* bitDepth = NULL;
213            bool isData = false; // TODO: Do not rely on the default value
214            char* allocation = NULL;
215            PyObject* allocationVars = NULL;
216            PyObject* toRefTransform = NULL;
217            PyObject* fromRefTransform = NULL;
218            
219            const char* toRefStr = 
220                ColorSpaceDirectionToString(COLORSPACE_DIR_TO_REFERENCE);
221            const char* fromRefStr = 
222                ColorSpaceDirectionToString(COLORSPACE_DIR_FROM_REFERENCE);
223            const char* kwlist[] = { "name", "family", "equalityGroup",
224                "description", "bitDepth", "isData", "allocation",
225                "allocationVars", toRefStr, fromRefStr, NULL };
226            if(!PyArg_ParseTupleAndKeywords(args, kwds, "|sssssO&sOOO",
227                const_cast<char **>(kwlist),
228                &name, &family, &equalityGroup, &description, &bitDepth,
229                ConvertPyObjectToBool, &isData,
230                &allocation, &allocationVars,
231                &toRefTransform, &fromRefTransform)) return -1;
232            
233            if(name) ptr->setName(name);
234            if(family) ptr->setFamily(family);
235            if(equalityGroup) ptr->setEqualityGroup(equalityGroup);
236            if(description) ptr->setDescription(description);
237            if(bitDepth) ptr->setBitDepth(BitDepthFromString(bitDepth));
238            ptr->setIsData(isData); // TODO: Do not rely on the default value
239            if(allocation) ptr->setAllocation(AllocationFromString(allocation));
240            if(allocationVars)
241            {
242                std::vector<float> vars;
243                if(!FillFloatVectorFromPySequence(allocationVars, vars))
244                {
245                    PyErr_SetString(PyExc_TypeError, "allocationVars kwarg must be a float array.");
246                    return -1;
247                }
248                ptr->setAllocationVars(static_cast<int>(vars.size()), &vars[0]);
249            }
250            if(toRefTransform)
251            {
252                ConstTransformRcPtr transform = GetConstTransform(toRefTransform, true);
253                ptr->setTransform(transform, COLORSPACE_DIR_TO_REFERENCE);
254            }
255            if(fromRefTransform)
256            {
257                ConstTransformRcPtr transform = GetConstTransform(fromRefTransform, true);
258                ptr->setTransform(transform, COLORSPACE_DIR_FROM_REFERENCE);
259            }
260            return ret;
261            
262            OCIO_PYTRY_EXIT(-1)
263        }
264        
265        void PyOCIO_ColorSpace_delete(PyOCIO_ColorSpace *self, PyObject * /*args*/)
266        {
267            DeletePyObject<PyOCIO_ColorSpace>(self);
268        }
269        
270        PyObject * PyOCIO_ColorSpace_isEditable(PyObject * self)
271        {
272            return PyBool_FromLong(IsPyColorSpaceEditable(self));
273        }
274        
275        PyObject * PyOCIO_ColorSpace_createEditableCopy(PyObject * self)
276        {
277            OCIO_PYTRY_ENTER()
278            ConstColorSpaceRcPtr colorSpace = GetConstColorSpace(self, true);
279            ColorSpaceRcPtr copy = colorSpace->createEditableCopy();
280            return BuildEditablePyColorSpace(copy);
281            OCIO_PYTRY_EXIT(NULL)
282        }
283        
284        PyObject * PyOCIO_ColorSpace_getName(PyObject * self)
285        {
286            OCIO_PYTRY_ENTER()
287            ConstColorSpaceRcPtr colorSpace = GetConstColorSpace(self, true);
288            return PyString_FromString(colorSpace->getName());
289            OCIO_PYTRY_EXIT(NULL)
290        }
291        
292        PyObject * PyOCIO_ColorSpace_setName(PyObject * self, PyObject * args)
293        {
294            OCIO_PYTRY_ENTER()
295            char* name = 0;
296            if (!PyArg_ParseTuple(args, "s:setName", &name)) return NULL;
297            ColorSpaceRcPtr colorSpace = GetEditableColorSpace(self);
298            colorSpace->setName(name);
299            Py_RETURN_NONE;
300            OCIO_PYTRY_EXIT(NULL)
301        }
302        
303        PyObject * PyOCIO_ColorSpace_getFamily(PyObject * self)
304        {
305            OCIO_PYTRY_ENTER()
306            ConstColorSpaceRcPtr colorSpace = GetConstColorSpace(self, true);
307            return PyString_FromString(colorSpace->getFamily());
308            OCIO_PYTRY_EXIT(NULL)
309        }
310        
311        PyObject * PyOCIO_ColorSpace_setFamily(PyObject * self, PyObject * args)
312        {
313            OCIO_PYTRY_ENTER()
314            char* name = 0;
315            if (!PyArg_ParseTuple(args, "s:setFamily", &name)) return NULL;
316            ColorSpaceRcPtr colorSpace = GetEditableColorSpace(self);
317            colorSpace->setFamily(name);
318            Py_RETURN_NONE;
319            OCIO_PYTRY_EXIT(NULL)
320        }
321        
322        PyObject * PyOCIO_ColorSpace_getEqualityGroup(PyObject * self)
323        {
324            OCIO_PYTRY_ENTER()
325            ConstColorSpaceRcPtr colorSpace = GetConstColorSpace(self, true);
326            return PyString_FromString(colorSpace->getEqualityGroup());
327            OCIO_PYTRY_EXIT(NULL)
328        }
329        
330        PyObject * PyOCIO_ColorSpace_setEqualityGroup(PyObject * self, PyObject * args)
331        {
332            OCIO_PYTRY_ENTER()
333            char* name = 0;
334            if (!PyArg_ParseTuple(args, "s:setEqualityGroup", &name)) return NULL;
335            ColorSpaceRcPtr colorSpace = GetEditableColorSpace(self);
336            colorSpace->setEqualityGroup(name);
337            Py_RETURN_NONE;
338            OCIO_PYTRY_EXIT(NULL)
339        }
340        
341        PyObject * PyOCIO_ColorSpace_getDescription(PyObject * self)
342        {
343            OCIO_PYTRY_ENTER()
344            ConstColorSpaceRcPtr colorSpace = GetConstColorSpace(self, true);
345            return PyString_FromString(colorSpace->getDescription());
346            OCIO_PYTRY_EXIT(NULL)
347        }
348        
349        PyObject * PyOCIO_ColorSpace_setDescription(PyObject * self, PyObject * args)
350        {
351            OCIO_PYTRY_ENTER()
352            char* name = 0;
353            if (!PyArg_ParseTuple(args, "s:setDescription", &name)) return NULL;
354            ColorSpaceRcPtr colorSpace = GetEditableColorSpace(self);
355            colorSpace->setDescription(name);
356            Py_RETURN_NONE;
357            OCIO_PYTRY_EXIT(NULL)
358        }
359        
360        PyObject * PyOCIO_ColorSpace_getBitDepth(PyObject * self)
361        {
362            OCIO_PYTRY_ENTER()
363            ConstColorSpaceRcPtr colorSpace = GetConstColorSpace(self, true);
364            return PyString_FromString( BitDepthToString(colorSpace->getBitDepth()));
365            OCIO_PYTRY_EXIT(NULL)
366        }
367        
368        PyObject * PyOCIO_ColorSpace_setBitDepth(PyObject * self, PyObject * args)
369        {
370            OCIO_PYTRY_ENTER()
371            char* name = 0;
372            if (!PyArg_ParseTuple(args, "s:setBitDepth", &name)) return NULL;
373            ColorSpaceRcPtr colorSpace = GetEditableColorSpace(self);
374            colorSpace->setBitDepth(BitDepthFromString(name));
375            Py_RETURN_NONE;
376            OCIO_PYTRY_EXIT(NULL)
377        }
378        
379        PyObject * PyOCIO_ColorSpace_isData(PyObject * self)
380        {
381            OCIO_PYTRY_ENTER()
382            ConstColorSpaceRcPtr colorSpace = GetConstColorSpace(self, true);
383            return PyBool_FromLong(colorSpace->isData());
384            OCIO_PYTRY_EXIT(NULL)
385        }
386        
387        PyObject * PyOCIO_ColorSpace_setIsData(PyObject * self, PyObject * args)
388        {
389            OCIO_PYTRY_ENTER()
390            bool isData = false;
391            if (!PyArg_ParseTuple(args, "O&:setIsData",
392                ConvertPyObjectToBool, &isData)) return NULL;
393            ColorSpaceRcPtr colorSpace = GetEditableColorSpace(self);
394            colorSpace->setIsData(isData);
395            Py_RETURN_NONE;
396            OCIO_PYTRY_EXIT(NULL)
397        }
398        
399        PyObject * PyOCIO_ColorSpace_getAllocation(PyObject * self)
400        {
401            OCIO_PYTRY_ENTER()
402            ConstColorSpaceRcPtr colorSpace = GetConstColorSpace(self, true);
403            return PyString_FromString(AllocationToString(colorSpace->getAllocation()));
404            OCIO_PYTRY_EXIT(NULL)
405        }
406        
407        PyObject * PyOCIO_ColorSpace_setAllocation(PyObject * self, PyObject * args)
408        {
409            OCIO_PYTRY_ENTER()
410            Allocation hwalloc;
411            if (!PyArg_ParseTuple(args, "O&:setAllocation",
412                ConvertPyObjectToAllocation, &hwalloc)) return NULL;
413            ColorSpaceRcPtr colorSpace = GetEditableColorSpace(self);
414            colorSpace->setAllocation(hwalloc);
415            Py_RETURN_NONE;
416            OCIO_PYTRY_EXIT(NULL)
417        }
418        
419        PyObject * PyOCIO_ColorSpace_getAllocationVars(PyObject * self)
420        {
421            OCIO_PYTRY_ENTER()
422            ConstColorSpaceRcPtr colorSpace = GetConstColorSpace(self, true);
423            std::vector<float> allocationvars(colorSpace->getAllocationNumVars());
424            if(!allocationvars.empty())
425                colorSpace->getAllocationVars(&allocationvars[0]);
426            return CreatePyListFromFloatVector(allocationvars);
427            OCIO_PYTRY_EXIT(NULL)
428        }
429        
430        PyObject * PyOCIO_ColorSpace_setAllocationVars(PyObject * self, PyObject * args)
431        {
432            OCIO_PYTRY_ENTER()
433            PyObject* pyvars = 0;
434            if (!PyArg_ParseTuple(args, "O:setAllocationVars", &pyvars)) return NULL;
435            std::vector<float> vars;
436            if(!FillFloatVectorFromPySequence(pyvars, vars))
437            {
438                PyErr_SetString(PyExc_TypeError, "First argument must be a float array.");
439                return 0;
440            }
441            ColorSpaceRcPtr colorSpace = GetEditableColorSpace(self);
442            if(!vars.empty())
443                colorSpace->setAllocationVars(static_cast<int>(vars.size()), &vars[0]);
444            Py_RETURN_NONE;
445            OCIO_PYTRY_EXIT(NULL)
446        }
447        
448        PyObject * PyOCIO_ColorSpace_getTransform(PyObject * self,  PyObject * args)
449        {
450            OCIO_PYTRY_ENTER()
451            ColorSpaceDirection dir;
452            if (!PyArg_ParseTuple(args, "O&:getTransform",
453                 ConvertPyObjectToColorSpaceDirection, &dir)) return NULL;
454            ConstColorSpaceRcPtr colorSpace = GetConstColorSpace(self, true);
455            ConstTransformRcPtr transform = colorSpace->getTransform(dir);
456            return BuildConstPyTransform(transform);
457            OCIO_PYTRY_EXIT(NULL)
458        }
459        
460        PyObject * PyOCIO_ColorSpace_setTransform(PyObject * self,  PyObject * args)
461        {
462            OCIO_PYTRY_ENTER()
463            PyObject* pytransform = 0;
464            ColorSpaceDirection dir;
465            if (!PyArg_ParseTuple(args, "OO&:setTransform", &pytransform,
466                ConvertPyObjectToColorSpaceDirection, &dir)) return NULL;
467            ConstTransformRcPtr transform = GetConstTransform(pytransform, true);
468            ColorSpaceRcPtr colorSpace = GetEditableColorSpace(self);
469            colorSpace->setTransform(transform, dir);
470            Py_RETURN_NONE;
471            OCIO_PYTRY_EXIT(NULL)
472        }
473        
474    }
475
476}
477OCIO_NAMESPACE_EXIT