Update widl to Wine-1.4

svn path=/trunk/; revision=57062
This commit is contained in:
Eric Kohl 2012-08-12 16:19:13 +00:00
parent 73862fa7c6
commit 80e2dfaa07
11 changed files with 1125 additions and 1105 deletions

View file

@ -74,9 +74,9 @@ static void write_function_stub( const type_t *iface, const var_t *func,
{ {
unsigned char explicit_fc, implicit_fc; unsigned char explicit_fc, implicit_fc;
int has_full_pointer = is_full_pointer_function(func); int has_full_pointer = is_full_pointer_function(func);
type_t *rettype = type_function_get_rettype(func->type); var_t *retval = type_function_get_retval(func->type);
const var_t *handle_var = get_func_handle_var( iface, func, &explicit_fc, &implicit_fc ); const var_t *handle_var = get_func_handle_var( iface, func, &explicit_fc, &implicit_fc );
int has_ret = !is_void(rettype); int has_ret = !is_void(retval->type);
if (is_interpreted_func( iface, func )) if (is_interpreted_func( iface, func ))
{ {
@ -97,9 +97,9 @@ static void write_function_stub( const type_t *iface, const var_t *func,
print_client("RPC_BINDING_HANDLE _Handle;\n"); print_client("RPC_BINDING_HANDLE _Handle;\n");
} }
if (has_ret && decl_indirect(rettype)) if (has_ret && decl_indirect(retval->type))
{ {
print_client("void *_p_%s;\n", "_RetVal" ); print_client("void *_p_%s;\n", retval->name);
} }
indent--; indent--;
print_client( "};\n\n" ); print_client( "};\n\n" );
@ -132,12 +132,12 @@ static void write_function_stub( const type_t *iface, const var_t *func,
indent++; indent++;
print_client( "struct __frame_%s%s __f, * const __frame = &__f;\n", prefix_client, get_name(func) ); print_client( "struct __frame_%s%s __f, * const __frame = &__f;\n", prefix_client, get_name(func) );
/* declare return value '_RetVal' */ /* declare return value */
if (has_ret) if (has_ret)
{ {
print_client("%s", ""); print_client("%s", "");
write_type_decl_left(client, rettype); write_type_decl(client, retval->type, retval->name);
fprintf(client, " _RetVal;\n"); fprintf(client, ";\n");
} }
print_client("RPC_MESSAGE _RpcMessage;\n"); print_client("RPC_MESSAGE _RpcMessage;\n");
@ -147,10 +147,9 @@ static void write_function_stub( const type_t *iface, const var_t *func,
if (explicit_fc == RPC_FC_BIND_GENERIC) if (explicit_fc == RPC_FC_BIND_GENERIC)
print_client("__frame->%s = %s;\n", handle_var->name, handle_var->name ); print_client("__frame->%s = %s;\n", handle_var->name, handle_var->name );
} }
if (has_ret && decl_indirect(rettype)) if (has_ret && decl_indirect(retval->type))
{ {
print_client("__frame->_p_%s = &%s;\n", print_client("__frame->_p_%s = &%s;\n", retval->name, retval->name);
"_RetVal", "_RetVal");
} }
fprintf(client, "\n"); fprintf(client, "\n");
@ -258,10 +257,10 @@ static void write_function_stub( const type_t *iface, const var_t *func,
/* unmarshal return value */ /* unmarshal return value */
if (has_ret) if (has_ret)
{ {
if (decl_indirect(rettype)) if (decl_indirect(retval->type))
print_client("MIDL_memset(&%s, 0, sizeof(%s));\n", "_RetVal", "_RetVal"); print_client("MIDL_memset(&%s, 0, sizeof(%s));\n", retval->name, retval->name);
else if (is_ptr(rettype) || is_array(rettype)) else if (is_ptr(retval->type) || is_array(retval->type))
print_client("%s = 0;\n", "_RetVal"); print_client("%s = 0;\n", retval->name);
write_remoting_arguments(client, indent, func, "", PASS_RETURN, PHASE_UNMARSHAL); write_remoting_arguments(client, indent, func, "", PASS_RETURN, PHASE_UNMARSHAL);
} }
@ -280,7 +279,7 @@ static void write_function_stub( const type_t *iface, const var_t *func,
if (has_ret) if (has_ret)
{ {
fprintf(client, "\n"); fprintf(client, "\n");
print_client("return _RetVal;\n"); print_client("return %s;\n", retval->name);
} }
indent--; indent--;
@ -472,8 +471,6 @@ static void write_client_ifaces(const statement_list_t *stmts, int expr_eval_rou
write_stubdescriptor(iface, expr_eval_routines); write_stubdescriptor(iface, expr_eval_routines);
} }
} }
else if (stmt->type == STMT_LIBRARY)
write_client_ifaces(stmt->u.lib->stmts, expr_eval_routines, proc_offset);
} }
} }

View file

@ -987,8 +987,6 @@ static void write_local_stubs_stmts(FILE *local_stubs, const statement_list_t *s
{ {
if (stmt->type == STMT_TYPE && type_get_type(stmt->u.type) == TYPE_INTERFACE) if (stmt->type == STMT_TYPE && type_get_type(stmt->u.type) == TYPE_INTERFACE)
write_locals(local_stubs, stmt->u.type, TRUE); write_locals(local_stubs, stmt->u.type, TRUE);
else if (stmt->type == STMT_LIBRARY)
write_local_stubs_stmts(local_stubs, stmt->u.lib->stmts);
} }
} }
@ -1360,10 +1358,15 @@ void write_header(const statement_list_t *stmts)
return; return;
} }
fprintf(header, "/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n\n", PACKAGE_VERSION, input_name); fprintf(header, "/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n\n", PACKAGE_VERSION, input_name);
fprintf(header, "#ifndef __REQUIRED_RPCNDR_H_VERSION__\n");
fprintf(header, "#define __REQUIRED_RPCNDR_H_VERSION__ 475\n");
fprintf(header, "#endif\n\n");
fprintf(header, "#include <rpc.h>\n" ); fprintf(header, "#include <rpc.h>\n" );
fprintf(header, "#include <rpcndr.h>\n\n" ); fprintf(header, "#include <rpcndr.h>\n\n" );
fprintf(header, "#if !defined(COM_NO_WINDOWS_H) && !defined(__WINESRC__)\n"); fprintf(header, "#ifndef COM_NO_WINDOWS_H\n");
fprintf(header, "#include <windows.h>\n"); fprintf(header, "#include <windows.h>\n");
fprintf(header, "#include <ole2.h>\n"); fprintf(header, "#include <ole2.h>\n");
fprintf(header, "#endif\n\n"); fprintf(header, "#endif\n\n");

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,8 @@
/* A Bison parser, made by GNU Bison 2.4.2. */ /* A Bison parser, made by GNU Bison 2.5. */
/* Skeleton interface for Bison's Yacc-like parsers in C /* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
Foundation, Inc.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -228,7 +227,7 @@
typedef union YYSTYPE typedef union YYSTYPE
{ {
/* Line 1685 of yacc.c */ /* Line 2068 of yacc.c */
#line 153 "parser.y" #line 153 "parser.y"
attr_t *attr; attr_t *attr;
@ -258,8 +257,8 @@ typedef union YYSTYPE
/* Line 1685 of yacc.c */ /* Line 2068 of yacc.c */
#line 263 "parser.tab.h" #line 262 "parser.tab.h"
} YYSTYPE; } YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */

View file

@ -1607,7 +1607,8 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
for (ft = v->type; is_ptr(ft); ft = type_pointer_get_ref(ft)) for (ft = v->type; is_ptr(ft); ft = type_pointer_get_ref(ft))
; ;
assert(type_get_type_detect_alias(ft) == TYPE_FUNCTION); assert(type_get_type_detect_alias(ft) == TYPE_FUNCTION);
ft->details.function->rettype = return_type; ft->details.function->retval = make_var(xstrdup("_RetVal"));
ft->details.function->retval->type = return_type;
/* move calling convention attribute, if present, from pointer nodes to /* move calling convention attribute, if present, from pointer nodes to
* function node */ * function node */
for (t = v->type; is_ptr(t); t = type_pointer_get_ref(t)) for (t = v->type; is_ptr(t); t = type_pointer_get_ref(t))

View file

@ -73,6 +73,7 @@ typedef int flex_int32_t;
typedef unsigned char flex_uint8_t; typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t; typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t; typedef unsigned int flex_uint32_t;
#endif /* ! C99 */
/* Limits of integral types. */ /* Limits of integral types. */
#ifndef INT8_MIN #ifndef INT8_MIN
@ -103,8 +104,6 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U) #define UINT32_MAX (4294967295U)
#endif #endif
#endif /* ! C99 */
#endif /* ! FLEXINT_H */ #endif /* ! FLEXINT_H */
#ifdef __cplusplus #ifdef __cplusplus
@ -161,15 +160,7 @@ typedef unsigned int flex_uint32_t;
/* Size of default input buffer. */ /* Size of default input buffer. */
#ifndef YY_BUF_SIZE #ifndef YY_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k.
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
* Ditto for the __ia64__ case accordingly.
*/
#define YY_BUF_SIZE 32768
#else
#define YY_BUF_SIZE 16384 #define YY_BUF_SIZE 16384
#endif /* __ia64__ */
#endif #endif
/* The state buf must be large enough to hold one state per character in the main buffer. /* The state buf must be large enough to hold one state per character in the main buffer.
@ -750,7 +741,7 @@ UUID *parse_uuid(const char *u)
* The flexer starts here * The flexer starts here
************************************************************************** **************************************************************************
*/ */
#line 754 "parser.yy.c" #line 745 "parser.yy.c"
#define INITIAL 0 #define INITIAL 0
#define QUOTE 1 #define QUOTE 1
@ -842,12 +833,7 @@ static int input (void );
/* Amount of stuff to slurp up with each read. */ /* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE #ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k */
#define YY_READ_BUF_SIZE 16384
#else
#define YY_READ_BUF_SIZE 8192 #define YY_READ_BUF_SIZE 8192
#endif /* __ia64__ */
#endif #endif
/* Copy whatever the last rule matched to the standard output. */ /* Copy whatever the last rule matched to the standard output. */
@ -855,7 +841,7 @@ static int input (void );
/* This used to be an fputs(), but since the string might contain NUL's, /* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite(). * we now use fwrite().
*/ */
#define ECHO do { if (fwrite( parser_text, parser_leng, 1, parser_out )) {} } while (0) #define ECHO fwrite( parser_text, parser_leng, 1, parser_out )
#endif #endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@ -866,7 +852,7 @@ static int input (void );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \ { \
int c = '*'; \ int c = '*'; \
size_t n; \ int n; \
for ( n = 0; n < max_size && \ for ( n = 0; n < max_size && \
(c = getc( parser_in )) != EOF && c != '\n'; ++n ) \ (c = getc( parser_in )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \ buf[n] = (char) c; \
@ -953,7 +939,7 @@ YY_DECL
#line 127 "parser.l" #line 127 "parser.l"
#line 957 "parser.yy.c" #line 943 "parser.yy.c"
if ( !(yy_init) ) if ( !(yy_init) )
{ {
@ -1268,7 +1254,7 @@ YY_RULE_SETUP
#line 209 "parser.l" #line 209 "parser.l"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 1272 "parser.yy.c" #line 1258 "parser.yy.c"
case YY_END_OF_BUFFER: case YY_END_OF_BUFFER:
{ {
@ -1987,8 +1973,8 @@ YY_BUFFER_STATE parser__scan_string (yyconst char * yystr )
/** Setup the input buffer state to scan the given bytes. The next call to parser_lex() will /** Setup the input buffer state to scan the given bytes. The next call to parser_lex() will
* scan from a @e copy of @a bytes. * scan from a @e copy of @a bytes.
* @param yybytes the byte buffer to scan * @param bytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param len the number of bytes in the buffer pointed to by @a bytes.
* *
* @return the newly allocated buffer state object. * @return the newly allocated buffer state object.
*/ */

View file

@ -148,7 +148,7 @@ static int need_delegation_indirect(const type_t *iface)
static void free_variable( const var_t *arg, const char *local_var_prefix ) static void free_variable( const var_t *arg, const char *local_var_prefix )
{ {
unsigned int type_offset = arg->type->typestring_offset; unsigned int type_offset = arg->typestring_offset;
type_t *type = arg->type; type_t *type = arg->type;
write_parameter_conf_or_var_exprs(proxy, indent, local_var_prefix, PHASE_FREE, arg, FALSE); write_parameter_conf_or_var_exprs(proxy, indent, local_var_prefix, PHASE_FREE, arg, FALSE);
@ -193,8 +193,8 @@ static void proxy_free_variables( var_list_t *args, const char *local_var_prefix
static void gen_proxy(type_t *iface, const var_t *func, int idx, static void gen_proxy(type_t *iface, const var_t *func, int idx,
unsigned int proc_offset) unsigned int proc_offset)
{ {
type_t *rettype = type_function_get_rettype(func->type); var_t *retval = type_function_get_retval(func->type);
int has_ret = !is_void(rettype); int has_ret = !is_void(retval->type);
int has_full_pointer = is_full_pointer_function(func); int has_full_pointer = is_full_pointer_function(func);
const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV); const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV);
const var_list_t *args = type_get_function_args(func->type); const var_list_t *args = type_get_function_args(func->type);
@ -204,7 +204,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
if (is_interpreted_func( iface, func )) if (is_interpreted_func( iface, func ))
{ {
if (get_stub_mode() == MODE_Oif && !is_callas( func->attrs )) return; if (get_stub_mode() == MODE_Oif && !is_callas( func->attrs )) return;
write_type_decl_left(proxy, type_function_get_rettype(func->type)); write_type_decl_left(proxy, retval->type);
print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func)); print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func));
write_args(proxy, args, iface->name, 1, TRUE); write_args(proxy, args, iface->name, 1, TRUE);
print_proxy( ")\n"); print_proxy( ")\n");
@ -221,7 +221,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
print_proxy( "}\n"); print_proxy( "}\n");
print_proxy( "\n"); print_proxy( "\n");
write_type_decl_left(proxy, rettype); write_type_decl_left(proxy, retval->type);
print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func)); print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func));
write_args(proxy, args, iface->name, 1, TRUE); write_args(proxy, args, iface->name, 1, TRUE);
print_proxy( ")\n"); print_proxy( ")\n");
@ -231,14 +231,13 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
/* local variables */ /* local variables */
if (has_ret) { if (has_ret) {
print_proxy( "%s", "" ); print_proxy( "%s", "" );
write_type_decl_left(proxy, rettype); write_type_decl(proxy, retval->type, retval->name);
print_proxy( " _RetVal;\n"); fprintf( proxy, ";\n" );
} }
print_proxy( "RPC_MESSAGE _RpcMessage;\n" ); print_proxy( "RPC_MESSAGE _RpcMessage;\n" );
if (has_ret) { if (has_ret) {
if (decl_indirect(rettype)) if (decl_indirect(retval->type))
print_proxy("void *_p_%s = &%s;\n", print_proxy("void *_p_%s = &%s;\n", retval->name, retval->name);
"_RetVal", "_RetVal");
} }
print_proxy( "\n"); print_proxy( "\n");
@ -282,10 +281,10 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
if (has_ret) if (has_ret)
{ {
if (decl_indirect(rettype)) if (decl_indirect(retval->type))
print_proxy("MIDL_memset(&%s, 0, sizeof(%s));\n", "_RetVal", "_RetVal"); print_proxy("MIDL_memset(&%s, 0, sizeof(%s));\n", retval->name, retval->name);
else if (is_ptr(rettype) || is_array(rettype)) else if (is_ptr(retval->type) || is_array(retval->type))
print_proxy("%s = 0;\n", "_RetVal"); print_proxy("%s = 0;\n", retval->name);
write_remoting_arguments(proxy, indent, func, "", PASS_RETURN, PHASE_UNMARSHAL); write_remoting_arguments(proxy, indent, func, "", PASS_RETURN, PHASE_UNMARSHAL);
} }
@ -763,12 +762,7 @@ static int does_any_iface(const statement_list_t *stmts, type_pred_t pred)
if (stmts) if (stmts)
LIST_FOR_EACH_ENTRY(stmt, stmts, const statement_t, entry) LIST_FOR_EACH_ENTRY(stmt, stmts, const statement_t, entry)
{ {
if (stmt->type == STMT_LIBRARY) if (stmt->type == STMT_TYPE && type_get_type(stmt->u.type) == TYPE_INTERFACE)
{
if (does_any_iface(stmt->u.lib->stmts, pred))
return TRUE;
}
else if (stmt->type == STMT_TYPE && type_get_type(stmt->u.type) == TYPE_INTERFACE)
{ {
if (pred(stmt->u.type)) if (pred(stmt->u.type))
return TRUE; return TRUE;
@ -782,7 +776,6 @@ int need_proxy(const type_t *iface)
{ {
if (!is_object( iface )) return 0; if (!is_object( iface )) return 0;
if (is_local( iface->attrs )) return 0; if (is_local( iface->attrs )) return 0;
if (is_attr( iface->attrs, ATTR_OLEAUTOMATION )) return 0;
if (is_attr( iface->attrs, ATTR_DISPINTERFACE )) return 0; if (is_attr( iface->attrs, ATTR_DISPINTERFACE )) return 0;
return 1; return 1;
} }
@ -843,9 +836,7 @@ static void write_proxy_stmts(const statement_list_t *stmts, unsigned int *proc_
const statement_t *stmt; const statement_t *stmt;
if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
{ {
if (stmt->type == STMT_LIBRARY) if (stmt->type == STMT_TYPE && type_get_type(stmt->u.type) == TYPE_INTERFACE)
write_proxy_stmts(stmt->u.lib->stmts, proc_offset);
else if (stmt->type == STMT_TYPE && type_get_type(stmt->u.type) == TYPE_INTERFACE)
{ {
if (need_proxy(stmt->u.type)) if (need_proxy(stmt->u.type))
write_proxy(stmt->u.type, proc_offset); write_proxy(stmt->u.type, proc_offset);
@ -869,9 +860,7 @@ static void build_iface_list( const statement_list_t *stmts, type_t **ifaces[],
if (!stmts) return; if (!stmts) return;
LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
{ {
if (stmt->type == STMT_LIBRARY) if (stmt->type == STMT_TYPE && type_get_type(stmt->u.type) == TYPE_INTERFACE)
build_iface_list(stmt->u.lib->stmts, ifaces, count);
else if (stmt->type == STMT_TYPE && type_get_type(stmt->u.type) == TYPE_INTERFACE)
{ {
type_t *iface = stmt->u.type; type_t *iface = stmt->u.type;
if (type_iface_get_inherit(iface) && need_proxy(iface)) if (type_iface_get_inherit(iface) && need_proxy(iface))

View file

@ -463,9 +463,7 @@ static void write_server_stmts(const statement_list_t *stmts, int expr_eval_rout
const statement_t *stmt; const statement_t *stmt;
if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
{ {
if (stmt->type == STMT_LIBRARY) if (stmt->type == STMT_TYPE && type_get_type(stmt->u.type) == TYPE_INTERFACE)
write_server_stmts(stmt->u.lib->stmts, expr_eval_routines, proc_offset);
else if (stmt->type == STMT_TYPE && type_get_type(stmt->u.type) == TYPE_INTERFACE)
{ {
type_t *iface = stmt->u.type; type_t *iface = stmt->u.type;
if (!need_stub(iface)) if (!need_stub(iface))

View file

@ -413,12 +413,12 @@ static int get_padding(const var_list_t *fields)
return ROUNDING(offset, salign); return ROUNDING(offset, salign);
} }
static unsigned int get_stack_size( const type_t *type, const attr_list_t *attrs, int *by_value ) static unsigned int get_stack_size( const var_t *var, int *by_value )
{ {
unsigned int stack_size; unsigned int stack_size;
int by_val; int by_val;
switch (typegen_detect_type( type, attrs, TDT_ALL_TYPES )) switch (typegen_detect_type( var->type, var->attrs, TDT_ALL_TYPES ))
{ {
case TGT_BASIC: case TGT_BASIC:
case TGT_ENUM: case TGT_ENUM:
@ -426,7 +426,7 @@ static unsigned int get_stack_size( const type_t *type, const attr_list_t *attrs
case TGT_STRUCT: case TGT_STRUCT:
case TGT_UNION: case TGT_UNION:
case TGT_USER_TYPE: case TGT_USER_TYPE:
stack_size = type_memsize( type ); stack_size = type_memsize( var->type );
by_val = (pointer_size < 8 || stack_size <= pointer_size); /* FIXME: should be platform-specific */ by_val = (pointer_size < 8 || stack_size <= pointer_size); /* FIXME: should be platform-specific */
break; break;
default: default:
@ -899,10 +899,10 @@ static void write_var_init(FILE *file, int indent, const type_t *t, const char *
void write_parameters_init(FILE *file, int indent, const var_t *func, const char *local_var_prefix) void write_parameters_init(FILE *file, int indent, const var_t *func, const char *local_var_prefix)
{ {
const var_t *var; const var_t *var = type_function_get_retval(func->type);
if (!is_void(type_function_get_rettype(func->type))) if (!is_void(var->type))
write_var_init(file, indent, type_function_get_rettype(func->type), "_RetVal", local_var_prefix); write_var_init(file, indent, var->type, var->name, local_var_prefix);
if (!type_get_function_args(func->type)) if (!type_get_function_args(func->type))
return; return;
@ -952,35 +952,34 @@ int decl_indirect(const type_t *t)
type_get_type(t) != TYPE_ARRAY); type_get_type(t) != TYPE_ARRAY);
} }
static unsigned char get_parameter_fc( const type_t *type, const attr_list_t *attrs, int is_return, static unsigned char get_parameter_fc( const var_t *var, int is_return, unsigned short *flags,
unsigned short *flags, unsigned int *stack_size, unsigned int *stack_size, unsigned int *typestring_offset )
unsigned int *typestring_offset )
{ {
unsigned int alignment, server_size = 0, buffer_size = 0; unsigned int alignment, server_size = 0, buffer_size = 0;
unsigned char fc = 0; unsigned char fc = 0;
int is_byval; int is_byval;
int is_in = is_attr(attrs, ATTR_IN); int is_in = is_attr(var->attrs, ATTR_IN);
int is_out = is_attr(attrs, ATTR_OUT); int is_out = is_attr(var->attrs, ATTR_OUT);
if (is_return) is_out = TRUE; if (is_return) is_out = TRUE;
else if (!is_in && !is_out) is_in = TRUE; else if (!is_in && !is_out) is_in = TRUE;
*flags = 0; *flags = 0;
*stack_size = get_stack_size( type, attrs, &is_byval ); *stack_size = get_stack_size( var, &is_byval );
*typestring_offset = type->typestring_offset; *typestring_offset = var->typestring_offset;
if (is_in) *flags |= IsIn; if (is_in) *flags |= IsIn;
if (is_out) *flags |= IsOut; if (is_out) *flags |= IsOut;
if (is_return) *flags |= IsReturn; if (is_return) *flags |= IsReturn;
if (!is_string_type( attrs, type )) if (!is_string_type( var->attrs, var->type ))
buffer_size = get_required_buffer_size_type( type, NULL, attrs, TRUE, &alignment ); buffer_size = get_required_buffer_size_type( var->type, NULL, var->attrs, TRUE, &alignment );
switch (typegen_detect_type( type, attrs, TDT_ALL_TYPES )) switch (typegen_detect_type( var->type, var->attrs, TDT_ALL_TYPES ))
{ {
case TGT_BASIC: case TGT_BASIC:
*flags |= IsBasetype; *flags |= IsBasetype;
fc = get_basic_fc_signed( type ); fc = get_basic_fc_signed( var->type );
if (fc == RPC_FC_BIND_PRIMITIVE) if (fc == RPC_FC_BIND_PRIMITIVE)
{ {
buffer_size = 4; /* actually 0 but avoids setting MustSize */ buffer_size = 4; /* actually 0 but avoids setting MustSize */
@ -989,7 +988,7 @@ static unsigned char get_parameter_fc( const type_t *type, const attr_list_t *at
break; break;
case TGT_ENUM: case TGT_ENUM:
*flags |= IsBasetype; *flags |= IsBasetype;
fc = get_enum_fc( type ); fc = get_enum_fc( var->type );
break; break;
case TGT_RANGE: case TGT_RANGE:
*flags |= IsByValue; *flags |= IsByValue;
@ -1004,16 +1003,19 @@ static unsigned char get_parameter_fc( const type_t *type, const attr_list_t *at
break; break;
case TGT_ARRAY: case TGT_ARRAY:
*flags |= MustFree; *flags |= MustFree;
if (type_array_is_decl_as_ptr(type) && type->details.array.ptr_tfsoff && if (type_array_is_decl_as_ptr(var->type) && var->type->details.array.ptr_tfsoff &&
get_pointer_fc( type, attrs, !is_return ) == RPC_FC_RP) get_pointer_fc( var->type, var->attrs, !is_return ) == RPC_FC_RP)
{
*typestring_offset = var->type->typestring_offset;
*flags |= IsSimpleRef; *flags |= IsSimpleRef;
}
break; break;
case TGT_STRING: case TGT_STRING:
*flags |= MustFree; *flags |= MustFree;
if (is_declptr( type ) && get_pointer_fc( type, attrs, !is_return ) == RPC_FC_RP) if (is_declptr( var->type ) && get_pointer_fc( var->type, var->attrs, !is_return ) == RPC_FC_RP)
{ {
/* skip over pointer description straight to string description */ /* skip over pointer description straight to string description */
if (is_conformant_array( type )) *typestring_offset += 4; if (is_conformant_array( var->type )) *typestring_offset += 4;
else *typestring_offset += 2; else *typestring_offset += 2;
*flags |= IsSimpleRef; *flags |= IsSimpleRef;
} }
@ -1026,11 +1028,11 @@ static unsigned char get_parameter_fc( const type_t *type, const attr_list_t *at
buffer_size = 20; buffer_size = 20;
break; break;
case TGT_POINTER: case TGT_POINTER:
if (get_pointer_fc( type, attrs, !is_return ) == RPC_FC_RP) if (get_pointer_fc( var->type, var->attrs, !is_return ) == RPC_FC_RP)
{ {
const type_t *ref = type_pointer_get_ref( type ); const type_t *ref = type_pointer_get_ref( var->type );
if (!is_string_type( attrs, ref )) if (!is_string_type( var->attrs, ref ))
buffer_size = get_required_buffer_size_type( ref, NULL, NULL, TRUE, &alignment ); buffer_size = get_required_buffer_size_type( ref, NULL, NULL, TRUE, &alignment );
switch (typegen_detect_type( ref, NULL, TDT_ALL_TYPES )) switch (typegen_detect_type( ref, NULL, TDT_ALL_TYPES ))
@ -1111,14 +1113,14 @@ static unsigned char get_func_oi2_flags( const var_t *func )
{ {
const var_t *var; const var_t *var;
var_list_t *args = type_get_function_args( func->type ); var_list_t *args = type_get_function_args( func->type );
type_t *ret_type = type_function_get_rettype( func->type ); var_t *retval = type_function_get_retval( func->type );
unsigned char oi2_flags = 0x40; /* HasExtensions */ unsigned char oi2_flags = 0x40; /* HasExtensions */
unsigned short flags; unsigned short flags;
unsigned int stack_size, typestring_offset; unsigned int stack_size, typestring_offset;
if (args) LIST_FOR_EACH_ENTRY( var, args, const var_t, entry ) if (args) LIST_FOR_EACH_ENTRY( var, args, const var_t, entry )
{ {
get_parameter_fc( var->type, var->attrs, 0, &flags, &stack_size, &typestring_offset ); get_parameter_fc( var, 0, &flags, &stack_size, &typestring_offset );
if (flags & MustSize) if (flags & MustSize)
{ {
if (flags & IsIn) oi2_flags |= 0x02; /* ClientMustSize */ if (flags & IsIn) oi2_flags |= 0x02; /* ClientMustSize */
@ -1126,24 +1128,22 @@ static unsigned char get_func_oi2_flags( const var_t *func )
} }
} }
if (!is_void( ret_type )) if (!is_void( retval->type ))
{ {
oi2_flags |= 0x04; /* HasRet */ oi2_flags |= 0x04; /* HasRet */
get_parameter_fc( ret_type, NULL, 1, &flags, &stack_size, &typestring_offset ); get_parameter_fc( retval, 1, &flags, &stack_size, &typestring_offset );
if (flags & MustSize) oi2_flags |= 0x01; /* ServerMustSize */ if (flags & MustSize) oi2_flags |= 0x01; /* ServerMustSize */
} }
return oi2_flags; return oi2_flags;
} }
static unsigned int write_new_procformatstring_type(FILE *file, int indent, static unsigned int write_new_procformatstring_type(FILE *file, int indent, const var_t *var,
const type_t *type,
const attr_list_t *attrs,
int is_return, unsigned int *stack_offset) int is_return, unsigned int *stack_offset)
{ {
char buffer[64]; char buffer[64];
unsigned int stack_size, typestring_offset; unsigned int stack_size, typestring_offset;
unsigned short flags; unsigned short flags;
unsigned char fc = get_parameter_fc( type, attrs, is_return, &flags, &stack_size, &typestring_offset ); unsigned char fc = get_parameter_fc( var, is_return, &flags, &stack_size, &typestring_offset );
strcpy( buffer, "/* flags:" ); strcpy( buffer, "/* flags:" );
if (flags & MustSize) strcat( buffer, " must size," ); if (flags & MustSize) strcat( buffer, " must size," );
@ -1172,20 +1172,18 @@ static unsigned int write_new_procformatstring_type(FILE *file, int indent,
return 6; return 6;
} }
static unsigned int write_old_procformatstring_type(FILE *file, int indent, static unsigned int write_old_procformatstring_type(FILE *file, int indent, const var_t *var,
const type_t *type,
const attr_list_t *attrs,
int is_return, int is_interpreted) int is_return, int is_interpreted)
{ {
unsigned int size; unsigned int size;
int is_in = is_attr(attrs, ATTR_IN); int is_in = is_attr(var->attrs, ATTR_IN);
int is_out = is_attr(attrs, ATTR_OUT); int is_out = is_attr(var->attrs, ATTR_OUT);
if (!is_in && !is_out) is_in = TRUE; if (!is_in && !is_out) is_in = TRUE;
if (type_get_type(type) == TYPE_BASIC || if (type_get_type(var->type) == TYPE_BASIC ||
type_get_type(type) == TYPE_ENUM) type_get_type(var->type) == TYPE_ENUM)
{ {
unsigned char fc; unsigned char fc;
@ -1194,13 +1192,13 @@ static unsigned int write_old_procformatstring_type(FILE *file, int indent,
else else
print_file(file, indent, "0x4e, /* FC_IN_PARAM_BASETYPE */\n"); print_file(file, indent, "0x4e, /* FC_IN_PARAM_BASETYPE */\n");
if (type_get_type(type) == TYPE_ENUM) if (type_get_type(var->type) == TYPE_ENUM)
{ {
fc = get_enum_fc(type); fc = get_enum_fc(var->type);
} }
else else
{ {
fc = get_basic_fc_signed(type); fc = get_basic_fc_signed(var->type);
if (fc == RPC_FC_BIND_PRIMITIVE) if (fc == RPC_FC_BIND_PRIMITIVE)
fc = RPC_FC_IGNORE; fc = RPC_FC_IGNORE;
@ -1212,12 +1210,12 @@ static unsigned int write_old_procformatstring_type(FILE *file, int indent,
} }
else else
{ {
unsigned short offset = type->typestring_offset; unsigned short offset = var->typestring_offset;
if (is_interpreted && is_array(type) && if (!is_interpreted && is_array(var->type) &&
type_array_is_decl_as_ptr(type) && type_array_is_decl_as_ptr(var->type) &&
type->details.array.ptr_tfsoff) var->type->details.array.ptr_tfsoff)
offset = type->details.array.ptr_tfsoff; offset = var->type->typestring_offset;
if (is_return) if (is_return)
print_file(file, indent, "0x52, /* FC_RETURN_PARAM */\n"); print_file(file, indent, "0x52, /* FC_RETURN_PARAM */\n");
@ -1228,7 +1226,7 @@ static unsigned int write_old_procformatstring_type(FILE *file, int indent,
else else
print_file(file, indent, "0x4d, /* FC_IN_PARAM */\n"); print_file(file, indent, "0x4d, /* FC_IN_PARAM */\n");
size = get_stack_size( type, attrs, NULL ); size = get_stack_size( var, NULL );
print_file(file, indent, "0x%02x,\n", size / pointer_size ); print_file(file, indent, "0x%02x,\n", size / pointer_size );
print_file(file, indent, "NdrFcShort(0x%x), /* type offset = %u */\n", offset, offset); print_file(file, indent, "NdrFcShort(0x%x), /* type offset = %u */\n", offset, offset);
size = 4; /* includes param type prefix */ size = 4; /* includes param type prefix */
@ -1318,7 +1316,7 @@ static void write_proc_func_header( FILE *file, int indent, const type_t *iface,
handle_stack_offset = stack_size; handle_stack_offset = stack_size;
handle_param_num = param_num; handle_param_num = param_num;
} }
stack_size += get_stack_size( var->type, var->attrs, NULL ); stack_size += get_stack_size( var, NULL );
param_num++; param_num++;
nb_args++; nb_args++;
} }
@ -1425,6 +1423,7 @@ static void write_procformatstring_func( FILE *file, int indent, const type_t *i
unsigned int stack_offset = is_object( iface ) ? pointer_size : 0; unsigned int stack_offset = is_object( iface ) ? pointer_size : 0;
int is_interpreted = is_interpreted_func( iface, func ); int is_interpreted = is_interpreted_func( iface, func );
int is_new_style = is_interpreted && (get_stub_mode() == MODE_Oif); int is_new_style = is_interpreted && (get_stub_mode() == MODE_Oif);
var_t *retval = type_function_get_retval( func->type );
if (is_interpreted) write_proc_func_header( file, indent, iface, func, offset, num_proc ); if (is_interpreted) write_proc_func_header( file, indent, iface, func, offset, num_proc );
@ -1436,16 +1435,14 @@ static void write_procformatstring_func( FILE *file, int indent, const type_t *i
{ {
print_file( file, 0, "/* %u (parameter %s) */\n", *offset, var->name ); print_file( file, 0, "/* %u (parameter %s) */\n", *offset, var->name );
if (is_new_style) if (is_new_style)
*offset += write_new_procformatstring_type(file, indent, var->type, var->attrs, *offset += write_new_procformatstring_type(file, indent, var, FALSE, &stack_offset);
FALSE, &stack_offset);
else else
*offset += write_old_procformatstring_type(file, indent, var->type, var->attrs, *offset += write_old_procformatstring_type(file, indent, var, FALSE, is_interpreted);
FALSE, is_interpreted);
} }
} }
/* emit return value data */ /* emit return value data */
if (is_void(type_function_get_rettype(func->type))) if (is_void(retval->type))
{ {
if (!is_new_style) if (!is_new_style)
{ {
@ -1459,11 +1456,9 @@ static void write_procformatstring_func( FILE *file, int indent, const type_t *i
{ {
print_file( file, 0, "/* %u (return value) */\n", *offset ); print_file( file, 0, "/* %u (return value) */\n", *offset );
if (is_new_style) if (is_new_style)
*offset += write_new_procformatstring_type(file, indent, type_function_get_rettype(func->type), *offset += write_new_procformatstring_type(file, indent, retval, TRUE, &stack_offset);
NULL, TRUE, &stack_offset);
else else
*offset += write_old_procformatstring_type(file, indent, type_function_get_rettype(func->type), *offset += write_old_procformatstring_type(file, indent, retval, TRUE, is_interpreted);
NULL, TRUE, is_interpreted);
} }
} }
@ -1488,8 +1483,6 @@ static void write_procformatstring_stmts(FILE *file, int indent, const statement
write_procformatstring_func( file, indent, iface, func, offset, count++ ); write_procformatstring_func( file, indent, iface, func, offset, count++ );
} }
} }
else if (stmt->type == STMT_LIBRARY)
write_procformatstring_stmts(file, indent, stmt->u.lib->stmts, pred, offset);
} }
} }
@ -1661,7 +1654,7 @@ static unsigned int write_conf_or_var_desc(FILE *file, const type_t *cont_type,
correlation_variable = var->type; correlation_variable = var->type;
break; break;
} }
offset += get_stack_size( var->type, var->attrs, NULL ); offset += get_stack_size( var, NULL );
} }
} }
else else
@ -2338,6 +2331,11 @@ static void write_array_element_type(FILE *file, const type_t *type,
ref->typestring_offset, tfsoff); ref->typestring_offset, tfsoff);
return; return;
} }
if (cont_is_complex && is_string_type(NULL, elem))
{
write_string_tfs(file, NULL, elem, TYPE_CONTEXT_CONTAINER, NULL, tfsoff);
return;
}
if (!is_string_type(NULL, elem) && if (!is_string_type(NULL, elem) &&
(type_get_type(ref) == TYPE_BASIC || type_get_type(ref) == TYPE_ENUM)) (type_get_type(ref) == TYPE_BASIC || type_get_type(ref) == TYPE_ENUM))
{ {
@ -2382,8 +2380,8 @@ static void write_descriptors(FILE *file, type_t *type, unsigned int *tfsoff)
print_file(file, 2, "0x%x,\t/* FIXME: always FC_LONG */\n", RPC_FC_LONG); print_file(file, 2, "0x%x,\t/* FIXME: always FC_LONG */\n", RPC_FC_LONG);
write_conf_or_var_desc(file, current_structure, offset, ft, write_conf_or_var_desc(file, current_structure, offset, ft,
get_attrp(f->attrs, ATTR_SWITCHIS)); get_attrp(f->attrs, ATTR_SWITCHIS));
print_file(file, 2, "NdrFcShort(%hd),\t/* Offset= %hd (%u) */\n", print_file(file, 2, "NdrFcShort(0x%hx),\t/* Offset= %hd (%u) */\n",
reloff, reloff, absoff); (unsigned short)reloff, reloff, absoff);
*tfsoff += 8; *tfsoff += 8;
} }
offset += size; offset += size;
@ -3617,7 +3615,7 @@ static int write_embedded_types(FILE *file, const attr_list_t *attrs, type_t *ty
static unsigned int process_tfs_stmts(FILE *file, const statement_list_t *stmts, static unsigned int process_tfs_stmts(FILE *file, const statement_list_t *stmts,
type_pred_t pred, unsigned int *typeformat_offset) type_pred_t pred, unsigned int *typeformat_offset)
{ {
const var_t *var; var_t *var;
const statement_t *stmt; const statement_t *stmt;
if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
@ -3625,12 +3623,7 @@ static unsigned int process_tfs_stmts(FILE *file, const statement_list_t *stmts,
const type_t *iface; const type_t *iface;
const statement_t *stmt_func; const statement_t *stmt_func;
if (stmt->type == STMT_LIBRARY) if (stmt->type != STMT_TYPE || type_get_type(stmt->u.type) != TYPE_INTERFACE)
{
process_tfs_stmts(file, stmt->u.lib->stmts, pred, typeformat_offset);
continue;
}
else if (stmt->type != STMT_TYPE || type_get_type(stmt->u.type) != TYPE_INTERFACE)
continue; continue;
iface = stmt->u.type; iface = stmt->u.type;
@ -3644,16 +3637,16 @@ static unsigned int process_tfs_stmts(FILE *file, const statement_list_t *stmts,
current_func = func; current_func = func;
if (is_local(func->attrs)) continue; if (is_local(func->attrs)) continue;
if (!is_void(type_function_get_rettype(func->type))) var = type_function_get_retval(func->type);
{ if (!is_void(var->type))
write_type_tfs( file, 2, func->attrs, type_function_get_rettype(func->type), var->typestring_offset = write_type_tfs( file, 2, func->attrs, var->type, func->name,
func->name, TYPE_CONTEXT_PARAM, typeformat_offset); TYPE_CONTEXT_PARAM, typeformat_offset);
}
if (type_get_function_args(func->type)) if (type_get_function_args(func->type))
LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), var_t, entry )
write_type_tfs( file, 2, var->attrs, var->type, var->name, var->typestring_offset = write_type_tfs( file, 2, var->attrs, var->type, var->name,
TYPE_CONTEXT_TOPLEVELPARAM, typeformat_offset ); TYPE_CONTEXT_TOPLEVELPARAM,
typeformat_offset );
} }
} }
@ -4476,12 +4469,8 @@ void write_remoting_arguments(FILE *file, int indent, const var_t *func, const c
if (pass == PASS_RETURN) if (pass == PASS_RETURN)
{ {
var_t var; write_remoting_arg( file, indent, func, local_var_prefix, pass, phase,
var = *func; type_function_get_retval(func->type) );
var.type = type_function_get_rettype(func->type);
var.name = xstrdup( "_RetVal" );
write_remoting_arg( file, indent, func, local_var_prefix, pass, phase, &var );
free( var.name );
} }
else else
{ {
@ -4511,12 +4500,7 @@ unsigned int get_size_procformatstring(const statement_list_t *stmts, type_pred_
const type_t *iface; const type_t *iface;
const statement_t *stmt_func; const statement_t *stmt_func;
if (stmt->type == STMT_LIBRARY) if (stmt->type != STMT_TYPE || type_get_type(stmt->u.type) != TYPE_INTERFACE)
{
size += get_size_procformatstring(stmt->u.lib->stmts, pred) - 1;
continue;
}
else if (stmt->type != STMT_TYPE || type_get_type(stmt->u.type) != TYPE_INTERFACE)
continue; continue;
iface = stmt->u.type; iface = stmt->u.type;
@ -4543,14 +4527,14 @@ void declare_stub_args( FILE *file, int indent, const var_t *func )
{ {
int in_attr, out_attr; int in_attr, out_attr;
int i = 0; int i = 0;
const var_t *var; const var_t *var = type_function_get_retval(func->type);
/* declare return value '_RetVal' */ /* declare return value */
if (!is_void(type_function_get_rettype(func->type))) if (!is_void(var->type))
{ {
print_file(file, indent, "%s", ""); print_file(file, indent, "%s", "");
write_type_decl_left(file, type_function_get_rettype(func->type)); write_type_decl(file, var->type, var->name);
fprintf(file, " _RetVal;\n"); fprintf(file, ";\n");
} }
if (!type_get_function_args(func->type)) if (!type_get_function_args(func->type))
@ -4605,6 +4589,7 @@ void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char
int in_attr, out_attr; int in_attr, out_attr;
int i = 0, sep = 0; int i = 0, sep = 0;
const var_t *var; const var_t *var;
type_t *ref;
if (!type_get_function_args(func->type)) if (!type_get_function_args(func->type))
return; return;
@ -4626,7 +4611,7 @@ void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char
fprintf(file, " = NdrContextHandleInitialize(\n"); fprintf(file, " = NdrContextHandleInitialize(\n");
print_file(file, indent + 1, "&__frame->_StubMsg,\n"); print_file(file, indent + 1, "&__frame->_StubMsg,\n");
print_file(file, indent + 1, "(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%d]);\n", print_file(file, indent + 1, "(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%d]);\n",
var->type->typestring_offset); var->typestring_offset);
break; break;
case TGT_ARRAY: case TGT_ARRAY:
if (type_array_has_conformance(var->type)) if (type_array_has_conformance(var->type))
@ -4663,7 +4648,8 @@ void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char
break; break;
case TGT_POINTER: case TGT_POINTER:
fprintf(file, " = &%s_W%u;\n", local_var_prefix, i); fprintf(file, " = &%s_W%u;\n", local_var_prefix, i);
switch (typegen_detect_type(type_pointer_get_ref(var->type), var->attrs, TDT_IGNORE_STRINGS)) ref = type_pointer_get_ref(var->type);
switch (typegen_detect_type(ref, var->attrs, TDT_IGNORE_STRINGS))
{ {
case TGT_BASIC: case TGT_BASIC:
case TGT_ENUM: case TGT_ENUM:
@ -4676,9 +4662,20 @@ void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char
print_file(file, indent, "memset(&%s_W%u, 0, sizeof(%s_W%u));\n", print_file(file, indent, "memset(&%s_W%u, 0, sizeof(%s_W%u));\n",
local_var_prefix, i, local_var_prefix, i); local_var_prefix, i, local_var_prefix, i);
break; break;
case TGT_ARRAY:
if (type_array_is_decl_as_ptr(ref))
{
print_file(file, indent, "%s_W%u = 0;\n", local_var_prefix, i);
break;
}
ref = type_array_get_element(ref);
/* fall through */
case TGT_STRUCT: case TGT_STRUCT:
case TGT_UNION: case TGT_UNION:
case TGT_ARRAY: if (type_has_pointers(ref))
print_file(file, indent, "memset(&%s_W%u, 0, sizeof(%s_W%u));\n",
local_var_prefix, i, local_var_prefix, i);
break;
case TGT_CTXT_HANDLE: case TGT_CTXT_HANDLE:
case TGT_CTXT_HANDLE_POINTER: case TGT_CTXT_HANDLE_POINTER:
case TGT_INVALID: case TGT_INVALID:
@ -4703,7 +4700,7 @@ void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char
void write_func_param_struct( FILE *file, const type_t *iface, const type_t *func, void write_func_param_struct( FILE *file, const type_t *iface, const type_t *func,
const char *var_decl, int add_retval ) const char *var_decl, int add_retval )
{ {
type_t *rettype = type_function_get_rettype( func ); var_t *retval = type_function_get_retval( func );
const var_list_t *args = type_get_function_args( func ); const var_list_t *args = type_get_function_args( func );
const var_t *arg; const var_t *arg;
int needs_packing; int needs_packing;
@ -4737,11 +4734,12 @@ void write_func_param_struct( FILE *file, const type_t *iface, const type_t *fun
else else
fprintf( file, "DECLSPEC_ALIGN(%u) %s;\n", pointer_size, arg->name ); fprintf( file, "DECLSPEC_ALIGN(%u) %s;\n", pointer_size, arg->name );
} }
if (add_retval && !is_void( rettype )) if (add_retval && !is_void( retval->type ))
{ {
print_file(file, 2, "%s", ""); print_file(file, 2, "%s", "");
write_type_decl( file, rettype, "_RetVal" ); write_type_decl( file, retval->type, retval->name );
if (is_array( rettype ) || is_ptr( rettype ) || type_memsize( rettype ) == pointer_size) if (is_array( retval->type ) || is_ptr( retval->type ) ||
type_memsize( retval->type ) == pointer_size)
fprintf( file, ";\n" ); fprintf( file, ";\n" );
else else
fprintf( file, " DECLSPEC_ALIGN(%u);\n", pointer_size ); fprintf( file, " DECLSPEC_ALIGN(%u);\n", pointer_size );

View file

@ -92,11 +92,16 @@ static inline var_list_t *type_function_get_args(const type_t *type)
return type->details.function->args; return type->details.function->args;
} }
static inline type_t *type_function_get_rettype(const type_t *type) static inline var_t *type_function_get_retval(const type_t *type)
{ {
type = type_get_real_type(type); type = type_get_real_type(type);
assert(type_get_type(type) == TYPE_FUNCTION); assert(type_get_type(type) == TYPE_FUNCTION);
return type->details.function->rettype; return type->details.function->retval;
}
static inline type_t *type_function_get_rettype(const type_t *type)
{
return type_function_get_retval(type)->type;
} }
static inline var_list_t *type_enum_get_values(const type_t *type) static inline var_list_t *type_enum_get_values(const type_t *type)

View file

@ -338,7 +338,7 @@ struct enumeration_details
struct func_details struct func_details
{ {
var_list_t *args; var_list_t *args;
struct _type_t *rettype; struct _var_t *retval;
int idx; int idx;
}; };
@ -445,6 +445,7 @@ struct _var_t {
expr_t *eval; expr_t *eval;
enum storage_class stgclass; enum storage_class stgclass;
unsigned int procstring_offset; unsigned int procstring_offset;
unsigned int typestring_offset;
struct _loc_info_t loc_info; struct _loc_info_t loc_info;