Merge branch 'refactor-upbc' into minitable-api

pull/13171/head
Joshua Haberman 3 years ago
commit a2004150f8
  1. 542
      cmake/google/protobuf/descriptor.upb.c
  2. 956
      cmake/google/protobuf/descriptor.upb.h
  3. 193
      upbc/protoc-gen-upb.cc

@ -23,11 +23,7 @@ static const upb_MiniTable_Field google_protobuf_FileDescriptorSet__fields[1] =
const upb_MiniTable google_protobuf_FileDescriptorSet_msginit = {
&google_protobuf_FileDescriptorSet_submsgs[0],
&google_protobuf_FileDescriptorSet__fields[0],
UPB_SIZE(4, 8), 1, kUpb_ExtMode_NonExtendable, 1, 8, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x000000003f00000a, &upb_prm_1bt_maxmaxb},
}),
UPB_SIZE(16, 16), 1, kUpb_ExtMode_NonExtendable, 1, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_FileDescriptorProto_submsgs[6] = {
@ -57,25 +53,7 @@ static const upb_MiniTable_Field google_protobuf_FileDescriptorProto__fields[12]
const upb_MiniTable google_protobuf_FileDescriptorProto_msginit = {
&google_protobuf_FileDescriptorProto_submsgs[0],
&google_protobuf_FileDescriptorProto__fields[0],
UPB_SIZE(64, 128), 12, kUpb_ExtMode_NonExtendable, 12, 120, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x000800000100000a, &upb_psb_1bt},
{0x0018000002000012, &upb_psb_1bt},
{0x002800003f00001a, &upb_prb_1bt},
{0x003000003f000022, &upb_prm_1bt_maxmaxb},
{0x003800003f01002a, &upb_prm_1bt_maxmaxb},
{0x004000003f020032, &upb_prm_1bt_maxmaxb},
{0x004800003f03003a, &upb_prm_1bt_maxmaxb},
{0x0050000003040042, &upb_psm_1bt_maxmaxb},
{0x005800000405004a, &upb_psm_1bt_maxmaxb},
{0x006000003f000050, &upb_prv4_1bt},
{0x006800003f000058, &upb_prv4_1bt},
{0x0070000005000062, &upb_psb_1bt},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(64, 128), 12, kUpb_ExtMode_NonExtendable, 12, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_DescriptorProto_submsgs[8] = {
@ -105,25 +83,7 @@ static const upb_MiniTable_Field google_protobuf_DescriptorProto__fields[10] = {
const upb_MiniTable google_protobuf_DescriptorProto_msginit = {
&google_protobuf_DescriptorProto_submsgs[0],
&google_protobuf_DescriptorProto__fields[0],
UPB_SIZE(48, 96), 10, kUpb_ExtMode_NonExtendable, 10, 120, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x000800000100000a, &upb_psb_1bt},
{0x001800003f000012, &upb_prm_1bt_maxmaxb},
{0x002000003f01001a, &upb_prm_1bt_maxmaxb},
{0x002800003f020022, &upb_prm_1bt_maxmaxb},
{0x003000003f03002a, &upb_prm_1bt_maxmaxb},
{0x003800003f040032, &upb_prm_1bt_maxmaxb},
{0x004000000205003a, &upb_psm_1bt_maxmaxb},
{0x004800003f060042, &upb_prm_1bt_maxmaxb},
{0x005000003f07004a, &upb_prm_1bt_maxmaxb},
{0x005800003f000052, &upb_prb_1bt},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(48, 96), 10, kUpb_ExtMode_NonExtendable, 10, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_DescriptorProto_ExtensionRange_submsgs[1] = {
@ -139,13 +99,7 @@ static const upb_MiniTable_Field google_protobuf_DescriptorProto_ExtensionRange_
const upb_MiniTable google_protobuf_DescriptorProto_ExtensionRange_msginit = {
&google_protobuf_DescriptorProto_ExtensionRange_submsgs[0],
&google_protobuf_DescriptorProto_ExtensionRange__fields[0],
UPB_SIZE(16, 24), 3, kUpb_ExtMode_NonExtendable, 3, 24, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x0004000001000008, &upb_psv4_1bt},
{0x0008000002000010, &upb_psv4_1bt},
{0x001000000300001a, &upb_psm_1bt_maxmaxb},
}),
UPB_SIZE(16, 32), 3, kUpb_ExtMode_NonExtendable, 3, 255, 0,
};
static const upb_MiniTable_Field google_protobuf_DescriptorProto_ReservedRange__fields[2] = {
@ -156,13 +110,7 @@ static const upb_MiniTable_Field google_protobuf_DescriptorProto_ReservedRange__
const upb_MiniTable google_protobuf_DescriptorProto_ReservedRange_msginit = {
NULL,
&google_protobuf_DescriptorProto_ReservedRange__fields[0],
UPB_SIZE(12, 12), 2, kUpb_ExtMode_NonExtendable, 2, 24, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x0004000001000008, &upb_psv4_1bt},
{0x0008000002000010, &upb_psv4_1bt},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(16, 16), 2, kUpb_ExtMode_NonExtendable, 2, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_ExtensionRangeOptions_submsgs[1] = {
@ -176,41 +124,7 @@ static const upb_MiniTable_Field google_protobuf_ExtensionRangeOptions__fields[1
const upb_MiniTable google_protobuf_ExtensionRangeOptions_msginit = {
&google_protobuf_ExtensionRangeOptions_submsgs[0],
&google_protobuf_ExtensionRangeOptions__fields[0],
UPB_SIZE(4, 8), 1, kUpb_ExtMode_Extendable, 0, 248, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x000000003f003eba, &upb_prm_2bt_maxmaxb},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(16, 16), 1, kUpb_ExtMode_Extendable, 0, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_FieldDescriptorProto_submsgs[1] = {
@ -234,41 +148,7 @@ static const upb_MiniTable_Field google_protobuf_FieldDescriptorProto__fields[11
const upb_MiniTable google_protobuf_FieldDescriptorProto_msginit = {
&google_protobuf_FieldDescriptorProto_submsgs[0],
&google_protobuf_FieldDescriptorProto__fields[0],
UPB_SIZE(68, 112), 11, kUpb_ExtMode_NonExtendable, 10, 248, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x001800000100000a, &upb_psb_1bt},
{0x0028000002000012, &upb_psb_1bt},
{0x0004000003000018, &upb_psv4_1bt},
{0x0008000004000020, &upb_psv4_1bt},
{0x000c000005000028, &upb_psv4_1bt},
{0x0038000006000032, &upb_psb_1bt},
{0x004800000700003a, &upb_psb_1bt},
{0x0058000008000042, &upb_psm_1bt_maxmaxb},
{0x0010000009000048, &upb_psv4_1bt},
{0x006000000a000052, &upb_psb_1bt},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x001400000b000188, &upb_psb1_2bt},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(80, 112), 11, kUpb_ExtMode_NonExtendable, 10, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_OneofDescriptorProto_submsgs[1] = {
@ -283,13 +163,7 @@ static const upb_MiniTable_Field google_protobuf_OneofDescriptorProto__fields[2]
const upb_MiniTable google_protobuf_OneofDescriptorProto_msginit = {
&google_protobuf_OneofDescriptorProto_submsgs[0],
&google_protobuf_OneofDescriptorProto__fields[0],
UPB_SIZE(16, 32), 2, kUpb_ExtMode_NonExtendable, 2, 24, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x000800000100000a, &upb_psb_1bt},
{0x0018000002000012, &upb_psm_1bt_maxmaxb},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(16, 32), 2, kUpb_ExtMode_NonExtendable, 2, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_EnumDescriptorProto_submsgs[3] = {
@ -309,17 +183,7 @@ static const upb_MiniTable_Field google_protobuf_EnumDescriptorProto__fields[5]
const upb_MiniTable google_protobuf_EnumDescriptorProto_msginit = {
&google_protobuf_EnumDescriptorProto_submsgs[0],
&google_protobuf_EnumDescriptorProto__fields[0],
UPB_SIZE(28, 56), 5, kUpb_ExtMode_NonExtendable, 5, 56, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x000800000100000a, &upb_psb_1bt},
{0x001800003f000012, &upb_prm_1bt_maxmaxb},
{0x002000000201001a, &upb_psm_1bt_maxmaxb},
{0x002800003f020022, &upb_prm_1bt_maxmaxb},
{0x003000003f00002a, &upb_prb_1bt},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(32, 64), 5, kUpb_ExtMode_NonExtendable, 5, 255, 0,
};
static const upb_MiniTable_Field google_protobuf_EnumDescriptorProto_EnumReservedRange__fields[2] = {
@ -330,13 +194,7 @@ static const upb_MiniTable_Field google_protobuf_EnumDescriptorProto_EnumReserve
const upb_MiniTable google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit = {
NULL,
&google_protobuf_EnumDescriptorProto_EnumReservedRange__fields[0],
UPB_SIZE(12, 12), 2, kUpb_ExtMode_NonExtendable, 2, 24, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x0004000001000008, &upb_psv4_1bt},
{0x0008000002000010, &upb_psv4_1bt},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(16, 16), 2, kUpb_ExtMode_NonExtendable, 2, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_EnumValueDescriptorProto_submsgs[1] = {
@ -352,13 +210,7 @@ static const upb_MiniTable_Field google_protobuf_EnumValueDescriptorProto__field
const upb_MiniTable google_protobuf_EnumValueDescriptorProto_msginit = {
&google_protobuf_EnumValueDescriptorProto_submsgs[0],
&google_protobuf_EnumValueDescriptorProto__fields[0],
UPB_SIZE(20, 32), 3, kUpb_ExtMode_NonExtendable, 3, 24, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x000800000100000a, &upb_psb_1bt},
{0x0004000002000010, &upb_psv4_1bt},
{0x001800000300001a, &upb_psm_1bt_maxmaxb},
}),
UPB_SIZE(32, 32), 3, kUpb_ExtMode_NonExtendable, 3, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_ServiceDescriptorProto_submsgs[2] = {
@ -375,13 +227,7 @@ static const upb_MiniTable_Field google_protobuf_ServiceDescriptorProto__fields[
const upb_MiniTable google_protobuf_ServiceDescriptorProto_msginit = {
&google_protobuf_ServiceDescriptorProto_submsgs[0],
&google_protobuf_ServiceDescriptorProto__fields[0],
UPB_SIZE(20, 40), 3, kUpb_ExtMode_NonExtendable, 3, 24, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x000800000100000a, &upb_psb_1bt},
{0x001800003f000012, &upb_prm_1bt_maxmaxb},
{0x002000000201001a, &upb_psm_1bt_maxmaxb},
}),
UPB_SIZE(32, 48), 3, kUpb_ExtMode_NonExtendable, 3, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_MethodDescriptorProto_submsgs[1] = {
@ -400,17 +246,7 @@ static const upb_MiniTable_Field google_protobuf_MethodDescriptorProto__fields[6
const upb_MiniTable google_protobuf_MethodDescriptorProto_msginit = {
&google_protobuf_MethodDescriptorProto_submsgs[0],
&google_protobuf_MethodDescriptorProto__fields[0],
UPB_SIZE(32, 64), 6, kUpb_ExtMode_NonExtendable, 6, 56, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x000800000100000a, &upb_psb_1bt},
{0x0018000002000012, &upb_psb_1bt},
{0x002800000300001a, &upb_psb_1bt},
{0x0038000004000022, &upb_psm_1bt_maxmaxb},
{0x0001000005000028, &upb_psb1_1bt},
{0x0002000006000030, &upb_psb1_1bt},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(32, 64), 6, kUpb_ExtMode_NonExtendable, 6, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_FileOptions_submsgs[1] = {
@ -444,41 +280,7 @@ static const upb_MiniTable_Field google_protobuf_FileOptions__fields[21] = {
const upb_MiniTable google_protobuf_FileOptions_msginit = {
&google_protobuf_FileOptions_submsgs[0],
&google_protobuf_FileOptions__fields[0],
UPB_SIZE(104, 192), 21, kUpb_ExtMode_Extendable, 1, 248, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x001800000100000a, &upb_psb_1bt},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0028000002000042, &upb_psb_1bt},
{0x0004000003000048, &upb_psv4_1bt},
{0x0008000004000050, &upb_psb1_1bt},
{0x003800000500005a, &upb_psb_1bt},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0009000006000180, &upb_psb1_2bt},
{0x000a000007000188, &upb_psb1_2bt},
{0x000b000008000190, &upb_psb1_2bt},
{0x0000000000000000, &fastdecode_generic},
{0x000c0000090001a0, &upb_psb1_2bt},
{0x005800000e0002aa, &upb_psb_2bt},
{0x0000000000000000, &fastdecode_generic},
{0x000d00000a0001b8, &upb_psb1_2bt},
{0x00780000100002c2, &upb_psb_2bt},
{0x00880000110002ca, &upb_psb_2bt},
{0x00100000120002d0, &upb_psb1_2bt},
{0x000e00000b0001d8, &upb_psb1_2bt},
{0x00980000130002e2, &upb_psb_2bt},
{0x00a80000140002ea, &upb_psb_2bt},
{0x0000000000000000, &fastdecode_generic},
{0x000f00000c0001f8, &upb_psb1_2bt},
}),
UPB_SIZE(112, 192), 21, kUpb_ExtMode_Extendable, 1, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_MessageOptions_submsgs[1] = {
@ -496,41 +298,7 @@ static const upb_MiniTable_Field google_protobuf_MessageOptions__fields[5] = {
const upb_MiniTable google_protobuf_MessageOptions_msginit = {
&google_protobuf_MessageOptions_submsgs[0],
&google_protobuf_MessageOptions__fields[0],
UPB_SIZE(12, 16), 5, kUpb_ExtMode_Extendable, 3, 248, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x0001000001000008, &upb_psb1_1bt},
{0x0002000002000010, &upb_psb1_1bt},
{0x0003000003000018, &upb_psb1_1bt},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0004000004000038, &upb_psb1_1bt},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x000800003f003eba, &upb_prm_2bt_maxmaxb},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(16, 16), 5, kUpb_ExtMode_Extendable, 3, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_FieldOptions_submsgs[1] = {
@ -551,41 +319,7 @@ static const upb_MiniTable_Field google_protobuf_FieldOptions__fields[8] = {
const upb_MiniTable google_protobuf_FieldOptions_msginit = {
&google_protobuf_FieldOptions_submsgs[0],
&google_protobuf_FieldOptions__fields[0],
UPB_SIZE(24, 32), 8, kUpb_ExtMode_Extendable, 3, 248, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x0004000001000008, &upb_psv4_1bt},
{0x0008000002000010, &upb_psb1_1bt},
{0x0009000003000018, &upb_psb1_1bt},
{0x0000000000000000, &fastdecode_generic},
{0x000a000004000028, &upb_psb1_1bt},
{0x000c000005000030, &upb_psv4_1bt},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0010000006000050, &upb_psb1_1bt},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0011000007000078, &upb_psb1_1bt},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x001800003f003eba, &upb_prm_2bt_maxmaxb},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(32, 32), 8, kUpb_ExtMode_Extendable, 3, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_OneofOptions_submsgs[1] = {
@ -599,41 +333,7 @@ static const upb_MiniTable_Field google_protobuf_OneofOptions__fields[1] = {
const upb_MiniTable google_protobuf_OneofOptions_msginit = {
&google_protobuf_OneofOptions_submsgs[0],
&google_protobuf_OneofOptions__fields[0],
UPB_SIZE(4, 8), 1, kUpb_ExtMode_Extendable, 0, 248, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x000000003f003eba, &upb_prm_2bt_maxmaxb},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(16, 16), 1, kUpb_ExtMode_Extendable, 0, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_EnumOptions_submsgs[1] = {
@ -649,41 +349,7 @@ static const upb_MiniTable_Field google_protobuf_EnumOptions__fields[3] = {
const upb_MiniTable google_protobuf_EnumOptions_msginit = {
&google_protobuf_EnumOptions_submsgs[0],
&google_protobuf_EnumOptions__fields[0],
UPB_SIZE(8, 16), 3, kUpb_ExtMode_Extendable, 0, 248, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0001000001000010, &upb_psb1_1bt},
{0x0002000002000018, &upb_psb1_1bt},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x000800003f003eba, &upb_prm_2bt_maxmaxb},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(16, 16), 3, kUpb_ExtMode_Extendable, 0, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_EnumValueOptions_submsgs[1] = {
@ -698,41 +364,7 @@ static const upb_MiniTable_Field google_protobuf_EnumValueOptions__fields[2] = {
const upb_MiniTable google_protobuf_EnumValueOptions_msginit = {
&google_protobuf_EnumValueOptions_submsgs[0],
&google_protobuf_EnumValueOptions__fields[0],
UPB_SIZE(8, 16), 2, kUpb_ExtMode_Extendable, 1, 248, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x0001000001000008, &upb_psb1_1bt},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x000800003f003eba, &upb_prm_2bt_maxmaxb},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(16, 16), 2, kUpb_ExtMode_Extendable, 1, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_ServiceOptions_submsgs[1] = {
@ -747,41 +379,7 @@ static const upb_MiniTable_Field google_protobuf_ServiceOptions__fields[2] = {
const upb_MiniTable google_protobuf_ServiceOptions_msginit = {
&google_protobuf_ServiceOptions_submsgs[0],
&google_protobuf_ServiceOptions__fields[0],
UPB_SIZE(8, 16), 2, kUpb_ExtMode_Extendable, 0, 248, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0001000001000288, &upb_psb1_2bt},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x000800003f003eba, &upb_prm_2bt_maxmaxb},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(16, 16), 2, kUpb_ExtMode_Extendable, 0, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_MethodOptions_submsgs[1] = {
@ -797,41 +395,7 @@ static const upb_MiniTable_Field google_protobuf_MethodOptions__fields[3] = {
const upb_MiniTable google_protobuf_MethodOptions_msginit = {
&google_protobuf_MethodOptions_submsgs[0],
&google_protobuf_MethodOptions__fields[0],
UPB_SIZE(12, 16), 3, kUpb_ExtMode_Extendable, 0, 248, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0001000001000288, &upb_psb1_2bt},
{0x0004000002000290, &upb_psv4_2bt},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x000800003f003eba, &upb_prm_2bt_maxmaxb},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(16, 16), 3, kUpb_ExtMode_Extendable, 0, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_UninterpretedOption_submsgs[1] = {
@ -851,25 +415,7 @@ static const upb_MiniTable_Field google_protobuf_UninterpretedOption__fields[7]
const upb_MiniTable google_protobuf_UninterpretedOption_msginit = {
&google_protobuf_UninterpretedOption_submsgs[0],
&google_protobuf_UninterpretedOption__fields[0],
UPB_SIZE(56, 88), 7, kUpb_ExtMode_NonExtendable, 0, 120, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x000800003f000012, &upb_prm_1bt_maxmaxb},
{0x001000000100001a, &upb_psb_1bt},
{0x0040000002000020, &upb_psv8_1bt},
{0x0048000003000028, &upb_psv8_1bt},
{0x0050000004000031, &upb_psf8_1bt},
{0x002000000500003a, &upb_psb_1bt},
{0x0030000006000042, &upb_psb_1bt},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(64, 96), 7, kUpb_ExtMode_NonExtendable, 0, 255, 0,
};
static const upb_MiniTable_Field google_protobuf_UninterpretedOption_NamePart__fields[2] = {
@ -880,13 +426,7 @@ static const upb_MiniTable_Field google_protobuf_UninterpretedOption_NamePart__f
const upb_MiniTable google_protobuf_UninterpretedOption_NamePart_msginit = {
NULL,
&google_protobuf_UninterpretedOption_NamePart__fields[0],
UPB_SIZE(12, 24), 2, kUpb_ExtMode_NonExtendable, 2, 24, 2,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x000800000100000a, &upb_psb_1bt},
{0x0001000002000010, &upb_psb1_1bt},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(16, 32), 2, kUpb_ExtMode_NonExtendable, 2, 255, 2,
};
static const upb_MiniTable_Sub google_protobuf_SourceCodeInfo_submsgs[1] = {
@ -900,11 +440,7 @@ static const upb_MiniTable_Field google_protobuf_SourceCodeInfo__fields[1] = {
const upb_MiniTable google_protobuf_SourceCodeInfo_msginit = {
&google_protobuf_SourceCodeInfo_submsgs[0],
&google_protobuf_SourceCodeInfo__fields[0],
UPB_SIZE(4, 8), 1, kUpb_ExtMode_NonExtendable, 1, 8, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x000000003f00000a, &upb_prm_1bt_maxmaxb},
}),
UPB_SIZE(16, 16), 1, kUpb_ExtMode_NonExtendable, 1, 255, 0,
};
static const upb_MiniTable_Field google_protobuf_SourceCodeInfo_Location__fields[5] = {
@ -918,17 +454,7 @@ static const upb_MiniTable_Field google_protobuf_SourceCodeInfo_Location__fields
const upb_MiniTable google_protobuf_SourceCodeInfo_Location_msginit = {
NULL,
&google_protobuf_SourceCodeInfo_Location__fields[0],
UPB_SIZE(32, 64), 5, kUpb_ExtMode_NonExtendable, 4, 56, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x000800003f00000a, &upb_ppv4_1bt},
{0x001000003f000012, &upb_ppv4_1bt},
{0x001800000100001a, &upb_psb_1bt},
{0x0028000002000022, &upb_psb_1bt},
{0x0000000000000000, &fastdecode_generic},
{0x003800003f000032, &upb_prb_1bt},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(32, 64), 5, kUpb_ExtMode_NonExtendable, 4, 255, 0,
};
static const upb_MiniTable_Sub google_protobuf_GeneratedCodeInfo_submsgs[1] = {
@ -942,11 +468,7 @@ static const upb_MiniTable_Field google_protobuf_GeneratedCodeInfo__fields[1] =
const upb_MiniTable google_protobuf_GeneratedCodeInfo_msginit = {
&google_protobuf_GeneratedCodeInfo_submsgs[0],
&google_protobuf_GeneratedCodeInfo__fields[0],
UPB_SIZE(4, 8), 1, kUpb_ExtMode_NonExtendable, 1, 8, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x000000003f00000a, &upb_prm_1bt_maxmaxb},
}),
UPB_SIZE(16, 16), 1, kUpb_ExtMode_NonExtendable, 1, 255, 0,
};
static const upb_MiniTable_Field google_protobuf_GeneratedCodeInfo_Annotation__fields[4] = {
@ -959,17 +481,7 @@ static const upb_MiniTable_Field google_protobuf_GeneratedCodeInfo_Annotation__f
const upb_MiniTable google_protobuf_GeneratedCodeInfo_Annotation_msginit = {
NULL,
&google_protobuf_GeneratedCodeInfo_Annotation__fields[0],
UPB_SIZE(24, 40), 4, kUpb_ExtMode_NonExtendable, 4, 56, 0,
UPB_FASTTABLE_INIT({
{0x0000000000000000, &fastdecode_generic},
{0x001000003f00000a, &upb_ppv4_1bt},
{0x0018000001000012, &upb_psb_1bt},
{0x0004000002000018, &upb_psv4_1bt},
{0x0008000003000020, &upb_psv4_1bt},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
{0x0000000000000000, &fastdecode_generic},
}),
UPB_SIZE(32, 48), 4, kUpb_ExtMode_NonExtendable, 4, 255, 0,
};
static const upb_MiniTable *messages_layout[27] = {

File diff suppressed because it is too large Load Diff

@ -618,25 +618,35 @@ void DumpEnumValues(const protobuf::EnumDescriptor* desc, Output& output) {
void GenerateExtensionInHeader(const protobuf::FieldDescriptor* ext,
Output& output) {
output(
"UPB_INLINE bool $0_has_$1(const struct $2 *msg) { "
"return _upb_Message_Getext(msg, &$3) != NULL; }\n",
R"cc(
UPB_INLINE bool $0_has_$1(const struct $2* msg) {
return _upb_Message_Getext(msg, &$3) != NULL;
}
)cc",
ExtensionIdentBase(ext), ext->name(), MessageName(ext->containing_type()),
ExtensionLayout(ext));
if (ext->is_repeated()) {
} else if (ext->message_type()) {
output(
"UPB_INLINE $0 $1_$2(const struct $3 *msg) { "
"const upb_Message_Extension *ext = _upb_Message_Getext(msg, &$4); "
"UPB_ASSERT(ext); return *UPB_PTR_AT(&ext->data, 0, $0); }\n",
R"cc(
UPB_INLINE $0 $1_$2(const struct $3* msg) {
const upb_Message_Extension* ext = _upb_Message_Getext(msg, &$4);
UPB_ASSERT(ext);
return *UPB_PTR_AT(&ext->data, 0, $0);
}
)cc",
CTypeConst(ext), ExtensionIdentBase(ext), ext->name(),
MessageName(ext->containing_type()), ExtensionLayout(ext),
FieldDefault(ext));
} else {
output(
"UPB_INLINE $0 $1_$2(const struct $3 *msg) { "
"const upb_Message_Extension *ext = _upb_Message_Getext(msg, &$4); "
"return ext ? *UPB_PTR_AT(&ext->data, 0, $0) : $5; }\n",
R"cc(
UPB_INLINE $0 $1_$2(const struct $3* msg) {
const upb_Message_Extension* ext = _upb_Message_Getext(msg, &$4);
return ext ? *UPB_PTR_AT(&ext->data, 0, $0) : $5;
}
)cc",
CTypeConst(ext), ExtensionIdentBase(ext), ext->name(),
MessageName(ext->containing_type()), ExtensionLayout(ext),
FieldDefault(ext));
@ -694,9 +704,11 @@ void GenerateOneofInHeader(const protobuf::OneofDescriptor* oneof,
"} $0_oneofcases;\n",
fullname);
output(
"UPB_INLINE $0_oneofcases $1_$2_case(const $1* msg) { "
"return ($0_oneofcases)*UPB_PTR_AT(msg, $3, int32_t); }\n"
"\n",
R"cc(
UPB_INLINE $0_oneofcases $1_$2_case(const $1* msg) {
return ($0_oneofcases)*UPB_PTR_AT(msg, $3, int32_t);
}
)cc",
fullname, msg_name, oneof->name(),
layout.GetOneofCaseOffset(oneof));
}
@ -706,20 +718,29 @@ void GenerateHazzer(const protobuf::FieldDescriptor* field,
Output& output) {
if (layout.HasHasbit(field)) {
output(
"UPB_INLINE bool $0_has_$1(const $0 *msg) { "
"return _upb_hasbit(msg, $2); }\n",
R"cc(
UPB_INLINE bool $0_has_$1(const $0* msg) {
return _upb_hasbit(msg, $2);
}
)cc",
msg_name, field->name(), layout.GetHasbitIndex(field));
} else if (field->real_containing_oneof()) {
output(
"UPB_INLINE bool $0_has_$1(const $0 *msg) { "
"return _upb_getoneofcase(msg, $2) == $3; }\n",
R"cc(
UPB_INLINE bool $0_has_$1(const $0* msg) {
return _upb_getoneofcase(msg, $2) == $3;
}
)cc",
msg_name, field->name(),
layout.GetOneofCaseOffset(field->real_containing_oneof()),
field->number());
} else if (field->message_type()) {
output(
"UPB_INLINE bool $0_has_$1(const $0 *msg) { "
"return _upb_has_submsg_nohasbit(msg, $2); }\n",
R"cc(
UPB_INLINE bool $0_has_$1(const $0* msg) {
return _upb_has_submsg_nohasbit(msg, $2);
}
)cc",
msg_name, field->name(), layout.GetFieldOffset(field));
}
}
@ -731,12 +752,18 @@ void GenerateMapGetters(const protobuf::FieldDescriptor* field,
const protobuf::FieldDescriptor* key = entry->FindFieldByNumber(1);
const protobuf::FieldDescriptor* val = entry->FindFieldByNumber(2);
output(
"UPB_INLINE size_t $0_$1_size(const $0 *msg) {"
"return _upb_msg_map_size(msg, $2); }\n",
R"cc(
UPB_INLINE size_t $0_$1_size(const $0* msg) {
return _upb_msg_map_size(msg, $2);
}
)cc",
msg_name, field->name(), layout.GetFieldOffset(field));
output(
"UPB_INLINE bool $0_$1_get(const $0 *msg, $2 key, $3 *val) { "
"return _upb_msg_map_get(msg, $4, &key, $5, val, $6); }\n",
R"cc(
UPB_INLINE bool $0_$1_get(const $0* msg, $2 key, $3* val) {
return _upb_msg_map_get(msg, $4, &key, $5, val, $6);
}
)cc",
msg_name, field->name(), CType(key), CType(val),
layout.GetFieldOffset(field),
key->cpp_type() == protobuf::FieldDescriptor::CPPTYPE_STRING
@ -746,8 +773,11 @@ void GenerateMapGetters(const protobuf::FieldDescriptor* field,
? "0"
: "sizeof(*val)");
output(
"UPB_INLINE $0 $1_$2_next(const $1 *msg, size_t* iter) { "
"return ($0)_upb_msg_map_next(msg, $3, iter); }\n",
R"cc(
UPB_INLINE $0 $1_$2_next(const $1* msg, size_t* iter) {
return ($0)_upb_msg_map_next(msg, $3, iter);
}
)cc",
CTypeConst(field), msg_name, field->name(),
layout.GetFieldOffset(field));
}
@ -755,11 +785,13 @@ void GenerateMapGetters(const protobuf::FieldDescriptor* field,
void GenerateMapEntryGetters(const protobuf::FieldDescriptor* field,
absl::string_view msg_name, Output& output) {
output(
"UPB_INLINE $0 $1_$2(const $1 *msg) {\n"
" $3 ret;\n"
" _upb_msg_map_$2(msg, &ret, $4);\n"
" return ret;\n"
"}\n",
R"cc(
UPB_INLINE $0 $1_$2(const $1* msg) {
$3 ret;
_upb_msg_map_$2(msg, &ret, $4);
return ret;
}
)cc",
CTypeConst(field), msg_name, field->name(), CType(field),
field->cpp_type() == protobuf::FieldDescriptor::CPPTYPE_STRING
? "0"
@ -770,8 +802,11 @@ void GenerateRepeatedGetters(const protobuf::FieldDescriptor* field,
const FileLayout& layout,
absl::string_view msg_name, Output& output) {
output(
"UPB_INLINE $0 const* $1_$2(const $1 *msg, size_t *len) { "
"return ($0 const*)_upb_array_accessor(msg, $3, len); }\n",
R"cc(
UPB_INLINE $0 const* $1_$2(const $1* msg, size_t* len) {
return ($0 const*)_upb_array_accessor(msg, $3, len);
}
)cc",
CTypeConst(field), msg_name, field->name(),
layout.GetFieldOffset(field));
}
@ -780,8 +815,11 @@ void GenerateOneofGetters(const protobuf::FieldDescriptor* field,
const FileLayout& layout,
absl::string_view msg_name, Output& output) {
output(
"UPB_INLINE $0 $1_$2(const $1 *msg) { "
"return UPB_READ_ONEOF(msg, $0, $3, $4, $5, $6); }\n",
R"cc(
UPB_INLINE $0 $1_$2(const $1* msg) {
return UPB_READ_ONEOF(msg, $0, $3, $4, $5, $6);
}
)cc",
CTypeConst(field), msg_name, field->name(),
layout.GetFieldOffset(field),
layout.GetOneofCaseOffset(field->real_containing_oneof()),
@ -835,14 +873,16 @@ void GenerateMapSetters(const protobuf::FieldDescriptor* field,
const protobuf::FieldDescriptor* key = entry->FindFieldByNumber(1);
const protobuf::FieldDescriptor* val = entry->FindFieldByNumber(2);
output(
"UPB_INLINE void $0_$1_clear($0 *msg) { _upb_msg_map_clear(msg, "
"$2); "
"}\n",
R"cc(
UPB_INLINE void $0_$1_clear($0* msg) { _upb_msg_map_clear(msg, $2); }
)cc",
msg_name, field->name(), layout.GetFieldOffset(field));
output(
"UPB_INLINE bool $0_$1_set($0 *msg, $2 key, $3 val, upb_Arena *a) "
"{ "
"return _upb_msg_map_set(msg, $4, &key, $5, &val, $6, a); }\n",
R"cc(
UPB_INLINE bool $0_$1_set($0* msg, $2 key, $3 val, upb_Arena* a) {
return _upb_msg_map_set(msg, $4, &key, $5, &val, $6, a);
}
)cc",
msg_name, field->name(), CType(key), CType(val),
layout.GetFieldOffset(field),
key->cpp_type() == protobuf::FieldDescriptor::CPPTYPE_STRING
@ -852,16 +892,22 @@ void GenerateMapSetters(const protobuf::FieldDescriptor* field,
? "0"
: "sizeof(val)");
output(
"UPB_INLINE bool $0_$1_delete($0 *msg, $2 key) { "
"return _upb_msg_map_delete(msg, $3, &key, $4); }\n",
R"cc(
UPB_INLINE bool $0_$1_delete($0* msg, $2 key) {
return _upb_msg_map_delete(msg, $3, &key, $4);
}
)cc",
msg_name, field->name(), CType(key),
layout.GetFieldOffset(field),
key->cpp_type() == protobuf::FieldDescriptor::CPPTYPE_STRING
? "0"
: "sizeof(key)");
output(
"UPB_INLINE $0 $1_$2_nextmutable($1 *msg, size_t* iter) { "
"return ($0)_upb_msg_map_next(msg, $3, iter); }\n",
R"cc(
UPB_INLINE $0 $1_$2_nextmutable($1* msg, size_t* iter) {
return ($0)_upb_msg_map_next(msg, $3, iter);
}
)cc",
CType(field), msg_name, field->name(),
layout.GetFieldOffset(field));
}
@ -870,36 +916,40 @@ void GenerateRepeatedSetters(const protobuf::FieldDescriptor* field,
const FileLayout& layout,
absl::string_view msg_name, Output& output) {
output(
"UPB_INLINE $0* $1_mutable_$2($1 *msg, size_t *len) {\n"
" return ($0*)_upb_array_mutable_accessor(msg, $3, len);\n"
"}\n",
R"cc(
UPB_INLINE $0* $1_mutable_$2($1* msg, size_t* len) {
return ($0*)_upb_array_mutable_accessor(msg, $3, len);
}
)cc",
CType(field), msg_name, field->name(), layout.GetFieldOffset(field));
output(
"UPB_INLINE $0* $1_resize_$2($1 *msg, size_t len, "
"upb_Arena *arena) {\n"
" return ($0*)_upb_Array_Resize_accessor2(msg, $3, len, $4, "
"arena);\n"
"}\n",
R"cc(
UPB_INLINE $0* $1_resize_$2($1* msg, size_t len, upb_Arena* arena) {
return ($0*)_upb_Array_Resize_accessor2(msg, $3, len, $4, arena);
}
)cc",
CType(field), msg_name, field->name(), layout.GetFieldOffset(field),
SizeLg2(field));
if (field->cpp_type() == protobuf::FieldDescriptor::CPPTYPE_MESSAGE) {
output(
"UPB_INLINE struct $0* $1_add_$2($1 *msg, upb_Arena *arena) {\n"
" struct $0* sub = (struct $0*)_upb_Message_New(&$3, arena);\n"
" bool ok = _upb_Array_Append_accessor2(\n"
" msg, $4, $5, &sub, arena);\n"
" if (!ok) return NULL;\n"
" return sub;\n"
"}\n",
R"cc(
UPB_INLINE struct $0* $1_add_$2($1* msg, upb_Arena* arena) {
struct $0* sub = (struct $0*)_upb_Message_New(&$3, arena);
bool ok = _upb_Array_Append_accessor2(msg, $4, $5, &sub, arena);
if (!ok) return NULL;
return sub;
}
)cc",
MessageName(field->message_type()), msg_name, field->name(),
MessageInit(field->message_type()), layout.GetFieldOffset(field),
SizeLg2(field));
} else {
output(
"UPB_INLINE bool $1_add_$2($1 *msg, $0 val, upb_Arena *arena) {\n"
" return _upb_Array_Append_accessor2(msg, $3, $4, &val,\n"
" arena);\n"
"}\n",
R"cc(
UPB_INLINE bool $1_add_$2($1* msg, $0 val, upb_Arena* arena) {
return _upb_Array_Append_accessor2(msg, $3, $4, &val, arena);
}
)cc",
CType(field), msg_name, field->name(), layout.GetFieldOffset(field),
SizeLg2(field));
}
@ -947,16 +997,17 @@ void GenerateNonRepeatedSetters(const protobuf::FieldDescriptor* field,
if (field->cpp_type() == protobuf::FieldDescriptor::CPPTYPE_MESSAGE &&
!field->containing_type()->options().map_entry()) {
output(
"UPB_INLINE struct $0* $1_mutable_$2($1 *msg, upb_Arena *arena) "
"{\n"
" struct $0* sub = (struct $0*)$1_$2(msg);\n"
" if (sub == NULL) {\n"
" sub = (struct $0*)_upb_Message_New(&$3, arena);\n"
" if (!sub) return NULL;\n"
" $1_set_$2(msg, sub);\n"
" }\n"
" return sub;\n"
"}\n",
R"cc(
UPB_INLINE struct $0* $1_mutable_$2($1* msg, upb_Arena* arena) {
struct $0* sub = (struct $0*)$1_$2(msg);
if (sub == NULL) {
sub = (struct $0*)_upb_Message_New(&$3, arena);
if (!sub) return NULL;
$1_set_$2(msg, sub);
}
return sub;
}
)cc",
MessageName(field->message_type()), msg_name, field->name(),
MessageInit(field->message_type()));
}

Loading…
Cancel
Save