mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-12 09:15:52 +02:00
rtl: added TRttiMethod.GetIsAsyncCall, issue 38803, from henrique
This commit is contained in:
parent
0e5b285b1d
commit
173ddc874b
@ -166,28 +166,33 @@ type
|
|||||||
private
|
private
|
||||||
FParameters: TRttiParameterArray;
|
FParameters: TRttiParameterArray;
|
||||||
|
|
||||||
function GetMethodTypeInfo: TTypeMemberMethod;
|
function GetIsAsyncCall: Boolean;
|
||||||
function GetIsClassMethod: boolean;
|
function GetIsClassMethod: Boolean;
|
||||||
function GetIsConstructor: boolean;
|
function GetIsConstructor: Boolean;
|
||||||
function GetIsDestructor: boolean;
|
function GetIsDestructor: Boolean;
|
||||||
function GetIsExternal: boolean;
|
function GetIsExternal: Boolean;
|
||||||
function GetIsStatic: boolean;
|
function GetIsSafeCall: Boolean;
|
||||||
function GetIsVarArgs: boolean;
|
function GetIsStatic: Boolean;
|
||||||
|
function GetIsVarArgs: Boolean;
|
||||||
function GetMethodKind: TMethodKind;
|
function GetMethodKind: TMethodKind;
|
||||||
|
function GetMethodTypeInfo: TTypeMemberMethod;
|
||||||
|
function GetProcedureFlags: TProcedureFlags;
|
||||||
function GetReturnType: TRttiType;
|
function GetReturnType: TRttiType;
|
||||||
|
|
||||||
procedure LoadParameters;
|
procedure LoadParameters;
|
||||||
public
|
public
|
||||||
function GetParameters: TRttiParameterArray;
|
function GetParameters: TRttiParameterArray;
|
||||||
|
|
||||||
|
property IsAsyncCall: Boolean read GetIsAsyncCall;
|
||||||
|
property IsClassMethod: Boolean read GetIsClassMethod;
|
||||||
|
property IsConstructor: Boolean read GetIsConstructor;
|
||||||
|
property IsDestructor: Boolean read GetIsDestructor;
|
||||||
|
property IsExternal: Boolean read GetIsExternal;
|
||||||
|
property IsSafeCall: Boolean read GetIsSafeCall;
|
||||||
|
property IsStatic: Boolean read GetIsStatic;
|
||||||
|
property MethodKind: TMethodKind read GetMethodKind;
|
||||||
property MethodTypeInfo: TTypeMemberMethod read GetMethodTypeInfo;
|
property MethodTypeInfo: TTypeMemberMethod read GetMethodTypeInfo;
|
||||||
property ReturnType: TRttiType read GetReturnType;
|
property ReturnType: TRttiType read GetReturnType;
|
||||||
property MethodKind: TMethodKind read GetMethodKind;
|
|
||||||
property IsConstructor: boolean read GetIsConstructor;
|
|
||||||
property IsDestructor: boolean read GetIsDestructor;
|
|
||||||
property IsClassMethod: boolean read GetIsClassMethod;
|
|
||||||
property IsExternal: boolean read GetIsExternal;
|
|
||||||
property IsStatic: boolean read GetIsStatic;// true = has Self argument
|
|
||||||
property IsVarArgs: boolean read GetIsVarArgs;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TRttiMethodArray = specialize TArray<TRttiMethod>;
|
TRttiMethodArray = specialize TArray<TRttiMethod>;
|
||||||
@ -1321,34 +1326,44 @@ begin
|
|||||||
Result := TTypeMemberMethod(FTypeInfo);
|
Result := TTypeMemberMethod(FTypeInfo);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TRttiMethod.GetIsClassMethod: boolean;
|
function TRttiMethod.GetIsClassMethod: Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=MethodTypeInfo.MethodKind in [mkClassFunction,mkClassProcedure];
|
Result:=MethodTypeInfo.MethodKind in [mkClassFunction,mkClassProcedure];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TRttiMethod.GetIsConstructor: boolean;
|
function TRttiMethod.GetIsConstructor: Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=MethodTypeInfo.MethodKind=mkConstructor;
|
Result:=MethodTypeInfo.MethodKind=mkConstructor;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TRttiMethod.GetIsDestructor: boolean;
|
function TRttiMethod.GetIsDestructor: Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=MethodTypeInfo.MethodKind=mkDestructor;
|
Result:=MethodTypeInfo.MethodKind=mkDestructor;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TRttiMethod.GetIsExternal: boolean;
|
function TRttiMethod.GetIsExternal: Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=(MethodTypeInfo.ProcSig.Flags and 4)>0; // pfExternal
|
Result := pfExternal in GetProcedureFlags;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TRttiMethod.GetIsStatic: boolean;
|
function TRttiMethod.GetIsStatic: Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=(MethodTypeInfo.ProcSig.Flags and 1)>0; // pfStatic
|
Result := pfStatic in GetProcedureFlags;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TRttiMethod.GetIsVarArgs: boolean;
|
function TRttiMethod.GetIsVarArgs: Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=(MethodTypeInfo.ProcSig.Flags and 2)>0; // pfVarargs
|
Result := pfVarargs in GetProcedureFlags;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TRttiMethod.GetIsAsyncCall: Boolean;
|
||||||
|
begin
|
||||||
|
Result := pfAsync in GetProcedureFlags;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TRttiMethod.GetIsSafeCall: Boolean;
|
||||||
|
begin
|
||||||
|
Result := pfSafeCall in GetProcedureFlags;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TRttiMethod.GetMethodKind: TMethodKind;
|
function TRttiMethod.GetMethodKind: TMethodKind;
|
||||||
@ -1356,6 +1371,22 @@ begin
|
|||||||
Result:=MethodTypeInfo.MethodKind;;
|
Result:=MethodTypeInfo.MethodKind;;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TRttiMethod.GetProcedureFlags: TProcedureFlags;
|
||||||
|
const
|
||||||
|
PROCEDURE_FLAGS: array of NativeInt = (1, 2, 4, 8, 16);
|
||||||
|
|
||||||
|
var
|
||||||
|
Flag, ProcedureFlags: NativeInt;
|
||||||
|
|
||||||
|
begin
|
||||||
|
ProcedureFlags := MethodTypeInfo.ProcSig.Flags;
|
||||||
|
Result := [];
|
||||||
|
|
||||||
|
for Flag := Low(PROCEDURE_FLAGS) to High(PROCEDURE_FLAGS) do
|
||||||
|
if PROCEDURE_FLAGS[Flag] and ProcedureFlags > 0 then
|
||||||
|
Result := Result + [TProcedureFlag(Flag)];
|
||||||
|
end;
|
||||||
|
|
||||||
function TRttiMethod.GetReturnType: TRttiType;
|
function TRttiMethod.GetReturnType: TRttiType;
|
||||||
begin
|
begin
|
||||||
Result := GRttiContext.GetType(MethodTypeInfo.ProcSig.ResultType);
|
Result := GRttiContext.GetType(MethodTypeInfo.ProcSig.ResultType);
|
||||||
|
Loading…
Reference in New Issue
Block a user