widl [3/4]: Fix out-only temporary variable generation

Dan Hipschman dsh at linux.ucla.edu
Tue Aug 15 20:33:58 CDT 2006


Widl has at least three problems with [out] temporary variables.  It is
declaring them for [in, out] when it should only use them for [out].  It
only initializes those that are [out], though, and it gets confused when
there are less things to initialize than are declared.  It also assigns
the wrong types to things because it processes the two operations in
opposite order.  Lastly, it tries to assign 0 to basic and structure types
alike, so I just replaced it with a memset rather than differentiate
between them.  Long story short, it fixes a bunch of compile errors in
widls output of oaidl.idl.

ChangeLog:
* Handle out-only temp variable declarations and initialization consistently
---
 tools/widl/proxy.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/tools/widl/proxy.c b/tools/widl/proxy.c
index 4a4e080..f060a23 100644
--- a/tools/widl/proxy.c
+++ b/tools/widl/proxy.c
@@ -685,8 +685,10 @@ static void gen_proxy(type_t *iface, fun
 static void stub_write_locals( var_t *arg )
 {
   int n = 0;
+  END_OF_LIST(arg);
   while (arg) {
-    int outptr = is_attr(arg->attrs, ATTR_OUT);
+    int outptr = is_attr(arg->attrs, ATTR_OUT)
+                 && ! is_attr(arg->attrs, ATTR_IN);
 
     /* create a temporary variable to store the output */
     if (outptr) {
@@ -702,7 +704,7 @@ static void stub_write_locals( var_t *ar
     fprintf(proxy, " ");
     write_name(proxy, arg);
     fprintf(proxy, ";\n");
-    arg = NEXT_LINK(arg);
+    arg = PREV_LINK(arg);
   }
 }
 
@@ -731,7 +733,8 @@ static void stub_unmarshall( var_t *arg 
         print_proxy("");
         write_name(proxy, arg);
         fprintf(proxy," = &_M%d;\n", n);
-        print_proxy("_M%d = 0;\n", n++);
+        print_proxy("MIDL_memset(&_M%d, 0, sizeof _M%d);\n", n, n);
+        ++n;
         break;
       }
     }



More information about the wine-patches mailing list