[Vala] Assist with compile issue re Cairo.PathData



Hello,
I'm sure this is my small brain and lack of experience, but I can't
get past this compile error. I will paste a complete sample below.

---

using Gee;
using Cairo;

// Compile with: valac --pkg gee-1.0 --pkg gtk+-3.0 -X -lm
cairopath.compile.bug.vala -o test

public abstract class Shape : Object {

  private Cairo.Path path;

  private void buggyfunc( Cairo.Context cr )
    //Algorithm from:
http://cairographics.org/manual/cairo-Paths.html#cairo-path-data-t

    //Catch null path situation. Wise?
    requires (this.path != null)
    {
    cr.new_path();

    //Bug here sometimes.
    //Cairo.PathData data;
    //Have tried Cairo.PathData[] data;

    for (int i = 0; i < this.path.num_data; i +=
this.path.data[i].header.length) {

      //BUG here too: Try 'var'... No go. :(
      var data = this.path.data[i];

      switch (data.header.type) {
        case Cairo.PathDataType.MOVE_TO:
          cr.move_to ( data[1].point.x, data[1].point.y );
          break;
        case Cairo.PathDataType.LINE_TO:
          cr.line_to ( data[1].point.x, data[1].point.y );
          break;
        case Cairo.PathDataType.CURVE_TO:
          cr.curve_to ( data[1].point.x, data[1].point.y,
                        data[2].point.x, data[2].point.y,
                        data[3].point.x, data[3].point.y );
          break;
        case Cairo.PathDataType.CLOSE_PATH:
          cr.close_path();
          break;
      }
    }//end for
  }
}

--

The error is:
cairopath.compile.bug.vala:31.24-31.30: error: The expression
`Cairo.PathData' does not denote an array
          cr.move_to ( data[1].point.x, data[1].point.y );
                             ^^^^^^^

Same for all use of data[].

I have tried various combinations of data[] and the error changes but
it's always to do with PathData being somehow not an array.

I'm shooting in the dark. Can anyone help me grok this?

/d


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]