fpc/tests/webtbs/tw8660.pp
Jonas Maebe a0b57eddb5 * new internal set format for big endian systems. Advantages:
* varsets ({$packset x}) are now supported on big endian targets
    * gdb now displays sets properly on big endian systems
    * cleanup of generic set code (in, include/exclude, helpers), all
      based on "bitpacked array[] of 0..1" now
  * there are no helpers available yet to convert sets from the old to
    the new format, because the set format will change again slightly
    in the near future (so that e.g. a set of 24..31 will be stored in
    1 byte), and creating two classes of set conversion helpers would
    confuse things (i.e., it's not recommended to use trunk currently for
    programs  which load sets stored to disk by big endian programs compiled
    by previous FPC versions)
  * cross-endian compiling has been tested and still works, but one case
    is not supported: compiling a compiler for a different endianess
    using a starting compiler from before the current revision (so first
    cycle natively, and then use the newly created compiler to create a
    cross-compiler)

git-svn-id: trunk@7395 -
2007-05-19 17:15:15 +00:00

42 lines
868 B
ObjectPascal

{$mode objfpc}
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 (on little endian systems)
V := C.St;
writeln(sizeof(V), ' ', byte(V)); // It's OK
writeln(sizeof(C.St), ' ', byte(C.St)); // It's OK
{$ifdef FPC_LITTLE_ENDIAN}
if GetOrdProp(C, 'St')<>5 then
{$else}
if GetOrdProp(C, 'St')<>160 then
{$endif}
halt(1);
if GetSetProp(C, 'St')<>'ckNormal,ckVip' then
halt(1);
writeln('ok');
end.