diff options
Diffstat (limited to 'src/google/protobuf/compiler/java/java_helpers.h')
-rw-r--r-- | src/google/protobuf/compiler/java/java_helpers.h | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/google/protobuf/compiler/java/java_helpers.h b/src/google/protobuf/compiler/java/java_helpers.h index 93f23a93..2707fa0a 100644 --- a/src/google/protobuf/compiler/java/java_helpers.h +++ b/src/google/protobuf/compiler/java/java_helpers.h @@ -149,6 +149,8 @@ enum JavaType { JavaType GetJavaType(const FieldDescriptor* field); +const char* PrimitiveTypeName(JavaType type); + // Get the fully-qualified class name for a boxed primitive type, e.g. // "java.lang.Integer" for JAVATYPE_INT. Returns NULL for enum and message // types. @@ -168,13 +170,6 @@ inline string ImmutableDefaultValue(const FieldDescriptor* field, } bool IsDefaultValueJavaDefault(const FieldDescriptor* field); -// Does this message class use UnknownFieldSet? -// Otherwise, unknown fields will be stored in a ByteString object -inline bool UseUnknownFieldSet(const Descriptor* descriptor) { - return descriptor->file()->options().optimize_for() != - FileOptions::LITE_RUNTIME; -} - // Does this message class have generated parsing, serialization, and other // standard methods for which reflection-based fallback implementations exist? inline bool HasGeneratedMethods(const Descriptor* descriptor) { @@ -308,12 +303,27 @@ bool HasRequiredFields(const Descriptor* descriptor); // Whether a .proto file supports field presence test for non-message types. inline bool SupportFieldPresence(const FileDescriptor* descriptor) { - return true; + return descriptor->syntax() != FileDescriptor::SYNTAX_PROTO3; +} + +// Whether unknown enum values are kept (i.e., not stored in UnknownFieldSet +// but in the message and can be queried using additional getters that return +// ints. +inline bool SupportUnknownEnumValue(const FileDescriptor* descriptor) { + return descriptor->syntax() == FileDescriptor::SYNTAX_PROTO3; } // Check whether a mesasge has repeated fields. bool HasRepeatedFields(const Descriptor* descriptor); +inline bool IsMapEntry(const Descriptor* descriptor) { + return descriptor->options().map_entry(); +} + +inline bool PreserveUnknownFields(const Descriptor* descriptor) { + return descriptor->file()->syntax() != FileDescriptor::SYNTAX_PROTO3; +} + } // namespace java } // namespace compiler } // namespace protobuf |