[fpc-devel] TObject differences between fpc and delphi

Michael Van Canneyt michael at freepascal.org
Wed Oct 28 15:48:33 CET 2009



On Wed, 28 Oct 2009, Paul Ishenin wrote:

> Paul Ishenin wrote:
>> I am trying to get UnitName from the RTTI but have some problems:
>> ...
>> Few questions now:
>> a) Why TypeInfo(TObject) <> TObject.ClassInfo?
>> b) Why TypeInfo(TPersistent) = TPersistent.ClassInfo?
> No idea why but it is the same in delphi < d2010. Probably in d2010 it 
> depends on project rtti settings. And UnitName = '' in d2009 for classes with 
> no RTTI.

The implementation is probably the same: consult RTTI if present.
If it is not present, then return empty...

>
>> c) How to get TypeInfo of the class inside that class class method?
> Probably no way except the using the same info which ClassType using.
>> So what is the best way to implement this UnitName method?
> Still the question. Using RTTI and return empty result if it does not exists 
> or changing the compiler to write unit name near the class name?

Maybe generate partial RTTI for classes not in $M+ ?

Michaek



More information about the fpc-devel mailing list