Jacek Caban : widl: Added an extension that uses inline functions instead of macros for C interface calls .

Alexandre Julliard julliard at winehq.org
Thu Jul 26 15:34:58 CDT 2012


Module: wine
Branch: master
Commit: 6b34eea6fcab318153993a3a08345b5d1eab5c3d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6b34eea6fcab318153993a3a08345b5d1eab5c3d

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Jul 26 11:35:43 2012 +0200

widl: Added an extension that uses inline functions instead of macros for C interface calls.

---

 tools/widl/header.c |   41 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/tools/widl/header.c b/tools/widl/header.c
index 0b2b9d5..454b523 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -902,6 +902,43 @@ static void write_cpp_method_def(FILE *header, const type_t *iface)
   }
 }
 
+static void write_inline_wrappers(FILE *header, const type_t *iface, const char *name)
+{
+  const statement_t *stmt;
+  int first_iface = 1;
+
+  if (type_iface_get_inherit(iface))
+    write_inline_wrappers(header, type_iface_get_inherit(iface), name);
+
+  STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface))
+  {
+    const var_t *func = stmt->u.var;
+
+    if (first_iface)
+    {
+      fprintf(header, "/*** %s methods ***/\n", iface->name);
+      first_iface = 0;
+    }
+
+    if (!is_callas(func->attrs)) {
+      const var_t *arg;
+
+      fprintf(header, "static FORCEINLINE ");
+      write_type_decl_left(header, type_function_get_rettype(func->type));
+      fprintf(header, " %s_%s(", name, get_name(func));
+      write_args(header, type_get_function_args(func->type), name, 1, FALSE);
+      fprintf(header, ") {\n");
+      fprintf(header, "    %s", is_void(type_function_get_rettype(func->type)) ? "" : "return ");
+      fprintf(header, "This->lpVtbl->%s(This", get_name(func));
+      if (type_get_function_args(func->type))
+          LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->type), const var_t, entry )
+              fprintf(header, ",%s", arg->name);
+      fprintf(header, ");\n");
+      fprintf(header, "}\n");
+    }
+  }
+}
+
 static void do_write_c_method_def(FILE *header, const type_t *iface, const char *name)
 {
   const statement_t *stmt;
@@ -1150,7 +1187,11 @@ static void write_com_interface_end(FILE *header, type_t *iface)
   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");




More information about the wine-cvs mailing list