Am 10.07.2020 um 03:02 schrieb Ryan Joseph via fpc-pascal:
On Jul 10, 2020, at 12:23 AM, Sven Barth via fpc-pascal
<fpc-pascal@lists.freepascal.org> wrote:
(so that it points to the VMT generated for the interface)
So, it sounds like what the interface actually is, is a pointer to VMT table.
Correct.
The VMT is generated with the class that implements the interface? Does it have
to do a lookup to find the VMT table, like calling Supports() does?
Yes, the VMT belongs to the class. It contains interface thunks that
adjust the Self pointer back to what the class expects before jumping(!)
to the correct methods.
A lookup is only necessary if you use e.g. "SomeClass as SomeIntf". In
the case of your example the compiler knows that TMyClass implements
IFoo and thus can simply adjust the Self pointer.
Regards,
Sven
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal