Re: Interface Question



Rob Kennedy wrote:

http://www.cs.wisc.edu/~rkennedy/interface-object

A fine article :-)

I only disagree with the last paragraph(s), about how to retrieve object references. In the case of a Delphi class, the offset of the interface pointer is stored in the interface description, no need to look into the stubs (hint: the compiler obtains the offset just from that place).

Looking into the stub code is a bit safer, because that code may be less version dependent, than the info in the classtype structure.


Another note:

Instances of the old "Object" type do not necessarily include an VMT pointer, in case the object has no virtual methods. This restriction may be compatible with CBuilder classes, and it makes it impossible to obtain an classtype or RTTI from such objects. But since a TObject already has virtual methods (Destroy...), the VMT pointer in Class objects always sits at the begin of every object.

DoDi
.