Skip to content

Commit 667f9ed

Browse files
Auto-generate files after cl/850499478
1 parent 0b16042 commit 667f9ed

File tree

4 files changed

+80
-75
lines changed

4 files changed

+80
-75
lines changed

php/ext/google/protobuf/php-upb.c

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13232,12 +13232,12 @@ static void set_default_default(upb_DefBuilder* ctx, upb_FieldDef* f,
1323213232
static bool _upb_FieldDef_InferLegacyFeatures(
1323313233
upb_DefBuilder* ctx, upb_FieldDef* f,
1323413234
const UPB_DESC(FieldDescriptorProto*) proto,
13235-
const UPB_DESC(FieldOptions*) options, upb_Syntax syntax,
13235+
const UPB_DESC(FieldOptions*) options, google_protobuf_Edition edition,
1323613236
UPB_DESC(FeatureSet*) features) {
1323713237
bool ret = false;
1323813238

1323913239
if (UPB_DESC(FieldDescriptorProto_label)(proto) == kUpb_Label_Required) {
13240-
if (syntax == kUpb_Syntax_Proto3) {
13240+
if (edition == google_protobuf_EDITION_PROTO3) {
1324113241
_upb_DefBuilder_Errf(ctx, "proto3 fields cannot be required (%s)",
1324213242
f->full_name);
1324313243
}
@@ -13281,15 +13281,15 @@ static void _upb_FieldDef_Create(upb_DefBuilder* ctx, const char* prefix,
1328113281

1328213282
UPB_DEF_SET_OPTIONS(f->opts, FieldDescriptorProto, FieldOptions, field_proto);
1328313283

13284-
upb_Syntax syntax = upb_FileDef_Syntax(f->file);
13284+
UPB_DESC(Edition) edition = upb_FileDef_Edition(f->file);
1328513285
const UPB_DESC(FeatureSet*) unresolved_features =
1328613286
UPB_DESC(FieldOptions_features)(f->opts);
1328713287
bool implicit = false;
1328813288

13289-
if (syntax != kUpb_Syntax_Editions) {
13289+
if (_upb_DefBuilder_IsLegacyEdition(edition)) {
1329013290
upb_Message_Clear(UPB_UPCAST(ctx->legacy_features),
1329113291
UPB_DESC_MINITABLE(FeatureSet));
13292-
if (_upb_FieldDef_InferLegacyFeatures(ctx, f, field_proto, f->opts, syntax,
13292+
if (_upb_FieldDef_InferLegacyFeatures(ctx, f, field_proto, f->opts, edition,
1329313293
ctx->legacy_features)) {
1329413294
implicit = true;
1329513295
unresolved_features = ctx->legacy_features;
@@ -13672,7 +13672,7 @@ static void resolve_default(upb_DefBuilder* ctx, upb_FieldDef* f,
1367213672
f->full_name);
1367313673
}
1367413674

13675-
if (upb_FileDef_Syntax(f->file) == kUpb_Syntax_Proto3) {
13675+
if (upb_FileDef_Edition(f->file) == google_protobuf_EDITION_PROTO3) {
1367613676
_upb_DefBuilder_Errf(ctx,
1367713677
"proto3 fields cannot have explicit defaults (%s)",
1367813678
f->full_name);
@@ -13738,7 +13738,6 @@ struct upb_FileDef {
1373813738
int top_lvl_ext_count;
1373913739
int service_count;
1374013740
int ext_count; // All exts in the file.
13741-
upb_Syntax syntax;
1374213741
};
1374313742

1374413743
UPB_API const char* upb_FileDef_EditionName(int edition) {
@@ -13780,8 +13779,6 @@ UPB_DESC(Edition) upb_FileDef_Edition(const upb_FileDef* f) {
1378013779

1378113780
const char* _upb_FileDef_RawPackage(const upb_FileDef* f) { return f->package; }
1378213781

13783-
upb_Syntax upb_FileDef_Syntax(const upb_FileDef* f) { return f->syntax; }
13784-
1378513782
int upb_FileDef_TopLevelMessageCount(const upb_FileDef* f) {
1378613783
return f->top_lvl_msg_count;
1378713784
}
@@ -14010,27 +14007,30 @@ void _upb_FileDef_Create(upb_DefBuilder* ctx,
1401014007
file->package = NULL;
1401114008
}
1401214009

14013-
// TODO: How should we validate this?
14014-
file->edition = UPB_DESC(FileDescriptorProto_edition)(file_proto);
14015-
14016-
if (UPB_DESC(FileDescriptorProto_has_syntax)(file_proto)) {
14017-
upb_StringView syntax = UPB_DESC(FileDescriptorProto_syntax)(file_proto);
14010+
upb_StringView syntax = UPB_DESC(FileDescriptorProto_syntax)(file_proto);
1401814011

14012+
if (UPB_DESC(FileDescriptorProto_has_edition)(file_proto)) {
14013+
if (!streql_view(syntax, "editions")) {
14014+
_upb_DefBuilder_Errf(ctx,
14015+
"Setting edition requires that syntax=\"editions\", "
14016+
"but syntax is \"" UPB_STRINGVIEW_FORMAT "\"",
14017+
UPB_STRINGVIEW_ARGS(syntax));
14018+
}
14019+
file->edition = UPB_DESC(FileDescriptorProto_edition)(file_proto);
14020+
} else if (UPB_DESC(FileDescriptorProto_has_syntax)(file_proto)) {
1401914021
if (streql_view(syntax, "proto2")) {
14020-
file->syntax = kUpb_Syntax_Proto2;
1402114022
file->edition = UPB_DESC(EDITION_PROTO2);
1402214023
} else if (streql_view(syntax, "proto3")) {
14023-
file->syntax = kUpb_Syntax_Proto3;
1402414024
file->edition = UPB_DESC(EDITION_PROTO3);
1402514025
} else if (streql_view(syntax, "editions")) {
14026-
file->syntax = kUpb_Syntax_Editions;
14027-
file->edition = UPB_DESC(FileDescriptorProto_edition)(file_proto);
14026+
_upb_DefBuilder_Errf(
14027+
ctx, "File has syntax=\"editions\", but no edition is specified");
1402814028
} else {
1402914029
_upb_DefBuilder_Errf(ctx, "Invalid syntax '" UPB_STRINGVIEW_FORMAT "'",
1403014030
UPB_STRINGVIEW_ARGS(syntax));
1403114031
}
1403214032
} else {
14033-
file->syntax = kUpb_Syntax_Proto2;
14033+
// The legacy default when no edition or syntax is specified is proto2.
1403414034
file->edition = UPB_DESC(EDITION_PROTO2);
1403514035
}
1403614036

@@ -14152,6 +14152,9 @@ void _upb_FileDef_Create(upb_DefBuilder* ctx,
1415214152
}
1415314153

1415414154

14155+
#include <assert.h>
14156+
#include <stdarg.h>
14157+
#include <stdint.h>
1415514158
#include <string.h>
1415614159

1415714160

@@ -14526,8 +14529,8 @@ const UPB_DESC(FeatureSet*)
1452614529
assert(parent);
1452714530
if (!child) return parent;
1452814531

14529-
if (child && !is_implicit &&
14530-
upb_FileDef_Syntax(ctx->file) != kUpb_Syntax_Editions) {
14532+
if (!is_implicit &&
14533+
_upb_DefBuilder_IsLegacyEdition(upb_FileDef_Edition(ctx->file))) {
1453114534
_upb_DefBuilder_Errf(ctx, "Features can only be specified for editions");
1453214535
}
1453314536

@@ -14936,10 +14939,6 @@ const char* upb_MessageDef_Name(const upb_MessageDef* m) {
1493614939
return _upb_DefBuilder_FullToShort(m->full_name);
1493714940
}
1493814941

14939-
upb_Syntax upb_MessageDef_Syntax(const upb_MessageDef* m) {
14940-
return upb_FileDef_Syntax(m->file);
14941-
}
14942-
1494314942
const upb_FieldDef* upb_MessageDef_FindFieldByNumber(const upb_MessageDef* m,
1494414943
uint32_t i) {
1494514944
upb_value val;

php/ext/google/protobuf/php-upb.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14058,12 +14058,6 @@ UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_semantic(google
1405814058

1405914059
#endif // GOOGLE_UPB_UPB_REFLECTION_DESCRIPTOR_BOOTSTRAP_H__
1406014060

14061-
typedef enum {
14062-
kUpb_Syntax_Proto2 = 2,
14063-
kUpb_Syntax_Proto3 = 3,
14064-
kUpb_Syntax_Editions = 99
14065-
} upb_Syntax;
14066-
1406714061
// Forward declarations for circular references.
1406814062
typedef struct upb_DefPool upb_DefPool;
1406914063
typedef struct upb_EnumDef upb_EnumDef;
@@ -14426,8 +14420,6 @@ int upb_FileDef_PublicDependencyCount(const upb_FileDef* f);
1442614420
const upb_ServiceDef* upb_FileDef_Service(const upb_FileDef* f, int i);
1442714421
int upb_FileDef_ServiceCount(const upb_FileDef* f);
1442814422

14429-
UPB_API upb_Syntax upb_FileDef_Syntax(const upb_FileDef* f);
14430-
1443114423
const upb_EnumDef* upb_FileDef_TopLevelEnum(const upb_FileDef* f, int i);
1443214424
int upb_FileDef_TopLevelEnumCount(const upb_FileDef* f);
1443314425

@@ -14588,7 +14580,6 @@ const upb_MessageReservedRange* upb_MessageDef_ReservedRange(
1458814580
const upb_MessageDef* m, int i);
1458914581
int upb_MessageDef_ReservedRangeCount(const upb_MessageDef* m);
1459014582

14591-
UPB_API upb_Syntax upb_MessageDef_Syntax(const upb_MessageDef* m);
1459214583
UPB_API upb_WellKnown upb_MessageDef_WellKnownType(const upb_MessageDef* m);
1459314584
UPB_API UPB_DESC(SymbolVisibility)
1459414585
upb_MessageDef_Visibility(const upb_MessageDef* m);
@@ -17238,6 +17229,13 @@ UPB_INLINE void _upb_DefBuilder_CheckIdentFull(upb_DefBuilder* ctx,
1723817229
if (!good) _upb_DefBuilder_CheckIdentSlow(ctx, name, true);
1723917230
}
1724017231

17232+
UPB_INLINE bool _upb_DefBuilder_IsLegacyEdition(google_protobuf_Edition edition) {
17233+
// Should only be called for a real edition, not a placeholder like
17234+
// EDITION_LEGACY.
17235+
UPB_ASSERT(edition >= google_protobuf_EDITION_PROTO2);
17236+
return edition <= google_protobuf_EDITION_PROTO3;
17237+
}
17238+
1724117239
// Returns true if the returned feature set is new and must be populated.
1724217240
bool _upb_DefBuilder_GetOrCreateFeatureSet(upb_DefBuilder* ctx,
1724317241
const UPB_DESC(FeatureSet*) parent,

ruby/ext/google/protobuf_c/ruby-upb.c

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12088,12 +12088,12 @@ static void set_default_default(upb_DefBuilder* ctx, upb_FieldDef* f,
1208812088
static bool _upb_FieldDef_InferLegacyFeatures(
1208912089
upb_DefBuilder* ctx, upb_FieldDef* f,
1209012090
const UPB_DESC(FieldDescriptorProto*) proto,
12091-
const UPB_DESC(FieldOptions*) options, upb_Syntax syntax,
12091+
const UPB_DESC(FieldOptions*) options, google_protobuf_Edition edition,
1209212092
UPB_DESC(FeatureSet*) features) {
1209312093
bool ret = false;
1209412094

1209512095
if (UPB_DESC(FieldDescriptorProto_label)(proto) == kUpb_Label_Required) {
12096-
if (syntax == kUpb_Syntax_Proto3) {
12096+
if (edition == google_protobuf_EDITION_PROTO3) {
1209712097
_upb_DefBuilder_Errf(ctx, "proto3 fields cannot be required (%s)",
1209812098
f->full_name);
1209912099
}
@@ -12137,15 +12137,15 @@ static void _upb_FieldDef_Create(upb_DefBuilder* ctx, const char* prefix,
1213712137

1213812138
UPB_DEF_SET_OPTIONS(f->opts, FieldDescriptorProto, FieldOptions, field_proto);
1213912139

12140-
upb_Syntax syntax = upb_FileDef_Syntax(f->file);
12140+
UPB_DESC(Edition) edition = upb_FileDef_Edition(f->file);
1214112141
const UPB_DESC(FeatureSet*) unresolved_features =
1214212142
UPB_DESC(FieldOptions_features)(f->opts);
1214312143
bool implicit = false;
1214412144

12145-
if (syntax != kUpb_Syntax_Editions) {
12145+
if (_upb_DefBuilder_IsLegacyEdition(edition)) {
1214612146
upb_Message_Clear(UPB_UPCAST(ctx->legacy_features),
1214712147
UPB_DESC_MINITABLE(FeatureSet));
12148-
if (_upb_FieldDef_InferLegacyFeatures(ctx, f, field_proto, f->opts, syntax,
12148+
if (_upb_FieldDef_InferLegacyFeatures(ctx, f, field_proto, f->opts, edition,
1214912149
ctx->legacy_features)) {
1215012150
implicit = true;
1215112151
unresolved_features = ctx->legacy_features;
@@ -12528,7 +12528,7 @@ static void resolve_default(upb_DefBuilder* ctx, upb_FieldDef* f,
1252812528
f->full_name);
1252912529
}
1253012530

12531-
if (upb_FileDef_Syntax(f->file) == kUpb_Syntax_Proto3) {
12531+
if (upb_FileDef_Edition(f->file) == google_protobuf_EDITION_PROTO3) {
1253212532
_upb_DefBuilder_Errf(ctx,
1253312533
"proto3 fields cannot have explicit defaults (%s)",
1253412534
f->full_name);
@@ -12594,7 +12594,6 @@ struct upb_FileDef {
1259412594
int top_lvl_ext_count;
1259512595
int service_count;
1259612596
int ext_count; // All exts in the file.
12597-
upb_Syntax syntax;
1259812597
};
1259912598

1260012599
UPB_API const char* upb_FileDef_EditionName(int edition) {
@@ -12636,8 +12635,6 @@ UPB_DESC(Edition) upb_FileDef_Edition(const upb_FileDef* f) {
1263612635

1263712636
const char* _upb_FileDef_RawPackage(const upb_FileDef* f) { return f->package; }
1263812637

12639-
upb_Syntax upb_FileDef_Syntax(const upb_FileDef* f) { return f->syntax; }
12640-
1264112638
int upb_FileDef_TopLevelMessageCount(const upb_FileDef* f) {
1264212639
return f->top_lvl_msg_count;
1264312640
}
@@ -12866,27 +12863,30 @@ void _upb_FileDef_Create(upb_DefBuilder* ctx,
1286612863
file->package = NULL;
1286712864
}
1286812865

12869-
// TODO: How should we validate this?
12870-
file->edition = UPB_DESC(FileDescriptorProto_edition)(file_proto);
12871-
12872-
if (UPB_DESC(FileDescriptorProto_has_syntax)(file_proto)) {
12873-
upb_StringView syntax = UPB_DESC(FileDescriptorProto_syntax)(file_proto);
12866+
upb_StringView syntax = UPB_DESC(FileDescriptorProto_syntax)(file_proto);
1287412867

12868+
if (UPB_DESC(FileDescriptorProto_has_edition)(file_proto)) {
12869+
if (!streql_view(syntax, "editions")) {
12870+
_upb_DefBuilder_Errf(ctx,
12871+
"Setting edition requires that syntax=\"editions\", "
12872+
"but syntax is \"" UPB_STRINGVIEW_FORMAT "\"",
12873+
UPB_STRINGVIEW_ARGS(syntax));
12874+
}
12875+
file->edition = UPB_DESC(FileDescriptorProto_edition)(file_proto);
12876+
} else if (UPB_DESC(FileDescriptorProto_has_syntax)(file_proto)) {
1287512877
if (streql_view(syntax, "proto2")) {
12876-
file->syntax = kUpb_Syntax_Proto2;
1287712878
file->edition = UPB_DESC(EDITION_PROTO2);
1287812879
} else if (streql_view(syntax, "proto3")) {
12879-
file->syntax = kUpb_Syntax_Proto3;
1288012880
file->edition = UPB_DESC(EDITION_PROTO3);
1288112881
} else if (streql_view(syntax, "editions")) {
12882-
file->syntax = kUpb_Syntax_Editions;
12883-
file->edition = UPB_DESC(FileDescriptorProto_edition)(file_proto);
12882+
_upb_DefBuilder_Errf(
12883+
ctx, "File has syntax=\"editions\", but no edition is specified");
1288412884
} else {
1288512885
_upb_DefBuilder_Errf(ctx, "Invalid syntax '" UPB_STRINGVIEW_FORMAT "'",
1288612886
UPB_STRINGVIEW_ARGS(syntax));
1288712887
}
1288812888
} else {
12889-
file->syntax = kUpb_Syntax_Proto2;
12889+
// The legacy default when no edition or syntax is specified is proto2.
1289012890
file->edition = UPB_DESC(EDITION_PROTO2);
1289112891
}
1289212892

@@ -13008,6 +13008,9 @@ void _upb_FileDef_Create(upb_DefBuilder* ctx,
1300813008
}
1300913009

1301013010

13011+
#include <assert.h>
13012+
#include <stdarg.h>
13013+
#include <stdint.h>
1301113014
#include <string.h>
1301213015

1301313016

@@ -13382,8 +13385,8 @@ const UPB_DESC(FeatureSet*)
1338213385
assert(parent);
1338313386
if (!child) return parent;
1338413387

13385-
if (child && !is_implicit &&
13386-
upb_FileDef_Syntax(ctx->file) != kUpb_Syntax_Editions) {
13388+
if (!is_implicit &&
13389+
_upb_DefBuilder_IsLegacyEdition(upb_FileDef_Edition(ctx->file))) {
1338713390
_upb_DefBuilder_Errf(ctx, "Features can only be specified for editions");
1338813391
}
1338913392

@@ -13792,10 +13795,6 @@ const char* upb_MessageDef_Name(const upb_MessageDef* m) {
1379213795
return _upb_DefBuilder_FullToShort(m->full_name);
1379313796
}
1379413797

13795-
upb_Syntax upb_MessageDef_Syntax(const upb_MessageDef* m) {
13796-
return upb_FileDef_Syntax(m->file);
13797-
}
13798-
1379913798
const upb_FieldDef* upb_MessageDef_FindFieldByNumber(const upb_MessageDef* m,
1380013799
uint32_t i) {
1380113800
upb_value val;
@@ -14882,6 +14881,11 @@ upb_ServiceDef* _upb_ServiceDefs_New(upb_DefBuilder* ctx, int n,
1488214881

1488314882
#include <inttypes.h>
1488414883
#include <math.h>
14884+
#include <setjmp.h>
14885+
#include <stdarg.h>
14886+
#include <stddef.h>
14887+
#include <stdint.h>
14888+
#include <string.h>
1488514889

1488614890

1488714891
// Must be last.
@@ -15409,14 +15413,20 @@ static google_protobuf_FileDescriptorProto* filedef_toproto(upb_ToProto_Context*
1540915413
}
1541015414
}
1541115415

15412-
if (upb_FileDef_Syntax(f) == kUpb_Syntax_Editions) {
15413-
google_protobuf_FileDescriptorProto_set_edition(proto, upb_FileDef_Edition(f));
15414-
}
15416+
google_protobuf_Edition edition = upb_FileDef_Edition(f);
1541515417

15416-
if (upb_FileDef_Syntax(f) == kUpb_Syntax_Proto3) {
15417-
google_protobuf_FileDescriptorProto_set_syntax(proto, strviewdup(ctx, "proto3"));
15418-
} else if (upb_FileDef_Syntax(f) == kUpb_Syntax_Editions) {
15419-
google_protobuf_FileDescriptorProto_set_syntax(proto, strviewdup(ctx, "editions"));
15418+
switch (edition) {
15419+
case google_protobuf_EDITION_PROTO2:
15420+
// We could set syntax to "proto2", but C++ omits it completely, which is
15421+
// equivalent.
15422+
break;
15423+
case google_protobuf_EDITION_PROTO3:
15424+
google_protobuf_FileDescriptorProto_set_syntax(proto, strviewdup(ctx, "proto3"));
15425+
break;
15426+
default:
15427+
google_protobuf_FileDescriptorProto_set_syntax(proto, strviewdup(ctx, "editions"));
15428+
google_protobuf_FileDescriptorProto_set_edition(proto, edition);
15429+
break;
1542015430
}
1542115431

1542215432
size_t n;

ruby/ext/google/protobuf_c/ruby-upb.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14097,12 +14097,6 @@ UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_semantic(google
1409714097

1409814098
#endif // GOOGLE_UPB_UPB_REFLECTION_DESCRIPTOR_BOOTSTRAP_H__
1409914099

14100-
typedef enum {
14101-
kUpb_Syntax_Proto2 = 2,
14102-
kUpb_Syntax_Proto3 = 3,
14103-
kUpb_Syntax_Editions = 99
14104-
} upb_Syntax;
14105-
1410614100
// Forward declarations for circular references.
1410714101
typedef struct upb_DefPool upb_DefPool;
1410814102
typedef struct upb_EnumDef upb_EnumDef;
@@ -14465,8 +14459,6 @@ int upb_FileDef_PublicDependencyCount(const upb_FileDef* f);
1446514459
const upb_ServiceDef* upb_FileDef_Service(const upb_FileDef* f, int i);
1446614460
int upb_FileDef_ServiceCount(const upb_FileDef* f);
1446714461

14468-
UPB_API upb_Syntax upb_FileDef_Syntax(const upb_FileDef* f);
14469-
1447014462
const upb_EnumDef* upb_FileDef_TopLevelEnum(const upb_FileDef* f, int i);
1447114463
int upb_FileDef_TopLevelEnumCount(const upb_FileDef* f);
1447214464

@@ -14627,7 +14619,6 @@ const upb_MessageReservedRange* upb_MessageDef_ReservedRange(
1462714619
const upb_MessageDef* m, int i);
1462814620
int upb_MessageDef_ReservedRangeCount(const upb_MessageDef* m);
1462914621

14630-
UPB_API upb_Syntax upb_MessageDef_Syntax(const upb_MessageDef* m);
1463114622
UPB_API upb_WellKnown upb_MessageDef_WellKnownType(const upb_MessageDef* m);
1463214623
UPB_API UPB_DESC(SymbolVisibility)
1463314624
upb_MessageDef_Visibility(const upb_MessageDef* m);
@@ -17042,6 +17033,13 @@ UPB_INLINE void _upb_DefBuilder_CheckIdentFull(upb_DefBuilder* ctx,
1704217033
if (!good) _upb_DefBuilder_CheckIdentSlow(ctx, name, true);
1704317034
}
1704417035

17036+
UPB_INLINE bool _upb_DefBuilder_IsLegacyEdition(google_protobuf_Edition edition) {
17037+
// Should only be called for a real edition, not a placeholder like
17038+
// EDITION_LEGACY.
17039+
UPB_ASSERT(edition >= google_protobuf_EDITION_PROTO2);
17040+
return edition <= google_protobuf_EDITION_PROTO3;
17041+
}
17042+
1704517043
// Returns true if the returned feature set is new and must be populated.
1704617044
bool _upb_DefBuilder_GetOrCreateFeatureSet(upb_DefBuilder* ctx,
1704717045
const UPB_DESC(FeatureSet*) parent,

0 commit comments

Comments
 (0)