|
|
|
@ -13,7 +13,6 @@ |
|
|
|
|
|
|
|
|
|
#include "upb/base/descriptor_constants.h" |
|
|
|
|
#include "upb/mini_table/internal/size_log2.h" |
|
|
|
|
#include "upb/mini_table/types.h" |
|
|
|
|
|
|
|
|
|
// Must be last.
|
|
|
|
|
#include "upb/port/def.inc" |
|
|
|
@ -76,47 +75,47 @@ extern "C" { |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
UPB_INLINE upb_FieldMode |
|
|
|
|
UPB_PRIVATE(_upb_MiniTableField_Mode)(const upb_MiniTableField* f) { |
|
|
|
|
UPB_PRIVATE(_upb_MiniTableField_Mode)(const struct upb_MiniTableField* f) { |
|
|
|
|
return (upb_FieldMode)(f->UPB_ONLYBITS(mode) & kUpb_FieldMode_Mask); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE upb_FieldRep |
|
|
|
|
UPB_PRIVATE(_upb_MiniTableField_GetRep)(const upb_MiniTableField* f) { |
|
|
|
|
UPB_PRIVATE(_upb_MiniTableField_GetRep)(const struct upb_MiniTableField* f) { |
|
|
|
|
return (upb_FieldRep)(f->UPB_ONLYBITS(mode) >> kUpb_FieldRep_Shift); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_IsArray)( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
const struct upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_Mode)(f) == kUpb_FieldMode_Array; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_IsMap)( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
const struct upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_Mode)(f) == kUpb_FieldMode_Map; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_IsScalar)( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
const struct upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_Mode)(f) == kUpb_FieldMode_Scalar; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_IsAlternate)( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
const struct upb_MiniTableField* f) { |
|
|
|
|
return (f->UPB_ONLYBITS(mode) & kUpb_LabelFlags_IsAlternate) != 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_IsExtension)( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
const struct upb_MiniTableField* f) { |
|
|
|
|
return (f->UPB_ONLYBITS(mode) & kUpb_LabelFlags_IsExtension) != 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_IsPacked)( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
const struct upb_MiniTableField* f) { |
|
|
|
|
return (f->UPB_ONLYBITS(mode) & kUpb_LabelFlags_IsPacked) != 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE upb_FieldType |
|
|
|
|
UPB_PRIVATE(_upb_MiniTableField_Type)(const upb_MiniTableField* f) { |
|
|
|
|
UPB_PRIVATE(_upb_MiniTableField_Type)(const struct upb_MiniTableField* f) { |
|
|
|
|
const upb_FieldType type = (upb_FieldType)f->UPB_PRIVATE(descriptortype); |
|
|
|
|
if (UPB_PRIVATE(_upb_MiniTableField_IsAlternate)(f)) { |
|
|
|
|
if (type == kUpb_FieldType_Int32) return kUpb_FieldType_Enum; |
|
|
|
@ -127,7 +126,7 @@ UPB_PRIVATE(_upb_MiniTableField_Type)(const upb_MiniTableField* f) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE upb_CType |
|
|
|
|
UPB_PRIVATE(_upb_MiniTableField_CType)(const upb_MiniTableField* f) { |
|
|
|
|
UPB_PRIVATE(_upb_MiniTableField_CType)(const struct upb_MiniTableField* f) { |
|
|
|
|
return upb_FieldType_CType(UPB_PRIVATE(_upb_MiniTableField_Type)(f)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -146,23 +145,23 @@ UPB_INLINE size_t UPB_PRIVATE(_upb_MiniTableField_HasbitOffset)( |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_IsClosedEnum)( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
const struct upb_MiniTableField* f) { |
|
|
|
|
return f->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Enum; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_IsInOneof)( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
const struct upb_MiniTableField* f) { |
|
|
|
|
return f->presence < 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_IsSubMessage)( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
const struct upb_MiniTableField* f) { |
|
|
|
|
return f->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Message || |
|
|
|
|
f->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Group; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_HasPresence)( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
const struct upb_MiniTableField* f) { |
|
|
|
|
if (UPB_PRIVATE(_upb_MiniTableField_IsExtension)(f)) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_IsScalar)(f); |
|
|
|
|
} else { |
|
|
|
@ -187,7 +186,7 @@ UPB_INLINE size_t UPB_PRIVATE(_upb_MiniTableField_OneofOffset)( |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE void UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
const struct upb_MiniTableField* f) { |
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == |
|
|
|
|
kUpb_FieldRep_NativePointer); |
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_IsArray)(f)); |
|
|
|
@ -195,15 +194,15 @@ UPB_INLINE void UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)( |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE void UPB_PRIVATE(_upb_MiniTableField_CheckIsMap)( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
const struct upb_MiniTableField* f) { |
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == |
|
|
|
|
kUpb_FieldRep_NativePointer); |
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_IsMap)(f)); |
|
|
|
|
UPB_ASSUME(f->presence == 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_INLINE size_t |
|
|
|
|
UPB_PRIVATE(_upb_MiniTableField_ElemSizeLg2)(const upb_MiniTableField* f) { |
|
|
|
|
UPB_INLINE size_t UPB_PRIVATE(_upb_MiniTableField_ElemSizeLg2)( |
|
|
|
|
const struct upb_MiniTableField* f) { |
|
|
|
|
const upb_FieldType field_type = UPB_PRIVATE(_upb_MiniTableField_Type)(f); |
|
|
|
|
return UPB_PRIVATE(_upb_FieldType_SizeLg2)(field_type); |
|
|
|
|
} |
|
|
|
|