Passing lisp vector to foreign code
So, I have a binary stream class that collects bytes into a buffer represented by a vector with a fill pointer. I want to take this buffer and send it to a C function, which stores it in a "database". Later, I want to retrieve this data via another binary stream class (we're experimenting with CL-STORE). Using the lw ffi, how do I set this up? It seems from the docs that I need to make a copy of the buffer in static space prior to sending it to C; is that correct? What should the ffi function declarations look like? Currently, I have: (fli:define-foreign-function (put-bytes "put_bytes" :source) ((bytes (:c-array (:unsigned :char))) (len :int)) :result-type :void :calling-convention :cdecl) (fli:define-foreign-function (get-bytes "get_bytes" :source) ((nbytes (:pointer (:int)))) :result-type (:c-array (:unsigned :char)) :calling-convention :cdecl) But, passing a Lisp vector to PUT-BYTES yields a type error: Expecting type (:foreign-array (:UNSIGNED :CHAR) (0)) (got #(76 ...)) so clearly I'm doing something wrong. Thanks for the help. David E. Young Bloodhound Software, Inc. For wisdom is more precious than rubies, and nothing you desire can compare with her. -- Prov. 8:11 "But all the world understands my language." -- Franz Josef Haydn (1732 - 1809) This email message is for the sole use of the intended recipients(s) and may contain confidential and privileged information of Bloodhound Software, Inc.. Any unauthorized review, use, disclosure is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.