aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2017-04-07 19:44:59 +1000
committerNeil <nyamatongwe@gmail.com>2017-04-07 19:44:59 +1000
commit1595b1fbedf5587bc7c60cc7a1156ac1bca69f59 (patch)
tree351e4826ae9f0f2996ac82d8c0c89c428bcb30b2
parentd97e0e4187f3130e2f06bc032040bc25485a2ece (diff)
downloadscintilla-mirror-1595b1fbedf5587bc7c60cc7a1156ac1bca69f59.tar.gz
Prefer C++ static cast over C-style casts.
-rw-r--r--include/Platform.h2
-rw-r--r--lexers/LexCPP.cxx6
-rw-r--r--lexers/LexPython.cxx4
-rw-r--r--src/AutoComplete.cxx4
-rw-r--r--src/Indicator.cxx7
-rw-r--r--win32/PlatWin.cxx4
-rw-r--r--win32/ScintillaWin.cxx10
7 files changed, 19 insertions, 18 deletions
diff --git a/include/Platform.h b/include/Platform.h
index 411d42a03..570ba738b 100644
--- a/include/Platform.h
+++ b/include/Platform.h
@@ -78,7 +78,7 @@ namespace Scintilla {
typedef float XYPOSITION;
typedef double XYACCUMULATOR;
inline int RoundXYPosition(XYPOSITION xyPos) {
- return int(xyPos + 0.5);
+ return static_cast<int>(xyPos + 0.5);
}
// Underlying the implementation of the platform classes are platform specific types.
diff --git a/lexers/LexCPP.cxx b/lexers/LexCPP.cxx
index d08ed7eac..bd9977b81 100644
--- a/lexers/LexCPP.cxx
+++ b/lexers/LexCPP.cxx
@@ -54,7 +54,7 @@ bool IsSpaceEquiv(int state) {
// Putting a space between the '++' post-inc operator and the '+' binary op
// fixes this, and is highly recommended for readability anyway.
bool FollowsPostfixOperator(StyleContext &sc, LexAccessor &styler) {
- Sci_Position pos = (Sci_Position) sc.currentPos;
+ Sci_Position pos = static_cast<Sci_Position>(sc.currentPos);
while (--pos > 0) {
const char ch = styler[pos];
if (ch == '+' || ch == '-') {
@@ -66,7 +66,7 @@ bool FollowsPostfixOperator(StyleContext &sc, LexAccessor &styler) {
bool followsReturnKeyword(StyleContext &sc, LexAccessor &styler) {
// Don't look at styles, so no need to flush.
- Sci_Position pos = (Sci_Position) sc.currentPos;
+ Sci_Position pos = static_cast<Sci_Position>(sc.currentPos);
Sci_Position currentLine = styler.GetLine(pos);
const Sci_Position lineStartPos = styler.LineStart(currentLine);
while (--pos > lineStartPos) {
@@ -145,7 +145,7 @@ void highlightTaskMarker(StyleContext &sc, LexAccessor &styler,
if ((isoperator(sc.chPrev) || IsASpace(sc.chPrev)) && markerList.Length()) {
const int lengthMarker = 50;
char marker[lengthMarker+1];
- Sci_Position currPos = (Sci_Position) sc.currentPos;
+ Sci_Position currPos = static_cast<Sci_Position>(sc.currentPos);
int i = 0;
while (i < lengthMarker) {
const char ch = styler.SafeGetCharAt(currPos + i);
diff --git a/lexers/LexPython.cxx b/lexers/LexPython.cxx
index f80721e2a..328ed7363 100644
--- a/lexers/LexPython.cxx
+++ b/lexers/LexPython.cxx
@@ -435,7 +435,7 @@ void LexerPython::ProcessLineEnd(StyleContext &sc, std::vector<SingleFStringExpS
if (deepestSingleStateIndex != -1) {
sc.SetState(fstringStateStack[deepestSingleStateIndex].state);
- while (fstringStateStack.size() > (unsigned long)deepestSingleStateIndex) {
+ while (fstringStateStack.size() > static_cast<unsigned long>(deepestSingleStateIndex)) {
PopFromStateStack(fstringStateStack, currentFStringExp);
}
}
@@ -714,7 +714,7 @@ void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, in
sc.ForwardSetState(SCE_P_DEFAULT);
needEOLCheck = true;
- while (fstringStateStack.size() > (unsigned long)matching_stack_i) {
+ while (fstringStateStack.size() > static_cast<unsigned long>(matching_stack_i)) {
PopFromStateStack(fstringStateStack, currentFStringExp);
}
}
diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx
index 3de39bfcc..1cbc68c3a 100644
--- a/src/AutoComplete.cxx
+++ b/src/AutoComplete.cxx
@@ -156,7 +156,7 @@ void AutoComplete::SetList(const char *list) {
Sorter IndexSort(this, list);
sortMatrix.clear();
- for (int i = 0; i < (int)IndexSort.indices.size() / 2; ++i)
+ for (int i = 0; i < static_cast<int>(IndexSort.indices.size()) / 2; ++i)
sortMatrix.push_back(i);
std::sort(sortMatrix.begin(), sortMatrix.end(), IndexSort);
if (autoSort == SC_ORDER_CUSTOM || sortMatrix.size() < 2) {
@@ -186,7 +186,7 @@ void AutoComplete::SetList(const char *list) {
item[wordLen] = '\0';
sortedList += item;
}
- for (int i = 0; i < (int)sortMatrix.size(); ++i)
+ for (int i = 0; i < static_cast<int>(sortMatrix.size()); ++i)
sortMatrix[i] = i;
lb->SetList(sortedList.c_str(), separator, typesep);
}
diff --git a/src/Indicator.cxx b/src/Indicator.cxx
index 4a2d43895..18ae0f2c8 100644
--- a/src/Indicator.cxx
+++ b/src/Indicator.cxx
@@ -21,7 +21,8 @@ using namespace Scintilla;
static PRectangle PixelGridAlign(const PRectangle &rc) {
// Move left and right side to nearest pixel to avoid blurry visuals
- return PRectangle::FromInts(int(rc.left + 0.5), int(rc.top), int(rc.right + 0.5), int(rc.bottom));
+ return PRectangle::FromInts(static_cast<int>(rc.left + 0.5), static_cast<int>(rc.top),
+ static_cast<int>(rc.right + 0.5), static_cast<int>(rc.bottom));
}
void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, const PRectangle &rcCharacter, DrawState drawState, int value) const {
@@ -35,8 +36,8 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
surface->PenColour(sacDraw.fore);
int ymid = static_cast<int>(rc.bottom + rc.top) / 2;
if (sacDraw.style == INDIC_SQUIGGLE) {
- int x = int(rc.left+0.5);
- const int xLast = int(rc.right+0.5);
+ int x = static_cast<int>(rc.left+0.5);
+ const int xLast = static_cast<int>(rc.right+0.5);
int y = 0;
surface->MoveTo(x, static_cast<int>(rc.top) + y);
while (x < xLast) {
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 1b0f65518..ec89479ab 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -1292,7 +1292,7 @@ static int Delta(int difference) {
}
static float RoundFloat(float f) {
- return float(int(f+0.5f));
+ return static_cast<float>(static_cast<int>(f+0.5f));
}
void SurfaceD2D::LineTo(int x_, int y_) {
@@ -1899,7 +1899,7 @@ static HCURSOR GetReverseArrowCursor() {
FlipBitmap(info.hbmMask, bmp.bmWidth, bmp.bmHeight);
if (info.hbmColor != NULL)
FlipBitmap(info.hbmColor, bmp.bmWidth, bmp.bmHeight);
- info.xHotspot = (DWORD)bmp.bmWidth - 1 - info.xHotspot;
+ info.xHotspot = static_cast<DWORD>(bmp.bmWidth) - 1 - info.xHotspot;
reverseArrowCursor = ::CreateIconIndirect(&info);
if (reverseArrowCursor != NULL)
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 5d159ca31..fdcfbda53 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -2689,11 +2689,11 @@ LRESULT ScintillaWin::ImeOnReconvert(LPARAM lParam) {
const int rcFeedLen = static_cast<int>(rcFeed.length()) * sizeof(wchar_t);
const int rcSize = sizeof(RECONVERTSTRING) + rcFeedLen + sizeof(wchar_t);
- RECONVERTSTRING *rc = (RECONVERTSTRING *)lParam;
+ RECONVERTSTRING *rc = reinterpret_cast<RECONVERTSTRING *>(lParam);
if (!rc)
return rcSize; // Immediately be back with rcSize of memory block.
- wchar_t *rcFeedStart = (wchar_t*)(rc + 1);
+ wchar_t *rcFeedStart = reinterpret_cast<wchar_t*>(rc + 1);
memcpy(rcFeedStart, &rcFeed[0], rcFeedLen);
std::string rcCompString = RangeText(mainStart, mainEnd);
@@ -2704,10 +2704,10 @@ LRESULT ScintillaWin::ImeOnReconvert(LPARAM lParam) {
// Map selection to dwCompStr.
// No selection assumes current caret as rcCompString without length.
rc->dwVersion = 0; // It should be absolutely 0.
- rc->dwStrLen = (DWORD)static_cast<int>(rcFeed.length());
+ rc->dwStrLen = static_cast<DWORD>(rcFeed.length());
rc->dwStrOffset = sizeof(RECONVERTSTRING);
- rc->dwCompStrLen = (DWORD)static_cast<int>(rcCompWstring.length());
- rc->dwCompStrOffset = (DWORD)static_cast<int>(rcCompWstart.length()) * sizeof(wchar_t);
+ rc->dwCompStrLen = static_cast<DWORD>(rcCompWstring.length());
+ rc->dwCompStrOffset = static_cast<DWORD>(rcCompWstart.length()) * sizeof(wchar_t);
rc->dwTargetStrLen = rc->dwCompStrLen;
rc->dwTargetStrOffset =rc->dwCompStrOffset;