1

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...*)

1 Answers1

2

The best way to combine Enum flags with NLua is using the helper function luanet.enum

value = luanet.enum (BindingFlags, 'NonPublic,Instance')

Example: https://github.com/codefoco/NLuaBox/blob/00af36aa480281ae33835173430a806c54c2f9dc/Resources/source/OutputViewController.lua#L41

Vinicius Jarina
  • 797
  • 5
  • 16