[Cffi-devel] cffi-grovel bitfield

Luís Oliveira luismbo at gmail.com
Sun Jan 25 23:06:57 UTC 2015


Hello Frank,

On Sat, Jan 17, 2015 at 9:27 AM, Frank <fau at riseup.net> wrote:
> enum uv_tcp_flags {
>   /* Used with uv_tcp_bind, when an IPv6 address is used. */
>   UV_TCP_IPV6ONLY = 1
> };
[...]
> #ifdef UV_TCP_IPV6ONLY
> fprintf(output, "%d", UV_TCP_IPV6ONLY);
> #else
> fputs("\n  #.(cl:progn (cl:warn 'cffi-grovel:missing-definition :name
> 'IPV6-ONLY) -1)", output);
> #endif
> fputs(")", output);
> fputs(")\n", output);
>
> Obviously the #ifdef guard is the culprit here.  Maybe you guys want to
> fix this?

Well, there's a purpose to that #ifdef, and it works nicely when
dealing with macro constants rather than enums.

I'm not sure what the best way is to cater to your use case. We have
CENUM and CONSTANTENUM for CFFI:DEFCFENUM, but only BITFIELD for
CFFI:DEFBITFIELD. The naming is a bit inconsistent.

But naming aside, do you feel like adding (and testing) an option to
CFFI:DEFBITFIELD that does what you want? A pull request on GitHub
would be great!

Thanks,

-- 
Luís Oliveira
http://kerno.org/~luis/




More information about the cffi-devel mailing list