Re: [Vala] Properly wrapping callbacks
- From: Frederik <scumm_fredo gmx net>
- To: vala-list <vala-list gnome org>
- Subject: Re: [Vala] Properly wrapping callbacks
- Date: Mon, 26 Jan 2009 11:32:16 +0100
Frederik wrote:
Michael 'Mickey' Lauer wrote:
Hi,
I'm working on my first binding for a non-gobject library -- please see
gsm0710_p.h.
My current vapi is also attached. I'm struggling with setting the callback
pointers now. How should the callbacks in my .vala object be defined so that
I can set them via e.g.
<callback>
var ctx = new Context();
ctx.at_command = <callback>
Cheers,
Mickey.
You should make your delegate non-static, since an instance gets passed.
In your case the instance gets passed as first parameter and not as last
parameter, so you must add [CCode [instance_pos = 0)]. And 'char*'
translates to 'string' in Vala.
[CCode [instance_pos = 0)]
public delegate int at_command_t (string command);
However, if it is meant as source object for some kind of event and not
as instance you should mark it as static and pass the context explicitly:
public static delegate int at_command_t (Context ctx, string command);
Regards,
Frederik
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]