@ -5487,12 +5487,6 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
}
}
}
}
namespace {
bool IsAllowedReservedField ( const FieldDescriptorProto & field ) {
return false ;
}
} // namespace
void DescriptorBuilder : : BuildFieldOrExtension ( const FieldDescriptorProto & proto ,
void DescriptorBuilder : : BuildFieldOrExtension ( const FieldDescriptorProto & proto ,
Descriptor * parent ,
Descriptor * parent ,
FieldDescriptor * result ,
FieldDescriptor * result ,
@ -5719,8 +5713,7 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
absl : : Substitute ( " Field numbers cannot be greater than $0. " ,
absl : : Substitute ( " Field numbers cannot be greater than $0. " ,
FieldDescriptor : : kMaxNumber ) ) ;
FieldDescriptor : : kMaxNumber ) ) ;
} else if ( result - > number ( ) > = FieldDescriptor : : kFirstReservedNumber & &
} else if ( result - > number ( ) > = FieldDescriptor : : kFirstReservedNumber & &
result - > number ( ) < = FieldDescriptor : : kLastReservedNumber & &
result - > number ( ) < = FieldDescriptor : : kLastReservedNumber ) {
! IsAllowedReservedField ( proto ) ) {
message_hints_ [ parent ] . RequestHintOnFieldNumbers (
message_hints_ [ parent ] . RequestHintOnFieldNumbers (
proto , DescriptorPool : : ErrorCollector : : NUMBER ) ;
proto , DescriptorPool : : ErrorCollector : : NUMBER ) ;
AddError ( result - > full_name ( ) , proto , DescriptorPool : : ErrorCollector : : NUMBER ,
AddError ( result - > full_name ( ) , proto , DescriptorPool : : ErrorCollector : : NUMBER ,
@ -8303,56 +8296,6 @@ void LazyDescriptor::Once(const ServiceDescriptor* service) {
}
}
}
}
// The format of this file is a sequence of lines like:
// <label>,<type>,<name>,<number>
// Whitespace is ignored.
// Lines that start with `#` are comments and ignored.
std : : vector < AllowedReservedField > ParseAllowedReservedField (
absl : : string_view input ) {
std : : vector < AllowedReservedField > out ;
for ( absl : : string_view line :
absl : : StrSplit ( input , absl : : ByAnyChar ( " \r \n " ) , absl : : SkipEmpty ( ) ) ) {
line = absl : : StripAsciiWhitespace ( line ) ;
// Skip comments
if ( absl : : StartsWith ( line , " # " ) ) continue ;
std : : vector < absl : : string_view > parts = absl : : StrSplit ( line , ' , ' ) ;
for ( auto & p : parts ) p = absl : : StripAsciiWhitespace ( p ) ;
if ( parts . size ( ) ! = 4 ) {
GOOGLE_LOG ( ERROR ) < < " Invalid line in ParseAllowedReservedField < " < < line
< < " > " ;
continue ;
}
AllowedReservedField field ;
if ( parts [ 0 ] = = " optional " ) {
field . label = FieldDescriptor : : LABEL_OPTIONAL ;
} else if ( parts [ 0 ] = = " repeated " ) {
field . label = FieldDescriptor : : LABEL_REPEATED ;
} else {
GOOGLE_LOG ( ERROR ) < < " Invalid label in ParseAllowedReservedField < " < < parts [ 0 ]
< < " > " ;
continue ;
}
field . type_name = std : : string ( parts [ 1 ] ) ;
field . name = std : : string ( parts [ 2 ] ) ;
if ( ! absl : : SimpleAtoi ( parts [ 3 ] , & field . number ) | |
field . number < FieldDescriptor : : kFirstReservedNumber | |
field . number > FieldDescriptor : : kLastReservedNumber ) {
GOOGLE_LOG ( ERROR ) < < " Invalid number in ParseAllowedReservedField < " < < parts [ 3 ]
< < " > " ;
continue ;
}
// Only insert after input has been verified.
out . push_back ( std : : move ( field ) ) ;
}
return out ;
}
namespace cpp {
namespace cpp {
bool HasPreservingUnknownEnumSemantics ( const FieldDescriptor * field ) {
bool HasPreservingUnknownEnumSemantics ( const FieldDescriptor * field ) {
return field - > file ( ) - > syntax ( ) = = FileDescriptor : : SYNTAX_PROTO3 ;
return field - > file ( ) - > syntax ( ) = = FileDescriptor : : SYNTAX_PROTO3 ;