mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-17 16:19:08 +02:00
Invoke in the RTTI Method.
This commit is contained in:
parent
b761a684e0
commit
09155a0b33
@ -39,7 +39,7 @@ type
|
|||||||
class function FromArray(TypeInfo: TTypeInfo; const Values: specialize TArray<TValue>): TValue; static;
|
class function FromArray(TypeInfo: TTypeInfo; const Values: specialize TArray<TValue>): TValue; static;
|
||||||
class function FromJSValue(v: JSValue): TValue; static;
|
class function FromJSValue(v: JSValue): TValue; static;
|
||||||
class function FromOrdinal(ATypeInfo: TTypeInfo; AValue: JSValue): TValue; static;
|
class function FromOrdinal(ATypeInfo: TTypeInfo; AValue: JSValue): TValue; static;
|
||||||
class procedure Make(ABuffer: JSValue; ATypeInfo: PTypeInfo; var Result: TValue); overload; static;
|
class procedure Make(const ABuffer: JSValue; const ATypeInfo: PTypeInfo; var Result: TValue); overload; static;
|
||||||
generic class procedure Make<T>(const Value: T; var Result: TValue); overload; static;
|
generic class procedure Make<T>(const Value: T; var Result: TValue); overload; static;
|
||||||
|
|
||||||
function AsBoolean: boolean;
|
function AsBoolean: boolean;
|
||||||
@ -207,6 +207,7 @@ type
|
|||||||
procedure LoadParameters;
|
procedure LoadParameters;
|
||||||
public
|
public
|
||||||
function GetParameters: TRttiParameterArray;
|
function GetParameters: TRttiParameterArray;
|
||||||
|
function Invoke(const Instance: TValue; const Args: array of TValue): TValue;
|
||||||
|
|
||||||
property IsAsyncCall: Boolean read GetIsAsyncCall;
|
property IsAsyncCall: Boolean read GetIsAsyncCall;
|
||||||
property IsClassMethod: Boolean read GetIsClassMethod;
|
property IsClassMethod: Boolean read GetIsClassMethod;
|
||||||
@ -246,6 +247,9 @@ type
|
|||||||
property Visibility: TMemberVisibility read GetVisibility;
|
property Visibility: TMemberVisibility read GetVisibility;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TRttiInstanceProperty = class(TRttiProperty)
|
||||||
|
end;
|
||||||
|
|
||||||
TRttiPropertyArray = specialize TArray<TRttiProperty>;
|
TRttiPropertyArray = specialize TArray<TRttiProperty>;
|
||||||
|
|
||||||
{ TRttiType }
|
{ TRttiType }
|
||||||
@ -627,7 +631,7 @@ begin
|
|||||||
Make(Value, System.TypeInfo(T), Result);
|
Make(Value, System.TypeInfo(T), Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TValue.Make(ABuffer: JSValue; ATypeInfo: PTypeInfo; var Result: TValue);
|
class procedure TValue.Make(const ABuffer: JSValue; const ATypeInfo: PTypeInfo; var Result: TValue);
|
||||||
begin
|
begin
|
||||||
Result.FData := ABuffer;
|
Result.FData := ABuffer;
|
||||||
Result.FTypeInfo := ATypeInfo;
|
Result.FTypeInfo := ATypeInfo;
|
||||||
@ -1731,6 +1735,26 @@ begin
|
|||||||
Result := FParameters;
|
Result := FParameters;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TRttiMethod.Invoke(const Instance: TValue; const Args: array of TValue): TValue;
|
||||||
|
var
|
||||||
|
A: Integer;
|
||||||
|
|
||||||
|
ReturnHandle: PTypeInfo;
|
||||||
|
|
||||||
|
AArgs: TJSValueDynArray;
|
||||||
|
|
||||||
|
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.FData := TJSFunction(TJSObject(Instance.AsJSValue)[Name]).apply(TJSObject(Instance.AsJSValue), AArgs);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TRttiProperty }
|
{ TRttiProperty }
|
||||||
|
|
||||||
constructor TRttiProperty.Create(AParent: TRttiType; ATypeInfo: TTypeMember);
|
constructor TRttiProperty.Create(AParent: TRttiType; ATypeInfo: TTypeMember);
|
||||||
|
Loading…
Reference in New Issue
Block a user