Browse Source

+ Added README and ex14 and ex15 examples

michael 24 years ago
parent
commit
77ec55dafb

+ 24 - 0
docs/typinfex/README

@@ -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

+ 2 - 0
docs/typinfex/ex1.pp

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

+ 3 - 1
docs/typinfex/ex10.pp

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

+ 2 - 0
docs/typinfex/ex11.pp

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

+ 2 - 1
docs/typinfex/ex12.pp

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

+ 1 - 0
docs/typinfex/ex13.pp

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

+ 33 - 0
docs/typinfex/ex14.pp

@@ -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 - 0
docs/typinfex/ex15.pp

@@ -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.

+ 2 - 0
docs/typinfex/ex2.pp

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

+ 2 - 0
docs/typinfex/ex3.pp

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

+ 3 - 1
docs/typinfex/ex4.pp

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

+ 3 - 1
docs/typinfex/ex5.pp

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

+ 3 - 1
docs/typinfex/ex6.pp

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

+ 3 - 1
docs/typinfex/ex7.pp

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

+ 3 - 1
docs/typinfex/ex8.pp

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

+ 3 - 1
docs/typinfex/ex9.pp

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

+ 4 - 0
docs/typinfex/rttiobj.pp

@@ -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;