]> git.lyx.org Git - features.git/commitdiff
a bit more const correctness
authorAndré Pönitz <poenitz@gmx.net>
Thu, 8 Aug 2002 16:08:11 +0000 (16:08 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 8 Aug 2002 16:08:11 +0000 (16:08 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4905 a592a061-630c-0410-9148-cb99ea01b6c8

22 files changed:
src/mathed/formula.C
src/mathed/formula.h
src/mathed/math_atom.h
src/mathed/math_charinset.C
src/mathed/math_charinset.h
src/mathed/math_cursor.C
src/mathed/math_cursor.h
src/mathed/math_data.C
src/mathed/math_extern.C
src/mathed/math_fracinset.C
src/mathed/math_fracinset.h
src/mathed/math_gridinset.h
src/mathed/math_hullinset.C
src/mathed/math_inset.h
src/mathed/math_iterator.C
src/mathed/math_macro.h
src/mathed/math_nestinset.C
src/mathed/math_nestinset.h
src/mathed/math_symbolinset.C
src/mathed/math_symbolinset.h
src/mathed/math_unknowninset.C
src/mathed/math_unknowninset.h

index d471a76ff6badcab53dc682671c17378c997f207..441767e649f59cb1e6c1bca28eecea66f5cad3f8 100644 (file)
@@ -396,13 +396,19 @@ bool InsetFormula::display() const
 }
 
 
-MathHullInset * InsetFormula::hull() const
+MathHullInset const * InsetFormula::hull() const
 {
        lyx::Assert(par_->asHullInset());
        return par_->asHullInset();
 }
 
 
+MathHullInset * InsetFormula::hull()
+{
+       lyx::Assert(par_->asHullInset());
+       return par_->asHullInset();
+}
+
 Inset::Code InsetFormula::lyxCode() const
 {
        return Inset::MATH_CODE;
index 1b1d66834ad2892e8804a69f586312ad6eee9cfc..f5ccf5bec7d6d77b91d85bed90f1c3705209f7c5 100644 (file)
@@ -94,7 +94,9 @@ private:
        /// available in AMS only?
        bool ams() const;
        /// access to hull
-       MathHullInset * hull() const;
+       MathHullInset const * hull() const;
+       /// access to hull
+       MathHullInset * hull();
        ///
        void handleExtern(string const & arg);
 
index 04cf2a391d637599f9934cda7b319bcdcacc64e1..4a7d1c1a51bbce0a434cfde56cda4a9ef239849f 100644 (file)
@@ -50,7 +50,8 @@ public:
        /// change inset under the hood
        void reset(MathInset * p);
        /// access to the inset (checked with gprof)
-       MathInset * nucleus() const { return nucleus_; }
+       MathInset const * nucleus() const { return nucleus_; }
+       MathInset       * nucleus()       { return nucleus_; }
        /// access to the inset
        MathInset * operator->() const { return nucleus_; }
 
index 6ec00b058277363e25575bd1da0dadf62aeca4e2..b44ad7111f438ce21a8d89695a179304707365ed 100644 (file)
@@ -135,7 +135,7 @@ bool MathCharInset::isRelOp() const
 }
 
 
-bool MathCharInset::match(MathInset * p) const
+bool MathCharInset::match(MathInset const * p) const
 {
        MathCharInset const * q = p->asCharInset();
        return q && char_ == q->char_;
index 22664138f6ff1c6bd074e4d9944e2c61ea6e7379..a25e8928784b8143cbd45ccec007076defccf9ae 100644 (file)
@@ -39,7 +39,7 @@ public:
        ///
        bool isRelOp() const;
        ///
-       bool match(MathInset *) const;
+       bool match(MathInset const *) const;
 
 private:
        /// the character
index cc011e635963b12a55cbe2c6416ffaa111463e6f..5874875f8563d97565dc47eaad8179b92524ad35 100644 (file)
@@ -587,7 +587,7 @@ bool MathCursor::toggleLimits()
 
 void MathCursor::macroModeClose()
 {
-       MathUnknownInset * p = inMacroMode();
+       MathUnknownInset const * p = inMacroMode();
        if (!p)
                return;
        p->finalize();
@@ -688,7 +688,6 @@ void MathCursor::selGet(MathArray & ar)
 }
 
 
-
 void MathCursor::drawSelection(MathPainterInfo & pi) const
 {
        if (!selection_)
@@ -702,7 +701,10 @@ void MathCursor::drawSelection(MathPainterInfo & pi) const
 
 void MathCursor::handleNest(MathAtom const & at)
 {
-       at->cell(0) = grabAndEraseSelection().glue();
+#ifdef WITH_WARNINGS
+#warning temporarily disabled
+       //at->cell(0) = grabAndEraseSelection().glue();
+#endif
        insert(at);
        pushRight(prevAtom());
 }
@@ -750,11 +752,11 @@ MathCursor::pos_type & MathCursor::pos()
 }
 
 
-MathUnknownInset * MathCursor::inMacroMode() const
+MathUnknownInset const * MathCursor::inMacroMode() const
 {
        if (!hasPrevAtom())
                return 0;
-       MathUnknownInset * p = prevAtom()->asUnknownInset();
+       MathUnknownInset const * p = prevAtom()->asUnknownInset();
        return (p && !p->final()) ? p : 0;
 }
 
index b16b55102db71ed99c3cb55c7b73a09bdac82c23..b529de23477ecd3a4657c8fe540aedae314eddd4 100644 (file)
@@ -134,7 +134,7 @@ public:
        /// interpret name a name of a macro
        void macroModeClose();
        /// are we currently typing the name of a macro?
-       MathUnknownInset * inMacroMode() const;
+       MathUnknownInset const * inMacroMode() const;
        /// are we currently typing '#1' or '#2' or...?
        bool inMacroArgMode() const;
        /// are we in math mode (1), text mode (-1) or unsure?
index 12de1e2582c103b9946a8749489481fe4b902061..b99772041ed13bbeee22e73e0bd4d2989a1a9b2e 100644 (file)
@@ -154,8 +154,11 @@ void MathArray::replace(ReplaceData & rep)
                }
        }
 
-       for (const_iterator it = begin(); it != end(); ++it)
-               it->nucleus()->replace(rep);
+#ifdef WITH_WARNINGS
+#warning temporarily disabled
+       // for (const_iterator it = begin(); it != end(); ++it)
+       //      it->nucleus()->replace(rep);
+#endif
 }
 
 
index 921e59fce4fe5f3c43de26f24df88342f3015288..b5d83a09ca6b92bd6a8020cbf39a85f70e198d42 100644 (file)
@@ -44,7 +44,7 @@ ostream & operator<<(ostream & os, MathArray const & ar)
 
 
 // define a function for tests
-typedef bool TestItemFunc(MathInset *);
+typedef bool TestItemFunc(MathInset const *);
 
 // define a function for replacing subexpressions
 typedef MathInset * ReplaceArgumentFunc(const MathArray & ar);
@@ -132,14 +132,14 @@ void extractStrings(MathArray & ar)
                if (!ar[i]->asCharInset())
                        continue;
                string s = charSequence(ar.begin() + i, ar.end());
-               ar[i].reset(new MathStringInset(s));
+               ar[i] = MathAtom(new MathStringInset(s));
                ar.erase(i + 1, i + s.size());
        }
        //lyxerr << "\nStrings to: " << ar << "\n";
 }
 
 
-MathInset * singleItem(MathArray & ar)
+MathInset const * singleItem(MathArray const & ar)
 {
        return ar.size() == 1 ? ar.begin()->nucleus() : 0;
 }
@@ -153,7 +153,7 @@ void extractMatrices(MathArray & ar)
                MathDelimInset * del = (*it)->asDelimInset();
                if (!del)
                        continue;
-               MathInset * arr = singleItem(del->cell(0));
+               MathInset const * arr = singleItem(del->cell(0));
                if (!arr || !arr->asGridInset())
                        continue;
                *it = MathAtom(new MathMatrixInset(*(arr->asGridInset())));
@@ -171,7 +171,7 @@ void extractMatrices(MathArray & ar)
 
 
 // convert this inset somehow to a string
-bool extractString(MathInset * p, string & str)
+bool extractString(MathInset const * p, string & str)
 {
        if (!p)
                return false;
@@ -204,7 +204,7 @@ bool extractNumber(MathArray const & ar, double & d)
 }
 
 
-bool testString(MathInset * p, const string & str)
+bool testString(MathInset const * p, const string & str)
 {
        string s;
        return extractString(p, s) && str == s;
@@ -257,7 +257,7 @@ void replaceNested(
 
                // replace the original stuff by the new inset
                ar.erase(it + 1, jt + 1);
-               (*it).reset(p);
+               *it = MathAtom(p);
        }
 }
 
@@ -319,7 +319,7 @@ void extractExps(MathArray & ar)
                        continue;
 
                // create a proper exp-inset as replacement 
-               *it = new MathExFuncInset("exp", sup->cell(1));
+               *it = MathAtom(new MathExFuncInset("exp", sup->cell(1)));
                ar.erase(it + 1);
        }
        //lyxerr << "\nExps to: " << ar << "\n";
@@ -338,7 +338,7 @@ void extractDets(MathArray & ar)
                        continue;
                if (!del->isAbs())
                        continue;
-               *it = new MathExFuncInset("det", del->cell(0));
+               *it = MathAtom(new MathExFuncInset("det", del->cell(0)));
        }
        //lyxerr << "\ndet to: " << ar << "\n";
 }
@@ -379,7 +379,7 @@ void extractNumbers(MathArray & ar)
 
                string s = digitSequence(ar.begin() + i, ar.end());
 
-               ar[i].reset(new MathNumberInset(s));
+               ar[i] = MathAtom(new MathNumberInset(s));
                ar.erase(i + 1, i + s.size());
        }
        //lyxerr << "\nNumbers to: " << ar << "\n";
@@ -391,13 +391,13 @@ void extractNumbers(MathArray & ar)
 // search deliminiters
 //
 
-bool testOpenParan(MathInset * p)
+bool testOpenParan(MathInset const * p)
 {
        return testString(p, "(");
 }
 
 
-bool testCloseParan(MathInset * p)
+bool testCloseParan(MathInset const * p)
 {
        return testString(p, ")");
 }
@@ -470,7 +470,7 @@ void extractFunctions(MathArray & ar)
                MathArray::iterator st = extractArgument(p->cell(0), jt, ar.end());
 
                // replace the function name by a real function inset
-               (*it).reset(p);
+               *it = MathAtom(p);
 
                // remove the source of the argument from the array
                ar.erase(it + 1, st);
@@ -486,19 +486,19 @@ void extractFunctions(MathArray & ar)
 // search integrals
 //
 
-bool testSymbol(MathInset * p, string const & name)
+bool testSymbol(MathInset const * p, string const & name)
 {
        return p->asSymbolInset() && p->asSymbolInset()->name() == name;
 }
 
 
-bool testIntSymbol(MathInset * p)
+bool testIntSymbol(MathInset const * p)
 {
        return testSymbol(p, "int");
 }
 
 
-bool testIntegral(MathInset * p)
+bool testIntegral(MathInset const * p)
 {
        return
         testIntSymbol(p) ||
@@ -509,7 +509,7 @@ bool testIntegral(MathInset * p)
 
 
 
-bool testIntDiff(MathInset * p)
+bool testIntDiff(MathInset const * p)
 {
        return testString(p, "d");
 }
@@ -554,7 +554,7 @@ void extractIntegrals(MathArray & ar)
 
                // remove used parts
                ar.erase(it + 1, tt);
-               (*it).reset(p);
+               *it = MathAtom(p);
        }
        //lyxerr << "\nIntegrals to: " << ar << "\n";
 }
@@ -571,13 +571,13 @@ bool testEqualSign(MathAtom const & at)
 }
 
 
-bool testSumSymbol(MathInset * p)
+bool testSumSymbol(MathInset const * p)
 {
        return testSymbol(p, "sum");
 }
 
 
-bool testSum(MathInset * p)
+bool testSum(MathInset const * p)
 {
        return
         testSumSymbol(p) ||
@@ -633,7 +633,7 @@ void extractSums(MathArray & ar)
 
                // cleanup
                ar.erase(it + 1, tt);
-               (*it).reset(p);
+               *it = MathAtom(p);
        }
        //lyxerr << "\nSums to: " << ar << "\n";
 }
@@ -656,9 +656,9 @@ bool testDiffArray(MathArray const & ar)
 }
 
 
-bool testDiffFrac(MathInset * p)
+bool testDiffFrac(MathInset const * p)
 {
-       MathFracInset * f = p->asFracInset();
+       MathFracInset const * f = p->asFracInset();
        return f && testDiffArray(f->cell(0)) && testDiffArray(f->cell(1));
 }
 
@@ -743,7 +743,7 @@ void extractDiff(MathArray & ar)
 
                // cleanup
                ar.erase(it + 1, jt);
-               (*it).reset(diff);
+               *it = MathAtom(diff);
        }
        //lyxerr << "\nDiffs to: " << ar << "\n";
 }
@@ -798,12 +798,11 @@ void extractLims(MathArray & ar)
                MathArray f;
                MathArray::iterator tt = extractArgument(f, it + 2, ar.end());
 
-               // create a proper inset as replacement
-               MathLimInset * p = new MathLimInset(f, x, x0);
-
                // cleanup
                ar.erase(it + 1, tt);
-               (*it).reset(p);
+
+               // create a proper inset as replacement
+               *it = MathAtom(new MathLimInset(f, x, x0));
        }
        //lyxerr << "\nLimits to: " << ar << "\n";
 }
index 49aea9182464aa6c6dd219580a5e2a5ec492ccd1..1ad3d222250769de745471eaebeca47af407cbb7 100644 (file)
@@ -29,6 +29,12 @@ MathFracInset * MathFracInset::asFracInset()
 }
 
 
+MathFracInset const * MathFracInset::asFracInset() const
+{
+       return atop_ ? 0 : this;
+}
+
+
 void MathFracInset::metrics(MathMetricsInfo & mi) const
 {
        MathFracChanger dummy(mi.base);
index 0fc668b914bd16e413b7099a25d7053a8870d56e..45197d59819825ae71c5bf5a3a29a42b623ca705 100644 (file)
@@ -25,8 +25,10 @@ public:
        void metricsT(TextMetricsInfo const & mi) const;
        ///
        void drawT(TextPainter &, int x, int y) const;
-       ///
+       /// identifies FracInsets
        MathFracInset * asFracInset();
+       /// identifies FracInsets
+       MathFracInset const * asFracInset() const;
        ///
        string name() const;
 
index 481544a5824186600d8b510462d093c179c34e59..0f8bfb68d881cf9d6b45eb73239a4fba5b330832 100644 (file)
@@ -125,7 +125,9 @@ public:
        /// 
        CellInfo & cellinfo(idx_type idx) { return cellinfo_[idx]; }
        /// identifies GridInset
-       virtual MathGridInset * asGridInset() { return this; }
+       MathGridInset * asGridInset() { return this; }
+       /// identifies GridInset
+       MathGridInset const * asGridInset() const { return this; }
 
        ///
        col_type ncols() const;
index 26353829161cc780acb8809472664be8ccedc888..a988bbe237ca514aa98394e7f4d7b129bb1c8c47 100644 (file)
@@ -516,9 +516,8 @@ void MathHullInset::mutate(string const & newtype)
                        setType("eqnarray");
                        mutate(newtype);
                } else if (newtype == "multline" || newtype == "gather") {
-                       setType("multline");
+                       setType(newtype);
                        numbered(0, false);
-                       mutate(newtype);
                } else {                        
                        MathGridInset::addCol(1);
                        // split it "nicely"
index 7b2de3d821d05a18e15317df7cde42cde47317ed..d092e1964560b9a3bf6148208b56f9d29442587d 100644 (file)
@@ -195,17 +195,21 @@ public:
        virtual MathDelimInset         * asDelimInset()         { return 0; }
        virtual MathDelimInset const   * asDelimInset() const   { return 0; }
        virtual MathFracInset          * asFracInset()          { return 0; }
+       virtual MathFracInset const    * asFracInset() const    { return 0; }
        virtual MathGridInset          * asGridInset()          { return 0; }
+       virtual MathGridInset const    * asGridInset() const    { return 0; }
        virtual MathHullInset          * asHullInset()          { return 0; }
        virtual MathHullInset const    * asHullInset() const    { return 0; }
        virtual MathMacroTemplate      * asMacroTemplate()      { return 0; }
        virtual MathMatrixInset const  * asMatrixInset() const  { return 0; }
        virtual MathNestInset          * asNestInset()          { return 0; }
+       virtual MathNestInset const    * asNestInset() const    { return 0; }
        virtual MathParboxInset        * asParboxInset()        { return 0; }
        virtual MathScriptInset        * asScriptInset()        { return 0; }
        virtual MathScriptInset const  * asScriptInset() const  { return 0; }
        virtual MathSpaceInset         * asSpaceInset()         { return 0; }
        virtual MathStringInset        * asStringInset()        { return 0; }
+       virtual MathStringInset const  * asStringInset() const  { return 0; }
        virtual MathSymbolInset const  * asSymbolInset() const  { return 0; }
        virtual MathUnknownInset       * asUnknownInset()       { return 0; }
        virtual MathUnknownInset const * asUnknownInset() const { return 0; }
@@ -236,11 +240,11 @@ public:
        /// char char code if possible
        virtual void handleFont(string const &) {}
        /// is this inset equal to a given other inset?
-       virtual bool match(MathInset *) const { return false; }
+       virtual bool match(MathInset const *) const { return false; }
        /// replace things by other things
        virtual void replace(ReplaceData &) {}
        /// do we contain a given subsequence?
-       virtual bool contains(MathArray const &) { return false; }
+       virtual bool contains(MathArray const &) const { return false; }
        /// access to the lock (only nest array have one)
        virtual bool lock() const { return false; }
        /// access to the lock (only nest array have one)
index 087c5f27d565db4ee38ef5978b9eaaad4db73580..8b70f3d52303d2b861e851e394583e762a00df20 100644 (file)
@@ -74,7 +74,7 @@ void MathIterator::goEnd()
 void MathIterator::operator++()
 {
        MathCursorPos   & top = back();
-       MathArray const & ar  = top.par_->cell(top.idx_);
+       MathArray & ar  = top.par_->cell(top.idx_);
 
        // move into the current inset if possible
        // it is impossible for pos() == size()!
index 9a944f5fc524cbd824473e6bc7412d0bf594958a..f36350bca74daedf984e62bae7263e478f2b44e3 100644 (file)
@@ -60,7 +60,7 @@ public:
        ///
        bool isMacro() const { return true; }
        ///
-       bool match(MathInset *) const { return false; }
+       bool match(MathInset const *) const { return false; }
 
        ///
        void maplize(MapleStream &) const;
index d0708b0be6e4ce0d462ffa80d4ab297410805aa0..fc3ea5d7a5f4a406e195820021cea7096a77bf08 100644 (file)
@@ -228,7 +228,7 @@ void MathNestInset::validate(LaTeXFeatures & features) const
 }
 
 
-bool MathNestInset::match(MathInset * p) const
+bool MathNestInset::match(MathInset const * p) const
 {
        if (nargs() != p->nargs())
                return false;
@@ -246,7 +246,7 @@ void MathNestInset::replace(ReplaceData & rep)
 }
 
 
-bool MathNestInset::contains(MathArray const & ar)
+bool MathNestInset::contains(MathArray const & ar) const
 {
        for (idx_type i = 0; i < nargs(); ++i)
                if (cell(i).contains(ar))
index 3ca195bab95b2efbf047a943f53529f672fd203f..cf9d4057a065e7d0389d01ce517380513c11f53f 100644 (file)
@@ -38,6 +38,8 @@ public:
        void substitute(MathMacro const & macro);
        /// identifies NestInsets
        MathNestInset * asNestInset() { return this; }
+       /// identifies NestInsets
+       MathNestInset const * asNestInset() const { return this; }
        /// get cursor position
        void getPos(idx_type idx, pos_type pos, int & x, int & y) const;
 
@@ -81,11 +83,11 @@ public:
        void validate(LaTeXFeatures & features) const;
 
        /// match in all cells
-       bool match(MathInset *) const;
+       bool match(MathInset const *) const;
        /// replace in all cells
        void replace(ReplaceData &);
        /// do we contain a given pattern?
-       bool contains(MathArray const &);
+       bool contains(MathArray const &) const;
        /// glue everything to a single cell
        MathArray glue() const;
 
index 245b5c9b80291856dae8030d0df9179d380c39e6..597dec9ee29a2f95f623b83be71a5f4eb4bb77ad 100644 (file)
@@ -140,7 +140,7 @@ char const * MathMLtype(string const & s)
 }
 
 
-bool MathSymbolInset::match(MathInset * p) const
+bool MathSymbolInset::match(MathInset const * p) const
 {
        MathSymbolInset const * q = p->asSymbolInset();
        return q && name() == q->name();
index 731633272626afec87a60803988585c81979e204..c79533e936038b049bee0c0eaa8df187c3064fdc 100644 (file)
@@ -34,7 +34,7 @@ public:
        /// the LaTeX name of the symbol (without the backslash)
        string name() const;
        ///
-       bool match(MathInset *) const;
+       bool match(MathInset const *) const;
        /// request "external features"
        void validate(LaTeXFeatures & features) const;
 
index fac5abeb22b64d48e2cf6f30013881aeb3f8bcd8..5bebcf321d100fcbc884fd074a29a284e55815d6 100644 (file)
@@ -27,13 +27,13 @@ string MathUnknownInset::name() const
 }
 
 
-void MathUnknownInset::setName(string const & name)
+void MathUnknownInset::setName(string const & name) const
 {
        name_ = name;
 }
 
 
-bool MathUnknownInset::match(MathInset * p) const
+bool MathUnknownInset::match(MathInset const * p) const
 {
        MathUnknownInset const * q = p->asUnknownInset();
        return q && name_ == q->name_;
@@ -61,7 +61,7 @@ void MathUnknownInset::draw(MathPainterInfo & pi, int x, int y) const
 }
 
 
-void MathUnknownInset::finalize()
+void MathUnknownInset::finalize() const
 {
        final_ = true;
 }
index 8ecc8064a6d21f3c915683f9ab0af828da392b5e..1b65a80d53ed4746905b8a4fd0330332f4f096dc 100644 (file)
@@ -23,7 +23,7 @@ public:
        ///
        void draw(MathPainterInfo & pi, int x, int y) const;
        ///
-       void setName(string const & name);
+       void setName(string const & name) const;
        ///
        string name() const;
        /// identifies UnknownInsets
@@ -31,7 +31,7 @@ public:
        /// identifies UnknownInsets
        MathUnknownInset * asUnknownInset() { return this; }
        ///
-       bool match(MathInset * p) const;
+       bool match(MathInset const * p) const;
 
        ///
        void normalize(NormalStream &) const;
@@ -44,14 +44,14 @@ public:
        ///
        void octavize(OctaveStream &) const;
        ///
-       void finalize();
+       void finalize() const;
        ///
        bool final() const;
 private:
        ///
-       string name_;
+       mutable string name_;
        /// are we finished creating the name?
-       bool final_;
+       mutable bool final_;
        ///
        bool black_;
 };