|
From: | Nala Ginrut |
Subject: | Re: ffi-help: handling types |
Date: | Wed, 28 Jun 2017 10:34:02 +0800 |
Hi All,
I am working on a ffi-helper: a program that will read in a C dot-h file and generate a Guile dot-scm file which defines a module to provide hooks into the associated C library. A little status on type handling:
For nominal C types I am trying to stick to the (system foreign) type system. For aggregate types I am using scheme-bytestructures (https://github.com/TaylanUB/scheme-bytestructures ). However, I am currently putting a guile struct wrapper on top of bytestructure descriptors in order to provide a more user-friendly interface (IMO).
In the demo I have created a (cairo cairo-svg) ffi-module which gets converted to a guile module via
$ guild compile-ffi cairo/cairo-svg.ffi
Then I start guile and do this:
scheme@(guile-user)> (use-modules (cairo cairo-svg))
scheme@(guile-user)> (use-modules (ffi-help))
scheme@(guile-user)> (use-modules (system foreign))
scheme@(guile-user)> (define srf (cairo_svg_surface_create (string->pointer "abc.svg") 200.0 200.0))
scheme@(guile-user)> srf
$2 = <cairo_surface_t* 7f9997d0cd40>
@(guile-user)> (define cr (cairo_create srf))
scheme@(guile-user)> cr
$1 = <cairo_t* 7f9999809e00>
scheme@(guile-user)> (define mx (make-cairo_matrix_t))
scheme@(guile-user)> mx
$3 = #<cairo_matrix_t 0x10aac4fa0>
scheme@(guile-user)> (pointer-to mx)
$4 = <cairo_matrix_t* 10aac4fa0>
scheme@(guile-user)> (cairo_get_font_matrix cr (pointer-to mx))
scheme@(guile-user)>
Matt
[Prev in Thread] | Current Thread | [Next in Thread] |