On Wed, Oct 21, 2009 at 17:15:04 +0200, Xavier Bestel wrote:
> On Tue, 2009-10-20 at 19:33 +0200, Xavier Bestel wrote:
[TokenValue means GLib.TokenValue below:]
> > But even with that I still have a problem: TokenValue is a simple enum,
> > tagged with [SimpleType] in the vapi file, but Vala inserts a
> > (non-existing) g_token_value_destroy() and of course fails at link-time.
> >
> > Could someone knowledgeable show me how to fix the vapi ?
>
> So, I've added [CCode (destroy_function = "")] which makes it work, but
> by pure luck: now the code generator inserts an "(&val)" into the code
> (i.e. it tries to destroy the value with an empty function name).
> That's ugly.
Hm, it probably shouldn't generate that. The need for CCode is weird --
TokenValue is declared [SimpleType] and that, being passed around by value,
shouldn't have a destroy function by default.
> I think it comes from the fact that TokenValue is actually an union, but
> Vala has no concept of union (even for foreign code) it it's declared as
Actually I believe it does -- *except* in foreign code.
> a struct in the vapi, which it tries to destroy after use.
I see it declared as
[SimpleType]
struct TokenValue
here (vala 0.7.7), which is the right way to declare it. Because struct just
means stored by value and [SimpleType] means passed by value as well. How
it's really declared in C is irrelevant to Vala.
> Is there some documentation about the code attributes somewhere ? I'd
> like to fix it myself but I need some pointers.
I fear there's nothing really comprehensive. You can find some things on the
wiki (live.gnome.org/Vala) and the rest you have to look at how other things
are defined.
--
Jan 'Bulb' Hudec <[email protected]>
_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list