Re: [Vala] Binding a function that return a structure, not a pointer



Hi,

2010/4/11 Luca Bruno <lethalman88 gmail com>:
On Sat, Apr 10, 2010 at 04:58:06PM -0700, Darren Warner wrote:

I'm creating a vapi for libexif (using vala-gen-introspect) which
includes a function that returns a structure:

typedef struct {ExifLong numerator; ExifLong denominator; }ExifRational;
ExifRational  exif_get_rational  (const unsigned char *b,
ExifByteOrder order);

If I don't alter ExifRational in my .metadata, the C compiler
complains about assigning ExifRational to ExifRational * when I try
to use the function.

If I set ExifRational is_value_type="1", which I believe I should
be, valac is generating an additional parameter (a pointer to a
temporary ExifRational) when calling exif_get_rational() - of course
the compiler complains at this also.

This seems like a newbie question, but I've been unable to find any
similar examples in the existing bindings, so any help would be
appreciated.

I might be wrong but it looks like it's used like a simple type.
Try adding [SimpleType] to your struct binding, e.g.:
or in the metadata file :

ExifRational is_value_type="1" simple_type="1"

HTH,
Abderrahim



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