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

Thomas Faber thfabba at gmx.de
Thu Jun 27 00:00:02 CDT 2013


Try 2: No unnecessary whitespace modification
-------------- next part --------------
From c181f068ab6f6cd9722cfa51fad8046ff78e9c66 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 | 58 ++++++++++++++++++++++++++++-------------------------
 1 file changed, 31 insertions(+), 27 deletions(-)

diff --git a/tools/widl/header.c b/tools/widl/header.c
index 2f275c7..40f77e2 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -1199,33 +1199,37 @@ static void write_com_interface_end(FILE *header, type_t *iface)
   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");
+  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