[racket-dev] Working Cairo-bindings for Racket?

From: Antti Karttunen (antti.karttunen at gmail.com)
Date: Sat Sep 27 05:08:53 EDT 2014

On Fri, Sep 26, 2014 at 4:05 PM, Sam Tobin-Hochstadt <samth at cs.indiana.edu>
wrote:

> Instead of changing my Planet package, it would be better to provide
> an FFI to cairo based on the existing one that's in the library you
> mention. I don't think any of my package would be useful for that,
> though.
>


Did I understand right that your cairo.ss is intended to work with some
substantially earlier version of Cairo-library, and you want to keep it
that way?

In any case, at least I realized that
(require racket/draw/unsafe/cairo-lib)
followed by  (define libcairo cairo-lib)

is (just ?) a more portable way of saying:

(define libcairo (ffi-lib "libcairo"))
[Or in Windows: (define libcairo (ffi-lib "libcairo-2")) because it is
called libcairo-2.dll]

Like this:
#lang racket
(require racket/draw/unsafe/cairo-lib)
(require ffi/unsafe)

cairo-lib
#<ffi-lib>
> (define libcairo (ffi-lib "libcairo"))
. . ffi-lib: couldn't open "libcairo.dll" (The specified module could not
be found.; errno=126)
> (define libcairo (ffi-lib "libcairo-2"))
> libcairo
#<ffi-lib>
> (eq? cairo-lib libcairo)
#t
>

--------------------


So I guess making my own set of bindings shouldn't be too much of
racket-science...


Best,

Antti


> Sam
>
> On Fri, Sep 26, 2014 at 8:44 AM, Antti Karttunen
> <antti.karttunen at gmail.com> wrote:
> >
> > Another question:
> >
> > Would it be a big job to edit the bindings in
> >
> http://planet.racket-lang.org/package-source/samth/cairo.plt/1/0/cairo.ss
> > so that it worked with the current
> >
> > (require racket/draw/unsafe/cairo-lib)
> >
> > cairo-lib
> > #<ffi-lib>
> >
> > ?
> >
> > I guess it's not just question of "deprecated names for Cairo functions"
> as
> > mentioned in the ticket:
> > http://planet.racket-lang.org/trac/ticket/357
> >
> > but also code like: (define libcairo (ffi-lib "libcairo"))
> >
> > right in the beginning of .../samth/cairo.plt/1/0/cairo.ss
> > ?
> >
> >
> > Yours,
> >
> > Antti Karttunen
> >
> >
> > _________________________
> >   Racket Developers list:
> >   http://lists.racket-lang.org/dev
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20140927/fa2807b6/attachment.html>

Posted on the dev mailing list.