Rename 'length delimited' to 'length prefixed'

PiperOrigin-RevId: 621597812
pull/16404/head
Protobuf Team Bot 8 months ago committed by Copybara-Service
parent 19417f19ae
commit d5a435fb4b
  1. 12
      upb/message/test.cc
  2. 4
      upb/test/BUILD
  3. 8
      upb/test/length_prefixed_test.cc
  4. 2
      upb/wire/decode.c
  5. 2
      upb/wire/decode.h
  6. 2
      upb/wire/encode.c
  7. 7
      upb/wire/encode.h

@ -588,7 +588,7 @@ TEST(MessageTest, Freeze) {
//
// static void DecodeEncodeArbitrarySchemaAndPayload(
// const upb::fuzz::MiniTableFuzzInput& input, std::string_view proto_payload,
// int decode_options, int encode_options, bool length_delimited = false) {
// int decode_options, int encode_options, bool length_prefixed = false) {
// // Lexan does not have setenv
// #ifndef _MSC_VER
// setenv("FUZZTEST_STACK_LIMIT", "262144", 1);
@ -605,9 +605,9 @@ TEST(MessageTest, Freeze) {
// upb::fuzz::BuildMiniTable(input, &exts, arena.ptr());
// if (!mini_table) return;
// upb_Message* msg = upb_Message_New(mini_table, arena.ptr());
// if (length_delimited) {
// if (length_prefixed) {
// size_t num_bytes_read = 0;
// upb_DecodeStatus status = upb_DecodeLengthDelimited(
// upb_DecodeStatus status = upb_DecodeLengthPrefixed(
// proto_payload.data(), proto_payload.size(), msg, &num_bytes_read,
// mini_table, exts, decode_options, arena.ptr());
// ASSERT_TRUE(status != kUpb_DecodeStatus_Ok ||
@ -618,9 +618,9 @@ TEST(MessageTest, Freeze) {
// }
// char* ptr;
// size_t size;
// if (length_delimited) {
// upb_EncodeLengthDelimited(msg, mini_table, encode_options, arena.ptr(),
// &ptr, &size);
// if (length_prefixed) {
// upb_EncodeLengthPrefixed(msg, mini_table, encode_options, arena.ptr(), &ptr,
// &size);
// } else {
// upb_Encode(msg, mini_table, encode_options, arena.ptr(), &ptr, &size);
// }

@ -202,8 +202,8 @@ cc_test(
)
cc_test(
name = "length_delimited_test",
srcs = ["length_delimited_test.cc"],
name = "length_prefixed_test",
srcs = ["length_prefixed_test.cc"],
copts = UPB_DEFAULT_CPPOPTS,
deps = [
":test_messages_proto2_upb_minitable",

@ -28,7 +28,7 @@ static void TestEncodeDecodeRoundTrip(
for (auto msg : msgs) {
char* buf;
size_t size;
ASSERT_TRUE(upb_EncodeLengthDelimited(UPB_UPCAST(msg), kTestMiniTable, 0,
ASSERT_TRUE(upb_EncodeLengthPrefixed(UPB_UPCAST(msg), kTestMiniTable, 0,
arena, &buf,
&size) == kUpb_EncodeStatus_Ok);
ASSERT_GT(size, 0); // Even empty messages are 1 byte in this encoding.
@ -41,7 +41,7 @@ static void TestEncodeDecodeRoundTrip(
protobuf_test_messages_proto2_TestAllTypesProto2* msg =
protobuf_test_messages_proto2_TestAllTypesProto2_new(arena);
size_t num_bytes_read;
ASSERT_TRUE(upb_DecodeLengthDelimited(
ASSERT_TRUE(upb_DecodeLengthPrefixed(
s.data(), s.length(), UPB_UPCAST(msg), &num_bytes_read,
kTestMiniTable, nullptr, 0, arena) == kUpb_DecodeStatus_Ok);
ASSERT_GT(num_bytes_read, 0);
@ -57,7 +57,7 @@ static void TestEncodeDecodeRoundTrip(
}
}
TEST(LengthDelimitedTest, OneEmptyMessage) {
TEST(LengthPrefixedTest, OneEmptyMessage) {
upb_Arena* arena = upb_Arena_New();
protobuf_test_messages_proto2_TestAllTypesProto2* msg =
protobuf_test_messages_proto2_TestAllTypesProto2_new(arena);
@ -65,7 +65,7 @@ TEST(LengthDelimitedTest, OneEmptyMessage) {
upb_Arena_Free(arena);
}
TEST(LengthDelimitedTest, AFewMessages) {
TEST(LengthPrefixedTest, AFewMessages) {
upb_Arena* arena = upb_Arena_New();
protobuf_test_messages_proto2_TestAllTypesProto2* a =
protobuf_test_messages_proto2_TestAllTypesProto2_new(arena);

@ -1394,7 +1394,7 @@ upb_DecodeStatus upb_Decode(const char* buf, size_t size, upb_Message* msg,
return upb_Decoder_Decode(&decoder, buf, msg, mt, arena);
}
upb_DecodeStatus upb_DecodeLengthDelimited(const char* buf, size_t size,
upb_DecodeStatus upb_DecodeLengthPrefixed(const char* buf, size_t size,
upb_Message* msg,
size_t* num_bytes_read,
const upb_MiniTable* mt,

@ -136,7 +136,7 @@ UPB_API upb_DecodeStatus upb_Decode(const char* buf, size_t size,
// Same as upb_Decode but with a varint-encoded length prepended.
// On success 'num_bytes_read' will be set to the how many bytes were read,
// on failure the contents of num_bytes_read is undefined.
UPB_API upb_DecodeStatus upb_DecodeLengthDelimited(
UPB_API upb_DecodeStatus upb_DecodeLengthPrefixed(
const char* buf, size_t size, upb_Message* msg, size_t* num_bytes_read,
const upb_MiniTable* mt, const upb_ExtensionRegistry* extreg, int options,
upb_Arena* arena);

@ -662,7 +662,7 @@ upb_EncodeStatus upb_Encode(const upb_Message* msg, const upb_MiniTable* l,
return _upb_Encode(msg, l, options, arena, buf, size, false);
}
upb_EncodeStatus upb_EncodeLengthDelimited(const upb_Message* msg,
upb_EncodeStatus upb_EncodeLengthPrefixed(const upb_Message* msg,
const upb_MiniTable* l, int options,
upb_Arena* arena, char** buf,
size_t* size) {

@ -69,11 +69,10 @@ UPB_API upb_EncodeStatus upb_Encode(const upb_Message* msg,
upb_Arena* arena, char** buf, size_t* size);
// Encodes the message prepended by a varint of the serialized length.
UPB_API upb_EncodeStatus upb_EncodeLengthDelimited(const upb_Message* msg,
UPB_API upb_EncodeStatus upb_EncodeLengthPrefixed(const upb_Message* msg,
const upb_MiniTable* l,
int options,
upb_Arena* arena, char** buf,
size_t* size);
int options, upb_Arena* arena,
char** buf, size_t* size);
#ifdef __cplusplus
} /* extern "C" */

Loading…
Cancel
Save