so, take this C definition:
typedef enum { a = 0, b } typeName;
it's a typedef where the type is not denoted by a name, but rather it's an inline (anonymous) enum.
the symmetric equivalent of this definition is not possible in cffi. it would look something like:
(cffi:defctype typeName (cffi:defcenum nil a b))
or maybe
(cffi:defctype typeName (cffi:cenum a b))
the issue where it comes up is in cffi/c2ffi, where the filtering rules may filter out entries, and because the above is not possible, the anonymous definition is given a generated name and referenced using that name later in the defctype. it causes headache where filters are applied to the typedef's name, and whether the anon definition is needed depends on the outcome of those filters.
i see two ways to solve this:
1) extend cffi:defctype (and anything else?) to support the above mentioned missing feature.
2) make the c2ffi generator smarter which would be a considerable amount of complexity for a half-assed solution (the output will be full of definitions called anon-123).
i'd vote for 1), and i'd be willing to implement it, but before i get into that, what do y'all think? some feedback would be welcome!
On Sat, 15 Oct 2016 18:24:04 +0100, Attila Lendvai wrote:
(cffi:defctype typeName (cffi:cenum a b))
[...]
- extend cffi:defctype (and anything else?) to support the above mentioned missing feature.
It makes perfect sense to support anonymous enums, structs, etc. Lispworks's FLI supports this, IIRC.
I don't think you need to change DEFCTYPE at all. You just need to implement :enum/:struct/etc type parsers using DEFINE-PARSE-METHOD.
Difficulties may lurk, of course. :-) Let me know if you need help.
Cheers, Luís