On Tue, Sep 15, 2009 at 17:14:38 -0500, Mr. Maxwell . wrote:
> 
> What do I do with the typedef struct declarations? This is what I have but I 
> don't think it's right.
> 
> c code
>   typedef struct { char _dummy; } ID3Tag;

They would have done better if they had

  typedef struct _ID3Tag ID3Tag

It's clearly not the real type, so why on earth they pretend it's complete...

> vala code
>     [CCode(cname = "typedef struct")]
>     public struct ID3Tag { private char _dummy; }

Given it's not the real type, it can't be a struct, because it can't be
allocated on the stack. You were already told the correct solution -- you
even quoted it below.

> On Tue, 15 Sep 2009 18:14:24 -0300 [email protected] wrote:
> > if the namespace will be called Id3 you can do this
> > 
> > [Compact]
> > [CCode (cname="ID3Tag")]
> > public class Tag
> > {
> >   [CCode (cname="ID3Tag_New")]
> >   public Tag ();
> >   [CCode (cname="ID3Tag_HasChanged")]
> > 
> >   public bool has_changed ();
> >   // add the others
> > }

Yes, that's the right solution.

Compact class is something, that is allocated on the heap and passed by
pointer (while struct is allocated on stack and passed by value) but unlike
normal classes does not support reference-counting.

> >  I don't remeber well how to add the free function (in this case
> >  ID3Tag_Delete), i think that in the CCode of the class you should add
> >  free_funcion="ID3Tag_Delete", but it's just a guess. 

That is a correct guess. It would be 

  [Compact]
  [CCode (cname = "ID3Tag", free_function = "IR3Tag_Delete")]
  public class Tag { ...

-- 
                                                 Jan 'Bulb' Hudec <[email protected]>
_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to