diff options
| author | Neil <nyamatongwe@gmail.com> | 2020-06-11 10:08:29 +1000 |
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2020-06-11 10:08:29 +1000 |
| commit | 877def4f243e1ef5eb39a6132f3969844e00be95 (patch) | |
| tree | 5041a5f52f7d38c026d594f53d3fabc813205221 | |
| parent | c8136baf0e923ea16cb5e75d75539ca61129925a (diff) | |
| download | scintilla-mirror-877def4f243e1ef5eb39a6132f3969844e00be95.tar.gz | |
Backport: Use noexcept where safe and maintainable.
Backport of changeset 8300:266c8247814e.
| -rw-r--r-- | src/Catalogue.cxx | 2 | ||||
| -rw-r--r-- | src/Catalogue.h | 2 | ||||
| -rw-r--r-- | src/CellBuffer.cxx | 2 | ||||
| -rw-r--r-- | src/CellBuffer.h | 2 | ||||
| -rw-r--r-- | src/CharClassify.cxx | 2 | ||||
| -rw-r--r-- | src/CharClassify.h | 2 | ||||
| -rw-r--r-- | src/ContractionState.cxx | 52 | ||||
| -rw-r--r-- | src/ContractionState.h | 24 | ||||
| -rw-r--r-- | src/Decoration.cxx | 4 | ||||
| -rw-r--r-- | src/Decoration.h | 4 | ||||
| -rw-r--r-- | src/Document.h | 2 | ||||
| -rw-r--r-- | src/EditModel.cxx | 2 | ||||
| -rw-r--r-- | src/EditModel.h | 2 | ||||
| -rw-r--r-- | src/EditView.cxx | 6 | ||||
| -rw-r--r-- | src/EditView.h | 6 | ||||
| -rw-r--r-- | src/ElapsedPeriod.h | 2 | ||||
| -rw-r--r-- | src/MarginView.cxx | 2 | ||||
| -rw-r--r-- | src/PositionCache.cxx | 24 | ||||
| -rw-r--r-- | src/PositionCache.h | 23 | ||||
| -rw-r--r-- | src/Selection.cxx | 24 | ||||
| -rw-r--r-- | src/Selection.h | 24 | ||||
| -rw-r--r-- | src/UniConversion.cxx | 2 | ||||
| -rw-r--r-- | src/UniConversion.h | 2 | ||||
| -rw-r--r-- | src/ViewStyle.cxx | 10 | ||||
| -rw-r--r-- | src/ViewStyle.h | 10 |
25 files changed, 119 insertions, 118 deletions
diff --git a/src/Catalogue.cxx b/src/Catalogue.cxx index 90dd8fa20..572d32526 100644 --- a/src/Catalogue.cxx +++ b/src/Catalogue.cxx @@ -34,7 +34,7 @@ const LexerModule *Catalogue::Find(int language) { return catalogueDefault.Find(language); } -const LexerModule *Catalogue::Find(const char *languageName) { +const LexerModule *Catalogue::Find(const char *languageName) noexcept { return catalogueDefault.Find(languageName); } diff --git a/src/Catalogue.h b/src/Catalogue.h index d8769a896..05a1f1d29 100644 --- a/src/Catalogue.h +++ b/src/Catalogue.h @@ -15,7 +15,7 @@ namespace Scintilla { class Catalogue { public: static const LexerModule *Find(int language); - static const LexerModule *Find(const char *languageName); + static const LexerModule *Find(const char *languageName) noexcept; static void AddLexerModule(LexerModule *plm); }; diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index cbc19f539..661502d33 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -666,7 +666,7 @@ bool CellBuffer::SetStyleAt(Sci::Position position, char styleValue) noexcept { } } -bool CellBuffer::SetStyleFor(Sci::Position position, Sci::Position lengthStyle, char styleValue) { +bool CellBuffer::SetStyleFor(Sci::Position position, Sci::Position lengthStyle, char styleValue) noexcept { if (!hasStyles) { return false; } diff --git a/src/CellBuffer.h b/src/CellBuffer.h index 3e16bcdc8..599b6062f 100644 --- a/src/CellBuffer.h +++ b/src/CellBuffer.h @@ -173,7 +173,7 @@ public: /// Setting styles for positions outside the range of the buffer is safe and has no effect. /// @return true if the style of a character is changed. bool SetStyleAt(Sci::Position position, char styleValue) noexcept; - bool SetStyleFor(Sci::Position position, Sci::Position lengthStyle, char styleValue); + bool SetStyleFor(Sci::Position position, Sci::Position lengthStyle, char styleValue) noexcept; const char *DeleteChars(Sci::Position position, Sci::Position deleteLength, bool &startSequence); diff --git a/src/CharClassify.cxx b/src/CharClassify.cxx index eb40a89c2..b5e2870f3 100644 --- a/src/CharClassify.cxx +++ b/src/CharClassify.cxx @@ -43,7 +43,7 @@ void CharClassify::SetCharClasses(const unsigned char *chars, cc newCharClass) { } } -int CharClassify::GetCharsOfClass(cc characterClass, unsigned char *buffer) const { +int CharClassify::GetCharsOfClass(cc characterClass, unsigned char *buffer) const noexcept { // Get characters belonging to the given char class; return the number // of characters (if the buffer is NULL, don't write to it). int count = 0; diff --git a/src/CharClassify.h b/src/CharClassify.h index 1381a1b34..36cc34558 100644 --- a/src/CharClassify.h +++ b/src/CharClassify.h @@ -17,7 +17,7 @@ public: enum cc { ccSpace, ccNewLine, ccWord, ccPunctuation }; void SetDefaultCharClasses(bool includeWordClass); void SetCharClasses(const unsigned char *chars, cc newCharClass); - int GetCharsOfClass(cc characterClass, unsigned char *buffer) const; + int GetCharsOfClass(cc characterClass, unsigned char *buffer) const noexcept; cc GetClass(unsigned char ch) const noexcept { return static_cast<cc>(charClass[ch]);} bool IsWord(unsigned char ch) const noexcept { return static_cast<cc>(charClass[ch]) == ccWord;} diff --git a/src/ContractionState.cxx b/src/ContractionState.cxx index 8d2427629..8897f3d95 100644 --- a/src/ContractionState.cxx +++ b/src/ContractionState.cxx @@ -60,32 +60,32 @@ public: void Clear() noexcept override; - Sci::Line LinesInDoc() const override; - Sci::Line LinesDisplayed() const override; - Sci::Line DisplayFromDoc(Sci::Line lineDoc) const override; - Sci::Line DisplayLastFromDoc(Sci::Line lineDoc) const override; - Sci::Line DocFromDisplay(Sci::Line lineDisplay) const override; + Sci::Line LinesInDoc() const noexcept override; + Sci::Line LinesDisplayed() const noexcept override; + Sci::Line DisplayFromDoc(Sci::Line lineDoc) const noexcept override; + Sci::Line DisplayLastFromDoc(Sci::Line lineDoc) const noexcept override; + Sci::Line DocFromDisplay(Sci::Line lineDisplay) const noexcept override; void InsertLines(Sci::Line lineDoc, Sci::Line lineCount) override; void DeleteLines(Sci::Line lineDoc, Sci::Line lineCount) override; - bool GetVisible(Sci::Line lineDoc) const override; + bool GetVisible(Sci::Line lineDoc) const noexcept override; bool SetVisible(Sci::Line lineDocStart, Sci::Line lineDocEnd, bool isVisible) override; - bool HiddenLines() const override; + bool HiddenLines() const noexcept override; - const char *GetFoldDisplayText(Sci::Line lineDoc) const override; + const char *GetFoldDisplayText(Sci::Line lineDoc) const noexcept override; bool SetFoldDisplayText(Sci::Line lineDoc, const char *text) override; - bool GetExpanded(Sci::Line lineDoc) const override; + bool GetExpanded(Sci::Line lineDoc) const noexcept override; bool SetExpanded(Sci::Line lineDoc, bool isExpanded) override; - Sci::Line ContractedNext(Sci::Line lineDocStart) const override; + Sci::Line ContractedNext(Sci::Line lineDocStart) const noexcept override; - int GetHeight(Sci::Line lineDoc) const override; + int GetHeight(Sci::Line lineDoc) const noexcept override; bool SetHeight(Sci::Line lineDoc, int height) override; - void ShowAll() override; + void ShowAll() noexcept override; - void Check() const; + void Check() const noexcept; }; template <typename LINE> @@ -157,7 +157,7 @@ void ContractionState<LINE>::Clear() noexcept { } template <typename LINE> -Sci::Line ContractionState<LINE>::LinesInDoc() const { +Sci::Line ContractionState<LINE>::LinesInDoc() const noexcept { if (OneToOne()) { return linesInDocument; } else { @@ -166,7 +166,7 @@ Sci::Line ContractionState<LINE>::LinesInDoc() const { } template <typename LINE> -Sci::Line ContractionState<LINE>::LinesDisplayed() const { +Sci::Line ContractionState<LINE>::LinesDisplayed() const noexcept { if (OneToOne()) { return linesInDocument; } else { @@ -175,7 +175,7 @@ Sci::Line ContractionState<LINE>::LinesDisplayed() const { } template <typename LINE> -Sci::Line ContractionState<LINE>::DisplayFromDoc(Sci::Line lineDoc) const { +Sci::Line ContractionState<LINE>::DisplayFromDoc(Sci::Line lineDoc) const noexcept { if (OneToOne()) { return (lineDoc <= linesInDocument) ? lineDoc : linesInDocument; } else { @@ -186,12 +186,12 @@ Sci::Line ContractionState<LINE>::DisplayFromDoc(Sci::Line lineDoc) const { } template <typename LINE> -Sci::Line ContractionState<LINE>::DisplayLastFromDoc(Sci::Line lineDoc) const { +Sci::Line ContractionState<LINE>::DisplayLastFromDoc(Sci::Line lineDoc) const noexcept { return DisplayFromDoc(lineDoc) + GetHeight(lineDoc) - 1; } template <typename LINE> -Sci::Line ContractionState<LINE>::DocFromDisplay(Sci::Line lineDisplay) const { +Sci::Line ContractionState<LINE>::DocFromDisplay(Sci::Line lineDisplay) const noexcept { if (OneToOne()) { return lineDisplay; } else { @@ -232,7 +232,7 @@ void ContractionState<LINE>::DeleteLines(Sci::Line lineDoc, Sci::Line lineCount) } template <typename LINE> -bool ContractionState<LINE>::GetVisible(Sci::Line lineDoc) const { +bool ContractionState<LINE>::GetVisible(Sci::Line lineDoc) const noexcept { if (OneToOne()) { return true; } else { @@ -269,7 +269,7 @@ bool ContractionState<LINE>::SetVisible(Sci::Line lineDocStart, Sci::Line lineDo } template <typename LINE> -bool ContractionState<LINE>::HiddenLines() const { +bool ContractionState<LINE>::HiddenLines() const noexcept { if (OneToOne()) { return false; } else { @@ -278,7 +278,7 @@ bool ContractionState<LINE>::HiddenLines() const { } template <typename LINE> -const char *ContractionState<LINE>::GetFoldDisplayText(Sci::Line lineDoc) const { +const char *ContractionState<LINE>::GetFoldDisplayText(Sci::Line lineDoc) const noexcept { Check(); return foldDisplayTexts->ValueAt(lineDoc).get(); } @@ -299,7 +299,7 @@ bool ContractionState<LINE>::SetFoldDisplayText(Sci::Line lineDoc, const char *t } template <typename LINE> -bool ContractionState<LINE>::GetExpanded(Sci::Line lineDoc) const { +bool ContractionState<LINE>::GetExpanded(Sci::Line lineDoc) const noexcept { if (OneToOne()) { return true; } else { @@ -326,7 +326,7 @@ bool ContractionState<LINE>::SetExpanded(Sci::Line lineDoc, bool isExpanded) { } template <typename LINE> -Sci::Line ContractionState<LINE>::ContractedNext(Sci::Line lineDocStart) const { +Sci::Line ContractionState<LINE>::ContractedNext(Sci::Line lineDocStart) const noexcept { if (OneToOne()) { return -1; } else { @@ -344,7 +344,7 @@ Sci::Line ContractionState<LINE>::ContractedNext(Sci::Line lineDocStart) const { } template <typename LINE> -int ContractionState<LINE>::GetHeight(Sci::Line lineDoc) const { +int ContractionState<LINE>::GetHeight(Sci::Line lineDoc) const noexcept { if (OneToOne()) { return 1; } else { @@ -377,7 +377,7 @@ bool ContractionState<LINE>::SetHeight(Sci::Line lineDoc, int height) { } template <typename LINE> -void ContractionState<LINE>::ShowAll() { +void ContractionState<LINE>::ShowAll() noexcept { const LINE lines = static_cast<LINE>(LinesInDoc()); Clear(); linesInDocument = lines; @@ -386,7 +386,7 @@ void ContractionState<LINE>::ShowAll() { // Debugging checks template <typename LINE> -void ContractionState<LINE>::Check() const { +void ContractionState<LINE>::Check() const noexcept { #ifdef CHECK_CORRECTNESS for (Sci::Line vline = 0; vline < LinesDisplayed(); vline++) { const Sci::Line lineDoc = DocFromDisplay(vline); diff --git a/src/ContractionState.h b/src/ContractionState.h index f9ec7b645..b30d071b4 100644 --- a/src/ContractionState.h +++ b/src/ContractionState.h @@ -18,30 +18,30 @@ public: virtual void Clear()=0; - virtual Sci::Line LinesInDoc() const=0; - virtual Sci::Line LinesDisplayed() const=0; - virtual Sci::Line DisplayFromDoc(Sci::Line lineDoc) const=0; - virtual Sci::Line DisplayLastFromDoc(Sci::Line lineDoc) const=0; - virtual Sci::Line DocFromDisplay(Sci::Line lineDisplay) const=0; + virtual Sci::Line LinesInDoc() const noexcept=0; + virtual Sci::Line LinesDisplayed() const noexcept=0; + virtual Sci::Line DisplayFromDoc(Sci::Line lineDoc) const noexcept=0; + virtual Sci::Line DisplayLastFromDoc(Sci::Line lineDoc) const noexcept=0; + virtual Sci::Line DocFromDisplay(Sci::Line lineDisplay) const noexcept=0; virtual void InsertLines(Sci::Line lineDoc, Sci::Line lineCount)=0; virtual void DeleteLines(Sci::Line lineDoc, Sci::Line lineCount)=0; - virtual bool GetVisible(Sci::Line lineDoc) const=0; + virtual bool GetVisible(Sci::Line lineDoc) const noexcept=0; virtual bool SetVisible(Sci::Line lineDocStart, Sci::Line lineDocEnd, bool isVisible)=0; - virtual bool HiddenLines() const=0; + virtual bool HiddenLines() const noexcept=0; - virtual const char *GetFoldDisplayText(Sci::Line lineDoc) const=0; + virtual const char *GetFoldDisplayText(Sci::Line lineDoc) const noexcept=0; virtual bool SetFoldDisplayText(Sci::Line lineDoc, const char *text)=0; - virtual bool GetExpanded(Sci::Line lineDoc) const=0; + virtual bool GetExpanded(Sci::Line lineDoc) const noexcept=0; virtual bool SetExpanded(Sci::Line lineDoc, bool isExpanded)=0; - virtual Sci::Line ContractedNext(Sci::Line lineDocStart) const=0; + virtual Sci::Line ContractedNext(Sci::Line lineDocStart) const noexcept =0; - virtual int GetHeight(Sci::Line lineDoc) const=0; + virtual int GetHeight(Sci::Line lineDoc) const noexcept=0; virtual bool SetHeight(Sci::Line lineDoc, int height)=0; - virtual void ShowAll()=0; + virtual void ShowAll() noexcept=0; }; std::unique_ptr<IContractionState> ContractionStateCreate(bool largeDocument); diff --git a/src/Decoration.cxx b/src/Decoration.cxx index 94ec25463..4bfff2d01 100644 --- a/src/Decoration.cxx +++ b/src/Decoration.cxx @@ -112,10 +112,10 @@ public: Sci::Position Start(int indicator, Sci::Position position) noexcept override; Sci::Position End(int indicator, Sci::Position position) noexcept override; - bool ClickNotified() const override { + bool ClickNotified() const noexcept override { return clickNotified; } - void SetClickNotified(bool notified) override { + void SetClickNotified(bool notified) noexcept override { clickNotified = notified; } }; diff --git a/src/Decoration.h b/src/Decoration.h index 923b0ce15..bab8e2500 100644 --- a/src/Decoration.h +++ b/src/Decoration.h @@ -46,8 +46,8 @@ public: virtual Sci::Position Start(int indicator, Sci::Position position) noexcept = 0; virtual Sci::Position End(int indicator, Sci::Position position) noexcept = 0; - virtual bool ClickNotified() const = 0; - virtual void SetClickNotified(bool notified) = 0; + virtual bool ClickNotified() const noexcept = 0; + virtual void SetClickNotified(bool notified) noexcept = 0; }; std::unique_ptr<IDecoration> DecorationCreate(bool largeDocument, int indicator); diff --git a/src/Document.h b/src/Document.h index 87582a26e..f56bf01eb 100644 --- a/src/Document.h +++ b/src/Document.h @@ -366,7 +366,7 @@ public: bool TentativeActive() const noexcept { return cb.TentativeActive(); } const char * SCI_METHOD BufferPointer() override { return cb.BufferPointer(); } - const char *RangePointer(Sci::Position position, Sci::Position rangeLength) { return cb.RangePointer(position, rangeLength); } + const char *RangePointer(Sci::Position position, Sci::Position rangeLength) noexcept { return cb.RangePointer(position, rangeLength); } Sci::Position GapPosition() const noexcept { return cb.GapPosition(); } int SCI_METHOD GetLineIndentation(Sci_Position line) override; diff --git a/src/EditModel.cxx b/src/EditModel.cxx index e55ddeb51..f43ae2aed 100644 --- a/src/EditModel.cxx +++ b/src/EditModel.cxx @@ -86,7 +86,7 @@ const char *EditModel::GetDefaultFoldDisplayText() const noexcept { return defaultFoldDisplayText.get(); } -const char *EditModel::GetFoldDisplayText(Sci::Line lineDoc) const { +const char *EditModel::GetFoldDisplayText(Sci::Line lineDoc) const noexcept { if (foldDisplayTextStyle == SC_FOLDDISPLAYTEXT_HIDDEN || pcs->GetExpanded(lineDoc)) { return nullptr; } diff --git a/src/EditModel.h b/src/EditModel.h index 2c3200881..cb6ea2839 100644 --- a/src/EditModel.h +++ b/src/EditModel.h @@ -65,7 +65,7 @@ public: virtual Range GetHotSpotRange() const noexcept = 0; void SetDefaultFoldDisplayText(const char *text); const char *GetDefaultFoldDisplayText() const noexcept; - const char *GetFoldDisplayText(Sci::Line lineDoc) const; + const char *GetFoldDisplayText(Sci::Line lineDoc) const noexcept; }; } diff --git a/src/EditView.cxx b/src/EditView.cxx index edb1e0a05..b3c577177 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -213,14 +213,14 @@ void EditView::ClearAllTabstops() noexcept { ldTabstops.reset(); } -XYPOSITION EditView::NextTabstopPos(Sci::Line line, XYPOSITION x, XYPOSITION tabWidth) const { +XYPOSITION EditView::NextTabstopPos(Sci::Line line, XYPOSITION x, XYPOSITION tabWidth) const noexcept { const int next = GetNextTabstop(line, static_cast<int>(x + tabWidthMinimumPixels)); if (next > 0) return static_cast<XYPOSITION>(next); return (static_cast<int>((x + tabWidthMinimumPixels) / tabWidth) + 1) * tabWidth; } -bool EditView::ClearTabstops(Sci::Line line) { +bool EditView::ClearTabstops(Sci::Line line) noexcept { return ldTabstops && ldTabstops->ClearTabstops(line); } @@ -231,7 +231,7 @@ bool EditView::AddTabstop(Sci::Line line, int x) { return ldTabstops && ldTabstops->AddTabstop(line, x); } -int EditView::GetNextTabstop(Sci::Line line, int x) const { +int EditView::GetNextTabstop(Sci::Line line, int x) const noexcept { if (ldTabstops) { return ldTabstops->GetNextTabstop(line, x); } else { diff --git a/src/EditView.h b/src/EditView.h index 2a2ca84d3..5f2950dc5 100644 --- a/src/EditView.h +++ b/src/EditView.h @@ -102,10 +102,10 @@ public: bool LinesOverlap() const noexcept; void ClearAllTabstops() noexcept; - XYPOSITION NextTabstopPos(Sci::Line line, XYPOSITION x, XYPOSITION tabWidth) const; - bool ClearTabstops(Sci::Line line); + XYPOSITION NextTabstopPos(Sci::Line line, XYPOSITION x, XYPOSITION tabWidth) const noexcept; + bool ClearTabstops(Sci::Line line) noexcept; bool AddTabstop(Sci::Line line, int x); - int GetNextTabstop(Sci::Line line, int x) const; + int GetNextTabstop(Sci::Line line, int x) const noexcept; void LinesAddedOrRemoved(Sci::Line lineOfPos, Sci::Line linesAdded); void DropGraphics(bool freeObjects); diff --git a/src/ElapsedPeriod.h b/src/ElapsedPeriod.h index 6f8cdabdf..e083c0dda 100644 --- a/src/ElapsedPeriod.h +++ b/src/ElapsedPeriod.h @@ -18,7 +18,7 @@ public: ElapsedPeriod() noexcept : tp(std::chrono::high_resolution_clock::now()) { } /// Return duration as floating point seconds - double Duration(bool reset=false) { + double Duration(bool reset=false) noexcept { const std::chrono::high_resolution_clock::time_point tpNow = std::chrono::high_resolution_clock::now(); const std::chrono::duration<double> stylingDuration = diff --git a/src/MarginView.cxx b/src/MarginView.cxx index e6f73c52a..9752371e1 100644 --- a/src/MarginView.cxx +++ b/src/MarginView.cxx @@ -171,7 +171,7 @@ void MarginView::RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const View } } -static int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault, const ViewStyle &vs) { +static int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault, const ViewStyle &vs) noexcept { if (vs.markers[markerCheck].markType == SC_MARK_EMPTY) return markerDefault; return markerCheck; diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 5a6d8dac0..5b9c2ddd4 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -90,12 +90,12 @@ void LineLayout::Free() noexcept { lineStarts.reset(); } -void LineLayout::Invalidate(validLevel validity_) { +void LineLayout::Invalidate(validLevel validity_) noexcept { if (validity > validity_) validity = validity_; } -int LineLayout::LineStart(int line) const { +int LineLayout::LineStart(int line) const noexcept { if (line <= 0) { return 0; } else if ((line >= lines) || !lineStarts) { @@ -105,7 +105,7 @@ int LineLayout::LineStart(int line) const { } } -int LineLayout::LineLastVisible(int line, Scope scope) const { +int LineLayout::LineLastVisible(int line, Scope scope) const noexcept { if (line < 0) { return 0; } else if ((line >= lines-1) || !lineStarts) { @@ -115,11 +115,11 @@ int LineLayout::LineLastVisible(int line, Scope scope) const { } } -Range LineLayout::SubLineRange(int subLine, Scope scope) const { +Range LineLayout::SubLineRange(int subLine, Scope scope) const noexcept { return Range(LineStart(subLine), LineLastVisible(subLine, scope)); } -bool LineLayout::InLine(int offset, int line) const { +bool LineLayout::InLine(int offset, int line) const noexcept { return ((offset >= LineStart(line)) && (offset < LineStart(line + 1))) || ((offset == numCharsInLine) && (line == (lines-1))); } @@ -178,7 +178,7 @@ void LineLayout::RestoreBracesHighlight(Range rangeLine, const Sci::Position bra xHighlightGuide = 0; } -int LineLayout::FindBefore(XYPOSITION x, Range range) const { +int LineLayout::FindBefore(XYPOSITION x, Range range) const noexcept { Sci::Position lower = range.start; Sci::Position upper = range.end; do { @@ -194,7 +194,7 @@ int LineLayout::FindBefore(XYPOSITION x, Range range) const { } -int LineLayout::FindPositionFromX(XYPOSITION x, Range range, bool charPosition) const { +int LineLayout::FindPositionFromX(XYPOSITION x, Range range, bool charPosition) const noexcept { int pos = FindBefore(x, range); while (pos < range.end) { if (charPosition) { @@ -211,7 +211,7 @@ int LineLayout::FindPositionFromX(XYPOSITION x, Range range, bool charPosition) return static_cast<int>(range.end); } -Point LineLayout::PointFromPosition(int posInLine, int lineHeight, PointEnd pe) const { +Point LineLayout::PointFromPosition(int posInLine, int lineHeight, PointEnd pe) const noexcept { Point pt; // In case of very long line put x at arbitrary large position if (posInLine > maxLineLength) { @@ -240,7 +240,7 @@ Point LineLayout::PointFromPosition(int posInLine, int lineHeight, PointEnd pe) return pt; } -int LineLayout::EndLineStyle() const { +int LineLayout::EndLineStyle() const noexcept { return styles[numCharsBeforeEOL > 0 ? numCharsBeforeEOL-1 : 0]; } @@ -289,7 +289,7 @@ void LineLayoutCache::Deallocate() noexcept { cache.clear(); } -void LineLayoutCache::Invalidate(LineLayout::validLevel validity_) { +void LineLayoutCache::Invalidate(LineLayout::validLevel validity_) noexcept { if (!cache.empty() && !allInvalidated) { for (const std::unique_ptr<LineLayout> &ll : cache) { if (ll) { @@ -370,7 +370,7 @@ void LineLayoutCache::Dispose(LineLayout *ll) noexcept { } // Simply pack the (maximum 4) character bytes into an int -static unsigned int KeyFromString(const char *charBytes, size_t len) { +static unsigned int KeyFromString(const char *charBytes, size_t len) noexcept { PLATFORM_ASSERT(len <= 4); unsigned int k=0; for (size_t i=0; i<len && charBytes[i]; i++) { @@ -602,7 +602,7 @@ void PositionCacheEntry::Clear() noexcept { } bool PositionCacheEntry::Retrieve(unsigned int styleNumber_, const char *s_, - unsigned int len_, XYPOSITION *positions_) const { + unsigned int len_, XYPOSITION *positions_) const noexcept { if ((styleNumber == styleNumber_) && (len == len_) && (memcmp(&positions[len], s_, len)== 0)) { for (unsigned int i=0; i<len; i++) { diff --git a/src/PositionCache.h b/src/PositionCache.h index 6edaddf8b..9ff3e1239 100644 --- a/src/PositionCache.h +++ b/src/PositionCache.h @@ -87,20 +87,21 @@ public: virtual ~LineLayout(); void Resize(int maxLineLength_); void Free() noexcept; - void Invalidate(validLevel validity_); - int LineStart(int line) const; + void Invalidate(validLevel validity_) noexcept; + int LineStart(int line) const noexcept; + int LineLength(int line) const noexcept; enum class Scope { visibleOnly, includeEnd }; - int LineLastVisible(int line, Scope scope) const; - Range SubLineRange(int subLine, Scope scope) const; - bool InLine(int offset, int line) const; + int LineLastVisible(int line, Scope scope) const noexcept; + Range SubLineRange(int subLine, Scope scope) const noexcept; + bool InLine(int offset, int line) const noexcept; void SetLineStart(int line, int start); void SetBracesHighlight(Range rangeLine, const Sci::Position braces[], char bracesMatchStyle, int xHighlight, bool ignoreStyle); void RestoreBracesHighlight(Range rangeLine, const Sci::Position braces[], bool ignoreStyle); - int FindBefore(XYPOSITION x, Range range) const; - int FindPositionFromX(XYPOSITION x, Range range, bool charPosition) const; - Point PointFromPosition(int posInLine, int lineHeight, PointEnd pe) const; - int EndLineStyle() const; + int FindBefore(XYPOSITION x, Range range) const noexcept; + int FindPositionFromX(XYPOSITION x, Range range, bool charPosition) const noexcept; + Point PointFromPosition(int posInLine, int lineHeight, PointEnd pe) const noexcept; + int EndLineStyle() const noexcept; }; /** @@ -128,7 +129,7 @@ public: llcPage=SC_CACHE_PAGE, llcDocument=SC_CACHE_DOCUMENT }; - void Invalidate(LineLayout::validLevel validity_); + void Invalidate(LineLayout::validLevel validity_) noexcept; void SetLevel(int level_) noexcept; int GetLevel() const noexcept { return level; } LineLayout *Retrieve(Sci::Line lineNumber, Sci::Line lineCaret, int maxChars, int styleClock_, @@ -152,7 +153,7 @@ public: ~PositionCacheEntry(); void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, const XYPOSITION *positions_, unsigned int clock_); void Clear() noexcept; - bool Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_) const; + bool Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_) const noexcept; static unsigned int Hash(unsigned int styleNumber_, const char *s, unsigned int len_) noexcept; bool NewerThan(const PositionCacheEntry &other) const noexcept; void ResetClock() noexcept; diff --git a/src/Selection.cxx b/src/Selection.cxx index fbdd375c6..95caf74b1 100644 --- a/src/Selection.cxx +++ b/src/Selection.cxx @@ -201,11 +201,11 @@ bool Selection::IsRectangular() const noexcept { return (selType == selRectangle) || (selType == selThin); } -Sci::Position Selection::MainCaret() const { +Sci::Position Selection::MainCaret() const noexcept { return ranges[mainRange].caret.Position(); } -Sci::Position Selection::MainAnchor() const { +Sci::Position Selection::MainAnchor() const noexcept { return ranges[mainRange].anchor.Position(); } @@ -213,7 +213,7 @@ SelectionRange &Selection::Rectangular() noexcept { return rangeRectangular; } -SelectionSegment Selection::Limits() const { +SelectionSegment Selection::Limits() const noexcept { if (ranges.empty()) { return SelectionSegment(); } else { @@ -247,23 +247,23 @@ void Selection::SetMain(size_t r) noexcept { mainRange = r; } -SelectionRange &Selection::Range(size_t r) { +SelectionRange &Selection::Range(size_t r) noexcept { return ranges[r]; } -const SelectionRange &Selection::Range(size_t r) const { +const SelectionRange &Selection::Range(size_t r) const noexcept { return ranges[r]; } -SelectionRange &Selection::RangeMain() { +SelectionRange &Selection::RangeMain() noexcept { return ranges[mainRange]; } -const SelectionRange &Selection::RangeMain() const { +const SelectionRange &Selection::RangeMain() const noexcept { return ranges[mainRange]; } -SelectionPosition Selection::Start() const { +SelectionPosition Selection::Start() const noexcept { if (IsRectangular()) { return rangeRectangular.Start(); } else { @@ -315,7 +315,7 @@ void Selection::MovePositions(bool insertion, Sci::Position startChange, Sci::Po } } -void Selection::TrimSelection(SelectionRange range) { +void Selection::TrimSelection(SelectionRange range) noexcept { for (size_t i=0; i<ranges.size();) { if ((i != mainRange) && (ranges[i].Trim(range))) { // Trimmed to empty so remove @@ -331,7 +331,7 @@ void Selection::TrimSelection(SelectionRange range) { } } -void Selection::TrimOtherSelections(size_t r, SelectionRange range) { +void Selection::TrimOtherSelections(size_t r, SelectionRange range) noexcept { for (size_t i = 0; i<ranges.size(); ++i) { if (i != r) { ranges[i].Trim(range); @@ -390,7 +390,7 @@ void Selection::CommitTentative() noexcept { tentativeMain = false; } -int Selection::CharacterInSelection(Sci::Position posCharacter) const { +int Selection::CharacterInSelection(Sci::Position posCharacter) const noexcept { for (size_t i=0; i<ranges.size(); i++) { if (ranges[i].ContainsCharacter(posCharacter)) return i == mainRange ? 1 : 2; @@ -398,7 +398,7 @@ int Selection::CharacterInSelection(Sci::Position posCharacter) const { return 0; } -int Selection::InSelectionForEOL(Sci::Position pos) const { +int Selection::InSelectionForEOL(Sci::Position pos) const noexcept { for (size_t i=0; i<ranges.size(); i++) { if (!ranges[i].Empty() && (pos > ranges[i].Start().Position()) && (pos <= ranges[i].End().Position())) return i == mainRange ? 1 : 2; diff --git a/src/Selection.h b/src/Selection.h index 741b75277..c5c7993cf 100644 --- a/src/Selection.h +++ b/src/Selection.h @@ -147,10 +147,10 @@ public: Selection(); ~Selection(); bool IsRectangular() const noexcept; - Sci::Position MainCaret() const; - Sci::Position MainAnchor() const; + Sci::Position MainCaret() const noexcept; + Sci::Position MainAnchor() const noexcept; SelectionRange &Rectangular() noexcept; - SelectionSegment Limits() const; + SelectionSegment Limits() const noexcept; // This is for when you want to move the caret in response to a // user direction command - for rectangular selections, use the range // that covers all selected text otherwise return the main selection. @@ -158,19 +158,19 @@ public: size_t Count() const noexcept; size_t Main() const noexcept; void SetMain(size_t r) noexcept; - SelectionRange &Range(size_t r); - const SelectionRange &Range(size_t r) const; - SelectionRange &RangeMain(); - const SelectionRange &RangeMain() const; - SelectionPosition Start() const; + SelectionRange &Range(size_t r) noexcept; + const SelectionRange &Range(size_t r) const noexcept; + SelectionRange &RangeMain() noexcept; + const SelectionRange &RangeMain() const noexcept; + SelectionPosition Start() const noexcept; bool MoveExtends() const noexcept; void SetMoveExtends(bool moveExtends_) noexcept; bool Empty() const noexcept; SelectionPosition Last() const noexcept; Sci::Position Length() const noexcept; void MovePositions(bool insertion, Sci::Position startChange, Sci::Position length) noexcept; - void TrimSelection(SelectionRange range); - void TrimOtherSelections(size_t r, SelectionRange range); + void TrimSelection(SelectionRange range) noexcept; + void TrimOtherSelections(size_t r, SelectionRange range) noexcept; void SetSelection(SelectionRange range); void AddSelection(SelectionRange range); void AddSelectionWithoutTrim(SelectionRange range); @@ -178,8 +178,8 @@ public: void DropAdditionalRanges(); void TentativeSelection(SelectionRange range); void CommitTentative() noexcept; - int CharacterInSelection(Sci::Position posCharacter) const; - int InSelectionForEOL(Sci::Position pos) const; + int CharacterInSelection(Sci::Position posCharacter) const noexcept; + int InSelectionForEOL(Sci::Position pos) const noexcept; Sci::Position VirtualSpaceFor(Sci::Position pos) const noexcept; void Clear(); void RemoveDuplicates(); diff --git a/src/UniConversion.cxx b/src/UniConversion.cxx index 5b75ca63c..508c33a2c 100644 --- a/src/UniConversion.cxx +++ b/src/UniConversion.cxx @@ -36,7 +36,7 @@ size_t UTF8Length(const wchar_t *uptr, size_t tlen) noexcept { return len; } -void UTF8FromUTF16(const wchar_t *uptr, size_t tlen, char *putf, size_t len) { +void UTF8FromUTF16(const wchar_t *uptr, size_t tlen, char *putf, size_t len) noexcept { size_t k = 0; for (size_t i = 0; i < tlen && uptr[i];) { const unsigned int uch = uptr[i]; diff --git a/src/UniConversion.h b/src/UniConversion.h index 0c7adff10..871f2c7b0 100644 --- a/src/UniConversion.h +++ b/src/UniConversion.h @@ -15,7 +15,7 @@ constexpr int UTF8MaxBytes = 4; constexpr int unicodeReplacementChar = 0xFFFD; size_t UTF8Length(const wchar_t *uptr, size_t tlen) noexcept; -void UTF8FromUTF16(const wchar_t *uptr, size_t tlen, char *putf, size_t len); +void UTF8FromUTF16(const wchar_t *uptr, size_t tlen, char *putf, size_t len) noexcept; void UTF8FromUTF32Character(int uch, char *putf) noexcept; size_t UTF16Length(const char *s, size_t len) noexcept; size_t UTF16FromUTF8(const char *s, size_t len, wchar_t *tbuf, size_t tlen); diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 8be2bdf6a..5b8a226f3 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -153,7 +153,7 @@ ViewStyle::~ViewStyle() { fonts.clear(); } -void ViewStyle::CalculateMarginWidthAndMask() { +void ViewStyle::CalculateMarginWidthAndMask() noexcept { fixedColumnWidth = marginInside ? leftMarginWidth : 0; maskInLine = 0xffffffff; int maskDefinedMarkers = 0; @@ -400,7 +400,7 @@ int ViewStyle::ExternalMarginWidth() const noexcept { return marginInside ? 0 : fixedColumnWidth; } -int ViewStyle::MarginFromLocation(Point pt) const { +int ViewStyle::MarginFromLocation(Point pt) const noexcept { int margin = -1; int x = marginInside ? 0 : -fixedColumnWidth; for (size_t i = 0; i < ms.size(); i++) { @@ -415,7 +415,7 @@ bool ViewStyle::ValidStyle(size_t styleIndex) const noexcept { return styleIndex < styles.size(); } -void ViewStyle::CalcLargestMarkerHeight() { +void ViewStyle::CalcLargestMarkerHeight() noexcept { largestMarkerHeight = 0; for (const LineMarker &marker : markers) { switch (marker.markType) { @@ -446,7 +446,7 @@ bool ViewStyle::IsLineFrameOpaque(bool caretActive, bool lineContainsCaret) cons // display itself (as long as it's not an SC_MARK_EMPTY marker). These are checked in order // with the earlier taking precedence. When multiple markers cause background override, // the colour for the highest numbered one is used. -ColourOptional ViewStyle::Background(int marksOfLine, bool caretActive, bool lineContainsCaret) const { +ColourOptional ViewStyle::Background(int marksOfLine, bool caretActive, bool lineContainsCaret) const noexcept { ColourOptional background; if (!caretLineFrame && (caretActive || alwaysShowCaretLineBackground) && showCaretLineBackground && (caretLineAlpha == SC_ALPHA_NOALPHA) && lineContainsCaret) { @@ -492,7 +492,7 @@ bool ViewStyle::WhiteSpaceVisible(bool inIndent) const noexcept { viewWhitespace == wsVisibleAlways; } -ColourDesired ViewStyle::WrapColour() const { +ColourDesired ViewStyle::WrapColour() const noexcept { if (whitespaceColours.fore.isSet) return whitespaceColours.fore; else diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 7f6853f13..33ea1d6c2 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -170,7 +170,7 @@ public: ViewStyle &operator=(const ViewStyle &) = delete; ViewStyle &operator=(ViewStyle &&) = delete; ~ViewStyle(); - void CalculateMarginWidthAndMask(); + void CalculateMarginWidthAndMask() noexcept; void Init(size_t stylesSize_=256); void Refresh(Surface &surface, int tabInChars); void ReleaseAllExtendedStyles() noexcept; @@ -181,15 +181,15 @@ public: void SetStyleFontName(int styleIndex, const char *name); bool ProtectionActive() const noexcept; int ExternalMarginWidth() const noexcept; - int MarginFromLocation(Point pt) const; + int MarginFromLocation(Point pt) const noexcept; bool ValidStyle(size_t styleIndex) const noexcept; - void CalcLargestMarkerHeight(); + void CalcLargestMarkerHeight() noexcept; int GetFrameWidth() const noexcept; bool IsLineFrameOpaque(bool caretActive, bool lineContainsCaret) const noexcept; - ColourOptional Background(int marksOfLine, bool caretActive, bool lineContainsCaret) const; + ColourOptional Background(int marksOfLine, bool caretActive, bool lineContainsCaret) const noexcept; bool SelectionBackgroundDrawn() const noexcept; bool WhitespaceBackgroundDrawn() const noexcept; - ColourDesired WrapColour() const; + ColourDesired WrapColour() const noexcept; bool SetWrapState(int wrapState_) noexcept; bool SetWrapVisualFlags(int wrapVisualFlags_) noexcept; |
