Sync to wine-1.1.4:
authorEric Kohl <eric.kohl@reactos.org>
Thu, 4 Dec 2008 21:22:42 +0000 (21:22 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Thu, 4 Dec 2008 21:22:42 +0000 (21:22 +0000)
- Rob Shearman <robertshearman@gmail.com> Tue, 26 Aug 2008
widl: Raise RPC_X_SS_IN_NULL_CONTEXT exception for NULL in-only context handles instead of RPC_X_NULL_REF_PTR.

Based on a patch by Michael Martin.

- Alexandre Julliard <julliard@winehq.org> Sat, 30 Aug 2008
widl: Replace write_name() by get_name() to make the code more readable.

- Dan Hipschman <dsh@linux.ucla.edu> Tue, 2 Sep 2008
widl: Output NULL for inherited methods in the vtbl.

svn path=/trunk/; revision=37862

reactos/media/doc/README.WINE
reactos/tools/widl/client.c
reactos/tools/widl/header.c
reactos/tools/widl/header.h
reactos/tools/widl/proxy.c
reactos/tools/widl/server.c
reactos/tools/widl/typegen.c

index 8256e73..82ebb73 100644 (file)
@@ -26,7 +26,7 @@ reactos/tools/wpp                 # Synced to Wine-20081105 (~Wine-1.1.7)
 reactos/tools/winebuild           # Synced to Wine-20081105 (~Wine-1.1.7)
 reactos/tools/wmc                 # Synced to Wine-20081105 (~Wine-1.1.7)
 reactos/tools/wrc                 # Synced to Wine-20081105 (~Wine-1.1.7)
-reactos/tools/widl                # Synced to Wine-1_1_3, omitting patches that break MIDL-Compatibility
+reactos/tools/widl                # Synced to Wine-1_1_4, omitting patches that break MIDL-Compatibility
 
 The following libraries are shared with Wine.
 
index c4d200a..191ae18 100644 (file)
@@ -103,8 +103,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
         if (needs_space_after(get_func_return_type(func)))
           fprintf(client, " ");
         if (callconv) fprintf(client, "%s ", callconv);
-        write_prefix_name(client, prefix_client, def);
-        fprintf(client, "(\n");
+        fprintf(client, "%s%s(\n", prefix_client, get_name(def));
         indent++;
         if (func->args)
             write_args(client, func->args, iface->name, 0, TRUE);
@@ -188,6 +187,14 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
             indent++;
             print_client("_Handle = NDRCContextBinding(%s%s);\n", is_ch_ptr ? "*" : "", context_handle_var->name);
             indent--;
+            if (is_attr(context_handle_var->attrs, ATTR_IN) &&
+                !is_attr(context_handle_var->attrs, ATTR_OUT))
+            {
+                print_client("else\n");
+                indent++;
+                print_client("RpcRaiseException(RPC_X_SS_IN_NULL_CONTEXT);\n");
+                indent--;
+            }
             fprintf(client, "\n");
         }
         else if (implicit_handle)
index 3e1b2d0..9f19b06 100644 (file)
@@ -130,21 +130,20 @@ void write_guid(FILE *f, const char *guid_prefix, const char *name, const UUID *
         uuid->Data4[6], uuid->Data4[7]);
 }
 
-void write_name(FILE *h, const var_t *v)
+const char *get_name(const var_t *v)
 {
-  if (is_attr( v->attrs, ATTR_PROPGET ))
-    fprintf(h, "get_" );
-  else if (is_attr( v->attrs, ATTR_PROPPUT ))
-    fprintf(h, "put_" );
-  else if (is_attr( v->attrs, ATTR_PROPPUTREF ))
-    fprintf(h, "putref_" );
-  fprintf(h, "%s", v->name);
-}
-
-void write_prefix_name(FILE *h, const char *prefix, const var_t *v)
-{
-  fprintf(h, "%s", prefix);
-  write_name(h, v);
+    static char buffer[256];
+
+    if (is_attr( v->attrs, ATTR_PROPGET ))
+        strcpy( buffer, "get_" );
+    else if (is_attr( v->attrs, ATTR_PROPPUT ))
+        strcpy( buffer, "put_" );
+    else if (is_attr( v->attrs, ATTR_PROPPUTREF ))
+        strcpy( buffer, "putref_" );
+    else
+        buffer[0] = 0;
+    strcat( buffer, v->name );
+    return buffer;
 }
 
 static void write_field(FILE *h, var_t *v)
@@ -192,7 +191,7 @@ static void write_enums(FILE *h, var_list_t *enums)
   {
     if (v->name) {
       indent(h, 0);
-      write_name(h, v);
+      fprintf(h, "%s", get_name(v));
       if (v->eval) {
         fprintf(h, " = ");
         write_expr(h, v->eval, 0, 1, NULL, NULL);
@@ -643,17 +642,13 @@ static void write_method_macro(FILE *header, const type_t *iface, const char *na
     if (!is_callas(def->attrs)) {
       const var_t *arg;
 
-      fprintf(header, "#define %s_", name);
-      write_name(header,def);
-      fprintf(header, "(This");
+      fprintf(header, "#define %s_%s(This", name, get_name(def));
       if (cur->args)
           LIST_FOR_EACH_ENTRY( arg, cur->args, const var_t, entry )
               fprintf(header, ",%s", arg->name);
       fprintf(header, ") ");
 
-      fprintf(header, "(This)->lpVtbl->");
-      write_name(header, def);
-      fprintf(header, "(This");
+      fprintf(header, "(This)->lpVtbl->%s(This", get_name(def));
       if (cur->args)
           LIST_FOR_EACH_ENTRY( arg, cur->args, const var_t, entry )
               fprintf(header, ",%s", arg->name);
@@ -706,9 +701,7 @@ static void write_cpp_method_def(FILE *header, const type_t *iface)
       indent(header, 0);
       fprintf(header, "virtual ");
       write_type_decl_left(header, get_func_return_type(cur));
-      fprintf(header, " %s ", callconv);
-      write_name(header, def);
-      fprintf(header, "(\n");
+      fprintf(header, " %s %s(\n", callconv, get_name(def));
       write_args(header, cur->args, iface->name, 2, TRUE);
       fprintf(header, ") = 0;\n");
       fprintf(header, "\n");
@@ -733,9 +726,7 @@ static void do_write_c_method_def(FILE *header, const type_t *iface, const char
       if (!callconv) callconv = "";
       indent(header, 0);
       write_type_decl_left(header, get_func_return_type(cur));
-      fprintf(header, " (%s *", callconv);
-      write_name(header, def);
-      fprintf(header, ")(\n");
+      fprintf(header, " (%s *%s)(\n", callconv, get_name(def));
       write_args(header, cur->args, name, 1, TRUE);
       fprintf(header, ");\n");
       fprintf(header, "\n");
@@ -767,15 +758,11 @@ static void write_method_proto(FILE *header, const type_t *iface)
       if (!callconv) callconv = "";
       /* proxy prototype */
       write_type_decl_left(header, get_func_return_type(cur));
-      fprintf(header, " %s %s_", callconv, iface->name);
-      write_name(header, def);
-      fprintf(header, "_Proxy(\n");
+      fprintf(header, " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(def));
       write_args(header, cur->args, iface->name, 1, TRUE);
       fprintf(header, ");\n");
       /* stub prototype */
-      fprintf(header, "void __RPC_STUB %s_", iface->name);
-      write_name(header,def);
-      fprintf(header, "_Stub(\n");
+      fprintf(header, "void __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(def));
       fprintf(header, "    IRpcStubBuffer* This,\n");
       fprintf(header, "    IRpcChannelBuffer* pRpcChannelBuffer,\n");
       fprintf(header, "    PRPC_MESSAGE pRpcMessage,\n");
@@ -807,9 +794,7 @@ void write_locals(FILE *fp, const type_t *iface, int body)
         const var_t *mdef = m->def;
         /* proxy prototype - use local prototype */
         write_type_decl_left(fp, get_func_return_type(m));
-        fprintf(fp, " CALLBACK %s_", iface->name);
-        write_name(fp, mdef);
-        fprintf(fp, "_Proxy(\n");
+        fprintf(fp, " CALLBACK %s_%s_Proxy(\n", iface->name, get_name(mdef));
         write_args(fp, m->args, iface->name, 1, TRUE);
         fprintf(fp, ")");
         if (body) {
@@ -831,9 +816,7 @@ void write_locals(FILE *fp, const type_t *iface, int body)
           fprintf(fp, ";\n");
         /* stub prototype - use remotable prototype */
         write_type_decl_left(fp, get_func_return_type(cur));
-        fprintf(fp, " __RPC_STUB %s_", iface->name);
-        write_name(fp, mdef);
-        fprintf(fp, "_Stub(\n");
+        fprintf(fp, " __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(mdef));
         write_args(fp, cur->args, iface->name, 1, TRUE);
         fprintf(fp, ")");
         if (body)
@@ -857,8 +840,7 @@ static void write_function_proto(FILE *header, const type_t *iface, const func_t
   write_type_decl_left(header, get_func_return_type(fun));
   fprintf(header, " ");
   if (callconv) fprintf(header, "%s ", callconv);
-  write_prefix_name(header, prefix, def);
-  fprintf(header, "(\n");
+  fprintf(header, "%s%s(\n", prefix, get_name(def));
   if (fun->args)
     write_args(header, fun->args, iface->name, 0, TRUE);
   else
index 3344c80..777beee 100644 (file)
@@ -31,8 +31,6 @@ extern unsigned long get_attrv(const attr_list_t *list, enum attr_type t);
 extern int is_void(const type_t *t);
 extern int is_conformant_array(const type_t *t);
 extern int is_declptr(const type_t *t);
-extern void write_name(FILE *h, const var_t *v);
-extern void write_prefix_name(FILE *h, const char *prefix, const var_t *v);
 extern const char* get_name(const var_t *v);
 extern void write_type_left(FILE *h, type_t *t, int declonly);
 extern void write_type_right(FILE *h, type_t *t, int is_field);
index 661ea2b..3a35cde 100644 (file)
@@ -140,6 +140,11 @@ int cant_be_null(const var_t *v)
   const attr_list_t *attrs = v->attrs;
   const type_t *type = v->type;
 
+  /* context handles have their own checking so they can be null for the
+   * purposes of null ref pointer checking */
+  if (is_aliaschain_attr(type, ATTR_CONTEXTHANDLE))
+      return 0;
+
   if (! attrs && type)
   {
     attrs = type->attrs;
@@ -259,9 +264,7 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx,
 
   indent = 0;
   write_type_decl_left(proxy, get_func_return_type(cur));
-  print_proxy( " %s %s_", callconv, iface->name);
-  write_name(proxy, def);
-  print_proxy( "_Proxy(\n");
+  print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(def));
   write_args(proxy, cur->args, iface->name, 1, TRUE);
   print_proxy( ")\n");
   print_proxy( "{\n");
@@ -371,9 +374,7 @@ static void gen_stub(type_t *iface, const func_t *cur, const char *cas,
   int has_full_pointer = is_full_pointer_function(cur);
 
   indent = 0;
-  print_proxy( "void __RPC_STUB %s_", iface->name);
-  write_name(proxy, def);
-  print_proxy( "_Stub(\n");
+  print_proxy( "void __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(def));
   indent++;
   print_proxy( "IRpcStubBuffer* This,\n");
   print_proxy( "IRpcChannelBuffer *_pRpcChannelBuffer,\n");
@@ -415,22 +416,13 @@ static void gen_stub(type_t *iface, const func_t *cur, const char *cas,
   print_proxy("");
   if (has_ret) fprintf(proxy, "_RetVal = ");
   if (cas) fprintf(proxy, "%s_%s_Stub", iface->name, cas);
-  else
-  {
-      fprintf(proxy, "_This->lpVtbl->");
-      write_name(proxy, def);
-  }
+  else fprintf(proxy, "_This->lpVtbl->%s", get_name(def));
   fprintf(proxy, "(_This");
 
   if (cur->args)
   {
       LIST_FOR_EACH_ENTRY( arg, cur->args, const var_t, entry )
-      {
-          fprintf(proxy, ", ");
-          if (arg->type->declarray)
-              fprintf(proxy, "*");
-          write_name(proxy, arg);
-      }
+          fprintf(proxy, ", %s%s", arg->type->declarray ? "*" : "", get_name(arg));
   }
   fprintf(proxy, ");\n");
   fprintf(proxy, "\n");
@@ -481,9 +473,8 @@ static int write_proxy_methods(type_t *iface, int skip)
     var_t *def = cur->def;
     if (!is_callas(def->attrs)) {
       if (i) fprintf(proxy, ",\n");
-      print_proxy( "%s%s_", skip ? "0\t/* " : "", iface->name);
-      write_name(proxy, def);
-      fprintf(proxy, "_Proxy%s", skip ? " */" : "");
+      if (skip) print_proxy( "0  /* %s_%s_Proxy */", iface->name, get_name(def));
+      else print_proxy( "%s_%s_Proxy", iface->name, get_name(def));
       i++;
     }
   }
@@ -501,15 +492,10 @@ static int write_stub_methods(type_t *iface, int skip)
   if (iface->funcs) LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) {
     var_t *def = cur->def;
     if (!is_local(def->attrs)) {
-      if (skip)
-        print_proxy("STUB_FORWARDING_FUNCTION,\n");
-      else {
-        if (i) fprintf(proxy,",\n");
-        print_proxy( "%s_", iface->name);
-        write_name(proxy, def);
-        fprintf(proxy, "_Stub");
-        i++;
-      }
+      if (i) fprintf(proxy,",\n");
+      if (skip) print_proxy("STUB_FORWARDING_FUNCTION");
+      else print_proxy( "%s_%s_Stub", iface->name, get_name(def));
+      i++;
     }
   }
   return i;
index 582a0cb..d79447b 100644 (file)
@@ -63,13 +63,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
         /* check for a defined binding handle */
         explicit_handle_var = get_explicit_handle_var(func);
 
-        fprintf(server, "void __RPC_STUB\n");
-        fprintf(server, "%s_", iface->name);
-        write_name(server, def);
-        fprintf(server, "(\n");
-        indent++;
-        print_server("PRPC_MESSAGE _pRpcMessage)\n");
-        indent--;
+        print_server("void __RPC_STUB %s_%s( PRPC_MESSAGE _pRpcMessage )\n", iface->name, get_name(def));
 
         /* write the functions body */
         fprintf(server, "{\n");
@@ -150,7 +144,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
             print_server("_RetVal = ");
         else
             print_server("");
-        write_prefix_name(server, prefix_server, def);
+        fprintf(server, "%s%s", prefix_server, get_name(def));
 
         if (func->args)
         {
@@ -176,10 +170,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
                 }
                 else
                 {
-                    print_server("");
-                    if (var->type->declarray)
-                        fprintf(server, "*");
-                    write_name(server, var);
+                    print_server("%s%s", var->type->declarray ? "*" : "", get_name(var));
                 }
             }
             fprintf(server, ");\n");
@@ -261,9 +252,7 @@ static void write_dispatchtable(type_t *iface)
     {
         var_t *def = func->def;
 
-        print_server("%s_", iface->name);
-        write_name(server, def);
-        fprintf(server, ",\n");
+        print_server("%s_%s,\n", iface->name, get_name(def));
 
         method_count++;
     }
index 35b2d71..9bb6989 100644 (file)
@@ -3196,11 +3196,9 @@ void declare_stub_args( FILE *file, int indent, const func_t *func )
             write_type_decl_left(file, var->type);
             fprintf(file, " ");
             if (var->type->declarray) {
-                fprintf(file, "( *");
-                write_name(file, var);
-                fprintf(file, " )");
+                fprintf(file, "(*%s)", get_name(var));
             } else
-                write_name(file, var);
+                fprintf(file, "%s", get_name(var));
             write_type_right(file, var->type, FALSE);
             fprintf(file, ";\n");
 
@@ -3231,8 +3229,7 @@ void assign_stub_out_args( FILE *file, int indent, const func_t *func )
 
         if (!in_attr)
         {
-            print_file(file, indent, "");
-            write_name(file, var);
+            print_file(file, indent, "%s", get_name(var));
 
             if (is_context_handle(var->type))
             {