bitmaps as special enums?

Jelmer Vernooij jelmer at samba.org
Sat Feb 24 11:00:50 GMT 2007


On Fri, Feb 23, 2007 at 10:05:45AM +0100, Stefan (metze) Metzmacher wrote:
> Jelmer Vernooij schrieb:
> > On Fri, 2007-02-23 at 08:59 +0100, Stefan (metze) Metzmacher wrote:
> >> Andrew Bartlett schrieb:
> >>> On Wed, 2007-02-21 at 14:26 +0000, Jelmer Vernooij wrote:
> >>>> Bitmaps and enums are similar in a lot of cases. I'd like to merge them
> >>>> into one type but have an attribute of some sort to indicate that
> >>>> multiple values can be used. In other words, I'd like to make bitmaps a
> >>>> special kind of enums.
> >>> Perhaps you could give an example on how the IDL would change as a
> >>> result of this?  I kind of like the bitmap syntax, being very clear that
> >>> this is a bitmap.
> >> can you demonstrate it with nbt_operation from nbt.idl please

> >> I'm interested in the IDL and output change.
> > So, what we have now is :
> >     typedef [bitmap16bit] bitmap {
> >         NBT_RCODE                   = 0x000F,
> >         NBT_FLAG_BROADCAST          = 0x0010,
> >         NBT_FLAG_RECURSION_AVAIL    = 0x0080,
> >         NBT_FLAG_RECURSION_DESIRED  = 0x0100,
> >         NBT_FLAG_TRUNCATION         = 0x0200,
> >         NBT_FLAG_AUTHORITIVE        = 0x0400,
> >         NBT_OPCODE                  = 0x7800,
> >         NBT_FLAG_REPLY              = 0x8000
> >     } nbt_operation;

> > what I'm proposing to change it to would be something like:

> >     typedef [bitmap,enum16bit] enum {
> >         NBT_RCODE                   = 0x000F,
> >         NBT_FLAG_BROADCAST          = 0x0010,
> >         NBT_FLAG_RECURSION_AVAIL    = 0x0080,
> >         NBT_FLAG_RECURSION_DESIRED  = 0x0100,
> >         NBT_FLAG_TRUNCATION         = 0x0200,
> >         NBT_FLAG_AUTHORITIVE        = 0x0400,
> >         NBT_OPCODE                  = 0x7800,
> >         NBT_FLAG_REPLY              = 0x8000
> >     } nbt_operation;

> > Of course, we could use a different name for the attribute (perhaps
> > "flags"?). 
> I like [bitmap,enum16bit] if the output isn't changed,
Cool, thanks! I'll have a look at that stuff once I get represent_as()
fixed up to be able to replace subcontext().

Cheers,

jelmer
-- 
Jelmer Vernooij <jelmer at samba.org> - http://jelmer.vernstok.nl/
 11:55:52 up 19 days, 11:00,  1 user,  load average: 1.05, 1.28, 1.20


More information about the samba-technical mailing list