Commit c7d68454 authored by Richard Pospesel's avatar Richard Pospesel Committed by Alexandre Julliard

widl: Refactor to have array type's element use decl_spec_t rather than type_t.

parent 1ffb6494
......@@ -583,7 +583,7 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc
result.type = type_pointer_get_ref(result.type);
else if(result.type && is_array(result.type)
&& type_array_is_decl_as_ptr(result.type))
result.type = type_array_get_element(result.type);
result.type = type_array_get_element_type(result.type);
else
error_loc_info(&expr_loc->v->loc_info, "dereference operator applied to non-pointer type in expression%s%s\n",
expr_loc->attr ? " for attribute " : "",
......@@ -665,7 +665,7 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc
if (result.type && is_array(result.type))
{
struct expression_type index_result;
result.type = type_array_get_element(result.type);
result.type = type_array_get_element_type(result.type);
index_result = resolve_expression(expr_loc, cont_type /* FIXME */, e->u.ext);
if (!index_result.type || !is_integer_type(index_result.type))
error_loc_info(&expr_loc->v->loc_info, "array subscript not of integral type in expression%s%s\n",
......
......@@ -361,9 +361,9 @@ void write_type_left(FILE *h, type_t *t, enum name_type name_type, int declonly)
fprintf(h, "%s", t->name);
else
{
write_type_left(h, type_array_get_element(t), name_type, declonly);
write_type_left(h, type_array_get_element_type(t), name_type, declonly);
if (type_array_is_decl_as_ptr(t))
write_pointer_left(h, type_array_get_element(t));
write_pointer_left(h, type_array_get_element_type(t));
}
break;
case TYPE_BASIC:
......@@ -443,7 +443,7 @@ void write_type_right(FILE *h, type_t *t, int is_field)
{
case TYPE_ARRAY:
{
type_t *elem = type_array_get_element(t);
type_t *elem = type_array_get_element_type(t);
if (type_array_is_decl_as_ptr(t))
{
if (!type_is_alias(elem) && is_array(elem) && !type_array_is_decl_as_ptr(elem))
......@@ -705,7 +705,7 @@ void check_for_additional_prototype_types(type_t *type)
else if (is_ptr(type))
type = type_pointer_get_ref(type);
else if (is_array(type))
type = type_array_get_element(type);
type = type_array_get_element_type(type);
else
break;
}
......
......@@ -88,7 +88,7 @@ static inline int last_ptr(const type_t *type)
static inline int last_array(const type_t *type)
{
return is_array(type) && !is_array(type_array_get_element(type));
return is_array(type) && !is_array(type_array_get_element_type(type));
}
static inline int is_string_type(const attr_list_t *attrs, const type_t *type)
......
......@@ -1469,7 +1469,7 @@ static type_t *get_array_or_ptr_ref(type_t *type)
if (is_ptr(type))
return type_pointer_get_ref(type);
else if (is_array(type))
return type_array_get_element(type);
return type_array_get_element_type(type);
return NULL;
}
......@@ -1485,7 +1485,7 @@ static type_t *append_chain_type(type_t *chain, type_t *type)
if (is_ptr(chain_type))
chain_type->details.pointer.ref = type;
else if (is_array(chain_type))
chain_type->details.array.elem = type;
chain_type->details.array.elem.type = type;
else
assert(0);
......@@ -1587,7 +1587,7 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
if (is_ptr(t))
t = type_pointer_get_ref(t);
else if (is_array(t))
t = type_array_get_element(t);
t = type_array_get_element_type(t);
else
break;
}
......@@ -1624,7 +1624,7 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
error_loc("%s: cannot specify size_is for an already sized array\n", v->name);
else
*ptype = type_new_array((*ptype)->name,
type_array_get_element(*ptype), FALSE,
type_array_get_element_type(*ptype), FALSE,
0, dim, NULL, FC_RP);
}
else if (is_ptr(*ptype))
......@@ -1637,7 +1637,7 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
if (is_ptr(*ptype))
ptype = &(*ptype)->details.pointer.ref;
else if (is_array(*ptype))
ptype = &(*ptype)->details.array.elem;
ptype = &(*ptype)->details.array.elem.type;
else
error_loc("%s: too many expressions in size_is attribute\n", v->name);
}
......@@ -1650,7 +1650,7 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
if (is_array(*ptype))
{
*ptype = type_new_array((*ptype)->name,
type_array_get_element(*ptype),
type_array_get_element_type(*ptype),
type_array_is_decl_as_ptr(*ptype),
type_array_get_dim(*ptype),
type_array_get_conformance(*ptype),
......@@ -1663,7 +1663,7 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
if (is_ptr(*ptype))
ptype = &(*ptype)->details.pointer.ref;
else if (is_array(*ptype))
ptype = &(*ptype)->details.array.elem;
ptype = &(*ptype)->details.array.elem.type;
else
error_loc("%s: too many expressions in length_is attribute\n", v->name);
}
......@@ -2648,7 +2648,7 @@ static void check_field_common(const type_t *container_type,
more_to_do = TRUE;
break;
case TGT_ARRAY:
type = type_array_get_element(type);
type = type_array_get_element_type(type);
more_to_do = TRUE;
break;
case TGT_USER_TYPE:
......
......@@ -97,7 +97,7 @@ static unsigned short builtin_vt(const type_t *t)
{
const type_t *elem_type;
if (is_array(t))
elem_type = type_array_get_element(t);
elem_type = type_array_get_element_type(t);
else
elem_type = type_pointer_get_ref(t);
if (type_get_type(elem_type) == TYPE_BASIC)
......@@ -198,7 +198,7 @@ unsigned short get_type_vt(type_t *t)
case TYPE_ARRAY:
if (type_array_is_decl_as_ptr(t))
{
if (match(type_array_get_element(t)->name, "SAFEARRAY"))
if (match(type_array_get_element_type(t)->name, "SAFEARRAY"))
return VT_SAFEARRAY;
return VT_PTR;
}
......
......@@ -235,7 +235,7 @@ type_t *type_new_array(const char *name, type_t *element, int declptr,
t->details.array.size_is = size_is;
else
t->details.array.dim = dim;
t->details.array.elem = element;
t->details.array.elem.type = element;
t->details.array.ptr_def_fc = ptr_default_fc;
return t;
}
......
......@@ -250,11 +250,16 @@ static inline expr_t *type_array_get_variance(const type_t *type)
return type->details.array.length_is;
}
static inline type_t *type_array_get_element(const type_t *type)
static inline const decl_spec_t *type_array_get_element(const type_t *type)
{
type = type_get_real_type(type);
assert(type_get_type(type) == TYPE_ARRAY);
return type->details.array.elem;
return &type->details.array.elem;
}
static inline type_t *type_array_get_element_type(const type_t *type)
{
return type_array_get_element(type)->type;
}
static inline int type_array_is_decl_as_ptr(const type_t *type)
......
......@@ -364,7 +364,7 @@ struct array_details
{
expr_t *size_is;
expr_t *length_is;
struct _type_t *elem;
struct _decl_spec_t elem;
unsigned int dim;
unsigned char ptr_def_fc;
unsigned char declptr; /* if declared as a pointer */
......
......@@ -912,10 +912,10 @@ static int encode_type(
case VT_SAFEARRAY:
{
type_t *element_type = type_alias_get_aliasee(type_array_get_element(type));
type_t *element_type = type_alias_get_aliasee(type_array_get_element_type(type));
int next_vt = get_type_vt(element_type);
encode_type(typelib, next_vt, type_alias_get_aliasee(type_array_get_element(type)),
encode_type(typelib, next_vt, type_alias_get_aliasee(type_array_get_element_type(type)),
&target_type, &child_size);
for (typeoffset = 0; typeoffset < typelib->typelib_segdir[MSFT_SEG_TYPEDESC].length; typeoffset += 8) {
......@@ -1056,7 +1056,7 @@ static int encode_var(
num_dims = 0;
for (atype = type;
is_array(atype) && !type_array_is_decl_as_ptr(atype);
atype = type_array_get_element(atype))
atype = type_array_get_element_type(atype))
++num_dims;
chat("array with %d dimensions\n", num_dims);
......@@ -1071,7 +1071,7 @@ static int encode_var(
arraydata += 2;
for (atype = type;
is_array(atype) && !type_array_is_decl_as_ptr(atype);
atype = type_array_get_element(atype))
atype = type_array_get_element_type(atype))
{
arraydata[0] = type_array_get_dim(atype);
arraydata[1] = 0;
......@@ -1093,7 +1093,7 @@ static int encode_var(
vt = get_type_vt(type);
if (vt == VT_PTR) {
type_t *ref = is_ptr(type) ?
type_pointer_get_ref(type) : type_array_get_element(type);
type_pointer_get_ref(type) : type_array_get_element_type(type);
int skip_ptr = encode_var(typelib, ref, var, &target_type, &child_size);
if(skip_ptr == 2) {
......@@ -1114,7 +1114,7 @@ static int encode_var(
if (target_type & 0x80000000) {
mix_field = ((target_type >> 16) & 0x3fff) | VT_BYREF;
} else if (get_type_vt(ref) == VT_SAFEARRAY) {
type_t *element_type = type_alias_get_aliasee(type_array_get_element(ref));
type_t *element_type = type_alias_get_aliasee(type_array_get_element_type(ref));
mix_field = get_type_vt(element_type) | VT_ARRAY | VT_BYREF;
} else {
typedata = (void *)&typelib->typelib_segment_data[MSFT_SEG_TYPEDESC][target_type];
......
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