* fix : correctly access the list of parameters of the extended method table

+ added test
This commit is contained in:
Sven/Sarah Barth 2024-01-15 23:13:39 +01:00
parent b81f92536d
commit 21ffa221e6
2 changed files with 75 additions and 1 deletions
rtl/objpas
tests/webtbs

View File

@ -4622,7 +4622,7 @@ begin
if Index >= ParamCount then
Result := Nil
else
Result := PVmtMethodParamArray(@params)[Index];
Result := PVmtMethodParam(@params) + Index;
end;
function TVMTMethodExEntry.GetResultLocs: PParameterLocations;

74
tests/webtbs/tw40595.pp Normal file
View File

@ -0,0 +1,74 @@
Program tw40595;
{$mode OBJFPC}{$H+}{$M+}
{$Modeswitch advancedrecords}
{$RTTI EXPLICIT PROPERTIES([vcPrivate,vcProtected,vcPublic,vcPublished])}
{$RTTI EXPLICIT FIELDS([vcPrivate,vcProtected,vcPublic,vcPublished])}
{$RTTI EXPLICIT METHODS([vcPrivate,vcProtected,vcPublic,vcPublished])}
Uses
SysUtils,
TypInfo;
Type
{ TUser }
TUser = Class
Private
FName: string;
FID: Integer;
Public
Procedure PrintID;
Constructor Create;
Procedure PrintName;
Published
Property ID: Integer read FID write FID;
Property Name: string read FName write FName;
End;
{ TUser }
Constructor TUser.Create;
Begin
FName := 'TUser.Name: ' + WChar($20A1) + ' ' + WChar($2211);
End;
Procedure TUser.PrintID;
Begin
WriteLn('User ID : ', ID);
End;
Procedure TUser.PrintName;
Begin
WriteLn('User Name : ', Name);
End;
const
MethodNames: array of String = (
'PrintID',
'Create',
'PrintName'
);
Var
I: Integer;
Count: LongInt;
Method: PVmtMethodExEntry;
Methods: PExtendedMethodInfoTable;
Begin
Count := GetMethodList(TUser, Methods, []);
If Methods <> nil Then
Begin
if Count <> Length(MethodNames) then
Halt(2);
For I := 0 To Pred(Count) Do
Begin
Method := Methods^[I];
if Method^.Name <> MethodNames[i] then
Halt(3 + i);
WriteLn(Format('%-10s - %d', [Method^.Name, Method^.Kind]));
End;
Freemem(Methods);
End else
Halt(1);
End.