mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-09-14 13:29:28 +02:00
Fix for invoking the constructor of the class using the RTTI.
This commit is contained in:
parent
32a78bc897
commit
bc9da80549
@ -221,6 +221,8 @@ type
|
|||||||
function GetReturnType: TRttiType;
|
function GetReturnType: TRttiType;
|
||||||
|
|
||||||
procedure LoadParameters;
|
procedure LoadParameters;
|
||||||
|
protected
|
||||||
|
function GetName: String; override;
|
||||||
public
|
public
|
||||||
function GetParameters: TRttiParameterArray;
|
function GetParameters: TRttiParameterArray;
|
||||||
function Invoke(const Instance: TValue; const Args: array of TValue): TValue;
|
function Invoke(const Instance: TValue; const Args: array of TValue): TValue;
|
||||||
@ -1881,6 +1883,14 @@ begin
|
|||||||
Result := Pool.GetType(MethodTypeInfo.ProcSig.ResultType);
|
Result := Pool.GetType(MethodTypeInfo.ProcSig.ResultType);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TRttiMethod.GetName: String;
|
||||||
|
begin
|
||||||
|
Result := inherited;
|
||||||
|
|
||||||
|
if IsConstructor then
|
||||||
|
Result := Result.SubString(0, Result.IndexOf('$'));
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TRttiMethod.LoadParameters;
|
procedure TRttiMethod.LoadParameters;
|
||||||
const
|
const
|
||||||
FLAGS_CONVERSION: array[TParamFlag] of NativeInt = (1, 2, 4, 8, 16, 32);
|
FLAGS_CONVERSION: array[TParamFlag] of NativeInt = (1, 2, 4, 8, 16, 32);
|
||||||
@ -1937,7 +1947,7 @@ begin
|
|||||||
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)[Name]).apply(TJSObject(Instance.AsJSValue), AArgs);
|
ReturnValue := TJSFunction(TJSObject(Instance.AsJSValue)[MethodTypeInfo.Name]).apply(TJSObject(Instance.AsJSValue), AArgs);
|
||||||
|
|
||||||
if Assigned(ReturnType) then
|
if Assigned(ReturnType) then
|
||||||
TValue.Make(ReturnValue, ReturnType.Handle, Result)
|
TValue.Make(ReturnValue, ReturnType.Handle, Result)
|
||||||
|
Loading…
Reference in New Issue
Block a user