John Reimer wrote:
In D (windows) it would look like so (assuming you have done away with the compilers internal detection of COM interfaces):

extern(C++) interface IUnknown:
{
    extern(Windows):
        int QueryInterface(nsIID* uuid, void **result);
        int AddRef();
        int Release();
}

I bet it would work fine and would be a good way to avoid the special-cased interfaces providing COM support in D. Instead we've special-cased for C++, which is, at least, a more general case. ;-)

There is one other problem. COM objects are not collected by the garbage collector because they are reference counted. Deriving from IUnknown means its a COM object which sets a flag in the ClassInfo, directing the garbage collector to not collect it. In fact, COM objects are allocated using malloc(). IUnknown.Release() uses free() to deallocate them.

Reply via email to