]> git.lyx.org Git - features.git/commitdiff
* replace int type by the correct custom type for pos, idx and size.
authorStefan Schimanski <sts@lyx.org>
Thu, 1 Nov 2007 15:36:27 +0000 (15:36 +0000)
committerStefan Schimanski <sts@lyx.org>
Thu, 1 Nov 2007 15:36:27 +0000 (15:36 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21336 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/MacroTable.cpp
src/mathed/MacroTable.h
src/mathed/MathData.cpp
src/mathed/MathMacro.cpp
src/mathed/MathMacro.h
src/mathed/MathMacroTemplate.h

index 2d7e207e9cf75151a251e97cd847f1bcf302dcb6..ac2ac88a7602af5c77bf07aaaa530c94edfe77fe 100644 (file)
@@ -78,7 +78,7 @@ void MacroData::expand(vector<MathData> const & args, MathData & to) const
 }
 
 
-int MacroData::optionals() const
+size_t MacroData::optionals() const
 {
        return optionals_;
 }
index 8181357b963e368cb5bf8c0e983e977c3e1e00db..082cf675d63f0d1547bfcfec70d17e016e239368 100644 (file)
@@ -40,11 +40,11 @@ public:
        ///
        docstring const & display() const { return display_; }
        /// arity including optional arguments (if there is any)
-       int numargs() const { return numargs_; }
+       size_t numargs() const { return numargs_; }
        /// replace #1,#2,... by given MathAtom 0,1,.., _including_ the possible optional argument
        void expand(std::vector<MathData> const & from, MathData & to) const;
        /// number of optional arguments
-       int optionals() const;
+       size_t optionals() const;
        ///
        std::vector<docstring> const & defaults() const;
        ///
@@ -80,7 +80,7 @@ private:
        ///
        docstring definition_;
        ///
-       int numargs_;
+       size_t numargs_;
        ///
        docstring display_;
        ///
@@ -90,7 +90,7 @@ private:
        ///
        bool redefinition_;
        ///
-       int optionals_;
+       size_t optionals_;
        ///
        std::vector<docstring> defaults_;
 };
index b417e4b30a01b0375dd31df4f275cf8dc8dbe427..dc180ccb8e9ec6416a77a9c714f2416099f68296 100644 (file)
@@ -337,7 +337,7 @@ void MathData::updateMacros(MetricsInfo & mi)
                // get macro
                macroInset->updateMacro(mi);
                size_t macroNumArgs = 0;
-               int macroOptionals = 0;
+               size_t macroOptionals = 0;
                MacroData const * macro = macroInset->macro();
                if (macro) {
                        macroNumArgs = macro->numargs();
@@ -416,8 +416,8 @@ void MathData::detachMacroParameters(Cursor & cur, const size_type macroPos)
        
        // find cursor slice
        int curMacroSlice = cur.find(macroInset);
-       int curMacroIdx = -1;
-       int curMacroPos = -1;
+       idx_type curMacroIdx = -1;
+       pos_type curMacroPos = -1;
        std::vector<CursorSlice> argSlices;
        if (curMacroSlice != -1) {
                                curMacroPos = cur[curMacroSlice].pos();
@@ -434,7 +434,7 @@ void MathData::detachMacroParameters(Cursor & cur, const size_type macroPos)
        }
        
        // optional arguments to be put back?
-       size_t p = macroPos + 1;
+       pos_type p = macroPos + 1;
        size_t j = 0;
        for (; j < detachedArgs.size() && j < macroInset->optionals(); ++j) {
                // another non-empty parameter follows?
@@ -495,7 +495,7 @@ void MathData::detachMacroParameters(Cursor & cur, const size_type macroPos)
                        insert(p, MathAtom(new InsetMathBrace(arg)));
                
                // cursor in j-th argument of macro?
-               if (curMacroIdx == int(j)) {
+               if (curMacroIdx == j) {
                        if (operator[](p).nucleus()->asBraceInset()) {
                                cur[curMacroSlice - 1].pos() = p;
                                cur.append(0, curMacroPos);
index 67a97cbd4dd99e2d6322e90e540d6f51d0a50d28..862afe3a0e09e0c6da64a40cd5bca3d53f50f499 100644 (file)
@@ -320,7 +320,7 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
        }
 
        // another argument selected?
-       int curIdx = cursorIdx(pi.base.bv->cursor());
+       idx_type curIdx = cursorIdx(pi.base.bv->cursor());
        if (previousCurIdx_ != curIdx || editing_ != editMode(pi.base.bv->cursor()))
                pi.base.bv->cursor().updateFlags(Update::Force);
 }
@@ -414,13 +414,13 @@ Inset * MathMacro::editXY(Cursor & cur, int x, int y)
 }
 
 
-void MathMacro::removeArgument(size_t pos) {
+void MathMacro::removeArgument(Inset::pos_type pos) {
        if (displayMode_ == DISPLAY_NORMAL) {
-               BOOST_ASSERT(pos >= 0 && pos < cells_.size());
+               BOOST_ASSERT(size_t(pos) < cells_.size());
                cells_.erase(cells_.begin() + pos);
-               if (pos < attachedArgsNum_)
+               if (size_t(pos) < attachedArgsNum_)
                        --attachedArgsNum_;
-               if (pos < optionals_) {
+               if (size_t(pos) < optionals_) {
                        --optionals_;
                }
 
@@ -429,13 +429,13 @@ void MathMacro::removeArgument(size_t pos) {
 }
 
 
-void MathMacro::insertArgument(size_t pos) {
+void MathMacro::insertArgument(Inset::pos_type pos) {
        if (displayMode_ == DISPLAY_NORMAL) {
-               BOOST_ASSERT(pos >= 0 && pos <= cells_.size());
+               BOOST_ASSERT(size_t(pos) <= cells_.size());
                cells_.insert(cells_.begin() + pos, MathData());
-               if (pos < attachedArgsNum_)
+               if (size_t(pos) < attachedArgsNum_)
                        ++attachedArgsNum_;
-               if (pos < optionals_)
+               if (size_t(pos) < optionals_)
                        ++optionals_;
 
                needsUpdate_ = true;
@@ -529,7 +529,7 @@ void MathMacro::write(WriteStream & os) const
 
                os << "\\" << name();
                bool first = true;
-               size_t i = 0;
+               idx_type i = 0;
 
                // Use macroBackup_ instead of macro_ here, because
                // this is outside the metrics/draw calls, hence the macro_
index 45239e83eba630d41cd517af3f9994ef8e928ef1..050abe1849d4b2d3e432df0527c95fad91d0c08e 100644 (file)
@@ -58,9 +58,9 @@ public:
        virtual bool notifyCursorLeaves(Cursor &);
        
        /// Remove cell (starting from 0)
-       void removeArgument(size_t pos);
+       void removeArgument(pos_type pos);
        /// Insert empty cell (starting from 0)
-       void insertArgument(size_t pos);
+       void insertArgument(pos_type pos);
 
        ///
        void validate(LaTeXFeatures &) const;
@@ -112,7 +112,7 @@ public:
        }
                
        ///
-       int optionals() const { return optionals_; }
+       size_t optionals() const { return optionals_; }
        ///
        void setOptionals(int n) { 
                if (n <= int(nargs()))
@@ -160,9 +160,9 @@ private:
        /// number of arguments that were really attached
        size_t attachedArgsNum_;
        /// cursor position during last draw
-       int previousCurIdx_;
+       idx_type previousCurIdx_;
        /// optional argument attached? (only in DISPLAY_NORMAL mode)
-       int optionals_;
+       size_t optionals_;
        /// fold mode to be set in next metrics call?
        bool nextFoldMode_;
        /// if macro_ == true, then here is a copy of the macro
index 36eb7fbab3e61090439f744a4d0a87fe3c6877bd..b90c8a96cb0c01d4f283118c3befef7fa0c14d8c 100644 (file)
@@ -89,11 +89,11 @@ private:
        ///
        void makeNonOptional(Cursor & cur);
        ///
-       pos_type defIdx() const { return optionals_ + 1; }
+       idx_type defIdx() const { return optionals_ + 1; }
        /// index of default value cell of optional parameter (#1 -> n=0)
-       pos_type optIdx(int n) const { return n + 1; }
+       idx_type optIdx(idx_type n) const { return n + 1; }
        ///
-       pos_type displayIdx() const { return optionals_ + 2; }
+       idx_type displayIdx() const { return optionals_ + 2; }
        /// The label with some holes to edit
        mutable MathData label_;
        ///