mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-04-07 08:47:49 +02:00
Fix in invoke to the constructor of the class to return the created instance.
This commit is contained in:
parent
6940c94333
commit
210ae9b76d
@ -1916,39 +1916,39 @@ end;
|
||||
function TRttiMethod.Invoke(const Instance: TValue; const Args: array of TValue): TValue;
|
||||
var
|
||||
A: Integer;
|
||||
|
||||
AArgs: TJSValueDynArray;
|
||||
ReturnValue: JSValue;
|
||||
|
||||
begin
|
||||
if Assigned(ReturnType) then
|
||||
Result.FTypeInfo := ReturnType.Handle;
|
||||
|
||||
SetLength(AArgs, Length(Args));
|
||||
|
||||
for A := Low(Args) to High(Args) do
|
||||
AArgs[A] := Args[A].AsJSValue;
|
||||
|
||||
Result.SetData(TJSFunction(TJSObject(Instance.AsJSValue)[Name]).apply(TJSObject(Instance.AsJSValue), AArgs));
|
||||
ReturnValue := TJSFunction(TJSObject(Instance.AsJSValue)[Name]).apply(TJSObject(Instance.AsJSValue), AArgs);
|
||||
|
||||
if Assigned(ReturnType) then
|
||||
TValue.Make(ReturnValue, ReturnType.Handle, Result)
|
||||
else if IsConstructor then
|
||||
TValue.Make(ReturnValue, Instance.TypeInfo, Result)
|
||||
end;
|
||||
|
||||
function TRttiMethod.Invoke(const Instance: TObject; const Args: array of TValue): TValue;
|
||||
|
||||
var
|
||||
v : TValue;
|
||||
v: TValue;
|
||||
|
||||
begin
|
||||
TValue.make(Instance,Instance.ClassInfo,v);
|
||||
Result:=Invoke(v,Args);
|
||||
TValue.Make(Instance, Instance.ClassInfo, v);
|
||||
Result := Invoke(v, Args);
|
||||
end;
|
||||
|
||||
function TRttiMethod.Invoke(const aClass: TClass; const Args: array of TValue
|
||||
): TValue;
|
||||
function TRttiMethod.Invoke(const aClass: TClass; const Args: array of TValue): TValue;
|
||||
var
|
||||
v : TValue;
|
||||
v: TValue;
|
||||
|
||||
begin
|
||||
TValue.make(aClass,aClass.ClassInfo,v);
|
||||
Result:=Invoke(V,Args);
|
||||
TValue.Make(aClass, aClass.ClassInfo, v);
|
||||
Result := Invoke(V, Args);
|
||||
end;
|
||||
|
||||
{ TRttiProperty }
|
||||
|
Loading…
Reference in New Issue
Block a user