views:

43

answers:

1

Is possible using the Rtti determine if a TRttiMethod is a marked as overload,override or abstract ?

thanks in advance.

+2  A: 

Overload: I don't think there's an RTTI flag for this, but you can check to see if there's more than one method with the same name. That's not perfect, but it's probably as close as you're going to get.

Override: First, make sure the method is virtual. (Or dynamic or message dispatch.) Then check the class's ancestors for other methods with the same name and VirtualIndex property.

Abstract: Deep in the implementation section of rtti.pas, in with a bunch of method data flags, is one called mfAbstract, defined as 1 shl 7;. There's no code that references this, but it is implemented in the RTTI generated by the compiler. When you have a TRttiMethod reference for the method, you can test it like this:

IsVirtual := PVmtMethodExEntry(method.Handle).Flags and (1 shl 7) <> 0;

PVmtMethodExEntry is declared in the TypInfo unit, so you'll need to use it for that to work.

Mason Wheeler