mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-30 08:42:52 +02:00
+ Added README and ex14 and ex15 examples
This commit is contained in:
parent
915b5cd7a9
commit
77ec55dafb
24
docs/typinfex/README
Normal file
24
docs/typinfex/README
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
This directory contains the examples for the typinfo unit.
|
||||||
|
|
||||||
|
rttiobj.pp This unit defines an object with RTTI generated.
|
||||||
|
It is used by the other examples.
|
||||||
|
|
||||||
|
trtti1.pp this program offers a series of tests of RTTI routines.
|
||||||
|
trtti2.pp this program offers a series of tests of RTTI routines.
|
||||||
|
trtti3.pp this program offers a series of tests of RTTI routines.
|
||||||
|
|
||||||
|
ex1.pp This program demonstrates the GetOrdProp function
|
||||||
|
ex2.pp This program demonstrates the GetEnumProp function
|
||||||
|
ex3.pp This program demonstrates the GetStrProp function
|
||||||
|
ex4.pp This program demonstrates the GetFloatProp function
|
||||||
|
ex5.pp This program demonstrates the GetObjectProp function
|
||||||
|
ex6.pp This program demonstrates the GetMethodProp function
|
||||||
|
ex7.pp This program demonstrates the GetSetProp function
|
||||||
|
ex8.pp This program demonstrates the SetToString function
|
||||||
|
ex9.pp This program demonstrates the GetEnumName, GetEnumValue functions
|
||||||
|
ex10.pp This program demonstrates the IsPublishedProp function
|
||||||
|
ex11.pp This program demonstrates the IsStoredProp function
|
||||||
|
ex12.pp This program demonstrates the GetPropInfos function
|
||||||
|
ex13.pp This program demonstrates the GetPropList function
|
||||||
|
ex14.pp This program demonstrates the FindPropInfo function
|
||||||
|
ex15.pp This program demonstrates the GetInt64Prop function
|
@ -1,5 +1,7 @@
|
|||||||
program example1;
|
program example1;
|
||||||
|
|
||||||
|
{ This program demonstrates the GetOrdProp function }
|
||||||
|
|
||||||
{$mode objfpc}
|
{$mode objfpc}
|
||||||
|
|
||||||
uses rttiobj,typinfo;
|
uses rttiobj,typinfo;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
program example11;
|
program example10;
|
||||||
|
|
||||||
|
{ This program demonstrates the IsPublishedProp function }
|
||||||
|
|
||||||
{$mode objfpc}
|
{$mode objfpc}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
program example11;
|
program example11;
|
||||||
|
|
||||||
|
{ This program demonstrates the IsStoredProp function }
|
||||||
|
|
||||||
{$mode objfpc}
|
{$mode objfpc}
|
||||||
|
|
||||||
uses rttiobj,typinfo;
|
uses rttiobj,typinfo;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
Program example13;
|
Program example12;
|
||||||
|
|
||||||
|
{ This program demonstrates the GetPropInfos function }
|
||||||
|
|
||||||
uses
|
uses
|
||||||
rttiobj,typinfo;
|
rttiobj,typinfo;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
Program example13;
|
Program example13;
|
||||||
|
|
||||||
|
{ This program demonstrates the GetPropList function }
|
||||||
|
|
||||||
uses
|
uses
|
||||||
rttiobj,typinfo;
|
rttiobj,typinfo;
|
||||||
|
33
docs/typinfex/ex14.pp
Normal file
33
docs/typinfex/ex14.pp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
Program example13;
|
||||||
|
|
||||||
|
{ This program demonstrates the FindPropInfo function }
|
||||||
|
|
||||||
|
{$mode objfpc}
|
||||||
|
|
||||||
|
uses
|
||||||
|
rttiobj,typinfo,sysutils;
|
||||||
|
|
||||||
|
|
||||||
|
Var
|
||||||
|
O : TMyTestObject;
|
||||||
|
PT : PTypeData;
|
||||||
|
PI : PPropInfo;
|
||||||
|
I,J : Longint;
|
||||||
|
PP : PPropList;
|
||||||
|
prI : PPropInfo;
|
||||||
|
|
||||||
|
begin
|
||||||
|
O:=TMyTestObject.Create;
|
||||||
|
PI:=FindPropInfo(O,'BooleanField');
|
||||||
|
Writeln('FindPropInfo(Instance,BooleanField) : ',PI^.Name);
|
||||||
|
PI:=FindPropInfo(O.ClassType,'ByteField');
|
||||||
|
Writeln('FindPropInfo(Class,ByteField) : ',PI^.Name);
|
||||||
|
Write ('FindPropInfo(Class,NonExistingProp) : ');
|
||||||
|
Try
|
||||||
|
PI:=FindPropInfo(O,'NonExistingProp');
|
||||||
|
except
|
||||||
|
On E: Exception do
|
||||||
|
Writeln('Caught exception "',E.ClassName,'" with message : ',E.Message);
|
||||||
|
end;
|
||||||
|
O.Free;
|
||||||
|
end.
|
25
docs/typinfex/ex15.pp
Normal file
25
docs/typinfex/ex15.pp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
program example15;
|
||||||
|
|
||||||
|
{ This program demonstrates the GetInt64Prop function }
|
||||||
|
|
||||||
|
{$mode objfpc}
|
||||||
|
|
||||||
|
uses rttiobj,typinfo;
|
||||||
|
|
||||||
|
Var
|
||||||
|
O : TMyTestObject;
|
||||||
|
PI : PPropInfo;
|
||||||
|
|
||||||
|
begin
|
||||||
|
O:=TMyTestObject.Create;
|
||||||
|
Writeln('Int64 property : ');
|
||||||
|
PI:=GetPropInfo(O,'Int64Field');
|
||||||
|
Writeln('Value : ',O.RealField);
|
||||||
|
Writeln('Get (name) : ',GetInt64Prop(O,'Int64Field'));
|
||||||
|
Writeln('Get (propinfo) : ',GetInt64Prop(O,PI));
|
||||||
|
SetInt64Prop(O,'RealField',12345);
|
||||||
|
Writeln('Set (name,12345) : ',O.Int64Field);
|
||||||
|
SetFloatProp(O,PI,54321);
|
||||||
|
Writeln('Set (propinfo,54321) : ',O.Int64Field);
|
||||||
|
O.Free;
|
||||||
|
end.
|
@ -1,5 +1,7 @@
|
|||||||
program example2;
|
program example2;
|
||||||
|
|
||||||
|
{ This program demonstrates the GetEnumProp function }
|
||||||
|
|
||||||
{$mode objfpc}
|
{$mode objfpc}
|
||||||
|
|
||||||
uses rttiobj,typinfo;
|
uses rttiobj,typinfo;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
program example3;
|
program example3;
|
||||||
|
|
||||||
|
{ This program demonstrates the GetStrProp function }
|
||||||
|
|
||||||
{$mode objfpc}
|
{$mode objfpc}
|
||||||
|
|
||||||
uses rttiobj,typinfo;
|
uses rttiobj,typinfo;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
program example3;
|
program example4;
|
||||||
|
|
||||||
|
{ This program demonstrates the GetFloatProp function }
|
||||||
|
|
||||||
{$mode objfpc}
|
{$mode objfpc}
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
program example3;
|
program example5;
|
||||||
|
|
||||||
|
{ This program demonstrates the GetObjectProp function }
|
||||||
|
|
||||||
{$mode objfpc}
|
{$mode objfpc}
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
program example3;
|
program example6;
|
||||||
|
|
||||||
|
{ This program demonstrates the GetMethodProp function }
|
||||||
|
|
||||||
{$mode objfpc}
|
{$mode objfpc}
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
program example1;
|
program example7;
|
||||||
|
|
||||||
|
{ This program demonstrates the GetSetProp function }
|
||||||
|
|
||||||
{$mode objfpc}
|
{$mode objfpc}
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
program example1;
|
program example8;
|
||||||
|
|
||||||
|
{ This program demonstrates the SetToString function }
|
||||||
|
|
||||||
{$mode objfpc}
|
{$mode objfpc}
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
program example2;
|
program example9;
|
||||||
|
|
||||||
|
{ This program demonstrates the GetEnumName, GetEnumValue functions }
|
||||||
|
|
||||||
{$mode objfpc}
|
{$mode objfpc}
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@ Type
|
|||||||
FObj : TObject;
|
FObj : TObject;
|
||||||
FNotifyEvent : TNotifyEvent;
|
FNotifyEvent : TNotifyEvent;
|
||||||
FSetField : TMyEnums;
|
FSetField : TMyEnums;
|
||||||
|
// FInt64Field : Int64;
|
||||||
|
FInt64Field : Integer;
|
||||||
FStored : Boolean;
|
FStored : Boolean;
|
||||||
Function GetBoolean : Boolean;
|
Function GetBoolean : Boolean;
|
||||||
Function GetByte : Byte;
|
Function GetByte : Byte;
|
||||||
@ -93,6 +95,8 @@ Type
|
|||||||
Property ObjField: TObject read FObj write FObj;
|
Property ObjField: TObject read FObj write FObj;
|
||||||
Property SetField : TMyEnums Read FSetField Write FSetField;
|
Property SetField : TMyEnums Read FSetField Write FSetField;
|
||||||
Property NotifyEvent : TNotifyEvent Read FNotifyEvent Write FNotifyEvent;
|
Property NotifyEvent : TNotifyEvent Read FNotifyEvent Write FNotifyEvent;
|
||||||
|
// Property Int64Field : Int64 Read Fint64Field Write FInt64Field;
|
||||||
|
Property Int64Field : Integer Read Fint64Field Write FInt64Field;
|
||||||
Property BooleanField : Boolean Read FBoolean Write FBoolean;
|
Property BooleanField : Boolean Read FBoolean Write FBoolean;
|
||||||
Property ByteField : Byte Read FByte Write FByte;
|
Property ByteField : Byte Read FByte Write FByte;
|
||||||
Property CharField : Char Read FChar Write FChar;
|
Property CharField : Char Read FChar Write FChar;
|
||||||
|
Loading…
Reference in New Issue
Block a user