tcustomattr1.pp 594 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. program tcustomattr1;
  2. {$mode objfpc}{$H+}
  3. {$modeswitch prefixedattributes}
  4. uses
  5. typinfo;
  6. type
  7. { tmyt }
  8. tmyt = class(TCustomAttribute)
  9. constructor create;
  10. end;
  11. type
  12. [Tmyt]
  13. TMyObject = class(TObject)
  14. end;
  15. var
  16. at: PAttributeTable;
  17. AClassAttribute: TCustomAttribute;
  18. { tmyt }
  19. constructor tmyt.create;
  20. begin
  21. //
  22. end;
  23. begin
  24. at := GetAttributeTable(TMyObject.ClassInfo);
  25. if not assigned(at) then
  26. halt(1);
  27. if at^.AttributeCount<>1 then
  28. halt(2);
  29. AClassAttribute := GetAttribute(at,0);
  30. if AClassAttribute = nil then
  31. halt(3);
  32. writeln('ok');
  33. end.