mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-16 19:19:04 +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;
|
||||
|
||||
procedure LoadParameters;
|
||||
protected
|
||||
function GetName: String; override;
|
||||
public
|
||||
function GetParameters: TRttiParameterArray;
|
||||
function Invoke(const Instance: TValue; const Args: array of TValue): TValue;
|
||||
@ -1881,6 +1883,14 @@ begin
|
||||
Result := Pool.GetType(MethodTypeInfo.ProcSig.ResultType);
|
||||
end;
|
||||
|
||||
function TRttiMethod.GetName: String;
|
||||
begin
|
||||
Result := inherited;
|
||||
|
||||
if IsConstructor then
|
||||
Result := Result.SubString(0, Result.IndexOf('$'));
|
||||
end;
|
||||
|
||||
procedure TRttiMethod.LoadParameters;
|
||||
const
|
||||
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
|
||||
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
|
||||
TValue.Make(ReturnValue, ReturnType.Handle, Result)
|
||||
|
Loading…
Reference in New Issue
Block a user