diff options
author | svenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2018-10-07 12:25:21 +0000 |
---|---|---|
committer | svenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2018-10-07 12:25:21 +0000 |
commit | b60e97ed037c65caaf891f2c2f3aa8e1e28a36f7 (patch) | |
tree | 7a773fd07e855f2f8017249a98db7dbc2626cd85 /packages/rtl-objpas | |
parent | cec9a08352af6059a982f05449527709cabd06a8 (diff) | |
download | fpc-b60e97ed037c65caaf891f2c2f3aa8e1e28a36f7.tar.gz |
* adjust Invoke API of FunctionCallManager to not rely on TValue
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@39881 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/rtl-objpas')
-rw-r--r-- | packages/rtl-objpas/src/inc/rtti.pp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/packages/rtl-objpas/src/inc/rtti.pp b/packages/rtl-objpas/src/inc/rtti.pp index 163a38d0be..c4e9bd1eaa 100644 --- a/packages/rtl-objpas/src/inc/rtti.pp +++ b/packages/rtl-objpas/src/inc/rtti.pp @@ -381,11 +381,16 @@ type EInvocationError = class(Exception); ENonPublicType = class(Exception); - TFunctionCallParameter = record - Value: TValue; + TFunctionCallParameterInfo = record + ParamType: PTypeInfo; ParamFlags: TParamFlags; ParaLocs: PParameterLocations; end; + + TFunctionCallParameter = record + ValueRef: Pointer; + Info: TFunctionCallParameterInfo; + end; TFunctionCallParameterArray = specialize TArray<TFunctionCallParameter>; TFunctionCallFlag = ( @@ -400,7 +405,7 @@ type TFunctionCallManager = record Invoke: procedure(CodeAddress: CodePointer; const Args: TFunctionCallParameterArray; CallingConvention: TCallConv; - ResultType: PTypeInfo; out ResultValue: TValue; Flags: TFunctionCallFlags); + ResultType: PTypeInfo; ResultValue: Pointer; Flags: TFunctionCallFlags); CreateCallbackProc: function(aHandler: TFunctionCallProc; aCallConv: TCallConv; aArgs: array of PTypeInfo; aResultType: PTypeInfo; aFlags: TFunctionCallFlags; aContext: Pointer): TFunctionCallCallback; CreateCallbackMethod: function(aHandler: TFunctionCallMethod; aCallConv: TCallConv; aArgs: array of PTypeInfo; aResultType: PTypeInfo; aFlags: TFunctionCallFlags; aContext: Pointer): TFunctionCallCallback; FreeCallback: procedure(aCallback: TFunctionCallCallback; aCallConv: TCallConv); @@ -433,6 +438,7 @@ function IsManaged(TypeInfo: PTypeInfo): boolean; { these resource strings are needed by units implementing function call managers } resourcestring SErrInvokeNotImplemented = 'Invoke functionality is not implemented'; + SErrInvokeResultTypeNoValue = 'Function has a result type, but no result pointer provided'; SErrInvokeFailed = 'Invoke call failed'; SErrCallbackNotImplented = 'Callback functionality is not implemented'; SErrCallConvNotSupported = 'Calling convention not supported: %s'; @@ -573,7 +579,7 @@ var FuncCallMgr: TFunctionCallManagerArray; procedure NoInvoke(aCodeAddress: CodePointer; const aArgs: TFunctionCallParameterArray; aCallConv: TCallConv; - aResultType: PTypeInfo; out aResultValue: TValue; aFlags: TFunctionCallFlags); + aResultType: PTypeInfo; aResultValue: Pointer; aFlags: TFunctionCallFlags); begin raise ENotImplemented.Create(SErrInvokeNotImplemented); end; @@ -722,12 +728,18 @@ begin SetLength(funcargs, Length(aArgs)); for i := Low(aArgs) to High(aArgs) do begin - funcargs[i - Low(aArgs) + Low(funcargs)].Value := aArgs[i]; - funcargs[i - Low(aArgs) + Low(funcargs)].ParamFlags := []; - funcargs[i - Low(aArgs) + Low(funcargs)].ParaLocs := Nil; + funcargs[i - Low(aArgs) + Low(funcargs)].ValueRef := aArgs[i].GetReferenceToRawData; + funcargs[i - Low(aArgs) + Low(funcargs)].Info.ParamType := aArgs[i].TypeInfo; + funcargs[i - Low(aArgs) + Low(funcargs)].Info.ParamFlags := []; + funcargs[i - Low(aArgs) + Low(funcargs)].Info.ParaLocs := Nil; end; - FuncCallMgr[aCallConv].Invoke(aCodeAddress, funcargs, aCallConv, aResultType, Result, flags); + if Assigned(aResultType) then + TValue.Make(Nil, aResultType, Result) + else + Result := TValue.Empty; + + FuncCallMgr[aCallConv].Invoke(aCodeAddress, funcargs, aCallConv, aResultType, Result.GetReferenceToRawData, flags); end; function CreateCallbackProc(aHandler: TFunctionCallProc; aCallConv: TCallConv; aArgs: array of PTypeInfo; aResultType: PTypeInfo; aFlags: TFunctionCallFlags; aContext: Pointer): TFunctionCallCallback; |