GIR definition of Cairo Matrix

From cairo_matrix_t: Cairo: A Vector Graphics Library the Cairo Matrix seems to be a stack-allocated entity (in C-like languages at least), like GtkTextIter or cairo.RectangleInt. But I wonder why in the GIR file the Cairo matrix is an opaque object with no fields?

/usr/share/gir-1.0/cairo-1.0.gir

While for RectangleInt and plain Rectangle

<record name="Rectangle" c:type="cairo_rectangle_t"
            glib:type-name="CairoRectangle"
            glib:get-type="cairo_gobject_rectangle_get_type">
      <field name="x" writable="1">
        <type name="gdouble" c:type="gdouble"/>
      </field>
      <field name="y" writable="1">
        <type name="gdouble" c:type="gdouble"/>
      </field>
      <field name="width" writable="1">
        <type name="gdouble" c:type="gdouble"/>
      </field>
      <field name="height" writable="1">
        <type name="gdouble" c:type="gdouble"/>
      </field>
    </record>
    <record name="RectangleInt" c:type="cairo_rectangle_int_t"
	    glib:type-name="CairoRectangleInt"
	    glib:get-type="cairo_gobject_rectangle_int_get_type">
      <field name="x" writable="1">
	<type name="gint" c:type="gint"/>
      </field>
      <field name="y" writable="1">
	<type name="gint" c:type="gint"/>
      </field>
      <field name="width" writable="1">
	<type name="gint" c:type="gint"/>
      </field>
      <field name="height" writable="1">
	<type name="gint" c:type="gint"/>
      </field>
    </record>

(For the Rectangle types, our bindings generator has worked fine.)
So we have to define the Matrix type fully manually. Because, there is no Allocator/Constructor provided, just an init() for the fields, we have to define the type properly, at least the correct size, even when we would have never to access the fields ourselves. Well, not that hard, I am just wondering.

Never, ever use the introspection data for Cairo. It’s only useful to generate the introspection data of other libraries. Cairo is not introspectable, that’s why the GIR is hand-written.

A late warning. Some years ago, when the cairo gir file was a bit extended, I put some effort into splitting the Cairo Nim bindings into two distinct files, a cairo.nim generated from the GIR file, containing some basic data types, and a much larger cairoimpl.nim created manually. I was aware that cairo.gir was manually created, but I assumed that its content was created with a lot of care, and may eventually cover full cairo. Well, then I will create the Matrix type manually.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.