[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[MIT-Scheme-devel] FFI and callbacks
From: |
craven |
Subject: |
[MIT-Scheme-devel] FFI and callbacks |
Date: |
Sat, 01 Aug 2015 20:22:48 +0200 |
User-agent: |
Notmuch/0.20.1 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-unknown-linux-gnu) |
Hello!
I've been playing around with displaying images in the Emacs SLIME REPL
from MIT/GNU Scheme, works very nicely so far. Now I've tried to get a
halfway decent binding for cairo (http://cairographics.org) working, but
run into a problem:
There is a function
cairo_status_t [an int]
cairo_surface_write_to_png_stream(
cairo_surface_t *surface, [the graphical data, just an alien]
cairo_write_func_t write_func, [the actual callback function]
void *closure); [some arbitrary data that is passed to the
callback]
cairo_write_func_t is defined as follows:
cairo_status_t (*cairo_write_func_t) (void *closure,
const unsigned char *data,
unsigned int length);
[see http://cairographics.org/manual/cairo-PNG-Support.html]
I'd like to make this accessible from Scheme, preferably by just calling
it in C, and returning all the data it writes as a vector8 (so a
string).
I've not been successful in declaring the callback, and if I just return
a char* from a wrapper function, it will be truncated at the first
#\nul.
How can I either implement the callback, so that I get at the data and
length in a Scheme function, or so that I can read all the incoming data
in C, and then pass it all back to Scheme correctly?
Thanks for any help, greetings!
Peter
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [MIT-Scheme-devel] FFI and callbacks,
craven <=