Update from the upstream.
* Updates for Python3 / MacSDK 10.15 / MSVS 2017
* Some code refactoring
Hiroyuki Komatsu
3 years ago
32 | 32 | python build_mozc.py runtests -c Debug |
33 | 33 | ``` |
34 | 34 | |
35 | Experimental: Instead of build_mozc.py, you can try to use Bazel. | |
36 | ||
37 | ``` | |
38 | bazel build package --config oss_linux | |
39 | ``` | |
40 | ||
41 | `package` is an alias to build `server:mozc_server` and `gui/tool:mozc_tool`. | |
42 | ||
43 | ||
35 | 44 | ### Build Mozc library for Android: |
36 | 45 | |
37 | 46 | Client code for Android apk is deprecated. |
41 | 50 | The conversion engine for Android is built with Bazel. |
42 | 51 | |
43 | 52 | ``` |
44 | bazel build android/jni:mozc_lib --config oss_android | |
53 | bazel build package --config oss_android | |
45 | 54 | ``` |
46 | 55 | |
56 | `package` is an alias to build `android/jni:mozc_lib`. | |
47 | 57 | |
48 | 58 | ## Build configurations for Linux desktop |
49 | 59 | In `python build_mozc.py gyp` step, there are two different styles to customize configurations. One is `GYP_DEFINES` environment variable and the other is commandline option. |
30 | 30 | # Description: |
31 | 31 | # Declaration of package_group for visibility managing. |
32 | 32 | |
33 | load("//:build_defs.bzl", "select_mozc") | |
33 | 34 | load("//tools/build_defs:stubs.bzl", "bzl_library") |
34 | 35 | |
35 | 36 | package_group( |
125 | 126 | name = "build_defs_bzl", |
126 | 127 | srcs = ["build_defs.bzl"], |
127 | 128 | parse_tests = False, |
128 | visibility = ["//visibility:private"], | |
129 | visibility = ["//:__subpackages__"], | |
129 | 130 | ) |
131 | ||
132 | filegroup( | |
133 | name = "package", | |
134 | srcs = select_mozc( | |
135 | default = [], | |
136 | oss_android = ["//android/jni:mozc_lib"], | |
137 | oss_linux = [ | |
138 | "//gui/tool:mozc_tool", | |
139 | "//server:mozc_server", | |
140 | ], | |
141 | ), | |
142 | ) |
35 | 35 | # tag = "v3.6.0.1", # 2018-06-09 |
36 | 36 | # ) |
37 | 37 | |
38 | # Japanese Usage Dictionary | |
39 | new_local_repository( | |
40 | name = "ja_usage_dict", | |
41 | path = "third_party/japanese_usage_dictionary", | |
42 | build_file = "BUILD.ja_usage_dict", | |
43 | ) | |
44 | ||
45 | # Qt | |
38 | 46 | new_local_repository( |
39 | 47 | name = "io_qt", |
40 | 48 | # This path should be updated per the environment. |
40 | 40 | |
41 | 41 | __author__ = "hidehiko" |
42 | 42 | |
43 | import cStringIO as StringIO | |
43 | import io | |
44 | 44 | import logging |
45 | 45 | import optparse |
46 | 46 | import os |
288 | 288 | def _ConsumeFloatList(self, s, num): |
289 | 289 | """Parses num floating values from s.""" |
290 | 290 | result = [] |
291 | for _ in xrange(num): | |
291 | for _ in range(num): | |
292 | 292 | value, s = self._ConsumeFloat(s) |
293 | 293 | result.append(value) |
294 | 294 | return result, s |
1034 | 1034 | |
1035 | 1035 | # Interface for drawable conversion. |
1036 | 1036 | def ConvertPictureDrawable(self, path): |
1037 | output = _OutputStream(StringIO.StringIO()) | |
1037 | output = _OutputStream(io.BytesIO()) | |
1038 | 1038 | self._ConvertPictureDrawableInternal(ElementTree.parse(path), output) |
1039 | 1039 | return output.output.getvalue() |
1040 | 1040 | |
1041 | 1041 | def ConvertStateListDrawable(self, drawable_source_list): |
1042 | output = _OutputStream(StringIO.StringIO()) | |
1042 | output = _OutputStream(io.BytesIO()) | |
1043 | 1043 | output.WriteByte(DRAWABLE_STATE_LIST) |
1044 | 1044 | output.WriteByte(len(drawable_source_list)) |
1045 | 1045 | for (state_list, path) in drawable_source_list: |
34 | 34 | # Usage: |
35 | 35 | # % blaze --blazerc android/blazerc build --config=android_arm android/jni:libmozc.so |
36 | 36 | |
37 | load( | |
38 | "//:build_defs.bzl", | |
39 | "cc_library_mozc", | |
40 | ) | |
37 | load("//:build_defs.bzl", "cc_library_mozc") | |
41 | 38 | |
42 | 39 | cc_library_mozc( |
43 | 40 | name = "mozc_lib", |
44 | 41 | srcs = ["mozcjni.cc"], |
42 | visibility = ["//:__pkg__"], | |
45 | 43 | deps = [ |
46 | 44 | "//base:logging", |
47 | 45 | "//base:singleton", |
514 | 514 | 'target_name': 'breakpad', |
515 | 515 | 'type': 'none', |
516 | 516 | 'variables': { |
517 | 'pbdir': '<(third_party_dir)/breakpad', | |
517 | 'bpdir': '<(third_party_dir)/breakpad', | |
518 | 518 | }, |
519 | 519 | 'actions': [{ |
520 | 520 | 'action_name': 'build_breakpad', |
521 | 521 | 'inputs': [ |
522 | '<(pbdir)/src/client/mac/Breakpad.xcodeproj/project.pbxproj', | |
522 | '<(bpdir)/src/client/mac/Breakpad.xcodeproj/project.pbxproj', | |
523 | 523 | ], |
524 | 524 | 'outputs': [ |
525 | 525 | '<(mac_breakpad_dir)/Breakpad.framework', |
529 | 529 | ], |
530 | 530 | 'action': [ |
531 | 531 | '<(python)', '../build_tools/build_breakpad.py', |
532 | '--pbdir', '<(pbdir)', | |
532 | '--bpdir', '<(bpdir)', | |
533 | 533 | '--outdir', '<(mac_breakpad_dir)', |
534 | 534 | '--sdk', 'macosx<(mac_sdk)', |
535 | 535 | '--deployment_target', '<(mac_deployment_target)', |
144 | 144 | const uint32 lo = Fingerprint32WithSeed(str, kFingerPrintSeed1); |
145 | 145 | uint64 result = static_cast<uint64>(hi) << 32 | static_cast<uint64>(lo); |
146 | 146 | if ((hi == 0) && (lo < 2)) { |
147 | result ^= GG_ULONGLONG(0x130f9bef94a0a928); | |
147 | result ^= 0x130f9bef94a0a928uLL; | |
148 | 148 | } |
149 | 149 | return result; |
150 | 150 | } |
115 | 115 | |
116 | 116 | value_type operator*() { return adapter_(iter_); } |
117 | 117 | |
118 | // MSVS 2017 requires this definition. | |
119 | // See: https://github.com/tensorflow/tensorflow/issues/15925 | |
120 | value_type operator*() const { return adapter_(iter_); } | |
121 | ||
118 | 122 | pointer operator->() const { return &(operator*()); } |
119 | 123 | |
120 | 124 | IteratorAdapter &operator++() { |
537 | 537 | // return false when an integer overflow happens. |
538 | 538 | bool AddAndCheckOverflow(uint64 arg1, uint64 arg2, uint64 *output) { |
539 | 539 | *output = arg1 + arg2; |
540 | if (arg2 > (kuint64max - arg1)) { | |
540 | if (arg2 > (std::numeric_limits<uint64>::max() - arg1)) { | |
541 | 541 | // overflow happens |
542 | 542 | return false; |
543 | 543 | } |
548 | 548 | // return false when an integer overflow happens. |
549 | 549 | bool MultiplyAndCheckOverflow(uint64 arg1, uint64 arg2, uint64 *output) { |
550 | 550 | *output = arg1 * arg2; |
551 | if (arg1 != 0 && arg2 > (kuint64max / arg1)) { | |
551 | if (arg1 != 0 && arg2 > (std::numeric_limits<uint64>::max() / arg1)) { | |
552 | 552 | // overflow happens |
553 | 553 | return false; |
554 | 554 | } |
618 | 618 | |
619 | 619 | template <> |
620 | 620 | bool SafeCast(int64 src, int16 *dest) { |
621 | if (src < static_cast<int64>(kint16min) || | |
622 | static_cast<int64>(kint16max) < src) { | |
621 | if (src < static_cast<int64>(std::numeric_limits<int16>::min()) || | |
622 | static_cast<int64>(std::numeric_limits<int16>::max()) < src) { | |
623 | 623 | return false; |
624 | 624 | } |
625 | 625 | *dest = static_cast<int16>(src); |
628 | 628 | |
629 | 629 | template <> |
630 | 630 | bool SafeCast(int64 src, int32 *dest) { |
631 | if (src < static_cast<int64>(kint32min) || | |
632 | static_cast<int64>(kint32max) < src) { | |
631 | if (src < static_cast<int64>(std::numeric_limits<int32>::min()) || | |
632 | static_cast<int64>(std::numeric_limits<int32>::max()) < src) { | |
633 | 633 | return false; |
634 | 634 | } |
635 | 635 | *dest = static_cast<int32>(src); |
638 | 638 | |
639 | 639 | template <> |
640 | 640 | bool SafeCast(uint64 src, int64 *dest) { |
641 | if (src > static_cast<uint64>(kint64max)) { | |
641 | if (src > static_cast<uint64>(std::numeric_limits<int64>::max())) { | |
642 | 642 | return false; |
643 | 643 | } |
644 | 644 | *dest = static_cast<int64>(src); |
647 | 647 | |
648 | 648 | template <> |
649 | 649 | bool SafeCast(uint64 src, uint16 *dest) { |
650 | if (src > static_cast<uint64>(kuint16max)) { | |
650 | if (src > static_cast<uint64>(std::numeric_limits<uint16>::max())) { | |
651 | 651 | return false; |
652 | 652 | } |
653 | 653 | *dest = static_cast<uint16>(src); |
656 | 656 | |
657 | 657 | template <> |
658 | 658 | bool SafeCast(uint64 src, uint32 *dest) { |
659 | if (src > static_cast<uint64>(kuint32max)) { | |
659 | if (src > static_cast<uint64>(std::numeric_limits<uint32>::max())) { | |
660 | 660 | return false; |
661 | 661 | } |
662 | 662 | *dest = static_cast<uint32>(src); |
677 | 677 | if (src == 0x8000000000000000ul) { |
678 | 678 | // This is an exceptional case. |src| isn't in the range of int64, |
679 | 679 | // but |-src| is in the range. |
680 | *dest = kint64min; | |
680 | *dest = std::numeric_limits<int64>::min(); | |
681 | 681 | return true; |
682 | 682 | } |
683 | 683 | return false; |
965 | 965 | // "一十二百" = [1, 10, 2, 100] => error |
966 | 966 | bool InterpretNumbersInJapaneseWay(const std::vector<uint64> &numbers, |
967 | 967 | uint64 *output) { |
968 | uint64 last_base = kuint64max; | |
968 | uint64 last_base = std::numeric_limits<uint64>::max(); | |
969 | 969 | auto begin = numbers.begin(); |
970 | 970 | *output = 0; |
971 | 971 | do { |
28 | 28 | |
29 | 29 | #include "base/number_util.h" |
30 | 30 | |
31 | #include <limits> | |
32 | ||
31 | 33 | #include "base/port.h" |
32 | 34 | #include "testing/base/public/googletest.h" |
33 | 35 | #include "testing/base/public/gunit.h" |
71 | 73 | EXPECT_EQ(-12345, value); |
72 | 74 | value = 0x4321; |
73 | 75 | EXPECT_TRUE(NumberUtil::SafeStrToInt16("-32768", &value)); |
74 | EXPECT_EQ(kint16min, value); // min of 16-bit signed integer | |
76 | EXPECT_EQ(std::numeric_limits<int16>::min(), value); | |
75 | 77 | value = 0x4321; |
76 | 78 | EXPECT_TRUE(NumberUtil::SafeStrToInt16("32767", &value)); |
77 | EXPECT_EQ(kint16max, value); // max of 16-bit signed integer | |
79 | EXPECT_EQ(std::numeric_limits<int16>::max(), value); | |
78 | 80 | value = 0x4321; |
79 | 81 | EXPECT_TRUE(NumberUtil::SafeStrToInt16(" 1", &value)); |
80 | 82 | EXPECT_EQ(1, value); |
131 | 133 | EXPECT_EQ(-12345678, value); |
132 | 134 | value = 0xDEADBEEF; |
133 | 135 | EXPECT_TRUE(NumberUtil::SafeStrToInt32("-2147483648", &value)); |
134 | EXPECT_EQ(kint32min, value); // min of 32-bit signed integer | |
136 | EXPECT_EQ(std::numeric_limits<int32>::min(), value); | |
135 | 137 | value = 0xDEADBEEF; |
136 | 138 | EXPECT_TRUE(NumberUtil::SafeStrToInt32("2147483647", &value)); |
137 | EXPECT_EQ(kint32max, value); // max of 32-bit signed integer | |
139 | EXPECT_EQ(std::numeric_limits<int32>::max(), value); | |
138 | 140 | value = 0xDEADBEEF; |
139 | 141 | EXPECT_TRUE(NumberUtil::SafeStrToInt32(" 1", &value)); |
140 | 142 | EXPECT_EQ(1, value); |
192 | 194 | EXPECT_EQ(-12345678, value); |
193 | 195 | value = 0xDEADBEEF; |
194 | 196 | EXPECT_TRUE(NumberUtil::SafeStrToInt64("-9223372036854775808", &value)); |
195 | EXPECT_EQ(kint64min, value); // min of 64-bit signed integer | |
197 | EXPECT_EQ(std::numeric_limits<int64>::min(), value); | |
196 | 198 | value = 0xDEADBEEF; |
197 | 199 | EXPECT_TRUE(NumberUtil::SafeStrToInt64("9223372036854775807", &value)); |
198 | EXPECT_EQ(kint64max, value); // max of 64-bit signed integer | |
200 | EXPECT_EQ(std::numeric_limits<int64>::max(), value); | |
199 | 201 | |
200 | 202 | EXPECT_FALSE(NumberUtil::SafeStrToInt64("-9223372036854775809", // overflow |
201 | 203 | &value)); |
75 | 75 | #undef MOZC_OS_DEFINED |
76 | 76 | |
77 | 77 | |
78 | #ifndef _MSC_VER | |
79 | #if !defined(__STDC_FORMAT_MACROS) | |
80 | #define __STDC_FORMAT_MACROS | |
81 | #endif // !__STDC_FORMAT_MACROS | |
82 | #include <inttypes.h> | |
83 | #endif // _MSC_VER | |
84 | #include <stdint.h> | |
85 | #include <sys/types.h> | |
86 | #include <cstddef> | |
78 | ||
79 | #ifdef GOOGLE_JAPANESE_INPUT_BUILD | |
80 | ||
81 | #include "absl/base/attributes.h" | |
82 | #include "absl/base/integral_types.h" | |
83 | #include "absl/base/macros.h" | |
84 | ||
85 | #else // GOOGLE_JAPANESE_INPUT_BUILD | |
86 | ||
87 | #include <cstdint> | |
87 | 88 | |
88 | 89 | #include "absl/base/attributes.h" |
89 | 90 | #include "absl/base/macros.h" |
90 | 91 | |
91 | #ifdef GOOGLE_JAPANESE_INPUT_BUILD | |
92 | #include "absl/base/integral_types.h" | |
93 | #else // GOOGLE_JAPANESE_INPUT_BUILD | |
92 | // Integral types. | |
93 | typedef std::int8_t int8; | |
94 | typedef std::int16_t int16; | |
95 | typedef std::int32_t int32; | |
96 | typedef std::int64_t int64; | |
94 | 97 | |
95 | // Integral types. | |
96 | typedef signed char int8; | |
97 | typedef short int16; // NOLINT | |
98 | typedef int int32; | |
99 | #ifdef COMPILER_MSVC | |
100 | typedef __int64 int64; | |
101 | #else | |
102 | typedef long long int64; // NOLINT | |
103 | #endif /* COMPILER_MSVC */ | |
104 | ||
105 | typedef unsigned char uint8; | |
106 | typedef unsigned short uint16; // NOLINT | |
107 | typedef unsigned int uint32; | |
108 | #ifdef COMPILER_MSVC | |
109 | typedef unsigned __int64 uint64; | |
110 | #else | |
111 | typedef unsigned long long uint64; // NOLINT | |
112 | #endif /* COMPILER_MSVC */ | |
98 | typedef std::uint8_t uint8; | |
99 | typedef std::uint16_t uint16; | |
100 | typedef std::uint32_t uint32; | |
101 | typedef std::uint64_t uint64; | |
113 | 102 | |
114 | 103 | typedef signed int char32; |
115 | ||
116 | #ifdef COMPILER_MSVC /* if Visual C++ */ | |
117 | ||
118 | // VC++ long long suffixes | |
119 | #define GG_LONGLONG(x) x##I64 | |
120 | #define GG_ULONGLONG(x) x##UI64 | |
121 | ||
122 | #else /* not Visual C++ */ | |
123 | ||
124 | #define GG_LONGLONG(x) x##LL | |
125 | #define GG_ULONGLONG(x) x##ULL | |
126 | ||
127 | #endif // COMPILER_MSVC | |
128 | ||
129 | // INT_MIN, INT_MAX, UINT_MAX family at Google | |
130 | const uint8 kuint8max{0xFF}; | |
131 | const uint16 kuint16max{0xFFFF}; | |
132 | const uint32 kuint32max{0xFFFFFFFF}; | |
133 | const uint64 kuint64max{GG_ULONGLONG(0xFFFFFFFFFFFFFFFF)}; | |
134 | const int8 kint8min{~0x7F}; | |
135 | const int8 kint8max{0x7F}; | |
136 | const int16 kint16min{~0x7FFF}; | |
137 | const int16 kint16max{0x7FFF}; | |
138 | const int32 kint32min{~0x7FFFFFFF}; | |
139 | const int32 kint32max{0x7FFFFFFF}; | |
140 | const int64 kint64min{GG_LONGLONG(~0x7FFFFFFFFFFFFFFF)}; | |
141 | const int64 kint64max{GG_LONGLONG(0x7FFFFFFFFFFFFFFF)}; | |
142 | 104 | |
143 | 105 | #endif // GOOGLE_JAPANESE_INPUT_BUILD |
144 | 106 |
31 | 31 | #include <climits> |
32 | 32 | #include <cstdlib> |
33 | 33 | #include <cstring> |
34 | #include <limits> | |
34 | 35 | #include <map> |
35 | 36 | #include <sstream> |
36 | 37 | #include <string> |
37 | 38 | |
38 | #include "base/compiler_specific.h" | |
39 | 39 | #include "base/file_stream.h" |
40 | 40 | #include "base/file_util.h" |
41 | 41 | #include "base/logging.h" |
1934 | 1934 | uint64 value; |
1935 | 1935 | } kCorrectPairs[] = { |
1936 | 1936 | {"\x00\x00\x00\x00\x00\x00\x00\x00", 0}, |
1937 | {"\x00\x00\x00\x00\x00\x00\x00\xFF", kuint8max}, | |
1938 | {"\x00\x00\x00\x00\x00\x00\xFF\xFF", kuint16max}, | |
1939 | {"\x00\x00\x00\x00\xFF\xFF\xFF\xFF", kuint32max}, | |
1940 | {"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF", kuint64max}, | |
1937 | {"\x00\x00\x00\x00\x00\x00\x00\xFF", std::numeric_limits<uint8>::max()}, | |
1938 | {"\x00\x00\x00\x00\x00\x00\xFF\xFF", std::numeric_limits<uint16>::max()}, | |
1939 | {"\x00\x00\x00\x00\xFF\xFF\xFF\xFF", std::numeric_limits<uint32>::max()}, | |
1940 | {"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF", std::numeric_limits<uint64>::max()}, | |
1941 | 1941 | {"\x01\x23\x45\x67\x89\xAB\xCD\xEF", 0x0123456789ABCDEF}, |
1942 | 1942 | {"\xFE\xDC\xBA\x98\x76\x54\x32\x10", 0xFEDCBA9876543210}, |
1943 | 1943 | }; |
32 | 32 | # so required macros are defined by depending on it. |
33 | 33 | |
34 | 34 | load("//tools/build_defs:build_cleaner.bzl", "register_extension_info") |
35 | load("//tools/build_defs:stubs.bzl", "pytype_strict_binary", "pytype_strict_library") | |
35 | 36 | load("//tools/build_rules/android_cc_test:def.bzl", "android_cc_test") |
36 | 37 | |
37 | 38 | def cc_library_mozc(deps = [], **kwargs): |
91 | 92 | label_regex_for_dep = "{extension_name}", |
92 | 93 | ) |
93 | 94 | |
94 | def py_library_mozc(name, srcs, **kwargs): | |
95 | def py_library_mozc(name, srcs, srcs_version = "PY2AND3", **kwargs): | |
95 | 96 | """py_library wrapper generating import-modified python scripts for iOS.""" |
96 | native.py_library( | |
97 | pytype_strict_library( | |
97 | 98 | name = name, |
98 | 99 | srcs = srcs, |
100 | srcs_version = srcs_version, | |
99 | 101 | **kwargs |
100 | 102 | ) |
101 | 103 | |
104 | 106 | label_regex_for_dep = "{extension_name}", |
105 | 107 | ) |
106 | 108 | |
107 | def py_binary_mozc(name, srcs, python_version = "PY3", **kwargs): | |
109 | def py_binary_mozc(name, srcs, python_version = "PY3", srcs_version = "PY2AND3", **kwargs): | |
108 | 110 | """py_binary wrapper generating import-modified python script for iOS. |
109 | 111 | |
110 | 112 | To use this rule, corresponding py_library_mozc needs to be defined to |
111 | 113 | generate iOS sources. |
112 | 114 | """ |
113 | native.py_binary( | |
115 | pytype_strict_binary( | |
114 | 116 | name = name, |
115 | 117 | srcs = srcs, |
116 | 118 | python_version = python_version, |
119 | srcs_version = srcs_version, | |
120 | test_lib = True, | |
117 | 121 | # This main specifier is required because, without it, py_binary expects |
118 | 122 | # that the file name of source containing main() is name.py. |
119 | 123 | main = srcs[0], |
476 | 476 | gyp_options.extend(['-D', 'target_platform=%s' % target_platform_value]) |
477 | 477 | |
478 | 478 | if IsWindows(): |
479 | gyp_options.extend(['-G', 'msvs_version=2015']) | |
479 | gyp_options.extend(['-G', 'msvs_version=2017']) | |
480 | 480 | |
481 | 481 | if (target_platform == 'Linux' and |
482 | 482 | '%s/unix/ibus/ibus.gyp' % SRC_DIR in gyp_file_names): |
101 | 101 | ], |
102 | 102 | ) |
103 | 103 | |
104 | py_library_mozc( | |
105 | name = "replace_version_lib", | |
106 | srcs = ["replace_version.py"], | |
107 | deps = [":mozc_version_lib"], | |
108 | ) | |
109 | ||
110 | 104 | py_binary_mozc( |
111 | 105 | name = "replace_version", |
112 | 106 | srcs = ["replace_version.py"], |
130 | 124 | name = "zlib_util", |
131 | 125 | srcs = ["zlib_util.py"], |
132 | 126 | visibility = ["//:__subpackages__"], |
133 | deps = [":zlib_util_main_lib"], | |
134 | ) | |
135 | ||
136 | py_library( | |
137 | name = "zlib_util_main_lib", | |
138 | srcs = ["zlib_util.py"], | |
127 | deps = [":zlib_util_lib"], | |
139 | 128 | ) |
140 | 129 | |
141 | 130 | py_library_mozc( |
30 | 30 | """Script building Breakpad for Mozc/Mac. |
31 | 31 | |
32 | 32 | ././tools/build_breakpad.py |
33 | --pbdir ./third_party/breakpad --outdir /tmp/breakpad | |
33 | --bpdir ./third_party/breakpad --outdir /tmp/breakpad | |
34 | 34 | """ |
35 | 35 | |
36 | 36 | from __future__ import absolute_import |
45 | 45 | |
46 | 46 | def ParseOption(): |
47 | 47 | parser = optparse.OptionParser() |
48 | parser.add_option('--pbdir', default='./third_party/breakpad') | |
48 | parser.add_option('--bpdir', default='./third_party/breakpad') | |
49 | 49 | parser.add_option('--outdir', default='./out_mac/Release/Breakpad') |
50 | parser.add_option('--sdk', default='macosx10.14') | |
50 | parser.add_option('--sdk', default='macosx10.15') | |
51 | 51 | parser.add_option('--deployment_target', default='10.9') |
52 | 52 | |
53 | 53 | (opts, _) = parser.parse_args() |
90 | 90 | Xcodebuild(projdir, 'symupload', 'x86_64', sdk, deployment_target, outdir) |
91 | 91 | |
92 | 92 | |
93 | def CreateOutDir(pbdir, outdir): | |
93 | def CreateOutDir(bpdir, outdir): | |
94 | 94 | workdir = os.path.join(outdir, 'src') |
95 | 95 | if not os.path.isdir(workdir): |
96 | 96 | os.makedirs(workdir) |
97 | ProcessCall(['rsync', '-avH', os.path.join(pbdir, 'src/'), workdir]) | |
97 | ProcessCall(['rsync', '-avH', os.path.join(bpdir, 'src/'), workdir]) | |
98 | 98 | |
99 | 99 | |
100 | 100 | def main(): |
101 | 101 | opts = ParseOption() |
102 | pbdir = os.path.abspath(opts.pbdir) | |
102 | bpdir = os.path.abspath(opts.bpdir) | |
103 | 103 | outdir = os.path.abspath(opts.outdir) |
104 | 104 | |
105 | CreateOutDir(pbdir, outdir) | |
105 | CreateOutDir(bpdir, outdir) | |
106 | 106 | BuildBreakpad(outdir, opts.sdk, opts.deployment_target) |
107 | 107 | BuildDumpSyms(outdir, opts.sdk, opts.deployment_target) |
108 | 108 | BuildSymupload(outdir, opts.sdk, opts.deployment_target) |
113 | 113 | for word_index in range(0, len(data), 8): |
114 | 114 | word_chunk = data[word_index:word_index + 8].ljust(8, '\x00') |
115 | 115 | stream.write('0x%016X, ' % struct.unpack('<Q', six.b(word_chunk))) |
116 | if (word_index / 8) % 4 == 3: | |
116 | if (word_index // 8) % 4 == 3: | |
117 | 117 | # Line feed for every 4 elements. |
118 | 118 | stream.write('\n') |
119 | 119 |
120 | 120 | template_dict = {} |
121 | 121 | with open(template_path) as template_file: |
122 | 122 | for line in template_file: |
123 | matchobj = re.match(r'(\w+) *= *(.*)', line.strip()) | |
123 | matchobj = re.match(r'(\w+) *= *(\w*)', line.strip()) | |
124 | 124 | if matchobj: |
125 | 125 | var = matchobj.group(1) |
126 | 126 | val = matchobj.group(2) |
152 | 152 | A replaced string. |
153 | 153 | """ |
154 | 154 | for unused_prefix, var_name, value in variables: |
155 | text = text.replace('@%s@' % var_name.upper(), str(value)) | |
155 | if var_name: | |
156 | text = text.replace('@%s@' % var_name.upper(), str(value)) | |
156 | 157 | |
157 | 158 | return text |
158 | 159 |
260 | 260 | py_binary_mozc( |
261 | 261 | name = "gen_typing_model", |
262 | 262 | srcs = ["gen_typing_model.py"], |
263 | python_version = "PY2", | |
263 | python_version = "PY3", | |
264 | 264 | deps = [":gen_typing_model_lib"], |
265 | 265 | ) |
266 | 266 |
702 | 702 | py_binary_mozc( |
703 | 703 | name = "gen_boundary_data", |
704 | 704 | srcs = ["gen_boundary_data.py"], |
705 | python_version = "PY2", | |
705 | python_version = "PY3", | |
706 | 706 | visibility = ["//data_manager:__subpackages__"], |
707 | 707 | deps = [":gen_boundary_data_lib"], |
708 | 708 | ) |
30 | 30 | |
31 | 31 | #include <algorithm> |
32 | 32 | #include <climits> |
33 | #include <limits> | |
33 | 34 | #include <string> |
34 | 35 | #include <utility> |
35 | 36 | #include <vector> |
221 | 222 | ConverterImpl::ConverterImpl() |
222 | 223 | : pos_matcher_(nullptr), |
223 | 224 | immutable_converter_(nullptr), |
224 | general_noun_id_(kuint16max) {} | |
225 | general_noun_id_(std::numeric_limits<uint16>::max()) {} | |
225 | 226 | |
226 | 227 | ConverterImpl::~ConverterImpl() = default; |
227 | 228 |
104 | 104 | |
105 | 105 | |
106 | 106 | def GenerateHeader(files): |
107 | try: | |
108 | print('namespace mozc{') | |
109 | print('struct TestCase {') | |
110 | print(' const bool enabled;') | |
111 | print(' const char *tsv;') | |
112 | print('} kTestData[] = {') | |
113 | for file in files: | |
107 | print('namespace mozc{') | |
108 | print('struct TestCase {') | |
109 | print(' const bool enabled;') | |
110 | print(' const char *tsv;') | |
111 | print('} kTestData[] = {') | |
112 | ||
113 | for file in files: | |
114 | try: | |
114 | 115 | for enabled, line in ParseFile(file): |
115 | 116 | print(' {%s, "%s"},' % (enabled, EscapeString(line))) |
116 | print(' {false, nullptr},') | |
117 | print('};') | |
118 | print('} // namespace mozc') | |
119 | except: | |
120 | print('cannot open %s' % (file)) | |
121 | sys.exit(1) | |
117 | except: | |
118 | print('cannot open %s' % file) | |
119 | sys.exit(1) | |
120 | ||
121 | print(' {false, nullptr},') | |
122 | print('};') | |
123 | print('} // namespace mozc') | |
122 | 124 | |
123 | 125 | |
124 | 126 | def main(): |
29 | 29 | #include "converter/segments.h" |
30 | 30 | |
31 | 31 | #include <algorithm> |
32 | #include <limits> | |
32 | 33 | #include <sstream> // For DebugString() |
33 | 34 | #include <string> |
34 | 35 | |
114 | 115 | size_t content_key_len, |
115 | 116 | size_t content_value_len, |
116 | 117 | uint32 *result) { |
117 | if (key_len > kuint8max || value_len > kuint8max || | |
118 | content_key_len > kuint8max || content_value_len > kuint8max) { | |
118 | if (key_len > std::numeric_limits<uint8>::max() || | |
119 | value_len > std::numeric_limits<uint8>::max() || | |
120 | content_key_len > std::numeric_limits<uint8>::max() || | |
121 | content_value_len > std::numeric_limits<uint8>::max()) { | |
119 | 122 | return false; |
120 | 123 | } |
121 | 124 | *result = (static_cast<uint32>(key_len) << 24) | |
32 | 32 | py_binary( |
33 | 33 | name = "filter", |
34 | 34 | srcs = ["filter.py"], |
35 | python_version = "PY2", | |
35 | python_version = "PY3", | |
36 | 36 | visibility = [ |
37 | 37 | ], |
38 | 38 | deps = ["//build_tools:code_generator_util"], |
30 | 30 | MAJOR = 2 |
31 | 31 | |
32 | 32 | MINOR = 25 |
33 | ||
34 | # Number to be increased. This value may be replaced by other tools. | |
33 | 35 | BUILD = 4100 |
36 | ||
37 | # Represent the platform and release channel. | |
34 | 38 | REVISION = 100 |
35 | 39 | |
36 | 40 | # This version represents the version of Mozc IME engine (converter, predictor, |
112 | 112 | py_binary_mozc( |
113 | 113 | name = "gen_connection_data", |
114 | 114 | srcs = ["gen_connection_data.py"], |
115 | python_version = "PY2", | |
115 | python_version = "PY3", | |
116 | 116 | deps = [ |
117 | 117 | ":gen_connection_data_lib", |
118 | 118 | "//build_tools:code_generator_util", |
28 | 28 | |
29 | 29 | #include "data_manager/dataset_reader.h" |
30 | 30 | |
31 | #include <limits> | |
31 | 32 | #include <sstream> |
32 | 33 | #include <string> |
33 | 34 | |
110 | 111 | // Metadata size is too large. |
111 | 112 | data = magic; |
112 | 113 | data.append("content and metadata"); |
113 | data.append(Util::SerializeUint64(kuint64max)); | |
114 | data.append(Util::SerializeUint64(std::numeric_limits<uint64>::max())); | |
114 | 115 | EXPECT_FALSE(DataSetReader::VerifyChecksum(data)); |
115 | 116 | EXPECT_FALSE(r.Init(data, magic)); |
116 | 117 | |
161 | 162 | auto e = md.add_entries(); |
162 | 163 | e->set_name("google"); |
163 | 164 | e->set_offset(content.size()); |
164 | e->set_size(kuint64max); // Too big size | |
165 | e->set_size(std::numeric_limits<uint64>::max()); // Too big size | |
165 | 166 | const string &md_str = md.SerializeAsString(); |
166 | 167 | string image = content; |
167 | 168 | image.append(md_str); |
222 | 222 | if cost == INVALID_COST: |
223 | 223 | cost = INVALID_1BYTE_COST |
224 | 224 | else: |
225 | cost /= resolution | |
225 | cost //= resolution | |
226 | 226 | assert cost != INVALID_1BYTE_COST |
227 | 227 | values.append(cost) |
228 | 228 |
92 | 92 | "//data/typing:typing_model_qwerty_mobile-hiragana.tsv", |
93 | 93 | "//data/typing:typing_model_toggle_flick-hiragana.tsv", |
94 | 94 | ], |
95 | usage_dict = "//third_party/japanese_usage_dictionary:usage_dict.txt", | |
95 | usage_dict = "@ja_usage_dict//:usage_dict.txt", | |
96 | 96 | use_1byte_cost = "false", |
97 | 97 | user_pos_def = "//data/rules:user_pos.def", |
98 | 98 | variant_rule = "//data/single_kanji:variant_rule.txt", |
127 | 127 | "//data/typing:typing_model_qwerty_mobile-hiragana.tsv", |
128 | 128 | "//data/typing:typing_model_toggle_flick-hiragana.tsv", |
129 | 129 | ], |
130 | usage_dict = "//third_party/japanese_usage_dictionary:usage_dict.txt", | |
130 | usage_dict = "@ja_usage_dict//:usage_dict.txt", | |
131 | 131 | use_1byte_cost = "false", |
132 | 132 | user_pos_def = "//data/rules:user_pos.def", |
133 | 133 | variant_rule = "//data/single_kanji:variant_rule.txt", |
573 | 573 | py_binary_mozc( |
574 | 574 | name = "gen_user_pos_data", |
575 | 575 | srcs = ["gen_user_pos_data.py"], |
576 | python_version = "PY2", | |
576 | python_version = "PY3", | |
577 | 577 | visibility = ["//:__subpackages__"], |
578 | 578 | deps = [ |
579 | 579 | ":gen_user_pos_data_lib", |
632 | 632 | py_binary_mozc( |
633 | 633 | name = "gen_pos_rewrite_rule", |
634 | 634 | srcs = ["gen_pos_rewrite_rule.py"], |
635 | python_version = "PY2", | |
635 | python_version = "PY3", | |
636 | 636 | visibility = ["//:__subpackages__"], |
637 | 637 | deps = [":gen_pos_rewrite_rule_lib"], |
638 | 638 | ) |
731 | 731 | py_binary_mozc( |
732 | 732 | name = "gen_suffix_data", |
733 | 733 | srcs = ["gen_suffix_data.py"], |
734 | python_version = "PY2", | |
734 | python_version = "PY3", | |
735 | 735 | visibility = ["//:__subpackages__"], |
736 | 736 | deps = [ |
737 | 737 | ":gen_suffix_data_lib", |
225 | 225 | pos_database.Parse(options.id_file, options.special_pos_file) |
226 | 226 | pos_matcher = pos_util.PosMatcher(pos_database) |
227 | 227 | pos_matcher.Parse(options.pos_matcher_rule_file) |
228 | with codecs.open(options.output_pos_matcher_data, 'wb') as stream: | |
228 | with open(options.output_pos_matcher_data, 'wb') as stream: | |
229 | 229 | OutputPosMatcherData(pos_matcher, stream) |
230 | 230 | |
231 | 231 |
30 | 30 | |
31 | 31 | #include <algorithm> |
32 | 32 | #include <cstdlib> |
33 | #include <limits> | |
33 | 34 | #include <memory> |
34 | 35 | #include <string> |
35 | 36 | #include <utility> |
83 | 84 | // Don't use small cost encoding by default. |
84 | 85 | original_flags_min_key_length_to_use_small_cost_encoding_ = |
85 | 86 | FLAGS_min_key_length_to_use_small_cost_encoding; |
86 | FLAGS_min_key_length_to_use_small_cost_encoding = kint32max; | |
87 | FLAGS_min_key_length_to_use_small_cost_encoding = | |
88 | std::numeric_limits<int32>::max(); | |
87 | 89 | |
88 | 90 | request_.Clear(); |
89 | 91 | config::ConfigHandler::GetDefaultConfig(&config_); |
58 | 58 | "about_dialog_en.qm", |
59 | 59 | "about_dialog_ja.qm", |
60 | 60 | "//data/images:product_icon_32bpp-128.png", |
61 | "//gui/base:tr_en.qm", | |
62 | "//gui/base:tr_ja.qm", | |
61 | 63 | ], |
62 | 64 | outs = ["qrc_about_dialog.cc"], |
63 | 65 | qrc_file = "about_dialog.qrc", |
38 | 38 | #include "base/system_util.h" |
39 | 39 | #include "base/util.h" |
40 | 40 | #include "base/version.h" |
41 | #include "gui/base/util.h" | |
41 | 42 | |
42 | 43 | namespace mozc { |
43 | 44 | namespace gui { |
56 | 57 | std::string tmp; |
57 | 58 | const std::string file_path = |
58 | 59 | FileUtil::JoinPath(SystemUtil::GetDocumentDirectory(), filenames[i]); |
59 | Util::StringReplace(*str, filenames[i], file_path, false, &tmp); | |
60 | mozc::Util::StringReplace(*str, filenames[i], file_path, false, &tmp); | |
60 | 61 | *str = tmp; |
61 | 62 | return true; |
62 | 63 | } |
73 | 74 | |
74 | 75 | } // namespace |
75 | 76 | |
76 | AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), callback_(NULL) { | |
77 | AboutDialog::AboutDialog(QWidget *parent) | |
78 | : QDialog(parent), callback_(nullptr) { | |
77 | 79 | setupUi(this); |
78 | 80 | setWindowFlags(Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); |
79 | 81 | setWindowModality(Qt::NonModal); |
85 | 87 | version_info += Version::GetMozcVersion().c_str(); |
86 | 88 | version_info += ")"; |
87 | 89 | version_label->setText(version_info); |
90 | gui::Util::ReplaceTitle(this); | |
91 | gui::Util::ReplaceLabel(label); | |
92 | gui::Util::ReplaceLabel(label_credits); | |
93 | gui::Util::ReplaceLabel(label_terms); | |
88 | 94 | |
89 | 95 | QPalette palette; |
90 | 96 | palette.setColor(QPalette::Window, QColor(236, 233, 216)); |
129 | 135 | if (!RunLevel::IsValidClientRunLevel()) { |
130 | 136 | return; |
131 | 137 | } |
132 | if (callback_ != NULL) { | |
138 | if (callback_ != nullptr) { | |
133 | 139 | callback_->linkActivated(link); |
134 | 140 | } else { |
135 | 141 | defaultLinkActivated(link); |
1 | 1 | <qresource> |
2 | 2 | <file>about_dialog_ja.qm</file> |
3 | 3 | <file>about_dialog_en.qm</file> |
4 | <file alias="tr_ja.qm">../base/tr_ja.qm</file> | |
5 | <file alias="tr_en.qm">../base/tr_en.qm</file> | |
4 | 6 | <file alias="product_logo.png">../../data/images/product_icon_32bpp-128.png</file> |
5 | 7 | </qresource> |
6 | 8 | </RCC> |
58 | 58 | </size> |
59 | 59 | </property> |
60 | 60 | <property name="windowTitle"> |
61 | <string>About Mozc</string> | |
61 | <string>About [ProductName]</string> | |
62 | 62 | </property> |
63 | 63 | <widget class="QFrame" name="color_frame"> |
64 | 64 | <property name="geometry"> |
94 | 94 | <x>20</x> |
95 | 95 | <y>10</y> |
96 | 96 | <width>471</width> |
97 | <height>81</height> | |
97 | <height>82</height> | |
98 | 98 | </rect> |
99 | 99 | </property> |
100 | 100 | <layout class="QGridLayout" name="gridLayout_3"> |
121 | 121 | </font> |
122 | 122 | </property> |
123 | 123 | <property name="text"> |
124 | <string><html><body>Mozc is made possible by <a href="file://credits_en.html"><span style=" text-decoration: underline; color:#0000ff;">open source software</span></a>.</body></html></string> | |
124 | <string><html><body>[ProductName] is made possible by <a href="file://credits_en.html"><span style=" text-decoration: underline; color:#0000ff;">open source software</span></a>.</body></html></string> | |
125 | 125 | </property> |
126 | 126 | </widget> |
127 | 127 | </item> |
159 | 159 | </font> |
160 | 160 | </property> |
161 | 161 | <property name="text"> |
162 | <string><html><body>Mozc <a href="https://github.com/google/mozc"><span style=" text-decoration: underline; color:#0000ff;">product information</span></a> <a href="https://github.com/google/mozc/issues"><span style=" text-decoration: underline; color:#0000ff;">issues</span></a></body></html></string> | |
162 | <string><html><body>[ProductName] <a href="https://github.com/google/mozc"><span style=" text-decoration: underline; color:#0000ff;">product information</span></a> <a href="https://github.com/google/mozc/issues"><span style=" text-decoration: underline; color:#0000ff;">issues</span></a></body></html></string> | |
163 | 163 | </property> |
164 | 164 | </widget> |
165 | 165 | </item> |
200 | 200 | </font> |
201 | 201 | </property> |
202 | 202 | <property name="text"> |
203 | <string>Mozc</string> | |
203 | <string>[ProductName]</string> | |
204 | 204 | </property> |
205 | 205 | <property name="alignment"> |
206 | 206 | <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> |
4 | 4 | <name>AboutDialog</name> |
5 | 5 | <message> |
6 | 6 | <location filename="about_dialog.ui" line="32"/> |
7 | <source>About Mozc</source> | |
7 | <source>About [ProductName]</source> | |
8 | 8 | <translation type="unfinished"></translation> |
9 | 9 | </message> |
10 | 10 | <message> |
14 | 14 | </message> |
15 | 15 | <message utf8="true"> |
16 | 16 | <location filename="about_dialog.ui" line="80"/> |
17 | <source>Copyright © 2019 Google Inc. All rights reserved.</source> | |
17 | <source>Copyright © 2020 Google Inc. All rights reserved.</source> | |
18 | 18 | <translation type="unfinished"></translation> |
19 | 19 | </message> |
20 | 20 | <message> |
21 | 21 | <location filename="about_dialog.ui" line="95"/> |
22 | <source><html><body>Mozc is made possible by <a href="file://credits_en.html"><span style=" text-decoration: underline; color:#0000ff;">open source software</span></a>.</body></html></source> | |
22 | <source><html><body>[ProductName] is made possible by <a href="file://credits_en.html"><span style=" text-decoration: underline; color:#0000ff;">open source software</span></a>.</body></html></source> | |
23 | 23 | <translation type="unfinished"></translation> |
24 | 24 | </message> |
25 | 25 | <message> |
26 | 26 | <location filename="about_dialog.ui" line="133"/> |
27 | <source><html><body>Mozc <a href="https://github.com/google/mozc"><span style=" text-decoration: underline; color:#0000ff;">product information</span></a> <a href="https://github.com/google/mozc/issues"><span style=" text-decoration: underline; color:#0000ff;">issues</span></a></body></html></source> | |
27 | <source><html><body>[ProductName] <a href="https://github.com/google/mozc"><span style=" text-decoration: underline; color:#0000ff;">product information</span></a> <a href="https://github.com/google/mozc/issues"><span style=" text-decoration: underline; color:#0000ff;">issues</span></a></body></html></source> | |
28 | 28 | <translation type="unfinished"></translation> |
29 | 29 | </message> |
30 | 30 | <message> |
31 | 31 | <location filename="about_dialog.ui" line="174"/> |
32 | <source>Mozc</source> | |
32 | <source>[ProductName]</source> | |
33 | 33 | <translation type="unfinished"></translation> |
34 | 34 | </message> |
35 | 35 | <message> |
Binary diff not shown
4 | 4 | <name>AboutDialog</name> |
5 | 5 | <message> |
6 | 6 | <location filename="about_dialog.ui" line="32"/> |
7 | <source>About Mozc</source> | |
8 | <translation>Mozcについて</translation> | |
7 | <source>About [ProductName]</source> | |
8 | <translation>[ProductName] について</translation> | |
9 | 9 | </message> |
10 | 10 | <message> |
11 | 11 | <location filename="about_dialog.ui" line="59"/> |
14 | 14 | </message> |
15 | 15 | <message utf8="true"> |
16 | 16 | <location filename="about_dialog.ui" line="80"/> |
17 | <source>Copyright © 2019 Google Inc. All rights reserved.</source> | |
17 | <source>Copyright © 2020 Google Inc. All rights reserved.</source> | |
18 | 18 | <translation type="unfinished"></translation> |
19 | 19 | </message> |
20 | 20 | <message> |
21 | 21 | <location filename="about_dialog.ui" line="95"/> |
22 | <source><html><body>Mozc is made possible by <a href="file://credits_en.html"><span style=" text-decoration: underline; color:#0000ff;">open source software</span></a>.</body></html></source> | |
23 | <translation><html><body>Mozcは<a href="file://credits_en.html"><span style=" text-decoration: underline; color:#0000ff;">オープンソースソフトウェア</span></a>を利用しています。</body></html></translation> | |
22 | <source><html><body>[ProductName] is made possible by <a href="file://credits_en.html"><span style=" text-decoration: underline; color:#0000ff;">open source software</span></a>.</body></html></source> | |
23 | <translation><html><body>[ProductName] は<a href="file://credits_en.html"><span style=" text-decoration: underline; color:#0000ff;">オープンソースソフトウェア</span></a>を利用しています。</body></html></translation> | |
24 | 24 | </message> |
25 | 25 | <message> |
26 | 26 | <location filename="about_dialog.ui" line="133"/> |
27 | <source><html><body>Mozc <a href="https://github.com/google/mozc"><span style=" text-decoration: underline; color:#0000ff;">product information</span></a> <a href="https://github.com/google/mozc/issues"><span style=" text-decoration: underline; color:#0000ff;">issues</span></a></body></html></source> | |
28 | <translation type="unfinished"><html><body>Mozc <a href="https://github.com/google/mozc"><span style=" text-decoration: underline; color:#0000ff;">製品情報</span></a> <a href="https://github.com/google/mozc/issues"><span style=" text-decoration: underline; color:#0000ff;">issues</span></a></body></html></translation> | |
27 | <source><html><body>[ProductName] <a href="https://github.com/google/mozc"><span style=" text-decoration: underline; color:#0000ff;">product information</span></a> <a href="https://github.com/google/mozc/issues"><span style=" text-decoration: underline; color:#0000ff;">issues</span></a></body></html></source> | |
28 | <translation type="unfinished"><html><body> [ProductName] <a href="https://github.com/google/mozc"><span style=" text-decoration: underline; color:#0000ff;">製品情報</span></a> <a href="https://github.com/google/mozc/issues"><span style=" text-decoration: underline; color:#0000ff;">issues</span></a></body></html></translation> | |
29 | 29 | </message> |
30 | 30 | <message> |
31 | 31 | <source><html><body>Google <a href="file://privacy_en.html"><span style=" text-decoration: underline; color:#0000ff;">privacy policy</span></a></body></html></source> |
33 | 33 | </message> |
34 | 34 | <message> |
35 | 35 | <location filename="about_dialog.ui" line="174"/> |
36 | <source>Mozc</source> | |
37 | <translation>Mozc</translation> | |
36 | <source>[ProductName]</source> | |
37 | <translation>[ProductName]</translation> | |
38 | 38 | </message> |
39 | 39 | <message> |
40 | 40 | <location filename="about_dialog.ui" line="197"/> |
49 | 49 | } |
50 | 50 | |
51 | 51 | mozc::gui::LocaleUtil::InstallTranslationMessageAndFont("about_dialog"); |
52 | mozc::gui::LocaleUtil::InstallTranslationMessageAndFont("tr"); | |
52 | 53 | mozc::gui::AboutDialog about_dialog; |
53 | 54 | |
54 | 55 | about_dialog.show(); |
61 | 61 | srcs = ["window_title_modifier.h"], |
62 | 62 | outs = ["moc_window_title_modifier.cc"], |
63 | 63 | ) |
64 | ||
65 | exports_files([ | |
66 | "tr_en.qm", | |
67 | "tr_ja.qm", | |
68 | ]) | |
64 | 69 | |
65 | 70 | qt_rcc_mozc( |
66 | 71 | name = "qrc_tr", |
49 | 49 | |
50 | 50 | #include <QtGui/QtGui> |
51 | 51 | #include <map> |
52 | #include <memory> | |
52 | 53 | #include <string> |
53 | 54 | |
54 | 55 | #include "base/logging.h" |
55 | #include "base/singleton.h" | |
56 | #include "base/util.h" | |
57 | 56 | |
58 | 57 | #ifdef MOZC_SHOW_BUILD_NUMBER_ON_TITLE |
59 | 58 | #include "gui/base/window_title_modifier.h" |
63 | 62 | namespace gui { |
64 | 63 | namespace { |
65 | 64 | |
66 | // sicnce Qtranslator and QFont must be available until | |
67 | // application exits, allocate the data with Singleton. | |
68 | class TranslationDataImpl { | |
69 | public: | |
70 | void InstallTranslationMessageAndFont(const char *resource_name); | |
65 | void InstallEventFilter() { | |
66 | #ifdef MOZC_SHOW_BUILD_NUMBER_ON_TITLE | |
67 | static WindowTitleModifier window_title_modifier; | |
68 | // Install WindowTilteModifier for official dev channel | |
69 | // append a special footer (Dev x.x.x) to the all Windows. | |
70 | qApp->installEventFilter(&window_title_modifier); | |
71 | #endif // MOZC_SHOW_BUILD_NUMBER_ON_TITLE | |
72 | } | |
71 | 73 | |
72 | TranslationDataImpl(); | |
73 | ~TranslationDataImpl() { | |
74 | for (std::map<string, QTranslator *>::iterator it = translators_.begin(); | |
75 | it != translators_.end(); ++it) { | |
76 | delete it->second; | |
77 | } | |
78 | translators_.clear(); | |
79 | } | |
80 | ||
81 | private: | |
82 | std::map<string, QTranslator *> translators_; | |
83 | QTranslator default_translator_; | |
84 | QFont font_; | |
85 | #ifdef MOZC_SHOW_BUILD_NUMBER_ON_TITLE | |
86 | WindowTitleModifier window_title_modifier_; | |
87 | #endif // MOZC_SHOW_BUILD_NUMBER_ON_TITLE | |
88 | }; | |
89 | ||
90 | TranslationDataImpl::TranslationDataImpl() { | |
74 | void InstallDefaultTranslator() { | |
91 | 75 | // qApplication must be loaded first |
92 | 76 | CHECK(qApp); |
93 | ||
94 | #ifdef MOZC_SHOW_BUILD_NUMBER_ON_TITLE | |
95 | // Install WindowTilteModifier for official dev channel | |
96 | // append a special footer (Dev x.x.x) to the all Windows. | |
97 | qApp->installEventFilter(&window_title_modifier_); | |
98 | #endif // MOZC_SHOW_BUILD_NUMBER_ON_TITLE | |
77 | static QTranslator translator; | |
99 | 78 | |
100 | 79 | // Load "<translation_path>/qt_<lang>.qm" from a qrc file. |
101 | bool loaded = default_translator_.load( | |
80 | bool loaded = translator.load( | |
102 | 81 | QLocale::system(), "qt", "_", |
103 | 82 | QLibraryInfo::location(QLibraryInfo::TranslationsPath), ".qm"); |
104 | 83 | if (!loaded) { |
105 | 84 | // Load ":/qt_<lang>.qm" from a qrc file. |
106 | loaded = | |
107 | default_translator_.load(QLocale::system(), "qt", "_", ":/", ".qm"); | |
85 | loaded = translator.load(QLocale::system(), "qt", "_", ":/", ".qm"); | |
108 | 86 | } |
109 | 87 | |
110 | 88 | if (loaded) { |
111 | qApp->installTranslator(&default_translator_); | |
89 | qApp->installTranslator(&translator); | |
112 | 90 | } |
113 | 91 | } |
114 | 92 | |
115 | void TranslationDataImpl::InstallTranslationMessageAndFont( | |
116 | const char *resource_name) { | |
117 | if (translators_.find(resource_name) != translators_.end()) { | |
93 | void InstallTranslator(const char *resource_name) { | |
94 | static std::map<string, std::unique_ptr<QTranslator>> translators; | |
95 | if (translators.find(resource_name) != translators.end()) { | |
118 | 96 | return; |
119 | 97 | } |
120 | QTranslator *translator = new QTranslator; | |
121 | CHECK(translator); | |
122 | translators_.insert(std::make_pair(resource_name, translator)); | |
98 | std::unique_ptr<QTranslator> translator(new QTranslator); | |
123 | 99 | |
124 | 100 | // Load ":/<resource_name>_<lang>.qm" from a qrc file. |
125 | 101 | if (translator->load(QLocale::system(), resource_name, "_", ":/", ".qm")) { |
126 | qApp->installTranslator(translator); | |
102 | qApp->installTranslator(translator.get()); | |
103 | translators.emplace(resource_name, std::move(translator)); | |
127 | 104 | } |
128 | 105 | } |
129 | 106 | |
130 | 107 | } // namespace |
131 | 108 | |
132 | 109 | void LocaleUtil::InstallTranslationMessageAndFont(const char *resource_name) { |
133 | Singleton<TranslationDataImpl>::get()->InstallTranslationMessageAndFont( | |
134 | resource_name); | |
110 | static bool called = false; | |
111 | if (!called) { | |
112 | called = true; | |
113 | InstallEventFilter(); | |
114 | InstallDefaultTranslator(); | |
115 | } | |
116 | InstallTranslator(resource_name); | |
135 | 117 | } |
136 | 118 | } // namespace gui |
137 | 119 | } // namespace mozc |
72 | 72 | #include <string> |
73 | 73 | #include <vector> |
74 | 74 | |
75 | #include "base/compiler_specific.h" | |
76 | 75 | #include "base/hash.h" |
77 | 76 | #include "base/logging.h" |
78 | 77 | #include "base/mmap.h" |
129 | 128 | explicit ScopedIFEDictionary(IFEDictionary *dic) : dic_(dic) {} |
130 | 129 | |
131 | 130 | ~ScopedIFEDictionary() { |
132 | if (dic_ != NULL) { | |
131 | if (dic_ != nullptr) { | |
133 | 132 | dic_->Close(); |
134 | 133 | dic_->Release(); |
135 | 134 | } |
153 | 152 | result_(E_FAIL), |
154 | 153 | size_(0), |
155 | 154 | index_(0) { |
156 | if (dic_.get() == NULL) { | |
157 | LOG(ERROR) << "IFEDictionaryFactory returned NULL"; | |
155 | if (dic_.get() == nullptr) { | |
156 | LOG(ERROR) << "IFEDictionaryFactory returned nullptr"; | |
158 | 157 | return; |
159 | 158 | } |
160 | 159 | |
161 | 160 | // open user dictionary |
162 | HRESULT result = dic_->Open(NULL, NULL); | |
161 | HRESULT result = dic_->Open(nullptr, nullptr); | |
163 | 162 | if (S_OK != result) { |
164 | 163 | LOG(ERROR) << "Cannot open user dictionary: " << result_; |
165 | 164 | return; |
166 | 165 | } |
167 | 166 | |
168 | POSTBL *pos_table = NULL; | |
167 | POSTBL *pos_table = nullptr; | |
169 | 168 | int pos_size = 0; |
170 | 169 | result_ = dic_->GetPosTable(&pos_table, &pos_size); |
171 | if (S_OK != result_ || pos_table == NULL || pos_size == 0) { | |
170 | if (S_OK != result_ || pos_table == nullptr || pos_size == 0) { | |
172 | 171 | LOG(ERROR) << "Cannot get POS table: " << result; |
173 | 172 | result_ = E_FAIL; |
174 | 173 | return; |
186 | 185 | // Don't use auto-registered words, since Mozc may not be able to |
187 | 186 | // handle auto_registered words correctly, and user is basically |
188 | 187 | // unaware of auto-registered words. |
189 | result_ = dic_->GetWords(NULL, NULL, NULL, IFED_POS_ALL, IFED_SELECT_ALL, | |
190 | IFED_REG_USER, // | FED_REG_AUTO | |
191 | reinterpret_cast<UCHAR *>(&buf_[0]), | |
192 | kBufferSize * sizeof(IMEWRD), &size_); | |
188 | result_ = | |
189 | dic_->GetWords(nullptr, nullptr, nullptr, IFED_POS_ALL, IFED_SELECT_ALL, | |
190 | IFED_REG_USER, // | FED_REG_AUTO | |
191 | reinterpret_cast<UCHAR *>(&buf_[0]), | |
192 | kBufferSize * sizeof(IMEWRD), &size_); | |
193 | 193 | } |
194 | 194 | |
195 | 195 | bool IsAvailable() const { |
204 | 204 | return false; |
205 | 205 | } |
206 | 206 | |
207 | if (entry == NULL) { | |
208 | LOG(ERROR) << "Entry is NULL"; | |
207 | if (entry == nullptr) { | |
208 | LOG(ERROR) << "Entry is nullptr"; | |
209 | 209 | return false; |
210 | 210 | } |
211 | 211 | entry->Clear(); |
212 | 212 | |
213 | 213 | if (index_ < size_) { |
214 | if (buf_[index_].pwchReading == NULL || | |
215 | buf_[index_].pwchDisplay == NULL) { | |
214 | if (buf_[index_].pwchReading == nullptr || | |
215 | buf_[index_].pwchDisplay == nullptr) { | |
216 | 216 | ++index_; |
217 | LOG(ERROR) << "pwchDisplay or pwchReading is NULL"; | |
217 | LOG(ERROR) << "pwchDisplay or pwchReading is nullptr"; | |
218 | 218 | return true; |
219 | 219 | } |
220 | 220 | |
234 | 234 | entry->pos = it->second; |
235 | 235 | |
236 | 236 | // set comment |
237 | if (buf_[index_].pvComment != NULL) { | |
237 | if (buf_[index_].pvComment != nullptr) { | |
238 | 238 | if (buf_[index_].uct == IFED_UCT_STRING_SJIS) { |
239 | 239 | EncodingUtil::SJISToUTF8( |
240 | 240 | reinterpret_cast<const char *>(buf_[index_].pvComment), |
127 | 127 | |
128 | 128 | UserDictionaryStorage::UserDictionary *dic = |
129 | 129 | storage_->GetUserDictionary(dic_id); |
130 | if (dic == NULL) { | |
131 | LOG(ERROR) << "GetUserDictionary returned NULL"; | |
130 | if (dic == nullptr) { | |
131 | LOG(ERROR) << "GetUserDictionary returned nullptr"; | |
132 | 132 | return false; |
133 | 133 | } |
134 | 134 |
59 | 59 | mozc::ScopedHandle handle( |
60 | 60 | ::CreateFileW(wfilename.c_str(), GENERIC_READ, |
61 | 61 | FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, |
62 | NULL, OPEN_EXISTING, 0, NULL)); | |
63 | if (NULL == handle.get()) { | |
62 | nullptr, OPEN_EXISTING, 0, nullptr)); | |
63 | if (nullptr == handle.get()) { | |
64 | 64 | LOG(ERROR) << "cannot open: " << lock_name << " " << ::GetLastError(); |
65 | 65 | return false; |
66 | 66 | } |
67 | 67 | |
68 | const DWORD size = ::GetFileSize(handle.get(), NULL); | |
68 | const DWORD size = ::GetFileSize(handle.get(), nullptr); | |
69 | 69 | if (-1 == static_cast<int>(size)) { |
70 | 70 | LOG(ERROR) << "GetFileSize failed:" << ::GetLastError(); |
71 | 71 | return false; |
80 | 80 | std::unique_ptr<char[]> buf(new char[size]); |
81 | 81 | |
82 | 82 | DWORD read_size = 0; |
83 | if (!::ReadFile(handle.get(), buf.get(), size, &read_size, NULL)) { | |
83 | if (!::ReadFile(handle.get(), buf.get(), size, &read_size, nullptr)) { | |
84 | 84 | LOG(ERROR) << "ReadFile failed: " << ::GetLastError(); |
85 | 85 | return false; |
86 | 86 | } |
35 | 35 | |
36 | 36 | QString TableUtil::SafeGetItemText(const QTableWidget *table_widget, int row, |
37 | 37 | int column) { |
38 | if (table_widget == NULL) { | |
38 | if (table_widget == nullptr) { | |
39 | 39 | return QString(); |
40 | 40 | } |
41 | // If |row| and/or |column| is out of range, we will get NULL anyway. | |
41 | // If |row| and/or |column| is out of range, we will get nullptr anyway. | |
42 | 42 | const QTableWidgetItem *item = table_widget->item(row, column); |
43 | if (item == NULL) { | |
43 | if (item == nullptr) { | |
44 | 44 | return QString(); |
45 | 45 | } |
46 | 46 | return item->text(); |
52 | 52 | #ifdef __APPLE__ |
53 | 53 | app->setFont(QFont("Hiragino Sans")); |
54 | 54 | #endif // __APPLE__ |
55 | ||
55 | 56 | return app; |
56 | 57 | } |
57 | 58 | |
65 | 66 | return name; |
66 | 67 | } |
67 | 68 | |
69 | // static | |
70 | void Util::ReplaceLabel(QLabel *label) { | |
71 | label->setText(ReplaceString(label->text())); | |
72 | } | |
73 | ||
74 | // static | |
75 | void Util::ReplaceTitle(QWidget *widget) { | |
76 | widget->setWindowTitle(Util::ReplaceString(widget->windowTitle())); | |
77 | } | |
78 | ||
79 | // static | |
80 | QString Util::ReplaceString(const QString &str) { | |
81 | QString replaced(str); | |
82 | return replaced.replace("[ProductName]", Util::ProductName()); | |
83 | } | |
84 | ||
68 | 85 | } // namespace gui |
69 | 86 | } // namespace mozc |
31 | 31 | |
32 | 32 | #include <QtCore/QString> |
33 | 33 | #include <QtWidgets/QApplication> |
34 | #include <QtWidgets/QLabel> | |
34 | 35 | #include <memory> |
35 | 36 | |
36 | 37 | namespace mozc { |
44 | 45 | // Returns the product name. |
45 | 46 | static const QString ProductName(); |
46 | 47 | |
48 | // Replace placeholders in the label. | |
49 | static void ReplaceLabel(QLabel *label); | |
50 | ||
51 | // Replace placeholders in the widget. | |
52 | static void ReplaceTitle(QWidget *widget); | |
53 | ||
54 | // Replace placeholders in the string. | |
55 | static QString ReplaceString(const QString &str); | |
56 | ||
47 | 57 | private: |
48 | 58 | Util() = delete; |
49 | 59 | virtual ~Util() = delete; |
65 | 65 | hr = link.CoCreateInstance(CLSID_ShellLink); |
66 | 66 | if (FAILED(hr)) { |
67 | 67 | DLOG(INFO) << "Failed to instantiate CLSID_ShellLink. hr = " << hr; |
68 | return NULL; | |
68 | return nullptr; | |
69 | 69 | } |
70 | 70 | |
71 | 71 | { |
74 | 74 | hr = link->SetPath(mozc_tool_path_wide.c_str()); |
75 | 75 | if (FAILED(hr)) { |
76 | 76 | DLOG(ERROR) << "SetPath failed. hr = " << hr; |
77 | return NULL; | |
77 | return nullptr; | |
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
84 | 84 | hr = link->SetArguments(argument_wide.c_str()); |
85 | 85 | if (FAILED(hr)) { |
86 | 86 | DLOG(ERROR) << "SetArguments failed. hr = " << hr; |
87 | return NULL; | |
87 | return nullptr; | |
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | 91 | CComQIPtr<IPropertyStore> property_store(link); |
92 | if (property_store == NULL) { | |
92 | if (property_store == nullptr) { | |
93 | 93 | DLOG(ERROR) << "QueryInterface failed."; |
94 | return NULL; | |
94 | return nullptr; | |
95 | 95 | } |
96 | 96 | |
97 | 97 | { |
101 | 101 | hr = ::InitPropVariantFromString(item_title_wide.c_str(), &prop_variant); |
102 | 102 | if (FAILED(hr)) { |
103 | 103 | DLOG(ERROR) << "QueryInterface failed. hr = " << hr; |
104 | return NULL; | |
104 | return nullptr; | |
105 | 105 | } |
106 | 106 | hr = property_store->SetValue(PKEY_Title, prop_variant); |
107 | 107 | ::PropVariantClear(&prop_variant); |
109 | 109 | |
110 | 110 | if (FAILED(hr)) { |
111 | 111 | DLOG(ERROR) << "SetValue failed. hr = " << hr; |
112 | return NULL; | |
112 | return nullptr; | |
113 | 113 | } |
114 | 114 | |
115 | 115 | hr = property_store->Commit(); |
116 | 116 | if (FAILED(hr)) { |
117 | 117 | DLOG(ERROR) << "Commit failed. hr = " << hr; |
118 | return NULL; | |
118 | return nullptr; | |
119 | 119 | } |
120 | 120 | |
121 | 121 | return link; |
160 | 160 | link = |
161 | 161 | InitializeShellLinkItem(kLinks[i].argument, kLinks[i].title_english); |
162 | 162 | } |
163 | if (link != NULL) { | |
163 | if (link != nullptr) { | |
164 | 164 | object_collection->AddObject(link); |
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | 168 | CComQIPtr<IObjectArray> object_array(object_collection); |
169 | if (object_array == NULL) { | |
169 | if (object_array == nullptr) { | |
170 | 170 | DLOG(ERROR) << "QueryInterface failed."; |
171 | 171 | return false; |
172 | 172 | } |
303 | 303 | wchar_t data[4] = {}; |
304 | 304 | ULONG num_chars = arraysize(data); |
305 | 305 | result = key.QueryStringValue(kIMEHotKeyEntryValue, data, &num_chars); |
306 | // Returned |num_char| includes NULL character. | |
306 | // Returned |num_char| includes nullptr character. | |
307 | 307 | |
308 | 308 | // This is only the condition when this function |
309 | 309 | // can return |true| |
362 | 362 | #ifdef OS_WIN |
363 | 363 | HRESULT hr = S_OK; |
364 | 364 | |
365 | hr = | |
366 | ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); | |
365 | hr = ::CoInitializeEx(nullptr, | |
366 | COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); | |
367 | 367 | if (FAILED(hr)) { |
368 | 368 | DLOG(INFO) << "CoInitializeEx failed. hr = " << hr; |
369 | 369 | return; |
39 | 39 | namespace gui { |
40 | 40 | bool WindowTitleModifier::eventFilter(QObject *obj, QEvent *event) { |
41 | 41 | QWidget *w = QApplication::activeWindow(); |
42 | if (w != NULL && obj != NULL && w == obj && | |
43 | QEvent::WindowActivate == event->type() && | |
44 | w->windowTitle().indexOf(prefix_) == -1) { | |
45 | w->setWindowTitle(w->windowTitle() + prefix_ + | |
46 | Version::GetMozcVersion().c_str() + suffix_); | |
42 | if (w == nullptr || obj != w || event->type() != QEvent::WindowActivate) { | |
43 | return QObject::eventFilter(obj, event); | |
44 | } | |
45 | ||
46 | const QString prefix = " (Dev "; | |
47 | const QString& title = w->windowTitle(); | |
48 | // The window title can be empty, even if it is specified. | |
49 | // See: https://doc.qt.io/qt-5/qmessagebox.html#setWindowTitle | |
50 | if (!title.isEmpty() && title.indexOf(prefix) == -1) { | |
51 | const QString version = prefix + Version::GetMozcVersion().c_str() + ")"; | |
52 | w->setWindowTitle(title + version); | |
47 | 53 | } |
48 | 54 | |
49 | 55 | return QObject::eventFilter(obj, event); |
50 | 56 | } |
51 | 57 | |
52 | WindowTitleModifier::WindowTitleModifier() : prefix_(" (Dev "), suffix_(")") {} | |
53 | ||
54 | WindowTitleModifier::~WindowTitleModifier() {} | |
55 | ||
56 | 58 | } // namespace gui |
57 | 59 | } // namespace mozc |
39 | 39 | Q_OBJECT; |
40 | 40 | |
41 | 41 | public: |
42 | WindowTitleModifier(); | |
43 | ~WindowTitleModifier(); | |
42 | WindowTitleModifier() = default; | |
43 | ~WindowTitleModifier() override = default; | |
44 | 44 | |
45 | 45 | protected: |
46 | 46 | bool eventFilter(QObject *obj, QEvent *event); |
47 | ||
48 | private: | |
49 | const QString prefix_; | |
50 | const QString suffix_; | |
51 | 47 | }; |
52 | 48 | } // namespace gui |
53 | 49 | } // namespace mozc |
48 | 48 | class CharacterFormEditor : public QTableWidget { |
49 | 49 | Q_OBJECT |
50 | 50 | public: |
51 | explicit CharacterFormEditor(QWidget *parent = NULL); | |
51 | explicit CharacterFormEditor(QWidget *parent = nullptr); | |
52 | 52 | virtual ~CharacterFormEditor(); |
53 | 53 | |
54 | 54 | void Load(const config::Config &config); |
58 | 58 | const QModelIndex &index) const { |
59 | 59 | QString str = index.model()->data(index, Qt::EditRole).toString(); |
60 | 60 | QComboBox *comboBox = static_cast<QComboBox *>(editor); |
61 | if (comboBox == NULL) { | |
61 | if (comboBox == nullptr) { | |
62 | 62 | return; |
63 | 63 | } |
64 | 64 | comboBox->setCurrentIndex(comboBox->findText(str)); |
67 | 67 | void ComboBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, |
68 | 68 | const QModelIndex &index) const { |
69 | 69 | QComboBox *comboBox = static_cast<QComboBox *>(editor); |
70 | if (comboBox == NULL || model == NULL) { | |
70 | if (comboBox == nullptr || model == nullptr) { | |
71 | 71 | return; |
72 | 72 | } |
73 | 73 | model->setData(index, comboBox->currentText(), Qt::EditRole); |
76 | 76 | void ComboBoxDelegate::updateEditorGeometry(QWidget *editor, |
77 | 77 | const QStyleOptionViewItem &option, |
78 | 78 | const QModelIndex &index) const { |
79 | if (editor == NULL) { | |
79 | if (editor == nullptr) { | |
80 | 80 | return; |
81 | 81 | } |
82 | 82 | editor->setGeometry(option.rect); |
43 | 43 | class ComboBoxDelegate : public QItemDelegate { |
44 | 44 | Q_OBJECT |
45 | 45 | public: |
46 | explicit ComboBoxDelegate(QObject *parent = NULL); | |
46 | explicit ComboBoxDelegate(QObject *parent = nullptr); | |
47 | 47 | virtual ~ComboBoxDelegate(); |
48 | 48 | |
49 | 49 | void SetItemList(const QStringList &item_list); |
753 | 753 | keymap::KeyMapManager::GetKeyMapFileName(itr->second); |
754 | 754 | std::unique_ptr<std::istream> ifs( |
755 | 755 | ConfigFileStream::LegacyOpen(keymap_file)); |
756 | CHECK(ifs.get() != NULL); // should never happen | |
756 | CHECK(ifs.get() != nullptr); // should never happen | |
757 | 757 | std::stringstream buffer; |
758 | 758 | buffer << ifs->rdbuf(); |
759 | 759 | current_keymap_table = buffer.str(); |
152 | 152 | |
153 | 153 | // Choose next or prev item. |
154 | 154 | QTableWidgetItem *item = editorTableWidget->item(rows.back() + 1, column); |
155 | if (item == NULL) { | |
155 | if (item == nullptr) { | |
156 | 156 | item = editorTableWidget->item(rows.back() - 1, column); |
157 | 157 | } |
158 | 158 | |
159 | 159 | // select item |
160 | if (item != NULL) { | |
160 | if (item != nullptr) { | |
161 | 161 | editorTableWidget->setCurrentItem(item); |
162 | 162 | } |
163 | 163 | |
187 | 187 | editorTableWidget->setItem(row, i, new QTableWidgetItem("")); |
188 | 188 | } |
189 | 189 | QTableWidgetItem *item = editorTableWidget->item(row, 0); |
190 | if (item != NULL) { | |
190 | if (item != nullptr) { | |
191 | 191 | editorTableWidget->setCurrentItem(item); |
192 | 192 | editorTableWidget->scrollToItem(item, QAbstractItemView::PositionAtCenter); |
193 | 193 | editorTableWidget->editItem(item); |
208 | 208 | |
209 | 209 | void GenericTableEditorDialog::InsertItem() { |
210 | 210 | QTableWidgetItem *current = editorTableWidget->currentItem(); |
211 | if (current == NULL) { | |
211 | if (current == nullptr) { | |
212 | 212 | QMessageBox::warning(this, windowTitle(), tr("No entry is selected")); |
213 | 213 | return; |
214 | 214 | } |
296 | 296 | |
297 | 297 | void GenericTableEditorDialog::OnContextMenuRequested(const QPoint &pos) { |
298 | 298 | QTableWidgetItem *item = editorTableWidget->itemAt(pos); |
299 | if (item == NULL) { | |
299 | if (item == nullptr) { | |
300 | 300 | return; |
301 | 301 | } |
302 | 302 | |
303 | 303 | QMenu *menu = new QMenu(this); |
304 | QAction *edit_action = NULL; | |
304 | QAction *edit_action = nullptr; | |
305 | 305 | const QList<QTableWidgetItem *> selected_items = |
306 | 306 | editorTableWidget->selectedItems(); |
307 | 307 | if (selected_items.count() == 1) { |
311 | 311 | QAction *delete_action = menu->addAction(tr("Remove entry")); |
312 | 312 | QAction *selected_action = menu->exec(QCursor::pos()); |
313 | 313 | |
314 | if (edit_action != NULL && selected_action == edit_action) { | |
314 | if (edit_action != nullptr && selected_action == edit_action) { | |
315 | 315 | editorTableWidget->editItem(selected_items[0]); |
316 | 316 | } else if (selected_action == rename_action) { |
317 | 317 | AddNewItem(); |
322 | 322 | |
323 | 323 | void GenericTableEditorDialog::UpdateOKButton(bool status) { |
324 | 324 | QPushButton *button = editorButtonBox->button(QDialogButtonBox::Ok); |
325 | if (button != NULL) { | |
325 | if (button != nullptr) { | |
326 | 326 | button->setEnabled(status); |
327 | 327 | } |
328 | 328 | } |
487 | 487 | |
488 | 488 | QPushButton *ok_button = |
489 | 489 | KeyBindingEditorbuttonBox->button(QDialogButtonBox::Ok); |
490 | CHECK(ok_button != NULL); | |
490 | CHECK(ok_button != nullptr); | |
491 | 491 | |
492 | 492 | filter_.reset(new KeyBindingFilter(KeyBindingLineEdit, ok_button)); |
493 | 493 | KeyBindingLineEdit->installEventFilter(filter_.get()); |
77 | 77 | const QString str = index.model()->data(index, Qt::EditRole).toString(); |
78 | 78 | KeyBindingEditorTriggerButton *button = |
79 | 79 | static_cast<KeyBindingEditorTriggerButton *>(editor); |
80 | if (button == NULL) { | |
80 | if (button == nullptr) { | |
81 | 81 | return; |
82 | 82 | } |
83 | 83 | button->setText(str); |
89 | 89 | const QModelIndex &index) const { |
90 | 90 | KeyBindingEditorTriggerButton *button = |
91 | 91 | static_cast<KeyBindingEditorTriggerButton *>(editor); |
92 | if (model == NULL || button == NULL) { | |
92 | if (model == nullptr || button == nullptr) { | |
93 | 93 | return; |
94 | 94 | } |
95 | 95 | model->setData(index, button->mutable_editor()->GetBinding(), Qt::EditRole); |
98 | 98 | void KeyBindingEditorDelegate::updateEditorGeometry( |
99 | 99 | QWidget *editor, const QStyleOptionViewItem &option, |
100 | 100 | const QModelIndex &index) const { |
101 | if (editor == NULL) { | |
101 | if (editor == nullptr) { | |
102 | 102 | return; |
103 | 103 | } |
104 | 104 | editor->setGeometry(option.rect); |
109 | 109 | KeyBindingEditorTriggerButton *button = |
110 | 110 | static_cast<KeyBindingEditorTriggerButton *>( |
111 | 111 | editor->mutable_trigger_parent()); |
112 | if (button == NULL) { | |
112 | if (button == nullptr) { | |
113 | 113 | return; |
114 | 114 | } |
115 | 115 | emit commitData(button); |
121 | 121 | KeyBindingEditorTriggerButton *button = |
122 | 122 | static_cast<KeyBindingEditorTriggerButton *>( |
123 | 123 | editor->mutable_trigger_parent()); |
124 | if (button == NULL) { | |
124 | if (button == nullptr) { | |
125 | 125 | return; |
126 | 126 | } |
127 | 127 | emit closeEditor(button); |
41 | 41 | class KeyBindingEditorDelegate : public QItemDelegate { |
42 | 42 | Q_OBJECT |
43 | 43 | public: |
44 | explicit KeyBindingEditorDelegate(QObject *parent = NULL); | |
44 | explicit KeyBindingEditorDelegate(QObject *parent = nullptr); | |
45 | 45 | virtual ~KeyBindingEditorDelegate(); |
46 | 46 | |
47 | 47 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
317 | 317 | KeyMapEditorDialog::~KeyMapEditorDialog() {} |
318 | 318 | |
319 | 319 | bool KeyMapEditorDialog::LoadFromStream(std::istream *is) { |
320 | if (is == NULL) { | |
320 | if (is == nullptr) { | |
321 | 321 | return false; |
322 | 322 | } |
323 | 323 | |
498 | 498 | keymap::KeyMapManager::GetKeyMapFileName(kKeyMaps[import_index]); |
499 | 499 | std::unique_ptr<std::istream> ifs( |
500 | 500 | ConfigFileStream::LegacyOpen(keymap_file)); |
501 | CHECK(ifs.get() != NULL); // should never happen | |
501 | CHECK(ifs.get() != nullptr); // should never happen | |
502 | 502 | CHECK(LoadFromStream(ifs.get())); |
503 | 503 | } |
504 | 504 | } else if (action == actions_[EXPORT_TO_FILE_INDEX]) { |
Binary diff not shown
90 | 90 | std::string RomanTableEditorDialog::GetDefaultRomanTable() { |
91 | 91 | std::unique_ptr<std::istream> ifs( |
92 | 92 | ConfigFileStream::LegacyOpen(kRomanTableFile)); |
93 | CHECK(ifs.get() != NULL); // should never happen | |
93 | CHECK(ifs.get() != nullptr); // should never happen | |
94 | 94 | std::string line, result; |
95 | 95 | std::vector<std::string> fields; |
96 | 96 | while (getline(*ifs.get(), line)) { |
170 | 170 | bool RomanTableEditorDialog::LoadDefaultRomanTable() { |
171 | 171 | std::unique_ptr<std::istream> ifs( |
172 | 172 | ConfigFileStream::LegacyOpen(kRomanTableFile)); |
173 | CHECK(ifs.get() != NULL); // should never happen | |
173 | CHECK(ifs.get() != nullptr); // should never happen | |
174 | 174 | CHECK(LoadFromStream(ifs.get())); |
175 | 175 | return true; |
176 | 176 | } |
48 | 48 | // Message |
49 | 49 | QObject::tr("Invalid confirmation dialog. " |
50 | 50 | "You specified less arguments."), |
51 | QMessageBox::Yes | QMessageBox::No, NULL, | |
51 | QMessageBox::Yes | QMessageBox::No, nullptr, | |
52 | 52 | Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowStaysOnTopHint); |
53 | 53 | |
54 | 54 | if (FLAGS_confirmation_type == "update") { |
58 | 58 | "(Note: some features will not be available " |
59 | 59 | "until you log out and log back in.)")); |
60 | 60 | QAbstractButton *yes_button = message_box.button(QMessageBox::Yes); |
61 | if (yes_button != NULL) { | |
61 | if (yes_button != nullptr) { | |
62 | 62 | yes_button->setText(QObject::tr("Activate now")); |
63 | 63 | } |
64 | 64 | QAbstractButton *no_button = message_box.button(QMessageBox::No); |
65 | if (no_button != NULL) { | |
65 | if (no_button != nullptr) { | |
66 | 66 | no_button->setText(QObject::tr("Wait until logout")); |
67 | 67 | } |
68 | 68 | } else if (FLAGS_confirmation_type == "log_out") { |
70 | 70 | QObject::tr("Mozc has been updated. " |
71 | 71 | "Please log out and back in to enable the new version.")); |
72 | 72 | QAbstractButton *yes_button = message_box.button(QMessageBox::Yes); |
73 | if (yes_button != NULL) { | |
73 | if (yes_button != nullptr) { | |
74 | 74 | yes_button->setText(QObject::tr("Log out")); |
75 | 75 | } |
76 | 76 | QAbstractButton *no_button = message_box.button(QMessageBox::No); |
77 | if (no_button != NULL) { | |
77 | if (no_button != nullptr) { | |
78 | 78 | no_button->setText(QObject::tr("Remind me in 1 hour")); |
79 | 79 | } |
80 | 80 | } |
52 | 52 | alternate_index = 1; |
53 | 53 | } else { |
54 | 54 | QTableWidgetItem *last_item = item(rowCount() - 1, 0); |
55 | if (last_item == NULL) { | |
55 | if (last_item == nullptr) { | |
56 | 56 | return; |
57 | 57 | } |
58 | 58 | rect = visualItemRect(last_item); |
77 | 77 | |
78 | 78 | // When empty area is double-clicked, emit a signal |
79 | 79 | #ifdef __APPLE__ |
80 | if (NULL == itemAt(event->pos())) { | |
80 | if (nullptr == itemAt(event->pos())) { | |
81 | 81 | emit emptyAreaClicked(); |
82 | 82 | } |
83 | 83 | #endif // __APPLE__ |
63 | 63 | #include "dictionary/user_dictionary_util.h" |
64 | 64 | #include "gui/base/encoding_util.h" |
65 | 65 | #include "gui/base/msime_user_dictionary_importer.h" |
66 | #include "gui/base/util.h" | |
66 | 67 | #include "gui/config_dialog/combobox_delegate.h" |
67 | 68 | #include "gui/dictionary_tool/find_dialog.h" |
68 | 69 | #include "gui/dictionary_tool/import_dialog.h" |
231 | 232 | |
232 | 233 | // strip UTF8 BOM |
233 | 234 | if (first_line_ && encoding_type_ == UserDictionaryImporter::UTF8) { |
234 | Util::StripUTF8BOM(line); | |
235 | } | |
236 | ||
237 | Util::ChopReturns(line); | |
235 | mozc::Util::StripUTF8BOM(line); | |
236 | } | |
237 | ||
238 | mozc::Util::ChopReturns(line); | |
238 | 239 | |
239 | 240 | first_line_ = false; |
240 | 241 | return true; |
286 | 287 | parent); |
287 | 288 | break; |
288 | 289 | default: |
289 | return NULL; | |
290 | } | |
291 | ||
292 | return NULL; | |
290 | return nullptr; | |
291 | } | |
292 | ||
293 | return nullptr; | |
293 | 294 | } |
294 | 295 | } // namespace |
295 | 296 | |
296 | 297 | DictionaryTool::DictionaryTool(QWidget *parent) |
297 | 298 | : QMainWindow(parent), |
298 | import_dialog_(NULL), | |
299 | find_dialog_(NULL), | |
299 | import_dialog_(nullptr), | |
300 | find_dialog_(nullptr), | |
300 | 301 | session_(new UserDictionarySession( |
301 | 302 | UserDictionaryUtil::GetUserDictionaryFileName())), |
302 | 303 | current_dic_id_(0), |
303 | 304 | modified_(false), |
304 | 305 | monitoring_user_edit_(false), |
305 | window_title_(tr("Mozc")), | |
306 | window_title_(gui::Util::ProductName()), | |
306 | 307 | dic_menu_(new QMenu), |
307 | new_action_(NULL), | |
308 | rename_action_(NULL), | |
309 | delete_action_(NULL), | |
310 | find_action_(NULL), | |
311 | import_create_action_(NULL), | |
312 | import_append_action_(NULL), | |
313 | export_action_(NULL), | |
314 | import_default_ime_action_(NULL), | |
308 | new_action_(nullptr), | |
309 | rename_action_(nullptr), | |
310 | delete_action_(nullptr), | |
311 | find_action_(nullptr), | |
312 | import_create_action_(nullptr), | |
313 | import_append_action_(nullptr), | |
314 | export_action_(nullptr), | |
315 | import_default_ime_action_(nullptr), | |
315 | 316 | client_(client::ClientFactory::NewClient()), |
316 | 317 | is_available_(true), |
317 | 318 | max_entry_size_(mozc::UserDictionaryStorage::max_entry_size()), |
580 | 581 | SyncToStorage(); |
581 | 582 | |
582 | 583 | DictionaryInfo dic_info = current_dictionary(); |
583 | if (dic_info.item == NULL) { | |
584 | if (dic_info.item == nullptr) { | |
584 | 585 | current_dic_id_ = 0; |
585 | 586 | StopMonitoringUserEdit(); |
586 | 587 | dic_content_->clearContents(); |
604 | 605 | UserDictionary *dic = |
605 | 606 | session_->mutable_storage()->GetUserDictionary(dic_info.id); |
606 | 607 | |
607 | if (dic == NULL) { | |
608 | if (dic == nullptr) { | |
608 | 609 | LOG(ERROR) << "Failed to load the dictionary: " << dic_info.id; |
609 | 610 | ReportError(); |
610 | 611 | return; |
680 | 681 | |
681 | 682 | void DictionaryTool::DeleteDictionary() { |
682 | 683 | DictionaryInfo dic_info = current_dictionary(); |
683 | if (dic_info.item == NULL) { | |
684 | if (dic_info.item == nullptr) { | |
684 | 685 | QMessageBox::information(this, window_title_, |
685 | 686 | tr("No dictionary is selected.")); |
686 | 687 | return; |
709 | 710 | |
710 | 711 | void DictionaryTool::RenameDictionary() { |
711 | 712 | DictionaryInfo dic_info = current_dictionary(); |
712 | if (dic_info.item == NULL) { | |
713 | if (dic_info.item == nullptr) { | |
713 | 714 | QMessageBox::information(this, window_title_, |
714 | 715 | tr("No dictionary is selected.")); |
715 | 716 | return; |
757 | 758 | |
758 | 759 | void DictionaryTool::ImportAndAppendDictionary() { |
759 | 760 | DictionaryInfo dic_info = current_dictionary(); |
760 | if (dic_info.item == NULL) { | |
761 | if (dic_info.item == nullptr) { | |
761 | 762 | LOG(WARNING) << "No dictionary to import is selected"; |
762 | 763 | QMessageBox::information(this, window_title_, |
763 | 764 | tr("No dictionary is selected.")); |
798 | 799 | "unsupported file format.\n\n" |
799 | 800 | "Please check the file format. " |
800 | 801 | "ATOK11 or older format is not supported by " |
801 | "Mozc.")); | |
802 | "%1.").arg(gui::Util::ProductName())); | |
802 | 803 | break; |
803 | 804 | case UserDictionaryImporter::IMPORT_TOO_MANY_WORDS: |
804 | 805 | QMessageBox::information( |
848 | 849 | |
849 | 850 | UserDictionary *dic = session_->mutable_storage()->GetUserDictionary(dic_id); |
850 | 851 | |
851 | if (dic == NULL) { | |
852 | if (dic == nullptr) { | |
852 | 853 | LOG(ERROR) << "Cannot find dictionary id: " << dic_id; |
853 | 854 | ReportError(); |
854 | 855 | return; |
866 | 867 | // Open dictionary |
867 | 868 | std::unique_ptr<UserDictionaryImporter::TextLineIteratorInterface> iter( |
868 | 869 | CreateTextLineIterator(encoding_type, file_name, this)); |
869 | if (iter.get() == NULL) { | |
870 | LOG(ERROR) << "CreateTextLineIterator returns NULL"; | |
870 | if (iter == nullptr) { | |
871 | LOG(ERROR) << "CreateTextLineIterator returns nullptr"; | |
871 | 872 | return; |
872 | 873 | } |
873 | 874 | |
905 | 906 | } |
906 | 907 | |
907 | 908 | DictionaryInfo dic_info = current_dictionary(); |
908 | if (dic_info.item == NULL) { | |
909 | if (dic_info.item == nullptr) { | |
909 | 910 | LOG(WARNING) << "No dictionary to import is selected"; |
910 | 911 | QMessageBox::information(this, window_title_, |
911 | 912 | tr("No dictionary is selected.")); |
954 | 955 | |
955 | 956 | void DictionaryTool::ExportDictionary() { |
956 | 957 | DictionaryInfo dic_info = current_dictionary(); |
957 | if (dic_info.item == NULL) { | |
958 | if (dic_info.item == nullptr) { | |
958 | 959 | LOG(WARNING) << "No dictionary to export is selected"; |
959 | 960 | QMessageBox::information(this, window_title_, |
960 | 961 | tr("No dictionary is selected.")); |
1039 | 1040 | QList<QListWidgetItem *> selected_dicts = dic_list_->selectedItems(); |
1040 | 1041 | if (selected_dicts.isEmpty()) { |
1041 | 1042 | LOG(WARNING) << "No current dictionary."; |
1042 | return NULL; | |
1043 | return nullptr; | |
1043 | 1044 | } |
1044 | 1045 | if (selected_dicts.size() > 1) { |
1045 | 1046 | LOG(WARNING) << "Multiple items are selected."; |
1110 | 1111 | } |
1111 | 1112 | |
1112 | 1113 | void DictionaryTool::MoveTo(int dictionary_row) { |
1113 | UserDictionary *target_dict = NULL; | |
1114 | UserDictionary *target_dict = nullptr; | |
1114 | 1115 | { |
1115 | 1116 | const QListWidgetItem *selected_dict = GetFirstSelectedDictionary(); |
1116 | if (selected_dict == NULL) { | |
1117 | if (selected_dict == nullptr) { | |
1117 | 1118 | return; |
1118 | 1119 | } |
1119 | 1120 | QListWidgetItem *target_dict_item = dic_list_->item(dictionary_row); |
1249 | 1250 | QTableWidgetItem *item = dic_content_->itemAt(pos); |
1250 | 1251 | // When the mouse pointer is not on an item of the table widget, we |
1251 | 1252 | // don't show context menu. |
1252 | if (item == NULL) { | |
1253 | if (item == nullptr) { | |
1253 | 1254 | return; |
1254 | 1255 | } |
1255 | 1256 | |
1279 | 1280 | change_dictionary_actions.reserve(dic_list_->count() - 1); |
1280 | 1281 | { |
1281 | 1282 | const QListWidgetItem *selected_dict = GetFirstSelectedDictionary(); |
1282 | if (selected_dict != NULL) { | |
1283 | if (selected_dict != nullptr) { | |
1283 | 1284 | for (size_t i = 0; i < dic_list_->count(); ++i) { |
1284 | 1285 | QListWidgetItem *item = dic_list_->item(i); |
1285 | 1286 | DCHECK(item); |
1337 | 1338 | |
1338 | 1339 | void DictionaryTool::OnContextMenuRequestedForList(const QPoint &pos) { |
1339 | 1340 | QListWidgetItem *item = dic_list_->itemAt(pos); |
1340 | if (item == NULL) { | |
1341 | if (item == nullptr) { | |
1341 | 1342 | return; |
1342 | 1343 | } |
1343 | 1344 | |
1349 | 1350 | QAction *export_action = menu->addAction(tr("Export this dictionary...")); |
1350 | 1351 | QAction *selected_action = menu->exec(QCursor::pos()); |
1351 | 1352 | |
1352 | if ((rename_action != NULL) && (selected_action == rename_action)) { | |
1353 | if ((rename_action != nullptr) && (selected_action == rename_action)) { | |
1353 | 1354 | RenameDictionary(); |
1354 | } else if ((delete_action != NULL) && (selected_action == delete_action)) { | |
1355 | } else if ((delete_action != nullptr) && (selected_action == delete_action)) { | |
1355 | 1356 | DeleteDictionary(); |
1356 | } else if ((import_action != NULL) && (selected_action == import_action)) { | |
1357 | } else if ((import_action != nullptr) && (selected_action == import_action)) { | |
1357 | 1358 | ImportAndAppendDictionary(); |
1358 | } else if ((export_action != NULL) && (selected_action == export_action)) { | |
1359 | } else if ((export_action != nullptr) && (selected_action == export_action)) { | |
1359 | 1360 | ExportDictionary(); |
1360 | 1361 | } |
1361 | 1362 | } |
1362 | 1363 | |
1363 | 1364 | DictionaryTool::DictionaryInfo DictionaryTool::current_dictionary() const { |
1364 | DictionaryInfo retval = {-1, 0, NULL}; | |
1365 | DictionaryInfo retval = {-1, 0, nullptr}; | |
1365 | 1366 | |
1366 | 1367 | QListWidgetItem *selected_dict = GetFirstSelectedDictionary(); |
1367 | if (selected_dict == NULL) { | |
1368 | if (selected_dict == nullptr) { | |
1368 | 1369 | return retval; |
1369 | 1370 | } |
1370 | 1371 | |
1382 | 1383 | UserDictionary *dic = |
1383 | 1384 | session_->mutable_storage()->GetUserDictionary(current_dic_id_); |
1384 | 1385 | |
1385 | if (dic == NULL) { | |
1386 | if (dic == nullptr) { | |
1386 | 1387 | LOG(ERROR) << "No save dictionary: " << current_dic_id_; |
1387 | 1388 | return; |
1388 | 1389 | } |
1574 | 1575 | delete_word_button_->setEnabled(dic_content_->rowCount() > 0); |
1575 | 1576 | |
1576 | 1577 | const DictionaryInfo dic_info = current_dictionary(); |
1577 | if (dic_info.item != NULL) { | |
1578 | if (dic_info.item != nullptr) { | |
1578 | 1579 | statusbar_message_ = QString(tr("%1: %2 entries")) |
1579 | 1580 | .arg(dic_info.item->text()) |
1580 | 1581 | .arg(dic_content_->rowCount()); |
175 | 175 | void GetSortedSelectedRows(std::vector<int> *rows) const; |
176 | 176 | |
177 | 177 | // Returns a pointer to the first selected dictionary. |
178 | // Returns NULL if no dictionary is selected. | |
178 | // Returns nullptr if no dictionary is selected. | |
179 | 179 | QListWidgetItem *GetFirstSelectedDictionary() const; |
180 | 180 | |
181 | 181 | ImportDialog *import_dialog_; |
Binary diff not shown
285 | 285 | <location filename="dictionary_tool.cc" line="786"/> |
286 | 286 | <source>You have imported a file in an invalid or unsupported file format. |
287 | 287 | |
288 | Please check the file format. ATOK11 or older format is not supported by Mozc.</source> | |
288 | Please check the file format. ATOK11 or older format is not supported by %1.</source> | |
289 | 289 | <translation></translation> |
290 | 290 | </message> |
291 | 291 | <message> |
Binary diff not shown
198 | 198 | <location filename="dictionary_tool.cc" line="786"/> |
199 | 199 | <source>You have imported a file in an invalid or unsupported file format. |
200 | 200 | |
201 | Please check the file format. ATOK11 or older format is not supported by Mozc.</source> | |
202 | <translation>指定されたファイルは Mozcでサポートされていないフォーマットで保存されています。 | |
201 | Please check the file format. ATOK11 or older format is not supported by %1.</source> | |
202 | <translation>指定されたファイルは %1 でサポートされていないフォーマットで保存されています。 | |
203 | 203 | |
204 | 204 | インポート対象のファイルフォーマットを確認してください。 |
205 | 205 |
44 | 44 | FindDialog::FindDialog(QWidget *parent, QTableWidget *table) |
45 | 45 | : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), |
46 | 46 | table_(table), |
47 | last_item_(NULL) { | |
47 | last_item_(nullptr) { | |
48 | 48 | setupUi(this); |
49 | 49 | setModal(false); |
50 | 50 | |
66 | 66 | QuerylineEdit->selectAll(); |
67 | 67 | } |
68 | 68 | FindForwardpushButton->setDefault(true); |
69 | last_item_ = NULL; | |
69 | last_item_ = nullptr; | |
70 | 70 | UpdateUIStatus(); |
71 | 71 | } |
72 | 72 | |
73 | 73 | void FindDialog::closeEvent(QCloseEvent *event) { |
74 | 74 | table_->setStyleSheet(""); |
75 | last_item_ = NULL; | |
75 | last_item_ = nullptr; | |
76 | 76 | } |
77 | 77 | |
78 | 78 | void FindDialog::UpdateUIStatus() { |
82 | 82 | } |
83 | 83 | |
84 | 84 | bool FindDialog::Match(const QString &query, int row, int column) { |
85 | if (last_item_ != NULL && last_item_ == table_->item(row, column)) { | |
85 | if (last_item_ != nullptr && last_item_ == table_->item(row, column)) { | |
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | const QString &value = table_->item(row, column)->text(); |
145 | 145 | table_->setCurrentItem(item); |
146 | 146 | table_->scrollToItem(item); |
147 | 147 | } else { |
148 | last_item_ = NULL; | |
148 | last_item_ = nullptr; | |
149 | 149 | QMessageBox::information(this, this->windowTitle(), |
150 | 150 | tr("Cannot find pattern %1").arg(query)); |
151 | 151 | } |
82 | 82 | static_cast<int>(UserDictionaryImporter::UTF8)); |
83 | 83 | |
84 | 84 | QPushButton *button = buttonbox_->button(QDialogButtonBox::Ok); |
85 | if (button != NULL) { | |
85 | if (button != nullptr) { | |
86 | 86 | button->setText(tr("Import")); |
87 | 87 | } |
88 | 88 | |
141 | 141 | |
142 | 142 | void ImportDialog::OnFormValueChanged() { |
143 | 143 | QPushButton *button = buttonbox_->button(QDialogButtonBox::Ok); |
144 | if (button != NULL) { | |
144 | if (button != nullptr) { | |
145 | 145 | button->setEnabled(IsAcceptButtonEnabled()); |
146 | 146 | } |
147 | 147 | } |
46 | 46 | // to set WindowStaysOnTopHint |
47 | 47 | QMessageBox message_box( |
48 | 48 | QMessageBox::Critical, QObject::tr("Mozc Fatal Error"), |
49 | message, QMessageBox::Ok, NULL, | |
49 | message, QMessageBox::Ok, nullptr, | |
50 | 50 | Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowStaysOnTopHint); |
51 | 51 | DeleyedMessageDialogHandler handler(&message_box); |
52 | 52 | handler.Exec(); |
63 | 63 | const int kDisableInterval = 3000; |
64 | 64 | QTimer::singleShot(kDisableInterval, this, SLOT(EnableOkButton())); |
65 | 65 | QAbstractButton *button = message_box_->button(QMessageBox::Ok); |
66 | if (button != NULL) { | |
66 | if (button != nullptr) { | |
67 | 67 | button->setEnabled(false); |
68 | 68 | } |
69 | 69 | message_box_->exec(); |
71 | 71 | |
72 | 72 | void DeleyedMessageDialogHandler::EnableOkButton() { |
73 | 73 | QAbstractButton *button = message_box_->button(QMessageBox::Ok); |
74 | if (button != NULL) { | |
74 | if (button != nullptr) { | |
75 | 75 | button->setEnabled(true); |
76 | 76 | } |
77 | 77 | } |
88 | 88 | cc_qt_binary_mozc( |
89 | 89 | name = "mozc_tool", |
90 | 90 | srcs = ["mozc_tool_main.cc"], |
91 | visibility = ["//:__pkg__"], | |
91 | 92 | deps = [ |
92 | 93 | ":mozc_tool_lib", |
93 | 94 | "//base:init_mozc", |
75 | 75 | #if defined(OS_WIN) |
76 | 76 | std::wstring wenvname; |
77 | 77 | mozc::Util::UTF8ToWide(envname, &wenvname); |
78 | const DWORD buffer_size = ::GetEnvironmentVariable(wenvname.c_str(), NULL, 0); | |
78 | const DWORD buffer_size = | |
79 | ::GetEnvironmentVariable(wenvname.c_str(), nullptr, 0); | |
79 | 80 | if (buffer_size == 0) { |
80 | 81 | return ""; |
81 | 82 | } |
225 | 226 | |
226 | 227 | QAbstractButton *button = |
227 | 228 | WordRegisterDialogbuttonBox->button(QDialogButtonBox::Ok); |
228 | if (button != NULL) { | |
229 | if (button != nullptr) { | |
229 | 230 | button->setEnabled(enabled); |
230 | 231 | } |
231 | 232 | } |
406 | 407 | |
407 | 408 | // Get default value from Clipboard |
408 | 409 | void WordRegisterDialog::SetDefaultEntryFromClipboard() { |
409 | if (QApplication::clipboard() == NULL) { | |
410 | if (QApplication::clipboard() == nullptr) { | |
410 | 411 | return; |
411 | 412 | } |
412 | 413 | CopyCurrentSelectionToClipboard(); |
418 | 419 | void WordRegisterDialog::CopyCurrentSelectionToClipboard() { |
419 | 420 | #ifdef OS_WIN |
420 | 421 | const HWND foreground_window = ::GetForegroundWindow(); |
421 | if (foreground_window == NULL) { | |
422 | if (foreground_window == nullptr) { | |
422 | 423 | LOG(ERROR) << "GetForegroundWindow() failed: " << ::GetLastError(); |
423 | 424 | return; |
424 | 425 | } |
425 | 426 | |
426 | const DWORD thread_id = ::GetWindowThreadProcessId(foreground_window, NULL); | |
427 | const DWORD thread_id = | |
428 | ::GetWindowThreadProcessId(foreground_window, nullptr); | |
427 | 429 | |
428 | 430 | if (!::AttachThreadInput(::GetCurrentThreadId(), thread_id, TRUE)) { |
429 | 431 | LOG(ERROR) << "AttachThreadInput failed: " << ::GetLastError(); |
434 | 436 | |
435 | 437 | ::AttachThreadInput(::GetCurrentThreadId(), thread_id, FALSE); |
436 | 438 | |
437 | if (focus_window == NULL || !::IsWindow(focus_window)) { | |
439 | if (focus_window == nullptr || !::IsWindow(focus_window)) { | |
438 | 440 | LOG(WARNING) << "No focus window"; |
439 | 441 | return; |
440 | 442 | } |
477 | 479 | #ifdef OS_WIN |
478 | 480 | // TODO(taku): implement it for other platform. |
479 | 481 | HIMC himc = ::ImmGetContext(reinterpret_cast<HWND>(winId())); |
480 | if (himc != NULL) { | |
482 | if (himc != nullptr) { | |
481 | 483 | ::ImmSetOpenStatus(himc, TRUE); |
482 | 484 | } |
483 | 485 | #endif // OS_WIN |
45 | 45 | 'compiler_host_version_int%': '0', # (major_ver) * 100 + (minor_ver) |
46 | 46 | |
47 | 47 | # Versioning stuff for Mac. |
48 | 'mac_sdk%': '10.14', | |
48 | 'mac_sdk%': '10.15', | |
49 | 49 | 'mac_deployment_target%': '10.9', |
50 | 50 | |
51 | 51 | # Flag to specify if the build target is for simulator or not. |
53 | 53 | 'compiler_host': 'msvs', |
54 | 54 | 'compiler_host_version_int': 1900, # Visual C++ 2015 or higher |
55 | 55 | }], |
56 | ['MSVS_VERSION=="2017"', { | |
57 | 'compiler_target': 'msvs', | |
58 | 'compiler_target_version_int': 1910, # Visual C++ 2017 or higher | |
59 | 'compiler_host': 'msvs', | |
60 | 'compiler_host_version_int': 1910, # Visual C++ 2017 or higher | |
61 | }], | |
56 | 62 | ], |
57 | 63 | 'msvc_disabled_warnings': [ |
58 | 64 | # 'expression' : signed/unsigned mismatch |
39 | 39 | |
40 | 40 | #endif // GOOGLE_JAPANESE_INPUT_BUILD |
41 | 41 | |
42 | #include "base/compiler_specific.h" | |
43 | 42 | #include "base/logging.h" |
44 | 43 | #include "base/port.h" |
45 | 44 | #include "base/singleton.h" |
28 | 28 | |
29 | 29 | #include "net/json_util.h" |
30 | 30 | |
31 | #include <limits> | |
31 | 32 | #include <string> |
32 | 33 | #include <vector> |
33 | 34 | |
246 | 247 | EXPECT_PROTO_EQ(msg, new_msg); |
247 | 248 | } |
248 | 249 | |
249 | TEST(JsonUtilTest, ConvertItemTest){ | |
250 | TEST(JsonUtilTest, ConvertItemTest) { | |
250 | 251 | #define TEST_CONVERT_ITEM(proto_setter, proto_value, json_name, json_value) \ |
251 | 252 | { \ |
252 | 253 | TestMsg msg; \ |
262 | 263 | FillRequiredFields(&msg); \ |
263 | 264 | EXPECT_PROTO_EQ(msg, new_msg); \ |
264 | 265 | } |
265 | TEST_CONVERT_ITEM( | |
266 | set_double_value, | |
267 | 1.0, "double_value", 1.0) TEST_CONVERT_ITEM(set_float_value, 2.0, | |
268 | "float_value", 2.0) TEST_CONVERT_ITEM(set_int32_value, | |
269 | 3, | |
270 | "int32_value", Json::Int(3)) TEST_CONVERT_ITEM(set_int32_value, | |
271 | -3, | |
272 | "int32_value", Json::Int(-3)) TEST_CONVERT_ITEM(set_int32_value, | |
273 | kint32min, | |
274 | "int32_value", Json::Int(kint32min)) TEST_CONVERT_ITEM(set_int32_value, | |
275 | kint32max, | |
276 | "int32_value", | |
277 | Json::Int( | |
278 | kint32max)) TEST_CONVERT_ITEM(set_int64_value, | |
279 | 4, | |
280 | "int64_value", | |
281 | "4") TEST_CONVERT_ITEM(set_int64_value, | |
282 | -4, | |
283 | "int64_value", | |
284 | "-4") TEST_CONVERT_ITEM(set_int64_value, | |
285 | kint64min, | |
286 | "int64_value", | |
287 | "-9223372036854775808") TEST_CONVERT_ITEM(set_int64_value, | |
288 | kint64max, | |
289 | "int64_value", | |
290 | "9223372036854775807") TEST_CONVERT_ITEM(set_uint32_value, | |
291 | 5, | |
292 | "uint32_value", | |
293 | Json::UInt( | |
294 | 5)) TEST_CONVERT_ITEM(set_uint32_value, | |
295 | kuint32max, | |
296 | "uint32_value", | |
297 | Json:: | |
298 | UInt( | |
299 | kuint32max)) TEST_CONVERT_ITEM(set_uint64_value, | |
300 | 6, | |
301 | "uint64_value", | |
302 | "6") TEST_CONVERT_ITEM(set_uint64_value, | |
303 | kuint64max, | |
304 | "uint64_value", | |
305 | "18446744073709551615") TEST_CONVERT_ITEM(set_sint32_value, | |
306 | 7, | |
307 | "sint32_value", | |
308 | Json::Int(7)) TEST_CONVERT_ITEM(set_sint32_value, | |
309 | -7, | |
310 | "sint32_value", Json::Int(-7)) TEST_CONVERT_ITEM(set_sint32_value, | |
311 | kint32min, | |
312 | "sint32_value", | |
313 | Json::Int( | |
314 | kint32min)) TEST_CONVERT_ITEM(set_sint32_value, | |
315 | kint32max, | |
316 | "sint32_value", | |
317 | Json:: | |
318 | Int(kint32max)) TEST_CONVERT_ITEM(set_sint64_value, | |
319 | 8, | |
320 | "sint64_value", | |
321 | "8") TEST_CONVERT_ITEM(set_sint64_value, | |
322 | -8, | |
323 | "sint64_value", | |
324 | "-8") TEST_CONVERT_ITEM(set_sint64_value, | |
325 | kint64min, | |
326 | "sint64_value", | |
327 | "-9223372036854775808") TEST_CONVERT_ITEM(set_sint64_value, | |
328 | kint64max, | |
329 | "sint64_value", | |
330 | "9223372036854775807") TEST_CONVERT_ITEM(set_fixed32_value, | |
331 | 9, | |
332 | "fixed32_value", Json::UInt(9)) TEST_CONVERT_ITEM(set_fixed32_value, | |
333 | kuint32max, | |
334 | "fixed32_value", | |
335 | Json:: | |
336 | UInt(kuint32max)) TEST_CONVERT_ITEM(set_fixed64_value, | |
337 | 10, | |
338 | "fixed64_value", | |
339 | "10") TEST_CONVERT_ITEM(set_fixed64_value, | |
340 | kuint64max, | |
341 | "fixed64_value", | |
342 | "18446744073709551615") TEST_CONVERT_ITEM(set_sfixed32_value, | |
343 | 11, | |
344 | "sfixed32_value", | |
345 | Json::Int( | |
346 | 11)) TEST_CONVERT_ITEM(set_sfixed32_value, | |
347 | -11, | |
348 | "sfixed32_value", | |
349 | Json:: | |
350 | Int(-11)) TEST_CONVERT_ITEM(set_sfixed32_value, | |
351 | kint32min, | |
352 | "sfixed32_value", | |
353 | Json:: | |
354 | Int(kint32min)) TEST_CONVERT_ITEM(set_sfixed32_value, | |
355 | kint32max, | |
356 | "sfixed32_value", | |
357 | Json::Int(kint32max)) TEST_CONVERT_ITEM(set_sfixed64_value, | |
358 | 12, | |
359 | "sfixed64_value", | |
360 | "12") TEST_CONVERT_ITEM(set_sfixed64_value, | |
361 | -12, | |
362 | "sfixed64_value", | |
363 | "-12") TEST_CONVERT_ITEM(set_sfixed64_value, | |
364 | kint64min, | |
365 | "sfixed64_value", | |
366 | "-9223372036854775808") TEST_CONVERT_ITEM(set_sfixed64_value, | |
367 | kint64max, | |
368 | "sfixed64_value", | |
369 | "9223372036854775807") TEST_CONVERT_ITEM(set_bool_value, | |
370 | true, | |
371 | "bool_value", | |
372 | true) TEST_CONVERT_ITEM(set_bool_value, | |
373 | false, | |
374 | "bool_value", false) TEST_CONVERT_ITEM(set_string_value, | |
375 | "string", | |
376 | "string_value", | |
377 | "string") TEST_CONVERT_ITEM(set_bytes_value, | |
378 | "bytes", | |
379 | "bytes_value", | |
380 | "bytes") TEST_CONVERT_ITEM(set_enum_value, | |
381 | ENUM_A, | |
382 | "enum_value", | |
383 | "ENUM_A") TEST_CONVERT_ITEM(set_innerenum_value, TestMsg::ENUM_1, | |
384 | "innerenum_value", | |
385 | "ENUM_1") | |
386 | ||
387 | TEST_CONVERT_ITEM(set_required_double_value, | |
388 | 1.0, "required_double_value", 1.0) TEST_CONVERT_ITEM(set_required_float_value, | |
389 | 2.0, | |
390 | "required_float_value", | |
391 | 2.0) | |
392 | TEST_CONVERT_ITEM(set_required_int32_value, | |
393 | 3, "required_int32_value", Json::Int(3)) TEST_CONVERT_ITEM(set_required_int32_value, | |
394 | -3, | |
395 | "required_int32_value", | |
396 | Json::Int( | |
397 | -3)) | |
398 | TEST_CONVERT_ITEM( | |
399 | set_required_int32_value, | |
400 | kint32min, "required_int32_value", Json::Int(kint32min)) | |
401 | TEST_CONVERT_ITEM( | |
402 | set_required_int32_value, | |
403 | kint32max, "required_int32_value", Json::Int(kint32max)) | |
404 | TEST_CONVERT_ITEM( | |
405 | set_required_int64_value, | |
406 | 4, "required_int64_value", | |
407 | "4") TEST_CONVERT_ITEM(set_required_int64_value, -4, | |
408 | "required_int64_value", | |
409 | "-4") | |
410 | TEST_CONVERT_ITEM( | |
411 | set_required_int64_value, | |
412 | kint64min, | |
413 | "required_int64_value", | |
414 | "-9223372036854775808") | |
415 | TEST_CONVERT_ITEM( | |
416 | set_required_int64_value, | |
417 | kint64max, | |
418 | "required_int64_value", | |
419 | "9223372036854775807") | |
420 | TEST_CONVERT_ITEM(set_required_uint32_value, | |
421 | 5, "required_uint32_value", | |
422 | Json:: | |
423 | UInt(5)) TEST_CONVERT_ITEM(set_required_uint32_value, | |
424 | kuint32max, | |
425 | "required_uint32_value", | |
426 | Json:: | |
427 | UInt( | |
428 | kuint32max)) | |
429 | TEST_CONVERT_ITEM( | |
430 | set_required_uint64_value, | |
431 | 6, "required_uint64_value", | |
432 | "6") TEST_CONVERT_ITEM(set_required_uint64_value, | |
433 | kuint64max, | |
434 | "required_" | |
435 | "uint64_" | |
436 | "value", | |
437 | "18446744073" | |
438 | "709551615") | |
439 | TEST_CONVERT_ITEM( | |
440 | set_required_sint32_value, 7, | |
441 | "required_sint32_value", | |
442 | Json::Int(7)) | |
443 | TEST_CONVERT_ITEM(set_required_sint32_value, | |
444 | -7, | |
445 | "required_" | |
446 | "sint32_" | |
447 | "value", | |
448 | Json::Int(-7)) | |
449 | TEST_CONVERT_ITEM(set_required_sint32_value, | |
450 | kint32min, | |
451 | "required" | |
452 | "_sint32_" | |
453 | "value", | |
454 | Json::Int( | |
455 | kint32min)) | |
456 | TEST_CONVERT_ITEM( | |
457 | set_required_sint32_value, | |
458 | kint32max, | |
459 | "required_sint32_" | |
460 | "value", | |
461 | Json::Int( | |
462 | kint32max)) | |
463 | TEST_CONVERT_ITEM( | |
464 | set_required_sint64_value, | |
465 | 8, | |
466 | "required_" | |
467 | "sint64_value", | |
468 | "8") | |
469 | TEST_CONVERT_ITEM( | |
470 | set_required_sint64_value, | |
471 | -8, | |
472 | "required_" | |
473 | "sint64_" | |
474 | "value", | |
475 | "-8") | |
476 | TEST_CONVERT_ITEM( | |
477 | set_required_sint64_value, | |
478 | kint64min, | |
479 | "requir" | |
480 | "ed_" | |
481 | "sint64" | |
482 | "_valu" | |
483 | "e", | |
484 | "-92233" | |
485 | "720368" | |
486 | "547758" | |
487 | "08") TEST_CONVERT_ITEM(set_required_sint64_value, | |
488 | kint64max, | |
489 | "required_sint64_value", | |
490 | "9223372036854775807") TEST_CONVERT_ITEM(set_required_fixed32_value, | |
491 | 9, | |
492 | "required_fixed32_value", Json::UInt(9)) TEST_CONVERT_ITEM(set_required_fixed32_value, kuint32max, | |
493 | "required_fixed32_value", | |
494 | Json::UInt(kuint32max)) TEST_CONVERT_ITEM(set_required_fixed64_value, | |
495 | 10, | |
496 | "required_fixed64_value", | |
497 | "10") TEST_CONVERT_ITEM(set_required_fixed64_value, kuint64max, | |
498 | "required_fixed64_value", | |
499 | "18446744073709551615") TEST_CONVERT_ITEM(set_required_sfixed32_value, | |
500 | 11, | |
501 | "required_sfixed32_value", Json::Int(11)) | |
502 | TEST_CONVERT_ITEM( | |
503 | set_required_sfixed32_value, | |
504 | -11, | |
505 | "re" | |
506 | "qu" | |
507 | "ir" | |
508 | "ed" | |
509 | "_s" | |
510 | "fi" | |
511 | "xe" | |
512 | "d3" | |
513 | "2_" | |
514 | "va" | |
515 | "lu" | |
516 | "e", | |
517 | Json::Int( | |
518 | -11)) | |
519 | TEST_CONVERT_ITEM( | |
520 | set_required_sfixed32_value, | |
521 | kint32min, | |
522 | "required_sfixed32_value", | |
523 | Json::Int( | |
524 | kint32min)) | |
525 | TEST_CONVERT_ITEM(set_required_sfixed32_value, | |
526 | kint32max, | |
527 | "required_sfixed32_value", | |
528 | Json::Int(kint32max)) TEST_CONVERT_ITEM(set_required_sfixed64_value, | |
529 | 12, | |
530 | "required_sfixed64_value", | |
531 | "12") TEST_CONVERT_ITEM(set_required_sfixed64_value, | |
532 | -12, | |
533 | "required_sfixed64_value", | |
534 | "-12") TEST_CONVERT_ITEM(set_required_sfixed64_value, | |
535 | kint64min, | |
536 | "required_sfixed64_value", | |
537 | "-9223372036854775808") TEST_CONVERT_ITEM(set_required_sfixed64_value, | |
538 | kint64max, | |
539 | "required_sfixed64_value", | |
540 | "9223372036854775807") TEST_CONVERT_ITEM(set_required_bool_value, | |
541 | true, | |
542 | "required_bool_value", | |
543 | true) TEST_CONVERT_ITEM(set_required_bool_value, | |
544 | false, | |
545 | "required_bool_value", | |
546 | false) | |
547 | TEST_CONVERT_ITEM( | |
548 | set_required_string_value, | |
549 | "string", | |
550 | "required_string_value", | |
551 | "string") | |
552 | TEST_CONVERT_ITEM( | |
553 | set_required_bytes_value, | |
554 | "bytes", | |
555 | "required_bytes_value", | |
556 | "bytes") | |
557 | TEST_CONVERT_ITEM( | |
558 | set_required_enum_value, | |
559 | ENUM_A, | |
560 | "required_enum_value", | |
561 | "ENUM_A") | |
562 | TEST_CONVERT_ITEM( | |
563 | set_required_innerenum_value, | |
564 | TestMsg:: | |
565 | ENUM_1, | |
566 | "required_innerenum_value", | |
567 | "ENUM_1") | |
266 | TEST_CONVERT_ITEM(set_double_value, 1.0, "double_value", 1.0); | |
267 | TEST_CONVERT_ITEM(set_float_value, 2.0, "float_value", 2.0); | |
268 | TEST_CONVERT_ITEM(set_int32_value, 3, "int32_value", Json::Int(3)); | |
269 | TEST_CONVERT_ITEM(set_int32_value, -3, "int32_value", Json::Int(-3)); | |
270 | TEST_CONVERT_ITEM(set_int32_value, std::numeric_limits<int32>::min(), | |
271 | "int32_value", | |
272 | Json::Int(std::numeric_limits<int32>::min())); | |
273 | TEST_CONVERT_ITEM(set_int32_value, std::numeric_limits<int32>::max(), | |
274 | "int32_value", | |
275 | Json::Int(std::numeric_limits<int32>::max())); | |
276 | TEST_CONVERT_ITEM(set_int64_value, 4, "int64_value", "4"); | |
277 | TEST_CONVERT_ITEM(set_int64_value, -4, "int64_value", "-4"); | |
278 | TEST_CONVERT_ITEM(set_int64_value, std::numeric_limits<int64>::min(), | |
279 | "int64_value", "-9223372036854775808"); | |
280 | TEST_CONVERT_ITEM(set_int64_value, std::numeric_limits<int64>::max(), | |
281 | "int64_value", "9223372036854775807"); | |
282 | TEST_CONVERT_ITEM(set_uint32_value, 5, "uint32_value", Json::UInt(5)); | |
283 | TEST_CONVERT_ITEM(set_uint32_value, std::numeric_limits<uint32>::max(), | |
284 | "uint32_value", | |
285 | Json::UInt(std::numeric_limits<uint32>::max())); | |
286 | TEST_CONVERT_ITEM(set_uint64_value, 6, "uint64_value", "6"); | |
287 | TEST_CONVERT_ITEM(set_uint64_value, std::numeric_limits<uint64>::max(), | |
288 | "uint64_value", "18446744073709551615"); | |
289 | TEST_CONVERT_ITEM(set_sint32_value, 7, "sint32_value", Json::Int(7)); | |
290 | TEST_CONVERT_ITEM(set_sint32_value, -7, "sint32_value", Json::Int(-7)); | |
291 | TEST_CONVERT_ITEM(set_sint32_value, std::numeric_limits<int32>::min(), | |
292 | "sint32_value", | |
293 | Json::Int(std::numeric_limits<int32>::min())); | |
294 | TEST_CONVERT_ITEM(set_sint32_value, std::numeric_limits<int32>::max(), | |
295 | "sint32_value", | |
296 | Json::Int(std::numeric_limits<int32>::max())); | |
297 | TEST_CONVERT_ITEM(set_sint64_value, 8, "sint64_value", "8"); | |
298 | TEST_CONVERT_ITEM(set_sint64_value, -8, "sint64_value", "-8"); | |
299 | TEST_CONVERT_ITEM(set_sint64_value, std::numeric_limits<int64>::min(), | |
300 | "sint64_value", "-9223372036854775808"); | |
301 | TEST_CONVERT_ITEM(set_sint64_value, std::numeric_limits<int64>::max(), | |
302 | "sint64_value", "9223372036854775807"); | |
303 | TEST_CONVERT_ITEM(set_fixed32_value, 9, "fixed32_value", Json::UInt(9)); | |
304 | TEST_CONVERT_ITEM(set_fixed32_value, std::numeric_limits<uint32>::max(), | |
305 | "fixed32_value", | |
306 | Json::UInt(std::numeric_limits<uint32>::max())); | |
307 | TEST_CONVERT_ITEM(set_fixed64_value, 10, "fixed64_value", "10"); | |
308 | TEST_CONVERT_ITEM(set_fixed64_value, std::numeric_limits<uint64>::max(), | |
309 | "fixed64_value", "18446744073709551615"); | |
310 | TEST_CONVERT_ITEM(set_sfixed32_value, 11, "sfixed32_value", Json::Int(11)); | |
311 | TEST_CONVERT_ITEM(set_sfixed32_value, -11, "sfixed32_value", Json::Int(-11)); | |
312 | TEST_CONVERT_ITEM(set_sfixed32_value, std::numeric_limits<int32>::min(), | |
313 | "sfixed32_value", | |
314 | Json::Int(std::numeric_limits<int32>::min())); | |
315 | TEST_CONVERT_ITEM(set_sfixed32_value, std::numeric_limits<int32>::max(), | |
316 | "sfixed32_value", | |
317 | Json::Int(std::numeric_limits<int32>::max())); | |
318 | TEST_CONVERT_ITEM(set_sfixed64_value, 12, "sfixed64_value", "12"); | |
319 | TEST_CONVERT_ITEM(set_sfixed64_value, -12, "sfixed64_value", "-12"); | |
320 | TEST_CONVERT_ITEM(set_sfixed64_value, std::numeric_limits<int64>::min(), | |
321 | "sfixed64_value", "-9223372036854775808"); | |
322 | TEST_CONVERT_ITEM(set_sfixed64_value, std::numeric_limits<int64>::max(), | |
323 | "sfixed64_value", "9223372036854775807"); | |
324 | TEST_CONVERT_ITEM(set_bool_value, true, "bool_value", true); | |
325 | TEST_CONVERT_ITEM(set_bool_value, false, "bool_value", false); | |
326 | TEST_CONVERT_ITEM(set_string_value, "string", "string_value", "string"); | |
327 | TEST_CONVERT_ITEM(set_bytes_value, "bytes", "bytes_value", "bytes"); | |
328 | TEST_CONVERT_ITEM(set_enum_value, ENUM_A, "enum_value", "ENUM_A"); | |
329 | TEST_CONVERT_ITEM(set_innerenum_value, TestMsg::ENUM_1, "innerenum_value", | |
330 | "ENUM_1"); | |
331 | ||
332 | TEST_CONVERT_ITEM(set_required_double_value, 1.0, "required_double_value", | |
333 | 1.0); | |
334 | TEST_CONVERT_ITEM(set_required_float_value, 2.0, "required_float_value", 2.0); | |
335 | TEST_CONVERT_ITEM(set_required_int32_value, 3, "required_int32_value", | |
336 | Json::Int(3)); | |
337 | TEST_CONVERT_ITEM(set_required_int32_value, -3, "required_int32_value", | |
338 | Json::Int(-3)); | |
339 | TEST_CONVERT_ITEM(set_required_int32_value, std::numeric_limits<int32>::min(), | |
340 | "required_int32_value", | |
341 | Json::Int(std::numeric_limits<int32>::min())); | |
342 | TEST_CONVERT_ITEM(set_required_int32_value, std::numeric_limits<int32>::max(), | |
343 | "required_int32_value", | |
344 | Json::Int(std::numeric_limits<int32>::max())); | |
345 | TEST_CONVERT_ITEM(set_required_int64_value, 4, "required_int64_value", "4"); | |
346 | TEST_CONVERT_ITEM(set_required_int64_value, -4, "required_int64_value", "-4"); | |
347 | TEST_CONVERT_ITEM(set_required_int64_value, std::numeric_limits<int64>::min(), | |
348 | "required_int64_value", "-9223372036854775808"); | |
349 | TEST_CONVERT_ITEM(set_required_int64_value, std::numeric_limits<int64>::max(), | |
350 | "required_int64_value", "9223372036854775807"); | |
351 | TEST_CONVERT_ITEM(set_required_uint32_value, 5, "required_uint32_value", | |
352 | Json::UInt(5)); | |
353 | TEST_CONVERT_ITEM(set_required_uint32_value, | |
354 | std::numeric_limits<uint32>::max(), "required_uint32_value", | |
355 | Json::UInt(std::numeric_limits<uint32>::max())); | |
356 | TEST_CONVERT_ITEM(set_required_uint64_value, 6, "required_uint64_value", "6"); | |
357 | TEST_CONVERT_ITEM(set_required_uint64_value, | |
358 | std::numeric_limits<uint64>::max(), "required_uint64_value", | |
359 | "18446744073709551615"); | |
360 | TEST_CONVERT_ITEM(set_required_sint32_value, 7, "required_sint32_value", | |
361 | Json::Int(7)); | |
362 | TEST_CONVERT_ITEM(set_required_sint32_value, -7, "required_sint32_value", | |
363 | Json::Int(-7)); | |
364 | TEST_CONVERT_ITEM(set_required_sint32_value, | |
365 | std::numeric_limits<int32>::min(), "required_sint32_value", | |
366 | Json::Int(std::numeric_limits<int32>::min())); | |
367 | TEST_CONVERT_ITEM(set_required_sint32_value, | |
368 | std::numeric_limits<int32>::max(), "required_sint32_value", | |
369 | Json::Int(std::numeric_limits<int32>::max())); | |
370 | TEST_CONVERT_ITEM(set_required_sint64_value, 8, "required_sint64_value", "8"); | |
371 | TEST_CONVERT_ITEM(set_required_sint64_value, -8, "required_sint64_value", | |
372 | "-8"); | |
373 | TEST_CONVERT_ITEM(set_required_sint64_value, | |
374 | std::numeric_limits<int64>::min(), "required_sint64_value", | |
375 | "-9223372036854775808"); | |
376 | TEST_CONVERT_ITEM(set_required_sint64_value, | |
377 | std::numeric_limits<int64>::max(), "required_sint64_value", | |
378 | "9223372036854775807"); | |
379 | TEST_CONVERT_ITEM(set_required_fixed32_value, 9, "required_fixed32_value", | |
380 | Json::UInt(9)); | |
381 | TEST_CONVERT_ITEM( | |
382 | set_required_fixed32_value, std::numeric_limits<uint32>::max(), | |
383 | "required_fixed32_value", Json::UInt(std::numeric_limits<uint32>::max())); | |
384 | TEST_CONVERT_ITEM(set_required_fixed64_value, 10, "required_fixed64_value", | |
385 | "10"); | |
386 | TEST_CONVERT_ITEM(set_required_fixed64_value, | |
387 | std::numeric_limits<uint64>::max(), | |
388 | "required_fixed64_value", "18446744073709551615"); | |
389 | TEST_CONVERT_ITEM(set_required_sfixed32_value, 11, "required_sfixed32_value", | |
390 | Json::Int(11)); | |
391 | TEST_CONVERT_ITEM(set_required_sfixed32_value, -11, "required_sfixed32_value", | |
392 | Json::Int(-11)); | |
393 | TEST_CONVERT_ITEM( | |
394 | set_required_sfixed32_value, std::numeric_limits<int32>::min(), | |
395 | "required_sfixed32_value", Json::Int(std::numeric_limits<int32>::min())); | |
396 | TEST_CONVERT_ITEM( | |
397 | set_required_sfixed32_value, std::numeric_limits<int32>::max(), | |
398 | "required_sfixed32_value", Json::Int(std::numeric_limits<int32>::max())); | |
399 | TEST_CONVERT_ITEM(set_required_sfixed64_value, 12, "required_sfixed64_value", | |
400 | "12"); | |
401 | TEST_CONVERT_ITEM(set_required_sfixed64_value, -12, "required_sfixed64_value", | |
402 | "-12"); | |
403 | TEST_CONVERT_ITEM(set_required_sfixed64_value, | |
404 | std::numeric_limits<int64>::min(), | |
405 | "required_sfixed64_value", "-9223372036854775808"); | |
406 | TEST_CONVERT_ITEM(set_required_sfixed64_value, | |
407 | std::numeric_limits<int64>::max(), | |
408 | "required_sfixed64_value", "9223372036854775807"); | |
409 | TEST_CONVERT_ITEM(set_required_bool_value, true, "required_bool_value", true); | |
410 | TEST_CONVERT_ITEM(set_required_bool_value, false, "required_bool_value", | |
411 | false); | |
412 | TEST_CONVERT_ITEM(set_required_string_value, "string", | |
413 | "required_string_value", "string"); | |
414 | TEST_CONVERT_ITEM(set_required_bytes_value, "bytes", "required_bytes_value", | |
415 | "bytes"); | |
416 | TEST_CONVERT_ITEM(set_required_enum_value, ENUM_A, "required_enum_value", | |
417 | "ENUM_A"); | |
418 | TEST_CONVERT_ITEM(set_required_innerenum_value, TestMsg::ENUM_1, | |
419 | "required_innerenum_value", "ENUM_1"); | |
568 | 420 | #undef TEST_CONVERT_ITEM |
569 | 421 | } |
570 | 422 | |
571 | TEST(JsonUtilTest, ConvertRepeatedItemTest){ | |
423 | TEST(JsonUtilTest, ConvertRepeatedItemTest) { | |
572 | 424 | #define TEST_CONVERT_REPEATED_ITEM(proto_adder, proto_value1, proto_value2, \ |
573 | 425 | proto_value3, json_name, json_value1, \ |
574 | 426 | json_value2, json_value3) \ |
590 | 442 | FillRequiredFields(&msg); \ |
591 | 443 | EXPECT_PROTO_EQ(msg, new_msg); \ |
592 | 444 | } |
593 | TEST_CONVERT_REPEATED_ITEM(add_repeated_double_value, 1.0, 2.0, 3.0, | |
594 | "repeated_double_value", 1.0, 2.0, 3.0) | |
595 | TEST_CONVERT_REPEATED_ITEM( | |
596 | add_repeated_float_value, 1.0, 2.0, | |
597 | 3.0, "repeated_float_value", 1.0, 2.0, 3.0) TEST_CONVERT_REPEATED_ITEM(add_repeated_int32_value, | |
598 | 1, | |
599 | 2, 3, | |
600 | "repeated_int32_value", Json::Int(1), Json::Int(2), Json::Int(3)) TEST_CONVERT_REPEATED_ITEM(add_repeated_int32_value, kint32min, | |
601 | kint32min, | |
602 | kint32min, | |
603 | "repeated_int32_value", Json::Int(kint32min), Json::Int(kint32min), Json::Int(kint32min)) TEST_CONVERT_REPEATED_ITEM(add_repeated_int32_value, | |
604 | kint32max, | |
605 | kint32max, | |
606 | kint32max, | |
607 | "repeated_int32_value", Json::Int(kint32max), Json::Int(kint32max), | |
608 | Json:: | |
609 | Int(kint32max)) TEST_CONVERT_REPEATED_ITEM(add_repeated_int64_value, | |
610 | 1, | |
611 | 2, | |
612 | 3, | |
613 | "repeated_int64_value", | |
614 | "1", | |
615 | "2", | |
616 | "3") TEST_CONVERT_REPEATED_ITEM(add_repeated_int64_value, | |
617 | kint64min, | |
618 | kint64min, | |
619 | kint64min, | |
620 | "repeated_int64_value", | |
621 | "-9223372036854775808", | |
622 | "-9223372036854775808", | |
623 | "-9223372036854775808") TEST_CONVERT_REPEATED_ITEM(add_repeated_int64_value, | |
624 | kint64max, kint64max, kint64max, | |
625 | "repeated_int64_value", | |
626 | "9223372036854775807", | |
627 | "9223372036854775807", | |
628 | "9223372036854775807") TEST_CONVERT_REPEATED_ITEM(add_repeated_uint32_value, | |
629 | 1, | |
630 | 2, | |
631 | 3, | |
632 | "repeated_uint32_value", Json::UInt(1), | |
633 | Json::UInt(2), Json::UInt(3)) TEST_CONVERT_REPEATED_ITEM(add_repeated_uint32_value, | |
634 | kuint32max, | |
635 | kuint32max, | |
636 | kuint32max, | |
637 | "repeated_uint32_value", | |
638 | Json::UInt(kuint32max), Json::UInt(kuint32max), | |
639 | Json::UInt( | |
640 | kuint32max)) TEST_CONVERT_REPEATED_ITEM(add_repeated_uint64_value, | |
641 | 1, | |
642 | 2, | |
643 | 3, | |
644 | "repeated_uint64_value", | |
645 | "1", | |
646 | "2", | |
647 | "3") TEST_CONVERT_REPEATED_ITEM(add_repeated_uint64_value, | |
648 | kuint64max, | |
649 | kuint64max, | |
650 | kuint64max, | |
651 | "repeated_uint64_value", | |
652 | "18446744073709551615", | |
653 | "18446744073709551615", | |
654 | "18446744073709551615") TEST_CONVERT_REPEATED_ITEM(add_repeated_sint32_value, | |
655 | 1, | |
656 | 2, | |
657 | 3, | |
658 | "repeated_sint32_value", Json::Int(1), Json::Int(2), | |
659 | Json:: | |
660 | Int(3)) | |
661 | TEST_CONVERT_REPEATED_ITEM( | |
662 | add_repeated_sint32_value, | |
663 | kint32min, kint32min, kint32min, "repeated_sint32_value", | |
664 | Json::Int(kint32min), | |
665 | Json::Int(kint32min), | |
666 | Json::Int(kint32min)) | |
667 | TEST_CONVERT_REPEATED_ITEM( | |
668 | add_repeated_sint32_value, | |
669 | kint32max, kint32max, kint32max, | |
670 | "repeated_sint32_value", Json::Int(kint32max), | |
671 | Json::Int(kint32max), Json::Int(kint32max)) | |
672 | TEST_CONVERT_REPEATED_ITEM( | |
673 | add_repeated_sint64_value, | |
674 | 1, 2, 3, "repeated_sint64_value", "1", | |
675 | "2", "3") TEST_CONVERT_REPEATED_ITEM(add_repeated_sint64_value, | |
676 | kint64min, | |
677 | kint64min, | |
678 | kint64min, | |
679 | "repeated_sint64_" | |
680 | "value", | |
681 | "-9223372036854775" | |
682 | "808", | |
683 | "-9223372036854775" | |
684 | "808", | |
685 | "-9223372036854775" | |
686 | "808") | |
687 | TEST_CONVERT_REPEATED_ITEM( | |
688 | add_repeated_sint64_value, | |
689 | kint64max, kint64max, kint64max, | |
690 | "repeated_sint64_value", "9223372036854775807", | |
691 | "9223372036854775807", "9223372036854775807") | |
692 | TEST_CONVERT_REPEATED_ITEM( | |
693 | add_repeated_fixed32_value, | |
694 | 1, 2, 3, "repeated_fixed32_value", | |
695 | Json::UInt(1), Json::UInt(2), | |
696 | Json::UInt(3)) | |
697 | TEST_CONVERT_REPEATED_ITEM( | |
698 | add_repeated_fixed32_value, | |
699 | kuint32max, | |
700 | kuint32max, | |
701 | kuint32max, | |
702 | "repeated_fixed32_value", | |
703 | Json::UInt(kuint32max), | |
704 | Json::UInt(kuint32max), | |
705 | Json::UInt( | |
706 | kuint32max)) TEST_CONVERT_REPEATED_ITEM(add_repeated_fixed64_value, 1, | |
707 | 2, | |
708 | 3, | |
709 | "repeated_fixed64_value", | |
710 | "1", | |
711 | "2", | |
712 | "3") | |
713 | TEST_CONVERT_REPEATED_ITEM( | |
714 | add_repeated_fixed64_value, | |
715 | kuint64max, | |
716 | kuint64max, | |
717 | kuint64max, | |
718 | "repeated_fixed64_value", | |
719 | "18446744073709551615", | |
720 | "18446744073709551615", | |
721 | "18446744073709551615") | |
722 | TEST_CONVERT_REPEATED_ITEM( | |
723 | add_repeated_sfixed32_value, 1, | |
724 | 2, 3, | |
725 | "repeated_sfixed32_value", | |
726 | Json::Int(1), | |
727 | Json::Int(2), | |
728 | Json::Int(3)) | |
729 | TEST_CONVERT_REPEATED_ITEM( | |
730 | add_repeated_sfixed32_value, | |
731 | kint32min, kint32min, kint32min, | |
732 | "repeated_sfixed32_value", | |
733 | Json::Int(kint32min), | |
734 | Json::Int(kint32min), | |
735 | Json::Int(kint32min)) | |
736 | TEST_CONVERT_REPEATED_ITEM( | |
737 | add_repeated_sfixed32_value, | |
738 | kint32max, kint32max, | |
739 | kint32max, | |
740 | "repeated_sfixed32_value", | |
741 | Json::Int(kint32max), | |
742 | Json::Int(kint32max), | |
743 | Json::Int(kint32max)) | |
744 | TEST_CONVERT_REPEATED_ITEM( | |
745 | add_repeated_sfixed64_value, | |
746 | 1, 2, 3, | |
747 | "repeated_sfixed64_" | |
748 | "value", | |
749 | "1", "2", "3") | |
750 | TEST_CONVERT_REPEATED_ITEM( | |
751 | add_repeated_sfixed64_value, | |
752 | kint64min, | |
753 | kint64min, | |
754 | kint64min, | |
755 | "repeated_sfixed64_" | |
756 | "value", | |
757 | "-92233720368547758" | |
758 | "08", | |
759 | "-92233720368547758" | |
760 | "08", | |
761 | "-92233720368547758" | |
762 | "08") | |
763 | TEST_CONVERT_REPEATED_ITEM( | |
764 | add_repeated_sfixed64_value, | |
765 | kint64max, | |
766 | kint64max, | |
767 | kint64max, | |
768 | "repeated_" | |
769 | "sfixed64_" | |
770 | "value", | |
771 | "92233720368547" | |
772 | "75807", | |
773 | "92233720368547" | |
774 | "75807", | |
775 | "92233720368547" | |
776 | "75807") | |
777 | TEST_CONVERT_REPEATED_ITEM( | |
778 | add_repeated_bool_value, | |
779 | true, true, | |
780 | false, | |
781 | "repeated_" | |
782 | "bool_" | |
783 | "value", | |
784 | true, true, | |
785 | false) | |
786 | TEST_CONVERT_REPEATED_ITEM( | |
787 | add_repeated_string_value, | |
788 | "ABC", | |
789 | "DEF", | |
790 | "GHQ", | |
791 | "repeat" | |
792 | "ed_" | |
793 | "string" | |
794 | "_valu" | |
795 | "e", | |
796 | "ABC", | |
797 | "DEF", | |
798 | "GHQ") | |
799 | TEST_CONVERT_REPEATED_ITEM( | |
800 | add_repeated_bytes_value, | |
801 | "AB" | |
802 | "C", | |
803 | "DE" | |
804 | "F", | |
805 | "GH" | |
806 | "Q", | |
807 | "re" | |
808 | "pe" | |
809 | "at" | |
810 | "ed" | |
811 | "_b" | |
812 | "yt" | |
813 | "es" | |
814 | "_v" | |
815 | "al" | |
816 | "u" | |
817 | "e", | |
818 | "AB" | |
819 | "C", | |
820 | "DE" | |
821 | "F", | |
822 | "GH" | |
823 | "Q") | |
824 | TEST_CONVERT_REPEATED_ITEM( | |
825 | add_repeated_enum_value, | |
826 | ENUM_A, | |
827 | ENUM_C, | |
828 | ENUM_B, | |
829 | "repeated_enum_value", | |
830 | "ENUM_A", | |
831 | "ENUM_C", | |
832 | "ENUM_B") | |
833 | TEST_CONVERT_REPEATED_ITEM( | |
834 | add_repeated_innerenum_value, | |
835 | TestMsg:: | |
836 | ENUM_1, | |
837 | TestMsg:: | |
838 | ENUM_2, | |
839 | TestMsg:: | |
840 | ENUM_0, | |
841 | "repeated_innerenum_value", | |
842 | "ENUM_1", | |
843 | "ENUM_2", | |
844 | "ENUM_0") | |
445 | TEST_CONVERT_REPEATED_ITEM(add_repeated_double_value, 1.0, 2.0, 3.0, | |
446 | "repeated_double_value", 1.0, 2.0, 3.0); | |
447 | TEST_CONVERT_REPEATED_ITEM(add_repeated_float_value, 1.0, 2.0, 3.0, | |
448 | "repeated_float_value", 1.0, 2.0, 3.0); | |
449 | TEST_CONVERT_REPEATED_ITEM(add_repeated_int32_value, 1, 2, 3, | |
450 | "repeated_int32_value", Json::Int(1), Json::Int(2), | |
451 | Json::Int(3)); | |
452 | TEST_CONVERT_REPEATED_ITEM( | |
453 | add_repeated_int32_value, std::numeric_limits<int32>::min(), | |
454 | std::numeric_limits<int32>::min(), std::numeric_limits<int32>::min(), | |
455 | "repeated_int32_value", Json::Int(std::numeric_limits<int32>::min()), | |
456 | Json::Int(std::numeric_limits<int32>::min()), | |
457 | Json::Int(std::numeric_limits<int32>::min())); | |
458 | TEST_CONVERT_REPEATED_ITEM( | |
459 | add_repeated_int32_value, std::numeric_limits<int32>::max(), | |
460 | std::numeric_limits<int32>::max(), std::numeric_limits<int32>::max(), | |
461 | "repeated_int32_value", Json::Int(std::numeric_limits<int32>::max()), | |
462 | Json::Int(std::numeric_limits<int32>::max()), | |
463 | Json::Int(std::numeric_limits<int32>::max())); | |
464 | TEST_CONVERT_REPEATED_ITEM(add_repeated_int64_value, 1, 2, 3, | |
465 | "repeated_int64_value", "1", "2", "3"); | |
466 | TEST_CONVERT_REPEATED_ITEM( | |
467 | add_repeated_int64_value, std::numeric_limits<int64>::min(), | |
468 | std::numeric_limits<int64>::min(), std::numeric_limits<int64>::min(), | |
469 | "repeated_int64_value", "-9223372036854775808", "-9223372036854775808", | |
470 | "-9223372036854775808"); | |
471 | TEST_CONVERT_REPEATED_ITEM( | |
472 | add_repeated_int64_value, std::numeric_limits<int64>::max(), | |
473 | std::numeric_limits<int64>::max(), std::numeric_limits<int64>::max(), | |
474 | "repeated_int64_value", "9223372036854775807", "9223372036854775807", | |
475 | "9223372036854775807"); | |
476 | TEST_CONVERT_REPEATED_ITEM(add_repeated_uint32_value, 1, 2, 3, | |
477 | "repeated_uint32_value", Json::UInt(1), | |
478 | Json::UInt(2), Json::UInt(3)); | |
479 | TEST_CONVERT_REPEATED_ITEM( | |
480 | add_repeated_uint32_value, std::numeric_limits<uint32>::max(), | |
481 | std::numeric_limits<uint32>::max(), std::numeric_limits<uint32>::max(), | |
482 | "repeated_uint32_value", Json::UInt(std::numeric_limits<uint32>::max()), | |
483 | Json::UInt(std::numeric_limits<uint32>::max()), | |
484 | Json::UInt(std::numeric_limits<uint32>::max())); | |
485 | TEST_CONVERT_REPEATED_ITEM(add_repeated_uint64_value, 1, 2, 3, | |
486 | "repeated_uint64_value", "1", "2", "3"); | |
487 | TEST_CONVERT_REPEATED_ITEM( | |
488 | add_repeated_uint64_value, std::numeric_limits<uint64>::max(), | |
489 | std::numeric_limits<uint64>::max(), std::numeric_limits<uint64>::max(), | |
490 | "repeated_uint64_value", "18446744073709551615", "18446744073709551615", | |
491 | "18446744073709551615"); | |
492 | TEST_CONVERT_REPEATED_ITEM(add_repeated_sint32_value, 1, 2, 3, | |
493 | "repeated_sint32_value", Json::Int(1), | |
494 | Json::Int(2), Json::Int(3)); | |
495 | TEST_CONVERT_REPEATED_ITEM( | |
496 | add_repeated_sint32_value, std::numeric_limits<int32>::min(), | |
497 | std::numeric_limits<int32>::min(), std::numeric_limits<int32>::min(), | |
498 | "repeated_sint32_value", Json::Int(std::numeric_limits<int32>::min()), | |
499 | Json::Int(std::numeric_limits<int32>::min()), | |
500 | Json::Int(std::numeric_limits<int32>::min())); | |
501 | TEST_CONVERT_REPEATED_ITEM( | |
502 | add_repeated_sint32_value, std::numeric_limits<int32>::max(), | |
503 | std::numeric_limits<int32>::max(), std::numeric_limits<int32>::max(), | |
504 | "repeated_sint32_value", Json::Int(std::numeric_limits<int32>::max()), | |
505 | Json::Int(std::numeric_limits<int32>::max()), | |
506 | Json::Int(std::numeric_limits<int32>::max())); | |
507 | TEST_CONVERT_REPEATED_ITEM(add_repeated_sint64_value, 1, 2, 3, | |
508 | "repeated_sint64_value", "1", "2", "3"); | |
509 | TEST_CONVERT_REPEATED_ITEM( | |
510 | add_repeated_sint64_value, std::numeric_limits<int64>::min(), | |
511 | std::numeric_limits<int64>::min(), std::numeric_limits<int64>::min(), | |
512 | "repeated_sint64_value", "-9223372036854775808", "-9223372036854775808", | |
513 | "-9223372036854775808"); | |
514 | TEST_CONVERT_REPEATED_ITEM( | |
515 | add_repeated_sint64_value, std::numeric_limits<int64>::max(), | |
516 | std::numeric_limits<int64>::max(), std::numeric_limits<int64>::max(), | |
517 | "repeated_sint64_value", "9223372036854775807", "9223372036854775807", | |
518 | "9223372036854775807"); | |
519 | TEST_CONVERT_REPEATED_ITEM(add_repeated_fixed32_value, 1, 2, 3, | |
520 | "repeated_fixed32_value", Json::UInt(1), | |
521 | Json::UInt(2), Json::UInt(3)); | |
522 | TEST_CONVERT_REPEATED_ITEM( | |
523 | add_repeated_fixed32_value, std::numeric_limits<uint32>::max(), | |
524 | std::numeric_limits<uint32>::max(), std::numeric_limits<uint32>::max(), | |
525 | "repeated_fixed32_value", Json::UInt(std::numeric_limits<uint32>::max()), | |
526 | Json::UInt(std::numeric_limits<uint32>::max()), | |
527 | Json::UInt(std::numeric_limits<uint32>::max())); | |
528 | TEST_CONVERT_REPEATED_ITEM(add_repeated_fixed64_value, 1, 2, 3, | |
529 | "repeated_fixed64_value", "1", "2", "3"); | |
530 | TEST_CONVERT_REPEATED_ITEM( | |
531 | add_repeated_fixed64_value, std::numeric_limits<uint64>::max(), | |
532 | std::numeric_limits<uint64>::max(), std::numeric_limits<uint64>::max(), | |
533 | "repeated_fixed64_value", "18446744073709551615", "18446744073709551615", | |
534 | "18446744073709551615"); | |
535 | TEST_CONVERT_REPEATED_ITEM(add_repeated_sfixed32_value, 1, 2, 3, | |
536 | "repeated_sfixed32_value", Json::Int(1), | |
537 | Json::Int(2), Json::Int(3)); | |
538 | TEST_CONVERT_REPEATED_ITEM( | |
539 | add_repeated_sfixed32_value, std::numeric_limits<int32>::min(), | |
540 | std::numeric_limits<int32>::min(), std::numeric_limits<int32>::min(), | |
541 | "repeated_sfixed32_value", Json::Int(std::numeric_limits<int32>::min()), | |
542 | Json::Int(std::numeric_limits<int32>::min()), | |
543 | Json::Int(std::numeric_limits<int32>::min())); | |
544 | TEST_CONVERT_REPEATED_ITEM( | |
545 | add_repeated_sfixed32_value, std::numeric_limits<int32>::max(), | |
546 | std::numeric_limits<int32>::max(), std::numeric_limits<int32>::max(), | |
547 | "repeated_sfixed32_value", Json::Int(std::numeric_limits<int32>::max()), | |
548 | Json::Int(std::numeric_limits<int32>::max()), | |
549 | Json::Int(std::numeric_limits<int32>::max())); | |
550 | TEST_CONVERT_REPEATED_ITEM(add_repeated_sfixed64_value, 1, 2, 3, | |
551 | "repeated_sfixed64_value", "1", "2", "3"); | |
552 | TEST_CONVERT_REPEATED_ITEM( | |
553 | add_repeated_sfixed64_value, std::numeric_limits<int64>::min(), | |
554 | std::numeric_limits<int64>::min(), std::numeric_limits<int64>::min(), | |
555 | "repeated_sfixed64_value", "-9223372036854775808", "-9223372036854775808", | |
556 | "-9223372036854775808"); | |
557 | TEST_CONVERT_REPEATED_ITEM( | |
558 | add_repeated_sfixed64_value, std::numeric_limits<int64>::max(), | |
559 | std::numeric_limits<int64>::max(), std::numeric_limits<int64>::max(), | |
560 | "repeated_sfixed64_value", "9223372036854775807", "9223372036854775807", | |
561 | "9223372036854775807"); | |
562 | TEST_CONVERT_REPEATED_ITEM(add_repeated_bool_value, true, true, false, | |
563 | "repeated_bool_value", true, true, false); | |
564 | TEST_CONVERT_REPEATED_ITEM(add_repeated_string_value, "ABC", "DEF", "GHQ", | |
565 | "repeated_string_value", "ABC", "DEF", "GHQ"); | |
566 | TEST_CONVERT_REPEATED_ITEM(add_repeated_bytes_value, "ABC", "DEF", "GHQ", | |
567 | "repeated_bytes_value", "ABC", "DEF", "GHQ"); | |
568 | TEST_CONVERT_REPEATED_ITEM(add_repeated_enum_value, ENUM_A, ENUM_C, ENUM_B, | |
569 | "repeated_enum_value", "ENUM_A", "ENUM_C", | |
570 | "ENUM_B"); | |
571 | TEST_CONVERT_REPEATED_ITEM(add_repeated_innerenum_value, TestMsg::ENUM_1, | |
572 | TestMsg::ENUM_2, TestMsg::ENUM_0, | |
573 | "repeated_innerenum_value", "ENUM_1", "ENUM_2", | |
574 | "ENUM_0"); | |
845 | 575 | #undef TEST_CONVERT_REPEATED_ITEM |
846 | 576 | } |
847 | 577 | |
954 | 684 | // signed int 32 |
955 | 685 | EXPECT_FALSE(ParseToMessage("{\"int32_value\": -2147483649}", &msg)); |
956 | 686 | EXPECT_TRUE(ParseToMessage("{\"int32_value\": -2147483648}", &msg)); |
957 | EXPECT_EQ(kint32min, msg.int32_value()); | |
687 | EXPECT_EQ(std::numeric_limits<int32>::min(), msg.int32_value()); | |
958 | 688 | EXPECT_TRUE(ParseToMessage("{\"int32_value\": 2147483647}", &msg)); |
959 | EXPECT_EQ(kint32max, msg.int32_value()); | |
689 | EXPECT_EQ(std::numeric_limits<int32>::max(), msg.int32_value()); | |
960 | 690 | EXPECT_FALSE(ParseToMessage("{\"int32_value\": 2147483648}", &msg)); |
961 | 691 | |
962 | 692 | EXPECT_FALSE(ParseToMessage("{\"sint32_value\": -2147483649}", &msg)); |
963 | 693 | EXPECT_TRUE(ParseToMessage("{\"sint32_value\": -2147483648}", &msg)); |
964 | EXPECT_EQ(kint32min, msg.sint32_value()); | |
694 | EXPECT_EQ(std::numeric_limits<int32>::min(), msg.sint32_value()); | |
965 | 695 | EXPECT_TRUE(ParseToMessage("{\"sint32_value\": 2147483647}", &msg)); |
966 | EXPECT_EQ(kint32max, msg.sint32_value()); | |
696 | EXPECT_EQ(std::numeric_limits<int32>::max(), msg.sint32_value()); | |
967 | 697 | EXPECT_FALSE(ParseToMessage("{\"sint32_value\": 2147483648}", &msg)); |
968 | 698 | |
969 | 699 | EXPECT_FALSE(ParseToMessage("{\"sfixed32_value\": -2147483649}", &msg)); |
970 | 700 | EXPECT_TRUE(ParseToMessage("{\"sfixed32_value\": -2147483648}", &msg)); |
971 | EXPECT_EQ(kint32min, msg.sfixed32_value()); | |
701 | EXPECT_EQ(std::numeric_limits<int32>::min(), msg.sfixed32_value()); | |
972 | 702 | EXPECT_TRUE(ParseToMessage("{\"sfixed32_value\": 2147483647}", &msg)); |
973 | EXPECT_EQ(kint32max, msg.sfixed32_value()); | |
703 | EXPECT_EQ(std::numeric_limits<int32>::max(), msg.sfixed32_value()); | |
974 | 704 | EXPECT_FALSE(ParseToMessage("{\"sfixed32_value\": 2147483648}", &msg)); |
975 | 705 | |
976 | 706 | // unsigned int 32 |
978 | 708 | EXPECT_TRUE(ParseToMessage("{\"uint32_value\": 0}", &msg)); |
979 | 709 | EXPECT_EQ(0, msg.uint32_value()); |
980 | 710 | EXPECT_TRUE(ParseToMessage("{\"uint32_value\": 4294967295}", &msg)); |
981 | EXPECT_EQ(kuint32max, msg.uint32_value()); | |
711 | EXPECT_EQ(std::numeric_limits<uint32>::max(), msg.uint32_value()); | |
982 | 712 | EXPECT_FALSE(ParseToMessage("{\"uint32_value\": 4294967296}", &msg)); |
983 | 713 | |
984 | 714 | EXPECT_FALSE(ParseToMessage("{\"fixed32_value\": -1}", &msg)); |
985 | 715 | EXPECT_TRUE(ParseToMessage("{\"fixed32_value\": 0}", &msg)); |
986 | 716 | EXPECT_EQ(0, msg.fixed32_value()); |
987 | 717 | EXPECT_TRUE(ParseToMessage("{\"fixed32_value\": 4294967295}", &msg)); |
988 | EXPECT_EQ(kuint32max, msg.fixed32_value()); | |
718 | EXPECT_EQ(std::numeric_limits<uint32>::max(), msg.fixed32_value()); | |
989 | 719 | EXPECT_FALSE(ParseToMessage("{\"fixed32_value\": 4294967296}", &msg)); |
990 | 720 | |
991 | 721 | // signed int 64 |
993 | 723 | ParseToMessage("{\"int64_value\": \"-9223372036854775809\"}", &msg)); |
994 | 724 | EXPECT_TRUE( |
995 | 725 | ParseToMessage("{\"int64_value\": \"-9223372036854775808\"}", &msg)); |
996 | EXPECT_EQ(kint64min, msg.int64_value()); | |
726 | EXPECT_EQ(std::numeric_limits<int64>::min(), msg.int64_value()); | |
997 | 727 | EXPECT_TRUE( |
998 | 728 | ParseToMessage("{\"int64_value\": \"9223372036854775807\"}", &msg)); |
999 | EXPECT_EQ(kint64max, msg.int64_value()); | |
729 | EXPECT_EQ(std::numeric_limits<int64>::max(), msg.int64_value()); | |
1000 | 730 | EXPECT_FALSE( |
1001 | 731 | ParseToMessage("{\"int64_value\": \"9223372036854775808\"}", &msg)); |
1002 | 732 | |
1004 | 734 | ParseToMessage("{\"sint64_value\": \"-9223372036854775809\"}", &msg)); |
1005 | 735 | EXPECT_TRUE( |
1006 | 736 | ParseToMessage("{\"sint64_value\": \"-9223372036854775808\"}", &msg)); |
1007 | EXPECT_EQ(kint64min, msg.sint64_value()); | |
737 | EXPECT_EQ(std::numeric_limits<int64>::min(), msg.sint64_value()); | |
1008 | 738 | EXPECT_TRUE( |
1009 | 739 | ParseToMessage("{\"sint64_value\": \"9223372036854775807\"}", &msg)); |
1010 | EXPECT_EQ(kint64max, msg.sint64_value()); | |
740 | EXPECT_EQ(std::numeric_limits<int64>::max(), msg.sint64_value()); | |
1011 | 741 | EXPECT_FALSE( |
1012 | 742 | ParseToMessage("{\"sint64_value\": \"9223372036854775808\"}", &msg)); |
1013 | 743 | |
1015 | 745 | ParseToMessage("{\"sfixed64_value\": \"-9223372036854775809\"}", &msg)); |
1016 | 746 | EXPECT_TRUE( |
1017 | 747 | ParseToMessage("{\"sfixed64_value\": \"-9223372036854775808\"}", &msg)); |
1018 | EXPECT_EQ(kint64min, msg.sfixed64_value()); | |
748 | EXPECT_EQ(std::numeric_limits<int64>::min(), msg.sfixed64_value()); | |
1019 | 749 | EXPECT_TRUE( |
1020 | 750 | ParseToMessage("{\"sfixed64_value\": \"9223372036854775807\"}", &msg)); |
1021 | EXPECT_EQ(kint64max, msg.sfixed64_value()); | |
751 | EXPECT_EQ(std::numeric_limits<int64>::max(), msg.sfixed64_value()); | |
1022 | 752 | EXPECT_FALSE( |
1023 | 753 | ParseToMessage("{\"sfixed64_value\": \"9223372036854775808\"}", &msg)); |
1024 | 754 | |
1028 | 758 | EXPECT_EQ(0, msg.uint64_value()); |
1029 | 759 | EXPECT_TRUE( |
1030 | 760 | ParseToMessage("{\"uint64_value\": \"18446744073709551615\"}", &msg)); |
1031 | EXPECT_EQ(kuint64max, msg.uint64_value()); | |
761 | EXPECT_EQ(std::numeric_limits<uint64>::max(), msg.uint64_value()); | |
1032 | 762 | EXPECT_FALSE( |
1033 | 763 | ParseToMessage("{\"uint64_value\": \"18446744073709551616\"}", &msg)); |
1034 | 764 | |
1037 | 767 | EXPECT_EQ(0, msg.fixed64_value()); |
1038 | 768 | EXPECT_TRUE( |
1039 | 769 | ParseToMessage("{\"fixed64_value\": \"18446744073709551615\"}", &msg)); |
1040 | EXPECT_EQ(kuint64max, msg.fixed64_value()); | |
770 | EXPECT_EQ(std::numeric_limits<uint64>::max(), msg.fixed64_value()); | |
1041 | 771 | EXPECT_FALSE( |
1042 | 772 | ParseToMessage("{\"fixed64_value\": \"18446744073709551616\"}", &msg)); |
1043 | 773 | } |
30 | 30 | |
31 | 31 | #include <algorithm> |
32 | 32 | #include <cctype> |
33 | #include <limits> | |
33 | 34 | #include <sstream> |
34 | 35 | #include <string> |
35 | 36 | #include <vector> |
52 | 53 | int slice_end; |
53 | 54 | int slice_step; |
54 | 55 | |
55 | static constexpr int kSliceUndef = kint32max; | |
56 | static constexpr int kSliceUndef = std::numeric_limits<int32>::max(); | |
56 | 57 | |
57 | 58 | static bool IsUndef(int n) { return n == kSliceUndef; } |
58 | 59 |
365 | 365 | py_binary_mozc( |
366 | 366 | name = "gen_zero_query_number_data", |
367 | 367 | srcs = ["gen_zero_query_number_data.py"], |
368 | python_version = "PY2", | |
368 | python_version = "PY3", | |
369 | 369 | deps = [ |
370 | 370 | ":gen_zero_query_number_data_lib", |
371 | 371 | ":gen_zero_query_util", |
384 | 384 | py_binary_mozc( |
385 | 385 | name = "gen_zero_query_data", |
386 | 386 | srcs = ["gen_zero_query_data.py"], |
387 | python_version = "PY2", | |
387 | python_version = "PY3", | |
388 | 388 | deps = [ |
389 | 389 | ":gen_zero_query_data_lib", |
390 | 390 | ":gen_zero_query_util", |
31 | 31 | #include <algorithm> |
32 | 32 | #include <cctype> |
33 | 33 | #include <climits> |
34 | #include <limits> | |
34 | 35 | #include <memory> |
35 | 36 | #include <string> |
36 | 37 | |
1454 | 1455 | target_next_entry = entry->add_next_entries(); |
1455 | 1456 | } else { |
1456 | 1457 | // Otherwise, find the oldest next_entry. |
1457 | uint64 last_access_time = kuint64max; | |
1458 | uint64 last_access_time = std::numeric_limits<uint64>::max(); | |
1458 | 1459 | for (int i = 0; i < entry->next_entries_size(); ++i) { |
1459 | 1460 | // Already has the same id |
1460 | 1461 | if (next_entry.entry_fp() == entry->next_entries(i).entry_fp()) { |
924 | 924 | py_binary_mozc( |
925 | 925 | name = "gen_emoji_rewriter_data", |
926 | 926 | srcs = ["gen_emoji_rewriter_data.py"], |
927 | python_version = "PY2", | |
927 | python_version = "PY3", | |
928 | 928 | deps = [ |
929 | 929 | ":gen_emoji_rewriter_data_lib", |
930 | 930 | "//build_tools:code_generator_util", |
1021 | 1021 | py_binary_mozc( |
1022 | 1022 | name = "gen_single_kanji_rewriter_data", |
1023 | 1023 | srcs = ["gen_single_kanji_rewriter_data.py"], |
1024 | python_version = "PY2", | |
1024 | python_version = "PY3", | |
1025 | 1025 | deps = [ |
1026 | 1026 | ":gen_single_kanji_rewriter_data_lib", |
1027 | 1027 | "//build_tools:code_generator_util", |
1073 | 1073 | py_binary_mozc( |
1074 | 1074 | name = "gen_counter_suffix_array", |
1075 | 1075 | srcs = ["gen_counter_suffix_array.py"], |
1076 | python_version = "PY2", | |
1076 | python_version = "PY3", | |
1077 | 1077 | deps = [ |
1078 | 1078 | ":gen_counter_suffix_array_lib", |
1079 | 1079 | "//build_tools:code_generator_util", |
1385 | 1385 | py_binary_mozc( |
1386 | 1386 | name = "gen_reading_correction_data", |
1387 | 1387 | srcs = ["gen_reading_correction_data.py"], |
1388 | python_version = "PY2", | |
1388 | python_version = "PY3", | |
1389 | 1389 | deps = [ |
1390 | 1390 | ":gen_reading_correction_data_lib", |
1391 | 1391 | "//build_tools:code_generator_util", |
45 | 45 | #include <string> |
46 | 46 | #include <vector> |
47 | 47 | |
48 | #include "base/compiler_specific.h" | |
49 | 48 | #include "base/logging.h" |
50 | 49 | #include "base/number_util.h" |
51 | 50 | #include "base/singleton.h" |
31 | 31 | #include <fstream> |
32 | 32 | #include <string> |
33 | 33 | |
34 | #include "base/compiler_specific.h" | |
35 | 34 | #include "base/file_util.h" |
36 | 35 | #include "base/logging.h" |
37 | 36 | #include "rewriter/calculator/calculator_interface.h" |
572 | 572 | |
573 | 573 | bool CollocationRewriter::IsName(const Segment::Candidate &cand) const { |
574 | 574 | const bool ret = (cand.lid == last_name_id_ || cand.lid == first_name_id_); |
575 | VLOG_IF(3, ret) << cand.value << " is name sagment"; | |
575 | if (ret) { | |
576 | VLOG(3) << cand.value << " is name sagment"; | |
577 | } | |
576 | 578 | return ret; |
577 | 579 | } |
578 | 580 | |
605 | 607 | cur.clear(); |
606 | 608 | CollocationUtil::GetNormalizedScript(curs[j], false, &cur); |
607 | 609 | if (collocation_filter_->Exists(prev, cur)) { |
608 | VLOG_IF(3, i != 0) << prev << cur << " " << seg->candidate(0).value | |
609 | << "->" << seg->candidate(i).value; | |
610 | if (i != 0) { | |
611 | VLOG(3) << prev << cur << " " << seg->candidate(0).value << "->" | |
612 | << seg->candidate(i).value; | |
613 | } | |
610 | 614 | seg->move_candidate(i, 0); |
611 | 615 | seg->mutable_candidate(0)->attributes |= |
612 | 616 | Segment::Candidate::CONTEXT_SENSITIVE; |
58 | 58 | import sys |
59 | 59 | |
60 | 60 | import six |
61 | from six import unichr # pylint: disable=redefined-builtin | |
62 | 61 | |
63 | 62 | from build_tools import code_generator_util |
64 | 63 | from build_tools import serialized_string_array_builder |
89 | 88 | def NormalizeString(string): |
90 | 89 | """Normalize full width ascii characters to half width characters.""" |
91 | 90 | offset = ord(u'A') - ord(u'A') |
92 | normalized = _FULLWIDTH_RE.sub(lambda x: unichr(ord(x.group(0)) - offset), | |
91 | normalized = _FULLWIDTH_RE.sub(lambda x: six.unichr(ord(x.group(0)) - offset), | |
93 | 92 | six.ensure_text(string)) |
94 | 93 | return normalized |
95 | 94 |
423 | 423 | // dangerous. So here checks the validity. For invalid candidate, inner |
424 | 424 | // segment boundary is ignored. |
425 | 425 | const bool is_valid = original.IsValid(); |
426 | VLOG_IF(2, !is_valid) << "Invalid candidate: " << original.DebugString(); | |
426 | if (!is_valid) { | |
427 | VLOG(2) << "Invalid candidate: " << original.DebugString(); | |
428 | } | |
427 | 429 | if (original.inner_segment_boundary.empty() || !is_valid) { |
428 | 430 | if (!manager->ConvertConversionStringWithAlternative( |
429 | 431 | original.value, default_value, alternative_value)) { |
30 | 30 | # Visibility: please choose a more appropriate default for the package, |
31 | 31 | # and update any rules that should be different. |
32 | 32 | |
33 | load( | |
34 | "//:build_defs.bzl", | |
35 | "cc_binary_mozc", | |
36 | ) | |
33 | load("//:build_defs.bzl", "cc_binary_mozc") | |
37 | 34 | |
38 | 35 | package(default_visibility = ["//:__subpackages__"]) |
39 | 36 |
29 | 29 | #include "session/session_usage_observer.h" |
30 | 30 | |
31 | 31 | #include <climits> |
32 | #include <limits> | |
32 | 33 | #include <map> |
33 | 34 | #include <string> |
34 | 35 | #include <vector> |
75 | 76 | uint32 GetDuration(uint64 base_value) { |
76 | 77 | const uint64 result = GetTimeInMilliSecond() - base_value; |
77 | 78 | if (result != static_cast<uint32>(result)) { |
78 | return kuint32max; | |
79 | return std::numeric_limits<uint32>::max(); | |
79 | 80 | } |
80 | 81 | return result; |
81 | 82 | } |
46 | 46 | def py2and3_test(**kwargs): |
47 | 47 | native.py_test(**kwargs) |
48 | 48 | pass |
49 | ||
50 | def pytype_strict_library(**kwargs): | |
51 | native.py_library(**kwargs) | |
52 | pass | |
53 | ||
54 | def pytype_strict_binary(test_lib = True, **kwargs): | |
55 | native.py_binary(**kwargs) | |
56 | pass |
33 | 33 | #include <windows.h> // windows.h must be included before strsafe.h |
34 | 34 | |
35 | 35 | #include <algorithm> |
36 | #include <limits> | |
36 | 37 | |
37 | 38 | #include "google/protobuf/stubs/common.h" |
38 | 39 | #include "base/logging.h" |
54 | 55 | |
55 | 56 | // Since IMM32 uses DWORD rather than size_t for data size in data structures, |
56 | 57 | // relevant data size are stored into DWORD constants here. |
57 | static_assert(sizeof(DWORD) <= kint32max, "Check DWORD size."); | |
58 | static_assert(sizeof(DWORD) <= std::numeric_limits<int32>::max(), | |
59 | "Check DWORD size."); | |
58 | 60 | |
59 | 61 | const DWORD kSizeOfDWORD = static_cast<DWORD>(sizeof(DWORD)); |
60 | 62 | |
61 | static_assert(sizeof(wchar_t) <= kint32max, "Check wchar_t size."); | |
63 | static_assert(sizeof(wchar_t) <= std::numeric_limits<int32>::max(), | |
64 | "Check wchar_t size."); | |
62 | 65 | const DWORD kSizeOfWCHAR = static_cast<DWORD>(sizeof(wchar_t)); |
63 | 66 | |
64 | static_assert(sizeof(CANDIDATEINFO) <= kint32max, "Check CANDIDATEINFO size."); | |
67 | static_assert(sizeof(CANDIDATEINFO) <= std::numeric_limits<int32>::max(), | |
68 | "Check CANDIDATEINFO size."); | |
65 | 69 | const DWORD kSizeOfCANDIDATEINFO = static_cast<DWORD>(sizeof(CANDIDATEINFO)); |
66 | 70 | |
67 | static_assert(sizeof(CANDIDATELIST) <= kint32max, "Check CANDIDATELIST size."); | |
71 | static_assert(sizeof(CANDIDATELIST) <= std::numeric_limits<int32>::max(), | |
72 | "Check CANDIDATELIST size."); | |
68 | 73 | const DWORD kSizeOfCANDIDATELIST = static_cast<DWORD>(sizeof(CANDIDATELIST)); |
69 | 74 | |
70 | 75 | static_assert(sizeof(CANDIDATELIST) > sizeof(DWORD), |
73 | 78 | static_cast<DWORD>(sizeof(CANDIDATELIST) - sizeof(DWORD)); |
74 | 79 | |
75 | 80 | static_assert((static_cast<int64>(sizeof(CANDIDATEINFO)) + |
76 | static_cast<int64>(sizeof(CANDIDATELIST))) < kint32max, | |
81 | static_cast<int64>(sizeof(CANDIDATELIST))) < | |
82 | std::numeric_limits<int32>::max(), | |
77 | 83 | "Check CANDIDATEINFO + CANDIDATELIST size."); |
78 | 84 | const DWORD kSizeOfCANDIDATEINFOAndCANDIDATELIST = |
79 | 85 | static_cast<DWORD>(sizeof(CANDIDATEINFO) + sizeof(CANDIDATELIST)); |
32 | 32 | #include "win32/ime/ime_impl_imm.h" |
33 | 33 | |
34 | 34 | #include <ime.h> |
35 | ||
36 | 35 | #include <strsafe.h> |
36 | ||
37 | #include <limits> | |
37 | 38 | |
38 | 39 | #include "google/protobuf/stubs/common.h" |
39 | 40 | #include "base/const.h" |
182 | 183 | return; |
183 | 184 | } |
184 | 185 | int32 revision = GetContextRevision(); |
185 | if (revision < kint32max) { | |
186 | if (revision < std::numeric_limits<int32>::max()) { | |
186 | 187 | ++revision; |
187 | 188 | } else { |
188 | 189 | revision = 0; |
113 | 113 | r'-dUCRTDir=C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x86', |
114 | 114 | ], |
115 | 115 | }], |
116 | ['MSVS_VERSION=="2017" and use_qt=="YES"', { | |
117 | 'additional_args': [ | |
118 | r'-dUCRTDir=C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x86', | |
119 | ], | |
120 | }], | |
116 | 121 | ], |
117 | 122 | 'omaha_guid': 'DDCCD2A9-025E-4142-BCEB-F467B88CF830', |
118 | 123 | 'omaha_client_key': r'Software\Google\Update\Clients\{<(omaha_guid)}', |
28 | 28 | |
29 | 29 | #include "win32/tip/tip_thread_context.h" |
30 | 30 | |
31 | #include <limits> | |
31 | 32 | #include <memory> |
32 | 33 | |
33 | 34 | #include "base/win_util.h" |
83 | 84 | } |
84 | 85 | |
85 | 86 | void TipThreadContext::IncrementFocusRevision() { |
86 | if (state_->focus_revision < kint32max) { | |
87 | if (state_->focus_revision < std::numeric_limits<int32>::max()) { | |
87 | 88 | state_->focus_revision++; |
88 | 89 | } else { |
89 | 90 | state_->focus_revision = 0; |