[cairo] Call for testers: Const status accessors

Andrea Canciani ranma42 at gmail.com
Fri Aug 5 02:36:23 PDT 2011


On Fri, Aug 5, 2011 at 10:34 AM, M Joonas Pihlaja
<jpihlaja at cc.helsinki.fi> wrote:
>
> On Fri, 5 Aug 2011, Andrea Canciani wrote:
>
>> The attached patch modifies cairo status accessors to accept a const
>> argument. This should be ok with C, but other languages might have
>> different issues.
>
> Cairo shouldn't be exporting const opaque pointer types since it's
> none of the callers business what happens inside an opaque object.

I agree. Unfortunately we're already exporting cairo_region_status().

> Const correctness in APIs isn't relevant in C unless the caller has
> full visibility into the structure and layout of an object.  IMHO
> using constness of an opaque pointer to reflect an operation's
> mutation-freeness of the underlying object, as seems to be the case in
> this patch, is an abuse of a perfectly fine qualifier, especially in
> C.  C++ in particular is a different case all together as it has much
> more support for this kind of semantic tagging using the const
> qualifier.

In this case the patch does not aim at tagging the functions with
additional information, but just at making the interface consistent
with cairo_region_status().

An alternative patch (which I would prefer, if it didn't possibly cause
new warnings in existing software) would just remove const from
cairo_region_status().

Would such a patch be preferred?

Andrea


More information about the cairo mailing list