* handle rtti for sets with a size of 1 and 2 properly, resolves #8660

git-svn-id: trunk@7125 -
This commit is contained in:
florian 2007-04-17 20:34:58 +00:00
parent c6fb0d4cab
commit c29455b111
5 changed files with 46 additions and 3 deletions

1
.gitattributes vendored
View File

@ -8153,6 +8153,7 @@ tests/webtbs/tw8513.pp svneol=native#text/plain
tests/webtbs/tw8525.pp svneol=native#text/plain
tests/webtbs/tw8573.pp svneol=native#text/plain
tests/webtbs/tw8615.pp svneol=native#text/plain
tests/webtbs/tw8660.pp svneol=native#text/plain
tests/webtbs/tw8664.pp svneol=native#text/plain
tests/webtbs/ub1873.pp svneol=native#text/plain
tests/webtbs/ub1883.pp svneol=native#text/plain

View File

@ -506,7 +506,14 @@ implementation
write_rtti_name(def);
if (tf_requires_proper_alignment in target_info.flags) then
current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(otULong));
case def.size of
1:
current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(otUByte));
2:
current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(otUWord));
4:
current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(otULong));
end;
if (tf_requires_proper_alignment in target_info.flags) then
current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_sym(ref_rtti(def.elementdef,rt)));

View File

@ -2094,7 +2094,7 @@ implementation
function tsetdef.is_publishable : boolean;
begin
is_publishable:=(settype=smallset);
is_publishable:=savesize in [1,2,4];
end;

View File

@ -84,7 +84,7 @@ unit typinfo;
case TTypeKind of
tkUnKnown,tkLString,tkWString,tkAString,tkVariant:
();
tkInteger,tkChar,tkEnumeration,tkWChar:
tkInteger,tkChar,tkEnumeration,tkWChar,tkSet:
(OrdType : TOrdType;
case TTypeKind of
tkInteger,tkChar,tkEnumeration,tkBool,tkWChar : (
@ -754,6 +754,7 @@ begin
DataSize:=1;
tkWChar:
DataSize:=2;
tkSet,
tkEnumeration,
tkInteger:
begin

34
tests/webtbs/tw8660.pp Normal file
View File

@ -0,0 +1,34 @@
program TestGetSetProp;
{$APPTYPE CONSOLE}{$PACKSET 1}
uses TypInfo;
{$M+}
type
TEnum = (ckNormal, ckBusiness, ckVip, ckCorporate);
TSet = set of TEnum;
TClient = class
private
_Num: byte; // Works if Integer
_St: TSet;
published
property Num: byte read _Num write _Num; // Works if Integer
property St: TSet read _St write _St;
end;
var
C : TClient;
V : TSet;
begin
C := TClient.Create;
C.Num := 2;
C.St := [ckVip, ckNormal]; // the numeric representation is 5
V := C.St;
writeln(sizeof(V), ' ', byte(V)); // It's OK
writeln(sizeof(C.St), ' ', byte(C.St)); // It's OK
if GetOrdProp(C, 'St')<>5 then
halt(1);
if GetSetProp(C, 'St')<>'ckNormal,ckVip' then
halt(1);
writeln('ok');
end.