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



Just to add to this, I've created a VAPI for libexif we use in Shotwell.
I've not submitted it because it's incomplete.  You might want to check it
out:

http://trac.yorba.org/browser/shotwell/trunk/vapi/libexif.vapi

-- Jim

On Mon, Apr 12, 2010 at 5:05 AM, Abderrahim Kitouni <a kitouni gmail com>wrote:

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
_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list



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