Class Object


			
class Object : public GCable
Programmer: Ryan Davis

Description:

Defines the smalltalk object model in terms of C++. Because objects are of varying length, some members don't actually exist and can be considered "virtual". This class _requires_ custom memory management.

Public Methods:

ClassPtr & klass ();
I return an ObjectPtr to the object's class.

UInteger objectCount ();
I return the number of object slots.

UInteger byteCount ();
I return the number of inline bytes stored.

ObjectPtr & object (const UInteger N);
I am the accessor to the Nth object stored. I assert that N < objectCount()

char & byte (const UInteger N);
I am the accessor to the Nth byte stored. I assert that N < byteCount()

char * byteString ();
I return the address of the first byte in the byteArray. DEFINE_SIZE - not needed because object is varying length, and properly calculated below...

virtual UInteger size ();
I return the total object size in bytes. Methods

Protected Methods:

void * operator new ( size_t size, Object * location);
I am the Object constructor... Since I am protected, I cannot be created on the stack... I must be invoked through my factory method create.

ObjectPtr * objectArray ();
I return the address of the first object in the objectArray.

virtual Boolean collectSubs ();
I override GCable's collectSubs because my sub-pointers need to be collected.

static UInteger calculateSize (UInteger objects, UInteger bytes);
Data

Protected Members:


ClassPtr myClass;



UInteger myObjectCount;



UInteger myByteCount;
ObjectPtr * myObjects; char * myBytes; The last two elements don't actually exist, per se. They are simulated through their respective accessor methods. This is needed in order to achieve the effect of a variable length object. However, this does require manual memory management for this class. Described later (when understood).