Re: [Vala] Crazy Vala callback behavior



Hello

                 في ح، 18-12-2011 عند 00:32 +0100 ، كتب Matthias Klumpp:
Hi!
This is a bit difficult to reproduce, so I'm not sure if this really is a bug.
I am mixing Vala and C code. I implement an internal class in Vala,
which defines the following callback:
  public signal Results request_whatprovides (uint filters, uint
provides, [CCode (array_length = false, array_null_terminated = true)]
string[] search);

AFAIK, signals with return values aren't supported in Vala. Another
important thing you didn't mention is what is result (is it a class, a
struct). And since you're talking about a callback, maybe you meant
delegate instead of signal. Please explain what you want to do rather
than how you think you should do it, it's better for helping you.

This callback is used to forward requests to a C library, which is
itself loaded as GModule, but I don't think this matter. Anyway, I
would expect that I need to implement a callback in C using these
parameters:

I think you really mean a delegate, and if so, your callback should have
the arguments (guint filters, guint provides, gchar** search, gpointer
user_data), and return a Results* if Results is a reference type, and
have the arguments (guint filters, guint provides, gchar** search,
Results* result, gpointer user_data) if Results is a struct.

 xy_request_whatprovides_cb (BackendProxy *sender,
                              PkBitfield filters,
                              PkProvidesEnum provides,
                              gchar** search,
                              gpointer user_data)

Why are you using different types for the arguments? You should probably
have bindings for the library that is used by both you app and the
loadable module.

HTH,
Abderrahim




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