[cffi-devel] C struct in C struct ?
James Bielman
jamesjb at jamesjb.com
Sun May 7 00:43:04 UTC 2006
Frank Goenninger <fgoenninger at prion.de> writes:
>> Ideally, :POINTER should probably become a parameterized type, so that
>> function would instead be:
>>
>> (defcfun struct-by-pointer :void
>> (a (:pointer a-struct))
>>
>> which will help us down the road when we implement optional pointer
>> type checking.
>
> Which I'd prefer also ! Let's you not only do type checking but is
> what I need most: As close to C as it can get. I'd have some
> translate-from/to-foreign functions specializing on the pointer type
> rather than defining a new type and dispatching on that.
I've pushed a patch adding this parameterization support for :pointer
to the darcs tree. It doesn't do type checking yet, but it makes the
code more readable (and is backwards compatible with the old
behavior).
>> In retrospect, the foreign type A-STRUCT should probably always mean
>> the structure itself by value, and declaring a function like:
>>
>> (defcfun struct-by-value :void
>> (a a-struct))
>>
>> should probably just be an error, instead of the DWIM-ish behavior of
>> canonicalizing A-STRUCT to :POINTER.
>
> It certainly would be more puristic and IMHO clean.
Unless there are any objections, I think I will make this (and
FOREIGN-SLOT-VALUE on aggregates) issue a warning that the behavior
will change in a future release, with a short description of how to
rewrite it correctly.
James
More information about the cffi-devel
mailing list