summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeff Davidson <jpd@google.com>2015-04-02 14:46:35 -0700
committerJeff Davidson <jpd@google.com>2015-04-03 10:04:41 -0700
commitbae6b59812ac972c9792605d521d6ada069288b2 (patch)
treef8b252def86c4bd71be3454b2542f72b9cd2a416 /src
parent00c7607ce445af504021447068d6237ba8100716 (diff)
downloadexternal_protobuf-bae6b59812ac972c9792605d521d6ada069288b2.zip
external_protobuf-bae6b59812ac972c9792605d521d6ada069288b2.tar.gz
external_protobuf-bae6b59812ac972c9792605d521d6ada069288b2.tar.bz2
Generate a CREATOR for each Parcelable message.
This is less ideal from a dex count perspective because it requires a new variable for each message, and because most apps have proguard rules that will ensure that CREATOR classes are retained. However, it is required to be able to use nano protos inside of AIDL files, as the autogenerated AIDL code fails to compile otherwise. This is a substantial benefit as it allows for backwards-compatible parameters and return types in AIDL methods along the lines of safeparcel. Bug: 19084705 Change-Id: I66a2c0424b96cf8ff6b631b186cc4f9407dfc1f4
Diffstat (limited to 'src')
-rw-r--r--src/google/protobuf/compiler/javanano/javanano_message.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/google/protobuf/compiler/javanano/javanano_message.cc b/src/google/protobuf/compiler/javanano/javanano_message.cc
index 4026031..758c9e8 100644
--- a/src/google/protobuf/compiler/javanano/javanano_message.cc
+++ b/src/google/protobuf/compiler/javanano/javanano_message.cc
@@ -154,6 +154,17 @@ void MessageGenerator::Generate(io::Printer* printer) {
}
printer->Indent();
+ if (params_.parcelable_messages()) {
+ printer->Print(
+ "\n"
+ "// Used by Parcelable\n"
+ "@SuppressWarnings({\"unused\"})\n"
+ "public static final android.os.Parcelable.Creator<$classname$> CREATOR =\n"
+ " new com.google.protobuf.nano.android.ParcelableMessageNanoCreator<\n"
+ " $classname$>($classname$.class);\n",
+ "classname", descriptor_->name());
+ }
+
// Nested types and extensions
for (int i = 0; i < descriptor_->extension_count(); i++) {
ExtensionGenerator(descriptor_->extension(i), params_).Generate(printer);