diff options
author | Ulas Kirazci <ulas@google.com> | 2013-09-28 23:34:02 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-09-28 23:34:02 +0000 |
commit | 4b7983cb71bda102b5b5d3aa2fb6767d0df4f6d4 (patch) | |
tree | 35f29c2fab71ccb576c1226644ce7f64914beb6b /java | |
parent | 93429474225b04f2951ed7cf59b6298fb2ce4b5a (diff) | |
parent | 1479c7ab1b72346df56b95816a58234ba2ceb9cd (diff) | |
download | protobuf-4b7983cb71bda102b5b5d3aa2fb6767d0df4f6d4.tar.gz protobuf-4b7983cb71bda102b5b5d3aa2fb6767d0df4f6d4.tar.bz2 protobuf-4b7983cb71bda102b5b5d3aa2fb6767d0df4f6d4.zip |
Merge "Implement enum_style=java option."
Diffstat (limited to 'java')
-rw-r--r-- | java/README.txt | 17 | ||||
-rw-r--r-- | java/src/test/java/com/google/protobuf/NanoTest.java | 13 |
2 files changed, 26 insertions, 4 deletions
diff --git a/java/README.txt b/java/README.txt index 9728f48e..e2e698e1 100644 --- a/java/README.txt +++ b/java/README.txt @@ -93,8 +93,9 @@ Micro version The runtime and generated code for MICRO_RUNTIME is smaller because it does not include support for the descriptor and reflection, and enums are generated as integer constants in -the parent message or the file's outer class. Also, not -currently supported are packed repeated elements or +the parent message or the file's outer class, with no +protection against invalid values set to enum fields. Also, +not currently supported are packed repeated elements or extensions. To create a jar file for the runtime and run tests invoke @@ -409,12 +410,20 @@ Nano version ============================ Nano is even smaller than micro, especially in the number of generated -functions. It is like micro except: +functions. It is like micro: + +- No support for descriptors and reflection; +- Enum constants are integers with no protection against invalid + values set to enum fields. + +Except: - Setter/getter/hazzer/clearer functions are opt-in. - If not opted in, has state is not available. Serialization outputs - all fields not equal to their default. (See important implications + all fields not equal to their default. (See important implications below.) +- Enum constants can be generated into container interfaces bearing + the enum's name (so the referencing code is in Java style). - CodedInputStreamMicro is renamed to CodedInputByteBufferNano and can only take byte[] (not InputStream). - Similar rename from CodedOutputStreamMicro to diff --git a/java/src/test/java/com/google/protobuf/NanoTest.java b/java/src/test/java/com/google/protobuf/NanoTest.java index fb6cccb2..84836195 100644 --- a/java/src/test/java/com/google/protobuf/NanoTest.java +++ b/java/src/test/java/com/google/protobuf/NanoTest.java @@ -31,8 +31,11 @@ package com.google.protobuf; import com.google.protobuf.nano.CodedInputByteBufferNano; +import com.google.protobuf.nano.EnumClassNanoMultiple; +import com.google.protobuf.nano.EnumClassNanos; import com.google.protobuf.nano.Extensions; import com.google.protobuf.nano.Extensions.AnotherMessage; +import com.google.protobuf.nano.FileScopeEnumMultiple; import com.google.protobuf.nano.FileScopeEnumRefNano; import com.google.protobuf.nano.InternalNano; import com.google.protobuf.nano.MessageNano; @@ -2391,6 +2394,16 @@ public class NanoTest extends TestCase { assertEquals(0, newMsg.id); } + public void testNanoJavaEnumStyle() throws Exception { + EnumClassNanos.EnumClassNano msg = new EnumClassNanos.EnumClassNano(); + assertEquals(EnumClassNanos.FileScopeEnum.ONE, msg.one); + assertEquals(EnumClassNanos.EnumClassNano.MessageScopeEnum.TWO, msg.two); + + EnumClassNanoMultiple msg2 = new EnumClassNanoMultiple(); + assertEquals(FileScopeEnumMultiple.THREE, msg2.three); + assertEquals(EnumClassNanoMultiple.MessageScopeEnumMultiple.FOUR, msg2.four); + } + /** * Tests that fields with a default value of NaN are not serialized when * set to NaN. This is a special case as NaN != NaN, so normal equality |