mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 15:47:51 +02:00
* rename TAttributeData to the more appropriate TAttributeTable
git-svn-id: trunk@42371 -
This commit is contained in:
parent
c17dafc2f9
commit
e060a43d70
@ -3398,12 +3398,12 @@ end;
|
|||||||
function TRttiProperty.GetAttributes: specialize TArray<TCustomAttribute>;
|
function TRttiProperty.GetAttributes: specialize TArray<TCustomAttribute>;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
ad: PAttributeData;
|
at: PAttributeTable;
|
||||||
begin
|
begin
|
||||||
if not FAttributesResolved then
|
if not FAttributesResolved then
|
||||||
begin
|
begin
|
||||||
ad := FPropInfo^.AttributeTable;
|
at := FPropInfo^.AttributeTable;
|
||||||
if Assigned(ad) then
|
if Assigned(at) then
|
||||||
begin
|
begin
|
||||||
SetLength(FAttributes, FPropInfo^.AttributeTable^.AttributeCount);
|
SetLength(FAttributes, FPropInfo^.AttributeTable^.AttributeCount);
|
||||||
for i := 0 to High(FAttributes) do
|
for i := 0 to High(FAttributes) do
|
||||||
@ -3629,16 +3629,16 @@ end;
|
|||||||
function TRttiType.GetAttributes: specialize TArray<TCustomAttribute>;
|
function TRttiType.GetAttributes: specialize TArray<TCustomAttribute>;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
ad: PAttributeData;
|
at: PAttributeTable;
|
||||||
begin
|
begin
|
||||||
if not FAttributesResolved then
|
if not FAttributesResolved then
|
||||||
begin
|
begin
|
||||||
ad := GetAttributeData(FTypeInfo);
|
at := GetAttributeTable(FTypeInfo);
|
||||||
if Assigned(ad) then
|
if Assigned(at) then
|
||||||
begin
|
begin
|
||||||
setlength(FAttributes,ad^.AttributeCount);
|
setlength(FAttributes,at^.AttributeCount);
|
||||||
for i := 0 to ad^.AttributeCount-1 do
|
for i := 0 to at^.AttributeCount-1 do
|
||||||
FAttributes[i]:=GetAttribute(ad,i);
|
FAttributes[i]:=GetAttribute(at,i);
|
||||||
end;
|
end;
|
||||||
FAttributesResolved:=true;
|
FAttributesResolved:=true;
|
||||||
end;
|
end;
|
||||||
|
@ -253,7 +253,7 @@ unit TypInfo;
|
|||||||
PAttributeProcList = ^TAttributeProcList;
|
PAttributeProcList = ^TAttributeProcList;
|
||||||
TAttributeProcList = array[0..$ffff] of TAttributeProc;
|
TAttributeProcList = array[0..$ffff] of TAttributeProc;
|
||||||
|
|
||||||
TAttributeData =
|
TAttributeTable =
|
||||||
{$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
|
{$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
|
||||||
packed
|
packed
|
||||||
{$endif}
|
{$endif}
|
||||||
@ -261,7 +261,7 @@ unit TypInfo;
|
|||||||
AttributeCount: word;
|
AttributeCount: word;
|
||||||
AttributesList: TAttributeProcList;
|
AttributesList: TAttributeProcList;
|
||||||
end;
|
end;
|
||||||
PAttributeData = ^TAttributeData;
|
PAttributeTable = ^TAttributeTable;
|
||||||
|
|
||||||
// members of TTypeData
|
// members of TTypeData
|
||||||
TArrayTypeData =
|
TArrayTypeData =
|
||||||
@ -522,7 +522,7 @@ unit TypInfo;
|
|||||||
ClassType : TClass;
|
ClassType : TClass;
|
||||||
Parent : PPTypeInfo;
|
Parent : PPTypeInfo;
|
||||||
PropCount : SmallInt;
|
PropCount : SmallInt;
|
||||||
AttributeTable : PAttributeData;
|
AttributeTable : PAttributeTable;
|
||||||
property UnitName: ShortString read GetUnitName;
|
property UnitName: ShortString read GetUnitName;
|
||||||
property PropertyTable: PPropData read GetPropertyTable;
|
property PropertyTable: PPropData read GetPropertyTable;
|
||||||
private
|
private
|
||||||
@ -625,7 +625,7 @@ unit TypInfo;
|
|||||||
(ClassType : TClass;
|
(ClassType : TClass;
|
||||||
ParentInfoRef : TypeInfoPtr;
|
ParentInfoRef : TypeInfoPtr;
|
||||||
PropCount : SmallInt;
|
PropCount : SmallInt;
|
||||||
AttributeTable : PAttributeData;
|
AttributeTable : PAttributeTable;
|
||||||
UnitName : ShortString;
|
UnitName : ShortString;
|
||||||
// here the properties follow as array of TPropInfo
|
// here the properties follow as array of TPropInfo
|
||||||
);
|
);
|
||||||
@ -744,7 +744,7 @@ unit TypInfo;
|
|||||||
// 6 : true, constant index property
|
// 6 : true, constant index property
|
||||||
PropProcs : Byte;
|
PropProcs : Byte;
|
||||||
|
|
||||||
AttributeTable : PAttributeData;
|
AttributeTable : PAttributeTable;
|
||||||
Name : ShortString;
|
Name : ShortString;
|
||||||
property PropType: PTypeInfo read GetPropType;
|
property PropType: PTypeInfo read GetPropType;
|
||||||
property Tail: Pointer read GetTail;
|
property Tail: Pointer read GetTail;
|
||||||
@ -893,11 +893,11 @@ procedure SetDynArrayProp(Instance: TObject; const PropName: string; const Value
|
|||||||
procedure SetDynArrayProp(Instance: TObject; PropInfo: PPropInfo; const Value: Pointer);
|
procedure SetDynArrayProp(Instance: TObject; PropInfo: PPropInfo; const Value: Pointer);
|
||||||
|
|
||||||
// Extended RTTI
|
// Extended RTTI
|
||||||
function GetAttributeData(TypeInfo: PTypeInfo): PAttributeData;
|
function GetAttributeTable(TypeInfo: PTypeInfo): PAttributeTable;
|
||||||
|
|
||||||
function GetPropAttribute(PropInfo: PPropInfo; AttributeNr: Word): TCustomAttribute;
|
function GetPropAttribute(PropInfo: PPropInfo; AttributeNr: Word): TCustomAttribute;
|
||||||
|
|
||||||
function GetAttribute(AttributeData: PAttributeData; AttributeNr: Word): TCustomAttribute;
|
function GetAttribute(AttributeTable: PAttributeTable; AttributeNr: Word): TCustomAttribute;
|
||||||
|
|
||||||
// Auxiliary routines, which may be useful
|
// Auxiliary routines, which may be useful
|
||||||
Function GetEnumName(TypeInfo : PTypeInfo;Value : Integer) : string;
|
Function GetEnumName(TypeInfo : PTypeInfo;Value : Integer) : string;
|
||||||
@ -976,7 +976,7 @@ begin
|
|||||||
{$endif}
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetAttributeData(TypeInfo: PTypeInfo): PAttributeData;
|
function GetAttributeTable(TypeInfo: PTypeInfo): PAttributeTable;
|
||||||
var
|
var
|
||||||
TD: PTypeData;
|
TD: PTypeData;
|
||||||
begin
|
begin
|
||||||
@ -999,7 +999,7 @@ end;
|
|||||||
|
|
||||||
function GetPropAttribute(PropInfo: PPropInfo; AttributeNr: Word): TCustomAttribute;
|
function GetPropAttribute(PropInfo: PPropInfo; AttributeNr: Word): TCustomAttribute;
|
||||||
var
|
var
|
||||||
attrtable: PAttributeData;
|
attrtable: PAttributeTable;
|
||||||
begin
|
begin
|
||||||
attrtable := PropInfo^.AttributeTable;
|
attrtable := PropInfo^.AttributeTable;
|
||||||
if not Assigned(attrtable) or (AttributeNr >= attrtable^.AttributeCount) then
|
if not Assigned(attrtable) or (AttributeNr >= attrtable^.AttributeCount) then
|
||||||
@ -1010,15 +1010,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetAttribute(AttributeData: PAttributeData; AttributeNr: Word): TCustomAttribute;
|
function GetAttribute(AttributeTable: PAttributeTable; AttributeNr: Word): TCustomAttribute;
|
||||||
var
|
var
|
||||||
AttributeProcList: TAttributeProcList;
|
AttributeProcList: TAttributeProcList;
|
||||||
begin
|
begin
|
||||||
if (AttributeData=nil) or (AttributeNr>=AttributeData^.AttributeCount) then
|
if (AttributeTable=nil) or (AttributeNr>=AttributeTable^.AttributeCount) then
|
||||||
result := nil
|
result := nil
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
result := AttributeData^.AttributesList[AttributeNr]();
|
result := AttributeTable^.AttributesList[AttributeNr]();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
ad: PAttributeData;
|
at: PAttributeTable;
|
||||||
AClassAttribute: TCustomAttribute;
|
AClassAttribute: TCustomAttribute;
|
||||||
|
|
||||||
{ tmyt }
|
{ tmyt }
|
||||||
@ -31,13 +31,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
ad := GetAttributeData(TMyObject.ClassInfo);
|
at := GetAttributeTable(TMyObject.ClassInfo);
|
||||||
if not assigned(ad) then
|
if not assigned(at) then
|
||||||
halt(1);
|
halt(1);
|
||||||
if ad^.AttributeCount<>1 then
|
if at^.AttributeCount<>1 then
|
||||||
halt(2);
|
halt(2);
|
||||||
|
|
||||||
AClassAttribute := GetAttribute(ad,0);
|
AClassAttribute := GetAttribute(at,0);
|
||||||
if AClassAttribute = nil then
|
if AClassAttribute = nil then
|
||||||
halt(3);
|
halt(3);
|
||||||
writeln('ok');
|
writeln('ok');
|
||||||
|
@ -18,17 +18,17 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
ad: PAttributeData;
|
at: PAttributeTable;
|
||||||
AClassAttribute: TCustomAttribute;
|
AClassAttribute: TCustomAttribute;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
ad := GetAttributeData(TMyObject.ClassInfo);
|
at := GetAttributeTable(TMyObject.ClassInfo);
|
||||||
if not Assigned(ad) then
|
if not Assigned(at) then
|
||||||
Halt(1);
|
Halt(1);
|
||||||
if ad^.AttributeCount<>1 then
|
if at^.AttributeCount<>1 then
|
||||||
halt(2);
|
halt(2);
|
||||||
|
|
||||||
AClassAttribute := GetAttribute(ad,0);
|
AClassAttribute := GetAttribute(at,0);
|
||||||
if AClassAttribute = nil then
|
if AClassAttribute = nil then
|
||||||
halt(3);
|
halt(3);
|
||||||
writeln('ok');
|
writeln('ok');
|
||||||
|
@ -22,16 +22,16 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
ad: PAttributeData;
|
at: PAttributeTable;
|
||||||
attr: TCustomAttribute;
|
attr: TCustomAttribute;
|
||||||
begin
|
begin
|
||||||
ad := GetAttributeData(TypeInfo(TTestObj));
|
at := GetAttributeTable(TypeInfo(TTestObj));
|
||||||
if not Assigned(ad) then
|
if not Assigned(at) then
|
||||||
Halt(1);
|
Halt(1);
|
||||||
if ad^.AttributeCount <> 1 then
|
if at^.AttributeCount <> 1 then
|
||||||
Halt(2);
|
Halt(2);
|
||||||
|
|
||||||
attr := GetAttribute(ad, 0);
|
attr := GetAttribute(at, 0);
|
||||||
if not Assigned(attr) then
|
if not Assigned(attr) then
|
||||||
Halt(3);
|
Halt(3);
|
||||||
if not (attr is TTestAttribute) then
|
if not (attr is TTestAttribute) then
|
||||||
|
@ -23,7 +23,7 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
rtd: PAttributeData;
|
rtd: PAttributeTable;
|
||||||
AClassAttribute: tmyt;
|
AClassAttribute: tmyt;
|
||||||
|
|
||||||
{ tmyt }
|
{ tmyt }
|
||||||
@ -34,7 +34,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
rtd := GetAttributeData(TMyObject.ClassInfo);
|
rtd := GetAttributeTable(TMyObject.ClassInfo);
|
||||||
|
|
||||||
if not Assigned(rtd) then
|
if not Assigned(rtd) then
|
||||||
halt(1);
|
halt(1);
|
||||||
|
@ -17,17 +17,17 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
ad: PAttributeData;
|
at: PAttributeTable;
|
||||||
AClassAttribute: TCustomAttribute;
|
AClassAttribute: TCustomAttribute;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
ad := GetAttributeData(TMyObject.ClassInfo);
|
at := GetAttributeTable(TMyObject.ClassInfo);
|
||||||
if not Assigned(ad) then
|
if not Assigned(at) then
|
||||||
halt(1);
|
halt(1);
|
||||||
if ad^.AttributeCount<>1 then
|
if at^.AttributeCount<>1 then
|
||||||
halt(2);
|
halt(2);
|
||||||
|
|
||||||
AClassAttribute := GetAttribute(ad,0);
|
AClassAttribute := GetAttribute(at,0);
|
||||||
if AClassAttribute = nil then
|
if AClassAttribute = nil then
|
||||||
halt(3);
|
halt(3);
|
||||||
writeln('ok');
|
writeln('ok');
|
||||||
|
Loading…
Reference in New Issue
Block a user