mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-04-20 11:09:24 +02:00
* Patch from henrique werlang to allow get/set value of records (Issue ID 38569)
This commit is contained in:
parent
4cbd08c400
commit
414ef0fe37
@ -201,9 +201,10 @@ type
|
||||
function GetVisibility: TMemberVisibility; override;
|
||||
public
|
||||
constructor Create(AParent: TRttiType; ATypeInfo: TTypeMember);
|
||||
function GetValue(Instance: TObject): TValue;
|
||||
function GetValue(Instance: JSValue): TValue;
|
||||
|
||||
procedure SetValue(Instance: TObject; const AValue: JSValue); overload;
|
||||
procedure SetValue(Instance: JSValue; const AValue: JSValue); overload;
|
||||
procedure SetValue(Instance: JSValue; const AValue: TValue); overload;
|
||||
procedure SetValue(Instance: TObject; const AValue: TValue); overload;
|
||||
|
||||
property PropertyTypeInfo: TTypeMemberProperty read GetPropertyTypeInfo;
|
||||
@ -377,7 +378,6 @@ type
|
||||
property ElementType: TRttiType read GetElementType;
|
||||
end;
|
||||
|
||||
|
||||
EInvoke = EJS;
|
||||
|
||||
TVirtualInterfaceInvokeEvent = function(const aMethodName: string;
|
||||
@ -1295,23 +1295,36 @@ begin
|
||||
Result := TTypeMemberProperty(FTypeInfo);
|
||||
end;
|
||||
|
||||
function TRttiProperty.GetValue(Instance: TObject): TValue;
|
||||
function TRttiProperty.GetValue(Instance: JSValue): TValue;
|
||||
var
|
||||
JSObject: TJSObject absolute Instance;
|
||||
|
||||
begin
|
||||
Result := TValue.Make(PropertyType.Handle, GetJSValueProp(Instance, PropertyTypeInfo));
|
||||
Result := TValue.Make(PropertyType.Handle, GetJSValueProp(JSObject, PropertyTypeInfo));
|
||||
end;
|
||||
|
||||
procedure TRttiProperty.SetValue(Instance: JSValue; const AValue: TValue);
|
||||
var
|
||||
JSObject: TJSObject absolute Instance;
|
||||
|
||||
begin
|
||||
SetJSValueProp(JSObject, PropertyTypeInfo, AValue.AsJSValue);
|
||||
end;
|
||||
|
||||
procedure TRttiProperty.SetValue(Instance: JSValue; const AValue: JSValue);
|
||||
var
|
||||
JSObject: TJSObject absolute Instance;
|
||||
|
||||
begin
|
||||
SetJSValueProp(JSObject, PropertyTypeInfo, AValue);
|
||||
end;
|
||||
|
||||
procedure TRttiProperty.SetValue(Instance: TObject; const AValue: TValue);
|
||||
begin
|
||||
SetJSValueProp(Instance, PropertyTypeInfo, AValue.AsJSValue);
|
||||
end;
|
||||
|
||||
procedure TRttiProperty.SetValue(Instance: TObject; const AValue: JSValue);
|
||||
begin
|
||||
SetJSValueProp(Instance, PropertyTypeInfo, AValue);
|
||||
SetValue(JSValue(Instance), AValue);
|
||||
end;
|
||||
|
||||
function TRttiProperty.GetPropertyType: TRttiType;
|
||||
|
||||
begin
|
||||
Result := GRttiContext.GetType(PropertyTypeInfo.TypeInfo);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user