mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 11:08:02 +02:00
* Add IsInstanceOf
This commit is contained in:
parent
972b961f2b
commit
a9ff6272f6
@ -229,6 +229,7 @@ type
|
||||
function GetArrayElement(AIndex: SizeInt): TValue;
|
||||
procedure SetArrayElement(AIndex: SizeInt; constref AValue: TValue);
|
||||
function IsType(aTypeInfo: PTypeInfo): boolean; inline;
|
||||
function IsInstanceOf(aClass : TClass): boolean; inline;
|
||||
function TryCast(aTypeInfo: PTypeInfo; out aResult: TValue; const aEmptyAsAnyType: Boolean = True): Boolean;
|
||||
function Cast(aTypeInfo: PTypeInfo; const aEmptyAsAnyType: Boolean = True): TValue; overload;
|
||||
{$ifndef NoGenericMethods}
|
||||
@ -1844,6 +1845,19 @@ begin
|
||||
Result:=IsDateTimeType(TypeInfo);
|
||||
end;
|
||||
|
||||
function TValue.IsInstanceOf(aClass : TClass): boolean;
|
||||
|
||||
var
|
||||
Obj : TObject;
|
||||
|
||||
begin
|
||||
Result:=IsObject;
|
||||
if not Result then
|
||||
exit;
|
||||
Obj:=AsObject;
|
||||
Result:=Assigned(Obj) and Obj.InheritsFrom(aClass);
|
||||
end;
|
||||
|
||||
{$ifndef NoGenericMethods}
|
||||
generic function TValue.IsType<T>:Boolean;
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user