tclassattribute9.pp 514 B

123456789101112131415161718192021222324252627282930313233
  1. program tclassattribute9;
  2. {$mode objfpc}{$H+}
  3. {$modeswitch prefixedattributes}
  4. uses
  5. typinfo;
  6. type
  7. { tmyt }
  8. // TCustomAttribute without constructor
  9. tmyt = class(TCustomAttribute);
  10. type
  11. [Tmyt]
  12. TMyObject = class(TObject)
  13. end;
  14. var
  15. ad: PAttributeData;
  16. AClassAttribute: TCustomAttribute;
  17. begin
  18. ad := GetAttributeData(TMyObject.ClassInfo);
  19. if ad^.AttributeCount<>1 then
  20. halt(1);
  21. AClassAttribute := GetAttribute(ad,0);
  22. if AClassAttribute = nil then
  23. halt(2);
  24. writeln('ok');
  25. end.