crystal clear()

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Sep 17 15:50:15 PDT 2010


On 09/17/2010 05:30 PM, Sean Kelly wrote:
> Steven Schveighoffer Wrote:
>>
>> But here is a legitimate question, how do we get the interfaces?  There's
>> no indication in the ABI of where the interfaces are.  I know from logic
>> that they must be before the data members.  But logic also says that
>> interfaces defined by the derived types must appear after the data members
>> of the base class.  This is indeed tricky.
>
> I'd guess that the interface vtbls are referenced from the class vtbl, so clearing the vptr should wipe everything.

Actually, casting to an interface adds a constant offset to the pointer 
to the object without using the vptr at all. The shared referencing you 
might be thinking about is the actual function addresses: portions of 
the main vtable are identical with the interfaces vtables.

So you'll have an odd object that still kind of works when invoked 
through an interface...

Andrei


More information about the Digitalmars-d mailing list