[fpc-pascal] Enum RTTI
jonas.maebe at elis.ugent.be
Thu Nov 5 11:26:19 CET 2009
On 05 Nov 2009, at 11:16, Wimpie Nortje wrote:
>>> 1) for enum_first to enum_last do....
>> Is there any way to achieve the following easily:
>> No, because succ/pred are not defined for sparse enums.
>>> 2) NumberOfItems(enum)
>> No. Even typeinfo() doesn't work for sparse enums.
> I don't think I use sparse enums. Mine are declared like:
> type aEnum = (Val1, Val2);
> So I think the Succ/Pred should work.
They do, and so do low/high:
$ cat tt2.pp
type aEnum = (Val1, Val2);
for e := low(aEnum) to high(aEnum) do
$ /usr/local/lib/fpc/2.2.4/ppcppc tt2
Free Pascal Compiler version 2.2.4 [2009/04/05] for powerpc
Copyright (c) 1993-2008 by Florian Klaempfl
Target OS: Darwin for PowerPC
8 lines compiled, 0.4 sec
I thought you were talking about sparse enums because you said that
low/high didn't work.
More information about the fpc-pascal