From 729b61c87ed50d243cace012f2daca5ffb972c79 Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 31 Jan 2025 22:41:15 +0100 Subject: [PATCH] rtl: added rttit StrictVsibility --- packages/rtl/src/rtti.pas | 19 ++++++++++++++----- packages/rtl/src/typinfo.pas | 12 +++++++----- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/packages/rtl/src/rtti.pas b/packages/rtl/src/rtti.pas index 809e4d3..d7679c7 100644 --- a/packages/rtl/src/rtti.pas +++ b/packages/rtl/src/rtti.pas @@ -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); diff --git a/packages/rtl/src/typinfo.pas b/packages/rtl/src/typinfo.pas index 7c8a378..35c3173 100644 --- a/packages/rtl/src/typinfo.pas +++ b/packages/rtl/src/typinfo.pas @@ -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;