rtl: added rttit StrictVsibility

This commit is contained in:
mattias 2025-01-31 22:41:15 +01:00
parent 55a3898b8c
commit 729b61c87e
2 changed files with 21 additions and 10 deletions

View File

@ -158,6 +158,7 @@ type
function GetMemberTypeInfo: TTypeMember;
function GetName: String; override;
function GetParent: TRttiType;
function GetStrictVisibility: Boolean; virtual;
function GetVisibility: TMemberVisibility; virtual;
function LoadCustomAttributes: TCustomAttributeArray; override;
public
@ -166,6 +167,7 @@ type
property MemberTypeInfo: TTypeMember read GetMemberTypeInfo;
property Parent: TRttiType read GetParent;
property Visibility: TMemberVisibility read GetVisibility;
property StrictVisibility: Boolean Read GetStrictVisibility;
end;
{ TRttiDataMember }
@ -1752,7 +1754,7 @@ end;
{ TRttiMember }
function TRttiMember.GetName: string;
function TRttiMember.GetName: String;
begin
Result := MemberTypeInfo.Name;
end;
@ -1762,12 +1764,19 @@ begin
Result := TRttiType(inherited Parent);
end;
function TRttiMember.GetStrictVisibility: Boolean;
begin
Result:=MemberTypeInfo.Visibility in [tmvStrictPrivate,tmvStrictProtected];
end;
function TRttiMember.GetVisibility: TMemberVisibility;
begin
if MemberTypeInfo.Visibility=tmvPublishedPublic then
Result:=mvPublic
else
Result:=TMemberVisibility(ord(MemberTypeInfo.Visibility));
case MemberTypeInfo.Visibility of
tmvPrivate, tmvStrictPrivate: Result:=mvPrivate;
tmvProtected, tmvStrictProtected: Result:=mvProtected;
tmvPublic, tmvPublishedPublic: Result:=mvPublic;
else Result:=mvPublished;
end;
end;
constructor TRttiMember.Create(AParent: TRttiType; ATypeInfo: TTypeMember);

View File

@ -201,11 +201,13 @@ type
TTypeMemberKinds = set of TTypeMemberKind;
TTypeMemberVisibility = (
tmvPrivate, // 0
tmvProtected, // 1
tmvPublic, // 2
tmvPublished, // 3
tmvPublishedPublic// 4, public for extended RTTI, published for basic RTTI, vcPublished was missing in the RTTI directive
tmvPrivate, // 0
tmvProtected, // 1
tmvPublic, // 2
tmvPublished, // 3
tmvPublishedPublic,// 4, public for extended RTTI, published for basic RTTI, vcPublished was missing in the RTTI directive
tmvStrictPrivate, // 5
tmvStrictProtected // 6
);
TTypeMemberVisibilities = set of TTypeMemberVisibility;