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

Jon D. Sawyer badquanta6384 at comcast.net
Wed Apr 7 00:34:39 CEST 2004


I appreciate the help but I'm not sure if you understand what it is I'm
trying to do.

SetFlag() and GetFlag() do binary operations on the flags controling an
SDL Surface.

Passing the BitMask to the GetFlag() will return weither or not the bit
is on in the flags variable.

Passing the BitMask and a boolean will turn on / off the bit in the
flags variable.

I wanted to provide shortcuts to GetFlag(SDL_SWSurface) and
SetFlag(SDL_Surface, TRUE) so you could say: SWSurface := TRUE;

If I understand correctly Indexed properties have to be signed interger
type... which would ruin the bitwise comparison because the Bit Mask is
a Unsigned integer type.

On Tue, 2004-04-06 at 06:29, Matt Emson wrote:
> > 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);
> 
> Looks like you're tying to use an indexed property. Dunno what mode you're
> using, but in Delphi mode:
> 
> unit Example;
> 
> interface
> 
> type
> 
>  t = class
>  private
>     FSurface: SDL_SWSurface;
> 
>     function GetSWSurfaceFlags(index: integer): Boolean;
>     procedure SetSWSurfaceFlags(index: integer; const Value: Boolean);
>  public
>    property SWSurfaceFlags[index: integer] : Boolean read GetSWSurfaceFlags
> write SetSWSurfaceFlags;
>  end;
> 
> implementation
> 
> { t }
> 
> function t.GetSWSurfaceFlags(index: integer): Boolean;
> begin
>   /// do stuff with FSurface
> end;
> 
> procedure t.SetSWSurfaceFlags(index: integer; const Value: Boolean);
> begin
>   /// do stuff with FSurface
> end;
> 
> end.
> 
> 
> You would then implement the get/set by implementing read/writes to
> SDL_SWSurface...
> 
> I would have thought that this is quite limiting though. I would also have
> a:
> 
> property SWSurfaceColor[index: uint32] : TColor
>   read GetSWSurfaceColor write SetSWSurfaceColor;
> 
> 
> function t.GetSWSurfaceColor(index: uint32): TColor;
> 
> procedure t.SetSWSurfaceColor(index: uint32; const value: TColor);
> 
> The params are not me being pedantic, by the was, but the way in which
> Delphi implements properties. Other FPC modes may be a little more
> forgiving.
> 
> Hope that helps,
> 
> Matt
> 
> 
> 
> 
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal





More information about the fpc-pascal mailing list