Re: [Vala] Properly wrapping callbacks
- From: Andrea Del Signore <sejerpz tin it>
- To: Michael 'Mickey' Lauer <mickey vanille-media de>
- Cc: vala-list gnome org
- Subject: Re: [Vala] Properly wrapping callbacks
- Date: Mon, 26 Jan 2009 20:20:48 +0100
On Mon, 2009-01-26 at 19:15 +0100, Michael 'Mickey' Lauer wrote:
Thanks for your mails, I think the VAPI part is clear to me now. Unfortunately
I still can't do the actual setting of the callback. I have:
=========== gsm0710_p.h ===========
typedef int (*gsm0710_context_at_command_callback)(struct
gsm0710_context *ctx, const char *cmd);
...
struct gsm0710_context
{
/* variables */
...
gsm0710_context_at_command_callback at_command;
...
}
========= gsm0710.vapi ===========
[CCode (instance_pos = 0)]
public delegate int AtCommandCallback( string cmd );
========= multiplexer.vala ==========
public class Multiplexer : Object
{
Context ctx;
public static int at_command_cb( Context ctx, char* command )
{
Multiplexer m = (Multiplexer) ctx.user_data;
debug( "CB: atCommand %s", (string)command );
return 1;
}
public Multiplexer( bool advanced, int framesize, string device, int
portspeed )
{
debug( "Multiplexer created for mode %s, framesize %d, device %s
@ %d", advanced? "advanced":"basic", framesize, device, portspeed );
ctx = new Context();
ctx.initialize();
ctx.server = 1;
ctx.mode = advanced? 1 : 0;
ctx.frame_size = framesize;
ctx.port_speed = portspeed;
ctx.at_command = at_command_cb;
}
}
I now get the following error:
make[1]: Leaving directory `/local/pkg/fso/fso-gsm0710muxd'
/usr/local/bin/valac -c --vapidir gsm0710 --pkg dbus-glib-1 --pkg
gsm0710 --save-temps --basedir . src/consts.vala src/multiplexer.vala
src/server.vala src/main.vala
src/multiplexer.vala:53.9-53.38: error: Assignment: Cannot convert from
`Multiplexer.at_command_cb' to `Gsm0710.Context.AtCommandCallback'
ctx.at_command = at_command_cb;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Compilation failed: 1 error(s), 0 warning(s)
What am I missing?
Cheers,
Mickey.
Hi,
I think that the delegate should be static:
[CCode (instance_pos = 0)]
public static delegate int AtCommandCallback( string cmd );
Regards,
Andrea
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]