Re: [Vala] Creating a binding for a non-glib library and using delegate to map a function pointer



في ج، 11-03-2011 عند 16:25 +0100 ، كتب Luca Dionisi:
Perhaps I got the point where I was wrong.

On Fri, Mar 11, 2011 at 12:42 PM, Luca Dionisi <luca dionisi gmail com> wrote:
First pass, I prepared a direct mapping vapi.
 libfoo.vapi    [http://pastebin.com/rZb6JqAZ]
 [IMPORTANT note: if I don't miss something, I have
 [to create a delegate, named FunctionDelegate, in the vapi
 [file in order to map the function pointer argument.

Another way to do that is to define the delegate in another vala
source file and include it in the compilation where libfoo.vapi is
used.
I think it would be better to just create a new header that you
reference in the vapi, it would be easier to distribute with your
wrapping library.

Another important point: you shouldn't use has_target=false if the
library you are binding has user_data arguments, so your
FunctionDelegate should be defined as 

public delegate void* FunctionDelegate ();

And generally, you should try to avoid using void* if possible. For
example, if it makes sense for your library, you can use a generic
delegate.

HTH,
Abderrahim

P.S. It may be more productive to ask questions directly on real-world
libraries rather than making a little "foo" library.

P.P.S. For little files like these, it would be better to inline or
attach them, so people can read them when offline.




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