[Cffi-devel] Fw: What is wrong with this 2d array of pointers

Joeish W joeish80829 at yahoo.com
Sun May 11 10:22:22 UTC 2014


I'm wrapping the C++ interface of OpenCv and C++ uses the 2d arrays.

Someone from CFFI-DEVEL already showed me how to this though:
((point 1 2) is just my OpenCV Point class wrapper)


(cffi::foreign-array-alloc 
 (make-array '(4 2) :initial-contents 
             (list (list (cffi:foreign-alloc :pointer :initial-element (c-pointer (point 1 2)))  
                         (cffi:foreign-alloc :pointer :initial-element (c-pointer (point 1 2)))) 
                   (list (cffi:foreign-alloc :pointer :initial-element (c-pointer (point 1 2)))  
                         (cffi:foreign-alloc :pointer :initial-element (c-pointer (point 1 2))))  
                   (list (cffi:foreign-alloc :pointer :initial-element (c-pointer (point 1 2)))  
                         (cffi:foreign-alloc :pointer :initial-element (c-pointer (point 1 2))))  
                   (list (cffi:foreign-alloc :pointer :initial-element (c-pointer (point 1 2)))  
                         (cffi:foreign-alloc :pointer :initial-element (c-pointer (point 1 2)))))) 
 '(:array :pointer 4 2))


I do appreciate your attention to this though...I had to go into CFFI and export foreign-array-alloc myself. Could I ask, if you are or know a CFFI developer if it might be possible to get this function exported automatically.  I have discovered a real world use for this function.


On Sunday, May 11, 2014 2:05 AM, Willem Rein Oudshoorn <woudshoo at xs4all.nl> wrote:
 
Joeish W <joeish80829 at yahoo.com> writes:
>
>> I was hoping someone could look at this and help me debug it.
>>
>> I'm getting:
>>
>> (FOREIGN-ALLOC :POINTER :INITIAL-ELEMENT (NULL-POINTER))
>> is not of type
>> SB-SYS:SYSTEM-AREA-POINTER. when I run it.
>>
>>
>>
>> (foreign-array-alloc #2A((
>>
>> (foreign-alloc :pointer :initial-element (null-pointer)) 
>> (foreign-alloc :pointer :initial-element (null-pointer))) 
>> ((foreign-alloc :pointer :initial-element (null-pointer)) 
>> (foreign-alloc :pointer :initial-element (null-pointer))) 
>> ((foreign-alloc :pointer :initial-element (null-pointer)) 
>> (foreign-alloc :pointer :initial-element (null-pointer))) 
>> ((foreign-alloc :pointer :initial-element (null-pointer)) 
>> (foreign-alloc :pointer :initial-element (null-pointer)))) '(:array :pointer 4 2))
>
>A few points:
>
>1. #2A(...) does not evaluate its content so the array consists of the
>   unevaluated forms.
>2. As far as I kno, foreign-array-alloc is not exported from CFFI, so
>   you should not use them in your code.
>3. C does not have two dimensional arrays anyway, so what are you trying todo?
>
>Wim Oudshoorn.
>
>
>_______________________________________________
>Cffi-devel mailing list
>Cffi-devel at common-lisp.net
>http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20140511/0de39f4f/attachment.html>


More information about the cffi-devel mailing list