Re: [Vala] Array parameter calling conventions



Walter Mundt wrote:

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.


I'd like to add it would be nice to have support for passing two arrays
of the same length - at least in VAPI.

Regards
-- 
I've probably left my head... somewhere. Please wait untill I find it.
Homepage (pl_PL): http://uzytkownik.jogger.pl/
(GNU/)Linux User: #425935 (see http://counter.li.org/)






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