On 1/24/06, <b class="gmail_sendername"><a href="mailto:efuzzyone@netscape.net">efuzzyone@netscape.net</a></b> <<a href="mailto:efuzzyone@netscape.net">efuzzyone@netscape.net</a>> wrote:<div><span class="gmail_quote">
</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello,<br>   Another concern of the original post was how to handle anonymous C<br>enums in cffi.
<br><br>Should one use `defconstants' for them? Or should cffi provide a<br>mechanism to declare anonymous enums?<br><br>As per my understanding cffi requires all enums to be named.<br><br>Thanks.<br>--<br>Surendra Singhi
<br><a href="http://ssinghi.kreeti.com/">http://ssinghi.kreeti.com/</a><br><br><br>-----Original Message-----<br>From: Luís Oliveira <<a href="mailto:luismbo@gmail.com">luismbo@gmail.com</a>><br>To: Frank Buss <<a href="mailto:fb@frank-buss.de">
fb@frank-buss.de</a>><br>Cc: <a href="mailto:cffi-devel@common-lisp.net">cffi-devel@common-lisp.net</a>; <a href="mailto:justinhj@gmail.com">justinhj@gmail.com</a>; 'Surendra Singhi'<br><<a href="mailto:EFuzzyONE@netscape.net">
EFuzzyONE@netscape.net</a>><br>Sent: Sun, 22 Jan 2006 15:56:45 +0000<br>Subject: Re: [cffi-devel] defenum proposal<br><br>  On 2006-jan-22, at 14:47, Frank Buss wrote:<br>  > It is not necessary to use keywords like for the named enums,
<br>because<br>  > unnamed enums in C are just syntatic sugar for a list of ><br>"#define"s, which<br>  > is mapped to a list of defconstants. I don't know, if this macro ><br>fits in the<br>  > philosophy of CFFI, perhaps in some utility class, and maybe with >
<br>another<br> > name "defanonenum".<br><br>  I don't really think of C's enum that way. If I want constants, I use<br>#define (and defconstant in CL). If I want to represent some sort of<br>entity or concept I use an enum (and symbols in CL). For example:
<br><br> #define MAX_COUNT 127<br><br> (defconstant +max-count+ 127)<br><br> vs.<br><br> enum {<br> RED,<br> BLUE<br> };<br><br> :red, :blue (or 'red, 'blue)<br><br> I suppose defcenum shouldn't force the user to use keywords though?
<br><br> --Luís Oliveira<br> <a href="http://student.dei.uc.pt/~lmoliv/">http://student.dei.uc.pt/~lmoliv/</a><br> Equipa Portuguesa do Translation Project<br> <a href="http://www.iro.umontreal.ca/translation/registry.cgi?team=pt">
http://www.iro.umontreal.ca/translation/registry.cgi?team=pt</a><br><br><br>___________________________________________________<br>Try the New Netscape Mail Today!<br>Virtually Spam-Free | More Storage | Import Your Contact List
<br><a href="http://mail.netscape.com">http://mail.netscape.com</a><br></blockquote></div><br>
<br>
The problem I am looking at is that SDL uses un-named enums quite a
lot. In addition it does arithmetic on them to create other enums...<br>
<br>
enum<br>
{<br>
 a_value,<br>
 another_value,<br>
}<br>
<br>
then it does<br>
<br>
#define MAKE_MASK (n) (1<<n)<br>
<br>
enum<br>
{<br>
  MAKE_MASK(a_value),<br>
  MAKE_MASK(another_value)<br>
}<br>
<br>
In order to do this I can define a lisp function in my swig interface
which does the same thing, but for that to work you need someway of
getting to the value of the first enums.<br>
<br>
Justin<br>
<br>
<br>