From: Richard Pospesel Subject: [PATCH 07/15] widl: type_new_array function now takes decl_spec_t for element rather than type_t Message-Id: <20190705215144.7474-6-richard@torproject.org> Date: Fri, 5 Jul 2019 14:51:36 -0700 In-Reply-To: <20190705215144.7474-5-richard@torproject.org> References: <20190705215003.7384-1-richard@torproject.org> <20190705215144.7474-1-richard@torproject.org> <20190705215144.7474-2-richard@torproject.org> <20190705215144.7474-3-richard@torproject.org> <20190705215144.7474-4-richard@torproject.org> <20190705215144.7474-5-richard@torproject.org> Signed-off-by: Richard Pospesel --- tools/widl/parser.y | 11 +++++++---- tools/widl/typetree.c | 6 ++++-- tools/widl/typetree.h | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 82cf36d297..f3414e1f70 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -1626,11 +1626,11 @@ 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_type(*ptype), FALSE, + type_array_get_element(*ptype), FALSE, 0, dim, NULL, FC_RP); } else if (is_ptr(*ptype)) - *ptype = type_new_array((*ptype)->name, type_pointer_get_ref_type(*ptype), TRUE, + *ptype = type_new_array((*ptype)->name, type_pointer_get_ref(*ptype), TRUE, 0, dim, NULL, pointer_default); else error_loc("%s: size_is attribute applied to illegal type\n", v->name); @@ -1653,7 +1653,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_type(*ptype), + type_array_get_element(*ptype), type_array_is_decl_as_ptr(*ptype), type_array_get_dim(*ptype), type_array_get_conformance(*ptype), @@ -1808,7 +1808,10 @@ static declarator_t *make_declarator(var_t *var) static type_t *make_safearray(type_t *type) { - return type_new_array(NULL, type_new_alias(type, "SAFEARRAY"), TRUE, 0, + decl_spec_t element_ds; + init_declspec(&element_ds, type_new_alias(type, "SAFEARRAY")); + + return type_new_array(NULL, &element_ds, TRUE, 0, NULL, NULL, FC_RP); } diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c index 4b37b0d524..6b50271377 100644 --- a/tools/widl/typetree.c +++ b/tools/widl/typetree.c @@ -220,7 +220,7 @@ type_t *type_new_coclass(char *name) } -type_t *type_new_array(const char *name, type_t *element, int declptr, +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) { @@ -232,7 +232,9 @@ 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.type = element; + if (element) { + t->details.array.elem = *element; + } t->details.array.ptr_def_fc = ptr_default_fc; return t; } diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h index c773ddd116..59bfb29fa4 100644 --- a/tools/widl/typetree.h +++ b/tools/widl/typetree.h @@ -33,7 +33,7 @@ type_t *type_new_function(var_list_t *args); type_t *type_new_pointer(unsigned char pointer_default, type_t *ref, attr_list_t *attrs); type_t *type_new_alias(type_t *t, const char *name); type_t *type_new_module(char *name); -type_t *type_new_array(const char *name, type_t *element, int declptr, +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); type_t *type_new_basic(enum type_basic_type basic_type); -- 2.17.1