Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2012-07

Opening FPC base classes

10 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin Schreiber

Hi,
I am the author of MSEide+MSEgui, a Free Pascal development environment: http://sourceforge.net/projects/mseide-msegui/

MSEide+MSEgui is not Delphi compatible and handles some basic TComponent issues differently to Lazarus:
http://www.lazarus.freepascal.org/

Is it possible to add
"
  protected //for toolkit access only
   property OwnerPrivate: TComponent read FOwner write FOwner; deprecated;
   property NamePrivate: TComponentName read FName write FName; deprecated;
   property ComponentsPrivate: TfpList read FComponents
                             write FComponents; deprecated;
   property ComponentStatePrivate: TComponentState read FComponentState
                             write FComponentState; deprecated;
   property FreeNotifiesPrivate: TFpList read FFreeNotifies
                             write FFreeNotifies; deprecated;
"
to TComponent in order other toolkits than Lazarus can fulfil their
taskwithout the necessity of changes in the FPC RTL?

TReader and TWriter are classes which normally are used by frameworks only. Is it possible to move all private fields of TFiler, TReader and TWriter to protected in order other toolkits than Lazarus can fulfil their task without the necessity of changes in the FPC RTL?

Is it possible to add
"
  protected //for toolkit access only
   property HandlePrivate: THandle read FHandle
                             write FHandle; deprecated;
" to THandleStream
and
"
  protected //for toolkit access only
   property CapacityPrivate: PtrInt read FCapacity
                             write FCapacity; deprecated;
" to TMemoryStream?

Thank you very much,

Martin

Reply by email

Unknown author
to Martin Schreiber
Martin Schreiber wrote 22 lines
Hi, I am the author of MSEide+MSEgui, a Free Pascal development environment: http://sourceforge.net/projects/mseide-msegui/ MSEide+MSEgui is not Delphi compatible and handles some basic TComponent issues differently to Lazarus: http://www.lazarus.freepascal.org/ Is it possible to add " protected //for toolkit access only property OwnerPrivate: TComponent read FOwner write FOwner; deprecated; property NamePrivate: TComponentName read FName write FName; deprecated; property ComponentsPrivate: TfpList read FComponents write FComponents; deprecated; property ComponentStatePrivate: TComponentState read FComponentState write FComponentState; deprecated; property FreeNotifiesPrivate: TFpList read FFreeNotifies write FFreeNotifies; deprecated; " to TComponent in order other toolkits than Lazarus can fulfil their taskwithout the necessity of changes in the FPC RTL?

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.

We can discuss alternative solutions for the tasks you need to do, if you'd care to explain them in detail.

Show quoted text 5 lines
TReader and TWriter are classes which normally are used by frameworks only. Is it possible to move all private fields of TFiler, TReader and TWriter to protected in order other toolkits than Lazarus can fulfil their task without the necessity of changes in the FPC RTL?

No problems here, we can give protected access to all of these fields.

Show quoted text 7 lines
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.

Show quoted text 6 lines
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 ?

Michael.

Reply by email

Martin Schreiber
to Unknown author
Show quoted text 6 lines
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.

[...]

Show quoted text 19 lines
> 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.

Show quoted text 11 lines
> 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

Reply by email

Unknown author
to Martin Schreiber
Martin Schreiber wrote 9 lines
On Monday 23 July 2012 13:58:56 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".

You ask to throw away the very purpose and reason of existence for TComponent. This is not going to happen.

The 'deprecated' does not change that. These fields are private for a reason. Making them protected exposes them e.g. in TForm and TDatamodule from Lazarus, which is a can of worms we are not going to open.

Please explain the actual problem. Till now you explain your solution to a problem you seem to have, not the problem itself. You hide behind other 'potential' problems.

And in general:
if TComponent imposes such restrictions on what you want to do: Simply do not use it. There is nothing sacred about TComponent. Lazarus for instance only requires TPersistent.

This is not as bad or such a big obstacle as it may seem: The tiOPF framework has written a complete class system without referring to TPersistent or TComponent, it uses RTII successfully. It works very well, I use it myself.

I don't see why you cannot do the same. It's perfectly possible to use the streaming system for both TComponent and other classes. All it takes is RTTI, which happens to be enabled in TPersistent.

If we need to make some adjustments in TFiler so it will treat additionally other classes as it currently treats TComponent, we can do that as well. This should not be hard to do. You probably only need 3 things:
- Decide (based on a class) whether to descend in a component or write a reference.
- Set the name.
- Set the owner/parent.
These operations can be moved to virtual methods, and then the streaming can stream a TComponent as well as a (supposed) TMSEComponent tree.

Show quoted text 23 lines
[...] >> 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.

Fine.

Show quoted text 35 lines
>> 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.

If it is internal to tmesefilestream, why don't you create your own descendent of TCustomMemoryStream ? If it is for this purpose, then it seems to be far easier to use that technique than to request this change. There is nothing magical about TMemoryStream.

Michael.

Reply by email

Martin Schreiber
to Unknown author
Show quoted text 26 lines
You ask to throw away the very purpose and reason of existence for TComponent. This is not going to happen. The 'deprecated' does not change that. These fields are private for a reason. Making them protected exposes them e.g. in TForm and TDatamodule from Lazarus, which is a can of worms we are not going to open. Please explain the actual problem. Till now you explain your solution to a problem you seem to have, not the problem itself. You hide behind other 'potential' problems. And in general: if TComponent imposes such restrictions on what you want to do: Simply do not use it. There is nothing sacred about TComponent. Lazarus for instance only requires TPersistent. This is not as bad or such a big obstacle as it may seem: The tiOPF framework has written a complete class system without referring to TPersistent or TComponent, it uses RTII successfully. It works very well, I use it myself. I don't see why you cannot do the same. It's perfectly possible to use the streaming system for both TComponent and other classes. All it takes is RTTI, which happens to be enabled in TPersistent.

Because of integration of third party components. But you are probably right, it seems to be the time to leave FCL compatibility. The design of TPersistent/TComponent and the whole classes unit has been made by Borland so that it made the development of a concurrent IDE to Delphi as difficult as possible. I hope Free Pascal has not the same attitude. ;-)

Thank you again for your time,

Martin

Reply by email

Unknown author
to Martin Schreiber
Martin Schreiber wrote 11 lines
On Monday 23 July 2012 15:31:42 wrote: > > I don't see why you cannot do the same. It's perfectly possible to use the > streaming system for both TComponent and other classes. All it takes is > RTTI, which happens to be enabled in TPersistent. > Because of integration of third party components. But you are probably right, it seems to be the time to leave FCL compatibility. The design of TPersistent/TComponent and the whole classes unit has been made by Borland so that it made the development of a concurrent IDE to Delphi as difficult as possible.

I've never seen it as such. There is nothing special about the classes unit. It uses available RTTI in a certain way, that's it.

You're free to create a system that uses the same RTTI in a completely different way, and build an eco system around this.

That you then cannot use code that expects the functionality of the classes unit, is a consequence you must accept.

I hope Free Pascal has not the same attitude. ;-)

Well, for starters, I don't draw the same conclusion as you:

You don't need to leave compatibility behind. IMO it is perfectly possible to design a streaming system that streams both TComponents as non-TComponents, given a few small changes to TFiler. That would allow you to re-use third-party TComponent descendents and still offer all the things you need in msegui/mseide.

I see that as a useful extension, and you can always ask for changes that would make this possible.

Michael.

Reply by email

Ivanko B
to Martin Schreiber: Because of integration of third party components. But you are probably right, it seems to…

These fields are private for a reason.
Making them protected exposes them e.g. in TForm and TDatamodule from Lazarus, which is a can of worms we are not going to open. ====================================
Such (exposing private fields to the protected level) properties may have special names which can be filtered out.
Guys, please take into consideration not only Martin but also Graeme,.. :)

2012/7/23, Martin Schreiber :

Show quoted text 45 lines
On Monday 23 July 2012 15:31:42 wrote: > > You ask to throw away the very purpose and reason of existence for > TComponent. This is not going to happen. > > The 'deprecated' does not change that. These fields are private for a > reason. Making them protected exposes them e.g. in TForm and TDatamodule > from Lazarus, which is a can of worms we are not going to open. > > Please explain the actual problem. Till now you explain your solution to > a > problem you seem to have, not the problem itself. You hide behind other > 'potential' problems. > > And in general: > if TComponent imposes such restrictions on what you want to do: Simply do > not use it. There is nothing sacred about TComponent. Lazarus for > instance > only requires TPersistent. > > This is not as bad or such a big obstacle as it may seem: The tiOPF > framework has written a complete class system without referring to > TPersistent or TComponent, it uses RTII successfully. > It works very well, I use it myself. > > I don't see why you cannot do the same. It's perfectly possible to use > the > streaming system for both TComponent and other classes. All it takes is > RTTI, which happens to be enabled in TPersistent. > Because of integration of third party components. But you are probably right, it seems to be the time to leave FCL compatibility. The design of TPersistent/TComponent and the whole classes unit has been made by Borland so that it made the development of a concurrent IDE to Delphi as difficult as possible. I hope Free Pascal has not the same attitude. ;-) Thank you again for your time, Martin _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Michael Van Canneyt
to Ivanko B
Ivanko B wrote 6 lines
These fields are private for a reason. Making them protected exposes them e.g. in TForm and TDatamodule from Lazarus, which is a can of worms we are not going to open. ==================================== Such (exposing private fields to the protected level) properties may have special names which can be filtered out.

If you don't want the limitations of TComponent, then do not use it.

Guys, please take into consideration not only Martin but also Graeme,.. :)

Graeme doesn't care one way or the other, since tiOPF (which he bases his classes on) doesn't use TComponent in the first place.

I'm open for legitimate extensions.

Martin - it should be noted - has never bothered to explain why he needs these changes. We got vague we do not know what extensions he needs, we cannot investigate the problems and give solutions.

End of story. I wasted enough time on this discussion.

Michael.

Reply by email

Martin Schreiber
to Ivanko B: These fields are private for a reason. Making them protected exposes them e.g. in TForm…
Ivanko B wrote 8 lines
These fields are private for a reason. Making them protected exposes them e.g. in TForm and TDatamodule from Lazarus, which is a can of worms we are not going to open. ==================================== Such (exposing private fields to the protected level) properties may have special names which can be filtered out. Guys, please take into consideration not only Martin but also Graeme,.. :)

Graeme does not need it, fpGUI does not stream components, has no IDE and is not such vanguard. ;-)

Martin

Reply by email

Graeme Geldenhuys
to Martin Schreiber
Martin Schreiber wrote
> Guys, please take into consideration not only Martin but also Graeme,.. :) > Graeme does not need it, fpGUI does not stream components, has no IDE...

For good reason. I don't want the headaches of designing and supporting a full blown IDE. I also don't like the 2+ files per Form that Lazarus IDE or MSEide uses, and which requires streaming. So I created a Forms Designer that doesn't require streaming, saved me some headaches, but also brought about some new features like... only one file needed for a Form design, support for 1 or more Forms designed in a single code unit, etc..

And as Michael mentioned, tiOPF is the only framework I use (and helped develop) for ALL my database needs. tiOPF is even handy to use in non-database applications. And Michael is correct - it doesn't use TComponent or does use RTTI extensively though.

I do agree with Michael though that issues with FPC's class designs must be discussed on a case-by-case basis, otherwise you throw the whole class hierarchy/design out the window.

Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Reply by email