widl: Don't store the default pointer type in the type_t structure.

This fixes type format string generation for the following IDL:

typedef int *intp;
[pointer_default(ref)] interface IRef {
    void a(intp *a);
}
[pointer_default(unique)] interface IUnique {
    void b(intp *a);
}

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-08-17 20:07:08 -05:00 committed by Alexandre Julliard
parent 5cc3548299
commit 60d668631f
7 changed files with 27 additions and 61 deletions

View File

@ -521,11 +521,11 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc
break;
case EXPR_STRLIT:
result.is_temporary = TRUE;
result.type = type_new_pointer(FC_UP, type_new_int(TYPE_BASIC_CHAR, 0));
result.type = type_new_pointer(type_new_int(TYPE_BASIC_CHAR, 0));
break;
case EXPR_WSTRLIT:
result.is_temporary = TRUE;
result.type = type_new_pointer(FC_UP, type_new_int(TYPE_BASIC_WCHAR, 0));
result.type = type_new_pointer(type_new_int(TYPE_BASIC_WCHAR, 0));
break;
case EXPR_CHARCONST:
result.is_temporary = TRUE;
@ -575,7 +575,7 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc
expr_loc->attr ? expr_loc->attr : "");
result.is_variable = FALSE;
result.is_temporary = TRUE;
result.type = type_new_pointer(FC_UP, result.type);
result.type = type_new_pointer(result.type);
break;
case EXPR_PPTR:
result = resolve_expression(expr_loc, cont_type, e->ref);

View File

@ -21,12 +21,6 @@
#ifndef __WIDL_PARSER_H
#define __WIDL_PARSER_H
typedef struct
{
type_t *interface;
unsigned char old_pointer_default;
} interface_info_t;
int parser_parse(void);
extern FILE *parser_in;

View File

@ -38,8 +38,6 @@
#include "expr.h"
#include "typetree.h"
static unsigned char pointer_default = FC_UP;
typedef struct list typelist_t;
struct typenode {
type_t *type;
@ -154,7 +152,6 @@ static typelib_t *current_typelib;
UUID *uuid;
unsigned int num;
double dbl;
interface_info_t ifinfo;
typelib_t *typelib;
struct _import_t *import;
struct _decl_spec_t *declspec;
@ -268,7 +265,7 @@ static typelib_t *current_typelib;
%type <str_list> str_list
%type <expr> m_expr expr expr_const expr_int_const array m_bitfield
%type <expr_list> m_exprs /* exprs expr_list */ expr_list_int_const
%type <ifinfo> interfacehdr
%type <type> interfacehdr
%type <stgclass> storage_cls_spec
%type <type_qualifier> type_qualifier m_type_qual_list
%type <function_specifier> function_specifier
@ -896,10 +893,7 @@ interface: tINTERFACE aIDENTIFIER { $$ = get_type(TYPE_INTERFACE, $2, current_n
| tINTERFACE aKNOWNTYPE { $$ = get_type(TYPE_INTERFACE, $2, current_namespace, 0); }
;
interfacehdr: attributes interface { $$.interface = $2;
$$.old_pointer_default = pointer_default;
if (is_attr($1, ATTR_POINTERDEFAULT))
pointer_default = get_attrv($1, ATTR_POINTERDEFAULT);
interfacehdr: attributes interface { $$ = $2;
check_def($2);
$2->attrs = check_iface_attrs($2->name, $1);
$2->defined = TRUE;
@ -907,20 +901,18 @@ interfacehdr: attributes interface { $$.interface = $2;
;
interfacedef: interfacehdr inherit
'{' int_statements '}' semicolon_opt { $$ = $1.interface;
'{' int_statements '}' semicolon_opt { $$ = $1;
if($$ == $2)
error_loc("Interface can't inherit from itself\n");
type_interface_define($$, $2, $4);
check_async_uuid($$);
pointer_default = $1.old_pointer_default;
}
/* MIDL is able to import the definition of a base class from inside the
* definition of a derived class, I'll try to support it with this rule */
| interfacehdr ':' aIDENTIFIER
'{' import int_statements '}'
semicolon_opt { $$ = $1.interface;
semicolon_opt { $$ = $1;
type_interface_define($$, find_type_or_error2($3, 0), $6);
pointer_default = $1.old_pointer_default;
}
| dispinterfacedef semicolon_opt { $$ = $1; }
;
@ -980,7 +972,7 @@ decl_spec_no_type:
declarator:
'*' m_type_qual_list declarator %prec PPTR
{ $$ = $3; append_chain_type($$, type_new_pointer(pointer_default, NULL), $2); }
{ $$ = $3; append_chain_type($$, type_new_pointer(NULL), $2); }
| callconv declarator { $$ = $2; append_chain_callconv($$->type, $1); }
| direct_declarator
;
@ -995,7 +987,7 @@ direct_declarator:
/* abstract declarator */
abstract_declarator:
'*' m_type_qual_list m_abstract_declarator %prec PPTR
{ $$ = $3; append_chain_type($$, type_new_pointer(pointer_default, NULL), $2); }
{ $$ = $3; append_chain_type($$, type_new_pointer(NULL), $2); }
| callconv m_abstract_declarator { $$ = $2; append_chain_callconv($$->type, $1); }
| abstract_direct_declarator
;
@ -1003,7 +995,7 @@ abstract_declarator:
/* abstract declarator without accepting direct declarator */
abstract_declarator_no_direct:
'*' m_type_qual_list m_any_declarator %prec PPTR
{ $$ = $3; append_chain_type($$, type_new_pointer(pointer_default, NULL), $2); }
{ $$ = $3; append_chain_type($$, type_new_pointer(NULL), $2); }
| callconv m_any_declarator { $$ = $2; append_chain_callconv($$->type, $1); }
;
@ -1030,7 +1022,7 @@ abstract_direct_declarator:
/* abstract or non-abstract declarator */
any_declarator:
'*' m_type_qual_list m_any_declarator %prec PPTR
{ $$ = $3; append_chain_type($$, type_new_pointer(pointer_default, NULL), $2); }
{ $$ = $3; append_chain_type($$, type_new_pointer(NULL), $2); }
| callconv m_any_declarator { $$ = $2; append_chain_callconv($$->type, $1); }
| any_direct_declarator
;
@ -1038,7 +1030,7 @@ any_declarator:
/* abstract or non-abstract declarator without accepting direct declarator */
any_declarator_no_direct:
'*' m_type_qual_list m_any_declarator %prec PPTR
{ $$ = $3; append_chain_type($$, type_new_pointer(pointer_default, NULL), $2); }
{ $$ = $3; append_chain_type($$, type_new_pointer(NULL), $2); }
| callconv m_any_declarator { $$ = $2; append_chain_callconv($$->type, $1); }
;
@ -1378,7 +1370,7 @@ static void append_array(declarator_t *decl, expr_t *expr)
/* An array is always a reference pointer unless explicitly marked otherwise
* (regardless of what the default pointer attribute is). */
array = type_new_array(NULL, NULL, FALSE, expr->is_const ? expr->cval : 0,
expr->is_const ? NULL : expr, NULL, FC_RP);
expr->is_const ? NULL : expr, NULL);
append_chain_type(decl, array, 0);
}
@ -1579,7 +1571,7 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, declarator
warning_loc_info(&v->loc_info,
"%s: pointer attribute applied to interface "
"pointer type has no effect\n", v->name);
if (!ptr_attr && top && type_pointer_get_default_fc(v->declspec.type) != FC_RP)
if (!ptr_attr && top)
{
/* FIXME: this is a horrible hack to cope with the issue that we
* store an offset to the typeformat string in the type object, but
@ -1643,11 +1635,11 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, declarator
else
*ptype = type_new_array((*ptype)->name,
type_array_get_element(*ptype), FALSE,
0, dim, NULL, FC_RP);
0, dim, NULL);
}
else if (is_ptr(*ptype))
*ptype = type_new_array((*ptype)->name, type_pointer_get_ref(*ptype), TRUE,
0, dim, NULL, pointer_default);
0, dim, NULL);
else
error_loc("%s: size_is attribute applied to illegal type\n", v->name);
}
@ -1671,8 +1663,7 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, declarator
type_array_get_element(*ptype),
type_array_is_decl_as_ptr(*ptype),
type_array_get_dim(*ptype),
type_array_get_conformance(*ptype),
dim, type_array_get_ptr_default_fc(*ptype));
type_array_get_conformance(*ptype), dim);
}
else
error_loc("%s: length_is attribute applied to illegal type\n", v->name);
@ -1798,7 +1789,7 @@ static type_t *make_safearray(type_t *type)
{
decl_spec_t ds = {.type = type};
ds.type = type_new_alias(&ds, "SAFEARRAY");
return type_new_array(NULL, &ds, TRUE, 0, NULL, NULL, FC_RP);
return type_new_array(NULL, &ds, TRUE, 0, NULL, NULL);
}
static typelib_t *make_library(const char *name, const attr_list_t *attrs)

View File

@ -276,10 +276,11 @@ unsigned char get_pointer_fc(const type_t *type, const attr_list_t *attrs, int t
if (toplevel_param)
return FC_RP;
else if (is_ptr(type))
return type_pointer_get_default_fc(type);
else
return type_array_get_ptr_default_fc(type);
if ((pointer_type = get_attrv(current_iface->attrs, ATTR_POINTERDEFAULT)))
return pointer_type;
return FC_UP;
}
static unsigned char get_pointer_fc_context( const type_t *type, const attr_list_t *attrs,

View File

@ -176,10 +176,9 @@ type_t *type_new_function(var_list_t *args)
return t;
}
type_t *type_new_pointer(unsigned char pointer_default, type_t *ref)
type_t *type_new_pointer(type_t *ref)
{
type_t *t = make_type(TYPE_POINTER);
t->details.pointer.def_fc = pointer_default;
t->details.pointer.ref.type = ref;
return t;
}
@ -218,8 +217,7 @@ type_t *type_new_coclass(char *name)
type_t *type_new_array(const char *name, const decl_spec_t *element, int declptr,
unsigned int dim, expr_t *size_is, expr_t *length_is,
unsigned char ptr_default_fc)
unsigned int dim, expr_t *size_is, expr_t *length_is)
{
type_t *t = make_type(TYPE_ARRAY);
if (name) t->name = xstrdup(name);
@ -231,7 +229,6 @@ type_t *type_new_array(const char *name, const decl_spec_t *element, int declptr
t->details.array.dim = dim;
if (element)
t->details.array.elem = *element;
t->details.array.ptr_def_fc = ptr_default_fc;
return t;
}

View File

@ -30,12 +30,11 @@ enum name_type {
};
type_t *type_new_function(var_list_t *args);
type_t *type_new_pointer(unsigned char pointer_default, type_t *ref);
type_t *type_new_pointer(type_t *ref);
type_t *type_new_alias(const decl_spec_t *t, const char *name);
type_t *type_new_module(char *name);
type_t *type_new_array(const char *name, const decl_spec_t *element, int declptr,
unsigned int dim, expr_t *size_is, expr_t *length_is,
unsigned char ptr_default_fc);
unsigned int dim, expr_t *size_is, expr_t *length_is);
type_t *type_new_basic(enum type_basic_type basic_type);
type_t *type_new_int(enum type_basic_type basic_type, int sign);
type_t *type_new_void(void);
@ -295,13 +294,6 @@ static inline int type_array_is_decl_as_ptr(const type_t *type)
return type->details.array.declptr;
}
static inline unsigned char type_array_get_ptr_default_fc(const type_t *type)
{
type = type_get_real_type(type);
assert(type_get_type(type) == TYPE_ARRAY);
return type->details.array.ptr_def_fc;
}
static inline int type_is_alias(const type_t *type)
{
return type->type_type == TYPE_ALIAS;
@ -338,13 +330,6 @@ static inline type_t *type_pointer_get_ref_type(const type_t *type)
return type_pointer_get_ref(type)->type;
}
static inline unsigned char type_pointer_get_default_fc(const type_t *type)
{
type = type_get_real_type(type);
assert(type_get_type(type) == TYPE_POINTER);
return type->details.pointer.def_fc;
}
static inline type_t *type_bitfield_get_field(const type_t *type)
{
type = type_get_real_type(type);

View File

@ -374,7 +374,6 @@ struct array_details
expr_t *length_is;
struct _decl_spec_t elem;
unsigned int dim;
unsigned char ptr_def_fc;
unsigned char declptr; /* if declared as a pointer */
unsigned short ptr_tfsoff; /* offset of pointer definition for declptr */
};
@ -393,7 +392,6 @@ struct basic_details
struct pointer_details
{
struct _decl_spec_t ref;
unsigned char def_fc;
};
struct bitfield_details