bitmaps as special enums?

Stefan (metze) Metzmacher metze at samba.org
Fri Feb 23 09:05:45 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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:
>>>> 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"?). 

I like [bitmap,enum16bit] if the output isn't changed,

metze

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFF3q5om70gjA5TCD8RAqQnAJ93XDCIGyGMzRk8PpEjshZMEH/JsACfSbnE
pCH8uWBt7z018MD+YMN+i1k=
=Gmm0
-----END PGP SIGNATURE-----


More information about the samba-technical mailing list