From fa5710f1cad50ddd17605c73d4661acbf265a469 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Sat, 2 Jan 2010 15:30:51 -0800 Subject: upb_string* -> upb_strptr, to follow aliasing rules. --- descriptor/descriptor.c | 836 ++++++++++++++++++++++++------------------------ descriptor/descriptor.h | 40 +-- src/upb.h | 43 ++- src/upb_data.c | 100 +++--- src/upb_data.h | 133 ++++---- src/upb_def.c | 74 ++--- src/upb_def.h | 20 +- src/upb_parse.c | 2 +- src/upb_parse.h | 4 +- src/upb_table.c | 14 +- src/upb_table.h | 4 +- src/upb_text.c | 4 +- src/upb_text.h | 4 +- tools/upbc.c | 64 ++-- 14 files changed, 690 insertions(+), 652 deletions(-) diff --git a/descriptor/descriptor.c b/descriptor/descriptor.c index 6d15f64..aa5a000 100644 --- a/descriptor/descriptor.c +++ b/descriptor/descriptor.c @@ -3,7 +3,7 @@ * It was created by the upb compiler (upbc) with the following * command-line: * - * tools/upbc -i upb_file_descriptor_set -o descriptor/descriptor descriptor/descriptor.proto.pb + * ./tools/upbc -i upb_file_descriptor_set -o descriptor/descriptor descriptor/descriptor.proto.pb * * This file is a dump of 'descriptor/descriptor.proto.pb'. * It contains exactly the same data, but in a C structure form @@ -42,120 +42,120 @@ static char strdata[] = "alue"; static upb_norefcount_string strings[] = { - UPB_STRLIT_LEN(&strdata[0], 32), - UPB_STRLIT_LEN(&strdata[32], 47), - UPB_STRLIT_LEN(&strdata[79], 36), - UPB_STRLIT_LEN(&strdata[115], 28), - UPB_STRLIT_LEN(&strdata[143], 41), - UPB_STRLIT_LEN(&strdata[184], 33), - UPB_STRLIT_LEN(&strdata[217], 37), - UPB_STRLIT_LEN(&strdata[254], 43), - UPB_STRLIT_LEN(&strdata[297], 42), - UPB_STRLIT_LEN(&strdata[339], 29), - UPB_STRLIT_LEN(&strdata[368], 35), - UPB_STRLIT_LEN(&strdata[403], 36), - UPB_STRLIT_LEN(&strdata[439], 28), - UPB_STRLIT_LEN(&strdata[467], 41), - UPB_STRLIT_LEN(&strdata[508], 31), - UPB_STRLIT_LEN(&strdata[539], 38), - UPB_STRLIT_LEN(&strdata[577], 30), - UPB_STRLIT_LEN(&strdata[607], 39), - UPB_STRLIT_LEN(&strdata[646], 31), - UPB_STRLIT_LEN(&strdata[677], 36), - UPB_STRLIT_LEN(&strdata[713], 45), - UPB_STRLIT_LEN(&strdata[758], 9), - UPB_STRLIT_LEN(&strdata[767], 4), - UPB_STRLIT_LEN(&strdata[771], 5), - UPB_STRLIT_LEN(&strdata[776], 15), - UPB_STRLIT_LEN(&strdata[791], 16), - UPB_STRLIT_LEN(&strdata[807], 19), - UPB_STRLIT_LEN(&strdata[826], 11), - UPB_STRLIT_LEN(&strdata[837], 24), - UPB_STRLIT_LEN(&strdata[861], 16), - UPB_STRLIT_LEN(&strdata[877], 14), - UPB_STRLIT_LEN(&strdata[891], 20), - UPB_STRLIT_LEN(&strdata[911], 12), - UPB_STRLIT_LEN(&strdata[923], 19), - UPB_STRLIT_LEN(&strdata[942], 17), - UPB_STRLIT_LEN(&strdata[959], 11), - UPB_STRLIT_LEN(&strdata[970], 14), - UPB_STRLIT_LEN(&strdata[984], 14), - UPB_STRLIT_LEN(&strdata[998], 14), - UPB_STRLIT_LEN(&strdata[1012], 5), - UPB_STRLIT_LEN(&strdata[1017], 14), - UPB_STRLIT_LEN(&strdata[1031], 21), - UPB_STRLIT_LEN(&strdata[1052], 13), - UPB_STRLIT_LEN(&strdata[1065], 8), - UPB_STRLIT_LEN(&strdata[1073], 12), - UPB_STRLIT_LEN(&strdata[1085], 5), - UPB_STRLIT_LEN(&strdata[1090], 12), - UPB_STRLIT_LEN(&strdata[1102], 22), - UPB_STRLIT_LEN(&strdata[1124], 14), - UPB_STRLIT_LEN(&strdata[1138], 9), - UPB_STRLIT_LEN(&strdata[1147], 10), - UPB_STRLIT_LEN(&strdata[1157], 11), - UPB_STRLIT_LEN(&strdata[1168], 9), - UPB_STRLIT_LEN(&strdata[1177], 12), - UPB_STRLIT_LEN(&strdata[1189], 12), - UPB_STRLIT_LEN(&strdata[1201], 10), - UPB_STRLIT_LEN(&strdata[1211], 10), - UPB_STRLIT_LEN(&strdata[1221], 10), - UPB_STRLIT_LEN(&strdata[1231], 10), - UPB_STRLIT_LEN(&strdata[1241], 12), - UPB_STRLIT_LEN(&strdata[1253], 13), - UPB_STRLIT_LEN(&strdata[1266], 13), - UPB_STRLIT_LEN(&strdata[1279], 11), - UPB_STRLIT_LEN(&strdata[1290], 11), - UPB_STRLIT_LEN(&strdata[1301], 11), - UPB_STRLIT_LEN(&strdata[1312], 11), - UPB_STRLIT_LEN(&strdata[1323], 11), - UPB_STRLIT_LEN(&strdata[1334], 4), - UPB_STRLIT_LEN(&strdata[1338], 19), - UPB_STRLIT_LEN(&strdata[1357], 19), - UPB_STRLIT_LEN(&strdata[1376], 5), - UPB_STRLIT_LEN(&strdata[1381], 13), - UPB_STRLIT_LEN(&strdata[1394], 10), - UPB_STRLIT_LEN(&strdata[1404], 10), - UPB_STRLIT_LEN(&strdata[1414], 27), - UPB_STRLIT_LEN(&strdata[1441], 12), - UPB_STRLIT_LEN(&strdata[1453], 3), - UPB_STRLIT_LEN(&strdata[1456], 9), - UPB_STRLIT_LEN(&strdata[1465], 20), - UPB_STRLIT_LEN(&strdata[1485], 8), - UPB_STRLIT_LEN(&strdata[1493], 9), - UPB_STRLIT_LEN(&strdata[1502], 15), - UPB_STRLIT_LEN(&strdata[1517], 5), - UPB_STRLIT_LEN(&strdata[1522], 5), - UPB_STRLIT_LEN(&strdata[1527], 4), - UPB_STRLIT_LEN(&strdata[1531], 15), - UPB_STRLIT_LEN(&strdata[1546], 16), - UPB_STRLIT_LEN(&strdata[1562], 10), - UPB_STRLIT_LEN(&strdata[1572], 12), - UPB_STRLIT_LEN(&strdata[1584], 19), - UPB_STRLIT_LEN(&strdata[1603], 20), - UPB_STRLIT_LEN(&strdata[1623], 12), - UPB_STRLIT_LEN(&strdata[1635], 5), - UPB_STRLIT_LEN(&strdata[1640], 23), - UPB_STRLIT_LEN(&strdata[1663], 12), - UPB_STRLIT_LEN(&strdata[1675], 6), - UPB_STRLIT_LEN(&strdata[1681], 4), - UPB_STRLIT_LEN(&strdata[1685], 9), - UPB_STRLIT_LEN(&strdata[1694], 18), - UPB_STRLIT_LEN(&strdata[1712], 11), - UPB_STRLIT_LEN(&strdata[1723], 6), - UPB_STRLIT_LEN(&strdata[1729], 12), - UPB_STRLIT_LEN(&strdata[1741], 7), - UPB_STRLIT_LEN(&strdata[1748], 11), - UPB_STRLIT_LEN(&strdata[1759], 7), - UPB_STRLIT_LEN(&strdata[1766], 6), - UPB_STRLIT_LEN(&strdata[1772], 18), - UPB_STRLIT_LEN(&strdata[1790], 7), - UPB_STRLIT_LEN(&strdata[1797], 5), - UPB_STRLIT_LEN(&strdata[1802], 12), - UPB_STRLIT_LEN(&strdata[1814], 4), - UPB_STRLIT_LEN(&strdata[1818], 9), - UPB_STRLIT_LEN(&strdata[1827], 20), - UPB_STRLIT_LEN(&strdata[1847], 5), + UPB_STATIC_STRING_INIT_LEN(&strdata[0], 32), + UPB_STATIC_STRING_INIT_LEN(&strdata[32], 47), + UPB_STATIC_STRING_INIT_LEN(&strdata[79], 36), + UPB_STATIC_STRING_INIT_LEN(&strdata[115], 28), + UPB_STATIC_STRING_INIT_LEN(&strdata[143], 41), + UPB_STATIC_STRING_INIT_LEN(&strdata[184], 33), + UPB_STATIC_STRING_INIT_LEN(&strdata[217], 37), + UPB_STATIC_STRING_INIT_LEN(&strdata[254], 43), + UPB_STATIC_STRING_INIT_LEN(&strdata[297], 42), + UPB_STATIC_STRING_INIT_LEN(&strdata[339], 29), + UPB_STATIC_STRING_INIT_LEN(&strdata[368], 35), + UPB_STATIC_STRING_INIT_LEN(&strdata[403], 36), + UPB_STATIC_STRING_INIT_LEN(&strdata[439], 28), + UPB_STATIC_STRING_INIT_LEN(&strdata[467], 41), + UPB_STATIC_STRING_INIT_LEN(&strdata[508], 31), + UPB_STATIC_STRING_INIT_LEN(&strdata[539], 38), + UPB_STATIC_STRING_INIT_LEN(&strdata[577], 30), + UPB_STATIC_STRING_INIT_LEN(&strdata[607], 39), + UPB_STATIC_STRING_INIT_LEN(&strdata[646], 31), + UPB_STATIC_STRING_INIT_LEN(&strdata[677], 36), + UPB_STATIC_STRING_INIT_LEN(&strdata[713], 45), + UPB_STATIC_STRING_INIT_LEN(&strdata[758], 9), + UPB_STATIC_STRING_INIT_LEN(&strdata[767], 4), + UPB_STATIC_STRING_INIT_LEN(&strdata[771], 5), + UPB_STATIC_STRING_INIT_LEN(&strdata[776], 15), + UPB_STATIC_STRING_INIT_LEN(&strdata[791], 16), + UPB_STATIC_STRING_INIT_LEN(&strdata[807], 19), + UPB_STATIC_STRING_INIT_LEN(&strdata[826], 11), + UPB_STATIC_STRING_INIT_LEN(&strdata[837], 24), + UPB_STATIC_STRING_INIT_LEN(&strdata[861], 16), + UPB_STATIC_STRING_INIT_LEN(&strdata[877], 14), + UPB_STATIC_STRING_INIT_LEN(&strdata[891], 20), + UPB_STATIC_STRING_INIT_LEN(&strdata[911], 12), + UPB_STATIC_STRING_INIT_LEN(&strdata[923], 19), + UPB_STATIC_STRING_INIT_LEN(&strdata[942], 17), + UPB_STATIC_STRING_INIT_LEN(&strdata[959], 11), + UPB_STATIC_STRING_INIT_LEN(&strdata[970], 14), + UPB_STATIC_STRING_INIT_LEN(&strdata[984], 14), + UPB_STATIC_STRING_INIT_LEN(&strdata[998], 14), + UPB_STATIC_STRING_INIT_LEN(&strdata[1012], 5), + UPB_STATIC_STRING_INIT_LEN(&strdata[1017], 14), + UPB_STATIC_STRING_INIT_LEN(&strdata[1031], 21), + UPB_STATIC_STRING_INIT_LEN(&strdata[1052], 13), + UPB_STATIC_STRING_INIT_LEN(&strdata[1065], 8), + UPB_STATIC_STRING_INIT_LEN(&strdata[1073], 12), + UPB_STATIC_STRING_INIT_LEN(&strdata[1085], 5), + UPB_STATIC_STRING_INIT_LEN(&strdata[1090], 12), + UPB_STATIC_STRING_INIT_LEN(&strdata[1102], 22), + UPB_STATIC_STRING_INIT_LEN(&strdata[1124], 14), + UPB_STATIC_STRING_INIT_LEN(&strdata[1138], 9), + UPB_STATIC_STRING_INIT_LEN(&strdata[1147], 10), + UPB_STATIC_STRING_INIT_LEN(&strdata[1157], 11), + UPB_STATIC_STRING_INIT_LEN(&strdata[1168], 9), + UPB_STATIC_STRING_INIT_LEN(&strdata[1177], 12), + UPB_STATIC_STRING_INIT_LEN(&strdata[1189], 12), + UPB_STATIC_STRING_INIT_LEN(&strdata[1201], 10), + UPB_STATIC_STRING_INIT_LEN(&strdata[1211], 10), + UPB_STATIC_STRING_INIT_LEN(&strdata[1221], 10), + UPB_STATIC_STRING_INIT_LEN(&strdata[1231], 10), + UPB_STATIC_STRING_INIT_LEN(&strdata[1241], 12), + UPB_STATIC_STRING_INIT_LEN(&strdata[1253], 13), + UPB_STATIC_STRING_INIT_LEN(&strdata[1266], 13), + UPB_STATIC_STRING_INIT_LEN(&strdata[1279], 11), + UPB_STATIC_STRING_INIT_LEN(&strdata[1290], 11), + UPB_STATIC_STRING_INIT_LEN(&strdata[1301], 11), + UPB_STATIC_STRING_INIT_LEN(&strdata[1312], 11), + UPB_STATIC_STRING_INIT_LEN(&strdata[1323], 11), + UPB_STATIC_STRING_INIT_LEN(&strdata[1334], 4), + UPB_STATIC_STRING_INIT_LEN(&strdata[1338], 19), + UPB_STATIC_STRING_INIT_LEN(&strdata[1357], 19), + UPB_STATIC_STRING_INIT_LEN(&strdata[1376], 5), + UPB_STATIC_STRING_INIT_LEN(&strdata[1381], 13), + UPB_STATIC_STRING_INIT_LEN(&strdata[1394], 10), + UPB_STATIC_STRING_INIT_LEN(&strdata[1404], 10), + UPB_STATIC_STRING_INIT_LEN(&strdata[1414], 27), + UPB_STATIC_STRING_INIT_LEN(&strdata[1441], 12), + UPB_STATIC_STRING_INIT_LEN(&strdata[1453], 3), + UPB_STATIC_STRING_INIT_LEN(&strdata[1456], 9), + UPB_STATIC_STRING_INIT_LEN(&strdata[1465], 20), + UPB_STATIC_STRING_INIT_LEN(&strdata[1485], 8), + UPB_STATIC_STRING_INIT_LEN(&strdata[1493], 9), + UPB_STATIC_STRING_INIT_LEN(&strdata[1502], 15), + UPB_STATIC_STRING_INIT_LEN(&strdata[1517], 5), + UPB_STATIC_STRING_INIT_LEN(&strdata[1522], 5), + UPB_STATIC_STRING_INIT_LEN(&strdata[1527], 4), + UPB_STATIC_STRING_INIT_LEN(&strdata[1531], 15), + UPB_STATIC_STRING_INIT_LEN(&strdata[1546], 16), + UPB_STATIC_STRING_INIT_LEN(&strdata[1562], 10), + UPB_STATIC_STRING_INIT_LEN(&strdata[1572], 12), + UPB_STATIC_STRING_INIT_LEN(&strdata[1584], 19), + UPB_STATIC_STRING_INIT_LEN(&strdata[1603], 20), + UPB_STATIC_STRING_INIT_LEN(&strdata[1623], 12), + UPB_STATIC_STRING_INIT_LEN(&strdata[1635], 5), + UPB_STATIC_STRING_INIT_LEN(&strdata[1640], 23), + UPB_STATIC_STRING_INIT_LEN(&strdata[1663], 12), + UPB_STATIC_STRING_INIT_LEN(&strdata[1675], 6), + UPB_STATIC_STRING_INIT_LEN(&strdata[1681], 4), + UPB_STATIC_STRING_INIT_LEN(&strdata[1685], 9), + UPB_STATIC_STRING_INIT_LEN(&strdata[1694], 18), + UPB_STATIC_STRING_INIT_LEN(&strdata[1712], 11), + UPB_STATIC_STRING_INIT_LEN(&strdata[1723], 6), + UPB_STATIC_STRING_INIT_LEN(&strdata[1729], 12), + UPB_STATIC_STRING_INIT_LEN(&strdata[1741], 7), + UPB_STATIC_STRING_INIT_LEN(&strdata[1748], 11), + UPB_STATIC_STRING_INIT_LEN(&strdata[1759], 7), + UPB_STATIC_STRING_INIT_LEN(&strdata[1766], 6), + UPB_STATIC_STRING_INIT_LEN(&strdata[1772], 18), + UPB_STATIC_STRING_INIT_LEN(&strdata[1790], 7), + UPB_STATIC_STRING_INIT_LEN(&strdata[1797], 5), + UPB_STATIC_STRING_INIT_LEN(&strdata[1802], 12), + UPB_STATIC_STRING_INIT_LEN(&strdata[1814], 4), + UPB_STATIC_STRING_INIT_LEN(&strdata[1818], 9), + UPB_STATIC_STRING_INIT_LEN(&strdata[1827], 20), + UPB_STATIC_STRING_INIT_LEN(&strdata[1847], 5), }; /* Forward declarations of messages, and array decls. */ @@ -365,7 +365,7 @@ static google_protobuf_DescriptorProto google_protobuf_DescriptorProto_values[18 .extension = false, .options = false, }}, - .name = (upb_string*)&strings[34], /* "FileDescriptorSet" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[34]), /* "FileDescriptorSet" */ .field = &google_protobuf_FieldDescriptorProto_arrays[0], .nested_type = 0, /* Not set. */ .enum_type = 0, /* Not set. */ @@ -383,7 +383,7 @@ static google_protobuf_DescriptorProto google_protobuf_DescriptorProto_values[18 .extension = false, .options = false, }}, - .name = (upb_string*)&strings[33], /* "FileDescriptorProto" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[33]), /* "FileDescriptorProto" */ .field = &google_protobuf_FieldDescriptorProto_arrays[1], .nested_type = 0, /* Not set. */ .enum_type = 0, /* Not set. */ @@ -401,7 +401,7 @@ static google_protobuf_DescriptorProto google_protobuf_DescriptorProto_values[18 .extension = false, .options = false, }}, - .name = (upb_string*)&strings[24], /* "DescriptorProto" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[24]), /* "DescriptorProto" */ .field = &google_protobuf_FieldDescriptorProto_arrays[2], .nested_type = &google_protobuf_DescriptorProto_arrays[1], .enum_type = 0, /* Not set. */ @@ -419,7 +419,7 @@ static google_protobuf_DescriptorProto google_protobuf_DescriptorProto_values[18 .extension = false, .options = false, }}, - .name = (upb_string*)&strings[31], /* "FieldDescriptorProto" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[31]), /* "FieldDescriptorProto" */ .field = &google_protobuf_FieldDescriptorProto_arrays[4], .nested_type = 0, /* Not set. */ .enum_type = &google_protobuf_EnumDescriptorProto_arrays[0], @@ -437,7 +437,7 @@ static google_protobuf_DescriptorProto google_protobuf_DescriptorProto_values[18 .extension = false, .options = false, }}, - .name = (upb_string*)&strings[26], /* "EnumDescriptorProto" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[26]), /* "EnumDescriptorProto" */ .field = &google_protobuf_FieldDescriptorProto_arrays[5], .nested_type = 0, /* Not set. */ .enum_type = 0, /* Not set. */ @@ -455,7 +455,7 @@ static google_protobuf_DescriptorProto google_protobuf_DescriptorProto_values[18 .extension = false, .options = false, }}, - .name = (upb_string*)&strings[28], /* "EnumValueDescriptorProto" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[28]), /* "EnumValueDescriptorProto" */ .field = &google_protobuf_FieldDescriptorProto_arrays[6], .nested_type = 0, /* Not set. */ .enum_type = 0, /* Not set. */ @@ -473,7 +473,7 @@ static google_protobuf_DescriptorProto google_protobuf_DescriptorProto_values[18 .extension = false, .options = false, }}, - .name = (upb_string*)&strings[47], /* "ServiceDescriptorProto" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[47]), /* "ServiceDescriptorProto" */ .field = &google_protobuf_FieldDescriptorProto_arrays[7], .nested_type = 0, /* Not set. */ .enum_type = 0, /* Not set. */ @@ -491,7 +491,7 @@ static google_protobuf_DescriptorProto google_protobuf_DescriptorProto_values[18 .extension = false, .options = false, }}, - .name = (upb_string*)&strings[41], /* "MethodDescriptorProto" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[41]), /* "MethodDescriptorProto" */ .field = &google_protobuf_FieldDescriptorProto_arrays[8], .nested_type = 0, /* Not set. */ .enum_type = 0, /* Not set. */ @@ -509,7 +509,7 @@ static google_protobuf_DescriptorProto google_protobuf_DescriptorProto_values[18 .extension = false, .options = false, }}, - .name = (upb_string*)&strings[35], /* "FileOptions" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[35]), /* "FileOptions" */ .field = &google_protobuf_FieldDescriptorProto_arrays[9], .nested_type = 0, /* Not set. */ .enum_type = &google_protobuf_EnumDescriptorProto_arrays[1], @@ -527,7 +527,7 @@ static google_protobuf_DescriptorProto google_protobuf_DescriptorProto_values[18 .extension = false, .options = false, }}, - .name = (upb_string*)&strings[40], /* "MessageOptions" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[40]), /* "MessageOptions" */ .field = &google_protobuf_FieldDescriptorProto_arrays[10], .nested_type = 0, /* Not set. */ .enum_type = 0, /* Not set. */ @@ -545,7 +545,7 @@ static google_protobuf_DescriptorProto google_protobuf_DescriptorProto_values[18 .extension = false, .options = false, }}, - .name = (upb_string*)&strings[32], /* "FieldOptions" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[32]), /* "FieldOptions" */ .field = &google_protobuf_FieldDescriptorProto_arrays[11], .nested_type = 0, /* Not set. */ .enum_type = &google_protobuf_EnumDescriptorProto_arrays[2], @@ -563,7 +563,7 @@ static google_protobuf_DescriptorProto google_protobuf_DescriptorProto_values[18 .extension = false, .options = false, }}, - .name = (upb_string*)&strings[27], /* "EnumOptions" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[27]), /* "EnumOptions" */ .field = &google_protobuf_FieldDescriptorProto_arrays[12], .nested_type = 0, /* Not set. */ .enum_type = 0, /* Not set. */ @@ -581,7 +581,7 @@ static google_protobuf_DescriptorProto google_protobuf_DescriptorProto_values[18 .extension = false, .options = false, }}, - .name = (upb_string*)&strings[29], /* "EnumValueOptions" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[29]), /* "EnumValueOptions" */ .field = &google_protobuf_FieldDescriptorProto_arrays[13], .nested_type = 0, /* Not set. */ .enum_type = 0, /* Not set. */ @@ -599,7 +599,7 @@ static google_protobuf_DescriptorProto google_protobuf_DescriptorProto_values[18 .extension = false, .options = false, }}, - .name = (upb_string*)&strings[48], /* "ServiceOptions" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[48]), /* "ServiceOptions" */ .field = &google_protobuf_FieldDescriptorProto_arrays[14], .nested_type = 0, /* Not set. */ .enum_type = 0, /* Not set. */ @@ -617,7 +617,7 @@ static google_protobuf_DescriptorProto google_protobuf_DescriptorProto_values[18 .extension = false, .options = false, }}, - .name = (upb_string*)&strings[42], /* "MethodOptions" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[42]), /* "MethodOptions" */ .field = &google_protobuf_FieldDescriptorProto_arrays[15], .nested_type = 0, /* Not set. */ .enum_type = 0, /* Not set. */ @@ -635,7 +635,7 @@ static google_protobuf_DescriptorProto google_protobuf_DescriptorProto_values[18 .extension = false, .options = false, }}, - .name = (upb_string*)&strings[68], /* "UninterpretedOption" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[68]), /* "UninterpretedOption" */ .field = &google_protobuf_FieldDescriptorProto_arrays[16], .nested_type = &google_protobuf_DescriptorProto_arrays[2], .enum_type = 0, /* Not set. */ @@ -653,7 +653,7 @@ static google_protobuf_DescriptorProto google_protobuf_DescriptorProto_values[18 .extension = false, .options = false, }}, - .name = (upb_string*)&strings[30], /* "ExtensionRange" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[30]), /* "ExtensionRange" */ .field = &google_protobuf_FieldDescriptorProto_arrays[3], .nested_type = 0, /* Not set. */ .enum_type = 0, /* Not set. */ @@ -671,7 +671,7 @@ static google_protobuf_DescriptorProto google_protobuf_DescriptorProto_values[18 .extension = false, .options = false, }}, - .name = (upb_string*)&strings[43], /* "NamePart" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[43]), /* "NamePart" */ .field = &google_protobuf_FieldDescriptorProto_arrays[17], .nested_type = 0, /* Not set. */ .enum_type = 0, /* Not set. */ @@ -693,8 +693,8 @@ static google_protobuf_FileDescriptorProto google_protobuf_FileDescriptorProto_v .extension = false, .options = true, }}, - .name = (upb_string*)&strings[74], /* "descriptor/descriptor.proto" */ - .package = (upb_string*)&strings[85], /* "google.protobuf" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[74]), /* "descriptor/descriptor.proto" */ + .package = UPB_STATIC_STRING_PTR_INIT(strings[85]), /* "google.protobuf" */ .dependency = 0, /* Not set. */ .message_type = &google_protobuf_DescriptorProto_arrays[0], .enum_type = 0, /* Not set. */ @@ -781,8 +781,8 @@ static google_protobuf_FileOptions google_protobuf_FileOptions_values[1] = { .java_multiple_files = false, .uninterpreted_option = false, }}, - .java_package = (upb_string*)&strings[69], /* "com.google.protobuf" */ - .java_outer_classname = (upb_string*)&strings[25], /* "DescriptorProtos" */ + .java_package = UPB_STATIC_STRING_PTR_INIT(strings[69]), /* "com.google.protobuf" */ + .java_outer_classname = UPB_STATIC_STRING_PTR_INIT(strings[25]), /* "DescriptorProtos" */ .optimize_for = 1, .java_multiple_files = 0, /* Not set. */ .uninterpreted_option = 0, /* Not set. */ @@ -796,7 +796,7 @@ static google_protobuf_EnumDescriptorProto google_protobuf_EnumDescriptorProto_v .value = true, .options = false, }}, - .name = (upb_string*)&strings[67], /* "Type" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[67]), /* "Type" */ .value = &google_protobuf_EnumValueDescriptorProto_arrays[0], .options = 0, /* Not set. */ }, @@ -806,7 +806,7 @@ static google_protobuf_EnumDescriptorProto google_protobuf_EnumDescriptorProto_v .value = true, .options = false, }}, - .name = (upb_string*)&strings[39], /* "Label" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[39]), /* "Label" */ .value = &google_protobuf_EnumValueDescriptorProto_arrays[1], .options = 0, /* Not set. */ }, @@ -816,7 +816,7 @@ static google_protobuf_EnumDescriptorProto google_protobuf_EnumDescriptorProto_v .value = true, .options = false, }}, - .name = (upb_string*)&strings[44], /* "OptimizeMode" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[44]), /* "OptimizeMode" */ .value = &google_protobuf_EnumValueDescriptorProto_arrays[2], .options = 0, /* Not set. */ }, @@ -826,7 +826,7 @@ static google_protobuf_EnumDescriptorProto google_protobuf_EnumDescriptorProto_v .value = true, .options = false, }}, - .name = (upb_string*)&strings[23], /* "CType" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[23]), /* "CType" */ .value = &google_protobuf_EnumValueDescriptorProto_arrays[3], .options = 0, /* Not set. */ }, @@ -844,13 +844,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[84], /* "file" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[84]), /* "file" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 1, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[11], /* ".google.protobuf.FileDescriptorProto" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[11]), /* ".google.protobuf.FileDescriptorProto" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -864,13 +864,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[96], /* "name" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[96]), /* "name" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 1, .label = 1, .type = 9, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -884,13 +884,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[104], /* "package" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[104]), /* "package" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 2, .label = 1, .type = 9, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -904,13 +904,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[72], /* "dependency" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[72]), /* "dependency" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 3, .label = 3, .type = 9, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -924,13 +924,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[94], /* "message_type" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[94]), /* "message_type" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 4, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[0], /* ".google.protobuf.DescriptorProto" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[0]), /* ".google.protobuf.DescriptorProto" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -944,13 +944,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[77], /* "enum_type" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[77]), /* "enum_type" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 5, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[2], /* ".google.protobuf.EnumDescriptorProto" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[2]), /* ".google.protobuf.EnumDescriptorProto" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -964,13 +964,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[107], /* "service" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[107]), /* "service" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 6, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[17], /* ".google.protobuf.ServiceDescriptorProto" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[17]), /* ".google.protobuf.ServiceDescriptorProto" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -984,13 +984,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[80], /* "extension" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[80]), /* "extension" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 7, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[6], /* ".google.protobuf.FieldDescriptorProto" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[6]), /* ".google.protobuf.FieldDescriptorProto" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1004,13 +1004,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[102], /* "options" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[102]), /* "options" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 8, .label = 1, .type = 11, - .type_name = (upb_string*)&strings[12], /* ".google.protobuf.FileOptions" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[12]), /* ".google.protobuf.FileOptions" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1024,13 +1024,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[96], /* "name" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[96]), /* "name" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 1, .label = 1, .type = 9, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1044,13 +1044,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[83], /* "field" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[83]), /* "field" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 2, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[6], /* ".google.protobuf.FieldDescriptorProto" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[6]), /* ".google.protobuf.FieldDescriptorProto" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1064,13 +1064,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[99], /* "nested_type" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[99]), /* "nested_type" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 3, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[0], /* ".google.protobuf.DescriptorProto" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[0]), /* ".google.protobuf.DescriptorProto" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1084,13 +1084,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[77], /* "enum_type" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[77]), /* "enum_type" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 4, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[2], /* ".google.protobuf.EnumDescriptorProto" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[2]), /* ".google.protobuf.EnumDescriptorProto" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1104,13 +1104,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[81], /* "extension_range" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[81]), /* "extension_range" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 5, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[1], /* ".google.protobuf.DescriptorProto.ExtensionRange" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[1]), /* ".google.protobuf.DescriptorProto.ExtensionRange" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1124,13 +1124,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[80], /* "extension" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[80]), /* "extension" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 6, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[6], /* ".google.protobuf.FieldDescriptorProto" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[6]), /* ".google.protobuf.FieldDescriptorProto" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1144,13 +1144,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[102], /* "options" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[102]), /* "options" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 7, .label = 1, .type = 11, - .type_name = (upb_string*)&strings[14], /* ".google.protobuf.MessageOptions" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[14]), /* ".google.protobuf.MessageOptions" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1164,13 +1164,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[108], /* "start" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[108]), /* "start" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 1, .label = 1, .type = 5, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1184,13 +1184,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[76], /* "end" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[76]), /* "end" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 2, .label = 1, .type = 5, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1204,13 +1204,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[96], /* "name" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[96]), /* "name" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 1, .label = 1, .type = 9, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1224,13 +1224,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[79], /* "extendee" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[79]), /* "extendee" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 2, .label = 1, .type = 9, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1244,13 +1244,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[100], /* "number" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[100]), /* "number" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 3, .label = 1, .type = 5, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1264,13 +1264,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[92], /* "label" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[92]), /* "label" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 4, .label = 1, .type = 14, - .type_name = (upb_string*)&strings[7], /* ".google.protobuf.FieldDescriptorProto.Label" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[7]), /* ".google.protobuf.FieldDescriptorProto.Label" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1284,13 +1284,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[110], /* "type" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[110]), /* "type" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 5, .label = 1, .type = 14, - .type_name = (upb_string*)&strings[8], /* ".google.protobuf.FieldDescriptorProto.Type" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[8]), /* ".google.protobuf.FieldDescriptorProto.Type" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1304,13 +1304,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[111], /* "type_name" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[111]), /* "type_name" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 6, .label = 1, .type = 9, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1324,13 +1324,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[71], /* "default_value" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[71]), /* "default_value" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 7, .label = 1, .type = 9, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1344,13 +1344,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[102], /* "options" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[102]), /* "options" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 8, .label = 1, .type = 11, - .type_name = (upb_string*)&strings[9], /* ".google.protobuf.FieldOptions" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[9]), /* ".google.protobuf.FieldOptions" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1364,13 +1364,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[96], /* "name" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[96]), /* "name" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 1, .label = 1, .type = 9, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1384,13 +1384,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[113], /* "value" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[113]), /* "value" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 2, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[4], /* ".google.protobuf.EnumValueDescriptorProto" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[4]), /* ".google.protobuf.EnumValueDescriptorProto" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1404,13 +1404,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[102], /* "options" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[102]), /* "options" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 3, .label = 1, .type = 11, - .type_name = (upb_string*)&strings[3], /* ".google.protobuf.EnumOptions" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[3]), /* ".google.protobuf.EnumOptions" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1424,13 +1424,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[96], /* "name" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[96]), /* "name" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 1, .label = 1, .type = 9, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1444,13 +1444,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[100], /* "number" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[100]), /* "number" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 2, .label = 1, .type = 5, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1464,13 +1464,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[102], /* "options" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[102]), /* "options" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 3, .label = 1, .type = 11, - .type_name = (upb_string*)&strings[5], /* ".google.protobuf.EnumValueOptions" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[5]), /* ".google.protobuf.EnumValueOptions" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1484,13 +1484,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[96], /* "name" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[96]), /* "name" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 1, .label = 1, .type = 9, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1504,13 +1504,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[95], /* "method" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[95]), /* "method" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 2, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[15], /* ".google.protobuf.MethodDescriptorProto" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[15]), /* ".google.protobuf.MethodDescriptorProto" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1524,13 +1524,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[102], /* "options" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[102]), /* "options" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 3, .label = 1, .type = 11, - .type_name = (upb_string*)&strings[18], /* ".google.protobuf.ServiceOptions" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[18]), /* ".google.protobuf.ServiceOptions" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1544,13 +1544,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[96], /* "name" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[96]), /* "name" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 1, .label = 1, .type = 9, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1564,13 +1564,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[87], /* "input_type" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[87]), /* "input_type" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 2, .label = 1, .type = 9, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1584,13 +1584,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[103], /* "output_type" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[103]), /* "output_type" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 3, .label = 1, .type = 9, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1604,13 +1604,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[102], /* "options" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[102]), /* "options" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 4, .label = 1, .type = 11, - .type_name = (upb_string*)&strings[16], /* ".google.protobuf.MethodOptions" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[16]), /* ".google.protobuf.MethodOptions" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1624,13 +1624,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[91], /* "java_package" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[91]), /* "java_package" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 1, .label = 1, .type = 9, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1644,13 +1644,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[90], /* "java_outer_classname" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[90]), /* "java_outer_classname" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 8, .label = 1, .type = 9, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1664,13 +1664,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = true, .options = false, }}, - .name = (upb_string*)&strings[101], /* "optimize_for" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[101]), /* "optimize_for" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 9, .label = 1, .type = 14, - .type_name = (upb_string*)&strings[13], /* ".google.protobuf.FileOptions.OptimizeMode" */ - .default_value = (upb_string*)&strings[45], /* "SPEED" */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[13]), /* ".google.protobuf.FileOptions.OptimizeMode" */ + .default_value = UPB_STATIC_STRING_PTR_INIT(strings[45]), /* "SPEED" */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1684,13 +1684,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = true, .options = false, }}, - .name = (upb_string*)&strings[89], /* "java_multiple_files" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[89]), /* "java_multiple_files" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 10, .label = 1, .type = 8, - .type_name = 0, /* Not set. */ - .default_value = (upb_string*)&strings[82], /* "false" */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STATIC_STRING_PTR_INIT(strings[82]), /* "false" */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1704,13 +1704,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[112], /* "uninterpreted_option" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[112]), /* "uninterpreted_option" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 999, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[19], /* ".google.protobuf.UninterpretedOption" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[19]), /* ".google.protobuf.UninterpretedOption" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1724,13 +1724,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = true, .options = false, }}, - .name = (upb_string*)&strings[93], /* "message_set_wire_format" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[93]), /* "message_set_wire_format" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 1, .label = 1, .type = 8, - .type_name = 0, /* Not set. */ - .default_value = (upb_string*)&strings[82], /* "false" */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STATIC_STRING_PTR_INIT(strings[82]), /* "false" */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1744,13 +1744,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[112], /* "uninterpreted_option" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[112]), /* "uninterpreted_option" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 999, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[19], /* ".google.protobuf.UninterpretedOption" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[19]), /* ".google.protobuf.UninterpretedOption" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1764,13 +1764,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[70], /* "ctype" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[70]), /* "ctype" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 1, .label = 1, .type = 14, - .type_name = (upb_string*)&strings[10], /* ".google.protobuf.FieldOptions.CType" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[10]), /* ".google.protobuf.FieldOptions.CType" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1784,13 +1784,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[105], /* "packed" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[105]), /* "packed" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 2, .label = 1, .type = 8, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1804,13 +1804,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = true, .options = false, }}, - .name = (upb_string*)&strings[73], /* "deprecated" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[73]), /* "deprecated" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 3, .label = 1, .type = 8, - .type_name = 0, /* Not set. */ - .default_value = (upb_string*)&strings[82], /* "false" */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STATIC_STRING_PTR_INIT(strings[82]), /* "false" */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1824,13 +1824,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[78], /* "experimental_map_key" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[78]), /* "experimental_map_key" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 9, .label = 1, .type = 9, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1844,13 +1844,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[112], /* "uninterpreted_option" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[112]), /* "uninterpreted_option" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 999, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[19], /* ".google.protobuf.UninterpretedOption" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[19]), /* ".google.protobuf.UninterpretedOption" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1864,13 +1864,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[112], /* "uninterpreted_option" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[112]), /* "uninterpreted_option" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 999, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[19], /* ".google.protobuf.UninterpretedOption" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[19]), /* ".google.protobuf.UninterpretedOption" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1884,13 +1884,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[112], /* "uninterpreted_option" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[112]), /* "uninterpreted_option" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 999, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[19], /* ".google.protobuf.UninterpretedOption" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[19]), /* ".google.protobuf.UninterpretedOption" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1904,13 +1904,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[112], /* "uninterpreted_option" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[112]), /* "uninterpreted_option" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 999, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[19], /* ".google.protobuf.UninterpretedOption" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[19]), /* ".google.protobuf.UninterpretedOption" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1924,13 +1924,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[112], /* "uninterpreted_option" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[112]), /* "uninterpreted_option" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 999, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[19], /* ".google.protobuf.UninterpretedOption" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[19]), /* ".google.protobuf.UninterpretedOption" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1944,13 +1944,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[96], /* "name" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[96]), /* "name" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 2, .label = 3, .type = 11, - .type_name = (upb_string*)&strings[20], /* ".google.protobuf.UninterpretedOption.NamePart" */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STATIC_STRING_PTR_INIT(strings[20]), /* ".google.protobuf.UninterpretedOption.NamePart" */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1964,13 +1964,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[86], /* "identifier_value" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[86]), /* "identifier_value" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 3, .label = 1, .type = 9, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -1984,13 +1984,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[106], /* "positive_int_value" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[106]), /* "positive_int_value" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 4, .label = 1, .type = 4, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -2004,13 +2004,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[98], /* "negative_int_value" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[98]), /* "negative_int_value" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 5, .label = 1, .type = 3, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -2024,13 +2024,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[75], /* "double_value" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[75]), /* "double_value" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 6, .label = 1, .type = 1, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -2044,13 +2044,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[109], /* "string_value" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[109]), /* "string_value" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 7, .label = 1, .type = 12, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -2064,13 +2064,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[97], /* "name_part" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[97]), /* "name_part" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 1, .label = 2, .type = 9, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, {.base = {UPB_DATA_FROZEN}, @@ -2084,13 +2084,13 @@ static google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto .default_value = false, .options = false, }}, - .name = (upb_string*)&strings[88], /* "is_extension" */ - .extendee = 0, /* Not set. */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[88]), /* "is_extension" */ + .extendee = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .number = 2, .label = 2, .type = 8, - .type_name = 0, /* Not set. */ - .default_value = 0, /* Not set. */ + .type_name = UPB_STRING_NULL_INITIALIZER, /* Not set. */ + .default_value = UPB_STRING_NULL_INITIALIZER, /* Not set. */ .options = 0, /* Not set. */ }, }; @@ -2102,7 +2102,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[51], /* "TYPE_DOUBLE" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[51]), /* "TYPE_DOUBLE" */ .number = 1, .options = 0, /* Not set. */ }, @@ -2112,7 +2112,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[55], /* "TYPE_FLOAT" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[55]), /* "TYPE_FLOAT" */ .number = 2, .options = 0, /* Not set. */ }, @@ -2122,7 +2122,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[58], /* "TYPE_INT64" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[58]), /* "TYPE_INT64" */ .number = 3, .options = 0, /* Not set. */ }, @@ -2132,7 +2132,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[66], /* "TYPE_UINT64" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[66]), /* "TYPE_UINT64" */ .number = 4, .options = 0, /* Not set. */ }, @@ -2142,7 +2142,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[57], /* "TYPE_INT32" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[57]), /* "TYPE_INT32" */ .number = 5, .options = 0, /* Not set. */ }, @@ -2152,7 +2152,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[54], /* "TYPE_FIXED64" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[54]), /* "TYPE_FIXED64" */ .number = 6, .options = 0, /* Not set. */ }, @@ -2162,7 +2162,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[53], /* "TYPE_FIXED32" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[53]), /* "TYPE_FIXED32" */ .number = 7, .options = 0, /* Not set. */ }, @@ -2172,7 +2172,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[49], /* "TYPE_BOOL" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[49]), /* "TYPE_BOOL" */ .number = 8, .options = 0, /* Not set. */ }, @@ -2182,7 +2182,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[64], /* "TYPE_STRING" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[64]), /* "TYPE_STRING" */ .number = 9, .options = 0, /* Not set. */ }, @@ -2192,7 +2192,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[56], /* "TYPE_GROUP" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[56]), /* "TYPE_GROUP" */ .number = 10, .options = 0, /* Not set. */ }, @@ -2202,7 +2202,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[59], /* "TYPE_MESSAGE" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[59]), /* "TYPE_MESSAGE" */ .number = 11, .options = 0, /* Not set. */ }, @@ -2212,7 +2212,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[50], /* "TYPE_BYTES" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[50]), /* "TYPE_BYTES" */ .number = 12, .options = 0, /* Not set. */ }, @@ -2222,7 +2222,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[65], /* "TYPE_UINT32" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[65]), /* "TYPE_UINT32" */ .number = 13, .options = 0, /* Not set. */ }, @@ -2232,7 +2232,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[52], /* "TYPE_ENUM" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[52]), /* "TYPE_ENUM" */ .number = 14, .options = 0, /* Not set. */ }, @@ -2242,7 +2242,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[60], /* "TYPE_SFIXED32" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[60]), /* "TYPE_SFIXED32" */ .number = 15, .options = 0, /* Not set. */ }, @@ -2252,7 +2252,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[61], /* "TYPE_SFIXED64" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[61]), /* "TYPE_SFIXED64" */ .number = 16, .options = 0, /* Not set. */ }, @@ -2262,7 +2262,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[62], /* "TYPE_SINT32" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[62]), /* "TYPE_SINT32" */ .number = 17, .options = 0, /* Not set. */ }, @@ -2272,7 +2272,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[63], /* "TYPE_SINT64" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[63]), /* "TYPE_SINT64" */ .number = 18, .options = 0, /* Not set. */ }, @@ -2282,7 +2282,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[36], /* "LABEL_OPTIONAL" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[36]), /* "LABEL_OPTIONAL" */ .number = 1, .options = 0, /* Not set. */ }, @@ -2292,7 +2292,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[38], /* "LABEL_REQUIRED" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[38]), /* "LABEL_REQUIRED" */ .number = 2, .options = 0, /* Not set. */ }, @@ -2302,7 +2302,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[37], /* "LABEL_REPEATED" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[37]), /* "LABEL_REPEATED" */ .number = 3, .options = 0, /* Not set. */ }, @@ -2312,7 +2312,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[45], /* "SPEED" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[45]), /* "SPEED" */ .number = 1, .options = 0, /* Not set. */ }, @@ -2322,7 +2322,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[21], /* "CODE_SIZE" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[21]), /* "CODE_SIZE" */ .number = 2, .options = 0, /* Not set. */ }, @@ -2332,7 +2332,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[22], /* "CORD" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[22]), /* "CORD" */ .number = 1, .options = 0, /* Not set. */ }, @@ -2342,7 +2342,7 @@ static google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescrip .number = true, .options = false, }}, - .name = (upb_string*)&strings[46], /* "STRING_PIECE" */ + .name = UPB_STATIC_STRING_PTR_INIT(strings[46]), /* "STRING_PIECE" */ .number = 2, .options = 0, /* Not set. */ }, diff --git a/descriptor/descriptor.h b/descriptor/descriptor.h index a591bba..8db5bd3 100644 --- a/descriptor/descriptor.h +++ b/descriptor/descriptor.h @@ -98,7 +98,7 @@ struct google_protobuf_UninterpretedOption_NamePart { bool is_extension:1; /* = 2, required. */ } has; } set_flags; - upb_string* name_part; + upb_strptr name_part; bool is_extension; }; UPB_DEFINE_MSG_ARRAY(google_protobuf_UninterpretedOption_NamePart) @@ -117,7 +117,7 @@ struct google_protobuf_DescriptorProto { bool options:1; /* = 7, optional. */ } has; } set_flags; - upb_string* name; + upb_strptr name; UPB_MSG_ARRAY(google_protobuf_FieldDescriptorProto)* field; UPB_MSG_ARRAY(google_protobuf_DescriptorProto)* nested_type; UPB_MSG_ARRAY(google_protobuf_EnumDescriptorProto)* enum_type; @@ -137,7 +137,7 @@ struct google_protobuf_EnumDescriptorProto { bool options:1; /* = 3, optional. */ } has; } set_flags; - upb_string* name; + upb_strptr name; UPB_MSG_ARRAY(google_protobuf_EnumValueDescriptorProto)* value; google_protobuf_EnumOptions* options; }; @@ -157,11 +157,11 @@ struct google_protobuf_UninterpretedOption { } has; } set_flags; UPB_MSG_ARRAY(google_protobuf_UninterpretedOption_NamePart)* name; - upb_string* identifier_value; + upb_strptr identifier_value; uint64_t positive_int_value; int64_t negative_int_value; double double_value; - upb_string* string_value; + upb_strptr string_value; }; UPB_DEFINE_MSG_ARRAY(google_protobuf_UninterpretedOption) @@ -180,9 +180,9 @@ struct google_protobuf_FileDescriptorProto { bool options:1; /* = 8, optional. */ } has; } set_flags; - upb_string* name; - upb_string* package; - struct upb_string_array* dependency; + upb_strptr name; + upb_strptr package; + upb_array* dependency; UPB_MSG_ARRAY(google_protobuf_DescriptorProto)* message_type; UPB_MSG_ARRAY(google_protobuf_EnumDescriptorProto)* enum_type; UPB_MSG_ARRAY(google_protobuf_ServiceDescriptorProto)* service; @@ -202,9 +202,9 @@ struct google_protobuf_MethodDescriptorProto { bool options:1; /* = 4, optional. */ } has; } set_flags; - upb_string* name; - upb_string* input_type; - upb_string* output_type; + upb_strptr name; + upb_strptr input_type; + upb_strptr output_type; google_protobuf_MethodOptions* options; }; UPB_DEFINE_MSG_ARRAY(google_protobuf_MethodDescriptorProto) @@ -231,7 +231,7 @@ struct google_protobuf_EnumValueDescriptorProto { bool options:1; /* = 3, optional. */ } has; } set_flags; - upb_string* name; + upb_strptr name; int32_t number; google_protobuf_EnumValueOptions* options; }; @@ -247,7 +247,7 @@ struct google_protobuf_ServiceDescriptorProto { bool options:1; /* = 3, optional. */ } has; } set_flags; - upb_string* name; + upb_strptr name; UPB_MSG_ARRAY(google_protobuf_MethodDescriptorProto)* method; google_protobuf_ServiceOptions* options; }; @@ -294,7 +294,7 @@ struct google_protobuf_FieldOptions { int32_t ctype; bool packed; bool deprecated; - upb_string* experimental_map_key; + upb_strptr experimental_map_key; UPB_MSG_ARRAY(google_protobuf_UninterpretedOption)* uninterpreted_option; }; UPB_DEFINE_MSG_ARRAY(google_protobuf_FieldOptions) @@ -311,8 +311,8 @@ struct google_protobuf_FileOptions { bool uninterpreted_option:1; /* = 999, repeated. */ } has; } set_flags; - upb_string* java_package; - upb_string* java_outer_classname; + upb_strptr java_package; + upb_strptr java_outer_classname; int32_t optimize_for; bool java_multiple_files; UPB_MSG_ARRAY(google_protobuf_UninterpretedOption)* uninterpreted_option; @@ -360,13 +360,13 @@ struct google_protobuf_FieldDescriptorProto { bool options:1; /* = 8, optional. */ } has; } set_flags; - upb_string* name; - upb_string* extendee; + upb_strptr name; + upb_strptr extendee; int32_t number; int32_t label; int32_t type; - upb_string* type_name; - upb_string* default_value; + upb_strptr type_name; + upb_strptr default_value; google_protobuf_FieldOptions* options; }; UPB_DEFINE_MSG_ARRAY(google_protobuf_FieldDescriptorProto) diff --git a/src/upb.h b/src/upb.h index e130dd8..ecd5637 100644 --- a/src/upb.h +++ b/src/upb.h @@ -125,15 +125,50 @@ struct upb_tag { // INTERNAL-ONLY: never refer to these types with a tag ("union", "struct"). // Always use the typedefs. -union _upb_string; union _upb_array; struct _upb_msg; -typedef union _upb_string upb_string; typedef union _upb_array upb_array; typedef struct _upb_msg upb_msg; typedef upb_atomic_refcount_t upb_data; +typedef uint32_t upb_strlen_t; + +// We have several different representations for string, depending on whether +// it has a refcount (and likely in the future, depending on whether it is a +// slice of another string). We could just have one representation with +// members that are sometimes unused, but this is wasteful in memory. The +// flags that are always part of the first word tell us which representation +// to use. +// +// In a way, this is like inheritance but instead of using a virtual pointer, +// we do switch/case in every "virtual" method. This may sound expensive but +// in many cases the different cases compile to exactly the same code, so there +// is no branch. + +typedef struct { + uint32_t byte_size_and_flags; + upb_strlen_t byte_len; + // We expect the data to be 8-bit clean (uint8_t), but char* is such an + // ingrained convention that we follow it. + char *ptr; +} upb_norefcount_string; + +// Used for a string with a refcount. +typedef struct { + upb_data base; + upb_strlen_t byte_len; + char *ptr; + uint32_t byte_size; +} upb_refcounted_string; + +typedef union { + // Must be first, for the UPB_STATIC_STRING_PTR_INIT() macro. + upb_norefcount_string *norefcount; + upb_data *base; + upb_refcounted_string *refcounted; +} upb_strptr; + // A single .proto value. The owner must have an out-of-band way of knowing // the type, so that it knows which union member to use. union upb_value { @@ -144,7 +179,7 @@ union upb_value { uint32_t uint32; uint64_t uint64; bool _bool; - upb_string *str; + upb_strptr str; upb_array *arr; upb_msg *msg; upb_data *data; @@ -161,7 +196,7 @@ union upb_value_ptr { uint32_t *uint32; uint64_t *uint64; bool *_bool; - upb_string **str; + upb_strptr *str; upb_array **arr; upb_msg **msg; upb_data **data; diff --git a/src/upb_data.c b/src/upb_data.c index e1aebdf..01acef8 100644 --- a/src/upb_data.c +++ b/src/upb_data.c @@ -57,65 +57,81 @@ static void check_not_frozen(upb_data *d) { /* upb_string *******************************************************************/ -upb_string *upb_string_new() { - upb_string *s = malloc(sizeof(upb_refcounted_string)); - data_init(&s->common.base, UPB_DATA_HEAPALLOCATED | UPB_DATA_REFCOUNTED); - s->refcounted.byte_size = 0; - s->common.byte_len = 0; - s->common.ptr = NULL; +static char *_upb_string_setptr(upb_strptr s, char *ptr) { + if(upb_data_hasflag(s.base, UPB_DATA_REFCOUNTED)) + return s.refcounted->ptr = ptr; + else + return s.norefcount->ptr = ptr; +} + +static void _upb_string_set_bytelen(upb_strptr s, upb_strlen_t newlen) { + if(upb_data_hasflag(s.base, UPB_DATA_REFCOUNTED)) { + s.refcounted->byte_len = newlen; + } else { + s.norefcount->byte_len = newlen; + } +} + +upb_strptr upb_string_new() { + upb_strptr s; + s.refcounted = malloc(sizeof(upb_refcounted_string)); + data_init(s.base, UPB_DATA_HEAPALLOCATED | UPB_DATA_REFCOUNTED); + s.refcounted->byte_size = 0; + s.refcounted->byte_len = 0; + s.refcounted->ptr = NULL; return s; } -static upb_strlen_t string_get_bytesize(upb_string *s) { - if(upb_data_hasflag(&s->common.base, UPB_DATA_REFCOUNTED)) { - return s->refcounted.byte_size; +static upb_strlen_t string_get_bytesize(upb_strptr s) { + if(upb_data_hasflag(s.base, UPB_DATA_REFCOUNTED)) { + return s.refcounted->byte_size; } else { - return (s->norefcount.byte_size_and_flags & 0xFFFFFFF8) >> 3; + return (s.norefcount->byte_size_and_flags & 0xFFFFFFF8) >> 3; } } -static void string_set_bytesize(upb_string *s, upb_strlen_t newsize) { - if(upb_data_hasflag(&s->common.base, UPB_DATA_REFCOUNTED)) { - s->refcounted.byte_size = newsize; +static void string_set_bytesize(upb_strptr s, upb_strlen_t newsize) { + if(upb_data_hasflag(s.base, UPB_DATA_REFCOUNTED)) { + s.refcounted->byte_size = newsize; } else { - s->norefcount.byte_size_and_flags &= 0x7; - s->norefcount.byte_size_and_flags |= (newsize << 3); + s.norefcount->byte_size_and_flags &= 0x7; + s.norefcount->byte_size_and_flags |= (newsize << 3); } } -void _upb_string_free(upb_string *s) +void _upb_string_free(upb_strptr s) { - if(string_get_bytesize(s) != 0) free(s->common.ptr); - free(s); + if(string_get_bytesize(s) != 0) free((void*)upb_string_getrobuf(s)); + free(s.base); } -void upb_string_resize(upb_string *s, upb_strlen_t byte_len) { - check_not_frozen(&s->common.base); +void upb_string_resize(upb_strptr s, upb_strlen_t byte_len) { + check_not_frozen(s.base); if(string_get_bytesize(s) < byte_len) { // Need to resize. size_t new_byte_size = round_up_to_pow2(byte_len); - s->common.ptr = realloc(s->common.ptr, new_byte_size); + _upb_string_setptr(s, realloc(_upb_string_getptr(s), new_byte_size)); string_set_bytesize(s, new_byte_size); } - s->common.byte_len = byte_len; + _upb_string_set_bytelen(s, byte_len); } -upb_string *upb_string_getref(upb_string *s, int ref_flags) { - if(_upb_data_incref(&s->common.base, ref_flags)) return s; - upb_string *copy = upb_strdup(s); +upb_strptr upb_string_getref(upb_strptr s, int ref_flags) { + if(_upb_data_incref(s.base, ref_flags)) return s; + upb_strptr copy = upb_strdup(s); if(ref_flags == UPB_REF_FROZEN) - upb_data_setflag(©->common.base, UPB_DATA_FROZEN); + upb_data_setflag(copy.base, UPB_DATA_FROZEN); return copy; } -upb_string *upb_strreadfile(const char *filename) { +upb_strptr upb_strreadfile(const char *filename) { FILE *f = fopen(filename, "rb"); - if(!f) return false; + if(!f) return UPB_STRING_NULL; if(fseek(f, 0, SEEK_END) != 0) goto error; long size = ftell(f); if(size < 0) goto error; if(fseek(f, 0, SEEK_SET) != 0) goto error; - upb_string *s = upb_string_new(); + upb_strptr s = upb_string_new(); char *buf = upb_string_getrwbuf(s, size); if(fread(buf, size, 1, f) != 1) goto error; fclose(f); @@ -123,18 +139,18 @@ upb_string *upb_strreadfile(const char *filename) { error: fclose(f); - return NULL; + return UPB_STRING_NULL; } -upb_string *upb_strdupc(const char *src) { - upb_string *copy = upb_string_new(); +upb_strptr upb_strdupc(const char *src) { + upb_strptr copy = upb_string_new(); upb_strlen_t len = strlen(src); char *buf = upb_string_getrwbuf(copy, len); memcpy(buf, src, len); return copy; } -void upb_strcat(upb_string *s, upb_string *append) { +void upb_strcat(upb_strptr s, upb_strptr append) { upb_strlen_t s_len = upb_strlen(s); upb_strlen_t append_len = upb_strlen(append); upb_strlen_t newlen = s_len + append_len; @@ -142,20 +158,20 @@ void upb_strcat(upb_string *s, upb_string *append) { upb_string_getrobuf(append), append_len); } -upb_string *upb_strslice(upb_string *s, int offset, int len) { - upb_string *slice = upb_string_new(); +upb_strptr upb_strslice(upb_strptr s, int offset, int len) { + upb_strptr slice = upb_string_new(); len = UPB_MIN((upb_strlen_t)len, upb_strlen(s) - (upb_strlen_t)offset); memcpy(upb_string_getrwbuf(slice, len), upb_string_getrobuf(s) + offset, len); return slice; } -upb_string *upb_strdup(upb_string *s) { - upb_string *copy = upb_string_new(); +upb_strptr upb_strdup(upb_strptr s) { + upb_strptr copy = upb_string_new(); upb_strcpy(copy, s); return copy; } -int upb_strcmp(upb_string *s1, upb_string *s2) { +int upb_strcmp(upb_strptr s1, upb_strptr s2) { upb_strlen_t common_length = UPB_MIN(upb_strlen(s1), upb_strlen(s2)); int common_diff = memcmp(upb_string_getrobuf(s1), upb_string_getrobuf(s2), common_length); @@ -315,8 +331,8 @@ static bool str_cb(void *udata, struct upb_msgdef *msgdef, union upb_value_ptr p = get_value_ptr(msg, f); upb_msg_sethas(msg, f); if(avail_len != total_len) abort(); /* TODO: support streaming. */ - if(!*p.str || !upb_data_only(*p.data)) { - if(*p.str) + if(upb_string_isnull(*p.str) || !upb_data_only(*p.data)) { + if(!upb_string_isnull(*p.str)) upb_string_unref(*p.str); *p.str = upb_string_new(); } @@ -373,7 +389,7 @@ void upb_msgparser_free(struct upb_msgparser *s) free(s); } -void upb_msg_parsestr(upb_msg *msg, struct upb_msgdef *md, upb_string *str, +void upb_msg_parsestr(upb_msg *msg, struct upb_msgdef *md, upb_strptr str, struct upb_status *status) { struct upb_msgparser *mp = upb_msgparser_new(md); @@ -383,7 +399,7 @@ void upb_msg_parsestr(upb_msg *msg, struct upb_msgdef *md, upb_string *str, upb_msgparser_free(mp); } -size_t upb_msgparser_parse(struct upb_msgparser *s, upb_string *str, +size_t upb_msgparser_parse(struct upb_msgparser *s, upb_strptr str, struct upb_status *status) { return upb_cbparser_parse(s->s, str, status); diff --git a/src/upb_data.h b/src/upb_data.h index 6dc343b..9c55cee 100644 --- a/src/upb_data.h +++ b/src/upb_data.h @@ -165,88 +165,70 @@ INLINE bool _upb_data_unref(upb_data *d) { /* upb_string *****************************************************************/ -typedef uint32_t upb_strlen_t; - -// We have several different representations for string, depending on whether -// it has a refcount (and likely in the future, depending on whether it is a -// slice of another string). We could just have one representation with -// members that are sometimes unused, but this is wasteful in memory. The -// flags that are always part of the first word tell us which representation -// to use. -// -// upb_string_common is the members that are common to all representations. -typedef struct { - upb_data base; - upb_strlen_t byte_len; - // We expect the data to be 8-bit clean (uint8_t), but char* is such an - // ingrained convention that we follow it. - char *ptr; -} upb_string_common; - -// Used for a string without a refcount. -typedef struct { - uint32_t byte_size_and_flags; - upb_strlen_t byte_len; - char *ptr; -} upb_norefcount_string; - -// Used for a string with a refcount. -typedef struct { - upb_data base; - upb_strlen_t byte_len; - char *ptr; - uint32_t byte_size; -} upb_refcounted_string; - -union _upb_string { - upb_norefcount_string norefcount; - upb_string_common common; - upb_refcounted_string refcounted; -}; - // Returns a newly constructed, refcounted string which starts out empty. // Caller owns one ref on it. The returned string will not be frozen. -upb_string *upb_string_new(void); +upb_strptr upb_string_new(void); // INTERNAL-ONLY: // Frees the given string, alone with any memory the string owned. -void _upb_string_free(upb_string *s); +void _upb_string_free(upb_strptr s); // Returns a string to which caller owns a ref, and contains the same contents // as src. The returned value may be a copy of src, if the requested flags // were incompatible with src's. -upb_string *upb_string_getref(upb_string *s, int ref_flags); +upb_strptr upb_string_getref(upb_strptr s, int ref_flags); + +#define UPB_STRING_NULL_INITIALIZER {NULL} +static const upb_strptr UPB_STRING_NULL = UPB_STRING_NULL_INITIALIZER; +INLINE bool upb_string_isnull(upb_strptr s) { + return s.base == NULL; +} // The caller releases a ref on src, which it must previously have owned a ref // on. -INLINE void upb_string_unref(upb_string *s) { - if(_upb_data_unref(&s->common.base)) _upb_string_free(s); +INLINE void upb_string_unref(upb_strptr s) { + if(_upb_data_unref(s.base)) _upb_string_free(s); } // The string is resized to byte_len. The string must not be frozen. -void upb_string_resize(upb_string *s, upb_strlen_t len); +void upb_string_resize(upb_strptr s, upb_strlen_t len); // Returns a buffer to which the caller may write. The string is resized to // byte_len (which may or may not trigger a reallocation). The string must not // be frozen. -INLINE char *upb_string_getrwbuf(upb_string *s, upb_strlen_t byte_len) { +INLINE char *upb_string_getrwbuf(upb_strptr s, upb_strlen_t byte_len) { upb_string_resize(s, byte_len); - return s->common.ptr; + if(upb_data_hasflag(s.base, UPB_DATA_REFCOUNTED)) + return s.refcounted->ptr; + else + return s.norefcount->ptr; } -INLINE void upb_string_clear(upb_string *s) { +INLINE void upb_string_clear(upb_strptr s) { upb_string_getrwbuf(s, 0); } +// INTERNAL-ONLY: +// Gets/sets the pointer. +INLINE char *_upb_string_getptr(upb_strptr s) { + if(upb_data_hasflag(s.base, UPB_DATA_REFCOUNTED)) + return s.refcounted->ptr; + else + return s.norefcount->ptr; +} + // Returns a buffer that the caller may use to read the current contents of // the string. The number of bytes available is upb_strlen(s). -INLINE const char *upb_string_getrobuf(upb_string *s) { - return s->common.ptr; +INLINE const char *upb_string_getrobuf(upb_strptr s) { + return _upb_string_getptr(s); } // Returns the current length of the string. -INLINE upb_strlen_t upb_strlen(upb_string *s) { - return s->common.byte_len; +INLINE upb_strlen_t upb_strlen(upb_strptr s) { + if(upb_data_hasflag(s.base, UPB_DATA_REFCOUNTED)) + return s.refcounted->byte_len; + else + return s.norefcount->byte_len; } /* upb_string library functions ***********************************************/ @@ -255,7 +237,7 @@ INLINE upb_strlen_t upb_strlen(upb_string *s) { // overflow. These only use the public upb_string interface. // More efficient than upb_strcmp if all you need is to test equality. -INLINE bool upb_streql(upb_string *s1, upb_string *s2) { +INLINE bool upb_streql(upb_strptr s1, upb_strptr s2) { upb_strlen_t len = upb_strlen(s1); if(len != upb_strlen(s2)) { return false; @@ -265,54 +247,65 @@ INLINE bool upb_streql(upb_string *s1, upb_string *s2) { } // Like strcmp(). -int upb_strcmp(upb_string *s1, upb_string *s2); +int upb_strcmp(upb_strptr s1, upb_strptr s2); // Like upb_strcpy, but copies from a buffer and length. -INLINE void upb_strcpylen(upb_string *dest, const void *src, upb_strlen_t len) { +INLINE void upb_strcpylen(upb_strptr dest, const void *src, upb_strlen_t len) { memcpy(upb_string_getrwbuf(dest, len), src, len); } // Replaces the contents of "dest" with the contents of "src". -INLINE void upb_strcpy(upb_string *dest, upb_string *src) { +INLINE void upb_strcpy(upb_strptr dest, upb_strptr src) { upb_strcpylen(dest, upb_string_getrobuf(src), upb_strlen(src)); } // Like upb_strcpy, but copies from a NULL-terminated string. -INLINE void upb_strcpyc(upb_string *dest, const char *src) { +INLINE void upb_strcpyc(upb_strptr dest, const char *src) { // This does two passes over src, but that is necessary unless we want to // repeatedly re-allocate dst, which seems worse. upb_strcpylen(dest, src, strlen(src)); } // Returns a new string whose contents are a copy of s. -upb_string *upb_strdup(upb_string *s); +upb_strptr upb_strdup(upb_strptr s); // Like upb_strdup(), but duplicates a C NULL-terminated string. -upb_string *upb_strdupc(const char *src); +upb_strptr upb_strdupc(const char *src); // Appends 'append' to 's' in-place, resizing s if necessary. -void upb_strcat(upb_string *s, upb_string *append); +void upb_strcat(upb_strptr s, upb_strptr append); // Returns a string that is a substring of the given string. Currently this // returns a copy, but in the future this may return an object that references // the original string data instead of copying it. Both now and in the future, // the caller owns a ref on whatever is returned. -upb_string *upb_strslice(upb_string *s, int offset, int len); +upb_strptr upb_strslice(upb_strptr s, int offset, int len); // Reads an entire file into a newly-allocated string (caller owns one ref). -upb_string *upb_strreadfile(const char *filename); +upb_strptr upb_strreadfile(const char *filename); // Typedef for a read-only string that is allocated statically or on the stack. // Initialize with the given macro, which must resolve to a const char*. You -// must not dynamically allocate this type. -typedef upb_string upb_static_string; -#define UPB_STRLIT_LEN(str, len) {0 | UPB_DATA_FROZEN, len, str} -#define UPB_STRLIT(str) {{0 | UPB_DATA_FROZEN, sizeof(str)-1, str}} +// must not dynamically allocate this type. Example usage: +// +// upb_static_string mystr = UPB_STATIC_STRING_INIT("biscuits"); +// upb_strptr mystr_ptr = UPB_STATIC_STRING_PTR_INIT(mystr); +// +// If C99 compund literals are available, the much nicer UPB_STRLIT macro is +// available instead: +// +// upb_strtr mystr_ptr = UPB_STRLIT("biscuits"); +// +typedef upb_norefcount_string upb_static_string; +#define UPB_STATIC_STRING_INIT_LEN(str, len) {0 | UPB_DATA_FROZEN, len, str} +#define UPB_STATIC_STRING_INIT(str) UPB_STATIC_STRING_INIT_LEN(str, sizeof(str)-1) +#define UPB_STATIC_STRING_PTR_INIT(static_string) {&static_string} +#define UPB_STRLIT(str) (upb_strptr){&(upb_static_string)UPB_STATIC_STRING_INIT(str)} // Allows using upb_strings in printf, ie: -// upb_string str = UPB_STRLIT("Hello, World!\n"); +// upb_strptr str = UPB_STRLIT("Hello, World!\n"); // printf("String is: " UPB_STRFMT, UPB_STRARG(str)); */ -#define UPB_STRARG(str) (str)->common.byte_len, (str)->common.ptr +#define UPB_STRARG(str) upb_strlen(str), upb_string_getrobuf(str) #define UPB_STRFMT "%.*s" /* upb_array ******************************************************************/ @@ -472,7 +465,7 @@ INLINE void upb_msg_clear(upb_msg *msg, struct upb_msgdef *md) { /* Parsing ********************************************************************/ -void upb_msg_parsestr(upb_msg *msg, struct upb_msgdef *md, upb_string *str, +void upb_msg_parsestr(upb_msg *msg, struct upb_msgdef *md, upb_strptr str, struct upb_status *status); struct upb_msgparser *upb_msgparser_new(struct upb_msgdef *def); @@ -480,7 +473,7 @@ void upb_msgparser_free(struct upb_msgparser *mp); void upb_msgparser_reset(struct upb_msgparser *mp, upb_msg *m); -size_t upb_msgparser_parse(struct upb_msgparser *mp, upb_string *str, +size_t upb_msgparser_parse(struct upb_msgparser *mp, upb_strptr str, struct upb_status *status); #endif diff --git a/src/upb_def.c b/src/upb_def.c index b1c4ab2..4f57407 100644 --- a/src/upb_def.c +++ b/src/upb_def.c @@ -150,7 +150,7 @@ void _upb_def_cyclic_ref(struct upb_def *def) { } static void upb_def_init(struct upb_def *def, enum upb_def_type type, - upb_string *fqname) { + upb_strptr fqname) { def->type = type; def->is_cyclic = 0; // We detect this later, after resolving refs. def->search_depth = 0; @@ -166,12 +166,12 @@ static void upb_def_uninit(struct upb_def *def) { struct upb_unresolveddef { struct upb_def base; - upb_string *name; + upb_strptr name; }; -static struct upb_unresolveddef *upb_unresolveddef_new(upb_string *str) { +static struct upb_unresolveddef *upb_unresolveddef_new(upb_strptr str) { struct upb_unresolveddef *def = malloc(sizeof(*def)); - upb_string *name = upb_string_getref(str, UPB_REF_THREADUNSAFE_READONLY); + upb_strptr name = upb_string_getref(str, UPB_REF_THREADUNSAFE_READONLY); upb_def_init(&def->base, UPB_DEF_UNRESOLVED, name); def->name = name; return def; @@ -273,7 +273,7 @@ static void fielddef_sort(struct upb_fielddef **defs, size_t num) static struct upb_msgdef *msgdef_new(struct upb_fielddef **fields, int num_fields, - upb_string *fqname, + upb_strptr fqname, struct upb_status *status) { if(num_fields > UPB_MAX_FIELDS) { @@ -356,11 +356,11 @@ struct ntoi_ent { struct iton_ent { struct upb_inttable_entry e; - upb_string *string; + upb_strptr string; }; static struct upb_enumdef *enumdef_new(google_protobuf_EnumDescriptorProto *ed, - upb_string *fqname) + upb_strptr fqname) { struct upb_enumdef *e = malloc(sizeof(*e)); upb_def_init(&e->base, UPB_DEF_ENUM, fqname); @@ -428,8 +428,8 @@ static int my_memrchr(char *data, char c, size_t len) /* Given a symbol and the base symbol inside which it is defined, find the * symbol's definition in t. */ static struct symtab_ent *resolve(struct upb_strtable *t, - upb_string *base, - upb_string *symbol) + upb_strptr base, + upb_strptr symbol) { if(upb_strlen(base) + upb_strlen(symbol) + 1 >= UPB_SYMBOL_MAXLEN || upb_strlen(symbol) == 0) return NULL; @@ -437,13 +437,13 @@ static struct symtab_ent *resolve(struct upb_strtable *t, if(upb_string_getrobuf(symbol)[0] == UPB_SYMBOL_SEPARATOR) { // Symbols starting with '.' are absolute, so we do a single lookup. // Slice to omit the leading '.' - upb_string *sym_str = upb_strslice(symbol, 1, INT_MAX); + upb_strptr sym_str = upb_strslice(symbol, 1, INT_MAX); struct symtab_ent *e = upb_strtable_lookup(t, sym_str); upb_string_unref(sym_str); return e; } else { // Remove components from base until we find an entry or run out. - upb_string *sym_str = upb_string_new(); + upb_strptr sym_str = upb_string_new(); int baselen = upb_strlen(base); while(1) { // sym_str = base[0...base_len] + UPB_SYMBOL_SEPARATOR + symbol @@ -466,8 +466,8 @@ static struct symtab_ent *resolve(struct upb_strtable *t, * join("Foo.Bar", "Baz") -> "Foo.Bar.Baz" * join("", "Baz") -> "Baz" * Caller owns a ref on the returned string. */ -static upb_string *join(upb_string *base, upb_string *name) { - upb_string *joined = upb_strdup(base); +static upb_strptr join(upb_strptr base, upb_strptr name) { + upb_strptr joined = upb_strdup(base); upb_strlen_t len = upb_strlen(joined); if(len > 0) { upb_string_getrwbuf(joined, len + 1)[len] = UPB_SYMBOL_SEPARATOR; @@ -476,34 +476,34 @@ static upb_string *join(upb_string *base, upb_string *name) { return joined; } -static upb_string *try_define(struct upb_strtable *t, upb_string *base, - upb_string *name, struct upb_status *status) +static upb_strptr try_define(struct upb_strtable *t, upb_strptr base, + upb_strptr name, struct upb_status *status) { - if(!name) { + if(upb_string_isnull(name)) { upb_seterr(status, UPB_STATUS_ERROR, "symbol in context '" UPB_STRFMT "' does not have a name", UPB_STRARG(base)); - return NULL; + return UPB_STRING_NULL; } - upb_string *fqname = join(base, name); + upb_strptr fqname = join(base, name); if(upb_strtable_lookup(t, fqname)) { upb_seterr(status, UPB_STATUS_ERROR, "attempted to redefine symbol '" UPB_STRFMT "'", UPB_STRARG(fqname)); upb_string_unref(fqname); - return NULL; + return UPB_STRING_NULL; } return fqname; } static void insert_enum(struct upb_strtable *t, google_protobuf_EnumDescriptorProto *ed, - upb_string *base, + upb_strptr base, struct upb_status *status) { - upb_string *name = ed->set_flags.has.name ? ed->name : NULL; - upb_string *fqname = try_define(t, base, name, status); - if(!fqname) return; + upb_strptr name = ed->set_flags.has.name ? ed->name : UPB_STRING_NULL; + upb_strptr fqname = try_define(t, base, name, status); + if(upb_string_isnull(fqname)) return; struct symtab_ent e; e.e.key = fqname; @@ -514,12 +514,12 @@ static void insert_enum(struct upb_strtable *t, static void insert_message(struct upb_strtable *t, google_protobuf_DescriptorProto *d, - upb_string *base, bool sort, + upb_strptr base, bool sort, struct upb_status *status) { - upb_string *name = d->set_flags.has.name ? d->name : NULL; - upb_string *fqname = try_define(t, base, name, status); - if(!fqname) return; + upb_strptr name = d->set_flags.has.name ? d->name : UPB_STRING_NULL; + upb_strptr fqname = try_define(t, base, name, status); + if(upb_string_isnull(fqname)) return; int num_fields = d->set_flags.has.field ? d->field->len : 0; struct symtab_ent e; @@ -610,7 +610,7 @@ static void addfd(struct upb_strtable *addto, struct upb_strtable *existingdefs, google_protobuf_FileDescriptorProto *fd, bool sort, struct upb_status *status) { - upb_string *pkg; + upb_strptr pkg; if(fd->set_flags.has.package) { pkg = upb_string_getref(fd->package, UPB_REF_FROZEN); } else { @@ -639,11 +639,11 @@ static void addfd(struct upb_strtable *addto, struct upb_strtable *existingdefs, for(e = upb_strtable_begin(addto); e; e = upb_strtable_next(addto, &e->e)) { struct upb_msgdef *m = upb_dyncast_msgdef(e->def); if(!m) continue; - upb_string *base = e->e.key; + upb_strptr base = e->e.key; for(upb_field_count_t i = 0; i < m->num_fields; i++) { struct upb_fielddef *f = &m->fields[i]; if(!upb_hasdef(f)) continue; // No resolving necessary. - upb_string *name = upb_downcast_unresolveddef(f->def)->name; + upb_strptr name = upb_downcast_unresolveddef(f->def)->name; struct symtab_ent *found = resolve(existingdefs, base, name); if(!found) found = resolve(addto, base, name); upb_field_type_t expected = upb_issubmsg(f) ? UPB_DEF_MSG : UPB_DEF_ENUM; @@ -695,8 +695,10 @@ struct upb_symtab *upb_symtab_new() assert(false); return NULL; // Indicates that upb is buggy or corrupt. } - upb_string name = UPB_STRLIT("google.protobuf.FileDescriptorSet"); - struct symtab_ent *e = upb_strtable_lookup(&s->psymtab, &name); + upb_static_string name = + UPB_STATIC_STRING_INIT("google.protobuf.FileDescriptorSet"); + upb_strptr nameptr = UPB_STATIC_STRING_PTR_INIT(name); + struct symtab_ent *e = upb_strtable_lookup(&s->psymtab, nameptr); assert(e); s->fds_msgdef = upb_downcast_msgdef(e->def); return s; @@ -741,7 +743,7 @@ struct upb_def **upb_symtab_getdefs(struct upb_symtab *s, int *count, return defs; } -struct upb_def *upb_symtab_lookup(struct upb_symtab *s, upb_string *sym) +struct upb_def *upb_symtab_lookup(struct upb_symtab *s, upb_strptr sym) { upb_rwlock_rdlock(&s->lock); struct symtab_ent *e = upb_strtable_lookup(&s->symtab, sym); @@ -755,8 +757,8 @@ struct upb_def *upb_symtab_lookup(struct upb_symtab *s, upb_string *sym) } -struct upb_def *upb_symtab_resolve(struct upb_symtab *s, upb_string *base, - upb_string *symbol) { +struct upb_def *upb_symtab_resolve(struct upb_symtab *s, upb_strptr base, + upb_strptr symbol) { upb_rwlock_rdlock(&s->lock); struct symtab_ent *e = resolve(&s->symtab, base, symbol); struct upb_def *ret = NULL; @@ -818,7 +820,7 @@ void upb_symtab_addfds(struct upb_symtab *s, return; } -void upb_symtab_add_desc(struct upb_symtab *s, upb_string *desc, +void upb_symtab_add_desc(struct upb_symtab *s, upb_strptr desc, struct upb_status *status) { upb_msg *fds = upb_msg_new(s->fds_msgdef); diff --git a/src/upb_def.h b/src/upb_def.h index d44f879..15af25a 100644 --- a/src/upb_def.h +++ b/src/upb_def.h @@ -53,7 +53,7 @@ enum upb_def_type { typedef int8_t upb_def_type_t; struct upb_def { - upb_string *fqname; // Fully qualified. + upb_strptr fqname; // Fully qualified. upb_atomic_refcount_t refcount; upb_def_type_t type; @@ -121,7 +121,7 @@ struct upb_fielddef { upb_field_type_t type; upb_label_t label; upb_field_number_t number; - upb_string *name; + upb_strptr name; union upb_value default_value; // These are set only when this fielddef is part of a msgdef. @@ -206,7 +206,7 @@ INLINE struct upb_fielddef *upb_msg_itof(struct upb_msgdef *m, uint32_t num) { } INLINE struct upb_fielddef *upb_msg_ntof(struct upb_msgdef *m, - upb_string *name) { + upb_strptr name) { struct upb_ntof_ent *e; e = (struct upb_ntof_ent*)upb_strtable_lookup(&m->ntof, name); return e ? e->f : NULL; @@ -223,9 +223,9 @@ struct upb_enumdef { typedef int32_t upb_enumval_t; // Lookups from name to integer and vice-versa. -bool upb_enumdef_ntoi(struct upb_enumdef *e, upb_string *name, +bool upb_enumdef_ntoi(struct upb_enumdef *e, upb_strptr name, upb_enumval_t *num); -upb_string *upb_enumdef_iton(struct upb_enumdef *e, upb_enumval_t num); +upb_strptr upb_enumdef_iton(struct upb_enumdef *e, upb_enumval_t num); // Iteration over name/value pairs. The order is undefined. // struct upb_enumd_iter i; @@ -235,7 +235,7 @@ upb_string *upb_enumdef_iton(struct upb_enumdef *e, upb_enumval_t num); struct upb_enum_iter { struct upb_enumdef *e; void *state; // Internal iteration state. - upb_string *name; + upb_strptr name; upb_enumval_t val; }; void upb_enum_begin(struct upb_enum_iter *iter, struct upb_enumdef *e); @@ -279,12 +279,12 @@ INLINE void upb_symtab_unref(struct upb_symtab *s) { // // If a def is found, the caller owns one ref on the returned def. Otherwise // returns NULL. -struct upb_def *upb_symtab_resolve(struct upb_symtab *s, upb_string *base, - upb_string *symbol); +struct upb_def *upb_symtab_resolve(struct upb_symtab *s, upb_strptr base, + upb_strptr symbol); // Find an entry in the symbol table with this exact name. If a def is found, // the caller owns one ref on the returned def. Otherwise returns NULL. -struct upb_def *upb_symtab_lookup(struct upb_symtab *s, upb_string *sym); +struct upb_def *upb_symtab_lookup(struct upb_symtab *s, upb_strptr sym); // Gets an array of pointers to all currently active defs in this symtab. The // caller owns the returned array (which is of length *count) as well as a ref @@ -298,7 +298,7 @@ struct upb_def **upb_symtab_getdefs(struct upb_symtab *s, int *count, // defined in desc). desc may not attempt to define any names that are already // defined in this symtab. Caller retains ownership of desc. status indicates // whether the operation was successful or not, and the error message (if any). -void upb_symtab_add_desc(struct upb_symtab *s, upb_string *desc, +void upb_symtab_add_desc(struct upb_symtab *s, upb_strptr desc, struct upb_status *status); #ifdef __cplusplus diff --git a/src/upb_parse.c b/src/upb_parse.c index 32332d9..c4790c6 100644 --- a/src/upb_parse.c +++ b/src/upb_parse.c @@ -416,7 +416,7 @@ static const void *pop(struct upb_cbparser *p, const uint8_t *start) } -size_t upb_cbparser_parse(struct upb_cbparser *p, upb_string *str, +size_t upb_cbparser_parse(struct upb_cbparser *p, upb_strptr str, struct upb_status *status) { // buf is our current offset, moves from start to end. diff --git a/src/upb_parse.h b/src/upb_parse.h index 7086204..056750f 100644 --- a/src/upb_parse.h +++ b/src/upb_parse.h @@ -80,7 +80,7 @@ void upb_cbparser_reset(struct upb_cbparser *p, void *udata); // // TODO: see if we can provide the following guarantee efficiently: // retval will always be >= len. */ -size_t upb_cbparser_parse(struct upb_cbparser *p, upb_string *str, +size_t upb_cbparser_parse(struct upb_cbparser *p, upb_strptr str, struct upb_status *status); /* Pick parser interface. ************************************************/ @@ -119,7 +119,7 @@ struct upb_pickparser *upb_pickparser_new(struct upb_msgdef *msgdef, upb_pp_str_cb str_cb); void upb_pickparser_free(struct upb_pickparser *p); void upb_pickparser_reset(struct upb_pickparser *p, void *udata); -size_t upb_pickparser_parse(struct upb_pickparser *p, upb_string *str, +size_t upb_pickparser_parse(struct upb_pickparser *p, upb_strptr str, struct upb_status *status); #ifdef __cplusplus diff --git a/src/upb_table.c b/src/upb_table.c index f6f6d22..14902df 100644 --- a/src/upb_table.c +++ b/src/upb_table.c @@ -57,19 +57,19 @@ void upb_strtable_free(struct upb_strtable *t) { upb_table_free(&t->t); } -static uint32_t strtable_bucket(struct upb_strtable *t, upb_string *key) +static uint32_t strtable_bucket(struct upb_strtable *t, upb_strptr key) { uint32_t hash = MurmurHash2(upb_string_getrobuf(key), upb_strlen(key), 0); return (hash & (upb_strtable_size(t)-1)) + 1; } -void *upb_strtable_lookup(struct upb_strtable *t, upb_string *key) +void *upb_strtable_lookup(struct upb_strtable *t, upb_strptr key) { uint32_t bucket = strtable_bucket(t, key); struct upb_strtable_entry *e; do { e = strent(t, bucket); - if(e->key && upb_streql(e->key, key)) return e; + if(!upb_string_isnull(e->key) && upb_streql(e->key, key)) return e; } while((bucket = e->next) != UPB_END_OF_CHAIN); return NULL; } @@ -149,7 +149,7 @@ static uint32_t empty_strbucket(struct upb_strtable *table) /* TODO: does it matter that this is biased towards the front of the table? */ for(uint32_t i = 1; i <= upb_strtable_size(table); i++) { struct upb_strtable_entry *e = strent(table, i); - if(e->key == NULL) return i; + if(upb_string_isnull(e->key)) return i; } assert(false); return 0; @@ -162,7 +162,7 @@ static void strinsert(struct upb_strtable *t, struct upb_strtable_entry *e) t->t.count++; uint32_t bucket = strtable_bucket(t, e->key); struct upb_strtable_entry *table_e = strent(t, bucket); - if(table_e->key != NULL) { /* Collision. */ + if(!upb_string_isnull(table_e->key)) { /* Collision. */ if(bucket == strtable_bucket(t, table_e->key)) { /* Existing element is in its main posisiton. Find an empty slot to * place our new element and append it to this key's chain. */ @@ -179,7 +179,7 @@ static void strinsert(struct upb_strtable *t, struct upb_strtable_entry *e) memcpy(strent(t, empty_bucket), table_e, t->t.entry_size); /* copies next */ struct upb_strtable_entry *evictee_e = strent(t, evictee_bucket); while(1) { - assert(evictee_e->key != NULL); + assert(!upb_string_isnull(evictee_e->key)); assert(evictee_e->next != UPB_END_OF_CHAIN); if(evictee_e->next == bucket) { evictee_e->next = empty_bucket; @@ -232,7 +232,7 @@ void *upb_strtable_next(struct upb_strtable *t, struct upb_strtable_entry *cur) do { cur = (void*)((char*)cur + t->t.entry_size); if(cur == end) return NULL; - } while(cur->key == NULL); + } while(upb_string_isnull(cur->key)); return cur; } diff --git a/src/upb_table.h b/src/upb_table.h index b89906d..f7f548b 100644 --- a/src/upb_table.h +++ b/src/upb_table.h @@ -38,7 +38,7 @@ struct upb_inttable_entry { // performance by letting us compare hashes before comparing lengths or the // strings themselves. struct upb_strtable_entry { - upb_string *key; // We own a frozen ref. + upb_strptr key; // We own a frozen ref. uint32_t next; // Internal chaining. }; @@ -116,7 +116,7 @@ INLINE void *upb_inttable_lookup(struct upb_inttable *t, uint32_t key) { return upb_inttable_fast_lookup(t, key, t->t.entry_size); } -void *upb_strtable_lookup(struct upb_strtable *t, upb_string *key); +void *upb_strtable_lookup(struct upb_strtable *t, upb_strptr key); /* Provides iteration over the table. The order in which the entries are * returned is undefined. Insertions invalidate iterators. The _next diff --git a/src/upb_text.c b/src/upb_text.c index 17efa9f..225b344 100644 --- a/src/upb_text.c +++ b/src/upb_text.c @@ -49,7 +49,7 @@ static void print_indent(struct upb_text_printer *p, FILE *stream) } void upb_text_printfield(struct upb_text_printer *p, - upb_string *name, + upb_strptr name, upb_field_type_t valtype, union upb_value val, FILE *stream) { @@ -63,7 +63,7 @@ void upb_text_printfield(struct upb_text_printer *p, } void upb_text_push(struct upb_text_printer *p, - upb_string *submsg_type, + upb_strptr submsg_type, FILE *stream) { print_indent(p, stream); diff --git a/src/upb_text.h b/src/upb_text.h index 6b2f4eb..bc15c3f 100644 --- a/src/upb_text.h +++ b/src/upb_text.h @@ -23,10 +23,10 @@ INLINE void upb_text_printer_init(struct upb_text_printer *p, bool single_line) p->single_line = single_line; } void upb_text_printval(upb_field_type_t type, union upb_value p, FILE *file); -void upb_text_printfield(struct upb_text_printer *p, upb_string *name, +void upb_text_printfield(struct upb_text_printer *p, upb_strptr name, upb_field_type_t valtype, union upb_value val, FILE *stream); -void upb_text_push(struct upb_text_printer *p, upb_string *submsg_type, +void upb_text_push(struct upb_text_printer *p, upb_strptr submsg_type, FILE *stream); void upb_text_pop(struct upb_text_printer *p, FILE *stream); diff --git a/tools/upbc.c b/tools/upbc.c index ed80d39..274aa00 100644 --- a/tools/upbc.c +++ b/tools/upbc.c @@ -21,7 +21,7 @@ * the string (and thus never need to re-allocate). */ // Convert to C identifier: foo.bar.Baz -> foo_bar_Baz. -static void to_cident(upb_string *str) +static void to_cident(upb_strptr str) { upb_strlen_t len = upb_strlen(str); char *buf = upb_string_getrwbuf(str, len); @@ -31,7 +31,7 @@ static void to_cident(upb_string *str) } // Convert to C proprocessor identifier: foo.bar.Baz -> FOO_BAR_BAZ. -static void to_preproc(upb_string *str) +static void to_preproc(upb_strptr str) { to_cident(str); upb_strlen_t len = upb_strlen(str); @@ -65,7 +65,7 @@ static void write_const_h(struct upb_def *defs[], int num_entries, char *outfile_name, FILE *stream) { /* Header file prologue. */ - upb_string *include_guard_name = upb_strdupc(outfile_name); + upb_strptr include_guard_name = upb_strdupc(outfile_name); to_preproc(include_guard_name); /* A bit cheesy, but will do the job. */ upb_strlen_t len = upb_strlen(include_guard_name); @@ -85,8 +85,8 @@ static void write_const_h(struct upb_def *defs[], int num_entries, for(int i = 0; i < num_entries; i++) { /* Foreach enum */ if(defs[i]->type != UPB_DEF_ENUM) continue; struct upb_enumdef *enumdef = upb_downcast_enumdef(defs[i]); - upb_string *enum_name = upb_strdup(UPB_UPCAST(enumdef)->fqname); - upb_string *enum_val_prefix = upb_strdup(enum_name); + upb_strptr enum_name = upb_strdup(UPB_UPCAST(enumdef)->fqname); + upb_strptr enum_val_prefix = upb_strdup(enum_name); to_cident(enum_name); const char *data = upb_string_getrobuf(enum_val_prefix); @@ -100,7 +100,7 @@ static void write_const_h(struct upb_def *defs[], int num_entries, bool first = true; /* Foreach enum value. */ for(upb_enum_begin(&iter, enumdef); !upb_enum_done(&iter); upb_enum_next(&iter)) { - upb_string *value_name = upb_strdup(iter.name); + upb_strptr value_name = upb_strdup(iter.name); to_preproc(value_name); /* " GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_UINT32 = 13," */ if (!first) fputs(",\n", stream); @@ -130,7 +130,7 @@ static void write_h(struct upb_def *defs[], int num_defs, char *outfile_name, char *descriptor_cident, FILE *stream) { /* Header file prologue. */ - upb_string *include_guard_name = upb_strdupc(outfile_name); + upb_strptr include_guard_name = upb_strdupc(outfile_name); to_preproc(include_guard_name); fputs("/* This file was generated by upbc (the upb compiler). " "Do not edit. */\n\n", stream), @@ -155,7 +155,7 @@ static void write_h(struct upb_def *defs[], int num_defs, char *outfile_name, for(int i = 0; i < num_defs; i++) { /* Foreach message */ struct upb_msgdef *m = upb_dyncast_msgdef(defs[i]); if(!m) continue; - upb_string *msg_name = upb_strdup(UPB_UPCAST(m)->fqname); + upb_strptr msg_name = upb_strdup(UPB_UPCAST(m)->fqname); to_cident(msg_name); fprintf(stream, "struct " UPB_STRFMT ";\n", UPB_STRARG(msg_name)); fprintf(stream, "typedef struct " UPB_STRFMT "\n " UPB_STRFMT ";\n\n", @@ -168,7 +168,7 @@ static void write_h(struct upb_def *defs[], int num_defs, char *outfile_name, for(int i = 0; i < num_defs; i++) { /* Foreach message */ struct upb_msgdef *m = upb_dyncast_msgdef(defs[i]); if(!m) continue; - upb_string *msg_name = upb_strdup(UPB_UPCAST(m)->fqname); + upb_strptr msg_name = upb_strdup(UPB_UPCAST(m)->fqname); to_cident(msg_name); fprintf(stream, "struct " UPB_STRFMT " {\n", UPB_STRARG(msg_name)); fputs(" upb_data base;\n", stream); @@ -186,9 +186,9 @@ static void write_h(struct upb_def *defs[], int num_defs, char *outfile_name, for(upb_field_count_t j = 0; j < m->num_fields; j++) { struct upb_fielddef *f = &m->fields[j]; if(upb_issubmsg(f)) { - upb_string *type_name = upb_strdup(f->def->fqname); + upb_strptr type_name = upb_strdup(f->def->fqname); to_cident(type_name); - if(f->label == GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_REPEATED) { + if(f->label == UPB_LABEL(REPEATED)) { fprintf(stream, " UPB_MSG_ARRAY(" UPB_STRFMT ")* " UPB_STRFMT ";\n", UPB_STRARG(type_name), UPB_STRARG(f->name)); } else { @@ -196,25 +196,13 @@ static void write_h(struct upb_def *defs[], int num_defs, char *outfile_name, UPB_STRARG(type_name), UPB_STRARG(f->name)); } upb_string_unref(type_name); - } else if(f->label == GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_REPEATED) { - static char* c_types[] = { - "", "struct upb_double_array*", "struct upb_float_array*", - "struct upb_int64_array*", "struct upb_uint64_array*", - "struct upb_int32_array*", "struct upb_uint64_array*", - "struct upb_uint32_array*", "struct upb_bool_array*", - "struct upb_string_array*", "", "", - "struct upb_string_array*", "struct upb_uint32_array*", - "struct upb_uint32_array*", "struct upb_int32_array*", - "struct upb_int64_array*", "struct upb_int32_array*", - "struct upb_int64_array*" - }; - fprintf(stream, " %s " UPB_STRFMT ";\n", - c_types[f->type], UPB_STRARG(f->name)); + } else if(f->label == UPB_LABEL(REPEATED)) { + fprintf(stream, " upb_array* " UPB_STRFMT ";\n", UPB_STRARG(f->name)); } else { static char* c_types[] = { "", "double", "float", "int64_t", "uint64_t", "int32_t", "uint64_t", - "uint32_t", "bool", "upb_string*", "", "", - "upb_string*", "uint32_t", "int32_t", "int32_t", "int64_t", + "uint32_t", "bool", "upb_strptr", "", "", + "upb_strptr", "uint32_t", "int32_t", "int32_t", "int64_t", "int32_t", "int64_t" }; fprintf(stream, " %s " UPB_STRFMT ";\n", @@ -246,7 +234,7 @@ struct strtable_entry { struct typetable_entry { struct upb_strtable_entry e; struct upb_fielddef *field; - upb_string *cident; /* Type name converted with to_cident(). */ + upb_strptr cident; /* Type name converted with to_cident(). */ /* A list of all values of this type, in an established order. */ union upb_value *values; int values_size, values_len; @@ -316,11 +304,11 @@ static void add_strings_from_msg(upb_msg *msg, struct upb_msgdef *md, struct typetable_entry *get_or_insert_typeentry(struct upb_strtable *t, struct upb_fielddef *f) { - upb_string *type_name = upb_issubmsg(f) ? upb_strdup(f->def->fqname) : + upb_strptr type_name = upb_issubmsg(f) ? upb_strdup(f->def->fqname) : upb_strdupc(upb_type_info[f->type].ctype); struct typetable_entry *type_e = upb_strtable_lookup(t, type_name); if(type_e == NULL) { - upb_string *cident = upb_strdup(type_name); + upb_strptr cident = upb_strdup(type_name); to_cident(cident); struct typetable_entry new_type_e = { .e = {.key = type_name}, .field = f, .cident = cident, @@ -434,7 +422,7 @@ static void write_message_c(upb_msg *msg, struct upb_msgdef *md, int col = 2; int offset = 0; for(int i = 0; i < size; i++) { - upb_string *s = str_entries[i]->e.key; + upb_strptr s = str_entries[i]->e.key; str_entries[i]->offset = offset; str_entries[i]->num = i; const char *buf = upb_string_getrobuf(s); @@ -452,7 +440,7 @@ static void write_message_c(upb_msg *msg, struct upb_msgdef *md, fputs("static upb_norefcount_string strings[] = {\n", stream); for(int i = 0; i < size; i++) { struct strtable_entry *e = str_entries[i]; - fprintf(stream, " UPB_STRLIT_LEN(&strdata[%d], %d),\n", e->offset, upb_strlen(e->e.key)); + fprintf(stream, " UPB_STATIC_STRING_INIT_LEN(&strdata[%d], %d),\n", e->offset, upb_strlen(e->e.key)); } fputs("};\n\n", stream); free(str_entries); @@ -527,7 +515,11 @@ static void write_message_c(upb_msg *msg, struct upb_msgdef *md, union upb_value val = upb_msg_get(msgdata, f); fprintf(stream, " ." UPB_STRFMT " = ", UPB_STRARG(f->name)); if(!upb_msg_has(msgdata, f)) { - fputs("0, /* Not set. */", stream); + if(upb_isstring(f) && !upb_isarray(f)) { + fputs("UPB_STRING_NULL_INITIALIZER, /* Not set. */", stream); + } else { + fputs("0, /* Not set. */", stream); + } } else if(upb_isstring(f)) { if(upb_isarray(f)) { fputs("Ack, string arrays are not supported yet!\n", stderr); @@ -535,7 +527,7 @@ static void write_message_c(upb_msg *msg, struct upb_msgdef *md, } else { struct strtable_entry *str_e = upb_strtable_lookup(&strings, val.str); assert(str_e); - fprintf(stream, "(upb_string*)&strings[%d], /* \"" UPB_STRFMT "\" */", + fprintf(stream, "UPB_STATIC_STRING_PTR_INIT(strings[%d]), /* \"" UPB_STRFMT "\" */", str_e->num, UPB_STRARG(val.str)); } } else if(upb_isarray(f)) { @@ -666,8 +658,8 @@ int main(int argc, char *argv[]) if(!outfile_base) outfile_base = input_file; // Read and parse input file. - upb_string *descriptor = upb_strreadfile(input_file); - if(!descriptor) + upb_strptr descriptor = upb_strreadfile(input_file); + if(upb_string_isnull(descriptor)) error("Couldn't read input file."); struct upb_symtab *s = upb_symtab_new(); upb_msg *fds_msg = upb_msg_new(s->fds_msgdef); -- cgit v1.2.3