Auto-generate files after cl/631612923

pull/16771/head
Protobuf Team Bot 9 months ago
parent 65821a67d6
commit 4d3a98c27e
  1. 2
      php/ext/google/protobuf/php-upb.c
  2. 390
      php/ext/google/protobuf/php-upb.h
  3. 2
      ruby/ext/google/protobuf_c/ruby-upb.c
  4. 390
      ruby/ext/google/protobuf_c/ruby-upb.h

@ -6158,7 +6158,7 @@ upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src,
return NULL;
}
UPB_PRIVATE(_upb_Message_SetTaggedMessagePtr)
(dst, mini_table, field,
(dst, field,
UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(dst_sub_message,
is_empty));
}

@ -413,113 +413,6 @@ void upb_Status_VAppendErrorFormat(upb_Status* status, const char* fmt,
#ifndef UPB_MESSAGE_ACCESSORS_H_
#define UPB_MESSAGE_ACCESSORS_H_
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#ifndef UPB_BASE_DESCRIPTOR_CONSTANTS_H_
#define UPB_BASE_DESCRIPTOR_CONSTANTS_H_
// Must be last.
// The types a field can have. Note that this list is not identical to the
// types defined in descriptor.proto, which gives INT32 and SINT32 separate
// types (we distinguish the two with the "integer encoding" enum below).
// This enum is an internal convenience only and has no meaning outside of upb.
typedef enum {
kUpb_CType_Bool = 1,
kUpb_CType_Float = 2,
kUpb_CType_Int32 = 3,
kUpb_CType_UInt32 = 4,
kUpb_CType_Enum = 5, // Enum values are int32. TODO: rename
kUpb_CType_Message = 6,
kUpb_CType_Double = 7,
kUpb_CType_Int64 = 8,
kUpb_CType_UInt64 = 9,
kUpb_CType_String = 10,
kUpb_CType_Bytes = 11
} upb_CType;
// The repeated-ness of each field; this matches descriptor.proto.
typedef enum {
kUpb_Label_Optional = 1,
kUpb_Label_Required = 2,
kUpb_Label_Repeated = 3
} upb_Label;
// Descriptor types, as defined in descriptor.proto.
typedef enum {
kUpb_FieldType_Double = 1,
kUpb_FieldType_Float = 2,
kUpb_FieldType_Int64 = 3,
kUpb_FieldType_UInt64 = 4,
kUpb_FieldType_Int32 = 5,
kUpb_FieldType_Fixed64 = 6,
kUpb_FieldType_Fixed32 = 7,
kUpb_FieldType_Bool = 8,
kUpb_FieldType_String = 9,
kUpb_FieldType_Group = 10,
kUpb_FieldType_Message = 11,
kUpb_FieldType_Bytes = 12,
kUpb_FieldType_UInt32 = 13,
kUpb_FieldType_Enum = 14,
kUpb_FieldType_SFixed32 = 15,
kUpb_FieldType_SFixed64 = 16,
kUpb_FieldType_SInt32 = 17,
kUpb_FieldType_SInt64 = 18,
} upb_FieldType;
#define kUpb_FieldType_SizeOf 19
#ifdef __cplusplus
extern "C" {
#endif
// Convert from upb_FieldType to upb_CType
UPB_INLINE upb_CType upb_FieldType_CType(upb_FieldType field_type) {
static const upb_CType c_type[] = {
kUpb_CType_Double, // kUpb_FieldType_Double
kUpb_CType_Float, // kUpb_FieldType_Float
kUpb_CType_Int64, // kUpb_FieldType_Int64
kUpb_CType_UInt64, // kUpb_FieldType_UInt64
kUpb_CType_Int32, // kUpb_FieldType_Int32
kUpb_CType_UInt64, // kUpb_FieldType_Fixed64
kUpb_CType_UInt32, // kUpb_FieldType_Fixed32
kUpb_CType_Bool, // kUpb_FieldType_Bool
kUpb_CType_String, // kUpb_FieldType_String
kUpb_CType_Message, // kUpb_FieldType_Group
kUpb_CType_Message, // kUpb_FieldType_Message
kUpb_CType_Bytes, // kUpb_FieldType_Bytes
kUpb_CType_UInt32, // kUpb_FieldType_UInt32
kUpb_CType_Enum, // kUpb_FieldType_Enum
kUpb_CType_Int32, // kUpb_FieldType_SFixed32
kUpb_CType_Int64, // kUpb_FieldType_SFixed64
kUpb_CType_Int32, // kUpb_FieldType_SInt32
kUpb_CType_Int64, // kUpb_FieldType_SInt64
};
// -1 here because the enum is one-based but the table is zero-based.
return c_type[field_type - 1];
}
UPB_INLINE bool upb_FieldType_IsPackable(upb_FieldType field_type) {
// clang-format off
const unsigned kUnpackableTypes =
(1 << kUpb_FieldType_String) |
(1 << kUpb_FieldType_Bytes) |
(1 << kUpb_FieldType_Message) |
(1 << kUpb_FieldType_Group);
// clang-format on
return (1 << field_type) & ~kUnpackableTypes;
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* UPB_BASE_DESCRIPTOR_CONSTANTS_H_ */
#ifndef UPB_BASE_STRING_VIEW_H_
#define UPB_BASE_STRING_VIEW_H_
@ -827,6 +720,109 @@ void upb_Arena_SetTraceHandler(void (*initArenaTraceHandler)(const upb_Arena*,
#include <stddef.h>
#ifndef UPB_BASE_DESCRIPTOR_CONSTANTS_H_
#define UPB_BASE_DESCRIPTOR_CONSTANTS_H_
// Must be last.
// The types a field can have. Note that this list is not identical to the
// types defined in descriptor.proto, which gives INT32 and SINT32 separate
// types (we distinguish the two with the "integer encoding" enum below).
// This enum is an internal convenience only and has no meaning outside of upb.
typedef enum {
kUpb_CType_Bool = 1,
kUpb_CType_Float = 2,
kUpb_CType_Int32 = 3,
kUpb_CType_UInt32 = 4,
kUpb_CType_Enum = 5, // Enum values are int32. TODO: rename
kUpb_CType_Message = 6,
kUpb_CType_Double = 7,
kUpb_CType_Int64 = 8,
kUpb_CType_UInt64 = 9,
kUpb_CType_String = 10,
kUpb_CType_Bytes = 11
} upb_CType;
// The repeated-ness of each field; this matches descriptor.proto.
typedef enum {
kUpb_Label_Optional = 1,
kUpb_Label_Required = 2,
kUpb_Label_Repeated = 3
} upb_Label;
// Descriptor types, as defined in descriptor.proto.
typedef enum {
kUpb_FieldType_Double = 1,
kUpb_FieldType_Float = 2,
kUpb_FieldType_Int64 = 3,
kUpb_FieldType_UInt64 = 4,
kUpb_FieldType_Int32 = 5,
kUpb_FieldType_Fixed64 = 6,
kUpb_FieldType_Fixed32 = 7,
kUpb_FieldType_Bool = 8,
kUpb_FieldType_String = 9,
kUpb_FieldType_Group = 10,
kUpb_FieldType_Message = 11,
kUpb_FieldType_Bytes = 12,
kUpb_FieldType_UInt32 = 13,
kUpb_FieldType_Enum = 14,
kUpb_FieldType_SFixed32 = 15,
kUpb_FieldType_SFixed64 = 16,
kUpb_FieldType_SInt32 = 17,
kUpb_FieldType_SInt64 = 18,
} upb_FieldType;
#define kUpb_FieldType_SizeOf 19
#ifdef __cplusplus
extern "C" {
#endif
// Convert from upb_FieldType to upb_CType
UPB_INLINE upb_CType upb_FieldType_CType(upb_FieldType field_type) {
static const upb_CType c_type[] = {
kUpb_CType_Double, // kUpb_FieldType_Double
kUpb_CType_Float, // kUpb_FieldType_Float
kUpb_CType_Int64, // kUpb_FieldType_Int64
kUpb_CType_UInt64, // kUpb_FieldType_UInt64
kUpb_CType_Int32, // kUpb_FieldType_Int32
kUpb_CType_UInt64, // kUpb_FieldType_Fixed64
kUpb_CType_UInt32, // kUpb_FieldType_Fixed32
kUpb_CType_Bool, // kUpb_FieldType_Bool
kUpb_CType_String, // kUpb_FieldType_String
kUpb_CType_Message, // kUpb_FieldType_Group
kUpb_CType_Message, // kUpb_FieldType_Message
kUpb_CType_Bytes, // kUpb_FieldType_Bytes
kUpb_CType_UInt32, // kUpb_FieldType_UInt32
kUpb_CType_Enum, // kUpb_FieldType_Enum
kUpb_CType_Int32, // kUpb_FieldType_SFixed32
kUpb_CType_Int64, // kUpb_FieldType_SFixed64
kUpb_CType_Int32, // kUpb_FieldType_SInt32
kUpb_CType_Int64, // kUpb_FieldType_SInt64
};
// -1 here because the enum is one-based but the table is zero-based.
return c_type[field_type - 1];
}
UPB_INLINE bool upb_FieldType_IsPackable(upb_FieldType field_type) {
// clang-format off
const unsigned kUnpackableTypes =
(1 << kUpb_FieldType_String) |
(1 << kUpb_FieldType_Bytes) |
(1 << kUpb_FieldType_Message) |
(1 << kUpb_FieldType_Group);
// clang-format on
return (1 << field_type) & ~kUnpackableTypes;
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* UPB_BASE_DESCRIPTOR_CONSTANTS_H_ */
#ifndef UPB_MESSAGE_INTERNAL_ARRAY_H_
#define UPB_MESSAGE_INTERNAL_ARRAY_H_
@ -3005,6 +3001,37 @@ UPB_API_INLINE const struct upb_Map* upb_Message_GetMap(
return ret;
}
UPB_API_INLINE uintptr_t upb_Message_GetTaggedMessagePtr(
const struct upb_Message* msg, const upb_MiniTableField* f,
struct upb_Message* default_val) {
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Message);
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) ==
UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte));
UPB_ASSUME(upb_MiniTableField_IsScalar(f));
uintptr_t tagged;
_upb_Message_GetNonExtensionField(msg, f, &default_val, &tagged);
return tagged;
}
// For internal use only; users cannot set tagged messages because only the
// parser and the message copier are allowed to directly create an empty
// message.
UPB_INLINE void UPB_PRIVATE(_upb_Message_SetTaggedMessagePtr)(
struct upb_Message* msg, const upb_MiniTableField* f,
uintptr_t sub_message) {
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Message);
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) ==
UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte));
UPB_ASSUME(upb_MiniTableField_IsScalar(f));
upb_Message_SetBaseField(msg, f, &sub_message);
}
UPB_API_INLINE const struct upb_Message* upb_Message_GetMessage(
const struct upb_Message* msg, const upb_MiniTableField* f) {
uintptr_t tagged = upb_Message_GetTaggedMessagePtr(msg, f, NULL);
return upb_TaggedMessagePtr_GetNonEmptyMessage(tagged);
}
UPB_API_INLINE upb_Array* upb_Message_GetMutableArray(
struct upb_Message* msg, const upb_MiniTableField* f) {
UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(f);
@ -3016,6 +3043,11 @@ UPB_API_INLINE struct upb_Map* upb_Message_GetMutableMap(
return (struct upb_Map*)upb_Message_GetMap(msg, f);
}
UPB_API_INLINE struct upb_Message* upb_Message_GetMutableMessage(
struct upb_Message* msg, const upb_MiniTableField* f) {
return (struct upb_Message*)upb_Message_GetMessage(msg, f);
}
UPB_API_INLINE upb_Array* upb_Message_GetOrCreateMutableArray(
struct upb_Message* msg, const upb_MiniTableField* f, upb_Arena* arena) {
UPB_ASSERT(arena);
@ -3189,6 +3221,16 @@ UPB_API_INLINE bool upb_Message_SetInt64(struct upb_Message* msg,
return UPB_PRIVATE(_upb_Message_SetField)(msg, f, val, a);
}
// Sets the value of a message-typed field. The mini_tables of `msg` and
// `sub_message` must have been linked for this to work correctly.
UPB_API_INLINE void upb_Message_SetMessage(struct upb_Message* msg,
const upb_MiniTable* m,
const upb_MiniTableField* f,
struct upb_Message* sub_message) {
UPB_PRIVATE(_upb_Message_SetTaggedMessagePtr)
(msg, f, UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(sub_message, false));
}
// Sets the value of a `string` or `bytes` field. The bytes of the value are not
// copied, so it is the caller's responsibility to ensure that they remain valid
// for the lifetime of `msg`. That might be done by copying them into the given
@ -3504,41 +3546,6 @@ UPB_API_INLINE upb_Message* upb_TaggedMessagePtr_GetNonEmptyMessage(
#endif /* UPB_MINI_TABLE_TAGGED_PTR_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
// Constructors
UPB_API_INLINE upb_MiniTableSub
upb_MiniTableSub_FromEnum(const upb_MiniTableEnum* subenum);
UPB_API_INLINE upb_MiniTableSub
upb_MiniTableSub_FromMessage(const upb_MiniTable* submsg);
// Getters
UPB_API_INLINE const upb_MiniTableEnum* upb_MiniTableSub_Enum(
upb_MiniTableSub sub);
UPB_API_INLINE const upb_MiniTable* upb_MiniTableSub_Message(
upb_MiniTableSub sub);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* UPB_MINI_TABLE_SUB_H_ */
// Must be last.
#ifdef __cplusplus
@ -3581,6 +3588,10 @@ UPB_API_INLINE upb_MessageValue
upb_Message_GetField(const upb_Message* msg, const upb_MiniTableField* f,
upb_MessageValue default_val);
UPB_API_INLINE upb_TaggedMessagePtr upb_Message_GetTaggedMessagePtr(
const upb_Message* msg, const upb_MiniTableField* field,
upb_Message* default_val);
UPB_API_INLINE const upb_Array* upb_Message_GetArray(
const upb_Message* msg, const upb_MiniTableField* f);
@ -3607,12 +3618,18 @@ UPB_API_INLINE int64_t upb_Message_GetInt64(const upb_Message* msg,
UPB_API_INLINE const upb_Map* upb_Message_GetMap(const upb_Message* msg,
const upb_MiniTableField* f);
UPB_API_INLINE const upb_Message* upb_Message_GetMessage(
const upb_Message* msg, const upb_MiniTableField* f);
UPB_API_INLINE upb_Array* upb_Message_GetMutableArray(
upb_Message* msg, const upb_MiniTableField* f);
UPB_API_INLINE upb_Map* upb_Message_GetMutableMap(upb_Message* msg,
const upb_MiniTableField* f);
UPB_API_INLINE upb_Message* upb_Message_GetMutableMessage(
upb_Message* msg, const upb_MiniTableField* f);
UPB_API_INLINE upb_Array* upb_Message_GetOrCreateMutableArray(
upb_Message* msg, const upb_MiniTableField* f, upb_Arena* arena);
@ -3660,6 +3677,11 @@ UPB_API_INLINE bool upb_Message_SetInt64(upb_Message* msg,
const upb_MiniTableField* f,
int64_t value, upb_Arena* a);
UPB_API_INLINE void upb_Message_SetMessage(upb_Message* msg,
const upb_MiniTable* m,
const upb_MiniTableField* f,
upb_Message* sub_message);
UPB_API_INLINE bool upb_Message_SetString(upb_Message* msg,
const upb_MiniTableField* f,
upb_StringView value, upb_Arena* a);
@ -3672,55 +3694,6 @@ UPB_API_INLINE bool upb_Message_SetUInt64(upb_Message* msg,
const upb_MiniTableField* f,
uint64_t value, upb_Arena* a);
UPB_API_INLINE upb_TaggedMessagePtr upb_Message_GetTaggedMessagePtr(
const upb_Message* msg, const upb_MiniTableField* field,
upb_Message* default_val) {
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Message);
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) ==
UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte));
UPB_ASSUME(upb_MiniTableField_IsScalar(field));
upb_TaggedMessagePtr tagged;
_upb_Message_GetNonExtensionField(msg, field, &default_val, &tagged);
return tagged;
}
UPB_API_INLINE const upb_Message* upb_Message_GetMessage(
const upb_Message* msg, const upb_MiniTableField* field) {
upb_TaggedMessagePtr tagged =
upb_Message_GetTaggedMessagePtr(msg, field, NULL);
return upb_TaggedMessagePtr_GetNonEmptyMessage(tagged);
}
UPB_API_INLINE upb_Message* upb_Message_GetMutableMessage(
upb_Message* msg, const upb_MiniTableField* field) {
return (upb_Message*)upb_Message_GetMessage(msg, field);
}
// For internal use only; users cannot set tagged messages because only the
// parser and the message copier are allowed to directly create an empty
// message.
UPB_INLINE void UPB_PRIVATE(_upb_Message_SetTaggedMessagePtr)(
struct upb_Message* msg, const upb_MiniTable* mini_table,
const upb_MiniTableField* f, upb_TaggedMessagePtr sub_message) {
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Message);
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) ==
UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte));
UPB_ASSUME(upb_MiniTableField_IsScalar(f));
upb_Message_SetBaseField(msg, f, &sub_message);
}
// Sets the value of a message-typed field. The `mini_table` and `field`
// parameters belong to `msg`, not `sub_message`. The mini_tables of `msg` and
// `sub_message` must have been linked for this to work correctly.
UPB_API_INLINE void upb_Message_SetMessage(upb_Message* msg,
const upb_MiniTable* mini_table,
const upb_MiniTableField* field,
upb_Message* sub_message) {
UPB_PRIVATE(_upb_Message_SetTaggedMessagePtr)
(msg, mini_table, field,
UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(sub_message, false));
}
UPB_API_INLINE void* upb_Message_ResizeArrayUninitialized(
upb_Message* msg, const upb_MiniTableField* f, size_t size,
upb_Arena* arena);
@ -3793,6 +3766,41 @@ UPB_INLINE void _upb_msg_map_set_value(void* msg, const void* val,
#define UPB_MINI_TABLE_DECODE_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
// Constructors
UPB_API_INLINE upb_MiniTableSub
upb_MiniTableSub_FromEnum(const upb_MiniTableEnum* subenum);
UPB_API_INLINE upb_MiniTableSub
upb_MiniTableSub_FromMessage(const upb_MiniTable* submsg);
// Getters
UPB_API_INLINE const upb_MiniTableEnum* upb_MiniTableSub_Enum(
upb_MiniTableSub sub);
UPB_API_INLINE const upb_MiniTable* upb_MiniTableSub_Message(
upb_MiniTableSub sub);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* UPB_MINI_TABLE_SUB_H_ */
// Export the newer headers, for legacy users. New users should include the
// more specific headers directly.
// IWYU pragma: begin_exports

@ -5650,7 +5650,7 @@ upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src,
return NULL;
}
UPB_PRIVATE(_upb_Message_SetTaggedMessagePtr)
(dst, mini_table, field,
(dst, field,
UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(dst_sub_message,
is_empty));
}

@ -415,113 +415,6 @@ void upb_Status_VAppendErrorFormat(upb_Status* status, const char* fmt,
#ifndef UPB_MESSAGE_ACCESSORS_H_
#define UPB_MESSAGE_ACCESSORS_H_
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#ifndef UPB_BASE_DESCRIPTOR_CONSTANTS_H_
#define UPB_BASE_DESCRIPTOR_CONSTANTS_H_
// Must be last.
// The types a field can have. Note that this list is not identical to the
// types defined in descriptor.proto, which gives INT32 and SINT32 separate
// types (we distinguish the two with the "integer encoding" enum below).
// This enum is an internal convenience only and has no meaning outside of upb.
typedef enum {
kUpb_CType_Bool = 1,
kUpb_CType_Float = 2,
kUpb_CType_Int32 = 3,
kUpb_CType_UInt32 = 4,
kUpb_CType_Enum = 5, // Enum values are int32. TODO: rename
kUpb_CType_Message = 6,
kUpb_CType_Double = 7,
kUpb_CType_Int64 = 8,
kUpb_CType_UInt64 = 9,
kUpb_CType_String = 10,
kUpb_CType_Bytes = 11
} upb_CType;
// The repeated-ness of each field; this matches descriptor.proto.
typedef enum {
kUpb_Label_Optional = 1,
kUpb_Label_Required = 2,
kUpb_Label_Repeated = 3
} upb_Label;
// Descriptor types, as defined in descriptor.proto.
typedef enum {
kUpb_FieldType_Double = 1,
kUpb_FieldType_Float = 2,
kUpb_FieldType_Int64 = 3,
kUpb_FieldType_UInt64 = 4,
kUpb_FieldType_Int32 = 5,
kUpb_FieldType_Fixed64 = 6,
kUpb_FieldType_Fixed32 = 7,
kUpb_FieldType_Bool = 8,
kUpb_FieldType_String = 9,
kUpb_FieldType_Group = 10,
kUpb_FieldType_Message = 11,
kUpb_FieldType_Bytes = 12,
kUpb_FieldType_UInt32 = 13,
kUpb_FieldType_Enum = 14,
kUpb_FieldType_SFixed32 = 15,
kUpb_FieldType_SFixed64 = 16,
kUpb_FieldType_SInt32 = 17,
kUpb_FieldType_SInt64 = 18,
} upb_FieldType;
#define kUpb_FieldType_SizeOf 19
#ifdef __cplusplus
extern "C" {
#endif
// Convert from upb_FieldType to upb_CType
UPB_INLINE upb_CType upb_FieldType_CType(upb_FieldType field_type) {
static const upb_CType c_type[] = {
kUpb_CType_Double, // kUpb_FieldType_Double
kUpb_CType_Float, // kUpb_FieldType_Float
kUpb_CType_Int64, // kUpb_FieldType_Int64
kUpb_CType_UInt64, // kUpb_FieldType_UInt64
kUpb_CType_Int32, // kUpb_FieldType_Int32
kUpb_CType_UInt64, // kUpb_FieldType_Fixed64
kUpb_CType_UInt32, // kUpb_FieldType_Fixed32
kUpb_CType_Bool, // kUpb_FieldType_Bool
kUpb_CType_String, // kUpb_FieldType_String
kUpb_CType_Message, // kUpb_FieldType_Group
kUpb_CType_Message, // kUpb_FieldType_Message
kUpb_CType_Bytes, // kUpb_FieldType_Bytes
kUpb_CType_UInt32, // kUpb_FieldType_UInt32
kUpb_CType_Enum, // kUpb_FieldType_Enum
kUpb_CType_Int32, // kUpb_FieldType_SFixed32
kUpb_CType_Int64, // kUpb_FieldType_SFixed64
kUpb_CType_Int32, // kUpb_FieldType_SInt32
kUpb_CType_Int64, // kUpb_FieldType_SInt64
};
// -1 here because the enum is one-based but the table is zero-based.
return c_type[field_type - 1];
}
UPB_INLINE bool upb_FieldType_IsPackable(upb_FieldType field_type) {
// clang-format off
const unsigned kUnpackableTypes =
(1 << kUpb_FieldType_String) |
(1 << kUpb_FieldType_Bytes) |
(1 << kUpb_FieldType_Message) |
(1 << kUpb_FieldType_Group);
// clang-format on
return (1 << field_type) & ~kUnpackableTypes;
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* UPB_BASE_DESCRIPTOR_CONSTANTS_H_ */
#ifndef UPB_BASE_STRING_VIEW_H_
#define UPB_BASE_STRING_VIEW_H_
@ -829,6 +722,109 @@ void upb_Arena_SetTraceHandler(void (*initArenaTraceHandler)(const upb_Arena*,
#include <stddef.h>
#ifndef UPB_BASE_DESCRIPTOR_CONSTANTS_H_
#define UPB_BASE_DESCRIPTOR_CONSTANTS_H_
// Must be last.
// The types a field can have. Note that this list is not identical to the
// types defined in descriptor.proto, which gives INT32 and SINT32 separate
// types (we distinguish the two with the "integer encoding" enum below).
// This enum is an internal convenience only and has no meaning outside of upb.
typedef enum {
kUpb_CType_Bool = 1,
kUpb_CType_Float = 2,
kUpb_CType_Int32 = 3,
kUpb_CType_UInt32 = 4,
kUpb_CType_Enum = 5, // Enum values are int32. TODO: rename
kUpb_CType_Message = 6,
kUpb_CType_Double = 7,
kUpb_CType_Int64 = 8,
kUpb_CType_UInt64 = 9,
kUpb_CType_String = 10,
kUpb_CType_Bytes = 11
} upb_CType;
// The repeated-ness of each field; this matches descriptor.proto.
typedef enum {
kUpb_Label_Optional = 1,
kUpb_Label_Required = 2,
kUpb_Label_Repeated = 3
} upb_Label;
// Descriptor types, as defined in descriptor.proto.
typedef enum {
kUpb_FieldType_Double = 1,
kUpb_FieldType_Float = 2,
kUpb_FieldType_Int64 = 3,
kUpb_FieldType_UInt64 = 4,
kUpb_FieldType_Int32 = 5,
kUpb_FieldType_Fixed64 = 6,
kUpb_FieldType_Fixed32 = 7,
kUpb_FieldType_Bool = 8,
kUpb_FieldType_String = 9,
kUpb_FieldType_Group = 10,
kUpb_FieldType_Message = 11,
kUpb_FieldType_Bytes = 12,
kUpb_FieldType_UInt32 = 13,
kUpb_FieldType_Enum = 14,
kUpb_FieldType_SFixed32 = 15,
kUpb_FieldType_SFixed64 = 16,
kUpb_FieldType_SInt32 = 17,
kUpb_FieldType_SInt64 = 18,
} upb_FieldType;
#define kUpb_FieldType_SizeOf 19
#ifdef __cplusplus
extern "C" {
#endif
// Convert from upb_FieldType to upb_CType
UPB_INLINE upb_CType upb_FieldType_CType(upb_FieldType field_type) {
static const upb_CType c_type[] = {
kUpb_CType_Double, // kUpb_FieldType_Double
kUpb_CType_Float, // kUpb_FieldType_Float
kUpb_CType_Int64, // kUpb_FieldType_Int64
kUpb_CType_UInt64, // kUpb_FieldType_UInt64
kUpb_CType_Int32, // kUpb_FieldType_Int32
kUpb_CType_UInt64, // kUpb_FieldType_Fixed64
kUpb_CType_UInt32, // kUpb_FieldType_Fixed32
kUpb_CType_Bool, // kUpb_FieldType_Bool
kUpb_CType_String, // kUpb_FieldType_String
kUpb_CType_Message, // kUpb_FieldType_Group
kUpb_CType_Message, // kUpb_FieldType_Message
kUpb_CType_Bytes, // kUpb_FieldType_Bytes
kUpb_CType_UInt32, // kUpb_FieldType_UInt32
kUpb_CType_Enum, // kUpb_FieldType_Enum
kUpb_CType_Int32, // kUpb_FieldType_SFixed32
kUpb_CType_Int64, // kUpb_FieldType_SFixed64
kUpb_CType_Int32, // kUpb_FieldType_SInt32
kUpb_CType_Int64, // kUpb_FieldType_SInt64
};
// -1 here because the enum is one-based but the table is zero-based.
return c_type[field_type - 1];
}
UPB_INLINE bool upb_FieldType_IsPackable(upb_FieldType field_type) {
// clang-format off
const unsigned kUnpackableTypes =
(1 << kUpb_FieldType_String) |
(1 << kUpb_FieldType_Bytes) |
(1 << kUpb_FieldType_Message) |
(1 << kUpb_FieldType_Group);
// clang-format on
return (1 << field_type) & ~kUnpackableTypes;
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* UPB_BASE_DESCRIPTOR_CONSTANTS_H_ */
#ifndef UPB_MESSAGE_INTERNAL_ARRAY_H_
#define UPB_MESSAGE_INTERNAL_ARRAY_H_
@ -3007,6 +3003,37 @@ UPB_API_INLINE const struct upb_Map* upb_Message_GetMap(
return ret;
}
UPB_API_INLINE uintptr_t upb_Message_GetTaggedMessagePtr(
const struct upb_Message* msg, const upb_MiniTableField* f,
struct upb_Message* default_val) {
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Message);
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) ==
UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte));
UPB_ASSUME(upb_MiniTableField_IsScalar(f));
uintptr_t tagged;
_upb_Message_GetNonExtensionField(msg, f, &default_val, &tagged);
return tagged;
}
// For internal use only; users cannot set tagged messages because only the
// parser and the message copier are allowed to directly create an empty
// message.
UPB_INLINE void UPB_PRIVATE(_upb_Message_SetTaggedMessagePtr)(
struct upb_Message* msg, const upb_MiniTableField* f,
uintptr_t sub_message) {
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Message);
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) ==
UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte));
UPB_ASSUME(upb_MiniTableField_IsScalar(f));
upb_Message_SetBaseField(msg, f, &sub_message);
}
UPB_API_INLINE const struct upb_Message* upb_Message_GetMessage(
const struct upb_Message* msg, const upb_MiniTableField* f) {
uintptr_t tagged = upb_Message_GetTaggedMessagePtr(msg, f, NULL);
return upb_TaggedMessagePtr_GetNonEmptyMessage(tagged);
}
UPB_API_INLINE upb_Array* upb_Message_GetMutableArray(
struct upb_Message* msg, const upb_MiniTableField* f) {
UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(f);
@ -3018,6 +3045,11 @@ UPB_API_INLINE struct upb_Map* upb_Message_GetMutableMap(
return (struct upb_Map*)upb_Message_GetMap(msg, f);
}
UPB_API_INLINE struct upb_Message* upb_Message_GetMutableMessage(
struct upb_Message* msg, const upb_MiniTableField* f) {
return (struct upb_Message*)upb_Message_GetMessage(msg, f);
}
UPB_API_INLINE upb_Array* upb_Message_GetOrCreateMutableArray(
struct upb_Message* msg, const upb_MiniTableField* f, upb_Arena* arena) {
UPB_ASSERT(arena);
@ -3191,6 +3223,16 @@ UPB_API_INLINE bool upb_Message_SetInt64(struct upb_Message* msg,
return UPB_PRIVATE(_upb_Message_SetField)(msg, f, val, a);
}
// Sets the value of a message-typed field. The mini_tables of `msg` and
// `sub_message` must have been linked for this to work correctly.
UPB_API_INLINE void upb_Message_SetMessage(struct upb_Message* msg,
const upb_MiniTable* m,
const upb_MiniTableField* f,
struct upb_Message* sub_message) {
UPB_PRIVATE(_upb_Message_SetTaggedMessagePtr)
(msg, f, UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(sub_message, false));
}
// Sets the value of a `string` or `bytes` field. The bytes of the value are not
// copied, so it is the caller's responsibility to ensure that they remain valid
// for the lifetime of `msg`. That might be done by copying them into the given
@ -3506,41 +3548,6 @@ UPB_API_INLINE upb_Message* upb_TaggedMessagePtr_GetNonEmptyMessage(
#endif /* UPB_MINI_TABLE_TAGGED_PTR_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
// Constructors
UPB_API_INLINE upb_MiniTableSub
upb_MiniTableSub_FromEnum(const upb_MiniTableEnum* subenum);
UPB_API_INLINE upb_MiniTableSub
upb_MiniTableSub_FromMessage(const upb_MiniTable* submsg);
// Getters
UPB_API_INLINE const upb_MiniTableEnum* upb_MiniTableSub_Enum(
upb_MiniTableSub sub);
UPB_API_INLINE const upb_MiniTable* upb_MiniTableSub_Message(
upb_MiniTableSub sub);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* UPB_MINI_TABLE_SUB_H_ */
// Must be last.
#ifdef __cplusplus
@ -3583,6 +3590,10 @@ UPB_API_INLINE upb_MessageValue
upb_Message_GetField(const upb_Message* msg, const upb_MiniTableField* f,
upb_MessageValue default_val);
UPB_API_INLINE upb_TaggedMessagePtr upb_Message_GetTaggedMessagePtr(
const upb_Message* msg, const upb_MiniTableField* field,
upb_Message* default_val);
UPB_API_INLINE const upb_Array* upb_Message_GetArray(
const upb_Message* msg, const upb_MiniTableField* f);
@ -3609,12 +3620,18 @@ UPB_API_INLINE int64_t upb_Message_GetInt64(const upb_Message* msg,
UPB_API_INLINE const upb_Map* upb_Message_GetMap(const upb_Message* msg,
const upb_MiniTableField* f);
UPB_API_INLINE const upb_Message* upb_Message_GetMessage(
const upb_Message* msg, const upb_MiniTableField* f);
UPB_API_INLINE upb_Array* upb_Message_GetMutableArray(
upb_Message* msg, const upb_MiniTableField* f);
UPB_API_INLINE upb_Map* upb_Message_GetMutableMap(upb_Message* msg,
const upb_MiniTableField* f);
UPB_API_INLINE upb_Message* upb_Message_GetMutableMessage(
upb_Message* msg, const upb_MiniTableField* f);
UPB_API_INLINE upb_Array* upb_Message_GetOrCreateMutableArray(
upb_Message* msg, const upb_MiniTableField* f, upb_Arena* arena);
@ -3662,6 +3679,11 @@ UPB_API_INLINE bool upb_Message_SetInt64(upb_Message* msg,
const upb_MiniTableField* f,
int64_t value, upb_Arena* a);
UPB_API_INLINE void upb_Message_SetMessage(upb_Message* msg,
const upb_MiniTable* m,
const upb_MiniTableField* f,
upb_Message* sub_message);
UPB_API_INLINE bool upb_Message_SetString(upb_Message* msg,
const upb_MiniTableField* f,
upb_StringView value, upb_Arena* a);
@ -3674,55 +3696,6 @@ UPB_API_INLINE bool upb_Message_SetUInt64(upb_Message* msg,
const upb_MiniTableField* f,
uint64_t value, upb_Arena* a);
UPB_API_INLINE upb_TaggedMessagePtr upb_Message_GetTaggedMessagePtr(
const upb_Message* msg, const upb_MiniTableField* field,
upb_Message* default_val) {
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Message);
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) ==
UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte));
UPB_ASSUME(upb_MiniTableField_IsScalar(field));
upb_TaggedMessagePtr tagged;
_upb_Message_GetNonExtensionField(msg, field, &default_val, &tagged);
return tagged;
}
UPB_API_INLINE const upb_Message* upb_Message_GetMessage(
const upb_Message* msg, const upb_MiniTableField* field) {
upb_TaggedMessagePtr tagged =
upb_Message_GetTaggedMessagePtr(msg, field, NULL);
return upb_TaggedMessagePtr_GetNonEmptyMessage(tagged);
}
UPB_API_INLINE upb_Message* upb_Message_GetMutableMessage(
upb_Message* msg, const upb_MiniTableField* field) {
return (upb_Message*)upb_Message_GetMessage(msg, field);
}
// For internal use only; users cannot set tagged messages because only the
// parser and the message copier are allowed to directly create an empty
// message.
UPB_INLINE void UPB_PRIVATE(_upb_Message_SetTaggedMessagePtr)(
struct upb_Message* msg, const upb_MiniTable* mini_table,
const upb_MiniTableField* f, upb_TaggedMessagePtr sub_message) {
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Message);
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) ==
UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte));
UPB_ASSUME(upb_MiniTableField_IsScalar(f));
upb_Message_SetBaseField(msg, f, &sub_message);
}
// Sets the value of a message-typed field. The `mini_table` and `field`
// parameters belong to `msg`, not `sub_message`. The mini_tables of `msg` and
// `sub_message` must have been linked for this to work correctly.
UPB_API_INLINE void upb_Message_SetMessage(upb_Message* msg,
const upb_MiniTable* mini_table,
const upb_MiniTableField* field,
upb_Message* sub_message) {
UPB_PRIVATE(_upb_Message_SetTaggedMessagePtr)
(msg, mini_table, field,
UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(sub_message, false));
}
UPB_API_INLINE void* upb_Message_ResizeArrayUninitialized(
upb_Message* msg, const upb_MiniTableField* f, size_t size,
upb_Arena* arena);
@ -3795,6 +3768,41 @@ UPB_INLINE void _upb_msg_map_set_value(void* msg, const void* val,
#define UPB_MINI_TABLE_DECODE_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
// Constructors
UPB_API_INLINE upb_MiniTableSub
upb_MiniTableSub_FromEnum(const upb_MiniTableEnum* subenum);
UPB_API_INLINE upb_MiniTableSub
upb_MiniTableSub_FromMessage(const upb_MiniTable* submsg);
// Getters
UPB_API_INLINE const upb_MiniTableEnum* upb_MiniTableSub_Enum(
upb_MiniTableSub sub);
UPB_API_INLINE const upb_MiniTable* upb_MiniTableSub_Message(
upb_MiniTableSub sub);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* UPB_MINI_TABLE_SUB_H_ */
// Export the newer headers, for legacy users. New users should include the
// more specific headers directly.
// IWYU pragma: begin_exports

Loading…
Cancel
Save