[PATCH 5/5] widl: Move the "idx" parameter from struct func_details to var_t.

Zebediah Figura z.figura12 at gmail.com
Tue Aug 13 21:08:07 CDT 2019


It's not a part of the type; e.g. it doesn't make sense on a function pointer.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 tools/widl/proxy.c     | 4 ++--
 tools/widl/typetree.c  | 7 +++----
 tools/widl/widltypes.h | 6 ++++--
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/tools/widl/proxy.c b/tools/widl/proxy.c
index 6f19ff15df..466c46219f 100644
--- a/tools/widl/proxy.c
+++ b/tools/widl/proxy.c
@@ -614,14 +614,14 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset)
     if (!is_local(func->attrs)) {
       const var_t *cas = is_callas(func->attrs);
       const char *cname = cas ? cas->name : NULL;
-      int idx = func->declspec.type->details.function->idx;
+      int idx = func->func_idx;
       if (cname) {
           const statement_t *stmt2;
           STATEMENTS_FOR_EACH_FUNC(stmt2, type_iface_get_stmts(iface)) {
               const var_t *m = stmt2->u.var;
               if (!strcmp(m->name, cname))
               {
-                  idx = m->declspec.type->details.function->idx;
+                  idx = m->func_idx;
                   break;
               }
           }
diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c
index 0a8ae0f3b2..e727d8c697 100644
--- a/tools/widl/typetree.c
+++ b/tools/widl/typetree.c
@@ -174,7 +174,6 @@ type_t *type_new_function(var_list_t *args)
     t = make_type(TYPE_FUNCTION);
     t->details.function = xmalloc(sizeof(*t->details.function));
     t->details.function->args = args;
-    t->details.function->idx = -1;
     return t;
 }
 
@@ -413,9 +412,9 @@ type_t *type_new_bitfield(type_t *field, const expr_t *bits)
     return t;
 }
 
-static int compute_method_indexes(type_t *iface)
+static unsigned int compute_method_indexes(type_t *iface)
 {
-    int idx;
+    unsigned int idx;
     statement_t *stmt;
 
     if (!iface->details.iface)
@@ -430,7 +429,7 @@ static int compute_method_indexes(type_t *iface)
     {
         var_t *func = stmt->u.var;
         if (!is_callas(func->attrs))
-            func->declspec.type->details.function->idx = idx++;
+            func->func_idx = idx++;
     }
 
     return idx;
diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h
index 729d712a27..5e0f34db8d 100644
--- a/tools/widl/widltypes.h
+++ b/tools/widl/widltypes.h
@@ -342,7 +342,6 @@ struct func_details
 {
   var_list_t *args;
   struct _var_t *retval;
-  int idx;
 };
 
 struct iface_details
@@ -460,9 +459,12 @@ struct _var_t {
   decl_spec_t declspec;
   attr_list_t *attrs;
   expr_t *eval;
-  unsigned int procstring_offset;
+
   unsigned int typestring_offset;
 
+  /* fields specific to functions */
+  unsigned int procstring_offset, func_idx;
+
   struct _loc_info_t loc_info;
 
   /* parser-internal */
-- 
2.22.0




More information about the wine-devel mailing list