|
|
@ -220,7 +220,6 @@ UPB_INLINE bool UPB_PRIVATE(_upb_MiniTableField_DataIsZero)( |
|
|
|
// const upb_MiniTableField* field,
|
|
|
|
// const upb_MiniTableField* field,
|
|
|
|
// bool value, upb_Arena* a) {
|
|
|
|
// bool value, upb_Arena* a) {
|
|
|
|
// UPB_ASSUME(field->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Bool);
|
|
|
|
// UPB_ASSUME(field->UPB_PRIVATE(descriptortype) == kUpb_FieldType_Bool);
|
|
|
|
// UPB_ASSUME(upb_MiniTableField_IsScalar(field));
|
|
|
|
|
|
|
|
// UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) ==
|
|
|
|
// UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(field) ==
|
|
|
|
// kUpb_FieldRep_1Byte);
|
|
|
|
// kUpb_FieldRep_1Byte);
|
|
|
|
// upb_Message_SetField(msg, field, &value, a);
|
|
|
|
// upb_Message_SetField(msg, field, &value, a);
|
|
|
@ -351,8 +350,8 @@ UPB_API_INLINE bool upb_Message_GetBool(const struct upb_Message* msg, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
bool default_val) { |
|
|
|
bool default_val) { |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Bool); |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Bool); |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_1Byte); |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_1Byte); |
|
|
|
upb_MessageValue def; |
|
|
|
upb_MessageValue def; |
|
|
|
def.bool_val = default_val; |
|
|
|
def.bool_val = default_val; |
|
|
|
return upb_Message_GetField(msg, f, def).bool_val; |
|
|
|
return upb_Message_GetField(msg, f, def).bool_val; |
|
|
@ -362,8 +361,8 @@ UPB_API_INLINE double upb_Message_GetDouble(const struct upb_Message* msg, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
double default_val) { |
|
|
|
double default_val) { |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Double); |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Double); |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_8Byte); |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_8Byte); |
|
|
|
|
|
|
|
|
|
|
|
upb_MessageValue def; |
|
|
|
upb_MessageValue def; |
|
|
|
def.double_val = default_val; |
|
|
|
def.double_val = default_val; |
|
|
@ -374,8 +373,8 @@ UPB_API_INLINE float upb_Message_GetFloat(const struct upb_Message* msg, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
float default_val) { |
|
|
|
float default_val) { |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Float); |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Float); |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte); |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte); |
|
|
|
|
|
|
|
|
|
|
|
upb_MessageValue def; |
|
|
|
upb_MessageValue def; |
|
|
|
def.float_val = default_val; |
|
|
|
def.float_val = default_val; |
|
|
@ -387,8 +386,8 @@ UPB_API_INLINE int32_t upb_Message_GetInt32(const struct upb_Message* msg, |
|
|
|
int32_t default_val) { |
|
|
|
int32_t default_val) { |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Int32 || |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Int32 || |
|
|
|
upb_MiniTableField_CType(f) == kUpb_CType_Enum); |
|
|
|
upb_MiniTableField_CType(f) == kUpb_CType_Enum); |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte); |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte); |
|
|
|
|
|
|
|
|
|
|
|
upb_MessageValue def; |
|
|
|
upb_MessageValue def; |
|
|
|
def.int32_val = default_val; |
|
|
|
def.int32_val = default_val; |
|
|
@ -399,8 +398,8 @@ UPB_API_INLINE int64_t upb_Message_GetInt64(const struct upb_Message* msg, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
int64_t default_val) { |
|
|
|
int64_t default_val) { |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Int64); |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Int64); |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_8Byte); |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_8Byte); |
|
|
|
|
|
|
|
|
|
|
|
upb_MessageValue def; |
|
|
|
upb_MessageValue def; |
|
|
|
def.int64_val = default_val; |
|
|
|
def.int64_val = default_val; |
|
|
@ -551,7 +550,6 @@ upb_Message_GetString(const struct upb_Message* msg, |
|
|
|
upb_MiniTableField_CType(f) == kUpb_CType_Bytes); |
|
|
|
upb_MiniTableField_CType(f) == kUpb_CType_Bytes); |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == |
|
|
|
kUpb_FieldRep_StringView); |
|
|
|
kUpb_FieldRep_StringView); |
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
upb_MessageValue def; |
|
|
|
upb_MessageValue def; |
|
|
|
def.str_val = default_val; |
|
|
|
def.str_val = default_val; |
|
|
@ -562,8 +560,8 @@ UPB_API_INLINE uint32_t upb_Message_GetUInt32(const struct upb_Message* msg, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
uint32_t default_val) { |
|
|
|
uint32_t default_val) { |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_UInt32); |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_UInt32); |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte); |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte); |
|
|
|
|
|
|
|
|
|
|
|
upb_MessageValue def; |
|
|
|
upb_MessageValue def; |
|
|
|
def.uint32_val = default_val; |
|
|
|
def.uint32_val = default_val; |
|
|
@ -574,23 +572,89 @@ UPB_API_INLINE uint64_t upb_Message_GetUInt64(const struct upb_Message* msg, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
uint64_t default_val) { |
|
|
|
uint64_t default_val) { |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_UInt64); |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_UInt64); |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_8Byte); |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_8Byte); |
|
|
|
|
|
|
|
|
|
|
|
upb_MessageValue def; |
|
|
|
upb_MessageValue def; |
|
|
|
def.uint64_val = default_val; |
|
|
|
def.uint64_val = default_val; |
|
|
|
return upb_Message_GetField(msg, f, def).uint64_val; |
|
|
|
return upb_Message_GetField(msg, f, def).uint64_val; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_Message_SetBool(struct upb_Message* msg, |
|
|
|
// BaseField Setters ///////////////////////////////////////////////////////////
|
|
|
|
const upb_MiniTableField* f, bool value, |
|
|
|
|
|
|
|
upb_Arena* a) { |
|
|
|
UPB_API_INLINE void upb_Message_SetBaseFieldBool(struct upb_Message* msg, |
|
|
|
|
|
|
|
const upb_MiniTableField* f, |
|
|
|
|
|
|
|
bool value) { |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Bool); |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Bool); |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_1Byte); |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_1Byte); |
|
|
|
|
|
|
|
upb_Message_SetBaseField(msg, f, &value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE void upb_Message_SetBaseFieldDouble(struct upb_Message* msg, |
|
|
|
|
|
|
|
const upb_MiniTableField* f, |
|
|
|
|
|
|
|
double value) { |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Double); |
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
upb_MessageValue val; |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_8Byte); |
|
|
|
val.bool_val = value; |
|
|
|
upb_Message_SetBaseField(msg, f, &value); |
|
|
|
return UPB_PRIVATE(_upb_Message_SetField)(msg, f, val, a); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE void upb_Message_SetBaseFieldFloat(struct upb_Message* msg, |
|
|
|
|
|
|
|
const upb_MiniTableField* f, |
|
|
|
|
|
|
|
float value) { |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Float); |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte); |
|
|
|
|
|
|
|
upb_Message_SetBaseField(msg, f, &value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE void upb_Message_SetBaseFieldInt32(struct upb_Message* msg, |
|
|
|
|
|
|
|
const upb_MiniTableField* f, |
|
|
|
|
|
|
|
int32_t value) { |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Int32 || |
|
|
|
|
|
|
|
upb_MiniTableField_CType(f) == kUpb_CType_Enum); |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte); |
|
|
|
|
|
|
|
upb_Message_SetBaseField(msg, f, &value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE void upb_Message_SetBaseFieldInt64(struct upb_Message* msg, |
|
|
|
|
|
|
|
const upb_MiniTableField* f, |
|
|
|
|
|
|
|
int64_t value) { |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Int64); |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_8Byte); |
|
|
|
|
|
|
|
upb_Message_SetBaseField(msg, f, &value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE void upb_Message_SetBaseFieldString(struct upb_Message* msg, |
|
|
|
|
|
|
|
const upb_MiniTableField* f, |
|
|
|
|
|
|
|
upb_StringView value) { |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_String || |
|
|
|
|
|
|
|
upb_MiniTableField_CType(f) == kUpb_CType_Bytes); |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == |
|
|
|
|
|
|
|
kUpb_FieldRep_StringView); |
|
|
|
|
|
|
|
upb_Message_SetBaseField(msg, f, &value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE void upb_Message_SetBaseFieldUInt32(struct upb_Message* msg, |
|
|
|
|
|
|
|
const upb_MiniTableField* f, |
|
|
|
|
|
|
|
uint32_t value) { |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_UInt32); |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte); |
|
|
|
|
|
|
|
upb_Message_SetBaseField(msg, f, &value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE void upb_Message_SetBaseFieldUInt64(struct upb_Message* msg, |
|
|
|
|
|
|
|
const upb_MiniTableField* f, |
|
|
|
|
|
|
|
uint64_t value) { |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_UInt64); |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_8Byte); |
|
|
|
|
|
|
|
upb_Message_SetBaseField(msg, f, &value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE void upb_Message_SetClosedEnum( |
|
|
|
UPB_API_INLINE void upb_Message_SetClosedEnum( |
|
|
@ -598,55 +662,132 @@ UPB_API_INLINE void upb_Message_SetClosedEnum( |
|
|
|
const upb_MiniTableField* f, int32_t value) { |
|
|
|
const upb_MiniTableField* f, int32_t value) { |
|
|
|
UPB_ASSERT(upb_MiniTableField_IsClosedEnum(f)); |
|
|
|
UPB_ASSERT(upb_MiniTableField_IsClosedEnum(f)); |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte); |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte); |
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
|
|
|
|
UPB_ASSERT(upb_MiniTableEnum_CheckValue( |
|
|
|
UPB_ASSERT(upb_MiniTableEnum_CheckValue( |
|
|
|
upb_MiniTable_GetSubEnumTable(msg_mini_table, f), value)); |
|
|
|
upb_MiniTable_GetSubEnumTable(msg_mini_table, f), value)); |
|
|
|
upb_Message_SetBaseField(msg, f, &value); |
|
|
|
upb_Message_SetBaseField(msg, f, &value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Extension Setters ///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_Message_SetExtensionBool( |
|
|
|
|
|
|
|
struct upb_Message* msg, const upb_MiniTableExtension* e, bool value, |
|
|
|
|
|
|
|
upb_Arena* a) { |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_Bool); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(e) == |
|
|
|
|
|
|
|
kUpb_FieldRep_1Byte); |
|
|
|
|
|
|
|
return upb_Message_SetExtension(msg, e, &value, a); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_Message_SetExtensionDouble( |
|
|
|
|
|
|
|
struct upb_Message* msg, const upb_MiniTableExtension* e, double value, |
|
|
|
|
|
|
|
upb_Arena* a) { |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_Double); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(e) == |
|
|
|
|
|
|
|
kUpb_FieldRep_8Byte); |
|
|
|
|
|
|
|
return upb_Message_SetExtension(msg, e, &value, a); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_Message_SetExtensionFloat( |
|
|
|
|
|
|
|
struct upb_Message* msg, const upb_MiniTableExtension* e, float value, |
|
|
|
|
|
|
|
upb_Arena* a) { |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_Float); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(e) == |
|
|
|
|
|
|
|
kUpb_FieldRep_4Byte); |
|
|
|
|
|
|
|
return upb_Message_SetExtension(msg, e, &value, a); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_Message_SetExtensionInt32( |
|
|
|
|
|
|
|
struct upb_Message* msg, const upb_MiniTableExtension* e, int32_t value, |
|
|
|
|
|
|
|
upb_Arena* a) { |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_Int32 || |
|
|
|
|
|
|
|
upb_MiniTableExtension_CType(e) == kUpb_CType_Enum); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(e) == |
|
|
|
|
|
|
|
kUpb_FieldRep_4Byte); |
|
|
|
|
|
|
|
return upb_Message_SetExtension(msg, e, &value, a); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_Message_SetExtensionInt64( |
|
|
|
|
|
|
|
struct upb_Message* msg, const upb_MiniTableExtension* e, int64_t value, |
|
|
|
|
|
|
|
upb_Arena* a) { |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_Int64); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(e) == |
|
|
|
|
|
|
|
kUpb_FieldRep_8Byte); |
|
|
|
|
|
|
|
return upb_Message_SetExtension(msg, e, &value, a); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_Message_SetExtensionString( |
|
|
|
|
|
|
|
struct upb_Message* msg, const upb_MiniTableExtension* e, |
|
|
|
|
|
|
|
upb_StringView value, upb_Arena* a) { |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_String || |
|
|
|
|
|
|
|
upb_MiniTableExtension_CType(e) == kUpb_CType_Bytes); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(e) == |
|
|
|
|
|
|
|
kUpb_FieldRep_StringView); |
|
|
|
|
|
|
|
return upb_Message_SetExtension(msg, e, &value, a); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_Message_SetExtensionUInt32( |
|
|
|
|
|
|
|
struct upb_Message* msg, const upb_MiniTableExtension* e, uint32_t value, |
|
|
|
|
|
|
|
upb_Arena* a) { |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_UInt32); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(e) == |
|
|
|
|
|
|
|
kUpb_FieldRep_4Byte); |
|
|
|
|
|
|
|
return upb_Message_SetExtension(msg, e, &value, a); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_Message_SetExtensionUInt64( |
|
|
|
|
|
|
|
struct upb_Message* msg, const upb_MiniTableExtension* e, uint64_t value, |
|
|
|
|
|
|
|
upb_Arena* a) { |
|
|
|
|
|
|
|
UPB_ASSUME(upb_MiniTableExtension_CType(e) == kUpb_CType_UInt64); |
|
|
|
|
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableExtension_GetRep)(e) == |
|
|
|
|
|
|
|
kUpb_FieldRep_8Byte); |
|
|
|
|
|
|
|
return upb_Message_SetExtension(msg, e, &value, a); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Universal Setters ///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_Message_SetBool(struct upb_Message* msg, |
|
|
|
|
|
|
|
const upb_MiniTableField* f, bool value, |
|
|
|
|
|
|
|
upb_Arena* a) { |
|
|
|
|
|
|
|
return upb_MiniTableField_IsExtension(f) |
|
|
|
|
|
|
|
? upb_Message_SetExtensionBool( |
|
|
|
|
|
|
|
msg, (const upb_MiniTableExtension*)f, value, a) |
|
|
|
|
|
|
|
: (upb_Message_SetBaseFieldBool(msg, f, value), true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_Message_SetDouble(struct upb_Message* msg, |
|
|
|
UPB_API_INLINE bool upb_Message_SetDouble(struct upb_Message* msg, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
double value, upb_Arena* a) { |
|
|
|
double value, upb_Arena* a) { |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Double); |
|
|
|
return upb_MiniTableField_IsExtension(f) |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_8Byte); |
|
|
|
? upb_Message_SetExtensionDouble( |
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
msg, (const upb_MiniTableExtension*)f, value, a) |
|
|
|
upb_MessageValue val; |
|
|
|
: (upb_Message_SetBaseFieldDouble(msg, f, value), true); |
|
|
|
val.double_val = value; |
|
|
|
|
|
|
|
return UPB_PRIVATE(_upb_Message_SetField)(msg, f, val, a); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_Message_SetFloat(struct upb_Message* msg, |
|
|
|
UPB_API_INLINE bool upb_Message_SetFloat(struct upb_Message* msg, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
float value, upb_Arena* a) { |
|
|
|
float value, upb_Arena* a) { |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Float); |
|
|
|
return upb_MiniTableField_IsExtension(f) |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte); |
|
|
|
? upb_Message_SetExtensionFloat( |
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
msg, (const upb_MiniTableExtension*)f, value, a) |
|
|
|
upb_MessageValue val; |
|
|
|
: (upb_Message_SetBaseFieldFloat(msg, f, value), true); |
|
|
|
val.float_val = value; |
|
|
|
|
|
|
|
return UPB_PRIVATE(_upb_Message_SetField)(msg, f, val, a); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_Message_SetInt32(struct upb_Message* msg, |
|
|
|
UPB_API_INLINE bool upb_Message_SetInt32(struct upb_Message* msg, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
int32_t value, upb_Arena* a) { |
|
|
|
int32_t value, upb_Arena* a) { |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Int32 || |
|
|
|
return upb_MiniTableField_IsExtension(f) |
|
|
|
upb_MiniTableField_CType(f) == kUpb_CType_Enum); |
|
|
|
? upb_Message_SetExtensionInt32( |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte); |
|
|
|
msg, (const upb_MiniTableExtension*)f, value, a) |
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
: (upb_Message_SetBaseFieldInt32(msg, f, value), true); |
|
|
|
upb_MessageValue val; |
|
|
|
|
|
|
|
val.int32_val = value; |
|
|
|
|
|
|
|
return UPB_PRIVATE(_upb_Message_SetField)(msg, f, val, a); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_Message_SetInt64(struct upb_Message* msg, |
|
|
|
UPB_API_INLINE bool upb_Message_SetInt64(struct upb_Message* msg, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
int64_t value, upb_Arena* a) { |
|
|
|
int64_t value, upb_Arena* a) { |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_Int64); |
|
|
|
return upb_MiniTableField_IsExtension(f) |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_8Byte); |
|
|
|
? upb_Message_SetExtensionInt64( |
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
msg, (const upb_MiniTableExtension*)f, value, a) |
|
|
|
upb_MessageValue val; |
|
|
|
: (upb_Message_SetBaseFieldInt64(msg, f, value), true); |
|
|
|
val.int64_val = value; |
|
|
|
|
|
|
|
return UPB_PRIVATE(_upb_Message_SetField)(msg, f, val, a); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Sets the value of a message-typed field. The mini_tables of `msg` and
|
|
|
|
// Sets the value of a message-typed field. The mini_tables of `msg` and
|
|
|
@ -666,36 +807,28 @@ UPB_API_INLINE void upb_Message_SetMessage(struct upb_Message* msg, |
|
|
|
UPB_API_INLINE bool upb_Message_SetString(struct upb_Message* msg, |
|
|
|
UPB_API_INLINE bool upb_Message_SetString(struct upb_Message* msg, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
upb_StringView value, upb_Arena* a) { |
|
|
|
upb_StringView value, upb_Arena* a) { |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_String || |
|
|
|
return upb_MiniTableField_IsExtension(f) |
|
|
|
upb_MiniTableField_CType(f) == kUpb_CType_Bytes); |
|
|
|
? upb_Message_SetExtensionString( |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == |
|
|
|
msg, (const upb_MiniTableExtension*)f, value, a) |
|
|
|
kUpb_FieldRep_StringView); |
|
|
|
: (upb_Message_SetBaseFieldString(msg, f, value), true); |
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
|
|
|
|
upb_MessageValue val; |
|
|
|
|
|
|
|
val.str_val = value; |
|
|
|
|
|
|
|
return UPB_PRIVATE(_upb_Message_SetField)(msg, f, val, a); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_Message_SetUInt32(struct upb_Message* msg, |
|
|
|
UPB_API_INLINE bool upb_Message_SetUInt32(struct upb_Message* msg, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
uint32_t value, upb_Arena* a) { |
|
|
|
uint32_t value, upb_Arena* a) { |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_UInt32); |
|
|
|
return upb_MiniTableField_IsExtension(f) |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_4Byte); |
|
|
|
? upb_Message_SetExtensionUInt32( |
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
msg, (const upb_MiniTableExtension*)f, value, a) |
|
|
|
upb_MessageValue val; |
|
|
|
: (upb_Message_SetBaseFieldUInt32(msg, f, value), true); |
|
|
|
val.uint32_val = value; |
|
|
|
|
|
|
|
return UPB_PRIVATE(_upb_Message_SetField)(msg, f, val, a); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE bool upb_Message_SetUInt64(struct upb_Message* msg, |
|
|
|
UPB_API_INLINE bool upb_Message_SetUInt64(struct upb_Message* msg, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
const upb_MiniTableField* f, |
|
|
|
uint64_t value, upb_Arena* a) { |
|
|
|
uint64_t value, upb_Arena* a) { |
|
|
|
UPB_ASSUME(upb_MiniTableField_CType(f) == kUpb_CType_UInt64); |
|
|
|
return upb_MiniTableField_IsExtension(f) |
|
|
|
UPB_ASSUME(UPB_PRIVATE(_upb_MiniTableField_GetRep)(f) == kUpb_FieldRep_8Byte); |
|
|
|
? upb_Message_SetExtensionUInt64( |
|
|
|
UPB_ASSUME(upb_MiniTableField_IsScalar(f)); |
|
|
|
msg, (const upb_MiniTableExtension*)f, value, a) |
|
|
|
upb_MessageValue val; |
|
|
|
: (upb_Message_SetBaseFieldUInt64(msg, f, value), true); |
|
|
|
val.uint64_val = value; |
|
|
|
|
|
|
|
return UPB_PRIVATE(_upb_Message_SetField)(msg, f, val, a); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UPB_API_INLINE void upb_Message_Clear(struct upb_Message* msg, |
|
|
|
UPB_API_INLINE void upb_Message_Clear(struct upb_Message* msg, |
|
|
|