[cairo] [Bug 90166] Add a way to specify units (in SVG output)

Uli Schlachter psychon at znc.in
Tue Oct 31 09:35:47 UTC 2017


On 30.10.2017 23:20, Antonio Ospite wrote:
> On Thu, 12 Oct 2017 21:59:08 +1030
> Adrian Johnson <ajohnson at redneon.com> wrote:
> 
> [...]
>> The enum in the patch is:
>>
>> typedef enum _cairo_svg_unit {
> 
> [...]
> 
>> } cairo_svg_unit_t;
>>
>> This looks good to me. It just needs a getter.
>>
> 
> About the getter function, what do you prefer?
> 
> 1. A function which returns the unit in the return value.
[...]
> 
> 2. A function which returns the unit in an output parameter and returns
>    a status in the return value.
>    
>    This seems more robust; is it cairo-style?
> 
[...]

Hi,

take a look at, for example, cairo_image_surface_get_width():

int
cairo_image_surface_get_width (cairo_surface_t *surface)
{
    cairo_image_surface_t *image_surface = (cairo_image_surface_t *)
surface;

    if (! _cairo_surface_is_image (surface)) {
	_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
	return 0;
    }

    return image_surface->width;
}

I'd say the same should be done here. No one will check the status
return value of such a function anyway.

Cheers,
Uli
-- 
A learning experience is one of those things that say,
'You know that thing you just did? Don't do that.'
                     -- Douglas Adams


More information about the cairo mailing list