www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Using COM. Please help.

reply Nub Public <nubpublic gmail.com> writes:
Hi. I've been trying to use Direct2D and I ran into some problems.

1. When translating the headers from the Windows SDK, what linkage 
should I use for the interfaces? Currently I use none and it works, but 
I want some confirmation in case something comes up later and bites my 
in the  ss.

2. Some members in the Direct2D interfaces are inlined. This gives me 
access violations when I declare and use them in my files. I guess those 
members are not exported to the Direct2D dlls. But there's no inline 
keyword in D. How do I solve this?

Help please.
Jun 26 2011
parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
You mean COM interfaces? I usually do this:

interface SomeComInterface : IUnknown
{
    extern(Windows):
    BOOL PrototypeFoo();
}

But maybe this is already implicit when deriving from IUnknown, I wouldn't know.

But from what I can tell some of those prototypes seem to have C
linkage, maybe you're getting access violations due to wrong calling
conventions.
Jun 26 2011
parent reply Nub Public <nubpublic gmail.com> writes:
On 6/27/2011 1:28 PM, Andrej Mitrovic wrote:
 You mean COM interfaces? I usually do this:

 interface SomeComInterface : IUnknown
 {
      extern(Windows):
      BOOL PrototypeFoo();
 }

 But maybe this is already implicit when deriving from IUnknown, I wouldn't
know.

 But from what I can tell some of those prototypes seem to have C
 linkage, maybe you're getting access violations due to wrong calling
 conventions.
Thanks for the reply. But it still doesn't work. interface ISomeComInterface : IUnknown { void funcWithManyParams(/*10 params*/); extern(/*insert whatever linkage here*/) void funcWrapperWithLessParams(/*3 params*/) { funcWithManyParams(/*fill in some default params*/); } //this func is inlined in the MS SDK header } DMD complains that the function body of funcWrapperWithLessParams isn't abstract.
Jun 27 2011
parent reply David Nadlinger <see klickverbot.at> writes:
On 6/27/11 9:04 AM, Nub Public wrote:
 DMD complains that the function body of funcWrapperWithLessParams isn't
 abstract.
I don't know if there is something COM-specific going on, but you might want to mark the wrapper method »final« – that's at least how it works for normal interfaces. David
Jun 27 2011
parent Nub Public <nubpublic gmail.com> writes:
On 6/27/2011 4:08 PM, David Nadlinger wrote:
 On 6/27/11 9:04 AM, Nub Public wrote:
 DMD complains that the function body of funcWrapperWithLessParams isn't
 abstract.
I don't know if there is something COM-specific going on, but you might want to mark the wrapper method »final« – that's at least how it works for normal interfaces. David
It works now. Thanks.
Jun 27 2011