mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-04-08 08:07:49 +02:00
Invoke function calling the correct construction function.
This commit is contained in:
parent
86083aa850
commit
516be722e2
@ -2228,7 +2228,7 @@ end;
|
||||
function TRttiMethod.GetProcedureSignature: TRttiProcedureSignature;
|
||||
begin
|
||||
if not Assigned(FProcedureSignature) then
|
||||
FProcedureSignature := TRttiProcedureSignature.Create;
|
||||
FProcedureSignature := TRttiProcedureSignature.Create(MethodTypeInfo.ProcSig);
|
||||
|
||||
Result := FProcedureSignature;
|
||||
end;
|
||||
@ -2242,15 +2242,30 @@ function TRttiMethod.Invoke(const Instance: TValue; const Args: array of TValue)
|
||||
var
|
||||
A: Integer;
|
||||
AArgs: TJSValueDynArray;
|
||||
Func: TJSFunction;
|
||||
InstanceObject: TJSObject;
|
||||
ReturnValue: JSValue;
|
||||
|
||||
begin
|
||||
InstanceObject := TJSObject(Instance.AsJSValue);
|
||||
|
||||
SetLength(AArgs, Length(Args));
|
||||
|
||||
for A := Low(Args) to High(Args) do
|
||||
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
|
||||
TValue.Make(ReturnValue, ReturnType.Handle, Result)
|
||||
|
Loading…
Reference in New Issue
Block a user