widl: Do not generate C structure for empty interfaces.

Thomas Faber thfabba at gmx.de
Wed Jun 26 14:01:28 CDT 2013


-------------- next part --------------
From d0e653eafeeac3307e1eb5058cbc56fc2f893280 Mon Sep 17 00:00:00 2001
From: Thomas Faber <thfabba at gmx.de>
Date: Sun, 23 Jun 2013 13:19:52 +0200
Subject: widl: Do not generate C structure for empty interfaces.

---
 tools/widl/header.c | 66 ++++++++++++++++++++++++++++-------------------------
 1 file changed, 35 insertions(+), 31 deletions(-)

diff --git a/tools/widl/header.c b/tools/widl/header.c
index 2f275c7..b407cd7 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -1165,14 +1165,14 @@ static void write_com_interface_end(FILE *header, type_t *iface)
   const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
 
   if (uuid)
-      write_guid(header, dispinterface ? "DIID" : "IID", iface->name, uuid);
+    write_guid(header, dispinterface ? "DIID" : "IID", iface->name, uuid);
 
   /* C++ interface */
   fprintf(header, "#if defined(__cplusplus) && !defined(CINTERFACE)\n");
   if (uuid)
-      fprintf(header, "MIDL_INTERFACE(\"%s\")\n", uuid_string(uuid));
+    fprintf(header, "MIDL_INTERFACE(\"%s\")\n", uuid_string(uuid));
   else
-      fprintf(header, "interface ");
+    fprintf(header, "interface ");
   if (type_iface_get_inherit(iface))
   {
     fprintf(header, "%s : public %s\n", iface->name,
@@ -1198,34 +1198,38 @@ static void write_com_interface_end(FILE *header, type_t *iface)
     fprintf(header, "    END_INTERFACE\n");
   fprintf(header, "};\n");
   if (uuid)
-      write_uuid_decl(header, iface->name, uuid);
-  fprintf(header, "#else\n");
-  /* C interface */
-  fprintf(header, "typedef struct %sVtbl {\n", iface->name);
-  indentation++;
-  fprintf(header, "    BEGIN_INTERFACE\n");
-  fprintf(header, "\n");
-  if (dispinterface)
-    write_c_disp_method_def(header, iface);
-  else
-    write_c_method_def(header, iface);
-  indentation--;
-  fprintf(header, "    END_INTERFACE\n");
-  fprintf(header, "} %sVtbl;\n", iface->name);
-  fprintf(header, "interface %s {\n", iface->name);
-  fprintf(header, "    CONST_VTBL %sVtbl* lpVtbl;\n", iface->name);
-  fprintf(header, "};\n");
-  fprintf(header, "\n");
-  fprintf(header, "#ifdef COBJMACROS\n");
-  /* dispinterfaces don't have real functions, so don't write macros for them,
-   * only for the interface this interface inherits from, i.e. IDispatch */
-  fprintf(header, "#ifndef WIDL_C_INLINE_WRAPPERS\n");
-  write_method_macro(header, dispinterface ? type_iface_get_inherit(iface) : iface, iface->name);
-  fprintf(header, "#else\n");
-  write_inline_wrappers(header, dispinterface ? type_iface_get_inherit(iface) : iface, iface->name);
-  fprintf(header, "#endif\n");
-  fprintf(header, "#endif\n");
-  fprintf(header, "\n");
+    write_uuid_decl(header, iface->name, uuid);
+  if (dispinterface ||
+      type_iface_get_stmts(iface) || type_iface_get_inherit(iface))
+  {
+    fprintf(header, "#else\n");
+    /* C interface */
+    fprintf(header, "typedef struct %sVtbl {\n", iface->name);
+    indentation++;
+    fprintf(header, "    BEGIN_INTERFACE\n");
+    fprintf(header, "\n");
+    if (dispinterface)
+      write_c_disp_method_def(header, iface);
+    else
+      write_c_method_def(header, iface);
+    indentation--;
+    fprintf(header, "    END_INTERFACE\n");
+    fprintf(header, "} %sVtbl;\n", iface->name);
+    fprintf(header, "interface %s {\n", iface->name);
+    fprintf(header, "    CONST_VTBL %sVtbl* lpVtbl;\n", iface->name);
+    fprintf(header, "};\n");
+    fprintf(header, "\n");
+    fprintf(header, "#ifdef COBJMACROS\n");
+    /* dispinterfaces don't have real functions, so don't write macros for them,
+     * only for the interface this interface inherits from, i.e. IDispatch */
+    fprintf(header, "#ifndef WIDL_C_INLINE_WRAPPERS\n");
+    write_method_macro(header, dispinterface ? type_iface_get_inherit(iface) : iface, iface->name);
+    fprintf(header, "#else\n");
+    write_inline_wrappers(header, dispinterface ? type_iface_get_inherit(iface) : iface, iface->name);
+    fprintf(header, "#endif\n");
+    fprintf(header, "#endif\n");
+    fprintf(header, "\n");
+  }
   fprintf(header, "#endif\n");
   fprintf(header, "\n");
   /* dispinterfaces don't have real functions, so don't write prototypes for
-- 
1.8.1.5


More information about the wine-patches mailing list