www.digitalmars.com         C & C++   DMDScript  

D - vtables

reply "Matthew Wilson" <matthew thedjournal.com> writes:
Probably dumb questions, but here goes ...

Do D object's have vtables that have a publicly described structure and
calling convention?

Is it compatible with C++ (and, therefore, COM, at least on Windows)?

Matthew
Jun 17 2002
parent Burton Radons <loth users.sourceforge.net> writes:
Matthew Wilson wrote:
 Probably dumb questions, but here goes ...
 
 Do D object's have vtables that have a publicly described structure and
 calling convention?
Yah, there's a vtable in the ClassInfo structure. The "Object Model" page goes into it. The first pointer in an object should be that to the vtable, while the first pointer in the vtable should be to a ... ClassLayout instance. Which is kind of difficult, it not existing. I assume this is ClassInfo and ... yes, it is. You can get this from an object pointer using: ClassInfo info = (ClassInfo) **(void ***) object; This class has a name and another vtable and a base reference (possibly using the same structure) - you can see it in (\dmd\src\phobos\object.d). Everything after the ClassInfo reference is virtual method pointers. In the object itself, there's another dword for the "monitor", whatever that is, then static members. Hopefully a method for doing this will show up in Object.
 Is it compatible with C++ (and, therefore, COM, at least on Windows)?
See the "D for Win32" page of the standard, and (\dmd\samples\d\chello.d) for an example.
Jun 18 2002