Jacek Caban : widl: Check function return values for additional prototype types.
Alexandre Julliard
julliard at winehq.org
Tue Jan 29 15:18:16 CST 2019
Module: wine
Branch: master
Commit: 759a3bf34d004a841f8fd49915fac339c1a1efb8
URL: https://source.winehq.org/git/wine.git/?a=commit;h=759a3bf34d004a841f8fd49915fac339c1a1efb8
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Jan 29 15:46:30 2019 +0100
widl: Check function return values for additional prototype types.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
tools/widl/header.c | 135 ++++++++++++++++++++++++-------------------------
tools/widl/parser.y | 6 ++-
tools/widl/widltypes.h | 2 +-
3 files changed, 71 insertions(+), 72 deletions(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c
index ef141d9..f618e02 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -637,82 +637,77 @@ unsigned int get_generic_handle_offset( const type_t *type )
/* check for types which require additional prototypes to be generated in the
* header */
-void check_for_additional_prototype_types(const var_list_t *list)
-{
- const var_t *v;
-
- if (!list) return;
- LIST_FOR_EACH_ENTRY( v, list, const var_t, entry )
- {
- type_t *type = v->type;
- if (!type) continue;
- for (;;) {
- const char *name = type->name;
- if (type->user_types_registered) break;
- type->user_types_registered = 1;
- if (is_attr(type->attrs, ATTR_CONTEXTHANDLE)) {
- if (!context_handle_registered(name))
- {
- context_handle_t *ch = xmalloc(sizeof(*ch));
- ch->name = xstrdup(name);
- list_add_tail(&context_handle_list, &ch->entry);
- }
- /* don't carry on parsing fields within this type */
- break;
- }
- if ((type_get_type(type) != TYPE_BASIC ||
- type_basic_get_type(type) != TYPE_BASIC_HANDLE) &&
- is_attr(type->attrs, ATTR_HANDLE)) {
- if (!generic_handle_registered(name))
- {
- generic_handle_t *gh = xmalloc(sizeof(*gh));
- gh->name = xstrdup(name);
- list_add_tail(&generic_handle_list, &gh->entry);
- }
- /* don't carry on parsing fields within this type */
- break;
+void check_for_additional_prototype_types(type_t *type)
+{
+ if (!type) return;
+ for (;;) {
+ const char *name = type->name;
+ if (type->user_types_registered) break;
+ type->user_types_registered = 1;
+ if (is_attr(type->attrs, ATTR_CONTEXTHANDLE)) {
+ if (!context_handle_registered(name))
+ {
+ context_handle_t *ch = xmalloc(sizeof(*ch));
+ ch->name = xstrdup(name);
+ list_add_tail(&context_handle_list, &ch->entry);
}
- if (is_attr(type->attrs, ATTR_WIREMARSHAL)) {
- if (!user_type_registered(name))
- {
- user_type_t *ut = xmalloc(sizeof *ut);
- ut->name = xstrdup(name);
- list_add_tail(&user_type_list, &ut->entry);
- }
- /* don't carry on parsing fields within this type as we are already
- * using a wire marshaled type */
- break;
+ /* don't carry on parsing fields within this type */
+ break;
+ }
+ if ((type_get_type(type) != TYPE_BASIC ||
+ type_basic_get_type(type) != TYPE_BASIC_HANDLE) &&
+ is_attr(type->attrs, ATTR_HANDLE)) {
+ if (!generic_handle_registered(name))
+ {
+ generic_handle_t *gh = xmalloc(sizeof(*gh));
+ gh->name = xstrdup(name);
+ list_add_tail(&generic_handle_list, &gh->entry);
}
- else if (type_is_complete(type))
+ /* don't carry on parsing fields within this type */
+ break;
+ }
+ if (is_attr(type->attrs, ATTR_WIREMARSHAL)) {
+ if (!user_type_registered(name))
{
- var_list_t *vars;
- switch (type_get_type_detect_alias(type))
- {
- case TYPE_ENUM:
- vars = type_enum_get_values(type);
- break;
- case TYPE_STRUCT:
- vars = type_struct_get_fields(type);
- break;
- case TYPE_UNION:
- vars = type_union_get_cases(type);
- break;
- default:
- vars = NULL;
- break;
- }
- check_for_additional_prototype_types(vars);
+ user_type_t *ut = xmalloc(sizeof *ut);
+ ut->name = xstrdup(name);
+ list_add_tail(&user_type_list, &ut->entry);
}
-
- if (type_is_alias(type))
- type = type_alias_get_aliasee(type);
- else if (is_ptr(type))
- type = type_pointer_get_ref(type);
- else if (is_array(type))
- type = type_array_get_element(type);
- else
+ /* don't carry on parsing fields within this type as we are already
+ * using a wire marshaled type */
+ break;
+ }
+ else if (type_is_complete(type))
+ {
+ var_list_t *vars;
+ const var_t *v;
+ switch (type_get_type_detect_alias(type))
+ {
+ case TYPE_ENUM:
+ vars = type_enum_get_values(type);
+ break;
+ case TYPE_STRUCT:
+ vars = type_struct_get_fields(type);
+ break;
+ case TYPE_UNION:
+ vars = type_union_get_cases(type);
+ break;
+ default:
+ vars = NULL;
break;
+ }
+ if (vars) LIST_FOR_EACH_ENTRY( v, vars, const var_t, entry )
+ check_for_additional_prototype_types(v->type);
}
+
+ if (type_is_alias(type))
+ type = type_alias_get_aliasee(type);
+ else if (is_ptr(type))
+ type = type_pointer_get_ref(type);
+ else if (is_array(type))
+ type = type_array_get_element(type);
+ else
+ break;
}
}
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index d979394..5156dce 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -2911,6 +2911,7 @@ static void check_statements(const statement_list_t *stmts, int is_inside_librar
static void check_all_user_types(const statement_list_t *stmts)
{
const statement_t *stmt;
+ const var_t *v;
if (stmts) LIST_FOR_EACH_ENTRY(stmt, stmts, const statement_t, entry)
{
@@ -2922,7 +2923,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;
- check_for_additional_prototype_types(func->type->details.function->args);
+ 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));
}
}
}
diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h
index 37792b2..afca4c0 100644
--- a/tools/widl/widltypes.h
+++ b/tools/widl/widltypes.h
@@ -556,7 +556,7 @@ typedef enum {
extern user_type_list_t user_type_list;
extern context_handle_list_t context_handle_list;
extern generic_handle_list_t generic_handle_list;
-void check_for_additional_prototype_types(const var_list_t *list);
+void check_for_additional_prototype_types(type_t *type);
void init_types(void);
type_t *alloc_type(void);
More information about the wine-cvs
mailing list