[fpc-pascal]Using UInt32 {LongWords} as Indexes for Properties.

Jon D. Sawyer badquanta at comcast.net
Tue Apr 6 07:58:50 CEST 2004


Ran into a problem of where I'm not sure how the code will work once I'm
finished and I'd rather not write all this if its not going to work:

I want to provide access to Bit-Flags that control a class of mine:

ig:

Property SWSurface : Boolean Index SDL_SWSurface 
Read GetFlags Write SetFlags;

If I declare Get/Set Flags as the following:
Function GetFlags(aBit: UInt32): Boolean;
Procedure SetFlags(aBit: UInt32; aBool: Boolean);

I of course get a bunch of:
cqsdl_surface.pp(17,6) Error: Illegal symbol for property access

So I set it to read:
Function GetFlags(aBit: Integer): Boolean;
Procedure SetFlags(aBit: Integer; aBool: Boolean);

And it compiles fine.  What I'm worried about is that if aBit is a
Signed Integer and the constant SDL_SWSurface was meant to be
treated as an Unsigned Integer can this code work the same?

This works:

Property Flags[aBit: UInt32]: Boolean Read GetFlag Write SetFlag;
Function GetFlags(aBit: UInt32): Boolean;
Procedure SetFlags(aBit: UInt32; aBool: Boolean);

BUT it means that the programmer has to supply the Bit mask and THAT
means yet-another-uses statement just for a few damned constants.  The
entire point of me providing these specifically named properties was to
stop that.

Any Suggestions?  Feel free to smack me around for being an idiot.





More information about the fpc-pascal mailing list