[LyX features/cleanup/updateMacros4] Comment

Richard Kimberly Heck rikiheck at lyx.org
Tue Nov 17 06:07:47 UTC 2020


The branch, cleanup/updateMacros4, has been updated.

- Log -----------------------------------------------------------------

commit 007b6f711dcdd24dc768954efa893958a41cebb7
Author: Richard Kimberly Heck <rikiheck at lyx.org>
Date:   Tue Nov 17 01:37:09 2020 -0500

    Comment

diff --git a/src/Buffer.h b/src/Buffer.h
index 267bf94..e7fd883 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -604,6 +604,8 @@ public:
 	/// Collect macro definitions in paragraphs
 	void updateMacros() const;
 	/// Iterate through the whole buffer and try to resolve macros
+	/// At the moment, this is only called when we are preparing for some
+	/// kind of output (including to the clipboard).
 	void updateMacroInstances(UpdateType) const;
 
 	/// List macro names of this buffer, the parent and the children

commit 3858c5692ea6318979db2373c982363a5363e827
Author: Richard Kimberly Heck <rikiheck at lyx.org>
Date:   Tue Nov 17 01:21:57 2020 -0500

    Renaming

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 97b837f..b5d9e4f 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -3872,7 +3872,7 @@ void Buffer::updateMacroInstances(UpdateType utype) const
 		MacroContext mc = MacroContext(this, it);
 		for (DocIterator::idx_type i = 0; i < n; ++i) {
 			MathData & data = minset->cell(i);
-			data.updateMacros(nullptr, mc, utype, 0);
+			data.updateMacroInstances(nullptr, mc, utype, 0);
 		}
 	}
 }
diff --git a/src/mathed/InsetMathMacro.cpp b/src/mathed/InsetMathMacro.cpp
index c051c8e..ab9af5f 100644
--- a/src/mathed/InsetMathMacro.cpp
+++ b/src/mathed/InsetMathMacro.cpp
@@ -726,7 +726,7 @@ void InsetMathMacro::updateRepresentation(Cursor * cur, MacroContext const & mc,
 	d->expanded_.setBuffer(buffer());
 	if (ret && !support::contains(display, latexname)) {
 		if (utype == OutputUpdate && !d->expanded_.empty())
-			d->expanded_.updateMacros(cur, mc, utype, nesting);
+			d->expanded_.updateMacroInstances(cur, mc, utype, nesting);
 	}
 	// get definition for list edit mode
 	asArray(display.empty() ? d->macro_->definition() : display,
diff --git a/src/mathed/MathData.cpp b/src/mathed/MathData.cpp
index 2b74cac..bccd28a 100644
--- a/src/mathed/MathData.cpp
+++ b/src/mathed/MathData.cpp
@@ -225,7 +225,7 @@ bool MathData::addToMathRow(MathRow & mrow, MetricsInfo & mi) const
 	bool has_contents = false;
 	BufferView * bv = mi.base.bv;
 	MathData * ar = const_cast<MathData*>(this);
-	ar->updateMacros(&bv->cursor(), mi.macrocontext,
+	ar->updateMacroInstances(&bv->cursor(), mi.macrocontext,
 	                 InternalUpdate, mi.base.macro_nesting);
 
 
@@ -398,7 +398,7 @@ void MathData::updateBuffer(ParIterator const & it, UpdateType utype, bool const
 }
 
 
-void MathData::updateMacros(Cursor * cur, MacroContext const & mc,
+void MathData::updateMacroInstances(Cursor * cur, MacroContext const & mc,
 		UpdateType utype, int nesting)
 {
 	// If we are editing a macro, we cannot update it immediately,
diff --git a/src/mathed/MathData.h b/src/mathed/MathData.h
index 3474980..199039d 100644
--- a/src/mathed/MathData.h
+++ b/src/mathed/MathData.h
@@ -178,7 +178,7 @@ public:
 
 	/// attach/detach arguments to macros, updating the cur to
 	/// stay visually at the same position (cur==0 is allowed)
-	void updateMacros(Cursor * cur, MacroContext const & mc, UpdateType, int nesting);
+	void updateMacroInstances(Cursor * cur, MacroContext const & mc, UpdateType, int nesting);
 	///
 	void updateBuffer(ParIterator const &, UpdateType, bool const deleted = false);
 	///

commit fffaf64ee3a512867550da7aba302f784ad393e3
Author: Richard Kimberly Heck <rikiheck at lyx.org>
Date:   Tue Nov 17 01:15:45 2020 -0500

    nullptr

diff --git a/src/mathed/MathData.cpp b/src/mathed/MathData.cpp
index 39d5f80..2b74cac 100644
--- a/src/mathed/MathData.cpp
+++ b/src/mathed/MathData.cpp
@@ -403,8 +403,8 @@ void MathData::updateMacros(Cursor * cur, MacroContext const & mc,
 {
 	// If we are editing a macro, we cannot update it immediately,
 	// otherwise wrong undo steps will be recorded (bug 6208).
-	InsetMath const * inmath = cur ? cur->inset().asInsetMath() : 0;
-	InsetMathMacro const * inmacro = inmath ? inmath->asMacro() : 0;
+	InsetMath const * inmath = cur ? cur->inset().asInsetMath() : nullptr;
+	InsetMathMacro const * inmacro = inmath ? inmath->asMacro() : nullptr;
 	docstring const edited_name = inmacro ? inmacro->name() : docstring();
 
 	// go over the array and look for macros
@@ -533,7 +533,7 @@ void MathData::detachMacroParameters(DocIterator * cur, const size_type macroPos
 	size_t j = 0;
 	// We do not want to use macroInset below, the insert() call in
 	// the loop will invalidate it.
-	macroInset = 0;
+	macroInset = nullptr;
 	for (; j < detachedArgs.size() && j < optionals; ++j) {
 		// another non-empty parameter follows?
 		bool canDropEmptyOptional = j >= lastNonEmptyOptional;
@@ -551,7 +551,7 @@ void MathData::detachMacroParameters(DocIterator * cur, const size_type macroPos
 		MathData & arg = detachedArgs[j];
 
 		// look for "]", i.e. put a brace around?
-		InsetMathBrace * brace = 0;
+		InsetMathBrace * brace = nullptr;
 		for (size_t q = 0; q < arg.size(); ++q) {
 			if (arg[q]->getChar() == ']') {
 				// put brace
@@ -708,7 +708,7 @@ void MathData::collectOptionalParameters(Cursor * cur,
 	size_t & pos, MathAtom & scriptToPutAround,
 	const pos_type macroPos, const int thisPos, const int thisSlice)
 {
-	Buffer * buf = cur ? cur->buffer() : 0;
+	Buffer * buf = cur ? cur->buffer() : nullptr;
 	// insert optional arguments?
 	while (params.size() < numOptionalParams
 	       && pos < size()

commit 05f950bc39fcb80ffd5396b8a02a83dfec450a24
Author: Richard Kimberly Heck <rikiheck at lyx.org>
Date:   Tue Nov 17 01:08:35 2020 -0500

    Move dump code to after we are done

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 30f04d8..97b837f 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -3792,6 +3792,21 @@ void Buffer::updateMacros() const
 {
 	if (d->macro_lock)
 		return;
+	
+	// start with empty table
+	d->macro_table.clear();
+	d->children_positions.clear();
+	d->position_to_children.clear();
+
+	// Iterate over buffer, starting with first paragraph
+	// The scope must be bigger than any lookup DocIterator
+	// later. For the global lookup, lastpit+1 is used, hence
+	// we use lastpit+2 here.
+	DocIterator it = par_iterator_begin();
+	DocIterator outerScope = it;
+	outerScope.pit() = outerScope.lastpit() + 2;
+	inset().updateMacros(it, outerScope);
+
 #if 0
 	LYXERR0("Starting macro dump");
 	for (auto const & m : d->macros) {
@@ -3807,20 +3822,6 @@ void Buffer::updateMacros() const
 	LYXERR0("");
 	LYXERR(Debug::MACROS, "updateMacro of " << d->filename.onlyFileName());
 #endif
-	
-	// start with empty table
-	d->macro_table.clear();
-	d->children_positions.clear();
-	d->position_to_children.clear();
-
-	// Iterate over buffer, starting with first paragraph
-	// The scope must be bigger than any lookup DocIterator
-	// later. For the global lookup, lastpit+1 is used, hence
-	// we use lastpit+2 here.
-	DocIterator it = par_iterator_begin();
-	DocIterator outerScope = it;
-	outerScope.pit() = outerScope.lastpit() + 2;
-	inset().updateMacros(it, outerScope);
 }
 
 

-----------------------------------------------------------------------

Summary of changes:
 src/Buffer.cpp                |   31 ++++++++++++++++---------------
 src/Buffer.h                  |    2 ++
 src/mathed/InsetMathMacro.cpp |    2 +-
 src/mathed/MathData.cpp       |   14 +++++++-------
 src/mathed/MathData.h         |    2 +-
 5 files changed, 27 insertions(+), 24 deletions(-)


hooks/post-receive
-- 
Repository for new features


More information about the lyx-cvs mailing list