Re: [Vala] Some basic problems with gstreamer



2008/4/22 Klaus Rotter <klaus rotters de>:
Klaus Rotter schrieb:

/home/klaus/oggtest/oggtest.vala:65.17-65.27: error: Argument 2: Cannot
 > convert from `oggVala.printPosition' to `GLib.SourceFunc'
 > Compilation failed: 1 error(s), 0 warning(s)

 Ah... shame on me! A type cast did the trick. I thought in those
 high-level programming languages you don't need those constructs :-)

 >                 Timeout.add (200, (Glib.SourceFunc) printPosition);

...

 But it seems I cannot give an argument to Timeout.add like I could do in
 C g_timeout_add. Is there any reason why all member in class Timeout in
 glib-2.vapi have no data argument? Or is this an error?

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.

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.

Did that make sense?  I''m not sure now...
-- 
Phil Housley



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]