|
|
|
@ -1009,8 +1009,84 @@ UPB_API void* upb_Array_MutableDataPtr(upb_Array* arr); |
|
|
|
|
#define UPB_MINI_TABLE_MESSAGE_H_ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef UPB_MINI_TABLE_INTERNAL_MESSAGE_H_ |
|
|
|
|
#define UPB_MINI_TABLE_INTERNAL_MESSAGE_H_ |
|
|
|
|
#ifndef UPB_MINI_TABLE_ENUM_H_ |
|
|
|
|
#define UPB_MINI_TABLE_ENUM_H_ |
|
|
|
|
|
|
|
|
|
#include <stdint.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef UPB_MINI_TABLE_INTERNAL_ENUM_H_ |
|
|
|
|
#define UPB_MINI_TABLE_INTERNAL_ENUM_H_ |
|
|
|
|
|
|
|
|
|
#include <stdint.h> |
|
|
|
|
|
|
|
|
|
// Must be last.
|
|
|
|
|
|
|
|
|
|
struct upb_MiniTableEnum { |
|
|
|
|
uint32_t UPB_PRIVATE(mask_limit); // Highest that can be tested with mask.
|
|
|
|
|
uint32_t UPB_PRIVATE(value_count); // Number of values after the bitfield.
|
|
|
|
|
uint32_t UPB_PRIVATE(data)[]; // Bitmask + enumerated values follow.
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
extern "C" { |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableEnum_CheckValue)( |
|
|
|
|
const struct upb_MiniTableEnum* e, uint32_t val) { |
|
|
|
|
if (UPB_LIKELY(val < 64)) { |
|
|
|
|
const uint64_t mask = |
|
|
|
|
e->UPB_PRIVATE(data)[0] | ((uint64_t)e->UPB_PRIVATE(data)[1] << 32); |
|
|
|
|
const uint64_t bit = 1ULL << val; |
|
|
|
|
return (mask & bit) != 0; |
|
|
|
|
} |
|
|
|
|
if (UPB_LIKELY(val < e->UPB_PRIVATE(mask_limit))) { |
|
|
|
|
const uint32_t mask = e->UPB_PRIVATE(data)[val / 32]; |
|
|
|
|
const uint32_t bit = 1ULL << (val % 32); |
|
|
|
|
return (mask & bit) != 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// OPT: binary search long lists?
|
|
|
|
|
const uint32_t* start = |
|
|
|
|
&e->UPB_PRIVATE(data)[e->UPB_PRIVATE(mask_limit) / 32]; |
|
|
|
|
const uint32_t* limit = &e->UPB_PRIVATE( |
|
|
|
|
data)[e->UPB_PRIVATE(mask_limit) / 32 + e->UPB_PRIVATE(value_count)]; |
|
|
|
|
for (const uint32_t* p = start; p < limit; p++) { |
|
|
|
|
if (*p == val) return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
} /* extern "C" */ |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* UPB_MINI_TABLE_INTERNAL_ENUM_H_ */ |
|
|
|
|
|
|
|
|
|
// Must be last
|
|
|
|
|
|
|
|
|
|
typedef struct upb_MiniTableEnum upb_MiniTableEnum; |
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
extern "C" { |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// Validates enum value against range defined by enum mini table.
|
|
|
|
|
UPB_INLINE bool upb_MiniTableEnum_CheckValue(const upb_MiniTableEnum* e, |
|
|
|
|
uint32_t val) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableEnum_CheckValue)(e, val); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
} /* extern "C" */ |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* UPB_MINI_TABLE_ENUM_H_ */ |
|
|
|
|
|
|
|
|
|
#ifndef UPB_MINI_TABLE_FIELD_H_ |
|
|
|
|
#define UPB_MINI_TABLE_FIELD_H_ |
|
|
|
|
|
|
|
|
|
#include <stdint.h> |
|
|
|
|
|
|
|
|
@ -1290,6 +1366,80 @@ UPB_INLINE size_t UPB_PRIVATE(_upb_MiniTableField_ElemSizeLg2)( |
|
|
|
|
|
|
|
|
|
#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_CType upb_MiniTableField_CType(const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_CType)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_HasPresence( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_HasPresence)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsArray(const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_IsArray)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsClosedEnum( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_IsClosedEnum)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsExtension( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_IsExtension)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsInOneof(const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_IsInOneof)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsMap(const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_IsMap)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsPacked(const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_IsPacked)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsScalar(const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_IsScalar)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsSubMessage( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_IsSubMessage)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE uint32_t upb_MiniTableField_Number(const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_Number)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE upb_FieldType |
|
|
|
|
upb_MiniTableField_Type(const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_Type)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
} /* extern "C" */ |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* UPB_MINI_TABLE_FIELD_H_ */ |
|
|
|
|
|
|
|
|
|
#ifndef UPB_MINI_TABLE_INTERNAL_MESSAGE_H_ |
|
|
|
|
#define UPB_MINI_TABLE_INTERNAL_MESSAGE_H_ |
|
|
|
|
|
|
|
|
|
#include <stdint.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef UPB_MINI_TABLE_INTERNAL_SUB_H_ |
|
|
|
|
#define UPB_MINI_TABLE_INTERNAL_SUB_H_ |
|
|
|
|
|
|
|
|
@ -1479,22 +1629,9 @@ UPB_PRIVATE(_upb_MiniTable_RequiredMask)(const struct upb_MiniTable* m) { |
|
|
|
|
|
|
|
|
|
#endif /* UPB_MINI_TABLE_INTERNAL_MESSAGE_H_ */ |
|
|
|
|
|
|
|
|
|
#ifndef UPB_MINI_TABLE_TYPES_H_ |
|
|
|
|
#define UPB_MINI_TABLE_TYPES_H_ |
|
|
|
|
|
|
|
|
|
// Minitable types are recursively defined so declare them all together here.
|
|
|
|
|
// Must be last.
|
|
|
|
|
|
|
|
|
|
typedef struct upb_MiniTable upb_MiniTable; |
|
|
|
|
typedef struct upb_MiniTableEnum upb_MiniTableEnum; |
|
|
|
|
typedef struct upb_MiniTableExtension upb_MiniTableExtension; |
|
|
|
|
typedef struct upb_MiniTableField upb_MiniTableField; |
|
|
|
|
typedef struct upb_MiniTableFile upb_MiniTableFile; |
|
|
|
|
|
|
|
|
|
typedef union upb_MiniTableSub upb_MiniTableSub; |
|
|
|
|
|
|
|
|
|
#endif /* UPB_MINI_TABLE_TYPES_H_ */ |
|
|
|
|
|
|
|
|
|
// Must be last.
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
extern "C" { |
|
|
|
@ -1654,6 +1791,8 @@ UPB_INLINE void UPB_PRIVATE(_upb_MiniTableExtension_SetSubMessage)( |
|
|
|
|
|
|
|
|
|
// Must be last.
|
|
|
|
|
|
|
|
|
|
typedef struct upb_MiniTableExtension upb_MiniTableExtension; |
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
extern "C" { |
|
|
|
|
#endif |
|
|
|
@ -2391,78 +2530,6 @@ bool UPB_PRIVATE(_upb_Message_Realloc)(upb_Message* msg, size_t need, |
|
|
|
|
|
|
|
|
|
#endif /* UPB_MESSAGE_INTERNAL_H_ */ |
|
|
|
|
|
|
|
|
|
#ifndef UPB_MINI_TABLE_FIELD_H_ |
|
|
|
|
#define UPB_MINI_TABLE_FIELD_H_ |
|
|
|
|
|
|
|
|
|
#include <stdint.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Must be last.
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
extern "C" { |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE upb_CType upb_MiniTableField_CType(const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_CType)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_HasPresence( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_HasPresence)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsArray(const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_IsArray)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsClosedEnum( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_IsClosedEnum)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsExtension( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_IsExtension)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsInOneof(const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_IsInOneof)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsMap(const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_IsMap)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsPacked(const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_IsPacked)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsScalar(const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_IsScalar)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_MiniTableField_IsSubMessage( |
|
|
|
|
const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_IsSubMessage)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE uint32_t upb_MiniTableField_Number(const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_Number)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UPB_API_INLINE upb_FieldType |
|
|
|
|
upb_MiniTableField_Type(const upb_MiniTableField* f) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableField_Type)(f); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
} /* extern "C" */ |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* UPB_MINI_TABLE_FIELD_H_ */ |
|
|
|
|
|
|
|
|
|
// Must be last.
|
|
|
|
|
|
|
|
|
|
#if defined(__GNUC__) && !defined(__clang__) |
|
|
|
@ -2912,86 +2979,14 @@ UPB_INLINE void UPB_PRIVATE(_upb_Array_Set)(upb_Array* array, size_t i, |
|
|
|
|
|
|
|
|
|
#endif /* UPB_MESSAGE_INTERNAL_ARRAY_H_ */ |
|
|
|
|
|
|
|
|
|
#ifndef UPB_MINI_TABLE_ENUM_H_ |
|
|
|
|
#define UPB_MINI_TABLE_ENUM_H_ |
|
|
|
|
|
|
|
|
|
#include <stdint.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef UPB_MINI_TABLE_INTERNAL_ENUM_H_ |
|
|
|
|
#define UPB_MINI_TABLE_INTERNAL_ENUM_H_ |
|
|
|
|
|
|
|
|
|
#include <stdint.h> |
|
|
|
|
|
|
|
|
|
// Must be last.
|
|
|
|
|
|
|
|
|
|
struct upb_MiniTableEnum { |
|
|
|
|
uint32_t UPB_PRIVATE(mask_limit); // Highest that can be tested with mask.
|
|
|
|
|
uint32_t UPB_PRIVATE(value_count); // Number of values after the bitfield.
|
|
|
|
|
uint32_t UPB_PRIVATE(data)[]; // Bitmask + enumerated values follow.
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
extern "C" { |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableEnum_CheckValue)( |
|
|
|
|
const struct upb_MiniTableEnum* e, uint32_t val) { |
|
|
|
|
if (UPB_LIKELY(val < 64)) { |
|
|
|
|
const uint64_t mask = |
|
|
|
|
e->UPB_PRIVATE(data)[0] | ((uint64_t)e->UPB_PRIVATE(data)[1] << 32); |
|
|
|
|
const uint64_t bit = 1ULL << val; |
|
|
|
|
return (mask & bit) != 0; |
|
|
|
|
} |
|
|
|
|
if (UPB_LIKELY(val < e->UPB_PRIVATE(mask_limit))) { |
|
|
|
|
const uint32_t mask = e->UPB_PRIVATE(data)[val / 32]; |
|
|
|
|
const uint32_t bit = 1ULL << (val % 32); |
|
|
|
|
return (mask & bit) != 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// OPT: binary search long lists?
|
|
|
|
|
const uint32_t* start = |
|
|
|
|
&e->UPB_PRIVATE(data)[e->UPB_PRIVATE(mask_limit) / 32]; |
|
|
|
|
const uint32_t* limit = &e->UPB_PRIVATE( |
|
|
|
|
data)[e->UPB_PRIVATE(mask_limit) / 32 + e->UPB_PRIVATE(value_count)]; |
|
|
|
|
for (const uint32_t* p = start; p < limit; p++) { |
|
|
|
|
if (*p == val) return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
} /* extern "C" */ |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* UPB_MINI_TABLE_INTERNAL_ENUM_H_ */ |
|
|
|
|
|
|
|
|
|
// Must be last
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
extern "C" { |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// Validates enum value against range defined by enum mini table.
|
|
|
|
|
UPB_INLINE bool upb_MiniTableEnum_CheckValue(const upb_MiniTableEnum* e, |
|
|
|
|
uint32_t val) { |
|
|
|
|
return UPB_PRIVATE(_upb_MiniTableEnum_CheckValue)(e, val); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
} /* extern "C" */ |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* UPB_MINI_TABLE_ENUM_H_ */ |
|
|
|
|
|
|
|
|
|
#ifndef UPB_MINI_TABLE_SUB_H_ |
|
|
|
|
#define UPB_MINI_TABLE_SUB_H_ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Must be last.
|
|
|
|
|
|
|
|
|
|
typedef union upb_MiniTableSub upb_MiniTableSub; |
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
extern "C" { |
|
|
|
|
#endif |
|
|
|
@ -3844,6 +3839,8 @@ UPB_INLINE const struct upb_MiniTable* UPB_PRIVATE(_upb_MiniTableFile_Message)( |
|
|
|
|
|
|
|
|
|
// Must be last.
|
|
|
|
|
|
|
|
|
|
typedef struct upb_MiniTableFile upb_MiniTableFile; |
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
extern "C" { |
|
|
|
|
#endif |
|
|
|
|