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)) {
// Increase the master counter?
if (layout.stepmastercounter)
counters.stepMaster(enumcounter, utype);
counters.stepParent(enumcounter, utype);
// Maybe we have to reset the enumeration counter.
if (!layout.resumecounter)
counters.reset(enumcounter);

View File

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

View File

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