I am having all sort of trouble with [FlagsAttribute] enums in Matlab. It appears there is no way to pass a combination of values as a parameter to .NET. For example, BindingFlags.Public|BindingFlags.Instance, once you combine these together in Matlab they become of an internal type and cannot be cast back to BindingFlags.
Things like
import System.*;
import System.Reflection.*;
flags = BindingFlags.Public+BindingFlags.Instance;
enum = Enum.ToObject(Type.GetType('System.Reflection.BindingFlags'), int32(flags));
or
enum = Enum.Parse(Type.GetType('System.Reflection.BindingFlags'), 'Public, Instance');
simply don't work as it reads:
??? One or more output arguments not assigned during call to "System.Enum.ToObject" (or "System.Enum.Parse").
On the other hand
enum = Enum.Parse(Type.GetType('System.Reflection.BindingFlags'), 'Public');
works just fine and returns <1x1 System.Reflection.BindingFlags> set to 'Public'.
That goes, needless to say, for all [FlagsAttribute] enums.
Am I missing something here? Writing a C# reflection enum wrapper for Matlab is not a big deal but that would slow things down enormously. Any workaround would be deeply, deeply appreciated.