remobjects / pascalscript

pascalscript
Other
447 stars 178 forks source link

Variant as Parametr in x64 #240

Open Varera opened 3 years ago

Varera commented 3 years ago

This code works fine in 32-bit mode, but in x64 the var2str_func function passes the parameter Unassigned. A rule parameter is passed to var2str

procedure TForm26.btn1Click(Sender: TObject); var PSS: TPSScript; begin PSS := TPSScript.Create(nil); try PSS.OnCompile := PSSCompile; PSS.Script.Text := 'begin var2str(12); var2str_func(13); end.'; if PSS.Compile then PSS.Execute; finally FreeAndNil(PSS); end; end;

function TForm26.var2str(AValue: Variant): string; begin Result := AValue; end;

function var2str_func(const AValue: Variant): string; begin Result := AValue; end;

procedure TForm26.PSSCompile(Sender: TPSScript); begin Sender.AddFunction(@var2str_func, 'function var2str_func(const AValue: Variant): string;'); Sender.AddMethod(Self, @TForm26.var2str, 'function var2str(AValue: Variant): string;'); end;