mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 21:10:01 +02:00
* Add GetMethod(name), patch by Lipinast Lekrisov, fixes issue #40953
This commit is contained in:
parent
b2892adebf
commit
d79c12ad5b
@ -375,10 +375,11 @@ type
|
|||||||
function GetDeclaredFields: TRttiFieldArray; virtual;
|
function GetDeclaredFields: TRttiFieldArray; virtual;
|
||||||
function GetProperties: TRttiPropertyArray; virtual;
|
function GetProperties: TRttiPropertyArray; virtual;
|
||||||
function GetProperty(const AName: string): TRttiProperty; virtual;
|
function GetProperty(const AName: string): TRttiProperty; virtual;
|
||||||
function GetMethods: TRttiMethodArray; virtual;
|
function GetMethods: TRttiMethodArray; virtual; overload;
|
||||||
|
function GetMethods(const aName: string): TRttiMethodArray; overload; virtual;
|
||||||
function GetMethod(const aName: String): TRttiMethod; virtual;
|
function GetMethod(const aName: String): TRttiMethod; virtual;
|
||||||
property IsInstance: boolean read GetIsInstance;
|
property IsInstance: boolean read GetIsInstance;
|
||||||
property isManaged: boolean read GetIsManaged;
|
property IsManaged: boolean read GetIsManaged;
|
||||||
property IsOrdinal: boolean read GetIsOrdinal;
|
property IsOrdinal: boolean read GetIsOrdinal;
|
||||||
property IsRecord: boolean read GetIsRecord;
|
property IsRecord: boolean read GetIsRecord;
|
||||||
property IsSet: boolean read GetIsSet;
|
property IsSet: boolean read GetIsSet;
|
||||||
@ -795,12 +796,12 @@ type
|
|||||||
FDeclaredMethods : TRttiMethodArray;
|
FDeclaredMethods : TRttiMethodArray;
|
||||||
FMethodsResolved : Boolean;
|
FMethodsResolved : Boolean;
|
||||||
protected
|
protected
|
||||||
function GetMethods: TRttiMethodArray; override;
|
|
||||||
procedure ResolveFields;
|
procedure ResolveFields;
|
||||||
procedure ResolveMethods;
|
procedure ResolveMethods;
|
||||||
procedure ResolveProperties;
|
procedure ResolveProperties;
|
||||||
function GetTypeSize: Integer; override;
|
function GetTypeSize: Integer; override;
|
||||||
public
|
public
|
||||||
|
function GetMethods: TRttiMethodArray; override;
|
||||||
function GetProperties: TRttiPropertyArray; override;
|
function GetProperties: TRttiPropertyArray; override;
|
||||||
function GetDeclaredFields: TRttiFieldArray; override;
|
function GetDeclaredFields: TRttiFieldArray; override;
|
||||||
function GetDeclaredMethods: TRttiMethodArray;
|
function GetDeclaredMethods: TRttiMethodArray;
|
||||||
@ -1256,6 +1257,7 @@ type
|
|||||||
Protected
|
Protected
|
||||||
function GetName: string; override;
|
function GetName: string; override;
|
||||||
Function GetIsConstructor: Boolean; override;
|
Function GetIsConstructor: Boolean; override;
|
||||||
|
Function GetIsDestructor: Boolean; override;
|
||||||
function GetCallingConvention: TCallConv; override;
|
function GetCallingConvention: TCallConv; override;
|
||||||
function GetReturnType: TRttiType; override;
|
function GetReturnType: TRttiType; override;
|
||||||
function GetDispatchKind: TDispatchKind; override;
|
function GetDispatchKind: TDispatchKind; override;
|
||||||
@ -6892,6 +6894,25 @@ begin
|
|||||||
Result := Nil;
|
Result := Nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TRttiType.GetMethods(const aName: string): TRttiMethodArray;
|
||||||
|
var
|
||||||
|
methods: specialize TArray<TRttiMethod>;
|
||||||
|
method: TRttiMethod;
|
||||||
|
count: Integer;
|
||||||
|
begin
|
||||||
|
methods := Self.GetMethods;
|
||||||
|
count := 0;
|
||||||
|
Result := nil;
|
||||||
|
|
||||||
|
for method in methods do
|
||||||
|
if SameText(method.Name, aName) then
|
||||||
|
begin
|
||||||
|
SetLength(Result, count + 1);
|
||||||
|
Result[count] := method;
|
||||||
|
Inc(count);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TRttiType.GetDeclaredMethods: TRttiMethodArray;
|
function TRttiType.GetDeclaredMethods: TRttiMethodArray;
|
||||||
begin
|
begin
|
||||||
Result := Nil;
|
Result := Nil;
|
||||||
@ -7209,12 +7230,12 @@ end;
|
|||||||
|
|
||||||
function TRttiRecordMethod.GetHasExtendedInfo: Boolean;
|
function TRttiRecordMethod.GetHasExtendedInfo: Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=False
|
Result:=True
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TRttiRecordMethod.GetCodeAddress: CodePointer;
|
function TRttiRecordMethod.GetCodeAddress: CodePointer;
|
||||||
begin
|
begin
|
||||||
Result := Nil;
|
Result := FHandle^.CodeAddress;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TRttiRecordMethod.GetIsClassMethod: Boolean;
|
function TRttiRecordMethod.GetIsClassMethod: Boolean;
|
||||||
@ -7315,6 +7336,11 @@ function TRttiRecordMethod.GetIsConstructor: Boolean;
|
|||||||
begin
|
begin
|
||||||
Result:=GetMethodKind in [mkConstructor,mkClassConstructor];
|
Result:=GetMethodKind in [mkConstructor,mkClassConstructor];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TRttiRecordMethod.GetIsDestructor: Boolean;
|
||||||
|
begin
|
||||||
|
Result:=False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{$ifndef InLazIDE}
|
{$ifndef InLazIDE}
|
||||||
|
Loading…
Reference in New Issue
Block a user