[fpc-devel] TObject differences between fpc and delphi

Paul Ishenin ip at kmiac.ru
Wed Oct 28 03:21:45 CET 2009


Michael Van Canneyt wrote:

> On the other hand, UnitName may come in handy for the Lazarus IDE.

And this is the most difficult thing amoung other new methods :)

I am trying to get UnitName from the RTTI but have some problems:

1. If I call PTypeInfo(TypeInfo(TObject))^.Kind then I get tkClass and 
UnitInfo can be retrieved since tkClass has this member.

2. If I am using PTypeInfo(TypeInfo(Self))^.Kind inside a class method I 
get tkUnknown and UnitName is not avaiable ofcource.

3. If I am using ClassInfo iside a class method then it returns nil if 
the class has no RTTI.

Few questions now:
a) Why TypeInfo(TObject) <> TObject.ClassInfo?
b) Why TypeInfo(TPersistent) = TPersistent.ClassInfo?
c) How to get TypeInfo of the class inside that class class method?

After all, if it should not use RTTI then I need to change the compiler 
to store also UnitName near the ClassName field but this is a be bad 
change since vmtMethodStart will change it offset and according to RTL 
comments few methods depends on that offsetts.

So what is the best way to implement this UnitName method?


Best regards,
Paul Ishenin.




More information about the fpc-devel mailing list