Interfacing with XPCOM

Walter Bright newshound1 at digitalmars.com
Mon Dec 1 00:57:07 PST 2008


John Reimer wrote:
> Hello Walter,
> 
>> John Reimer wrote:
>>
>>> Hello Walter,
>>>
>>>> So are you saying that XPCOM will work on Linux with D if only the
>>>> extern(Windows) was actually extern(C++) ?
>>>>
>>> Just to make this clear, I'm banking on that the fact that
>>> extern(C++) on an interface should also remove the necessity to alias
>>> to a COM interface on linux.  I am guessing that extern(C++) makes a
>>> vtable the same as COM minus the extern(Windows) decoration.  If this
>>> is not exactly true, then my hypothesis won't hold. :-)
>>>
>> Neither affects the vtable layout. They affect the calling convention
>> (register usage, parameter order, stack cleaning, return value).
>>
> 
> 
> Okay, I'm confused then.  While I understand that the compiler uses 
> specifically uses extern(...) to describe the calling convention, I 
> /assumed/ that the compiler was detecting this the extern(C++) like so:
> 
> extern (C++)
> {
>  interface D
>  {
>    int bar(int i, int j, int k);
>  }
> 
>  D getD();
> }
> 
> 
> And converting what would normal be a D interface (with RTTI reference 
> in first element of vtable) to a regular vtable compatible with a C++ 
> class type?
> 
> How is the vtable made C++ compatible?

You're right, I was wrong.

It looks like all I need to do is change the default linkage inside 
IUnknown from Windows to System, as System is implemented as Windows 
under windows, and C under linux.



More information about the Digitalmars-d mailing list