On Sat, Sep 19, 2009 at 11:08:36 -0400, Michael B. Trausch wrote:
> I'm currently working on bindings for the gpgme library, and have a
> question while working on them. Many of the structures are defined like
> this:
>
> struct _private_name {
> ...
> };
>
> typedef struct _private_name *public_name_t;
>
> Now, as far as binding these for Vala goes, this means that Vala
> shouldn't emit code that makes these names into pointers, because they
> are already pointers. Does that mean that _private_name is what should
> be bound to, not the public_name_t?
Yes, I think you should bind it like
[Compact]
[CCode(cname = "struct _private_name", copy_function = "public_name_copy",
free_function = "public_name_free")]
class PublicName {
[CCode(cname = "public_name_new")]
public PublicName();
...
}
And if it does support reference-counting it should be
[Compact]
[CCode(cname = "struct _private_name", ref_function = "public_name_ref",
unref_function = "public_name_unref")]
class PublicName {
[CCode(cname = "public_name_new")]
public PublicName();
...
}
The [Compact] means it's not registered with GType system, which I suppose
it's true when it does not follow any GObject conventions
(and I think vala also wouldn't expect it to have a construct function than).
I shortly thought that it would be also possible to bind it as [SimpleType]
struct with the public_name_t, but vala wouldn't keep track of ownership for
you than, so it does not make much sense.
--
Jan 'Bulb' Hudec <[email protected]>
_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list