[fpc-pascal] Typinfo incompatibilities between FPC and Delphi
mailinglists at geldenhuys.co.uk
Mon Jun 2 00:05:23 CEST 2014
On 2014-05-31 10:57, Vincent Snijders wrote:
> I think it is possible to write code without $ifdef (valid for Delphi
> and FPC) if you use the typeinfo unit to extract the information.
Almost, but not quite. Good news is, it is not nearly as bad as Sven
makes it out to be.
The tiOPF project uses RTTI extensively. I have written a lot of that
code, and with the following helper function, I could eliminate a lot of
IFDEF's between FPC and Delphi RTTI behaviour.
function tiGetTypeInfo(PropInfo: PPropInfo): PTypeInfo;
Result := PropInfo^.PropType;
Result := PropInfo^.PropType^;
I've also introduced an enhanced GetPropInfo() with a signature as follows:
function tiGetPropInfo(AClass: TClass; PropPath: string; PInstance:
To see the complete code, take a look at the Core/tiRTTI.pas unit in the
tiOPF's 'tiopf2' branch.
That unit is also fully unit tested. Tests and usage examples can be
found in the following unit:
- Graeme -
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
More information about the fpc-pascal