View Issue Details

IDProjectCategoryView StatusLast Update
0038823pas2jsrtlpublic2021-04-30 11:20
Reporterhenrique Assigned ToMattias Gaertner  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformPas2JsOSWindows 
Summary0038823: Adjusted parameter load
DescriptionThe loading of the procedures and parameters of the methods was having problems and I adjusted the implementation.
TagsNo tags attached.
Fixed in Revision1175.
Attached Files

Activities

henrique

2021-04-29 16:31

reporter  

0001-Ajuste-na-carga-de-par-metros.patch (3,186 bytes)   
From 7a7dfc6941e3e13a9856e6329096870e226d6444 Mon Sep 17 00:00:00 2001
From: Henrique Gottardi Werlang <henriquewerlang@hotmail.com>
Date: Thu, 29 Apr 2021 11:25:10 -0300
Subject: [PATCH] =?UTF-8?q?Ajuste=20na=20carga=20de=20par=C3=A2metros.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 packages/rtl/rtti.pas | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/packages/rtl/rtti.pas b/packages/rtl/rtti.pas
index 505b4949..dad73d92 100644
--- a/packages/rtl/rtti.pas
+++ b/packages/rtl/rtti.pas
@@ -146,6 +146,8 @@ type
 
   TRttiFieldArray = specialize TArray<TRttiField>;
 
+  { TRttiParameter }
+
   TRttiParameter = class(TRttiNamedObject)
   private
     FParamType: TRttiType;
@@ -165,6 +167,7 @@ type
   TRttiMethod = class(TRttiMember)
   private
     FParameters: TRttiParameterArray;
+    FParametersLoaded: Boolean;
 
     function GetIsAsyncCall: Boolean;
     function GetIsClassMethod: Boolean;
@@ -1373,10 +1376,12 @@ end;
 
 function TRttiMethod.GetProcedureFlags: TProcedureFlags;
 const
-  PROCEDURE_FLAGS: array of NativeInt = (1, 2, 4, 8, 16);
+  PROCEDURE_FLAGS: array[TProcedureFlag] of NativeInt = (1, 2, 4, 8, 16);
 
 var
-  Flag, ProcedureFlags: NativeInt;
+  Flag: TProcedureFlag;
+
+  ProcedureFlags: NativeInt;
 
 begin
   ProcedureFlags := MethodTypeInfo.ProcSig.Flags;
@@ -1384,7 +1389,7 @@ begin
 
   for Flag := Low(PROCEDURE_FLAGS) to High(PROCEDURE_FLAGS) do
     if PROCEDURE_FLAGS[Flag] and ProcedureFlags > 0 then
-      Result := Result + [TProcedureFlag(Flag)];
+      Result := Result + [Flag];
 end;
 
 function TRttiMethod.GetReturnType: TRttiType;
@@ -1394,28 +1399,35 @@ end;
 
 procedure TRttiMethod.LoadParameters;
 const
-  FLAGS_CONVERSION: array[TParamFlag] of Integer = (1, 2, 4, 8, 16, 32);
+  FLAGS_CONVERSION: array[TParamFlag] of NativeInt = (1, 2, 4, 8, 16, 32);
 
 var
-  A, Flag: Integer;
+  A: Integer;
+
+  Flag: TParamFlag;
 
   Param: TProcedureParam;
 
   RttiParam: TRttiParameter;
 
+  MethodParams: TProcedureParams;
+
 begin
-  SetLength(FParameters, Length(MethodTypeInfo.ProcSig.Params));
+  FParametersLoaded := True;
+  MethodParams := MethodTypeInfo.ProcSig.Params;
+
+  SetLength(FParameters, Length(MethodParams));
 
   for A := Low(FParameters) to High(FParameters) do
   begin
-    Param := MethodTypeInfo.ProcSig.Params[A];
+    Param := MethodParams[A];
     RttiParam := TRttiParameter.Create;
     RttiParam.FName := Param.Name;
     RttiParam.FParamType := GRttiContext.GetType(Param.TypeInfo);
 
-    for Flag in FLAGS_CONVERSION do
-      if Flag and Param.Flags > 0 then
-        RttiParam.FFlags := RttiParam.FFlags + [TParamFlag(A)];
+    for Flag := Low(FLAGS_CONVERSION) to High(FLAGS_CONVERSION) do
+      if FLAGS_CONVERSION[Flag] and Param.Flags > 0 then
+        RttiParam.FFlags := RttiParam.FFlags + [Flag];
 
     FParameters[A] := RttiParam;
   end;
@@ -1423,7 +1435,7 @@ end;
 
 function TRttiMethod.GetParameters: TRttiParameterArray;
 begin
-  if not Assigned(FParameters) then
+  if not FParametersLoaded then
     LoadParameters;
 
   Result := FParameters;
-- 
2.31.1.windows.1

Mattias Gaertner

2021-04-30 11:20

manager   ~0130673

Thanks!

Issue History

Date Modified Username Field Change
2021-04-29 16:31 henrique New Issue
2021-04-29 16:31 henrique File Added: 0001-Ajuste-na-carga-de-par-metros.patch
2021-04-29 18:50 Mattias Gaertner Assigned To => Mattias Gaertner
2021-04-29 18:50 Mattias Gaertner Status new => assigned
2021-04-30 11:20 Mattias Gaertner Status assigned => resolved
2021-04-30 11:20 Mattias Gaertner Resolution open => fixed
2021-04-30 11:20 Mattias Gaertner Fixed in Revision => 1175.
2021-04-30 11:20 Mattias Gaertner Note Added: 0130673