From faf2f08712362b2b39422bf8680ae2248f345940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Tue, 8 Jan 2002 11:03:34 +0000 Subject: [PATCH] some changes to make some compilers somewhat happier git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3310 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/formula.C | 1 - src/mathed/math_cursor.C | 5 +++-- src/mathed/math_data.h | 2 ++ src/mathed/math_factory.C | 2 +- src/mathed/math_hash.C | 4 +++- src/mathed/math_inset.h | 12 +++++++----- src/mathed/math_iterator.C | 4 ++-- src/mathed/math_iterator.h | 2 +- src/mathed/math_parser.h | 37 +++++++++++++++++++---------------- src/mathed/math_scriptinset.C | 19 +++++++++--------- src/mathed/math_scriptinset.h | 6 +++--- src/mathed/math_xdata.C | 12 ++++++------ 12 files changed, 57 insertions(+), 49 deletions(-) diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 37fb7351b3..40fbf3d7ad 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -503,7 +503,6 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action, bool needEqnArray(string const & extra) { - return false; return extra == "dsolve"; } diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 34ecf9af92..3a2f305013 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -619,7 +619,7 @@ void MathCursor::macroModeClose() int MathCursor::macroNamePos() const { - for (int i = pos() - 1; i >= 0; --i) { + for (MathInset::difference_type i = pos() - 1; i >= 0; --i) { MathAtom & p = array().at(i); if (p->code() == LM_TC_TEX && p->getChar() == '\\') return i; @@ -631,7 +631,8 @@ int MathCursor::macroNamePos() const string MathCursor::macroName() const { string s; - for (int i = macroNamePos(); i >= 0 && i < int(pos()); ++i) + MathInset::difference_type i = macroNamePos(); + for ( ; i >= 0 && i < int(pos()); ++i) s += array().at(i)->getChar(); return s; } diff --git a/src/mathed/math_data.h b/src/mathed/math_data.h index 373396bbdb..2e029e2aa1 100644 --- a/src/mathed/math_data.h +++ b/src/mathed/math_data.h @@ -51,6 +51,8 @@ public: /// typedef buffer_type::size_type size_type; /// + typedef buffer_type::difference_type difference_type; + /// typedef buffer_type::size_type idx_type; /// typedef buffer_type::size_type pos_type; diff --git a/src/mathed/math_factory.C b/src/mathed/math_factory.C index 7e09a0abcc..1c49eb935b 100644 --- a/src/mathed/math_factory.C +++ b/src/mathed/math_factory.C @@ -30,7 +30,7 @@ MathAtom createMathInset(latexkeys const * l) case LM_TK_FUNCLIM: return MathAtom(new MathFuncLimInset(l->name)); case LM_TK_SPECIAL: - return MathAtom(new MathSpecialCharInset(l->id)); + return MathAtom(new MathSpecialCharInset(static_cast(l->id))); case LM_TK_SYM: case LM_TK_CMR: case LM_TK_CMSY: diff --git a/src/mathed/math_hash.C b/src/mathed/math_hash.C index 59777ecb61..46927b920b 100644 --- a/src/mathed/math_hash.C +++ b/src/mathed/math_hash.C @@ -11,6 +11,7 @@ namespace { +// global std::map theWordList; @@ -18,11 +19,12 @@ struct key_type { /// char const * name; /// - short token; + MathTokenEnum token; /// unsigned int id; }; + key_type wordlist_array[] = { {"!", LM_TK_SPACE, 0}, diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index 5b8d6de1da..8f607e319f 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -78,15 +78,17 @@ class MathPosFinder; class MathInset { public: /// short of anything else reasonable - typedef MathArray::size_type size_type; + typedef MathArray::size_type size_type; + /// type for cursor positions differences within a cell + typedef MathArray::difference_type difference_type; /// type for cursor positions within a cell - typedef MathArray::size_type pos_type; + typedef MathArray::size_type pos_type; /// type for cell indices - typedef size_type idx_type; + typedef size_type idx_type; /// type for row numbers - typedef size_type row_type; + typedef size_type row_type; /// type for column numbers - typedef size_type col_type; + typedef size_type col_type; /// our members behave nicely... MathInset() {} diff --git a/src/mathed/math_iterator.C b/src/mathed/math_iterator.C index 0ba7588063..3d6406c799 100644 --- a/src/mathed/math_iterator.C +++ b/src/mathed/math_iterator.C @@ -138,10 +138,10 @@ void MathIterator::operator++() } -void MathIterator::jump(int i) +void MathIterator::jump(MathInset::difference_type i) { position().pos_ += i; - lyx::Assert(position().pos_ >= 0); + //lyx::Assert(position().pos_ >= 0); lyx::Assert(position().pos_ <= cell().size()); } diff --git a/src/mathed/math_iterator.h b/src/mathed/math_iterator.h index 03bd047870..7b484b030b 100644 --- a/src/mathed/math_iterator.h +++ b/src/mathed/math_iterator.h @@ -21,7 +21,7 @@ public: /// move on one step void operator++(); /// move on several steps - void jump(int n); + void jump(MathInset::difference_type); /// read access to top most item MathCursorPos const & position() const; /// write access to top most item diff --git a/src/mathed/math_parser.h b/src/mathed/math_parser.h index 8984fa3763..c3f64eea5e 100644 --- a/src/mathed/math_parser.h +++ b/src/mathed/math_parser.h @@ -26,8 +26,6 @@ #include "LString.h" #include "math_defs.h" -class MathHullInset; -class MathMacroTemplate; class MathAtom; class MathArray; class LyXLex; @@ -36,7 +34,7 @@ class LyXLex; enum MathTokenEnum { /// - LM_TK_SYM = 256, + LM_TK_SYM, /// LM_TK_BOX, /// @@ -118,36 +116,41 @@ enum MathTokenEnum /// struct latexkeys { - /// + /// name of the macro or primitive string name; - /// - short token; - /// + /// one of the categories above + MathTokenEnum token; + /// an id within a category if needed (only for spaces?) unsigned int id; - /// - unsigned char latex_font_id; - /// + /// which font to use (optional) + unsigned int latex_font_id; + /// operator/... string type; - /// + /// how is this called as XML entity? string xmlname; }; -/// +/// check whether this is a well-known (La)TeX macro or primitive latexkeys const * in_word_set(string const & str); -/// -void ReadSymbols(string const & file); - +/// parse formula from a string bool mathed_parse_normal(MathAtom &, string const &); +/// ... a stream bool mathed_parse_normal(MathAtom &, std::istream &); +/// ... the LyX lexxer bool mathed_parse_normal(MathAtom &, LyXLex &); +/// parse a macro definition from a string, enter it into the macro table string mathed_parse_macro(string const &); +/// ... a stream string mathed_parse_macro(std::istream &); +/// ... the LyX lexxer string mathed_parse_macro(LyXLex &); -void mathed_parse_cell(MathArray & ar, string const & str); -void mathed_parse_cell(MathArray & ar, std::istream & is); +/// parse a single cell from a string +void mathed_parse_cell(MathArray & ar, string const &); +/// ... a stream +void mathed_parse_cell(MathArray & ar, std::istream &); #endif diff --git a/src/mathed/math_scriptinset.C b/src/mathed/math_scriptinset.C index b752716f3a..5c5aa5c7e3 100644 --- a/src/mathed/math_scriptinset.C +++ b/src/mathed/math_scriptinset.C @@ -106,37 +106,37 @@ int MathScriptInset::dy1(MathInset const * nuc) const int MathScriptInset::dx0(MathInset const * nuc) const { lyx::Assert(hasDown()); - return hasLimits(nuc) ? (width(nuc) - down().width()) / 2 : nwid(nuc); + return hasLimits(nuc) ? (width2(nuc) - down().width()) / 2 : nwid(nuc); } int MathScriptInset::dx1(MathInset const * nuc) const { lyx::Assert(hasUp()); - return hasLimits(nuc) ? (width(nuc) - up().width()) / 2 : nwid(nuc); + return hasLimits(nuc) ? (width2(nuc) - up().width()) / 2 : nwid(nuc); } int MathScriptInset::dxx(MathInset const * nuc) const { //lyx::Assert(nuc()); - return hasLimits(nuc) ? (width(nuc) - nwid(nuc)) / 2 : 0; + return hasLimits(nuc) ? (width2(nuc) - nwid(nuc)) / 2 : 0; } -int MathScriptInset::ascent(MathInset const * nuc) const +int MathScriptInset::ascent2(MathInset const * nuc) const { return dy1(nuc) + (hasUp() ? up().ascent() : 0); } -int MathScriptInset::descent(MathInset const * nuc) const +int MathScriptInset::descent2(MathInset const * nuc) const { return dy0(nuc) + (hasDown() ? down().descent() : 0); } -int MathScriptInset::width(MathInset const * nuc) const +int MathScriptInset::width2(MathInset const * nuc) const { int wid = 0; if (hasLimits(nuc)) { @@ -190,10 +190,9 @@ void MathScriptInset::metrics(MathInset const * nuc, MathNestInset::metrics(mi); if (nuc) nuc->metrics(mi); - - ascent_ = ascent(nuc); - descent_ = descent(nuc); - width_ = width(nuc); + ascent_ = ascent2(nuc); + descent_ = descent2(nuc); + width_ = width2(nuc); } diff --git a/src/mathed/math_scriptinset.h b/src/mathed/math_scriptinset.h index 608ce1fda5..b6626f2806 100644 --- a/src/mathed/math_scriptinset.h +++ b/src/mathed/math_scriptinset.h @@ -34,11 +34,11 @@ public: /// void draw(MathInset const * nuc, Painter &, int x, int y) const; /// - int ascent(MathInset const * nuc) const; + int ascent2(MathInset const * nuc) const; /// - int descent(MathInset const * nuc) const; + int descent2(MathInset const * nuc) const; /// - int width(MathInset const * nuc) const; + int width2(MathInset const * nuc) const; /// bool idxLeft(idx_type &, pos_type &) const; diff --git a/src/mathed/math_xdata.C b/src/mathed/math_xdata.C index 28f5d5c32e..998c3e0130 100644 --- a/src/mathed/math_xdata.C +++ b/src/mathed/math_xdata.C @@ -36,9 +36,9 @@ void MathXArray::metrics(MathMetricsInfo const & mi) const MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it); if (q) { q->metrics(p, mi); - ascent_ = std::max(ascent_, q->ascent(p)); - descent_ = std::max(descent_, q->descent(p)); - width_ += q->width(p); + ascent_ = std::max(ascent_, q->ascent2(p)); + descent_ = std::max(descent_, q->descent2(p)); + width_ += q->width2(p); ++it; } else { p->metrics(mi); @@ -67,7 +67,7 @@ void MathXArray::draw(Painter & pain, int x, int y) const MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it); if (q) { q->draw(p, pain, x, y); - x += q->width(p); + x += q->width2(p); ++it; } else { p->draw(pain, x, y); @@ -87,7 +87,7 @@ int MathXArray::pos2x(size_type targetpos) const if (q) { ++it; if (it < target) - x += q->width(p); + x += q->width2(p); else // "half" position x += q->dxx(p) + q->nwid(p); } else @@ -111,7 +111,7 @@ MathArray::size_type MathXArray::x2pos(int targetx) const if (it + 1 != end()) q = asScript(it); if (q) { - wid = q->width(p); + wid = q->width2(p); ++it; } else wid = p->width();