Am 03.06.2014 10:26 schrieb "Graeme Geldenhuys" <
mailingli...@geldenhuys.co.uk>:
>
> 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.
> > http://www.freepascal.org/docs-html/rtl/typinfo/
>
> Almost, but not quite. Good news is, it is not nearly as bad as Sven
> makes it out to be.
>

If one uses a helper function like you did then it's indeed not as bad, but
if one doesn't...

> function tiGetTypeInfo(PropInfo: PPropInfo): PTypeInfo;
> begin
> {$IFDEF FPC}
>   Result := PropInfo^.PropType;
> {$ELSE}
>   Result := PropInfo^.PropType^;
> {$ENDIF}
> end;

Out of curiosity: is this helper declared as "inline"? Would get rid of the
call completely in both Delphi and FPC...

>
> I've also introduced an enhanced GetPropInfo() with a signature as
follows:
>
> function tiGetPropInfo(AClass: TClass; PropPath: string; PInstance:
> Pointer): PPropInfo;

Might also profit from a declaration as "inline" :)

Yours,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to