aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/javanano
Commit message (Collapse)AuthorAge
* Add std:: namespace prefix to set and map (#3332)Gravatar tanderson-google2017-07-09
| | | * Remove using std::{set,map}
* Remove "using namespace std" from stubs/common.hGravatar Adam Cozzette2017-04-26
| | | | | | | | This prevents the contents of the std namespace from being effectively pulled into the top-level namespace in all translation units that include common.h. I left in individual using statements for a few common things like std::set and std::map, because it did not seem worth going through the churn of updating the whole codebase to fix those right now.
* Fix javanano packageGravatar Jisi Liu2016-03-31
|
* Integrate google internal changes.Gravatar Jisi Liu2016-03-30
|
* Generate a package name suffix ".nano" for nano messagesGravatar Xiao Hang2015-07-29
| | | | Also introducing an option javanano_use_deprecated_package to allow users to disable the suffix
* Generate a CREATOR for each Parcelable message.Gravatar Jeff Davidson2015-04-28
| | | | | | | | | | | | | | | 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
* Inline unknownFieldData{Equals,HashCode} to generated code.Gravatar Brian Duff2015-04-28
| | | | | | | | | | It turns out dex (apparently) was inlining these protected final methods from ExtendableMessageNano into every message class. Removing these methods from the base class and inlining their code reduces the method count by 2 methods / message when the store_unknown_fields option is on. Change-Id: I0aa09f2016d39939c4c8b8219601793b8fab301f
* Expose generate_clear as an option.Gravatar Brian Duff2015-04-28
| | | | | | | | | | | | | | | | | | I wasn't able to get the clear() method to inline into the constructor when optimizations are on in proguard. As a result, every message has an extra superfluous kept method assuming the app never uses clear() directly. There are a couple of instances where setting this option false is necessary in order to get code dexing successfully without hitting the method limit, e.g. https://goto.google.com/tltzq In this example, I tried turning on the method/inlining/unique and method/inlining/short optimizations before resorting to adding the generate_clear option, but the method count did not decrease. The clear() methods were contributing over a thousand extra methods. Change-Id: If6a9651d6a59cdf70b1040d8248779710ac73105
* Generate @IntDef annotations for nanoproto enums.Gravatar Jeff Davidson2015-04-28
| | | | | | | | | | @IntDef is a support library annotation which allows build tools to determine the valid set of values for a given integer field when that field is intended to be restricted like an enum. This avoids the overhead of enums while still allowing for compile-time type checking in most circumstances. Change-Id: Iee02e0b49a8e069f6456572f538e0a0d301fdfd5
* Add clone() method support for nano.Gravatar Brian Duff2015-04-28
| | | | | | Upstreamed from Another Place (cr/57247854). Change-Id: I2aaf59544c0f5ae21a51891d8a5eeda1dc722c90
* When no clear() is generated, still initialize fields.Gravatar Brian Duff2015-04-28
| | | | | | | | | | | | | | | | https://android-review.googlesource.com/#/c/67890/ removed field initialization from the ctor, making it just call clear() instead. When I added the generate_clear option back (as part of the reftypes compat mode) in https://android-review.googlesource.com/#/c/109530/, I forgot to ensure that what clear() used to do was inlined in the constructor. This change fixes NPEs that are happening for users of reftypes_compat_mode who rely on unset repeated fields being empty arrays rather than null. Change-Id: Idb58746c60f4a4054b7ebb5c3b0e76b16ff88184
* Fix bug with large extension field numbers.Gravatar Brian Duff2015-04-28
| | | | | | | | | | | | | | | | | | | Previously, extensions with field numbers greater than 268435455 would result in a compile time error in generated code that looks something like this: Foo.java:3178: error: integer number too large: 3346754610 3346754610); This is because we were trying to represent the tag number (an unsigned int) using a java int constant, but java int constants are signed, and can't exceed Integer.MAX_VALUE. Fixed by declaring it as a long instead, and casting it down to an int in the implementation. This is safe, because the tag value always fits in 32 bis. Change-Id: If2017bacb4e20af667eaeaf9b65ddc2c30a7709f
* Merge pull request #185 from mzhaom/remove-unusedGravatar Jisi Liu2015-02-26
|\ | | | | Remove unused methods:
* | Fix review comments.Gravatar Jisi Liu2015-02-19
| | | | | | | | Change-Id: Iafd4a3aa9d55e31478bf070311eeadfe95ece4d7
* | Remove the unused set common oneof variables in helperGravatar Jisi Liu2015-02-19
| |
* | fix equal and hash for bytes field for javanano oneofGravatar Jisi Liu2015-02-19
| |
* | Clear oneofs.Gravatar Jisi Liu2015-02-19
| |
* | hashcode and equals for oneofs in nano.Gravatar Jisi Liu2015-02-19
| |
* | Equals for message oneof field in nano.Gravatar Jisi Liu2015-02-19
| |
* | Oneof message level elements (consts, case getter/clear) and messsage type ↵Gravatar Jisi Liu2015-02-19
| | | | | | | | field oneof support.
* | Initial check-in for message oneof.Gravatar Jisi Liu2015-02-19
| |
* | Initial check in for primitive oneof fields.Gravatar Jisi Liu2015-02-19
| |
* | Get the map factory per mergeFrom() call for JavaNano.Gravatar Jisi Liu2015-02-07
| |
* | implement hashCode() for JavaNano maps.Gravatar Jisi Liu2015-02-06
| |
* | Implement Equals for nano.Gravatar Jisi Liu2015-02-06
| |
* | Fix the behavior when merging conflicting keys, the new value alwaysGravatar Jisi Liu2015-02-05
| | | | | | | | override the existing one even for message types.
* | Moving internal code to InternalNano and rename MapUtil to MapFactories.Gravatar Jisi Liu2015-02-04
| |
* | parsing and serialzation for maps in JavaNano.Gravatar Jisi Liu2015-02-03
| |
* | Parsing for Maps in JavaNanoGravatar Jisi Liu2015-02-02
| |
* | Use map generator for maps field; skip entry message.Gravatar Jisi Liu2015-02-02
| |
* | Initial checkin for maps support in JavaNano.Gravatar Jisi Liu2015-01-30
| |
| * Remove unused methods:Gravatar Ming Zhao2015-01-29
|/ | | | MessageTypeProtoName, IsVariableLenType
* Prepare nano proto code to be merged into protobuf repository.Gravatar Feng Xiao2014-11-19
|
* Change reftypes_primitive_enums to reftypes_compat_mode.Gravatar Brian Duff2014-10-01
| | | | | | Make the clear() method stripped in reftypes_compat_mode. Change-Id: I0ec35537856f59a6ecf231bfd74df995c858e2b2
* Adds a primitive enum mode for reftypes.Gravatar Brian Duff2014-09-30
| | | | | | This is a compatibility shim. Change-Id: Ia0b417d4621e391ede618d0b3b1c470c9896e0ff
* Includes a MessageNano subclass's name's hashCode in hashCode calculations.Gravatar Jason Neufeld2014-09-16
| | | | | | | | | | In the current implementation, a message with the same amount of null or equal-valued fields as a different message type will have the same hashCode. This adds more variety by including the hashCode of the class's name in the hashCode calculations. Change-Id: I284e3e6d198ad8037815948d1f65686465ffd623 Signed-off-by: Jason Neufeld <jneufeld@google.com>
* Don't return NULL from {Boxed}PrimitiveTypeName.Gravatar Brian Duff2014-07-21
| | | | | | | The behavior of the string ctor is undefined when you pass NULL. This is checked strictly in C++11, so fails to compile. Change-Id: Id5e0984ad1d37f2d504f7c42ac23e52ed4a58903
* Fix access around unknownFieldData.Gravatar Max Cai2014-07-15
| | | | | | | | | | | Instead of publishing its class I chose to encapsulate the troublesome references in equals()/hashCode() in the generated code into superclass methods in ExtendableMessageNano. Changed a couple of java packages in the test suite to catch this issue easier in the future. Change-Id: I43f88411f63bb6f3ffc8d63361f2f77bebf6220a
* Support generation of Parcelable nano messages.Gravatar Jeff Davidson2014-04-25
| | | | | | | | | | | | | | | | | | | | This CL adds the "parcelable_messages" option. When enabled, all generated message classes will conform to the Android Parcelable contract. This is achieved by introducing a new parent class for generated classes which implements the required functionality. Since the store_unknown_fields option also makes use of a superclass, ExtendableMessageNano, we have two versions of the new Parcelable superclass: one extending MessageNano, and one extending ExtendableMessageNano. These classes are otherwise identical. As these classes depend on Android framework jars, they are not included in the host .jar build of the nanoproto library. Finally, add a test suite for running tests of Android-specific functionality, as this cannot be done on a desktop JVM. Change-Id: Icc2a257f03317e947f7078dbb9857c3286857497
* Adds --ignore_service nano proto compiler flagGravatar Jie Dai2014-04-23
| | | | | | | | Nano proto compiler normally throws an error if any service is defined. If --ignore-services=true is set, no error is thrown and the service is simply skipped. Change-Id: Id82583555085cc55550d03a485d3f0189885240b
* Don't reset cachedSize to 0 in getSerializedSizeGravatar Dave Hawkey2014-04-10
| | | | | | | | | | | | This avoids a race-condition when cachedSize is momentarily set to 0 for non-empty messages if multiple threads call getSerializedSize (e.g. during serialization). This is a retry of https://android-review.googlesource.com/#/c/88570/. getSerializedSize() has been kept non-final so that messages generated with a previous version of the compiler will not break. Change-Id: I8d8154a10938cde579ae19c55eae55b1e70e0bda
* Revert "Don't reset cachedSize to 0 in getSerializedSize"Gravatar Wink Saville2014-03-21
| | | | This reverts commit c6e12c6702ca764486f952654ba1568f00efe813.
* Don't reset cachedSize to 0 in getSerializedSizeGravatar Dave Hawkey2014-03-21
| | | | | | | | This avoids a race-condition when cachedSize is momentarily set to 0 for non-empty messages if multiple threads call getSerializedSize (e.g. during serialization). Change-Id: I15a8ded92edbf41bf1c8d787960c5bbbc8a323c5
* Merge "Extension overhaul."Gravatar Max Cai2014-02-17
|\
* | Fix repeated packed field merging code for non-packed data.Gravatar Max Cai2014-01-16
| | | | | | | | | | | | | | Enum fix is already included in the previous commit. Bug: https://code.google.com/p/android/issues/detail?id=64893 Change-Id: I9fecff3c8822918a019028eb57fa39b361a2c960
* | Add validation when parsing enum fields.Gravatar Max Cai2014-01-16
| | | | | | | | | | | | | | | | | | | | | | | | Invalid values from the wire are silently ignored. Unlike full/lite, the invalid values are not stored into the unknown fields, because there's no way to get them out from Nano's unknown fields without a matching Extension. Edited README and slightly moved it towards a standalone section for Nano, independent of the Micro section. Change-Id: I2c1eb07f4d6d8f3aea242b8ddd95b9c966f3f177
* | Allow whitespace in nano codegen options.Gravatar Max Cai2014-01-14
| | | | | | | | | | | | So we don't need to keep all option in a single line in the .mk files. Change-Id: I786b879b334cac4cd13b32fabcb76efe53b4ac80
* | Correctness: floating point equality using bits instead of ==.Gravatar Max Cai2014-01-10
| | | | | | | | | | | | | | | | | | | | | | Special values for float and double make it inaccurate to test the equality with ==. The main Java library uses the standard Object.equals() implementation for all fields, which for floating point fields means Float.equals() or Double.equals(). They define equality as bitwise equality, with all NaN representations normalized to the same bit sequence (and therefore equal to each other). This test checks that the nano implementation complies with Object.equals(), so NaN == NaN and +0.0 != -0.0. Change-Id: I97bb4a3687223d8a212c70cd736436b9dd80c1d7
* | Don't serialize required fields whose 'has' flags are unset.Gravatar Max Cai2014-01-10
| | | | | | | | Change-Id: Ibbe944fff83e44a8f2206e18ee9ec6f10661297a
| * Extension overhaul.Gravatar Max Cai2014-01-10
|/ | | | | | | | | | | | | | | | | | | | | | - 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