tests.rtti.attrtypes.pas 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. unit tests.rtti.attrtypes;
  2. {These types are put in a different unit so the $RTTI directive only influences these classes }
  3. {$mode objfpc}
  4. {$ModeSwitch prefixedattributes}
  5. {$modeswitch advancedrecords}
  6. interface
  7. uses
  8. TypInfo;
  9. Type
  10. {$RTTI Explicit Fields[vcPrivate,vcPublic,vcProtected,vcPublished]
  11. Properties[vcPrivate,vcPublic,vcProtected,vcPublished]
  12. }
  13. { TIntAttribute }
  14. { WeakAttribute }
  15. WeakAttribute = class(TCustomAttribute)
  16. Constructor Create;
  17. end;
  18. TIntAttribute = class(TCustomAttribute)
  19. Private
  20. FInt : Integer;
  21. Public
  22. Constructor Create(aInt: Integer);
  23. Property Int : Integer Read FInt;
  24. end;
  25. MyAttribute = class(TIntAttribute)
  26. end;
  27. My2Attribute = class(TIntAttribute);
  28. My3Attribute = class(TIntAttribute);
  29. My4Attribute = class(TIntAttribute);
  30. TFieldObject = Class(TObject)
  31. Private
  32. [Weak]
  33. [my(1)]
  34. [my2(2)]
  35. PrivateField : Integer;
  36. Protected
  37. [my2(3)]
  38. ProtectedField : Integer;
  39. Public
  40. [my3(4)]
  41. PublicField : Integer;
  42. Public
  43. [my3(4)]
  44. A, B : Integer;
  45. end;
  46. {$M+}
  47. TPropertyObject = Class(TObject)
  48. Private
  49. PrivateField : Integer;
  50. [Weak]
  51. [my(1)]
  52. [my2(2)]
  53. Property PrivateProperty : Integer Read PrivateField;
  54. Protected
  55. ProtectedField : Integer;
  56. [my2(3)]
  57. Property ProtectedProperty : Integer Read ProtectedField;
  58. Public
  59. PublicField : Integer;
  60. PublishedField : Integer;
  61. [my3(4)]
  62. Property PublicProperty : Integer Read PublicField;
  63. Published
  64. [my3(5)]
  65. Property PublishedProperty : Integer Read PublishedField;
  66. end;
  67. TFieldRecord = Record
  68. Private
  69. [Weak]
  70. [my(1)]
  71. [my2(2)]
  72. PrivateField : Integer;
  73. Public
  74. [my3(3)]
  75. PublicField : Integer;
  76. Public
  77. [my3(4)]
  78. A,B : Integer;
  79. end;
  80. implementation
  81. constructor WeakAttribute.Create;
  82. begin
  83. // Do nothing
  84. end;
  85. { TIntAttribute }
  86. constructor TIntAttribute.Create(aInt: Integer);
  87. begin
  88. Fint:=aInt;
  89. end;
  90. end.