[fpc-devel] Opening FPC base classes

Martin Schreiber mse00000 at gmail.com
Mon Jul 23 14:57:01 CEST 2012


On Monday 23 July 2012 13:58:56 michael.vancanneyt at wisa.be wrote:
>
> These fields must remain private to ensure proper functioning of the
> component system. Too much depends on the proper functioning of the
> notification API and the owner/owned relations and its inherent memory
> management.
>
That is one of the reasons I need the full control. Please remember, the 
properties are "deprecated".
There is a risk that I fall into a trap and must wait until changes in the RTL 
have been accepted and the next FPC version has been released until I can 
advance. It is also an assurance to be able to implement hotfixes for 
TComponent issues which sometimes happen. I hope this is sufficient to 
justify the deprecated protected properties.
To discuss the different design goals and implementations of Lazarus and 
MSEide+MSEgui component design time handling and runtime streaming would be 
very hard and timeconsuming. And if me or any other kit developer has new 
ideas we are at the same point again.

[...]

> > Is it possible to add
> > "
> >  protected //for toolkit access only
> >   property HandlePrivate: THandle read FHandle
> >                             write FHandle; deprecated;
> > " to THandleStream
>
> No problems here. We can do this as well, provided we can make the
> signature slightly different:
>
>
>   protected
>     Procedure SetHandle(AHandle : THandle); virtual;
>     property HandlePrivate: THandle read SetHandle
>
> SetHandle will just set the FHandle fields, but I want a virtual setter
> so descendent classes get a chance to react on the change in case they need
> to.
>
Then SetHandle() is sufficient.

> > and
> > "
> >  protected //for toolkit access only
> >   property CapacityPrivate: PtrInt read FCapacity
> >                             write FCapacity; deprecated;
> > " to TMemoryStream?
>
> TMemoryStream.Capacity is already read/write.
>
> Why do you think you need direct access to the field ?
>
"
  TMemoryStream = class(TCustomMemoryStream)
  private
    FCapacity: PtrInt;
    procedure SetCapacity(NewCapacity: PtrInt);
  protected
    function Realloc(var NewCapacity: PtrInt): Pointer; virtual;
    property Capacity: PtrInt read FCapacity write SetCapacity;

procedure TMemoryStream.SetCapacity(NewCapacity: PtrInt);

begin
  SetPointer (Realloc(NewCapacity),Fsize);
  FCapacity:=NewCapacity;
end;

"

The reason is to replace the memory without to trigger Realloc(). Used in the 
internal memory stream of tmsefilestream. tmsefilestream.create() behaves as 
memory stream, tmesefilestream('thefilename') as file so the descendants 
(ttextdatastream for example) can work with all the different stream kinds 
and inherit from TStream.

"
 tmsefilestream = class(thandlestream)
[...]
   constructor create(const afilename: filenamety; 
                      const aopenmode: fileopenmodety = fm_read;
                      const accessmode: fileaccessmodesty = [];
                      const rights: filerightsty = defaultfilerights); 
overload;
   constructor createtransaction(const afilename: filenamety;
                      rights: filerightsty = defaultfilerights); overload;
   constructor createtempfile(const prefix: filenamety; out afilename: 
filenamety);
   constructor create(ahandle: integer); overload; virtual; //allways called
   constructor create; overload; 
                                  //memorystream
   constructor create(const aopenmode: fileopenmodety); overload; 
                                  //memorystream
   constructor createstringcopy(const adata: string); //implies fm_read
"

Martin



More information about the fpc-devel mailing list