[Top][All Lists]

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

Re: [Chicken-users] Update: Cairo binding

From: Elf
Subject: Re: [Chicken-users] Update: Cairo binding
Date: Sun, 6 Apr 2008 22:17:32 -0700 (PDT)

thank you, luke!

i would say always change things that mutate pointers into normal return vals.
i would also generally argue against using values and instead using lists for
return elements (although there may be exceptions to this).

also, thanks for getting cairo working, this will make some other ports much
simpler.  much appreciated!


On Mon, 7 Apr 2008, Luke McCarthy wrote:

I've got about 99% of the API for Cairo 1.4.14 complete. Notable additions are
patterns and scaled fonts, and some missing drawing functions, but it's
mostly getters and setters of which there are many! The main thing missing is
glyph support, because I can't think of a good way of passing arrays of
structs from Scheme, and a few other trivialities like getting the reference
count and get/set "user data" which are not very useful for Schemers.

I want to change some aspects of the API for ease of use. Obviously I want to
consult the list first since I don't want to break anyone's code. I don't
imagine many (any?) people are using the Cairo binding yet, it is *alpha*
after all.

Mainly I want to change things so that values which are returned from the C
function through "out" args are instead returned as any Scheme programmer
would expect. For example, change (cairo-text-extents) to return a text
extents object instead of mutating an object passed as an argument.

; private
(define cairo-font-extents*
 (foreign-lambda void "cairo_font_extents" cairo_t cairo_font_extents_t))

; public
(define (cairo-font-extents cr)
 (let ([fe (make-cairo-font-extents-type)])
   (cairo-font-extents* cr fe)

There are similar cases for floating-point arguments which currently expect
f64vectors (of 1) which is a bit of a hack. It would be better to hide this
and return doubles.

Some procedures return multiple arguments. Should I use (values) or (list) ?
Currently I am using (values) in most cases but there is a case where I had
to use (list) since there could be an error (return #f on error) e.g.
(cairo-pattern-get-rgba) which may fail if the pattern is not an RGBA pattern
(there are different types of pattern). Alternatively I could throw an
exception but I'm not familiar with the Chicken way of doing this.

I'd like to get feedback on these issues before I release the code.


Luke McCarthy

Chicken-users mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]