widl [3/3]: Handle top-level conformance for complex arrays

Dan Hipschman dsh at linux.ucla.edu
Wed Sep 19 19:05:38 CDT 2007


This adds top-level conformance computations for complex arrays.  Tests
pass on wine and windows.

---
 dlls/rpcrt4/tests/server.c   |   15 +++++++++++++++
 dlls/rpcrt4/tests/server.idl |    1 +
 tools/widl/typegen.c         |   34 +++++++++++++++++++---------------
 3 files changed, 35 insertions(+), 15 deletions(-)

diff --git a/dlls/rpcrt4/tests/server.c b/dlls/rpcrt4/tests/server.c
index 031714f..cdec58b 100644
--- a/dlls/rpcrt4/tests/server.c
+++ b/dlls/rpcrt4/tests/server.c
@@ -357,6 +357,16 @@ s_sum_padded2(padded_t ps[2])
 }
 
 int
+s_sum_padded_conf(padded_t *ps, int n)
+{
+  int sum = 0;
+  int i;
+  for (i = 0; i < n; ++i)
+    sum += s_sum_padded(&ps[i]);
+  return sum;
+}
+
+int
 s_sum_bogus(bogus_t *b)
 {
   return *b->h.p1 + *b->p2 + *b->p3 + b->c;
@@ -501,6 +511,11 @@ basic_tests(void)
   padded2[1].i = 3;
   padded2[1].c = 7;
   ok(sum_padded2(padded2) == 6, "RPC sum_padded2\n");
+  padded2[0].i = -5;
+  padded2[0].c = 1;
+  padded2[1].i = 3;
+  padded2[1].c = 7;
+  ok(sum_padded_conf(padded2, 2) == 6, "RPC sum_padded_conf\n");
 
   i1 = 14;
   i2 = -7;
diff --git a/dlls/rpcrt4/tests/server.idl b/dlls/rpcrt4/tests/server.idl
index 9f66fe7..cadd1df 100644
--- a/dlls/rpcrt4/tests/server.idl
+++ b/dlls/rpcrt4/tests/server.idl
@@ -208,6 +208,7 @@ interface IServer
 
   int sum_padded(padded_t *p);
   int sum_padded2(padded_t ps[2]);
+  int sum_padded_conf([size_is(n)] padded_t *ps, int n);
 
   typedef struct
   {
diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index 84efe96..288de10 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -2580,11 +2580,9 @@ void write_remoting_arguments(FILE *file, int indent, const func_t *func,
         else if (is_array(type))
         {
             unsigned char tc = type->type;
-            const char *array_type;
+            const char *array_type = "FixedArray";
 
-            if (tc == RPC_FC_SMFARRAY || tc == RPC_FC_LGFARRAY)
-                array_type = "FixedArray";
-            else if (tc == RPC_FC_SMVARRAY || tc == RPC_FC_LGVARRAY)
+            if (tc == RPC_FC_SMVARRAY || tc == RPC_FC_LGVARRAY)
             {
                 if (is_size_needed_for_phase(phase))
                 {
@@ -2605,22 +2603,28 @@ void write_remoting_arguments(FILE *file, int indent, const func_t *func,
                 }
                 array_type = "ConformantArray";
             }
-            else if (tc == RPC_FC_CVARRAY)
+            else if (tc == RPC_FC_CVARRAY || tc == RPC_FC_BOGUS_ARRAY)
             {
                 if (is_size_needed_for_phase(phase))
                 {
-                    print_file(file, indent, "_StubMsg.MaxCount = (unsigned long)");
-                    write_expr(file, type->size_is, 1);
-                    fprintf(file, ";\n");
-                    print_file(file, indent, "_StubMsg.Offset = (unsigned long)0;\n"); /* FIXME */
-                    print_file(file, indent, "_StubMsg.ActualCount = (unsigned long)");
-                    write_expr(file, type->length_is, 1);
-                    fprintf(file, ";\n\n");
+                    if (type->size_is)
+                    {
+                        print_file(file, indent, "_StubMsg.MaxCount = (unsigned long)");
+                        write_expr(file, type->size_is, 1);
+                        fprintf(file, ";\n");
+                    }
+                    if (type->length_is)
+                    {
+                        print_file(file, indent, "_StubMsg.Offset = (unsigned long)0;\n"); /* FIXME */
+                        print_file(file, indent, "_StubMsg.ActualCount = (unsigned long)");
+                        write_expr(file, type->length_is, 1);
+                        fprintf(file, ";\n\n");
+                    }
                 }
-                array_type = "ConformantVaryingArray";
+                array_type = (tc == RPC_FC_BOGUS_ARRAY
+                              ? "ComplexArray"
+                              : "ConformantVaryingArray");
             }
-            else
-                array_type = "ComplexArray";
 
             if (!in_attr && phase == PHASE_FREE)
             {



More information about the wine-patches mailing list