|
|
@ -15,6 +15,7 @@ |
|
|
|
#include <string.h> |
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
|
|
|
|
#include "upb/base/descriptor_constants.h" |
|
|
|
#include "upb/base/descriptor_constants.h" |
|
|
|
|
|
|
|
#include "upb/base/internal/endian.h" |
|
|
|
#include "upb/base/string_view.h" |
|
|
|
#include "upb/base/string_view.h" |
|
|
|
#include "upb/hash/common.h" |
|
|
|
#include "upb/hash/common.h" |
|
|
|
#include "upb/hash/str_table.h" |
|
|
|
#include "upb/hash/str_table.h" |
|
|
@ -37,7 +38,6 @@ |
|
|
|
#include "upb/mini_table/message.h" |
|
|
|
#include "upb/mini_table/message.h" |
|
|
|
#include "upb/mini_table/sub.h" |
|
|
|
#include "upb/mini_table/sub.h" |
|
|
|
#include "upb/wire/internal/constants.h" |
|
|
|
#include "upb/wire/internal/constants.h" |
|
|
|
#include "upb/wire/internal/endian.h" |
|
|
|
|
|
|
|
#include "upb/wire/types.h" |
|
|
|
#include "upb/wire/types.h" |
|
|
|
|
|
|
|
|
|
|
|
// Must be last.
|
|
|
|
// Must be last.
|
|
|
@ -130,12 +130,12 @@ static void encode_bytes(upb_encstate* e, const void* data, size_t len) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void encode_fixed64(upb_encstate* e, uint64_t val) { |
|
|
|
static void encode_fixed64(upb_encstate* e, uint64_t val) { |
|
|
|
val = UPB_PRIVATE(_upb_BigEndian64)(val); |
|
|
|
val = upb_BigEndian64(val); |
|
|
|
encode_bytes(e, &val, sizeof(uint64_t)); |
|
|
|
encode_bytes(e, &val, sizeof(uint64_t)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void encode_fixed32(upb_encstate* e, uint32_t val) { |
|
|
|
static void encode_fixed32(upb_encstate* e, uint32_t val) { |
|
|
|
val = UPB_PRIVATE(_upb_BigEndian32)(val); |
|
|
|
val = upb_BigEndian32(val); |
|
|
|
encode_bytes(e, &val, sizeof(uint32_t)); |
|
|
|
encode_bytes(e, &val, sizeof(uint32_t)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -186,18 +186,18 @@ static void encode_fixedarray(upb_encstate* e, const upb_Array* arr, |
|
|
|
const char* data = _upb_array_constptr(arr); |
|
|
|
const char* data = _upb_array_constptr(arr); |
|
|
|
const char* ptr = data + bytes - elem_size; |
|
|
|
const char* ptr = data + bytes - elem_size; |
|
|
|
|
|
|
|
|
|
|
|
if (tag || !UPB_PRIVATE(_upb_IsLittleEndian)()) { |
|
|
|
if (tag || !upb_IsLittleEndian()) { |
|
|
|
while (true) { |
|
|
|
while (true) { |
|
|
|
if (elem_size == 4) { |
|
|
|
if (elem_size == 4) { |
|
|
|
uint32_t val; |
|
|
|
uint32_t val; |
|
|
|
memcpy(&val, ptr, sizeof(val)); |
|
|
|
memcpy(&val, ptr, sizeof(val)); |
|
|
|
val = UPB_PRIVATE(_upb_BigEndian32)(val); |
|
|
|
val = upb_BigEndian32(val); |
|
|
|
encode_bytes(e, &val, elem_size); |
|
|
|
encode_bytes(e, &val, elem_size); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
UPB_ASSERT(elem_size == 8); |
|
|
|
UPB_ASSERT(elem_size == 8); |
|
|
|
uint64_t val; |
|
|
|
uint64_t val; |
|
|
|
memcpy(&val, ptr, sizeof(val)); |
|
|
|
memcpy(&val, ptr, sizeof(val)); |
|
|
|
val = UPB_PRIVATE(_upb_BigEndian64)(val); |
|
|
|
val = upb_BigEndian64(val); |
|
|
|
encode_bytes(e, &val, elem_size); |
|
|
|
encode_bytes(e, &val, elem_size); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -552,7 +552,7 @@ static void encode_message(upb_encstate* e, const upb_Message* msg, |
|
|
|
m->UPB_PRIVATE(required_count)) { |
|
|
|
m->UPB_PRIVATE(required_count)) { |
|
|
|
uint64_t msg_head; |
|
|
|
uint64_t msg_head; |
|
|
|
memcpy(&msg_head, msg, 8); |
|
|
|
memcpy(&msg_head, msg, 8); |
|
|
|
msg_head = UPB_PRIVATE(_upb_BigEndian64)(msg_head); |
|
|
|
msg_head = upb_BigEndian64(msg_head); |
|
|
|
if (UPB_PRIVATE(_upb_MiniTable_RequiredMask)(m) & ~msg_head) { |
|
|
|
if (UPB_PRIVATE(_upb_MiniTable_RequiredMask)(m) & ~msg_head) { |
|
|
|
encode_err(e, kUpb_EncodeStatus_MissingRequired); |
|
|
|
encode_err(e, kUpb_EncodeStatus_MissingRequired); |
|
|
|
} |
|
|
|
} |
|
|
|