Skip to content

Commit b3330bb

Browse files
Noriyuki Takahashiyukawa
Noriyuki Takahashi
authored andcommitted
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
1 parent d56d5db commit b3330bb

40 files changed

+177
-113
lines changed

src/dictionary/file/codec_test.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,17 @@
2929

3030
#include "dictionary/file/codec.h"
3131

32+
#include <memory>
33+
3234
#include "base/file_stream.h"
3335
#include "base/file_util.h"
3436
#include "base/logging.h"
35-
#include "base/scoped_ptr.h"
3637
#include "base/util.h"
3738
#include "dictionary/file/codec_interface.h"
3839
#include "dictionary/file/section.h"
3940
#include "testing/base/public/googletest.h"
4041
#include "testing/base/public/gunit.h"
4142

42-
DECLARE_string(test_tmpdir);
43-
4443
namespace mozc {
4544
namespace dictionary {
4645
namespace {
@@ -117,7 +116,7 @@ class CodecMock : public DictionaryFileCodecInterface {
117116
};
118117

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

187186
TEST_F(CodecTest, CodecTest) {
188-
scoped_ptr<DictionaryFileCodec> default_codec(
187+
std::unique_ptr<DictionaryFileCodec> default_codec(
189188
new DictionaryFileCodec);
190189
DictionaryFileCodecFactory::SetCodec(default_codec.get());
191190
const DictionaryFileCodecInterface *codec =

src/dictionary/file/dictionary_file.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
#ifndef MOZC_DICTIONARY_FILE_DICTIONARY_FILE_H_
3434
#define MOZC_DICTIONARY_FILE_DICTIONARY_FILE_H_
3535

36+
#include <memory>
3637
#include <string>
3738
#include <vector>
3839

3940
#include "base/mmap.h"
4041
#include "base/port.h"
41-
#include "base/scoped_ptr.h"
4242

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

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

6969
DISALLOW_COPY_AND_ASSIGN(DictionaryFile);

src/dictionary/text_dictionary_loader.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#include <algorithm>
3737
#include <limits>
38+
#include <memory>
3839
#include <string>
3940
#include <vector>
4041

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

317-
scoped_ptr<Token> token(new Token);
318+
std::unique_ptr<Token> token(new Token);
318319

319320
// Parse key, lid, rid, cost, value.
320321
Util::NormalizeVoicedSoundMark(columns[0], &token->key);

src/gui/about_dialog/about_dialog.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@
3434

3535
#include <QtGui/QDialog>
3636

37+
#include <memory>
38+
3739
#include "base/port.h"
38-
#include "base/scoped_ptr.h"
3940
#include "gui/about_dialog/ui_about_dialog.h"
4041

4142
class QImage;
@@ -53,7 +54,7 @@ class AboutDialog : public QDialog,
5354
private Ui::AboutDialog {
5455
Q_OBJECT;
5556
public:
56-
explicit AboutDialog(QWidget *parent = NULL);
57+
explicit AboutDialog(QWidget *parent = nullptr);
5758
void SetLinkCallback(LinkCallbackInterface *callback);
5859

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

6465
private:
6566
LinkCallbackInterface *callback_;
66-
scoped_ptr<QImage> product_image_;
67+
std::unique_ptr<QImage> product_image_;
6768
};
6869

6970
} // namespace mozc::gui

src/gui/base/setup_util.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
#ifndef MOZC_GUI_BASE_SETUP_UTIL_H_
3131
#define MOZC_GUI_BASE_SETUP_UTIL_H_
3232

33+
#include <memory>
34+
3335
#include "base/port.h"
34-
#include "base/scoped_ptr.h"
3536

3637
namespace mozc {
3738

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

75-
scoped_ptr<UserDictionaryStorage> storage_;
76+
std::unique_ptr<UserDictionaryStorage> storage_;
7677

7778
bool is_userdictionary_locked_;
7879

7980
DISALLOW_COPY_AND_ASSIGN(SetupUtil);
8081
};
82+
8183
} // namespace gui
8284
} // namespace mozc
8385

src/gui/base/singleton_window_helper.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444
#ifndef MOZC_GUI_BASE_SINGLETON_WINDOW_HELPER_H_
4545
#define MOZC_GUI_BASE_SINGLETON_WINDOW_HELPER_H_
4646

47+
#include <memory>
4748
#include <string>
4849

4950
#include "base/port.h"
50-
#include "base/scoped_ptr.h"
5151

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

6868
private:
69-
scoped_ptr<ProcessMutex> mutex_;
69+
std::unique_ptr<ProcessMutex> mutex_;
7070

7171
DISALLOW_COPY_AND_ASSIGN(SingletonWindowHelper);
7272
};
73+
7374
} // namespace gui
7475
} // namespace mozc
7576

src/gui/character_pad/character_pad_libmain.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333

3434
#include <QtGui/QApplication>
3535
#include <QtCore/QFile>
36+
37+
#include <memory>
38+
3639
#include "base/logging.h"
3740
#include "base/system_util.h"
3841
#include "base/util.h"
@@ -59,6 +62,7 @@ enum {
5962
CHARACTER_PALETTE,
6063
HAND_WRITING
6164
};
65+
6266
} // namespace
6367

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

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

73-
scoped_ptr<QMainWindow> window;
77+
std::unique_ptr<QMainWindow> window;
7478

7579
if (mode == HAND_WRITING) {
7680
window.reset(new mozc::gui::HandWriting);

src/gui/character_pad/character_palette.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@
3232

3333
#include <QtCore/QMap>
3434
#include <QtGui/QMainWindow>
35+
36+
#include <memory>
37+
3538
#include "base/port.h"
36-
#include "base/scoped_ptr.h"
3739
#include "gui/character_pad/ui_character_palette.h"
3840

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

89-
scoped_ptr<client::ClientInterface> client_;
91+
std::unique_ptr<client::ClientInterface> client_;
9092
bool usage_stats_enabled_;
9193

9294
private:

src/gui/character_pad/hand_writing.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232

3333
#include <QtGui/QMainWindow>
3434

35-
#include "base/scoped_ptr.h"
35+
#include <memory>
36+
3637
#include "gui/character_pad/ui_hand_writing.h"
3738

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

7273
void updateHandwritingSource(int index);
7374

74-
scoped_ptr<client::ClientInterface> client_;
75+
std::unique_ptr<client::ClientInterface> client_;
7576
bool usage_stats_enabled_;
7677
// Do not depend on CloudHandwriting class to keep dependencies
7778
// minimum.
@@ -84,9 +85,9 @@ class HandWriting : public QMainWindow,
8485
// necessary and updates the current config as
8586
// |config.set_allow_cloud_handwriting(true)| when it is allowed.
8687
bool TryToEnableCloudHandwriting();
87-
scoped_ptr<mozc::handwriting::HandwritingInterface> cloud_handwriting_;
88+
std::unique_ptr<mozc::handwriting::HandwritingInterface> cloud_handwriting_;
8889
#endif // ENABLE_CLOUD_HANDWRITING
89-
scoped_ptr<mozc::handwriting::HandwritingInterface> zinnia_handwriting_;
90+
std::unique_ptr<mozc::handwriting::HandwritingInterface> zinnia_handwriting_;
9091
};
9192
} // namespace gui
9293
} // namespace mozc

src/gui/config_dialog/character_form_editor.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@
2727
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2828
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929

30+
#include "gui/config_dialog/character_form_editor.h"
31+
3032
#include <QtGui/QtGui>
33+
34+
#include <memory>
35+
3136
#include "config/config_handler.h"
32-
#include "gui/config_dialog/character_form_editor.h"
3337
#include "gui/config_dialog/combobox_delegate.h"
3438

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

120-
scoped_ptr<config::Config> default_config;
124+
std::unique_ptr<config::Config> default_config;
121125
const config::Config *target_config = &config;
122126

123127
// make sure that table isn't empty.

src/gui/config_dialog/character_form_editor.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131
#define MOZC_GUI_CONFIG_DIALOG_CHARACTER_FORM_EDITOR_H_
3232

3333
#include <QtGui/QTableWidget>
34+
35+
#include <memory>
36+
3437
#include "base/port.h"
35-
#include "base/scoped_ptr.h"
3638
#include "protocol/config.pb.h"
3739

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

5658
private:
57-
scoped_ptr<ComboBoxDelegate> delegate_;
59+
std::unique_ptr<ComboBoxDelegate> delegate_;
5860
};
59-
} // gui
60-
} // mozc
61+
62+
} // namespace gui
63+
} // namespace mozc
6164

6265
#if defined UI_CONFIG_DIALOG_H
6366
using mozc::gui::CharacterFormEditor;

src/gui/config_dialog/config_dialog.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@
3636
#endif
3737

3838
#include <QtGui/QMessageBox>
39+
3940
#include <algorithm>
4041
#include <cstdlib>
42+
#include <memory>
4143
#include <sstream>
44+
4245
#include "base/config_file_stream.h"
4346
#include "base/const.h"
4447
#include "base/logging.h"
@@ -815,7 +818,7 @@ void ConfigDialog::EditKeymap() {
815818
// Load from predefined mapping file.
816819
const char *keymap_file =
817820
keymap::KeyMapManager::GetKeyMapFileName(itr->second);
818-
scoped_ptr<istream> ifs(
821+
std::unique_ptr<istream> ifs(
819822
ConfigFileStream::LegacyOpen(keymap_file));
820823
CHECK(ifs.get() != NULL); // should never happen
821824
stringstream buffer;

src/gui/config_dialog/config_dialog.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@
3434

3535
#include <QtCore/QObject>
3636
#include <QtCore/QTimer>
37+
3738
#include <map>
39+
#include <memory>
3840
#include <string>
41+
3942
#include "base/port.h"
40-
#include "base/scoped_ptr.h"
4143
#include "gui/config_dialog/ui_config_dialog.h"
4244
#include "protocol/config.pb.h"
4345

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

103-
scoped_ptr<client::ClientInterface> client_;
105+
std::unique_ptr<client::ClientInterface> client_;
104106
string custom_keymap_table_;
105107
string custom_roman_table_;
106108
config::Config::InformationListConfig information_list_config_;

src/gui/config_dialog/keybinding_editor.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@
3232

3333
#include <QtGui/QtGui>
3434
#include <QtGui/QDialog>
35+
36+
#include <memory>
3537
#include <string>
38+
3639
#include "base/port.h"
37-
#include "base/scoped_ptr.h"
3840
#include "gui/config_dialog/ui_keybinding_editor.h"
3941

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

7678
private:
7779
QWidget *trigger_parent_;
78-
scoped_ptr<KeyBindingFilter> filter_;
80+
std::unique_ptr<KeyBindingFilter> filter_;
7981
};
80-
} // namespace mozc::gui
82+
83+
} // namespace gui
8184
} // namespace mozc
85+
8286
#endif // MOZC_GUI_CONFIG_DIALOG_KEYBINDING_EDITOR_H_

src/gui/config_dialog/keybinding_editor_delegate.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include <QtGui/QtGui>
3333
#include <QtGui/QPushButton>
3434

35+
#include <memory>
36+
3537
#include "base/logging.h"
3638
#include "gui/config_dialog/keybinding_editor.h"
3739

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

5759
private:
58-
scoped_ptr<KeyBindingEditor> editor_;
60+
std::unique_ptr<KeyBindingEditor> editor_;
5961
};
6062

6163
KeyBindingEditorDelegate::KeyBindingEditorDelegate(QObject *parent)

0 commit comments

Comments
 (0)