Remove 'slave' terminology from Counters.cpp.

And with it, 'master'. That is less problematic by itself (so I'm not
worried about 'master document'), but here it doesn't make a lot of
sense without 'slave'.
This commit is contained in:
Richard Kimberly Heck 2020-11-02 17:03:42 -05:00
parent 8a25741ccd
commit 39f997048e
3 changed files with 42 additions and 42 deletions

View File

@ -5155,7 +5155,7 @@ void Buffer::Impl::setLabel(ParIterator & it, UpdateType utype) const
if (needEnumCounterReset(it)) { if (needEnumCounterReset(it)) {
// Increase the master counter? // Increase the master counter?
if (layout.stepmastercounter) if (layout.stepmastercounter)
counters.stepMaster(enumcounter, utype); counters.stepParent(enumcounter, utype);
// Maybe we have to reset the enumeration counter. // Maybe we have to reset the enumeration counter.
if (!layout.resumecounter) if (!layout.resumecounter)
counters.reset(enumcounter); counters.reset(enumcounter);

View File

@ -43,7 +43,7 @@ Counter::Counter()
Counter::Counter(docstring const & mc, docstring const & ls, Counter::Counter(docstring const & mc, docstring const & ls,
docstring const & lsa, docstring const & guiname) docstring const & lsa, docstring const & guiname)
: initial_value_(0), saved_value_(0), master_(mc), labelstring_(ls), : initial_value_(0), saved_value_(0), parent_(mc), labelstring_(ls),
labelstringappendix_(lsa), guiname_(guiname) labelstringappendix_(lsa), guiname_(guiname)
{ {
reset(); reset();
@ -87,9 +87,9 @@ bool Counter::read(Lexer & lex)
switch (le) { switch (le) {
case CT_WITHIN: case CT_WITHIN:
lex.next(); lex.next();
master_ = lex.getDocString(); parent_ = lex.getDocString();
if (master_ == "none") if (parent_ == "none")
master_.erase(); parent_.erase();
break; break;
case CT_INITIALVALUE: case CT_INITIALVALUE:
lex.next(); lex.next();
@ -176,17 +176,17 @@ void Counter::reset()
} }
docstring const & Counter::master() const docstring const & Counter::parent() const
{ {
return master_; return parent_;
} }
bool Counter::checkAndRemoveMaster(docstring const & cnt) bool Counter::checkAndRemoveParent(docstring const & cnt)
{ {
if (master_ != cnt) if (parent_ != cnt)
return false; return false;
master_ = docstring(); parent_ = docstring();
return true; return true;
} }
@ -211,18 +211,18 @@ Counters::Counters() : appendix_(false), subfloat_(false), longtable_(false)
void Counters::newCounter(docstring const & newc, void Counters::newCounter(docstring const & newc,
docstring const & masterc, docstring const & parentc,
docstring const & ls, docstring const & ls,
docstring const & lsa, docstring const & lsa,
docstring const & guiname) docstring const & guiname)
{ {
if (!masterc.empty() && !hasCounter(masterc)) { if (!parentc.empty() && !hasCounter(parentc)) {
lyxerr << "Master counter does not exist: " lyxerr << "Parent counter does not exist: "
<< to_utf8(masterc) << to_utf8(parentc)
<< endl; << endl;
return; return;
} }
counterList_[newc] = Counter(masterc, ls, lsa, guiname); counterList_[newc] = Counter(parentc, ls, lsa, guiname);
} }
@ -315,18 +315,18 @@ void Counters::restoreValue(docstring const & ctr) const
} }
void Counters::resetSlaves(docstring const & count) void Counters::resetChildren(docstring const & count)
{ {
for (auto & ctr : counterList_) { for (auto & ctr : counterList_) {
if (ctr.second.master() == count) { if (ctr.second.parent() == count) {
ctr.second.reset(); ctr.second.reset();
resetSlaves(ctr.first); resetChildren(ctr.first);
} }
} }
} }
void Counters::stepMaster(docstring const & ctr, UpdateType utype) void Counters::stepParent(docstring const & ctr, UpdateType utype)
{ {
CounterList::iterator it = counterList_.find(ctr); CounterList::iterator it = counterList_.find(ctr);
if (it == counterList_.end()) { if (it == counterList_.end()) {
@ -334,7 +334,7 @@ void Counters::stepMaster(docstring const & ctr, UpdateType utype)
<< to_utf8(ctr) << endl; << to_utf8(ctr) << endl;
return; return;
} }
step(it->second.master(), utype); step(it->second.parent(), utype);
} }
@ -354,7 +354,7 @@ void Counters::step(docstring const & ctr, UpdateType utype)
counter_stack_.push_back(ctr); counter_stack_.push_back(ctr);
} }
resetSlaves(ctr); resetChildren(ctr);
} }
@ -405,8 +405,8 @@ bool Counters::remove(docstring const & cnt)
if (!retval) if (!retval)
return false; return false;
for (auto & ctr : counterList_) { for (auto & ctr : counterList_) {
if (ctr.second.checkAndRemoveMaster(cnt)) if (ctr.second.checkAndRemoveParent(cnt))
LYXERR(Debug::TCLASS, "Removed master counter `" + LYXERR(Debug::TCLASS, "Removed parent counter `" +
to_utf8(cnt) + "' from counter: " + to_utf8(ctr.first)); to_utf8(cnt) + "' from counter: " + to_utf8(ctr.first));
} }
return retval; return retval;
@ -500,8 +500,8 @@ docstring Counters::flattenLabelString(docstring const & counter,
callers.push_back(counter); callers.push_back(counter);
if (ls.empty()) { if (ls.empty()) {
if (!c.master().empty()) if (!c.parent().empty())
ls = flattenLabelString(c.master(), in_appendix, lang, callers) ls = flattenLabelString(c.parent(), in_appendix, lang, callers)
+ from_ascii("."); + from_ascii(".");
callers.pop_back(); callers.pop_back();
return ls + from_ascii("\\arabic{") + counter + "}"; return ls + from_ascii("\\arabic{") + counter + "}";

View File

@ -52,12 +52,12 @@ public:
void step(); void step();
/// ///
void reset(); void reset();
/// Returns the master counter of this counter. /// Returns the parent counter of this counter.
docstring const & master() const; docstring const & parent() const;
/// Checks if the master counter is cnt, and if so removes /// Checks if the parent counter is cnt, and if so removes
/// it. This is used when a counter is deleted. /// it. This is used when a counter is deleted.
/// \return whether we removed the master. /// \return whether we removed the parent.
bool checkAndRemoveMaster(docstring const & cnt); bool checkAndRemoveParent(docstring const & cnt);
/// Returns a LaTeX-like string to format the counter. /// Returns a LaTeX-like string to format the counter.
/** This is similar to what one gets in LaTeX when using /** This is similar to what one gets in LaTeX when using
* "\the<counter>". The \c in_appendix bool tells whether we * "\the<counter>". The \c in_appendix bool tells whether we
@ -87,12 +87,12 @@ private:
int initial_value_; int initial_value_;
/// ///
int saved_value_; int saved_value_;
/// contains master counter name. /// contains parent counter name.
/** The master counter is the counter that, if stepped /** The parent counter is the counter that, if stepped
* (incremented) zeroes this counter. E.g. "subsection"'s * (incremented) zeroes this counter. E.g. "subsection"'s
* master is "section". * parent is "section".
*/ */
docstring master_; docstring parent_;
/// Contains a LaTeX-like string to format the counter. /// Contains a LaTeX-like string to format the counter.
docstring labelstring_; docstring labelstring_;
/// The same as labelstring_, but in appendices. /// The same as labelstring_, but in appendices.
@ -119,10 +119,10 @@ public:
/// from the document class (e.g., which ones are defined). /// from the document class (e.g., which ones are defined).
/// Instead, call Counters::reset(). /// Instead, call Counters::reset().
Counters(); Counters();
/// Add new counter newc having masterc as its master, /// Add new counter newc having parentc its parent,
/// ls as its label, and lsa as its appendix label. /// ls as its label, and lsa as its appendix label.
void newCounter(docstring const & newc, void newCounter(docstring const & newc,
docstring const & masterc, docstring const & parentc,
docstring const & ls, docstring const & ls,
docstring const & lsa, docstring const & lsa,
docstring const & guiname); docstring const & guiname);
@ -143,14 +143,14 @@ public:
void saveValue(docstring const & ctr) const; void saveValue(docstring const & ctr) const;
/// ///
void restoreValue(docstring const & ctr) const; void restoreValue(docstring const & ctr) const;
/// Reset recursively all the counters that are slaves of the one named by \c ctr. /// Reset recursively all the counters that are children of the one named by \c ctr.
void resetSlaves(docstring const & ctr); void resetChildren(docstring const & ctr);
/// Increment by one master of counter named by \c ctr. /// Increment by one the parent of counter named by \c ctr.
/// This also resets the counter named by \c ctr. /// This also resets the counter named by \c ctr.
/// \param utype determines whether we track the counters. /// \param utype determines whether we track the counters.
void stepMaster(docstring const & ctr, UpdateType utype); void stepParent(docstring const & ctr, UpdateType utype);
/// Increment by one counter named by \c ctr, and zeroes slave /// Increment by one counter named by \c ctr, and zeroes child
/// counter(s) for which it is the master. /// counter(s) for which it is the parent.
/// \param utype determines whether we track the counters. /// \param utype determines whether we track the counters.
void step(docstring const & ctr, UpdateType utype); void step(docstring const & ctr, UpdateType utype);
/// Reset all counters, and all the internal data structures /// Reset all counters, and all the internal data structures