On 11/11/2012 01:01 AM, Nikolay Sivov wrote:
On 11/11/2012 05:00, Max TenEyck Woodbury wrote:
I mentioned this a few days ago. It would have helped if you had raised this point then.
As it stands, it is simply a way to adding data members to an aggregate with an interface.
Data members to an aggregate? What are you talking about and what it has to do with interface definition?
An aggregate is a collection of information, like a class, struct or union.
Some aggregates include 'interface's, a COM, OLE or RPC thingy. The interface can have only methods defined, but those methods might want access to some additional data. To get to that data, the method now has to build a pointer to the containing aggregate and reference the data through that pointer. This introduces complications to the code since the data may not be in same place in the aggregate in each instance where the interface is used. You need a slightly different code sequence for each different place the method is needed. However, the source code will be virtually identical for each instance.
This patch allows those aggregate data members associated with the interface, which are not technically part of the interface, to be placed in a fixed relation to the interfaces Vtbl pointer. (Practically the Vtbl pointer is the interface.) By establishing such a relationship, the need to convert from the pointer to the interface (specifically to its Vtbl pointer) to a pointer to its containing aggregate in order to get to the relevant data is removed.
Now, technically, the associated data is not part of the interface. It is part of the aggregate containing and implementing the interface. Moving the declaration from the aggregate to the end of the struc for the interface is a hack that lets simpler and more general code to be generated.
So, it's a hack, that you only use if you want to, to speed up execution and simplify maintenance.