|
@@ -399,6 +399,7 @@ type
|
|
TRttiMethod = class(TRttiMember)
|
|
TRttiMethod = class(TRttiMember)
|
|
private
|
|
private
|
|
FString: String;
|
|
FString: String;
|
|
|
|
+ function GetFlags: TFunctionCallFlags;
|
|
protected
|
|
protected
|
|
function GetCallingConvention: TCallConv; virtual; abstract;
|
|
function GetCallingConvention: TCallConv; virtual; abstract;
|
|
function GetCodeAddress: CodePointer; virtual; abstract;
|
|
function GetCodeAddress: CodePointer; virtual; abstract;
|
|
@@ -429,6 +430,9 @@ type
|
|
function Invoke(aInstance: TObject; const aArgs: array of TValue): TValue;
|
|
function Invoke(aInstance: TObject; const aArgs: array of TValue): TValue;
|
|
function Invoke(aInstance: TClass; const aArgs: array of TValue): TValue;
|
|
function Invoke(aInstance: TClass; const aArgs: array of TValue): TValue;
|
|
function Invoke(aInstance: TValue; const aArgs: array of TValue): TValue;
|
|
function Invoke(aInstance: TValue; const aArgs: array of TValue): TValue;
|
|
|
|
+ { Note: once "reference to" is supported these will be replaced by a single method }
|
|
|
|
+ function CreateImplementation(aUserData: Pointer; aCallback: TMethodImplementationCallbackMethod): TMethodImplementation;
|
|
|
|
+ function CreateImplementation(aUserData: Pointer; aCallback: TMethodImplementationCallbackProc): TMethodImplementation;
|
|
end;
|
|
end;
|
|
|
|
|
|
TRttiStructuredType = class(TRttiType)
|
|
TRttiStructuredType = class(TRttiType)
|
|
@@ -2610,6 +2614,13 @@ begin
|
|
Result := False;
|
|
Result := False;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TRttiMethod.GetFlags: TFunctionCallFlags;
|
|
|
|
+begin
|
|
|
|
+ Result := [];
|
|
|
|
+ if IsStatic then
|
|
|
|
+ Include(Result, fcfStatic);
|
|
|
|
+end;
|
|
|
|
+
|
|
function TRttiMethod.GetParameters: specialize TArray<TRttiParameter>;
|
|
function TRttiMethod.GetParameters: specialize TArray<TRttiParameter>;
|
|
begin
|
|
begin
|
|
Result := GetParameters(False);
|
|
Result := GetParameters(False);
|
|
@@ -2714,6 +2725,76 @@ begin
|
|
Result := Rtti.Invoke(Name, addr, CallingConvention, IsStatic, aInstance, aArgs, GetParameters(True), ReturnType);
|
|
Result := Rtti.Invoke(Name, addr, CallingConvention, IsStatic, aInstance, aArgs, GetParameters(True), ReturnType);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TRttiMethod.CreateImplementation(aUserData: Pointer; aCallback: TMethodImplementationCallbackMethod): TMethodImplementation;
|
|
|
|
+var
|
|
|
|
+ params: specialize TArray<TRttiParameter>;
|
|
|
|
+ args: specialize TArray<TFunctionCallParameterInfo>;
|
|
|
|
+ res: PTypeInfo;
|
|
|
|
+ restype: TRttiType;
|
|
|
|
+ resinparam: Boolean;
|
|
|
|
+ i: SizeInt;
|
|
|
|
+begin
|
|
|
|
+ if not Assigned(aCallback) then
|
|
|
|
+ raise EArgumentNilException.Create(SErrMethodImplNoCallback);
|
|
|
|
+
|
|
|
|
+ resinparam := False;
|
|
|
|
+ params := GetParameters(True);
|
|
|
|
+ SetLength(args, Length(params));
|
|
|
|
+ for i := 0 to High(params) do begin
|
|
|
|
+ if Assigned(params[i].ParamType) then
|
|
|
|
+ args[i].ParamType := params[i].ParamType.FTypeInfo
|
|
|
|
+ else
|
|
|
|
+ args[i].ParamType := Nil;
|
|
|
|
+ args[i].ParamFlags := params[i].Flags;
|
|
|
|
+ args[i].ParaLocs := Nil;
|
|
|
|
+ if pfResult in params[i].Flags then
|
|
|
|
+ resinparam := True;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ restype := GetReturnType;
|
|
|
|
+ if Assigned(restype) and not resinparam then
|
|
|
|
+ res := restype.FTypeInfo
|
|
|
|
+ else
|
|
|
|
+ res := Nil;
|
|
|
|
+
|
|
|
|
+ Result := TMethodImplementation.Create(GetCallingConvention, args, res, GetFlags, aUserData, aCallback);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TRttiMethod.CreateImplementation(aUserData: Pointer; aCallback: TMethodImplementationCallbackProc): TMethodImplementation;
|
|
|
|
+var
|
|
|
|
+ params: specialize TArray<TRttiParameter>;
|
|
|
|
+ args: specialize TArray<TFunctionCallParameterInfo>;
|
|
|
|
+ res: PTypeInfo;
|
|
|
|
+ restype: TRttiType;
|
|
|
|
+ resinparam: Boolean;
|
|
|
|
+ i: SizeInt;
|
|
|
|
+begin
|
|
|
|
+ if not Assigned(aCallback) then
|
|
|
|
+ raise EArgumentNilException.Create(SErrMethodImplNoCallback);
|
|
|
|
+
|
|
|
|
+ resinparam := False;
|
|
|
|
+ params := GetParameters(True);
|
|
|
|
+ SetLength(args, Length(params));
|
|
|
|
+ for i := 0 to High(params) do begin
|
|
|
|
+ if Assigned(params[i].ParamType) then
|
|
|
|
+ args[i].ParamType := params[i].ParamType.FTypeInfo
|
|
|
|
+ else
|
|
|
|
+ args[i].ParamType := Nil;
|
|
|
|
+ args[i].ParamFlags := params[i].Flags;
|
|
|
|
+ args[i].ParaLocs := Nil;
|
|
|
|
+ if pfResult in params[i].Flags then
|
|
|
|
+ resinparam := True;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ restype := GetReturnType;
|
|
|
|
+ if Assigned(restype) and not resinparam then
|
|
|
|
+ res := restype.FTypeInfo
|
|
|
|
+ else
|
|
|
|
+ res := Nil;
|
|
|
|
+
|
|
|
|
+ Result := TMethodImplementation.Create(GetCallingConvention, args, res, GetFlags, aUserData, aCallback);
|
|
|
|
+end;
|
|
|
|
+
|
|
{ TRttiInvokableType }
|
|
{ TRttiInvokableType }
|
|
|
|
|
|
function TRttiInvokableType.GetParameters: specialize TArray<TRttiParameter>;
|
|
function TRttiInvokableType.GetParameters: specialize TArray<TRttiParameter>;
|