Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
July 2019
- 65 participants
- 633 messages
[PATCH 09/15] widl: now using type qualifier and func specifier enums on decl_spec_t rather than attributes on the type_t
by Richard Pospesel
Signed-off-by: Richard Pospesel <richard(a)torproject.org>
---
tools/widl/expr.c | 6 +-
tools/widl/header.c | 20 ++--
tools/widl/parser.y | 220 +++++++++++++++++++++++++++--------------
tools/widl/typetree.c | 3 +-
tools/widl/typetree.h | 2 +-
tools/widl/widltypes.h | 23 +++--
6 files changed, 178 insertions(+), 96 deletions(-)
diff --git a/tools/widl/expr.c b/tools/widl/expr.c
index 85ba4639e1..2f07581662 100644
--- a/tools/widl/expr.c
+++ b/tools/widl/expr.c
@@ -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), NULL);
+ result.type = type_new_pointer(FC_UP, 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), NULL);
+ result.type = type_new_pointer(FC_UP, 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, NULL);
+ result.type = type_new_pointer(FC_UP, result.type);
break;
case EXPR_PPTR:
result = resolve_expression(expr_loc, cont_type, e->ref);
diff --git a/tools/widl/header.c b/tools/widl/header.c
index 192abece1e..9e9cd5f6ff 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -309,7 +309,7 @@ void write_declspec_left(FILE* h, const decl_spec_t *ds, enum name_type name_typ
name = type_get_name(t, name_type);
- if (is_attr(t->attrs, ATTR_CONST) &&
+ if ((ds->typequalifier == TYPE_QUALIFIER_CONST) &&
(type_is_alias(t) || !is_ptr(t)))
fprintf(h, "const ");
@@ -360,7 +360,7 @@ void write_declspec_left(FILE* h, const decl_spec_t *ds, enum name_type name_typ
{
write_declspec_left(h, type_pointer_get_ref(t), name_type, declonly);
write_pointer_left(h, type_pointer_get_ref_type(t));
- if (is_attr(t->attrs, ATTR_CONST)) fprintf(h, "const ");
+ if (ds->typequalifier == TYPE_QUALIFIER_CONST) fprintf(h, "const ");
break;
}
case TYPE_ARRAY:
@@ -501,14 +501,16 @@ static void write_type_v(FILE *h, const decl_spec_t *ds, int is_field, int declo
if (!h) return;
if (t) {
- for (pt = t; is_ptr(pt); pt = type_pointer_get_ref_type(pt), ptr_level++)
+ const decl_spec_t *dpt = NULL;
+ for (dpt = ds; is_ptr(dpt->type); dpt = type_pointer_get_ref(dpt->type), ptr_level++)
;
+ pt = dpt->type;
if (type_get_type_detect_alias(pt) == TYPE_FUNCTION) {
int i;
const char *callconv = get_attrp(pt->attrs, ATTR_CALLCONV);
if (!callconv && is_object_interface) callconv = "STDMETHODCALLTYPE";
- if (is_attr(pt->attrs, ATTR_INLINE)) fprintf(h, "inline ");
+ if (dpt->funcspecifier == FUNCTION_SPECIFIER_INLINE) fprintf(h, "inline ");
write_declspec_left(h, type_function_get_retdeclspec(pt), NAME_DEFAULT, declonly);
fputc(' ', h);
if (ptr_level) fputc('(', h);
@@ -809,17 +811,17 @@ static void write_typedef(FILE *header, type_t *type)
int is_const_decl(const var_t *var)
{
- const type_t *t;
+ const decl_spec_t *ds;
/* strangely, MIDL accepts a const attribute on any pointer in the
* declaration to mean that data isn't being instantiated. this appears
* to be a bug, but there is no benefit to being incompatible with MIDL,
* so we'll do the same thing */
- for (t = var->declspec.type; ; )
+ for (ds = &var->declspec; ;)
{
- if (is_attr(t->attrs, ATTR_CONST))
+ if (ds->typequalifier == TYPE_QUALIFIER_CONST)
return TRUE;
- else if (is_ptr(t))
- t = type_pointer_get_ref_type(t);
+ else if (is_ptr(ds->type))
+ ds = type_pointer_get_ref(ds->type);
else break;
}
return FALSE;
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 07261b99dc..de1dc709fc 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -60,7 +60,7 @@ static void fix_incomplete_types(type_t *complete_type);
static str_list_t *append_str(str_list_t *list, char *str);
static attr_list_t *append_attr(attr_list_t *list, attr_t *attr);
static attr_list_t *append_attr_list(attr_list_t *new_list, attr_list_t *old_list);
-static decl_spec_t *make_decl_spec(type_t *type, decl_spec_t *left, decl_spec_t *right, attr_t *attr, enum storage_class stgclass);
+static decl_spec_t *make_decl_spec(type_t *type, decl_spec_t *left, decl_spec_t *right, enum storage_class stgclass, enum type_qualifier typequalifier, enum function_specifier funcspecifier);
static attr_t *make_attr(enum attr_type type);
static attr_t *make_attrv(enum attr_type type, unsigned int val);
static attr_t *make_attrp(enum attr_type type, void *val);
@@ -76,6 +76,7 @@ static declarator_t *make_declarator(var_t *var);
static type_t *make_safearray(type_t *type);
static typelib_t *make_library(const char *name, const attr_list_t *attrs);
static type_t *append_chain_type(type_t *chain, type_t *type);
+static decl_spec_t *append_chain_declspec(decl_spec_t *chain, type_t *type, enum type_qualifier typequalifier);
static warning_list_t *append_warning(warning_list_t *, int);
static type_t *reg_typedefs(decl_spec_t *decl_spec, var_list_t *names, attr_list_t *attrs);
@@ -158,6 +159,8 @@ static typelib_t *current_typelib;
struct _import_t *import;
struct _decl_spec_t *declspec;
enum storage_class stgclass;
+ enum type_qualifier typequalifier;
+ enum function_specifier funcspecifier;
}
%token <str> aIDENTIFIER aPRAGMA
@@ -259,14 +262,16 @@ static typelib_t *current_typelib;
%token tWCHAR tWIREMARSHAL
%token tAPARTMENT tNEUTRAL tSINGLE tFREE tBOTH
-%type <attr> attribute type_qualifier function_specifier acf_attribute
-%type <attr_list> m_attributes attributes attrib_list m_type_qual_list
+%type <attr> attribute acf_attribute
+%type <attr_list> m_attributes attributes attrib_list
%type <attr_list> acf_attributes acf_attribute_list
%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 <stgclass> storage_cls_spec
+%type <typequalifier> type_qualifier m_type_qual_bits
+%type <funcspecifier> function_specifier
%type <declspec> decl_spec decl_spec_no_type m_decl_spec_no_type
%type <type> inherit interface interfacedef interfacedec
%type <type> dispinterface dispinterfacehdr dispinterfacedef
@@ -948,20 +953,20 @@ storage_cls_spec:
;
function_specifier:
- tINLINE { $$ = make_attr(ATTR_INLINE); }
+ tINLINE { $$ = FUNCTION_SPECIFIER_INLINE; }
;
type_qualifier:
- tCONST { $$ = make_attr(ATTR_CONST); }
+ tCONST { $$ = TYPE_QUALIFIER_CONST; }
;
-m_type_qual_list: { $$ = NULL; }
- | m_type_qual_list type_qualifier { $$ = append_attr($1, $2); }
+m_type_qual_bits: { $$ = TYPE_QUALIFIER_NONE; }
+ | m_type_qual_bits type_qualifier { $$ = $1 | $2; }
;
-decl_spec: type m_decl_spec_no_type { $$ = make_decl_spec($1, $2, NULL, NULL, STG_NONE); }
+decl_spec: type m_decl_spec_no_type { $$ = make_decl_spec($1, $2, NULL, STG_NONE, TYPE_QUALIFIER_NONE, FUNCTION_SPECIFIER_NONE); }
| decl_spec_no_type type m_decl_spec_no_type
- { $$ = make_decl_spec($2, $1, $3, NULL, STG_NONE); }
+ { $$ = make_decl_spec($2, $1, $3, STG_NONE, TYPE_QUALIFIER_NONE, FUNCTION_SPECIFIER_NONE); }
;
m_decl_spec_no_type: { $$ = NULL; }
@@ -969,44 +974,44 @@ m_decl_spec_no_type: { $$ = NULL; }
;
decl_spec_no_type:
- type_qualifier m_decl_spec_no_type { $$ = make_decl_spec(NULL, $2, NULL, $1, STG_NONE); }
- | function_specifier m_decl_spec_no_type { $$ = make_decl_spec(NULL, $2, NULL, $1, STG_NONE); }
- | storage_cls_spec m_decl_spec_no_type { $$ = make_decl_spec(NULL, $2, NULL, NULL, $1); }
+ type_qualifier m_decl_spec_no_type { $$ = make_decl_spec(NULL, $2, NULL, STG_NONE, $1, FUNCTION_SPECIFIER_NONE); }
+ | function_specifier m_decl_spec_no_type { $$ = make_decl_spec(NULL, $2, NULL, STG_NONE, TYPE_QUALIFIER_NONE, $1); }
+ | storage_cls_spec m_decl_spec_no_type { $$ = make_decl_spec(NULL, $2, NULL, $1, TYPE_QUALIFIER_NONE, FUNCTION_SPECIFIER_NONE); }
;
declarator:
- '*' m_type_qual_list declarator %prec PPTR
- { $$ = $3; $$->type = append_chain_type($$->type, type_new_pointer(pointer_default, NULL, $2)); }
+ '*' m_type_qual_bits declarator %prec PPTR
+ { $$ = $3; append_chain_declspec(&$$->declspec, type_new_pointer(pointer_default, NULL), $2); }
| callconv declarator { $$ = $2; if ($$->func_type) $$->func_type->attrs = append_attr($$->func_type->attrs, make_attrp(ATTR_CALLCONV, $1));
- else if ($$->type) $$->type->attrs = append_attr($$->type->attrs, make_attrp(ATTR_CALLCONV, $1)); }
+ else if ($$->declspec.type) $$->declspec.type->attrs = append_attr($$->declspec.type->attrs, make_attrp(ATTR_CALLCONV, $1)); }
| direct_declarator
;
direct_declarator:
ident { $$ = make_declarator($1); }
| '(' declarator ')' { $$ = $2; }
- | direct_declarator array { $$ = $1; $$->type = append_array($$->type, $2); }
+ | direct_declarator array { $$ = $1; $$->declspec.type = append_array($$->declspec.type, $2); }
| direct_declarator '(' m_args ')' { $$ = $1;
- $$->func_type = append_chain_type($$->type, type_new_function($3));
- $$->type = NULL;
+ $$->func_type = append_chain_type($$->declspec.type, type_new_function($3));
+ $$->declspec.type = NULL;
}
;
/* abstract declarator */
abstract_declarator:
- '*' m_type_qual_list m_abstract_declarator %prec PPTR
- { $$ = $3; $$->type = append_chain_type($$->type, type_new_pointer(pointer_default, NULL, $2)); }
+ '*' m_type_qual_bits m_abstract_declarator %prec PPTR
+ { $$ = $3; append_chain_declspec(&$$->declspec, type_new_pointer(pointer_default, NULL), $2); }
| callconv m_abstract_declarator { $$ = $2; if ($$->func_type) $$->func_type->attrs = append_attr($$->func_type->attrs, make_attrp(ATTR_CALLCONV, $1));
- else if ($$->type) $$->type->attrs = append_attr($$->type->attrs, make_attrp(ATTR_CALLCONV, $1)); }
+ else if ($$->declspec.type) $$->declspec.type->attrs = append_attr($$->declspec.type->attrs, make_attrp(ATTR_CALLCONV, $1)); }
| abstract_direct_declarator
;
/* abstract declarator without accepting direct declarator */
abstract_declarator_no_direct:
- '*' m_type_qual_list m_any_declarator %prec PPTR
- { $$ = $3; $$->type = append_chain_type($$->type, type_new_pointer(pointer_default, NULL, $2)); }
+ '*' m_type_qual_bits m_any_declarator %prec PPTR
+ { $$ = $3; append_chain_declspec(&$$->declspec, type_new_pointer(pointer_default, NULL), $2); }
| callconv m_any_declarator { $$ = $2; if ($$->func_type) $$->func_type->attrs = append_attr($$->func_type->attrs, make_attrp(ATTR_CALLCONV, $1));
- else if ($$->type) $$->type->attrs = append_attr($$->type->attrs, make_attrp(ATTR_CALLCONV, $1)); }
+ else if ($$->declspec.type) $$->declspec.type->attrs = append_attr($$->declspec.type->attrs, make_attrp(ATTR_CALLCONV, $1)); }
;
/* abstract declarator or empty */
@@ -1017,33 +1022,33 @@ m_abstract_declarator: { $$ = make_declarator(NULL); }
/* abstract direct declarator */
abstract_direct_declarator:
'(' abstract_declarator_no_direct ')' { $$ = $2; }
- | abstract_direct_declarator array { $$ = $1; $$->type = append_array($$->type, $2); }
- | array { $$ = make_declarator(NULL); $$->type = append_array($$->type, $1); }
+ | abstract_direct_declarator array { $$ = $1; $$->declspec.type = append_array($$->declspec.type, $2); }
+ | array { $$ = make_declarator(NULL); $$->declspec.type = append_array($$->declspec.type, $1); }
| '(' m_args ')'
{ $$ = make_declarator(NULL);
- $$->func_type = append_chain_type($$->type, type_new_function($2));
- $$->type = NULL;
+ $$->func_type = append_chain_type($$->declspec.type, type_new_function($2));
+ $$->declspec.type = NULL;
}
| abstract_direct_declarator '(' m_args ')'
{ $$ = $1;
- $$->func_type = append_chain_type($$->type, type_new_function($3));
- $$->type = NULL;
+ $$->func_type = append_chain_type($$->declspec.type, type_new_function($3));
+ $$->declspec.type = NULL;
}
;
/* abstract or non-abstract declarator */
any_declarator:
- '*' m_type_qual_list m_any_declarator %prec PPTR
- { $$ = $3; $$->type = append_chain_type($$->type, type_new_pointer(pointer_default, NULL, $2)); }
- | callconv m_any_declarator { $$ = $2; $$->type->attrs = append_attr($$->type->attrs, make_attrp(ATTR_CALLCONV, $1)); }
+ '*' m_type_qual_bits m_any_declarator %prec PPTR
+ { $$ = $3; append_chain_declspec(&$$->declspec, type_new_pointer(pointer_default, NULL), $2); }
+ | callconv m_any_declarator { $$ = $2; $$->declspec.type->attrs = append_attr($$->declspec.type->attrs, make_attrp(ATTR_CALLCONV, $1)); }
| any_direct_declarator
;
/* abstract or non-abstract declarator without accepting direct declarator */
any_declarator_no_direct:
- '*' m_type_qual_list m_any_declarator %prec PPTR
- { $$ = $3; $$->type = append_chain_type($$->type, type_new_pointer(pointer_default, NULL, $2)); }
- | callconv m_any_declarator { $$ = $2; $$->type->attrs = append_attr($$->type->attrs, make_attrp(ATTR_CALLCONV, $1)); }
+ '*' m_type_qual_bits m_any_declarator %prec PPTR
+ { $$ = $3; append_chain_declspec(&$$->declspec, type_new_pointer(pointer_default, NULL), $2); }
+ | callconv m_any_declarator { $$ = $2; $$->declspec.type->attrs = append_attr($$->declspec.type->attrs, make_attrp(ATTR_CALLCONV, $1)); }
;
/* abstract or non-abstract declarator or empty */
@@ -1057,17 +1062,17 @@ m_any_declarator: { $$ = make_declarator(NULL); }
any_direct_declarator:
ident { $$ = make_declarator($1); }
| '(' any_declarator_no_direct ')' { $$ = $2; }
- | any_direct_declarator array { $$ = $1; $$->type = append_array($$->type, $2); }
- | array { $$ = make_declarator(NULL); $$->type = append_array($$->type, $1); }
+ | any_direct_declarator array { $$ = $1; $$->declspec.type = append_array($$->declspec.type, $2); }
+ | array { $$ = make_declarator(NULL); $$->declspec.type = append_array($$->declspec.type, $1); }
| '(' m_args ')'
{ $$ = make_declarator(NULL);
- $$->func_type = append_chain_type($$->type, type_new_function($2));
- $$->type = NULL;
+ $$->func_type = append_chain_type($$->declspec.type, type_new_function($2));
+ $$->declspec.type = NULL;
}
| any_direct_declarator '(' m_args ')'
{ $$ = $1;
- $$->func_type = append_chain_type($$->type, type_new_function($3));
- $$->type = NULL;
+ $$->func_type = append_chain_type($$->declspec.type, type_new_function($3));
+ $$->declspec.type = NULL;
}
;
@@ -1233,6 +1238,7 @@ static attr_list_t *append_attr(attr_list_t *list, attr_t *attr)
LIST_FOR_EACH_ENTRY(attr_existing, list, attr_t, entry)
if (attr_existing->type == attr->type)
{
+ __builtin_trap();
parser_warning("duplicate attribute %s\n", get_attr_display_name(attr->type));
/* use the last attribute, like MIDL does */
list_remove(&attr_existing->entry);
@@ -1292,53 +1298,73 @@ static attr_list_t *map_attrs(const attr_list_t *list, map_attrs_filter_t filter
return new_list;
}
-static decl_spec_t *make_decl_spec(type_t *type, decl_spec_t *left, decl_spec_t *right, attr_t *attr, enum storage_class stgclass)
+static decl_spec_t *make_decl_spec(type_t *type, decl_spec_t *left, decl_spec_t *right, enum storage_class stgclass, enum type_qualifier typequalifier, enum function_specifier funcspecifier)
{
decl_spec_t *declspec = left ? left : right;
if (!declspec)
{
declspec = xmalloc(sizeof(*declspec));
declspec->type = NULL;
- declspec->attrs = NULL;
declspec->stgclass = STG_NONE;
+ declspec->typequalifier = TYPE_QUALIFIER_NONE;
+ declspec->funcspecifier = FUNCTION_SPECIFIER_NONE;
}
declspec->type = type;
if (left && declspec != left)
{
- declspec->attrs = append_attr_list(declspec->attrs, left->attrs);
if (declspec->stgclass == STG_NONE)
declspec->stgclass = left->stgclass;
else if (left->stgclass != STG_NONE)
error_loc("only one storage class can be specified\n");
+
+ if (declspec->typequalifier == TYPE_QUALIFIER_NONE)
+ declspec->typequalifier = left->typequalifier;
+ else if (left->typequalifier != TYPE_QUALIFIER_NONE)
+ error_loc("only one type qualifier can be specified\n");
+
+ if (declspec->funcspecifier == FUNCTION_SPECIFIER_NONE)
+ declspec->funcspecifier = left->funcspecifier;
+ else if (left->funcspecifier != FUNCTION_SPECIFIER_NONE)
+ error_loc("only one function specifier can be specified\n");
+
assert(!left->type);
free(left);
}
if (right && declspec != right)
{
- declspec->attrs = append_attr_list(declspec->attrs, right->attrs);
if (declspec->stgclass == STG_NONE)
declspec->stgclass = right->stgclass;
else if (right->stgclass != STG_NONE)
error_loc("only one storage class can be specified\n");
+
+ if (declspec->typequalifier == TYPE_QUALIFIER_NONE)
+ declspec->typequalifier = right->typequalifier;
+ else if (right->typequalifier != TYPE_QUALIFIER_NONE)
+ error_loc("only one type qualifier can be specified\n");
+
+ if (declspec->funcspecifier == FUNCTION_SPECIFIER_NONE)
+ declspec->funcspecifier = right->funcspecifier;
+ else if (right->funcspecifier != FUNCTION_SPECIFIER_NONE)
+ error_loc("only one function specifier can be specified\n");
+
assert(!right->type);
free(right);
}
- declspec->attrs = append_attr(declspec->attrs, attr);
if (declspec->stgclass == STG_NONE)
declspec->stgclass = stgclass;
else if (stgclass != STG_NONE)
error_loc("only one storage class can be specified\n");
- /* apply attributes to type */
- if (type && declspec->attrs)
- {
- attr_list_t *attrs;
- declspec->type = duptype(type, 1);
- attrs = map_attrs(type->attrs, NULL);
- declspec->type->attrs = append_attr_list(attrs, declspec->attrs);
- declspec->attrs = NULL;
- }
+ if (declspec->typequalifier == TYPE_QUALIFIER_NONE)
+ declspec->typequalifier = typequalifier;
+ else if (typequalifier != TYPE_QUALIFIER_NONE)
+ error_loc("only one type qualifier can be specified\n");
+
+ if (declspec->funcspecifier == FUNCTION_SPECIFIER_NONE)
+ declspec->funcspecifier = funcspecifier;
+ else if (funcspecifier != FUNCTION_SPECIFIER_NONE)
+ error_loc("only one function specifier can be specified\n");
return declspec;
}
@@ -1477,7 +1503,7 @@ static type_t *get_array_or_ptr_ref(type_t *type)
static type_t *append_chain_type(type_t *chain, type_t *type)
{
- type_t *chain_type;
+ type_t *chain_type = NULL;
if (!chain)
return type;
@@ -1495,6 +1521,34 @@ static type_t *append_chain_type(type_t *chain, type_t *type)
return chain;
}
+static decl_spec_t *append_chain_declspec(decl_spec_t *chain, type_t *type, enum type_qualifier typequalifier)
+{
+ type_t *chain_type = chain->type;
+ decl_spec_t *chain_declspec = NULL;
+
+ if (!chain_type)
+ {
+ chain->type = type;
+ chain->typequalifier = typequalifier;
+ return chain;
+ }
+
+ for(; get_array_or_ptr_ref(chain_type); chain_type = get_array_or_ptr_ref(chain_type))
+ ;
+
+ if (is_ptr(chain_type))
+ chain_declspec = &chain_type->details.pointer.ref;
+ else if (is_array(chain_type))
+ chain_declspec = &chain_type->details.array.elem;
+ else
+ assert(NULL);
+
+ chain_declspec->type = type;
+ chain_declspec->typequalifier = typequalifier;
+
+ return chain;
+}
+
static warning_list_t *append_warning(warning_list_t *list, int num)
{
warning_t *entry;
@@ -1510,7 +1564,7 @@ static warning_list_t *append_warning(warning_list_t *list, int num)
return list;
}
-static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const declarator_t *decl,
+static var_t *declare_var(attr_list_t *attrs, decl_spec_t *declspec, const declarator_t *decl,
int top)
{
var_t *v = decl->var;
@@ -1519,25 +1573,41 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
expr_t *dim;
type_t **ptype;
type_t *func_type = decl ? decl->func_type : NULL;
- type_t *type = decl_spec->type;
+ type_t *type = declspec->type;
- if (is_attr(type->attrs, ATTR_INLINE))
- {
+
+ if (declspec->funcspecifier == FUNCTION_SPECIFIER_INLINE) {
if (!func_type)
error_loc("inline attribute applied to non-function type\n");
else
{
- type_t *t;
- /* move inline attribute from return type node to function node */
- for (t = func_type; is_ptr(t); t = type_pointer_get_ref_type(t))
- ;
- t->attrs = move_attr(t->attrs, type->attrs, ATTR_INLINE);
+ v->declspec.funcspecifier = declspec->funcspecifier;
}
}
- /* add type onto the end of the pointers in pident->type */
- v->declspec.type = append_chain_type(decl ? decl->type : NULL, type);
- v->declspec.stgclass = decl_spec->stgclass;
+ /* if the var type is a pointerish, we need to move the type qualifier to the pointee's declspec
+ * unless the pointee already has const type qualifier*/
+ if (!decl)
+ {
+ /* simplest case, no pointers to deal with here */
+ v->declspec.typequalifier = declspec->typequalifier;
+ } else if (decl->bits)
+ {
+ /* dealing with a bitfield, generate bitfield and copy over typequalifier*/
+ v->declspec.type = type_new_bitfield(declspec->type, decl->bits);
+ v->declspec.typequalifier = declspec->typequalifier;
+ }
+ else
+ {
+ /* here we're dealing with a pointerish type chain, so we need to pull
+ * the typequalifier off of the declspec and stick them in the type's attr list
+ */
+ v->declspec.type = decl->declspec.type;
+ v->declspec.typequalifier = decl->declspec.typequalifier;
+ append_chain_declspec(&v->declspec, type, declspec->typequalifier);
+ }
+
+ v->declspec.stgclass = declspec->stgclass;
v->attrs = attrs;
/* check for pointer attribute being applied to non-pointer, non-array
@@ -1680,12 +1750,17 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
{
type_t *ft, *t;
type_t *return_type = v->declspec.type;
+ enum type_qualifier typequalifier = v->declspec.typequalifier;
+
v->declspec.type = func_type;
+ v->declspec.typequalifier = TYPE_QUALIFIER_NONE;
for (ft = v->declspec.type; is_ptr(ft); ft = type_pointer_get_ref_type(ft))
;
assert(type_get_type_detect_alias(ft) == TYPE_FUNCTION);
ft->details.function->retval = make_var(xstrdup("_RetVal"));
ft->details.function->retval->declspec.type = return_type;
+ ft->details.function->retval->declspec.typequalifier = typequalifier;
+
/* move calling convention attribute, if present, from pointer nodes to
* function node */
for (t = v->declspec.type; is_ptr(t); t = type_pointer_get_ref_type(t))
@@ -1699,9 +1774,6 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
error_loc("calling convention applied to non-function-pointer type\n");
}
- if (decl->bits)
- v->declspec.type = type_new_bitfield(v->declspec.type, decl->bits);
-
return v;
}
@@ -1801,7 +1873,7 @@ static declarator_t *make_declarator(var_t *var)
{
declarator_t *d = xmalloc(sizeof(*d));
d->var = var ? var : make_var(NULL);
- d->type = NULL;
+ init_declspec(&d->declspec, NULL);
d->func_type = NULL;
d->bits = NULL;
return d;
@@ -2180,7 +2252,6 @@ struct allowed_attr allowed_attr[] =
/* ATTR_CASE */ { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "case" },
/* ATTR_CODE */ { 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "code" },
/* ATTR_COMMSTATUS */ { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "comm_status" },
- /* ATTR_CONST */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "const" },
/* ATTR_CONTEXTHANDLE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "context_handle" },
/* ATTR_CONTROL */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, "control" },
/* ATTR_DECODE */ { 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "decode" },
@@ -2215,7 +2286,6 @@ struct allowed_attr allowed_attr[] =
/* ATTR_IMMEDIATEBIND */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "immediatebind" },
/* ATTR_IMPLICIT_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "implicit_handle" },
/* ATTR_IN */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "in" },
- /* ATTR_INLINE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "inline" },
/* ATTR_INPUTSYNC */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "inputsync" },
/* ATTR_LENGTHIS */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, "length_is" },
/* ATTR_LIBLCID */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "lcid" },
diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c
index 282f0dbbab..f08bee0bac 100644
--- a/tools/widl/typetree.c
+++ b/tools/widl/typetree.c
@@ -177,12 +177,11 @@ type_t *type_new_function(var_list_t *args)
return t;
}
-type_t *type_new_pointer(unsigned char pointer_default, type_t *ref, attr_list_t *attrs)
+type_t *type_new_pointer(unsigned char pointer_default, type_t *ref)
{
type_t *t = make_type(TYPE_POINTER);
t->details.pointer.def_fc = pointer_default;
t->details.pointer.ref.type = ref;
- t->attrs = attrs;
return t;
}
diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h
index 9434075108..a68bc981cf 100644
--- a/tools/widl/typetree.h
+++ b/tools/widl/typetree.h
@@ -30,7 +30,7 @@ enum name_type {
};
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_pointer(unsigned char pointer_default, type_t *ref);
type_t *type_new_alias(const decl_spec_t *aliasee, 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,
diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h
index d637e0024c..108e537383 100644
--- a/tools/widl/widltypes.h
+++ b/tools/widl/widltypes.h
@@ -81,7 +81,6 @@ enum attr_type
ATTR_CASE,
ATTR_CODE,
ATTR_COMMSTATUS,
- ATTR_CONST, /* const pseudo-attribute */
ATTR_CONTEXTHANDLE,
ATTR_CONTROL,
ATTR_DECODE,
@@ -116,7 +115,6 @@ enum attr_type
ATTR_IMMEDIATEBIND,
ATTR_IMPLICIT_HANDLE,
ATTR_IN,
- ATTR_INLINE,
ATTR_INPUTSYNC,
ATTR_LENGTHIS,
ATTR_LIBLCID,
@@ -235,6 +233,18 @@ enum storage_class
STG_REGISTER,
};
+enum type_qualifier
+{
+ TYPE_QUALIFIER_NONE = 0,
+ TYPE_QUALIFIER_CONST = 1,
+};
+
+enum function_specifier
+{
+ FUNCTION_SPECIFIER_NONE,
+ FUNCTION_SPECIFIER_INLINE,
+};
+
enum statement_type
{
STMT_LIBRARY,
@@ -297,8 +307,9 @@ struct str_list_entry_t
struct _decl_spec_t
{
type_t *type;
- attr_list_t *attrs;
enum storage_class stgclass;
+ enum type_qualifier typequalifier;
+ enum function_specifier funcspecifier;
};
struct _attr_t {
@@ -478,7 +489,7 @@ struct _var_t {
struct _declarator_t {
var_t *var;
- type_t *type;
+ decl_spec_t declspec;
type_t *func_type;
expr_t *bits;
@@ -604,9 +615,9 @@ static inline int is_global_namespace(const struct namespace *namespace)
static inline decl_spec_t *init_declspec(decl_spec_t *declspec, type_t *type)
{
declspec->type = type;
- declspec->attrs = NULL;
declspec->stgclass = STG_NONE;
-
+ declspec->typequalifier=TYPE_QUALIFIER_NONE;
+ declspec->funcspecifier=FUNCTION_SPECIFIER_NONE;
return declspec;
}
--
2.17.1
July 5, 2019
[PATCH 06/15] widl: refactor generators to use decl_spec_t rather than type_t where needed
by Richard Pospesel
Signed-off-by: Richard Pospesel <richard(a)torproject.org>
---
tools/widl/client.c | 8 +-
tools/widl/header.c | 72 +++++++++------
tools/widl/header.h | 4 +-
tools/widl/proxy.c | 6 +-
tools/widl/server.c | 7 +-
tools/widl/typegen.c | 215 ++++++++++++++++++++++++-------------------
6 files changed, 177 insertions(+), 135 deletions(-)
diff --git a/tools/widl/client.c b/tools/widl/client.c
index 545a35c0c9..9a15153bab 100644
--- a/tools/widl/client.c
+++ b/tools/widl/client.c
@@ -54,10 +54,10 @@ static void write_client_func_decl( const type_t *iface, const var_t *func )
{
const char *callconv = get_attrp(func->declspec.type->attrs, ATTR_CALLCONV);
const var_list_t *args = type_function_get_args(func->declspec.type);
- type_t *rettype = type_function_get_rettype(func->declspec.type);
+ const decl_spec_t *retdeclspec = type_function_get_retdeclspec(func->declspec.type);
if (!callconv) callconv = "__cdecl";
- write_type_decl_left(client, rettype);
+ write_declspec_decl_left(client, retdeclspec);
fprintf(client, " %s ", callconv);
fprintf(client, "%s%s(\n", prefix_client, get_name(func));
indent++;
@@ -136,7 +136,7 @@ static void write_function_stub( const type_t *iface, const var_t *func,
if (has_ret)
{
print_client("%s", "");
- write_type_decl(client, retval->declspec.type, retval->name);
+ write_declspec_decl(client, &retval->declspec, retval->name);
fprintf(client, ";\n");
}
print_client("RPC_MESSAGE _RpcMessage;\n");
@@ -488,7 +488,7 @@ static void write_implicithandledecl(type_t *iface)
if (implicit_handle)
{
- write_type_decl( client, implicit_handle->declspec.type, implicit_handle->name );
+ write_declspec_decl( client, &implicit_handle->declspec, implicit_handle->name );
fprintf(client, ";\n\n");
}
}
diff --git a/tools/widl/header.c b/tools/widl/header.c
index d8f31a69f9..192abece1e 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -43,7 +43,7 @@ user_type_list_t user_type_list = LIST_INIT(user_type_list);
context_handle_list_t context_handle_list = LIST_INIT(context_handle_list);
generic_handle_list_t 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 write_type_def_or_decl(FILE *f, const decl_spec_t *ds, int field, const char *name);
static void indent(FILE *h, int delta)
{
@@ -252,7 +252,7 @@ static void write_fields(FILE *h, var_list_t *fields)
default:
;
}
- write_type_def_or_decl(h, v->declspec.type, TRUE, name);
+ write_type_def_or_decl(h, &v->declspec, TRUE, name);
fprintf(h, ";\n");
}
}
@@ -295,8 +295,15 @@ static void write_pointer_left(FILE *h, type_t *ref)
}
void write_type_left(FILE *h, type_t *t, enum name_type name_type, int declonly)
+{
+ decl_spec_t ds;
+ write_declspec_left(h, init_declspec(&ds, t), name_type, declonly);
+}
+
+void write_declspec_left(FILE* h, const decl_spec_t *ds, enum name_type name_type, int declonly)
{
const char *name;
+ type_t *t = ds->type;
if (!h) return;
@@ -351,7 +358,7 @@ void write_type_left(FILE *h, type_t *t, enum name_type name_type, int declonly)
break;
case TYPE_POINTER:
{
- write_type_left(h, type_pointer_get_ref_type(t), name_type, declonly);
+ write_declspec_left(h, type_pointer_get_ref(t), name_type, declonly);
write_pointer_left(h, type_pointer_get_ref_type(t));
if (is_attr(t->attrs, ATTR_CONST)) fprintf(h, "const ");
break;
@@ -361,7 +368,7 @@ 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_type(t), name_type, declonly);
+ write_declspec_left(h, type_array_get_element(t), name_type, declonly);
if (type_array_is_decl_as_ptr(t))
write_pointer_left(h, type_array_get_element_type(t));
}
@@ -485,8 +492,9 @@ void write_type_right(FILE *h, type_t *t, int is_field)
}
}
-static void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const char *name)
+static void write_type_v(FILE *h, const decl_spec_t *ds, int is_field, int declonly, const char *name)
{
+ type_t *t = ds->type;
type_t *pt = NULL;
int ptr_level = 0;
@@ -501,14 +509,14 @@ static void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const c
const char *callconv = get_attrp(pt->attrs, ATTR_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), NAME_DEFAULT, declonly);
+ write_declspec_left(h, type_function_get_retdeclspec(pt), NAME_DEFAULT, declonly);
fputc(' ', h);
if (ptr_level) fputc('(', h);
if (callconv) fprintf(h, "%s ", callconv);
for (i = 0; i < ptr_level; i++)
fputc('*', h);
} else
- write_type_left(h, t, NAME_DEFAULT, declonly);
+ write_declspec_left(h, ds, NAME_DEFAULT, declonly);
}
if (name) fprintf(h, "%s%s", !t || needs_space_after(t) ? " " : "", name );
@@ -529,9 +537,9 @@ static void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const c
}
}
-static 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, const decl_spec_t *ds, int field, const char *name)
{
- write_type_v(f, t, field, FALSE, name);
+ write_type_v(f, ds, field, FALSE, name);
}
static void write_type_definition(FILE *f, type_t *t)
@@ -560,12 +568,18 @@ static void write_type_definition(FILE *f, type_t *t)
void write_type_decl(FILE *f, type_t *t, const char *name)
{
- write_type_v(f, t, FALSE, TRUE, name);
+ decl_spec_t ds;
+ write_declspec_decl(f, init_declspec(&ds, t), name);
+}
+
+void write_declspec_decl(FILE *f, const decl_spec_t *ds, const char *name)
+{
+ write_type_v(f, ds, FALSE, TRUE, name);
}
-void write_type_decl_left(FILE *f, type_t *t)
+void write_declspec_decl_left(FILE *f, const decl_spec_t *ds)
{
- write_type_left(f, t, NAME_DEFAULT, TRUE);
+ write_declspec_left(f, ds, NAME_DEFAULT, TRUE);
}
static int user_type_registered(const char *name)
@@ -789,7 +803,7 @@ static void write_generic_handle_routines(FILE *header)
static void write_typedef(FILE *header, type_t *type)
{
fprintf(header, "typedef ");
- write_type_def_or_decl(header, type_alias_get_aliasee_type(type), FALSE, type->name);
+ write_type_def_or_decl(header, type_alias_get_aliasee(type), FALSE, type->name);
fprintf(header, ";\n");
}
@@ -833,7 +847,7 @@ static void write_declaration(FILE *header, const var_t *v)
fprintf(header, "extern ");
break;
}
- write_type_def_or_decl(header, v->declspec.type, FALSE, v->name);
+ write_type_def_or_decl(header, &v->declspec, FALSE, v->name);
fprintf(header, ";\n\n");
}
}
@@ -1073,7 +1087,7 @@ void write_args(FILE *h, const var_list_t *args, const char *name, int method, i
}
else fprintf(h, ",");
}
- write_type_decl(h, arg->declspec.type, arg->name);
+ write_declspec_decl(h, &arg->declspec, arg->name);
if (method == 2) {
const expr_t *expr = get_attrp(arg->attrs, ATTR_DEFAULTVALUE);
if (expr) {
@@ -1125,11 +1139,11 @@ static void write_cpp_method_def(FILE *header, const type_t *iface)
indent(header, 0);
fprintf(header, "virtual ");
- write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
+ write_declspec_decl_left(header, type_function_get_retdeclspec(func->declspec.type));
fprintf(header, "* %s %s(\n", callconv, get_name(func));
++indentation;
indent(header, 0);
- write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
+ write_declspec_decl_left(header, type_function_get_retdeclspec(func->declspec.type));
fprintf(header, " *__ret");
--indentation;
if (args) {
@@ -1139,7 +1153,7 @@ static void write_cpp_method_def(FILE *header, const type_t *iface)
fprintf(header, ") = 0;\n");
indent(header, 0);
- write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
+ write_declspec_decl_left(header, type_function_get_retdeclspec(func->declspec.type));
fprintf(header, " %s %s(\n", callconv, get_name(func));
write_args(header, args, iface->name, 2, TRUE);
fprintf(header, ")\n");
@@ -1147,7 +1161,7 @@ static void write_cpp_method_def(FILE *header, const type_t *iface)
fprintf(header, "{\n");
++indentation;
indent(header, 0);
- write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
+ write_declspec_decl_left(header, type_function_get_retdeclspec(func->declspec.type));
fprintf(header, " __ret;\n");
indent(header, 0);
fprintf(header, "return *%s(&__ret", get_name(func));
@@ -1164,7 +1178,7 @@ static void write_cpp_method_def(FILE *header, const type_t *iface)
indent(header, 0);
fprintf(header, "virtual ");
- write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
+ write_declspec_decl_left(header, type_function_get_retdeclspec(func->declspec.type));
fprintf(header, " %s %s(\n", callconv, get_name(func));
write_args(header, args, iface->name, 2, TRUE);
fprintf(header, ") = 0;\n");
@@ -1201,7 +1215,7 @@ static void write_inline_wrappers(FILE *header, const type_t *iface, const type_
const var_t *arg;
fprintf(header, "static FORCEINLINE ");
- write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
+ write_declspec_decl_left(header, type_function_get_retdeclspec(func->declspec.type));
fprintf(header, " %s_%s(", name, get_name(func));
write_args(header, type_function_get_args(func->declspec.type), name, 1, FALSE);
fprintf(header, ") {\n");
@@ -1213,7 +1227,7 @@ static void write_inline_wrappers(FILE *header, const type_t *iface, const type_
get_vtbl_entry_name(iface, func));
} else {
indent(header, 0);
- write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
+ write_declspec_decl_left(header, type_function_get_retdeclspec(func->declspec.type));
fprintf(header, " __ret;\n");
indent(header, 0);
fprintf(header, "return *This->lpVtbl->%s(This,&__ret", get_vtbl_entry_name(iface, func));
@@ -1248,7 +1262,7 @@ static void do_write_c_method_def(FILE *header, const type_t *iface, const char
const char *callconv = get_attrp(func->declspec.type->attrs, ATTR_CALLCONV);
if (!callconv) callconv = "STDMETHODCALLTYPE";
indent(header, 0);
- write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
+ write_declspec_decl_left(header, type_function_get_retdeclspec(func->declspec.type));
if (is_aggregate_return(func))
fprintf(header, " *");
if (is_inherited_method(iface, func))
@@ -1261,7 +1275,7 @@ static void do_write_c_method_def(FILE *header, const type_t *iface, const char
if (is_aggregate_return(func)) {
fprintf(header, ",\n");
indent(header, 0);
- write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
+ write_declspec_decl_left(header, type_function_get_retdeclspec(func->declspec.type));
fprintf(header, " *__ret");
}
--indentation;
@@ -1297,7 +1311,7 @@ static void write_method_proto(FILE *header, const type_t *iface)
const char *callconv = get_attrp(func->declspec.type->attrs, ATTR_CALLCONV);
if (!callconv) callconv = "STDMETHODCALLTYPE";
/* proxy prototype */
- write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
+ write_declspec_decl_left(header, type_function_get_retdeclspec(func->declspec.type));
fprintf(header, " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func));
write_args(header, type_function_get_args(func->declspec.type), iface->name, 1, TRUE);
fprintf(header, ");\n");
@@ -1332,7 +1346,7 @@ static void write_locals(FILE *fp, const type_t *iface, int body)
if (&stmt2->entry != type_iface_get_stmts(iface)) {
const var_t *m = stmt2->u.var;
/* proxy prototype - use local prototype */
- write_type_decl_left(fp, type_function_get_rettype(m->declspec.type));
+ write_declspec_decl_left(fp, type_function_get_retdeclspec(m->declspec.type));
fprintf(fp, " CALLBACK %s_%s_Proxy(\n", iface->name, get_name(m));
write_args(fp, type_function_get_args(m->declspec.type), iface->name, 1, TRUE);
fprintf(fp, ")");
@@ -1354,7 +1368,7 @@ static void write_locals(FILE *fp, const type_t *iface, int body)
else
fprintf(fp, ";\n");
/* stub prototype - use remotable prototype */
- write_type_decl_left(fp, type_function_get_rettype(func->declspec.type));
+ write_declspec_decl_left(fp, type_function_get_retdeclspec(func->declspec.type));
fprintf(fp, " __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(m));
write_args(fp, type_function_get_args(func->declspec.type), iface->name, 1, TRUE);
fprintf(fp, ")");
@@ -1406,7 +1420,7 @@ static void write_function_proto(FILE *header, const type_t *iface, const var_t
if (!callconv) callconv = "__cdecl";
/* FIXME: do we need to handle call_as? */
- write_type_decl_left(header, type_function_get_rettype(fun->declspec.type));
+ write_declspec_decl_left(header, type_function_get_retdeclspec(fun->declspec.type));
fprintf(header, " %s ", callconv);
fprintf(header, "%s%s(\n", prefix, get_name(fun));
if (type_function_get_args(fun->declspec.type))
@@ -1536,7 +1550,7 @@ static void write_rpc_interface_start(FILE *header, const type_t *iface)
if (var)
{
fprintf(header, "extern ");
- write_type_decl( header, var->declspec.type, var->name );
+ write_declspec_decl( header, &var->declspec, var->name );
fprintf(header, ";\n");
}
if (old_names)
diff --git a/tools/widl/header.h b/tools/widl/header.h
index 94b90a391f..0e62f77c8f 100644
--- a/tools/widl/header.h
+++ b/tools/widl/header.h
@@ -29,10 +29,12 @@ extern int is_attr(const attr_list_t *list, enum attr_type t);
extern void *get_attrp(const attr_list_t *list, enum attr_type t);
extern unsigned int get_attrv(const attr_list_t *list, enum attr_type t);
extern const char* get_name(const var_t *v);
+extern void write_declspec_left(FILE *h, const decl_spec_t *ds, enum name_type name_type, int declonly);
extern void write_type_left(FILE *h, type_t *t, enum name_type name_type, int declonly);
extern void write_type_right(FILE *h, type_t *t, int is_field);
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_declspec_decl(FILE *f, const decl_spec_t *ds, const char *name);
+extern void write_declspec_decl_left(FILE *f, const decl_spec_t *ds);
extern unsigned int get_context_handle_offset( const type_t *type );
extern unsigned int get_generic_handle_offset( const type_t *type );
extern int needs_space_after(type_t *t);
diff --git a/tools/widl/proxy.c b/tools/widl/proxy.c
index 5b5a092c83..9f7fd530b1 100644
--- a/tools/widl/proxy.c
+++ b/tools/widl/proxy.c
@@ -202,7 +202,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
if (is_interpreted_func( iface, func ))
{
if (get_stub_mode() == MODE_Oif && !is_callas( func->attrs )) return;
- write_type_decl_left(proxy, retval->declspec.type);
+ write_declspec_decl_left(proxy, &retval->declspec);
print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func));
write_args(proxy, args, iface->name, 1, TRUE);
print_proxy( ")\n");
@@ -219,7 +219,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
print_proxy( "}\n");
print_proxy( "\n");
- write_type_decl_left(proxy, retval->declspec.type);
+ write_declspec_decl_left(proxy, &retval->declspec);
print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func));
write_args(proxy, args, iface->name, 1, TRUE);
print_proxy( ")\n");
@@ -229,7 +229,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
/* local variables */
if (has_ret) {
print_proxy( "%s", "" );
- write_type_decl(proxy, retval->declspec.type, retval->name);
+ write_declspec_decl(proxy, &retval->declspec, retval->name);
fprintf( proxy, ";\n" );
}
print_proxy( "RPC_MESSAGE _RpcMessage;\n" );
diff --git a/tools/widl/server.c b/tools/widl/server.c
index 6ce3db5e1c..fa457af2f3 100644
--- a/tools/widl/server.c
+++ b/tools/widl/server.c
@@ -55,7 +55,8 @@ static void write_function_stub(const type_t *iface, const var_t *func, unsigned
unsigned char explicit_fc, implicit_fc;
int has_full_pointer = is_full_pointer_function(func);
const var_t *handle_var = get_func_handle_var( iface, func, &explicit_fc, &implicit_fc );
- type_t *ret_type = type_function_get_rettype(func->declspec.type);
+ const decl_spec_t *ret_declspec = type_function_get_retdeclspec(func->declspec.type);
+ type_t *ret_type = ret_declspec->type;
if (is_interpreted_func( iface, func )) return;
@@ -159,7 +160,7 @@ static void write_function_stub(const type_t *iface, const var_t *func, unsigned
{
print_server("__frame->_RetVal = NDRSContextUnmarshall((char*)0, _pRpcMessage->DataRepresentation);\n");
print_server("*((");
- write_type_decl(server, ret_type, NULL);
+ write_declspec_decl(server, ret_declspec, NULL);
fprintf(server, "*)NDRSContextValue(__frame->_RetVal)) = ");
}
else
@@ -185,7 +186,7 @@ static void write_function_stub(const type_t *iface, const var_t *func, unsigned
* be direct, otherwise it is a pointer */
const char *ch_ptr = is_aliaschain_attr(var->declspec.type, ATTR_CONTEXTHANDLE) ? "*" : "";
print_server("(");
- write_type_decl_left(server, var->declspec.type);
+ write_declspec_decl_left(server, &var->declspec);
fprintf(server, ")%sNDRSContextValue(__frame->%s)", ch_ptr, var->name);
}
else
diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index ddf555cd9b..eebb99f0ef 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -85,14 +85,14 @@ static const unsigned short IsSimpleRef = 0x0100;
static unsigned int field_memsize(const type_t *type, unsigned int *offset);
static unsigned int fields_memsize(const var_list_t *fields, unsigned int *align);
-static unsigned int write_array_tfs(FILE *file, const attr_list_t *attrs, type_t *type,
+static unsigned int write_array_tfs(FILE *file, const attr_list_t *attrs, const decl_spec_t *declspec,
const char *name, unsigned int *typestring_offset);
-static unsigned int write_struct_tfs(FILE *file, type_t *type, const char *name, unsigned int *tfsoff);
-static int write_embedded_types(FILE *file, const attr_list_t *attrs, type_t *type,
+static unsigned int write_struct_tfs(FILE *file, const decl_spec_t *declspec, const char *name, unsigned int *tfsoff);
+static int write_embedded_types(FILE *file, const attr_list_t *attrs, const decl_spec_t *declspec,
const char *name, int write_ptr, unsigned int *tfsoff);
static const var_t *find_array_or_string_in_struct(const type_t *type);
static unsigned int write_string_tfs(FILE *file, const attr_list_t *attrs,
- type_t *type, enum type_context context,
+ const decl_spec_t *declspec, enum type_context context,
const char *name, unsigned int *typestring_offset);
static unsigned int get_required_buffer_size_type( const type_t *type, const char *name,
const attr_list_t *attrs, int toplevel_param,
@@ -2216,22 +2216,23 @@ static unsigned int write_simple_pointer(FILE *file, const attr_list_t *attrs,
return 4;
}
-static void print_start_tfs_comment(FILE *file, type_t *t, unsigned int tfsoff)
+static void print_start_tfs_comment(FILE *file, const decl_spec_t *ds, unsigned int tfsoff)
{
print_file(file, 0, "/* %u (", tfsoff);
- write_type_decl(file, t, NULL);
+ write_declspec_decl(file, ds, NULL);
print_file(file, 0, ") */\n");
}
static unsigned int write_pointer_tfs(FILE *file, const attr_list_t *attrs,
- type_t *type, unsigned int ref_offset,
+ const decl_spec_t *declspec, unsigned int ref_offset,
enum type_context context,
unsigned int *typestring_offset)
{
unsigned int offset = *typestring_offset;
+ type_t *type = declspec->type;
type_t *ref = type_pointer_get_ref_type(type);
- print_start_tfs_comment(file, type, offset);
+ print_start_tfs_comment(file, declspec, offset);
update_tfsoff(type, offset, file);
switch (typegen_detect_type(ref, attrs, TDT_ALL_TYPES))
@@ -2274,10 +2275,11 @@ static int user_type_has_variable_size(const type_t *t)
return FALSE;
}
-static unsigned int write_user_tfs(FILE *file, type_t *type, unsigned int *tfsoff)
+static unsigned int write_user_tfs(FILE *file, const decl_spec_t *declspec, unsigned int *tfsoff)
{
unsigned int start, absoff, flags;
const char *name = NULL;
+ type_t *type = declspec->type;
type_t *utype = get_user_type(type, &name);
unsigned int usize = type_memsize(utype);
unsigned int ualign = type_buffer_alignment(utype);
@@ -2295,6 +2297,7 @@ static unsigned int write_user_tfs(FILE *file, type_t *type, unsigned int *tfsof
type_get_type(utype) == TYPE_ENUM)
{
unsigned char fc;
+ decl_spec_t ds;
if (type_get_type(utype) == TYPE_ENUM)
fc = get_enum_fc(utype);
@@ -2302,7 +2305,7 @@ static unsigned int write_user_tfs(FILE *file, type_t *type, unsigned int *tfsof
fc = get_basic_fc(utype);
absoff = *tfsoff;
- print_start_tfs_comment(file, utype, absoff);
+ print_start_tfs_comment(file, init_declspec(&ds, utype), absoff);
print_file(file, 2, "0x%x,\t/* %s */\n", fc, string_of_type(fc));
print_file(file, 2, "0x5c,\t/* FC_PAD */\n");
*tfsoff += 2;
@@ -2310,7 +2313,10 @@ static unsigned int write_user_tfs(FILE *file, type_t *type, unsigned int *tfsof
else
{
if (!processed(utype))
- write_embedded_types(file, NULL, utype, utype->name, TRUE, tfsoff);
+ {
+ decl_spec_t ds;
+ write_embedded_types(file, NULL, init_declspec(&ds, utype), utype->name, TRUE, tfsoff);
+ }
absoff = utype->typestring_offset;
}
@@ -2323,7 +2329,7 @@ static unsigned int write_user_tfs(FILE *file, type_t *type, unsigned int *tfsof
start = *tfsoff;
update_tfsoff(type, start, file);
- print_start_tfs_comment(file, type, start);
+ print_start_tfs_comment(file, declspec, start);
print_file(file, 2, "0x%x,\t/* FC_USER_MARSHAL */\n", FC_USER_MARSHAL);
print_file(file, 2, "0x%x,\t/* Alignment= %d, Flags= %02x */\n",
flags | (ualign - 1), ualign - 1, flags);
@@ -2380,7 +2386,8 @@ static void write_member_type(FILE *file, const type_t *cont,
static void write_array_element_type(FILE *file, const attr_list_t *attrs, const type_t *type,
int cont_is_complex, unsigned int *tfsoff)
{
- type_t *elem = type_array_get_element_type(type);
+ const decl_spec_t *element = type_array_get_element(type);
+ type_t *elem = element->type;
if (!is_embedded_complex(elem) && is_ptr(elem))
{
@@ -2394,7 +2401,7 @@ static void write_array_element_type(FILE *file, const attr_list_t *attrs, const
}
if (cont_is_complex && is_string_type(attrs, elem))
{
- write_string_tfs(file, NULL, elem, TYPE_CONTEXT_CONTAINER, NULL, tfsoff);
+ write_string_tfs(file, NULL, element, TYPE_CONTEXT_CONTAINER, NULL, tfsoff);
return;
}
if (!is_string_type(NULL, elem) &&
@@ -2449,10 +2456,11 @@ static void write_descriptors(FILE *file, type_t *type, unsigned int *tfsoff)
}
static int write_pointer_description_offsets(
- FILE *file, const attr_list_t *attrs, type_t *type,
+ FILE *file, const attr_list_t *attrs, const decl_spec_t *declspec,
unsigned int *offset_in_memory, unsigned int *offset_in_buffer,
unsigned int *typestring_offset)
{
+ type_t *type = declspec->type;
int written = 0;
if ((is_ptr(type) && type_get_type(type_pointer_get_ref_type(type)) != TYPE_INTERFACE) ||
@@ -2483,7 +2491,7 @@ static int write_pointer_description_offsets(
type_t *ref = type_pointer_get_ref_type(type);
if (is_string_type(attrs, type))
- write_string_tfs(file, attrs, type, TYPE_CONTEXT_CONTAINER, NULL, typestring_offset);
+ write_string_tfs(file, attrs, declspec, TYPE_CONTEXT_CONTAINER, NULL, typestring_offset);
else if (processed(ref))
write_nonsimple_pointer(file, attrs, type, TYPE_CONTEXT_CONTAINER,
ref->typestring_offset, typestring_offset);
@@ -2508,7 +2516,7 @@ static int write_pointer_description_offsets(
if (is_array(type))
{
return write_pointer_description_offsets(
- file, attrs, type_array_get_element_type(type), offset_in_memory,
+ file, attrs, type_array_get_element(type), offset_in_memory,
offset_in_buffer, typestring_offset);
}
else if (is_non_complex_struct(type))
@@ -2527,7 +2535,7 @@ static int write_pointer_description_offsets(
*offset_in_buffer += padding;
}
written += write_pointer_description_offsets(
- file, v->attrs, v->declspec.type, offset_in_memory, offset_in_buffer,
+ file, v->attrs, &v->declspec, offset_in_memory, offset_in_buffer,
typestring_offset);
}
}
@@ -2547,10 +2555,11 @@ static int write_pointer_description_offsets(
}
static int write_no_repeat_pointer_descriptions(
- FILE *file, const attr_list_t *attrs, type_t *type,
+ FILE *file, const attr_list_t *attrs, const decl_spec_t *declspec,
unsigned int *offset_in_memory, unsigned int *offset_in_buffer,
unsigned int *typestring_offset)
{
+ type_t *type = declspec->type;
int written = 0;
if (is_ptr(type) ||
@@ -2560,7 +2569,7 @@ static int write_no_repeat_pointer_descriptions(
print_file(file, 2, "0x%02x, /* FC_PAD */\n", FC_PAD);
*typestring_offset += 2;
- return write_pointer_description_offsets(file, attrs, type,
+ return write_pointer_description_offsets(file, attrs, declspec,
offset_in_memory, offset_in_buffer, typestring_offset);
}
@@ -2579,7 +2588,7 @@ static int write_no_repeat_pointer_descriptions(
*offset_in_buffer += padding;
}
written += write_no_repeat_pointer_descriptions(
- file, v->attrs, v->declspec.type,
+ file, v->attrs, &v->declspec,
offset_in_memory, offset_in_buffer, typestring_offset);
}
}
@@ -2598,10 +2607,11 @@ static int write_no_repeat_pointer_descriptions(
/* Note: if file is NULL return value is number of pointers to write, else
* it is the number of type format characters written */
static int write_fixed_array_pointer_descriptions(
- FILE *file, const attr_list_t *attrs, type_t *type,
+ FILE *file, const attr_list_t *attrs, const decl_spec_t *declspec,
unsigned int *offset_in_memory, unsigned int *offset_in_buffer,
unsigned int *typestring_offset)
{
+ type_t *type = declspec->type;
int pointer_count = 0;
if (type_get_type(type) == TYPE_ARRAY &&
@@ -2611,7 +2621,7 @@ static int write_fixed_array_pointer_descriptions(
/* unfortunately, this needs to be done in two passes to avoid
* writing out redundant FC_FIXED_REPEAT descriptions */
pointer_count = write_pointer_description_offsets(
- NULL, attrs, type_array_get_element_type(type), NULL, NULL, &temp);
+ NULL, attrs, type_array_get_element(type), NULL, NULL, &temp);
if (pointer_count > 0)
{
unsigned int increment_size;
@@ -2629,7 +2639,7 @@ static int write_fixed_array_pointer_descriptions(
*typestring_offset += 10;
pointer_count = write_pointer_description_offsets(
- file, attrs, type, &offset_of_array_pointer_mem,
+ file, attrs, declspec, &offset_of_array_pointer_mem,
&offset_of_array_pointer_buf, typestring_offset);
}
}
@@ -2648,7 +2658,7 @@ static int write_fixed_array_pointer_descriptions(
*offset_in_buffer += padding;
}
pointer_count += write_fixed_array_pointer_descriptions(
- file, v->attrs, v->declspec.type, offset_in_memory, offset_in_buffer,
+ file, v->attrs, &v->declspec, offset_in_memory, offset_in_buffer,
typestring_offset);
}
}
@@ -2682,7 +2692,7 @@ static int write_conformant_array_pointer_descriptions(
/* unfortunately, this needs to be done in two passes to avoid
* writing out redundant FC_VARIABLE_REPEAT descriptions */
pointer_count = write_pointer_description_offsets(
- NULL, attrs, type_array_get_element_type(type), NULL, NULL, &temp);
+ NULL, attrs, type_array_get_element(type), NULL, NULL, &temp);
if (pointer_count > 0)
{
unsigned int increment_size;
@@ -2702,7 +2712,7 @@ static int write_conformant_array_pointer_descriptions(
*typestring_offset += 8;
pointer_count = write_pointer_description_offsets(
- file, attrs, type_array_get_element_type(type),
+ file, attrs, type_array_get_element(type),
&offset_of_array_pointer_mem, &offset_of_array_pointer_buf,
typestring_offset);
}
@@ -2726,7 +2736,7 @@ static int write_varying_array_pointer_descriptions(
/* unfortunately, this needs to be done in two passes to avoid
* writing out redundant FC_VARIABLE_REPEAT descriptions */
pointer_count = write_pointer_description_offsets(
- NULL, attrs, type_array_get_element_type(type), NULL, NULL, &temp);
+ NULL, attrs, type_array_get_element(type), NULL, NULL, &temp);
if (pointer_count > 0)
{
unsigned int increment_size;
@@ -2744,7 +2754,7 @@ static int write_varying_array_pointer_descriptions(
*typestring_offset += 8;
pointer_count = write_pointer_description_offsets(
- file, attrs, type_array_get_element_type(type), offset_in_memory,
+ file, attrs, type_array_get_element(type), offset_in_memory,
offset_in_buffer, typestring_offset);
}
}
@@ -2789,9 +2799,10 @@ static int write_varying_array_pointer_descriptions(
return pointer_count;
}
-static void write_pointer_description(FILE *file, const attr_list_t *attrs, type_t *type,
+static void write_pointer_description(FILE *file, const attr_list_t *attrs, const decl_spec_t *declspec,
unsigned int *typestring_offset)
{
+ type_t *type = declspec->type;
unsigned int offset_in_buffer;
unsigned int offset_in_memory;
@@ -2802,7 +2813,7 @@ static void write_pointer_description(FILE *file, const attr_list_t *attrs, type
offset_in_memory = 0;
offset_in_buffer = 0;
write_no_repeat_pointer_descriptions(
- file, NULL, type,
+ file, NULL, declspec,
&offset_in_memory, &offset_in_buffer, typestring_offset);
}
@@ -2810,7 +2821,7 @@ static void write_pointer_description(FILE *file, const attr_list_t *attrs, type
offset_in_memory = 0;
offset_in_buffer = 0;
write_fixed_array_pointer_descriptions(
- file, NULL, type,
+ file, NULL, declspec,
&offset_in_memory, &offset_in_buffer, typestring_offset);
/* pass 3: search for pointers in conformant only arrays (but don't descend
@@ -2836,9 +2847,10 @@ static void write_pointer_description(FILE *file, const attr_list_t *attrs, type
}
static unsigned int write_string_tfs(FILE *file, const attr_list_t *attrs,
- type_t *type, enum type_context context,
+ const decl_spec_t *declspec, enum type_context context,
const char *name, unsigned int *typestring_offset)
{
+ type_t *type = declspec->type;
unsigned int start_offset;
unsigned char rtype;
type_t *elem_type;
@@ -2852,7 +2864,7 @@ static unsigned int write_string_tfs(FILE *file, const attr_list_t *attrs,
int pointer_type = get_pointer_fc_context(type, attrs, context);
if (!pointer_type)
pointer_type = FC_RP;
- print_start_tfs_comment(file, type, *typestring_offset);
+ print_start_tfs_comment(file, declspec, *typestring_offset);
print_file(file, 2,"0x%x, 0x%x,\t/* %s%s */\n",
pointer_type, flag, string_of_type(pointer_type),
flag ? " [simple_pointer]" : "");
@@ -2871,7 +2883,7 @@ static unsigned int write_string_tfs(FILE *file, const attr_list_t *attrs,
elem_type = type_pointer_get_ref_type(type);
if (type_get_type(elem_type) == TYPE_POINTER && is_array(type))
- return write_array_tfs(file, attrs, type, name, typestring_offset);
+ return write_array_tfs(file, attrs, declspec, name, typestring_offset);
if (type_get_type(elem_type) != TYPE_BASIC)
{
@@ -2945,9 +2957,10 @@ static unsigned int write_string_tfs(FILE *file, const attr_list_t *attrs,
}
}
-static unsigned int write_array_tfs(FILE *file, const attr_list_t *attrs, type_t *type,
+static unsigned int write_array_tfs(FILE *file, const attr_list_t *attrs, const decl_spec_t *declspec,
const char *name, unsigned int *typestring_offset)
{
+ type_t *type = declspec->type;
const expr_t *length_is = type_array_get_variance(type);
const expr_t *size_is = type_array_get_conformance(type);
unsigned int align;
@@ -2960,7 +2973,7 @@ static unsigned int write_array_tfs(FILE *file, const attr_list_t *attrs, type_t
: 0;
if (!is_string_type(attrs, type_array_get_element_type(type)))
- write_embedded_types(file, attrs, type_array_get_element_type(type), name, FALSE, typestring_offset);
+ write_embedded_types(file, attrs, type_array_get_element(type), name, FALSE, typestring_offset);
size = type_memsize(is_conformant_array(type) ? type_array_get_element_type(type) : type);
align = type_buffer_alignment(is_conformant_array(type) ? type_array_get_element_type(type) : type);
@@ -2968,7 +2981,7 @@ static unsigned int write_array_tfs(FILE *file, const attr_list_t *attrs, type_t
start_offset = *typestring_offset;
update_tfsoff(type, start_offset, file);
- print_start_tfs_comment(file, type, start_offset);
+ print_start_tfs_comment(file, declspec, start_offset);
print_file(file, 2, "0x%02x,\t/* %s */\n", fc, string_of_type(fc));
print_file(file, 2, "0x%x,\t/* %d */\n", align - 1, align - 1);
*typestring_offset += 2;
@@ -3023,7 +3036,7 @@ static unsigned int write_array_tfs(FILE *file, const attr_list_t *attrs, type_t
print_file(file, 2, "0x%x,\t/* FC_PP */\n", FC_PP);
print_file(file, 2, "0x%x,\t/* FC_PAD */\n", FC_PAD);
*typestring_offset += 2;
- write_pointer_description(file, is_string_type(attrs, type) ? attrs : NULL, type, typestring_offset);
+ write_pointer_description(file, is_string_type(attrs, type) ? attrs : NULL, declspec, typestring_offset);
print_file(file, 2, "0x%x,\t/* FC_END */\n", FC_END);
*typestring_offset += 1;
}
@@ -3130,9 +3143,10 @@ static void write_struct_members(FILE *file, const type_t *type,
write_end(file, typestring_offset);
}
-static unsigned int write_struct_tfs(FILE *file, type_t *type,
+static unsigned int write_struct_tfs(FILE *file, const decl_spec_t *declspec,
const char *name, unsigned int *tfsoff)
{
+ type_t *type = declspec->type;
const type_t *save_current_structure = current_structure;
unsigned int total_size;
const var_t *array;
@@ -3155,15 +3169,15 @@ static unsigned int write_struct_tfs(FILE *file, type_t *type,
name, USHRT_MAX, total_size - USHRT_MAX);
if (fields) LIST_FOR_EACH_ENTRY(f, fields, var_t, entry)
- write_embedded_types(file, f->attrs, f->declspec.type, f->name, FALSE, tfsoff);
+ write_embedded_types(file, f->attrs, &f->declspec, f->name, FALSE, tfsoff);
array = find_array_or_string_in_struct(type);
if (array && !processed(array->declspec.type))
{
if(is_string_type(array->attrs, array->declspec.type))
- write_string_tfs(file, array->attrs, array->declspec.type, TYPE_CONTEXT_CONTAINER, array->name, tfsoff);
+ write_string_tfs(file, array->attrs, &array->declspec, TYPE_CONTEXT_CONTAINER, array->name, tfsoff);
else
- write_array_tfs(file, array->attrs, array->declspec.type, array->name, tfsoff);
+ write_array_tfs(file, array->attrs, &array->declspec, array->name, tfsoff);
}
corroff = *tfsoff;
@@ -3171,7 +3185,7 @@ static unsigned int write_struct_tfs(FILE *file, type_t *type,
start_offset = *tfsoff;
update_tfsoff(type, start_offset, file);
- print_start_tfs_comment(file, type, start_offset);
+ print_start_tfs_comment(file, declspec, start_offset);
print_file(file, 2, "0x%x,\t/* %s */\n", fc, string_of_type(fc));
print_file(file, 2, "0x%x,\t/* %d */\n", align - 1, align - 1);
print_file(file, 2, "NdrFcShort(0x%hx),\t/* %d */\n", (unsigned short)total_size, total_size);
@@ -3210,7 +3224,7 @@ static unsigned int write_struct_tfs(FILE *file, type_t *type,
print_file(file, 2, "0x%x,\t/* FC_PP */\n", FC_PP);
print_file(file, 2, "0x%x,\t/* FC_PAD */\n", FC_PAD);
*tfsoff += 2;
- write_pointer_description(file, NULL, type, tfsoff);
+ write_pointer_description(file, NULL, declspec, tfsoff);
print_file(file, 2, "0x%x,\t/* FC_END */\n", FC_END);
*tfsoff += 1;
}
@@ -3225,14 +3239,15 @@ static unsigned int write_struct_tfs(FILE *file, type_t *type,
type->ptrdesc = *tfsoff;
if (fields) LIST_FOR_EACH_ENTRY(f, fields, const var_t, entry)
{
- type_t *ft = f->declspec.type;
+ const decl_spec_t *fds = &f->declspec;
+ type_t *ft = fds->type;
switch (typegen_detect_type(ft, f->attrs, TDT_IGNORE_STRINGS))
{
case TGT_POINTER:
if (is_string_type(f->attrs, ft))
- write_string_tfs(file, f->attrs, ft, TYPE_CONTEXT_CONTAINER, f->name, tfsoff);
+ write_string_tfs(file, f->attrs, fds, TYPE_CONTEXT_CONTAINER, f->name, tfsoff);
else
- write_pointer_tfs(file, f->attrs, ft,
+ write_pointer_tfs(file, f->attrs, fds,
type_pointer_get_ref_type(ft)->typestring_offset,
TYPE_CONTEXT_CONTAINER, tfsoff);
break;
@@ -3295,8 +3310,9 @@ static void write_branch_type(FILE *file, const type_t *t, unsigned int *tfsoff)
}
static unsigned int write_union_tfs(FILE *file, const attr_list_t *attrs,
- type_t *type, unsigned int *tfsoff)
+ const decl_spec_t *declspec, unsigned int *tfsoff)
{
+ type_t* type = declspec->type;
unsigned int start_offset;
unsigned int size;
var_list_t *fields;
@@ -3322,12 +3338,12 @@ static unsigned int write_union_tfs(FILE *file, const attr_list_t *attrs,
if (cases)
nbranch += list_count(cases);
if (f->declspec.type)
- write_embedded_types(file, f->attrs, f->declspec.type, f->name, TRUE, tfsoff);
+ write_embedded_types(file, f->attrs, &f->declspec, f->name, TRUE, tfsoff);
}
start_offset = *tfsoff;
update_tfsoff(type, start_offset, file);
- print_start_tfs_comment(file, type, start_offset);
+ print_start_tfs_comment(file, declspec, start_offset);
if (type_get_type(type) == TYPE_ENCAPSULATED_UNION)
{
const var_t *sv = type_union_get_switch_value(type);
@@ -3460,16 +3476,17 @@ static unsigned int write_union_tfs(FILE *file, const attr_list_t *attrs,
return start_offset;
}
-static unsigned int write_ip_tfs(FILE *file, const attr_list_t *attrs, type_t *type,
+static unsigned int write_ip_tfs(FILE *file, const attr_list_t *attrs, const decl_spec_t *declspec,
unsigned int *typeformat_offset)
{
unsigned int i;
+ type_t *type = declspec->type;
unsigned int start_offset = *typeformat_offset;
expr_t *iid = get_attrp(attrs, ATTR_IIDIS);
if (!iid && processed(type)) return type->typestring_offset;
- print_start_tfs_comment(file, type, start_offset);
+ print_start_tfs_comment(file, declspec, start_offset);
update_tfsoff(type, start_offset, file);
if (iid)
@@ -3505,14 +3522,15 @@ static unsigned int write_ip_tfs(FILE *file, const attr_list_t *attrs, type_t *t
static unsigned int write_contexthandle_tfs(FILE *file,
const attr_list_t *attrs,
- type_t *type,
+ const decl_spec_t *declspec,
enum type_context context,
unsigned int *typeformat_offset)
{
+ type_t *type = declspec->type;
unsigned int start_offset = *typeformat_offset;
unsigned char flags = get_contexthandle_flags( current_iface, attrs, type, context == TYPE_CONTEXT_RETVAL );
- print_start_tfs_comment(file, type, start_offset);
+ print_start_tfs_comment(file, declspec, start_offset);
if (flags & 0x80) /* via ptr */
{
@@ -3580,21 +3598,22 @@ static unsigned int write_range_tfs(FILE *file, const attr_list_t *attrs,
}
static unsigned int write_type_tfs(FILE *file, const attr_list_t *attrs,
- type_t *type, const char *name,
+ const decl_spec_t *declspec, const char *name,
enum type_context context,
unsigned int *typeformat_offset)
{
unsigned int offset;
+ type_t *type = declspec->type;
switch (typegen_detect_type(type, attrs, TDT_ALL_TYPES))
{
case TGT_CTXT_HANDLE:
case TGT_CTXT_HANDLE_POINTER:
- return write_contexthandle_tfs(file, attrs, type, context, typeformat_offset);
+ return write_contexthandle_tfs(file, attrs, declspec, context, typeformat_offset);
case TGT_USER_TYPE:
- return write_user_tfs(file, type, typeformat_offset);
+ return write_user_tfs(file, declspec, typeformat_offset);
case TGT_STRING:
- return write_string_tfs(file, attrs, type, context, name, typeformat_offset);
+ return write_string_tfs(file, attrs, declspec, context, name, typeformat_offset);
case TGT_ARRAY:
{
unsigned int off;
@@ -3602,7 +3621,7 @@ static unsigned int write_type_tfs(FILE *file, const attr_list_t *attrs,
if ((context != TYPE_CONTEXT_CONTAINER &&
context != TYPE_CONTEXT_CONTAINER_NO_POINTERS) ||
!is_conformant_array(type) || type_array_is_decl_as_ptr(type))
- off = write_array_tfs(file, attrs, type, name, typeformat_offset);
+ off = write_array_tfs(file, attrs, declspec, name, typeformat_offset);
else
off = 0;
if (context != TYPE_CONTEXT_CONTAINER &&
@@ -3628,9 +3647,9 @@ static unsigned int write_type_tfs(FILE *file, const attr_list_t *attrs,
return off;
}
case TGT_STRUCT:
- return write_struct_tfs(file, type, name, typeformat_offset);
+ return write_struct_tfs(file, declspec, name, typeformat_offset);
case TGT_UNION:
- return write_union_tfs(file, attrs, type, typeformat_offset);
+ return write_union_tfs(file, attrs, declspec, typeformat_offset);
case TGT_ENUM:
case TGT_BASIC:
/* nothing to do */
@@ -3643,11 +3662,11 @@ static unsigned int write_type_tfs(FILE *file, const attr_list_t *attrs,
return write_range_tfs(file, attrs, type, range_list, typeformat_offset);
}
case TGT_IFACE_POINTER:
- return write_ip_tfs(file, attrs, type, typeformat_offset);
+ return write_ip_tfs(file, attrs, declspec, typeformat_offset);
case TGT_POINTER:
{
enum type_context ref_context;
- type_t *ref = type_pointer_get_ref_type(type);
+ const decl_spec_t *ref = type_pointer_get_ref(type);
if (context == TYPE_CONTEXT_TOPLEVELPARAM)
ref_context = TYPE_CONTEXT_PARAM;
@@ -3656,10 +3675,10 @@ static unsigned int write_type_tfs(FILE *file, const attr_list_t *attrs,
else
ref_context = context;
- if (is_string_type(attrs, ref))
+ if (is_string_type(attrs, ref->type))
{
if (context != TYPE_CONTEXT_CONTAINER_NO_POINTERS)
- write_pointer_tfs(file, attrs, type, *typeformat_offset + 4, context, typeformat_offset);
+ write_pointer_tfs(file, attrs, declspec, *typeformat_offset + 4, context, typeformat_offset);
offset = write_type_tfs(file, attrs, ref, name, ref_context, typeformat_offset);
if (context == TYPE_CONTEXT_CONTAINER_NO_POINTERS)
@@ -3667,11 +3686,11 @@ static unsigned int write_type_tfs(FILE *file, const attr_list_t *attrs,
return offset;
}
- offset = write_type_tfs( file, attrs, type_pointer_get_ref_type(type), name,
+ offset = write_type_tfs( file, attrs, type_pointer_get_ref(type), name,
ref_context, typeformat_offset);
if (context == TYPE_CONTEXT_CONTAINER_NO_POINTERS)
return 0;
- return write_pointer_tfs(file, attrs, type, offset, context, typeformat_offset);
+ return write_pointer_tfs(file, attrs, declspec, offset, context, typeformat_offset);
}
case TGT_INVALID:
break;
@@ -3680,10 +3699,10 @@ static unsigned int write_type_tfs(FILE *file, const attr_list_t *attrs,
return 0;
}
-static int write_embedded_types(FILE *file, const attr_list_t *attrs, type_t *type,
+static int write_embedded_types(FILE *file, const attr_list_t *attrs, const decl_spec_t *declspec,
const char *name, int write_ptr, unsigned int *tfsoff)
{
- return write_type_tfs(file, attrs, type, name, write_ptr ? TYPE_CONTEXT_CONTAINER : TYPE_CONTEXT_CONTAINER_NO_POINTERS, tfsoff);
+ return write_type_tfs(file, attrs, declspec, name, write_ptr ? TYPE_CONTEXT_CONTAINER : TYPE_CONTEXT_CONTAINER_NO_POINTERS, tfsoff);
}
static void process_tfs_iface(type_t *iface, FILE *file, int indent, unsigned int *offset)
@@ -3710,12 +3729,12 @@ static void process_tfs_iface(type_t *iface, FILE *file, int indent, unsigned in
var = type_function_get_retval(func->declspec.type);
if (!is_void(var->declspec.type))
- var->typestring_offset = write_type_tfs( file, var->attrs, var->declspec.type, func->name,
+ var->typestring_offset = write_type_tfs( file, var->attrs, &var->declspec, func->name,
TYPE_CONTEXT_RETVAL, offset);
if (type_function_get_args(func->declspec.type))
LIST_FOR_EACH_ENTRY( var, type_function_get_args(func->declspec.type), var_t, entry )
- var->typestring_offset = write_type_tfs( file, var->attrs, var->declspec.type, var->name,
+ var->typestring_offset = write_type_tfs( file, var->attrs, &var->declspec, var->name,
TYPE_CONTEXT_TOPLEVELPARAM, offset );
break;
@@ -3727,9 +3746,12 @@ static void process_tfs_iface(type_t *iface, FILE *file, int indent, unsigned in
{
if (is_attr(type_entry->type->attrs, ATTR_ENCODE)
|| is_attr(type_entry->type->attrs, ATTR_DECODE))
+ {
+ decl_spec_t ds;
type_entry->type->typestring_offset = write_type_tfs( file,
- type_entry->type->attrs, type_entry->type, type_entry->type->name,
+ type_entry->type->attrs, init_declspec(&ds, type_entry->type), type_entry->type->name,
TYPE_CONTEXT_CONTAINER, offset);
+ }
}
break;
}
@@ -3976,7 +3998,8 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix,
enum remoting_phase phase, enum pass pass, const var_t *var,
const char *varname)
{
- type_t *type = var->declspec.type;
+ const decl_spec_t *declspec = &var->declspec;
+ type_t *type = declspec->type;
unsigned int alignment = 0;
/* no work to do for other phases, buffer sizing is done elsewhere */
@@ -4007,8 +4030,8 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix,
}
else
{
- const type_t *ref = is_ptr(type) ? type_pointer_get_ref_type(type) : type;
- switch (get_basic_fc(ref))
+ const decl_spec_t *ref = is_ptr(type) ? type_pointer_get_ref(type) : declspec;
+ switch (get_basic_fc(ref->type))
{
case FC_BYTE:
case FC_CHAR:
@@ -4045,7 +4068,7 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix,
default:
error("print_phase_basetype: Unsupported type: %s (0x%02x, ptr_level: 0)\n",
- var->name, get_basic_fc(ref));
+ var->name, get_basic_fc(ref->type));
}
if (phase == PHASE_MARSHAL && alignment > 1)
@@ -4056,7 +4079,7 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix,
if (phase == PHASE_MARSHAL)
{
print_file(file, indent, "*(");
- write_type_decl(file, is_ptr(type) ? type_pointer_get_ref_type(type) : type, NULL);
+ write_declspec_decl(file, is_ptr(type) ? type_pointer_get_ref(type) : declspec, NULL);
if (is_ptr(type))
fprintf(file, " *)__frame->_StubMsg.Buffer = *");
else
@@ -4067,7 +4090,7 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix,
else if (phase == PHASE_UNMARSHAL)
{
print_file(file, indent, "if (__frame->_StubMsg.Buffer + sizeof(");
- write_type_decl(file, is_ptr(type) ? type_pointer_get_ref_type(type) : type, NULL);
+ write_declspec_decl(file, is_ptr(type) ? type_pointer_get_ref(type) : declspec, NULL);
fprintf(file, ") > __frame->_StubMsg.BufferEnd)\n");
print_file(file, indent, "{\n");
print_file(file, indent + 1, "RpcRaiseException(RPC_X_BAD_STUB_DATA);\n");
@@ -4079,12 +4102,12 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix,
fprintf(file, " = (");
else
fprintf(file, " = *(");
- write_type_decl(file, is_ptr(type) ? type_pointer_get_ref_type(type) : type, NULL);
+ write_declspec_decl(file, is_ptr(type) ? type_pointer_get_ref(type) : declspec, NULL);
fprintf(file, " *)__frame->_StubMsg.Buffer;\n");
}
print_file(file, indent, "__frame->_StubMsg.Buffer += sizeof(");
- write_type_decl(file, is_ptr(type) ? type_pointer_get_ref_type(type) : type, NULL);
+ write_declspec_decl(file, is_ptr(type) ? type_pointer_get_ref(type) : declspec, NULL);
fprintf(file, ");\n");
}
}
@@ -4389,9 +4412,9 @@ static void write_remoting_arg(FILE *file, int indent, const var_t *func, const
range_max = LIST_ENTRY(list_next(range_list, list_head(range_list)), const expr_t, entry);
print_file(file, indent, "if ((%s%s < (", local_var_prefix, var->name);
- write_type_decl(file, var->declspec.type, NULL);
+ write_declspec_decl(file, &var->declspec, NULL);
fprintf(file, ")0x%x) || (%s%s > (", range_min->cval, local_var_prefix, var->name);
- write_type_decl(file, var->declspec.type, NULL);
+ write_declspec_decl(file, &var->declspec, NULL);
fprintf(file, ")0x%x))\n", range_max->cval);
print_file(file, indent, "{\n");
print_file(file, indent+1, "RpcRaiseException(RPC_S_INVALID_BOUND);\n");
@@ -4616,7 +4639,7 @@ void declare_stub_args( FILE *file, int indent, const var_t *func )
else
{
print_file(file, indent, "%s", "");
- write_type_decl(file, var->declspec.type, var->name);
+ write_declspec_decl(file, &var->declspec, var->name);
fprintf(file, ";\n");
}
}
@@ -4637,21 +4660,21 @@ void declare_stub_args( FILE *file, int indent, const var_t *func )
{
if (!in_attr && !is_conformant_array(var->declspec.type))
{
- type_t *type_to_print;
+ const decl_spec_t *declspec_to_print;
char name[16];
print_file(file, indent, "%s", "");
if (type_get_type(var->declspec.type) == TYPE_ARRAY &&
!type_array_is_decl_as_ptr(var->declspec.type))
- type_to_print = var->declspec.type;
+ declspec_to_print = &var->declspec;
else
- type_to_print = type_pointer_get_ref_type(var->declspec.type);
+ declspec_to_print = type_pointer_get_ref(var->declspec.type);
sprintf(name, "_W%u", i++);
- write_type_decl(file, type_to_print, name);
+ write_declspec_decl(file, declspec_to_print, name);
fprintf(file, ";\n");
}
print_file(file, indent, "%s", "");
- write_type_decl_left(file, var->declspec.type);
+ write_declspec_decl_left(file, &var->declspec);
fprintf(file, " ");
if (type_get_type(var->declspec.type) == TYPE_ARRAY &&
!type_array_is_decl_as_ptr(var->declspec.type)) {
@@ -4804,7 +4827,7 @@ void write_func_param_struct( FILE *file, const type_t *iface, const type_t *fun
if (args) LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
{
print_file(file, 2, "%s", "");
- write_type_left( file, (type_t *)arg->declspec.type, NAME_DEFAULT, TRUE );
+ write_declspec_left( file, &arg->declspec, NAME_DEFAULT, TRUE );
if (needs_space_after( arg->declspec.type )) fputc( ' ', file );
if (is_array( arg->declspec.type ) && !type_array_is_decl_as_ptr( arg->declspec.type )) fputc( '*', file );
@@ -4821,7 +4844,7 @@ void write_func_param_struct( FILE *file, const type_t *iface, const type_t *fun
if (add_retval && !is_void( retval->declspec.type ))
{
print_file(file, 2, "%s", "");
- write_type_decl( file, retval->declspec.type, retval->name );
+ write_declspec_decl( file, &retval->declspec, retval->name );
if (is_array( retval->declspec.type ) || is_ptr( retval->declspec.type ) ||
type_memsize( retval->declspec.type ) == pointer_size)
fprintf( file, ";\n" );
@@ -4868,10 +4891,11 @@ int write_expr_eval_routines(FILE *file, const char *iface)
}
else
{
+ decl_spec_t declspec;
print_file(file, 1, "%s", "");
- write_type_left(file, (type_t *)eval->cont_type, NAME_DEFAULT, TRUE);
+ write_declspec_left(file, init_declspec(&declspec, (type_t*)eval->cont_type), NAME_DEFAULT, TRUE);
fprintf(file, " *%s = (", var_name);
- write_type_left(file, (type_t *)eval->cont_type, NAME_DEFAULT, TRUE);
+ write_declspec_left(file, init_declspec(&declspec, (type_t*)eval->cont_type), NAME_DEFAULT, TRUE);
fprintf(file, " *)(pStubMsg->StackTop - %u);\n", eval->baseoff);
}
print_file(file, 1, "pStubMsg->Offset = 0;\n"); /* FIXME */
@@ -4965,7 +4989,8 @@ error:
void write_client_call_routine( FILE *file, const type_t *iface, const var_t *func,
const char *prefix, unsigned int proc_offset )
{
- type_t *rettype = type_function_get_rettype( func->declspec.type );
+ const decl_spec_t *retdeclspec = type_function_get_retdeclspec(func->declspec.type);
+ type_t *rettype = retdeclspec->type;
int has_ret = !is_void( rettype );
const var_list_t *args = type_function_get_args( func->declspec.type );
const var_t *arg;
@@ -5015,7 +5040,7 @@ void write_client_call_routine( FILE *file, const type_t *iface, const var_t *fu
if (has_ret)
{
print_file( file, 1, "return (" );
- write_type_decl_left(file, rettype);
+ write_declspec_decl_left(file, retdeclspec);
fprintf( file, ")%s;\n", pointer_size == 8 ? "_RetVal.Simple" : "*(LONG_PTR *)&_RetVal" );
}
print_file( file, 0, "}\n\n");
--
2.17.1
July 5, 2019
[PATCH 05/15] widl: add type_function_get_retdeclspec function
by Richard Pospesel
Signed-off-by: Richard Pospesel <richard(a)torproject.org>
---
tools/widl/typetree.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h
index 1fd86bbc89..c773ddd116 100644
--- a/tools/widl/typetree.h
+++ b/tools/widl/typetree.h
@@ -129,9 +129,14 @@ static inline var_t *type_function_get_retval(const type_t *type)
return type->details.function->retval;
}
+static inline const decl_spec_t *type_function_get_retdeclspec(const type_t *type)
+{
+ return &type_function_get_retval(type)->declspec;
+}
+
static inline type_t *type_function_get_rettype(const type_t *type)
{
- return type_function_get_retval(type)->declspec.type;
+ return type_function_get_retdeclspec(type)->type;
}
static inline var_list_t *type_enum_get_values(const type_t *type)
--
2.17.1
July 5, 2019
[PATCH 04/15] widl: move type_t's orig member to new alias_details struct and refactor to use decl_spec_t and added asserts in relevant places to ensure we're not dealing a typedef when accessing type's details member
by Richard Pospesel
Signed-off-by: Richard Pospesel <richard(a)torproject.org>
---
tools/widl/client.c | 4 +--
tools/widl/header.c | 52 +++++++++++++++--------------
tools/widl/header.h | 2 +-
tools/widl/parser.y | 44 ++++++++++++++++--------
tools/widl/proxy.c | 28 ++++++++--------
tools/widl/server.c | 6 ++--
tools/widl/typegen.c | 74 +++++++++++++++++++++--------------------
tools/widl/typetree.c | 12 ++++---
tools/widl/typetree.h | 53 +++++++++++++++++++++++++++--
tools/widl/widl.c | 1 +
tools/widl/widltypes.h | 64 ++++++++++++-----------------------
tools/widl/write_msft.c | 26 ++++++++-------
12 files changed, 208 insertions(+), 158 deletions(-)
diff --git a/tools/widl/client.c b/tools/widl/client.c
index b0a5d0cc8c..545a35c0c9 100644
--- a/tools/widl/client.c
+++ b/tools/widl/client.c
@@ -34,7 +34,7 @@
#include "parser.h"
#include "header.h"
-#include "widltypes.h"
+#include "typetree.h"
#include "typegen.h"
#include "expr.h"
@@ -53,7 +53,7 @@ static void print_client( const char *format, ... )
static void write_client_func_decl( const type_t *iface, const var_t *func )
{
const char *callconv = get_attrp(func->declspec.type->attrs, ATTR_CALLCONV);
- const var_list_t *args = type_get_function_args(func->declspec.type);
+ const var_list_t *args = type_function_get_args(func->declspec.type);
type_t *rettype = type_function_get_rettype(func->declspec.type);
if (!callconv) callconv = "__cdecl";
diff --git a/tools/widl/header.c b/tools/widl/header.c
index 8c07564751..d8f31a69f9 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -75,7 +75,7 @@ int is_ptrchain_attr(const var_t *var, enum attr_type t)
if (is_attr(type->attrs, t))
return 1;
else if (type_is_alias(type))
- type = type_alias_get_aliasee(type);
+ type = type_alias_get_aliasee_type(type);
else if (is_ptr(type))
type = type_pointer_get_ref_type(type);
else return 0;
@@ -91,7 +91,7 @@ int is_aliaschain_attr(const type_t *type, enum attr_type attr)
if (is_attr(t->attrs, attr))
return 1;
else if (type_is_alias(t))
- t = type_alias_get_aliasee(t);
+ t = type_alias_get_aliasee_type(t);
else return 0;
}
}
@@ -602,7 +602,7 @@ unsigned int get_context_handle_offset( const type_t *type )
while (!is_attr( type->attrs, ATTR_CONTEXTHANDLE ))
{
- if (type_is_alias( type )) type = type_alias_get_aliasee( type );
+ if (type_is_alias( type )) type = type_alias_get_aliasee_type( type );
else if (is_ptr( type )) type = type_pointer_get_ref_type( type );
else error( "internal error: %s is not a context handle\n", type->name );
}
@@ -622,7 +622,7 @@ unsigned int get_generic_handle_offset( const type_t *type )
while (!is_attr( type->attrs, ATTR_HANDLE ))
{
- if (type_is_alias( type )) type = type_alias_get_aliasee( type );
+ if (type_is_alias( type )) type = type_alias_get_aliasee_type( type );
else if (is_ptr( type )) type = type_pointer_get_ref_type( type );
else error( "internal error: %s is not a generic handle\n", type->name );
}
@@ -701,7 +701,7 @@ void check_for_additional_prototype_types(type_t *type)
}
if (type_is_alias(type))
- type = type_alias_get_aliasee(type);
+ type = type_alias_get_aliasee_type(type);
else if (is_ptr(type))
type = type_pointer_get_ref_type(type);
else if (is_array(type))
@@ -789,7 +789,7 @@ static void write_generic_handle_routines(FILE *header)
static void write_typedef(FILE *header, type_t *type)
{
fprintf(header, "typedef ");
- write_type_def_or_decl(header, type_alias_get_aliasee(type), FALSE, type->name);
+ write_type_def_or_decl(header, type_alias_get_aliasee_type(type), FALSE, type->name);
fprintf(header, ";\n");
}
@@ -852,7 +852,7 @@ const type_t* get_explicit_generic_handle_type(const var_t* var)
const type_t *t;
for (t = var->declspec.type;
is_ptr(t) || type_is_alias(t);
- t = type_is_alias(t) ? type_alias_get_aliasee(t) : type_pointer_get_ref_type(t))
+ t = type_is_alias(t) ? type_alias_get_aliasee_type(t) : type_pointer_get_ref_type(t))
if ((type_get_type_detect_alias(t) != TYPE_BASIC || type_basic_get_type(t) != TYPE_BASIC_HANDLE) &&
is_attr(t->attrs, ATTR_HANDLE))
return t;
@@ -863,7 +863,7 @@ const var_t *get_func_handle_var( const type_t *iface, const var_t *func,
unsigned char *explicit_fc, unsigned char *implicit_fc )
{
const var_t *var;
- const var_list_t *args = type_get_function_args( func->declspec.type );
+ const var_list_t *args = type_function_get_args( func->declspec.type );
*explicit_fc = *implicit_fc = 0;
if (args) LIST_FOR_EACH_ENTRY( var, args, const var_t, entry )
@@ -907,10 +907,10 @@ int has_out_arg_or_return(const var_t *func)
if (!is_void(type_function_get_rettype(func->declspec.type)))
return 1;
- if (!type_get_function_args(func->declspec.type))
+ if (!type_function_get_args(func->declspec.type))
return 0;
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), const var_t, entry )
+ LIST_FOR_EACH_ENTRY( var, type_function_get_args(func->declspec.type), const var_t, entry )
if (is_attr(var->attrs, ATTR_OUT))
return 1;
@@ -1030,8 +1030,8 @@ static void write_method_macro(FILE *header, const type_t *iface, const type_t *
const var_t *arg;
fprintf(header, "#define %s_%s(This", name, get_name(func));
- if (type_get_function_args(func->declspec.type))
- LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->declspec.type), const var_t, entry )
+ if (type_function_get_args(func->declspec.type))
+ LIST_FOR_EACH_ENTRY( arg, type_function_get_args(func->declspec.type), const var_t, entry )
fprintf(header, ",%s", arg->name);
fprintf(header, ") ");
@@ -1042,8 +1042,8 @@ static void write_method_macro(FILE *header, const type_t *iface, const type_t *
}
fprintf(header, "(This)->lpVtbl->%s(This", get_vtbl_entry_name(iface, func));
- if (type_get_function_args(func->declspec.type))
- LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->declspec.type), const var_t, entry )
+ if (type_function_get_args(func->declspec.type))
+ LIST_FOR_EACH_ENTRY( arg, type_function_get_args(func->declspec.type), const var_t, entry )
fprintf(header, ",%s", arg->name);
fprintf(header, ")\n");
}
@@ -1115,7 +1115,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->declspec.type->attrs, ATTR_CALLCONV);
- const var_list_t *args = type_get_function_args(func->declspec.type);
+ const var_list_t *args = type_function_get_args(func->declspec.type);
const var_t *arg;
if (!callconv) callconv = "STDMETHODCALLTYPE";
@@ -1203,7 +1203,7 @@ static void write_inline_wrappers(FILE *header, const type_t *iface, const type_
fprintf(header, "static FORCEINLINE ");
write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
fprintf(header, " %s_%s(", name, get_name(func));
- write_args(header, type_get_function_args(func->declspec.type), name, 1, FALSE);
+ write_args(header, type_function_get_args(func->declspec.type), name, 1, FALSE);
fprintf(header, ") {\n");
++indentation;
if (!is_aggregate_return(func)) {
@@ -1218,8 +1218,8 @@ static void write_inline_wrappers(FILE *header, const type_t *iface, const type_
indent(header, 0);
fprintf(header, "return *This->lpVtbl->%s(This,&__ret", get_vtbl_entry_name(iface, func));
}
- if (type_get_function_args(func->declspec.type))
- LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->declspec.type), const var_t, entry )
+ if (type_function_get_args(func->declspec.type))
+ LIST_FOR_EACH_ENTRY( arg, type_function_get_args(func->declspec.type), const var_t, entry )
fprintf(header, ",%s", arg->name);
fprintf(header, ");\n");
--indentation;
@@ -1265,9 +1265,9 @@ static void do_write_c_method_def(FILE *header, const type_t *iface, const char
fprintf(header, " *__ret");
}
--indentation;
- if (type_get_function_args(func->declspec.type)) {
+ if (type_function_get_args(func->declspec.type)) {
fprintf(header, ",\n");
- write_args(header, type_get_function_args(func->declspec.type), name, 0, TRUE);
+ write_args(header, type_function_get_args(func->declspec.type), name, 0, TRUE);
}
fprintf(header, ");\n");
fprintf(header, "\n");
@@ -1299,7 +1299,7 @@ static void write_method_proto(FILE *header, const type_t *iface)
/* proxy prototype */
write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
fprintf(header, " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func));
- write_args(header, type_get_function_args(func->declspec.type), iface->name, 1, TRUE);
+ write_args(header, type_function_get_args(func->declspec.type), iface->name, 1, TRUE);
fprintf(header, ");\n");
/* stub prototype */
fprintf(header, "void __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(func));
@@ -1334,7 +1334,7 @@ static void write_locals(FILE *fp, const type_t *iface, int body)
/* proxy prototype - use local prototype */
write_type_decl_left(fp, type_function_get_rettype(m->declspec.type));
fprintf(fp, " CALLBACK %s_%s_Proxy(\n", iface->name, get_name(m));
- write_args(fp, type_get_function_args(m->declspec.type), iface->name, 1, TRUE);
+ write_args(fp, type_function_get_args(m->declspec.type), iface->name, 1, TRUE);
fprintf(fp, ")");
if (body) {
type_t *rt = type_function_get_rettype(m->declspec.type);
@@ -1356,7 +1356,7 @@ static void write_locals(FILE *fp, const type_t *iface, int body)
/* stub prototype - use remotable prototype */
write_type_decl_left(fp, type_function_get_rettype(func->declspec.type));
fprintf(fp, " __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(m));
- write_args(fp, type_get_function_args(func->declspec.type), iface->name, 1, TRUE);
+ write_args(fp, type_function_get_args(func->declspec.type), iface->name, 1, TRUE);
fprintf(fp, ")");
if (body)
/* Remotable methods must all return HRESULTs. */
@@ -1409,8 +1409,8 @@ static void write_function_proto(FILE *header, const type_t *iface, const var_t
write_type_decl_left(header, type_function_get_rettype(fun->declspec.type));
fprintf(header, " %s ", callconv);
fprintf(header, "%s%s(\n", prefix, get_name(fun));
- if (type_get_function_args(fun->declspec.type))
- write_args(header, type_get_function_args(fun->declspec.type), iface->name, 0, TRUE);
+ if (type_function_get_args(fun->declspec.type))
+ write_args(header, type_function_get_args(fun->declspec.type), iface->name, 0, TRUE);
else
fprintf(header, " void");
fprintf(header, ");\n\n");
@@ -1648,6 +1648,7 @@ static void write_forward_decls(FILE *header, const statement_list_t *stmts)
if (type_get_type(stmt->u.type) == TYPE_INTERFACE)
{
type_t *iface = stmt->u.type;
+ assert(type_get_type_detect_alias(iface) == TYPE_INTERFACE);
if (is_object(iface) || is_attr(iface->attrs, ATTR_DISPINTERFACE))
{
write_forward(header, iface);
@@ -1689,6 +1690,7 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons
{
type_t *iface = stmt->u.type;
type_t *async_iface = iface->details.iface->async_iface;
+ assert(type_get_type_detect_alias(iface) == TYPE_INTERFACE);
if (is_object(iface)) is_object_interface++;
if (is_attr(stmt->u.type->attrs, ATTR_DISPINTERFACE) || is_object(stmt->u.type))
{
diff --git a/tools/widl/header.h b/tools/widl/header.h
index eb98125b25..94b90a391f 100644
--- a/tools/widl/header.h
+++ b/tools/widl/header.h
@@ -102,7 +102,7 @@ static inline int is_context_handle(const type_t *type)
const type_t *t;
for (t = type;
is_ptr(t) || type_is_alias(t);
- t = type_is_alias(t) ? type_alias_get_aliasee(t) : type_pointer_get_ref_type(t))
+ t = type_is_alias(t) ? type_alias_get_aliasee_type(t) : type_pointer_get_ref_type(t))
if (is_attr(t->attrs, ATTR_CONTEXTHANDLE))
return 1;
return 0;
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index ff867655fa..82cf36d297 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -1423,6 +1423,7 @@ void clear_all_offsets(void)
static void type_function_add_head_arg(type_t *type, var_t *arg)
{
+ assert(type_get_type_detect_alias(type) == TYPE_FUNCTION);
if (!type->details.function->args)
{
type->details.function->args = xmalloc( sizeof(*type->details.function->args) );
@@ -1482,6 +1483,7 @@ static type_t *append_chain_type(type_t *chain, type_t *type)
for (chain_type = chain; get_array_or_ptr_ref(chain_type); chain_type = get_array_or_ptr_ref(chain_type))
;
+ assert(!type_is_alias(chain_type));
if (is_ptr(chain_type))
chain_type->details.pointer.ref.type = type;
else if (is_array(chain_type))
@@ -1550,7 +1552,7 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
{
ptr_attr = get_attrv(ptr->attrs, ATTR_POINTERTYPE);
if (!ptr_attr && type_is_alias(ptr))
- ptr = type_alias_get_aliasee(ptr);
+ ptr = type_alias_get_aliasee_type(ptr);
else
break;
}
@@ -1561,7 +1563,7 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
warning_loc_info(&v->loc_info,
"%s: pointer attribute applied to interface "
"pointer type has no effect\n", v->name);
- if (!ptr_attr && top && (*pt)->details.pointer.def_fc != FC_RP)
+ if (!ptr_attr && top && type_pointer_get_default_fc(*pt) != FC_RP)
{
/* 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
@@ -1634,6 +1636,7 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
error_loc("%s: size_is attribute applied to illegal type\n", v->name);
}
+ assert(!type_is_alias(*ptype));
if (is_ptr(*ptype))
ptype = &(*ptype)->details.pointer.ref.type;
else if (is_array(*ptype))
@@ -1660,6 +1663,7 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
error_loc("%s: length_is attribute applied to illegal type\n", v->name);
}
+ assert(!type_is_alias(*ptype));
if (is_ptr(*ptype))
ptype = &(*ptype)->details.pointer.ref.type;
else if (is_array(*ptype))
@@ -1902,7 +1906,8 @@ type_t *reg_type(type_t *type, const char *name, struct namespace *namespace, in
static int is_incomplete(const type_t *t)
{
return !t->defined &&
- (type_get_type_detect_alias(t) == TYPE_STRUCT ||
+ (type_get_type_detect_alias(t) == TYPE_ENUM ||
+ type_get_type_detect_alias(t) == TYPE_STRUCT ||
type_get_type_detect_alias(t) == TYPE_UNION ||
type_get_type_detect_alias(t) == TYPE_ENCAPSULATED_UNION);
}
@@ -1910,19 +1915,16 @@ static int is_incomplete(const type_t *t)
void add_incomplete(type_t *t)
{
struct typenode *tn = xmalloc(sizeof *tn);
+ assert(is_incomplete(t));
tn->type = t;
list_add_tail(&incomplete_types, &tn->entry);
}
static void fix_type(type_t *t)
{
- if (type_is_alias(t) && is_incomplete(t)) {
- type_t *ot = type_alias_get_aliasee(t);
- fix_type(ot);
- if (type_get_type_detect_alias(ot) == TYPE_STRUCT ||
- type_get_type_detect_alias(ot) == TYPE_UNION ||
- type_get_type_detect_alias(ot) == TYPE_ENCAPSULATED_UNION)
- t->details.structure = ot->details.structure;
+ if (type_is_alias(t) && is_incomplete(t))
+ {
+ type_t *ot = type_alias_get_aliasee_type(t);
t->defined = ot->defined;
}
}
@@ -1946,7 +1948,7 @@ static void fix_incomplete_types(type_t *complete_type)
{
if (type_is_equal(complete_type, tn->type))
{
- tn->type->details.structure = complete_type->details.structure;
+ tn->type->details = complete_type->details;
list_remove(&tn->entry);
free(tn);
}
@@ -2651,10 +2653,15 @@ static void check_field_common(const type_t *container_type,
type = type_array_get_element_type(type);
more_to_do = TRUE;
break;
+ case TGT_ENUM:
+ type = type_get_real_type(type);
+ if(!type_is_complete(type))
+ {
+ error_loc_info(&arg->loc_info, "undefined type declaration enum %s\n", type->name);
+ }
case TGT_USER_TYPE:
case TGT_IFACE_POINTER:
case TGT_BASIC:
- case TGT_ENUM:
case TGT_RANGE:
/* nothing to do */
break;
@@ -2679,10 +2686,15 @@ static void check_remoting_fields(const var_t *var, type_t *type)
if (type_is_complete(type))
fields = type_struct_get_fields(type);
else
- error_loc_info(&var->loc_info, "undefined type declaration %s\n", type->name);
+ error_loc_info(&var->loc_info, "undefined type declaration struct %s\n", type->name);
}
else if (type_get_type(type) == TYPE_UNION || type_get_type(type) == TYPE_ENCAPSULATED_UNION)
- fields = type_union_get_cases(type);
+ {
+ if (type_is_complete(type))
+ fields = type_union_get_cases(type);
+ else
+ error_loc_info(&var->loc_info, "undefined type declaration union %s\n", type->name);
+ }
if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
if (field->declspec.type) check_field_common(type, type->name, field);
@@ -2694,6 +2706,7 @@ static void check_remoting_args(const var_t *func)
const char *funcname = func->name;
const var_t *arg;
+ assert(type_get_type_detect_alias(func->declspec.type) == TYPE_FUNCTION);
if (func->declspec.type->details.function->args) LIST_FOR_EACH_ENTRY( arg, func->declspec.type->details.function->args, const var_t, entry )
{
const type_t *type = arg->declspec.type;
@@ -2828,6 +2841,7 @@ static void check_async_uuid(type_t *iface)
type_t *async_iface;
type_t *inherit;
+ assert(type_get_type_detect_alias(iface) == TYPE_INTERFACE);
if (!is_attr(iface->attrs, ATTR_ASYNCUUID)) return;
inherit = iface->details.iface->inherit;
@@ -2844,6 +2858,7 @@ static void check_async_uuid(type_t *iface)
var_t *begin_func, *finish_func, *func = stmt->u.var, *arg;
var_list_t *begin_args = NULL, *finish_args = NULL, *args;
+ assert(type_get_type_detect_alias(func->declspec.type) == TYPE_FUNCTION);
args = func->declspec.type->details.function->args;
if (args) LIST_FOR_EACH_ENTRY(arg, args, var_t, entry)
{
@@ -2914,6 +2929,7 @@ static void check_all_user_types(const statement_list_t *stmts)
const statement_t *stmt_func;
STATEMENTS_FOR_EACH_FUNC(stmt_func, type_iface_get_stmts(stmt->u.type)) {
const var_t *func = stmt_func->u.var;
+ assert(type_get_type_detect_alias(func->declspec.type) == TYPE_FUNCTION);
if (func->declspec.type->details.function->args)
LIST_FOR_EACH_ENTRY( v, func->declspec.type->details.function->args, const var_t, entry )
check_for_additional_prototype_types(v->declspec.type);
diff --git a/tools/widl/proxy.c b/tools/widl/proxy.c
index 8f65e8aa7b..5b5a092c83 100644
--- a/tools/widl/proxy.c
+++ b/tools/widl/proxy.c
@@ -195,7 +195,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
int has_ret = !is_void(retval->declspec.type);
int has_full_pointer = is_full_pointer_function(func);
const char *callconv = get_attrp(func->declspec.type->attrs, ATTR_CALLCONV);
- const var_list_t *args = type_get_function_args(func->declspec.type);
+ const var_list_t *args = type_function_get_args(func->declspec.type);
if (!callconv) callconv = "STDMETHODCALLTYPE";
indent = 0;
@@ -246,7 +246,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
write_full_pointer_init(proxy, indent, func, FALSE);
/* FIXME: trace */
- clear_output_vars( type_get_function_args(func->declspec.type) );
+ clear_output_vars( type_function_get_args(func->declspec.type) );
print_proxy( "RpcTryExcept\n" );
print_proxy( "{\n" );
@@ -301,7 +301,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
print_proxy( "{\n" );
if (has_ret) {
indent++;
- proxy_free_variables( type_get_function_args(func->declspec.type), "" );
+ proxy_free_variables( type_function_get_args(func->declspec.type), "" );
print_proxy( "_RetVal = NdrProxyErrorHandler(RpcExceptionCode());\n" );
indent--;
}
@@ -389,9 +389,9 @@ static void gen_stub(type_t *iface, const var_t *func, const char *cas,
else fprintf(proxy, "__frame->_This->lpVtbl->%s", get_name(func));
fprintf(proxy, "(__frame->_This");
- if (type_get_function_args(func->declspec.type))
+ if (type_function_get_args(func->declspec.type))
{
- LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->declspec.type), const var_t, entry )
+ LIST_FOR_EACH_ENTRY( arg, type_function_get_args(func->declspec.type), const var_t, entry )
fprintf(proxy, ", %s__frame->%s", is_array(arg->declspec.type) && !type_array_is_decl_as_ptr(arg->declspec.type) ? "*" :"" , arg->name);
}
fprintf(proxy, ");\n");
@@ -434,7 +434,7 @@ static void gen_stub_thunk( type_t *iface, const var_t *func, unsigned int proc_
{
int has_ret = !is_void( type_function_get_rettype( func->declspec.type ));
const var_t *arg, *callas = is_callas( func->attrs );
- const var_list_t *args = type_get_function_args( func->declspec.type );
+ const var_list_t *args = type_function_get_args( func->declspec.type );
indent = 0;
print_proxy( "void __RPC_API %s_%s_Thunk( PMIDL_STUB_MESSAGE pStubMsg )\n",
@@ -614,14 +614,14 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset)
if (!is_local(func->attrs)) {
const var_t *cas = is_callas(func->attrs);
const char *cname = cas ? cas->name : NULL;
- int idx = func->declspec.type->details.function->idx;
+ int idx = type_get_details(func->declspec.type)->function->idx;
if (cname) {
const statement_t *stmt2;
STATEMENTS_FOR_EACH_FUNC(stmt2, type_iface_get_stmts(iface)) {
const var_t *m = stmt2->u.var;
if (!strcmp(m->name, cname))
{
- idx = m->declspec.type->details.function->idx;
+ idx = type_get_details(m->declspec.type)->function->idx;
break;
}
}
@@ -739,7 +739,7 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset)
print_proxy( "{\n");
indent++;
print_proxy( "%s_%s\n",
- iface->details.iface->async_iface == iface ? "CStdAsyncStubBuffer" : "CStdStubBuffer",
+ type_get_details(iface)->iface->async_iface == iface ? "CStdAsyncStubBuffer" : "CStdStubBuffer",
need_delegation_indirect(iface) ? "DELEGATING_METHODS" : "METHODS");
indent--;
print_proxy( "}\n");
@@ -840,8 +840,8 @@ static void write_proxy_stmts(const statement_list_t *stmts, unsigned int *proc_
if (need_proxy(iface))
{
write_proxy(iface, proc_offset);
- if (iface->details.iface->async_iface)
- write_proxy(iface->details.iface->async_iface, proc_offset);
+ if (type_get_details(iface)->iface->async_iface)
+ write_proxy(type_get_details(iface)->iface->async_iface, proc_offset);
}
}
}
@@ -870,9 +870,9 @@ static void build_iface_list( const statement_list_t *stmts, type_t **ifaces[],
{
*ifaces = xrealloc( *ifaces, (*count + 1) * sizeof(**ifaces) );
(*ifaces)[(*count)++] = iface;
- if (iface->details.iface->async_iface)
+ if (type_get_details(iface)->iface->async_iface)
{
- iface = iface->details.iface->async_iface;
+ iface = type_get_details(iface)->iface->async_iface;
*ifaces = xrealloc( *ifaces, (*count + 1) * sizeof(**ifaces) );
(*ifaces)[(*count)++] = iface;
}
@@ -1012,7 +1012,7 @@ static void write_proxy_routines(const statement_list_t *stmts)
table_version = get_stub_mode() == MODE_Oif ? 2 : 1;
for (i = 0; i < count; i++)
{
- if (interfaces[i]->details.iface->async_iface != interfaces[i]) continue;
+ if (type_get_details(interfaces[i])->iface->async_iface != interfaces[i]) continue;
if (table_version != 6)
{
fprintf(proxy, "static const IID *_AsyncInterfaceTable[] =\n");
diff --git a/tools/widl/server.c b/tools/widl/server.c
index fb14dd87bc..6ce3db5e1c 100644
--- a/tools/widl/server.c
+++ b/tools/widl/server.c
@@ -121,7 +121,7 @@ static void write_function_stub(const type_t *iface, const var_t *func, unsigned
if (has_full_pointer)
write_full_pointer_init(server, indent, func, TRUE);
- if (type_get_function_args(func->declspec.type))
+ if (type_function_get_args(func->declspec.type))
{
print_server("if ((_pRpcMessage->DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)\n");
indent++;
@@ -166,13 +166,13 @@ static void write_function_stub(const type_t *iface, const var_t *func, unsigned
print_server("%s", is_void(ret_type) ? "" : "__frame->_RetVal = ");
fprintf(server, "%s%s", prefix_server, get_name(func));
- if (type_get_function_args(func->declspec.type))
+ if (type_function_get_args(func->declspec.type))
{
int first_arg = 1;
fprintf(server, "(\n");
indent++;
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), const var_t, entry )
+ LIST_FOR_EACH_ENTRY( var, type_function_get_args(func->declspec.type), const var_t, entry )
{
if (first_arg)
first_arg = 0;
diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index f901f83d1e..ddf555cd9b 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -197,7 +197,7 @@ static void *get_aliaschain_attrp(const type_t *type, enum attr_type attr)
if (is_attr(t->attrs, attr))
return get_attrp(t->attrs, attr);
else if (type_is_alias(t))
- t = type_alias_get_aliasee(t);
+ t = type_alias_get_aliasee_type(t);
else return NULL;
}
}
@@ -267,7 +267,7 @@ unsigned char get_pointer_fc(const type_t *type, const attr_list_t *attrs, int t
if (pointer_type)
return pointer_type;
- for (t = type; type_is_alias(t); t = type_alias_get_aliasee(t))
+ for (t = type; type_is_alias(t); t = type_alias_get_aliasee_type(t))
{
pointer_type = get_attrv(t->attrs, ATTR_POINTERTYPE);
if (pointer_type)
@@ -316,7 +316,7 @@ static type_t *get_user_type(const type_t *t, const char **pname)
}
if (type_is_alias(t))
- t = type_alias_get_aliasee(t);
+ t = type_alias_get_aliasee_type(t);
else
return NULL;
}
@@ -857,7 +857,7 @@ static const char *get_context_handle_type_name(const type_t *type)
const type_t *t;
for (t = type;
is_ptr(t) || type_is_alias(t);
- t = type_is_alias(t) ? type_alias_get_aliasee(t) : type_pointer_get_ref_type(t))
+ t = type_is_alias(t) ? type_alias_get_aliasee_type(t) : type_pointer_get_ref_type(t))
if (is_attr(t->attrs, ATTR_CONTEXTHANDLE))
return t->name;
assert(0);
@@ -912,10 +912,10 @@ void write_parameters_init(FILE *file, int indent, const var_t *func, const char
if (!is_void(var->declspec.type))
write_var_init(file, indent, var->declspec.type, var->name, local_var_prefix);
- if (!type_get_function_args(func->declspec.type))
+ if (!type_function_get_args(func->declspec.type))
return;
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), const var_t, entry )
+ LIST_FOR_EACH_ENTRY( var, type_function_get_args(func->declspec.type), const var_t, entry )
write_var_init(file, indent, var->declspec.type, var->name, local_var_prefix);
fprintf(file, "\n");
@@ -1011,7 +1011,7 @@ static unsigned char get_parameter_fc( const var_t *var, int is_return, unsigned
break;
case TGT_ARRAY:
*flags |= MustFree;
- if (type_array_is_decl_as_ptr(var->declspec.type) && var->declspec.type->details.array.ptr_tfsoff &&
+ if (type_array_is_decl_as_ptr(var->declspec.type) && type_get_details(var->declspec.type)->array.ptr_tfsoff &&
get_pointer_fc( var->declspec.type, var->attrs, !is_return ) == FC_RP)
{
*typestring_offset = var->declspec.type->typestring_offset;
@@ -1128,7 +1128,7 @@ static unsigned char get_parameter_fc( const var_t *var, int is_return, unsigned
static unsigned char get_func_oi2_flags( const var_t *func )
{
const var_t *var;
- var_list_t *args = type_get_function_args( func->declspec.type );
+ var_list_t *args = type_function_get_args( func->declspec.type );
var_t *retval = type_function_get_retval( func->declspec.type );
unsigned char oi2_flags = 0x40; /* HasExtensions */
unsigned short flags;
@@ -1230,8 +1230,10 @@ static unsigned int write_old_procformatstring_type(FILE *file, int indent, cons
if (!is_interpreted && is_array(var->declspec.type) &&
type_array_is_decl_as_ptr(var->declspec.type) &&
- var->declspec.type->details.array.ptr_tfsoff)
+ type_get_details(var->declspec.type)->array.ptr_tfsoff)
+ {
offset = var->declspec.type->typestring_offset;
+ }
if (is_return)
print_file(file, indent, "0x52, /* FC_RETURN_PARAM */\n");
@@ -1254,7 +1256,7 @@ int is_interpreted_func( const type_t *iface, const var_t *func )
{
const char *str;
const var_t *var;
- const var_list_t *args = type_get_function_args( func->declspec.type );
+ const var_list_t *args = type_function_get_args( func->declspec.type );
const type_t *ret_type = type_function_get_rettype( func->declspec.type );
if (type_get_type( ret_type ) == TYPE_BASIC)
@@ -1305,7 +1307,7 @@ static void write_proc_func_header( FILE *file, int indent, const type_t *iface,
unsigned short num_proc )
{
var_t *var;
- var_list_t *args = type_get_function_args( func->declspec.type );
+ var_list_t *args = type_function_get_args( func->declspec.type );
unsigned char explicit_fc, implicit_fc;
unsigned char handle_flags;
const var_t *handle_var = get_func_handle_var( iface, func, &explicit_fc, &implicit_fc );
@@ -1394,7 +1396,7 @@ static void write_proc_func_header( FILE *file, int indent, const type_t *iface,
if (is_attr( func->attrs, ATTR_NOTIFY )) ext_flags |= 0x08; /* HasNotify */
if (is_attr( func->attrs, ATTR_NOTIFYFLAG )) ext_flags |= 0x10; /* HasNotify2 */
- if (iface == iface->details.iface->async_iface) oi2_flags |= 0x20;
+ if (iface == type_get_const_details(iface)->iface->async_iface) oi2_flags |= 0x20;
size = get_function_buffer_size( func, PASS_IN );
print_file( file, indent, "NdrFcShort(0x%x),\t/* client buffer = %u */\n", size, size );
@@ -1445,10 +1447,10 @@ static void write_procformatstring_func( FILE *file, int indent, const type_t *i
if (is_interpreted) write_proc_func_header( file, indent, iface, func, offset, num_proc );
/* emit argument data */
- if (type_get_function_args(func->declspec.type))
+ if (type_function_get_args(func->declspec.type))
{
const var_t *var;
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), const var_t, entry )
+ LIST_FOR_EACH_ENTRY( var, type_function_get_args(func->declspec.type), const var_t, entry )
{
print_file( file, 0, "/* %u (parameter %s) */\n", *offset, var->name );
if (is_new_style)
@@ -1488,13 +1490,13 @@ static void for_each_iface(const statement_list_t *stmts,
if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
{
- if (stmt->type != STMT_TYPE || type_get_type(stmt->u.type) != TYPE_INTERFACE)
+ if (stmt->type != STMT_TYPE || type_get_type_detect_alias(stmt->u.type) != TYPE_INTERFACE)
continue;
iface = stmt->u.type;
if (!pred(iface)) continue;
proc(iface, file, indent, offset);
- if (iface->details.iface->async_iface)
- proc(iface->details.iface->async_iface, file, indent, offset);
+ if (type_get_const_details(iface)->iface->async_iface)
+ proc(type_get_const_details(iface)->iface->async_iface, file, indent, offset);
}
}
@@ -1669,7 +1671,7 @@ static unsigned int write_conf_or_var_desc(FILE *file, const type_t *cont_type,
if (type_get_type(cont_type) == TYPE_FUNCTION)
{
- var_list_t *args = type_get_function_args( cont_type );
+ var_list_t *args = type_function_get_args( cont_type );
if (is_object( iface )) offset += pointer_size;
if (args) LIST_FOR_EACH_ENTRY( var, args, const var_t, entry )
@@ -2079,9 +2081,9 @@ int is_full_pointer_function(const var_t *func)
const var_t *var;
if (type_has_full_pointer(type_function_get_rettype(func->declspec.type), func->attrs, TRUE))
return TRUE;
- if (!type_get_function_args(func->declspec.type))
+ if (!type_function_get_args(func->declspec.type))
return FALSE;
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), const var_t, entry )
+ LIST_FOR_EACH_ENTRY( var, type_function_get_args(func->declspec.type), const var_t, entry )
if (type_has_full_pointer( var->declspec.type, var->attrs, TRUE ))
return TRUE;
return FALSE;
@@ -3621,7 +3623,7 @@ static unsigned int write_type_tfs(FILE *file, const attr_list_t *attrs,
if (ptr_type != FC_RP) update_tfsoff( type, off, file );
*typeformat_offset += 4;
}
- type->details.array.ptr_tfsoff = off;
+ type_get_details(type)->array.ptr_tfsoff = off;
}
return off;
}
@@ -3711,8 +3713,8 @@ static void process_tfs_iface(type_t *iface, FILE *file, int indent, unsigned in
var->typestring_offset = write_type_tfs( file, var->attrs, var->declspec.type, func->name,
TYPE_CONTEXT_RETVAL, offset);
- if (type_get_function_args(func->declspec.type))
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), var_t, entry )
+ if (type_function_get_args(func->declspec.type))
+ LIST_FOR_EACH_ENTRY( var, type_function_get_args(func->declspec.type), var_t, entry )
var->typestring_offset = write_type_tfs( file, var->attrs, var->declspec.type, var->name,
TYPE_CONTEXT_TOPLEVELPARAM, offset );
break;
@@ -3911,9 +3913,9 @@ static unsigned int get_function_buffer_size( const var_t *func, enum pass pass
const var_t *var;
unsigned int total_size = 0, alignment;
- if (type_get_function_args(func->declspec.type))
+ if (type_function_get_args(func->declspec.type))
{
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), const var_t, entry )
+ LIST_FOR_EACH_ENTRY( var, type_function_get_args(func->declspec.type), const var_t, entry )
{
total_size += get_required_buffer_size(var, &alignment, pass);
total_size += alignment;
@@ -4350,10 +4352,10 @@ static void write_remoting_arg(FILE *file, int indent, const var_t *func, const
((tc == FC_SMVARRAY || tc == FC_LGVARRAY) && in_attr) ||
(tc == FC_CARRAY && !in_attr))
{
- if (type_array_is_decl_as_ptr(type) && type->details.array.ptr_tfsoff)
+ if (type_array_is_decl_as_ptr(type) && type_get_const_details(type)->array.ptr_tfsoff)
{
print_phase_function(file, indent, "Pointer", local_var_prefix, phase, var,
- type->details.array.ptr_tfsoff);
+ type_get_const_details(type)->array.ptr_tfsoff);
break;
}
print_phase_function(file, indent, array_type, local_var_prefix, phase, var, start_offset);
@@ -4561,9 +4563,9 @@ void write_remoting_arguments(FILE *file, int indent, const var_t *func, const c
else
{
const var_t *var;
- if (!type_get_function_args(func->declspec.type))
+ if (!type_function_get_args(func->declspec.type))
return;
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), const var_t, entry )
+ LIST_FOR_EACH_ENTRY( var, type_function_get_args(func->declspec.type), const var_t, entry )
write_remoting_arg( file, indent, func, local_var_prefix, pass, phase, var );
}
}
@@ -4619,10 +4621,10 @@ void declare_stub_args( FILE *file, int indent, const var_t *func )
}
}
- if (!type_get_function_args(func->declspec.type))
+ if (!type_function_get_args(func->declspec.type))
return;
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), const var_t, entry )
+ LIST_FOR_EACH_ENTRY( var, type_function_get_args(func->declspec.type), const var_t, entry )
{
in_attr = is_attr(var->attrs, ATTR_IN);
out_attr = is_attr(var->attrs, ATTR_OUT);
@@ -4673,10 +4675,10 @@ void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char
const var_t *var;
type_t *ref;
- if (!type_get_function_args(func->declspec.type))
+ if (!type_function_get_args(func->declspec.type))
return;
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), const var_t, entry )
+ LIST_FOR_EACH_ENTRY( var, type_function_get_args(func->declspec.type), const var_t, entry )
{
in_attr = is_attr(var->attrs, ATTR_IN);
out_attr = is_attr(var->attrs, ATTR_OUT);
@@ -4783,7 +4785,7 @@ void write_func_param_struct( FILE *file, const type_t *iface, const type_t *fun
const char *var_decl, int add_retval )
{
var_t *retval = type_function_get_retval( func );
- const var_list_t *args = type_get_function_args( func );
+ const var_list_t *args = type_function_get_args( func );
const var_t *arg;
int needs_packing;
unsigned int align = 0;
@@ -4833,7 +4835,7 @@ void write_func_param_struct( FILE *file, const type_t *iface, const type_t *fun
void write_pointer_checks( FILE *file, int indent, const var_t *func )
{
- const var_list_t *args = type_get_function_args( func->declspec.type );
+ const var_list_t *args = type_function_get_args( func->declspec.type );
const var_t *var;
if (!args) return;
@@ -4965,7 +4967,7 @@ void write_client_call_routine( FILE *file, const type_t *iface, const var_t *fu
{
type_t *rettype = type_function_get_rettype( func->declspec.type );
int has_ret = !is_void( rettype );
- const var_list_t *args = type_get_function_args( func->declspec.type );
+ const var_list_t *args = type_function_get_args( func->declspec.type );
const var_t *arg;
int len, needs_params = 0;
diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c
index 0a8ae0f3b2..4b37b0d524 100644
--- a/tools/widl/typetree.c
+++ b/tools/widl/typetree.c
@@ -49,7 +49,6 @@ type_t *make_type(enum type_type type)
t->type_type = type;
t->attrs = NULL;
t->c_name = NULL;
- t->orig = NULL;
memset(&t->details, 0, sizeof(t->details));
t->typestring_offset = 0;
t->ptrdesc = 0;
@@ -189,14 +188,12 @@ type_t *type_new_pointer(unsigned char pointer_default, type_t *ref, attr_list_t
type_t *type_new_alias(type_t *t, const char *name)
{
- type_t *a = duptype(t, 0);
+ type_t *a = make_type(t->type_type);
a->name = xstrdup(name);
a->attrs = NULL;
- a->orig = t;
+ a->details.alias.aliasee.type = t;
a->is_alias = TRUE;
- /* for pointer types */
- a->details = t->details;
init_loc_info(&a->loc_info);
return a;
@@ -438,6 +435,7 @@ static int compute_method_indexes(type_t *iface)
void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stmts)
{
+ assert(type_get_type_detect_alias(iface) == TYPE_INTERFACE);
iface->details.iface = xmalloc(sizeof(*iface->details.iface));
iface->details.iface->disp_props = NULL;
iface->details.iface->disp_methods = NULL;
@@ -451,6 +449,7 @@ void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stm
void type_dispinterface_define(type_t *iface, var_list_t *props, var_list_t *methods)
{
+ assert(type_get_type_detect_alias(iface) == TYPE_INTERFACE);
iface->details.iface = xmalloc(sizeof(*iface->details.iface));
iface->details.iface->disp_props = props;
iface->details.iface->disp_methods = methods;
@@ -465,6 +464,7 @@ void type_dispinterface_define(type_t *iface, var_list_t *props, var_list_t *met
void type_dispinterface_define_from_iface(type_t *dispiface, type_t *iface)
{
+ assert(type_get_type_detect_alias(iface) == TYPE_INTERFACE);
dispiface->details.iface = xmalloc(sizeof(*dispiface->details.iface));
dispiface->details.iface->disp_props = NULL;
dispiface->details.iface->disp_methods = NULL;
@@ -479,6 +479,7 @@ void type_dispinterface_define_from_iface(type_t *dispiface, type_t *iface)
void type_module_define(type_t *module, statement_list_t *stmts)
{
+ assert(type_get_type_detect_alias(module) == TYPE_MODULE);
if (module->details.module) error_loc("multiple definition error\n");
module->details.module = xmalloc(sizeof(*module->details.module));
module->details.module->stmts = stmts;
@@ -487,6 +488,7 @@ void type_module_define(type_t *module, statement_list_t *stmts)
type_t *type_coclass_define(type_t *coclass, ifref_list_t *ifaces)
{
+ assert(type_get_type_detect_alias(coclass) == TYPE_COCLASS);
coclass->details.coclass.ifaces = ifaces;
coclass->defined = TRUE;
return coclass;
diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h
index 22232fc0a7..1fd86bbc89 100644
--- a/tools/widl/typetree.h
+++ b/tools/widl/typetree.h
@@ -56,11 +56,35 @@ const char *type_get_name(const type_t *type, enum name_type name_type);
/* FIXME: shouldn't need to export this */
type_t *duptype(type_t *t, int dupname);
+#define STATEMENTS_FOR_EACH_FUNC(stmt, stmts) \
+ if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, statement_t, entry ) \
+ if (stmt->type == STMT_DECLARATION && stmt->u.var->declspec.stgclass == STG_NONE && \
+ type_get_type_detect_alias(stmt->u.var->declspec.type) == TYPE_FUNCTION)
+
+static inline enum type_type type_get_type_detect_alias(const type_t *type)
+{
+ if (type->is_alias)
+ return TYPE_ALIAS;
+ return type->type_type;
+}
+
+static inline int statements_has_func(const statement_list_t *stmts)
+{
+ const statement_t *stmt;
+ int has_func = 0;
+ STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
+ {
+ has_func = 1;
+ break;
+ }
+ return has_func;
+}
+
/* un-alias the type until finding the non-alias type */
static inline type_t *type_get_real_type(const type_t *type)
{
if (type->is_alias)
- return type_get_real_type(type->orig);
+ return type_get_real_type(type->details.alias.aliasee.type);
else
return (type_t *)type;
}
@@ -281,10 +305,15 @@ static inline int type_is_alias(const type_t *type)
return type->is_alias;
}
-static inline type_t *type_alias_get_aliasee(const type_t *type)
+static inline const decl_spec_t *type_alias_get_aliasee(const type_t *type)
{
assert(type_is_alias(type));
- return type->orig;
+ return &type->details.alias.aliasee;
+}
+
+static inline type_t *type_alias_get_aliasee_type(const type_t *type)
+{
+ return type_alias_get_aliasee(type)->type;
}
static inline ifref_list_t *type_coclass_get_ifaces(const type_t *type)
@@ -327,4 +356,22 @@ static inline const expr_t *type_bitfield_get_bits(const type_t *type)
return type->details.bitfield.bits;
}
+/* gets pointer to details_t union with the assumption the caller wants to write to it
+ * so assert if we're actually dealing with an alias and writing to the details would
+ * overwrite the alias_details
+ */
+static inline details_t *type_get_details(type_t* type)
+{
+ assert(!type_is_alias(type));
+ return &type->details;
+}
+
+/* const overload of type_get_details */
+
+static inline const details_t *type_get_const_details(const type_t* type)
+{
+ assert(!type_is_alias(type));
+ return &type->details;
+}
+
#endif /* WIDL_TYPE_TREE_H */
diff --git a/tools/widl/widl.c b/tools/widl/widl.c
index 0bcf67ba73..866c897ebb 100644
--- a/tools/widl/widl.c
+++ b/tools/widl/widl.c
@@ -494,6 +494,7 @@ static void write_id_data_stmts(const statement_list_t *stmts)
uuid = get_attrp(type->attrs, ATTR_UUID);
write_id_guid(idfile, "IID", is_attr(type->attrs, ATTR_DISPINTERFACE) ? "DIID" : "IID",
type->name, uuid);
+ assert(type_get_type_detect_alias(type) == TYPE_INTERFACE);
if (type->details.iface->async_iface)
{
uuid = get_attrp(type->details.iface->async_iface->attrs, ATTR_UUID);
diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h
index bd727f70b6..d637e0024c 100644
--- a/tools/widl/widltypes.h
+++ b/tools/widl/widltypes.h
@@ -394,6 +394,11 @@ struct bitfield_details
const expr_t *bits;
};
+struct alias_details
+{
+ struct _decl_spec_t aliasee;
+};
+
#define HASHMAX 64
struct namespace {
@@ -422,26 +427,28 @@ enum type_type
TYPE_BITFIELD,
};
+typedef union _details_t
+{
+ struct struct_details *structure;
+ struct enumeration_details *enumeration;
+ struct func_details *function;
+ struct iface_details *iface;
+ struct module_details *module;
+ struct array_details array;
+ struct coclass_details coclass;
+ struct basic_details basic;
+ struct pointer_details pointer;
+ struct bitfield_details bitfield;
+ struct alias_details alias;
+} details_t;
+
struct _type_t {
const char *name;
struct namespace *namespace;
enum type_type type_type;
attr_list_t *attrs;
- union
- {
- struct struct_details *structure;
- struct enumeration_details *enumeration;
- struct func_details *function;
- struct iface_details *iface;
- struct module_details *module;
- struct array_details array;
- struct coclass_details coclass;
- struct basic_details basic;
- struct pointer_details pointer;
- struct bitfield_details bitfield;
- } details;
+ details_t details;
const char *c_name;
- type_t *orig; /* dup'd types */
unsigned int typestring_offset;
unsigned int ptrdesc; /* used for complex structs */
int typelib_idx;
@@ -589,35 +596,6 @@ void init_loc_info(loc_info_t *);
char *format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix);
-static inline var_list_t *type_get_function_args(const type_t *func_type)
-{
- return func_type->details.function->args;
-}
-
-static inline enum type_type type_get_type_detect_alias(const type_t *type)
-{
- if (type->is_alias)
- return TYPE_ALIAS;
- return type->type_type;
-}
-
-#define STATEMENTS_FOR_EACH_FUNC(stmt, stmts) \
- if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, statement_t, entry ) \
- if (stmt->type == STMT_DECLARATION && stmt->u.var->declspec.stgclass == STG_NONE && \
- type_get_type_detect_alias(stmt->u.var->declspec.type) == TYPE_FUNCTION)
-
-static inline int statements_has_func(const statement_list_t *stmts)
-{
- const statement_t *stmt;
- int has_func = 0;
- STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
- {
- has_func = 1;
- break;
- }
- return has_func;
-}
-
static inline int is_global_namespace(const struct namespace *namespace)
{
return !namespace->name;
diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c
index 9a3edf7291..13d768ab2e 100644
--- a/tools/widl/write_msft.c
+++ b/tools/widl/write_msft.c
@@ -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));
+ type_t *element_type = type_alias_get_aliasee_type(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(type)),
+ encode_type(typelib, next_vt, type_alias_get_aliasee_type(type_array_get_element_type(type)),
&target_type, &child_size);
for (typeoffset = 0; typeoffset < typelib->typelib_segdir[MSFT_SEG_TYPEDESC].length; typeoffset += 8) {
@@ -968,7 +968,7 @@ static int encode_type(
{
/* typedef'd types without public attribute aren't included in the typelib */
while (type_is_alias(type) && !is_attr(type->attrs, ATTR_PUBLIC))
- type = type_alias_get_aliasee(type);
+ type = type_alias_get_aliasee_type(type);
chat("encode_type: VT_USERDEFINED - adding new type %s, real type %d\n",
type->name, type_get_type(type));
@@ -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_type(ref));
+ type_t *element_type = type_alias_get_aliasee_type(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];
@@ -1301,8 +1301,8 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, var_t *func, int index)
return S_FALSE;
}
- if (type_get_function_args(func->declspec.type))
- LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->declspec.type), var_t, entry )
+ if (type_function_get_args(func->declspec.type))
+ LIST_FOR_EACH_ENTRY( arg, type_function_get_args(func->declspec.type), var_t, entry )
{
num_params++;
if (arg->attrs) LIST_FOR_EACH_ENTRY( attr, arg->attrs, const attr_t, entry ) {
@@ -1471,10 +1471,10 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, var_t *func, int index)
warning("unknown number of optional attrs\n");
}
- if (type_get_function_args(func->declspec.type))
+ if (type_function_get_args(func->declspec.type))
{
i = 0;
- LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->declspec.type), var_t, entry )
+ LIST_FOR_EACH_ENTRY( arg, type_function_get_args(func->declspec.type), var_t, entry )
{
int paramflags = 0;
int *paramdata = typedata + 6 + extra_attr + (num_defaults ? num_params : 0) + i * 3;
@@ -1572,10 +1572,10 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, var_t *func, int index)
if(typeinfo->typekind == TKIND_MODULE)
namedata[9] |= 0x20;
- if (type_get_function_args(func->declspec.type))
+ if (type_function_get_args(func->declspec.type))
{
i = 0;
- LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->declspec.type), var_t, entry )
+ LIST_FOR_EACH_ENTRY( arg, type_function_get_args(func->declspec.type), var_t, entry )
{
/* don't give the last arg of a [propput*] func a name */
if(i != num_params - 1 || (invokekind != 0x4 /* INVOKE_PROPERTYPUT */ && invokekind != 0x8 /* INVOKE_PROPERTYPUTREF */))
@@ -1977,6 +1977,7 @@ static void add_dispinterface_typeinfo(msft_typelib_t *typelib, type_t *dispinte
var_t *var;
msft_typeinfo_t *msft_typeinfo;
+ assert(type_get_type_detect_alias(dispinterface) == TYPE_INTERFACE);
if (-1 < dispinterface->typelib_idx)
return;
@@ -2181,7 +2182,7 @@ static void add_typedef_typeinfo(msft_typelib_t *typelib, type_t *tdef)
if (-1 < tdef->typelib_idx)
return;
- type = type_alias_get_aliasee(tdef);
+ type = type_alias_get_aliasee_type(tdef);
if (!type->name || strcmp(tdef->name, type->name) != 0)
{
@@ -2297,6 +2298,7 @@ static void add_module_typeinfo(msft_typelib_t *typelib, type_t *module)
const statement_t *stmt;
msft_typeinfo_t *msft_typeinfo;
+ assert(type_get_type_detect_alias(module) == TYPE_MODULE);
if (-1 < module->typelib_idx)
return;
@@ -2364,7 +2366,7 @@ static void add_entry(msft_typelib_t *typelib, const statement_t *stmt)
if (is_attr(type_entry->type->attrs, ATTR_PUBLIC))
add_typedef_typeinfo(typelib, type_entry->type);
else
- add_type_typeinfo(typelib, type_alias_get_aliasee(type_entry->type));
+ add_type_typeinfo(typelib, type_alias_get_aliasee_type(type_entry->type));
}
break;
}
--
2.17.1
July 5, 2019
[PATCH 02/15] widl: refactor to have array type's element use decl_spec_t rather than type_t
by Richard Pospesel
Signed-off-by: Richard Pospesel <richard(a)torproject.org>
---
tools/widl/expr.c | 4 +--
tools/widl/header.c | 8 +++---
tools/widl/header.h | 2 +-
tools/widl/parser.y | 16 +++++------
tools/widl/typegen.c | 60 ++++++++++++++++++++---------------------
tools/widl/typelib.c | 4 +--
tools/widl/typetree.c | 2 +-
tools/widl/typetree.h | 9 +++++--
tools/widl/widltypes.h | 2 +-
tools/widl/write_msft.c | 12 ++++-----
10 files changed, 62 insertions(+), 57 deletions(-)
diff --git a/tools/widl/expr.c b/tools/widl/expr.c
index 7ec42db79f..55efc694dd 100644
--- a/tools/widl/expr.c
+++ b/tools/widl/expr.c
@@ -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",
diff --git a/tools/widl/header.c b/tools/widl/header.c
index 3e8cbfae5e..c10b149d89 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -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;
}
diff --git a/tools/widl/header.h b/tools/widl/header.h
index 0d44b4039f..e4aa0f0088 100644
--- a/tools/widl/header.h
+++ b/tools/widl/header.h
@@ -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)
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 50e42291bd..6075d231f6 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -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:
diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index f685f7156a..19255ec850 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -510,7 +510,7 @@ unsigned char get_struct_fc(const type_t *type)
continue;
}
- if (is_array(type_array_get_element(field->declspec.type)))
+ if (is_array(type_array_get_element_type(field->declspec.type)))
return FC_BOGUS_STRUCT;
if (type_array_has_conformance(field->declspec.type))
@@ -523,7 +523,7 @@ unsigned char get_struct_fc(const type_t *type)
if (type_array_has_variance(t))
has_variance = 1;
- t = type_array_get_element(t);
+ t = type_array_get_element_type(t);
typegen_type = typegen_detect_type(t, field->attrs, TDT_IGNORE_STRINGS);
}
@@ -625,7 +625,7 @@ static unsigned char get_array_fc(const type_t *type)
const expr_t *size_is;
const type_t *elem_type;
- elem_type = type_array_get_element(type);
+ elem_type = type_array_get_element_type(type);
size_is = type_array_get_conformance(type);
if (!size_is)
@@ -714,7 +714,7 @@ static int type_has_pointers(const type_t *type)
case TGT_POINTER:
return TRUE;
case TGT_ARRAY:
- return type_array_is_decl_as_ptr(type) || type_has_pointers(type_array_get_element(type));
+ return type_array_is_decl_as_ptr(type) || type_has_pointers(type_array_get_element_type(type));
case TGT_STRUCT:
{
var_list_t *fields = type_struct_get_fields(type);
@@ -768,7 +768,7 @@ static int type_has_full_pointer(const type_t *type, const attr_list_t *attrs,
if (get_pointer_fc(type, attrs, toplevel_param) == FC_FP)
return TRUE;
else
- return type_has_full_pointer(type_array_get_element(type), NULL, FALSE);
+ return type_has_full_pointer(type_array_get_element_type(type), NULL, FALSE);
case TGT_STRUCT:
{
var_list_t *fields = type_struct_get_fields(type);
@@ -1944,12 +1944,12 @@ unsigned int type_memsize_and_alignment(const type_t *t, unsigned int *align)
{
if (is_conformant_array(t))
{
- type_memsize_and_alignment(type_array_get_element(t), align);
+ type_memsize_and_alignment(type_array_get_element_type(t), align);
size = 0;
}
else
size = type_array_get_dim(t) *
- type_memsize_and_alignment(type_array_get_element(t), align);
+ type_memsize_and_alignment(type_array_get_element_type(t), align);
}
else /* declared as a pointer */
{
@@ -2054,7 +2054,7 @@ static unsigned int type_buffer_alignment(const type_t *t)
break;
case TYPE_ARRAY:
if (!type_array_is_decl_as_ptr(t))
- return type_buffer_alignment( type_array_get_element(t) );
+ return type_buffer_alignment( type_array_get_element_type(t) );
/* else fall through */
case TYPE_POINTER:
return 4;
@@ -2378,7 +2378,7 @@ static void write_member_type(FILE *file, const type_t *cont,
static void write_array_element_type(FILE *file, const attr_list_t *attrs, const type_t *type,
int cont_is_complex, unsigned int *tfsoff)
{
- type_t *elem = type_array_get_element(type);
+ type_t *elem = type_array_get_element_type(type);
if (!is_embedded_complex(elem) && is_ptr(elem))
{
@@ -2506,7 +2506,7 @@ static int write_pointer_description_offsets(
if (is_array(type))
{
return write_pointer_description_offsets(
- file, attrs, type_array_get_element(type), offset_in_memory,
+ file, attrs, type_array_get_element_type(type), offset_in_memory,
offset_in_buffer, typestring_offset);
}
else if (is_non_complex_struct(type))
@@ -2609,14 +2609,14 @@ static int write_fixed_array_pointer_descriptions(
/* unfortunately, this needs to be done in two passes to avoid
* writing out redundant FC_FIXED_REPEAT descriptions */
pointer_count = write_pointer_description_offsets(
- NULL, attrs, type_array_get_element(type), NULL, NULL, &temp);
+ NULL, attrs, type_array_get_element_type(type), NULL, NULL, &temp);
if (pointer_count > 0)
{
unsigned int increment_size;
unsigned int offset_of_array_pointer_mem = 0;
unsigned int offset_of_array_pointer_buf = 0;
- increment_size = type_memsize(type_array_get_element(type));
+ increment_size = type_memsize(type_array_get_element_type(type));
print_file(file, 2, "0x%02x, /* FC_FIXED_REPEAT */\n", FC_FIXED_REPEAT);
print_file(file, 2, "0x%02x, /* FC_PAD */\n", FC_PAD);
@@ -2680,14 +2680,14 @@ static int write_conformant_array_pointer_descriptions(
/* unfortunately, this needs to be done in two passes to avoid
* writing out redundant FC_VARIABLE_REPEAT descriptions */
pointer_count = write_pointer_description_offsets(
- NULL, attrs, type_array_get_element(type), NULL, NULL, &temp);
+ NULL, attrs, type_array_get_element_type(type), NULL, NULL, &temp);
if (pointer_count > 0)
{
unsigned int increment_size;
unsigned int offset_of_array_pointer_mem = offset_in_memory;
unsigned int offset_of_array_pointer_buf = offset_in_memory;
- increment_size = type_memsize(type_array_get_element(type));
+ increment_size = type_memsize(type_array_get_element_type(type));
if (increment_size > USHRT_MAX)
error("array size of %u bytes is too large\n", increment_size);
@@ -2700,7 +2700,7 @@ static int write_conformant_array_pointer_descriptions(
*typestring_offset += 8;
pointer_count = write_pointer_description_offsets(
- file, attrs, type_array_get_element(type),
+ file, attrs, type_array_get_element_type(type),
&offset_of_array_pointer_mem, &offset_of_array_pointer_buf,
typestring_offset);
}
@@ -2724,12 +2724,12 @@ static int write_varying_array_pointer_descriptions(
/* unfortunately, this needs to be done in two passes to avoid
* writing out redundant FC_VARIABLE_REPEAT descriptions */
pointer_count = write_pointer_description_offsets(
- NULL, attrs, type_array_get_element(type), NULL, NULL, &temp);
+ NULL, attrs, type_array_get_element_type(type), NULL, NULL, &temp);
if (pointer_count > 0)
{
unsigned int increment_size;
- increment_size = type_memsize(type_array_get_element(type));
+ increment_size = type_memsize(type_array_get_element_type(type));
if (increment_size > USHRT_MAX)
error("array size of %u bytes is too large\n", increment_size);
@@ -2742,7 +2742,7 @@ static int write_varying_array_pointer_descriptions(
*typestring_offset += 8;
pointer_count = write_pointer_description_offsets(
- file, attrs, type_array_get_element(type), offset_in_memory,
+ file, attrs, type_array_get_element_type(type), offset_in_memory,
offset_in_buffer, typestring_offset);
}
}
@@ -2864,7 +2864,7 @@ static unsigned int write_string_tfs(FILE *file, const attr_list_t *attrs,
}
if (is_array(type))
- elem_type = type_array_get_element(type);
+ elem_type = type_array_get_element_type(type);
else
elem_type = type_pointer_get_ref(type);
@@ -2957,11 +2957,11 @@ static unsigned int write_array_tfs(FILE *file, const attr_list_t *attrs, type_t
? type_memsize(current_structure)
: 0;
- if (!is_string_type(attrs, type_array_get_element(type)))
- write_embedded_types(file, attrs, type_array_get_element(type), name, FALSE, typestring_offset);
+ if (!is_string_type(attrs, type_array_get_element_type(type)))
+ write_embedded_types(file, attrs, type_array_get_element_type(type), name, FALSE, typestring_offset);
- size = type_memsize(is_conformant_array(type) ? type_array_get_element(type) : type);
- align = type_buffer_alignment(is_conformant_array(type) ? type_array_get_element(type) : type);
+ size = type_memsize(is_conformant_array(type) ? type_array_get_element_type(type) : type);
+ align = type_buffer_alignment(is_conformant_array(type) ? type_array_get_element_type(type) : type);
fc = get_array_fc(type);
start_offset = *typestring_offset;
@@ -2992,7 +2992,7 @@ static unsigned int write_array_tfs(FILE *file, const attr_list_t *attrs, type_t
if (fc == FC_SMVARRAY || fc == FC_LGVARRAY)
{
- unsigned int elsize = type_memsize(type_array_get_element(type));
+ unsigned int elsize = type_memsize(type_array_get_element_type(type));
unsigned int dim = type_array_get_dim(type);
if (fc == FC_LGVARRAY)
@@ -3015,7 +3015,7 @@ static unsigned int write_array_tfs(FILE *file, const attr_list_t *attrs, type_t
+= write_conf_or_var_desc(file, current_structure, baseoff,
type, length_is);
- if (type_has_pointers(type_array_get_element(type)) &&
+ if (type_has_pointers(type_array_get_element_type(type)) &&
(type_array_is_decl_as_ptr(type) || !current_structure))
{
print_file(file, 2, "0x%x,\t/* FC_PP */\n", FC_PP);
@@ -3868,7 +3868,7 @@ static unsigned int get_required_buffer_size_type(
case FC_SMFARRAY:
case FC_LGFARRAY:
return type_array_get_dim(type) *
- get_required_buffer_size_type(type_array_get_element(type), name,
+ get_required_buffer_size_type(type_array_get_element_type(type), name,
NULL, FALSE, alignment);
}
}
@@ -4098,7 +4098,7 @@ expr_t *get_size_is_expr(const type_t *t, const char *name)
{
expr_t *x = NULL;
- for ( ; is_array(t); t = type_array_get_element(t))
+ for ( ; is_array(t); t = type_array_get_element_type(t))
if (type_array_has_conformance(t) &&
type_array_get_conformance(t)->type != EXPR_VOID)
{
@@ -4704,7 +4704,7 @@ void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char
fprintf(file, " = NdrAllocate(&__frame->_StubMsg, ");
for (type = var->declspec.type;
is_array(type) && type_array_has_conformance(type);
- type = type_array_get_element(type))
+ type = type_array_get_element_type(type))
{
write_expr(file, type_array_get_conformance(type), TRUE,
TRUE, NULL, NULL, local_var_prefix);
@@ -4716,7 +4716,7 @@ void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char
print_file(file, indent, "memset(%s%s, 0, ", local_var_prefix, var->name);
for (type = var->declspec.type;
is_array(type) && type_array_has_conformance(type);
- type = type_array_get_element(type))
+ type = type_array_get_element_type(type))
{
write_expr(file, type_array_get_conformance(type), TRUE,
TRUE, NULL, NULL, local_var_prefix);
@@ -4750,7 +4750,7 @@ void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char
print_file(file, indent, "%s_W%u = 0;\n", local_var_prefix, i);
break;
}
- ref = type_array_get_element(ref);
+ ref = type_array_get_element_type(ref);
/* fall through */
case TGT_STRUCT:
case TGT_UNION:
diff --git a/tools/widl/typelib.c b/tools/widl/typelib.c
index 93f8f4de19..bf667a9a23 100644
--- a/tools/widl/typelib.c
+++ b/tools/widl/typelib.c
@@ -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;
}
diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c
index 3b0c944387..51e54d2a9f 100644
--- a/tools/widl/typetree.c
+++ b/tools/widl/typetree.c
@@ -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;
}
diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h
index 9f0dc5afc6..3205d58450 100644
--- a/tools/widl/typetree.h
+++ b/tools/widl/typetree.h
@@ -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)
diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h
index 31a0cc74dd..6ab419b30e 100644
--- a/tools/widl/widltypes.h
+++ b/tools/widl/widltypes.h
@@ -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 */
diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c
index 7738cae729..ff3a63bf46 100644
--- a/tools/widl/write_msft.c
+++ b/tools/widl/write_msft.c
@@ -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];
--
2.17.1
July 5, 2019
[PATCH 01/15] widl: change struct _var_t's type member to a struct _decl_spec_t
by Richard Pospesel
Signed-off-by: Richard Pospesel <richard(a)torproject.org>
---
tools/widl/client.c | 32 ++--
tools/widl/expr.c | 8 +-
tools/widl/header.c | 116 +++++++-------
tools/widl/parser.y | 113 +++++++-------
tools/widl/proxy.c | 58 +++----
tools/widl/server.c | 16 +-
tools/widl/typegen.c | 334 ++++++++++++++++++++--------------------
tools/widl/typetree.c | 8 +-
tools/widl/typetree.h | 4 +-
tools/widl/widltypes.h | 25 ++-
tools/widl/write_msft.c | 22 +--
11 files changed, 372 insertions(+), 364 deletions(-)
diff --git a/tools/widl/client.c b/tools/widl/client.c
index fe88f5993c..b0a5d0cc8c 100644
--- a/tools/widl/client.c
+++ b/tools/widl/client.c
@@ -52,9 +52,9 @@ static void print_client( const char *format, ... )
static void write_client_func_decl( const type_t *iface, const var_t *func )
{
- const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV);
- const var_list_t *args = type_get_function_args(func->type);
- type_t *rettype = type_function_get_rettype(func->type);
+ const char *callconv = get_attrp(func->declspec.type->attrs, ATTR_CALLCONV);
+ const var_list_t *args = type_get_function_args(func->declspec.type);
+ type_t *rettype = type_function_get_rettype(func->declspec.type);
if (!callconv) callconv = "__cdecl";
write_type_decl_left(client, rettype);
@@ -74,9 +74,9 @@ static void write_function_stub( const type_t *iface, const var_t *func,
{
unsigned char explicit_fc, implicit_fc;
int has_full_pointer = is_full_pointer_function(func);
- var_t *retval = type_function_get_retval(func->type);
+ var_t *retval = type_function_get_retval(func->declspec.type);
const var_t *handle_var = get_func_handle_var( iface, func, &explicit_fc, &implicit_fc );
- int has_ret = !is_void(retval->type);
+ int has_ret = !is_void(retval->declspec.type);
if (is_interpreted_func( iface, func ))
{
@@ -97,7 +97,7 @@ static void write_function_stub( const type_t *iface, const var_t *func,
print_client("RPC_BINDING_HANDLE _Handle;\n");
}
- if (has_ret && decl_indirect(retval->type))
+ if (has_ret && decl_indirect(retval->declspec.type))
{
print_client("void *_p_%s;\n", retval->name);
}
@@ -136,7 +136,7 @@ static void write_function_stub( const type_t *iface, const var_t *func,
if (has_ret)
{
print_client("%s", "");
- write_type_decl(client, retval->type, retval->name);
+ write_type_decl(client, retval->declspec.type, retval->name);
fprintf(client, ";\n");
}
print_client("RPC_MESSAGE _RpcMessage;\n");
@@ -147,7 +147,7 @@ static void write_function_stub( const type_t *iface, const var_t *func,
if (explicit_fc == FC_BIND_GENERIC)
print_client("__frame->%s = %s;\n", handle_var->name, handle_var->name );
}
- if (has_ret && decl_indirect(retval->type))
+ if (has_ret && decl_indirect(retval->declspec.type))
{
print_client("__frame->_p_%s = &%s;\n", retval->name, retval->name);
}
@@ -194,7 +194,7 @@ static void write_function_stub( const type_t *iface, const var_t *func,
/* if the context_handle attribute appears in the chain of types
* without pointers being followed, then the context handle must
* be direct, otherwise it is a pointer */
- int is_ch_ptr = !is_aliaschain_attr(handle_var->type, ATTR_CONTEXTHANDLE);
+ int is_ch_ptr = !is_aliaschain_attr(handle_var->declspec.type, ATTR_CONTEXTHANDLE);
print_client("if (%s%s != 0)\n", is_ch_ptr ? "*" : "", handle_var->name);
indent++;
print_client("__frame->_Handle = NDRCContextBinding(%s%s);\n",
@@ -257,9 +257,9 @@ static void write_function_stub( const type_t *iface, const var_t *func,
/* unmarshal return value */
if (has_ret)
{
- if (decl_indirect(retval->type))
+ if (decl_indirect(retval->declspec.type))
print_client("MIDL_memset(&%s, 0, sizeof(%s));\n", retval->name, retval->name);
- else if (is_ptr(retval->type) || is_array(retval->type))
+ else if (is_ptr(retval->declspec.type) || is_array(retval->declspec.type))
print_client("%s = 0;\n", retval->name);
write_remoting_arguments(client, indent, func, "", PASS_RETURN, PHASE_UNMARSHAL);
}
@@ -365,8 +365,8 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
case STMT_DECLARATION:
{
const var_t *func = stmt->u.var;
- if (stmt->u.var->stgclass != STG_NONE
- || type_get_type_detect_alias(stmt->u.var->type) != TYPE_FUNCTION)
+ if (stmt->u.var->declspec.stgclass != STG_NONE
+ || type_get_type_detect_alias(stmt->u.var->declspec.type) != TYPE_FUNCTION)
continue;
write_function_stub( iface, func, method_count++, *proc_offset );
*proc_offset += get_size_procformatstring_func( iface, func );
@@ -488,7 +488,7 @@ static void write_implicithandledecl(type_t *iface)
if (implicit_handle)
{
- write_type_decl( client, implicit_handle->type, implicit_handle->name );
+ write_type_decl( client, implicit_handle->declspec.type, implicit_handle->name );
fprintf(client, ";\n\n");
}
}
@@ -532,8 +532,8 @@ static void write_client_ifaces(const statement_list_t *stmts, int expr_eval_rou
LIST_FOR_EACH_ENTRY(stmt2, type_iface_get_stmts(iface), const statement_t, entry)
{
- if (stmt2->type == STMT_DECLARATION && stmt2->u.var->stgclass == STG_NONE &&
- type_get_type_detect_alias(stmt2->u.var->type) == TYPE_FUNCTION)
+ if (stmt2->type == STMT_DECLARATION && stmt2->u.var->declspec.stgclass == STG_NONE &&
+ type_get_type_detect_alias(stmt2->u.var->declspec.type) == TYPE_FUNCTION)
{
needs_stub = 1;
break;
diff --git a/tools/widl/expr.c b/tools/widl/expr.c
index 2ed4aff6ad..7ec42db79f 100644
--- a/tools/widl/expr.c
+++ b/tools/widl/expr.c
@@ -194,10 +194,10 @@ expr_t *make_exprt(enum expr_type type, var_t *var, expr_t *expr)
expr_t *e;
type_t *tref;
- if (var->stgclass != STG_NONE && var->stgclass != STG_REGISTER)
+ if (var->declspec.stgclass != STG_NONE && var->declspec.stgclass != STG_REGISTER)
error_loc("invalid storage class for type expression\n");
- tref = var->type;
+ tref = var->declspec.type;
e = xmalloc(sizeof(expr_t));
e->type = type;
@@ -474,7 +474,7 @@ static type_t *find_identifier(const char *identifier, const type_t *cont_type,
if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
if (field->name && !strcmp(identifier, field->name))
{
- type = field->type;
+ type = field->declspec.type;
*found_in_cont_type = 1;
break;
}
@@ -482,7 +482,7 @@ static type_t *find_identifier(const char *identifier, const type_t *cont_type,
if (!type)
{
var_t *const_var = find_const(identifier, 0);
- if (const_var) type = const_var->type;
+ if (const_var) type = const_var->declspec.type;
}
return type;
diff --git a/tools/widl/header.c b/tools/widl/header.c
index f618e02f3d..3e8cbfae5e 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -69,7 +69,7 @@ int is_ptrchain_attr(const var_t *var, enum attr_type t)
return 1;
else
{
- type_t *type = var->type;
+ type_t *type = var->declspec.type;
for (;;)
{
if (is_attr(type->attrs, t))
@@ -204,9 +204,9 @@ static void write_fields(FILE *h, var_list_t *fields)
if (!fields) return;
LIST_FOR_EACH_ENTRY( v, fields, var_t, entry ) {
- if (!v || !v->type) continue;
+ if (!v || !v->declspec.type) continue;
- switch(type_get_type_detect_alias(v->type)) {
+ switch(type_get_type_detect_alias(v->declspec.type)) {
case TYPE_STRUCT:
case TYPE_ENCAPSULATED_UNION:
nameless_struct_cnt++;
@@ -220,12 +220,12 @@ static void write_fields(FILE *h, var_list_t *fields)
}
LIST_FOR_EACH_ENTRY( v, fields, var_t, entry ) {
- if (!v || !v->type) continue;
+ if (!v || !v->declspec.type) continue;
indent(h, 0);
name = v->name;
- switch(type_get_type_detect_alias(v->type)) {
+ switch(type_get_type_detect_alias(v->declspec.type)) {
case TYPE_STRUCT:
case TYPE_ENCAPSULATED_UNION:
if(!v->name) {
@@ -252,7 +252,7 @@ static void write_fields(FILE *h, var_list_t *fields)
default:
;
}
- write_type_def_or_decl(h, v->type, TRUE, name);
+ write_type_def_or_decl(h, v->declspec.type, TRUE, name);
fprintf(h, ";\n");
}
}
@@ -697,7 +697,7 @@ void check_for_additional_prototype_types(type_t *type)
break;
}
if (vars) LIST_FOR_EACH_ENTRY( v, vars, const var_t, entry )
- check_for_additional_prototype_types(v->type);
+ check_for_additional_prototype_types(v->declspec.type);
}
if (type_is_alias(type))
@@ -800,7 +800,7 @@ int is_const_decl(const var_t *var)
* declaration to mean that data isn't being instantiated. this appears
* to be a bug, but there is no benefit to being incompatible with MIDL,
* so we'll do the same thing */
- for (t = var->type; ; )
+ for (t = var->declspec.type; ; )
{
if (is_attr(t->attrs, ATTR_CONST))
return TRUE;
@@ -821,7 +821,7 @@ static void write_declaration(FILE *header, const var_t *v)
}
else
{
- switch (v->stgclass)
+ switch (v->declspec.stgclass)
{
case STG_NONE:
case STG_REGISTER: /* ignored */
@@ -833,7 +833,7 @@ static void write_declaration(FILE *header, const var_t *v)
fprintf(header, "extern ");
break;
}
- write_type_def_or_decl(header, v->type, FALSE, v->name);
+ write_type_def_or_decl(header, v->declspec.type, FALSE, v->name);
fprintf(header, ";\n\n");
}
}
@@ -850,7 +850,7 @@ static void write_library(FILE *header, const typelib_t *typelib)
const type_t* get_explicit_generic_handle_type(const var_t* var)
{
const type_t *t;
- for (t = var->type;
+ for (t = var->declspec.type;
is_ptr(t) || type_is_alias(t);
t = type_is_alias(t) ? type_alias_get_aliasee(t) : type_pointer_get_ref(t))
if ((type_get_type_detect_alias(t) != TYPE_BASIC || type_basic_get_type(t) != TYPE_BASIC_HANDLE) &&
@@ -863,13 +863,13 @@ const var_t *get_func_handle_var( const type_t *iface, const var_t *func,
unsigned char *explicit_fc, unsigned char *implicit_fc )
{
const var_t *var;
- const var_list_t *args = type_get_function_args( func->type );
+ const var_list_t *args = type_get_function_args( func->declspec.type );
*explicit_fc = *implicit_fc = 0;
if (args) LIST_FOR_EACH_ENTRY( var, args, const var_t, entry )
{
if (!is_attr( var->attrs, ATTR_IN ) && is_attr( var->attrs, ATTR_OUT )) continue;
- if (type_get_type( var->type ) == TYPE_BASIC && type_basic_get_type( var->type ) == TYPE_BASIC_HANDLE)
+ if (type_get_type( var->declspec.type ) == TYPE_BASIC && type_basic_get_type( var->declspec.type ) == TYPE_BASIC_HANDLE)
{
*explicit_fc = FC_BIND_PRIMITIVE;
return var;
@@ -879,7 +879,7 @@ const var_t *get_func_handle_var( const type_t *iface, const var_t *func,
*explicit_fc = FC_BIND_GENERIC;
return var;
}
- if (is_context_handle( var->type ))
+ if (is_context_handle( var->declspec.type ))
{
*explicit_fc = FC_BIND_CONTEXT;
return var;
@@ -888,8 +888,8 @@ const var_t *get_func_handle_var( const type_t *iface, const var_t *func,
if ((var = get_attrp( iface->attrs, ATTR_IMPLICIT_HANDLE )))
{
- if (type_get_type( var->type ) == TYPE_BASIC &&
- type_basic_get_type( var->type ) == TYPE_BASIC_HANDLE)
+ if (type_get_type( var->declspec.type ) == TYPE_BASIC &&
+ type_basic_get_type( var->declspec.type ) == TYPE_BASIC_HANDLE)
*implicit_fc = FC_BIND_PRIMITIVE;
else
*implicit_fc = FC_BIND_GENERIC;
@@ -904,13 +904,13 @@ int has_out_arg_or_return(const var_t *func)
{
const var_t *var;
- if (!is_void(type_function_get_rettype(func->type)))
+ if (!is_void(type_function_get_rettype(func->declspec.type)))
return 1;
- if (!type_get_function_args(func->type))
+ if (!type_get_function_args(func->declspec.type))
return 0;
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry )
+ LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), const var_t, entry )
if (is_attr(var->attrs, ATTR_OUT))
return 1;
@@ -990,7 +990,7 @@ static int is_override_method(const type_t *iface, const type_t *child, const va
static int is_aggregate_return(const var_t *func)
{
- enum type_type type = type_get_type(type_function_get_rettype(func->type));
+ enum type_type type = type_get_type(type_function_get_rettype(func->declspec.type));
return type == TYPE_STRUCT || type == TYPE_UNION ||
type == TYPE_COCLASS || type == TYPE_INTERFACE;
}
@@ -1030,8 +1030,8 @@ static void write_method_macro(FILE *header, const type_t *iface, const type_t *
const var_t *arg;
fprintf(header, "#define %s_%s(This", name, get_name(func));
- if (type_get_function_args(func->type))
- LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->type), const var_t, entry )
+ if (type_get_function_args(func->declspec.type))
+ LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->declspec.type), const var_t, entry )
fprintf(header, ",%s", arg->name);
fprintf(header, ") ");
@@ -1042,8 +1042,8 @@ static void write_method_macro(FILE *header, const type_t *iface, const type_t *
}
fprintf(header, "(This)->lpVtbl->%s(This", get_vtbl_entry_name(iface, func));
- if (type_get_function_args(func->type))
- LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->type), const var_t, entry )
+ if (type_get_function_args(func->declspec.type))
+ LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->declspec.type), const var_t, entry )
fprintf(header, ",%s", arg->name);
fprintf(header, ")\n");
}
@@ -1073,7 +1073,7 @@ void write_args(FILE *h, const var_list_t *args, const char *name, int method, i
}
else fprintf(h, ",");
}
- write_type_decl(h, arg->type, arg->name);
+ write_type_decl(h, arg->declspec.type, arg->name);
if (method == 2) {
const expr_t *expr = get_attrp(arg->attrs, ATTR_DEFAULTVALUE);
if (expr) {
@@ -1085,7 +1085,7 @@ void write_args(FILE *h, const var_list_t *args, const char *name, int method, i
expr_t bstr;
/* Fixup the expression type for a BSTR like midl does. */
- if (get_type_vt(arg->type) == VT_BSTR && expr->type == EXPR_STRLIT)
+ if (get_type_vt(arg->declspec.type) == VT_BSTR && expr->type == EXPR_STRLIT)
{
bstr = *expr;
bstr.type = EXPR_WSTRLIT;
@@ -1114,8 +1114,8 @@ 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);
- const var_list_t *args = type_get_function_args(func->type);
+ const char *callconv = get_attrp(func->declspec.type->attrs, ATTR_CALLCONV);
+ const var_list_t *args = type_get_function_args(func->declspec.type);
const var_t *arg;
if (!callconv) callconv = "STDMETHODCALLTYPE";
@@ -1125,11 +1125,11 @@ static void write_cpp_method_def(FILE *header, const type_t *iface)
indent(header, 0);
fprintf(header, "virtual ");
- write_type_decl_left(header, type_function_get_rettype(func->type));
+ write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
fprintf(header, "* %s %s(\n", callconv, get_name(func));
++indentation;
indent(header, 0);
- write_type_decl_left(header, type_function_get_rettype(func->type));
+ write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
fprintf(header, " *__ret");
--indentation;
if (args) {
@@ -1139,7 +1139,7 @@ static void write_cpp_method_def(FILE *header, const type_t *iface)
fprintf(header, ") = 0;\n");
indent(header, 0);
- write_type_decl_left(header, type_function_get_rettype(func->type));
+ write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
fprintf(header, " %s %s(\n", callconv, get_name(func));
write_args(header, args, iface->name, 2, TRUE);
fprintf(header, ")\n");
@@ -1147,7 +1147,7 @@ static void write_cpp_method_def(FILE *header, const type_t *iface)
fprintf(header, "{\n");
++indentation;
indent(header, 0);
- write_type_decl_left(header, type_function_get_rettype(func->type));
+ write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
fprintf(header, " __ret;\n");
indent(header, 0);
fprintf(header, "return *%s(&__ret", get_name(func));
@@ -1164,7 +1164,7 @@ static void write_cpp_method_def(FILE *header, const type_t *iface)
indent(header, 0);
fprintf(header, "virtual ");
- write_type_decl_left(header, type_function_get_rettype(func->type));
+ write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
fprintf(header, " %s %s(\n", callconv, get_name(func));
write_args(header, args, iface->name, 2, TRUE);
fprintf(header, ") = 0;\n");
@@ -1201,25 +1201,25 @@ static void write_inline_wrappers(FILE *header, const type_t *iface, const type_
const var_t *arg;
fprintf(header, "static FORCEINLINE ");
- write_type_decl_left(header, type_function_get_rettype(func->type));
+ write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
fprintf(header, " %s_%s(", name, get_name(func));
- write_args(header, type_get_function_args(func->type), name, 1, FALSE);
+ write_args(header, type_get_function_args(func->declspec.type), name, 1, FALSE);
fprintf(header, ") {\n");
++indentation;
if (!is_aggregate_return(func)) {
indent(header, 0);
fprintf(header, "%sThis->lpVtbl->%s(This",
- is_void(type_function_get_rettype(func->type)) ? "" : "return ",
+ is_void(type_function_get_rettype(func->declspec.type)) ? "" : "return ",
get_vtbl_entry_name(iface, func));
} else {
indent(header, 0);
- write_type_decl_left(header, type_function_get_rettype(func->type));
+ write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
fprintf(header, " __ret;\n");
indent(header, 0);
fprintf(header, "return *This->lpVtbl->%s(This,&__ret", get_vtbl_entry_name(iface, func));
}
- if (type_get_function_args(func->type))
- LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->type), const var_t, entry )
+ if (type_get_function_args(func->declspec.type))
+ LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->declspec.type), const var_t, entry )
fprintf(header, ",%s", arg->name);
fprintf(header, ");\n");
--indentation;
@@ -1245,10 +1245,10 @@ static void do_write_c_method_def(FILE *header, const type_t *iface, const char
first_iface = 0;
}
if (!is_callas(func->attrs)) {
- const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV);
+ const char *callconv = get_attrp(func->declspec.type->attrs, ATTR_CALLCONV);
if (!callconv) callconv = "STDMETHODCALLTYPE";
indent(header, 0);
- write_type_decl_left(header, type_function_get_rettype(func->type));
+ write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
if (is_aggregate_return(func))
fprintf(header, " *");
if (is_inherited_method(iface, func))
@@ -1261,13 +1261,13 @@ static void do_write_c_method_def(FILE *header, const type_t *iface, const char
if (is_aggregate_return(func)) {
fprintf(header, ",\n");
indent(header, 0);
- write_type_decl_left(header, type_function_get_rettype(func->type));
+ write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
fprintf(header, " *__ret");
}
--indentation;
- if (type_get_function_args(func->type)) {
+ if (type_get_function_args(func->declspec.type)) {
fprintf(header, ",\n");
- write_args(header, type_get_function_args(func->type), name, 0, TRUE);
+ write_args(header, type_get_function_args(func->declspec.type), name, 0, TRUE);
}
fprintf(header, ");\n");
fprintf(header, "\n");
@@ -1294,12 +1294,12 @@ static void write_method_proto(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);
+ const char *callconv = get_attrp(func->declspec.type->attrs, ATTR_CALLCONV);
if (!callconv) callconv = "STDMETHODCALLTYPE";
/* proxy prototype */
- write_type_decl_left(header, type_function_get_rettype(func->type));
+ write_type_decl_left(header, type_function_get_rettype(func->declspec.type));
fprintf(header, " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func));
- write_args(header, type_get_function_args(func->type), iface->name, 1, TRUE);
+ write_args(header, type_get_function_args(func->declspec.type), iface->name, 1, TRUE);
fprintf(header, ");\n");
/* stub prototype */
fprintf(header, "void __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(func));
@@ -1332,12 +1332,12 @@ static void write_locals(FILE *fp, const type_t *iface, int body)
if (&stmt2->entry != type_iface_get_stmts(iface)) {
const var_t *m = stmt2->u.var;
/* proxy prototype - use local prototype */
- write_type_decl_left(fp, type_function_get_rettype(m->type));
+ write_type_decl_left(fp, type_function_get_rettype(m->declspec.type));
fprintf(fp, " CALLBACK %s_%s_Proxy(\n", iface->name, get_name(m));
- write_args(fp, type_get_function_args(m->type), iface->name, 1, TRUE);
+ write_args(fp, type_get_function_args(m->declspec.type), iface->name, 1, TRUE);
fprintf(fp, ")");
if (body) {
- type_t *rt = type_function_get_rettype(m->type);
+ type_t *rt = type_function_get_rettype(m->declspec.type);
fprintf(fp, "\n{\n");
fprintf(fp, " %s\n", comment);
if (rt->name && strcmp(rt->name, "HRESULT") == 0)
@@ -1354,9 +1354,9 @@ static void write_locals(FILE *fp, const type_t *iface, int body)
else
fprintf(fp, ";\n");
/* stub prototype - use remotable prototype */
- write_type_decl_left(fp, type_function_get_rettype(func->type));
+ write_type_decl_left(fp, type_function_get_rettype(func->declspec.type));
fprintf(fp, " __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(m));
- write_args(fp, type_get_function_args(func->type), iface->name, 1, TRUE);
+ write_args(fp, type_get_function_args(func->declspec.type), iface->name, 1, TRUE);
fprintf(fp, ")");
if (body)
/* Remotable methods must all return HRESULTs. */
@@ -1402,15 +1402,15 @@ void write_local_stubs(const statement_list_t *stmts)
static void write_function_proto(FILE *header, const type_t *iface, const var_t *fun, const char *prefix)
{
- const char *callconv = get_attrp(fun->type->attrs, ATTR_CALLCONV);
+ const char *callconv = get_attrp(fun->declspec.type->attrs, ATTR_CALLCONV);
if (!callconv) callconv = "__cdecl";
/* FIXME: do we need to handle call_as? */
- write_type_decl_left(header, type_function_get_rettype(fun->type));
+ write_type_decl_left(header, type_function_get_rettype(fun->declspec.type));
fprintf(header, " %s ", callconv);
fprintf(header, "%s%s(\n", prefix, get_name(fun));
- if (type_get_function_args(fun->type))
- write_args(header, type_get_function_args(fun->type), iface->name, 0, TRUE);
+ if (type_get_function_args(fun->declspec.type))
+ write_args(header, type_get_function_args(fun->declspec.type), iface->name, 0, TRUE);
else
fprintf(header, " void");
fprintf(header, ");\n\n");
@@ -1536,7 +1536,7 @@ static void write_rpc_interface_start(FILE *header, const type_t *iface)
if (var)
{
fprintf(header, "extern ");
- write_type_decl( header, var->type, var->name );
+ write_type_decl( header, var->declspec.type, var->name );
fprintf(header, ";\n");
}
if (old_names)
@@ -1745,7 +1745,7 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons
fprintf(header, "%s\n", stmt->u.str);
break;
case STMT_DECLARATION:
- if (iface && type_get_type(stmt->u.var->type) == TYPE_FUNCTION)
+ if (iface && type_get_type(stmt->u.var->declspec.type) == TYPE_FUNCTION)
{
if (!ignore_funcs)
{
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 1e5c8e181d..50e42291bd 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -52,13 +52,6 @@ struct _import_t
int import_performed;
};
-typedef struct _decl_spec_t
-{
- type_t *type;
- attr_list_t *attrs;
- enum storage_class stgclass;
-} decl_spec_t;
-
typelist_t incomplete_types = LIST_INIT(incomplete_types);
static void fix_incomplete(void);
@@ -651,10 +644,10 @@ enum_list: enum { if (!$1->eval)
enum: ident '=' expr_int_const { $$ = reg_const($1);
$$->eval = $3;
- $$->type = type_new_int(TYPE_BASIC_INT, 0);
+ $$->declspec.type = type_new_int(TYPE_BASIC_INT, 0);
}
| ident { $$ = reg_const($1);
- $$->type = type_new_int(TYPE_BASIC_INT, 0);
+ $$->declspec.type = type_new_int(TYPE_BASIC_INT, 0);
}
;
@@ -740,7 +733,7 @@ field: m_attributes decl_spec struct_declarator_list ';'
$$ = set_var_types($1, $2, $3);
}
| m_attributes uniondef ';' { var_t *v = make_var(NULL);
- v->type = $2; v->attrs = $1;
+ v->declspec.type = $2; v->attrs = $1;
$$ = append_var(NULL, v);
}
;
@@ -764,13 +757,13 @@ s_field: m_attributes decl_spec declarator { $$ = declare_var(check_field_attrs
free($3);
}
| m_attributes structdef { var_t *v = make_var(NULL);
- v->type = $2; v->attrs = $1;
+ v->declspec.type = $2; v->attrs = $1;
$$ = v;
}
;
funcdef: declaration { $$ = $1;
- if (type_get_type($$->type) != TYPE_FUNCTION)
+ if (type_get_type($$->declspec.type) != TYPE_FUNCTION)
error_loc("only methods may be declared inside the methods section of a dispinterface\n");
check_function_attrs($$->name, $$->attrs);
}
@@ -1540,19 +1533,19 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
}
/* add type onto the end of the pointers in pident->type */
- v->type = append_chain_type(decl ? decl->type : NULL, type);
- v->stgclass = decl_spec->stgclass;
+ v->declspec.type = append_chain_type(decl ? decl->type : NULL, type);
+ v->declspec.stgclass = decl_spec->stgclass;
v->attrs = attrs;
/* check for pointer attribute being applied to non-pointer, non-array
* type */
- if (!is_array(v->type))
+ if (!is_array(v->declspec.type))
{
int ptr_attr = get_attrv(v->attrs, ATTR_POINTERTYPE);
const type_t *ptr = NULL;
/* pointer attributes on the left side of the type belong to the function
* pointer, if one is being declared */
- type_t **pt = func_type ? &func_type : &v->type;
+ type_t **pt = func_type ? &func_type : &v->declspec.type;
for (ptr = *pt; ptr && !ptr_attr; )
{
ptr_attr = get_attrv(ptr->attrs, ATTR_POINTERTYPE);
@@ -1585,7 +1578,7 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
{
type_t *t = type;
- if (!is_ptr(v->type) && !is_array(v->type))
+ if (!is_ptr(v->declspec.type) && !is_array(v->declspec.type))
error_loc("'%s': [string] attribute applied to non-pointer, non-array type\n",
v->name);
@@ -1611,15 +1604,15 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
if (is_attr(v->attrs, ATTR_V1ENUM))
{
- if (type_get_type_detect_alias(v->type) != TYPE_ENUM)
+ if (type_get_type_detect_alias(v->declspec.type) != TYPE_ENUM)
error_loc("'%s': [v1_enum] attribute applied to non-enum type\n", v->name);
}
- if (is_attr(v->attrs, ATTR_RANGE) && !is_allowed_range_type(v->type))
+ if (is_attr(v->attrs, ATTR_RANGE) && !is_allowed_range_type(v->declspec.type))
error_loc("'%s': [range] attribute applied to non-integer type\n",
v->name);
- ptype = &v->type;
+ ptype = &v->declspec.type;
if (sizes) LIST_FOR_EACH_ENTRY(dim, sizes, expr_t, entry)
{
if (dim->type != EXPR_VOID)
@@ -1649,7 +1642,7 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
error_loc("%s: too many expressions in size_is attribute\n", v->name);
}
- ptype = &v->type;
+ ptype = &v->declspec.type;
if (lengs) LIST_FOR_EACH_ENTRY(dim, lengs, expr_t, entry)
{
if (dim->type != EXPR_VOID)
@@ -1681,28 +1674,28 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
if (func_type)
{
type_t *ft, *t;
- type_t *return_type = v->type;
- v->type = func_type;
- for (ft = v->type; is_ptr(ft); ft = type_pointer_get_ref(ft))
+ type_t *return_type = v->declspec.type;
+ v->declspec.type = func_type;
+ for (ft = v->declspec.type; is_ptr(ft); ft = type_pointer_get_ref(ft))
;
assert(type_get_type_detect_alias(ft) == TYPE_FUNCTION);
ft->details.function->retval = make_var(xstrdup("_RetVal"));
- ft->details.function->retval->type = return_type;
+ ft->details.function->retval->declspec.type = return_type;
/* move calling convention attribute, if present, from pointer nodes to
* function node */
- for (t = v->type; is_ptr(t); t = type_pointer_get_ref(t))
+ for (t = v->declspec.type; is_ptr(t); t = type_pointer_get_ref(t))
ft->attrs = move_attr(ft->attrs, t->attrs, ATTR_CALLCONV);
}
else
{
type_t *t;
- for (t = v->type; is_ptr(t); t = type_pointer_get_ref(t))
+ for (t = v->declspec.type; is_ptr(t); t = type_pointer_get_ref(t))
if (is_attr(t->attrs, ATTR_CALLCONV))
error_loc("calling convention applied to non-function-pointer type\n");
}
if (decl->bits)
- v->type = type_new_bitfield(v->type, decl->bits);
+ v->declspec.type = type_new_bitfield(v->declspec.type, decl->bits);
return v;
}
@@ -1770,10 +1763,9 @@ var_t *make_var(char *name)
{
var_t *v = xmalloc(sizeof(var_t));
v->name = name;
- v->type = NULL;
+ init_declspec(&v->declspec, NULL);
v->attrs = NULL;
v->eval = NULL;
- v->stgclass = STG_NONE;
init_loc_info(&v->loc_info);
return v;
}
@@ -1782,10 +1774,9 @@ static var_t *copy_var(var_t *src, char *name, map_attrs_filter_t attr_filter)
{
var_t *v = xmalloc(sizeof(var_t));
v->name = name;
- v->type = src->type;
+ v->declspec = src->declspec;
v->attrs = map_attrs(src->attrs, attr_filter);
v->eval = src->eval;
- v->stgclass = src->stgclass;
v->loc_info = src->loc_info;
return v;
}
@@ -2010,7 +2001,7 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at
cur->loc_info.line_number);
name = declare_var(attrs, decl_spec, decl, 0);
- cur = type_new_alias(name->type, name->name);
+ cur = type_new_alias(name->declspec.type, name->name);
cur->attrs = attrs;
if (is_incomplete(cur))
@@ -2285,10 +2276,10 @@ static attr_list_t *check_iface_attrs(const char *name, attr_list_t *attrs)
if (attr->type == ATTR_IMPLICIT_HANDLE)
{
const var_t *var = attr->u.pval;
- if (type_get_type( var->type) == TYPE_BASIC &&
- type_basic_get_type( var->type ) == TYPE_BASIC_HANDLE)
+ if (type_get_type( var->declspec.type) == TYPE_BASIC &&
+ type_basic_get_type( var->declspec.type ) == TYPE_BASIC_HANDLE)
continue;
- if (is_aliaschain_attr( var->type, ATTR_HANDLE ))
+ if (is_aliaschain_attr( var->declspec.type, ATTR_HANDLE ))
continue;
error_loc("attribute %s requires a handle type in interface %s\n",
allowed_attr[attr->type].display_name, name);
@@ -2520,7 +2511,7 @@ static void check_remoting_fields(const var_t *var, type_t *type);
static void check_field_common(const type_t *container_type,
const char *container_name, const var_t *arg)
{
- type_t *type = arg->type;
+ type_t *type = arg->declspec.type;
int more_to_do;
const char *container_type_name;
const char *var_type;
@@ -2550,7 +2541,7 @@ static void check_field_common(const type_t *container_type,
}
if (is_attr(arg->attrs, ATTR_LENGTHIS) &&
- (is_attr(arg->attrs, ATTR_STRING) || is_aliaschain_attr(arg->type, ATTR_STRING)))
+ (is_attr(arg->attrs, ATTR_STRING) || is_aliaschain_attr(arg->declspec.type, ATTR_STRING)))
error_loc_info(&arg->loc_info,
"string and length_is specified for argument %s are mutually exclusive attributes\n",
arg->name);
@@ -2694,7 +2685,7 @@ static void check_remoting_fields(const var_t *var, type_t *type)
fields = type_union_get_cases(type);
if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
- if (field->type) check_field_common(type, type->name, field);
+ if (field->declspec.type) check_field_common(type, type->name, field);
}
/* checks that arguments for a function make sense for marshalling and unmarshalling */
@@ -2703,9 +2694,9 @@ static void check_remoting_args(const var_t *func)
const char *funcname = func->name;
const var_t *arg;
- if (func->type->details.function->args) LIST_FOR_EACH_ENTRY( arg, func->type->details.function->args, const var_t, entry )
+ if (func->declspec.type->details.function->args) LIST_FOR_EACH_ENTRY( arg, func->declspec.type->details.function->args, const var_t, entry )
{
- const type_t *type = arg->type;
+ const type_t *type = arg->declspec.type;
/* check that [out] parameters have enough pointer levels */
if (is_attr(arg->attrs, ATTR_OUT))
@@ -2745,16 +2736,16 @@ static void check_remoting_args(const var_t *func)
}
}
- check_field_common(func->type, funcname, arg);
+ check_field_common(func->declspec.type, funcname, arg);
}
- if (type_get_type(type_function_get_rettype(func->type)) != TYPE_VOID)
+ if (type_get_type(type_function_get_rettype(func->declspec.type)) != TYPE_VOID)
{
var_t var;
var = *func;
- var.type = type_function_get_rettype(func->type);
+ var.declspec.type = type_function_get_rettype(func->declspec.type);
var.name = xstrdup("return value");
- check_field_common(func->type, funcname, &var);
+ check_field_common(func->declspec.type, funcname, &var);
free(var.name);
}
}
@@ -2771,8 +2762,8 @@ static void add_explicit_handle_if_necessary(const type_t *iface, var_t *func)
* function */
var_t *idl_handle = make_var(xstrdup("IDL_handle"));
idl_handle->attrs = append_attr(NULL, make_attr(ATTR_IN));
- idl_handle->type = find_type_or_error("handle_t", 0);
- type_function_add_head_arg(func->type, idl_handle);
+ idl_handle->declspec.type = find_type_or_error("handle_t", 0);
+ type_function_add_head_arg(func->declspec.type, idl_handle);
}
}
@@ -2853,7 +2844,7 @@ static void check_async_uuid(type_t *iface)
var_t *begin_func, *finish_func, *func = stmt->u.var, *arg;
var_list_t *begin_args = NULL, *finish_args = NULL, *args;
- args = func->type->details.function->args;
+ args = func->declspec.type->details.function->args;
if (args) LIST_FOR_EACH_ENTRY(arg, args, var_t, entry)
{
if (is_attr(arg->attrs, ATTR_IN) || !is_attr(arg->attrs, ATTR_OUT))
@@ -2863,15 +2854,15 @@ static void check_async_uuid(type_t *iface)
}
begin_func = copy_var(func, concat_str("Begin_", func->name), NULL);
- begin_func->type = type_new_function(begin_args);
- begin_func->type->attrs = func->attrs;
- begin_func->type->details.function->retval = func->type->details.function->retval;
+ begin_func->declspec.type = type_new_function(begin_args);
+ begin_func->declspec.type->attrs = func->attrs;
+ begin_func->declspec.type->details.function->retval = func->declspec.type->details.function->retval;
stmts = append_statement(stmts, make_statement_declaration(begin_func));
finish_func = copy_var(func, concat_str("Finish_", func->name), NULL);
- finish_func->type = type_new_function(finish_args);
- finish_func->type->attrs = func->attrs;
- finish_func->type->details.function->retval = func->type->details.function->retval;
+ finish_func->declspec.type = type_new_function(finish_args);
+ finish_func->declspec.type->attrs = func->attrs;
+ finish_func->declspec.type->details.function->retval = func->declspec.type->details.function->retval;
stmts = append_statement(stmts, make_statement_declaration(finish_func));
}
@@ -2923,10 +2914,10 @@ static void check_all_user_types(const statement_list_t *stmts)
const statement_t *stmt_func;
STATEMENTS_FOR_EACH_FUNC(stmt_func, type_iface_get_stmts(stmt->u.type)) {
const var_t *func = stmt_func->u.var;
- if (func->type->details.function->args)
- LIST_FOR_EACH_ENTRY( v, func->type->details.function->args, const var_t, entry )
- check_for_additional_prototype_types(v->type);
- check_for_additional_prototype_types(type_function_get_rettype(func->type));
+ if (func->declspec.type->details.function->args)
+ LIST_FOR_EACH_ENTRY( v, func->declspec.type->details.function->args, const var_t, entry )
+ check_for_additional_prototype_types(v->declspec.type);
+ check_for_additional_prototype_types(type_function_get_rettype(func->declspec.type));
}
}
}
@@ -2974,16 +2965,16 @@ static statement_t *make_statement_declaration(var_t *var)
{
statement_t *stmt = make_statement(STMT_DECLARATION);
stmt->u.var = var;
- if (var->stgclass == STG_EXTERN && var->eval)
+ if (var->declspec.stgclass == STG_EXTERN && var->eval)
warning("'%s' initialised and declared extern\n", var->name);
if (is_const_decl(var))
{
if (var->eval)
reg_const(var);
}
- else if (type_get_type(var->type) == TYPE_FUNCTION)
+ else if (type_get_type(var->declspec.type) == TYPE_FUNCTION)
check_function_attrs(var->name, var->attrs);
- else if (var->stgclass == STG_NONE || var->stgclass == STG_REGISTER)
+ else if (var->declspec.stgclass == STG_NONE || var->declspec.stgclass == STG_REGISTER)
error_loc("instantiation of data is illegal\n");
return stmt;
}
diff --git a/tools/widl/proxy.c b/tools/widl/proxy.c
index ef52e35a4c..0b37cc9758 100644
--- a/tools/widl/proxy.c
+++ b/tools/widl/proxy.c
@@ -105,15 +105,15 @@ static void clear_output_vars( const var_list_t *args )
{
if (is_attr(arg->attrs, ATTR_IN)) continue;
if (!is_attr(arg->attrs, ATTR_OUT)) continue;
- if (is_ptr(arg->type))
+ if (is_ptr(arg->declspec.type))
{
- if (type_get_type(type_pointer_get_ref(arg->type)) == TYPE_BASIC) continue;
- if (type_get_type(type_pointer_get_ref(arg->type)) == TYPE_ENUM) continue;
+ if (type_get_type(type_pointer_get_ref(arg->declspec.type)) == TYPE_BASIC) continue;
+ if (type_get_type(type_pointer_get_ref(arg->declspec.type)) == TYPE_ENUM) continue;
}
print_proxy( "if (%s) MIDL_memset( %s, 0, ", arg->name, arg->name );
- if (is_array(arg->type) && type_array_has_conformance(arg->type))
+ if (is_array(arg->declspec.type) && type_array_has_conformance(arg->declspec.type))
{
- write_expr( proxy, type_array_get_conformance(arg->type), 1, 1, NULL, NULL, "" );
+ write_expr( proxy, type_array_get_conformance(arg->declspec.type), 1, 1, NULL, NULL, "" );
fprintf( proxy, " * " );
}
fprintf( proxy, "sizeof( *%s ));\n", arg->name );
@@ -147,7 +147,7 @@ static int need_delegation_indirect(const type_t *iface)
static void free_variable( const var_t *arg, const char *local_var_prefix )
{
unsigned int type_offset = arg->typestring_offset;
- type_t *type = arg->type;
+ type_t *type = arg->declspec.type;
write_parameter_conf_or_var_exprs(proxy, indent, local_var_prefix, PHASE_FREE, arg, FALSE);
@@ -191,18 +191,18 @@ static void proxy_free_variables( var_list_t *args, const char *local_var_prefix
static void gen_proxy(type_t *iface, const var_t *func, int idx,
unsigned int proc_offset)
{
- var_t *retval = type_function_get_retval(func->type);
- int has_ret = !is_void(retval->type);
+ var_t *retval = type_function_get_retval(func->declspec.type);
+ int has_ret = !is_void(retval->declspec.type);
int has_full_pointer = is_full_pointer_function(func);
- const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV);
- const var_list_t *args = type_get_function_args(func->type);
+ const char *callconv = get_attrp(func->declspec.type->attrs, ATTR_CALLCONV);
+ const var_list_t *args = type_get_function_args(func->declspec.type);
if (!callconv) callconv = "STDMETHODCALLTYPE";
indent = 0;
if (is_interpreted_func( iface, func ))
{
if (get_stub_mode() == MODE_Oif && !is_callas( func->attrs )) return;
- write_type_decl_left(proxy, retval->type);
+ write_type_decl_left(proxy, retval->declspec.type);
print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func));
write_args(proxy, args, iface->name, 1, TRUE);
print_proxy( ")\n");
@@ -219,7 +219,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
print_proxy( "}\n");
print_proxy( "\n");
- write_type_decl_left(proxy, retval->type);
+ write_type_decl_left(proxy, retval->declspec.type);
print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func));
write_args(proxy, args, iface->name, 1, TRUE);
print_proxy( ")\n");
@@ -229,12 +229,12 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
/* local variables */
if (has_ret) {
print_proxy( "%s", "" );
- write_type_decl(proxy, retval->type, retval->name);
+ write_type_decl(proxy, retval->declspec.type, retval->name);
fprintf( proxy, ";\n" );
}
print_proxy( "RPC_MESSAGE _RpcMessage;\n" );
if (has_ret) {
- if (decl_indirect(retval->type))
+ if (decl_indirect(retval->declspec.type))
print_proxy("void *_p_%s = &%s;\n", retval->name, retval->name);
}
print_proxy( "\n");
@@ -246,7 +246,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
write_full_pointer_init(proxy, indent, func, FALSE);
/* FIXME: trace */
- clear_output_vars( type_get_function_args(func->type) );
+ clear_output_vars( type_get_function_args(func->declspec.type) );
print_proxy( "RpcTryExcept\n" );
print_proxy( "{\n" );
@@ -279,9 +279,9 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
if (has_ret)
{
- if (decl_indirect(retval->type))
+ if (decl_indirect(retval->declspec.type))
print_proxy("MIDL_memset(&%s, 0, sizeof(%s));\n", retval->name, retval->name);
- else if (is_ptr(retval->type) || is_array(retval->type))
+ else if (is_ptr(retval->declspec.type) || is_array(retval->declspec.type))
print_proxy("%s = 0;\n", retval->name);
write_remoting_arguments(proxy, indent, func, "", PASS_RETURN, PHASE_UNMARSHAL);
}
@@ -301,7 +301,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
print_proxy( "{\n" );
if (has_ret) {
indent++;
- proxy_free_variables( type_get_function_args(func->type), "" );
+ proxy_free_variables( type_get_function_args(func->declspec.type), "" );
print_proxy( "_RetVal = NdrProxyErrorHandler(RpcExceptionCode());\n" );
indent--;
}
@@ -320,7 +320,7 @@ static void gen_stub(type_t *iface, const var_t *func, const char *cas,
unsigned int proc_offset)
{
const var_t *arg;
- int has_ret = !is_void(type_function_get_rettype(func->type));
+ int has_ret = !is_void(type_function_get_rettype(func->declspec.type));
int has_full_pointer = is_full_pointer_function(func);
if (is_interpreted_func( iface, func )) return;
@@ -389,10 +389,10 @@ static void gen_stub(type_t *iface, const var_t *func, const char *cas,
else fprintf(proxy, "__frame->_This->lpVtbl->%s", get_name(func));
fprintf(proxy, "(__frame->_This");
- if (type_get_function_args(func->type))
+ if (type_get_function_args(func->declspec.type))
{
- LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->type), const var_t, entry )
- fprintf(proxy, ", %s__frame->%s", is_array(arg->type) && !type_array_is_decl_as_ptr(arg->type) ? "*" :"" , arg->name);
+ LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->declspec.type), const var_t, entry )
+ fprintf(proxy, ", %s__frame->%s", is_array(arg->declspec.type) && !type_array_is_decl_as_ptr(arg->declspec.type) ? "*" :"" , arg->name);
}
fprintf(proxy, ");\n");
fprintf(proxy, "\n");
@@ -401,7 +401,7 @@ static void gen_stub(type_t *iface, const var_t *func, const char *cas,
write_remoting_arguments(proxy, indent, func, "__frame->", PASS_OUT, PHASE_BUFFERSIZE);
- if (!is_void(type_function_get_rettype(func->type)))
+ if (!is_void(type_function_get_rettype(func->declspec.type)))
write_remoting_arguments(proxy, indent, func, "__frame->", PASS_RETURN, PHASE_BUFFERSIZE);
print_proxy("NdrStubGetBuffer(This, _pRpcChannelBuffer, &__frame->_StubMsg);\n");
@@ -410,7 +410,7 @@ static void gen_stub(type_t *iface, const var_t *func, const char *cas,
fprintf(proxy, "\n");
/* marshall the return value */
- if (!is_void(type_function_get_rettype(func->type)))
+ if (!is_void(type_function_get_rettype(func->declspec.type)))
write_remoting_arguments(proxy, indent, func, "__frame->", PASS_RETURN, PHASE_MARSHAL);
indent--;
@@ -432,16 +432,16 @@ static void gen_stub(type_t *iface, const var_t *func, const char *cas,
static void gen_stub_thunk( type_t *iface, const var_t *func, unsigned int proc_offset )
{
- int has_ret = !is_void( type_function_get_rettype( func->type ));
+ int has_ret = !is_void( type_function_get_rettype( func->declspec.type ));
const var_t *arg, *callas = is_callas( func->attrs );
- const var_list_t *args = type_get_function_args( func->type );
+ const var_list_t *args = type_get_function_args( func->declspec.type );
indent = 0;
print_proxy( "void __RPC_API %s_%s_Thunk( PMIDL_STUB_MESSAGE pStubMsg )\n",
iface->name, get_name(func) );
print_proxy( "{\n");
indent++;
- write_func_param_struct( proxy, iface, func->type,
+ write_func_param_struct( proxy, iface, func->declspec.type,
"*pParamStruct = (struct _PARAM_STRUCT *)pStubMsg->StackTop", has_ret );
print_proxy( "%s%s_%s_Stub( pParamStruct->This",
has_ret ? "pParamStruct->_RetVal = " : "", iface->name, callas->name );
@@ -614,14 +614,14 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset)
if (!is_local(func->attrs)) {
const var_t *cas = is_callas(func->attrs);
const char *cname = cas ? cas->name : NULL;
- int idx = func->type->details.function->idx;
+ int idx = func->declspec.type->details.function->idx;
if (cname) {
const statement_t *stmt2;
STATEMENTS_FOR_EACH_FUNC(stmt2, type_iface_get_stmts(iface)) {
const var_t *m = stmt2->u.var;
if (!strcmp(m->name, cname))
{
- idx = m->type->details.function->idx;
+ idx = m->declspec.type->details.function->idx;
break;
}
}
diff --git a/tools/widl/server.c b/tools/widl/server.c
index 59c17d661f..fb14dd87bc 100644
--- a/tools/widl/server.c
+++ b/tools/widl/server.c
@@ -55,7 +55,7 @@ static void write_function_stub(const type_t *iface, const var_t *func, unsigned
unsigned char explicit_fc, implicit_fc;
int has_full_pointer = is_full_pointer_function(func);
const var_t *handle_var = get_func_handle_var( iface, func, &explicit_fc, &implicit_fc );
- type_t *ret_type = type_function_get_rettype(func->type);
+ type_t *ret_type = type_function_get_rettype(func->declspec.type);
if (is_interpreted_func( iface, func )) return;
@@ -121,7 +121,7 @@ static void write_function_stub(const type_t *iface, const var_t *func, unsigned
if (has_full_pointer)
write_full_pointer_init(server, indent, func, TRUE);
- if (type_get_function_args(func->type))
+ if (type_get_function_args(func->declspec.type))
{
print_server("if ((_pRpcMessage->DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)\n");
indent++;
@@ -166,31 +166,31 @@ static void write_function_stub(const type_t *iface, const var_t *func, unsigned
print_server("%s", is_void(ret_type) ? "" : "__frame->_RetVal = ");
fprintf(server, "%s%s", prefix_server, get_name(func));
- if (type_get_function_args(func->type))
+ if (type_get_function_args(func->declspec.type))
{
int first_arg = 1;
fprintf(server, "(\n");
indent++;
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry )
+ LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), const var_t, entry )
{
if (first_arg)
first_arg = 0;
else
fprintf(server, ",\n");
- if (is_context_handle(var->type))
+ if (is_context_handle(var->declspec.type))
{
/* if the context_handle attribute appears in the chain of types
* without pointers being followed, then the context handle must
* be direct, otherwise it is a pointer */
- const char *ch_ptr = is_aliaschain_attr(var->type, ATTR_CONTEXTHANDLE) ? "*" : "";
+ const char *ch_ptr = is_aliaschain_attr(var->declspec.type, ATTR_CONTEXTHANDLE) ? "*" : "";
print_server("(");
- write_type_decl_left(server, var->type);
+ write_type_decl_left(server, var->declspec.type);
fprintf(server, ")%sNDRSContextValue(__frame->%s)", ch_ptr, var->name);
}
else
{
- print_server("%s__frame->%s", is_array(var->type) && !type_array_is_decl_as_ptr(var->type) ? "*" : "", var->name);
+ print_server("%s__frame->%s", is_array(var->declspec.type) && !type_array_is_decl_as_ptr(var->declspec.type) ? "*" : "", var->name);
}
}
fprintf(server, ");\n");
diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index a121364415..f685f7156a 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -379,13 +379,13 @@ enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *att
static int cant_be_null(const var_t *v)
{
- switch (typegen_detect_type(v->type, v->attrs, TDT_IGNORE_STRINGS))
+ switch (typegen_detect_type(v->declspec.type, v->attrs, TDT_IGNORE_STRINGS))
{
case TGT_ARRAY:
- if (!type_array_is_decl_as_ptr( v->type )) return 0;
+ if (!type_array_is_decl_as_ptr( v->declspec.type )) return 0;
/* fall through */
case TGT_POINTER:
- return (get_pointer_fc(v->type, v->attrs, TRUE) == FC_RP);
+ return (get_pointer_fc(v->declspec.type, v->attrs, TRUE) == FC_RP);
case TGT_CTXT_HANDLE_POINTER:
return TRUE;
default:
@@ -405,7 +405,7 @@ static int get_padding(const var_list_t *fields)
LIST_FOR_EACH_ENTRY(f, fields, const var_t, entry)
{
- type_t *ft = f->type;
+ type_t *ft = f->declspec.type;
unsigned int align = 0;
unsigned int size = type_memsize_and_alignment(ft, &align);
align = clamp_align(align);
@@ -422,7 +422,7 @@ static unsigned int get_stack_size( const var_t *var, int *by_value )
unsigned int stack_size;
int by_val;
- switch (typegen_detect_type( var->type, var->attrs, TDT_ALL_TYPES ))
+ switch (typegen_detect_type( var->declspec.type, var->attrs, TDT_ALL_TYPES ))
{
case TGT_BASIC:
case TGT_ENUM:
@@ -430,7 +430,7 @@ static unsigned int get_stack_size( const var_t *var, int *by_value )
case TGT_STRUCT:
case TGT_UNION:
case TGT_USER_TYPE:
- stack_size = type_memsize( var->type );
+ stack_size = type_memsize( var->declspec.type );
by_val = (pointer_size < 8 || stack_size <= pointer_size); /* FIXME: should be platform-specific */
break;
default:
@@ -495,14 +495,14 @@ unsigned char get_struct_fc(const type_t *type)
if (fields) LIST_FOR_EACH_ENTRY( field, fields, var_t, entry )
{
- type_t *t = field->type;
+ type_t *t = field->declspec.type;
enum typegen_type typegen_type;
typegen_type = typegen_detect_type(t, field->attrs, TDT_IGNORE_STRINGS);
if (typegen_type == TGT_ARRAY && !type_array_is_decl_as_ptr(t))
{
- if (is_string_type(field->attrs, field->type))
+ if (is_string_type(field->attrs, field->declspec.type))
{
if (is_conformant_array(t))
has_conformance = 1;
@@ -510,10 +510,10 @@ unsigned char get_struct_fc(const type_t *type)
continue;
}
- if (is_array(type_array_get_element(field->type)))
+ if (is_array(type_array_get_element(field->declspec.type)))
return FC_BOGUS_STRUCT;
- if (type_array_has_conformance(field->type))
+ if (type_array_has_conformance(field->declspec.type))
{
has_conformance = 1;
if (list_next(fields, &field->entry))
@@ -721,7 +721,7 @@ static int type_has_pointers(const type_t *type)
const var_t *field;
if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
{
- if (type_has_pointers(field->type))
+ if (type_has_pointers(field->declspec.type))
return TRUE;
}
break;
@@ -733,7 +733,7 @@ static int type_has_pointers(const type_t *type)
fields = type_union_get_cases(type);
if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
{
- if (field->type && type_has_pointers(field->type))
+ if (field->declspec.type && type_has_pointers(field->declspec.type))
return TRUE;
}
break;
@@ -775,7 +775,7 @@ static int type_has_full_pointer(const type_t *type, const attr_list_t *attrs,
const var_t *field;
if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
{
- if (type_has_full_pointer(field->type, field->attrs, FALSE))
+ if (type_has_full_pointer(field->declspec.type, field->attrs, FALSE))
return TRUE;
}
break;
@@ -787,7 +787,7 @@ static int type_has_full_pointer(const type_t *type, const attr_list_t *attrs,
fields = type_union_get_cases(type);
if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
{
- if (field->type && type_has_full_pointer(field->type, field->attrs, FALSE))
+ if (field->declspec.type && type_has_full_pointer(field->declspec.type, field->attrs, FALSE))
return TRUE;
}
break;
@@ -907,16 +907,16 @@ static void write_var_init(FILE *file, int indent, const type_t *t, const char *
void write_parameters_init(FILE *file, int indent, const var_t *func, const char *local_var_prefix)
{
- const var_t *var = type_function_get_retval(func->type);
+ const var_t *var = type_function_get_retval(func->declspec.type);
- if (!is_void(var->type))
- write_var_init(file, indent, var->type, var->name, local_var_prefix);
+ if (!is_void(var->declspec.type))
+ write_var_init(file, indent, var->declspec.type, var->name, local_var_prefix);
- if (!type_get_function_args(func->type))
+ if (!type_get_function_args(func->declspec.type))
return;
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry )
- write_var_init(file, indent, var->type, var->name, local_var_prefix);
+ LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), const var_t, entry )
+ write_var_init(file, indent, var->declspec.type, var->name, local_var_prefix);
fprintf(file, "\n");
}
@@ -980,14 +980,14 @@ static unsigned char get_parameter_fc( const var_t *var, int is_return, unsigned
if (is_out) *flags |= IsOut;
if (is_return) *flags |= IsReturn;
- if (!is_string_type( var->attrs, var->type ))
- buffer_size = get_required_buffer_size_type( var->type, NULL, var->attrs, TRUE, &alignment );
+ if (!is_string_type( var->attrs, var->declspec.type ))
+ buffer_size = get_required_buffer_size_type( var->declspec.type, NULL, var->attrs, TRUE, &alignment );
- switch (typegen_detect_type( var->type, var->attrs, TDT_ALL_TYPES ))
+ switch (typegen_detect_type( var->declspec.type, var->attrs, TDT_ALL_TYPES ))
{
case TGT_BASIC:
*flags |= IsBasetype;
- fc = get_basic_fc_signed( var->type );
+ fc = get_basic_fc_signed( var->declspec.type );
if (fc == FC_BIND_PRIMITIVE)
{
buffer_size = 4; /* actually 0 but avoids setting MustSize */
@@ -996,7 +996,7 @@ static unsigned char get_parameter_fc( const var_t *var, int is_return, unsigned
break;
case TGT_ENUM:
*flags |= IsBasetype;
- fc = get_enum_fc( var->type );
+ fc = get_enum_fc( var->declspec.type );
break;
case TGT_RANGE:
*flags |= IsByValue;
@@ -1011,19 +1011,19 @@ static unsigned char get_parameter_fc( const var_t *var, int is_return, unsigned
break;
case TGT_ARRAY:
*flags |= MustFree;
- if (type_array_is_decl_as_ptr(var->type) && var->type->details.array.ptr_tfsoff &&
- get_pointer_fc( var->type, var->attrs, !is_return ) == FC_RP)
+ if (type_array_is_decl_as_ptr(var->declspec.type) && var->declspec.type->details.array.ptr_tfsoff &&
+ get_pointer_fc( var->declspec.type, var->attrs, !is_return ) == FC_RP)
{
- *typestring_offset = var->type->typestring_offset;
+ *typestring_offset = var->declspec.type->typestring_offset;
*flags |= IsSimpleRef;
}
break;
case TGT_STRING:
*flags |= MustFree;
- if (is_declptr( var->type ) && get_pointer_fc( var->type, var->attrs, !is_return ) == FC_RP)
+ if (is_declptr( var->declspec.type ) && get_pointer_fc( var->declspec.type, var->attrs, !is_return ) == FC_RP)
{
/* skip over pointer description straight to string description */
- if (is_conformant_array( var->type )) *typestring_offset += 4;
+ if (is_conformant_array( var->declspec.type )) *typestring_offset += 4;
else *typestring_offset += 2;
*flags |= IsSimpleRef;
}
@@ -1036,9 +1036,9 @@ static unsigned char get_parameter_fc( const var_t *var, int is_return, unsigned
buffer_size = 20;
break;
case TGT_POINTER:
- if (get_pointer_fc( var->type, var->attrs, !is_return ) == FC_RP)
+ if (get_pointer_fc( var->declspec.type, var->attrs, !is_return ) == FC_RP)
{
- const type_t *ref = type_pointer_get_ref( var->type );
+ const type_t *ref = type_pointer_get_ref( var->declspec.type );
if (!is_string_type( var->attrs, ref ))
buffer_size = get_required_buffer_size_type( ref, NULL, NULL, TRUE, &alignment );
@@ -1128,8 +1128,8 @@ static unsigned char get_parameter_fc( const var_t *var, int is_return, unsigned
static unsigned char get_func_oi2_flags( const var_t *func )
{
const var_t *var;
- var_list_t *args = type_get_function_args( func->type );
- var_t *retval = type_function_get_retval( func->type );
+ var_list_t *args = type_get_function_args( func->declspec.type );
+ var_t *retval = type_function_get_retval( func->declspec.type );
unsigned char oi2_flags = 0x40; /* HasExtensions */
unsigned short flags;
unsigned int stack_size, typestring_offset;
@@ -1144,7 +1144,7 @@ static unsigned char get_func_oi2_flags( const var_t *func )
}
}
- if (!is_void( retval->type ))
+ if (!is_void( retval->declspec.type ))
{
oi2_flags |= 0x04; /* HasRet */
get_parameter_fc( retval, 1, &flags, &stack_size, &typestring_offset );
@@ -1198,8 +1198,8 @@ static unsigned int write_old_procformatstring_type(FILE *file, int indent, cons
if (!is_in && !is_out) is_in = TRUE;
- if (type_get_type(var->type) == TYPE_BASIC ||
- type_get_type(var->type) == TYPE_ENUM)
+ if (type_get_type(var->declspec.type) == TYPE_BASIC ||
+ type_get_type(var->declspec.type) == TYPE_ENUM)
{
unsigned char fc;
@@ -1208,13 +1208,13 @@ static unsigned int write_old_procformatstring_type(FILE *file, int indent, cons
else
print_file(file, indent, "0x4e, /* FC_IN_PARAM_BASETYPE */\n");
- if (type_get_type(var->type) == TYPE_ENUM)
+ if (type_get_type(var->declspec.type) == TYPE_ENUM)
{
- fc = get_enum_fc(var->type);
+ fc = get_enum_fc(var->declspec.type);
}
else
{
- fc = get_basic_fc_signed(var->type);
+ fc = get_basic_fc_signed(var->declspec.type);
if (fc == FC_BIND_PRIMITIVE)
fc = FC_IGNORE;
@@ -1228,10 +1228,10 @@ static unsigned int write_old_procformatstring_type(FILE *file, int indent, cons
{
unsigned short offset = var->typestring_offset;
- if (!is_interpreted && is_array(var->type) &&
- type_array_is_decl_as_ptr(var->type) &&
- var->type->details.array.ptr_tfsoff)
- offset = var->type->typestring_offset;
+ if (!is_interpreted && is_array(var->declspec.type) &&
+ type_array_is_decl_as_ptr(var->declspec.type) &&
+ var->declspec.type->details.array.ptr_tfsoff)
+ offset = var->declspec.type->typestring_offset;
if (is_return)
print_file(file, indent, "0x52, /* FC_RETURN_PARAM */\n");
@@ -1254,8 +1254,8 @@ int is_interpreted_func( const type_t *iface, const var_t *func )
{
const char *str;
const var_t *var;
- const var_list_t *args = type_get_function_args( func->type );
- const type_t *ret_type = type_function_get_rettype( func->type );
+ const var_list_t *args = type_get_function_args( func->declspec.type );
+ const type_t *ret_type = type_function_get_rettype( func->declspec.type );
if (type_get_type( ret_type ) == TYPE_BASIC)
{
@@ -1277,10 +1277,10 @@ int is_interpreted_func( const type_t *iface, const var_t *func )
if (get_stub_mode() != MODE_Oif && args)
{
LIST_FOR_EACH_ENTRY( var, args, const var_t, entry )
- switch (type_get_type( var->type ))
+ switch (type_get_type( var->declspec.type ))
{
case TYPE_BASIC:
- switch (type_basic_get_type( var->type ))
+ switch (type_basic_get_type( var->declspec.type ))
{
/* floating point arguments are not supported in Oi mode */
case TYPE_BASIC_FLOAT: return 0;
@@ -1305,7 +1305,7 @@ static void write_proc_func_header( FILE *file, int indent, const type_t *iface,
unsigned short num_proc )
{
var_t *var;
- var_list_t *args = type_get_function_args( func->type );
+ var_list_t *args = type_get_function_args( func->declspec.type );
unsigned char explicit_fc, implicit_fc;
unsigned char handle_flags;
const var_t *handle_var = get_func_handle_var( iface, func, &explicit_fc, &implicit_fc );
@@ -1336,7 +1336,7 @@ static void write_proc_func_header( FILE *file, int indent, const type_t *iface,
param_num++;
nb_args++;
}
- if (!is_void( type_function_get_rettype( func->type )))
+ if (!is_void( type_function_get_rettype( func->declspec.type )))
{
stack_size += pointer_size;
nb_args++;
@@ -1364,22 +1364,22 @@ static void write_proc_func_header( FILE *file, int indent, const type_t *iface,
*offset += 4;
break;
case FC_BIND_GENERIC:
- handle_flags = type_memsize( handle_var->type );
+ handle_flags = type_memsize( handle_var->declspec.type );
print_file( file, indent, "0x%02x,\t/* %s */\n", explicit_fc, string_of_type(explicit_fc) );
print_file( file, indent, "0x%02x,\n", handle_flags );
print_file( file, indent, "NdrFcShort(0x%hx),\t/* stack offset = %hu */\n",
handle_stack_offset, handle_stack_offset );
- print_file( file, indent, "0x%02x,\n", get_generic_handle_offset( handle_var->type ) );
+ print_file( file, indent, "0x%02x,\n", get_generic_handle_offset( handle_var->declspec.type ) );
print_file( file, indent, "0x%x,\t/* FC_PAD */\n", FC_PAD);
*offset += 6;
break;
case FC_BIND_CONTEXT:
- handle_flags = get_contexthandle_flags( iface, handle_var->attrs, handle_var->type, 0 );
+ handle_flags = get_contexthandle_flags( iface, handle_var->attrs, handle_var->declspec.type, 0 );
print_file( file, indent, "0x%02x,\t/* %s */\n", explicit_fc, string_of_type(explicit_fc) );
print_file( file, indent, "0x%02x,\n", handle_flags );
print_file( file, indent, "NdrFcShort(0x%hx),\t/* stack offset = %hu */\n",
handle_stack_offset, handle_stack_offset );
- print_file( file, indent, "0x%02x,\n", get_context_handle_offset( handle_var->type ) );
+ print_file( file, indent, "0x%02x,\n", get_context_handle_offset( handle_var->declspec.type ) );
print_file( file, indent, "0x%02x,\t/* param %hu */\n", handle_param_num, handle_param_num );
*offset += 6;
break;
@@ -1415,9 +1415,9 @@ static void write_proc_func_header( FILE *file, int indent, const type_t *iface,
if (is_object( iface )) pos += 2;
if (args) LIST_FOR_EACH_ENTRY( var, args, var_t, entry )
{
- if (type_get_type( var->type ) == TYPE_BASIC)
+ if (type_get_type( var->declspec.type ) == TYPE_BASIC)
{
- switch (type_basic_get_type( var->type ))
+ switch (type_basic_get_type( var->declspec.type ))
{
case TYPE_BASIC_FLOAT: fpu_mask |= 1 << pos; break;
case TYPE_BASIC_DOUBLE: fpu_mask |= 2 << pos; break;
@@ -1440,15 +1440,15 @@ static void write_procformatstring_func( FILE *file, int indent, const type_t *i
unsigned int stack_offset = is_object( iface ) ? pointer_size : 0;
int is_interpreted = is_interpreted_func( iface, func );
int is_new_style = is_interpreted && (get_stub_mode() == MODE_Oif);
- var_t *retval = type_function_get_retval( func->type );
+ var_t *retval = type_function_get_retval( func->declspec.type );
if (is_interpreted) write_proc_func_header( file, indent, iface, func, offset, num_proc );
/* emit argument data */
- if (type_get_function_args(func->type))
+ if (type_get_function_args(func->declspec.type))
{
const var_t *var;
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry )
+ LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), const var_t, entry )
{
print_file( file, 0, "/* %u (parameter %s) */\n", *offset, var->name );
if (is_new_style)
@@ -1459,7 +1459,7 @@ static void write_procformatstring_func( FILE *file, int indent, const type_t *i
}
/* emit return value data */
- if (is_void(retval->type))
+ if (is_void(retval->declspec.type))
{
if (!is_new_style)
{
@@ -1606,7 +1606,7 @@ static unsigned int write_conf_or_var_desc(FILE *file, const type_t *cont_type,
{
conftype = FC_TOP_LEVEL_CONFORMANCE;
conftype_string = "parameter";
- cont_type = current_func->type;
+ cont_type = current_func->declspec.type;
name = current_func->name;
iface = current_iface;
}
@@ -1677,7 +1677,7 @@ static unsigned int write_conf_or_var_desc(FILE *file, const type_t *cont_type,
if (var->name && !strcmp(var->name, subexpr->u.sval))
{
expr_loc.v = var;
- correlation_variable = var->type;
+ correlation_variable = var->declspec.type;
break;
}
offset += get_stack_size( var, NULL );
@@ -1689,11 +1689,11 @@ static unsigned int write_conf_or_var_desc(FILE *file, const type_t *cont_type,
if (fields) LIST_FOR_EACH_ENTRY( var, fields, const var_t, entry )
{
- unsigned int size = field_memsize( var->type, &offset );
+ unsigned int size = field_memsize( var->declspec.type, &offset );
if (var->name && !strcmp(var->name, subexpr->u.sval))
{
expr_loc.v = var;
- correlation_variable = var->type;
+ correlation_variable = var->declspec.type;
break;
}
offset += size;
@@ -1832,7 +1832,7 @@ static unsigned int fields_memsize(const var_list_t *fields, unsigned int *align
LIST_FOR_EACH_ENTRY( v, fields, const var_t, entry )
{
unsigned int falign = 0;
- unsigned int fsize = type_memsize_and_alignment(v->type, &falign);
+ unsigned int fsize = type_memsize_and_alignment(v->declspec.type, &falign);
if (*align < falign) *align = falign;
falign = clamp_align(falign);
size = ROUND_SIZE(size, falign);
@@ -1854,9 +1854,9 @@ static unsigned int union_memsize(const var_list_t *fields, unsigned int *pmaxa)
if (fields) LIST_FOR_EACH_ENTRY( v, fields, const var_t, entry )
{
/* we could have an empty default field with NULL type */
- if (v->type)
+ if (v->declspec.type)
{
- size = type_memsize_and_alignment(v->type, &align);
+ size = type_memsize_and_alignment(v->declspec.type, &align);
if (maxs < size) maxs = size;
if (*pmaxa < align) *pmaxa = align;
}
@@ -2029,8 +2029,8 @@ static unsigned int type_buffer_alignment(const type_t *t)
if (!(fields = type_struct_get_fields(t))) break;
LIST_FOR_EACH_ENTRY( var, fields, const var_t, entry )
{
- if (!var->type) continue;
- align = type_buffer_alignment( var->type );
+ if (!var->declspec.type) continue;
+ align = type_buffer_alignment( var->declspec.type );
if (max < align) max = align;
}
break;
@@ -2038,8 +2038,8 @@ static unsigned int type_buffer_alignment(const type_t *t)
if (!(fields = type_encapsulated_union_get_fields(t))) break;
LIST_FOR_EACH_ENTRY( var, fields, const var_t, entry )
{
- if (!var->type) continue;
- align = type_buffer_alignment( var->type );
+ if (!var->declspec.type) continue;
+ align = type_buffer_alignment( var->declspec.type );
if (max < align) max = align;
}
break;
@@ -2047,8 +2047,8 @@ static unsigned int type_buffer_alignment(const type_t *t)
if (!(fields = type_union_get_cases(t))) break;
LIST_FOR_EACH_ENTRY( var, fields, const var_t, entry )
{
- if (!var->type) continue;
- align = type_buffer_alignment( var->type );
+ if (!var->declspec.type) continue;
+ align = type_buffer_alignment( var->declspec.type );
if (max < align) max = align;
}
break;
@@ -2077,12 +2077,12 @@ static unsigned int type_buffer_alignment(const type_t *t)
int is_full_pointer_function(const var_t *func)
{
const var_t *var;
- if (type_has_full_pointer(type_function_get_rettype(func->type), func->attrs, TRUE))
+ if (type_has_full_pointer(type_function_get_rettype(func->declspec.type), func->attrs, TRUE))
return TRUE;
- if (!type_get_function_args(func->type))
+ if (!type_get_function_args(func->declspec.type))
return FALSE;
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry )
- if (type_has_full_pointer( var->type, var->attrs, TRUE ))
+ LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), const var_t, entry )
+ if (type_has_full_pointer( var->declspec.type, var->attrs, TRUE ))
return TRUE;
return FALSE;
}
@@ -2424,7 +2424,7 @@ static void write_descriptors(FILE *file, type_t *type, unsigned int *tfsoff)
if (fs) LIST_FOR_EACH_ENTRY(f, fs, var_t, entry)
{
- type_t *ft = f->type;
+ type_t *ft = f->declspec.type;
unsigned int size = field_memsize( ft, &offset );
if (type_get_type(ft) == TYPE_UNION && is_attr(f->attrs, ATTR_SWITCHIS))
{
@@ -2519,13 +2519,13 @@ static int write_pointer_description_offsets(
{
unsigned int padding;
unsigned int align = 0;
- type_memsize_and_alignment(v->type, &align);
+ type_memsize_and_alignment(v->declspec.type, &align);
padding = ROUNDING(*offset_in_memory, align);
*offset_in_memory += padding;
*offset_in_buffer += padding;
}
written += write_pointer_description_offsets(
- file, v->attrs, v->type, offset_in_memory, offset_in_buffer,
+ file, v->attrs, v->declspec.type, offset_in_memory, offset_in_buffer,
typestring_offset);
}
}
@@ -2571,13 +2571,13 @@ static int write_no_repeat_pointer_descriptions(
{
unsigned int padding;
unsigned int align = 0;
- type_memsize_and_alignment(v->type, &align);
+ type_memsize_and_alignment(v->declspec.type, &align);
padding = ROUNDING(*offset_in_memory, align);
*offset_in_memory += padding;
*offset_in_buffer += padding;
}
written += write_no_repeat_pointer_descriptions(
- file, v->attrs, v->type,
+ file, v->attrs, v->declspec.type,
offset_in_memory, offset_in_buffer, typestring_offset);
}
}
@@ -2640,13 +2640,13 @@ static int write_fixed_array_pointer_descriptions(
{
unsigned int padding;
unsigned int align = 0;
- type_memsize_and_alignment(v->type, &align);
+ type_memsize_and_alignment(v->declspec.type, &align);
padding = ROUNDING(*offset_in_memory, align);
*offset_in_memory += padding;
*offset_in_buffer += padding;
}
pointer_count += write_fixed_array_pointer_descriptions(
- file, v->attrs, v->type, offset_in_memory, offset_in_buffer,
+ file, v->attrs, v->declspec.type, offset_in_memory, offset_in_buffer,
typestring_offset);
}
}
@@ -2755,20 +2755,20 @@ static int write_varying_array_pointer_descriptions(
{
unsigned int align = 0, padding;
- if (is_array(v->type) && type_array_has_variance(v->type))
+ if (is_array(v->declspec.type) && type_array_has_variance(v->declspec.type))
{
*offset_in_buffer = ROUND_SIZE(*offset_in_buffer, 4);
/* skip over variance and offset in buffer */
*offset_in_buffer += 8;
}
- type_memsize_and_alignment(v->type, &align);
+ type_memsize_and_alignment(v->declspec.type, &align);
padding = ROUNDING(*offset_in_memory, align);
*offset_in_memory += padding;
*offset_in_buffer += padding;
}
pointer_count += write_varying_array_pointer_descriptions(
- file, v->attrs, v->type, offset_in_memory, offset_in_buffer,
+ file, v->attrs, v->declspec.type, offset_in_memory, offset_in_buffer,
typestring_offset);
}
}
@@ -2820,7 +2820,7 @@ static void write_pointer_description(FILE *file, const attr_list_t *attrs, type
else if (type_get_type(type) == TYPE_STRUCT &&
get_struct_fc(type) == FC_CPSTRUCT)
{
- type_t *carray = find_array_or_string_in_struct(type)->type;
+ type_t *carray = find_array_or_string_in_struct(type)->declspec.type;
write_conformant_array_pointer_descriptions( file, NULL, carray,
type_memsize(type), typestring_offset);
}
@@ -3058,7 +3058,7 @@ static const var_t *find_array_or_string_in_struct(const type_t *type)
return NULL;
last_field = LIST_ENTRY( list_tail(fields), const var_t, entry );
- ft = last_field->type;
+ ft = last_field->declspec.type;
if (is_conformant_array(ft) && !type_array_is_decl_as_ptr(ft))
return last_field;
@@ -3081,7 +3081,7 @@ static void write_struct_members(FILE *file, const type_t *type,
if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
{
- type_t *ft = field->type;
+ type_t *ft = field->declspec.type;
unsigned int align = 0;
unsigned int size = type_memsize_and_alignment(ft, &align);
align = clamp_align(align);
@@ -3110,7 +3110,7 @@ static void write_struct_members(FILE *file, const type_t *type,
offset = ROUND_SIZE(offset, align);
*typestring_offset += 1;
}
- write_member_type(file, type, is_complex, field->attrs, field->type, corroff,
+ write_member_type(file, type, is_complex, field->attrs, field->declspec.type, corroff,
typestring_offset);
offset += size;
}
@@ -3153,15 +3153,15 @@ static unsigned int write_struct_tfs(FILE *file, type_t *type,
name, USHRT_MAX, total_size - USHRT_MAX);
if (fields) LIST_FOR_EACH_ENTRY(f, fields, var_t, entry)
- write_embedded_types(file, f->attrs, f->type, f->name, FALSE, tfsoff);
+ write_embedded_types(file, f->attrs, f->declspec.type, f->name, FALSE, tfsoff);
array = find_array_or_string_in_struct(type);
- if (array && !processed(array->type))
+ if (array && !processed(array->declspec.type))
{
- if(is_string_type(array->attrs, array->type))
- write_string_tfs(file, array->attrs, array->type, TYPE_CONTEXT_CONTAINER, array->name, tfsoff);
+ if(is_string_type(array->attrs, array->declspec.type))
+ write_string_tfs(file, array->attrs, array->declspec.type, TYPE_CONTEXT_CONTAINER, array->name, tfsoff);
else
- write_array_tfs(file, array->attrs, array->type, array->name, tfsoff);
+ write_array_tfs(file, array->attrs, array->declspec.type, array->name, tfsoff);
}
corroff = *tfsoff;
@@ -3177,7 +3177,7 @@ static unsigned int write_struct_tfs(FILE *file, type_t *type,
if (array)
{
- unsigned int absoff = array->type->typestring_offset;
+ unsigned int absoff = array->declspec.type->typestring_offset;
short reloff = absoff - *tfsoff;
print_file(file, 2, "NdrFcShort(0x%hx),\t/* Offset= %hd (%u) */\n",
reloff, reloff, absoff);
@@ -3223,7 +3223,7 @@ static unsigned int write_struct_tfs(FILE *file, type_t *type,
type->ptrdesc = *tfsoff;
if (fields) LIST_FOR_EACH_ENTRY(f, fields, const var_t, entry)
{
- type_t *ft = f->type;
+ type_t *ft = f->declspec.type;
switch (typegen_detect_type(ft, f->attrs, TDT_IGNORE_STRINGS))
{
case TGT_POINTER:
@@ -3319,8 +3319,8 @@ static unsigned int write_union_tfs(FILE *file, const attr_list_t *attrs,
expr_list_t *cases = get_attrp(f->attrs, ATTR_CASE);
if (cases)
nbranch += list_count(cases);
- if (f->type)
- write_embedded_types(file, f->attrs, f->type, f->name, TRUE, tfsoff);
+ if (f->declspec.type)
+ write_embedded_types(file, f->attrs, f->declspec.type, f->name, TRUE, tfsoff);
}
start_offset = *tfsoff;
@@ -3329,7 +3329,7 @@ static unsigned int write_union_tfs(FILE *file, const attr_list_t *attrs,
if (type_get_type(type) == TYPE_ENCAPSULATED_UNION)
{
const var_t *sv = type_union_get_switch_value(type);
- const type_t *st = sv->type;
+ const type_t *st = sv->declspec.type;
unsigned int align = 0;
unsigned char fc;
@@ -3361,8 +3361,8 @@ static unsigned int write_union_tfs(FILE *file, const attr_list_t *attrs,
type_memsize_and_alignment(st, &align);
if (fields) LIST_FOR_EACH_ENTRY(f, fields, var_t, entry)
{
- if (f->type)
- type_memsize_and_alignment(f->type, &align);
+ if (f->declspec.type)
+ type_memsize_and_alignment(f->declspec.type, &align);
}
print_file(file, 2, "0x%x,\t/* FC_ENCAPSULATED_UNION */\n", FC_ENCAPSULATED_UNION);
@@ -3417,7 +3417,7 @@ static unsigned int write_union_tfs(FILE *file, const attr_list_t *attrs,
if (fields) LIST_FOR_EACH_ENTRY(f, fields, var_t, entry)
{
- type_t *ft = f->type;
+ type_t *ft = f->declspec.type;
expr_list_t *cases = get_attrp(f->attrs, ATTR_CASE);
int deflt = is_attr(f->attrs, ATTR_DEFAULT);
expr_t *c;
@@ -3699,21 +3699,21 @@ static void process_tfs_iface(type_t *iface, FILE *file, int indent, unsigned in
{
const var_t *func = stmt->u.var;
- if(stmt->u.var->stgclass != STG_NONE
- || type_get_type_detect_alias(stmt->u.var->type) != TYPE_FUNCTION)
+ if(stmt->u.var->declspec.stgclass != STG_NONE
+ || type_get_type_detect_alias(stmt->u.var->declspec.type) != TYPE_FUNCTION)
continue;
current_func = func;
if (is_local(func->attrs)) continue;
- var = type_function_get_retval(func->type);
- if (!is_void(var->type))
- var->typestring_offset = write_type_tfs( file, var->attrs, var->type, func->name,
+ var = type_function_get_retval(func->declspec.type);
+ if (!is_void(var->declspec.type))
+ var->typestring_offset = write_type_tfs( file, var->attrs, var->declspec.type, func->name,
TYPE_CONTEXT_RETVAL, offset);
- if (type_get_function_args(func->type))
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), var_t, entry )
- var->typestring_offset = write_type_tfs( file, var->attrs, var->type, var->name,
+ if (type_get_function_args(func->declspec.type))
+ LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), var_t, entry )
+ var->typestring_offset = write_type_tfs( file, var->attrs, var->declspec.type, var->name,
TYPE_CONTEXT_TOPLEVELPARAM, offset );
break;
@@ -3899,8 +3899,8 @@ static unsigned int get_required_buffer_size(const var_t *var, unsigned int *ali
return 20;
}
- if (!is_string_type(var->attrs, var->type))
- return get_required_buffer_size_type(var->type, var->name,
+ if (!is_string_type(var->attrs, var->declspec.type))
+ return get_required_buffer_size_type(var->declspec.type, var->name,
var->attrs, TRUE, alignment);
}
return 0;
@@ -3911,19 +3911,19 @@ static unsigned int get_function_buffer_size( const var_t *func, enum pass pass
const var_t *var;
unsigned int total_size = 0, alignment;
- if (type_get_function_args(func->type))
+ if (type_get_function_args(func->declspec.type))
{
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry )
+ LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), const var_t, entry )
{
total_size += get_required_buffer_size(var, &alignment, pass);
total_size += alignment;
}
}
- if (pass == PASS_OUT && !is_void(type_function_get_rettype(func->type)))
+ if (pass == PASS_OUT && !is_void(type_function_get_rettype(func->declspec.type)))
{
var_t v = *func;
- v.type = type_function_get_rettype(func->type);
+ v.declspec.type = type_function_get_rettype(func->declspec.type);
total_size += get_required_buffer_size(&v, &alignment, PASS_RETURN);
total_size += alignment;
}
@@ -3959,9 +3959,9 @@ static void print_phase_function(FILE *file, int indent, const char *type,
print_file(file, indent, "&__frame->_StubMsg,\n");
print_file(file, indent, "%s%s%s%s%s,\n",
(phase == PHASE_UNMARSHAL) ? "(unsigned char **)" : "(unsigned char *)",
- (phase == PHASE_UNMARSHAL || decl_indirect(var->type)) ? "&" : "",
+ (phase == PHASE_UNMARSHAL || decl_indirect(var->declspec.type)) ? "&" : "",
local_var_prefix,
- (phase == PHASE_UNMARSHAL && decl_indirect(var->type)) ? "_p_" : "",
+ (phase == PHASE_UNMARSHAL && decl_indirect(var->declspec.type)) ? "_p_" : "",
var->name);
print_file(file, indent, "(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%d]%s\n",
type_offset, (phase == PHASE_UNMARSHAL) ? "," : ");");
@@ -3974,7 +3974,7 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix,
enum remoting_phase phase, enum pass pass, const var_t *var,
const char *varname)
{
- type_t *type = var->type;
+ type_t *type = var->declspec.type;
unsigned int alignment = 0;
/* no work to do for other phases, buffer sizing is done elsewhere */
@@ -4116,7 +4116,7 @@ expr_t *get_size_is_expr(const type_t *t, const char *name)
void write_parameter_conf_or_var_exprs(FILE *file, int indent, const char *local_var_prefix,
enum remoting_phase phase, const var_t *var, int valid_variance)
{
- const type_t *type = var->type;
+ const type_t *type = var->declspec.type;
/* get fundamental type for the argument */
for (;;)
{
@@ -4190,7 +4190,7 @@ static void write_remoting_arg(FILE *file, int indent, const var_t *func, const
{
int in_attr, out_attr, pointer_type;
const char *type_str = NULL;
- const type_t *type = var->type;
+ const type_t *type = var->declspec.type;
unsigned int alignment, start_offset = type->typestring_offset;
if (is_ptr(type) || is_array(type))
@@ -4243,7 +4243,7 @@ static void write_remoting_arg(FILE *file, int indent, const var_t *func, const
print_file(file, indent, "NdrServerContextNewMarshall(\n");
print_file(file, indent + 1, "&__frame->_StubMsg,\n");
print_file(file, indent + 1, "(NDR_SCONTEXT)%s%s,\n", local_var_prefix, var->name);
- print_file(file, indent + 1, "(NDR_RUNDOWN)%s_rundown,\n", get_context_handle_type_name(var->type));
+ print_file(file, indent + 1, "(NDR_RUNDOWN)%s_rundown,\n", get_context_handle_type_name(var->declspec.type));
print_file(file, indent + 1, "(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%d]);\n", start_offset);
}
}
@@ -4387,9 +4387,9 @@ static void write_remoting_arg(FILE *file, int indent, const var_t *func, const
range_max = LIST_ENTRY(list_next(range_list, list_head(range_list)), const expr_t, entry);
print_file(file, indent, "if ((%s%s < (", local_var_prefix, var->name);
- write_type_decl(file, var->type, NULL);
+ write_type_decl(file, var->declspec.type, NULL);
fprintf(file, ")0x%x) || (%s%s > (", range_min->cval, local_var_prefix, var->name);
- write_type_decl(file, var->type, NULL);
+ write_type_decl(file, var->declspec.type, NULL);
fprintf(file, ")0x%x))\n", range_max->cval);
print_file(file, indent, "{\n");
print_file(file, indent+1, "RpcRaiseException(RPC_S_INVALID_BOUND);\n");
@@ -4556,14 +4556,14 @@ void write_remoting_arguments(FILE *file, int indent, const var_t *func, const c
if (pass == PASS_RETURN)
{
write_remoting_arg( file, indent, func, local_var_prefix, pass, phase,
- type_function_get_retval(func->type) );
+ type_function_get_retval(func->declspec.type) );
}
else
{
const var_t *var;
- if (!type_get_function_args(func->type))
+ if (!type_get_function_args(func->declspec.type))
return;
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry )
+ LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), const var_t, entry )
write_remoting_arg( file, indent, func, local_var_prefix, pass, phase, var );
}
}
@@ -4604,62 +4604,62 @@ void declare_stub_args( FILE *file, int indent, const var_t *func )
{
int in_attr, out_attr;
int i = 0;
- const var_t *var = type_function_get_retval(func->type);
+ const var_t *var = type_function_get_retval(func->declspec.type);
/* declare return value */
- if (!is_void(var->type))
+ if (!is_void(var->declspec.type))
{
- if (is_context_handle(var->type))
+ if (is_context_handle(var->declspec.type))
print_file(file, indent, "NDR_SCONTEXT %s;\n", var->name);
else
{
print_file(file, indent, "%s", "");
- write_type_decl(file, var->type, var->name);
+ write_type_decl(file, var->declspec.type, var->name);
fprintf(file, ";\n");
}
}
- if (!type_get_function_args(func->type))
+ if (!type_get_function_args(func->declspec.type))
return;
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry )
+ LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), const var_t, entry )
{
in_attr = is_attr(var->attrs, ATTR_IN);
out_attr = is_attr(var->attrs, ATTR_OUT);
if (!out_attr && !in_attr)
in_attr = 1;
- if (is_context_handle(var->type))
+ if (is_context_handle(var->declspec.type))
print_file(file, indent, "NDR_SCONTEXT %s;\n", var->name);
else
{
- if (!in_attr && !is_conformant_array(var->type))
+ if (!in_attr && !is_conformant_array(var->declspec.type))
{
type_t *type_to_print;
char name[16];
print_file(file, indent, "%s", "");
- if (type_get_type(var->type) == TYPE_ARRAY &&
- !type_array_is_decl_as_ptr(var->type))
- type_to_print = var->type;
+ if (type_get_type(var->declspec.type) == TYPE_ARRAY &&
+ !type_array_is_decl_as_ptr(var->declspec.type))
+ type_to_print = var->declspec.type;
else
- type_to_print = type_pointer_get_ref(var->type);
+ type_to_print = type_pointer_get_ref(var->declspec.type);
sprintf(name, "_W%u", i++);
write_type_decl(file, type_to_print, name);
fprintf(file, ";\n");
}
print_file(file, indent, "%s", "");
- write_type_decl_left(file, var->type);
+ write_type_decl_left(file, var->declspec.type);
fprintf(file, " ");
- if (type_get_type(var->type) == TYPE_ARRAY &&
- !type_array_is_decl_as_ptr(var->type)) {
+ if (type_get_type(var->declspec.type) == TYPE_ARRAY &&
+ !type_array_is_decl_as_ptr(var->declspec.type)) {
fprintf(file, "(*%s)", var->name);
} else
fprintf(file, "%s", var->name);
- write_type_right(file, var->type, FALSE);
+ write_type_right(file, var->declspec.type, FALSE);
fprintf(file, ";\n");
- if (decl_indirect(var->type))
+ if (decl_indirect(var->declspec.type))
print_file(file, indent, "void *_p_%s;\n", var->name);
}
}
@@ -4673,10 +4673,10 @@ void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char
const var_t *var;
type_t *ref;
- if (!type_get_function_args(func->type))
+ if (!type_get_function_args(func->declspec.type))
return;
- LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry )
+ LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->declspec.type), const var_t, entry )
{
in_attr = is_attr(var->attrs, ATTR_IN);
out_attr = is_attr(var->attrs, ATTR_OUT);
@@ -4687,7 +4687,7 @@ void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char
{
print_file(file, indent, "%s%s", local_var_prefix, var->name);
- switch (typegen_detect_type(var->type, var->attrs, TDT_IGNORE_STRINGS))
+ switch (typegen_detect_type(var->declspec.type, var->attrs, TDT_IGNORE_STRINGS))
{
case TGT_CTXT_HANDLE_POINTER:
fprintf(file, " = NdrContextHandleInitialize(\n");
@@ -4696,13 +4696,13 @@ void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char
var->typestring_offset);
break;
case TGT_ARRAY:
- if (type_array_has_conformance(var->type))
+ if (type_array_has_conformance(var->declspec.type))
{
unsigned int size;
type_t *type;
fprintf(file, " = NdrAllocate(&__frame->_StubMsg, ");
- for (type = var->type;
+ for (type = var->declspec.type;
is_array(type) && type_array_has_conformance(type);
type = type_array_get_element(type))
{
@@ -4714,7 +4714,7 @@ void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char
fprintf(file, "%u);\n", size);
print_file(file, indent, "memset(%s%s, 0, ", local_var_prefix, var->name);
- for (type = var->type;
+ for (type = var->declspec.type;
is_array(type) && type_array_has_conformance(type);
type = type_array_get_element(type))
{
@@ -4730,7 +4730,7 @@ void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char
break;
case TGT_POINTER:
fprintf(file, " = &%s_W%u;\n", local_var_prefix, i);
- ref = type_pointer_get_ref(var->type);
+ ref = type_pointer_get_ref(var->declspec.type);
switch (typegen_detect_type(ref, var->attrs, TDT_IGNORE_STRINGS))
{
case TGT_BASIC:
@@ -4790,7 +4790,7 @@ void write_func_param_struct( FILE *file, const type_t *iface, const type_t *fun
if (args)
LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
- if (!is_array( arg->type )) type_memsize_and_alignment( arg->type, &align );
+ if (!is_array( arg->declspec.type )) type_memsize_and_alignment( arg->declspec.type, &align );
needs_packing = (align > pointer_size);
@@ -4802,26 +4802,26 @@ void write_func_param_struct( FILE *file, const type_t *iface, const type_t *fun
if (args) LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
{
print_file(file, 2, "%s", "");
- write_type_left( file, (type_t *)arg->type, NAME_DEFAULT, TRUE );
- if (needs_space_after( arg->type )) fputc( ' ', file );
- if (is_array( arg->type ) && !type_array_is_decl_as_ptr( arg->type )) fputc( '*', file );
+ write_type_left( file, (type_t *)arg->declspec.type, NAME_DEFAULT, TRUE );
+ if (needs_space_after( arg->declspec.type )) fputc( ' ', file );
+ if (is_array( arg->declspec.type ) && !type_array_is_decl_as_ptr( arg->declspec.type )) fputc( '*', file );
/* FIXME: should check for large args being passed by pointer */
align = 0;
- if (is_array( arg->type ) || is_ptr( arg->type )) align = pointer_size;
- else type_memsize_and_alignment( arg->type, &align );
+ if (is_array( arg->declspec.type ) || is_ptr( arg->declspec.type )) align = pointer_size;
+ else type_memsize_and_alignment( arg->declspec.type, &align );
if (align >= pointer_size)
fprintf( file, "%s;\n", arg->name );
else
fprintf( file, "%s DECLSPEC_ALIGN(%u);\n", arg->name, pointer_size );
}
- if (add_retval && !is_void( retval->type ))
+ if (add_retval && !is_void( retval->declspec.type ))
{
print_file(file, 2, "%s", "");
- write_type_decl( file, retval->type, retval->name );
- if (is_array( retval->type ) || is_ptr( retval->type ) ||
- type_memsize( retval->type ) == pointer_size)
+ write_type_decl( file, retval->declspec.type, retval->name );
+ if (is_array( retval->declspec.type ) || is_ptr( retval->declspec.type ) ||
+ type_memsize( retval->declspec.type ) == pointer_size)
fprintf( file, ";\n" );
else
fprintf( file, " DECLSPEC_ALIGN(%u);\n", pointer_size );
@@ -4833,7 +4833,7 @@ void write_func_param_struct( FILE *file, const type_t *iface, const type_t *fun
void write_pointer_checks( FILE *file, int indent, const var_t *func )
{
- const var_list_t *args = type_get_function_args( func->type );
+ const var_list_t *args = type_get_function_args( func->declspec.type );
const var_t *var;
if (!args) return;
@@ -4963,9 +4963,9 @@ error:
void write_client_call_routine( FILE *file, const type_t *iface, const var_t *func,
const char *prefix, unsigned int proc_offset )
{
- type_t *rettype = type_function_get_rettype( func->type );
+ type_t *rettype = type_function_get_rettype( func->declspec.type );
int has_ret = !is_void( rettype );
- const var_list_t *args = type_get_function_args( func->type );
+ const var_list_t *args = type_get_function_args( func->declspec.type );
const var_t *arg;
int len, needs_params = 0;
@@ -4976,7 +4976,7 @@ void write_client_call_routine( FILE *file, const type_t *iface, const var_t *fu
if (needs_params)
{
if (has_ret) print_file( file, 1, "%s", "CLIENT_CALL_RETURN _RetVal;\n" );
- write_func_param_struct( file, iface, func->type, "__params", FALSE );
+ write_func_param_struct( file, iface, func->declspec.type, "__params", FALSE );
if (is_object( iface )) print_file( file, 1, "__params.This = This;\n" );
if (args)
LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c
index b93806be98..3b0c944387 100644
--- a/tools/widl/typetree.c
+++ b/tools/widl/typetree.c
@@ -137,7 +137,7 @@ type_t *type_new_function(var_list_t *args)
if (args)
{
arg = LIST_ENTRY(list_head(args), var_t, entry);
- if (list_count(args) == 1 && !arg->name && arg->type && type_get_type(arg->type) == TYPE_VOID)
+ if (list_count(args) == 1 && !arg->name && arg->declspec.type && type_get_type(arg->declspec.type) == TYPE_VOID)
{
list_remove(&arg->entry);
free(arg);
@@ -147,7 +147,7 @@ type_t *type_new_function(var_list_t *args)
}
if (args) LIST_FOR_EACH_ENTRY(arg, args, var_t, entry)
{
- if (arg->type && type_get_type(arg->type) == TYPE_VOID)
+ if (arg->declspec.type && type_get_type(arg->declspec.type) == TYPE_VOID)
error_loc("argument '%s' has void type\n", arg->name);
if (!arg->name)
{
@@ -354,7 +354,7 @@ type_t *type_new_encapsulated_union(char *name, var_t *switch_field, var_t *unio
{
type_t *t = get_type(TYPE_ENCAPSULATED_UNION, name, NULL, tsUNION);
if (!union_field) union_field = make_var( xstrdup("tagged_union") );
- union_field->type = type_new_nonencapsulated_union(NULL, TRUE, cases);
+ union_field->declspec.type = type_new_nonencapsulated_union(NULL, TRUE, cases);
t->details.structure = xmalloc(sizeof(*t->details.structure));
t->details.structure->fields = append_var( NULL, switch_field );
t->details.structure->fields = append_var( t->details.structure->fields, union_field );
@@ -430,7 +430,7 @@ static int compute_method_indexes(type_t *iface)
{
var_t *func = stmt->u.var;
if (!is_callas(func->attrs))
- func->type->details.function->idx = idx++;
+ func->declspec.type->details.function->idx = idx++;
}
return idx;
diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h
index fc134cd575..9f0dc5afc6 100644
--- a/tools/widl/typetree.h
+++ b/tools/widl/typetree.h
@@ -107,7 +107,7 @@ static inline var_t *type_function_get_retval(const type_t *type)
static inline type_t *type_function_get_rettype(const type_t *type)
{
- return type_function_get_retval(type)->type;
+ return type_function_get_retval(type)->declspec.type;
}
static inline var_list_t *type_enum_get_values(const type_t *type)
@@ -142,7 +142,7 @@ static inline var_list_t *type_union_get_cases(const type_t *type)
if (type_type == TYPE_ENCAPSULATED_UNION)
{
const var_t *uv = LIST_ENTRY(list_tail(type->details.structure->fields), const var_t, entry);
- return uv->type->details.structure->fields;
+ return uv->declspec.type->details.structure->fields;
}
else
return type->details.structure->fields;
diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h
index 1177c1a00a..31a0cc74dd 100644
--- a/tools/widl/widltypes.h
+++ b/tools/widl/widltypes.h
@@ -40,6 +40,7 @@ typedef struct _attr_t attr_t;
typedef struct _expr_t expr_t;
typedef struct _type_t type_t;
typedef struct _var_t var_t;
+typedef struct _decl_spec_t decl_spec_t;
typedef struct _declarator_t declarator_t;
typedef struct _ifref_t ifref_t;
typedef struct _typelib_entry_t typelib_entry_t;
@@ -293,6 +294,13 @@ struct str_list_entry_t
struct list entry;
};
+struct _decl_spec_t
+{
+ type_t *type;
+ attr_list_t *attrs;
+ enum storage_class stgclass;
+};
+
struct _attr_t {
enum attr_type type;
union {
@@ -449,10 +457,10 @@ struct _type_t {
struct _var_t {
char *name;
- type_t *type;
+ decl_spec_t declspec;
+
attr_list_t *attrs;
expr_t *eval;
- enum storage_class stgclass;
unsigned int procstring_offset;
unsigned int typestring_offset;
@@ -596,8 +604,8 @@ static inline enum type_type type_get_type_detect_alias(const type_t *type)
#define STATEMENTS_FOR_EACH_FUNC(stmt, stmts) \
if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, statement_t, entry ) \
- if (stmt->type == STMT_DECLARATION && stmt->u.var->stgclass == STG_NONE && \
- type_get_type_detect_alias(stmt->u.var->type) == TYPE_FUNCTION)
+ if (stmt->type == STMT_DECLARATION && stmt->u.var->declspec.stgclass == STG_NONE && \
+ type_get_type_detect_alias(stmt->u.var->declspec.type) == TYPE_FUNCTION)
static inline int statements_has_func(const statement_list_t *stmts)
{
@@ -616,4 +624,13 @@ static inline int is_global_namespace(const struct namespace *namespace)
return !namespace->name;
}
+static inline decl_spec_t *init_declspec(decl_spec_t *declspec, type_t *type)
+{
+ declspec->type = type;
+ declspec->attrs = NULL;
+ declspec->stgclass = STG_NONE;
+
+ return declspec;
+}
+
#endif
diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c
index 4dcbc03702..7738cae729 100644
--- a/tools/widl/write_msft.c
+++ b/tools/widl/write_msft.c
@@ -1301,8 +1301,8 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, var_t *func, int index)
return S_FALSE;
}
- if (type_get_function_args(func->type))
- LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->type), var_t, entry )
+ if (type_get_function_args(func->declspec.type))
+ LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->declspec.type), var_t, entry )
{
num_params++;
if (arg->attrs) LIST_FOR_EACH_ENTRY( attr, arg->attrs, const attr_t, entry ) {
@@ -1444,7 +1444,7 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, var_t *func, int index)
/* fill out the basic type information */
typedata[0] = typedata_size | (index << 16);
- encode_var(typeinfo->typelib, type_function_get_rettype(func->type), func,
+ encode_var(typeinfo->typelib, type_function_get_rettype(func->declspec.type), func,
&typedata[1], &decoded_size);
typedata[2] = funcflags;
typedata[3] = ((52 /*sizeof(FUNCDESC)*/ + decoded_size) << 16) | typeinfo->typeinfo->cbSizeVft;
@@ -1471,10 +1471,10 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, var_t *func, int index)
warning("unknown number of optional attrs\n");
}
- if (type_get_function_args(func->type))
+ if (type_get_function_args(func->declspec.type))
{
i = 0;
- LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->type), var_t, entry )
+ LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->declspec.type), var_t, entry )
{
int paramflags = 0;
int *paramdata = typedata + 6 + extra_attr + (num_defaults ? num_params : 0) + i * 3;
@@ -1482,13 +1482,13 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, var_t *func, int index)
if(defaultdata) *defaultdata = -1;
- encode_var(typeinfo->typelib, arg->type, arg, paramdata, &decoded_size);
+ encode_var(typeinfo->typelib, arg->declspec.type, arg, paramdata, &decoded_size);
if (arg->attrs) LIST_FOR_EACH_ENTRY( attr, arg->attrs, const attr_t, entry ) {
switch(attr->type) {
case ATTR_DEFAULTVALUE:
{
paramflags |= 0x30; /* PARAMFLAG_FHASDEFAULT | PARAMFLAG_FOPT */
- write_default_value(typeinfo->typelib, arg->type, (expr_t *)attr->u.pval, defaultdata);
+ write_default_value(typeinfo->typelib, arg->declspec.type, (expr_t *)attr->u.pval, defaultdata);
break;
}
case ATTR_IN:
@@ -1572,10 +1572,10 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, var_t *func, int index)
if(typeinfo->typekind == TKIND_MODULE)
namedata[9] |= 0x20;
- if (type_get_function_args(func->type))
+ if (type_get_function_args(func->declspec.type))
{
i = 0;
- LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->type), var_t, entry )
+ LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->declspec.type), var_t, entry )
{
/* don't give the last arg of a [propput*] func a name */
if(i != num_params - 1 || (invokekind != 0x4 /* INVOKE_PROPERTYPUT */ && invokekind != 0x8 /* INVOKE_PROPERTYPUTREF */))
@@ -1697,8 +1697,8 @@ static HRESULT add_var_desc(msft_typeinfo_t *typeinfo, UINT index, var_t* var)
typeinfo->var_offsets[var_num] = offset;
/* figure out type widths and whatnot */
- var_datawidth = type_memsize_and_alignment(var->type, &var_alignment);
- encode_var(typeinfo->typelib, var->type, var, &typedata[1], &var_type_size);
+ var_datawidth = type_memsize_and_alignment(var->declspec.type, &var_alignment);
+ encode_var(typeinfo->typelib, var->declspec.type, var, &typedata[1], &var_type_size);
/* pad out starting position to data width */
typeinfo->datawidth += var_alignment - 1;
--
2.17.1
July 5, 2019
Wine on Solaris 2.11
by Rick V
I've managed to compile the Wine 4.10 runtime bits on Solaris 2, but i
keep running into a problem with the native linker (and GNU LD/GOLD)
where winebuild/winegcc fails to remove the import symbols from the
wrapped PE-in-ELF shared object:
../../tools/winegcc/winegcc -o acledit.dll.so -B../../tools/winebuild
-fno-PIC -fasynchronous-unwind-tables \
-shared ../../../dlls/acledit/acledit.spec -mno-cygwin main.o
-lsocket -lnsl -mimpure-text -L/usr/local/lib -Wl,-R/usr/local/lib
Undefined first referenced
symbol in file
__wine$func$msvcrt$1016$ftell
../../dlls/msvcrt/libmsvcrt.a(msvcrt.8sjEgq.o)
__wine$func$msvcrt$1024$getenv
../../dlls/msvcrt/libmsvcrt.a(msvcrt.k9b5ph.o)
__wine$func$msvcrt$1060$localtime
../../dlls/msvcrt/libmsvcrt.a(msvcrt.4A4GdP.o)
__wine$func$msvcrt$1019$fwrite
../../dlls/msvcrt/libmsvcrt.a(msvcrt.kAOzVa.o)
__wine$func$msvcrt$1007$fread
../../dlls/msvcrt/libmsvcrt.a(msvcrt.socBBA.o)
(and so forth)
I'm at a loss to describe any extra information, and I don't think using
GNU LD or GOLD fixes this (might have to remove any target-specific code
in winebuild to fall through to Linux/GNU LD behaviour to check)
Thanks
R
July 5, 2019
Re: [PATCH v2] server: Rename cpu_type_t to client_cpu_t.
by Alex Henrie
Hi Jacek,
Names with the suffix _t are reserved for POSIX extensions, so you
might want to drop the _t from this typename altogether. See
https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#t…
-Alex
July 5, 2019
specific api functions for screen readers questions
by Mgr. Janusz Chmiel
Dear specialists,
Does somebody of you know, if Wine support API functions which could be
used by very simple focusable object based screen reader? This screen
reader would react on key events and other internal WIne events such as
if dialog window have been displaied.
Screen reader should send textual content of focusable objects such as
buttons, comboboxes, dialog windows, menu items to speech output.
Because screen reader which I would like to develop can not use
Microsoft components including Microsoft C run-times, SAPI5, 4 or newest
Windows 10 speech kit, there is only possibility to develop integrated
speech engine from scrath. Or ask you how complex would be for you to
develop software bridge between Wine and speech-dispatcher speech
server. This software bridge would introduce simple Speech functions and
procedures, which would allow developers to send textual data to active
speech engine by using Speech-dispatcher speech server.
FOr beginning, I would like to know, if Wine contain some USER32.dll and
other API calls, which are able to get text information from object
which have focus.
Sure, screen reader, which I would like to develop will be very simple.
It will never be comparable with NVDA, Jaws or with other complex screen
readers for Windows. I would like to only develop at least simple focus
and event based screen reader, which will be able to use with simple Win
32 apps such as notepad, integrated explorer.exe with Wine, with
MP3directcut for Windows, ETC.
Because screen reader can not use libraries from Microsoft, I Am aware,
that my goal will never produce screen reader which will be able to
support object hiearchi browsing inside active Window.
Very important question is, if Wine contain APi calls to detect object
class name, which will be detected from object, which have focus.
Without this routine, my dream will be never possible.
Last question.
Does integrated Windows PE routines support machine code instructions,
which have been generated by Free Basic compiler for Windows? Because I
do not know, if generated machine code hhave not been specifically
prepared for original Microsoft Windows so if compiled apps, which would
run normally from original Windows will not cause random crashes and
stability issues when running it with Wine.
I can not use programming languages from Microsoft. There are 3 Basic
language compiler from other teams than from Microsoft. Power Basic,
Free Basic and Pure Basic. BUt Pure Basic is commercial, Power Basic is
commercial and Free Basic is The onlyone free Basic compiler, which
generates .exe apps which do not depend on Microsoft .dlls as default.
I have old time experience with various screen readers.
When Windows 3.11 have been developed, two very smart C++ ddevelopers
in our country have developed screen readers for Windows 3.11. It did
not used mSAA. Screen reader had its internal speech engine which had
nothing to do with Speech API, because in 1994 there was no such
routines from Microsoft.
Screen reader have reacted on keyboard events, it spoken lines of text
from editable fields, text of dialog windows, menu items.
So do you think, that APi calls which are available inside WIne now can
allow Me to develop such focusable object based screen reader? Or it is
paradox situation, that WIndows 3.11 16 Bit version from 1994 have
allowed that and modern Wine do not allow it?
Really, I do not write about Windows 95. It was really Windows FOR
WORKGROUPS 3.11 AND ITS 16 BIT VERSION, NOT Win32.
Thank you very much for yours kind acces to my questions. I will intrude
you as little as possible, I know, that you are very overloaded. I need
to know, if my dream can come true or no.
July 5, 2019
Re: [PATCH 2/2] winmm: Build with msvcrt.
by Andrew Eikum
Signed-off-by: Andrew Eikum <aeikum(a)codeweavers.com>
On Tue, Jul 02, 2019 at 08:00:47PM +0200, Jacek Caban wrote:
> Signed-off-by: Jacek Caban <jacek(a)codeweavers.com>
> ---
> dlls/winmm/Makefile.in | 2 +
> dlls/winmm/driver.c | 6 +--
> dlls/winmm/joystick.c | 8 ----
> dlls/winmm/lolvldrv.c | 2 -
> dlls/winmm/mci.c | 105 ++++++++++++++++++++---------------------
> 5 files changed, 54 insertions(+), 69 deletions(-)
>
>
> diff --git a/dlls/winmm/Makefile.in b/dlls/winmm/Makefile.in
> index 3036526c14..c05115d5c5 100644
> --- a/dlls/winmm/Makefile.in
> +++ b/dlls/winmm/Makefile.in
> @@ -3,6 +3,8 @@ MODULE = winmm.dll
> IMPORTLIB = winmm
> IMPORTS = uuid user32 advapi32 ole32 msacm32
>
> +EXTRADLLFLAGS = -mno-cygwin
> +
> C_SRCS = \
> driver.c \
> joystick.c \
> diff --git a/dlls/winmm/driver.c b/dlls/winmm/driver.c
> index 0117c60496..24db0edc37 100644
> --- a/dlls/winmm/driver.c
> +++ b/dlls/winmm/driver.c
> @@ -20,9 +20,6 @@
> * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
> */
>
> -#include "config.h"
> -#include "wine/port.h"
> -
> #include <string.h>
> #include <stdarg.h>
> #include "windef.h"
> @@ -34,7 +31,6 @@
> #include "mmddk.h"
> #include "winemm.h"
> #include "wine/debug.h"
> -#include "wine/unicode.h"
> #include "excpt.h"
> #include "wine/exception.h"
>
> @@ -287,7 +283,7 @@ LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCWSTR fn, LPARAM lParam2)
>
> TRACE("(%s, %08lX);\n", debugstr_w(fn), lParam2);
>
> - if ((ptr = strchrW(fn, ' ')) != NULL) {
> + if ((ptr = wcschr(fn, ' ')) != NULL) {
> *ptr++ = '\0';
> while (*ptr == ' ') ptr++;
> if (*ptr == '\0') ptr = NULL;
> diff --git a/dlls/winmm/joystick.c b/dlls/winmm/joystick.c
> index 92a7ce95d8..e844be1837 100644
> --- a/dlls/winmm/joystick.c
> +++ b/dlls/winmm/joystick.c
> @@ -21,19 +21,11 @@
> * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
> */
>
> -#include "config.h"
> -
> -#ifdef HAVE_UNISTD_H
> -# include <unistd.h>
> -#endif
> #include <stdarg.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <fcntl.h>
> -#ifdef HAVE_SYS_IOCTL_H
> -#include <sys/ioctl.h>
> -#endif
>
> #include "windef.h"
> #include "winbase.h"
> diff --git a/dlls/winmm/lolvldrv.c b/dlls/winmm/lolvldrv.c
> index 95f454f31d..34c9b1408f 100644
> --- a/dlls/winmm/lolvldrv.c
> +++ b/dlls/winmm/lolvldrv.c
> @@ -20,8 +20,6 @@
> * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
> */
>
> -#include "config.h"
> -#include "wine/port.h"
>
> #define NONAMELESSUNION
> #define COBJMACROS
> diff --git a/dlls/winmm/mci.c b/dlls/winmm/mci.c
> index 0319a0b16c..39f9853939 100644
> --- a/dlls/winmm/mci.c
> +++ b/dlls/winmm/mci.c
> @@ -37,8 +37,6 @@
> * - command table handling isn't thread safe
> */
>
> -#include "config.h"
> -#include "wine/port.h"
>
> #include <stdlib.h>
> #include <stdarg.h>
> @@ -58,7 +56,6 @@
> #include "winemm.h"
>
> #include "wine/debug.h"
> -#include "wine/unicode.h"
>
> WINE_DEFAULT_DEBUG_CHANNEL(mci);
>
> @@ -81,7 +78,7 @@ static UINT MCI_SetCommandTable(HGLOBAL hMem, UINT uDevType);
> /* dup a string and uppercase it */
> static inline LPWSTR str_dup_upper( LPCWSTR str )
> {
> - INT len = (strlenW(str) + 1) * sizeof(WCHAR);
> + INT len = (lstrlenW(str) + 1) * sizeof(WCHAR);
> LPWSTR p = HeapAlloc( GetProcessHeap(), 0, len );
> if (p)
> {
> @@ -118,12 +115,12 @@ static UINT MCI_GetDriverFromString(LPCWSTR lpstrName)
> if (!lpstrName)
> return 0;
>
> - if (!strcmpiW(lpstrName, wszAll))
> + if (!wcsicmp(lpstrName, wszAll))
> return MCI_ALL_DEVICE_ID;
>
> EnterCriticalSection(&WINMM_cs);
> for (wmd = MciDrivers; wmd; wmd = wmd->lpNext) {
> - if (wmd->lpstrAlias && strcmpiW(wmd->lpstrAlias, lpstrName) == 0) {
> + if (wmd->lpstrAlias && wcsicmp(wmd->lpstrAlias, lpstrName) == 0) {
> ret = wmd->wDeviceID;
> break;
> }
> @@ -530,7 +527,7 @@ static DWORD MCI_GetDevTypeFromFileName(LPCWSTR fileName, LPWSTR buf, UINT len)
> static const WCHAR keyW[] = {'S','O','F','T','W','A','R','E','\\','M','i','c','r','o','s','o','f','t','\\',
> 'W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
> 'M','C','I',' ','E','x','t','e','n','s','i','o','n','s',0};
> - if ((tmp = strrchrW(fileName, '.'))) {
> + if ((tmp = wcsrchr(fileName, '.'))) {
> if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, keyW,
> 0, KEY_QUERY_VALUE, &hKey ) == ERROR_SUCCESS) {
> DWORD dwLen = len;
> @@ -553,7 +550,7 @@ static UINT MCI_GetDevTypeFromResource(LPCWSTR lpstrName)
> for (uDevType = MCI_DEVTYPE_FIRST; uDevType <= MCI_DEVTYPE_LAST; uDevType++) {
> if (LoadStringW(hWinMM32Instance, uDevType, buf, ARRAY_SIZE(buf))) {
> /* FIXME: ignore digits suffix */
> - if (!strcmpiW(buf, lpstrName))
> + if (!wcsicmp(buf, lpstrName))
> return uDevType;
> }
> }
> @@ -594,7 +591,7 @@ static BOOL MCI_IsCommandTableValid(UINT uTbl)
> lmem = S_MciCmdTable[uTbl].lpTable;
> do {
> str = (LPCWSTR)lmem;
> - lmem += (strlenW(str) + 1) * sizeof(WCHAR);
> + lmem += (lstrlenW(str) + 1) * sizeof(WCHAR);
> flg = *(const DWORD*)lmem;
> eid = *(const WORD*)(lmem + sizeof(DWORD));
> lmem += sizeof(DWORD) + sizeof(WORD);
> @@ -639,7 +636,7 @@ static BOOL MCI_DumpCommandTable(UINT uTbl)
> do {
> /* DWORD flg; */
> str = (LPCWSTR)lmem;
> - lmem += (strlenW(str) + 1) * sizeof(WCHAR);
> + lmem += (lstrlenW(str) + 1) * sizeof(WCHAR);
> /* flg = *(const DWORD*)lmem; */
> eid = *(const WORD*)(lmem + sizeof(DWORD));
> /* TRACE("cmd=%s %08lx %04x\n", debugstr_w(str), flg, eid); */
> @@ -731,7 +728,7 @@ static UINT MCI_SetCommandTable(HGLOBAL hMem, UINT uDevType)
> count = 0;
> do {
> str = (LPCWSTR)lmem;
> - lmem += (strlenW(str) + 1) * sizeof(WCHAR);
> + lmem += (lstrlenW(str) + 1) * sizeof(WCHAR);
> eid = *(const WORD*)(lmem + sizeof(DWORD));
> lmem += sizeof(DWORD) + sizeof(WORD);
> if (eid == MCI_COMMAND_HEAD)
> @@ -745,7 +742,7 @@ static UINT MCI_SetCommandTable(HGLOBAL hMem, UINT uDevType)
> count = 0;
> do {
> str = (LPCWSTR)lmem;
> - lmem += (strlenW(str) + 1) * sizeof(WCHAR);
> + lmem += (lstrlenW(str) + 1) * sizeof(WCHAR);
> eid = *(const WORD*)(lmem + sizeof(DWORD));
> lmem += sizeof(DWORD) + sizeof(WORD);
> if (eid == MCI_COMMAND_HEAD)
> @@ -847,7 +844,7 @@ static DWORD MCI_LoadMciDriver(LPCWSTR _strDevTyp, LPWINE_MCIDRIVER* lpwmd)
> /* silence warning if all is used... some bogus program use commands like
> * 'open all'...
> */
> - if (strcmpiW(strDevTyp, wszAll) == 0) {
> + if (wcsicmp(strDevTyp, wszAll) == 0) {
> dwRet = MCIERR_CANNOT_USE_ALL;
> } else {
> FIXME("Couldn't load driver for type %s.\n",
> @@ -928,9 +925,9 @@ static DWORD MCI_FinishOpen(LPWINE_MCIDRIVER wmd, LPMCI_OPEN_PARMSW lpParms,
> return MCIERR_DEVICE_OPEN;
> }
> if (alias) {
> - wmd->lpstrAlias = HeapAlloc(GetProcessHeap(), 0, (strlenW(alias)+1) * sizeof(WCHAR));
> + wmd->lpstrAlias = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(alias)+1) * sizeof(WCHAR));
> if (!wmd->lpstrAlias) return MCIERR_OUT_OF_MEMORY;
> - strcpyW( wmd->lpstrAlias, alias);
> + lstrcpyW( wmd->lpstrAlias, alias);
> /* In most cases, natives adds MCI_OPEN_ALIAS to the flags passed to the driver.
> * Don't. The drivers don't care about the winmm alias. */
> }
> @@ -955,7 +952,7 @@ static LPCWSTR MCI_FindCommand(UINT uTbl, LPCWSTR verb)
> * array look up
> */
> for (idx = 0; idx < S_MciCmdTable[uTbl].nVerbs; idx++) {
> - if (strcmpiW(S_MciCmdTable[uTbl].aVerbs[idx], verb) == 0)
> + if (wcsicmp(S_MciCmdTable[uTbl].aVerbs[idx], verb) == 0)
> return S_MciCmdTable[uTbl].aVerbs[idx];
> }
>
> @@ -967,7 +964,7 @@ static LPCWSTR MCI_FindCommand(UINT uTbl, LPCWSTR verb)
> */
> static DWORD MCI_GetReturnType(LPCWSTR lpCmd)
> {
> - lpCmd = (LPCWSTR)((const BYTE*)(lpCmd + strlenW(lpCmd) + 1) + sizeof(DWORD) + sizeof(WORD));
> + lpCmd = (LPCWSTR)((const BYTE*)(lpCmd + lstrlenW(lpCmd) + 1) + sizeof(DWORD) + sizeof(WORD));
> if (*lpCmd == '\0' && *(const WORD*)((const BYTE*)(lpCmd + 1) + sizeof(DWORD)) == MCI_RETURN) {
> return *(const DWORD*)(lpCmd + 1);
> }
> @@ -979,7 +976,7 @@ static DWORD MCI_GetReturnType(LPCWSTR lpCmd)
> */
> static WORD MCI_GetMessage(LPCWSTR lpCmd)
> {
> - return (WORD)*(const DWORD*)(lpCmd + strlenW(lpCmd) + 1);
> + return (WORD)*(const DWORD*)(lpCmd + lstrlenW(lpCmd) + 1);
> }
>
> /**************************************************************************
> @@ -1036,19 +1033,19 @@ static DWORD MCI_GetString(LPWSTR* str, LPWSTR* args)
>
> /* see if we have a quoted string */
> if (*ptr == '"') {
> - ptr = strchrW(*str = ptr + 1, '"');
> + ptr = wcschr(*str = ptr + 1, '"');
> if (!ptr) return MCIERR_NO_CLOSING_QUOTE;
> /* FIXME: shall we escape \" from string ?? */
> if (ptr[-1] == '\\') TRACE("Ooops: un-escaped \"\n");
> *ptr++ = '\0'; /* remove trailing " */
> if (*ptr != ' ' && *ptr != '\0') return MCIERR_EXTRA_CHARACTERS;
> } else {
> - ptr = strchrW(ptr, ' ');
> + ptr = wcschr(ptr, ' ');
>
> if (ptr) {
> *ptr++ = '\0';
> } else {
> - ptr = *args + strlenW(*args);
> + ptr = *args + lstrlenW(*args);
> }
> *str = *args;
> }
> @@ -1084,7 +1081,7 @@ static DWORD MCI_ParseOptArgs(DWORD* data, int _offset, LPCWSTR lpCmd,
>
> do { /* loop on options for command table for the requested verb */
> str = (LPCWSTR)lmem;
> - lmem += ((len = strlenW(str)) + 1) * sizeof(WCHAR);
> + lmem += ((len = lstrlenW(str)) + 1) * sizeof(WCHAR);
> flg = *(const DWORD*)lmem;
> eid = *(const WORD*)(lmem + sizeof(DWORD));
> lmem += sizeof(DWORD) + sizeof(WORD);
> @@ -1107,7 +1104,7 @@ static DWORD MCI_ParseOptArgs(DWORD* data, int _offset, LPCWSTR lpCmd,
> }
> }
>
> - if (strncmpiW(args, str, len) == 0 &&
> + if (wcsnicmp(args, str, len) == 0 &&
> ((eid == MCI_STRING && len == 0) || args[len] == 0 || args[len] == ' ')) {
> /* store good values into data[] */
> args += len;
> @@ -1217,7 +1214,7 @@ static DWORD MCI_HandleReturnValues(DWORD dwRet, LPWINE_MCIDRIVER wmd, DWORD ret
> switch (dwRet & 0xFFFF0000ul) {
> case 0:
> case MCI_INTEGER_RETURNED:
> - snprintfW(lpstrRet, uRetLen, fmt_d, data);
> + swprintf(lpstrRet, uRetLen, fmt_d, data);
> break;
> case MCI_RESOURCE_RETURNED:
> /* return string which ID is HIWORD(data),
> @@ -1232,12 +1229,12 @@ static DWORD MCI_HandleReturnValues(DWORD dwRet, LPWINE_MCIDRIVER wmd, DWORD ret
> HIWORD(data), lpstrRet, uRetLen);
> break;
> case MCI_COLONIZED3_RETURN:
> - snprintfW(lpstrRet, uRetLen, wszCol3,
> + swprintf(lpstrRet, uRetLen, wszCol3,
> LOBYTE(LOWORD(data)), HIBYTE(LOWORD(data)),
> LOBYTE(HIWORD(data)));
> break;
> case MCI_COLONIZED4_RETURN:
> - snprintfW(lpstrRet, uRetLen, wszCol4,
> + swprintf(lpstrRet, uRetLen, wszCol4,
> LOBYTE(LOWORD(data)), HIBYTE(LOWORD(data)),
> LOBYTE(HIWORD(data)), HIBYTE(HIWORD(data)));
> break;
> @@ -1253,7 +1250,7 @@ static DWORD MCI_HandleReturnValues(DWORD dwRet, LPWINE_MCIDRIVER wmd, DWORD ret
> switch (dwRet & 0xFFFF0000ul) {
> case 0:
> case MCI_INTEGER_RETURNED:
> - snprintfW(lpstrRet, uRetLen, fmt_ld, data);
> + swprintf(lpstrRet, uRetLen, fmt_ld, data);
> break;
> case MCI_RESOURCE_RETURNED:
> /* return string which ID is HIWORD(data),
> @@ -1268,12 +1265,12 @@ static DWORD MCI_HandleReturnValues(DWORD dwRet, LPWINE_MCIDRIVER wmd, DWORD ret
> HIWORD(data), lpstrRet, uRetLen);
> break;
> case MCI_COLONIZED3_RETURN:
> - snprintfW(lpstrRet, uRetLen, wszCol3,
> + swprintf(lpstrRet, uRetLen, wszCol3,
> LOBYTE(LOWORD(data)), HIBYTE(LOWORD(data)),
> LOBYTE(HIWORD(data)));
> break;
> case MCI_COLONIZED4_RETURN:
> - snprintfW(lpstrRet, uRetLen, wszCol4,
> + swprintf(lpstrRet, uRetLen, wszCol4,
> LOBYTE(LOWORD(data)), HIBYTE(LOWORD(data)),
> LOBYTE(HIWORD(data)), HIBYTE(HIWORD(data)));
> break;
> @@ -1291,7 +1288,7 @@ static DWORD MCI_HandleReturnValues(DWORD dwRet, LPWINE_MCIDRIVER wmd, DWORD ret
> {
> DWORD *data = (DWORD *)(params + 1);
> *data = *(LPDWORD)lpstrRet;
> - snprintfW(lpstrRet, uRetLen, fmt_d, *data);
> + swprintf(lpstrRet, uRetLen, fmt_d, *data);
> break;
> }
> default:
> @@ -1304,7 +1301,7 @@ static DWORD MCI_HandleReturnValues(DWORD dwRet, LPWINE_MCIDRIVER wmd, DWORD ret
> DWORD *data = (DWORD *)(params + 1);
> if (dwRet & 0xFFFF0000ul)
> WARN("Oooch. MCI_STRING and HIWORD(dwRet)=%04x\n", HIWORD(dwRet));
> - snprintfW(lpstrRet, uRetLen, fmt_d4, data[0], data[1], data[2], data[3]);
> + swprintf(lpstrRet, uRetLen, fmt_d4, data[0], data[1], data[2], data[3]);
> break;
> }
> default: FIXME("Unknown MCI return type %d\n", retType);
> @@ -1347,14 +1344,14 @@ DWORD WINAPI mciSendStringW(LPCWSTR lpstrCommand, LPWSTR lpstrRet,
> return MCIERR_MISSING_COMMAND_STRING;
>
> /* format is <command> <device> <optargs> */
> - if (!(verb = HeapAlloc(GetProcessHeap(), 0, (strlenW(lpstrCommand)+1) * sizeof(WCHAR))))
> + if (!(verb = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(lpstrCommand)+1) * sizeof(WCHAR))))
> return MCIERR_OUT_OF_MEMORY;
> - strcpyW( verb, lpstrCommand );
> + lstrcpyW( verb, lpstrCommand );
> CharLowerW(verb);
>
> memset(&data, 0, sizeof(data));
>
> - if (!(args = strchrW(verb, ' '))) {
> + if (!(args = wcschr(verb, ' '))) {
> dwRet = MCIERR_MISSING_DEVICE_NAME;
> goto errCleanUp;
> }
> @@ -1362,19 +1359,19 @@ DWORD WINAPI mciSendStringW(LPCWSTR lpstrCommand, LPWSTR lpstrRet,
> if ((dwRet = MCI_GetString(&dev, &args))) {
> goto errCleanUp;
> }
> - uDevID = strcmpiW(dev, wszAll) ? 0 : MCI_ALL_DEVICE_ID;
> + uDevID = wcsicmp(dev, wszAll) ? 0 : MCI_ALL_DEVICE_ID;
>
> /* Determine devType from open */
> - if (!strcmpW(verb, wszOpen)) {
> + if (!wcscmp(verb, wszOpen)) {
> LPWSTR tmp;
> WCHAR buf[128];
>
> /* case dev == 'new' has to be handled */
> - if (!strcmpW(dev, wszNew)) {
> + if (!wcscmp(dev, wszNew)) {
> dev = 0;
> - if ((devType = strstrW(args, wszTypeS)) != NULL) {
> + if ((devType = wcsstr(args, wszTypeS)) != NULL) {
> devType += 5;
> - tmp = strchrW(devType, ' ');
> + tmp = wcschr(devType, ' ');
> if (tmp) *tmp = '\0';
> devType = str_dup_upper(devType);
> if (tmp) *tmp = ' ';
> @@ -1386,7 +1383,7 @@ DWORD WINAPI mciSendStringW(LPCWSTR lpstrCommand, LPWSTR lpstrRet,
> }
> dwFlags |= MCI_OPEN_ELEMENT;
> data.open.lpstrElementName = &wszNull[0];
> - } else if ((devType = strchrW(dev, '!')) != NULL) {
> + } else if ((devType = wcschr(dev, '!')) != NULL) {
> *devType++ = '\0';
> tmp = devType; devType = dev; dev = tmp;
>
> @@ -1397,16 +1394,16 @@ DWORD WINAPI mciSendStringW(LPCWSTR lpstrCommand, LPWSTR lpstrRet,
> data.open.lpstrElementName = dev;
> } else if (DRIVER_GetLibName(dev, wszMci, buf, sizeof(buf))) {
> /* this is the name of a mci driver's type */
> - tmp = strchrW(dev, ' ');
> + tmp = wcschr(dev, ' ');
> if (tmp) *tmp = '\0';
> data.open.lpstrDeviceType = dev;
> devType = str_dup_upper(dev);
> if (tmp) *tmp = ' ';
> dwFlags |= MCI_OPEN_TYPE;
> } else {
> - if ((devType = strstrW(args, wszTypeS)) != NULL) {
> + if ((devType = wcsstr(args, wszTypeS)) != NULL) {
> devType += 5;
> - tmp = strchrW(devType, ' ');
> + tmp = wcschr(devType, ' ');
> if (tmp) *tmp = '\0';
> devType = str_dup_upper(devType);
> if (tmp) *tmp = ' ';
> @@ -1424,7 +1421,7 @@ DWORD WINAPI mciSendStringW(LPCWSTR lpstrCommand, LPWSTR lpstrRet,
> dwRet = MCIERR_CANNOT_USE_ALL;
> goto errCleanUp;
> }
> - if (!strstrW(args, wszSAliasS) && !dev) {
> + if (!wcsstr(args, wszSAliasS) && !dev) {
> dwRet = MCIERR_NEW_REQUIRES_ALIAS;
> goto errCleanUp;
> }
> @@ -1450,11 +1447,11 @@ DWORD WINAPI mciSendStringW(LPCWSTR lpstrCommand, LPWSTR lpstrRet,
> {
> static const WCHAR wszOpenWait[] = {'o','p','e','n',' ','%','s',' ','w','a','i','t',0};
> WCHAR buf[138], retbuf[6];
> - snprintfW(buf, ARRAY_SIZE(buf), wszOpenWait, dev);
> + swprintf(buf, ARRAY_SIZE(buf), wszOpenWait, dev);
> /* open via mciSendString handles quoting, dev!file syntax and alias creation */
> if ((dwRet = mciSendStringW(buf, retbuf, ARRAY_SIZE(retbuf), 0)) != 0)
> goto errCleanUp;
> - auto_open = strtoulW(retbuf, NULL, 10);
> + auto_open = wcstoul(retbuf, NULL, 10);
> TRACE("auto-opened %u for %s\n", auto_open, debugstr_w(dev));
>
> /* FIXME: test for notify flag (how to preparse?) before opening */
> @@ -1541,7 +1538,7 @@ DWORD WINAPI mciSendStringW(LPCWSTR lpstrCommand, LPWSTR lpstrRet,
>
> switch (wMsg) {
> case MCI_OPEN:
> - if (strcmpW(verb, wszOpen)) {
> + if (wcscmp(verb, wszOpen)) {
> FIXME("Cannot open with command %s\n", debugstr_w(verb));
> dwRet = MCIERR_DRIVER_INTERNAL;
> wMsg = 0;
> @@ -1757,8 +1754,8 @@ static DWORD MCI_Open(DWORD dwParam, LPMCI_OPEN_PARMSW lpParms)
> dwRet = MCIERR_NULL_PARAMETER_BLOCK;
> goto errCleanUp;
> }
> - strcpyW(strDevTyp, lpParms->lpstrDeviceType);
> - ptr = strchrW(strDevTyp, '!');
> + lstrcpyW(strDevTyp, lpParms->lpstrDeviceType);
> + ptr = wcschr(strDevTyp, '!');
> if (ptr) {
> /* this behavior is not documented in windows. However, since, in
> * some occasions, MCI_OPEN handling is translated by WinMM into
> @@ -1805,7 +1802,7 @@ static DWORD MCI_Open(DWORD dwParam, LPMCI_OPEN_PARMSW lpParms)
> goto errCleanUp;
> }
> /* FIXME: this will not work if several CDROM drives are installed on the machine */
> - strcpyW(strDevTyp, wszCdAudio);
> + lstrcpyW(strDevTyp, wszCdAudio);
> }
> }
>
> @@ -1894,10 +1891,10 @@ static DWORD MCI_WriteString(LPWSTR lpDstStr, DWORD dstSize, LPCWSTR lpSrcStr)
> DWORD ret = 0;
>
> if (lpSrcStr) {
> - if (dstSize <= strlenW(lpSrcStr)) {
> + if (dstSize <= lstrlenW(lpSrcStr)) {
> ret = MCIERR_PARAM_OVERFLOW;
> } else {
> - strcpyW(lpDstStr, lpSrcStr);
> + lstrcpyW(lpDstStr, lpSrcStr);
> }
> } else {
> *lpDstStr = 0;
> @@ -1945,7 +1942,7 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSW lpParm
> RegCloseKey( hKey );
> }
> if (GetPrivateProfileStringW(wszMci, 0, wszNull, buf, ARRAY_SIZE(buf), wszSystemIni))
> - for (s = buf; *s; s += strlenW(s) + 1) cnt++;
> + for (s = buf; *s; s += lstrlenW(s) + 1) cnt++;
> }
> } else {
> if (dwFlags & MCI_SYSINFO_OPEN) {
> @@ -2023,7 +2020,7 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSW lpParm
> }
> if (!s) {
> if (GetPrivateProfileStringW(wszMci, 0, wszNull, buf, ARRAY_SIZE(buf), wszSystemIni)) {
> - for (p = buf; *p; p += strlenW(p) + 1, cnt++) {
> + for (p = buf; *p; p += lstrlenW(p) + 1, cnt++) {
> TRACE("%d: %s\n", cnt, debugstr_w(p));
> if (cnt == lpParms->dwNumber - 1) {
> s = p;
>
>
July 5, 2019