widl: Set the default calling convention at header generation time, not at parsing time.
This commit is contained in:
parent
7d2869457f
commit
c6668089a4
|
@ -39,10 +39,13 @@
|
|||
typedef struct _user_type_t generic_handle_t;
|
||||
|
||||
static int indentation = 0;
|
||||
static int is_object_interface = 0;
|
||||
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 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)
|
||||
{
|
||||
int 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) {
|
||||
int i;
|
||||
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 ");
|
||||
write_type_left(h, type_function_get_rettype(pt), declonly);
|
||||
fputc(' ', h);
|
||||
if (ptr_level) fputc('(', h);
|
||||
fprintf(h, "%s ", callconv);
|
||||
if (callconv) fprintf(h, "%s ", callconv);
|
||||
for (i = 0; i < ptr_level; i++)
|
||||
fputc('*', h);
|
||||
} else
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -785,7 +788,7 @@ static void write_cpp_method_def(FILE *header, const type_t *iface)
|
|||
const var_t *func = stmt->u.var;
|
||||
if (!is_callas(func->attrs)) {
|
||||
const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV);
|
||||
if (!callconv) callconv = "";
|
||||
if (!callconv) callconv = "STDMETHODCALLTYPE";
|
||||
indent(header, 0);
|
||||
fprintf(header, "virtual ");
|
||||
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
|
|||
}
|
||||
if (!is_callas(func->attrs)) {
|
||||
const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV);
|
||||
if (!callconv) callconv = "";
|
||||
if (!callconv) callconv = "STDMETHODCALLTYPE";
|
||||
indent(header, 0);
|
||||
write_type_decl_left(header, type_function_get_rettype(func->type));
|
||||
fprintf(header, " (%s *%s)(\n", callconv, get_name(func));
|
||||
|
@ -846,7 +849,7 @@ static void write_method_proto(FILE *header, const type_t *iface)
|
|||
|
||||
if (!is_local(func->attrs)) {
|
||||
const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV);
|
||||
if (!callconv) callconv = "";
|
||||
if (!callconv) callconv = "STDMETHODCALLTYPE";
|
||||
/* proxy prototype */
|
||||
write_type_decl_left(header, type_function_get_rettype(func->type));
|
||||
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
|
|||
if (type_get_type(stmt->u.type) == TYPE_INTERFACE)
|
||||
{
|
||||
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))
|
||||
{
|
||||
write_com_interface_start(header, iface);
|
||||
|
@ -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_rpc_interface_end(header, iface);
|
||||
}
|
||||
if (is_object(iface)) is_object_interface++;
|
||||
}
|
||||
else if (type_get_type(stmt->u.type) == TYPE_COCLASS)
|
||||
write_coclass(header, stmt->u.type);
|
||||
|
|
|
@ -34,7 +34,6 @@ extern int is_declptr(const type_t *t);
|
|||
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_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_left(FILE *f, type_t *t);
|
||||
extern int needs_space_after(type_t *t);
|
||||
|
|
|
@ -66,7 +66,6 @@
|
|||
#define YYERROR_VERBOSE
|
||||
|
||||
static unsigned char pointer_default = RPC_FC_UP;
|
||||
static int is_object_interface = FALSE;
|
||||
|
||||
typedef struct list typelist_t;
|
||||
struct typenode {
|
||||
|
@ -806,7 +805,6 @@ dispinterface: tDISPINTERFACE aIDENTIFIER { $$ = get_type(TYPE_INTERFACE, $2, 0)
|
|||
;
|
||||
|
||||
dispinterfacehdr: attributes dispinterface { attr_t *attrs;
|
||||
is_object_interface = TRUE;
|
||||
$$ = $2;
|
||||
check_def($$);
|
||||
attrs = make_attr(ATTR_DISPINTERFACE);
|
||||
|
@ -836,7 +834,7 @@ dispinterfacedef: dispinterfacehdr '{'
|
|||
;
|
||||
|
||||
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); }
|
||||
|
@ -849,7 +847,6 @@ interfacehdr: attributes interface { $$.interface = $2;
|
|||
pointer_default = get_attrv($1, ATTR_POINTERDEFAULT);
|
||||
check_def($2);
|
||||
$2->attrs = check_iface_attrs($2->name, $1);
|
||||
is_object_interface = is_object($2);
|
||||
$2->defined = TRUE;
|
||||
}
|
||||
;
|
||||
|
@ -1575,12 +1572,6 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
|
|||
* function node */
|
||||
for (t = v->type; is_ptr(t); t = type_pointer_get_ref(t))
|
||||
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
|
||||
{
|
||||
|
|
|
@ -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_full_pointer = is_full_pointer_function(func);
|
||||
const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV);
|
||||
if (!callconv) callconv = "";
|
||||
if (!callconv) callconv = "STDMETHODCALLTYPE";
|
||||
|
||||
indent = 0;
|
||||
print_proxy( "static void __finally_%s_%s_Proxy( struct __proxy_frame *__frame )\n",
|
||||
|
|
Loading…
Reference in New Issue