|
|
|
@ -1245,6 +1245,12 @@ UPB_PRIVATE(_upb_MiniTableField_Number)(const struct upb_MiniTableField* f) { |
|
|
|
|
return f->UPB_ONLYBITS(number); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE size_t |
|
|
|
|
_upb_MiniTableField_OneofOffset(const struct upb_MiniTableField* f) { |
|
|
|
|
UPB_ASSERT(UPB_PRIVATE(_upb_MiniTableField_IsInOneof)(f)); |
|
|
|
|
return ~(ptrdiff_t)f->presence; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE void UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)( |
|
|
|
|
const struct upb_MiniTableField* f) { |
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == |
|
|
|
@ -2459,24 +2465,20 @@ UPB_INLINE void UPB_PRIVATE(_upb_Message_ClearHasbit)( |
|
|
|
|
|
|
|
|
|
// Oneof case access ///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
UPB_INLINE size_t _upb_MiniTableField_OneofOffset(const upb_MiniTableField* f) { |
|
|
|
|
UPB_ASSERT(f->presence < 0); |
|
|
|
|
return ~(ptrdiff_t)f->presence; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE uint32_t* _upb_Message_OneofCasePtr(upb_Message* msg, |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
UPB_INLINE uint32_t* UPB_PRIVATE(_upb_Message_OneofCasePtr)( |
|
|
|
|
upb_Message* msg, const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PTR_AT(msg, _upb_MiniTableField_OneofOffset(f), uint32_t); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE uint32_t _upb_Message_GetOneofCase(const upb_Message* msg, |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
return *_upb_Message_OneofCasePtr((upb_Message*)msg, f); |
|
|
|
|
UPB_INLINE uint32_t UPB_PRIVATE(_upb_Message_GetOneofCase)( |
|
|
|
|
const upb_Message* msg, const upb_MiniTableField* f) { |
|
|
|
|
return *UPB_PRIVATE(_upb_Message_OneofCasePtr)((upb_Message*)msg, f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE void _upb_Message_SetOneofCase(upb_Message* msg, |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
*_upb_Message_OneofCasePtr(msg, f) = upb_MiniTableField_Number(f); |
|
|
|
|
UPB_INLINE void UPB_PRIVATE(_upb_Message_SetOneofCase)( |
|
|
|
|
upb_Message* msg, const upb_MiniTableField* f) { |
|
|
|
|
*UPB_PRIVATE(_upb_Message_OneofCasePtr)(msg, f) = |
|
|
|
|
upb_MiniTableField_Number(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: implement _upb_Message_ClearOneofCase()
|
|
|
|
@ -2493,12 +2495,12 @@ UPB_INLINE const void* _upb_MiniTableField_GetConstPtr( |
|
|
|
|
return (char*)msg + field->offset; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE void _upb_Message_SetPresence(upb_Message* msg, |
|
|
|
|
const upb_MiniTableField* field) { |
|
|
|
|
UPB_INLINE void UPB_PRIVATE(_upb_Message_SetPresence)( |
|
|
|
|
upb_Message* msg, const upb_MiniTableField* field) { |
|
|
|
|
if (field->presence > 0) { |
|
|
|
|
UPB_PRIVATE(_upb_Message_SetHasbit)(msg, field); |
|
|
|
|
} else if (upb_MiniTableField_IsInOneof(field)) { |
|
|
|
|
_upb_Message_SetOneofCase(msg, field); |
|
|
|
|
UPB_PRIVATE(_upb_Message_SetOneofCase)(msg, field); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2584,7 +2586,7 @@ UPB_INLINE bool _upb_Message_HasNonExtensionField( |
|
|
|
|
UPB_ASSERT(upb_MiniTableField_HasPresence(field)); |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsExtension(field)); |
|
|
|
|
if (upb_MiniTableField_IsInOneof(field)) { |
|
|
|
|
return _upb_Message_GetOneofCase(msg, field) == |
|
|
|
|
return UPB_PRIVATE(_upb_Message_GetOneofCase)(msg, field) == |
|
|
|
|
upb_MiniTableField_Number(field); |
|
|
|
|
} else { |
|
|
|
|
return UPB_PRIVATE(_upb_Message_GetHasbit)(msg, field); |
|
|
|
@ -2647,7 +2649,7 @@ UPB_INLINE upb_MutableMessageValue _upb_Message_GetMutableField( |
|
|
|
|
UPB_INLINE void _upb_Message_SetNonExtensionField( |
|
|
|
|
upb_Message* msg, const upb_MiniTableField* field, const void* val) { |
|
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsExtension(field)); |
|
|
|
|
_upb_Message_SetPresence(msg, field); |
|
|
|
|
UPB_PRIVATE(_upb_Message_SetPresence)(msg, field); |
|
|
|
|
_upb_MiniTable_CopyFieldData(_upb_MiniTableField_GetPtr(msg, field), val, |
|
|
|
|
field); |
|
|
|
|
} |
|
|
|
@ -2682,7 +2684,7 @@ UPB_INLINE void _upb_Message_ClearNonExtensionField( |
|
|
|
|
if (field->presence > 0) { |
|
|
|
|
UPB_PRIVATE(_upb_Message_ClearHasbit)(msg, field); |
|
|
|
|
} else if (upb_MiniTableField_IsInOneof(field)) { |
|
|
|
|
uint32_t* ptr = _upb_Message_OneofCasePtr(msg, field); |
|
|
|
|
uint32_t* ptr = UPB_PRIVATE(_upb_Message_OneofCasePtr)(msg, field); |
|
|
|
|
if (*ptr != upb_MiniTableField_Number(field)) return; |
|
|
|
|
*ptr = 0; |
|
|
|
|
} |
|
|
|
@ -2929,7 +2931,7 @@ UPB_API_INLINE bool upb_Message_HasField(const upb_Message* msg, |
|
|
|
|
UPB_API_INLINE uint32_t upb_Message_WhichOneofFieldNumber( |
|
|
|
|
const upb_Message* message, const upb_MiniTableField* oneof_field) { |
|
|
|
|
UPB_ASSUME(upb_MiniTableField_IsInOneof(oneof_field)); |
|
|
|
|
return _upb_Message_GetOneofCase(message, oneof_field); |
|
|
|
|
return UPB_PRIVATE(_upb_Message_GetOneofCase)(message, oneof_field); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// NOTE: The default_val is only used for fields that support presence.
|
|
|
|
@ -3232,7 +3234,7 @@ UPB_API_INLINE upb_Message* upb_Message_GetOrCreateMutableMessage( |
|
|
|
|
UPB_ASSERT(sub_mini_table); |
|
|
|
|
sub_message = _upb_Message_New(sub_mini_table, arena); |
|
|
|
|
*UPB_PTR_AT(msg, field->offset, upb_Message*) = sub_message; |
|
|
|
|
_upb_Message_SetPresence(msg, field); |
|
|
|
|
UPB_PRIVATE(_upb_Message_SetPresence)(msg, field); |
|
|
|
|
} |
|
|
|
|
return sub_message; |
|
|
|
|
} |
|
|
|
|