Hi,
I've been attempting to assimilate the corresponding code to Ian Piumerta's
object model at http://piumarta.com/software/cola/objmodel2.pdf
My C knowledge is lacking, because I don't understand some of the basics in it.
I thought maybe some of you might be kind enough to elucidate.
I really don't understand what this means:
typedef struct object *(*method_t)(struct object *receiver, ...);
typedef provides a new definition of a type based on an existing type, right?
But what is the bit in brackets, and what is the ellipsis?
Also, what is this?
struct vtable *_vt[0];
Is that creating a pointer to a struct array which has zero elements in it? I
don't follow what that's for?
The other thing I don't follow AT ALL is the negative 1 indexes.
Code around line 128, point in case:
struct object *vtable_allocate(struct vtable *self, int payloadSize)
{
struct object *object = (struct object *)alloc(payloadSize);
object->_vt[-1] = self;
return object;
}
what is object ->_vt[-1] = self; ? I mean, I "get" the object -> _vt bit, but
the [-1] totally throws me. What's a negative 1 index on an array in C? I
didn't even know you could do this.
Any help would totally be appreciated, or any referral to these "topics" on
some educational resource somewhere. My old C books don't have these things in
them at all.
Julian.
_______________________________________________
fonc mailing list
[email protected]
http://vpri.org/mailman/listinfo/fonc