commit 01e673635b0701cd0cd19ef96bc5e4b3879b6db1
Author: Yuriy Skalko <[email protected]>
Date: Wed Nov 4 12:04:39 2020 +0200
MacroData refactoring
---
src/Buffer.cpp | 2 +-
src/mathed/MacroTable.cpp | 19 +++++++------------
src/mathed/MacroTable.h | 20 ++++++++++----------
3 files changed, 18 insertions(+), 23 deletions(-)
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index e86450d..acda58f 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -3802,7 +3802,7 @@ void Buffer::Impl::updateMacros(DocIterator & it,
DocIterator & scope)
// FIXME (Abdel), I don't understand why we
pass 'it' here
// instead of 'macroTemplate' defined above...
is this correct?
macros[macroTemplate.name()][it] =
- Impl::ScopeMacro(scope,
MacroData(const_cast<Buffer *>(owner_), it));
+ Impl::ScopeMacro(scope,
MacroData(owner_, it));
break;
}
default:
diff --git a/src/mathed/MacroTable.cpp b/src/mathed/MacroTable.cpp
index fb2a9e0..218c849 100644
--- a/src/mathed/MacroTable.cpp
+++ b/src/mathed/MacroTable.cpp
@@ -41,23 +41,18 @@ namespace lyx {
//
/////////////////////////////////////////////////////////////////////
-MacroData::MacroData(Buffer * buf)
- : buffer_(buf), queried_(true), numargs_(0), sym_(0), optionals_(0),
- lockCount_(0), redefinition_(false), type_(MacroTypeNewcommand)
+MacroData::MacroData(const Buffer * buf)
+ : buffer_(buf), queried_(true)
{}
-MacroData::MacroData(Buffer * buf, DocIterator const & pos)
- : buffer_(buf), pos_(pos), queried_(false), numargs_(0), sym_(0),
- optionals_(0), lockCount_(0), redefinition_(false),
- type_(MacroTypeNewcommand)
-{
-}
+MacroData::MacroData(Buffer const * buf, DocIterator const & pos)
+ : buffer_(buf), pos_(pos)
+{}
-MacroData::MacroData(Buffer * buf, InsetMathMacroTemplate const & macro)
- : buffer_(buf), queried_(false), numargs_(0), sym_(0), optionals_(0),
- lockCount_(0), redefinition_(false), type_(MacroTypeNewcommand)
+MacroData::MacroData(Buffer const * buf, InsetMathMacroTemplate const & macro)
+ : buffer_(buf)
{
queryData(macro);
}
diff --git a/src/mathed/MacroTable.h b/src/mathed/MacroTable.h
index b588ee2..77b306f 100644
--- a/src/mathed/MacroTable.h
+++ b/src/mathed/MacroTable.h
@@ -38,11 +38,11 @@ enum MacroType {
class MacroData {
public:
/// 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
- MacroData(Buffer * buf, DocIterator const & pos);
+ MacroData(Buffer const * buf, DocIterator const & pos);
/// 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_; }
@@ -122,25 +122,25 @@ private:
/// macros.
mutable DocIterator pos_;
///
- mutable bool queried_;
+ mutable bool queried_ = false;
///
mutable docstring definition_;
///
- mutable size_t numargs_;
+ mutable size_t numargs_ = 0;
///
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 int lockCount_;
+ mutable int lockCount_ = 0;
///
- mutable bool redefinition_;
+ mutable bool redefinition_ = false;
///
- mutable MacroType type_;
+ mutable MacroType type_ = MacroTypeNewcommand;
};
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs