mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 13:28:05 +02:00

Note: this also means that TCustomAttribute itself can not be used as an attribute * adjusted existing tests + added test git-svn-id: trunk@42471 -
43 lines
684 B
ObjectPascal
43 lines
684 B
ObjectPascal
program tcustomattr10;
|
|
|
|
{$mode objfpc}{$H+}
|
|
{$modeswitch prefixedattributes}
|
|
|
|
uses
|
|
typinfo;
|
|
|
|
type
|
|
{ TMyAttr }
|
|
TMyAttrAttribute = class(TCustomAttribute)
|
|
constructor Create;
|
|
end;
|
|
|
|
type
|
|
// The attribute should be also accessable without the Attribute suffix.
|
|
[TMyAttr]
|
|
TMyObject = class(TObject)
|
|
end;
|
|
|
|
constructor TMyAttrAttribute.Create;
|
|
begin
|
|
|
|
end;
|
|
|
|
var
|
|
at: PAttributeTable;
|
|
AClassAttribute: TCustomAttribute;
|
|
|
|
begin
|
|
at := GetAttributeTable(TMyObject.ClassInfo);
|
|
if not Assigned(at) then
|
|
Halt(1);
|
|
if at^.AttributeCount<>1 then
|
|
halt(2);
|
|
|
|
AClassAttribute := GetAttribute(at,0);
|
|
if AClassAttribute = nil then
|
|
halt(3);
|
|
writeln('ok');
|
|
end.
|
|
|