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@xs4all.nl> wrote:
Joeish W <joeish80829@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@common-lisp.net
http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel