mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-18 16:49:05 +02:00
rtl: AsInstance RTTI Implementation, from henrique, issue 38361
This commit is contained in:
parent
7597eb96e3
commit
6dff05705c
@ -70,6 +70,7 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
TRttiType = class;
|
TRttiType = class;
|
||||||
|
TRttiInstanceType = class;
|
||||||
|
|
||||||
{ TRTTIContext }
|
{ TRTTIContext }
|
||||||
|
|
||||||
@ -201,11 +202,11 @@ type
|
|||||||
FAttributes: TCustomAttributeArray;
|
FAttributes: TCustomAttributeArray;
|
||||||
FTypeInfo: TTypeInfo;
|
FTypeInfo: TTypeInfo;
|
||||||
//FMethods: specialize TArray<TRttiMethod>;
|
//FMethods: specialize TArray<TRttiMethod>;
|
||||||
//function GetAsInstance: TRttiInstanceType;
|
function GetAsInstance: TRttiInstanceType;
|
||||||
protected
|
protected
|
||||||
function GetName: string; override;
|
function GetName: string; override;
|
||||||
//function GetHandle: Pointer; override;
|
//function GetHandle: Pointer; override;
|
||||||
function GetIsInstance: boolean; virtual;
|
function GetIsInstance: boolean;
|
||||||
//function GetIsManaged: boolean; virtual;
|
//function GetIsManaged: boolean; virtual;
|
||||||
function GetIsOrdinal: boolean; virtual;
|
function GetIsOrdinal: boolean; virtual;
|
||||||
function GetIsRecord: boolean; virtual;
|
function GetIsRecord: boolean; virtual;
|
||||||
@ -236,7 +237,7 @@ type
|
|||||||
property IsRecord: boolean read GetIsRecord;
|
property IsRecord: boolean read GetIsRecord;
|
||||||
property IsSet: boolean read GetIsSet;
|
property IsSet: boolean read GetIsSet;
|
||||||
//property BaseType: TRttiType read GetBaseType;
|
//property BaseType: TRttiType read GetBaseType;
|
||||||
//property AsInstance: TRttiInstanceType read GetAsInstance;
|
property AsInstance: TRttiInstanceType read GetAsInstance;
|
||||||
property TypeKind: TTypeKind read GetTypeKind;
|
property TypeKind: TTypeKind read GetTypeKind;
|
||||||
//property TypeSize: integer read GetTypeSize;
|
//property TypeSize: integer read GetTypeSize;
|
||||||
end;
|
end;
|
||||||
@ -276,7 +277,6 @@ 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);
|
||||||
|
|
||||||
@ -962,11 +962,6 @@ begin
|
|||||||
inherited Create(ATypeInfo);
|
inherited Create(ATypeInfo);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TRttiInstanceType.GetIsInstance: boolean;
|
|
||||||
begin
|
|
||||||
Result:=True;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TRttiInterfaceType }
|
{ TRttiInterfaceType }
|
||||||
|
|
||||||
constructor TRttiInterfaceType.Create(ATypeInfo: PTypeInfo);
|
constructor TRttiInterfaceType.Create(ATypeInfo: PTypeInfo);
|
||||||
@ -1250,7 +1245,7 @@ end;
|
|||||||
|
|
||||||
function TRttiType.GetIsInstance: boolean;
|
function TRttiType.GetIsInstance: boolean;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=Self is TRttiInstanceType;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TRttiType.GetIsOrdinal: boolean;
|
function TRttiType.GetIsOrdinal: boolean;
|
||||||
@ -1273,6 +1268,11 @@ begin
|
|||||||
Result:=FTypeInfo.Kind;
|
Result:=FTypeInfo.Kind;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TRttiType.GetAsInstance: TRttiInstanceType;
|
||||||
|
begin
|
||||||
|
Result := Self as TRttiInstanceType;
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TRttiType.Create(ATypeInfo: PTypeInfo);
|
constructor TRttiType.Create(ATypeInfo: PTypeInfo);
|
||||||
begin
|
begin
|
||||||
inherited Create();
|
inherited Create();
|
||||||
|
Loading…
Reference in New Issue
Block a user