rtl: added TRttiProperty.Index and IsClassProperty

This commit is contained in:
mattias 2025-02-03 14:19:09 +01:00
parent 37b7f89a39
commit 752c5a130d
2 changed files with 25 additions and 0 deletions

View File

@ -283,6 +283,9 @@ type
TRttiProperty = class(TRttiDataMember)
private
function GetDataType: TRttiType; override;
function GetDefault: JSValue;
function GetIndex: Integer;
function GetIsClassProperty: boolean;
function GetPropertyTypeInfo: TTypeMemberProperty;
function GetPropertyType: TRttiType;
function GetIsWritable: boolean; override;
@ -298,6 +301,9 @@ type
property PropertyTypeInfo: TTypeMemberProperty read GetPropertyTypeInfo;
property PropertyType: TRttiType read GetPropertyType;
property Default: JSValue read GetDefault;
property Index: Integer read GetIndex;
property IsClassProperty: boolean read GetIsClassProperty;
property IsReadable: boolean read GetIsReadable;
property IsWritable: boolean read GetIsWritable;
property Visibility: TMemberVisibility read GetVisibility;
@ -2271,6 +2277,24 @@ begin
Result := GetPropertyType;
end;
function TRttiProperty.GetDefault: JSValue;
begin
Result:=PropertyTypeInfo.Default;
end;
function TRttiProperty.GetIndex: Integer;
begin
if isUndefined(PropertyTypeInfo.Index) then
Result:=0
else
Result:=Integer(PropertyTypeInfo.Index);
end;
function TRttiProperty.GetIsClassProperty: boolean;
begin
Result:=(PropertyTypeInfo.Flags and pfClassProperty) > 0;
end;
function TRttiProperty.GetPropertyTypeInfo: TTypeMemberProperty;
begin
Result := TTypeMemberProperty(inherited Handle);

View File

@ -252,6 +252,7 @@ const
pfStoredFunction = 12; // stored function, function name is in Stored
pfHasIndex = 16; { if getter is function, append Index as last param
if setter is function, append Index as second last param }
pfClassProperty = 32;
type
{ TTypeMemberProperty - Kind = tmkProperty }