[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua binding: How to implement C enum
- From: Patrick Rapin <toupie300@...>
- Date: Thu, 15 Dec 2011 16:44:42 +0100
> So I would like to know the community opinion on this: How to implement this kind of C enums?
In my Pipeline project, enumeration values are strings.
But you can OR bitfield values by just concatenating them with any
not-alphanumerical separator.
Moreover, the "~" character is used to denote AND NOT value
So for your enumeration (note that I have added ALL entry):
> typedef enum {
> UNKNOWN = 0x00000000,
> FRONTONLY = 0x00000001,
> BACKVIDEO = 0x00000002,
> BACKSYSTEM = 0x00000004,
> TRIPLE = 0x00000008,
> WINDOWS = 0x00000010,
> ALL = 0x0000001F
> } BufferMode;
We can have for example:
Fct ("FRONTONLY") --> 1
Fct ("BACKVIDEO, TRIPLE") --> 0x82
Fct "BACKSYSTEM|WINDOWS" --> 0x14
Fct ("ALL ~TRIPLE, ~FRONTONLY") --> 0x16