Re: [Vala] Generating bindings for non-GLib/GObject based API
- From: Michael Wild <themiwi users sourceforge net>
- To: Abderrahim Kitouni <a kitouni gmail com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] Generating bindings for non-GLib/GObject based API
- Date: Thu, 22 Apr 2010 17:02:25 +0200
On 22. Apr, 2010, at 16:12 , Abderrahim Kitouni wrote:
Hello,
2010/4/22 Michael Wild <themiwi users sourceforge net>:
I don't understand this, does the function still alocate the instance,
or does it just initialize it?
It does both, it just doesn't return the result in the return argument, but in one of the parameters. I
found an example with the same issue, but I don't understand how Vala can be doing the right thing.
Looking at zlib.vapi I see
[CCode (cname = "z_stream", destroy_function = "deflateEnd")]
public struct DeflateStream : Stream {
[CCode (cname = "deflateInit")]
public DeflateStream (int level = Level.DEFAULT_COMPRESSION);
// ...
}
but deflateInit has the following (sanitized) signature:
int deflateInit(z_stream *strm, int level);
How does Vala know that it must pick the first argument and not the return value?
Because the function doesn't allocate the struct, only initializes it.
So it's used :
z_stream strm;
deflateInit(&strm, ...);
this way you have to declare your type as a struct (and not a class).
HTH,
Abderrahim
Ahh, I see. No, in my case the function definitely does the allocation. Is there any way to make Vala work
with this function or do I need some wrapper function? How would I best do this?
Michael
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]