1) the C function allocates an array (as a side effect) and passes back a pointer to array to lisp . I would later have to free memory for this array explicitly.
2) the lisp function allocates an array and passes a pointer to the "C" function, The C function modifies the array. In this case lisp would be allocating the array. Side question: Do I need to use CFFI in lisp to allocate the array ? - or can this be done transparently by the lisp dynamic typing when the array variable is bound ?
3) I have several simple C functions that return smaller arrays (like [ x, y, z], where x,y,z = float or integer.). Would be nice to be able to pass by value as a return value on the stack, but I am not sure how to handle this from C to lisp. Example:
C function:
Color getColorValue ( Image *image, x, y), Where color is a array triplet [r, g, b],, could be floats or ints depending...
Desired lisp function:
(let ((color (get-color-value image x y))
; then do something with list "color
4) unrelated question...maybe this should be posted to swig list (but i am not sure if there are any active CFFI users in that group).
Is there an easy way to automatically create lisp-style function names ?
For example:
swig generates:
(cffi:defcfun ("frameHeight" frameHeight) :int
(frame :pointer))
I would like to generate translate the C function name to "frame-height" (to make it more of a lisp style).
I tried using
%rename frameHeight frame-height
in the swig. ".i" file template, but that doesn't seem to work. The notes in the documentation on "lispify" I am not at the stage where I understand it.
I thought that some google searches would turn up some canonical examples or tutorials on this, but there are not many (except the curl example - and it makes me wonder how many people are actually using it :-)
thanks again,
K