FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

WindowsAPI style: extern (Windows) and COM interfaces

 
Post new topic   Reply to topic     Forum Index -> Bindings
View previous topic :: View next topic  
Author Message
smjg



Joined: 29 Sep 2004
Posts: 41

PostPosted: Fri Oct 17, 2008 4:06 pm    Post subject: WindowsAPI style: extern (Windows) and COM interfaces Reply with quote

We seem to have a handful of different styles for the extern (Windows) (or lack thereof) applied to COM interfaces.

1. Not at all - most instances at the moment

2. extern (Windows) wrapping the whole interface - unknwn.d
Code:
extern (Windows) {

    interface IUnknown {
        HRESULT QueryInterface(IID* riid, void** pvObject);
        ULONG AddRef();
        ULONG Release();
    }
    // ...
}

3. with a colon just inside the interface - directx modules
Code:
interface ID3D10DeviceChild : IUnknown {
    extern(Windows) :
    void GetDevice(ID3D10Device* ppDevice);
    HRESULT GetPrivateData(REFGUID guid, UINT *pDataSize, void *pData);
    HRESULT SetPrivateData(REFGUID guid, UINT DataSize, void *pData);
    HRESULT SetPrivateDataInterface(REFGUID guid, IUnknown pData);
}

We should decide on a consistent style to use. And while I'm not sure I like the indentation of style 3, if we're going to use this one we ought to change the spacing to extern (Windows): to be consistent with other things.

Other possibilities:

4.
Code:
extern (Windows) interface IUnknown {
    HRESULT QueryInterface(IID* riid, void** pvObject);
    ULONG AddRef();
    ULONG Release();
}


5.
Code:
interface IUnknown {
    extern (Windows) {
        HRESULT QueryInterface(IID* riid, void** pvObject);
        ULONG AddRef();
        ULONG Release();
    }
}


6.
Code:
interface IUnknown {
extern (Windows):
    HRESULT QueryInterface(IID* riid, void** pvObject);
    ULONG AddRef();
    ULONG Release();
}


7.
Code:
interface IUnknown {
    extern (Windows):
        HRESULT QueryInterface(IID* riid, void** pvObject);
        ULONG AddRef();
        ULONG Release();
}

First, somebody who knows how to test it needs to confirm: Is the extern (Windows) necessary? If so, do styles 2 and 3 both achieve the intended result?

Assuming that it works, my vote would go to style 2, enabling a single extern (Windows) to wrap multiple COM interfaces (and possibly global functions as well). Style 4 would be used when there is just the one interface to declare as extern (Windows).

What does everyone think?

Stewart.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Bindings All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group