From: Matt Wette <matt.wette@gmail.com>
To: Matt Wette <matt.wette@gmail.com>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: ffi-helper: status
Date: Mon, 10 Jul 2017 19:49:12 -0700 [thread overview]
Message-ID: <4B3AF9A3-C690-465C-AE54-D6E4DBA066FB@gmail.com> (raw)
In-Reply-To: <30D395AD-3130-469D-AF9A-67F735852ACB@gmail.com>
> On Jul 7, 2017, at 5:31 PM, Matt Wette <matt.wette@gmail.com> wrote:
>
>
>> On Jul 7, 2017, at 5:18 PM, Matt Wette <matt.wette@gmail.com> wrote:
>> However, the above generates 397 FFI declarations into a cairo.scm file which is about 6000 lines long. I’m not
>> sure if I want to start testing this code or start converting suggestions and have guile-users do some testing.
>
> That is, for this example, I no longer run into declarations which my code says “failed,” indicating that it didn’t know what to do with the declaration.
>
> I already notice that the function types converters should be called “unwrap” and that they should be called by the procedure interface. I am going to start playing with cairo_set_user_data to see if passed procedures work.
Another working demo:
mwette$ guile exam.d/cairo02.scm
d1 called with ((abc . 123) (def . 456))
mwette$ cat exam.d/cairo02.scm
;; exam.d/cairo02.scm
(use-modules (cairo cairo)) ; auto-generated from cairo.h etc
(use-modules (ffi-help-rt)) ; pointer-to
(use-modules (system foreign)) ; string->pointer, pointer<->scm
(define srf (cairo_svg_surface_create (string->pointer "abc.svg") 200.0 200.0))
(define cr (cairo_create srf))
;; typedef struct _cairo_user_data_key {
;; int unused;
;; } cairo_user_data_key_t;
;;
;; typedef void (*cairo_destroy_func_t)(void *data);
;;
;; cairo_status_t cairo_set_user_data(cairo_t *cr, const cairo_user_data_key_t
;; *key, void *user_data, cairo_destroy_func_t destroy);
(define k1 (make-cairo_user_data_key_t)) ; make a key
(define v1 '((abc . 123) (def . 456))) ; make some data
(define (d1 data) ; callback
(simple-format #t "d1 called with ~S\n" (pointer->scm data)))
(cairo_set_user_data cr (pointer-to k1) (scm->pointer v1) d1)
(cairo_destroy cr)
(cairo_surface_destroy srf)
;; --- last line ---
prev parent reply other threads:[~2017-07-11 2:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-08 0:18 ffi-helper: status Matt Wette
2017-07-08 0:31 ` Matt Wette
2017-07-11 2:49 ` Matt Wette [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B3AF9A3-C690-465C-AE54-D6E4DBA066FB@gmail.com \
--to=matt.wette@gmail.com \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).