Alexandre Julliard : widl: Don' t output callback conformances for non-interpreted functions.

Alexandre Julliard julliard at winehq.org
Mon May 30 12:41:16 CDT 2011


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Sat May 28 13:38:25 2011 +0200

widl: Don't output callback conformances for non-interpreted functions.

The Windows marshaller calls the callback with an invalid stack.

---

 tools/widl/typegen.c |   21 ++++++++++++++++++++-
 tools/widl/typegen.h |    1 +
 2 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index 2c62987..8d93b331a 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -908,6 +908,19 @@ static unsigned int write_procformatstring_type(FILE *file, int indent,
     return size;
 }
 
+int is_interpreted_func( const type_t *iface, const var_t *func )
+{
+    const char *str;
+    const type_t *ret_type = type_function_get_rettype( func->type );
+
+    /* return value must fit in a long_ptr for interpreted functions */
+    if (type_get_type( ret_type ) == TYPE_BASIC && type_memsize( ret_type ) > pointer_size)
+        return 0;
+    if ((str = get_attrp( func->attrs, ATTR_OPTIMIZE ))) return !strcmp( str, "i" );
+    if ((str = get_attrp( iface->attrs, ATTR_OPTIMIZE ))) return !strcmp( str, "i" );
+    return 0;
+}
+
 static void write_procformatstring_func( FILE *file, int indent,
                                          const var_t *func, unsigned int *offset )
 {
@@ -1229,7 +1242,7 @@ static unsigned int write_conf_or_var_desc(FILE *file, const type_t *cont_type,
         print_file(file, 2, "NdrFcShort(0x%hx),\t/* offset = %d */\n",
                    (unsigned short)offset, offset);
     }
-    else
+    else if (!iface || is_interpreted_func( iface, current_func ))
     {
         unsigned int callback_offset = 0;
         struct expr_eval_routine *eval;
@@ -1267,6 +1280,12 @@ static unsigned int write_conf_or_var_desc(FILE *file, const type_t *cont_type,
         print_file(file, 2, "0x%x,\t/* %s */\n", RPC_FC_CALLBACK, "FC_CALLBACK");
         print_file(file, 2, "NdrFcShort(0x%hx),\t/* %u */\n", (unsigned short)callback_offset, callback_offset);
     }
+    else  /* output a dummy corr desc that isn't used */
+    {
+        print_file(file, 2, "0x%x,\t/* Corr desc: unused for %s */\n", conftype, name);
+        print_file(file, 2, "0x0,\n" );
+        print_file(file, 2, "NdrFcShort(0x0),\n" );
+    }
     return 4;
 }
 
diff --git a/tools/widl/typegen.h b/tools/widl/typegen.h
index 5d46614..f348bd3 100644
--- a/tools/widl/typegen.h
+++ b/tools/widl/typegen.h
@@ -82,6 +82,7 @@ void write_endpoints( FILE *f, const char *prefix, const str_list_t *list );
 void write_exceptions( FILE *file );
 unsigned int type_memsize(const type_t *t);
 int decl_indirect(const type_t *t);
+int is_interpreted_func(const type_t *iface, const var_t *func);
 void write_parameters_init(FILE *file, int indent, const var_t *func, const char *local_var_prefix);
 void print(FILE *file, int indent, const char *format, va_list ap);
 expr_t *get_size_is_expr(const type_t *t, const char *name);




More information about the wine-cvs mailing list