From 382ddccb550e1c822ef26a0e65988998f7446624 Mon Sep 17 00:00:00 2001 From: Max Cai Date: Wed, 20 Nov 2013 18:59:01 +0000 Subject: Extension overhaul. - Get rid of TypeLiteral. It was introduced to read the component type of a List 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 --- src/google/protobuf/compiler/javanano/javanano_helpers.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/google/protobuf/compiler/javanano/javanano_helpers.h') diff --git a/src/google/protobuf/compiler/javanano/javanano_helpers.h b/src/google/protobuf/compiler/javanano/javanano_helpers.h index 753a4bd..886bff8 100644 --- a/src/google/protobuf/compiler/javanano/javanano_helpers.h +++ b/src/google/protobuf/compiler/javanano/javanano_helpers.h @@ -39,6 +39,7 @@ #include #include #include +#include namespace google { namespace protobuf { @@ -111,6 +112,9 @@ string FieldConstantName(const FieldDescriptor *field); string FieldDefaultConstantName(const FieldDescriptor *field); +// Print the field's proto-syntax definition as a comment. +void PrintFieldComment(io::Printer* printer, const FieldDescriptor* field); + enum JavaType { JAVATYPE_INT, JAVATYPE_LONG, @@ -129,10 +133,12 @@ inline JavaType GetJavaType(const FieldDescriptor* field) { return GetJavaType(field->type()); } +string 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. -const char* BoxedPrimitiveTypeName(JavaType type); +string BoxedPrimitiveTypeName(JavaType type); string EmptyArrayName(const Params& params, const FieldDescriptor* field); -- cgit v1.1