Juno-Windows-Class-Library icon indicating copy to clipboard operation
Juno-Windows-Class-Library copied to clipboard

enums vs. flags vs. defaults

Open Numpsy opened this issue 13 years ago • 0 comments

com.reflect contains a 'TypeAttributes' enum.

TypeImpl has an 'attr_' member of type TypeAttributes.

When Parameter.getParameters builds up the parameter list for a function, it creates an instance of TypeImpl using a constructor which just takes a type name, which means that the attr_ member is left at it's deafult value ('CoClass' , as that's the first member of the enum).

This isn't causing any issues at the moment (as tlbimpd only needs the type name to output the .d code), but while looking at issue #14 i happened to call IsCoClass() on the parameters of a function, which then of course always returns 'true'. This is a bit misleading, as the type is more 'unpopulated' at this point, so the IsXXX functions should always be false.

On a more general note, the member of TypeImpl is 'TypeAttributes', but is actually used as a set of flags (e.g. Dispatch types have it set to (TypeAttributes.Interface | TypeAttributes.InterfaceIsDispatch)). Possibly not a great idea.

Numpsy avatar Jan 29 '12 20:01 Numpsy