Browse Source

* fix tests now that the RTTI of method pointer variables also contains the hidden parameters

git-svn-id: trunk@39901 -
svenbarth 6 years ago
parent
commit
2f6b15b1e2
2 changed files with 34 additions and 18 deletions
  1. 31 17
      tests/webtbs/tw12038.pp
  2. 3 1
      tests/webtbs/tw2886.pp

+ 31 - 17
tests/webtbs/tw12038.pp

@@ -123,12 +123,18 @@ Function BuildMethodDefinition(Liste: ParametersMethod1;NumI :Integer):String;
 //Build the definition of  method
 //Build the definition of  method
 var
 var
   Definition: String;
   Definition: String;
-  i: integer;
+  i, v: integer;
 begin
 begin
  Result:='';
  Result:='';
  Definition := '(';
  Definition := '(';
+ v := 0;
  For i:= 1 to NumI do
  For i:= 1 to NumI do
  begin
  begin
+  if pfHidden in Liste.AMat[I].Flags
+   then Continue;
+  Inc(v);
+  if v>0
+   then Definition := Definition + '; ';
   if pfVar in Liste.AMat[I].Flags
   if pfVar in Liste.AMat[I].Flags
    then Definition := Definition+('var ');
    then Definition := Definition+('var ');
   if pfconst in Liste.AMat[I].Flags
   if pfconst in Liste.AMat[I].Flags
@@ -143,8 +149,8 @@ begin
    then Definition := Definition+('out ');
    then Definition := Definition+('out ');
 
 
   Definition := Format('%s%s: %s', [Definition, Liste.AMat[I].ParamName, Liste.AMat[I].TypeName]);
   Definition := Format('%s%s: %s', [Definition, Liste.AMat[I].ParamName, Liste.AMat[I].TypeName]);
-  If I<NumI
-   then Definition := Definition + '; '
+  {If I<NumI
+   then Definition := Definition + '; '}
  end;
  end;
   Definition := Definition + ')';
   Definition := Definition + ')';
 
 
@@ -200,7 +206,7 @@ var
  OrdinalValue,
  OrdinalValue,
    CurrentParamPosition,
    CurrentParamPosition,
    ParamNameLength,
    ParamNameLength,
-   i, j         : integer;
+   i, j, v      : integer;
    ParamName,
    ParamName,
    TypeName     : string;
    TypeName     : string;
    TypeData     : PTypeData;
    TypeData     : PTypeData;
@@ -272,6 +278,7 @@ begin
         Definition:='(';
         Definition:='(';
 //              Definition := Definition+'(';
 //              Definition := Definition+'(';
         CurrentParamPosition := 0;
         CurrentParamPosition := 0;
+        v := 0;
         for i:= 1 to DTypeData^.ParamCount do
         for i:= 1 to DTypeData^.ParamCount do
           begin
           begin
             { First Handle the ParamFlag }
             { First Handle the ParamFlag }
@@ -280,18 +287,23 @@ begin
            writeln('ord(Flags):',ord(DTypeData^.ParamList[CurrentParamPosition]));
            writeln('ord(Flags):',ord(DTypeData^.ParamList[CurrentParamPosition]));
 //         For i:= 1 to NumI do
 //         For i:= 1 to NumI do
 //         begin
 //         begin
-            if pfVar in Flags
-             then Definition := Definition+('var ');
-            if pfconst in Flags
-             then Definition := Definition+('const ');
-            if pfArray in Flags
-             then Definition := Definition+('array of ');
-            if pfAddress in Flags
-             then Definition := Definition+('adresse ?'); // si Self ?
-            if pfReference in Flags
-             then Definition := Definition+('reference ?'); // ??
-            if pfout in Flags
-             then Definition := Definition+('out ');
+            if not (pfHidden in Flags) then
+              begin
+                If v>0 then Definition := Definition + '; ';
+                if pfVar in Flags
+                 then Definition := Definition+('var ');
+                if pfconst in Flags
+                 then Definition := Definition+('const ');
+                if pfArray in Flags
+                 then Definition := Definition+('array of ');
+                if pfAddress in Flags
+                 then Definition := Definition+('adresse ?'); // si Self ?
+                if pfReference in Flags
+                 then Definition := Definition+('reference ?'); // ??
+                if pfout in Flags
+                 then Definition := Definition+('out ');
+                Inc(v);
+              end;
            
            
            { Next char is the length of the ParamName}
            { Next char is the length of the ParamName}
            inc(CurrentParamPosition,SizeOf(TParamFlags));
            inc(CurrentParamPosition,SizeOf(TParamFlags));
@@ -312,8 +324,10 @@ begin
                                    ParamNameLength + 1;
                                    ParamNameLength + 1;
            writeln('ParamName:',i,':', ParamName);
            writeln('ParamName:',i,':', ParamName);
            writeln('TypeName:',i,':', TypeName);
            writeln('TypeName:',i,':', TypeName);
+           if pfHidden in Flags then
+             Continue;
            Definition := Format('%s%s: %s', [Definition, ParamName, TypeName]);
            Definition := Format('%s%s: %s', [Definition, ParamName, TypeName]);
-           If I<DTypeData^.ParamCount  then Definition := Definition + '; '
+           //If I<DTypeData^.ParamCount  then Definition := Definition + '; '
          end;
          end;
         if DTypeData^.MethodKind = mkFunction then
         if DTypeData^.MethodKind = mkFunction then
           begin
           begin

+ 3 - 1
tests/webtbs/tw2886.pp

@@ -60,7 +60,9 @@ begin
     inc(Offset,Len+1);
     inc(Offset,Len+1);
 
 
     writeln('Param ',i+1,'/',ParamCount,' ',CurParamName,':',CurTypeIdentifier);
     writeln('Param ',i+1,'/',ParamCount,' ',CurParamName,':',CurTypeIdentifier);
-    if (CurParamName<>'Sender')  or (CurTypeIdentifier<>'TObject') then
+    // Note by SB (2019-10-08): The first parameter is now the hidden $self
+    if (CurParamName<>'$self')  or (CurTypeIdentifier<>'Pointer') then
+    //if (CurParamName<>'Sender')  or (CurTypeIdentifier<>'TObject') then
       begin
       begin
         writeln('ERROR!');
         writeln('ERROR!');
         halt(1);
         halt(1);