[Vala] How to wrap delegates that receive the target in non-last positions and are passed as fields of a struct?



My question is how to indicate in a .vapi that the target of a
delegate is in a certain position.
Let me explain first my case:

The omx callbacks do not receive the target in the last position, but
in the second (app_data):

    public delegate Error EmptyBufferDoneFunc(
        Handle component,
        void *app_data,
        BufferHeader buffer);

And, the callbacks are not added one by one, but as a whole using
a struct of callbacks:

    public struct Callback {
        public EventHandlerFunc EventHandler;
        public EmptyBufferDoneFunc EmptyBufferDone;
        public FillBufferDoneFunc FillBufferDone;
    }

And that struct is passed as an argument to a call:

    public Error get_handle(out Handle component, string
component_name, void *app_data, Callback callbacks);

So, I want vala to pass the hidden instance pointer (this) to the
callbacks, in the position of app_data.
So, for global functions, app_data would become NULL and for methos
app_data would be this.

That way instance methods could be used as callbacks, instead of
static or global functions.

How to do that?

Thanks in advance.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]