From f61aac6b1bd7f9e8c349baaa06351c0fc630fc51 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 12 Nov 2020 10:22:22 +0100 Subject: [PATCH] Doc: resolve references to child classes too. --- src/db/db/gsiDeclDbCommonStreamOptions.cc | 4 +- src/lay/lay/layGSIHelpProvider.cc | 58 +++++++++++++++++++++-- testdata/ruby/dbReaders.rb | 8 ++++ 3 files changed, 65 insertions(+), 5 deletions(-) diff --git a/src/db/db/gsiDeclDbCommonStreamOptions.cc b/src/db/db/gsiDeclDbCommonStreamOptions.cc index 669dbd7e0..32b8ede8c 100644 --- a/src/db/db/gsiDeclDbCommonStreamOptions.cc +++ b/src/db/db/gsiDeclDbCommonStreamOptions.cc @@ -172,8 +172,8 @@ gsi::ClassExt common_reader_options ( "@brief Gets the cell conflict resolution mode\n" "\n" "Multiple layout files can be collected into a single Layout object by reading file after file into the Layout object. " - "Cells with same names are considered a conflict. This mode indicates how such conflicts are resolved. See \\CellConflictResolution " - "for the values allowed. The default mode is \\CellConflictResolution#AddToCell.\n" + "Cells with same names are considered a conflict. This mode indicates how such conflicts are resolved. See \\LoadLayoutOptions::CellConflictResolution " + "for the values allowed. The default mode is \\LoadLayoutOptions::CellConflictResolution#AddToCell.\n" "\n" "This option has been introduced in version 0.27." ) + diff --git a/src/lay/lay/layGSIHelpProvider.cc b/src/lay/lay/layGSIHelpProvider.cc index 171b3fc6a..01c678f12 100644 --- a/src/lay/lay/layGSIHelpProvider.cc +++ b/src/lay/lay/layGSIHelpProvider.cc @@ -318,6 +318,55 @@ real_class (const gsi::ClassBase *cls) return cls->declaration () ? cls->declaration () : cls; } +namespace { + +class RecursiveClassIterator +{ +public: + typedef const gsi::ClassBase &reference; + typedef const gsi::ClassBase *pointer; + + RecursiveClassIterator () + { + if (gsi::ClassBase::begin_classes () != gsi::ClassBase::end_classes ()) { + m_cls_iter_stack.push_back (std::make_pair (gsi::ClassBase::begin_classes (), gsi::ClassBase::end_classes ())); + } + } + + bool at_end () const + { + return m_cls_iter_stack.empty (); + } + + RecursiveClassIterator &operator++ () + { + if (operator* ().begin_child_classes () != operator* ().end_child_classes ()) { + m_cls_iter_stack.push_back (std::make_pair (operator* ().begin_child_classes (), operator* ().end_child_classes ())); + } else { + while (! m_cls_iter_stack.empty () && ++m_cls_iter_stack.back ().first == m_cls_iter_stack.back ().second) { + m_cls_iter_stack.pop_back (); + } + } + + return *this; + } + + const gsi::ClassBase &operator* () const + { + return *m_cls_iter_stack.back ().first; + } + + const gsi::ClassBase *operator-> () const + { + return m_cls_iter_stack.back ().first.operator-> (); + } + +private: + std::list > m_cls_iter_stack; +}; + +} + static std::string replace_references (const std::string &t, const gsi::ClassBase *cls_base) { @@ -341,7 +390,7 @@ replace_references (const std::string &t, const gsi::ClassBase *cls_base) r += std::string (t, q, p - q); size_t pp = ++p; - while (p < t.size () && (t[p] == '_' || isalnum (t [p]))) { + while (p < t.size () && (t[p] == '_' || t[p] == ':' || isalnum (t [p]))) { ++p; } if (p < t.size () && (t[p] == '?' || t [p] == '=')) { @@ -369,8 +418,11 @@ replace_references (const std::string &t, const gsi::ClassBase *cls_base) found = true; } - for (gsi::ClassBase::class_iterator c = gsi::ClassBase::begin_classes (); c != gsi::ClassBase::end_classes () && !found; ++c) { - if (c->name () == id) { + for (RecursiveClassIterator c; ! c.at_end (); ++c) { +if (id.find ("CellConflict") != std::string::npos) { +printf("@@@ %s <-> %s\n", c->qname().c_str(), id.c_str()); fflush(stdout); +} + if (c->qname () == id) { r += "