Skip to content

Commit 0fa45b2

Browse files
Auto-generate files after cl/850517623
1 parent 00d838b commit 0fa45b2

File tree

4 files changed

+62
-40
lines changed

4 files changed

+62
-40
lines changed

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -497,14 +497,6 @@ Error, UINTPTR_MAX is undefined
497497

498498
#undef UPB_FASTTABLE_SUPPORTED
499499

500-
/* Disable proto2 arena behavior (TEMPORARY) **********************************/
501-
502-
#ifdef UPB_DISABLE_CLOSED_ENUM_CHECKING
503-
#define UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN 1
504-
#else
505-
#define UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN 0
506-
#endif
507-
508500
#if defined(__cplusplus)
509501
#if defined(__clang__) || UPB_GNUC_MIN(6, 0)
510502
// https://gcc.gnu.org/gcc-6/changes.html
@@ -11595,6 +11587,7 @@ struct upb_DefPool {
1159511587
void* scratch_data;
1159611588
size_t scratch_size;
1159711589
size_t bytes_loaded;
11590+
bool disable_closed_enum_checking;
1159811591
};
1159911592

1160011593
void upb_DefPool_Free(upb_DefPool* s) {
@@ -11612,6 +11605,7 @@ upb_DefPool* upb_DefPool_New(void) {
1161211605

1161311606
s->arena = upb_Arena_New();
1161411607
s->bytes_loaded = 0;
11608+
s->disable_closed_enum_checking = false;
1161511609

1161611610
s->scratch_size = 240;
1161711611
s->scratch_data = upb_gmalloc(s->scratch_size);
@@ -11644,6 +11638,15 @@ upb_DefPool* upb_DefPool_New(void) {
1164411638
return NULL;
1164511639
}
1164611640

11641+
void upb_DefPool_DisableClosedEnumChecking(upb_DefPool* s) {
11642+
UPB_ASSERT(upb_strtable_count(&s->files) == 0);
11643+
s->disable_closed_enum_checking = true;
11644+
}
11645+
11646+
bool upb_DefPool_ClosedEnumCheckingDisabled(const upb_DefPool* s) {
11647+
return s->disable_closed_enum_checking;
11648+
}
11649+
1164711650
const UPB_DESC(FeatureSetDefaults) *
1164811651
upb_DefPool_FeatureSetDefaults(const upb_DefPool* s) {
1164911652
return s->feature_set_defaults;
@@ -12283,7 +12286,7 @@ static bool upb_EnumDef_IsSpecifiedAsClosed(const upb_EnumDef* e) {
1228312286
}
1228412287

1228512288
bool upb_EnumDef_IsClosed(const upb_EnumDef* e) {
12286-
if (UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN) return false;
12289+
if (_upb_FileDef_ClosedEnumCheckingDisabled(e->file)) return false;
1228712290
return upb_EnumDef_IsSpecifiedAsClosed(e);
1228812291
}
1228912292

@@ -13801,6 +13804,10 @@ const int32_t* _upb_FileDef_WeakDependencyIndexes(const upb_FileDef* f) {
1380113804
return f->weak_deps;
1380213805
}
1380313806

13807+
bool _upb_FileDef_ClosedEnumCheckingDisabled(const upb_FileDef* f) {
13808+
return upb_DefPool_ClosedEnumCheckingDisabled(f->symtab);
13809+
}
13810+
1380413811
int upb_FileDef_TopLevelEnumCount(const upb_FileDef* f) {
1380513812
return f->top_lvl_enum_count;
1380613813
}
@@ -18397,7 +18404,6 @@ const char* UPB_PRIVATE(_upb_WireReader_SkipGroup)(
1839718404
#undef UPB_MSAN
1839818405
#undef UPB_MALLOC_ALIGN
1839918406
#undef UPB_TSAN
18400-
#undef UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN
1840118407
#undef UPB_DEPRECATED
1840218408
#undef UPB_GNUC_MIN
1840318409
#undef UPB_DESCRIPTOR_UPB_H_FILENAME

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -496,14 +496,6 @@ Error, UINTPTR_MAX is undefined
496496

497497
#undef UPB_FASTTABLE_SUPPORTED
498498

499-
/* Disable proto2 arena behavior (TEMPORARY) **********************************/
500-
501-
#ifdef UPB_DISABLE_CLOSED_ENUM_CHECKING
502-
#define UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN 1
503-
#else
504-
#define UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN 0
505-
#endif
506-
507499
#if defined(__cplusplus)
508500
#if defined(__clang__) || UPB_GNUC_MIN(6, 0)
509501
// https://gcc.gnu.org/gcc-6/changes.html
@@ -14199,6 +14191,20 @@ const upb_FieldDef** upb_DefPool_GetAllExtensions(const upb_DefPool* s,
1419914191
const upb_MessageDef* m,
1420014192
size_t* count);
1420114193

14194+
// If called, closed enums will be treated as open enums. This is non-standard
14195+
// behavior and will cause conformance tests to fail, but it is more useful
14196+
// behavior overall and can be used in situations where where the
14197+
// non-conformance is acceptable.
14198+
//
14199+
// This function may only be called immediately after upb_DefPool_New().
14200+
// It is an error to call it on an existing def pool or after defs have
14201+
// already been added to the pool.
14202+
//
14203+
// Note: we still require that implicit presence fields have zero as their
14204+
// default value.
14205+
UPB_API void upb_DefPool_DisableClosedEnumChecking(upb_DefPool* s);
14206+
bool upb_DefPool_ClosedEnumCheckingDisabled(const upb_DefPool* s);
14207+
1420214208
#ifdef __cplusplus
1420314209
} /* extern "C" */
1420414210
#endif
@@ -17276,6 +17282,7 @@ const upb_MiniTableExtension* _upb_FileDef_ExtensionMiniTable(
1727617282
const upb_FileDef* f, int i);
1727717283
const int32_t* _upb_FileDef_PublicDependencyIndexes(const upb_FileDef* f);
1727817284
const int32_t* _upb_FileDef_WeakDependencyIndexes(const upb_FileDef* f);
17285+
bool _upb_FileDef_ClosedEnumCheckingDisabled(const upb_FileDef* f);
1727917286

1728017287
// upb_FileDef_Package() returns "" if f->package is NULL, this does not.
1728117288
const char* _upb_FileDef_RawPackage(const upb_FileDef* f);
@@ -17998,7 +18005,6 @@ UPB_PRIVATE(upb_WireWriter_VarintUnusedSizeFromLeadingZeros64)(uint64_t clz) {
1799818005
#undef UPB_MSAN
1799918006
#undef UPB_MALLOC_ALIGN
1800018007
#undef UPB_TSAN
18001-
#undef UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN
1800218008
#undef UPB_DEPRECATED
1800318009
#undef UPB_GNUC_MIN
1800418010
#undef UPB_DESCRIPTOR_UPB_H_FILENAME

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -497,14 +497,6 @@ Error, UINTPTR_MAX is undefined
497497

498498
#undef UPB_FASTTABLE_SUPPORTED
499499

500-
/* Disable proto2 arena behavior (TEMPORARY) **********************************/
501-
502-
#ifdef UPB_DISABLE_CLOSED_ENUM_CHECKING
503-
#define UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN 1
504-
#else
505-
#define UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN 0
506-
#endif
507-
508500
#if defined(__cplusplus)
509501
#if defined(__clang__) || UPB_GNUC_MIN(6, 0)
510502
// https://gcc.gnu.org/gcc-6/changes.html
@@ -10451,6 +10443,7 @@ struct upb_DefPool {
1045110443
void* scratch_data;
1045210444
size_t scratch_size;
1045310445
size_t bytes_loaded;
10446+
bool disable_closed_enum_checking;
1045410447
};
1045510448

1045610449
void upb_DefPool_Free(upb_DefPool* s) {
@@ -10468,6 +10461,7 @@ upb_DefPool* upb_DefPool_New(void) {
1046810461

1046910462
s->arena = upb_Arena_New();
1047010463
s->bytes_loaded = 0;
10464+
s->disable_closed_enum_checking = false;
1047110465

1047210466
s->scratch_size = 240;
1047310467
s->scratch_data = upb_gmalloc(s->scratch_size);
@@ -10500,6 +10494,15 @@ upb_DefPool* upb_DefPool_New(void) {
1050010494
return NULL;
1050110495
}
1050210496

10497+
void upb_DefPool_DisableClosedEnumChecking(upb_DefPool* s) {
10498+
UPB_ASSERT(upb_strtable_count(&s->files) == 0);
10499+
s->disable_closed_enum_checking = true;
10500+
}
10501+
10502+
bool upb_DefPool_ClosedEnumCheckingDisabled(const upb_DefPool* s) {
10503+
return s->disable_closed_enum_checking;
10504+
}
10505+
1050310506
const UPB_DESC(FeatureSetDefaults) *
1050410507
upb_DefPool_FeatureSetDefaults(const upb_DefPool* s) {
1050510508
return s->feature_set_defaults;
@@ -11139,7 +11142,7 @@ static bool upb_EnumDef_IsSpecifiedAsClosed(const upb_EnumDef* e) {
1113911142
}
1114011143

1114111144
bool upb_EnumDef_IsClosed(const upb_EnumDef* e) {
11142-
if (UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN) return false;
11145+
if (_upb_FileDef_ClosedEnumCheckingDisabled(e->file)) return false;
1114311146
return upb_EnumDef_IsSpecifiedAsClosed(e);
1114411147
}
1114511148

@@ -12657,6 +12660,10 @@ const int32_t* _upb_FileDef_WeakDependencyIndexes(const upb_FileDef* f) {
1265712660
return f->weak_deps;
1265812661
}
1265912662

12663+
bool _upb_FileDef_ClosedEnumCheckingDisabled(const upb_FileDef* f) {
12664+
return upb_DefPool_ClosedEnumCheckingDisabled(f->symtab);
12665+
}
12666+
1266012667
int upb_FileDef_TopLevelEnumCount(const upb_FileDef* f) {
1266112668
return f->top_lvl_enum_count;
1266212669
}
@@ -17956,7 +17963,6 @@ const char* UPB_PRIVATE(_upb_WireReader_SkipGroup)(
1795617963
#undef UPB_MSAN
1795717964
#undef UPB_MALLOC_ALIGN
1795817965
#undef UPB_TSAN
17959-
#undef UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN
1796017966
#undef UPB_DEPRECATED
1796117967
#undef UPB_GNUC_MIN
1796217968
#undef UPB_DESCRIPTOR_UPB_H_FILENAME

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Ruby is still using proto3 enum semantics for proto2
2-
#define UPB_DISABLE_CLOSED_ENUM_CHECKING
31
/* Amalgamated source file */
42

53
/*
@@ -498,14 +496,6 @@ Error, UINTPTR_MAX is undefined
498496

499497
#undef UPB_FASTTABLE_SUPPORTED
500498

501-
/* Disable proto2 arena behavior (TEMPORARY) **********************************/
502-
503-
#ifdef UPB_DISABLE_CLOSED_ENUM_CHECKING
504-
#define UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN 1
505-
#else
506-
#define UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN 0
507-
#endif
508-
509499
#if defined(__cplusplus)
510500
#if defined(__clang__) || UPB_GNUC_MIN(6, 0)
511501
// https://gcc.gnu.org/gcc-6/changes.html
@@ -14238,6 +14228,20 @@ const upb_FieldDef** upb_DefPool_GetAllExtensions(const upb_DefPool* s,
1423814228
const upb_MessageDef* m,
1423914229
size_t* count);
1424014230

14231+
// If called, closed enums will be treated as open enums. This is non-standard
14232+
// behavior and will cause conformance tests to fail, but it is more useful
14233+
// behavior overall and can be used in situations where where the
14234+
// non-conformance is acceptable.
14235+
//
14236+
// This function may only be called immediately after upb_DefPool_New().
14237+
// It is an error to call it on an existing def pool or after defs have
14238+
// already been added to the pool.
14239+
//
14240+
// Note: we still require that implicit presence fields have zero as their
14241+
// default value.
14242+
UPB_API void upb_DefPool_DisableClosedEnumChecking(upb_DefPool* s);
14243+
bool upb_DefPool_ClosedEnumCheckingDisabled(const upb_DefPool* s);
14244+
1424114245
#ifdef __cplusplus
1424214246
} /* extern "C" */
1424314247
#endif
@@ -17080,6 +17084,7 @@ const upb_MiniTableExtension* _upb_FileDef_ExtensionMiniTable(
1708017084
const upb_FileDef* f, int i);
1708117085
const int32_t* _upb_FileDef_PublicDependencyIndexes(const upb_FileDef* f);
1708217086
const int32_t* _upb_FileDef_WeakDependencyIndexes(const upb_FileDef* f);
17087+
bool _upb_FileDef_ClosedEnumCheckingDisabled(const upb_FileDef* f);
1708317088

1708417089
// upb_FileDef_Package() returns "" if f->package is NULL, this does not.
1708517090
const char* _upb_FileDef_RawPackage(const upb_FileDef* f);
@@ -17837,7 +17842,6 @@ UPB_PRIVATE(upb_WireWriter_VarintUnusedSizeFromLeadingZeros64)(uint64_t clz) {
1783717842
#undef UPB_MSAN
1783817843
#undef UPB_MALLOC_ALIGN
1783917844
#undef UPB_TSAN
17840-
#undef UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN
1784117845
#undef UPB_DEPRECATED
1784217846
#undef UPB_GNUC_MIN
1784317847
#undef UPB_DESCRIPTOR_UPB_H_FILENAME

0 commit comments

Comments
 (0)