]> git.lyx.org Git - features.git/commitdiff
Some comments, and some conditional code to dump the macro table.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Mon, 9 Nov 2020 22:27:57 +0000 (17:27 -0500)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Mon, 9 Nov 2020 22:27:57 +0000 (17:27 -0500)
src/Buffer.cpp

index 91602dad6f61d003d40a77c1cbab914e4d6605e5..b6b742baf943e2f023d03dca4f6756307c46071d 100644 (file)
@@ -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<DocIterator, ScopeMacro> PositionScopeMacroMap;
-       typedef map<docstring, PositionScopeMacroMap> NamePositionScopeMacroMap;
+       typedef map<docstring, PositionScopeMacroMap> 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<Buffer const * const, DocIterator> 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();