Internal change
PiperOrigin-RevId: 521226781
This commit is contained in:
parent
d9f940f8b2
commit
50a49fd16c
|
@ -511,7 +511,7 @@ class TemplateParser::Parser::ParserImpl {
|
|||
DO(ConsumeIdentifier(&field_name));
|
||||
|
||||
if (allow_field_number_) {
|
||||
int32 field_number = std::atoi(field_name.c_str()); // NOLINT
|
||||
int32_t field_number = std::atoi(field_name.c_str()); // NOLINT
|
||||
if (descriptor->IsExtensionNumber(field_number)) {
|
||||
field = reflection->FindKnownExtensionByNumber(field_number);
|
||||
} else if (descriptor->IsReservedNumber(field_number)) {
|
||||
|
@ -765,28 +765,28 @@ class TemplateParser::Parser::ParserImpl {
|
|||
|
||||
switch (field->cpp_type()) {
|
||||
case FieldDescriptor::CPPTYPE_INT32: {
|
||||
int64 value;
|
||||
int64_t value;
|
||||
DO(ConsumeSignedInteger(&value, kint32max));
|
||||
SET_FIELD(Int32, static_cast<int32>(value));
|
||||
SET_FIELD(Int32, static_cast<int32_t>(value));
|
||||
break;
|
||||
}
|
||||
|
||||
case FieldDescriptor::CPPTYPE_UINT32: {
|
||||
uint64 value;
|
||||
uint64_t value;
|
||||
DO(ConsumeUnsignedInteger(&value, kuint32max));
|
||||
SET_FIELD(UInt32, static_cast<uint32>(value));
|
||||
SET_FIELD(UInt32, static_cast<uint32_t>(value));
|
||||
break;
|
||||
}
|
||||
|
||||
case FieldDescriptor::CPPTYPE_INT64: {
|
||||
int64 value;
|
||||
int64_t value;
|
||||
DO(ConsumeSignedInteger(&value, kint64max));
|
||||
SET_FIELD(Int64, value);
|
||||
break;
|
||||
}
|
||||
|
||||
case FieldDescriptor::CPPTYPE_UINT64: {
|
||||
uint64 value;
|
||||
uint64_t value;
|
||||
DO(ConsumeUnsignedInteger(&value, kuint64max));
|
||||
SET_FIELD(UInt64, value);
|
||||
break;
|
||||
|
@ -815,7 +815,7 @@ class TemplateParser::Parser::ParserImpl {
|
|||
|
||||
case FieldDescriptor::CPPTYPE_BOOL: {
|
||||
if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
|
||||
uint64 value;
|
||||
uint64_t value;
|
||||
DO(ConsumeUnsignedInteger(&value, 1));
|
||||
SET_FIELD(Bool, value);
|
||||
} else {
|
||||
|
@ -836,7 +836,7 @@ class TemplateParser::Parser::ParserImpl {
|
|||
|
||||
case FieldDescriptor::CPPTYPE_ENUM: {
|
||||
std::string value;
|
||||
int64 int_value = kint64max;
|
||||
int64_t int_value = kint64max;
|
||||
const EnumDescriptor* enum_type = field->enum_type();
|
||||
const EnumValueDescriptor* enum_value = NULL;
|
||||
|
||||
|
@ -1037,7 +1037,7 @@ class TemplateParser::Parser::ParserImpl {
|
|||
|
||||
// Consumes a uint64 and saves its value in the value parameter.
|
||||
// Returns false if the token is not of type INTEGER.
|
||||
bool ConsumeUnsignedInteger(uint64* value, uint64 max_value) {
|
||||
bool ConsumeUnsignedInteger(uint64_t* value, uint64_t max_value) {
|
||||
if (!LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
|
||||
ReportError("Expected integer, got: " + tokenizer_.current().text);
|
||||
return false;
|
||||
|
@ -1058,7 +1058,7 @@ class TemplateParser::Parser::ParserImpl {
|
|||
// we actually may consume an additional token (for the minus sign) in this
|
||||
// method. Returns false if the token is not an integer
|
||||
// (signed or otherwise).
|
||||
bool ConsumeSignedInteger(int64* value, uint64 max_value) {
|
||||
bool ConsumeSignedInteger(int64_t* value, uint64_t max_value) {
|
||||
bool negative = false;
|
||||
#ifndef PROTO2_OPENSOURCE
|
||||
if (absl::StartsWith(tokenizer_.current().text, "0x")) {
|
||||
|
@ -1075,18 +1075,18 @@ class TemplateParser::Parser::ParserImpl {
|
|||
++max_value;
|
||||
}
|
||||
|
||||
uint64 unsigned_value;
|
||||
uint64_t unsigned_value;
|
||||
|
||||
DO(ConsumeUnsignedInteger(&unsigned_value, max_value));
|
||||
|
||||
if (negative) {
|
||||
if ((static_cast<uint64>(kint64max) + 1) == unsigned_value) {
|
||||
if ((static_cast<uint64_t>(kint64max) + 1) == unsigned_value) {
|
||||
*value = kint64min;
|
||||
} else {
|
||||
*value = -static_cast<int64>(unsigned_value);
|
||||
*value = -static_cast<int64_t>(unsigned_value);
|
||||
}
|
||||
} else {
|
||||
*value = static_cast<int64>(unsigned_value);
|
||||
*value = static_cast<int64_t>(unsigned_value);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1094,7 +1094,7 @@ class TemplateParser::Parser::ParserImpl {
|
|||
|
||||
// Consumes a uint64 and saves its value in the value parameter.
|
||||
// Accepts decimal numbers only, rejects hex or oct numbers.
|
||||
bool ConsumeUnsignedDecimalInteger(uint64* value, uint64 max_value) {
|
||||
bool ConsumeUnsignedDecimalInteger(uint64_t* value, uint64_t max_value) {
|
||||
if (!LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
|
||||
ReportError("Expected integer, got: " + tokenizer_.current().text);
|
||||
return false;
|
||||
|
@ -1131,7 +1131,7 @@ class TemplateParser::Parser::ParserImpl {
|
|||
// Therefore, we must check both cases here.
|
||||
if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
|
||||
// We have found an integer value for the double.
|
||||
uint64 integer_value;
|
||||
uint64_t integer_value;
|
||||
DO(ConsumeUnsignedDecimalInteger(&integer_value, kuint64max));
|
||||
|
||||
*value = static_cast<double>(integer_value);
|
||||
|
|
Loading…
Reference in New Issue
Block a user