aboutsummaryrefslogtreecommitdiffstats
path: root/src/google/protobuf/unittest_extension_packed_nano.proto
diff options
context:
space:
mode:
authorMax Cai <maxtroy@google.com>2013-11-20 18:59:01 +0000
committerMax Cai <maxtroy@google.com>2014-01-10 11:50:32 +0000
commit382ddccb550e1c822ef26a0e65988998f7446624 (patch)
tree5159c510e6a895f4ce56310b8f23b7bb4aafc2f0 /src/google/protobuf/unittest_extension_packed_nano.proto
parente7741c064ee4cdc5fa41e6444ed45131672fed97 (diff)
downloadexternal_protobuf-382ddccb550e1c822ef26a0e65988998f7446624.zip
external_protobuf-382ddccb550e1c822ef26a0e65988998f7446624.tar.gz
external_protobuf-382ddccb550e1c822ef26a0e65988998f7446624.tar.bz2
Extension overhaul.
- Get rid of TypeLiteral<T>. It was introduced to read the component type of a List<T> at runtime. But we use arrays everywhere else, and we can always read the component type of an array type at runtime. - Properly read/write "minor" types (e.g. sint32, sfixed32). The old implementation could only read/write data as the "typical" types (one per Java type), e.g. java.lang.Integer -> int32, java.lang.Long -> int64. So if e.g. an extension specifies sfixed32 as the type, it would be read/written in the totally incompatible int32 format. - Properly serialize repeated packed fields. The old implementation doesn't do packed serialization. As an added bonus, and to be more aligned with the rest of protobuf nano / main, repeated packable extensions can deserialize both packed and non-packed data. - Split Extension class into a hierarchy so under typical usage a large chunk of code dealing with primitive type extensions can be removed by ProGuard. Bug: https://code.google.com/p/android/issues/detail?id=62586 Change-Id: I0d692f35cc2a8ad3a5a1cb3ce001282b2356b041
Diffstat (limited to 'src/google/protobuf/unittest_extension_packed_nano.proto')
-rw-r--r--src/google/protobuf/unittest_extension_packed_nano.proto29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/google/protobuf/unittest_extension_packed_nano.proto b/src/google/protobuf/unittest_extension_packed_nano.proto
new file mode 100644
index 0000000..3586de7
--- /dev/null
+++ b/src/google/protobuf/unittest_extension_packed_nano.proto
@@ -0,0 +1,29 @@
+syntax = "proto2";
+
+option java_multiple_files = true;
+option java_package = "com.google.protobuf.nano";
+
+import "google/protobuf/unittest_extension_nano.proto";
+
+// Must be compiled separately due to extension number reuse.
+// The reuse is deliberate, for testing wire compatibility.
+
+message PackedExtensions {
+ extend ExtendableMessage {
+ repeated int32 packed_int32 = 10 [ packed = true ];
+ repeated uint32 packed_uint32 = 11 [ packed = true ];
+ repeated sint32 packed_sint32 = 12 [ packed = true ];
+ repeated int64 packed_int64 = 13 [ packed = true ];
+ repeated uint64 packed_uint64 = 14 [ packed = true ];
+ repeated sint64 packed_sint64 = 15 [ packed = true ];
+ repeated fixed32 packed_fixed32 = 16 [ packed = true ];
+ repeated sfixed32 packed_sfixed32 = 17 [ packed = true ];
+ repeated fixed64 packed_fixed64 = 18 [ packed = true ];
+ repeated sfixed64 packed_sfixed64 = 19 [ packed = true ];
+ repeated bool packed_bool = 20 [ packed = true ];
+ repeated float packed_float = 21 [ packed = true ];
+ repeated double packed_double = 22 [ packed = true ];
+ repeated AnEnum packed_enum = 23 [ packed = true ];
+ // Non-packable types omitted.
+ }
+}