@@ -752,10 +752,6 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase {
752
752
bool is_map () const ; // shorthand for type() == TYPE_MESSAGE &&
753
753
// message_type()->options().map_entry()
754
754
755
- // Returns true if this field was syntactically written with "optional" in the
756
- // .proto file. Excludes singular proto3 fields that do not have a label.
757
- bool has_optional_keyword () const ;
758
-
759
755
// Returns true if this field tracks presence, ie. does the field
760
756
// distinguish between "unset" and "present with default value."
761
757
// This includes required, optional, and oneof fields. It excludes maps,
@@ -920,6 +916,11 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase {
920
916
friend class io ::Printer;
921
917
friend class compiler ::cpp::Formatter;
922
918
friend class Reflection ;
919
+ friend class FieldDescriptorLegacy ;
920
+
921
+ // Returns true if this field was syntactically written with "optional" in the
922
+ // .proto file. Excludes singular proto3 fields that do not have a label.
923
+ bool has_optional_keyword () const ;
923
924
924
925
// Fill the json_name field of FieldDescriptorProto.
925
926
void CopyJsonNameTo (FieldDescriptorProto* proto) const ;
@@ -1040,10 +1041,6 @@ class PROTOBUF_EXPORT OneofDescriptor : private internal::SymbolBase {
1040
1041
// Index of this oneof within the message's oneof array.
1041
1042
int index () const ;
1042
1043
1043
- // Returns whether this oneof was inserted by the compiler to wrap a proto3
1044
- // optional field. If this returns true, code generators should *not* emit it.
1045
- bool is_synthetic () const ;
1046
-
1047
1044
// The .proto file in which this oneof was defined. Never nullptr.
1048
1045
const FileDescriptor* file () const ;
1049
1046
// The Descriptor for the message containing this oneof.
@@ -1080,6 +1077,11 @@ class PROTOBUF_EXPORT OneofDescriptor : private internal::SymbolBase {
1080
1077
// Allows access to GetLocationPath for annotations.
1081
1078
friend class io ::Printer;
1082
1079
friend class compiler ::cpp::Formatter;
1080
+ friend class OneofDescriptorLegacy ;
1081
+
1082
+ // Returns whether this oneof was inserted by the compiler to wrap a proto3
1083
+ // optional field. If this returns true, code generators should *not* emit it.
1084
+ bool is_synthetic () const ;
1083
1085
1084
1086
// See Descriptor::DebugString().
1085
1087
void DebugString (int depth, std::string* contents,
@@ -1651,7 +1653,11 @@ class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase {
1651
1653
// descriptor.proto, and any available extensions of that message.
1652
1654
const FileOptions& options () const ;
1653
1655
1654
- // Syntax of this file.
1656
+ private:
1657
+ // With the upcoming release of editions, syntax should not be used for
1658
+ // business logic. Instead, the various feature helpers defined in this file
1659
+ // should be used to query more targeted behaviors. For example:
1660
+ // has_presence, is_closed, requires_utf8_validation.
1655
1661
enum Syntax
1656
1662
#ifndef SWIG
1657
1663
: int
@@ -1662,8 +1668,15 @@ class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase {
1662
1668
SYNTAX_PROTO3 = 3 ,
1663
1669
};
1664
1670
Syntax syntax () const ;
1671
+
1672
+ // Define a visibility-restricted wrapper for internal use until the migration
1673
+ // is complete.
1674
+ friend class FileDescriptorLegacy ;
1675
+
1665
1676
static const char * SyntaxName (Syntax syntax);
1666
1677
1678
+ public:
1679
+
1667
1680
// Find a top-level message type by name (not full_name). Returns nullptr if
1668
1681
// not found.
1669
1682
const Descriptor* FindMessageTypeByName (absl::string_view name) const ;
0 commit comments