mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-03 04:49:42 +01:00
* passing by value of variants with stdcall conventions, resolves #10042
git-svn-id: trunk@11498 -
This commit is contained in:
parent
1fa70f7a0a
commit
a34529f50f
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -8307,6 +8307,7 @@ tests/webtbs/tw10002.pp svneol=native#text/plain
|
||||
tests/webtbs/tw10009.pp svneol=native#text/plain
|
||||
tests/webtbs/tw10013.pp svneol=native#text/plain
|
||||
tests/webtbs/tw10033.pp svneol=native#text/plain
|
||||
tests/webtbs/tw10042.pp svneol=native#text/plain
|
||||
tests/webtbs/tw10072.pp svneol=native#text/plain
|
||||
tests/webtbs/tw10203.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1021.pp svneol=native#text/plain
|
||||
|
||||
@ -1150,8 +1150,11 @@ implementation
|
||||
vs_value :
|
||||
if needs_inittable then
|
||||
begin
|
||||
{ variants are already handled by the call to fpc_variant_copy_overwrite }
|
||||
if tparavarsym(p).vardef.typ <> variantdef then begin
|
||||
{ variants are already handled by the call to fpc_variant_copy_overwrite if
|
||||
they are passed by reference }
|
||||
if not((tparavarsym(p).vardef.typ=variantdef) and
|
||||
paramanager.push_addr_param(tparavarsym(p).varspez,tparavarsym(p).vardef,current_procinfo.procdef.proccalloption)) then
|
||||
begin
|
||||
location_get_data_ref(list,tparavarsym(p).initialloc,href,is_open_array(tparavarsym(p).vardef));
|
||||
cg.g_incrrefcount(list,tparavarsym(p).vardef,href);
|
||||
end;
|
||||
|
||||
56
tests/webtbs/tw10042.pp
Normal file
56
tests/webtbs/tw10042.pp
Normal file
@ -0,0 +1,56 @@
|
||||
{$mode objfpc}
|
||||
{$H+}
|
||||
// Run with paramters "1 2 3 4 5"
|
||||
|
||||
{$MACRO ON}
|
||||
{ $DEFINE stdcall:=register}
|
||||
|
||||
Uses
|
||||
SysUtils,
|
||||
Variants;
|
||||
|
||||
Type
|
||||
TMyClass = Class
|
||||
Function GetProperty(Dum: Variant): Variant; stdcall;
|
||||
End;
|
||||
|
||||
Var
|
||||
FUser: TMyClass;
|
||||
FI: Longint;
|
||||
Parameters: Array Of String;
|
||||
|
||||
Function TMyClass.GetProperty(Dum: Variant): Variant; stdcall;
|
||||
Begin
|
||||
Result := '';
|
||||
End;
|
||||
|
||||
procedure Display;
|
||||
var
|
||||
FI: longint;
|
||||
begin
|
||||
// Output content of the parameters buffer
|
||||
For FI := 0 to Length(Parameters) - 1 Do Write(Parameters[FI] + ' ');
|
||||
Writeln;
|
||||
end;
|
||||
|
||||
Begin
|
||||
// Create class instance
|
||||
FUser := TMyClass.Create;
|
||||
|
||||
// Fetch params to parameters structure
|
||||
SetLength(Parameters, System.ParamCount + 1);
|
||||
For FI := 0 to Length(Parameters) - 1 Do Parameters[FI] := System.ParamStr(FI);
|
||||
|
||||
// Display parameters
|
||||
Display;
|
||||
|
||||
// Process params
|
||||
For FI := 0 To Length(Parameters) - 1 do
|
||||
Begin
|
||||
// Get property
|
||||
FUser.GetProperty(Parameters[FI]);
|
||||
|
||||
// Display parameters
|
||||
Display;
|
||||
End;
|
||||
End.
|
||||
Loading…
Reference in New Issue
Block a user