blob: 28a393088f67b1fafa27867a33d866abddda9264 (
plain)
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
|
program rtti;
{$ifdef fpc}
{$mode objfpc}{$H+}
{$apptype console}
{$endif}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, typinfo
{ you can add units after this };
type
{ TSomeBaseClass }
TSomeBaseClass = class(TPersistent)
private
FSomeProperty: Integer;
public
property SomeProperty: Integer read FSomeProperty write FSomeProperty default 10;
end;
{ TSomeDerivedClass }
TSomeDerivedClass = class(TSomeBaseClass)
private
FOwnProperty: Integer;
published
property SomeProperty;
property OwnProperty: Integer read FOwnProperty write FOwnProperty default 11;
end;
var
BC : TSomeBaseClass;
DC: TSomeDerivedClass;
Info: PPropInfo;
begin
DC := TSomeDerivedClass.Create;
Info := GetPropInfo(DC, 'SomeProperty');
if (Info^.Default<>10) then
Halt(1);
Info := GetPropInfo(DC, 'OwnProperty');
if Info^.Default<>11 then
Halt(2);
end.
|