Skip to content
Permalink
Browse files

Deprecate scoped_ptr part 2.

With this CL, scoped_ptr is replaced with std::unique_ptr mainly in the
following directories.
 - src/dictionary/file/
 - src/gui/
 - src/server/
 - src/storage/

BUG=#219
TEST=unittest
REF_BUG=9164610
REF_CL=84944931,84944947,84945576,85032863,85033860
  • Loading branch information...
Noriyuki Takahashi authored and yukawa committed Oct 25, 2015
1 parent d56d5db commit b3330bb9043f689faaab5af653e0feba9ed5cf4f
Showing with 177 additions and 113 deletions.
  1. +4 −5 src/dictionary/file/codec_test.cc
  2. +2 −2 src/dictionary/file/dictionary_file.h
  3. +3 −2 src/dictionary/text_dictionary_loader.cc
  4. +4 −3 src/gui/about_dialog/about_dialog.h
  5. +4 −2 src/gui/base/setup_util.h
  6. +3 −2 src/gui/base/singleton_window_helper.h
  7. +5 −1 src/gui/character_pad/character_pad_libmain.cc
  8. +4 −2 src/gui/character_pad/character_palette.h
  9. +5 −4 src/gui/character_pad/hand_writing.h
  10. +6 −2 src/gui/config_dialog/character_form_editor.cc
  11. +7 −4 src/gui/config_dialog/character_form_editor.h
  12. +4 −1 src/gui/config_dialog/config_dialog.cc
  13. +4 −2 src/gui/config_dialog/config_dialog.h
  14. +7 −3 src/gui/config_dialog/keybinding_editor.h
  15. +3 −1 src/gui/config_dialog/keybinding_editor_delegate.cc
  16. +4 −1 src/gui/config_dialog/keymap_editor.cc
  17. +10 −6 src/gui/config_dialog/keymap_editor.h
  18. +5 −2 src/gui/config_dialog/roman_table_editor.cc
  19. +8 −3 src/gui/config_dialog/roman_table_editor.h
  20. +9 −8 src/gui/dictionary_tool/dictionary_tool.cc
  21. +7 −5 src/gui/dictionary_tool/dictionary_tool.h
  22. +6 −2 src/gui/post_install_dialog/post_install_dialog.h
  23. +4 −2 src/gui/set_default_dialog/set_default_dialog.cc
  24. +6 −4 src/gui/tool/mozc_tool_libmain.cc
  25. +4 −3 src/gui/tool/prelauncher_libmain.cc
  26. +9 −5 src/gui/word_register_dialog/word_register_dialog.h
  27. +1 −1 src/mozc_version_template.txt
  28. +2 −1 src/prediction/gen_suggestion_filter_main.cc
  29. +2 −1 src/rewriter/gen_existence_data.cc
  30. +6 −6 src/server/mozc_rpc_server_main.cc
  31. +3 −2 src/server/mozc_server.cc
  32. +3 −4 src/storage/encrypted_string_storage_test.cc
  33. +3 −2 src/storage/existence_filter.h
  34. +4 −4 src/storage/existence_filter_test.cc
  35. +3 −3 src/storage/lru_storage.cc
  36. +4 −3 src/storage/lru_storage.h
  37. +2 −2 src/storage/memory_storage_test.cc
  38. +2 −2 src/storage/registry.cc
  39. +2 −2 src/storage/tiny_storage.cc
  40. +3 −3 src/storage/tiny_storage_test.cc
@@ -29,18 +29,17 @@

#include "dictionary/file/codec.h"

#include <memory>

#include "base/file_stream.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/scoped_ptr.h"
#include "base/util.h"
#include "dictionary/file/codec_interface.h"
#include "dictionary/file/section.h"
#include "testing/base/public/googletest.h"
#include "testing/base/public/gunit.h"

DECLARE_string(test_tmpdir);

namespace mozc {
namespace dictionary {
namespace {
@@ -117,7 +116,7 @@ class CodecMock : public DictionaryFileCodecInterface {
};

TEST_F(CodecTest, FactoryTest) {
scoped_ptr<CodecMock> codec_mock(new CodecMock);
std::unique_ptr<CodecMock> codec_mock(new CodecMock);
DictionaryFileCodecFactory::SetCodec(codec_mock.get());
const DictionaryFileCodecInterface *codec =
DictionaryFileCodecFactory::GetCodec();
@@ -185,7 +184,7 @@ TEST_F(CodecTest, DefaultTest) {
}

TEST_F(CodecTest, CodecTest) {
scoped_ptr<DictionaryFileCodec> default_codec(
std::unique_ptr<DictionaryFileCodec> default_codec(
new DictionaryFileCodec);
DictionaryFileCodecFactory::SetCodec(default_codec.get());
const DictionaryFileCodecInterface *codec =
@@ -33,12 +33,12 @@
#ifndef MOZC_DICTIONARY_FILE_DICTIONARY_FILE_H_
#define MOZC_DICTIONARY_FILE_DICTIONARY_FILE_H_

#include <memory>
#include <string>
#include <vector>

#include "base/mmap.h"
#include "base/port.h"
#include "base/scoped_ptr.h"

namespace mozc {
namespace dictionary {
@@ -63,7 +63,7 @@ class DictionaryFile {

private:
// This will be nullptr if the mapping source is given as a pointer.
scoped_ptr<Mmap> mapping_;
std::unique_ptr<Mmap> mapping_;
vector<DictionaryFileSection> sections_;

DISALLOW_COPY_AND_ASSIGN(DictionaryFile);
@@ -35,6 +35,7 @@

#include <algorithm>
#include <limits>
#include <memory>
#include <string>
#include <vector>

@@ -273,7 +274,7 @@ void TextDictionaryLoader::LoadReadingCorrectionTokens(
// We here assume that the wrong reading appear with 1/100 probability
// of the original (correct) reading.
const int kCostPenalty = 2302; // -log(1/100) * 500;
scoped_ptr<Token> token(new Token);
std::unique_ptr<Token> token(new Token);
value_key.second.CopyToString(&token->key);
token->value = max_cost_token->value;
token->lid = max_cost_token->lid;
@@ -314,7 +315,7 @@ Token *TextDictionaryLoader::ParseTSV(
const vector<StringPiece> &columns) const {
CHECK_LE(5, columns.size()) << "Lack of columns: " << columns.size();

scoped_ptr<Token> token(new Token);
std::unique_ptr<Token> token(new Token);

// Parse key, lid, rid, cost, value.
Util::NormalizeVoicedSoundMark(columns[0], &token->key);
@@ -34,8 +34,9 @@

#include <QtGui/QDialog>

#include <memory>

#include "base/port.h"
#include "base/scoped_ptr.h"
#include "gui/about_dialog/ui_about_dialog.h"

class QImage;
@@ -53,7 +54,7 @@ class AboutDialog : public QDialog,
private Ui::AboutDialog {
Q_OBJECT;
public:
explicit AboutDialog(QWidget *parent = NULL);
explicit AboutDialog(QWidget *parent = nullptr);
void SetLinkCallback(LinkCallbackInterface *callback);

void paintEvent(QPaintEvent *event);
@@ -63,7 +64,7 @@ class AboutDialog : public QDialog,

private:
LinkCallbackInterface *callback_;
scoped_ptr<QImage> product_image_;
std::unique_ptr<QImage> product_image_;
};

} // namespace mozc::gui
@@ -30,8 +30,9 @@
#ifndef MOZC_GUI_BASE_SETUP_UTIL_H_
#define MOZC_GUI_BASE_SETUP_UTIL_H_

#include <memory>

#include "base/port.h"
#include "base/scoped_ptr.h"

namespace mozc {

@@ -72,12 +73,13 @@ class SetupUtil {
// Imports MS-IME's user dictionary to Mozc' dictionary
bool MigrateDictionaryFromMSIME();

scoped_ptr<UserDictionaryStorage> storage_;
std::unique_ptr<UserDictionaryStorage> storage_;

bool is_userdictionary_locked_;

DISALLOW_COPY_AND_ASSIGN(SetupUtil);
};

} // namespace gui
} // namespace mozc

@@ -44,10 +44,10 @@
#ifndef MOZC_GUI_BASE_SINGLETON_WINDOW_HELPER_H_
#define MOZC_GUI_BASE_SINGLETON_WINDOW_HELPER_H_

#include <memory>
#include <string>

#include "base/port.h"
#include "base/scoped_ptr.h"

namespace mozc {
class ProcessMutex;
@@ -66,10 +66,11 @@ class SingletonWindowHelper {
bool ActivatePreviousWindow();

private:
scoped_ptr<ProcessMutex> mutex_;
std::unique_ptr<ProcessMutex> mutex_;

DISALLOW_COPY_AND_ASSIGN(SingletonWindowHelper);
};

} // namespace gui
} // namespace mozc

@@ -33,6 +33,9 @@

#include <QtGui/QApplication>
#include <QtCore/QFile>

#include <memory>

#include "base/logging.h"
#include "base/system_util.h"
#include "base/util.h"
@@ -59,6 +62,7 @@ enum {
CHARACTER_PALETTE,
HAND_WRITING
};

} // namespace

int RunCharacterPad(int argc, char *argv[],
@@ -70,7 +74,7 @@ int RunCharacterPad(int argc, char *argv[],

mozc::gui::LocaleUtil::InstallTranslationMessageAndFont("character_pad");

scoped_ptr<QMainWindow> window;
std::unique_ptr<QMainWindow> window;

if (mode == HAND_WRITING) {
window.reset(new mozc::gui::HandWriting);
@@ -32,8 +32,10 @@

#include <QtCore/QMap>
#include <QtGui/QMainWindow>

#include <memory>

#include "base/port.h"
#include "base/scoped_ptr.h"
#include "gui/character_pad/ui_character_palette.h"

class QTextCodec;
@@ -86,7 +88,7 @@ class CharacterPalette : public QMainWindow,
bool winEvent(MSG *message, long *result);
#endif // OS_WIN

scoped_ptr<client::ClientInterface> client_;
std::unique_ptr<client::ClientInterface> client_;
bool usage_stats_enabled_;

private:
@@ -32,7 +32,8 @@

#include <QtGui/QMainWindow>

#include "base/scoped_ptr.h"
#include <memory>

#include "gui/character_pad/ui_hand_writing.h"

namespace mozc {
@@ -71,7 +72,7 @@ class HandWriting : public QMainWindow,

void updateHandwritingSource(int index);

scoped_ptr<client::ClientInterface> client_;
std::unique_ptr<client::ClientInterface> client_;
bool usage_stats_enabled_;
// Do not depend on CloudHandwriting class to keep dependencies
// minimum.
@@ -84,9 +85,9 @@ class HandWriting : public QMainWindow,
// necessary and updates the current config as
// |config.set_allow_cloud_handwriting(true)| when it is allowed.
bool TryToEnableCloudHandwriting();
scoped_ptr<mozc::handwriting::HandwritingInterface> cloud_handwriting_;
std::unique_ptr<mozc::handwriting::HandwritingInterface> cloud_handwriting_;
#endif // ENABLE_CLOUD_HANDWRITING
scoped_ptr<mozc::handwriting::HandwritingInterface> zinnia_handwriting_;
std::unique_ptr<mozc::handwriting::HandwritingInterface> zinnia_handwriting_;
};
} // namespace gui
} // namespace mozc
@@ -27,9 +27,13 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "gui/config_dialog/character_form_editor.h"

#include <QtGui/QtGui>

#include <memory>

#include "config/config_handler.h"
#include "gui/config_dialog/character_form_editor.h"
#include "gui/config_dialog/combobox_delegate.h"

namespace mozc {
@@ -117,7 +121,7 @@ void CharacterFormEditor::Load(const config::Config &config) {
header << tr("Group") << tr("Composition") << tr("Conversion");
setHorizontalHeaderLabels(header);

scoped_ptr<config::Config> default_config;
std::unique_ptr<config::Config> default_config;
const config::Config *target_config = &config;

// make sure that table isn't empty.
@@ -31,8 +31,10 @@
#define MOZC_GUI_CONFIG_DIALOG_CHARACTER_FORM_EDITOR_H_

#include <QtGui/QTableWidget>

#include <memory>

#include "base/port.h"
#include "base/scoped_ptr.h"
#include "protocol/config.pb.h"

namespace mozc {
@@ -54,10 +56,11 @@ class CharacterFormEditor : public QTableWidget {
void Save(config::Config *config);

private:
scoped_ptr<ComboBoxDelegate> delegate_;
std::unique_ptr<ComboBoxDelegate> delegate_;
};
} // gui
} // mozc

} // namespace gui
} // namespace mozc

#if defined UI_CONFIG_DIALOG_H
using mozc::gui::CharacterFormEditor;
@@ -36,9 +36,12 @@
#endif

#include <QtGui/QMessageBox>

#include <algorithm>
#include <cstdlib>
#include <memory>
#include <sstream>

#include "base/config_file_stream.h"
#include "base/const.h"
#include "base/logging.h"
@@ -815,7 +818,7 @@ void ConfigDialog::EditKeymap() {
// Load from predefined mapping file.
const char *keymap_file =
keymap::KeyMapManager::GetKeyMapFileName(itr->second);
scoped_ptr<istream> ifs(
std::unique_ptr<istream> ifs(
ConfigFileStream::LegacyOpen(keymap_file));
CHECK(ifs.get() != NULL); // should never happen
stringstream buffer;
@@ -34,10 +34,12 @@

#include <QtCore/QObject>
#include <QtCore/QTimer>

#include <map>
#include <memory>
#include <string>

#include "base/port.h"
#include "base/scoped_ptr.h"
#include "gui/config_dialog/ui_config_dialog.h"
#include "protocol/config.pb.h"

@@ -100,7 +102,7 @@ class ConfigDialog : public QDialog,
bool Update();
void Reload();

scoped_ptr<client::ClientInterface> client_;
std::unique_ptr<client::ClientInterface> client_;
string custom_keymap_table_;
string custom_roman_table_;
config::Config::InformationListConfig information_list_config_;
@@ -32,9 +32,11 @@

#include <QtGui/QtGui>
#include <QtGui/QDialog>

#include <memory>
#include <string>

#include "base/port.h"
#include "base/scoped_ptr.h"
#include "gui/config_dialog/ui_keybinding_editor.h"

namespace mozc {
@@ -75,8 +77,10 @@ class KeyBindingEditor : public QDialog,

private:
QWidget *trigger_parent_;
scoped_ptr<KeyBindingFilter> filter_;
std::unique_ptr<KeyBindingFilter> filter_;
};
} // namespace mozc::gui

} // namespace gui
} // namespace mozc

#endif // MOZC_GUI_CONFIG_DIALOG_KEYBINDING_EDITOR_H_
@@ -32,6 +32,8 @@
#include <QtGui/QtGui>
#include <QtGui/QPushButton>

#include <memory>

#include "base/logging.h"
#include "gui/config_dialog/keybinding_editor.h"

@@ -55,7 +57,7 @@ class KeyBindingEditorTriggerButton : public QPushButton {
}

private:
scoped_ptr<KeyBindingEditor> editor_;
std::unique_ptr<KeyBindingEditor> editor_;
};

KeyBindingEditorDelegate::KeyBindingEditorDelegate(QObject *parent)

0 comments on commit b3330bb

Please sign in to comment.
You can’t perform that action at this time.