widl [2/3]: Respect pointer attributes better

Dan Hipschman dsh at linux.ucla.edu
Wed Sep 19 19:04:49 CDT 2007


This patch gets widl to respect pointer attributes (currently, it does
so only for typedef'd types).  This should fix the problem with [unique]
mentioned by Mikolaj here:
http://www.winehq.org/pipermail/wine-devel/2007-September/059270.html
Thanks to Mikolaj for pointing this out to me.  Tests pass on wine and
windows.

---
 dlls/rpcrt4/tests/server.c   |    8 ++++++++
 dlls/rpcrt4/tests/server.idl |    1 +
 tools/widl/parser.y          |   19 +++++++++++++++++++
 3 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/dlls/rpcrt4/tests/server.c b/dlls/rpcrt4/tests/server.c
index 40f9a81..031714f 100644
--- a/dlls/rpcrt4/tests/server.c
+++ b/dlls/rpcrt4/tests/server.c
@@ -363,6 +363,12 @@ s_sum_bogus(bogus_t *b)
 }
 
 void
+s_check_null(int *null)
+{
+  ok(!null, "RPC check_null\n");
+}
+
+void
 s_stop(void)
 {
   ok(RPC_S_OK == RpcMgmtStopServerListening(NULL), "RpcMgmtStopServerListening\n");
@@ -504,6 +510,8 @@ basic_tests(void)
   bogus.p3 = &i3;
   bogus.c = 9;
   ok(sum_bogus(&bogus) == 12, "RPC sum_bogus\n");
+
+  check_null(NULL);
 }
 
 static void
diff --git a/dlls/rpcrt4/tests/server.idl b/dlls/rpcrt4/tests/server.idl
index 23ca779..9f66fe7 100644
--- a/dlls/rpcrt4/tests/server.idl
+++ b/dlls/rpcrt4/tests/server.idl
@@ -223,6 +223,7 @@ interface IServer
   } bogus_t;
 
   int sum_bogus(bogus_t *b);
+  void check_null([unique] int *null);
 
   void stop(void);
 }
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 46fb439..17dd700 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -1266,6 +1266,7 @@ static void set_type(var_t *v, type_t *type, int ptr_level, array_dims_t *arr)
 {
   expr_list_t *sizes = get_attrp(v->attrs, ATTR_SIZEIS);
   expr_list_t *lengs = get_attrp(v->attrs, ATTR_LENGTHIS);
+  int ptr_type = get_attrv(v->attrs, ATTR_POINTERTYPE);
   int sizeless, has_varconf;
   expr_t *dim;
   type_t *atype, **ptype;
@@ -1273,7 +1274,25 @@ static void set_type(var_t *v, type_t *type, int ptr_level, array_dims_t *arr)
   v->type = type;
 
   for ( ; 0 < ptr_level; --ptr_level)
+  {
     v->type = make_type(RPC_FC_RP, v->type);
+    if (ptr_level == 1 && ptr_type && !arr)
+    {
+      v->type->type = ptr_type;
+      ptr_type = 0;
+    }
+  }
+
+  if (ptr_type)
+  {
+    if (is_ptr(v->type))
+    {
+      v->type = duptype(v->type, 1);
+      v->type->type = ptr_type;
+    }
+    else if (!arr)
+      error("%s: pointer attribute applied to non-pointer type", v->name);
+  }
 
   sizeless = FALSE;
   if (arr) LIST_FOR_EACH_ENTRY_REV(dim, arr, expr_t, entry)



More information about the wine-patches mailing list