SanderMertens / python-binding

Python for Corto

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Update Corto objects

jleeothon opened this issue · comments

There shall be an .update method in the cortopy.object class that is similar to the Corto .update method.

For the first design of this method, it will wrap around .setval. Roughly:

# module cortopy
class object:
    def update(self, value):
        # corto_updateBegin()
        self.setval(value)
        # corto_updateEnd()

For future reference, updates could additionally be implemented as context managers, e.g.:

with cortopy.update(myobject):
    # set some values
    # set more values
    pass

In order for Python code to be executed as observers, we need some C function (in cortopy, for example), that will execute Python code. Then wrap this function around with a Corto observer, and then register it with an object. Some useful code therefor:

int CORTOPY_BINDING = corto_callRegisterBinding(handler, NULL, NULL, NULL);
o = corto_observerCreate(...);
o->impl = po;
o->kind = CORTOPY_BINDING;