File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,6 +78,41 @@ string getEnumFromValue(Enum)(Enum value)
7878 return null ;
7979}
8080
81+ /+ TODO: I'd quite like to support bitfields too...
82+ uint getBitfieldValue(Enum)(const(char)[] flags)
83+ {
84+ uint value;
85+ foreach(token; flags.splitter('|').map!(a => a.strip).filter!(a => !a.empty))
86+ {
87+ Enum val = getEnumValue!Enum(token);
88+ if(val != cast(Enum)-1)
89+ value |= val;
90+ }
91+ return value;
92+ }
93+
94+ string getBitfieldFromValue(Enum)(uint bits)
95+ {
96+ string bitfield;
97+ foreach(i; 0..32)
98+ {
99+ uint bit = 1 << i;
100+ if(!(bits & bit))
101+ continue;
102+
103+ string key = getEnumFromValue(cast(Enum)bit);
104+ if(key)
105+ {
106+ if(!bitfield)
107+ bitfield = key;
108+ else
109+ bitfield = bitfield ~ "|" ~ key;
110+ }
111+ }
112+ return bitfield;
113+ }
114+ +/
115+
81116void pushEnum (T)(lua_State* L, T value) if (is (T == enum ))
82117{
83118 string key = getEnumFromValue(value);
Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ public:
9999 }
100100
101101 // / The underlying $(D lua_State) pointer for interfacing with C.
102- @property lua_State* state() nothrow pure @safe
102+ @property inout ( lua_State) * state() inout nothrow pure @safe
103103 {
104104 return L;
105105 }
You can’t perform that action at this time.
0 commit comments