Skip to content

Commit 5d1f40d

Browse files
committed
deperecate legacy typedef for int/uint
1 parent 0776526 commit 5d1f40d

24 files changed

+108
-115
lines changed

src/bpe_model_trainer.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ std::string Trainer::Symbol::ToString() const {
3333
}
3434

3535
Trainer::Symbol *Trainer::GetCharSymbol(char32 c) {
36-
const uint64 freq = port::FindWithDefault(required_chars_, c, 1);
36+
const uint64_t freq = port::FindWithDefault(required_chars_, c, 1);
3737
CHECK_GT(freq, 0);
3838
const auto it = symbols_cache_.find(c);
3939
if (it != symbols_cache_.end()) {
@@ -55,7 +55,7 @@ Trainer::Symbol *Trainer::GetPairSymbol(const Symbol *left,
5555
return nullptr;
5656
}
5757

58-
const uint64 fp = port::FingerprintCat(left->fp, right->fp);
58+
const uint64_t fp = port::FingerprintCat(left->fp, right->fp);
5959
const auto it = symbols_cache_.find(fp);
6060
if (it != symbols_cache_.end()) {
6161
return it->second;
@@ -275,7 +275,7 @@ util::Status Trainer::Train() {
275275
// Add new bigrams which are created after symbol replacement.
276276
// We do not need to scan all characters, but scan the neighbors in
277277
// best_symbol.
278-
for (const uint64 &encoded_pos : best_symbol->positions) {
278+
for (const uint64_t &encoded_pos : best_symbol->positions) {
279279
const Position pos = DecodePos(encoded_pos);
280280

281281
if (symbols_[pos.sid][pos.left] == nullptr) {

src/char_model_trainer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ util::Status Trainer::Train() {
3232
const int vocab_size = trainer_spec_.vocab_size() - meta_pieces_.size();
3333
CHECK_GE_OR_RETURN(vocab_size, 0);
3434

35-
uint64 sum = 0;
35+
uint64_t sum = 0;
3636
for (const auto &it : required_chars_) {
3737
sum += it.second;
3838
}

src/common.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,9 @@
4141
#include <windows.h>
4242
#endif
4343

44-
typedef int8_t int8;
45-
typedef int16_t int16;
46-
typedef int32_t int32;
47-
typedef int64_t int64;
48-
typedef uint8_t uint8;
49-
typedef uint16_t uint16;
5044
typedef uint32_t char32;
51-
typedef uint32_t uint32;
52-
typedef uint64_t uint64;
5345

54-
static constexpr uint32 kUnicodeError = 0xFFFD;
46+
static constexpr uint32_t kUnicodeError = 0xFFFD;
5547

5648
template <typename T, size_t N>
5749
char (&ArraySizeHelper(T (&array)[N]))[N];
@@ -66,7 +58,8 @@ char (&ArraySizeHelper(const T (&array)[N]))[N];
6658
#if defined(_FREEBSD)
6759
#include <sys/endian.h>
6860
#endif
69-
#if !defined(__APPLE__) && !defined(_WIN32) && !defined(_FREEBSD) && !defined(_AIX)
61+
#if !defined(__APPLE__) && !defined(_WIN32) && !defined(_FREEBSD) && \
62+
!defined(_AIX)
7063
#include <endian.h>
7164
#if BYTE_ORDER == __BIG_ENDIAN
7265
#define IS_BIG_ENDIAN
@@ -80,7 +73,7 @@ char (&ArraySizeHelper(const T (&array)[N]))[N];
8073
namespace sentencepiece {
8174
namespace util {
8275
#ifndef OS_WIN
83-
inline uint32 Swap32(uint32 x) { return __builtin_bswap32(x); }
76+
inline uint32_t Swap32(uint32_t x) { return __builtin_bswap32(x); }
8477
#endif // OS_WIN
8578
} // namespace util
8679

src/compile_charsmap_main.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ struct BinaryBlob {
127127
os << kHeader;
128128

129129
os << "#if defined(_WIN32) && !defined(__CYGWIN__)\n";
130-
os << "constexpr unsigned long long int kNormalizationRules_blob_uint64[] = "
130+
os << "constexpr unsigned long long int kNormalizationRules_blob_uint64_t[] = "
131131
"{\n";
132132
std::vector<size_t> offset;
133133
os << ToHexUInt64Array(data, &offset);
@@ -136,7 +136,7 @@ struct BinaryBlob {
136136
os << "const BinaryBlob kNormalizationRules_blob[] = {\n";
137137
for (size_t i = 0; i < data.size(); ++i) {
138138
os << "{ \"" << data[i].first << "\", " << data[i].second.size() << ", ";
139-
os << "reinterpret_cast<const char *>(kNormalizationRules_blob_uint64 + "
139+
os << "reinterpret_cast<const char *>(kNormalizationRules_blob_uint64_t + "
140140
<< offset[i] << ") },\n";
141141
}
142142
os << "};\n";

src/error.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
// We want to define them in other cc file.
2424
#include "third_party/absl/flags/flag.h"
2525
#include "third_party/absl/flags/parse.h"
26-
ABSL_FLAG(int32, minloglevel, 0,
26+
ABSL_FLAG(int32_t, minloglevel, 0,
2727
"Messages logged at a lower level than this don't actually.");
2828
#endif
2929

src/init.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "third_party/protobuf-lite/google/protobuf/message_lite.h"
2727
#endif
2828

29-
ABSL_DECLARE_FLAG(int32, minloglevel);
29+
ABSL_DECLARE_FLAG(int32_t, minloglevel);
3030

3131
namespace sentencepiece {
3232
inline void ParseCommandLineFlags(const char *usage, int *argc, char ***argv,

src/init_test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
#include "common.h"
1818
#include "testharness.h"
1919

20-
ABSL_FLAG(int32, int32_f, 10, "int32_flags");
20+
ABSL_FLAG(int32_t, int32_f, 10, "int32_flags");
2121
ABSL_FLAG(bool, bool_f, false, "bool_flags");
22-
ABSL_FLAG(int64, int64_f, 9223372036854775807LL, "int64_flags");
23-
ABSL_FLAG(uint64, uint64_f, 18446744073709551615ULL, "uint64_flags");
22+
ABSL_FLAG(int64_t, int64_f, 9223372036854775807LL, "int64_flags");
23+
ABSL_FLAG(uint64_t, uint64_f, 18446744073709551615ULL, "uint64_flags");
2424
ABSL_FLAG(double, double_f, 40.0, "double_flags");
2525
ABSL_FLAG(std::string, string_f, "str", "string_flags");
2626

src/normalization_rule.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct BinaryBlob {
1111
};
1212

1313
#if defined(_WIN32) && !defined(__CYGWIN__)
14-
constexpr unsigned long long int kNormalizationRules_blob_uint64[] = {
14+
constexpr unsigned long long int kNormalizationRules_blob_uint64_t[] = {
1515
0x0000FC000002BC00, 0x0003243D00031C3E, 0x0002E4CC00032C3C,
1616
0x8000238200000DB8, 0x000005B80002DCCC, 0x0002E4CC80002376,
1717
0x8000238600001DB8, 0x000248CC00010D91, 0x00014D8C000038CD,
@@ -40603,13 +40603,13 @@ constexpr unsigned long long int kNormalizationRules_blob_uint64[] = {
4060340603

4060440604
const BinaryBlob kNormalizationRules_blob[] = {
4060540605
{"nfkc", 240008,
40606-
reinterpret_cast<const char *>(kNormalizationRules_blob_uint64 + 0)},
40606+
reinterpret_cast<const char *>(kNormalizationRules_blob_uint64_t + 0)},
4060740607
{"nmt_nfkc", 240007,
40608-
reinterpret_cast<const char *>(kNormalizationRules_blob_uint64 + 30001)},
40608+
reinterpret_cast<const char *>(kNormalizationRules_blob_uint64_t + 30001)},
4060940609
{"nfkc_cf", 247028,
40610-
reinterpret_cast<const char *>(kNormalizationRules_blob_uint64 + 60002)},
40610+
reinterpret_cast<const char *>(kNormalizationRules_blob_uint64_t + 60002)},
4061140611
{"nmt_nfkc_cf", 247027,
40612-
reinterpret_cast<const char *>(kNormalizationRules_blob_uint64 + 90881)},
40612+
reinterpret_cast<const char *>(kNormalizationRules_blob_uint64_t + 90881)},
4061340613
};
4061440614
#else
4061540615
constexpr BinaryBlob kNormalizationRules_blob[] = {

src/sentencepiece_processor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ util::Status SentencePieceProcessor::LoadVocabulary(absl::string_view filename,
351351
const std::vector<std::string> v = absl::StrSplit(line, '\t');
352352
CHECK_GE_OR_RETURN(v.size(), 1);
353353
CHECK_OR_RETURN(!v[0].empty());
354-
int32 freq = 1;
354+
int32_t freq = 1;
355355
if (v.size() >= 2) {
356356
CHECK_OR_RETURN(absl::SimpleAtoi(v[1], &freq))
357357
<< "Could not parse the frequency";

src/spec_parser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace sentencepiece {
4747

4848
#define PARSE_INT32(param_name) \
4949
if (name == #param_name) { \
50-
int32 v; \
50+
int32_t v; \
5151
if (!string_util::lexical_cast(value, &v)) \
5252
return util::StatusBuilder(util::StatusCode::kInvalidArgument, GTL_LOC) \
5353
<< "cannot parse \"" << value << "\" as int."; \
@@ -57,7 +57,7 @@ namespace sentencepiece {
5757

5858
#define PARSE_UINT64(param_name) \
5959
if (name == #param_name) { \
60-
uint64 v; \
60+
uint64_t v; \
6161
if (!string_util::lexical_cast(value, &v)) \
6262
return util::StatusBuilder(util::StatusCode::kInvalidArgument, GTL_LOC) \
6363
<< "cannot parse \"" << value << "\" as int."; \

0 commit comments

Comments
 (0)