* directly pass the pointer to the result value; avoids an unnecessary copy operation

git-svn-id: trunk@41837 -
This commit is contained in:
svenbarth 2019-04-04 19:32:23 +00:00
parent 36255a700d
commit 04f681d7c6

View File

@ -405,7 +405,7 @@ var
argtypes: array of pffi_type; argtypes: array of pffi_type;
argvalues: array of Pointer; argvalues: array of Pointer;
rtype: pffi_type; rtype: pffi_type;
rvalue: ffi_arg; rvalue: Pointer;
i, arglen, argoffset, retidx, argstart: LongInt; i, arglen, argoffset, retidx, argstart: LongInt;
cif: ffi_cif; cif: ffi_cif;
retparam: Boolean; retparam: Boolean;
@ -482,17 +482,19 @@ begin
argtypes[retidx] := TypeInfoToFFIType(aResultType, []); argtypes[retidx] := TypeInfoToFFIType(aResultType, []);
argvalues[retidx] := ValueToFFIValue(aResultValue, aResultType^.Kind, [], True); argvalues[retidx] := ValueToFFIValue(aResultValue, aResultType^.Kind, [], True);
rtype := @ffi_type_void; rtype := @ffi_type_void;
rvalue := Nil;
end else begin end else begin
rtype := TypeInfoToFFIType(aResultType, []); rtype := TypeInfoToFFIType(aResultType, []);
if Assigned(aResultType) then
rvalue := aResultValue
else
rvalue := Nil;
end; end;
if ffi_prep_cif(@cif, abi, arglen, rtype, @argtypes[0]) <> FFI_OK then if ffi_prep_cif(@cif, abi, arglen, rtype, @argtypes[0]) <> FFI_OK then
raise EInvocationError.Create(SErrInvokeFailed); raise EInvocationError.Create(SErrInvokeFailed);
ffi_call(@cif, ffi_fn(aCodeAddress), @rvalue, @argvalues[0]); ffi_call(@cif, ffi_fn(aCodeAddress), rvalue, @argvalues[0]);
if Assigned(aResultType) and not retparam then
FFIValueToValue(@rvalue, aResultValue, aResultType);
end; end;
const const