On Mon, Sep 23, 2013 at 4:28 PM, Zaher Dirkey wrote:
> The idea is simply than needs to use a stream or RTTI, it is like a
> record, if looked at an object like as a record but it is inheritable.
> Compile can now every object body, and do the assigning as record assign.
>
> That's the featur
On Mon, Sep 23, 2013 at 12:58 PM, Graeme Geldenhuys wrote:
>
> Also be careful about the pitfalls of cloning a class. eg: How you want
> to handle more complex cases. eg: Cloning a class with a reference to
> another class, or cloning a class with an embedded class (field), etc...
> tiOPF's imple
On 23/09/13 10:46, Michael Van Canneyt wrote:
> I've done this several times, it works well for most situations.
My I also suggest Zaher takes a look at tiOPF's code to see how they
implement class cloning.
Also be careful about the pitfalls of cloning a class. eg: How you want
to handle more com
Am 23.09.2013 14:23, schrieb patspiper:
On 23/09/13 14:57, Michael Van Canneyt wrote:
On Mon, 23 Sep 2013, Mattias Gaertner wrote:
On Mon, 23 Sep 2013 11:46:54 +0200 (CEST)
Michael Van Canneyt wrote:
On Mon, 23 Sep 2013, Zaher Dirkey wrote:
On Mon, Sep 23, 2013 at 10:02 AM, Michael V
On Mon, 23 Sep 2013, Frederic Da Vitoria wrote:
Yes. But that works only for 'simple' types and still requires you to write
code.
For the more general case where you can have arrays, classes, interfaces and
whatnot as fields of your object, there is simply no correct way.
Isn't there? Ma
2013/9/23 Michael Van Canneyt
>
> On Mon, 23 Sep 2013, Mattias Gaertner wrote:
>
> On Mon, 23 Sep 2013 11:46:54 +0200 (CEST)
>> Michael Van Canneyt wrote:
>>
>> On Mon, 23 Sep 2013, Zaher Dirkey wrote:
>>>
>>> On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt <
mich...@freepascal.org
On 23/09/13 14:57, Michael Van Canneyt wrote:
On Mon, 23 Sep 2013, Mattias Gaertner wrote:
On Mon, 23 Sep 2013 11:46:54 +0200 (CEST)
Michael Van Canneyt wrote:
On Mon, 23 Sep 2013, Zaher Dirkey wrote:
On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt
wrote:
Var
C : TBaseObjectC
On Mon, 23 Sep 2013, Mattias Gaertner wrote:
On Mon, 23 Sep 2013 11:46:54 +0200 (CEST)
Michael Van Canneyt wrote:
On Mon, 23 Sep 2013, Zaher Dirkey wrote:
On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt
wrote:
Var
C : TBaseObjectClass;
begin
C:=TBase
On Mon, 23 Sep 2013 12:10:41 +0200
Frederic Da Vitoria wrote:
> 2013/9/23 Mattias Gaertner
>
> > On Mon, 23 Sep 2013 11:46:54 +0200 (CEST)
> > Michael Van Canneyt wrote:
> >
> > >
> > >
> > > On Mon, 23 Sep 2013, Zaher Dirkey wrote:
> > >
> > > >
> > > > On Mon, Sep 23, 2013 at 10:02 AM, Micha
On Mon, 23 Sep 2013 13:13:27 +0300
Zaher Dirkey wrote:
> On Mon, Sep 23, 2013 at 12:57 PM, Mattias Gaertner <
> nc-gaert...@netcologne.de> wrote:
>
> > type
> > TMyClass = class(TPersistent)
> > private
> >type
> > TMyClassVars = record
> >a,b,c: string;
> > end;
> > pri
On Mon, Sep 23, 2013 at 12:57 PM, Mattias Gaertner <
nc-gaert...@netcologne.de> wrote:
> type
> TMyClass = class(TPersistent)
> private
>type
> TMyClassVars = record
>a,b,c: string;
> end;
> private
>F: TMyClassVars;
> public
>procedure Assign(Source: TPersistent)
2013/9/23 Mattias Gaertner
> On Mon, 23 Sep 2013 11:46:54 +0200 (CEST)
> Michael Van Canneyt wrote:
>
> >
> >
> > On Mon, 23 Sep 2013, Zaher Dirkey wrote:
> >
> > >
> > > On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt <
> mich...@freepascal.org> wrote:
> > > Var
> > > C : TB
On Mon, 23 Sep 2013 11:46:54 +0200 (CEST)
Michael Van Canneyt wrote:
>
>
> On Mon, 23 Sep 2013, Zaher Dirkey wrote:
>
> >
> > On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt
> > wrote:
> > Var
> > C : TBaseObjectClass;
> > begin
> > C:=TBaseObjectClass(Clas
On Mon, 23 Sep 2013, Zaher Dirkey wrote:
On Mon, Sep 23, 2013 at 12:46 PM, Michael Van Canneyt
wrote:
There is no such safe mechanism.
The best you can do is make the properties published, and write an RTTI
lookup routine that copies all Published values.
I've done this
On Mon, Sep 23, 2013 at 12:46 PM, Michael Van Canneyt <
mich...@freepascal.org> wrote:
> There is no such safe mechanism.
>
> The best you can do is make the properties published, and write an RTTI
> lookup routine that copies all Published values.
> I've done this several times, it works well for
On Mon, 23 Sep 2013, Zaher Dirkey wrote:
On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt
wrote:
Var
C : TBaseObjectClass;
begin
C:=TBaseObjectClass(ClassType);
Result:=C.Create;
end;
Yes, that help me, thanks.
Now about assigning I must re
On Mon, Sep 23, 2013 at 10:02 AM, Michael Van Canneyt <
mich...@freepascal.org> wrote:
> Var
> C : TBaseObjectClass;
> begin
> C:=TBaseObjectClass(ClassType)**;
> Result:=C.Create;
> end;
>
Yes, that help me, thanks.
Now about assigning I must repeat it (assign) for every child class copy
On Mon, 23 Sep 2013, patspiper wrote:
On 23/09/13 10:02, Michael Van Canneyt wrote:
This is wrong. You are typecasting a class reference to an object instance.
The following works:
{$mode objfpc}
Type
TBaseObject = class(TObject)
public
constructor Create; virtual;
function Clone
On 23/09/13 10:02, Michael Van Canneyt wrote:
This is wrong. You are typecasting a class reference to an object
instance.
The following works:
{$mode objfpc}
Type
TBaseObject = class(TObject)
public
constructor Create; virtual;
function Clone:TBaseObject;
end;
TBaseObjectClass
On Mon, 23 Sep 2013, Zaher Dirkey wrote:
Hi,
I have objects (classes) derived from base one
TBaseObject = class(TObject)
public
constructor Create; virtual;
function Clone:TBaseObject;
end;
TMyObject = class(TBaseObject)
my fields here
end;
o1, o2:TmyObject;
o1 already created;
o
On Mon, Sep 23, 2013 at 8:50 AM, Sven Barth wrote:
> You need to add a "Result.Assign(Self)" to your clone call and implement
> a virtually inherited "Assign" method in each class where you copy all
> fields. This is how "TPersistent" and its descendants do it as well.
Yes I added assign, but a
Am 23.09.2013 07:15 schrieb "Zaher Dirkey" :
>
> Hi,
> I have objects (classes) derived from base one
>
> TBaseObject = class(TObject)
> public
>constructor Create; virtual;
>function Clone:TBaseObject;
> end;
>
> TMyObject = class(TBaseObject)
>my fields here
> end;
>
> o1, o2:TmyObjec
22 matches
Mail list logo