From 53d7f614d59a31fdaa8a31b1181e469de3e517af Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 18 Sep 2013 14:29:52 +0200 Subject: Unpublished optional bases of published interfaces complicate things Change-Id: I206b623fcc3c9e04fc5336cb3704315c44fb83b8 --- unoidl/source/unoidl-read.cxx | 49 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/unoidl/source/unoidl-read.cxx b/unoidl/source/unoidl-read.cxx index 2d3d00ffe3e0..2bbe8b672dba 100644 --- a/unoidl/source/unoidl-read.cxx +++ b/unoidl/source/unoidl-read.cxx @@ -43,7 +43,11 @@ void badUsage() { << std::endl << ("last is written to stdout; if --published is specified," " only the") - << std::endl << "published entities are written out." << std::endl; + << std::endl + << ("published entities (plus any non-published entities referenced" + " from published") + << std::endl + << "via any unpublished optional bases) are written out." << std::endl; std::exit(EXIT_FAILURE); } @@ -133,13 +137,15 @@ OUString decomposeType( } struct Entity { - explicit Entity(rtl::Reference const & theEntity): - entity(theEntity), sorted(false), written(false) + explicit Entity( + rtl::Reference const & theEntity, bool theRelevant): + entity(theEntity), relevant(theRelevant), sorted(false), written(false) {} rtl::Reference const entity; std::set dependencies; std::set interfaceDependencies; + bool relevant; bool sorted; bool written; }; @@ -229,12 +235,18 @@ void scanMap( manager, static_cast(ent.get())->createCursor(), published, name + ".", entities); - } else if (!published - || (static_cast(ent.get()) - ->isPublished())) - { + } else { std::map::iterator i( - entities.insert(std::make_pair(name, Entity(ent))).first); + entities.insert( + std::make_pair( + name, + Entity( + ent, + (!published + || (static_cast( + ent.get()) + ->isPublished()))))) + .first); switch (ent->getSort()) { case unoidl::Entity::SORT_MODULE: assert(false); // this cannot happen @@ -390,6 +402,22 @@ void scanMap( } } +void propagateRelevant(std::map & entities, Entity & entity) { + if (!entity.relevant) { + entity.relevant = true; + if (entity.sorted) { + for (std::set::iterator i(entity.dependencies.begin()); + i != entity.dependencies.end(); ++i) + { + std::map::iterator j(entities.find(*i)); + if (j != entities.end()) { + propagateRelevant(entities, j->second); + } + } + } + } +} + void visit( std::map & entities, std::map::iterator const & iterator, @@ -405,6 +433,9 @@ void visit( { std::map::iterator j(entities.find(*i)); if (j != entities.end()) { + if (iterator->second.relevant) { + propagateRelevant(entities, j->second); + } visit(entities, j, result); } } @@ -555,7 +586,7 @@ void writeEntity( OUString const & name) { std::map::iterator i(entities.find(name)); - if (i != entities.end()) { + if (i != entities.end() && i->second.relevant) { assert(!i->second.written); i->second.written = true; for (std::set::iterator j( -- cgit