mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 00:48:10 +02:00
* fix #40595: correctly access the list of parameters of the extended method table
+ added test
This commit is contained in:
parent
b81f92536d
commit
21ffa221e6
@ -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
74
tests/webtbs/tw40595.pp
Normal 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.
|
||||
|
Loading…
Reference in New Issue
Block a user