Re: Interface Question



Rob Kennedy wrote:

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).


How can it be stored in the interface description?

How not? Every Delphi class type contains the descriptions of the interfaces, implemented by this class. These interface descriptions are different for every class!

But there is no class type yet. All we have is an interface reference, and we're trying to get to the object.

The interface reference is a pointer to an pointer to the interface description, from which you can retrieve RTTI as from a class description. The methods may be undocumented, but the RTL contains according data types and procedures. One such information is the offset of the interface pointer within the object, and subtracting that value from the interface reference will turn it into the object reference.

DoDi
.



Relevant Pages

  • Re: RFC: New module Module::Bundled::Files
    ... # Failed test ... "import" is not exported by the Exporter module ... The object oriented interface and the usage of object references to ...
    (comp.lang.perl.modules)
  • Re: Interfaces and Classes, where do I ask about the differences?
    ... how am I mixing interface with object references? ... What interface reference would I have ... that the compiler generates code to call _Release on FDocumentInterface ...
    (borland.public.delphi.non-technical)
  • Re: CoMarshalInterThreadInterfaceInStream FinalRelease not called
    ... You need to marshal the ougoing interface, ... Microsoft MVP, MCSD ... "Alexander Nickolov" wrote: ... interface pointer is working as intended but my FinalRelease is not ...
    (microsoft.public.vc.atl)
  • Re: vTable offsets
    ... What about starting by posting the interface in question you are ... >> have to build all vtables by hand. ... The vTable offset starts ... >> Microsoft MVP, MCSD ...
    (microsoft.public.win32.programmer.ole)
  • Re: Pointer Marshalling quesiton
    ... involves interface pointer marshling. ... Microsoft MVP, MCSD ... "Alexander Nickolov" wrote: ...
    (microsoft.public.win32.programmer.ole)