@ -592,16 +592,14 @@ static void _upb_FieldDef_Create(upb_DefBuilder* ctx, const char* prefix,
f - > full_name , ( int ) f - > type_ ) ;
f - > full_name , ( int ) f - > type_ ) ;
}
}
}
}
} else if ( has_type_name ) {
f - > type_ =
UPB_FIELD_TYPE_UNSPECIFIED ; // We'll assign this in resolve_fielddef()
}
}
if ( ! has_type & & has_type_name ) {
if ( f - > type_ < kUpb_FieldType_Double | | f - > type_ > kUpb_FieldType_SInt64 ) {
f - > type_ =
_upb_DefBuilder_Errf ( ctx , " invalid type for field %s (%d) " , f - > full_name ,
UPB_FIELD_TYPE_UNSPECIFIED ; // We'll assign this in resolve_subdef()
f - > type_ ) ;
} else {
if ( f - > type_ < kUpb_FieldType_Double | | f - > type_ > kUpb_FieldType_SInt64 ) {
_upb_DefBuilder_Errf ( ctx , " invalid type for field %s (%d) " , f - > full_name ,
f - > type_ ) ;
}
}
}
if ( f - > label_ < kUpb_Label_Optional | | f - > label_ > kUpb_Label_Repeated ) {
if ( f - > label_ < kUpb_Label_Optional | | f - > label_ > kUpb_Label_Repeated ) {
@ -650,15 +648,14 @@ static void _upb_FieldDef_Create(upb_DefBuilder* ctx, const char* prefix,
f - > is_packed = UPB_DESC ( FieldOptions_packed ) ( f - > opts ) ;
f - > is_packed = UPB_DESC ( FieldOptions_packed ) ( f - > opts ) ;
} else {
} else {
// Repeated fields default to packed for proto3 only.
// Repeated fields default to packed for proto3 only.
f - > is_packed = has_type & & upb_FieldDef_IsPrimitive ( f ) & &
f - > is_packed = upb_FieldDef_IsPrimitive ( f ) & &
f - > label_ = = kUpb_Label_Repeated & &
f - > label_ = = kUpb_Label_Repeated & &
upb_FileDef_Syntax ( f - > file ) = = kUpb_Syntax_Proto3 ;
upb_FileDef_Syntax ( f - > file ) = = kUpb_Syntax_Proto3 ;
}
}
f - > has_presence =
f - > has_presence =
( ! upb_FieldDef_IsRepeated ( f ) ) & &
( ! upb_FieldDef_IsRepeated ( f ) ) & &
( f - > type_ = = kUpb_FieldType_Message | | f - > type_ = = kUpb_FieldType_Group | |
( upb_FieldDef_IsSubMessage ( f ) | | upb_FieldDef_ContainingOneof ( f ) | |
upb_FieldDef_ContainingOneof ( f ) | |
( upb_FileDef_Syntax ( f - > file ) = = kUpb_Syntax_Proto2 ) ) ;
( upb_FileDef_Syntax ( f - > file ) = = kUpb_Syntax_Proto2 ) ) ;
}
}
@ -766,22 +763,16 @@ static void resolve_subdef(upb_DefBuilder* ctx, const char* prefix,
case UPB_DEFTYPE_ENUM :
case UPB_DEFTYPE_ENUM :
f - > sub . enumdef = def ;
f - > sub . enumdef = def ;
f - > type_ = kUpb_FieldType_Enum ;
f - > type_ = kUpb_FieldType_Enum ;
if ( ! UPB_DESC ( FieldOptions_has_packed ) ( f - > opts ) ) {
f - > is_packed = f - > label_ = = kUpb_Label_Repeated & &
upb_FileDef_Syntax ( f - > file ) = = kUpb_Syntax_Proto3 ;
}
break ;
break ;
case UPB_DEFTYPE_MSG :
case UPB_DEFTYPE_MSG :
f - > sub . msgdef = def ;
f - > sub . msgdef = def ;
f - > type_ = kUpb_FieldType_Message ; // It appears there is no way of
f - > type_ = kUpb_FieldType_Message ; // It appears there is no way of
// this being a group.
// this being a group.
f - > has_presence = ! upb_FieldDef_IsRepeated ( f ) ;
break ;
break ;
default :
default :
_upb_DefBuilder_Errf ( ctx , " Couldn't resolve type name for field %s " ,
_upb_DefBuilder_Errf ( ctx , " Couldn't resolve type name for field %s " ,
f - > full_name ) ;
f - > full_name ) ;
}
}
break ;
}
}
case kUpb_FieldType_Message :
case kUpb_FieldType_Message :
case kUpb_FieldType_Group :
case kUpb_FieldType_Group :