Commit c6668089 authored by Alexandre Julliard's avatar Alexandre Julliard

widl: Set the default calling convention at header generation time, not at parsing time.

parent 7d286945
...@@ -39,10 +39,13 @@ ...@@ -39,10 +39,13 @@
typedef struct _user_type_t generic_handle_t; typedef struct _user_type_t generic_handle_t;
static int indentation = 0; static int indentation = 0;
static int is_object_interface = 0;
user_type_list_t user_type_list = LIST_INIT(user_type_list); user_type_list_t user_type_list = LIST_INIT(user_type_list);
static context_handle_list_t context_handle_list = LIST_INIT(context_handle_list); static context_handle_list_t context_handle_list = LIST_INIT(context_handle_list);
static struct list generic_handle_list = LIST_INIT(generic_handle_list); static struct list generic_handle_list = LIST_INIT(generic_handle_list);
static void write_type_def_or_decl(FILE *f, type_t *t, int field, const char *name);
static void indent(FILE *h, int delta) static void indent(FILE *h, int delta)
{ {
int c; int c;
...@@ -366,12 +369,12 @@ static void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const c ...@@ -366,12 +369,12 @@ static void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const c
if (type_get_type_detect_alias(pt) == TYPE_FUNCTION) { if (type_get_type_detect_alias(pt) == TYPE_FUNCTION) {
int i; int i;
const char *callconv = get_attrp(pt->attrs, ATTR_CALLCONV); const char *callconv = get_attrp(pt->attrs, ATTR_CALLCONV);
if (!callconv) callconv = ""; if (!callconv && is_object_interface) callconv = "STDMETHODCALLTYPE";
if (is_attr(pt->attrs, ATTR_INLINE)) fprintf(h, "inline "); if (is_attr(pt->attrs, ATTR_INLINE)) fprintf(h, "inline ");
write_type_left(h, type_function_get_rettype(pt), declonly); write_type_left(h, type_function_get_rettype(pt), declonly);
fputc(' ', h); fputc(' ', h);
if (ptr_level) fputc('(', h); if (ptr_level) fputc('(', h);
fprintf(h, "%s ", callconv); if (callconv) fprintf(h, "%s ", callconv);
for (i = 0; i < ptr_level; i++) for (i = 0; i < ptr_level; i++)
fputc('*', h); fputc('*', h);
} else } else
...@@ -396,7 +399,7 @@ static void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const c ...@@ -396,7 +399,7 @@ static void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const c
} }
} }
void write_type_def_or_decl(FILE *f, type_t *t, int field, const char *name) static void write_type_def_or_decl(FILE *f, type_t *t, int field, const char *name)
{ {
write_type_v(f, t, field, FALSE, name); write_type_v(f, t, field, FALSE, name);
} }
...@@ -785,7 +788,7 @@ static void write_cpp_method_def(FILE *header, const type_t *iface) ...@@ -785,7 +788,7 @@ static void write_cpp_method_def(FILE *header, const type_t *iface)
const var_t *func = stmt->u.var; const var_t *func = stmt->u.var;
if (!is_callas(func->attrs)) { if (!is_callas(func->attrs)) {
const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV); const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV);
if (!callconv) callconv = ""; if (!callconv) callconv = "STDMETHODCALLTYPE";
indent(header, 0); indent(header, 0);
fprintf(header, "virtual "); fprintf(header, "virtual ");
write_type_decl_left(header, type_function_get_rettype(func->type)); write_type_decl_left(header, type_function_get_rettype(func->type));
...@@ -815,7 +818,7 @@ static void do_write_c_method_def(FILE *header, const type_t *iface, const char ...@@ -815,7 +818,7 @@ static void do_write_c_method_def(FILE *header, const type_t *iface, const char
} }
if (!is_callas(func->attrs)) { if (!is_callas(func->attrs)) {
const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV); const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV);
if (!callconv) callconv = ""; if (!callconv) callconv = "STDMETHODCALLTYPE";
indent(header, 0); indent(header, 0);
write_type_decl_left(header, type_function_get_rettype(func->type)); write_type_decl_left(header, type_function_get_rettype(func->type));
fprintf(header, " (%s *%s)(\n", callconv, get_name(func)); fprintf(header, " (%s *%s)(\n", callconv, get_name(func));
...@@ -846,7 +849,7 @@ static void write_method_proto(FILE *header, const type_t *iface) ...@@ -846,7 +849,7 @@ static void write_method_proto(FILE *header, const type_t *iface)
if (!is_local(func->attrs)) { if (!is_local(func->attrs)) {
const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV); const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV);
if (!callconv) callconv = ""; if (!callconv) callconv = "STDMETHODCALLTYPE";
/* proxy prototype */ /* proxy prototype */
write_type_decl_left(header, type_function_get_rettype(func->type)); write_type_decl_left(header, type_function_get_rettype(func->type));
fprintf(header, " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func)); fprintf(header, " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func));
...@@ -1217,6 +1220,7 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons ...@@ -1217,6 +1220,7 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons
if (type_get_type(stmt->u.type) == TYPE_INTERFACE) if (type_get_type(stmt->u.type) == TYPE_INTERFACE)
{ {
type_t *iface = stmt->u.type; type_t *iface = stmt->u.type;
if (is_object(iface)) is_object_interface++;
if (is_attr(stmt->u.type->attrs, ATTR_DISPINTERFACE) || is_object(stmt->u.type)) if (is_attr(stmt->u.type->attrs, ATTR_DISPINTERFACE) || is_object(stmt->u.type))
{ {
write_com_interface_start(header, iface); write_com_interface_start(header, iface);
...@@ -1229,6 +1233,7 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons ...@@ -1229,6 +1233,7 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons
write_header_stmts(header, type_iface_get_stmts(iface), iface, FALSE); write_header_stmts(header, type_iface_get_stmts(iface), iface, FALSE);
write_rpc_interface_end(header, iface); write_rpc_interface_end(header, iface);
} }
if (is_object(iface)) is_object_interface++;
} }
else if (type_get_type(stmt->u.type) == TYPE_COCLASS) else if (type_get_type(stmt->u.type) == TYPE_COCLASS)
write_coclass(header, stmt->u.type); write_coclass(header, stmt->u.type);
......
...@@ -34,7 +34,6 @@ extern int is_declptr(const type_t *t); ...@@ -34,7 +34,6 @@ extern int is_declptr(const type_t *t);
extern const char* get_name(const var_t *v); extern const char* get_name(const var_t *v);
extern void write_type_left(FILE *h, type_t *t, int declonly); extern void write_type_left(FILE *h, type_t *t, int declonly);
extern void write_type_right(FILE *h, type_t *t, int is_field); extern void write_type_right(FILE *h, type_t *t, int is_field);
extern void write_type_def_or_decl(FILE *h, type_t *t, int is_field, const char *name);
extern void write_type_decl(FILE *f, type_t *t, const char *name); extern void write_type_decl(FILE *f, type_t *t, const char *name);
extern void write_type_decl_left(FILE *f, type_t *t); extern void write_type_decl_left(FILE *f, type_t *t);
extern int needs_space_after(type_t *t); extern int needs_space_after(type_t *t);
......
...@@ -66,7 +66,6 @@ ...@@ -66,7 +66,6 @@
#define YYERROR_VERBOSE #define YYERROR_VERBOSE
static unsigned char pointer_default = RPC_FC_UP; static unsigned char pointer_default = RPC_FC_UP;
static int is_object_interface = FALSE;
typedef struct list typelist_t; typedef struct list typelist_t;
struct typenode { struct typenode {
...@@ -806,7 +805,6 @@ dispinterface: tDISPINTERFACE aIDENTIFIER { $$ = get_type(TYPE_INTERFACE, $2, 0) ...@@ -806,7 +805,6 @@ dispinterface: tDISPINTERFACE aIDENTIFIER { $$ = get_type(TYPE_INTERFACE, $2, 0)
; ;
dispinterfacehdr: attributes dispinterface { attr_t *attrs; dispinterfacehdr: attributes dispinterface { attr_t *attrs;
is_object_interface = TRUE;
$$ = $2; $$ = $2;
check_def($$); check_def($$);
attrs = make_attr(ATTR_DISPINTERFACE); attrs = make_attr(ATTR_DISPINTERFACE);
...@@ -836,7 +834,7 @@ dispinterfacedef: dispinterfacehdr '{' ...@@ -836,7 +834,7 @@ dispinterfacedef: dispinterfacehdr '{'
; ;
inherit: { $$ = NULL; } inherit: { $$ = NULL; }
| ':' aKNOWNTYPE { $$ = find_type_or_error2($2, 0); is_object_interface = 1; } | ':' aKNOWNTYPE { $$ = find_type_or_error2($2, 0); }
; ;
interface: tINTERFACE aIDENTIFIER { $$ = get_type(TYPE_INTERFACE, $2, 0); } interface: tINTERFACE aIDENTIFIER { $$ = get_type(TYPE_INTERFACE, $2, 0); }
...@@ -849,7 +847,6 @@ interfacehdr: attributes interface { $$.interface = $2; ...@@ -849,7 +847,6 @@ interfacehdr: attributes interface { $$.interface = $2;
pointer_default = get_attrv($1, ATTR_POINTERDEFAULT); pointer_default = get_attrv($1, ATTR_POINTERDEFAULT);
check_def($2); check_def($2);
$2->attrs = check_iface_attrs($2->name, $1); $2->attrs = check_iface_attrs($2->name, $1);
is_object_interface = is_object($2);
$2->defined = TRUE; $2->defined = TRUE;
} }
; ;
...@@ -1575,12 +1572,6 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl ...@@ -1575,12 +1572,6 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
* 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))
ft->attrs = move_attr(ft->attrs, t->attrs, ATTR_CALLCONV); ft->attrs = move_attr(ft->attrs, t->attrs, ATTR_CALLCONV);
if (is_object_interface && !is_attr(ft->attrs, ATTR_CALLCONV))
{
static char *stdmethodcalltype;
if (!stdmethodcalltype) stdmethodcalltype = strdup("STDMETHODCALLTYPE");
ft->attrs = append_attr(NULL, make_attrp(ATTR_CALLCONV, stdmethodcalltype));
}
} }
else else
{ {
......
...@@ -280,7 +280,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx, ...@@ -280,7 +280,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
int has_ret = !is_void(type_function_get_rettype(func->type)); int has_ret = !is_void(type_function_get_rettype(func->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);
if (!callconv) callconv = ""; if (!callconv) callconv = "STDMETHODCALLTYPE";
indent = 0; indent = 0;
print_proxy( "static void __finally_%s_%s_Proxy( struct __proxy_frame *__frame )\n", print_proxy( "static void __finally_%s_%s_Proxy( struct __proxy_frame *__frame )\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment