Re: [AD] 4.3 graphic drivers

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 2005-11-11, Elias Pschernig <elias@xxxxxxxxxx> wrote:
> On Fri, 2005-11-11 at 22:38 +1100, Peter Wang wrote:
> > 
> > register_vtable_v1() would need to adapt V1 vtables to V2:
> > 
> >     void register_vtable_v1(VTABLE_V1 *v1)
> >     {
> > 	VTABLE_V2 *v2 = allocate_v2_vtable();
> > 	v2->v1_vtable = v1;
> > 	v2->new_method = NULL;
> > 	v2->some_method = v1_some_method_adaptor;
> >     }
> > 
> > I'm not sure where v1_some_method_adaptor is going to get the address of
> > v1->some_method from.  Presumably the same place as all the other
> > suggestions so far.  Once we decide V1 compatibility is no longer
> > needed, it can be thrown out.
> 
> Maybe each VTABLE needs a pointer to all the predecessors?

That's what I was thinking with the field `v2->v1_table'.  It would be a
bit ugly as we want drivers to fill in VTABLE_V2 instances statically,
but they would need to leave a blank slot for where the v1_vtable field
would go.

But the question remains, where does `v1_some_method_adaptor' get the
address of `v2->v1_vtable' from?  It has the function signature of
`some_method' so the vtable is not available from its arguments.
Presumably the currently used vtable will be stored in a global, or each
adaptor function will have a corresponding global variable pointing to
the function that it should call.  Those options only work if one vtable
is in use at a time.

In some cases an argument might be an object with a pointer to its own
vtable.  And we have the option of simply passing the vtable to all
methods, but that is really ugly.  How were the other proposals going to
handle this?

Peter





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/