From 2ed48ef81e612403f8af51374e1e705989a60e0f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 13 May 2012 21:37:23 +0000 Subject: [PATCH] No changes, just simplify the code using wx2stc() a little. Assign wx2stc() return value to a suitably const variable instead of using ugly casts to get rid of constness. Also use wxCharBuffer/char* explicitly inside explicit wxUSE_UNICODE checks, using wxWX2MBbuf here doesn't gain us anything and just confuses the reader of this code. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71429 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/stc/private.h | 4 ++-- src/stc/PlatWX.cpp | 2 +- src/stc/stc.cpp | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/wx/stc/private.h b/include/wx/stc/private.h index 6a57cb9adb..34143aca3c 100644 --- a/include/wx/stc/private.h +++ b/include/wx/stc/private.h @@ -21,7 +21,7 @@ extern wxString stc2wx(const char* str); extern wxString stc2wx(const char* str, size_t len); -extern const wxWX2MBbuf wx2stc(const wxString& str); +extern wxCharBuffer wx2stc(const wxString& str); // This function takes both wxString and wxCharBuffer because it uses either // one or the other of them depending on the build mode. In Unicode it uses the @@ -40,7 +40,7 @@ inline wxString stc2wx(const char* str) { inline wxString stc2wx(const char* str, size_t len) { return wxString(str, len); } -inline const wxWX2MBbuf wx2stc(const wxString& str) { +inline const char* wx2stc(const wxString& str) { return str.mbc_str(); } diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index f2c6302917..917e4ea467 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -1583,7 +1583,7 @@ wxString stc2wx(const char* str) } -const wxWX2MBbuf wx2stc(const wxString& str) +wxWX2MBbuf wx2stc(const wxString& str) { const wchar_t* wcstr = str.c_str(); size_t wclen = str.length(); diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index e55e329d6f..cc580a1ff3 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -258,7 +258,7 @@ void wxStyledTextCtrl::SetHScrollBar(wxScrollBar* bar) { // Add text to the document at current position. void wxStyledTextCtrl::AddText(const wxString& text) { - wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); + const wxWX2MBbuf buf = wx2stc(text); SendMsg(2001, wx2stclen(text, buf), (sptr_t)(const char*)buf); } @@ -1410,7 +1410,7 @@ int wxStyledTextCtrl::FindText(int minPos, int maxPos, TextToFind ft; ft.chrg.cpMin = minPos; ft.chrg.cpMax = maxPos; - wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); + const wxWX2MBbuf buf = wx2stc(text); ft.lpstrText = (char*)(const char*)buf; return SendMsg(2150, flags, (sptr_t)&ft); @@ -1708,7 +1708,7 @@ int wxStyledTextCtrl::GetTargetEnd() const // Returns the length of the replacement text. int wxStyledTextCtrl::ReplaceTarget(const wxString& text) { - wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); + const wxWX2MBbuf buf = wx2stc(text); return SendMsg(2194, wx2stclen(text, buf), (sptr_t)(const char*)buf); } @@ -1720,7 +1720,7 @@ int wxStyledTextCtrl::GetTargetEnd() const // caused by processing the \d patterns. int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) { - wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); + const wxWX2MBbuf buf = wx2stc(text); return SendMsg(2195, wx2stclen(text, buf), (sptr_t)(const char*)buf); } @@ -1729,7 +1729,7 @@ int wxStyledTextCtrl::GetTargetEnd() const // Returns length of range or -1 for failure in which case target is not moved. int wxStyledTextCtrl::SearchInTarget(const wxString& text) { - wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); + const wxWX2MBbuf buf = wx2stc(text); return SendMsg(2197, wx2stclen(text, buf), (sptr_t)(const char*)buf); } @@ -2085,7 +2085,7 @@ bool wxStyledTextCtrl::GetUseVerticalScrollBar() const // Append a string to the end of the document without changing the selection. void wxStyledTextCtrl::AppendText(const wxString& text) { - wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); + const wxWX2MBbuf buf = wx2stc(text); SendMsg(2282, wx2stclen(text, buf), (sptr_t)(const char*)buf); }