[Vala] Array parameter calling conventions
- From: Walter Mundt <emage spamcop net>
- To: vala-list gnome org
- Subject: [Vala] Array parameter calling conventions
- Date: Fri, 27 Mar 2009 16:10:35 -0400
I've noticed that in VAPI files, there seems to only be two calling
conventions for array-type parameters: with and without the length and
size params passed.
To make it cleaner to bind to C libraries, it would be nice to have a
more flexible way to specify this. How hard/desirable would it be to
add a CCode spec that operates vaguely like this:
Base function, and call in Vala:
public static void foo(int[] bar);
int[] mybar;
foo(mybar);
Variant A:
public static void foo([CCode(array_params="length,ptr")]int[] bar);
generates:
foo(mybar_length, mybar);
Variant B:
public static void foo([CCode(array_params="ptr,size")]int[] bar);
generates:
foo(mybar, mybar_size); // some C API's want a byte count
// rather than an element count
This would allow you to write a VAPI file that seamlessly passes
whatever array length/size information is desired in whatever order the
pre-existing C declaration wants it, as long as the size parameter is in
some way adjacent to the actual array pointer.
--
Walter Mundt
emage spamcop net
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]