t-suw****@users*****
t-suw****@users*****
2007年 12月 21日 (金) 22:11:21 JST
Index: AquaSKK/AquaSKKServer.mm diff -u AquaSKK/AquaSKKServer.mm:1.3 AquaSKK/AquaSKKServer.mm:1.4 --- AquaSKK/AquaSKKServer.mm:1.3 Mon Dec 18 00:05:41 2006 +++ AquaSKK/AquaSKKServer.mm Fri Dec 21 22:11:21 2007 @@ -1,5 +1,5 @@ /* -*- objc -*- - $Id: AquaSKKServer.mm,v 1.3 2006/12/17 15:05:41 t-suwa Exp $ + $Id: AquaSKKServer.mm,v 1.4 2007/12/21 13:11:21 t-suwa Exp $ MacOS X implementation of the SKK input method. @@ -61,15 +61,13 @@ NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; - // «Ìzñð[h·é - NSArray* content = [[PreferencesController sharedController] contentForDictionarySet]; + // bZ[WnhðN®·é + ServerMessageReceiver::start(kAquaSKKServerRunLoopMode); // «T[o[ðN®·é + NSArray* content = [[PreferencesController sharedController] contentForDictionarySet]; DictionarySet::theInstance().Initialize((CFArrayRef)content); - // bZ[WnhðN®·é - ServerMessageReceiver::start(kAquaSKKServerRunLoopMode); - // skkserv G~ [VÌN® if([defaults boolForKey:KEY_skkserv_enabled]) { skkserv::theInstance().start([defaults integerForKey:KEY_skkserv_port], Index: AquaSKK/ChangeLog diff -u AquaSKK/ChangeLog:1.56 AquaSKK/ChangeLog:1.57 --- AquaSKK/ChangeLog:1.56 Mon Dec 17 23:48:49 2007 +++ AquaSKK/ChangeLog Fri Dec 21 22:11:21 2007 @@ -1,3 +1,10 @@ +2007-12-21 Tomotaka SUWA <t.suw****@mac*****> + + * AquaSKKServer.mm: è¾æ¸ãµã¼ãã¼ã®åã«ã¡ãã»ã¼ã¸ãã³ãã©ãåæåã + ãããã«å¤æ´ã + + * DictionarySet.*: è¾æ¸ã®åæåãéåæåã + 2007-12-17 Tomotaka SUWA <t.suw****@mac*****> * BIM.cpp: ASCII ã¢ã¼ã以å¤ã§ HOME, END, HELP ãå¹ããªãä¸å ·åãä¿® Index: AquaSKK/DictionarySet.cpp diff -u AquaSKK/DictionarySet.cpp:1.9 AquaSKK/DictionarySet.cpp:1.10 --- AquaSKK/DictionarySet.cpp:1.9 Tue Jun 12 23:25:08 2007 +++ AquaSKK/DictionarySet.cpp Fri Dec 21 22:11:21 2007 @@ -1,5 +1,5 @@ /* - $Id: DictionarySet.cpp,v 1.9 2007/06/12 14:25:08 t-suwa Exp $ + $Id: DictionarySet.cpp,v 1.10 2007/12/21 13:11:21 t-suwa Exp $ MacOS X implementation of the SKK input method. @@ -104,7 +104,17 @@ return id.str(); } -void DictionarySet::load(CFArrayRef arrayRef) { +void* DictionarySet::thread(void* param) { + DictionarySet* obj = reinterpret_cast<DictionarySet*>(param); + + obj->load(); + + return 0; +} + +void DictionarySet::load() { + Guard scope(async_); + DictionaryContainer cache; DictionaryPref entry; @@ -124,8 +134,8 @@ } // å ¨ã¦ã®è¾æ¸ããã£ãã·ã¥ã«ãã¼ããã - for(CFIndex index = 0; index < CFArrayGetCount(arrayRef); ++ index) { - CFDictionaryRef dictRef = (CFDictionaryRef)CFRetain(CFArrayGetValueAtIndex(arrayRef, index)); + for(CFIndex index = 0; index < CFArrayGetCount(arrayRef_); ++ index) { + CFDictionaryRef dictRef = (CFDictionaryRef)CFRetain(CFArrayGetValueAtIndex(arrayRef_, index)); // DictionaryPref ãä½ã entry.active = ((CFBooleanRef)CFDictionaryGetValue(dictRef, CFSTR("active")) == kCFBooleanTrue); @@ -161,6 +171,8 @@ // è¾æ¸ã®ãã£ãã·ã¥ãå ¥ãæ¿ãã std::for_each(dicts_.begin(), dicts_.end(), DeleteDictionary()); cache.swap(dicts_); + + CFRelease(arrayRef_); } DictionarySet::DictionarySet() { @@ -179,21 +191,32 @@ } void DictionarySet::Initialize(CFArrayRef arrayRef) { - // è¾æ¸ããã¼ããã - load(arrayRef); + Guard scope(async_); + + arrayRef_ = (CFArrayRef)CFRetain(arrayRef); + + pthread_t loader_; + pthread_create(&loader_, 0, DictionarySet::thread, this); + pthread_detach(loader_); } void DictionarySet::Terminate() { + Guard scope(async_); + // å ¨ã¦ã®è¾æ¸ãåé¤ãã std::for_each(dicts_.begin(), dicts_.end(), DeleteDictionary()); dicts_.clear(); } std::string DictionarySet::CompleteEntry(const std::string& key, char result_delimiter) { + Guard scope(async_); + return userdict_->findCompletions(key, result_delimiter); } std::string DictionarySet::FindOkuriAri(const std::string& key, const std::string& okuri, char result_delimiter) { + Guard scope(async_); + SKKEntry strict_match = SKKEntry::CreateOkuriAri(key); SKKEntry normal_match = strict_match; @@ -243,6 +266,8 @@ } std::string DictionarySet::FindOkuriNasi(const std::string& key, char result_delimiter) { + Guard scope(async_); + SKKEntry match = SKKEntry::CreateOkuriNasi(key); for(DictionaryPrefIterator iter = prefs_.begin(); iter != prefs_.end(); ++ iter) { @@ -265,6 +290,8 @@ } void DictionarySet::RegisterOkuriAri(const std::string& key, const std::string& okuri, const std::string& entry) { + Guard scope(async_); + if(key.empty() || entry.empty() || okuri.empty()) { std::cerr << "AquaSKK: Invalid registration received" << std::endl; } else { @@ -273,6 +300,8 @@ } void DictionarySet::RegisterOkuriNasi(const std::string& key, const std::string& entry) { + Guard scope(async_); + // key ã ããã§ãã¯ãã(ãã°ã«å¤æã®ç»é²æ㯠entry ã¯ç©º) if(key.empty()) { std::cerr << "AquaSKK: Invalid registration received" << std::endl; @@ -282,6 +311,8 @@ } void DictionarySet::RemoveOkuriAri(const std::string& key, const std::string& entry) { + Guard scope(async_); + if(key.empty() || entry.empty()) { std::cerr << "AquaSKK: Invalid removal received" << std::endl; } else { @@ -290,6 +321,8 @@ } void DictionarySet::RemoveOkuriNasi(const std::string& key, const std::string& entry) { + Guard scope(async_); + if(key.empty() || entry.empty()) { std::cerr << "AquaSKK: Invalid removal received" << std::endl; } else { Index: AquaSKK/DictionarySet.h diff -u AquaSKK/DictionarySet.h:1.3 AquaSKK/DictionarySet.h:1.4 --- AquaSKK/DictionarySet.h:1.3 Mon Dec 18 00:05:41 2006 +++ AquaSKK/DictionarySet.h Fri Dec 21 22:11:21 2007 @@ -1,5 +1,5 @@ /* -*- c++ -*- - $Id: DictionarySet.h,v 1.3 2006/12/17 15:05:41 t-suwa Exp $ + $Id: DictionarySet.h,v 1.4 2007/12/21 13:11:21 t-suwa Exp $ MacOS X implementation of the SKK input method. @@ -27,11 +27,14 @@ #include <string> #include <vector> #include <map> +#include "Mutex.h" class Dictionary; class UserDictionary; class DictionarySet { + Mutex async_; + // è¾æ¸ã®ç¨®é¡ enum DictionaryTypes { SKKDictionaryType = 10, @@ -58,9 +61,12 @@ DictionaryPrefContainer prefs_; DictionaryContainer dicts_; + CFArrayRef arrayRef_; + Dictionary* createDictionary(const DictionaryPref& pref) const; std::string generateID(const DictionaryPref& pref) const; - void load(CFArrayRef arrayRef); + static void* thread(void* param); + void load(); DictionarySet(); ~DictionarySet(); Index: AquaSKK/Info-AquaSKKInputMethod.plist diff -u AquaSKK/Info-AquaSKKInputMethod.plist:1.23 AquaSKK/Info-AquaSKKInputMethod.plist:1.24 --- AquaSKK/Info-AquaSKKInputMethod.plist:1.23 Mon Dec 17 23:48:49 2007 +++ AquaSKK/Info-AquaSKKInputMethod.plist Fri Dec 21 22:11:21 2007 @@ -23,7 +23,7 @@ <key>CFBundleSignature</key> <string>askk</string> <key>CFBundleVersion</key> - <string>2007-12-17</string> + <string>2007-12-21</string> <key>CSResourcesFileMapped</key> <true/> <key>tsInputMethodIconFileKey</key> Index: AquaSKK/Info-AquaSKKServer.plist diff -u AquaSKK/Info-AquaSKKServer.plist:1.23 AquaSKK/Info-AquaSKKServer.plist:1.24 --- AquaSKK/Info-AquaSKKServer.plist:1.23 Mon Dec 17 23:48:49 2007 +++ AquaSKK/Info-AquaSKKServer.plist Fri Dec 21 22:11:21 2007 @@ -23,7 +23,7 @@ <key>CFBundleSignature</key> <string>askk</string> <key>CFBundleVersion</key> - <string>2007-12-17</string> + <string>2007-12-21</string> <key>NSMainNibFile</key> <string>Principal</string> <key>NSPrincipalClass</key>