From 33754798947fc772d69e125e52e6247356456a2d Mon Sep 17 00:00:00 2001 From: fxliang Date: Thu, 9 May 2024 17:32:10 +0800 Subject: [PATCH] chore: fix warnings in project WeaselTSF --- WeaselTSF/CandidateList.cpp | 6 +++--- WeaselTSF/Composition.cpp | 8 ++++---- WeaselTSF/KeyEventSink.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/WeaselTSF/CandidateList.cpp b/WeaselTSF/CandidateList.cpp index f9f4c5cd3..66c40be82 100644 --- a/WeaselTSF/CandidateList.cpp +++ b/WeaselTSF/CandidateList.cpp @@ -108,7 +108,7 @@ STDMETHODIMP CCandidateList::GetDocumentMgr(ITfDocumentMgr** ppdim) { } STDMETHODIMP CCandidateList::GetCount(UINT* pCandidateCount) { - *pCandidateCount = _ui->ctx().cinfo.candies.size(); + *pCandidateCount = static_cast(_ui->ctx().cinfo.candies.size()); return S_OK; } @@ -124,7 +124,7 @@ STDMETHODIMP CCandidateList::GetString(UINT uIndex, BSTR* pbstr) { return E_INVALIDARG; auto& str = cinfo.candies[uIndex].str; - *pbstr = SysAllocStringLen(str.c_str(), str.size() + 1); + *pbstr = SysAllocStringLen(str.c_str(), static_cast(str.size()) + 1); return S_OK; } @@ -399,7 +399,7 @@ void WeaselTSF::_HandleMousePageEvent(bool* const nextPage, int offset = *scrollNextPage ? 1 : -1; offset = offset * (is_reposition ? -1 : 1); int index = (int)current_select + offset; - if (index >= 0 && index < cand_count) + if (index >= 0 && index < (int)cand_count) m_client.HighlightCandidateOnCurrentPage((size_t)index); else { KeyEvent ke{0, 0}; diff --git a/WeaselTSF/Composition.cpp b/WeaselTSF/Composition.cpp index 35ad5b1e9..728a05d18 100644 --- a/WeaselTSF/Composition.cpp +++ b/WeaselTSF/Composition.cpp @@ -162,7 +162,6 @@ STDAPI CGetTextExtentEditSession::DoEditSession(TfEditCookie ec) { BOOL fClipped; TF_SELECTION selection; ULONG nSelection; - LONG cch; if (FAILED(_pContext->QueryInterface(IID_ITfInsertAtSelection, (LPVOID*)&pInsertAtSelection))) @@ -271,8 +270,8 @@ STDAPI CInlinePreeditEditSession::DoEditSession(TfEditCookie ec) { if ((_pComposition->GetRange(&pRangeComposition)) != S_OK) return E_FAIL; - if ((pRangeComposition->SetText(ec, 0, preedit.c_str(), preedit.length())) != - S_OK) + if ((pRangeComposition->SetText(ec, 0, preedit.c_str(), + static_cast(preedit.length()))) != S_OK) return E_FAIL; /* TODO: Check the availability and correctness of these values */ @@ -347,7 +346,8 @@ STDMETHODIMP CInsertTextEditSession::DoEditSession(TfEditCookie ec) { if (FAILED(_pComposition->GetRange(&pRange))) return E_FAIL; - if (FAILED(pRange->SetText(ec, 0, _text.c_str(), _text.length()))) + if (FAILED(pRange->SetText(ec, 0, _text.c_str(), + static_cast(_text.length())))) return E_FAIL; /* update the selection to an insertion point just past the inserted text. */ diff --git a/WeaselTSF/KeyEventSink.cpp b/WeaselTSF/KeyEventSink.cpp index ef1f4c591..b84ff73ce 100644 --- a/WeaselTSF/KeyEventSink.cpp +++ b/WeaselTSF/KeyEventSink.cpp @@ -11,7 +11,7 @@ void WeaselTSF::_ProcessKeyEvent(WPARAM wParam, LPARAM lParam, BOOL* pfEaten) { _EnsureServerConnected(); weasel::KeyEvent ke; GetKeyboardState(_lpbKeyState); - if (!ConvertKeyEvent(wParam, lParam, _lpbKeyState, ke)) { + if (!ConvertKeyEvent(static_cast(wParam), lParam, _lpbKeyState, ke)) { /* Unknown key event */ *pfEaten = FALSE; } else {