From 83b1f081176425537fe38c7ad116670b6bc596a4 Mon Sep 17 00:00:00 2001 From: Rob Shearman Date: Mon, 5 Jan 2009 23:34:38 +0000 Subject: [PATCH] widl: Add function for getting the interfaces defined by a coclass type. Split out the defining of coclass types in the parser into a function. --- tools/widl/parser.y | 5 +---- tools/widl/typetree.c | 7 +++++++ tools/widl/typetree.h | 7 +++++++ tools/widl/write_msft.c | 6 ++++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 2820f45e1fc..b8e1d4da50f 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -830,10 +830,7 @@ coclasshdr: attributes coclass { $$ = $2; ; coclassdef: coclasshdr '{' coclass_ints '}' semicolon_opt - { $$ = $1; - $$->ifaces = $3; - $$->defined = TRUE; - } + { $$ = type_coclass_define($1, $3); } ; coclass_ints: { $$ = NULL; } diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c index 54859be4617..8a42d565480 100644 --- a/tools/widl/typetree.c +++ b/tools/widl/typetree.c @@ -137,3 +137,10 @@ void type_module_define(type_t *module, statement_list_t *stmts) module->details.module->stmts = stmts; module->defined = TRUE; } + +type_t *type_coclass_define(type_t *coclass, ifref_list_t *ifaces) +{ + coclass->ifaces = ifaces; + coclass->defined = TRUE; + return coclass; +} diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h index 0fcfb3af00f..af4d5e637e9 100644 --- a/tools/widl/typetree.h +++ b/tools/widl/typetree.h @@ -32,6 +32,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, func_list_t *methods); void type_dispinterface_define_from_iface(type_t *dispiface, type_t *iface); void type_module_define(type_t *module, statement_list_t *stmts); +type_t *type_coclass_define(type_t *coclass, ifref_list_t *ifaces); /* FIXME: shouldn't need to export this */ type_t *duptype(type_t *t, int dupname); @@ -153,4 +154,10 @@ static inline int type_is_alias(const type_t *type) return type->is_alias; } +static inline ifref_list_t *type_coclass_get_ifaces(const type_t *type) +{ + assert(type->type == RPC_FC_COCLASS); + return type->ifaces; +} + #endif /* WIDL_TYPE_TREE_H */ diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c index d7bbd603cd9..bf95b1365c1 100644 --- a/tools/widl/write_msft.c +++ b/tools/widl/write_msft.c @@ -2099,6 +2099,7 @@ static void add_coclass_typeinfo(msft_typelib_t *typelib, type_t *cls) MSFT_RefRecord *ref, *first = NULL, *first_source = NULL; int have_default = 0, have_default_source = 0; const attr_t *attr; + ifref_list_t *ifaces; if (-1 < cls->typelib_idx) return; @@ -2106,13 +2107,14 @@ static void add_coclass_typeinfo(msft_typelib_t *typelib, type_t *cls) cls->typelib_idx = typelib->typelib_header.nrtypeinfos; msft_typeinfo = create_msft_typeinfo(typelib, TKIND_COCLASS, cls->name, cls->attrs); - if (cls->ifaces) LIST_FOR_EACH_ENTRY( iref, cls->ifaces, ifref_t, entry ) num_ifaces++; + ifaces = type_coclass_get_ifaces(cls); + if (ifaces) LIST_FOR_EACH_ENTRY( iref, ifaces, ifref_t, entry ) num_ifaces++; offset = msft_typeinfo->typeinfo->datatype1 = ctl2_alloc_segment(typelib, MSFT_SEG_REFERENCES, num_ifaces * sizeof(*ref), 0); i = 0; - if (cls->ifaces) LIST_FOR_EACH_ENTRY( iref, cls->ifaces, ifref_t, entry ) { + if (ifaces) LIST_FOR_EACH_ENTRY( iref, ifaces, ifref_t, entry ) { if(iref->iface->typelib_idx == -1) add_interface_typeinfo(typelib, iref->iface); ref = (MSFT_RefRecord*) (typelib->typelib_segment_data[MSFT_SEG_REFERENCES] + offset + i * sizeof(*ref)); -- 2.11.4.GIT