[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to wrap arrays?
From: |
Ludovic Courtès |
Subject: |
Re: how to wrap arrays? |
Date: |
Mon, 04 Sep 2006 10:29:50 +0200 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) |
Hi,
Andreas Rottmann <address@hidden> writes:
> John Steele Scott <address@hidden> writes:
>> Just for fun, I am using g-wrap to interface the cairo graphics library
>> with guile. Thankfully this library has quite a wrapper-friendly
>> interface, but I don't know how to do this one:
>>
>> void cairo_set_dash(cairo_t *cr,
>> const double *dashes,
>> int num_dashes,
>> double offset);
>>
>> The num_dashes argument gives the number of values pointed to by
>> dashes, and it may be 0.
>>
>> Ideally I'd like to be able to have a Scheme function which could be
>> called like:
>>
>> (cairo-set-dash cr (list 1.0 3.0 1.5 2.5) 2.5)
>>
>> Where dashes and num_dashes can be supplied based on the values and
>> length of the list. But at the moment I don't know see how to handle
>> the dashes argument at all. Any help would be appreciated.
>>
> G-Wrap currently doesn't support this (yet); a half-manual wrapper
> must be written, consisting of an override and a C part:
>
> The override:
>
> (define-function gtk_stock_add
> (c-name "_wrap_gtk_stock_add")
> (overrides "gtk_stock_add")
> (return-type "none")
> (parameters
> '("SCM" "items")))
This is not "standard" G-Wrap: it's the higher-level layer used in
`guile-gnome' (and possibly others).
If you want to use standard G-Wrap to produce your semi-manual wrapper,
you can create a C function like this:
static void
wrap_cairo_set_dash (cairo_t *c, SCM the_list, double offset)
{
/* Traverse the list and turn it into a C array... */
return cairo_set_dash (c, array, array_size, offset);
}
And then, you can wrap it using the `scm' type from the standard wrapset
(see the manual) for the second argument.
Now, I'd rather use a Scheme vector to represent a C vector so that it
wouldn't need to be traversed at "marshalling"-time.
Thanks,
Ludovic.