[cairo] const-ness fixes for transform_distance and transform_point

Owen Taylor otaylor at redhat.com
Mon May 9 10:06:04 PDT 2005

On Mon, 2005-05-09 at 12:43 -0400, Carl Worth wrote:

> With this in place, I think I'd like to change cairo_get_matrix (yes,
> one more time), to return a const pointer to the current matrix. This
> should be about as convenient to use as the matrix-as-value version I
> wanted earlier, but without the efficiency problems. As is, I've found
> situations where one has to do things such as:
> 	cairo_matrix_t ctm;
> 	cairo_get_matrix (cr, &ctm);
> 	cairo_scaled_font_create (face, font_matrix, &ctm);
> where one would prefer to do:
> 	cairo_scaled_font_create (face, font_matrix,
> 				  cairo_get_matrix (cr));
> But it wasn't really feasible to even consider returning a const
> pointer without the current patch for const-correctness.
> And if we were to do that, the API would have the nice property that
> the only place a non-const cairo_matrix_t* would appear would be as
> the first parameter of a cairo_matrix function, (where we currently
> have non-const cairo_matrix_t* as the final parameter for filling out
> a return value).

This does muddle the "plain structure returns are out-parameters"
rule that I documented in the language binding appendix.

That is, currently, we have conceptual unity between:

cairo_get_matrix (cairo_t *cr, cairo_matrix_t *matrix);

cairo_font_extents (cairo_t              *cr,
                    cairo_font_extents_t *extents);

It doesn't really make things harder, we just add another pattern
to the pile: "plain structure returns are out-parameters
or const return values", but there is some loss of consistency


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050509/ff4774dd/attachment.pgp

More information about the cairo mailing list