Invoke function calling the correct construction function.

This commit is contained in:
Henrique Gottardi Werlang 2025-03-15 09:09:09 -03:00
parent 86083aa850
commit 516be722e2

View File

@ -2228,7 +2228,7 @@ end;
function TRttiMethod.GetProcedureSignature: TRttiProcedureSignature; function TRttiMethod.GetProcedureSignature: TRttiProcedureSignature;
begin begin
if not Assigned(FProcedureSignature) then if not Assigned(FProcedureSignature) then
FProcedureSignature := TRttiProcedureSignature.Create; FProcedureSignature := TRttiProcedureSignature.Create(MethodTypeInfo.ProcSig);
Result := FProcedureSignature; Result := FProcedureSignature;
end; end;
@ -2242,15 +2242,30 @@ function TRttiMethod.Invoke(const Instance: TValue; const Args: array of TValue)
var var
A: Integer; A: Integer;
AArgs: TJSValueDynArray; AArgs: TJSValueDynArray;
Func: TJSFunction;
InstanceObject: TJSObject;
ReturnValue: JSValue; ReturnValue: JSValue;
begin begin
InstanceObject := TJSObject(Instance.AsJSValue);
SetLength(AArgs, Length(Args)); SetLength(AArgs, Length(Args));
for A := Low(Args) to High(Args) do for A := Low(Args) to High(Args) do
AArgs[A] := Args[A].AsJSValue; AArgs[A] := Args[A].AsJSValue;
ReturnValue := TJSFunction(TJSObject(Instance.AsJSValue)[MethodTypeInfo.Name]).apply(TJSObject(Instance.AsJSValue), AArgs); if IsConstructor then
begin
Func := TJSFunction(InstanceObject['$create']);
ReturnValue := Func.apply(InstanceObject, [MethodTypeInfo.Name, AArgs]);
end
else
begin
Func := TJSFunction(InstanceObject[MethodTypeInfo.Name]);
ReturnValue := Func.apply(InstanceObject, AArgs);
end;
if Assigned(ReturnType) then if Assigned(ReturnType) then
TValue.Make(ReturnValue, ReturnType.Handle, Result) TValue.Make(ReturnValue, ReturnType.Handle, Result)