From 44da106995e3b3ca4068f584c16f59d8fced4e69 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Fri, 24 May 2013 00:04:54 +1000 Subject: Made methods const where they can be and are logically const as well. --- lexlib/Accessor.cxx | 2 +- lexlib/Accessor.h | 2 +- lexlib/LexAccessor.h | 12 ++++++------ lexlib/OptionSet.h | 6 +++--- lexlib/StyleContext.h | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'lexlib') diff --git a/lexlib/Accessor.cxx b/lexlib/Accessor.cxx index 65609598f..f67737d4d 100644 --- a/lexlib/Accessor.cxx +++ b/lexlib/Accessor.cxx @@ -28,7 +28,7 @@ using namespace Scintilla; Accessor::Accessor(IDocument *pAccess_, PropSetSimple *pprops_) : LexAccessor(pAccess_), pprops(pprops_) { } -int Accessor::GetPropertyInt(const char *key, int defaultValue) { +int Accessor::GetPropertyInt(const char *key, int defaultValue) const { return pprops->GetInt(key, defaultValue); } diff --git a/lexlib/Accessor.h b/lexlib/Accessor.h index 2f28c1acd..9789f2b4a 100644 --- a/lexlib/Accessor.h +++ b/lexlib/Accessor.h @@ -24,7 +24,7 @@ class Accessor : public LexAccessor { public: PropSetSimple *pprops; Accessor(IDocument *pAccess_, PropSetSimple *pprops_); - int GetPropertyInt(const char *, int defaultValue=0); + int GetPropertyInt(const char *, int defaultValue=0) const; int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0); }; diff --git a/lexlib/LexAccessor.h b/lexlib/LexAccessor.h index 59ae11346..4223f302d 100644 --- a/lexlib/LexAccessor.h +++ b/lexlib/LexAccessor.h @@ -90,7 +90,7 @@ public: } return buf[position - startPos]; } - bool IsLeadByte(char ch) { + bool IsLeadByte(char ch) const { return pAccess->IsDBCSLeadByte(ch); } EncodingType Encoding() const { @@ -104,13 +104,13 @@ public: } return true; } - char StyleAt(int position) { + char StyleAt(int position) const { return static_cast(pAccess->StyleAt(position) & mask); } - int GetLine(int position) { + int GetLine(int position) const { return pAccess->LineFromPosition(position); } - int LineStart(int line) { + int LineStart(int line) const { return pAccess->LineStart(line); } int LineEnd(int line) { @@ -126,7 +126,7 @@ public: return startNext - 1; } } - int LevelAt(int line) { + int LevelAt(int line) const { return pAccess->GetLevel(line); } int Length() const { @@ -140,7 +140,7 @@ public: validLen = 0; } } - int GetLineState(int line) { + int GetLineState(int line) const { return pAccess->GetLineState(line); } int SetLineState(int line, int state) { diff --git a/lexlib/OptionSet.h b/lexlib/OptionSet.h index 873ac8b6c..2935a2089 100644 --- a/lexlib/OptionSet.h +++ b/lexlib/OptionSet.h @@ -40,7 +40,7 @@ class OptionSet { Option(plcos ps_, std::string description_) : opType(SC_TYPE_STRING), ps(ps_), description(description_) { } - bool Set(T *base, const char *val) { + bool Set(T *base, const char *val) const { switch (opType) { case SC_TYPE_BOOLEAN: { bool option = atoi(val) != 0; @@ -94,7 +94,7 @@ public: nameToDef[name] = Option(ps, description); AppendName(name); } - const char *PropertyNames() { + const char *PropertyNames() const { return names.c_str(); } int PropertyType(const char *name) { @@ -130,7 +130,7 @@ public: } } - const char *DescribeWordListSets() { + const char *DescribeWordListSets() const { return wordLists.c_str(); } }; diff --git a/lexlib/StyleContext.h b/lexlib/StyleContext.h index c79d42e37..319f51088 100644 --- a/lexlib/StyleContext.h +++ b/lexlib/StyleContext.h @@ -188,7 +188,7 @@ public: styler.ColourTo(currentPos - ((currentPos > lengthDocument) ? 2 : 1), state); state = state_; } - int LengthCurrent() { + int LengthCurrent() const { return currentPos - styler.GetStartSegment(); } int GetRelative(int n) { -- cgit v1.2.3