175
168
tkMethods = [tkMethod];
176
169
tkProperties = tkAny-tkMethods-[tkUnknown];
178
{ general property handling }
179
// just skips the id and the name
180
function GetTypeData(TypeInfo : PTypeInfo) : PTypeData;
182
// searches in the property PropName
183
function GetPropInfo(TypeInfo : PTypeInfo;const PropName : string) : PPropInfo;
184
procedure GetPropInfos(TypeInfo : PTypeInfo;PropList : PPropList);
185
function GetPropList(TypeInfo : PTypeInfo;TypeKinds : TTypeKinds;
186
PropList : PPropList) : Integer;
188
// returns true, if PropInfo is a stored property
189
function IsStoredProp(Instance : TObject;PropInfo : PPropInfo) : Boolean;
191
{ subroutines to read/write properties }
192
function GetOrdProp(Instance : TObject;PropInfo : PPropInfo) : Longint;
193
procedure SetOrdProp(Instance : TObject;PropInfo : PPropInfo;
196
function GetStrProp(Instance : TObject;PropInfo : PPropInfo) : Ansistring;
197
procedure SetStrProp(Instance : TObject;PropInfo : PPropInfo;
198
const Value : Ansistring);
200
function GetFloatProp(Instance : TObject;PropInfo : PPropInfo) : Extended;
201
procedure SetFloatProp(Instance : TObject;PropInfo : PPropInfo;
204
function GetVariantProp(Instance : TObject;PropInfo : PPropInfo): Variant;
205
procedure SetVariantProp(Instance : TObject;PropInfo : PPropInfo;
206
const Value: Variant);
208
function GetMethodProp(Instance : TObject;PropInfo : PPropInfo) : TMethod;
209
procedure SetMethodProp(Instance : TObject;PropInfo : PPropInfo;
210
const Value : TMethod);
212
function GetInt64Prop(Instance: TObject; PropInfo: PPropInfo): Int64;
213
procedure SetInt64Prop(Instance: TObject; PropInfo: PPropInfo;
217
function GetEnumName(TypeInfo : PTypeInfo;Value : Integer) : string;
218
function GetEnumValue(TypeInfo : PTypeInfo;const Name : string) : Integer;
171
// general property handling
172
Function GetTypeData(TypeInfo : PTypeInfo) : PTypeData;
174
Function GetPropInfo(TypeInfo : PTypeInfo;const PropName : string) : PPropInfo;
175
Function GetPropInfo(TypeInfo : PTypeInfo;const PropName : string; AKinds : TTypeKinds) : PPropInfo;
176
Function GetPropInfo(Instance: TObject; const PropName: string; AKinds: TTypeKinds) : PPropInfo;
177
Function GetPropInfo(Instance: TObject; const PropName: string): PPropInfo;
178
Function GetPropInfo(AClass: TClass; const PropName: string; AKinds: TTypeKinds) : PPropInfo;
179
Function GetPropInfo(AClass: TClass; const PropName: string): PPropInfo;
180
Function FindPropInfo(Instance: TObject; const PropName: string): PPropInfo;
181
Function FindPropInfo(AClass:TClass;const PropName: string): PPropInfo;
182
Procedure GetPropInfos(TypeInfo : PTypeInfo;PropList : PPropList);
183
Function GetPropList(TypeInfo : PTypeInfo;TypeKinds : TTypeKinds; PropList : PPropList) : Integer;
185
// Property information routines.
186
Function IsStoredProp(Instance: TObject;PropInfo : PPropInfo) : Boolean;
187
Function IsStoredProp(Instance: TObject; const PropName: string): Boolean;
188
Function IsPublishedProp(Instance: TObject; const PropName: string): Boolean;
189
Function IsPublishedProp(AClass: TClass; const PropName: string): Boolean;
190
Function PropType(Instance: TObject; const PropName: string): TTypeKind;
191
Function PropType(AClass: TClass; const PropName: string): TTypeKind;
192
Function PropIsType(Instance: TObject; const PropName: string; TypeKind: TTypeKind): Boolean;
193
Function PropIsType(AClass: TClass; const PropName: string; TypeKind: TTypeKind): Boolean;
195
// subroutines to read/write properties
196
Function GetOrdProp(Instance: TObject; PropInfo : PPropInfo) : Longint;
197
Function GetOrdProp(Instance: TObject; const PropName: string): Longint;
198
Procedure SetOrdProp(Instance: TObject; PropInfo : PPropInfo; Value : Longint);
199
Procedure SetOrdProp(Instance: TObject; const PropName: string; Value: Longint);
201
Function GetEnumProp(Instance: TObject; const PropName: string): string;
202
Function GetEnumProp(Instance: TObject; const PropInfo: PPropInfo): string;
203
Procedure SetEnumProp(Instance: TObject; const PropName: string;const Value: string);
204
Procedure SetEnumProp(Instance: TObject; const PropInfo: PPropInfo;const Value: string);
206
Function GetSetProp(Instance: TObject; const PropName: string): string;
207
Function GetSetProp(Instance: TObject; const PropName: string; Brackets: Boolean): string;
208
Function GetSetProp(Instance: TObject; const PropInfo: PPropInfo; Brackets: Boolean): string;
209
Procedure SetSetProp(Instance: TObject; const PropName: string; const Value: string);
210
Procedure SetSetProp(Instance: TObject; const PropInfo: PPropInfo; const Value: string);
212
Function GetStrProp(Instance: TObject; PropInfo : PPropInfo) : Ansistring;
213
Function GetStrProp(Instance: TObject; const PropName: string): string;
214
Procedure SetStrProp(Instance: TObject; const PropName: string; const Value: AnsiString);
215
Procedure SetStrProp(Instance: TObject; PropInfo : PPropInfo; const Value : Ansistring);
217
{$ifdef HASWIDESTRING}
218
Function GetWideStrProp(Instance: TObject; PropInfo: PPropInfo): WideString;
219
Function GetWideStrProp(Instance: TObject; const PropName: string): WideString;
220
Procedure SetWideStrProp(Instance: TObject; const PropName: string; const Value: WideString);
221
Procedure SetWideStrProp(Instance: TObject; PropInfo: PPropInfo; const Value: WideString);
222
{$endif HASWIDESTRING}
224
Function GetFloatProp(Instance: TObject; PropInfo : PPropInfo) : Extended;
225
Function GetFloatProp(Instance: TObject; const PropName: string): Extended;
226
Procedure SetFloatProp(Instance: TObject; const PropName: string; Value: Extended);
227
Procedure SetFloatProp(Instance: TObject; PropInfo : PPropInfo; Value : Extended);
229
Function GetVariantProp(Instance: TObject; PropInfo : PPropInfo): Variant;
230
Function GetVariantProp(Instance: TObject; const PropName: string): Variant;
231
Procedure SetVariantProp(Instance: TObject; const PropName: string; const Value: Variant);
232
Procedure SetVariantProp(Instance: TObject; PropInfo : PPropInfo; const Value: Variant);
234
Function GetObjectProp(Instance: TObject; const PropName: string): TObject;
235
Function GetObjectProp(Instance: TObject; const PropName: string; MinClass: TClass): TObject;
236
Function GetObjectProp(Instance: TObject; PropInfo: PPropInfo): TObject;
237
Function GetObjectProp(Instance: TObject; PropInfo: PPropInfo; MinClass: TClass): TObject;
238
Procedure SetObjectProp(Instance: TObject; const PropName: string; Value: TObject);
239
Procedure SetObjectProp(Instance: TObject; PropInfo: PPropInfo; Value: TObject);
241
Function GetObjectPropClass(Instance: TObject; const PropName: string): TClass;
243
Function GetMethodProp(Instance: TObject; PropInfo: PPropInfo) : TMethod;
244
Function GetMethodProp(Instance: TObject; const PropName: string): TMethod;
245
Procedure SetMethodProp(Instance: TObject; PropInfo: PPropInfo; const Value : TMethod);
246
Procedure SetMethodProp(Instance: TObject; const PropName: string; const Value: TMethod);
248
Function GetInt64Prop(Instance: TObject; PropInfo: PPropInfo): Int64;
249
Function GetInt64Prop(Instance: TObject; const PropName: string): Int64;
250
Procedure SetInt64Prop(Instance: TObject; PropInfo: PPropInfo; const Value: Int64);
251
Procedure SetInt64Prop(Instance: TObject; const PropName: string; const Value: Int64);
253
Function GetPropValue(Instance: TObject; const PropName: string): Variant;
254
Function GetPropValue(Instance: TObject; const PropName: string; PreferStrings: Boolean): Variant;
255
Procedure SetPropValue(Instance: TObject; const PropName: string; const Value: Variant);
257
// Auxiliary routines, which may be useful
258
Function GetEnumName(TypeInfo : PTypeInfo;Value : Integer) : string;
259
Function GetEnumValue(TypeInfo : PTypeInfo;const Name : string) : Integer;
260
function SetToString(PropInfo: PPropInfo; Value: Integer; Brackets: Boolean) : String;
261
function SetToString(PropInfo: PPropInfo; Value: Integer) : String;
262
function StringToSet(PropInfo: PPropInfo; const Value: string): Integer;
222
265
BooleanIdents: array[Boolean] of String = ('False', 'True');
223
266
DotSep: String = '.';
235
function CallIntegerFunc(s: Pointer; Address: Pointer; Index, IValue: LongInt): Int64; assembler;
239
// ? Indexed function
248
// now the result is in EDX:EAX
251
function CallIntegerProc(s : Pointer;Address : Pointer;Value : Integer; INdex,IValue : Longint) : Integer;assembler;
258
// ? Indexed procedure
269
function CallExtendedFunc(s : Pointer;Address : Pointer; INdex,IValue : Longint) : Extended;assembler;
273
// ? Indexed function
285
function CallExtendedProc(s : Pointer;Address : Pointer;Value : Extended; INdex,IVAlue : Longint) : Integer;assembler;
294
// ? Indexed procedure
305
function CallBooleanFunc(s : Pointer;Address : Pointer; Index,IValue : Longint) : Boolean;assembler;
309
// ? Indexed function
320
// Assembler functions can't have short stringreturn values.
321
// So we make a procedure with var parameter.
322
// That's not true (FK)
324
Procedure CallSStringFunc(s : Pointer;Address : Pointer; INdex,IValue : Longint;
325
Var Res: Shortstring);assembler;
329
// ? Indexed function
335
// the result is stored in an invisible parameter
342
Procedure CallSStringProc(s : Pointer;Address : Pointer;Const Value : ShortString; INdex,IVAlue : Longint);assembler;
349
// ? Indexed procedure
362
function GetTypeData(TypeInfo : PTypeInfo) : PTypeData;
365
GetTypeData:=PTypeData(pointer(TypeInfo)+2+PByte(pointer(TypeInfo)+1)^);
368
function GetPropInfo(TypeInfo : PTypeInfo;const PropName : string) : PPropInfo;
377
while Assigned(TypeInfo) do
380
hp:=GetTypeData(Typeinfo);
382
// the class info rtti the property rtti follows
384
Result:=PPropInfo(pointer(@hp^.UnitName)+Length(hp^.UnitName)+1+SizeOF(Word));
385
for i:=1 to hp^.PropCount do
387
// found a property of that name ?
388
if Upcase(Result^.Name)=P then
391
// skip to next property
392
Result:=PPropInfo(pointer(@Result^.Name)+byte(Result^.Name[0])+1);
395
Typeinfo:=hp^.ParentInfo;
400
function IsStoredProp(Instance : TObject;PropInfo : PPropInfo) : Boolean;
403
case (PropInfo^.PropProcs shr 4) and 3 of
405
IsStoredProp:=PBoolean(Pointer(Instance)+Longint(PropInfo^.StoredProc))^;
407
IsStoredProp:=CallBooleanFunc(Instance,PropInfo^.StoredProc,0,0);
409
IsStoredProp:=CallBooleanFunc(Instance,ppointer(Pointer(Instance.ClassType)+Longint(PropInfo^.StoredProc))^,0,0);
411
IsStoredProp:=LongBool(PropInfo^.StoredProc);
415
procedure GetPropInfos(TypeInfo : PTypeInfo;PropList : PPropList);
269
EPropertyError = Class(Exception);
274
SErrPropertyNotFound = 'Unknown property: "%s"';
275
SErrUnknownEnumValue = 'Unknown enumeration value: "%s"';
280
{ ---------------------------------------------------------------------
282
---------------------------------------------------------------------}
284
Function GetEnumName(TypeInfo : PTypeInfo;Value : Integer) : string;
286
Var PS : PShortString;
290
PT:=GetTypeData(TypeInfo);
292
// If PT^.MinValue<0 then Value:=Ord(Value<>0); {map to 0/1}
296
PS:=PShortString(pointer(PS)+PByte(PS)^+1);
303
Function GetEnumValue(TypeInfo : PTypeInfo;const Name : string) : Integer;
305
Var PS : PShortString;
310
If Length(Name)=0 then
312
PT:=GetTypeData(TypeInfo);
316
While (Result=-1) and (PByte(PS)^<>0) do
318
If CompareText(PS^, Name) = 0 then
320
PS:=PShortString(pointer(PS)+PByte(PS)^+1);
326
Function SetToString(PropInfo: PPropInfo; Value: Integer; Brackets: Boolean) : String;
333
PTI:=GetTypeData(PropInfo^.PropType)^.CompType;
335
For I:=0 to SizeOf(Integer)*8-1 do
337
if ((Value and 1)<>0) then
340
Result:=GetEnumName(PTI,i)
342
Result:=Result+','+GetEnumName(PTI,I);
347
Result:='['+Result+']';
351
Function SetToString(PropInfo: PPropInfo; Value: Integer) : String;
354
Result:=SetToString(PropInfo,Value,False);
359
SetDelim = ['[',']',',',' '];
361
Function GetNextElement(Var S : String) : String;
369
While (J<=Length(S)) and Not (S[j] in SetDelim) do
371
Result:=Copy(S,1,j-1);
377
Function StringToSet(PropInfo: PPropInfo; const Value: string): Integer;
385
PTI:=GetTypeData(PropInfo^.PropType)^.Comptype;
390
While (I<=Length(S)) and (S[i] in SetDelim) do
396
T:=GetNextElement(S);
399
I:=GetEnumValue(PTI,T);
401
raise EPropertyError.CreateFmt(SErrUnknownEnumValue, [T]);
402
Result:=Result or (1 shl i);
408
Function GetTypeData(TypeInfo : PTypeInfo) : PTypeData;
410
GetTypeData:=PTypeData(pointer(TypeInfo)+2+PByte(pointer(TypeInfo)+1)^);
414
{ ---------------------------------------------------------------------
415
Basic Type information functions.
416
---------------------------------------------------------------------}
418
Function GetPropInfo(TypeInfo : PTypeInfo;const PropName : string) : PPropInfo;
426
while Assigned(TypeInfo) do
429
hp:=GetTypeData(Typeinfo);
430
// the class info rtti the property rtti follows immediatly
431
pd:=pointer(pointer(@hp^.UnitName)+Length(hp^.UnitName)+1);
432
Result:=@pd^.PropList;
433
for i:=1 to pd^.PropCount do
435
// found a property of that name ?
436
if Upcase(Result^.Name)=P then
438
// skip to next property
439
Result:=PPropInfo(pointer(@Result^.Name)+byte(Result^.Name[0])+1);
442
Typeinfo:=hp^.ParentInfo;
448
Function GetPropInfo(TypeInfo : PTypeInfo;const PropName : string; Akinds : TTypeKinds) : PPropInfo;
450
Result:=GetPropInfo(TypeInfo,PropName);
452
If (Result<>Nil) then
453
If Not (Result^.PropType^.Kind in AKinds) then
458
Function GetPropInfo(AClass: TClass; const PropName: string; AKinds: TTypeKinds) : PPropInfo;
460
Result:=GetPropInfo(PTypeInfo(AClass.ClassInfo),PropName,AKinds);
464
Function GetPropInfo(Instance: TObject; const PropName: string; AKinds: TTypeKinds) : PPropInfo;
466
Result:=GetPropInfo(Instance.ClassType,PropName,AKinds);
470
Function GetPropInfo(Instance: TObject; const PropName: string): PPropInfo;
472
Result:=GetPropInfo(Instance,PropName,[]);
476
Function GetPropInfo(AClass: TClass; const PropName: string): PPropInfo;
478
Result:=GetPropInfo(AClass,PropName,[]);
482
Function FindPropInfo(Instance: TObject; const PropName: string): PPropInfo;
484
result:=GetPropInfo(Instance, PropName);
486
Raise EPropertyError.CreateFmt(SErrPropertyNotFound, [PropName]);
490
Function FindPropInfo(AClass:TClass;const PropName: string): PPropInfo;
492
result:=GetPropInfo(AClass,PropName);
494
Raise EPropertyError.CreateFmt(SErrPropertyNotFound, [PropName]);
498
Function IsStoredProp(Instance : TObject;PropInfo : PPropInfo) : Boolean;
500
TBooleanFunc=function:boolean of object;
504
case (PropInfo^.PropProcs shr 4) and 3 of
506
Result:=PBoolean(Pointer(Instance)+Longint(PropInfo^.StoredProc))^;
508
Result:=LongBool(PropInfo^.StoredProc);
512
if (PropInfo^.PropProcs shr 4) and 3=ptstatic then
513
AMethod.Code:=PropInfo^.StoredProc
515
AMethod.Code:=ppointer(Pointer(Instance.ClassType)+Longint(PropInfo^.StoredProc))^;
516
AMethod.Data:=Instance;
517
Result:=TBooleanFunc(AMethod)();
523
Procedure GetPropInfos(TypeInfo : PTypeInfo;PropList : PPropList);
417
525
Store Pointers to property information in the list pointed
418
526
to by proplist. PRopList must contain enough space to hold ALL
428
TD:=GetTypeData(TypeInfo);
429
// Get this objects TOTAL published properties count
430
TP:=(@TD^.UnitName+Length(TD^.UnitName)+1);
432
// Now point TP to first propinfo record.
433
Inc(Longint(TP),SizeOF(Word));
437
Inc(Longint(PropList),SizeOf(Pointer));
438
// Point to TP next propinfo record.
439
// Located at Name[Length(Name)+1] !
440
TP:=PPropInfo(pointer(@TP^.Name)+PByte(@TP^.Name)^+1);
443
// recursive call for parent info.
444
If TD^.Parentinfo<>Nil then
445
GetPropInfos (TD^.ParentInfo,PropList);
448
Procedure InsertProp (PL : PProplist;PI : PPropInfo; Count : longint);
534
TD:=GetTypeData(TypeInfo);
535
// Get this objects TOTAL published properties count
536
TP:=(@TD^.UnitName+Length(TD^.UnitName)+1);
538
// Now point TP to first propinfo record.
539
Inc(Pointer(TP),SizeOF(Word));
454
While (I<Count) and (PI^.Name>PL^[I]^.Name) do Inc(I);
456
Move(PL^[I], PL^[I+1], (Count - I) * SizeOf(Pointer));
543
Inc(Pointer(PropList),SizeOf(Pointer));
544
// Point to TP next propinfo record.
545
// Located at Name[Length(Name)+1] !
546
TP:=PPropInfo(pointer(@TP^.Name)+PByte(@TP^.Name)^+1);
460
function GetPropList(TypeInfo : PTypeInfo;TypeKinds : TTypeKinds;
461
PropList : PPropList) : Integer;
464
Store Pointers to property information OF A CERTAIN KIND in the list pointed
465
to by proplist. PRopList must contain enough space to hold ALL
468
Var TempList : PPropList;
469
PropInfo : PPropinfo;
474
Count:=GetTypeData(TypeInfo)^.Propcount;
549
// recursive call for parent info.
550
If TD^.Parentinfo<>Nil then
551
GetPropInfos (TD^.ParentInfo,PropList);
555
Procedure InsertProp (PL : PProplist;PI : PPropInfo; Count : longint);
560
While (I<Count) and (PI^.Name>PL^[I]^.Name) do
563
Move(PL^[I], PL^[I+1], (Count - I) * SizeOf(Pointer));
568
Function GetPropList(TypeInfo : PTypeInfo;TypeKinds : TTypeKinds; PropList : PPropList) : Integer;
570
Store Pointers to property information OF A CERTAIN KIND in the list pointed
571
to by proplist. PRopList must contain enough space to hold ALL
575
TempList : PPropList;
576
PropInfo : PPropinfo;
580
Count:=GetTypeData(TypeInfo)^.Propcount;
583
GetMem(TempList,Count*SizeOf(Pointer));
585
GetPropInfos(TypeInfo,TempList);
586
For I:=0 to Count-1 do
477
GetMem(TempList,Count*SizeOf(Pointer));
479
GetPropInfos(TypeInfo,TempList);
480
For I:=0 to Count-1 do
588
PropInfo:=TempList^[i];
589
If PropInfo^.PropType^.Kind in TypeKinds then
482
PropInfo:=TempList^[i];
483
If PropInfo^.PropType^.Kind in TypeKinds then
485
591
InsertProp(PropList,PropInfo,Result);
490
FreeMem(TempList,Count*SizeOf(Pointer));
495
Procedure SetIndexValues (P: PPRopInfo; Var Index,IValue : Longint);
498
Index:=((P^.PropProcs shr 6) and 1);
505
function GetOrdProp(Instance : TObject;PropInfo : PPropInfo) : Longint;
508
value,Index,Ivalue : longint;
512
SetIndexValues(PropInfo,Index,Ivalue);
513
case (PropInfo^.PropProcs) and 3 of
515
Value:=PLongint(Pointer(Instance)+Longint(PropInfo^.GetProc))^;
517
Value:=CallIntegerFunc(Instance,PropInfo^.GetProc,Index,IValue);
519
Value:=CallIntegerFunc(Instance,PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.GetProc))^,Index,IValue);
521
{ cut off unnecessary stuff }
522
TypeInfo := PropInfo^.PropType;
523
case TypeInfo^.Kind of
525
Value:=Value and $ff;
527
Value:=Value and $ffff;
529
case GetTypeData(TypeInfo)^.OrdType of
531
Value:=Value and $ffff;
533
Value:=Value and $ff;
539
procedure SetOrdProp(Instance : TObject;PropInfo : PPropInfo;
543
Index,IValue : Longint;
547
{ cut off unnecessary stuff }
548
case GetTypeData(PropInfo^.PropType)^.OrdType of
549
otSWord,otUWord: begin
550
Value:=Value and $ffff;
553
otSByte,otUByte: begin
554
Value:=Value and $ff;
559
SetIndexValues(PropInfo,Index,Ivalue);
560
case (PropInfo^.PropProcs shr 2) and 3 of
563
1: PByte(Pointer(Instance)+Longint(PropInfo^.SetProc))^:=Byte(Value);
564
2: PWord(Pointer(Instance)+Longint(PropInfo^.SetProc))^:=Word(Value);
565
4: PLongint(Pointer(Instance)+Longint(PropInfo^.SetProc))^:=Value;
568
CallIntegerProc(Instance,PropInfo^.SetProc,Value,Index,IValue);
570
CallIntegerProc(Instance,PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.SetProc))^,Value,Index,IValue);
574
function GetStrProp(Instance: TObject; PropInfo: PPropInfo): AnsiString;
576
Index, IValue: LongInt;
577
ShortResult: ShortString;
579
SetIndexValues(PropInfo, Index, IValue);
580
case Propinfo^.PropType^.Kind of
582
case (PropInfo^.PropProcs) and 3 of
584
Result := PShortString(Pointer(Instance) + LongWord(PropInfo^.GetProc))^;
587
CallSStringFunc(Instance, PropInfo^.GetProc, Index, IValue, ShortResult);
588
Result := ShortResult;
592
CallSStringFunc(Instance, PPointer(Pointer(Instance.ClassType) +
593
LongWord(PropInfo^.GetProc))^, Index, IValue, ShortResult);
594
Result := ShortResult;
598
case (PropInfo^.PropProcs) and 3 of
600
Result := PAnsiString(Pointer(Instance) + LongWord(PropInfo^.GetProc))^;
602
Pointer(Result) := Pointer(LongWord(CallIntegerFunc(Instance, PropInfo^.GetProc, Index, IValue)));
604
Pointer(Result) := Pointer(LongWord(CallIntegerFunc(Instance,
605
PPointer(Pointer(Instance.ClassType) + LongWord(PropInfo^.GetProc))^, Index, IValue)));
608
// Property is neither of type AnsiString nor of type ShortString
609
SetLength(Result, 0);
613
procedure SetAStrProp(Instance : TObject;PropInfo : PPropInfo;
614
const Value : AnsiString);
617
Dirty trick based on fact that AnsiString is just a pointer,
618
hence can be treated like an integer type.
621
Index,Ivalue : Longint;
623
SetIndexValues(PropInfo,Index,IValue);
624
case (PropInfo^.PropProcs shr 2) and 3 of
626
PAnsiString(Pointer(Instance) + Longint(PropInfo^.SetProc))^ := Value;
628
CallIntegerProc(Instance,PropInfo^.SetProc,Longint(Pointer(Value)),Index,IValue);
630
CallIntegerProc(Instance,PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.SetProc))^,Longint(Pointer(Value)),Index,IValue);
634
procedure SetSStrProp(Instance : TObject;PropInfo : PPropInfo;
635
const Value : ShortString);
637
Var Index,IValue: longint;
640
SetIndexValues(PRopInfo,Index,IValue);
641
case (PropInfo^.PropProcs shr 2) and 3 of
643
PShortString(Pointer(Instance)+Longint(PropInfo^.SetProc))^:=Value;
645
CallSStringProc(Instance,PropInfo^.SetProc,Value,Index,IValue);
647
CallSStringProc(Instance,PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.SetProc))^,Value,Index,IValue);
651
procedure SetStrProp(Instance : TObject;PropInfo : PPropInfo;
652
const Value : AnsiString);
655
Case Propinfo^.PropType^.Kind of
656
tkSString : SetSStrProp(Instance,PropInfo,Value);
657
tkAString : SetAStrProp(Instance,Propinfo,Value);
661
function GetFloatProp(Instance : TObject;PropInfo : PPropInfo) : Extended;
664
Index,Ivalue : longint;
669
SetIndexValues(PropInfo,Index,Ivalue);
670
case (PropInfo^.PropProcs) and 3 of
672
Case GetTypeData(PropInfo^.PropType)^.FloatType of
674
Value:=PSingle(Pointer(Instance)+Longint(PropInfo^.GetProc))^;
676
Value:=PDouble(Pointer(Instance)+Longint(PropInfo^.GetProc))^;
678
Value:=PExtended(Pointer(Instance)+Longint(PropInfo^.GetProc))^;
680
Value:=PComp(Pointer(Instance)+Longint(PropInfo^.GetProc))^;
681
{ Uncommenting this code results in a internal error!!
683
Value:=PFixed16(Pointer(Instance)+Longint(PropInfo^.GetProc))^;
685
Value:=PFixed32(Pointer(Instance)+Longint(PropInfo^.GetProc))^;
689
Value:=CallExtendedFunc(Instance,PropInfo^.GetProc,Index,IValue);
691
Value:=CallExtendedFunc(Instance,PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.GetProc))^,Index,IValue);
696
procedure SetFloatProp(Instance : TObject;PropInfo : PPropInfo;
699
Var IValue,Index : longint;
702
SetIndexValues(PropInfo,Index,Ivalue);
703
case (PropInfo^.PropProcs shr 2) and 3 of
705
Case GetTypeData(PropInfo^.PropType)^.FloatType of
707
PSingle(Pointer(Instance)+Longint(PropInfo^.SetProc))^:=Value;
709
PDouble(Pointer(Instance)+Longint(PropInfo^.SetProc))^:=Value;
711
PExtended(Pointer(Instance)+Longint(PropInfo^.SetProc))^:=Value;
713
PComp(Pointer(Instance)+Longint(PropInfo^.SetProc))^:=Comp(Value);
714
{ Uncommenting this code results in a internal error!!
716
PFixed16(Pointer(Instance)+Longint(PropInfo^.SetProc))^:=Value;
718
PFixed32(Pointer(Instance)+Longint(PropInfo^.SetProc))^:=Value;
722
CallExtendedProc(Instance,PropInfo^.SetProc,Value,Index,IValue);
724
CallExtendedProc(Instance,PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.SetProc))^,Value,Index,IValue);
728
function GetVariantProp(Instance : TObject;PropInfo : PPropInfo): Variant;
735
procedure SetVariantProp(Instance : TObject;PropInfo : PPropInfo;
736
const Value: Variant);
742
function GetMethodProp(Instance : TObject;PropInfo : PPropInfo) : TMethod;
746
Index,Ivalue : longint;
749
SetIndexValues(PropInfo,Index,Ivalue);
750
case (PropInfo^.PropProcs) and 3 of
752
Value:=PMethod(Pointer(Instance)+Longint(PropInfo^.GetProc));
754
Value:=PMethod(LongInt(CallIntegerFunc(Instance,PropInfo^.GetProc,Index,IValue)));
756
Value:=PMethod(LongInt(CallIntegerFunc(Instance,PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.GetProc))^,Index,IValue)));
758
GetMethodProp:=Value^;
761
procedure SetMethodProp(Instance : TObject;PropInfo : PPropInfo;
762
const Value : TMethod);
765
Index,IValue : Longint;
768
SetIndexValues(PropInfo,Index,Ivalue);
769
case (PropInfo^.PropProcs shr 2) and 3 of
771
PMethod(Pointer(Instance)+Longint(PropInfo^.SetProc))^ := Value;
773
CallIntegerProc(Instance,PropInfo^.SetProc,Integer(@Value), Index, IValue);
775
CallIntegerProc(Instance,
776
PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.SetProc))^,
777
Integer(@Value), Index, IValue);
781
function GetInt64Prop(Instance: TObject; PropInfo: PPropInfo): Int64;
783
Index, IValue: LongInt;
785
SetIndexValues(PropInfo,Index,Ivalue);
786
case PropInfo^.PropProcs and 3 of
788
Result := PInt64(Pointer(Instance)+Longint(PropInfo^.GetProc))^;
790
Result := CallIntegerFunc(Instance, PropInfo^.GetProc, Index, IValue);
792
Result := CallIntegerFunc(Instance,
793
PPointer(Pointer(Instance.ClassType) + LongInt(PropInfo^.GetProc))^,
798
procedure SetInt64Prop(Instance: TObject; PropInfo: PPropInfo;
801
// !!!: Implement me!
804
function GetEnumName(TypeInfo : PTypeInfo;Value : Integer) : string;
806
Var PS : PShortString;
810
PT:=GetTypeData(TypeInfo);
812
// If PT^.MinValue<0 then Value:=Ord(Value<>0); {map to 0/1}
816
PS:=PShortString(pointer(PS)+PByte(PS)^+1);
822
function GetEnumValue(TypeInfo : PTypeInfo;const Name : string) : Integer;
824
Var PS : PShortString;
829
If Length(Name)=0 then exit(-1);
830
PT:=GetTypeData(TypeInfo);
834
While (Result=-1) and (PByte(PS)^<>0) do
836
If CompareText(PS^, Name) = 0 then
838
PS:=PShortString(pointer(PS)+PByte(PS)^+1);
596
FreeMem(TempList,Count*SizeOf(Pointer));
602
{ ---------------------------------------------------------------------
603
Property access functions
604
---------------------------------------------------------------------}
606
{ ---------------------------------------------------------------------
608
---------------------------------------------------------------------}
610
Function GetOrdProp(Instance : TObject;PropInfo : PPropInfo) : Longint;
612
TGetIntegerProcIndex=function(index:longint):longint of object;
613
TGetIntegerProc=function:longint of object;
619
case (PropInfo^.PropProcs) and 3 of
621
Result:=PLongint(Pointer(Instance)+Longint(PropInfo^.GetProc))^;
625
if (PropInfo^.PropProcs and 3)=ptStatic then
626
AMethod.Code:=PropInfo^.GetProc
628
AMethod.Code:=PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.GetProc))^;
629
AMethod.Data:=Instance;
630
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
631
Result:=TGetIntegerProcIndex(AMethod)(PropInfo^.Index)
633
Result:=TGetIntegerProc(AMethod)();
636
{ cut off unnecessary stuff }
637
TypeInfo := PropInfo^.PropType;
638
case TypeInfo^.Kind of
640
Result:=Result and $ff;
642
Result:=Result and $ffff;
645
case GetTypeData(TypeInfo)^.OrdType of
647
Result:=Result and $ffff;
649
Result:=Result and $ff;
655
Procedure SetOrdProp(Instance : TObject;PropInfo : PPropInfo;Value : Longint);
657
TSetIntegerProcIndex=procedure(index,i:longint) of object;
658
TSetIntegerProc=procedure(i:longint) of object;
664
if PropInfo^.PropType^.Kind <> tkClass then
666
{ cut off unnecessary stuff }
667
case GetTypeData(PropInfo^.PropType)^.OrdType of
670
Value:=Value and $ffff;
675
Value:=Value and $ff;
680
case (PropInfo^.PropProcs shr 2) and 3 of
683
1: PByte(Pointer(Instance)+Longint(PropInfo^.SetProc))^:=Byte(Value);
684
2: PWord(Pointer(Instance)+Longint(PropInfo^.SetProc))^:=Word(Value);
685
4: PLongint(Pointer(Instance)+Longint(PropInfo^.SetProc))^:=Value;
690
if ((PropInfo^.PropProcs shr 2) and 3)=ptStatic then
691
AMethod.Code:=PropInfo^.SetProc
693
AMethod.Code:=PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.SetProc))^;
694
AMethod.Data:=Instance;
695
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
696
TSetIntegerProcIndex(AMethod)(PropInfo^.Index,Value)
698
TSetIntegerProc(AMethod)(Value);
704
Function GetOrdProp(Instance: TObject; const PropName: string): Longint;
706
Result:=GetOrdProp(Instance,FindPropInfo(Instance,PropName));
710
Procedure SetOrdProp(Instance: TObject; const PropName: string; Value: Longint);
712
SetOrdProp(Instance,FindPropInfo(Instance,PropName),Value);
716
Function GetEnumProp(Instance: TObject; Const PropInfo: PPropInfo): string;
718
Result:=GetEnumName(PropInfo^.PropType, GetOrdProp(Instance, PropInfo));
722
Function GetEnumProp(Instance: TObject; const PropName: string): string;
724
Result:=GetEnumProp(Instance,FindPropInfo(Instance,PropName));
728
Procedure SetEnumProp(Instance: TObject; const PropName: string; const Value: string);
730
SetEnumProp(Instance,FindPropInfo(Instance,PropName),Value);
734
Procedure SetEnumProp(Instance: TObject; Const PropInfo : PPropInfo; const Value: string);
738
If PropInfo<>Nil then
740
PV:=GetEnumValue(PropInfo^.PropType, Value);
742
raise EPropertyError.CreateFmt(SErrUnknownEnumValue, [Value]);
743
SetOrdProp(Instance, PropInfo,PV);
748
{ ---------------------------------------------------------------------
750
---------------------------------------------------------------------}
752
Function GetSetProp(Instance: TObject; const PropName: string): string;
754
Result:=GetSetProp(Instance,PropName,False);
758
Function GetSetProp(Instance: TObject; const PropName: string; Brackets: Boolean): string;
760
Result:=GetSetProp(Instance,FindPropInfo(Instance,PropName),Brackets);
764
Function GetSetProp(Instance: TObject; const PropInfo: PPropInfo; Brackets: Boolean): string;
766
Result:=SetToString(PropInfo,GetOrdProp(Instance,PropInfo),Brackets);
770
Procedure SetSetProp(Instance: TObject; const PropName: string; const Value: string);
772
SetSetProp(Instance,FindPropInfo(Instance,PropName),Value);
776
Procedure SetSetProp(Instance: TObject; const PropInfo: PPropInfo; const Value: string);
778
SetOrdProp(Instance,PropInfo,StringToSet(PropInfo,Value));
781
{ ---------------------------------------------------------------------
783
---------------------------------------------------------------------}
785
Function GetObjectProp(Instance: TObject; const PropName: string): TObject;
787
Result:=GetObjectProp(Instance,PropName,Nil);
791
Function GetObjectProp(Instance: TObject; const PropName: string; MinClass: TClass): TObject;
793
Result:=GetObjectProp(Instance,FindPropInfo(Instance,PropName),MinClass);
797
Function GetObjectProp(Instance: TObject; PropInfo : PPropInfo): TObject;
799
Result:=GetObjectProp(Instance,PropInfo,Nil);
803
Function GetObjectProp(Instance: TObject; PropInfo : PPropInfo; MinClass: TClass): TObject;
806
Result:=TObject(GetInt64Prop(Instance,PropInfo));
808
Result:=TObject(GetOrdProp(Instance,PropInfo));
810
If (MinClass<>Nil) and (Result<>Nil) Then
811
If Not Result.InheritsFrom(MinClass) then
816
Procedure SetObjectProp(Instance: TObject; const PropName: string; Value: TObject);
818
SetObjectProp(Instance,FindPropInfo(Instance,PropName),Value);
822
Procedure SetObjectProp(Instance: TObject; PropInfo : PPropInfo; Value: TObject);
825
SetInt64Prop(Instance,PropInfo,Int64(Value));
827
SetOrdProp(Instance,PropInfo,Integer(Value));
832
Function GetObjectPropClass(Instance: TObject; const PropName: string): TClass;
834
Result:=GetTypeData(FindPropInfo(Instance,PropName)^.PropType)^.ClassType;
838
{ ---------------------------------------------------------------------
840
---------------------------------------------------------------------}
842
Function GetStrProp(Instance: TObject; PropInfo: PPropInfo): AnsiString;
844
TGetShortStrProcIndex=function(index:longint):ShortString of object;
845
TGetShortStrProc=function():ShortString of object;
846
TGetAnsiStrProcIndex=function(index:longint):AnsiString of object;
847
TGetAnsiStrProc=function():AnsiString of object;
852
case Propinfo^.PropType^.Kind of
853
{$ifdef HASWIDESTRING}
855
Result:=GetWideStrProp(Instance,PropInfo);
856
{$endif HASWIDESTRING}
859
case (PropInfo^.PropProcs) and 3 of
861
Result := PShortString(Pointer(Instance) + LongWord(PropInfo^.GetProc))^;
865
if (PropInfo^.PropProcs and 3)=ptStatic then
866
AMethod.Code:=PropInfo^.GetProc
868
AMethod.Code:=PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.GetProc))^;
869
AMethod.Data:=Instance;
870
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
871
Result:=TGetShortStrProcIndex(AMethod)(PropInfo^.Index)
873
Result:=TGetShortStrProc(AMethod)();
879
case (PropInfo^.PropProcs) and 3 of
881
Result := PAnsiString(Pointer(Instance) + LongWord(PropInfo^.GetProc))^;
885
if (PropInfo^.PropProcs and 3)=ptStatic then
886
AMethod.Code:=PropInfo^.GetProc
888
AMethod.Code:=PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.GetProc))^;
889
AMethod.Data:=Instance;
890
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
891
Result:=TGetAnsiStrProcIndex(AMethod)(PropInfo^.Index)
893
Result:=TGetAnsiStrProc(AMethod)();
901
Procedure SetStrProp(Instance : TObject;PropInfo : PPropInfo; const Value : AnsiString);
903
TSetShortStrProcIndex=procedure(index:longint;const s:ShortString) of object;
904
TSetShortStrProc=procedure(const s:ShortString) of object;
905
TSetAnsiStrProcIndex=procedure(index:longint;s:AnsiString) of object;
906
TSetAnsiStrProc=procedure(s:AnsiString) of object;
910
case Propinfo^.PropType^.Kind of
911
{$ifdef HASWIDESTRING}
913
SetWideStrProp(Instance,PropInfo,Value);
914
{$endif HASWIDESTRING}
917
case (PropInfo^.PropProcs shr 2) and 3 of
919
PShortString(Pointer(Instance) + LongWord(PropInfo^.SetProc))^:=Value;
923
if (PropInfo^.PropProcs and 3)=ptStatic then
924
AMethod.Code:=PropInfo^.SetProc
926
AMethod.Code:=PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.SetProc))^;
927
AMethod.Data:=Instance;
928
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
929
TSetShortStrProcIndex(AMethod)(PropInfo^.Index,Value)
931
TSetShortStrProc(AMethod)(Value);
937
case (PropInfo^.PropProcs shr 2) and 3 of
939
PAnsiString(Pointer(Instance) + LongWord(PropInfo^.SetProc))^:=Value;
943
if ((PropInfo^.PropProcs shr 2) and 3)=ptStatic then
944
AMethod.Code:=PropInfo^.SetProc
946
AMethod.Code:=PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.SetProc))^;
947
AMethod.Data:=Instance;
948
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
949
TSetAnsiStrProcIndex(AMethod)(PropInfo^.Index,Value)
951
TSetAnsiStrProc(AMethod)(Value);
959
Function GetStrProp(Instance: TObject; const PropName: string): string;
961
Result:=GetStrProp(Instance,FindPropInfo(Instance,PropName));
965
Procedure SetStrProp(Instance: TObject; const PropName: string; const Value: AnsiString);
967
SetStrProp(Instance,FindPropInfo(Instance,PropName),Value);
971
{$ifdef HASWIDESTRING}
972
Function GetWideStrProp(Instance: TObject; const PropName: string): WideString;
974
Result:=GetWideStrProp(Instance, FindPropInfo(Instance, PropName));
978
procedure SetWideStrProp(Instance: TObject; const PropName: string; const Value: WideString);
980
SetStrProp(Instance,FindPropInfo(Instance,PropName),Value);
984
Function GetWideStrProp(Instance: TObject; PropInfo: PPropInfo): WideString;
986
TGetWideStrProcIndex=function(index:longint):WideString of object;
987
TGetWideStrProc=function():WideString of object;
992
case Propinfo^.PropType^.Kind of
994
Result:=GetStrProp(Instance,PropInfo);
997
case (PropInfo^.PropProcs) and 3 of
999
Result := PWideString(Pointer(Instance)+PtrUInt(PropInfo^.GetProc))^;
1003
if (PropInfo^.PropProcs and 3)=ptStatic then
1004
AMethod.Code:=PropInfo^.GetProc
1006
AMethod.Code:=PPointer(Pointer(Instance.ClassType)+PtrUInt(PropInfo^.GetProc))^;
1007
AMethod.Data:=Instance;
1008
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
1009
Result:=TGetWideStrProcIndex(AMethod)(PropInfo^.Index)
1011
Result:=TGetWideStrProc(AMethod)();
1019
Procedure SetWideStrProp(Instance: TObject; PropInfo: PPropInfo; const Value: WideString);
1021
TSetWideStrProcIndex=procedure(index:longint;s:WideString) of object;
1022
TSetWideStrProc=procedure(s:WideString) of object;
1026
case Propinfo^.PropType^.Kind of
1027
tkSString,tkAString:
1028
SetStrProp(Instance,PropInfo,Value);
1031
case (PropInfo^.PropProcs shr 2) and 3 of
1033
PWideString(Pointer(Instance)+PtrUInt(PropInfo^.SetProc))^:=Value;
1037
if ((PropInfo^.PropProcs shr 2) and 3)=ptStatic then
1038
AMethod.Code:=PropInfo^.SetProc
1040
AMethod.Code:=PPointer(Pointer(Instance.ClassType)+PtrUInt(PropInfo^.SetProc))^;
1041
AMethod.Data:=Instance;
1042
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
1043
TSetWideStrProcIndex(AMethod)(PropInfo^.Index,Value)
1045
TSetWideStrProc(AMethod)(Value);
1052
{$endif HASWIDESTRING}
1055
{ ---------------------------------------------------------------------
1057
---------------------------------------------------------------------}
1059
function GetFloatProp(Instance : TObject;PropInfo : PPropInfo) : Extended;
1061
TGetExtendedProc = function:Extended of object;
1062
TGetExtendedProcIndex = function(Index: integer): Extended of object;
1063
TGetDoubleProc = function:Double of object;
1064
TGetDoubleProcIndex = function(Index: integer): Double of object;
1065
TGetSingleProc = function:Single of object;
1066
TGetSingleProcIndex = function(Index: integer):Single of object;
1067
{$ifdef HASCURRENCY}
1068
TGetCurrencyProc = function : Currency of object;
1069
TGetCurrencyProcIndex = function(Index: integer) : Currency of object;
1070
{$endif HASCURRENCY}
1075
case PropInfo^.PropProcs and 3 of
1077
Case GetTypeData(PropInfo^.PropType)^.FloatType of
1079
Result:=PSingle(Pointer(Instance)+Longint(PropInfo^.GetProc))^;
1081
Result:=PDouble(Pointer(Instance)+Longint(PropInfo^.GetProc))^;
1083
Result:=PExtended(Pointer(Instance)+Longint(PropInfo^.GetProc))^;
1085
Result:=PComp(Pointer(Instance)+Longint(PropInfo^.GetProc))^;
1086
{$ifdef HASCURRENCY}
1088
Result:=PCurrency(Pointer(Instance)+Longint(PropInfo^.GetProc))^;
1089
{$endif HASCURRENCY}
1094
if (PropInfo^.PropProcs and 3)=ptStatic then
1095
AMethod.Code:=PropInfo^.GetProc
1097
AMethod.Code:=PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.GetProc))^;
1098
AMethod.Data:=Instance;
1099
Case GetTypeData(PropInfo^.PropType)^.FloatType of
1101
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
1102
Result:=TGetSingleProc(AMethod)()
1104
Result:=TGetSingleProcIndex(AMethod)(PropInfo^.Index);
1106
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
1107
Result:=TGetDoubleProc(AMethod)()
1109
Result:=TGetDoubleProcIndex(AMethod)(PropInfo^.Index);
1111
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
1112
Result:=TGetExtendedProc(AMethod)()
1114
Result:=TGetExtendedProcIndex(AMethod)(PropInfo^.Index);
1121
Procedure SetFloatProp(Instance : TObject;PropInfo : PPropInfo; Value : Extended);
1123
TSetExtendedProc = procedure(const AValue: Extended) of object;
1124
TSetExtendedProcIndex = procedure(Index: integer; const AValue: Extended) of object;
1125
TSetDoubleProc = procedure(const AValue: Double) of object;
1126
TSetDoubleProcIndex = procedure(Index: integer; const AValue: Double) of object;
1127
TSetSingleProc = procedure(const AValue: Single) of object;
1128
TSetSingleProcIndex = procedure(Index: integer; const AValue: Single) of object;
1129
{$ifdef HASCURRENCY}
1130
TSetCurrencyProc = procedure(const AValue: Currency) of object;
1131
TSetCurrencyProcIndex = procedure(Index: integer; const AValue: Currency) of object;
1132
{$endif HASCURRENCY}
1136
case (PropInfo^.PropProcs shr 2) and 3 of
1138
Case GetTypeData(PropInfo^.PropType)^.FloatType of
1140
PSingle(Pointer(Instance)+Longint(PropInfo^.SetProc))^:=Value;
1142
PDouble(Pointer(Instance)+Longint(PropInfo^.SetProc))^:=Value;
1144
PExtended(Pointer(Instance)+Longint(PropInfo^.SetProc))^:=Value;
1145
{$ifdef FPC_COMP_IS_INT64}
1147
PComp(Pointer(Instance)+PtrUInt(PropInfo^.SetProc))^:=trunc(Value);
1148
{$else FPC_COMP_IS_INT64}
1150
PComp(Pointer(Instance)+PtrUInt(PropInfo^.SetProc))^:=Value;
1151
{$endif FPC_COMP_IS_INT64}
1156
if ((PropInfo^.PropProcs shr 2) and 3)=ptStatic then
1157
AMethod.Code:=PropInfo^.SetProc
1159
AMethod.Code:=PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.SetProc))^;
1160
AMethod.Data:=Instance;
1161
Case GetTypeData(PropInfo^.PropType)^.FloatType of
1163
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
1164
TSetSingleProc(AMethod)(Value)
1166
TSetSingleProcIndex(AMethod)(PropInfo^.Index,Value);
1168
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
1169
TSetDoubleProc(AMethod)(Value)
1171
TSetDoubleProcIndex(AMethod)(PropInfo^.Index,Value);
1173
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
1174
TSetExtendedProc(AMethod)(Value)
1176
TSetExtendedProcIndex(AMethod)(PropInfo^.Index,Value);
1183
function GetFloatProp(Instance: TObject; const PropName: string): Extended;
1185
Result:=GetFloatProp(Instance,FindPropInfo(Instance,PropName))
1189
Procedure SetFloatProp(Instance: TObject; const PropName: string; Value: Extended);
1191
SetFloatProp(Instance,FindPropInfo(Instance,PropName),Value);
1195
{ ---------------------------------------------------------------------
1197
---------------------------------------------------------------------}
1199
Function GetVariantProp(Instance : TObject;PropInfo : PPropInfo): Variant;
1201
{$warning GetVariantProp not implemented}
1210
Procedure SetVariantProp(Instance : TObject;PropInfo : PPropInfo; const Value: Variant);
1212
{$warning SetVariantProp not implemented}
1216
Function GetVariantProp(Instance: TObject; const PropName: string): Variant;
1218
Result:=GetVariantProp(Instance,FindPropInfo(Instance,PropName));
1222
Procedure SetVariantProp(Instance: TObject; const PropName: string; const Value: Variant);
1224
SetVariantprop(instance,FindpropInfo(Instance,PropName),Value);
1228
{ ---------------------------------------------------------------------
1230
---------------------------------------------------------------------}
1233
Function GetMethodProp(Instance : TObject;PropInfo : PPropInfo) : TMethod;
1235
TGetMethodProcIndex=function(index:longint):PMethod of object;
1236
TGetMethodProc=function():PMethod of object;
1242
case (PropInfo^.PropProcs) and 3 of
1244
Value:=PMethod(Pointer(Instance)+Longint(PropInfo^.GetProc));
1248
if (PropInfo^.PropProcs and 3)=ptStatic then
1249
AMethod.Code:=PropInfo^.GetProc
1251
AMethod.Code:=PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.GetProc))^;
1252
AMethod.Data:=Instance;
1253
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
1254
Value:=TGetMethodProcIndex(AMethod)(PropInfo^.Index)
1256
Value:=TGetMethodProc(AMethod)();
1269
Procedure SetMethodProp(Instance : TObject;PropInfo : PPropInfo; const Value : TMethod);
1271
TSetMethodProcIndex=procedure(index:longint;p:PMethod) of object;
1272
TSetMethodProc=procedure(p:PMethod) of object;
1276
case (PropInfo^.PropProcs shr 2) and 3 of
1278
PMethod(Pointer(Instance)+Longint(PropInfo^.SetProc))^ := Value;
1282
if ((PropInfo^.PropProcs shr 2) and 3)=ptStatic then
1283
AMethod.Code:=PropInfo^.SetProc
1285
AMethod.Code:=PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.SetProc))^;
1286
AMethod.Data:=Instance;
1287
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
1288
TSetMethodProcIndex(AMethod)(PropInfo^.Index,@Value)
1290
TSetMethodProc(AMethod)(@Value);
1296
Function GetMethodProp(Instance: TObject; const PropName: string): TMethod;
1298
Result:=GetMethodProp(Instance,FindPropInfo(Instance,PropName));
1302
Procedure SetMethodProp(Instance: TObject; const PropName: string; const Value: TMethod);
1304
SetMethodProp(Instance,FindPropInfo(Instance,PropName),Value);
1308
{ ---------------------------------------------------------------------
1310
---------------------------------------------------------------------}
1312
Function GetInt64Prop(Instance: TObject; PropInfo: PPropInfo): Int64;
1314
TGetInt64ProcIndex=function(index:longint):Int64 of object;
1315
TGetInt64Proc=function():Int64 of object;
1320
case (PropInfo^.PropProcs) and 3 of
1322
Result:=PInt64(Pointer(Instance)+Longint(PropInfo^.GetProc))^;
1326
if (PropInfo^.PropProcs and 3)=ptStatic then
1327
AMethod.Code:=PropInfo^.GetProc
1329
AMethod.Code:=PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.GetProc))^;
1330
AMethod.Data:=Instance;
1331
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
1332
result:=TGetInt64ProcIndex(AMethod)(PropInfo^.Index)
1334
result:=TGetInt64Proc(AMethod)();
1340
procedure SetInt64Prop(Instance: TObject; PropInfo: PPropInfo; const Value: Int64);
1342
TSetInt64ProcIndex=procedure(index:longint;i:Int64) of object;
1343
TSetInt64Proc=procedure(i:Int64) of object;
1347
case (PropInfo^.PropProcs shr 2) and 3 of
1349
PInt64(Pointer(Instance)+Longint(PropInfo^.SetProc))^ := Value;
1353
if ((PropInfo^.PropProcs shr 2) and 3)=ptStatic then
1354
AMethod.Code:=PropInfo^.SetProc
1356
AMethod.Code:=PPointer(Pointer(Instance.ClassType)+Longint(PropInfo^.SetProc))^;
1357
AMethod.Data:=Instance;
1358
if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
1359
TSetInt64ProcIndex(AMethod)(PropInfo^.Index,Value)
1361
TSetInt64Proc(AMethod)(Value);
1367
Function GetInt64Prop(Instance: TObject; const PropName: string): Int64;
1369
Result:=GetInt64Prop(Instance,FindPropInfo(Instance,PropName));
1373
Procedure SetInt64Prop(Instance: TObject; const PropName: string; const Value: Int64);
1375
SetInt64Prop(Instance,FindPropInfo(Instance,PropName),Value);
1379
{ ---------------------------------------------------------------------
1380
All properties through variant.
1381
---------------------------------------------------------------------}
1383
Function GetPropValue(Instance: TObject; const PropName: string): Variant;
1385
Result:=GetPropValue(Instance,PropName,True);
1389
Function GetPropValue(Instance: TObject; const PropName: string; PreferStrings: Boolean): Variant;
1394
Procedure SetPropValue(Instance: TObject; const PropName: string; const Value: Variant);
1399
{ ---------------------------------------------------------------------
1400
Easy access methods that appeared in Delphi 5
1401
---------------------------------------------------------------------}
1403
Function IsPublishedProp(Instance: TObject; const PropName: string): Boolean;
1405
Result:=GetPropInfo(Instance,PropName)<>Nil;
1408
Function IsPublishedProp(AClass: TClass; const PropName: string): Boolean;
1410
Result:=GetPropInfo(AClass,PropName)<>Nil;
1413
Function PropIsType(Instance: TObject; const PropName: string; TypeKind: TTypeKind): Boolean;
1415
Result:=FindPropInfo(Instance,PropName)^.PropType^.Kind=TypeKind
1418
Function PropIsType(AClass: TClass; const PropName: string; TypeKind: TTypeKind): Boolean;
1420
Result:=PropType(AClass,PropName)=TypeKind
1423
Function PropType(Instance: TObject; const PropName: string): TTypeKind;
1425
Result:=FindPropInfo(Instance,PropName)^.PropType^.Kind;
1428
Function PropType(AClass: TClass; const PropName: string): TTypeKind;
1430
Result:=FindPropInfo(AClass,PropName)^.PropType^.Kind;
1433
Function IsStoredProp(Instance: TObject; const PropName: string): Boolean;
1435
Result:=IsStoredProp(instance,FindPropInfo(Instance,PropName));
846
1440
$Log: typinfo.pp,v $
847
Revision 1.1.2.6 2000/12/13 23:26:13 sg
848
* Fixed typo in SetFloatProp
849
* Rewrote GetStrProp, now all AnsiString will be correctly
852
Revision 1.1.2.5 2000/12/13 10:10:59 michael
853
+ Applied patch from Mattias Gaertner, bug 1273
855
Revision 1.1.2.4 2000/12/10 14:18:50 michael
856
+ Applied fix from Mattias Gaertner (bug 1288)
858
Revision 1.1.2.3 2000/12/03 21:58:53 peter
859
* typekind is the same as 1.1
861
Revision 1.1.2.2 2000/11/25 18:34:00 sg
862
* (Final) fix for AnsiString reference counter problem in SetStrProp
864
Revision 1.1.2.1 2000/07/17 07:10:29 sg
865
* Fixed GetEnumValue (bug #1049, reported by Neil Graham)
867
Revision 1.1 2000/07/13 06:31:01 michael
870
Revision 1.43 2000/06/29 08:47:13 sg
871
* Bugfix for SetAStrProp (reference counter hasn't been increased)
872
* Implemented GetInt64Prop
874
Revision 1.42 2000/06/22 20:02:51 peter
875
* qword,int64 rtti support basics
877
Revision 1.41 2000/06/22 15:31:09 sg
878
* Fixed a small typo in my previous update
880
Revision 1.40 2000/06/22 15:29:31 sg
881
* Added prototypes for GetInt64Prop and SetInt64Prop
882
* Added constants "BooleanIdents" and "DotSep"
884
Revision 1.39 2000/05/18 09:42:17 michael
885
+ GetPropInfo now case insensitive
887
Revision 1.38 2000/02/15 14:39:56 florian
888
* disabled FIXED data type per default
890
Revision 1.37 2000/02/09 16:59:33 peter
893
Revision 1.36 2000/01/07 16:41:44 daniel
896
Revision 1.35 2000/01/07 16:32:29 daniel
897
* copyright 2000 added
899
Revision 1.34 2000/01/06 01:08:33 sg
900
* _This_ is the real revision 1.32... :-)
902
Revision 1.33 2000/01/06 00:23:24 pierre
903
* missing declarations for otChar andotWChar added
905
Revision 1.32 2000/01/05 18:59:56 sg
906
* Fixed missing () in InsertProp which caused memory corruptions
907
* GetOrdProp handles Char and WChar now. (there are still some
908
property types missing!)
910
Revision 1.31 1999/12/28 12:19:36 jonas
911
* replaced "movl mem,%eax; xorl %eax,%eax" with "movl mem,%eax;
914
Revision 1.30 1999/11/06 14:41:31 peter
917
Revision 1.29 1999/09/16 08:59:48 florian
918
* GetPropInfo returns now nil if the property wasn't found
920
Revision 1.28 1999/09/15 20:27:24 florian
921
+ patch of Sebastion Guenther applied: Get/SetMethodProp implementation
923
Revision 1.27 1999/09/08 16:14:43 peter
926
Revision 1.26 1999/09/03 15:39:23 michael
927
* Fixes from Sebastian Guenther
929
Revision 1.25 1999/08/29 22:21:27 michael
930
* Patch from Sebastian Guenther
932
Revision 1.24 1999/08/06 13:21:40 michael
933
* Patch from Sebastian Guenther
b'\\ No newline at end of file'
1441
Revision 1.25 2004/05/24 21:05:19 florian
1442
* fixed comp property writing for cpus where comp=int64
1444
Revision 1.24 2004/05/23 19:00:40 florian
1445
+ added widestring routines
1447
Revision 1.23 2004/02/22 16:48:39 florian
1448
* several 64 bit issues fixed
1450
Revision 1.22 2004/02/21 22:53:49 florian
1451
* several 64 bit/x86-64 fixes
1453
Revision 1.21 2004/02/20 15:55:26 peter
1454
* enable variant again
1456
Revision 1.20 2003/12/24 22:27:13 peter
1460
Revision 1.19 2003/12/22 11:32:04 marco
1461
* splitted up tintfflags into several components
1463
Revision 1.18 2003/10/24 08:37:20 marco
1466
Revision 1.17 2003/10/17 20:58:27 olle
1467
* Changed m68k to cpum68k, i386 to cpui386
1469
Revision 1.16 2003/04/24 11:46:25 florian
1470
* fixed wrong newlines
1472
Revision 1.15 2003/03/29 16:55:56 michael
1473
+ Patch from Mattias Gaertner for single typeinfo
1475
Revision 1.14 2002/09/07 16:01:22 peter
1476
* old logs removed and tabs fixed
1478
Revision 1.13 2002/04/04 18:32:59 peter
1479
* merged getpropinfo fix