Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: third_party/protobuf/java/core/src/main/java/com/google/protobuf/Descriptors.java

Issue 2600753002: Reverts third_party/protobuf: Update to HEAD (f52e188fe4) (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/java/core/src/main/java/com/google/protobuf/Descriptors.java
diff --git a/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Descriptors.java b/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Descriptors.java
index 38346f1559fb2192c7b32b278d49f73dd8fe0132..e00ea342ea0c3f2c59fbd80126b4e71d149b4c0d 100644
--- a/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Descriptors.java
+++ b/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Descriptors.java
@@ -871,10 +871,6 @@ public final class Descriptors {
nestedTypes[i].setProto(proto.getNestedType(i));
}
- for (int i = 0; i < oneofs.length; i++) {
- oneofs[i].setProto(proto.getOneofDecl(i));
- }
-
for (int i = 0; i < enumTypes.length; i++) {
enumTypes[i].setProto(proto.getEnumType(i));
}
@@ -1212,20 +1208,33 @@ public final class Descriptors {
private final Object defaultDefault;
}
- // This method should match exactly with the ToJsonName() function in C++
- // descriptor.cc.
- private static String fieldNameToJsonName(String name) {
+ // TODO(xiaofeng): Implement it consistently across different languages. See b/24751348.
+ private static String fieldNameToLowerCamelCase(String name) {
StringBuilder result = new StringBuilder(name.length());
boolean isNextUpperCase = false;
for (int i = 0; i < name.length(); i++) {
Character ch = name.charAt(i);
- if (ch == '_') {
- isNextUpperCase = true;
- } else if (isNextUpperCase) {
- result.append(Character.toUpperCase(ch));
+ if (Character.isLowerCase(ch)) {
+ if (isNextUpperCase) {
+ result.append(Character.toUpperCase(ch));
+ } else {
+ result.append(ch);
+ }
isNextUpperCase = false;
- } else {
+ } else if (Character.isUpperCase(ch)) {
+ if (i == 0) {
+ // Force first letter to lower-case.
+ result.append(Character.toLowerCase(ch));
+ } else {
+ // Capital letters after the first are left as-is.
+ result.append(ch);
+ }
+ isNextUpperCase = false;
+ } else if (Character.isDigit(ch)) {
result.append(ch);
+ isNextUpperCase = false;
+ } else {
+ isNextUpperCase = true;
}
}
return result.toString();
@@ -1244,7 +1253,7 @@ public final class Descriptors {
if (proto.hasJsonName()) {
jsonName = proto.getJsonName();
} else {
- jsonName = fieldNameToJsonName(proto.getName());
+ jsonName = fieldNameToLowerCamelCase(proto.getName());
}
if (proto.hasType()) {
@@ -2123,7 +2132,7 @@ public final class Descriptors {
// Can't happen, because addPackage() only fails when the name
// conflicts with a non-package, but we have not yet added any
// non-packages at this point.
- throw new AssertionError(e);
+ assert false;
}
}
}
@@ -2504,10 +2513,6 @@ public final class Descriptors {
public int getFieldCount() { return fieldCount; }
- public OneofOptions getOptions() {
- return proto.getOptions();
- }
-
/** Get a list of this message type's fields. */
public List<FieldDescriptor> getFields() {
return Collections.unmodifiableList(Arrays.asList(fields));
@@ -2517,10 +2522,6 @@ public final class Descriptors {
return fields[index];
}
- private void setProto(final OneofDescriptorProto proto) {
- this.proto = proto;
- }
-
private OneofDescriptor(final OneofDescriptorProto proto,
final FileDescriptor file,
final Descriptor parent,

Powered by Google App Engine
This is Rietveld 408576698