aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/compiler/java/java_helpers.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/compiler/java/java_helpers.h')
-rw-r--r--src/google/protobuf/compiler/java/java_helpers.h59
1 files changed, 45 insertions, 14 deletions
diff --git a/src/google/protobuf/compiler/java/java_helpers.h b/src/google/protobuf/compiler/java/java_helpers.h
index 829ec3d7..dd9b65b8 100644
--- a/src/google/protobuf/compiler/java/java_helpers.h
+++ b/src/google/protobuf/compiler/java/java_helpers.h
@@ -37,8 +37,8 @@
#include <string>
#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/io/printer.h>
#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/io/printer.h>
#include <google/protobuf/descriptor.h>
namespace google {
@@ -74,6 +74,10 @@ string UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field);
// of lower-casing the first letter of the name.)
string UnderscoresToCamelCase(const MethodDescriptor* method);
+// Similar to UnderscoresToCamelCase, but guarentees that the result is a
+// complete Java identifier by adding a _ if needed.
+string CamelCaseFieldName(const FieldDescriptor* field);
+
// Get an identifier that uniquely identifies this type within the file.
// This is used to declare static variables related to this type at the
// outermost file scope.
@@ -132,6 +136,13 @@ inline string ShortMutableJavaClassName(const Descriptor* descriptor) {
return descriptor->name();
}
+// Whether the given descriptor is for one of the core descriptor protos. We
+// cannot currently use the new runtime with core protos since there is a
+// bootstrapping problem with obtaining their descriptors.
+inline bool IsDescriptorProto(const Descriptor* descriptor) {
+ return descriptor->file()->name() == "google/protobuf/descriptor.proto";
+}
+
// Whether we should generate multiple java files for messages.
inline bool MultipleJavaFiles(
@@ -242,15 +253,6 @@ inline bool HasGenericServices(const FileDescriptor *file, bool enforce_lite) {
file->options().java_generic_services();
}
-inline bool IsLazy(const FieldDescriptor* descriptor, bool enforce_lite) {
- // Currently, the proto-lite version supports lazy field.
- // TODO(niwasaki): Support lazy fields also for other proto runtimes.
- if (HasDescriptorMethods(descriptor->file(), enforce_lite)) {
- return false;
- }
- return descriptor->options().lazy();
-}
-
// Methods for shared bitfields.
// Gets the name of the shared bitfield for the given index.
@@ -372,14 +374,14 @@ inline bool IsMapField(const FieldDescriptor* descriptor) {
return descriptor->is_map();
}
-inline bool PreserveUnknownFields(const Descriptor* descriptor) {
- return descriptor->file()->syntax() != FileDescriptor::SYNTAX_PROTO3;
-}
-
inline bool IsAnyMessage(const Descriptor* descriptor) {
return descriptor->full_name() == "google.protobuf.Any";
}
+inline bool IsWrappersProtoFile(const FileDescriptor* descriptor) {
+ return descriptor->name() == "google/protobuf/wrappers.proto";
+}
+
inline bool CheckUtf8(const FieldDescriptor* descriptor) {
return descriptor->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 ||
descriptor->file()->options().java_string_check_utf8();
@@ -388,6 +390,35 @@ inline bool CheckUtf8(const FieldDescriptor* descriptor) {
inline string GeneratedCodeVersionSuffix() {
return "V3";
}
+
+inline bool EnableExperimentalRuntime(Context* context) {
+ return false;
+}
+
+void WriteUInt32ToUtf16CharSequence(uint32 number, std::vector<uint16>* output);
+
+inline void WriteIntToUtf16CharSequence(int value,
+ std::vector<uint16>* output) {
+ WriteUInt32ToUtf16CharSequence(static_cast<uint32>(value), output);
+}
+
+// Escape a UTF-16 character so it can be embedded in a Java string literal.
+void EscapeUtf16ToString(uint16 code, string* output);
+
+// Only the lowest two bytes of the return value are used. The lowest byte
+// is the integer value of a j/c/g/protobuf/FieldType enum. For the other
+// byte:
+// bit 0: whether the field is required.
+// bit 1: whether the field requires UTF-8 validation.
+// bit 2: whether the field needs isInitialized check.
+// bit 3: whether the field is a map field with proto2 enum value.
+// bits 4-7: unused
+int GetExperimentalJavaFieldType(const FieldDescriptor* field);
+
+// To get the total number of entries need to be built for experimental runtime
+// and the first field number that are not in the table part
+std::pair<int, int> GetTableDrivenNumberOfEntriesAndLookUpStartFieldNumber(
+ const FieldDescriptor** fields, int count);
} // namespace java
} // namespace compiler
} // namespace protobuf