<div dir="ltr"><div><div>Hi Liam,<br></div>Thanks for the response. It works! Actually, there was one hitch, which I'd like to explain, if for no other reason than posterity.<br><br></div><div>I had translate-into-foreign-memory, translate-to-foreign, and free-translated object defined, which were supposed to unpack a list (using first, second, third, and fourth), not a plist. The list I sent had two symbols, a list, and a symbol, as you said. Perhaps I didn't understand the ' quote function, but I thought it was supposed to interpret stuff inside the list. That's my Lisp ignorance showing.<br><br>Because I had those three methods defined, changing to a plist as you suggested didn't work. I tried just removing the methods entirely, assuming perhaps what you were getting at here is that CFFI can accept plists by default, so that the methods only need to be defined if you want to use a custom mechanism for passing the structs. This worked! I didn't know about this important feature. I didn't see it in the manual, or any of my Google searches.<br><br></div><div>Thanks so much for your help!<br><br></div><div>Marshall<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 30, 2015 at 6:27 PM, Liam Healy <span dir="ltr"><<a href="mailto:lnp@healy.washington.dc.us" target="_blank">lnp@healy.washington.dc.us</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Looks like you're sending it a list of symbols 'read-func etc.<br>
'(read-func seek-func (null-pointer) tell-func)<br>
is a list of two symbols, a list, then another symbol. It needs to be<br>
a plist (property list) with alternating slot names and values<br>
(list 'read-func read-func 'seek-func seek-func...)<br>
(At the moment I can't remember if the slot names are in the keyword<br>
package or not, so you might need :read-func instead of 'read-func<br>
etc.)<br>
<span class="HOEnZb"><font color="#888888"><br>
Liam<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Thu, Apr 30, 2015 at 7:28 PM, Marshall Mason<br>
<<a href="mailto:marshallmason2@gmail.com">marshallmason2@gmail.com</a>> wrote:<br>
> Hello,<br>
> I'm using SBCL version 1.2.4, CFFI version 0.14.0, and libffi version 3.1.<br>
> I've been trying to pass a struct by value using CFFI and libffi. I'm a<br>
> newbie to both CFFI and Lisp so I had to piece this together from the manual<br>
> as well as some of the unit tests that come with CFFI. I'm getting an error<br>
> that I just can't get past:<br>
><br>
> The value READ-FUNC is not of type SB-SYS:SYSTEM-AREA-POINTER<br>
><br>
> The library I'm trying to wrap is libvorbisfile, which decodes Ogg Vorbis<br>
> files. It has an init function called ov_open_callbacks:<br>
><br>
> int ov_open_callbacks(void *datasource, OggVorbis_File *vf, const char<br>
> *initial, long ibytes, ov_callbacks callbacks);<br>
><br>
> The part it's choking on is the last argument, a struct, passed by value, of<br>
> callback functions:<br>
><br>
> typedef struct {<br>
> size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void<br>
> *datasource);<br>
> int (*seek_func) (void *datasource, ogg_int64_t offset, int whence);<br>
> int (*close_func) (void *datasource);<br>
> long (*tell_func) (void *datasource);<br>
> } ov_callbacks;<br>
><br>
> The library is designed to use one of a few static structs defined in a<br>
> header file. Since it's defined in the header file and not in<br>
> libvorbisfile.so, I must create CFFI translation code. There were a lot of<br>
> other structs I had to wrap with CFFI as well. Here is my code:<br>
><br>
> <a href="http://pastie.org/10122885" target="_blank">http://pastie.org/10122885</a><br>
><br>
> Does anyone have any clues about what I'm doing wrong here?<br>
><br>
> (Regarding my previous email about getting CFFI working on Debian jessie, it<br>
> turns out the Debian version of cl-alexandria is missing a file and cl-cffi<br>
> is buggy, so I just added the missing file and installed the CFFI source by<br>
> hand. Thanks for the response, Fau.)<br>
><br>
> Marshall<br>
</div></div></blockquote></div><br></div>