2
0
Эх сурвалжийг харах

rtl: added TRttiProperty.Index and IsClassProperty

mattias 7 сар өмнө
parent
commit
752c5a130d

+ 24 - 0
packages/rtl/src/rtti.pas

@@ -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);

+ 1 - 0
packages/rtl/src/typinfo.pas

@@ -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 }