Note that there are some explanatory texts on larger screens.

plurals
  1. POCommon lisp, CFFI, and instantiating c structs
    primarykey
    data
    text
    <p>I've been on google for about, oh, 3 hours looking for a solution to this "problem." I'm trying to figure out how to instantiate a C structure in lisp using CFFI. I have a struct in c:</p> <pre><code>struct cpVect{cpFloat x,y;} </code></pre> <p>Simple right? I have auto-generated CFFI bindings (swig, I think) to this struct:</p> <pre><code>(cffi:defcstruct #.(chipmunk-lispify "cpVect" 'classname) (#.(chipmunk-lispify "x" 'slotname) :double) (#.(chipmunk-lispify "y" 'slotname) :double)) </code></pre> <p>This generates a struct "VECT" with slots :X and :Y, which foreign-slot-names confirms (please note that I neither generated the bindings or programmed the C library (chipmunk physics), but the actual functions are being called from lisp just fine).</p> <p>I've searched far and wide, and maybe I've seen it 100 times and glossed over it, but I cannot figure out how to create a instance of cpVect in lisp to use in other functions.</p> <p>Note the function:</p> <pre><code>cpShape *cpPolyShapeNew(cpBody *body, int numVerts, cpVect *verts, cpVect offset) </code></pre> <p>Takes not only a cpVect, but also a pointer to a set of cpVects, which brings me to my second question: how do I create a pointer to a set of structs?</p> <p>I've been to <a href="http://common-lisp.net/project/cffi/manual/html_node/defcstruct.html" rel="nofollow">http://common-lisp.net/project/cffi/manual/html_node/defcstruct.html</a> and tried the code, but get "Error: Unbound variable: PTR" (I'm in Clozure CL), not to mention that looks to only return a pointer, not an instance.</p> <p>I'm new to lisp, been going pretty strong so far, but this is the first real problem I've hit that I can't figure out. Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload