* Functions to see whether a published property is readable or writeable

git-svn-id: trunk@37497 -
This commit is contained in:
michael 2017-10-20 19:41:56 +00:00
parent a3bcefd78c
commit 3f09294aab
2 changed files with 37 additions and 0 deletions

View File

@ -304,6 +304,8 @@ ResourceString
SErrStatusCallBackRequired = 'Thread status report handler cannot be empty.';
SErrFindNeedsSortedList = 'Cannot use find on unsorted list';
SParamIsNegative = 'Parameter "%s" cannot be negative.';
SErrCannotWriteToProperty = 'Cannot write to property "%s".';
SErrCannotReadProperty = 'Cannot read property "%s".';
{ ---------------------------------------------------------------------
Keysim Names

View File

@ -746,6 +746,12 @@ function GetPropList(Instance: TObject; out PropList: PPropList): Integer;
// Property information routines.
Function IsReadableProp(PropInfo : PPropInfo) : Boolean;
Function IsReadableProp(Instance: TObject; const PropName: string): Boolean;
Function IsReadableProp(AClass: TClass; const PropName: string): Boolean;
Function IsWriteableProp(PropInfo : PPropInfo) : Boolean;
Function IsWriteableProp(Instance: TObject; const PropName: string): Boolean;
Function IsWriteableProp(AClass: TClass; const PropName: string): Boolean;
Function IsStoredProp(Instance: TObject;PropInfo : PPropInfo) : Boolean;
Function IsStoredProp(Instance: TObject; const PropName: string): Boolean;
Function IsPublishedProp(Instance: TObject; const PropName: string): Boolean;
@ -1242,6 +1248,35 @@ begin
Raise EPropertyError.CreateFmt(SErrPropertyNotFound, [PropName]);
end;
function IsReadableProp(PropInfo: PPropInfo): Boolean;
begin
Result:=(((PropInfo^.PropProcs) and 3) in [ptField,ptStatic,ptVirtual]);
end;
function IsReadableProp(Instance: TObject; const PropName: string): Boolean;
begin
Result:=IsReadableProp(FindPropInfo(Instance,PropName));
end;
function IsReadableProp(AClass: TClass; const PropName: string): Boolean;
begin
Result:=IsReadableProp(FindPropInfo(AClass,PropName));
end;
function IsWriteableProp(PropInfo: PPropInfo): Boolean;
begin
Result:=(((PropInfo^.PropProcs shr 2) and 3) in [ptField,ptStatic,ptVirtual]);
end;
function IsWriteableProp(Instance: TObject; const PropName: string): Boolean;
begin
Result:=IsWriteableProp(FindPropInfo(Instance,PropName));
end;
function IsWriteableProp(AClass: TClass; const PropName: string): Boolean;
begin
Result:=IsWriteableProp(FindPropInfo(AClass,PropName));
end;
Function IsStoredProp(Instance : TObject;PropInfo : PPropInfo) : Boolean;
type