bitmaps as special enums?

Jelmer Vernooij jelmer at samba.org
Fri Feb 23 08:04:28 GMT 2007


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:
> >> Hi Tridge,
> >>
> >> 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.
> Jelmer,
> 
> 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"?). 

There are no consequences for the output.

Cheers,

jelmer

-- 
Jelmer Vernooij <jelmer at samba.org> - http://samba.org/~jelmer/


More information about the samba-technical mailing list