On 15 October 2013 23:30, Evan Nemerson <[email protected]> wrote:
> 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:

It would be useless to say I understand that, but I get the start of a
fuzzy idea :) Heuristic: if the C library uses structs and unions and
arrays thereof, fear for my sanity!

I will use your code as an edit/run/redo lesson.

>         while ( i < path.num_data ) {
>           unowned Cairo.PathData? data = path.data[i];
I'm not sure why the data var was declared, it's not used.

>           Cairo.PathDataHeader* header = &(path.data[i].header);
This I kind of get from a little reading of docs. (header is a
pointer, it's being given the address of some other thing.)

Do I have to perform a "delete header;" within the loop? At end of loop? At all?

>           switch (header->type) {
>             case Cairo.PathDataType.MOVE_TO:
>               Cairo.PathDataPoint* point = &(path.data[i + 1].point);
Same delete questions on "point".

>               do_move_to_things (point.x, point.y);
>               break;
>           }
>           i += header.length;
>         }

Sundry questions if you're in the mood:
unowned Cairo.PathData? data = path.data[i];
According to 'pointers' section in the Vala tut, this could be written as:
Cairo.PathData* data = path.data[i];
Is that so? (i.e. dropping the 'unowned', which is still a mystery to me.)
How about that nullable character ... Cairo.PathData*? = :-O

Can one declare vars before the loop, like:
Cairo.PathDataPoint* point;
And then within the loop:
point = &(path.data...);

Awesome response though, thanks for your time.
\d
_______________________________________________
vala-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to