mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 10:45:08 +02:00
* directly pass the pointer to the result value; avoids an unnecessary copy operation
git-svn-id: trunk@41837 -
This commit is contained in:
parent
36255a700d
commit
04f681d7c6
@ -405,7 +405,7 @@ var
|
||||
argtypes: array of pffi_type;
|
||||
argvalues: array of Pointer;
|
||||
rtype: pffi_type;
|
||||
rvalue: ffi_arg;
|
||||
rvalue: Pointer;
|
||||
i, arglen, argoffset, retidx, argstart: LongInt;
|
||||
cif: ffi_cif;
|
||||
retparam: Boolean;
|
||||
@ -482,17 +482,19 @@ begin
|
||||
argtypes[retidx] := TypeInfoToFFIType(aResultType, []);
|
||||
argvalues[retidx] := ValueToFFIValue(aResultValue, aResultType^.Kind, [], True);
|
||||
rtype := @ffi_type_void;
|
||||
rvalue := Nil;
|
||||
end else begin
|
||||
rtype := TypeInfoToFFIType(aResultType, []);
|
||||
if Assigned(aResultType) then
|
||||
rvalue := aResultValue
|
||||
else
|
||||
rvalue := Nil;
|
||||
end;
|
||||
|
||||
if ffi_prep_cif(@cif, abi, arglen, rtype, @argtypes[0]) <> FFI_OK then
|
||||
raise EInvocationError.Create(SErrInvokeFailed);
|
||||
|
||||
ffi_call(@cif, ffi_fn(aCodeAddress), @rvalue, @argvalues[0]);
|
||||
|
||||
if Assigned(aResultType) and not retparam then
|
||||
FFIValueToValue(@rvalue, aResultValue, aResultType);
|
||||
ffi_call(@cif, ffi_fn(aCodeAddress), rvalue, @argvalues[0]);
|
||||
end;
|
||||
|
||||
const
|
||||
|
Loading…
Reference in New Issue
Block a user