Interfacing with XPCOM
John Reimer
terminal.node at gmail.com
Mon Dec 1 17:12:55 PST 2008
Hello Walter,
> John Reimer wrote:
>
>> It would be nice if extern(C++) were still ported to D 1.0, but the
>> other alternative of enabling extern(System) in COM support (instead
>> of extern(Windows) ) will also work.
>>
> Unfortunately, extern(C++), even if ported to D1, will not work for
> COM objects. COM objects, to be compatible with Windows, need to be
> the Windows calling convention.
>
Er... Yes, actually my statement above was meant to emphasize the potential
usefulness of extern(C++) for XPCOM support on Linux among many things.
That said, I'm guessing that even extern(C++) would work fine for COM support
on windows if one directly declares the interface methods with extern(Windows)
attribute. Similar to COM, C++ XPCOM on win32 seems to do this as well:
it applies stdcall to the XPCOM class (interface) methods.
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. ;-)
-JJR
More information about the Digitalmars-d
mailing list