Hi,
I'm using my ffi cairo bindings, that worked fine in the past. However now that I'm using Gambit compiled with C++ support it stopped working.
I got this error:
*** ERROR IN main-sdl#main, "main-sdl.scm"@19.24 -- (Argument 2) Can't convert to C type (cairo#cairo-image-surface-create-for-data '#<|unsigned char*| #16 0x7f33ba191000> 1 500 500 2000)
On the ffi side, things are declared like this:
(c-define-type cairo-format-t "cairo_format_t") (define CAIRO_FORMAT_ARGB32 0) (define CAIRO_FORMAT_RGB24 1) (define CAIRO_FORMAT_A8 2) (define CAIRO_FORMAT_A1 3) (define CAIRO_FORMAT_RGB16_565 4) (define cairo-image-surface-create-for-data (c-lambda (unsigned-char* cairo-format-t int int int) cairo-surface-t* "cairo_image_surface_create_for_data"))
And used like this:
(cairo-image-surface-create-for-data (SDL::surface-pixels sdl-surface) CAIRO_FORMAT_RGB24 maxx maxy (SDL::screen-pitch sdl-surface))
I've tried with this idea:
(define cairo-format (c-lambda (int) cairo-format-t " switch (___arg1) { case 0: ___result = CAIRO_FORMAT_ARGB32; break; case 1: ___result = CAIRO_FORMAT_RGB24; break; // and so on... } "))
And then calling on the Scheme side "(cairo-format CAIRO_FORMAT_RGB24)" instead of just using the int directly, but it segfaults.
How should I really handle enums properly?
Best regards,