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 CPRCEN_engine_set_callback
function takes the user data before the callback whereas, by default, Vala expects it to come after. I know about the CCode
attribute's delegate_target_pos
parameter, but no matter what position I specify, the userdata
value gets supplied as the first argument instead of the third in the generated function call. I just can't seem to wrap my head around Vala's parameter positioning logic.
Here's how I'd like the binding to ultimately 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 make this work?