+ Added README and ex14 and ex15 examples

This commit is contained in:
michael 2001-09-02 21:45:29 +00:00
parent 915b5cd7a9
commit 77ec55dafb
17 changed files with 118 additions and 8 deletions

24
docs/typinfex/README Normal file
View 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

View File

@ -1,5 +1,7 @@
program example1;
{ This program demonstrates the GetOrdProp function }
{$mode objfpc}
uses rttiobj,typinfo;

View File

@ -1,4 +1,6 @@
program example11;
program example10;
{ This program demonstrates the IsPublishedProp function }
{$mode objfpc}

View File

@ -1,5 +1,7 @@
program example11;
{ This program demonstrates the IsStoredProp function }
{$mode objfpc}
uses rttiobj,typinfo;

View File

@ -1,5 +1,6 @@
Program example13;
Program example12;
{ This program demonstrates the GetPropInfos function }
uses
rttiobj,typinfo;

View File

@ -1,5 +1,6 @@
Program example13;
{ This program demonstrates the GetPropList function }
uses
rttiobj,typinfo;

33
docs/typinfex/ex14.pp Normal file
View 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
View 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.

View File

@ -1,5 +1,7 @@
program example2;
{ This program demonstrates the GetEnumProp function }
{$mode objfpc}
uses rttiobj,typinfo;

View File

@ -1,5 +1,7 @@
program example3;
{ This program demonstrates the GetStrProp function }
{$mode objfpc}
uses rttiobj,typinfo;

View File

@ -1,4 +1,6 @@
program example3;
program example4;
{ This program demonstrates the GetFloatProp function }
{$mode objfpc}

View File

@ -1,4 +1,6 @@
program example3;
program example5;
{ This program demonstrates the GetObjectProp function }
{$mode objfpc}

View File

@ -1,4 +1,6 @@
program example3;
program example6;
{ This program demonstrates the GetMethodProp function }
{$mode objfpc}

View File

@ -1,4 +1,6 @@
program example1;
program example7;
{ This program demonstrates the GetSetProp function }
{$mode objfpc}

View File

@ -1,4 +1,6 @@
program example1;
program example8;
{ This program demonstrates the SetToString function }
{$mode objfpc}

View File

@ -1,4 +1,6 @@
program example2;
program example9;
{ This program demonstrates the GetEnumName, GetEnumValue functions }
{$mode objfpc}

View File

@ -38,6 +38,8 @@ Type
FObj : TObject;
FNotifyEvent : TNotifyEvent;
FSetField : TMyEnums;
// FInt64Field : Int64;
FInt64Field : Integer;
FStored : Boolean;
Function GetBoolean : Boolean;
Function GetByte : Byte;
@ -93,6 +95,8 @@ Type
Property ObjField: TObject read FObj write FObj;
Property SetField : TMyEnums Read FSetField Write FSetField;
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 ByteField : Byte Read FByte Write FByte;
Property CharField : Char Read FChar Write FChar;