On Mon, Mar 7, 2011 at 4:55 PM, nitralime nitralime@googlemail.com wrote:
(defcenum (:a 1) ... (:c #.(logior 1 2)) ...).
My point regarding "enum" definition was actually if it is possible to write down a definition of enum in CFFI without breaking the "abstraction". In the body of enum as you see there is an interdependency between the fields of enum being defined: the value of c depends on a and b and the value of d depends on c.
Yeah. I'm afraid you'd need to do something along the lines of:
(defconstant +a+ 1) (defcenunum (:a #.+a+) (:b #.(frob +a+)))
but it has some limitations and it's undocumented (see src/types.lisp).
With that CFFI array type "typedef char XXX[8]" can be translated now as "(defctype XXX (:array :char 8))"!
What are those limitations?
One of the limitations is that it doesn't do proper memory management on the array element type, which is not a problem for primitive types such as :char.
Another limitation is that if you pass a Lisp array via the :array type to a foreign function that modifies it you won't see any changes reflected in the Lisp array, as the Lisp/foreign conversion is currently one-way only.
Cheers,