|
|
@ -995,6 +995,8 @@ UPB_INLINE bool upb_MiniTableEnum_CheckValue(const upb_MiniTableEnum* e, |
|
|
|
#ifndef UPB_MINI_TABLE_FIELD_H_ |
|
|
|
#ifndef UPB_MINI_TABLE_FIELD_H_ |
|
|
|
#define UPB_MINI_TABLE_FIELD_H_ |
|
|
|
#define UPB_MINI_TABLE_FIELD_H_ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <stddef.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef UPB_MINI_TABLE_INTERNAL_FIELD_H_ |
|
|
|
#ifndef UPB_MINI_TABLE_INTERNAL_FIELD_H_ |
|
|
|
#define UPB_MINI_TABLE_INTERNAL_FIELD_H_ |
|
|
|
#define UPB_MINI_TABLE_INTERNAL_FIELD_H_ |
|
|
@ -1091,6 +1093,74 @@ UPB_INLINE void _upb_MiniTableField_CheckIsMap( |
|
|
|
|
|
|
|
|
|
|
|
#endif /* UPB_MINI_TABLE_INTERNAL_FIELD_H_ */ |
|
|
|
#endif /* UPB_MINI_TABLE_INTERNAL_FIELD_H_ */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Must be last.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct upb_MiniTableField upb_MiniTableField; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
|
|
|
extern "C" { |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE upb_FieldType |
|
|
|
|
|
|
|
upb_MiniTableField_Type(const upb_MiniTableField* f) { |
|
|
|
|
|
|
|
if (f->mode & kUpb_LabelFlags_IsAlternate) { |
|
|
|
|
|
|
|
if (f->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Int32) { |
|
|
|
|
|
|
|
return kUpb_FieldType_Enum; |
|
|
|
|
|
|
|
} else if (f->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Bytes) { |
|
|
|
|
|
|
|
return kUpb_FieldType_String; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
UPB_ASSERT(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return (upb_FieldType)f->UPB_PRIVATE(descriptortype); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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* f) { |
|
|
|
|
|
|
|
return f->mode & kUpb_LabelFlags_IsExtension; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsInOneof(const upb_MiniTableField* f) { |
|
|
|
|
|
|
|
return f->presence < 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsRepeatedOrMap( |
|
|
|
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
|
|
|
// This works because upb_FieldMode has no value 3.
|
|
|
|
|
|
|
|
return !(f->mode & kUpb_FieldMode_Scalar); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsSubMessage( |
|
|
|
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
|
|
|
return f->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Message || |
|
|
|
|
|
|
|
f->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Group; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_HasPresence( |
|
|
|
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
|
|
|
if (upb_MiniTableField_IsExtension(f)) { |
|
|
|
|
|
|
|
return !upb_MiniTableField_IsRepeatedOrMap(f); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return f->presence != 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
|
|
|
} /* extern "C" */ |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* UPB_MINI_TABLE_FIELD_H_ */ |
|
|
|
|
|
|
|
|
|
|
|
#ifndef UPB_MINI_TABLE_INTERNAL_MESSAGE_H_ |
|
|
|
#ifndef UPB_MINI_TABLE_INTERNAL_MESSAGE_H_ |
|
|
|
#define UPB_MINI_TABLE_INTERNAL_MESSAGE_H_ |
|
|
|
#define UPB_MINI_TABLE_INTERNAL_MESSAGE_H_ |
|
|
|
|
|
|
|
|
|
|
@ -1186,70 +1256,6 @@ union upb_MiniTableSub { |
|
|
|
extern "C" { |
|
|
|
extern "C" { |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
typedef struct upb_MiniTableField upb_MiniTableField; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE upb_FieldType |
|
|
|
|
|
|
|
upb_MiniTableField_Type(const upb_MiniTableField* field) { |
|
|
|
|
|
|
|
if (field->mode & kUpb_LabelFlags_IsAlternate) { |
|
|
|
|
|
|
|
if (field->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Int32) { |
|
|
|
|
|
|
|
return kUpb_FieldType_Enum; |
|
|
|
|
|
|
|
} else if (field->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Bytes) { |
|
|
|
|
|
|
|
return kUpb_FieldType_String; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
UPB_ASSERT(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return (upb_FieldType)field->UPB_PRIVATE(descriptortype); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_IsRepeatedOrMap( |
|
|
|
|
|
|
|
const upb_MiniTableField* field) { |
|
|
|
|
|
|
|
// 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_MiniTableField_IsRepeatedOrMap(field); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return field->presence != 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
|
|
|
} /* extern "C" */ |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* UPB_MINI_TABLE_FIELD_H_ */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Must be last.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
|
|
|
extern "C" { |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct upb_MiniTable upb_MiniTable; |
|
|
|
typedef struct upb_MiniTable upb_MiniTable; |
|
|
|
|
|
|
|
|
|
|
|
UPB_API const upb_MiniTableField* upb_MiniTable_FindFieldByNumber( |
|
|
|
UPB_API const upb_MiniTableField* upb_MiniTable_FindFieldByNumber( |
|
|
@ -2289,14 +2295,14 @@ UPB_INLINE void _upb_Message_ClearHasbitByField(const upb_Message* msg, |
|
|
|
|
|
|
|
|
|
|
|
// Oneof case access ///////////////////////////////////////////////////////////
|
|
|
|
// Oneof case access ///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
UPB_INLINE size_t _upb_OneofCase_Offset(const upb_MiniTableField* f) { |
|
|
|
UPB_INLINE size_t _upb_MiniTableField_OneofOffset(const upb_MiniTableField* f) { |
|
|
|
UPB_ASSERT(f->presence < 0); |
|
|
|
UPB_ASSERT(f->presence < 0); |
|
|
|
return ~(ptrdiff_t)f->presence; |
|
|
|
return ~(ptrdiff_t)f->presence; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UPB_INLINE uint32_t* _upb_Message_OneofCasePtr(upb_Message* msg, |
|
|
|
UPB_INLINE uint32_t* _upb_Message_OneofCasePtr(upb_Message* msg, |
|
|
|
const upb_MiniTableField* f) { |
|
|
|
const upb_MiniTableField* f) { |
|
|
|
return UPB_PTR_AT(msg, _upb_OneofCase_Offset(f), uint32_t); |
|
|
|
return UPB_PTR_AT(msg, _upb_MiniTableField_OneofOffset(f), uint32_t); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UPB_INLINE uint32_t _upb_Message_GetOneofCase(const upb_Message* msg, |
|
|
|
UPB_INLINE uint32_t _upb_Message_GetOneofCase(const upb_Message* msg, |
|
|
@ -2313,10 +2319,6 @@ UPB_INLINE void _upb_Message_SetOneofCase(upb_Message* msg, |
|
|
|
|
|
|
|
|
|
|
|
// LINT.ThenChange(GoogleInternalName2)
|
|
|
|
// LINT.ThenChange(GoogleInternalName2)
|
|
|
|
|
|
|
|
|
|
|
|
UPB_INLINE bool _upb_MiniTableField_InOneOf(const upb_MiniTableField* field) { |
|
|
|
|
|
|
|
return field->presence < 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_INLINE void* _upb_MiniTableField_GetPtr(upb_Message* msg, |
|
|
|
UPB_INLINE void* _upb_MiniTableField_GetPtr(upb_Message* msg, |
|
|
|
const upb_MiniTableField* field) { |
|
|
|
const upb_MiniTableField* field) { |
|
|
|
return (char*)msg + field->offset; |
|
|
|
return (char*)msg + field->offset; |
|
|
@ -2331,7 +2333,7 @@ UPB_INLINE void _upb_Message_SetPresence(upb_Message* msg, |
|
|
|
const upb_MiniTableField* field) { |
|
|
|
const upb_MiniTableField* field) { |
|
|
|
if (field->presence > 0) { |
|
|
|
if (field->presence > 0) { |
|
|
|
_upb_Message_SetHasbitByField(msg, field); |
|
|
|
_upb_Message_SetHasbitByField(msg, field); |
|
|
|
} else if (_upb_MiniTableField_InOneOf(field)) { |
|
|
|
} else if (upb_MiniTableField_IsInOneof(field)) { |
|
|
|
_upb_Message_SetOneofCase(msg, field); |
|
|
|
_upb_Message_SetOneofCase(msg, field); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2422,7 +2424,7 @@ UPB_INLINE bool _upb_Message_HasNonExtensionField( |
|
|
|
const upb_Message* msg, const upb_MiniTableField* field) { |
|
|
|
const upb_Message* msg, const upb_MiniTableField* field) { |
|
|
|
UPB_ASSERT(upb_MiniTableField_HasPresence(field)); |
|
|
|
UPB_ASSERT(upb_MiniTableField_HasPresence(field)); |
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsExtension(field)); |
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsExtension(field)); |
|
|
|
if (_upb_MiniTableField_InOneOf(field)) { |
|
|
|
if (upb_MiniTableField_IsInOneof(field)) { |
|
|
|
return _upb_Message_GetOneofCase(msg, field) == field->number; |
|
|
|
return _upb_Message_GetOneofCase(msg, field) == field->number; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return _upb_Message_GetHasbitByField(msg, field); |
|
|
|
return _upb_Message_GetHasbitByField(msg, field); |
|
|
@ -2433,7 +2435,7 @@ static UPB_FORCEINLINE void _upb_Message_GetNonExtensionField( |
|
|
|
const upb_Message* msg, const upb_MiniTableField* field, |
|
|
|
const upb_Message* msg, const upb_MiniTableField* field, |
|
|
|
const void* default_val, void* val) { |
|
|
|
const void* default_val, void* val) { |
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsExtension(field)); |
|
|
|
UPB_ASSUME(!upb_MiniTableField_IsExtension(field)); |
|
|
|
if ((_upb_MiniTableField_InOneOf(field) || |
|
|
|
if ((upb_MiniTableField_IsInOneof(field) || |
|
|
|
_upb_MiniTable_ValueIsNonZero(default_val, field)) && |
|
|
|
_upb_MiniTable_ValueIsNonZero(default_val, field)) && |
|
|
|
!_upb_Message_HasNonExtensionField(msg, field)) { |
|
|
|
!_upb_Message_HasNonExtensionField(msg, field)) { |
|
|
|
_upb_MiniTable_CopyFieldData(val, default_val, field); |
|
|
|
_upb_MiniTable_CopyFieldData(val, default_val, field); |
|
|
@ -2519,7 +2521,7 @@ UPB_INLINE void _upb_Message_ClearNonExtensionField( |
|
|
|
upb_Message* msg, const upb_MiniTableField* field) { |
|
|
|
upb_Message* msg, const upb_MiniTableField* field) { |
|
|
|
if (field->presence > 0) { |
|
|
|
if (field->presence > 0) { |
|
|
|
_upb_Message_ClearHasbitByField(msg, field); |
|
|
|
_upb_Message_ClearHasbitByField(msg, field); |
|
|
|
} else if (_upb_MiniTableField_InOneOf(field)) { |
|
|
|
} else if (upb_MiniTableField_IsInOneof(field)) { |
|
|
|
uint32_t* ptr = _upb_Message_OneofCasePtr(msg, field); |
|
|
|
uint32_t* ptr = _upb_Message_OneofCasePtr(msg, field); |
|
|
|
if (*ptr != field->number) return; |
|
|
|
if (*ptr != field->number) return; |
|
|
|
*ptr = 0; |
|
|
|
*ptr = 0; |
|
|
@ -2718,7 +2720,7 @@ UPB_API_INLINE bool upb_Message_HasField(const upb_Message* msg, |
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE uint32_t upb_Message_WhichOneofFieldNumber( |
|
|
|
UPB_API_INLINE uint32_t upb_Message_WhichOneofFieldNumber( |
|
|
|
const upb_Message* message, const upb_MiniTableField* oneof_field) { |
|
|
|
const upb_Message* message, const upb_MiniTableField* oneof_field) { |
|
|
|
UPB_ASSUME(_upb_MiniTableField_InOneOf(oneof_field)); |
|
|
|
UPB_ASSUME(upb_MiniTableField_IsInOneof(oneof_field)); |
|
|
|
return _upb_Message_GetOneofCase(message, oneof_field); |
|
|
|
return _upb_Message_GetOneofCase(message, oneof_field); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|