Robert Shearman : widl: Add some const attributes.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Dec 26 11:46:42 CST 2005


Module: wine
Branch: refs/heads/master
Commit: 7f2419ceed5c90130a8ac2062d6daa5f2e487930
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=7f2419ceed5c90130a8ac2062d6daa5f2e487930

Author: Robert Shearman <rob at codeweavers.com>
Date:   Mon Dec 26 13:11:33 2005 +0100

widl: Add some const attributes.

---

 tools/widl/header.c     |   46 +++++++++++++++++++++++-----------------------
 tools/widl/header.h     |   20 ++++++++++----------
 tools/widl/parser.y     |    6 +++---
 tools/widl/proxy.c      |    6 +++---
 tools/widl/write_msft.c |    2 +-
 5 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/tools/widl/header.c b/tools/widl/header.c
index f68844b..b60cf8e 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -46,7 +46,7 @@ static void indent(FILE *h, int delta)
   if (delta > 0) indentation += delta;
 }
 
-int is_attr(attr_t *a, enum attr_type t)
+int is_attr(const attr_t *a, enum attr_type t)
 {
   while (a) {
     if (a->type == t) return 1;
@@ -55,7 +55,7 @@ int is_attr(attr_t *a, enum attr_type t)
   return 0;
 }
 
-void *get_attrp(attr_t *a, enum attr_type t)
+void *get_attrp(const attr_t *a, enum attr_type t)
 {
   while (a) {
     if (a->type == t) return a->u.pval;
@@ -64,7 +64,7 @@ void *get_attrp(attr_t *a, enum attr_typ
   return NULL;
 }
 
-unsigned long get_attrv(attr_t *a, enum attr_type t)
+unsigned long get_attrv(const attr_t *a, enum attr_type t)
 {
   while (a) {
     if (a->type == t) return a->u.ival;
@@ -73,7 +73,7 @@ unsigned long get_attrv(attr_t *a, enum 
   return 0;
 }
 
-int is_void(type_t *t, var_t *v)
+int is_void(const type_t *t, const var_t *v)
 {
   if (v && v->ptr_level) return 0;
   if (!t->type && !t->ref) return 1;
@@ -90,7 +90,7 @@ static void write_guid(const char *guid_
         uuid->Data4[6], uuid->Data4[7]);
 }
 
-static void write_pident(FILE *h, var_t *v)
+static void write_pident(FILE *h, const var_t *v)
 {
   int c;
   for (c=0; c<v->ptr_level; c++) {
@@ -99,7 +99,7 @@ static void write_pident(FILE *h, var_t 
   if (v->name) fprintf(h, "%s", v->name);
 }
 
-void write_name(FILE *h, var_t *v)
+void write_name(FILE *h, const var_t *v)
 {
   if (is_attr( v->attrs, ATTR_PROPGET ))
     fprintf(h, "get_" );
@@ -110,12 +110,12 @@ void write_name(FILE *h, var_t *v)
   fprintf(h, "%s", v->name);
 }
 
-char* get_name(var_t *v)
+const char* get_name(const var_t *v)
 {
   return v->name;
 }
 
-static void write_array(FILE *h, expr_t *v, int field)
+static void write_array(FILE *h, const expr_t *v, int field)
 {
   if (!v) return;
   while (NEXT_LINK(v)) v = NEXT_LINK(v);
@@ -199,7 +199,7 @@ static void write_enums(FILE *h, var_t *
   fprintf(h, "\n");
 }
 
-void write_type(FILE *h, type_t *t, var_t *v, const char *n)
+void write_type(FILE *h, type_t *t, const var_t *v, const char *n)
 {
   int c;
 
@@ -381,10 +381,10 @@ void write_user_types(void)
   }
 }
 
-void write_typedef(type_t *type, var_t *names)
+void write_typedef(type_t *type, const var_t *names)
 {
   char *tname = names->tname;
-  var_t *lname;
+  const var_t *lname;
   while (NEXT_LINK(names)) names = NEXT_LINK(names);
   lname = names;
   fprintf(header, "typedef ");
@@ -477,14 +477,14 @@ void write_expr(FILE *h, expr_t *e)
   do_write_expr(h, e, 0);
 }
 
-void write_constdef(var_t *v)
+void write_constdef(const var_t *v)
 {
   fprintf(header, "#define %s (", get_name(v));
   write_expr(header, v->eval);
   fprintf(header, ")\n\n");
 }
 
-void write_externdef(var_t *v)
+void write_externdef(const var_t *v)
 {
   fprintf(header, "extern const ");
   write_type(header, v->type, NULL, v->tname);
@@ -545,7 +545,7 @@ var_t *is_callas(attr_t *a)
   return get_attrp(a, ATTR_CALLAS);
 }
 
-static int write_method_macro(type_t *iface, char *name)
+static int write_method_macro(const type_t *iface, const char *name)
 {
   int idx;
   func_t *cur = iface->funcs;
@@ -636,7 +636,7 @@ void write_args(FILE *h, var_t *arg, con
   if (do_indent) indentation--;
 }
 
-static void write_cpp_method_def(type_t *iface)
+static void write_cpp_method_def(const type_t *iface)
 {
   func_t *cur = iface->funcs;
 
@@ -659,7 +659,7 @@ static void write_cpp_method_def(type_t 
   }
 }
 
-static void do_write_c_method_def(type_t *iface, char *name)
+static void do_write_c_method_def(const type_t *iface, char *name)
 {
   func_t *cur = iface->funcs;
 
@@ -685,17 +685,17 @@ static void do_write_c_method_def(type_t
   }
 }
 
-static void write_c_method_def(type_t *iface)
+static void write_c_method_def(const type_t *iface)
 {
   do_write_c_method_def(iface, iface->name);
 }
 
-static void write_c_disp_method_def(type_t *iface)
+static void write_c_disp_method_def(const type_t *iface)
 {
   do_write_c_method_def(iface->ref, iface->name);
 }
 
-static void write_method_proto(type_t *iface)
+static void write_method_proto(const type_t *iface)
 {
   func_t *cur = iface->funcs;
 
@@ -759,7 +759,7 @@ static void write_method_proto(type_t *i
   }
 }
 
-static void write_function_proto(type_t *iface)
+static void write_function_proto(const type_t *iface)
 {
   char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
   int explicit_handle = is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE);
@@ -816,13 +816,13 @@ void write_forward(type_t *iface)
   }
 }
 
-static void write_iface_guid(type_t *iface)
+static void write_iface_guid(const type_t *iface)
 {
   UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
   write_guid("IID", iface->name, uuid);
 } 
 
-static void write_dispiface_guid(type_t *iface)
+static void write_dispiface_guid(const type_t *iface)
 {
   UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
   write_guid("DIID", iface->name, uuid);
@@ -895,7 +895,7 @@ static void write_com_interface(type_t *
   fprintf(header,"\n#endif  /* __%s_INTERFACE_DEFINED__ */\n\n", iface->name);
 }
 
-static void write_rpc_interface(type_t *iface)
+static void write_rpc_interface(const type_t *iface)
 {
   unsigned long ver = get_attrv(iface->attrs, ATTR_VERSION);
   char *var = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
diff --git a/tools/widl/header.h b/tools/widl/header.h
index c649513..8adf929 100644
--- a/tools/widl/header.h
+++ b/tools/widl/header.h
@@ -21,13 +21,13 @@
 #ifndef __WIDL_HEADER_H
 #define __WIDL_HEADER_H
 
-extern int is_attr(attr_t *a, enum attr_type t);
-extern void *get_attrp(attr_t *a, enum attr_type t);
-extern unsigned long get_attrv(attr_t *a, enum attr_type t);
-extern int is_void(type_t *t, var_t *v);
-extern void write_name(FILE *h, var_t *v);
-extern char* get_name(var_t *v);
-extern void write_type(FILE *h, type_t *t, var_t *v, const char *n);
+extern int is_attr(const attr_t *a, enum attr_type t);
+extern void *get_attrp(const attr_t *a, enum attr_type t);
+extern unsigned long get_attrv(const attr_t *a, enum attr_type t);
+extern int is_void(const type_t *t, const var_t *v);
+extern void write_name(FILE *h, const var_t *v);
+extern const char* get_name(const var_t *v);
+extern void write_type(FILE *h, type_t *t, const var_t *v, const char *n);
 extern int is_object(attr_t *a);
 extern int is_local(attr_t *a);
 extern var_t *is_callas(attr_t *a);
@@ -36,10 +36,10 @@ extern void write_forward(type_t *iface)
 extern void write_interface(type_t *iface);
 extern void write_dispinterface(type_t *iface);
 extern void write_coclass(class_t *iface);
-extern void write_typedef(type_t *type, var_t *names);
+extern void write_typedef(type_t *type, const var_t *names);
 extern void write_expr(FILE *h, expr_t *e);
-extern void write_constdef(var_t *v);
-extern void write_externdef(var_t *v);
+extern void write_constdef(const var_t *v);
+extern void write_externdef(const var_t *v);
 extern void write_library(const char *name, attr_t *attr);
 extern void write_user_types(void);
 extern var_t* get_explicit_handle_var(func_t* func);
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index a556108..7c32944 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -84,7 +84,7 @@ static var_t *make_var(char *name);
 static func_t *make_func(var_t *def, var_t *args);
 static class_t *make_class(char *name);
 
-static type_t *reg_type(type_t *type, char *name, int t);
+static type_t *reg_type(type_t *type, const char *name, int t);
 static type_t *reg_types(type_t *type, var_t *names, int t);
 static type_t *find_type(const char *name, int t);
 static type_t *find_type2(char *name, int t);
@@ -1102,7 +1102,7 @@ static int hash_ident(const char *name)
 /***** type repository *****/
 
 struct rtype {
-  char *name;
+  const char *name;
   type_t *type;
   int t;
   struct rtype *next;
@@ -1110,7 +1110,7 @@ struct rtype {
 
 struct rtype *type_hash[HASHMAX];
 
-static type_t *reg_type(type_t *type, char *name, int t)
+static type_t *reg_type(type_t *type, const char *name, int t)
 {
   struct rtype *nt;
   int hash;
diff --git a/tools/widl/proxy.c b/tools/widl/proxy.c
index c91d388..988f1e7 100644
--- a/tools/widl/proxy.c
+++ b/tools/widl/proxy.c
@@ -206,7 +206,7 @@ static void proxy_check_pointers( var_t 
 static void marshall_size_arg( var_t *arg )
 {
   int index = 0;
-  type_t *type = get_base_type(arg);
+  const type_t *type = get_base_type(arg);
   expr_t *expr;
 
   expr = get_attrp( arg->attrs, ATTR_SIZEIS );
@@ -728,7 +728,7 @@ static void stub_genmarshall( var_t *arg
   stub_gen_marshall_copydata( args );
 }
 
-static void gen_stub(type_t *iface, func_t *cur, char *cas)
+static void gen_stub(type_t *iface, func_t *cur, const char *cas)
 {
   var_t *def = cur->def;
   var_t *arg;
@@ -892,7 +892,7 @@ static void write_proxy(type_t *iface)
     var_t *def = cur->def;
     if (!is_local(def->attrs)) {
       var_t *cas = is_callas(def->attrs);
-      char *cname = cas ? cas->name : NULL;
+      const char *cname = cas ? cas->name : NULL;
       int idx = cur->idx;
       if (cname) {
         func_t *m = iface->funcs;
diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c
index 220fc50..bf1806b 100644
--- a/tools/widl/write_msft.c
+++ b/tools/widl/write_msft.c
@@ -1627,7 +1627,7 @@ static HRESULT add_impl_type(msft_typein
 }
 
 static msft_typeinfo_t *create_msft_typeinfo(msft_typelib_t *typelib, enum type_kind kind,
-                                             char *name, attr_t *attr, int idx)
+                                             const char *name, attr_t *attr, int idx)
 {
     msft_typeinfo_t *msft_typeinfo;
     int nameoffset;




More information about the wine-cvs mailing list