Eric Kohl : widl: Fix format string size calculation.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Mar 23 13:50:09 CST 2006


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

Author: Eric Kohl <eric.kohl at t-online.de>
Date:   Thu Mar 23 10:33:08 2006 +0100

widl: Fix format string size calculation.

- Move proc format string size calculation from client.c and server.c
  to typegen.c.
- Implement type format string size calculation.

---

 tools/widl/client.c  |   34 ++++-----------------------
 tools/widl/server.c  |   34 ++++-----------------------
 tools/widl/typegen.c |   64 +++++++++++++++++++++++++++++++++++++++++++++++++-
 tools/widl/typegen.h |    4 ++-
 4 files changed, 76 insertions(+), 60 deletions(-)

diff --git a/tools/widl/client.c b/tools/widl/client.c
index 3197b73..db8ce7f 100644
--- a/tools/widl/client.c
+++ b/tools/widl/client.c
@@ -1,7 +1,7 @@
 /*
  * IDL Compiler
  *
- * Copyright 2005 Eric Kohl
+ * Copyright 2005-2006 Eric Kohl
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -384,35 +384,11 @@ static void write_formatdesc( const char
 
 static void write_formatstringsdecl(type_t *iface)
 {
-    int byte_count = 1;
+    print_client("#define TYPE_FORMAT_STRING_SIZE %d\n",
+                 get_size_typeformatstring(iface));
 
-    print_client("#define TYPE_FORMAT_STRING_SIZE %d\n", 3); /* FIXME */
-
-    /* determine the proc format string size */
-    if (iface->funcs)
-    {
-        func_t *func = iface->funcs;
-        while (NEXT_LINK(func)) func = NEXT_LINK(func);
-        while (func)
-        {
-            /* argument list size */
-            if (func->args)
-            {
-                var_t *var = func->args;
-                while (NEXT_LINK(var)) var = NEXT_LINK(var);
-                while (var)
-                {
-                    byte_count += 2; /* FIXME: determine real size */
-                    var = PREV_LINK(var);
-                }
-            }
-    
-            /* return value size */
-            byte_count += 2; /* FIXME: determine real size */
-            func = PREV_LINK(func);
-        }
-    }
-    print_client("#define PROC_FORMAT_STRING_SIZE %d\n", byte_count);
+    print_client("#define PROC_FORMAT_STRING_SIZE %d\n",
+                 get_size_procformatstring(iface));
 
     fprintf(client, "\n");
     write_formatdesc("TYPE");
diff --git a/tools/widl/server.c b/tools/widl/server.c
index 3f7b976..1b134f3 100644
--- a/tools/widl/server.c
+++ b/tools/widl/server.c
@@ -1,7 +1,7 @@
 /*
  * IDL Compiler
  *
- * Copyright 2005 Eric Kohl
+ * Copyright 2005-2006 Eric Kohl
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -472,35 +472,11 @@ static void write_formatdesc( const char
 
 static void write_formatstringsdecl(type_t *iface)
 {
-    int byte_count = 1;
+    print_server("#define TYPE_FORMAT_STRING_SIZE %d\n",
+                 get_size_typeformatstring(iface));
 
-    print_server("#define TYPE_FORMAT_STRING_SIZE %d\n", 3); /* FIXME */
-
-    /* determine the proc format string size */
-    if (iface->funcs)
-    {
-        func_t *func = iface->funcs;
-        while (NEXT_LINK(func)) func = NEXT_LINK(func);
-        while (func)
-        {
-            /* argument list size */
-            if (func->args)
-            {
-                var_t *var = func->args;
-                while (NEXT_LINK(var)) var = NEXT_LINK(var);
-                while (var)
-                {
-                    byte_count += 2; /* FIXME: determine real size */
-                    var = PREV_LINK(var);
-                }
-            }
-    
-            /* return value size */
-            byte_count += 2; /* FIXME: determine real size */
-            func = PREV_LINK(func);
-        }
-    }
-    print_server("#define PROC_FORMAT_STRING_SIZE %d\n", byte_count);
+    print_server("#define PROC_FORMAT_STRING_SIZE %d\n",
+                 get_size_procformatstring(iface));
 
     fprintf(server, "\n");
     write_formatdesc("TYPE");
diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index d9b722c..fd2d040 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -1,7 +1,7 @@
 /*
  * Format String Generator for IDL Compiler
  *
- * Copyright 2005 Eric Kohl
+ * Copyright 2005-2006 Eric Kohl
  * Copyright 2005-2006 Robert Shearman
  *
  * This library is free software; you can redistribute it and/or
@@ -1591,6 +1591,68 @@ size_t get_size_typeformatstring_var(con
     return type_offset;
 }
 
+size_t get_size_procformatstring(const type_t *iface)
+{
+    size_t size = 1;
+    func_t *func;
+    var_t *var;
+
+    if (iface->funcs)
+    {
+        func = iface->funcs;
+        while (NEXT_LINK(func)) func = NEXT_LINK(func);
+        while (func)
+        {
+            /* argument list size */
+            if (func->args)
+            {
+                var = func->args;
+                while (NEXT_LINK(var)) var = NEXT_LINK(var);
+                while (var)
+                {
+                    size += get_size_procformatstring_var(var);
+                    var = PREV_LINK(var);
+                }
+            }
+
+            /* return value size */
+            size += 2; /* FIXME: determine real size */
+            func = PREV_LINK(func);
+        }
+    }
+    return size;
+}
+
+size_t get_size_typeformatstring(const type_t *iface)
+{
+    size_t size = 3;
+    func_t *func;
+    var_t *var;
+
+    if (iface->funcs)
+    {
+        func = iface->funcs;
+        while (NEXT_LINK(func)) func = NEXT_LINK(func);
+        while (func)
+        {
+            /* argument list size */
+            if (func->args)
+            {
+                var = func->args;
+                while (NEXT_LINK(var)) var = NEXT_LINK(var);
+                while (var)
+                {
+                    size += get_size_typeformatstring_var(var);
+                    var = PREV_LINK(var);
+                }
+            }
+
+            func = PREV_LINK(func);
+        }
+    }
+    return size;
+}
+
 static void write_struct_expr(FILE *h, const expr_t *e, int brackets,
                               const var_t *fields, const char *structvar)
 {
diff --git a/tools/widl/typegen.h b/tools/widl/typegen.h
index 0150429..080bdaf 100644
--- a/tools/widl/typegen.h
+++ b/tools/widl/typegen.h
@@ -1,7 +1,7 @@
 /*
  * Format String Generator for IDL Compiler
  *
- * Copyright 2005 Eric Kohl
+ * Copyright 2005-2006 Eric Kohl
  * Copyright 2005 Robert Shearman
  *
  * This library is free software; you can redistribute it and/or
@@ -41,5 +41,7 @@ unsigned int get_required_buffer_size(co
 void write_remoting_arguments(FILE *file, int indent, const func_t *func, unsigned int *type_offset, enum pass pass, enum remoting_phase phase);
 size_t get_size_procformatstring_var(const var_t *var);
 size_t get_size_typeformatstring_var(const var_t *var);
+size_t get_size_procformatstring(const type_t *iface);
+size_t get_size_typeformatstring(const type_t *iface);
 int write_expr_eval_routines(FILE *file, const char *iface);
 void write_expr_eval_routine_list(FILE *file, const char *iface);




More information about the wine-cvs mailing list