|
@@ -133,7 +133,11 @@ unit typinfo;
|
|
end;
|
|
end;
|
|
|
|
|
|
// unsed, just for completeness
|
|
// unsed, just for completeness
|
|
- TPropData = packed record
|
|
|
|
|
|
+ TPropData =
|
|
|
|
+{$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
|
|
|
|
+ packed
|
|
|
|
+{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
|
|
|
|
+ record
|
|
PropCount : Word;
|
|
PropCount : Word;
|
|
PropList : record end;
|
|
PropList : record end;
|
|
end;
|
|
end;
|
|
@@ -281,6 +285,16 @@ type
|
|
Auxiliary methods
|
|
Auxiliary methods
|
|
---------------------------------------------------------------------}
|
|
---------------------------------------------------------------------}
|
|
|
|
|
|
|
|
+function aligntoptr(p : pointer) : pointer;
|
|
|
|
+ begin
|
|
|
|
+{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
|
|
|
|
+ if (ptrint(p) mod sizeof(ptrint))<>0 then
|
|
|
|
+ inc(ptrint(p),sizeof(ptrint)-ptrint(p) mod sizeof(ptrint));
|
|
|
|
+ result:=p;
|
|
|
|
+{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
Function GetEnumName(TypeInfo : PTypeInfo;Value : Integer) : string;
|
|
Function GetEnumName(TypeInfo : PTypeInfo;Value : Integer) : string;
|
|
|
|
|
|
Var PS : PShortString;
|
|
Var PS : PShortString;
|
|
@@ -407,7 +421,7 @@ end;
|
|
|
|
|
|
Function GetTypeData(TypeInfo : PTypeInfo) : PTypeData;
|
|
Function GetTypeData(TypeInfo : PTypeInfo) : PTypeData;
|
|
begin
|
|
begin
|
|
- GetTypeData:=PTypeData(pointer(TypeInfo)+2+PByte(pointer(TypeInfo)+1)^);
|
|
|
|
|
|
+ GetTypeData:=PTypeData(aligntoptr(PTypeData(pointer(TypeInfo)+2+PByte(pointer(TypeInfo)+1)^)));
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -428,7 +442,7 @@ begin
|
|
// skip the name
|
|
// skip the name
|
|
hp:=GetTypeData(Typeinfo);
|
|
hp:=GetTypeData(Typeinfo);
|
|
// the class info rtti the property rtti follows immediatly
|
|
// the class info rtti the property rtti follows immediatly
|
|
- pd:=pointer(pointer(@hp^.UnitName)+Length(hp^.UnitName)+1);
|
|
|
|
|
|
+ pd:=aligntoptr(pointer(pointer(@hp^.UnitName)+Length(hp^.UnitName)+1));
|
|
Result:=@pd^.PropList;
|
|
Result:=@pd^.PropList;
|
|
for i:=1 to pd^.PropCount do
|
|
for i:=1 to pd^.PropCount do
|
|
begin
|
|
begin
|
|
@@ -436,7 +450,7 @@ begin
|
|
if Upcase(Result^.Name)=P then
|
|
if Upcase(Result^.Name)=P then
|
|
exit;
|
|
exit;
|
|
// skip to next property
|
|
// skip to next property
|
|
- Result:=PPropInfo(pointer(@Result^.Name)+byte(Result^.Name[0])+1);
|
|
|
|
|
|
+ Result:=PPropInfo(aligntoptr(pointer(@Result^.Name)+byte(Result^.Name[0])+1));
|
|
end;
|
|
end;
|
|
// parent class
|
|
// parent class
|
|
Typeinfo:=hp^.ParentInfo;
|
|
Typeinfo:=hp^.ParentInfo;
|
|
@@ -533,17 +547,18 @@ Var
|
|
begin
|
|
begin
|
|
TD:=GetTypeData(TypeInfo);
|
|
TD:=GetTypeData(TypeInfo);
|
|
// Get this objects TOTAL published properties count
|
|
// Get this objects TOTAL published properties count
|
|
- TP:=(@TD^.UnitName+Length(TD^.UnitName)+1);
|
|
|
|
|
|
+ TP:=aligntoptr(PPropInfo(aligntoptr((@TD^.UnitName+Length(TD^.UnitName)+1))));
|
|
Count:=PWord(TP)^;
|
|
Count:=PWord(TP)^;
|
|
// Now point TP to first propinfo record.
|
|
// Now point TP to first propinfo record.
|
|
Inc(Pointer(TP),SizeOF(Word));
|
|
Inc(Pointer(TP),SizeOF(Word));
|
|
|
|
+ tp:=aligntoptr(tp);
|
|
While Count>0 do
|
|
While Count>0 do
|
|
begin
|
|
begin
|
|
PropList^[0]:=TP;
|
|
PropList^[0]:=TP;
|
|
Inc(Pointer(PropList),SizeOf(Pointer));
|
|
Inc(Pointer(PropList),SizeOf(Pointer));
|
|
// Point to TP next propinfo record.
|
|
// Point to TP next propinfo record.
|
|
// Located at Name[Length(Name)+1] !
|
|
// Located at Name[Length(Name)+1] !
|
|
- TP:=PPropInfo(pointer(@TP^.Name)+PByte(@TP^.Name)^+1);
|
|
|
|
|
|
+ TP:=aligntoptr(PPropInfo(pointer(@TP^.Name)+PByte(@TP^.Name)^+1));
|
|
Dec(Count);
|
|
Dec(Count);
|
|
end;
|
|
end;
|
|
// recursive call for parent info.
|
|
// recursive call for parent info.
|
|
@@ -1475,7 +1490,10 @@ end;
|
|
end.
|
|
end.
|
|
{
|
|
{
|
|
$Log$
|
|
$Log$
|
|
- Revision 1.28 2004-08-16 16:12:28 peter
|
|
|
|
|
|
+ Revision 1.29 2004-10-04 21:26:16 florian
|
|
|
|
+ * rtti alignment fixed
|
|
|
|
+
|
|
|
|
+ Revision 1.28 2004/08/16 16:12:28 peter
|
|
* patch from mattias to fix endianness and bufferoverflow with
|
|
* patch from mattias to fix endianness and bufferoverflow with
|
|
1 and 2 byte ordinals
|
|
1 and 2 byte ordinals
|
|
|
|
|