You're close.  valac doesn't handle this very well because of the
anonymous structs in the C API.  It wants to assign to temporary
variables even when all you're doing is accessing fields, and since
they're structs the temporary variables aren't pointers, which will
cause the CC to complain (even though the types are compatible).  You
can use pointers to assign temporary variables in vala to work around
this:

        Cairo.Path path = cr.copy_path ();
        int i = 0;
        
        while ( i < path.num_data ) {
          unowned Cairo.PathData? data = path.data[i];
          Cairo.PathDataHeader* header = &(path.data[i].header);
        
          switch (header->type) {
            case Cairo.PathDataType.MOVE_TO:
              Cairo.PathDataPoint* point = &(path.data[i + 1].point);
              do_move_to_things (point.x, point.y);
              break;
          }
        
          i += header.length;
        }

I didn't bother with the other cases in the switch—you should get the
idea.


-Evan



On Tue, 2013-10-15 at 14:45 -0600, Shawn Ferris wrote:
> nevermind.. I just noticed that's wrong too :D
> 
> 
> On Tue, Oct 15, 2013 at 2:42 PM, Shawn Ferris <shawn.fer...@gmail.com>wrote:
> 
> > On Tue, Oct 15, 2013 at 12:48 PM, Donn Ingle <donn.in...@gmail.com> wrote:
> >
> >> > array.. A quick glance at the cairo vapi, and I think you really want
> >> this?:
> >> >     Cairo.PathData[] data = path.data;
> >>
> >> I feel disturbed by that ;) Not sure why.
> >>
> >> The code I'm trying to Vala-ize is here:
> >> http://cairographics.org/manual/cairo-Paths.html#cairo-path-data-t
> >>
> >>
> > Ahh.. this makes a bit more sense.. I still don't know if this is the
> > correct way, but...
> >
> >     Cairo.PathData[] data;
> >
> >     for (int i = 0; i < this.path.num_data; i +=
> > this.path.data[i].header.length) {
> >
> >       var data = &this.path.data[i];
> >
> > Shawn
> >
> _______________________________________________
> vala-list mailing list
> vala-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/vala-list

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to