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

Thomas Faber thfabba at gmx.de
Sun Jun 30 16:14:18 CDT 2013


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!

> 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.

Thanks a lot.
-Thomas
-------------- next part --------------
From 55a00aae2900cec493b06d6a434809f053d76fe5 Mon Sep 17 00:00:00 2001
From: Thomas Faber <thfabba at gmx.de>
Date: Sun, 30 Jun 2013 19:42:32 +0200
Subject: widl: Require interfaces to inherit from another interface unless
 explicitly exempted.

---
 tools/widl/typetree.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c
index a9e71be..de373a2 100644
--- a/tools/widl/typetree.c
+++ b/tools/widl/typetree.c
@@ -352,6 +352,14 @@ type_t *type_new_bitfield(type_t *field, const expr_t *bits)
     return t;
 }
 
+static int is_root_interface(type_t *iface)
+{
+    if (!strcmp(iface->name, "IUnknown")) return TRUE;
+    if (!strcmp(iface->name, "ID3DInclude")) return TRUE;
+    if (!strcmp(iface->name, "nsISupports")) return TRUE;
+    return FALSE;
+}
+
 static int compute_method_indexes(type_t *iface)
 {
     int idx;
@@ -377,11 +385,15 @@ static int compute_method_indexes(type_t *iface)
 
 void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stmts)
 {
+    const attr_t *attr;
     iface->details.iface = xmalloc(sizeof(*iface->details.iface));
     iface->details.iface->disp_props = NULL;
     iface->details.iface->disp_methods = NULL;
     iface->details.iface->stmts = stmts;
     iface->details.iface->inherit = inherit;
+    if (iface->attrs) LIST_FOR_EACH_ENTRY( attr, iface->attrs, const attr_t, entry )
+        if (attr->type == ATTR_OBJECT && !inherit && !is_root_interface(iface))
+            error_loc("object interface must inherit from another object interface\n");
     iface->defined = TRUE;
     compute_method_indexes(iface);
 }
-- 
1.8.1.5


More information about the wine-devel mailing list