diff options
-rw-r--r-- | lexlib/CharacterCategory.cxx | 12 | ||||
-rw-r--r-- | lexlib/CharacterSet.cxx | 4 | ||||
-rw-r--r-- | lexlib/CharacterSet.h | 38 | ||||
-rw-r--r-- | lexlib/LexAccessor.h | 2 | ||||
-rw-r--r-- | lexlib/LexerModule.cxx | 17 | ||||
-rw-r--r-- | lexlib/LexerModule.h | 21 | ||||
-rw-r--r-- | lexlib/OptionSet.h | 8 | ||||
-rw-r--r-- | lexlib/PropSetSimple.cxx | 14 | ||||
-rw-r--r-- | lexlib/SparseState.h | 8 | ||||
-rw-r--r-- | lexlib/StyleContext.h | 4 | ||||
-rw-r--r-- | lexlib/SubStyles.h | 22 | ||||
-rw-r--r-- | lexlib/WordList.cxx | 20 | ||||
-rw-r--r-- | lexlib/WordList.h | 16 |
13 files changed, 90 insertions, 96 deletions
diff --git a/lexlib/CharacterCategory.cxx b/lexlib/CharacterCategory.cxx index 1e7ae8361..a2b0e0cca 100644 --- a/lexlib/CharacterCategory.cxx +++ b/lexlib/CharacterCategory.cxx @@ -3846,8 +3846,8 @@ const int catRanges[] = { //--Autogenerated -- end of section automatically generated }; -const int maxUnicode = 0x10ffff; -const int maskCategory = 0x1F; +constexpr int maxUnicode = 0x10ffff; +constexpr int maskCategory = 0x1F; } @@ -3880,7 +3880,7 @@ enum class OtherID { oidNone, oidStart, oidContinue }; // Some characters are treated as valid for identifiers even // though most characters from their category are not. // Values copied from http://www.unicode.org/Public/9.0.0/ucd/PropList.txt -OtherID OtherIDOfCharacter(int character) { +OtherID OtherIDOfCharacter(int character) noexcept { if ( (character == 0x1885) || // MONGOLIAN LETTER ALI GALI BALUDA (character == 0x1886) || // MONGOLIAN LETTER ALI GALI THREE BALUDA @@ -3904,11 +3904,11 @@ OtherID OtherIDOfCharacter(int character) { // Pattern_Syntax|Pattern_White_Space. // As of Unicode 9, only VERTICAL TILDE which is in Lm and has Pattern_Syntax matches. // Should really generate from PropList.txt a list of Pattern_Syntax and Pattern_White_Space. -bool IsIdPattern(int character) { +constexpr bool IsIdPattern(int character) noexcept { return character == 0x2E2F; } -bool OmitXidStart(int character) { +bool OmitXidStart(int character) noexcept { switch (character) { case 0x037A: // GREEK YPOGEGRAMMENI case 0x0E33: // THAI CHARACTER SARA AM @@ -3939,7 +3939,7 @@ bool OmitXidStart(int character) { } } -bool OmitXidContinue(int character) { +bool OmitXidContinue(int character) noexcept { switch (character) { case 0x037A: // GREEK YPOGEGRAMMENI case 0x309B: // KATAKANA-HIRAGANA VOICED SOUND MARK diff --git a/lexlib/CharacterSet.cxx b/lexlib/CharacterSet.cxx index 2a1dabc1c..b934c2dd4 100644 --- a/lexlib/CharacterSet.cxx +++ b/lexlib/CharacterSet.cxx @@ -15,7 +15,7 @@ using namespace Scintilla; namespace Scintilla { -int CompareCaseInsensitive(const char *a, const char *b) { +int CompareCaseInsensitive(const char *a, const char *b) noexcept { while (*a && *b) { if (*a != *b) { const char upperA = MakeUpperCase(*a); @@ -30,7 +30,7 @@ int CompareCaseInsensitive(const char *a, const char *b) { return *a - *b; } -int CompareNCaseInsensitive(const char *a, const char *b, size_t len) { +int CompareNCaseInsensitive(const char *a, const char *b, size_t len) noexcept { while (*a && *b && len) { if (*a != *b) { const char upperA = MakeUpperCase(*a); diff --git a/lexlib/CharacterSet.h b/lexlib/CharacterSet.h index f71dbc964..a518c27fc 100644 --- a/lexlib/CharacterSet.h +++ b/lexlib/CharacterSet.h @@ -94,12 +94,12 @@ public: bset[uch] = true; } } - bool Contains(int val) const { + bool Contains(int val) const noexcept { assert(val >= 0); if (val < 0) return false; return (val < size) ? bset[val] : valueAfter; } - bool Contains(char ch) const { + bool Contains(char ch) const noexcept { // Overload char as char may be signed const unsigned char uch = ch; return Contains(uch); @@ -108,19 +108,19 @@ public: // Functions for classifying characters -inline bool IsASpace(int ch) { +constexpr bool IsASpace(int ch) noexcept { return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d)); } -inline bool IsASpaceOrTab(int ch) { +constexpr bool IsASpaceOrTab(int ch) noexcept { return (ch == ' ') || (ch == '\t'); } -inline bool IsADigit(int ch) { +constexpr bool IsADigit(int ch) noexcept { return (ch >= '0') && (ch <= '9'); } -inline bool IsADigit(int ch, int base) { +constexpr bool IsADigit(int ch, int base) noexcept { if (base <= 10) { return (ch >= '0') && (ch < '0' + base); } else { @@ -130,23 +130,23 @@ inline bool IsADigit(int ch, int base) { } } -inline bool IsASCII(int ch) { +constexpr bool IsASCII(int ch) noexcept { return (ch >= 0) && (ch < 0x80); } -inline bool IsLowerCase(int ch) { +constexpr bool IsLowerCase(int ch) noexcept { return (ch >= 'a') && (ch <= 'z'); } -inline bool IsUpperCase(int ch) { +constexpr bool IsUpperCase(int ch) noexcept { return (ch >= 'A') && (ch <= 'Z'); } -inline bool IsUpperOrLowerCase(int ch) { +constexpr bool IsUpperOrLowerCase(int ch) noexcept { return IsUpperCase(ch) || IsLowerCase(ch); } -inline bool IsAlphaNumeric(int ch) { +constexpr bool IsAlphaNumeric(int ch) noexcept { return ((ch >= '0') && (ch <= '9')) || ((ch >= 'a') && (ch <= 'z')) || @@ -157,19 +157,19 @@ inline bool IsAlphaNumeric(int ch) { * Check if a character is a space. * This is ASCII specific but is safe with chars >= 0x80. */ -inline bool isspacechar(int ch) { +constexpr bool isspacechar(int ch) noexcept { return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d)); } -inline bool iswordchar(int ch) { +constexpr bool iswordchar(int ch) noexcept { return IsAlphaNumeric(ch) || ch == '.' || ch == '_'; } -inline bool iswordstart(int ch) { +constexpr bool iswordstart(int ch) noexcept { return IsAlphaNumeric(ch) || ch == '_'; } -inline bool isoperator(int ch) { +constexpr bool isoperator(int ch) noexcept { if (IsAlphaNumeric(ch)) return false; if (ch == '%' || ch == '^' || ch == '&' || ch == '*' || @@ -185,7 +185,7 @@ inline bool isoperator(int ch) { // Simple case functions for ASCII supersets. template <typename T> -inline T MakeUpperCase(T ch) { +constexpr T MakeUpperCase(T ch) noexcept { if (ch < 'a' || ch > 'z') return ch; else @@ -193,15 +193,15 @@ inline T MakeUpperCase(T ch) { } template <typename T> -inline T MakeLowerCase(T ch) { +constexpr T MakeLowerCase(T ch) noexcept { if (ch < 'A' || ch > 'Z') return ch; else return ch - 'A' + 'a'; } -int CompareCaseInsensitive(const char *a, const char *b); -int CompareNCaseInsensitive(const char *a, const char *b, size_t len); +int CompareCaseInsensitive(const char *a, const char *b) noexcept; +int CompareNCaseInsensitive(const char *a, const char *b, size_t len) noexcept; } diff --git a/lexlib/LexAccessor.h b/lexlib/LexAccessor.h index e11535bf7..658eb6e6d 100644 --- a/lexlib/LexAccessor.h +++ b/lexlib/LexAccessor.h @@ -77,7 +77,7 @@ public: } return buf[position - startPos]; } - IDocument *MultiByteAccess() const { + IDocument *MultiByteAccess() const noexcept { return pAccess; } /** Safe version of operator[], returning a defined value for invalid position. */ diff --git a/lexlib/LexerModule.cxx b/lexlib/LexerModule.cxx index 3d4010756..0f1498bf2 100644 --- a/lexlib/LexerModule.cxx +++ b/lexlib/LexerModule.cxx @@ -30,7 +30,7 @@ LexerModule::LexerModule(int language_, LexerFunction fnFolder_, const char *const wordListDescriptions_[], const LexicalClass *lexClasses_, - size_t nClasses_) : + size_t nClasses_) noexcept : language(language_), fnLexer(fnLexer_), fnFolder(fnFolder_), @@ -44,7 +44,7 @@ LexerModule::LexerModule(int language_, LexerModule::LexerModule(int language_, LexerFactoryFunction fnFactory_, const char *languageName_, - const char * const wordListDescriptions_[]) : + const char * const wordListDescriptions_[]) noexcept : language(language_), fnLexer(nullptr), fnFolder(nullptr), @@ -55,14 +55,11 @@ LexerModule::LexerModule(int language_, languageName(languageName_) { } -LexerModule::~LexerModule() { -} - -int LexerModule::GetLanguage() const { +int LexerModule::GetLanguage() const noexcept { return language; } -int LexerModule::GetNumWordLists() const { +int LexerModule::GetNumWordLists() const noexcept { if (!wordListDescriptions) { return -1; } else { @@ -76,7 +73,7 @@ int LexerModule::GetNumWordLists() const { } } -const char *LexerModule::GetWordListDescription(int index) const { +const char *LexerModule::GetWordListDescription(int index) const noexcept { assert(index < GetNumWordLists()); if (!wordListDescriptions || (index >= GetNumWordLists())) { return ""; @@ -85,11 +82,11 @@ const char *LexerModule::GetWordListDescription(int index) const { } } -const LexicalClass *LexerModule::LexClasses() const { +const LexicalClass *LexerModule::LexClasses() const noexcept { return lexClasses; } -size_t LexerModule::NamedStyles() const { +size_t LexerModule::NamedStyles() const noexcept { return nClasses; } diff --git a/lexlib/LexerModule.h b/lexlib/LexerModule.h index d3b378c9b..83bdf237d 100644 --- a/lexlib/LexerModule.h +++ b/lexlib/LexerModule.h @@ -43,32 +43,31 @@ public: LexerFunction fnFolder_= nullptr, const char * const wordListDescriptions_[]=nullptr, const LexicalClass *lexClasses_=nullptr, - size_t nClasses_=0); + size_t nClasses_=0) noexcept; LexerModule( int language_, LexerFactoryFunction fnFactory_, const char *languageName_, - const char * const wordListDescriptions_[]=nullptr); - virtual ~LexerModule(); - int GetLanguage() const; + const char * const wordListDescriptions_[]=nullptr) noexcept; + int GetLanguage() const noexcept; // -1 is returned if no WordList information is available - int GetNumWordLists() const; - const char *GetWordListDescription(int index) const; - const LexicalClass *LexClasses() const; - size_t NamedStyles() const; + int GetNumWordLists() const noexcept; + const char *GetWordListDescription(int index) const noexcept; + const LexicalClass *LexClasses() const noexcept; + size_t NamedStyles() const noexcept; ILexer5 *Create() const; - virtual void Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, + void Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, WordList *keywordlists[], Accessor &styler) const; - virtual void Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, + void Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, WordList *keywordlists[], Accessor &styler) const; friend class CatalogueModules; }; -inline int Maximum(int a, int b) { +inline int Maximum(int a, int b) noexcept { return (a > b) ? a : b; } diff --git a/lexlib/OptionSet.h b/lexlib/OptionSet.h index 918eaba4f..3c282e49b 100644 --- a/lexlib/OptionSet.h +++ b/lexlib/OptionSet.h @@ -68,7 +68,7 @@ class OptionSet { } return false; } - const char *Get() const { + const char *Get() const noexcept { return value.c_str(); } }; @@ -83,8 +83,6 @@ class OptionSet { names += name; } public: - virtual ~OptionSet() { - } void DefineProperty(const char *name, plcob pb, std::string description="") { nameToDef[name] = Option(pb, description); AppendName(name); @@ -97,7 +95,7 @@ public: nameToDef[name] = Option(ps, description); AppendName(name); } - const char *PropertyNames() const { + const char *PropertyNames() const noexcept { return names.c_str(); } int PropertyType(const char *name) { @@ -141,7 +139,7 @@ public: } } - const char *DescribeWordListSets() const { + const char *DescribeWordListSets() const noexcept { return wordLists.c_str(); } }; diff --git a/lexlib/PropSetSimple.cxx b/lexlib/PropSetSimple.cxx index 6e1312527..6ee57d667 100644 --- a/lexlib/PropSetSimple.cxx +++ b/lexlib/PropSetSimple.cxx @@ -21,10 +21,14 @@ namespace { typedef std::map<std::string, std::string> mapss; -mapss *PropsFromPointer(void *impl) { +mapss *PropsFromPointer(void *impl) noexcept { return static_cast<mapss *>(impl); } +constexpr bool IsASpaceCharacter(int ch) noexcept { + return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d)); +} + } PropSetSimple::PropSetSimple() { @@ -35,7 +39,7 @@ PropSetSimple::PropSetSimple() { PropSetSimple::~PropSetSimple() { mapss *props = PropsFromPointer(impl); delete props; - impl = 0; + impl = nullptr; } void PropSetSimple::Set(const char *key, const char *val, size_t lenKey, size_t lenVal) { @@ -45,10 +49,6 @@ void PropSetSimple::Set(const char *key, const char *val, size_t lenKey, size_t (*props)[std::string(key, lenKey)] = std::string(val, lenVal); } -static bool IsASpaceCharacter(unsigned int ch) { - return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d)); -} - void PropSetSimple::Set(const char *keyVal) { while (IsASpaceCharacter(*keyVal)) keyVal++; @@ -90,7 +90,7 @@ const char *PropSetSimple::Get(const char *key) const { // for that, through a recursive function and a simple chain of pointers. struct VarChain { - VarChain(const char *var_=nullptr, const VarChain *link_= nullptr): var(var_), link(link_) {} + VarChain(const char *var_=nullptr, const VarChain *link_= nullptr) noexcept : var(var_), link(link_) {} bool contains(const char *testVar) const { return (var && (0 == strcmp(var, testVar))) diff --git a/lexlib/SparseState.h b/lexlib/SparseState.h index 4e7ac92e3..6286c76af 100644 --- a/lexlib/SparseState.h +++ b/lexlib/SparseState.h @@ -17,12 +17,12 @@ class SparseState { struct State { Sci_Position position; T value; - State(Sci_Position position_, T value_) : position(position_), value(value_) { + constexpr State(Sci_Position position_, T value_) noexcept : position(position_), value(value_) { } - inline bool operator<(const State &other) const { + inline bool operator<(const State &other) const noexcept { return position < other.position; } - inline bool operator==(const State &other) const { + inline bool operator==(const State &other) const noexcept { return (position == other.position) && (value == other.value); } }; @@ -31,7 +31,7 @@ class SparseState { stateVector states; typename stateVector::iterator Find(Sci_Position position) { - State searchValue(position, T()); + const State searchValue(position, T()); return std::lower_bound(states.begin(), states.end(), searchValue); } diff --git a/lexlib/StyleContext.h b/lexlib/StyleContext.h index 6c617a098..c9ff4efbb 100644 --- a/lexlib/StyleContext.h +++ b/lexlib/StyleContext.h @@ -100,7 +100,7 @@ public: styler.ColourTo(currentPos - ((currentPos > lengthDocument) ? 2 : 1), state); styler.Flush(); } - bool More() const { + bool More() const noexcept { return currentPos < endPos; } void Forward() { @@ -139,7 +139,7 @@ public: } } } - void ChangeState(int state_) { + void ChangeState(int state_) noexcept { state = state_; } void SetState(int state_) { diff --git a/lexlib/SubStyles.h b/lexlib/SubStyles.h index f9bdfe65c..4bfe7ebfc 100644 --- a/lexlib/SubStyles.h +++ b/lexlib/SubStyles.h @@ -27,23 +27,23 @@ public: wordToStyle.clear(); } - int Base() const { + int Base() const noexcept { return baseStyle; } - int Start() const { + int Start() const noexcept { return firstStyle; } - int Last() const { + int Last() const noexcept { return firstStyle + lenStyles - 1; } - int Length() const { + int Length() const noexcept { return lenStyles; } - void Clear() { + void Clear() noexcept { firstStyle = 0; lenStyles = 0; wordToStyle.clear(); @@ -57,7 +57,7 @@ public: return -1; } - bool IncludesStyle(int style) const { + bool IncludesStyle(int style) const noexcept { return (style >= firstStyle) && (style < (firstStyle + lenStyles)); } @@ -98,7 +98,7 @@ class SubStyles { int allocated; std::vector<WordClassifier> classifiers; - int BlockFromBaseStyle(int baseStyle) const { + int BlockFromBaseStyle(int baseStyle) const noexcept { for (int b=0; b < classifications; b++) { if (baseStyle == baseStyles[b]) return b; @@ -145,12 +145,12 @@ public: } } - int Start(int styleBase) { + int Start(int styleBase) noexcept { const int block = BlockFromBaseStyle(styleBase); return (block >= 0) ? classifiers[block].Start() : -1; } - int Length(int styleBase) { + int Length(int styleBase) noexcept { const int block = BlockFromBaseStyle(styleBase); return (block >= 0) ? classifiers[block].Length() : 0; } @@ -163,7 +163,7 @@ public: return subStyle; } - int DistanceToSecondaryStyles() const { + int DistanceToSecondaryStyles() const noexcept { return secondaryDistance; } @@ -197,7 +197,7 @@ public: it->Clear(); } - const WordClassifier &Classifier(int baseStyle) const { + const WordClassifier &Classifier(int baseStyle) const noexcept { const int block = BlockFromBaseStyle(baseStyle); return classifiers[block >= 0 ? block : 0]; } diff --git a/lexlib/WordList.cxx b/lexlib/WordList.cxx index 937f18948..460995daa 100644 --- a/lexlib/WordList.cxx +++ b/lexlib/WordList.cxx @@ -70,11 +70,11 @@ WordList::~WordList() { Clear(); } -WordList::operator bool() const { +WordList::operator bool() const noexcept { return len ? true : false; } -bool WordList::operator!=(const WordList &other) const { +bool WordList::operator!=(const WordList &other) const noexcept { if (len != other.len) return true; for (int i=0; i<len; i++) { @@ -84,17 +84,17 @@ bool WordList::operator!=(const WordList &other) const { return false; } -int WordList::Length() const { +int WordList::Length() const noexcept { return len; } -void WordList::Clear() { +void WordList::Clear() noexcept { if (words) { delete []list; delete []words; } - words = 0; - list = 0; + words = nullptr; + list = nullptr; len = 0; } @@ -160,7 +160,7 @@ bool WordList::Set(const char *s) { * Prefix elements start with '^' and match all strings that start with the rest of the element * so '^GTK_' matches 'GTK_X', 'GTK_MAJOR_VERSION', and 'GTK_'. */ -bool WordList::InList(const char *s) const { +bool WordList::InList(const char *s) const noexcept { if (0 == words) return false; const unsigned char firstChar = s[0]; @@ -202,7 +202,7 @@ bool WordList::InList(const char *s) const { * with def to be a keyword, but also defi, defin and define are valid. * The marker is ~ in this case. */ -bool WordList::InListAbbreviated(const char *s, const char marker) const { +bool WordList::InListAbbreviated(const char *s, const char marker) const noexcept { if (0 == words) return false; const unsigned char firstChar = s[0]; @@ -256,7 +256,7 @@ bool WordList::InListAbbreviated(const char *s, const char marker) const { * The marker is ~ in this case. * No multiple markers check is done and wont work. */ -bool WordList::InListAbridged(const char *s, const char marker) const { +bool WordList::InListAbridged(const char *s, const char marker) const noexcept { if (0 == words) return false; const unsigned char firstChar = s[0]; @@ -309,7 +309,7 @@ bool WordList::InListAbridged(const char *s, const char marker) const { return false; } -const char *WordList::WordAt(int n) const { +const char *WordList::WordAt(int n) const noexcept { return words[n]; } diff --git a/lexlib/WordList.h b/lexlib/WordList.h index c1253cec6..127f00e68 100644 --- a/lexlib/WordList.h +++ b/lexlib/WordList.h @@ -22,15 +22,15 @@ class WordList { public: explicit WordList(bool onlyLineEnds_ = false); ~WordList(); - operator bool() const; - bool operator!=(const WordList &other) const; - int Length() const; - void Clear(); + operator bool() const noexcept; + bool operator!=(const WordList &other) const noexcept; + int Length() const noexcept; + void Clear() noexcept; bool Set(const char *s); - bool InList(const char *s) const; - bool InListAbbreviated(const char *s, const char marker) const; - bool InListAbridged(const char *s, const char marker) const; - const char *WordAt(int n) const; + bool InList(const char *s) const noexcept; + bool InListAbbreviated(const char *s, const char marker) const noexcept; + bool InListAbridged(const char *s, const char marker) const noexcept; + const char *WordAt(int n) const noexcept; }; } |