mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 12:05:57 +02:00
* Use pointer get/set methods
git-svn-id: trunk@37496 -
This commit is contained in:
parent
3d3bbcfa9c
commit
a3bcefd78c
@ -1403,6 +1403,7 @@ end;
|
|||||||
---------------------------------------------------------------------}
|
---------------------------------------------------------------------}
|
||||||
|
|
||||||
Function GetOrdProp(Instance : TObject;PropInfo : PPropInfo) : Int64;
|
Function GetOrdProp(Instance : TObject;PropInfo : PPropInfo) : Int64;
|
||||||
|
|
||||||
type
|
type
|
||||||
TGetInt64ProcIndex=function(index:longint):Int64 of object;
|
TGetInt64ProcIndex=function(index:longint):Int64 of object;
|
||||||
TGetInt64Proc=function():Int64 of object;
|
TGetInt64Proc=function():Int64 of object;
|
||||||
@ -1425,6 +1426,7 @@ begin
|
|||||||
Signed := false;
|
Signed := false;
|
||||||
DataSize := 4;
|
DataSize := 4;
|
||||||
case TypeInfo^.Kind of
|
case TypeInfo^.Kind of
|
||||||
|
// We keep this for backwards compatibility, but internally it is no longer used.
|
||||||
{$ifdef cpu64}
|
{$ifdef cpu64}
|
||||||
tkInterface,
|
tkInterface,
|
||||||
tkInterfaceRaw,
|
tkInterfaceRaw,
|
||||||
@ -1506,13 +1508,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
else
|
||||||
|
raise EPropertyError.CreateFmt(SErrCannotReadProperty, [PropInfo^.Name]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Resourcestring
|
|
||||||
SErrCannotWriteToProperty = 'Cannot write to property %s.';
|
|
||||||
|
|
||||||
Procedure SetOrdProp(Instance : TObject;PropInfo : PPropInfo;Value : Int64);
|
Procedure SetOrdProp(Instance : TObject;PropInfo : PPropInfo;Value : Int64);
|
||||||
|
|
||||||
type
|
type
|
||||||
TSetInt64ProcIndex=procedure(index:longint;i:Int64) of object;
|
TSetInt64ProcIndex=procedure(index:longint;i:Int64) of object;
|
||||||
TSetInt64Proc=procedure(i:Int64) of object;
|
TSetInt64Proc=procedure(i:Int64) of object;
|
||||||
@ -1692,6 +1695,73 @@ begin
|
|||||||
SetOrdProp(Instance,PropInfo,StringToSet(PropInfo,Value));
|
SetOrdProp(Instance,PropInfo,StringToSet(PropInfo,Value));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ ---------------------------------------------------------------------
|
||||||
|
Pointer properties - internal only
|
||||||
|
---------------------------------------------------------------------}
|
||||||
|
|
||||||
|
Function GetPointerProp(Instance: TObject; PropInfo : PPropInfo): Pointer;
|
||||||
|
|
||||||
|
Type
|
||||||
|
TGetPointerProcIndex = function (index:longint): Pointer of object;
|
||||||
|
TGetPointerProc = function (): Pointer of object;
|
||||||
|
|
||||||
|
var
|
||||||
|
AMethod : TMethod;
|
||||||
|
|
||||||
|
begin
|
||||||
|
case (PropInfo^.PropProcs) and 3 of
|
||||||
|
ptField:
|
||||||
|
Result := PPointer(Pointer(Instance) + LongWord(PropInfo^.GetProc))^;
|
||||||
|
ptStatic,
|
||||||
|
ptVirtual:
|
||||||
|
begin
|
||||||
|
if (PropInfo^.PropProcs and 3)=ptStatic then
|
||||||
|
AMethod.Code:=PropInfo^.GetProc
|
||||||
|
else
|
||||||
|
AMethod.Code:=PCodePointer(Pointer(Instance.ClassType)+PtrUInt(PropInfo^.GetProc))^;
|
||||||
|
AMethod.Data:=Instance;
|
||||||
|
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
|
||||||
|
Result:=TGetPointerProcIndex(AMethod)(PropInfo^.Index)
|
||||||
|
else
|
||||||
|
Result:=TGetPointerProc(AMethod)();
|
||||||
|
end;
|
||||||
|
else
|
||||||
|
raise EPropertyError.CreateFmt(SErrCannotReadProperty, [PropInfo^.Name]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Procedure SetPointerProp(Instance: TObject; PropInfo : PPropInfo; Value: Pointer);
|
||||||
|
|
||||||
|
type
|
||||||
|
TSetPointerProcIndex = procedure(index: longint; p: pointer) of object;
|
||||||
|
TSetPointerProc = procedure(p: pointer) of object;
|
||||||
|
|
||||||
|
var
|
||||||
|
AMethod : TMethod;
|
||||||
|
|
||||||
|
begin
|
||||||
|
case (PropInfo^.PropProcs shr 2) and 3 of
|
||||||
|
ptField:
|
||||||
|
PPointer(Pointer(Instance) + LongWord(PropInfo^.SetProc))^:=Value;
|
||||||
|
ptStatic,
|
||||||
|
ptVirtual:
|
||||||
|
begin
|
||||||
|
if ((PropInfo^.PropProcs shr 2) and 3)=ptStatic then
|
||||||
|
AMethod.Code:=PropInfo^.SetProc
|
||||||
|
else
|
||||||
|
AMethod.Code:=PCodePointer(Pointer(Instance.ClassType)+PtrUInt(PropInfo^.SetProc))^;
|
||||||
|
AMethod.Data:=Instance;
|
||||||
|
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
|
||||||
|
TSetPointerProcIndex(AMethod)(PropInfo^.Index,Value)
|
||||||
|
else
|
||||||
|
TSetPointerProc(AMethod)(Value);
|
||||||
|
end;
|
||||||
|
else
|
||||||
|
raise EPropertyError.CreateFmt(SErrCannotWriteToProperty, [PropInfo^.Name]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ ---------------------------------------------------------------------
|
{ ---------------------------------------------------------------------
|
||||||
Object properties
|
Object properties
|
||||||
---------------------------------------------------------------------}
|
---------------------------------------------------------------------}
|
||||||
@ -1716,11 +1786,7 @@ end;
|
|||||||
|
|
||||||
Function GetObjectProp(Instance: TObject; PropInfo : PPropInfo; MinClass: TClass): TObject;
|
Function GetObjectProp(Instance: TObject; PropInfo : PPropInfo; MinClass: TClass): TObject;
|
||||||
begin
|
begin
|
||||||
{$ifdef cpu64}
|
Result:=TObject(GetPointerProp(Instance,PropInfo));
|
||||||
Result:=TObject(GetInt64Prop(Instance,PropInfo));
|
|
||||||
{$else cpu64}
|
|
||||||
Result:=TObject(PtrInt(GetOrdProp(Instance,PropInfo)));
|
|
||||||
{$endif cpu64}
|
|
||||||
If (MinClass<>Nil) and (Result<>Nil) Then
|
If (MinClass<>Nil) and (Result<>Nil) Then
|
||||||
If Not Result.InheritsFrom(MinClass) then
|
If Not Result.InheritsFrom(MinClass) then
|
||||||
Result:=Nil;
|
Result:=Nil;
|
||||||
@ -1734,12 +1800,9 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
Procedure SetObjectProp(Instance: TObject; PropInfo : PPropInfo; Value: TObject);
|
Procedure SetObjectProp(Instance: TObject; PropInfo : PPropInfo; Value: TObject);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{$ifdef cpu64}
|
SetPointerProp(Instance,PropInfo,Pointer(Value));
|
||||||
SetInt64Prop(Instance,PropInfo,Int64(Value));
|
|
||||||
{$else cpu64}
|
|
||||||
SetOrdProp(Instance,PropInfo,PtrInt(Value));
|
|
||||||
{$endif cpu64}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1748,6 +1811,7 @@ begin
|
|||||||
Result:=GetTypeData(FindPropInfo(Instance,PropName,[tkClass])^.PropType)^.ClassType;
|
Result:=GetTypeData(FindPropInfo(Instance,PropName,[tkClass])^.PropType)^.ClassType;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function GetObjectPropClass(AClass: TClass; const PropName: string): TClass;
|
Function GetObjectPropClass(AClass: TClass; const PropName: string): TClass;
|
||||||
begin
|
begin
|
||||||
Result:=GetTypeData(FindPropInfo(AClass,PropName,[tkClass])^.PropType)^.ClassType;
|
Result:=GetTypeData(FindPropInfo(AClass,PropName,[tkClass])^.PropType)^.ClassType;
|
||||||
@ -1789,6 +1853,8 @@ begin
|
|||||||
else
|
else
|
||||||
Result:=TGetInterfaceProc(AMethod)();
|
Result:=TGetInterfaceProc(AMethod)();
|
||||||
end;
|
end;
|
||||||
|
else
|
||||||
|
raise EPropertyError.CreateFmt(SErrCannotReadProperty, [PropInfo^.Name]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1800,11 +1866,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure SetInterfaceProp(Instance: TObject; PropInfo: PPropInfo; const Value: IInterface);
|
procedure SetInterfaceProp(Instance: TObject; PropInfo: PPropInfo; const Value: IInterface);
|
||||||
|
|
||||||
type
|
type
|
||||||
TSetIntfStrProcIndex=procedure(index:longint;const i:IInterface) of object;
|
TSetIntfStrProcIndex=procedure(index:longint;const i:IInterface) of object;
|
||||||
TSetIntfStrProc=procedure(i:IInterface) of object;
|
TSetIntfStrProc=procedure(i:IInterface) of object;
|
||||||
|
|
||||||
var
|
var
|
||||||
AMethod : TMethod;
|
AMethod : TMethod;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
case Propinfo^.PropType^.Kind of
|
case Propinfo^.PropType^.Kind of
|
||||||
tkInterface:
|
tkInterface:
|
||||||
@ -1848,11 +1917,7 @@ end;
|
|||||||
function GetRawInterfaceProp(Instance: TObject; PropInfo: PPropInfo): Pointer;
|
function GetRawInterfaceProp(Instance: TObject; PropInfo: PPropInfo): Pointer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{$ifdef cpu64}
|
Result:=GetPointerProp(Instance,PropInfo);
|
||||||
Result:=Pointer(GetInt64Prop(Instance,PropInfo));
|
|
||||||
{$else cpu64}
|
|
||||||
Result:=Pointer(PtrInt(GetOrdProp(Instance,PropInfo)));
|
|
||||||
{$endif cpu64}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure SetRawInterfaceProp(Instance: TObject; const PropName: string; const Value: Pointer);
|
procedure SetRawInterfaceProp(Instance: TObject; const PropName: string; const Value: Pointer);
|
||||||
@ -1862,38 +1927,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure SetRawInterfaceProp(Instance: TObject; PropInfo: PPropInfo; const Value: Pointer);
|
procedure SetRawInterfaceProp(Instance: TObject; PropInfo: PPropInfo; const Value: Pointer);
|
||||||
type
|
|
||||||
TSetPointerProcIndex=procedure(index:longint;const i:Pointer) of object;
|
|
||||||
TSetPointerProc=procedure(i:Pointer) of object;
|
|
||||||
var
|
|
||||||
AMethod : TMethod;
|
|
||||||
begin
|
begin
|
||||||
case Propinfo^.PropType^.Kind of
|
SetPointerProp(Instance,PropInfo,Value);
|
||||||
tkInterfaceRaw:
|
|
||||||
begin
|
|
||||||
case (PropInfo^.PropProcs shr 2) and 3 of
|
|
||||||
ptField:
|
|
||||||
PPointer(Pointer(Instance)+PtrUInt(PropInfo^.SetProc))^:=Value;
|
|
||||||
ptStatic,
|
|
||||||
ptVirtual:
|
|
||||||
begin
|
|
||||||
if ((PropInfo^.PropProcs shr 2) and 3)=ptStatic then
|
|
||||||
AMethod.Code:=PropInfo^.SetProc
|
|
||||||
else
|
|
||||||
AMethod.Code:=PCodePointer(Pointer(Instance.ClassType)+PtrUInt(PropInfo^.SetProc))^;
|
|
||||||
AMethod.Data:=Instance;
|
|
||||||
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
|
|
||||||
TSetPointerProcIndex(AMethod)(PropInfo^.Index,Value)
|
|
||||||
else
|
|
||||||
TSetPointerProc(AMethod)(Value);
|
|
||||||
end;
|
|
||||||
else
|
|
||||||
raise EPropertyError.CreateFmt(SErrCannotWriteToProperty, [PropInfo^.Name]);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
tkInterface:
|
|
||||||
Raise Exception.Create('Cannot set interface from RAW interface');
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ ---------------------------------------------------------------------
|
{ ---------------------------------------------------------------------
|
||||||
@ -1906,14 +1942,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function GetDynArrayProp(Instance: TObject; PropInfo: PPropInfo): Pointer;
|
function GetDynArrayProp(Instance: TObject; PropInfo: PPropInfo): Pointer;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ we need a dynamic array as that type is usually passed differently from
|
{ we need a dynamic array as that type is usually passed differently from
|
||||||
a plain pointer }
|
a plain pointer }
|
||||||
TDynArray=array of Byte;
|
TDynArray=array of Byte;
|
||||||
TGetDynArrayProc=function:TDynArray of object;
|
TGetDynArrayProc=function:TDynArray of object;
|
||||||
TGetDynArrayProcIndex=function(index:longint):TDynArray of object;
|
TGetDynArrayProcIndex=function(index:longint):TDynArray of object;
|
||||||
|
|
||||||
var
|
var
|
||||||
AMethod : TMethod;
|
AMethod : TMethod;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
if PropInfo^.PropType^.Kind<>tkDynArray then
|
if PropInfo^.PropType^.Kind<>tkDynArray then
|
||||||
@ -1934,6 +1973,8 @@ begin
|
|||||||
else
|
else
|
||||||
Result:=Pointer(TGetDynArrayProc(AMethod)());
|
Result:=Pointer(TGetDynArrayProc(AMethod)());
|
||||||
end;
|
end;
|
||||||
|
else
|
||||||
|
raise EPropertyError.CreateFmt(SErrCannotReadProperty, [PropInfo^.Name]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1943,14 +1984,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure SetDynArrayProp(Instance: TObject; PropInfo: PPropInfo; const Value: Pointer);
|
procedure SetDynArrayProp(Instance: TObject; PropInfo: PPropInfo; const Value: Pointer);
|
||||||
|
|
||||||
type
|
type
|
||||||
{ we need a dynamic array as that type is usually passed differently from
|
{ we need a dynamic array as that type is usually passed differently from
|
||||||
a plain pointer }
|
a plain pointer }
|
||||||
TDynArray=array of Byte;
|
TDynArray=array of Byte;
|
||||||
TSetDynArrayProcIndex=procedure(index:longint;const i:TDynArray) of object;
|
TSetDynArrayProcIndex=procedure(index:longint;const i:TDynArray) of object;
|
||||||
TSetDynArrayProc=procedure(i:TDynArray) of object;
|
TSetDynArrayProc=procedure(i:TDynArray) of object;
|
||||||
|
|
||||||
var
|
var
|
||||||
AMethod: TMethod;
|
AMethod: TMethod;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if PropInfo^.PropType^.Kind<>tkDynArray then
|
if PropInfo^.PropType^.Kind<>tkDynArray then
|
||||||
Exit;
|
Exit;
|
||||||
@ -1980,13 +2024,16 @@ end;
|
|||||||
---------------------------------------------------------------------}
|
---------------------------------------------------------------------}
|
||||||
|
|
||||||
Function GetStrProp(Instance: TObject; PropInfo: PPropInfo): AnsiString;
|
Function GetStrProp(Instance: TObject; PropInfo: PPropInfo): AnsiString;
|
||||||
|
|
||||||
type
|
type
|
||||||
TGetShortStrProcIndex=function(index:longint):ShortString of object;
|
TGetShortStrProcIndex=function(index:longint):ShortString of object;
|
||||||
TGetShortStrProc=function():ShortString of object;
|
TGetShortStrProc=function():ShortString of object;
|
||||||
TGetAnsiStrProcIndex=function(index:longint):AnsiString of object;
|
TGetAnsiStrProcIndex=function(index:longint):AnsiString of object;
|
||||||
TGetAnsiStrProc=function():AnsiString of object;
|
TGetAnsiStrProc=function():AnsiString of object;
|
||||||
|
|
||||||
var
|
var
|
||||||
AMethod : TMethod;
|
AMethod : TMethod;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:='';
|
Result:='';
|
||||||
case Propinfo^.PropType^.Kind of
|
case Propinfo^.PropType^.Kind of
|
||||||
@ -2012,6 +2059,8 @@ begin
|
|||||||
else
|
else
|
||||||
Result:=TGetShortStrProc(AMethod)();
|
Result:=TGetShortStrProc(AMethod)();
|
||||||
end;
|
end;
|
||||||
|
else
|
||||||
|
raise EPropertyError.CreateFmt(SErrCannotReadProperty, [PropInfo^.Name]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
tkAString:
|
tkAString:
|
||||||
@ -2032,6 +2081,8 @@ begin
|
|||||||
else
|
else
|
||||||
Result:=TGetAnsiStrProc(AMethod)();
|
Result:=TGetAnsiStrProc(AMethod)();
|
||||||
end;
|
end;
|
||||||
|
else
|
||||||
|
raise EPropertyError.CreateFmt(SErrCannotReadProperty, [PropInfo^.Name]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -2039,13 +2090,16 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
Procedure SetStrProp(Instance : TObject;PropInfo : PPropInfo; const Value : AnsiString);
|
Procedure SetStrProp(Instance : TObject;PropInfo : PPropInfo; const Value : AnsiString);
|
||||||
|
|
||||||
type
|
type
|
||||||
TSetShortStrProcIndex=procedure(index:longint;const s:ShortString) of object;
|
TSetShortStrProcIndex=procedure(index:longint;const s:ShortString) of object;
|
||||||
TSetShortStrProc=procedure(const s:ShortString) of object;
|
TSetShortStrProc=procedure(const s:ShortString) of object;
|
||||||
TSetAnsiStrProcIndex=procedure(index:longint;s:AnsiString) of object;
|
TSetAnsiStrProcIndex=procedure(index:longint;s:AnsiString) of object;
|
||||||
TSetAnsiStrProc=procedure(s:AnsiString) of object;
|
TSetAnsiStrProc=procedure(s:AnsiString) of object;
|
||||||
|
|
||||||
var
|
var
|
||||||
AMethod : TMethod;
|
AMethod : TMethod;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
case Propinfo^.PropType^.Kind of
|
case Propinfo^.PropType^.Kind of
|
||||||
tkWString:
|
tkWString:
|
||||||
@ -2096,8 +2150,6 @@ begin
|
|||||||
raise EPropertyError.CreateFmt(SErrCannotWriteToProperty, [PropInfo^.Name]);
|
raise EPropertyError.CreateFmt(SErrCannotWriteToProperty, [PropInfo^.Name]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
else
|
|
||||||
raise EPropertyError.CreateFmt(SErrCannotWriteToProperty, [PropInfo^.Name]);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2157,6 +2209,8 @@ begin
|
|||||||
else
|
else
|
||||||
Result:=TGetWideStrProc(AMethod)();
|
Result:=TGetWideStrProc(AMethod)();
|
||||||
end;
|
end;
|
||||||
|
else
|
||||||
|
raise EPropertyError.CreateFmt(SErrCannotReadProperty, [PropInfo^.Name]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -2201,23 +2255,28 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
Function GetUnicodeStrProp(Instance: TObject; const PropName: string): UnicodeString;
|
Function GetUnicodeStrProp(Instance: TObject; const PropName: string): UnicodeString;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=GetUnicodeStrProp(Instance, FindPropInfo(Instance, PropName));
|
Result:=GetUnicodeStrProp(Instance, FindPropInfo(Instance, PropName));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure SetUnicodeStrProp(Instance: TObject; const PropName: string; const Value: UnicodeString);
|
procedure SetUnicodeStrProp(Instance: TObject; const PropName: string; const Value: UnicodeString);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
SetUnicodeStrProp(Instance,FindPropInfo(Instance,PropName),Value);
|
SetUnicodeStrProp(Instance,FindPropInfo(Instance,PropName),Value);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function GetUnicodeStrProp(Instance: TObject; PropInfo: PPropInfo): UnicodeString;
|
Function GetUnicodeStrProp(Instance: TObject; PropInfo: PPropInfo): UnicodeString;
|
||||||
|
|
||||||
type
|
type
|
||||||
TGetUnicodeStrProcIndex=function(index:longint):UnicodeString of object;
|
TGetUnicodeStrProcIndex=function(index:longint):UnicodeString of object;
|
||||||
TGetUnicodeStrProc=function():UnicodeString of object;
|
TGetUnicodeStrProc=function():UnicodeString of object;
|
||||||
|
|
||||||
var
|
var
|
||||||
AMethod : TMethod;
|
AMethod : TMethod;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:='';
|
Result:='';
|
||||||
case Propinfo^.PropType^.Kind of
|
case Propinfo^.PropType^.Kind of
|
||||||
@ -2243,6 +2302,8 @@ begin
|
|||||||
else
|
else
|
||||||
Result:=TGetUnicodeStrProc(AMethod)();
|
Result:=TGetUnicodeStrProc(AMethod)();
|
||||||
end;
|
end;
|
||||||
|
else
|
||||||
|
raise EPropertyError.CreateFmt(SErrCannotReadProperty, [PropInfo^.Name]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -2250,11 +2311,14 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
Procedure SetUnicodeStrProp(Instance: TObject; PropInfo: PPropInfo; const Value: UnicodeString);
|
Procedure SetUnicodeStrProp(Instance: TObject; PropInfo: PPropInfo; const Value: UnicodeString);
|
||||||
|
|
||||||
type
|
type
|
||||||
TSetUnicodeStrProcIndex=procedure(index:longint;s:UnicodeString) of object;
|
TSetUnicodeStrProcIndex=procedure(index:longint;s:UnicodeString) of object;
|
||||||
TSetUnicodeStrProc=procedure(s:UnicodeString) of object;
|
TSetUnicodeStrProc=procedure(s:UnicodeString) of object;
|
||||||
|
|
||||||
var
|
var
|
||||||
AMethod : TMethod;
|
AMethod : TMethod;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
case Propinfo^.PropType^.Kind of
|
case Propinfo^.PropType^.Kind of
|
||||||
tkSString,tkAString:
|
tkSString,tkAString:
|
||||||
@ -2291,8 +2355,10 @@ function GetRawbyteStrProp(Instance: TObject; PropInfo: PPropInfo): RawByteStrin
|
|||||||
type
|
type
|
||||||
TGetRawByteStrProcIndex=function(index:longint): RawByteString of object;
|
TGetRawByteStrProcIndex=function(index:longint): RawByteString of object;
|
||||||
TGetRawByteStrProc=function():RawByteString of object;
|
TGetRawByteStrProc=function():RawByteString of object;
|
||||||
|
|
||||||
var
|
var
|
||||||
AMethod : TMethod;
|
AMethod : TMethod;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:='';
|
Result:='';
|
||||||
case Propinfo^.PropType^.Kind of
|
case Propinfo^.PropType^.Kind of
|
||||||
@ -2320,6 +2386,8 @@ begin
|
|||||||
else
|
else
|
||||||
Result:=TGetRawByteStrProc(AMethod)();
|
Result:=TGetRawByteStrProc(AMethod)();
|
||||||
end;
|
end;
|
||||||
|
else
|
||||||
|
raise EPropertyError.CreateFmt(SErrCannotReadProperty, [PropInfo^.Name]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -2335,8 +2403,10 @@ procedure SetRawByteStrProp(Instance: TObject; PropInfo: PPropInfo; const Value:
|
|||||||
type
|
type
|
||||||
TSetRawByteStrProcIndex=procedure(index:longint;s:RawByteString) of object;
|
TSetRawByteStrProcIndex=procedure(index:longint;s:RawByteString) of object;
|
||||||
TSetRawByteStrProc=procedure(s:RawByteString) of object;
|
TSetRawByteStrProc=procedure(s:RawByteString) of object;
|
||||||
|
|
||||||
var
|
var
|
||||||
AMethod : TMethod;
|
AMethod : TMethod;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
case Propinfo^.PropType^.Kind of
|
case Propinfo^.PropType^.Kind of
|
||||||
tkWString:
|
tkWString:
|
||||||
@ -2369,11 +2439,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure SetRawByteStrProp(Instance: TObject; const PropName: string; const Value: RawByteString);
|
procedure SetRawByteStrProp(Instance: TObject; const PropName: string; const Value: RawByteString);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
SetRawByteStrProp(Instance,FindPropInfo(Instance,PropName),Value);
|
SetRawByteStrProp(Instance,FindPropInfo(Instance,PropName),Value);
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -2385,6 +2455,7 @@ end;
|
|||||||
---------------------------------------------------------------------}
|
---------------------------------------------------------------------}
|
||||||
|
|
||||||
function GetFloatProp(Instance : TObject;PropInfo : PPropInfo) : Extended;
|
function GetFloatProp(Instance : TObject;PropInfo : PPropInfo) : Extended;
|
||||||
|
|
||||||
type
|
type
|
||||||
TGetExtendedProc = function:Extended of object;
|
TGetExtendedProc = function:Extended of object;
|
||||||
TGetExtendedProcIndex = function(Index: integer): Extended of object;
|
TGetExtendedProcIndex = function(Index: integer): Extended of object;
|
||||||
@ -2394,8 +2465,10 @@ type
|
|||||||
TGetSingleProcIndex = function(Index: integer):Single of object;
|
TGetSingleProcIndex = function(Index: integer):Single of object;
|
||||||
TGetCurrencyProc = function : Currency of object;
|
TGetCurrencyProc = function : Currency of object;
|
||||||
TGetCurrencyProcIndex = function(Index: integer) : Currency of object;
|
TGetCurrencyProcIndex = function(Index: integer) : Currency of object;
|
||||||
|
|
||||||
var
|
var
|
||||||
AMethod : TMethod;
|
AMethod : TMethod;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=0.0;
|
Result:=0.0;
|
||||||
case PropInfo^.PropProcs and 3 of
|
case PropInfo^.PropProcs and 3 of
|
||||||
@ -2443,11 +2516,14 @@ begin
|
|||||||
Result:=TGetCurrencyProcIndex(AMethod)(PropInfo^.Index);
|
Result:=TGetCurrencyProcIndex(AMethod)(PropInfo^.Index);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
else
|
||||||
|
raise EPropertyError.CreateFmt(SErrCannotReadProperty, [PropInfo^.Name]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Procedure SetFloatProp(Instance : TObject;PropInfo : PPropInfo; Value : Extended);
|
Procedure SetFloatProp(Instance : TObject;PropInfo : PPropInfo; Value : Extended);
|
||||||
|
|
||||||
type
|
type
|
||||||
TSetExtendedProc = procedure(const AValue: Extended) of object;
|
TSetExtendedProc = procedure(const AValue: Extended) of object;
|
||||||
TSetExtendedProcIndex = procedure(Index: integer; AValue: Extended) of object;
|
TSetExtendedProcIndex = procedure(Index: integer; AValue: Extended) of object;
|
||||||
@ -2457,8 +2533,10 @@ type
|
|||||||
TSetSingleProcIndex = procedure(Index: integer; AValue: Single) of object;
|
TSetSingleProcIndex = procedure(Index: integer; AValue: Single) of object;
|
||||||
TSetCurrencyProc = procedure(const AValue: Currency) of object;
|
TSetCurrencyProc = procedure(const AValue: Currency) of object;
|
||||||
TSetCurrencyProcIndex = procedure(Index: integer; AValue: Currency) of object;
|
TSetCurrencyProcIndex = procedure(Index: integer; AValue: Currency) of object;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
AMethod : TMethod;
|
AMethod : TMethod;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
case (PropInfo^.PropProcs shr 2) and 3 of
|
case (PropInfo^.PropProcs shr 2) and 3 of
|
||||||
ptfield:
|
ptfield:
|
||||||
@ -2535,12 +2613,15 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
Function GetMethodProp(Instance : TObject;PropInfo : PPropInfo) : TMethod;
|
Function GetMethodProp(Instance : TObject;PropInfo : PPropInfo) : TMethod;
|
||||||
|
|
||||||
type
|
type
|
||||||
TGetMethodProcIndex=function(Index: Longint): TMethod of object;
|
TGetMethodProcIndex=function(Index: Longint): TMethod of object;
|
||||||
TGetMethodProc=function(): TMethod of object;
|
TGetMethodProc=function(): TMethod of object;
|
||||||
|
|
||||||
var
|
var
|
||||||
value: PMethod;
|
value: PMethod;
|
||||||
AMethod : TMethod;
|
AMethod : TMethod;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result.Code:=nil;
|
Result.Code:=nil;
|
||||||
Result.Data:=nil;
|
Result.Data:=nil;
|
||||||
@ -2564,16 +2645,21 @@ begin
|
|||||||
else
|
else
|
||||||
Result:=TGetMethodProc(AMethod)();
|
Result:=TGetMethodProc(AMethod)();
|
||||||
end;
|
end;
|
||||||
|
else
|
||||||
|
raise EPropertyError.CreateFmt(SErrCannotReadProperty, [PropInfo^.Name]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Procedure SetMethodProp(Instance : TObject;PropInfo : PPropInfo; const Value : TMethod);
|
Procedure SetMethodProp(Instance : TObject;PropInfo : PPropInfo; const Value : TMethod);
|
||||||
|
|
||||||
type
|
type
|
||||||
TSetMethodProcIndex=procedure(index:longint;p:TMethod) of object;
|
TSetMethodProcIndex=procedure(index:longint;p:TMethod) of object;
|
||||||
TSetMethodProc=procedure(p:TMethod) of object;
|
TSetMethodProc=procedure(p:TMethod) of object;
|
||||||
|
|
||||||
var
|
var
|
||||||
AMethod : TMethod;
|
AMethod : TMethod;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
case (PropInfo^.PropProcs shr 2) and 3 of
|
case (PropInfo^.PropProcs shr 2) and 3 of
|
||||||
ptField:
|
ptField:
|
||||||
|
Loading…
Reference in New Issue
Block a user