[cffi-devel] Re: [feature request] array type

Jack Unrue jdunrue at gmail.com
Sun Dec 11 06:48:58 UTC 2005


> Hello,
>
> Can you give me an example usage of such type or an example that shows
> how the current array support is insufficient?

Thanks, Luís. I may be misunderstanding what array support is already
present.  I'm looking for basically what you proposed in your reply to:

http://common-lisp.net/pipermail/cffi-devel/2005-September/000058.html

My goal is simply to declare structs whose C equivalent includes
array members. I'm not sure how the array declaration would
be done in CFFI so I'll use LispWorks FLI instead:

(fli:define-c-struct foo
    (data (:c-array :int 32))
    (id :int))

would correspond to

struct foo {
    int data[32];
    int id;
};

such that allocating an instance of foo on the Lisp side could be
accomplished without having to separately allocate the data
array.  In LispWorks, I would use fli:with-dynamic-foreign-objects
to allocate a temporary instance of foo.

A real example of how I would use this is the Win32 BeginPaint
function which populates a supplied pointer to a PAINTSTRUCT
(which has a 32 byte array as the last member).

Thanks again, and if RTFM is the answer, please do point me
in the right direction :-)

--
Jack Unrue



More information about the cffi-devel mailing list