I have a C API that looks like this:
typedef void (*cprcen_channel_callback) (CPRC_abuf *abuf, void *user_data);
int CPRCEN_engine_set_callback(CPRCEN_engine *eng, CPRCEN_channel_handle chan,
void *userdata, cprcen_channel_callback callback);
As you can see, the function CPRCEN_engine_set_callbacktakes user data before the callback, whereas by default Vala expects this to happen. I know about attribute CCodeattribute delegate_target_pos, but no matter what position I specify, the value userdatagets as the first argument instead of the third in the generated function call. I just can't bow my head around the Vala parameter positioning logic.
Here is how I would like the binding to eventually look:
[CCode(cname = "cprcen_channel_callback", has_target = true)]
public delegate void ChannelCallback(AudioBuffer abuf);
[Compact]
[CCode(cname = "CPRCEN_engine")]
public class Engine {
[CCode(cname = "CPRCEN_engine_set_callback")]
public int set_channel_callback(ChannelHandle chan, ChannelCallback callback);
}
How do I do this job?
source
share