remove 'platform' param from upb_MiniTable_Build()

_upb_MiniTable_Build() is now the general version of the function;
upb_MiniTable_Build() calls it and sets the platform to default/native.

PiperOrigin-RevId: 491091021
pull/13171/head
Eric Salo 2 years ago committed by Copybara-Service
parent 0a2c988286
commit 32f28fcdc6
  1. 6
      upb/fuzz_test_util.cc
  2. 3
      upb/message/accessors_test.cc
  3. 2
      upb/mini_table/decode.c
  4. 9
      upb/mini_table/decode.h
  5. 20
      upb/mini_table/encode_test.cc
  6. 6
      upbc/file_layout.cc

@ -87,10 +87,8 @@ void Builder::BuildMessages() {
upb::Status status;
mini_tables_.reserve(input_->mini_descriptors.size());
for (const auto& d : input_->mini_descriptors) {
upb_MiniTable* table;
table =
upb_MiniTable_Build(d.data(), d.size(), kUpb_MiniTablePlatform_Native,
arena_, status.ptr());
upb_MiniTable* table =
upb_MiniTable_Build(d.data(), d.size(), arena_, status.ptr());
if (table) mini_tables_.push_back(table);
}
}

@ -569,8 +569,7 @@ upb_MiniTable* CreateMiniTableWithEmptySubTables(upb_Arena* arena) {
upb_Status status;
upb_Status_Clear(&status);
upb_MiniTable* table =
upb_MiniTable_Build(e.data().data(), e.data().size(),
kUpb_MiniTablePlatform_Native, arena, &status);
upb_MiniTable_Build(e.data().data(), e.data().size(), arena, &status);
EXPECT_EQ(status.ok, true);
// Initialize sub table to null. Not using upb_MiniTable_SetSubMessage
// since it checks ->ext on parameter.

@ -930,7 +930,7 @@ const char* _upb_MiniTableExtension_Build(const char* data, size_t len,
return ret;
}
upb_MiniTable* upb_MiniTable_Build(const char* data, size_t len,
upb_MiniTable* _upb_MiniTable_Build(const char* data, size_t len,
upb_MiniTablePlatform platform,
upb_Arena* arena, upb_Status* status) {
void* buf = NULL;

@ -50,10 +50,17 @@ extern "C" {
// errors occur, returns NULL and sets a status message. In the success case,
// the caller must call upb_MiniTable_SetSub*() for all message or proto2 enum
// fields to link the table to the appropriate sub-tables.
upb_MiniTable* upb_MiniTable_Build(const char* data, size_t len,
upb_MiniTable* _upb_MiniTable_Build(const char* data, size_t len,
upb_MiniTablePlatform platform,
upb_Arena* arena, upb_Status* status);
UPB_INLINE upb_MiniTable* upb_MiniTable_Build(const char* data, size_t len,
upb_Arena* arena,
upb_Status* status) {
return _upb_MiniTable_Build(data, len, kUpb_MiniTablePlatform_Native, arena,
status);
}
// Links a sub-message field to a MiniTable for that sub-message. If a
// sub-message field is not linked, it will be treated as an unknown field
// during parsing, and setting the field will not be allowed. It is possible

@ -49,7 +49,7 @@ TEST_P(MiniTableTest, Empty) {
upb::Arena arena;
upb::Status status;
upb_MiniTable* table =
upb_MiniTable_Build(NULL, 0, GetParam(), arena.ptr(), status.ptr());
_upb_MiniTable_Build(NULL, 0, GetParam(), arena.ptr(), status.ptr());
ASSERT_NE(nullptr, table);
EXPECT_EQ(0, table->field_count);
EXPECT_EQ(0, table->required_count);
@ -65,7 +65,7 @@ TEST_P(MiniTableTest, AllScalarTypes) {
count++;
}
upb::Status status;
upb_MiniTable* table = upb_MiniTable_Build(
upb_MiniTable* table = _upb_MiniTable_Build(
e.data().data(), e.data().size(), GetParam(), arena.ptr(), status.ptr());
ASSERT_NE(nullptr, table);
EXPECT_EQ(count, table->field_count);
@ -91,7 +91,7 @@ TEST_P(MiniTableTest, AllRepeatedTypes) {
count++;
}
upb::Status status;
upb_MiniTable* table = upb_MiniTable_Build(
upb_MiniTable* table = _upb_MiniTable_Build(
e.data().data(), e.data().size(), GetParam(), arena.ptr(), status.ptr());
ASSERT_NE(nullptr, table);
EXPECT_EQ(count, table->field_count);
@ -119,7 +119,7 @@ TEST_P(MiniTableTest, Skips) {
count++;
}
upb::Status status;
upb_MiniTable* table = upb_MiniTable_Build(
upb_MiniTable* table = _upb_MiniTable_Build(
e.data().data(), e.data().size(), GetParam(), arena.ptr(), status.ptr());
ASSERT_NE(nullptr, table);
EXPECT_EQ(count, table->field_count);
@ -149,7 +149,7 @@ TEST_P(MiniTableTest, AllScalarTypesOneof) {
ASSERT_TRUE(e.PutOneofField(i));
}
upb::Status status;
upb_MiniTable* table = upb_MiniTable_Build(
upb_MiniTable* table = _upb_MiniTable_Build(
e.data().data(), e.data().size(), GetParam(), arena.ptr(), status.ptr());
ASSERT_NE(nullptr, table) << status.error_message();
EXPECT_EQ(count, table->field_count);
@ -182,7 +182,7 @@ TEST_P(MiniTableTest, SizeOverflow) {
ASSERT_TRUE(e.PutField(kUpb_FieldType_Double, i, 0));
}
upb::Status status;
upb_MiniTable* table = upb_MiniTable_Build(
upb_MiniTable* table = _upb_MiniTable_Build(
e.data().data(), e.data().size(), GetParam(), arena.ptr(), status.ptr());
ASSERT_NE(nullptr, table) << status.error_message();
@ -191,7 +191,7 @@ TEST_P(MiniTableTest, SizeOverflow) {
for (size_t i = 1; i < max_double_fields + 2; i++) {
ASSERT_TRUE(e.PutField(kUpb_FieldType_Double, i, 0));
}
upb_MiniTable* table2 = upb_MiniTable_Build(
upb_MiniTable* table2 = _upb_MiniTable_Build(
e.data().data(), e.data().size(), GetParam(), arena.ptr(), status.ptr());
ASSERT_EQ(nullptr, table2) << status.error_message();
}
@ -244,7 +244,7 @@ TEST_P(MiniTableTest, SubsInitializedToNull) {
ASSERT_TRUE(e.PutField(kUpb_FieldType_Message, 15, 0));
ASSERT_TRUE(e.PutField(kUpb_FieldType_Message, 16, 0));
upb::Status status;
upb_MiniTable* table = upb_MiniTable_Build(
upb_MiniTable* table = _upb_MiniTable_Build(
e.data().data(), e.data().size(), GetParam(), arena.ptr(), status.ptr());
ASSERT_NE(nullptr, table);
EXPECT_EQ(table->field_count, 2);
@ -288,7 +288,7 @@ TEST_P(MiniTableTest, Extendible) {
count++;
}
upb::Status status;
upb_MiniTable* table = upb_MiniTable_Build(
upb_MiniTable* table = _upb_MiniTable_Build(
e.data().data(), e.data().size(), GetParam(), arena.ptr(), status.ptr());
ASSERT_NE(nullptr, table);
EXPECT_EQ(kUpb_ExtMode_Extendable, table->ext & kUpb_ExtMode_Extendable);
@ -299,7 +299,7 @@ TEST_P(MiniTableTest, Extendible) {
// static void BuildMiniTable(std::string_view s, bool is_32bit) {
// upb::Arena arena;
// upb::Status status;
// upb_MiniTable_Build(
// _upb_MiniTable_Build(
// s.data(), s.size(),
// is_32bit ? kUpb_MiniTablePlatform_32Bit : kUpb_MiniTablePlatform_64Bit,
// arena.ptr(), status.ptr());

@ -306,7 +306,7 @@ upb_MiniTable* FilePlatformLayout::MakeMapMiniTable(
const absl::string_view str = e.data();
upb::Status status;
upb_MiniTable* ret = upb_MiniTable_Build(str.data(), str.size(), platform_,
upb_MiniTable* ret = _upb_MiniTable_Build(str.data(), str.size(), platform_,
arena_.ptr(), status.ptr());
if (!ret) {
fprintf(stderr, "Error building mini-table: %s\n", status.error_message());
@ -322,7 +322,7 @@ upb_MiniTable* FilePlatformLayout::MakeMessageSetMiniTable(
const absl::string_view str = e.data();
upb::Status status;
upb_MiniTable* ret = upb_MiniTable_Build(str.data(), str.size(), platform_,
upb_MiniTable* ret = _upb_MiniTable_Build(str.data(), str.size(), platform_,
arena_.ptr(), status.ptr());
if (!ret) {
fprintf(stderr, "Error building mini-table: %s\n", status.error_message());
@ -349,7 +349,7 @@ upb_MiniTable* FilePlatformLayout::MakeRegularMiniTable(
}
absl::string_view str = e.data();
upb::Status status;
upb_MiniTable* ret = upb_MiniTable_Build(str.data(), str.size(), platform_,
upb_MiniTable* ret = _upb_MiniTable_Build(str.data(), str.size(), platform_,
arena_.ptr(), status.ptr());
if (!ret) {
fprintf(stderr, "Error building mini-table: %s\n", status.error_message());

Loading…
Cancel
Save