December 09, 2005
Hi,

A quick-and-easy question on the implementation of interfaces in gdc: hows it done, with multiple inheritance, interface dispatch tables like in gcj or some third method?

Greetings
Ingmar Schuster
December 10, 2005
Ingmar Schuster wrote:
> Hi,
> 
> A quick-and-easy question on the implementation of interfaces in gdc: hows it done, with multiple inheritance, interface dispatch tables like in gcj or some third method?
> 
> Greetings
> Ingmar Schuster

Basically, it's multiple inheritance.

When a class is declared to implement an interface, a field is added to the class that points to a virtual method table for that interface.  If an interface is reimplemented in a descendant class, another field is added instead of using the one from the ancestor class.  Both fields will have the same value.

Except for COM interfaces, the first entry of the interface virtual method table points to some information that can be used to cast the interface reference back to its object reference.

David