|
|
|
@ -1086,16 +1086,6 @@ UPB_INLINE void _upb_MiniTableField_CheckIsMap( |
|
|
|
|
UPB_ASSUME(field->presence == 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE bool upb_IsRepeatedOrMap(const struct upb_MiniTableField* field) { |
|
|
|
|
// This works because upb_FieldMode has no value 3.
|
|
|
|
|
return !(field->mode & kUpb_FieldMode_Scalar); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE bool upb_IsSubMessage(const struct upb_MiniTableField* field) { |
|
|
|
|
return field->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Message || |
|
|
|
|
field->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Group; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
} /* extern "C" */ |
|
|
|
|
#endif |
|
|
|
@ -1217,20 +1207,32 @@ UPB_API_INLINE upb_CType upb_MiniTableField_CType(const upb_MiniTableField* f) { |
|
|
|
|
return upb_FieldType_CType(upb_MiniTableField_Type(f)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsClosedEnum( |
|
|
|
|
const upb_MiniTableField* field) { |
|
|
|
|
return field->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Enum; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsExtension( |
|
|
|
|
const upb_MiniTableField* field) { |
|
|
|
|
return field->mode & kUpb_LabelFlags_IsExtension; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsClosedEnum( |
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsRepeatedOrMap( |
|
|
|
|
const upb_MiniTableField* field) { |
|
|
|
|
return field->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Enum; |
|
|
|
|
// This works because upb_FieldMode has no value 3.
|
|
|
|
|
return !(field->mode & kUpb_FieldMode_Scalar); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsSubMessage( |
|
|
|
|
const upb_MiniTableField* field) { |
|
|
|
|
return field->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Message || |
|
|
|
|
field->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Group; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_HasPresence( |
|
|
|
|
const upb_MiniTableField* field) { |
|
|
|
|
if (upb_MiniTableField_IsExtension(field)) { |
|
|
|
|
return !upb_IsRepeatedOrMap(field); |
|
|
|
|
return !upb_MiniTableField_IsRepeatedOrMap(field); |
|
|
|
|
} else { |
|
|
|
|
return field->presence != 0; |
|
|
|
|
} |
|
|
|
@ -2397,7 +2399,7 @@ _upb_MiniTable_ElementSizeLg2(const upb_MiniTableField* field) { |
|
|
|
|
// const upb_MiniTableField* field,
|
|
|
|
|
// bool value, upb_Arena* a) {
|
|
|
|
|
// UPB_ASSUME(field->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Bool);
|
|
|
|
|
// UPB_ASSUME(!upb_IsRepeatedOrMap(field));
|
|
|
|
|
// UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field));
|
|
|
|
|
// UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_1Byte);
|
|
|
|
|
// _upb_Message_SetField(msg, field, &value, a);
|
|
|
|
|
// }
|
|
|
|
@ -2722,7 +2724,7 @@ UPB_API_INLINE bool upb_Message_GetBool(const upb_Message* msg, |
|
|
|
|
bool default_val) { |
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Bool); |
|
|
|
|
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_1Byte); |
|
|
|
|
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field)); |
|
|
|
|
bool ret; |
|
|
|
|
_upb_Message_GetField(msg, field, &default_val, &ret); |
|
|
|
|
return ret; |
|
|
|
@ -2733,7 +2735,7 @@ UPB_API_INLINE bool upb_Message_SetBool(upb_Message* msg, |
|
|
|
|
bool value, upb_Arena* a) { |
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Bool); |
|
|
|
|
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_1Byte); |
|
|
|
|
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field)); |
|
|
|
|
return _upb_Message_SetField(msg, field, &value, a); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2743,7 +2745,7 @@ UPB_API_INLINE int32_t upb_Message_GetInt32(const upb_Message* msg, |
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Int32 || |
|
|
|
|
upb_MiniTableField_CType(field) == kUpb_CType_Enum); |
|
|
|
|
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_4Byte); |
|
|
|
|
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field)); |
|
|
|
|
int32_t ret; |
|
|
|
|
_upb_Message_GetField(msg, field, &default_val, &ret); |
|
|
|
|
return ret; |
|
|
|
@ -2755,7 +2757,7 @@ UPB_API_INLINE bool upb_Message_SetInt32(upb_Message* msg, |
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Int32 || |
|
|
|
|
upb_MiniTableField_CType(field) == kUpb_CType_Enum); |
|
|
|
|
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_4Byte); |
|
|
|
|
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field)); |
|
|
|
|
return _upb_Message_SetField(msg, field, &value, a); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2764,7 +2766,7 @@ UPB_API_INLINE uint32_t upb_Message_GetUInt32(const upb_Message* msg, |
|
|
|
|
uint32_t default_val) { |
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_UInt32); |
|
|
|
|
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_4Byte); |
|
|
|
|
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field)); |
|
|
|
|
uint32_t ret; |
|
|
|
|
_upb_Message_GetField(msg, field, &default_val, &ret); |
|
|
|
|
return ret; |
|
|
|
@ -2775,7 +2777,7 @@ UPB_API_INLINE bool upb_Message_SetUInt32(upb_Message* msg, |
|
|
|
|
uint32_t value, upb_Arena* a) { |
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_UInt32); |
|
|
|
|
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_4Byte); |
|
|
|
|
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field)); |
|
|
|
|
return _upb_Message_SetField(msg, field, &value, a); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2784,7 +2786,7 @@ UPB_API_INLINE void upb_Message_SetClosedEnum( |
|
|
|
|
const upb_MiniTableField* field, int32_t value) { |
|
|
|
|
UPB_ASSERT(upb_MiniTableField_IsClosedEnum(field)); |
|
|
|
|
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_4Byte); |
|
|
|
|
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSERT(upb_MiniTableEnum_CheckValue( |
|
|
|
|
upb_MiniTable_GetSubEnumTable(msg_mini_table, field), value)); |
|
|
|
|
_upb_Message_SetNonExtensionField(msg, field, &value); |
|
|
|
@ -2795,7 +2797,7 @@ UPB_API_INLINE int64_t upb_Message_GetInt64(const upb_Message* msg, |
|
|
|
|
uint64_t default_val) { |
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Int64); |
|
|
|
|
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_8Byte); |
|
|
|
|
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field)); |
|
|
|
|
int64_t ret; |
|
|
|
|
_upb_Message_GetField(msg, field, &default_val, &ret); |
|
|
|
|
return ret; |
|
|
|
@ -2806,7 +2808,7 @@ UPB_API_INLINE bool upb_Message_SetInt64(upb_Message* msg, |
|
|
|
|
int64_t value, upb_Arena* a) { |
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Int64); |
|
|
|
|
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_8Byte); |
|
|
|
|
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field)); |
|
|
|
|
return _upb_Message_SetField(msg, field, &value, a); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2815,7 +2817,7 @@ UPB_API_INLINE uint64_t upb_Message_GetUInt64(const upb_Message* msg, |
|
|
|
|
uint64_t default_val) { |
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_UInt64); |
|
|
|
|
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_8Byte); |
|
|
|
|
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field)); |
|
|
|
|
uint64_t ret; |
|
|
|
|
_upb_Message_GetField(msg, field, &default_val, &ret); |
|
|
|
|
return ret; |
|
|
|
@ -2826,7 +2828,7 @@ UPB_API_INLINE bool upb_Message_SetUInt64(upb_Message* msg, |
|
|
|
|
uint64_t value, upb_Arena* a) { |
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_UInt64); |
|
|
|
|
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_8Byte); |
|
|
|
|
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field)); |
|
|
|
|
return _upb_Message_SetField(msg, field, &value, a); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2835,7 +2837,7 @@ UPB_API_INLINE float upb_Message_GetFloat(const upb_Message* msg, |
|
|
|
|
float default_val) { |
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Float); |
|
|
|
|
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_4Byte); |
|
|
|
|
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field)); |
|
|
|
|
float ret; |
|
|
|
|
_upb_Message_GetField(msg, field, &default_val, &ret); |
|
|
|
|
return ret; |
|
|
|
@ -2846,7 +2848,7 @@ UPB_API_INLINE bool upb_Message_SetFloat(upb_Message* msg, |
|
|
|
|
float value, upb_Arena* a) { |
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Float); |
|
|
|
|
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_4Byte); |
|
|
|
|
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field)); |
|
|
|
|
return _upb_Message_SetField(msg, field, &value, a); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2855,7 +2857,7 @@ UPB_API_INLINE double upb_Message_GetDouble(const upb_Message* msg, |
|
|
|
|
double default_val) { |
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Double); |
|
|
|
|
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_8Byte); |
|
|
|
|
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field)); |
|
|
|
|
double ret; |
|
|
|
|
_upb_Message_GetField(msg, field, &default_val, &ret); |
|
|
|
|
return ret; |
|
|
|
@ -2866,7 +2868,7 @@ UPB_API_INLINE bool upb_Message_SetDouble(upb_Message* msg, |
|
|
|
|
double value, upb_Arena* a) { |
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Double); |
|
|
|
|
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_8Byte); |
|
|
|
|
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field)); |
|
|
|
|
return _upb_Message_SetField(msg, field, &value, a); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2876,7 +2878,7 @@ upb_Message_GetString(const upb_Message* msg, const upb_MiniTableField* field, |
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_String || |
|
|
|
|
upb_MiniTableField_CType(field) == kUpb_CType_Bytes); |
|
|
|
|
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_StringView); |
|
|
|
|
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field)); |
|
|
|
|
upb_StringView ret; |
|
|
|
|
_upb_Message_GetField(msg, field, &def_val, &ret); |
|
|
|
|
return ret; |
|
|
|
@ -2888,7 +2890,7 @@ UPB_API_INLINE bool upb_Message_SetString(upb_Message* msg, |
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_String || |
|
|
|
|
upb_MiniTableField_CType(field) == kUpb_CType_Bytes); |
|
|
|
|
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_StringView); |
|
|
|
|
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field)); |
|
|
|
|
return _upb_Message_SetField(msg, field, &value, a); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2898,7 +2900,7 @@ UPB_API_INLINE upb_TaggedMessagePtr upb_Message_GetTaggedMessagePtr( |
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Message); |
|
|
|
|
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == |
|
|
|
|
UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte)); |
|
|
|
|
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field)); |
|
|
|
|
upb_TaggedMessagePtr tagged; |
|
|
|
|
_upb_Message_GetNonExtensionField(msg, field, &default_val, &tagged); |
|
|
|
|
return tagged; |
|
|
|
@ -2921,7 +2923,7 @@ UPB_API_INLINE void _upb_Message_SetTaggedMessagePtr( |
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Message); |
|
|
|
|
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == |
|
|
|
|
UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte)); |
|
|
|
|
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsRepeatedOrMap(field)); |
|
|
|
|
UPB_ASSERT(mini_table->subs[field->UPB_PRIVATE(submsg_index)].submsg); |
|
|
|
|
_upb_Message_SetNonExtensionField(msg, field, &sub_message); |
|
|
|
|
} |
|
|
|
|