Rob Shearman : widl: Simplify write_typeformatstring_var.

Alexandre Julliard julliard at winehq.org
Tue Mar 16 11:49:13 CDT 2010


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

Author: Rob Shearman <robertshearman at gmail.com>
Date:   Mon Mar 15 19:29:43 2010 +0000

widl: Simplify write_typeformatstring_var.

The check for whether a pointer is the last one is redundant since
typegen_detect_type does a stricter check on the ref type. Replace one
other instance of last_ptr with a more readable equivalent.

---

 tools/widl/typegen.c |   62 ++++++++++++++++++++++++-------------------------
 1 files changed, 30 insertions(+), 32 deletions(-)

diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index 19f66c0..b0c2c20 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -1339,7 +1339,7 @@ static unsigned int write_nonsimple_pointer(FILE *file, const attr_list_t *attrs
     if (out_attr && !in_attr && pointer_type == RPC_FC_RP)
         flags |= RPC_FC_P_ONSTACK;
 
-    if (is_ptr(type) && !last_ptr(type))
+    if (is_ptr(type) && is_declptr(type_pointer_get_ref(type)))
         flags |= RPC_FC_P_DEREF;
 
     print_file(file, 2, "0x%x, 0x%x,\t\t/* %s",
@@ -2794,50 +2794,48 @@ static unsigned int write_typeformatstring_var(FILE *file, int indent, const var
     case TGT_IFACE_POINTER:
         return write_ip_tfs(file, var->attrs, type, typeformat_offset);
     case TGT_POINTER:
-        if (last_ptr(type))
+    {
+        type_t *ref = type_pointer_get_ref(type);
+
+        switch (typegen_detect_type(ref, NULL, TDT_ALL_TYPES))
         {
+        /* special case for pointers to base types */
+        case TGT_BASIC:
+        case TGT_ENUM:
+        {
+            unsigned char fc;
             size_t start_offset = *typeformat_offset;
             int in_attr = is_attr(var->attrs, ATTR_IN);
             int out_attr = is_attr(var->attrs, ATTR_OUT);
-            const type_t *ref = type_pointer_get_ref(type);
-
-            switch (typegen_detect_type(ref, NULL, TDT_ALL_TYPES))
-            {
-            /* special case for pointers to base types */
-            case TGT_BASIC:
-            case TGT_ENUM:
-            {
-                unsigned char fc;
 
-                if (type_get_type(ref) == TYPE_ENUM)
-                    fc = get_enum_fc(ref);
-                else
-                    fc = get_basic_fc(ref);
-
-                print_file(file, indent, "0x%x, 0x%x,    /* %s %s[simple_pointer] */\n",
-                           get_pointer_fc(type, var->attrs, toplevel_param),
-                           (!in_attr && out_attr) ? 0x0C : 0x08,
-                           string_of_type(get_pointer_fc(type, var->attrs, toplevel_param)),
-                           (!in_attr && out_attr) ? "[allocated_on_stack] " : "");
-                print_file(file, indent, "0x%02x,    /* %s */\n",
-                           fc, string_of_type(fc));
-                print_file(file, indent, "0x5c,          /* FC_PAD */\n");
-                *typeformat_offset += 4;
-                return start_offset;
-            }
-            default:
-                break;
-            }
+            if (type_get_type(ref) == TYPE_ENUM)
+                fc = get_enum_fc(ref);
+            else
+                fc = get_basic_fc(ref);
+
+            print_file(file, indent, "0x%x, 0x%x,    /* %s %s[simple_pointer] */\n",
+                       get_pointer_fc(type, var->attrs, toplevel_param),
+                       (!in_attr && out_attr) ? 0x0C : 0x08,
+                       string_of_type(get_pointer_fc(type, var->attrs, toplevel_param)),
+                       (!in_attr && out_attr) ? "[allocated_on_stack] " : "");
+            print_file(file, indent, "0x%02x,    /* %s */\n",
+                       fc, string_of_type(fc));
+            print_file(file, indent, "0x5c,          /* FC_PAD */\n");
+            *typeformat_offset += 4;
+            return start_offset;
+        }
+        default:
+            break;
         }
 
-        offset = write_typeformatstring_var(file, indent, func,
-                                            type_pointer_get_ref(type), var,
+        offset = write_typeformatstring_var(file, indent, func, ref, var,
                                             FALSE, typeformat_offset);
         if (file)
             fprintf(file, "/* %2u */\n", *typeformat_offset);
         return write_nonsimple_pointer(file, var->attrs, type,
                                        toplevel_param,
                                        offset, typeformat_offset);
+    }
     case TGT_INVALID:
         break;
     }




More information about the wine-cvs mailing list