[cffi-devel] Proposal for Array Type

Luis Oliveira luismbo at gmail.com
Tue Sep 13 04:17:36 UTC 2005


On 13/set/2005, at 04:29, Rayiner Hashem wrote:
> A while ago, somebody pointed out that structures with array members 
> don't compile properly on Verrazano.
>  In looking at the issue, I realized that arrays are something of a 
> special case in C-FFI, as they are morally
>  type-specifiers in defcstruct declarations, but do not have 
> underlying types. Therefore, I propose a new C-FFI
>  declaration:
>
>  (defcarray <foreign-type-name> <base-type> <length>)

I have implemented something like this in uffi-compat. I think it'd be 
much cleaner to simply have an array type:

(:array type &rest dims)

Then you could do (defctype my-int-array (:array :int 5 12)) or 
something like that.


>  An explicit nil for the <length> argument would be equivalent to:
>  (define-foreign-type int-array () ':pointer)

Hmm, is this really necessary?


Anyway, this is certainly doable, and pretty easy too. Most of what's 
necessary to do this is already in uffi-compat. I'll look into this 
when refactoring the type system. I really need to resort my TODO list, 
*sigh* :-)

-- 
Luís Oliveira
http://student.dei.uc.pt/~lmoliv/
Equipa Portuguesa do Translation Project
http://www2.iro.umontreal.ca/~pinard/po/registry.cgi?team=pt




More information about the cffi-devel mailing list