From: | Sensei |
Date: | 08 Aug 2000 at 15:53:53 |
Subject: | Re: OM_NEW (was: Re: BOOPSI again & again) |
Czesc Allan!
Dnia 07-Aug-00, Allan Odgaard napisa�:
> A2 is the object pointer, but during OM_NEW it's AFAIK used to hold a
> pointer to the class structure.
> So if you trash this, the boopsi rootclass won't be able to create the
> object (even though it could just use A0) -- I don't know why it's like
> this, maybe Olaf could give us some background info?
I can ;): A0 is a pointer to Hook structure (&class->cl_Dispatcher) of
actually
executed class, but rootclass must know which class object it has to create
in its own dispatcher...
If my explanation is not clear, maybe below MUI-based example will:
Area class is a subclass of Notify class and Notify class is a subclass of
rootclass, so when OM_NEW method is pased to Area class dispatcher, it will
do:
if( object = DoSuperMethodA( areaiclass, object (in fact areaiclass), msg ) )
{ ... }
Then method is passed to Notify class dispatcher and it will do:
if( object = DoSuperMethodA( notifyiclass, object (areaiclass), msg ) )
{ ... }
Then method is passed to rootclass dispatcher and it will do:
/*
* Sorry, we can only guessing, AmigaOS source is not available, yet ;))
*/
Calculate size of all classes objects:
struct IClass *iclass1 = (struct IClass *) object;
struct _Object *_object;
ULONG size = sizeof( struct _Object );
while( iclass1->cl_Super )
{
size += iclass1->cl_InstSize;
iclass1 = iclass->cl_Super;
}
/*
* rootclass object have size 0 so we can omit size += iclass1->cl_InstSize;
* here...
*/
if( object = AllocMem( size, MEMFPUBLIC | MEMF_CLEAR ) )
{
object->oClass = (struct IClass *) object; (in fact still areaiclass)
object = BASEOBJECT( object );
}
return( object (in fact it is not struct Object pointer anymore - it's
Notify class instance data pointer now) );
Regards!
Przemyslaw 'SENSEI' Gruchala
code/gfx2d/gfx3d/webmaster
Amiga 1200
Apollo 1240/33 MHz, 18 MB RAM, BTC 33.6 bps
HDD 3.2 GB, HDD 520 MB, CD x12
---------------------------------------
250 tys. opisow stron w 16 kategoriach
Otwarty Katalog Onetu
http://oko.onet.pl
---------------------------------------