widl: Do not generate C structure for empty interfaces. (try 2)

Jacek Caban jacek at codeweavers.com
Tue Jul 2 06:15:19 CDT 2013


On 06/30/13 23:14, Thomas Faber wrote:
> On 2013-06-27 13:33, Jacek Caban wrote:
>> That
>> said, if such interfaces are just obscure special case, I would say we
>> shouldn't care. We may easily avoid them (I just sent a patch avoiding
>> it in mshtml).
> Ah, I hadn't even considered changing the interface. Seemed like it was
> something mandated by Mozilla's use of it.
> This indeed seems to be the best solution to the immediate problem of
> mshtml not building with MSVC.
> Thanks!

In general, Mozilla uses their own variant of COM, called XPCOM. It
happens to be similar enough to MS variant of COM that we may use widl
to generate its binary compatible headers, but if there is any
incompatibility, fixing it in nsiface.idl is preferred over hacking widl.

>> If you want a better solution to avoid such problems in the future, I
>> would suggest adding an error, like midl does. This will, however,
>> require some more changes in Wine. At least MSHTML already has an
>> interface identical to IUnknown (nsISupports), which would cause the
>> error. This should be solvable with some tricks.
> That sounds like the smart thing to do. I've attached the simplest
> version that comes to mind.
> The interfaces I needed to exempt were IUnknown (naturally),
> ID3DInclude (which PSDK seems to define via cpp_quote), and nsISupports
> as you already mentioned.
> Midl also seems to have an "if not inside a library" condition, which
> I'll try to add as well. I'd have liked to use is_object in widl, but
> that also triggers on the odl attribute.
>
> I'll send it to -patches once I'm satisfied with it, but I'm pretty
> fond of the simple approach already. Let me know if you have any
> comments.

I don't think we want to maintain such a list of special interfaces in
widl sources. IUnknown is a special case in many aspects, so that's
fine. ID3DInclude is something that definitely shouldn't be there. It's
also small enough that cpp_quote should be fine for this. nsISupports
is, as I said earlier, something that would be better worked around in
nsiface.idl. The attached patch does that, although now there will
probably be duplicated UUID error on midl. That's also something we
could work around with some preprocessor tricks...

If this would be generic enough problem, we could add some widl
extension, like a special attribute, but your findings show that it's
too rare to mitigate that.

Thanks,
Jacek
-------------- next part --------------
diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl
index fcdf6f1..3bbcd46 100644
--- a/dlls/mshtml/nsiface.idl
+++ b/dlls/mshtml/nsiface.idl
@@ -26,6 +26,7 @@
 cpp_quote("#define GECKO_VERSION \"2.21\"")
 cpp_quote("#define GECKO_VERSION_STRING \"Wine Gecko \" GECKO_VERSION")
 
+import "unknwn.idl";
 import "wtypes.idl";
 
 cpp_quote("#ifdef WINE_NO_UNICODE_MACROS")
@@ -114,12 +115,8 @@ interface IMoniker;
     uuid(00000000-0000-0000-c000-000000000046),
     local
 ]
-interface nsISupports
-{
-    nsresult QueryInterface(nsIIDRef riid, void **result);
-    nsrefcnt AddRef();
-    nsrefcnt Release();
-}
+interface nsISupports : IUnknown
+{}
 
 /* Currently we don't need a full declaration of these interfaces */
 typedef nsISupports nsISHistory;


More information about the wine-devel mailing list