mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-16 05:19:04 +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;
|
function GetVisibility: TMemberVisibility; override;
|
||||||
public
|
public
|
||||||
constructor Create(AParent: TRttiType; ATypeInfo: TTypeMember);
|
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;
|
procedure SetValue(Instance: TObject; const AValue: TValue); overload;
|
||||||
|
|
||||||
property PropertyTypeInfo: TTypeMemberProperty read GetPropertyTypeInfo;
|
property PropertyTypeInfo: TTypeMemberProperty read GetPropertyTypeInfo;
|
||||||
@ -377,7 +378,6 @@ type
|
|||||||
property ElementType: TRttiType read GetElementType;
|
property ElementType: TRttiType read GetElementType;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
EInvoke = EJS;
|
EInvoke = EJS;
|
||||||
|
|
||||||
TVirtualInterfaceInvokeEvent = function(const aMethodName: string;
|
TVirtualInterfaceInvokeEvent = function(const aMethodName: string;
|
||||||
@ -1295,23 +1295,36 @@ begin
|
|||||||
Result := TTypeMemberProperty(FTypeInfo);
|
Result := TTypeMemberProperty(FTypeInfo);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TRttiProperty.GetValue(Instance: TObject): TValue;
|
function TRttiProperty.GetValue(Instance: JSValue): TValue;
|
||||||
|
var
|
||||||
|
JSObject: TJSObject absolute Instance;
|
||||||
|
|
||||||
begin
|
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;
|
end;
|
||||||
|
|
||||||
procedure TRttiProperty.SetValue(Instance: TObject; const AValue: TValue);
|
procedure TRttiProperty.SetValue(Instance: TObject; const AValue: TValue);
|
||||||
begin
|
begin
|
||||||
SetJSValueProp(Instance, PropertyTypeInfo, AValue.AsJSValue);
|
SetValue(JSValue(Instance), AValue);
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TRttiProperty.SetValue(Instance: TObject; const AValue: JSValue);
|
|
||||||
begin
|
|
||||||
SetJSValueProp(Instance, PropertyTypeInfo, AValue);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TRttiProperty.GetPropertyType: TRttiType;
|
function TRttiProperty.GetPropertyType: TRttiType;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result := GRttiContext.GetType(PropertyTypeInfo.TypeInfo);
|
Result := GRttiContext.GetType(PropertyTypeInfo.TypeInfo);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user