Re: [Vala] Porting libpurple library to Vala.



On Mon, 2010-09-20 at 09:08 +0200, Krzysztof Klinikowski wrote:
Hello.
I'm currently working at porting libgadu library written mostly in
pure C to Vala. I made some work now and I stuck on that:

        int (*resolver_start)(int *fd, void **private_data, const char
*hostname);
        void (*resolver_cleanup)(void **private_data, int force);

You need to create a delegate for each type. It is hard to know what
void **private_data should be mapped to without knowing how it is used,
but if you keep it as a void** something like this should work:

[CCode (has_target = false)]
public delegate int ResolverStartFunc (int fd, void** private_data,
string hostname);
[CCode (has_target = false)]
public delegate void ResolverCleanupFunc (void** private_data, int
force);

And then the fields would be something like:

public ResolverStartFunc resolver_start;
public ResolverCleanupFunc resolver_cleanup;

There are a few examples in the sqlite3 vapi of callbacks which are
missing a typedef in C, although I can't think of any examples where
they are used as fields in a class or struct.


-Evan




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