[2/4] widl: Replace get_name with a field reference

Dan Hipschman dsh at linux.ucla.edu
Tue Jun 5 20:49:12 CDT 2007


This patch just gets rid of a function that isn't really helpful.  It
was included in the larger patch last time, so this just separates it
out.  It doesn't make much of a difference in size, though.

A call to get_name(v) just returns v->name.  I've found the abstraction
to be more confusing than helpful, and a field reference is transparent.

---
 tools/widl/header.c |   17 ++++++-----------
 tools/widl/header.h |    1 -
 tools/widl/proxy.c  |    2 +-
 3 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/tools/widl/header.c b/tools/widl/header.c
index 4f5b6b5..6f4a7ba 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -141,11 +141,6 @@ void write_prefix_name(FILE *h, const char *prefix, const var_t *v)
   write_name(h, v);
 }
 
-const char* get_name(const var_t *v)
-{
-  return v->name;
-}
-
 void write_array(FILE *h, array_dims_t *dims, int field)
 {
   expr_t *v;
@@ -170,7 +165,7 @@ static void write_field(FILE *h, var_t *v)
   if (v->type) {
     indent(h, 0);
     write_type(h, v->type);
-    if (get_name(v))
+    if (v->name)
       fprintf(h, " %s", v->name);
     else {
       /* not all C/C++ compilers support anonymous structs and unions */
@@ -210,7 +205,7 @@ static void write_enums(FILE *h, var_list_t *enums)
   if (!enums) return;
   LIST_FOR_EACH_ENTRY( v, enums, var_t, entry )
   {
-    if (get_name(v)) {
+    if (v->name) {
       indent(h, 0);
       write_name(h, v);
       if (v->eval) {
@@ -444,7 +439,7 @@ void write_expr(FILE *h, const expr_t *e, int brackets)
 
 void write_constdef(const var_t *v)
 {
-  fprintf(header, "#define %s (", get_name(v));
+  fprintf(header, "#define %s (", v->name);
   write_expr(header, v->eval, 0);
   fprintf(header, ")\n\n");
 }
@@ -453,7 +448,7 @@ void write_externdef(const var_t *v)
 {
   fprintf(header, "extern const ");
   write_type(header, v->type);
-  if (get_name(v))
+  if (v->name)
     fprintf(header, " %s", v->name);
   fprintf(header, ";\n\n");
 }
@@ -688,7 +683,7 @@ static void write_method_proto(const type_t *iface)
     if (cas) {
       const func_t *m;
       LIST_FOR_EACH_ENTRY( m, iface->funcs, const func_t, entry )
-          if (!strcmp(get_name(m->def), cas->name)) break;
+          if (!strcmp(m->def->name, cas->name)) break;
       if (&m->entry != iface->funcs) {
         const var_t *mdef = m->def;
         /* proxy prototype - use local prototype */
@@ -707,7 +702,7 @@ static void write_method_proto(const type_t *iface)
         fprintf(header, ");\n");
       }
       else {
-        parser_warning("invalid call_as attribute (%s -> %s)\n", get_name(def), cas->name);
+        parser_warning("invalid call_as attribute (%s -> %s)\n", def->name, cas->name);
       }
     }
   }
diff --git a/tools/widl/header.h b/tools/widl/header.h
index 57ae6b4..dd5c1ea 100644
--- a/tools/widl/header.h
+++ b/tools/widl/header.h
@@ -32,7 +32,6 @@ extern int is_conformant_array( const array_dims_t *array );
 extern int is_non_void(const expr_list_t *list);
 extern void write_name(FILE *h, const var_t *v);
 extern void write_prefix_name(FILE *h, const char *prefix, const var_t *v);
-extern const char* get_name(const var_t *v);
 extern void write_type(FILE *h, type_t *t);
 extern int is_object(const attr_list_t *list);
 extern int is_local(const attr_list_t *list);
diff --git a/tools/widl/proxy.c b/tools/widl/proxy.c
index 9cc61c2..9066d87 100644
--- a/tools/widl/proxy.c
+++ b/tools/widl/proxy.c
@@ -507,7 +507,7 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset)
       if (cname) {
           const func_t *m;
           LIST_FOR_EACH_ENTRY( m, iface->funcs, const func_t, entry )
-              if (!strcmp(get_name(m->def), cname))
+              if (!strcmp(m->def->name, cname))
               {
                   idx = m->idx;
                   break;



More information about the wine-patches mailing list