MacroData refactoring

This commit is contained in:
Yuriy Skalko 2020-11-04 12:04:39 +02:00
parent 5a54ccfa87
commit 01e673635b
3 changed files with 18 additions and 23 deletions

View File

@ -3802,7 +3802,7 @@ void Buffer::Impl::updateMacros(DocIterator & it, DocIterator & scope)
// FIXME (Abdel), I don't understand why we pass 'it' here // FIXME (Abdel), I don't understand why we pass 'it' here
// instead of 'macroTemplate' defined above... is this correct? // instead of 'macroTemplate' defined above... is this correct?
macros[macroTemplate.name()][it] = macros[macroTemplate.name()][it] =
Impl::ScopeMacro(scope, MacroData(const_cast<Buffer *>(owner_), it)); Impl::ScopeMacro(scope, MacroData(owner_, it));
break; break;
} }
default: default:

View File

@ -41,23 +41,18 @@ namespace lyx {
// //
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
MacroData::MacroData(Buffer * buf) MacroData::MacroData(const Buffer * buf)
: buffer_(buf), queried_(true), numargs_(0), sym_(0), optionals_(0), : buffer_(buf), queried_(true)
lockCount_(0), redefinition_(false), type_(MacroTypeNewcommand)
{} {}
MacroData::MacroData(Buffer * buf, DocIterator const & pos) MacroData::MacroData(Buffer const * buf, DocIterator const & pos)
: buffer_(buf), pos_(pos), queried_(false), numargs_(0), sym_(0), : buffer_(buf), pos_(pos)
optionals_(0), lockCount_(0), redefinition_(false), {}
type_(MacroTypeNewcommand)
{
}
MacroData::MacroData(Buffer * buf, InsetMathMacroTemplate const & macro) MacroData::MacroData(Buffer const * buf, InsetMathMacroTemplate const & macro)
: buffer_(buf), queried_(false), numargs_(0), sym_(0), optionals_(0), : buffer_(buf)
lockCount_(0), redefinition_(false), type_(MacroTypeNewcommand)
{ {
queryData(macro); queryData(macro);
} }

View File

@ -38,11 +38,11 @@ enum MacroType {
class MacroData { class MacroData {
public: public:
/// Constructor to make STL containers happy /// Constructor to make STL containers happy
explicit MacroData(Buffer * buf = 0); explicit MacroData(Buffer const * buf = 0);
/// Create lazy MacroData which only queries the macro template when needed /// Create lazy MacroData which only queries the macro template when needed
MacroData(Buffer * buf, DocIterator const & pos); MacroData(Buffer const * buf, DocIterator const & pos);
/// Create non-lazy MacroData which directly queries the macro template /// Create non-lazy MacroData which directly queries the macro template
MacroData(Buffer * buf, InsetMathMacroTemplate const & macro); MacroData(Buffer const * buf, InsetMathMacroTemplate const & macro);
/// ///
docstring const & definition() const { updateData(); return definition_; } docstring const & definition() const { updateData(); return definition_; }
@ -122,25 +122,25 @@ private:
/// macros. /// macros.
mutable DocIterator pos_; mutable DocIterator pos_;
/// ///
mutable bool queried_; mutable bool queried_ = false;
/// ///
mutable docstring definition_; mutable docstring definition_;
/// ///
mutable size_t numargs_; mutable size_t numargs_ = 0;
/// ///
mutable docstring display_; mutable docstring display_;
/// ///
latexkeys const * sym_; latexkeys const * sym_ = nullptr;
/// ///
mutable size_t optionals_; mutable size_t optionals_ = 0;
/// ///
mutable std::vector<docstring> defaults_; mutable std::vector<docstring> defaults_;
/// ///
mutable int lockCount_; mutable int lockCount_ = 0;
/// ///
mutable bool redefinition_; mutable bool redefinition_ = false;
/// ///
mutable MacroType type_; mutable MacroType type_ = MacroTypeNewcommand;
}; };