fpc/tests/webtbs/tw34509.pp
2018-12-26 22:59:48 +00:00

34 lines
494 B
ObjectPascal

{ %TARGET = win64 }
program tw34509;
{$MODE DELPHI}
uses
TypInfo,
RTTI;
type
TRec = record
S: string;
I: Integer;
end;
function Test(P: TRec): TRec;
begin
Result := P;
WriteLn('P: ', P.S, ' - ', P.I);
end;
var
V: TValue;
R1, R2: TRec;
begin
R1.S := 'abc';
R1.I := 123;
TValue.Make(@R1, TypeInfo(TRec), V);
R2 := TRec(Rtti.Invoke(@Test, [V], ccReg, TypeInfo(TRec), True, False).GetReferenceToRawData^);
WriteLn('R: ', R2.S, ' - ', R2.I);
//ReadLn;
end.