1 |
commit: cf8c637056d4c4ef0853e469361d252438a54cb6 |
2 |
Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org> |
3 |
AuthorDate: Sun May 5 02:19:04 2019 +0000 |
4 |
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun May 5 19:04:01 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cf8c6370 |
7 |
|
8 |
app-i18n/mozc: Fix building with dev-libs/protobuf future version. |
9 |
|
10 |
Fixes: https://bugs.gentoo.org/681702 |
11 |
Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache.Org> |
12 |
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org> |
13 |
|
14 |
...protobuf_generated_classes_no_inheritance.patch | 1039 ++++++++++++++++++++ |
15 |
app-i18n/mozc/mozc-2.23.2815.102.ebuild | 1 + |
16 |
app-i18n/mozc/mozc-9999.ebuild | 1 + |
17 |
3 files changed, 1041 insertions(+) |
18 |
|
19 |
diff --git a/app-i18n/mozc/files/mozc-2.23.2815.102-protobuf_generated_classes_no_inheritance.patch b/app-i18n/mozc/files/mozc-2.23.2815.102-protobuf_generated_classes_no_inheritance.patch |
20 |
new file mode 100644 |
21 |
index 00000000000..2cd75728154 |
22 |
--- /dev/null |
23 |
+++ b/app-i18n/mozc/files/mozc-2.23.2815.102-protobuf_generated_classes_no_inheritance.patch |
24 |
@@ -0,0 +1,1039 @@ |
25 |
+https://github.com/google/mozc/issues/460 |
26 |
+ |
27 |
+--- /src/dictionary/user_dictionary.cc |
28 |
++++ /src/dictionary/user_dictionary.cc |
29 |
+@@ -289,7 +289,7 @@ |
30 |
+ } |
31 |
+ |
32 |
+ auto_register_mode_ = false; |
33 |
+- dic_->Load(*(storage.get())); |
34 |
++ dic_->Load(storage.get()->user_dictionary_storage_base); |
35 |
+ } |
36 |
+ |
37 |
+ private: |
38 |
+--- /src/dictionary/user_dictionary_session.cc |
39 |
++++ /src/dictionary/user_dictionary_session.cc |
40 |
+@@ -69,11 +69,11 @@ |
41 |
+ } |
42 |
+ |
43 |
+ virtual bool RunUndo(mozc::UserDictionaryStorage *storage) { |
44 |
+- if (storage->dictionaries_size() == 0) { |
45 |
++ if (storage->user_dictionary_storage_base.dictionaries_size() == 0) { |
46 |
+ return false; |
47 |
+ } |
48 |
+ |
49 |
+- storage->mutable_dictionaries()->RemoveLast(); |
50 |
++ storage->user_dictionary_storage_base.mutable_dictionaries()->RemoveLast(); |
51 |
+ return true; |
52 |
+ } |
53 |
+ |
54 |
+@@ -94,7 +94,7 @@ |
55 |
+ } |
56 |
+ |
57 |
+ RepeatedPtrField<UserDictionary> *dictionaries = |
58 |
+- storage->mutable_dictionaries(); |
59 |
++ storage->user_dictionary_storage_base.mutable_dictionaries(); |
60 |
+ dictionaries->AddAllocated(dictionary_.release()); |
61 |
+ |
62 |
+ // Adjust the position of the reverted dictionary. |
63 |
+@@ -120,10 +120,10 @@ |
64 |
+ } |
65 |
+ |
66 |
+ virtual bool RunUndo(mozc::UserDictionaryStorage *storage) { |
67 |
+- if (storage->dictionaries_size() != 1) { |
68 |
++ if (storage->user_dictionary_storage_base.dictionaries_size() != 1) { |
69 |
+ return false; |
70 |
+ } |
71 |
+- dictionary_->Swap(storage->mutable_dictionaries(0)); |
72 |
++ dictionary_->Swap(storage->user_dictionary_storage_base.mutable_dictionaries(0)); |
73 |
+ return true; |
74 |
+ } |
75 |
+ |
76 |
+@@ -144,7 +144,7 @@ |
77 |
+ virtual bool RunUndo(mozc::UserDictionaryStorage *storage) { |
78 |
+ UserDictionary *dictionary = |
79 |
+ UserDictionaryUtil::GetMutableUserDictionaryById( |
80 |
+- storage, dictionary_id_); |
81 |
++ &storage->user_dictionary_storage_base, dictionary_id_); |
82 |
+ if (dictionary == NULL) { |
83 |
+ return false; |
84 |
+ } |
85 |
+@@ -169,7 +169,7 @@ |
86 |
+ virtual bool RunUndo(mozc::UserDictionaryStorage *storage) { |
87 |
+ UserDictionary *dictionary = |
88 |
+ UserDictionaryUtil::GetMutableUserDictionaryById( |
89 |
+- storage, dictionary_id_); |
90 |
++ &storage->user_dictionary_storage_base, dictionary_id_); |
91 |
+ if (dictionary == NULL || dictionary->entries_size() == 0) { |
92 |
+ return false; |
93 |
+ } |
94 |
+@@ -195,7 +195,7 @@ |
95 |
+ virtual bool RunUndo(mozc::UserDictionaryStorage *storage) { |
96 |
+ UserDictionary *dictionary = |
97 |
+ UserDictionaryUtil::GetMutableUserDictionaryById( |
98 |
+- storage, dictionary_id_); |
99 |
++ &storage->user_dictionary_storage_base, dictionary_id_); |
100 |
+ if (dictionary == NULL || |
101 |
+ index_ < 0 || dictionary->entries_size() <= index_) { |
102 |
+ return false; |
103 |
+@@ -240,7 +240,7 @@ |
104 |
+ virtual bool RunUndo(mozc::UserDictionaryStorage *storage) { |
105 |
+ UserDictionary *dictionary = |
106 |
+ UserDictionaryUtil::GetMutableUserDictionaryById( |
107 |
+- storage, dictionary_id_); |
108 |
++ &storage->user_dictionary_storage_base, dictionary_id_); |
109 |
+ if (dictionary == NULL) { |
110 |
+ return false; |
111 |
+ } |
112 |
+@@ -306,7 +306,7 @@ |
113 |
+ virtual bool RunUndo(mozc::UserDictionaryStorage *storage) { |
114 |
+ UserDictionary *dictionary = |
115 |
+ UserDictionaryUtil::GetMutableUserDictionaryById( |
116 |
+- storage, dictionary_id_); |
117 |
++ &storage->user_dictionary_storage_base, dictionary_id_); |
118 |
+ if (dictionary == NULL) { |
119 |
+ return false; |
120 |
+ } |
121 |
+@@ -345,7 +345,7 @@ |
122 |
+ |
123 |
+ // TODO(hidehiko) move this to header. |
124 |
+ const UserDictionaryStorage &UserDictionarySession::storage() const { |
125 |
+- return *storage_; |
126 |
++ return storage_->user_dictionary_storage_base; |
127 |
+ } |
128 |
+ mozc::UserDictionaryStorage *UserDictionarySession::mutable_storage() { |
129 |
+ return storage_.get(); |
130 |
+@@ -464,7 +464,7 @@ |
131 |
+ const string &dictionary_name, uint64 *new_dictionary_id) { |
132 |
+ UserDictionaryCommandStatus::Status status = |
133 |
+ UserDictionaryUtil::CreateDictionary( |
134 |
+- storage_.get(), dictionary_name, new_dictionary_id); |
135 |
++ &storage_->user_dictionary_storage_base, dictionary_name, new_dictionary_id); |
136 |
+ if (status == UserDictionaryCommandStatus::USER_DICTIONARY_COMMAND_SUCCESS) { |
137 |
+ AddUndoCommand(new UndoCreateDictionaryCommand); |
138 |
+ } |
139 |
+@@ -488,7 +488,7 @@ |
140 |
+ int original_index; |
141 |
+ UserDictionary *deleted_dictionary; |
142 |
+ if (!UserDictionaryUtil::DeleteDictionary( |
143 |
+- storage_.get(), dictionary_id, |
144 |
++ &storage_->user_dictionary_storage_base, dictionary_id, |
145 |
+ &original_index, &deleted_dictionary)) { |
146 |
+ // Failed to delete the dictionary. |
147 |
+ return UserDictionaryCommandStatus::UNKNOWN_DICTIONARY_ID; |
148 |
+@@ -510,7 +510,7 @@ |
149 |
+ uint64 dictionary_id, const string &dictionary_name) { |
150 |
+ string original_name; |
151 |
+ const UserDictionary *dictionary = |
152 |
+- UserDictionaryUtil::GetUserDictionaryById(*storage_, dictionary_id); |
153 |
++ UserDictionaryUtil::GetUserDictionaryById(storage_->user_dictionary_storage_base, dictionary_id); |
154 |
+ if (dictionary != NULL) { |
155 |
+ // Note that if dictionary is null, it means the dictionary_id is invalid |
156 |
+ // so following RenameDictionary will fail, and error handling is done |
157 |
+@@ -547,7 +547,7 @@ |
158 |
+ uint64 dictionary_id, const UserDictionary::Entry &entry) { |
159 |
+ UserDictionary *dictionary = |
160 |
+ UserDictionaryUtil::GetMutableUserDictionaryById( |
161 |
+- storage_.get(), dictionary_id); |
162 |
++ &storage_->user_dictionary_storage_base, dictionary_id); |
163 |
+ if (dictionary == NULL) { |
164 |
+ return UserDictionaryCommandStatus::UNKNOWN_DICTIONARY_ID; |
165 |
+ } |
166 |
+@@ -575,7 +575,7 @@ |
167 |
+ uint64 dictionary_id, int index, const UserDictionary::Entry &entry) { |
168 |
+ UserDictionary *dictionary = |
169 |
+ UserDictionaryUtil::GetMutableUserDictionaryById( |
170 |
+- storage_.get(), dictionary_id); |
171 |
++ &storage_->user_dictionary_storage_base, dictionary_id); |
172 |
+ if (dictionary == NULL) { |
173 |
+ return UserDictionaryCommandStatus::UNKNOWN_DICTIONARY_ID; |
174 |
+ } |
175 |
+@@ -604,7 +604,7 @@ |
176 |
+ uint64 dictionary_id, const std::vector<int> &index_list) { |
177 |
+ UserDictionary *dictionary = |
178 |
+ UserDictionaryUtil::GetMutableUserDictionaryById( |
179 |
+- storage_.get(), dictionary_id); |
180 |
++ &storage_->user_dictionary_storage_base, dictionary_id); |
181 |
+ if (dictionary == NULL) { |
182 |
+ return UserDictionaryCommandStatus::UNKNOWN_DICTIONARY_ID; |
183 |
+ } |
184 |
+@@ -644,7 +644,7 @@ |
185 |
+ uint64 dictionary_id, const string &data) { |
186 |
+ UserDictionary *dictionary = |
187 |
+ UserDictionaryUtil::GetMutableUserDictionaryById( |
188 |
+- storage_.get(), dictionary_id); |
189 |
++ &storage_->user_dictionary_storage_base, dictionary_id); |
190 |
+ if (dictionary == NULL) { |
191 |
+ return UserDictionaryCommandStatus::UNKNOWN_DICTIONARY_ID; |
192 |
+ } |
193 |
+@@ -699,7 +699,7 @@ |
194 |
+ uint64 *new_dictionary_id) { |
195 |
+ UserDictionaryCommandStatus::Status status = |
196 |
+ UserDictionaryUtil::CreateDictionary( |
197 |
+- storage_.get(), dictionary_name, new_dictionary_id); |
198 |
++ &storage_->user_dictionary_storage_base, dictionary_name, new_dictionary_id); |
199 |
+ if (status != UserDictionaryCommandStatus::USER_DICTIONARY_COMMAND_SUCCESS) { |
200 |
+ return status; |
201 |
+ } |
202 |
+@@ -709,7 +709,7 @@ |
203 |
+ |
204 |
+ UserDictionary *dictionary = |
205 |
+ UserDictionaryUtil::GetMutableUserDictionaryById( |
206 |
+- storage_.get(), *new_dictionary_id); |
207 |
++ &storage_->user_dictionary_storage_base, *new_dictionary_id); |
208 |
+ if (dictionary == NULL) { |
209 |
+ // The dictionary should be always found. |
210 |
+ return UserDictionaryCommandStatus::UNKNOWN_ERROR; |
211 |
+@@ -719,7 +719,7 @@ |
212 |
+ } |
213 |
+ |
214 |
+ bool UserDictionarySession::EnsureNonEmptyStorage() { |
215 |
+- if (storage_->dictionaries_size() > 0) { |
216 |
++ if (storage_->user_dictionary_storage_base.dictionaries_size() > 0) { |
217 |
+ // The storage already has at least one dictionary. Do nothing. |
218 |
+ return false; |
219 |
+ } |
220 |
+@@ -728,7 +728,7 @@ |
221 |
+ uint64 new_dictionary_id; |
222 |
+ UserDictionaryCommandStatus::Status status = |
223 |
+ UserDictionaryUtil::CreateDictionary( |
224 |
+- storage_.get(), default_dictionary_name_, &new_dictionary_id); |
225 |
++ &storage_->user_dictionary_storage_base, default_dictionary_name_, &new_dictionary_id); |
226 |
+ CHECK_EQ( |
227 |
+ status, UserDictionaryCommandStatus::USER_DICTIONARY_COMMAND_SUCCESS); |
228 |
+ return true; |
229 |
+@@ -755,7 +755,7 @@ |
230 |
+ |
231 |
+ void UserDictionarySession::ClearDictionariesAndUndoHistory() { |
232 |
+ ScopedUserDictionaryLocker l(storage_.get()); |
233 |
+- storage_->clear_dictionaries(); |
234 |
++ storage_->user_dictionary_storage_base.clear_dictionaries(); |
235 |
+ ClearUndoHistory(); |
236 |
+ } |
237 |
+ |
238 |
+--- /src/dictionary/user_dictionary_session_test.cc |
239 |
++++ /src/dictionary/user_dictionary_session_test.cc |
240 |
+@@ -95,12 +95,12 @@ |
241 |
+ |
242 |
+ ASSERT_EQ(UserDictionaryCommandStatus::FILE_NOT_FOUND, session.Load()); |
243 |
+ |
244 |
+- session.mutable_storage()->set_version(10); |
245 |
++ session.mutable_storage()->user_dictionary_storage_base.set_version(10); |
246 |
+ ASSERT_EQ(UserDictionaryCommandStatus::USER_DICTIONARY_COMMAND_SUCCESS, |
247 |
+ session.Save()); |
248 |
+ |
249 |
+ // Clear once, in order to make sure that Load is actually working. |
250 |
+- session.mutable_storage()->Clear(); |
251 |
++ session.mutable_storage()->user_dictionary_storage_base.Clear(); |
252 |
+ ASSERT_EQ(UserDictionaryCommandStatus::USER_DICTIONARY_COMMAND_SUCCESS, |
253 |
+ session.Load()); |
254 |
+ |
255 |
+@@ -130,7 +130,7 @@ |
256 |
+ |
257 |
+ // Create huge dummy data. |
258 |
+ { |
259 |
+- UserDictionaryStorage *storage = session.mutable_storage(); |
260 |
++ UserDictionaryStorage *storage = &session.mutable_storage()->user_dictionary_storage_base; |
261 |
+ for (int i = 0; i < 100; ++i) { |
262 |
+ UserDictionary *dictionary = storage->add_dictionaries(); |
263 |
+ for (int j = 0; j < 1000; ++j) { |
264 |
+@@ -147,7 +147,7 @@ |
265 |
+ ASSERT_EQ(UserDictionaryCommandStatus::FILE_SIZE_LIMIT_EXCEEDED, |
266 |
+ session.Save()); |
267 |
+ |
268 |
+- session.mutable_storage()->Clear(); |
269 |
++ session.mutable_storage()->user_dictionary_storage_base.Clear(); |
270 |
+ ASSERT_EQ(UserDictionaryCommandStatus::USER_DICTIONARY_COMMAND_SUCCESS, |
271 |
+ session.Load()); |
272 |
+ |
273 |
+@@ -191,7 +191,7 @@ |
274 |
+ |
275 |
+ while (session.storage().dictionaries_size() < |
276 |
+ ::mozc::UserDictionaryStorage::max_dictionary_size()) { |
277 |
+- session.mutable_storage()->add_dictionaries(); |
278 |
++ session.mutable_storage()->user_dictionary_storage_base.add_dictionaries(); |
279 |
+ } |
280 |
+ EXPECT_EQ(UserDictionaryCommandStatus::DICTIONARY_SIZE_LIMIT_EXCEEDED, |
281 |
+ session.CreateDictionary("dictionary 2", &dummy_dictionary_id)); |
282 |
+@@ -204,7 +204,7 @@ |
283 |
+ const uint64 kDummyId = 10; |
284 |
+ { |
285 |
+ UserDictionary *user_dictionary = |
286 |
+- session.mutable_storage()->add_dictionaries(); |
287 |
++ session.mutable_storage()->user_dictionary_storage_base.add_dictionaries(); |
288 |
+ user_dictionary->set_id(kDummyId); |
289 |
+ } |
290 |
+ |
291 |
+@@ -229,7 +229,7 @@ |
292 |
+ const uint64 kDummyId = 10; |
293 |
+ { |
294 |
+ UserDictionary *user_dictionary = |
295 |
+- session.mutable_storage()->add_dictionaries(); |
296 |
++ session.mutable_storage()->user_dictionary_storage_base.add_dictionaries(); |
297 |
+ user_dictionary->set_id(kDummyId); |
298 |
+ } |
299 |
+ |
300 |
+--- /src/dictionary/user_dictionary_storage.cc |
301 |
++++ /src/dictionary/user_dictionary_storage.cc |
302 |
+@@ -109,7 +109,7 @@ |
303 |
+ mozc::protobuf::io::IstreamInputStream zero_copy_input(&ifs); |
304 |
+ mozc::protobuf::io::CodedInputStream decoder(&zero_copy_input); |
305 |
+ decoder.SetTotalBytesLimit(kDefaultTotalBytesLimit, -1); |
306 |
+- if (!ParseFromCodedStream(&decoder)) { |
307 |
++ if (!user_dictionary_storage_base.ParseFromCodedStream(&decoder)) { |
308 |
+ LOG(ERROR) << "Failed to parse"; |
309 |
+ if (!decoder.ConsumedEntireMessage() || !ifs.eof()) { |
310 |
+ LOG(ERROR) << "ParseFromStream failed: file seems broken"; |
311 |
+@@ -137,11 +137,11 @@ |
312 |
+ } |
313 |
+ |
314 |
+ // Check dictionary id here. if id is 0, assign random ID. |
315 |
+- for (int i = 0; i < dictionaries_size(); ++i) { |
316 |
+- const UserDictionary &dict = dictionaries(i); |
317 |
++ for (int i = 0; i < user_dictionary_storage_base.dictionaries_size(); ++i) { |
318 |
++ const UserDictionary &dict = user_dictionary_storage_base.dictionaries(i); |
319 |
+ if (dict.id() == 0) { |
320 |
+- mutable_dictionaries(i)->set_id( |
321 |
+- UserDictionaryUtil::CreateNewDictionaryId(*this)); |
322 |
++ user_dictionary_storage_base.mutable_dictionaries(i)->set_id( |
323 |
++ UserDictionaryUtil::CreateNewDictionaryId(this->user_dictionary_storage_base)); |
324 |
+ } |
325 |
+ } |
326 |
+ |
327 |
+@@ -171,7 +171,7 @@ |
328 |
+ return false; |
329 |
+ } |
330 |
+ |
331 |
+- if (!SerializeToOstream(&ofs)) { |
332 |
++ if (!user_dictionary_storage_base.SerializeToOstream(&ofs)) { |
333 |
+ LOG(ERROR) << "SerializeToString failed"; |
334 |
+ last_error_type_ = SYNC_FAILURE; |
335 |
+ return false; |
336 |
+@@ -227,7 +227,7 @@ |
337 |
+ return false; |
338 |
+ } |
339 |
+ |
340 |
+- const UserDictionary &dic = dictionaries(index); |
341 |
++ const UserDictionary &dic = user_dictionary_storage_base.dictionaries(index); |
342 |
+ for (size_t i = 0; i < dic.entries_size(); ++i) { |
343 |
+ const UserDictionaryEntry &entry = dic.entries(i); |
344 |
+ ofs << entry.key() << "\t" << entry.value() << "\t" |
345 |
+@@ -241,7 +241,7 @@ |
346 |
+ bool UserDictionaryStorage::CreateDictionary( |
347 |
+ const string &dic_name, uint64 *new_dic_id) { |
348 |
+ UserDictionaryCommandStatus::Status status = |
349 |
+- UserDictionaryUtil::CreateDictionary(this, dic_name, new_dic_id); |
350 |
++ UserDictionaryUtil::CreateDictionary(&this->user_dictionary_storage_base, dic_name, new_dic_id); |
351 |
+ // Update last_error_type_ |
352 |
+ switch (status) { |
353 |
+ case UserDictionaryCommandStatus::DICTIONARY_NAME_EMPTY: |
354 |
+@@ -273,7 +273,7 @@ |
355 |
+ } |
356 |
+ |
357 |
+ bool UserDictionaryStorage::DeleteDictionary(uint64 dic_id) { |
358 |
+- if (!UserDictionaryUtil::DeleteDictionary(this, dic_id, NULL, NULL)) { |
359 |
++ if (!UserDictionaryUtil::DeleteDictionary(&this->user_dictionary_storage_base, dic_id, NULL, NULL)) { |
360 |
+ // Failed to delete dictionary. |
361 |
+ last_error_type_ = INVALID_DICTIONARY_ID; |
362 |
+ return false; |
363 |
+@@ -304,8 +304,8 @@ |
364 |
+ return true; |
365 |
+ } |
366 |
+ |
367 |
+- for (int i = 0; i < dictionaries_size(); ++i) { |
368 |
+- if (dic_name == dictionaries(i).name()) { |
369 |
++ for (int i = 0; i < user_dictionary_storage_base.dictionaries_size(); ++i) { |
370 |
++ if (dic_name == user_dictionary_storage_base.dictionaries(i).name()) { |
371 |
+ last_error_type_ = DUPLICATED_DICTIONARY_NAME; |
372 |
+ LOG(ERROR) << "duplicated dictionary name"; |
373 |
+ return false; |
374 |
+@@ -318,14 +318,14 @@ |
375 |
+ } |
376 |
+ |
377 |
+ int UserDictionaryStorage::GetUserDictionaryIndex(uint64 dic_id) const { |
378 |
+- return UserDictionaryUtil::GetUserDictionaryIndexById(*this, dic_id); |
379 |
++ return UserDictionaryUtil::GetUserDictionaryIndexById(this->user_dictionary_storage_base, dic_id); |
380 |
+ } |
381 |
+ |
382 |
+ bool UserDictionaryStorage::GetUserDictionaryId(const string &dic_name, |
383 |
+ uint64 *dic_id) { |
384 |
+- for (size_t i = 0; i < dictionaries_size(); ++i) { |
385 |
+- if (dic_name == dictionaries(i).name()) { |
386 |
+- *dic_id = dictionaries(i).id(); |
387 |
++ for (size_t i = 0; i < user_dictionary_storage_base.dictionaries_size(); ++i) { |
388 |
++ if (dic_name == user_dictionary_storage_base.dictionaries(i).name()) { |
389 |
++ *dic_id = user_dictionary_storage_base.dictionaries(i).id(); |
390 |
+ return true; |
391 |
+ } |
392 |
+ } |
393 |
+@@ -335,7 +335,7 @@ |
394 |
+ |
395 |
+ user_dictionary::UserDictionary *UserDictionaryStorage::GetUserDictionary( |
396 |
+ uint64 dic_id) { |
397 |
+- return UserDictionaryUtil::GetMutableUserDictionaryById(this, dic_id); |
398 |
++ return UserDictionaryUtil::GetMutableUserDictionaryById(&this->user_dictionary_storage_base, dic_id); |
399 |
+ } |
400 |
+ |
401 |
+ UserDictionaryStorage::UserDictionaryStorageErrorType |
402 |
+@@ -352,8 +352,8 @@ |
403 |
+ } |
404 |
+ |
405 |
+ int auto_index = -1; |
406 |
+- for (int i = 0; i < dictionaries_size(); ++i) { |
407 |
+- if (dictionaries(i).name() == kAutoRegisteredDictionaryName) { |
408 |
++ for (int i = 0; i < user_dictionary_storage_base.dictionaries_size(); ++i) { |
409 |
++ if (user_dictionary_storage_base.dictionaries(i).name() == kAutoRegisteredDictionaryName) { |
410 |
+ auto_index = i; |
411 |
+ break; |
412 |
+ } |
413 |
+@@ -361,17 +361,17 @@ |
414 |
+ |
415 |
+ UserDictionary *dic = NULL; |
416 |
+ if (auto_index == -1) { |
417 |
+- if (UserDictionaryUtil::IsStorageFull(*this)) { |
418 |
++ if (UserDictionaryUtil::IsStorageFull(this->user_dictionary_storage_base)) { |
419 |
+ last_error_type_ = TOO_MANY_DICTIONARIES; |
420 |
+ LOG(ERROR) << "too many dictionaries"; |
421 |
+ UnLock(); |
422 |
+ return false; |
423 |
+ } |
424 |
+- dic = add_dictionaries(); |
425 |
+- dic->set_id(UserDictionaryUtil::CreateNewDictionaryId(*this)); |
426 |
++ dic = user_dictionary_storage_base.add_dictionaries(); |
427 |
++ dic->set_id(UserDictionaryUtil::CreateNewDictionaryId(this->user_dictionary_storage_base)); |
428 |
+ dic->set_name(kAutoRegisteredDictionaryName); |
429 |
+ } else { |
430 |
+- dic = mutable_dictionaries(auto_index); |
431 |
++ dic = user_dictionary_storage_base.mutable_dictionaries(auto_index); |
432 |
+ } |
433 |
+ |
434 |
+ if (dic == NULL) { |
435 |
+@@ -410,13 +410,13 @@ |
436 |
+ } |
437 |
+ |
438 |
+ bool UserDictionaryStorage::ConvertSyncDictionariesToNormalDictionaries() { |
439 |
+- if (CountSyncableDictionaries(*this) == 0) { |
440 |
++ if (CountSyncableDictionaries(this->user_dictionary_storage_base) == 0) { |
441 |
+ return false; |
442 |
+ } |
443 |
+ |
444 |
+- for (int dictionary_index = dictionaries_size() - 1; |
445 |
++ for (int dictionary_index = user_dictionary_storage_base.dictionaries_size() - 1; |
446 |
+ dictionary_index >= 0; --dictionary_index) { |
447 |
+- UserDictionary *dic = mutable_dictionaries(dictionary_index); |
448 |
++ UserDictionary *dic = user_dictionary_storage_base.mutable_dictionaries(dictionary_index); |
449 |
+ if (!dic->syncable()) { |
450 |
+ continue; |
451 |
+ } |
452 |
+@@ -433,10 +433,10 @@ |
453 |
+ |
454 |
+ // Delete removed or unused sync dictionaries. |
455 |
+ if (dic->removed() || dic->entries_size() == 0) { |
456 |
+- for (int i = dictionary_index + 1; i < dictionaries_size(); ++i) { |
457 |
+- mutable_dictionaries()->SwapElements(i - 1, i); |
458 |
++ for (int i = dictionary_index + 1; i < user_dictionary_storage_base.dictionaries_size(); ++i) { |
459 |
++ user_dictionary_storage_base.mutable_dictionaries()->SwapElements(i - 1, i); |
460 |
+ } |
461 |
+- mutable_dictionaries()->RemoveLast(); |
462 |
++ user_dictionary_storage_base.mutable_dictionaries()->RemoveLast(); |
463 |
+ continue; |
464 |
+ } |
465 |
+ |
466 |
+@@ -445,7 +445,7 @@ |
467 |
+ kDictionaryNameConvertedFromSyncableDictionary; |
468 |
+ int index = 0; |
469 |
+ while (UserDictionaryUtil::ValidateDictionaryName( |
470 |
+- *this, new_dictionary_name) |
471 |
++ this->user_dictionary_storage_base, new_dictionary_name) |
472 |
+ != UserDictionaryCommandStatus::USER_DICTIONARY_COMMAND_SUCCESS) { |
473 |
+ ++index; |
474 |
+ new_dictionary_name = Util::StringPrintf( |
475 |
+@@ -456,7 +456,7 @@ |
476 |
+ dic->set_syncable(false); |
477 |
+ } |
478 |
+ |
479 |
+- DCHECK_EQ(0, CountSyncableDictionaries(*this)); |
480 |
++ DCHECK_EQ(0, CountSyncableDictionaries(this->user_dictionary_storage_base)); |
481 |
+ |
482 |
+ return true; |
483 |
+ } |
484 |
+@@ -487,7 +487,7 @@ |
485 |
+ bool UserDictionaryStorage::IsValidDictionaryName(const string &name) { |
486 |
+ UserDictionaryCommandStatus::Status status = |
487 |
+ UserDictionaryUtil::ValidateDictionaryName( |
488 |
+- UserDictionaryStorage::default_instance(), name); |
489 |
++ user_dictionary::UserDictionaryStorage::default_instance(), name); |
490 |
+ |
491 |
+ // Update last_error_type_. |
492 |
+ switch (status) { |
493 |
+--- /src/dictionary/user_dictionary_storage.h |
494 |
++++ /src/dictionary/user_dictionary_storage.h |
495 |
+@@ -72,13 +72,15 @@ |
496 |
+ class Mutex; |
497 |
+ class ProcessMutex; |
498 |
+ |
499 |
+-// Inherit from ProtocolBuffer |
500 |
+-// TODO(hidehiko): Get rid of this implementation. |
501 |
+-class UserDictionaryStorage : public user_dictionary::UserDictionaryStorage { |
502 |
++class UserDictionaryStorage { |
503 |
+ public: |
504 |
+ typedef user_dictionary::UserDictionary UserDictionary; |
505 |
+ typedef user_dictionary::UserDictionary::Entry UserDictionaryEntry; |
506 |
+ |
507 |
++ // Instance of base class generated by Protocol Buffers compiler. |
508 |
++ // Regular inheritance strongly discouraged. |
509 |
++ user_dictionary::UserDictionaryStorage user_dictionary_storage_base; |
510 |
++ |
511 |
+ enum UserDictionaryStorageErrorType { |
512 |
+ USER_DICTIONARY_STORAGE_NO_ERROR = 0, // default |
513 |
+ FILE_NOT_EXISTS, |
514 |
+--- /src/dictionary/user_dictionary_storage_test.cc |
515 |
++++ /src/dictionary/user_dictionary_storage_test.cc |
516 |
+@@ -118,13 +118,13 @@ |
517 |
+ const size_t kDictionariesSize = 3; |
518 |
+ uint64 id[kDictionariesSize]; |
519 |
+ |
520 |
+- const size_t dict_size = storage.dictionaries_size(); |
521 |
++ const size_t dict_size = storage.user_dictionary_storage_base.dictionaries_size(); |
522 |
+ |
523 |
+ for (size_t i = 0; i < kDictionariesSize; ++i) { |
524 |
+ EXPECT_TRUE(storage.CreateDictionary( |
525 |
+ "test" + std::to_string(static_cast<uint32>(i)), |
526 |
+ &id[i])); |
527 |
+- EXPECT_EQ(i + 1 + dict_size, storage.dictionaries_size()); |
528 |
++ EXPECT_EQ(i + 1 + dict_size, storage.user_dictionary_storage_base.dictionaries_size()); |
529 |
+ } |
530 |
+ |
531 |
+ for (size_t i = 0; i < kDictionariesSize; ++i) { |
532 |
+@@ -133,7 +133,7 @@ |
533 |
+ } |
534 |
+ |
535 |
+ for (size_t i = 0; i < kDictionariesSize; ++i) { |
536 |
+- EXPECT_EQ(storage.mutable_dictionaries(i + dict_size), |
537 |
++ EXPECT_EQ(storage.user_dictionary_storage_base.mutable_dictionaries(i + dict_size), |
538 |
+ storage.GetUserDictionary(id[i])); |
539 |
+ EXPECT_EQ(NULL, storage.GetUserDictionary(id[i] + 1)); |
540 |
+ } |
541 |
+@@ -165,7 +165,7 @@ |
542 |
+ EXPECT_FALSE(storage.DeleteDictionary(0)); |
543 |
+ |
544 |
+ EXPECT_TRUE(storage.DeleteDictionary(id[1])); |
545 |
+- EXPECT_EQ(kDictionariesSize + dict_size - 1, storage.dictionaries_size()); |
546 |
++ EXPECT_EQ(kDictionariesSize + dict_size - 1, storage.user_dictionary_storage_base.dictionaries_size()); |
547 |
+ } |
548 |
+ |
549 |
+ TEST_F(UserDictionaryStorageTest, DeleteTest) { |
550 |
+@@ -174,7 +174,7 @@ |
551 |
+ |
552 |
+ // repeat 10 times |
553 |
+ for (int i = 0; i < 10; ++i) { |
554 |
+- storage.Clear(); |
555 |
++ storage.user_dictionary_storage_base.Clear(); |
556 |
+ std::vector<uint64> ids(100); |
557 |
+ for (size_t i = 0; i < ids.size(); ++i) { |
558 |
+ EXPECT_TRUE(storage.CreateDictionary( |
559 |
+@@ -191,10 +191,10 @@ |
560 |
+ alive.push_back(ids[i]); |
561 |
+ } |
562 |
+ |
563 |
+- EXPECT_EQ(alive.size(), storage.dictionaries_size()); |
564 |
++ EXPECT_EQ(alive.size(), storage.user_dictionary_storage_base.dictionaries_size()); |
565 |
+ |
566 |
+ for (size_t i = 0; i < alive.size(); ++i) { |
567 |
+- EXPECT_EQ(alive[i], storage.dictionaries(i).id()); |
568 |
++ EXPECT_EQ(alive[i], storage.user_dictionary_storage_base.dictionaries(i).id()); |
569 |
+ } |
570 |
+ } |
571 |
+ } |
572 |
+@@ -268,7 +268,7 @@ |
573 |
+ const size_t entry_size = Util::Random(100) + 1; |
574 |
+ for (size_t j = 0; j < entry_size; ++j) { |
575 |
+ UserDictionaryStorage::UserDictionary *dic = |
576 |
+- storage1.mutable_dictionaries(i); |
577 |
++ storage1.user_dictionary_storage_base.mutable_dictionaries(i); |
578 |
+ UserDictionaryStorage::UserDictionaryEntry *entry = |
579 |
+ dic->add_entries(); |
580 |
+ entry->set_key(GenRandomString(10)); |
581 |
+@@ -288,7 +288,7 @@ |
582 |
+ EXPECT_TRUE(storage2.Load()); |
583 |
+ } |
584 |
+ |
585 |
+- EXPECT_EQ(storage1.DebugString(), storage2.DebugString()); |
586 |
++ EXPECT_EQ(storage1.user_dictionary_storage_base.DebugString(), storage2.user_dictionary_storage_base.DebugString()); |
587 |
+ } |
588 |
+ } |
589 |
+ |
590 |
+@@ -352,7 +352,7 @@ |
591 |
+ uint64 dict_id = 0; |
592 |
+ ASSERT_TRUE(storage.CreateDictionary(data.dictionary_name, &dict_id)); |
593 |
+ UserDictionaryStorage::UserDictionary *dict = |
594 |
+- storage.mutable_dictionaries(storage.GetUserDictionaryIndex(dict_id)); |
595 |
++ storage.user_dictionary_storage_base.mutable_dictionaries(storage.GetUserDictionaryIndex(dict_id)); |
596 |
+ dict->set_syncable(data.is_sync_dictionary); |
597 |
+ dict->set_removed(data.is_removed_dictionary); |
598 |
+ if (data.has_normal_entry) { |
599 |
+@@ -369,7 +369,7 @@ |
600 |
+ entry->set_removed(true); |
601 |
+ } |
602 |
+ } |
603 |
+- EXPECT_EQ(9, UserDictionaryStorage::CountSyncableDictionaries(storage)); |
604 |
++ EXPECT_EQ(9, UserDictionaryStorage::CountSyncableDictionaries(storage.user_dictionary_storage_base)); |
605 |
+ |
606 |
+ ASSERT_TRUE(storage.ConvertSyncDictionariesToNormalDictionaries()); |
607 |
+ |
608 |
+@@ -385,12 +385,12 @@ |
609 |
+ { true, kDictionaryNameConvertedFromSyncableDictionary }, |
610 |
+ }; |
611 |
+ |
612 |
+- EXPECT_EQ(0, UserDictionaryStorage::CountSyncableDictionaries(storage)); |
613 |
+- ASSERT_EQ(arraysize(expected_data), storage.dictionaries_size()); |
614 |
++ EXPECT_EQ(0, UserDictionaryStorage::CountSyncableDictionaries(storage.user_dictionary_storage_base)); |
615 |
++ ASSERT_EQ(arraysize(expected_data), storage.user_dictionary_storage_base.dictionaries_size()); |
616 |
+ for (size_t i = 0; i < arraysize(expected_data); ++i) { |
617 |
+ SCOPED_TRACE(Util::StringPrintf("verify %d", static_cast<int>(i))); |
618 |
+ const ExpectedData &expected = expected_data[i]; |
619 |
+- const UserDictionaryStorage::UserDictionary &dict = storage.dictionaries(i); |
620 |
++ const UserDictionaryStorage::UserDictionary &dict = storage.user_dictionary_storage_base.dictionaries(i); |
621 |
+ |
622 |
+ EXPECT_EQ(expected.dictionary_name, dict.name()); |
623 |
+ EXPECT_FALSE(dict.syncable()); |
624 |
+@@ -404,42 +404,42 @@ |
625 |
+ } |
626 |
+ |
627 |
+ // Test duplicated dictionary name. |
628 |
+- storage.Clear(); |
629 |
++ storage.user_dictionary_storage_base.Clear(); |
630 |
+ { |
631 |
+ uint64 dict_id = 0; |
632 |
+ storage.CreateDictionary( |
633 |
+ UserDictionaryStorage::default_sync_dictionary_name(), &dict_id); |
634 |
+ storage.CreateDictionary( |
635 |
+ kDictionaryNameConvertedFromSyncableDictionary, &dict_id); |
636 |
+- ASSERT_EQ(2, storage.dictionaries_size()); |
637 |
++ ASSERT_EQ(2, storage.user_dictionary_storage_base.dictionaries_size()); |
638 |
+ UserDictionaryStorage::UserDictionary *dict; |
639 |
+- dict = storage.mutable_dictionaries(0); |
640 |
++ dict = storage.user_dictionary_storage_base.mutable_dictionaries(0); |
641 |
+ dict->set_syncable(true); |
642 |
+ dict->add_entries()->set_key("0"); |
643 |
+- dict = storage.mutable_dictionaries(1); |
644 |
++ dict = storage.user_dictionary_storage_base.mutable_dictionaries(1); |
645 |
+ dict->set_syncable(false); |
646 |
+ dict->add_entries()->set_key("1"); |
647 |
+ } |
648 |
+ ASSERT_TRUE(storage.ConvertSyncDictionariesToNormalDictionaries()); |
649 |
+- EXPECT_EQ(0, UserDictionaryStorage::CountSyncableDictionaries(storage)); |
650 |
+- EXPECT_EQ(2, storage.dictionaries_size()); |
651 |
++ EXPECT_EQ(0, UserDictionaryStorage::CountSyncableDictionaries(storage.user_dictionary_storage_base)); |
652 |
++ EXPECT_EQ(2, storage.user_dictionary_storage_base.dictionaries_size()); |
653 |
+ EXPECT_EQ(Util::StringPrintf("%s_1", |
654 |
+ kDictionaryNameConvertedFromSyncableDictionary), |
655 |
+- storage.dictionaries(0).name()); |
656 |
++ storage.user_dictionary_storage_base.dictionaries(0).name()); |
657 |
+ EXPECT_EQ(kDictionaryNameConvertedFromSyncableDictionary, |
658 |
+- storage.dictionaries(1).name()); |
659 |
++ storage.user_dictionary_storage_base.dictionaries(1).name()); |
660 |
+ } |
661 |
+ |
662 |
+ TEST_F(UserDictionaryStorageTest, AddToAutoRegisteredDictionary) { |
663 |
+ { |
664 |
+ UserDictionaryStorage storage(GetUserDictionaryFile()); |
665 |
+- EXPECT_EQ(0, storage.dictionaries_size()); |
666 |
++ EXPECT_EQ(0, storage.user_dictionary_storage_base.dictionaries_size()); |
667 |
+ EXPECT_TRUE(storage.AddToAutoRegisteredDictionary( |
668 |
+ "key1", "value1", UserDictionary::NOUN)); |
669 |
+- EXPECT_EQ(1, storage.dictionaries_size()); |
670 |
+- EXPECT_EQ(1, storage.dictionaries(0).entries_size()); |
671 |
++ EXPECT_EQ(1, storage.user_dictionary_storage_base.dictionaries_size()); |
672 |
++ EXPECT_EQ(1, storage.user_dictionary_storage_base.dictionaries(0).entries_size()); |
673 |
+ const UserDictionaryStorage::UserDictionaryEntry &entry1 = |
674 |
+- storage.dictionaries(0).entries(0); |
675 |
++ storage.user_dictionary_storage_base.dictionaries(0).entries(0); |
676 |
+ EXPECT_EQ("key1", entry1.key()); |
677 |
+ EXPECT_EQ("value1", entry1.value()); |
678 |
+ EXPECT_EQ(UserDictionary::NOUN, entry1.pos()); |
679 |
+@@ -447,10 +447,10 @@ |
680 |
+ |
681 |
+ EXPECT_TRUE(storage.AddToAutoRegisteredDictionary( |
682 |
+ "key2", "value2", UserDictionary::NOUN)); |
683 |
+- EXPECT_EQ(1, storage.dictionaries_size()); |
684 |
+- EXPECT_EQ(2, storage.dictionaries(0).entries_size()); |
685 |
++ EXPECT_EQ(1, storage.user_dictionary_storage_base.dictionaries_size()); |
686 |
++ EXPECT_EQ(2, storage.user_dictionary_storage_base.dictionaries(0).entries_size()); |
687 |
+ const UserDictionaryStorage::UserDictionaryEntry &entry2 = |
688 |
+- storage.dictionaries(0).entries(1); |
689 |
++ storage.user_dictionary_storage_base.dictionaries(0).entries(1); |
690 |
+ EXPECT_EQ("key2", entry2.key()); |
691 |
+ EXPECT_EQ("value2", entry2.value()); |
692 |
+ EXPECT_EQ(UserDictionary::NOUN, entry2.pos()); |
693 |
+@@ -474,7 +474,7 @@ |
694 |
+ { |
695 |
+ UserDictionaryStorage storage(GetUserDictionaryFile()); |
696 |
+ { |
697 |
+- UserDictionary *dictionary = storage.add_dictionaries(); |
698 |
++ UserDictionary *dictionary = storage.user_dictionary_storage_base.add_dictionaries(); |
699 |
+ dictionary->set_id(kDummyDictionaryId); |
700 |
+ UserDictionary::Entry *entry = dictionary->add_entries(); |
701 |
+ entry->set_key("key"); |
702 |
+--- /src/dictionary/user_dictionary_test.cc |
703 |
++++ /src/dictionary/user_dictionary_test.cc |
704 |
+@@ -334,9 +334,9 @@ |
705 |
+ std::istringstream is(contents); |
706 |
+ CHECK(is.good()); |
707 |
+ |
708 |
+- storage->Clear(); |
709 |
++ storage->user_dictionary_storage_base.Clear(); |
710 |
+ UserDictionaryStorage::UserDictionary *dic |
711 |
+- = storage->add_dictionaries(); |
712 |
++ = storage->user_dictionary_storage_base.add_dictionaries(); |
713 |
+ CHECK(dic); |
714 |
+ |
715 |
+ string line; |
716 |
+@@ -389,7 +389,7 @@ |
717 |
+ { |
718 |
+ UserDictionaryStorage storage(""); |
719 |
+ UserDictionaryTest::LoadFromString(kUserDictionary0, &storage); |
720 |
+- dic->Load(storage); |
721 |
++ dic->Load(storage.user_dictionary_storage_base); |
722 |
+ } |
723 |
+ |
724 |
+ // A normal lookup operation. |
725 |
+@@ -425,7 +425,7 @@ |
726 |
+ { |
727 |
+ UserDictionaryStorage storage(""); |
728 |
+ LoadFromString(kUserDictionary1, &storage); |
729 |
+- dic->Load(storage); |
730 |
++ dic->Load(storage.user_dictionary_storage_base); |
731 |
+ } |
732 |
+ |
733 |
+ // A normal lookup again. |
734 |
+@@ -450,7 +450,7 @@ |
735 |
+ { |
736 |
+ UserDictionaryStorage storage(""); |
737 |
+ LoadFromString(kUserDictionary0, &storage); |
738 |
+- dic->Load(storage); |
739 |
++ dic->Load(storage.user_dictionary_storage_base); |
740 |
+ } |
741 |
+ |
742 |
+ // A normal lookup operation. |
743 |
+@@ -480,7 +480,7 @@ |
744 |
+ { |
745 |
+ UserDictionaryStorage storage(""); |
746 |
+ LoadFromString(kUserDictionary1, &storage); |
747 |
+- dic->Load(storage); |
748 |
++ dic->Load(storage.user_dictionary_storage_base); |
749 |
+ } |
750 |
+ |
751 |
+ // A normal lookup. |
752 |
+@@ -504,7 +504,7 @@ |
753 |
+ { |
754 |
+ UserDictionaryStorage storage(""); |
755 |
+ LoadFromString(kUserDictionary0, &storage); |
756 |
+- dic->Load(storage); |
757 |
++ dic->Load(storage.user_dictionary_storage_base); |
758 |
+ } |
759 |
+ |
760 |
+ // A normal lookup operation. |
761 |
+@@ -540,7 +540,7 @@ |
762 |
+ uint64 id = 0; |
763 |
+ EXPECT_TRUE(storage.CreateDictionary("test", &id)); |
764 |
+ UserDictionaryStorage::UserDictionary *dic = |
765 |
+- storage.mutable_dictionaries(0); |
766 |
++ storage.user_dictionary_storage_base.mutable_dictionaries(0); |
767 |
+ |
768 |
+ // "名詞" |
769 |
+ UserDictionaryStorage::UserDictionaryEntry *entry = |
770 |
+@@ -555,7 +555,7 @@ |
771 |
+ entry->set_value("suggest_only"); |
772 |
+ entry->set_pos(user_dictionary::UserDictionary::SUGGESTION_ONLY); |
773 |
+ |
774 |
+- user_dic->Load(storage); |
775 |
++ user_dic->Load(storage.user_dictionary_storage_base); |
776 |
+ } |
777 |
+ |
778 |
+ // "suggestion_only" should not be looked up. |
779 |
+@@ -577,7 +577,7 @@ |
780 |
+ { |
781 |
+ UserDictionaryStorage storage(""); |
782 |
+ UserDictionaryTest::LoadFromString(kUserDictionary0, &storage); |
783 |
+- dic->Load(storage); |
784 |
++ dic->Load(storage.user_dictionary_storage_base); |
785 |
+ } |
786 |
+ |
787 |
+ TestLookupPrefixHelper(nullptr, 0, "start", 4, *dic); |
788 |
+@@ -612,7 +612,7 @@ |
789 |
+ uint64 id = 0; |
790 |
+ EXPECT_TRUE(storage.CreateDictionary("test", &id)); |
791 |
+ UserDictionaryStorage::UserDictionary *dic = |
792 |
+- storage.mutable_dictionaries(0); |
793 |
++ storage.user_dictionary_storage_base.mutable_dictionaries(0); |
794 |
+ for (size_t j = 0; j < 10000; ++j) { |
795 |
+ UserDictionaryStorage::UserDictionaryEntry *entry = |
796 |
+ dic->add_entries(); |
797 |
+@@ -681,15 +681,15 @@ |
798 |
+ UserDictionaryStorage storage(filename); |
799 |
+ EXPECT_TRUE(storage.Load()); |
800 |
+ int index = 0; |
801 |
+- EXPECT_EQ(1, storage.dictionaries_size()); |
802 |
+- EXPECT_EQ(100, storage.dictionaries(index).entries_size()); |
803 |
++ EXPECT_EQ(1, storage.user_dictionary_storage_base.dictionaries_size()); |
804 |
++ EXPECT_EQ(100, storage.user_dictionary_storage_base.dictionaries(index).entries_size()); |
805 |
+ for (int i = 0; i < 100; ++i) { |
806 |
+ EXPECT_EQ("key" + std::to_string(i), |
807 |
+- storage.dictionaries(index).entries(i).key()); |
808 |
++ storage.user_dictionary_storage_base.dictionaries(index).entries(i).key()); |
809 |
+ EXPECT_EQ("value" + std::to_string(i), |
810 |
+- storage.dictionaries(index).entries(i).value()); |
811 |
++ storage.user_dictionary_storage_base.dictionaries(index).entries(i).value()); |
812 |
+ EXPECT_EQ(user_dictionary::UserDictionary::NOUN, |
813 |
+- storage.dictionaries(index).entries(i).pos()); |
814 |
++ storage.user_dictionary_storage_base.dictionaries(index).entries(i).pos()); |
815 |
+ } |
816 |
+ } |
817 |
+ |
818 |
+@@ -722,12 +722,12 @@ |
819 |
+ { |
820 |
+ UserDictionaryStorage storage(filename); |
821 |
+ EXPECT_TRUE(storage.Load()); |
822 |
+- EXPECT_EQ(1, storage.dictionaries_size()); |
823 |
+- EXPECT_EQ(1, storage.dictionaries(0).entries_size()); |
824 |
+- EXPECT_EQ("key", storage.dictionaries(0).entries(0).key()); |
825 |
+- EXPECT_EQ("value", storage.dictionaries(0).entries(0).value()); |
826 |
++ EXPECT_EQ(1, storage.user_dictionary_storage_base.dictionaries_size()); |
827 |
++ EXPECT_EQ(1, storage.user_dictionary_storage_base.dictionaries(0).entries_size()); |
828 |
++ EXPECT_EQ("key", storage.user_dictionary_storage_base.dictionaries(0).entries(0).key()); |
829 |
++ EXPECT_EQ("value", storage.user_dictionary_storage_base.dictionaries(0).entries(0).value()); |
830 |
+ EXPECT_EQ(user_dictionary::UserDictionary::NOUN, |
831 |
+- storage.dictionaries(0).entries(0).pos()); |
832 |
++ storage.user_dictionary_storage_base.dictionaries(0).entries(0).pos()); |
833 |
+ } |
834 |
+ } |
835 |
+ |
836 |
+@@ -746,7 +746,7 @@ |
837 |
+ uint64 id = 0; |
838 |
+ EXPECT_TRUE(storage.CreateDictionary("test", &id)); |
839 |
+ UserDictionaryStorage::UserDictionary *dic = |
840 |
+- storage.mutable_dictionaries(0); |
841 |
++ storage.user_dictionary_storage_base.mutable_dictionaries(0); |
842 |
+ for (size_t j = 0; j < 10000; ++j) { |
843 |
+ UserDictionaryStorage::UserDictionaryEntry *entry = |
844 |
+ dic->add_entries(); |
845 |
+@@ -770,7 +770,7 @@ |
846 |
+ |
847 |
+ suppression_dictionary_->Lock(); |
848 |
+ EXPECT_TRUE(suppression_dictionary_->IsLocked()); |
849 |
+- user_dic->Load(storage); |
850 |
++ user_dic->Load(storage.user_dictionary_storage_base); |
851 |
+ EXPECT_FALSE(suppression_dictionary_->IsLocked()); |
852 |
+ |
853 |
+ for (size_t j = 0; j < 10; ++j) { |
854 |
+@@ -782,11 +782,11 @@ |
855 |
+ |
856 |
+ // Remove suppression entry |
857 |
+ { |
858 |
+- storage.Clear(); |
859 |
++ storage.user_dictionary_storage_base.Clear(); |
860 |
+ uint64 id = 0; |
861 |
+ EXPECT_TRUE(storage.CreateDictionary("test", &id)); |
862 |
+ UserDictionaryStorage::UserDictionary *dic = |
863 |
+- storage.mutable_dictionaries(0); |
864 |
++ storage.user_dictionary_storage_base.mutable_dictionaries(0); |
865 |
+ for (size_t j = 0; j < 10000; ++j) { |
866 |
+ UserDictionaryStorage::UserDictionaryEntry *entry = |
867 |
+ dic->add_entries(); |
868 |
+@@ -798,7 +798,7 @@ |
869 |
+ } |
870 |
+ |
871 |
+ suppression_dictionary_->Lock(); |
872 |
+- user_dic->Load(storage); |
873 |
++ user_dic->Load(storage.user_dictionary_storage_base); |
874 |
+ EXPECT_FALSE(suppression_dictionary_->IsLocked()); |
875 |
+ |
876 |
+ for (size_t j = 0; j < 10; ++j) { |
877 |
+@@ -825,7 +825,7 @@ |
878 |
+ uint64 id = 0; |
879 |
+ EXPECT_TRUE(storage.CreateDictionary("test", &id)); |
880 |
+ UserDictionaryStorage::UserDictionary *dic = |
881 |
+- storage.mutable_dictionaries(0); |
882 |
++ storage.user_dictionary_storage_base.mutable_dictionaries(0); |
883 |
+ |
884 |
+ for (size_t j = 0; j < 10; ++j) { |
885 |
+ UserDictionaryStorage::UserDictionaryEntry *entry = |
886 |
+@@ -845,7 +845,7 @@ |
887 |
+ entry->set_pos(user_dictionary::UserDictionary::SUGGESTION_ONLY); |
888 |
+ } |
889 |
+ |
890 |
+- user_dic->Load(storage); |
891 |
++ user_dic->Load(storage.user_dictionary_storage_base); |
892 |
+ } |
893 |
+ |
894 |
+ { |
895 |
+@@ -878,7 +878,7 @@ |
896 |
+ UserDictionaryStorage storage(""); |
897 |
+ |
898 |
+ { |
899 |
+- UserDictionaryStorage::UserDictionary *dic1 = storage.add_dictionaries(); |
900 |
++ UserDictionaryStorage::UserDictionary *dic1 = storage.user_dictionary_storage_base.add_dictionaries(); |
901 |
+ CHECK(dic1); |
902 |
+ UserDictionaryStorage::UserDictionaryEntry *entry; |
903 |
+ entry = dic1->add_entries(); |
904 |
+@@ -893,7 +893,7 @@ |
905 |
+ entry->set_pos(user_dictionary::UserDictionary::NOUN); |
906 |
+ } |
907 |
+ { |
908 |
+- UserDictionaryStorage::UserDictionary *dic2 = storage.add_dictionaries(); |
909 |
++ UserDictionaryStorage::UserDictionary *dic2 = storage.user_dictionary_storage_base.add_dictionaries(); |
910 |
+ CHECK(dic2); |
911 |
+ UserDictionaryStorage::UserDictionaryEntry *entry; |
912 |
+ entry = dic2->add_entries(); |
913 |
+@@ -912,7 +912,7 @@ |
914 |
+ entry->set_value("value5"); |
915 |
+ entry->set_pos(user_dictionary::UserDictionary::NOUN); |
916 |
+ } |
917 |
+- dic->Load(storage); |
918 |
++ dic->Load(storage.user_dictionary_storage_base); |
919 |
+ |
920 |
+ EXPECT_INTEGER_STATS("UserRegisteredWord", 5); |
921 |
+ } |
922 |
+@@ -925,7 +925,7 @@ |
923 |
+ { |
924 |
+ UserDictionaryStorage storage(""); |
925 |
+ UserDictionaryTest::LoadFromString(kUserDictionary0, &storage); |
926 |
+- dic->Load(storage); |
927 |
++ dic->Load(storage.user_dictionary_storage_base); |
928 |
+ } |
929 |
+ |
930 |
+ // Entry is in user dictionary but has no comment. |
931 |
+--- /src/gui/word_register_dialog/word_register_dialog.cc |
932 |
++++ /src/gui/word_register_dialog/word_register_dialog.cc |
933 |
+@@ -298,7 +298,7 @@ |
934 |
+ } |
935 |
+ |
936 |
+ UserDictionary *dic = |
937 |
+- session_->mutable_storage()->mutable_dictionaries(index); |
938 |
++ session_->mutable_storage()->user_dictionary_storage_base.mutable_dictionaries(index); |
939 |
+ CHECK(dic); |
940 |
+ |
941 |
+ if (dic->name() != DictionarycomboBox->currentText().toStdString()) { |
942 |
+--- /src/prediction/user_history_predictor.cc |
943 |
++++ /src/prediction/user_history_predictor.cc |
944 |
+@@ -291,23 +291,23 @@ |
945 |
+ return false; |
946 |
+ } |
947 |
+ |
948 |
+- if (!ParseFromString(input)) { |
949 |
++ if (!user_history_base.ParseFromString(input)) { |
950 |
+ LOG(ERROR) << "ParseFromString failed. message looks broken"; |
951 |
+ return false; |
952 |
+ } |
953 |
+ |
954 |
+- VLOG(1) << "Loaded user histroy, size=" << entries_size(); |
955 |
++ VLOG(1) << "Loaded user histroy, size=" << user_history_base.entries_size(); |
956 |
+ return true; |
957 |
+ } |
958 |
+ |
959 |
+ bool UserHistoryStorage::Save() const { |
960 |
+- if (entries_size() == 0) { |
961 |
++ if (user_history_base.entries_size() == 0) { |
962 |
+ LOG(WARNING) << "etries size is 0. Not saved"; |
963 |
+ return false; |
964 |
+ } |
965 |
+ |
966 |
+ string output; |
967 |
+- if (!AppendToString(&output)) { |
968 |
++ if (!user_history_base.AppendToString(&output)) { |
969 |
+ LOG(ERROR) << "AppendToString failed"; |
970 |
+ return false; |
971 |
+ } |
972 |
+@@ -494,12 +494,12 @@ |
973 |
+ return false; |
974 |
+ } |
975 |
+ |
976 |
+- for (size_t i = 0; i < history.entries_size(); ++i) { |
977 |
+- dic_->Insert(EntryFingerprint(history.entries(i)), |
978 |
+- history.entries(i)); |
979 |
++ for (size_t i = 0; i < history.user_history_base.entries_size(); ++i) { |
980 |
++ dic_->Insert(EntryFingerprint(history.user_history_base.entries(i)), |
981 |
++ history.user_history_base.entries(i)); |
982 |
+ } |
983 |
+ |
984 |
+- VLOG(1) << "Loaded user histroy, size=" << history.entries_size(); |
985 |
++ VLOG(1) << "Loaded user histroy, size=" << history.user_history_base.entries_size(); |
986 |
+ |
987 |
+ return true; |
988 |
+ } |
989 |
+@@ -521,13 +521,13 @@ |
990 |
+ |
991 |
+ UserHistoryStorage history(filename); |
992 |
+ for (const DicElement *elm = tail; elm != nullptr; elm = elm->prev) { |
993 |
+- history.add_entries()->CopyFrom(elm->value); |
994 |
++ history.user_history_base.add_entries()->CopyFrom(elm->value); |
995 |
+ } |
996 |
+ |
997 |
+ // Updates usage stats here. |
998 |
+ UsageStats::SetInteger( |
999 |
+ "UserHistoryPredictorEntrySize", |
1000 |
+- static_cast<int>(history.entries_size())); |
1001 |
++ static_cast<int>(history.user_history_base.entries_size())); |
1002 |
+ |
1003 |
+ if (!history.Save()) { |
1004 |
+ LOG(ERROR) << "UserHistoryStorage::Save() failed"; |
1005 |
+--- /src/prediction/user_history_predictor.h |
1006 |
++++ /src/prediction/user_history_predictor.h |
1007 |
+@@ -61,11 +61,15 @@ |
1008 |
+ class UserHistoryPredictorSyncer; |
1009 |
+ |
1010 |
+ // Added serialization method for UserHistory. |
1011 |
+-class UserHistoryStorage : public mozc::user_history_predictor::UserHistory { |
1012 |
++class UserHistoryStorage { |
1013 |
+ public: |
1014 |
+ explicit UserHistoryStorage(const string &filename); |
1015 |
+ ~UserHistoryStorage(); |
1016 |
+ |
1017 |
++ // Instance of base class generated by Protocol Buffers compiler. |
1018 |
++ // Regular inheritance strongly discouraged. |
1019 |
++ mozc::user_history_predictor::UserHistory user_history_base; |
1020 |
++ |
1021 |
+ // Loads from encrypted file. |
1022 |
+ bool Load(); |
1023 |
+ |
1024 |
+--- /src/prediction/user_history_predictor_test.cc |
1025 |
++++ /src/prediction/user_history_predictor_test.cc |
1026 |
+@@ -2222,7 +2222,7 @@ |
1027 |
+ |
1028 |
+ UserHistoryStorage storage1(filename); |
1029 |
+ |
1030 |
+- UserHistoryPredictor::Entry *entry = storage1.add_entries(); |
1031 |
++ UserHistoryPredictor::Entry *entry = storage1.user_history_base.add_entries(); |
1032 |
+ CHECK(entry); |
1033 |
+ entry->set_key("key"); |
1034 |
+ entry->set_key("value"); |
1035 |
+@@ -2230,7 +2230,7 @@ |
1036 |
+ UserHistoryStorage storage2(filename); |
1037 |
+ storage2.Load(); |
1038 |
+ |
1039 |
+- EXPECT_EQ(storage1.DebugString(), storage2.DebugString()); |
1040 |
++ EXPECT_EQ(storage1.user_history_base.DebugString(), storage2.user_history_base.DebugString()); |
1041 |
+ FileUtil::Unlink(filename); |
1042 |
+ } |
1043 |
+ |
1044 |
+--- /src/rewriter/usage_rewriter_test.cc |
1045 |
++++ /src/rewriter/usage_rewriter_test.cc |
1046 |
+@@ -312,7 +312,7 @@ |
1047 |
+ // Load mock data |
1048 |
+ { |
1049 |
+ UserDictionaryStorage storage(""); |
1050 |
+- UserDictionaryStorage::UserDictionary *dic = storage.add_dictionaries(); |
1051 |
++ UserDictionaryStorage::UserDictionary *dic = storage.user_dictionary_storage_base.add_dictionaries(); |
1052 |
+ |
1053 |
+ UserDictionaryStorage::UserDictionaryEntry *entry = dic->add_entries(); |
1054 |
+ entry->set_key("うま"); |
1055 |
+@@ -320,7 +320,7 @@ |
1056 |
+ entry->set_pos(user_dictionary::UserDictionary::NOUN); |
1057 |
+ entry->set_comment("アルパカコメント"); |
1058 |
+ |
1059 |
+- user_dictionary_->Load(storage); |
1060 |
++ user_dictionary_->Load(storage.user_dictionary_storage_base); |
1061 |
+ } |
1062 |
+ |
1063 |
+ // Emulates the conversion of key="うま". |
1064 |
|
1065 |
diff --git a/app-i18n/mozc/mozc-2.23.2815.102.ebuild b/app-i18n/mozc/mozc-2.23.2815.102.ebuild |
1066 |
index 21a1291f1ea..d4572c6e970 100644 |
1067 |
--- a/app-i18n/mozc/mozc-2.23.2815.102.ebuild |
1068 |
+++ b/app-i18n/mozc/mozc-2.23.2815.102.ebuild |
1069 |
@@ -106,6 +106,7 @@ src_unpack() { |
1070 |
src_prepare() { |
1071 |
eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-system_libraries.patch" |
1072 |
eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-gcc-8.patch" |
1073 |
+ eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-protobuf_generated_classes_no_inheritance.patch" |
1074 |
eapply -p2 "${FILESDIR}/${PN}-2.20.2673.102-tests_build.patch" |
1075 |
eapply -p2 "${FILESDIR}/${PN}-2.20.2673.102-tests_skipping.patch" |
1076 |
|
1077 |
|
1078 |
diff --git a/app-i18n/mozc/mozc-9999.ebuild b/app-i18n/mozc/mozc-9999.ebuild |
1079 |
index 7876d9ed378..144d03b4d78 100644 |
1080 |
--- a/app-i18n/mozc/mozc-9999.ebuild |
1081 |
+++ b/app-i18n/mozc/mozc-9999.ebuild |
1082 |
@@ -106,6 +106,7 @@ src_unpack() { |
1083 |
src_prepare() { |
1084 |
eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-system_libraries.patch" |
1085 |
eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-gcc-8.patch" |
1086 |
+ eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-protobuf_generated_classes_no_inheritance.patch" |
1087 |
eapply -p2 "${FILESDIR}/${PN}-2.20.2673.102-tests_build.patch" |
1088 |
eapply -p2 "${FILESDIR}/${PN}-2.20.2673.102-tests_skipping.patch" |