1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
{ the parent in the RTTI of a non derived helper is Nil, otherwise it is the
typeinfo of the parent helper; also the type info of the extended type is
available through ExtendedInfo }
program thlp38;
{$ifdef fpc}
{$mode delphi}
{$endif}
uses
typinfo;
type
TTest = class
end;
TTestHelper = class helper for TTest
end;
TTestHelperSub = class helper(TTestHelper) for TTest
end;
var
titest, titesthelper, titesthelpersub: PTypeInfo;
td: PTypeData;
ti: PTypeInfo;
begin
titest := TypeInfo(TTest);
titesthelper := TypeInfo(TTestHelper);
titesthelpersub := TypeInfo(TTestHelperSub);
if titesthelper^.Kind <> tkHelper then begin
Writeln('Type is not a helper');
Halt(1);
end;
if titesthelpersub^.Kind <> tkHelper then begin
Writeln('Type is not a helper');
Halt(2);
end;
td := GetTypeData(titesthelper);
if td^.ExtendedInfo <> titest then begin
Writeln('Extends wrong type');
Halt(4);
end;
td := GetTypeData(titesthelpersub);
if td^.ExtendedInfo <> titest then begin
Writeln('Extends wrong type');
Halt(6);
end;
if td^.HelperParent <> titesthelper then begin
Writeln('Wrong parent of helper');
Halt(7);
end;
Writeln('ok');
end.
|