mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-26 14:50:16 +02:00
Merge branch 'master' of gitlab.com:freepascal.org/fpc/pas2js
This commit is contained in:
commit
8a2a2006c0
@ -39,8 +39,8 @@ 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 function Make(TypeInfo: TTypeInfo; const Value: JSValue): TValue; static;
|
class procedure Make(ABuffer: JSValue; ATypeInfo: PTypeInfo; var Result: TValue); overload; static;
|
||||||
class function Make(const Value: TValue): TValue; static;
|
generic class procedure Make<T>(const Value: T; var Result: TValue); overload; static;
|
||||||
|
|
||||||
function AsBoolean: boolean;
|
function AsBoolean: boolean;
|
||||||
function AsClass: TClass;
|
function AsClass: TClass;
|
||||||
@ -590,18 +590,18 @@ end;
|
|||||||
|
|
||||||
generic class function TValue.From<T>(const Value: T): TValue;
|
generic class function TValue.From<T>(const Value: T): TValue;
|
||||||
begin
|
begin
|
||||||
Result := Make(System.TypeInfo(T), Value);
|
Make(Value, System.TypeInfo(T), Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TValue.Make(TypeInfo: TTypeInfo; const Value: JSValue): TValue;
|
class procedure TValue.Make(ABuffer: JSValue; ATypeInfo: PTypeInfo; var Result: TValue);
|
||||||
begin
|
begin
|
||||||
Result.FData := Value;
|
Result.FData := ABuffer;
|
||||||
Result.FTypeInfo := TypeInfo;
|
Result.FTypeInfo := ATypeInfo;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TValue.Make(const Value: TValue): TValue;
|
generic class procedure TValue.Make<T>(const Value: T; var Result: TValue);
|
||||||
begin
|
begin
|
||||||
Result := TValue.Make(Value.TypeInfo, Value.AsJSValue);
|
TValue.Make(Value, System.TypeInfo(T), Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TValue.Cast(ATypeInfo: TTypeInfo; const EmptyAsAnyType: Boolean): TValue;
|
function TValue.Cast(ATypeInfo: TTypeInfo; const EmptyAsAnyType: Boolean): TValue;
|
||||||
@ -666,7 +666,7 @@ begin
|
|||||||
|
|
||||||
if ATypeInfo = System.TypeInfo(TValue) then
|
if ATypeInfo = System.TypeInfo(TValue) then
|
||||||
begin
|
begin
|
||||||
AResult := TValue.Make(System.TypeInfo(TValue), Self);
|
TValue.Make(Self, System.TypeInfo(TValue), AResult);
|
||||||
Exit(True);
|
Exit(True);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -716,7 +716,7 @@ begin
|
|||||||
TypeOfValue:=System.TypeInfo(JSValue);
|
TypeOfValue:=System.TypeInfo(JSValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Result := Make(TypeOfValue, v);
|
Make(v, TypeOfValue, Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TValue.FromArray(TypeInfo: TTypeInfo; const Values: specialize TArray<TValue>): TValue;
|
class function TValue.FromArray(TypeInfo: TTypeInfo; const Values: specialize TArray<TValue>): TValue;
|
||||||
@ -750,9 +750,9 @@ begin
|
|||||||
raise EInvalidCast.Create('Invalid type in FromOrdinal');
|
raise EInvalidCast.Create('Invalid type in FromOrdinal');
|
||||||
|
|
||||||
if ATypeInfo.Kind = tkBool then
|
if ATypeInfo.Kind = tkBool then
|
||||||
Result := TValue.Make(ATypeInfo, AValue = True)
|
TValue.Make(AValue = True, ATypeInfo, Result)
|
||||||
else
|
else
|
||||||
Result := TValue.Make(ATypeInfo, NativeInt(AValue));
|
TValue.Make(NativeInt(AValue), ATypeInfo, Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TValue.IsObject: boolean;
|
function TValue.IsObject: boolean;
|
||||||
@ -1607,7 +1607,7 @@ var
|
|||||||
JSObject: TJSObject absolute Instance;
|
JSObject: TJSObject absolute Instance;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result := TValue.Make(PropertyType.Handle, GetJSValueProp(JSObject, PropertyTypeInfo));
|
TValue.Make(GetJSValueProp(JSObject, PropertyTypeInfo), PropertyType.Handle, Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TRttiProperty.SetValue(Instance: JSValue; const AValue: TValue);
|
procedure TRttiProperty.SetValue(Instance: JSValue; const AValue: TValue);
|
||||||
|
Loading…
Reference in New Issue
Block a user