mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-09-01 06:10:26 +02:00
rtl: startedd RTTI info for record types, patch 38322
This commit is contained in:
parent
0746298593
commit
0b86b71d49
@ -248,7 +248,7 @@ type
|
|||||||
FMethods: TRttiMethodArray;
|
FMethods: TRttiMethodArray;
|
||||||
FProperties: TRttiPropertyArray;
|
FProperties: TRttiPropertyArray;
|
||||||
protected
|
protected
|
||||||
function GetAncestor: TRttiStructuredType; virtual; abstract;
|
function GetAncestor: TRttiStructuredType; virtual;
|
||||||
function GetStructTypeInfo: TTypeInfoStruct;
|
function GetStructTypeInfo: TTypeInfoStruct;
|
||||||
public
|
public
|
||||||
constructor Create(ATypeInfo: PTypeInfo);
|
constructor Create(ATypeInfo: PTypeInfo);
|
||||||
@ -274,9 +274,10 @@ type
|
|||||||
function GetMetaClassType: TClass;
|
function GetMetaClassType: TClass;
|
||||||
protected
|
protected
|
||||||
function GetAncestor: TRttiStructuredType; override;
|
function GetAncestor: TRttiStructuredType; override;
|
||||||
|
function GetIsInstance: boolean; override;
|
||||||
public
|
public
|
||||||
constructor Create(ATypeInfo: PTypeInfo);
|
constructor Create(ATypeInfo: PTypeInfo);
|
||||||
function GetIsInstance: boolean; override;
|
|
||||||
property ClassTypeInfo: TTypeInfoClass read GetClassTypeInfo;
|
property ClassTypeInfo: TTypeInfoClass read GetClassTypeInfo;
|
||||||
property MetaClassType: TClass read GetMetaClassType;
|
property MetaClassType: TClass read GetMetaClassType;
|
||||||
end;
|
end;
|
||||||
@ -296,6 +297,19 @@ type
|
|||||||
property InterfaceTypeInfo: TTypeInfoInterface read GetInterfaceTypeInfo;
|
property InterfaceTypeInfo: TTypeInfoInterface read GetInterfaceTypeInfo;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TRttiRecordType }
|
||||||
|
|
||||||
|
TRttiRecordType = class(TRttiStructuredType)
|
||||||
|
private
|
||||||
|
function GetRecordTypeInfo: TTypeInfoRecord;
|
||||||
|
protected
|
||||||
|
function GetIsRecord: Boolean; override;
|
||||||
|
public
|
||||||
|
constructor Create(ATypeInfo: PTypeInfo);
|
||||||
|
|
||||||
|
property RecordTypeInfo: TTypeInfoRecord read GetRecordTypeInfo;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TRttiOrdinalType }
|
{ TRttiOrdinalType }
|
||||||
|
|
||||||
TRttiOrdinalType = class(TRttiType)
|
TRttiOrdinalType = class(TRttiType)
|
||||||
@ -838,6 +852,11 @@ begin
|
|||||||
Result := FProperties;
|
Result := FProperties;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TRttiStructuredType.GetAncestor: TRttiStructuredType;
|
||||||
|
begin
|
||||||
|
Result := nil;
|
||||||
|
end;
|
||||||
|
|
||||||
function TRttiStructuredType.GetStructTypeInfo: TTypeInfoStruct;
|
function TRttiStructuredType.GetStructTypeInfo: TTypeInfoStruct;
|
||||||
begin
|
begin
|
||||||
Result:=TTypeInfoStruct(FTypeInfo);
|
Result:=TTypeInfoStruct(FTypeInfo);
|
||||||
@ -944,6 +963,25 @@ begin
|
|||||||
Result := GRttiContext.GetType(InterfaceTypeInfo.Ancestor) as TRttiStructuredType;
|
Result := GRttiContext.GetType(InterfaceTypeInfo.Ancestor) as TRttiStructuredType;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TRttiRecordType }
|
||||||
|
|
||||||
|
function TRttiRecordType.GetRecordTypeInfo: TTypeInfoRecord;
|
||||||
|
begin
|
||||||
|
Result := TTypeInfoRecord(FTypeInfo);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TRttiRecordType.GetIsRecord: Boolean;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TRttiRecordType.Create(ATypeInfo: PTypeInfo);
|
||||||
|
begin
|
||||||
|
if not (TTypeInfo(ATypeInfo) is TTypeInfoClass) then
|
||||||
|
raise EInvalidCast.Create('');
|
||||||
|
inherited Create(ATypeInfo);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TRTTIContext }
|
{ TRTTIContext }
|
||||||
|
|
||||||
class constructor TRTTIContext.Init;
|
class constructor TRTTIContext.Init;
|
||||||
@ -984,7 +1022,7 @@ var
|
|||||||
nil, // tkMethod
|
nil, // tkMethod
|
||||||
TRttiType, // tkArray
|
TRttiType, // tkArray
|
||||||
TRttiDynamicArrayType, // tkDynArray
|
TRttiDynamicArrayType, // tkDynArray
|
||||||
TRttiType, // tkRecord
|
TRttiRecordType, // tkRecord
|
||||||
TRttiInstanceType, // tkClass
|
TRttiInstanceType, // tkClass
|
||||||
TRttiType, // tkClassRef
|
TRttiType, // tkClassRef
|
||||||
TRttiType, // tkPointer
|
TRttiType, // tkPointer
|
||||||
|
Loading…
Reference in New Issue
Block a user