Re: [Vala] Some basic problems with gstreamer
- From: Klaus Rotter <klaus rotters de>
- To: vala-list gnome org
- Subject: Re: [Vala] Some basic problems with gstreamer
- Date: Wed, 23 Apr 2008 15:47:42 +0200
Phil Housley wrote:
Normally you shouldn't need to cast a callback. The issue here is
that the function doesn't actually match the definition of SourceFunc,
which takes no arguments in Vala.
The definition in the vapi file is:
public static uint add (uint interval, SourceFunc function);
Valac compiles this
Timeout.add (200, (GLib.SourceFunc) printPosition);
to that:
g_timeout_add (((guint) 200), ((GSourceFunc) ogg_vala_printPosition), NULL);
I want instead of the NULL ptr a ptr to my pipeline class. So I changed
it to this
((Timeout) pipeline).add (200, (GLib.SourceFunc) printPosition);
valac compiles it to that:
g_timeout_add (((guint) 200), ((GSourceFunc) ogg_vala_printPosition), NULL);
But I want this (in the c-code):
g_timeout_add (((guint) 200), ((GSourceFunc) ogg_vala_printPosition), pipeline);
What's wrong?
Vala will use the data argument of a callback registering function to
pass a "this" pointer, it's that which allows you to use an instance
method as a callback. If you run valac with the --save-temps argument
you can see the C code that is produced, which is pretty useful for
checking if you know a C API as well.
Hm... I think defining the callbacks inside the class (at least my way)
isn't useful. I moved it outside (just like a global C function) and
it worked better.
Isn't there a way to define the callbacks inside my class?
-Klaus
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]