Name

TInterfaceEntry Type

Syntax

type
  TInterfaceEntry = packed record
    IID: TGUID;
    VTable: Pointer;
    IOffset: Integer;
    ImplGetter: Integer;
  end;

Description

Every class that implements one or more interfaces has a table of interface entries in its RTTI. The TInterfaceEntry record stores the necessary information for the interface. See Chapter 3 for more information about RTTI.

Tips and Tricks

  • An object can implement an interface using a property (with the implements directive). The property is implemented with a field or method reference, which is stored in the ImplGetter member as the field offset, virtual method offset, or static method pointer. Usually, the class implements the interface by implementing all the methods of the interface and ImplGetter is zero.

  • If the class implements the interface directly, the compiler generates a virtual method table for the interface and stores a pointer to the vtable in the VTable field. The compiler also generates a hidden field to store the interface. The field’s offset in the object is IOffset. When you create a new object, Delphi automatically initializes the hidden interface fields.

  • See the TObject type and its GetInterfaceTable and GetInterface methods to see how Delphi looks up interfaces.

See Also

Implements Directive, Interface Keyword, PInterfaceEntry Type, Property Keyword, TGUID Type, TInterfaceTable Type, TObject Type
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset