I have the following reflection code in C# which I'm trying to replicate using NLua script:
G.Object.GetType().GetField("count", BindingFlags.Instance | BindingFlags.NonPublic);
Everything is fine, until I try to use Bitwise OR operation on two flags. I have alerady tried:
BindingFlags.Instance + BindingFlags.NonPublic
(arithmetic operation on non-number)
BindingFlags.Instance | BindingFLags.NonPublic
(not working, obviously, but worth a try)
I have also tried pure Lua implementations of bit-manipulation libraries. All fail, because what I'm trying to OR is called 'userdata' type in NLua.
Conversion of 'userdata' type using tonumber() also fails.
My current Lua code is below:
obj = G.Object:GetType()
field = obj:GetField("count", *...two OR'd flags here...*)
The best way to combine Enum flags with NLua is using the helper function luanet.enum
value = luanet.enum (BindingFlags, 'NonPublic,Instance')