unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* ffi-help: handling types
@ 2017-06-28  2:26 Matt Wette
  2017-06-28  2:34 ` Nala Ginrut
  0 siblings, 1 reply; 2+ messages in thread
From: Matt Wette @ 2017-06-28  2:26 UTC (permalink / raw)
  To: guile-devel

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: ffi-help: handling types
  2017-06-28  2:26 ffi-help: handling types Matt Wette
@ 2017-06-28  2:34 ` Nala Ginrut
  0 siblings, 0 replies; 2+ messages in thread
From: Nala Ginrut @ 2017-06-28  2:34 UTC (permalink / raw)
  To: Matt Wette; +Cc: guile-devel

[-- Attachment #1: Type: text/plain, Size: 1646 bytes --]

Good job!


2017年6月28日 上午10:26,"Matt Wette" <matt.wette@gmail.com>写道:

> 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
>
>
>

[-- Attachment #2: Type: text/html, Size: 2185 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-28  2:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-28  2:26 ffi-help: handling types Matt Wette
2017-06-28  2:34 ` Nala Ginrut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).