On 1/24/06, efuzzyone@netscape.net <efuzzyone@netscape.net> wrote:
Hello,
   Another concern of the original post was how to handle anonymous C
enums in cffi.

Should one use `defconstants' for them? Or should cffi provide a
mechanism to declare anonymous enums?

As per my understanding cffi requires all enums to be named.

Thanks.
--
Surendra Singhi
http://ssinghi.kreeti.com/


-----Original Message-----
From: Luís Oliveira <luismbo@gmail.com>
To: Frank Buss < fb@frank-buss.de>
Cc: cffi-devel@common-lisp.net; justinhj@gmail.com; 'Surendra Singhi'
< EFuzzyONE@netscape.net>
Sent: Sun, 22 Jan 2006 15:56:45 +0000
Subject: Re: [cffi-devel] defenum proposal

  On 2006-jan-22, at 14:47, Frank Buss wrote:
  > It is not necessary to use keywords like for the named enums,
because
  > unnamed enums in C are just syntatic sugar for a list of >
"#define"s, which
  > is mapped to a list of defconstants. I don't know, if this macro >
fits in the
  > philosophy of CFFI, perhaps in some utility class, and maybe with >
another
> name "defanonenum".

  I don't really think of C's enum that way. If I want constants, I use
#define (and defconstant in CL). If I want to represent some sort of
entity or concept I use an enum (and symbols in CL). For example:

#define MAX_COUNT 127

(defconstant +max-count+ 127)

vs.

enum {
RED,
BLUE
};

:red, :blue (or 'red, 'blue)

I suppose defcenum shouldn't force the user to use keywords though?

--Luís Oliveira
http://student.dei.uc.pt/~lmoliv/
Equipa Portuguesa do Translation Project
http://www.iro.umontreal.ca/translation/registry.cgi?team=pt


___________________________________________________
Try the New Netscape Mail Today!
Virtually Spam-Free | More Storage | Import Your Contact List
http://mail.netscape.com


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...

enum
{
 a_value,
 another_value,
}

then it does

#define MAKE_MASK (n) (1<<n)

enum
{
  MAKE_MASK(a_value),
  MAKE_MASK(another_value)
}

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.

Justin