From: Richard Kimberly Heck Date: Mon, 9 Nov 2020 22:27:57 +0000 (-0500) Subject: Some comments, and some conditional code to dump the macro table. X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=30415c80f7934580ce2e1fdf0b5f84b5faeba9da;p=features.git Some comments, and some conditional code to dump the macro table. --- diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 91602dad6f..b6b742baf9 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -204,17 +204,21 @@ public: ScopeMacro() {} ScopeMacro(DocIterator const & s, MacroData const & m) : scope(s), macro(m) {} + // The SCOPE is really just the last position at which the macro + // is in force. This will be the end of the file (if there are no + // children) unless it is in (say) a note, or an inactive branch, + // in which case it will be the end of that construct. DocIterator scope; MacroData macro; }; typedef map PositionScopeMacroMap; - typedef map NamePositionScopeMacroMap; + typedef map MacroMap; /// map from the macro name to the position map, /// which maps the macro definition position to the scope and the MacroData. - NamePositionScopeMacroMap macros; + MacroMap macros; /// Each child Buffer is listed in this map, together with where - /// it is included in this Buffer. + /// it is first included in this Buffer. typedef map BufferPositionMap; BufferPositionMap children_positions; /// We also have a map from the positions where Buffers are included @@ -3599,9 +3603,9 @@ MacroData const * Buffer::Impl::getBufferMacro(docstring const & name, MacroData const * bestData = nullptr; // find macro definitions for name - NamePositionScopeMacroMap::const_iterator nameIt = macros.find(name); + MacroMap::const_iterator nameIt = macros.find(name); if (nameIt != macros.end()) { - // find last definition in front of pos or at pos itself + // find last definition in front of pos PositionScopeMacroMap::const_iterator it = greatest_below(nameIt->second, pos); if (it != nameIt->second.end()) { @@ -3825,9 +3829,22 @@ void Buffer::updateMacros() const { if (d->macro_lock) return; - +#if 0 + LYXERR0("Starting macro dump"); + for (auto const & m : d->macros) { + LYXERR0(m.first); + for (auto const & m1 : m.second) { + LYXERR0(m1.first); + LYXERR0("Scope: " << m1.second.scope); + LYXERR0("Def: " << m1.second.macro.definition()); + LYXERR0(""); + } + } + LYXERR0("Ending macro dump"); + LYXERR0(""); LYXERR(Debug::MACROS, "updateMacro of " << d->filename.onlyFileName()); - +#endif + // start with empty table d->macros.clear(); d->children_positions.clear();