www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Documentation on D's vtable

reply lurker <lurker mailinator.com> writes:
Where's the vtable layout documented? I couldn't find it in the documentation.

Bonus points: How would it look like in C?

Thanks
Jul 26 2010
next sibling parent bearophile <bearophileHUGS lycos.com> writes:
lurker:
 Where's T documented? I couldn't find it in the documentation.
 Bonus points: How would it look like in C?
There are two groups of specs, the D language specs, and the specs of how dmd compiles D code. The vtable layout is a dmd spec, because in theory other D compilers can implement virtual functions in another ways (for example with dispatch tree, that are better for inlining, but have other disadvantages). D language specs show that D classes have the .__vptr and .__monitor properties, but I think the vptr can be just a ID pointer if a compiler implements virtual calls with dispatch trees, because there is no need of a virtual table. Bye, bearophile
Jul 26 2010
prev sibling parent Robert Clipsham <robert octarineparrot.com> writes:
On 26/07/10 21:56, lurker wrote:
 Where's the vtable layout documented? I couldn't find it in the documentation.

 Bonus points: How would it look like in C?

 Thanks
See: http://www.digitalmars.com/d/1.0/abi.html http://www.digitalmars.com/d/2.0/abi.html For D2, you can take a look at this header for how a class should look to C (look at the Object struct): http://dsource.org/projects/druntime/browser/trunk/src/rt/mars.h I believe D1 has a similar file, I'll leave you to find that yourself though :) -- Robert http://octarineparrot.com/
Jul 26 2010