Add std:: prefix to Windows build
BUG=#392
TEST=unittest
REF_BUG=71969651
REF_CL=185083237
REF_TIME=2018-02-09T11:17:12+09:00
REF_TIME_RAW=1518142632 +0900
Hiroyuki Komatsu
6 years ago
29 | 29 | |
30 | 30 | MAJOR=2 |
31 | 31 | MINOR=23 |
32 | BUILD=2803 | |
32 | BUILD=2804 | |
33 | 33 | REVISION=102 |
34 | 34 | # This version represents the version of Mozc IME engine (converter, predictor, |
35 | 35 | # etc.). This version info is included both in the Mozc server and in the Mozc |
83 | 83 | // characters. |
84 | 84 | // If the cache service is not installed, default settings is returned |
85 | 85 | // with setting |installed| flag to false. |
86 | static bool BackupStateAsString(wstring *buffer); | |
86 | static bool BackupStateAsString(std::wstring *buffer); | |
87 | 87 | |
88 | 88 | // Return true if the previous status of the service is successfully |
89 | 89 | // restored from the specified std::wstring instance. |
201 | 201 | const bool show_suggest_window = |
202 | 202 | ui_visibility_tracker.IsSuggestWindowVisible(); |
203 | 203 | |
204 | std::vector<wstring> candidate_list; | |
204 | std::vector<std::wstring> candidate_list; | |
205 | 205 | DWORD focused_index = 0; |
206 | 206 | if (!context.IsEmpty() && context.GetOpenStatus()) { |
207 | 207 | // Copy the last output. |
349 | 349 | |
350 | 350 | virtual ULONG AddRef() { |
351 | 351 | const LONG count = ::InterlockedIncrement(&reference_count_); |
352 | return static_cast<ULONG>(max(count, static_cast<LONG>(0))); | |
352 | return static_cast<ULONG>(std::max(count, static_cast<LONG>(0))); | |
353 | 353 | } |
354 | 354 | |
355 | 355 | virtual ULONG Release() { |
118 | 118 | |
119 | 119 | class EnumTfCandidatesImpl : public IEnumTfCandidates { |
120 | 120 | public: |
121 | explicit EnumTfCandidatesImpl(const std::vector<wstring> &candidates) | |
121 | explicit EnumTfCandidatesImpl(const std::vector<std::wstring> &candidates) | |
122 | 122 | : candidates_(candidates), |
123 | 123 | current_(0) { |
124 | 124 | } |
209 | 209 | |
210 | 210 | TipRefCount ref_count_; |
211 | 211 | |
212 | std::vector<wstring> candidates_; | |
212 | std::vector<std::wstring> candidates_; | |
213 | 213 | size_t current_; |
214 | 214 | |
215 | 215 | DISALLOW_COPY_AND_ASSIGN(EnumTfCandidatesImpl); |
217 | 217 | |
218 | 218 | class CandidateListImpl : public ITfCandidateList { |
219 | 219 | public: |
220 | CandidateListImpl(const std::vector<wstring> &candidates, | |
220 | CandidateListImpl(const std::vector<std::wstring> &candidates, | |
221 | 221 | TipCandidateListCallback *callback) |
222 | 222 | : candidates_(candidates), |
223 | 223 | callback_(callback) { |
305 | 305 | } |
306 | 306 | |
307 | 307 | TipRefCount ref_count_; |
308 | std::vector<wstring> candidates_; | |
308 | std::vector<std::wstring> candidates_; | |
309 | 309 | unique_ptr<TipCandidateListCallback> callback_; |
310 | 310 | |
311 | 311 | DISALLOW_COPY_AND_ASSIGN(CandidateListImpl); |
317 | 317 | } |
318 | 318 | |
319 | 319 | // static |
320 | ITfCandidateList *TipCandidateList::New(const std::vector<wstring> &candidates, | |
321 | TipCandidateListCallback *callback) { | |
320 | ITfCandidateList *TipCandidateList::New( | |
321 | const std::vector<std::wstring> &candidates, | |
322 | TipCandidateListCallback *callback) { | |
322 | 323 | return new CandidateListImpl(candidates, callback); |
323 | 324 | } |
324 | 325 |
59 | 59 | // is called with CAND_FINALIZED. TipCandidateList will take the |
60 | 60 | // ownership of |callback|. |callback| can be nullptr. |
61 | 61 | // Caller must maintain the reference count of the returned object. |
62 | static ITfCandidateList *New(const std::vector<wstring> &candidates, | |
62 | static ITfCandidateList *New(const std::vector<std::wstring> &candidates, | |
63 | 63 | TipCandidateListCallback *callback); |
64 | 64 | static const IID& GetIID(); |
65 | 65 |
159 | 159 | TEST(TipCandidateListTest, EmptyCandiate) { |
160 | 160 | MockCallbackResult result; |
161 | 161 | |
162 | std::vector<wstring> empty; | |
162 | std::vector<std::wstring> empty; | |
163 | 163 | CComPtr<ITfCandidateList> candidate_list( |
164 | 164 | TipCandidateList::New(empty, new MockCallback(&result))); |
165 | 165 | ASSERT_NE(nullptr, candidate_list); |
193 | 193 | TEST(TipCandidateListTest, NonEmptyCandiates) { |
194 | 194 | MockCallbackResult result; |
195 | 195 | |
196 | std::vector<wstring> source; | |
196 | std::vector<std::wstring> source; | |
197 | 197 | for (wchar_t c = L'A'; c < L'Z'; ++c) { |
198 | 198 | source.push_back(std::wstring(c, 1)); |
199 | 199 | } |
130 | 130 | if (!TipEditSession::GetTextSync(text_service_, range, &query)) { |
131 | 131 | return E_FAIL; |
132 | 132 | } |
133 | std::vector<wstring> candidates; | |
133 | std::vector<std::wstring> candidates; | |
134 | 134 | if (!provider_->Query(query, TipQueryProvider::kDefault, &candidates)) { |
135 | 135 | return E_FAIL; |
136 | 136 | } |
60 | 60 | // The TipQueryProvider interface methods. |
61 | 61 | virtual bool Query(const std::wstring &query, |
62 | 62 | QueryType type, |
63 | std::vector<wstring> *result) { | |
63 | std::vector<std::wstring> *result) { | |
64 | 64 | if (type == kReconversion) { |
65 | 65 | return ReconvertQuery(query, result); |
66 | 66 | } |
68 | 68 | } |
69 | 69 | |
70 | 70 | bool SimpleQuery(const std::wstring &query, |
71 | std::vector<wstring> *result) { | |
71 | std::vector<std::wstring> *result) { | |
72 | 72 | { |
73 | 73 | KeyEvent key_event; |
74 | 74 | string utf8_query; |
103 | 103 | } |
104 | 104 | |
105 | 105 | bool ReconvertQuery(const std::wstring &query, |
106 | std::vector<wstring> *result) { | |
106 | std::vector<std::wstring> *result) { | |
107 | 107 | { |
108 | 108 | string utf8_query; |
109 | 109 | Util::WideToUTF8(query, &utf8_query); |
53 | 53 | }; |
54 | 54 | virtual bool Query(const std::wstring &query, |
55 | 55 | QueryType type, |
56 | std::vector<wstring> *result) = 0; | |
56 | std::vector<std::wstring> *result) = 0; | |
57 | 57 | }; |
58 | 58 | |
59 | 59 | } // namespace tsf |
247 | 247 | // This is why we should carefully choose parameters passed to |
248 | 248 | // ITfContextView::GetRangeFromPoint here. |
249 | 249 | const POINT dummy_point = { |
250 | numeric_limits<LONG>::min(), numeric_limits<LONG>::min() | |
250 | std::numeric_limits<LONG>::min(), std::numeric_limits<LONG>::min() | |
251 | 251 | }; |
252 | 252 | CComPtr<ITfRange> dummy_range; |
253 | 253 | const HRESULT next_hr = context_view->GetRangeFromPoint( |
199 | 199 | if (!TipEditSession::GetTextSync(text_service_, range, &query)) { |
200 | 200 | return E_FAIL; |
201 | 201 | } |
202 | std::vector<wstring> candidates; | |
202 | std::vector<std::wstring> candidates; | |
203 | 203 | if (!provider->Query(query, |
204 | 204 | TipQueryProvider::kReconversion, |
205 | 205 | &candidates)) { |
118 | 118 | if (candidate_list == nullptr) { |
119 | 119 | return E_INVALIDARG; |
120 | 120 | } |
121 | std::vector<wstring> candidates; | |
121 | std::vector<std::wstring> candidates; | |
122 | 122 | if (!provider_->Query(query, TipQueryProvider::kDefault, &candidates)) { |
123 | 123 | return E_FAIL; |
124 | 124 | } |
1238 | 1238 | return; |
1239 | 1239 | } |
1240 | 1240 | // Transfer the ownership. |
1241 | unique_ptr<TipPrivateContext> private_context(it->second); | |
1241 | std::unique_ptr<TipPrivateContext> private_context(it->second); | |
1242 | 1242 | private_context_map_.erase(it); |
1243 | 1243 | if (private_context.get() == nullptr) { |
1244 | 1244 | return; |
1794 | 1794 | CComPtrHash<ITfContext>>; |
1795 | 1795 | PrivateContextMap private_context_map_; |
1796 | 1796 | PreservedKeyMap preserved_key_map_; |
1797 | unique_ptr<TipThreadContext> thread_context_; | |
1797 | std::unique_ptr<TipThreadContext> thread_context_; | |
1798 | 1798 | HWND task_window_handle_; |
1799 | 1799 | HWND renderer_callback_window_handle_; |
1800 | 1800 |
122 | 122 | void CalcLayout(const Candidates &candidates, |
123 | 123 | const TextRenderer &text_renderer, |
124 | 124 | TableLayout *table_layout, |
125 | std::vector<wstring> *candidate_strings) { | |
125 | std::vector<std::wstring> *candidate_strings) { | |
126 | 126 | table_layout->Initialize(candidates.candidate_size(), NUMBER_OF_COLUMNS); |
127 | 127 | |
128 | 128 | table_layout->SetWindowBorder(kWindowBorder); |
179 | 179 | CBitmapHandle RenderImpl(const Candidates &candidates, |
180 | 180 | const TableLayout &table_layout, |
181 | 181 | const TextRenderer &text_renderer, |
182 | const std::vector<wstring> &candidate_strings) { | |
182 | const std::vector<std::wstring> &candidate_strings) { | |
183 | 183 | const int width = table_layout.GetTotalSize().width; |
184 | 184 | const int height = table_layout.GetTotalSize().height; |
185 | 185 | |
273 | 273 | const renderer::win32::TextRenderer *text_renderer, |
274 | 274 | renderer::TableLayout *table_layout, |
275 | 275 | SIZE *size, int *left_align_offset) { |
276 | std::vector<wstring> candidate_strings; | |
276 | std::vector<std::wstring> candidate_strings; | |
277 | 277 | CalcLayout(candidates, *text_renderer, table_layout, &candidate_strings); |
278 | 278 | |
279 | 279 | const Size &total_size = table_layout->GetTotalSize(); |