From 0486140c3dc934f9cc77d2db9f141d1c1c4dc34d Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sat, 28 May 2011 13:38:25 +0200 Subject: [PATCH] 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 deletion(-) diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index 2c629874071..8d93b331a08 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 5d46614d166..f348bd3ca88 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);