Re: [Vala] [PATCH] Add libarchive bindings.
- From: Evan Nemerson <evan coeus-group com>
- To: Julian Andres Klode <jak jak-linux org>
- Cc: vala-list <vala-list gnome org>
- Subject: Re: [Vala] [PATCH] Add libarchive bindings.
- Date: Sun, 22 Nov 2009 11:18:20 -0800
On Sun, 2009-11-22 at 18:37 +0100, Julian Andres Klode wrote:
On Sun, Nov 22, 2009 at 05:32:36PM +0100, Michael 'Mickey' Lauer wrote:
Hi Julian,
this looks mostly good, however please do not use
[CCode (has_target = false)] unless the upstream API does not provide a
user_data or client_data pointer. In the case of your delegates, it
seems all provide such a client_data pointer, so rather use
[CCode (instance_pos = ...)] for it, otherwise you would limit callbacks
to being static only.
Any more exact ideas? All delegates take the Archive instance as their
first parameter and userdata as their second:
public delegate off_t SkipCallback (Archive archive, void* client_data, off_t request);
I believe this is what you want:
[CCode (instance_pos = 1.9)]
public delegate off_t SkipCallback (Archive archive, off_t request);
Now, one method of Read (a sublcass of Archive) is:
public Result open (void* client_data, OpenCallback ocb, ReadCallback rcb, CloseCallback ccb);
And "client_data" shall be passed to all callbacks.
Ah, that is more tricky. AFAIK there isn't really an elegant way to do
this, since Vala assumes one user data argument per callback. You could
try something along the like:
public Result open (
[CCode (delegate_target_pos = 0.9)] OpenCallback ocb,
[CCode (delegate_target_pos = 0.9)] ReadCallback rcb,
[CCode (delegate_target_pos = 0.9)] CloseCallback ccb);
Which I believe will generate correct code, but there is likely to be a
problem if the user data argument for the three callbacks would have
been different. For example,
archive.open (Foo.open_cb, Bar.read_cb, Baz.close_cb);
Will most likely break horribly at runtime, though it probably won't
emit any errors or warnings at compile time.
I want have the delegate be:
public delegate off_t SkipCallback (off_t request);
and the method:
public Result open (OpenCallback ocb, ReadCallback rcb, CloseCallback ccb);
How should I do this?
I don't think you can do that for the delegate signature because there
is no Archive parameter.
Also, can you please not use "using Posix" in the bindings? Lots of
people use the vapi as a reference, and it's a bit disorienting.
-Evan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]