widl [3/6]: Represent typedefs with easier to use structures

Robert Shearman rob at codeweavers.com
Tue Aug 29 07:45:41 CDT 2006


Dan Hipschman wrote:

>diff --git a/tools/widl/header.c b/tools/widl/header.c
>index 3a4cea9..5de43c0 100644
>--- a/tools/widl/header.c
>+++ b/tools/widl/header.c
>@@ -203,13 +203,14 @@ void write_type(FILE *h, type_t *t, cons
> {
>   int c;
> 
>+  if (t->is_const) fprintf(h, "const ");
>+
>   if (n) fprintf(h, "%s", n);
>+  else if (t->kind == TKIND_ALIAS) fprintf(h, "%s", t->name);
>  
>

I'm not really sure we should be depending on a typelib thing for a 
fundamental concept such as this. In fact, I think the kind field of the 
type_t structure could probably be removed and generated as needed in 
the typelib generation code.

>@@ -902,6 +885,7 @@ static type_t *make_int(int sign)
> 
> void init_types(void)
> {
>+  decl_builtin("void", 0);
>   decl_builtin("byte", RPC_FC_BYTE);
>   decl_builtin("wchar_t", RPC_FC_WCHAR);
>   decl_builtin("int", RPC_FC_LONG);     /* win32 */
>  
>

This would seem as though it would make widl incorrectly accept "int 
func(void a);" as a valid statement. I think you need to try to fix this 
case.

>@@ -1147,6 +1131,7 @@ static type_t *make_type(unsigned char t
>   t->type = type;
>   t->ref = ref;
>   t->attrs = NULL;
>+  t->orig = NULL;
>   t->funcs = NULL;
>   t->fields = NULL;
>   t->ifaces = NULL;
>@@ -1175,8 +1160,15 @@ static typeref_t *uniq_tref(typeref_t *r
>   typeref_t *t = ref;
>   type_t *tp;
>   if (t->uniq) return t;
>-  tp = make_type(0, t->ref);
>-  tp->name = t->name;
>+
>+  if (t->name)
>+  {
>+    tp = duptype(t->ref, 0);
>+    tp->name = t->name;
>+  }
>+  else
>+    tp = duptype(t->ref, 1);
>+
>   t->name = NULL;
>   t->ref = tp;
>   t->uniq = 1;
>@@ -1311,11 +1303,27 @@ static unsigned char get_pointer_type( t
>   return RPC_FC_FP;
> }
> 
>-static type_t *reg_types(type_t *type, var_t *names, int t)
>+static type_t *reg_typedefs(type_t *type, var_t *names, attr_t *attrs)
> {
>   type_t *ptr = type;
>   int ptrc = 0;
> 
>+  /* We must generate names for tagless enum, struct or union.
>+     Typedef-ing a tagless enum, struct or union means we want the typedef
>+     to be included in a library whether it has other attributes or not,
>+     hence the public attribute.  */
>+  if ((type->kind == TKIND_ENUM || type->kind == TKIND_RECORD
>+       || type->kind == TKIND_UNION) && ! type->name && ! parse_only)
>+  {
>+    if (! is_attr(attrs, ATTR_PUBLIC))
>+    {
>+      attr_t *new_attrs = make_attr(ATTR_PUBLIC);
>+      LINK(new_attrs, attrs);
>+      attrs = new_attrs;
>+    }
>  
>

I'm not sure it is necessary to include this change with the rest of the 
patch. I'm also not sure what you are trying to accomplish here (as we 
always add the type to a typelib, no matter whether the type has the 
public attribute).

>+    type->name = gen_name();
>+  }
>+
>   while (names) {
>     var_t *next = NEXT_LINK(names);
>     if (names->name) {
>@@ -1323,8 +1331,7 @@ static type_t *reg_types(type_t *type, v
>       int cptr = names->ptr_level;
>       if (cptr > ptrc) {
>         while (cptr > ptrc) {
>-          int t = get_pointer_type( cur );
>-          cur = ptr = make_type(t, cur);
>+          cur = ptr = make_type(RPC_FC_RP, cur);
>           ptrc++;
>         }
>       } else {
>  
>

Thanks and keep up the good work!

-- 
Rob Shearman




More information about the wine-devel mailing list