Commit Graph

250 Commits

Author SHA1 Message Date
Brian Duff
553d39f9d8 Merge "Add MessageNano.messageNanoEquals()." 2014-09-02 22:25:40 +00:00
Brian Duff
72881dad55 Add MessageNano.messageNanoEquals().
Allows two messages to be compared directly for equality without
generating an equals method for every generated message.

(Ports CL58125010)

Change-Id: I92ab5088539d1fd722fee7b5e28a8c825926c3b6
2014-09-02 22:24:21 +00:00
Max Cai
9d9cb7c330 Merge "Fixed octal printing of bytearrays" 2014-08-29 15:30:31 +00:00
Linus Tufvesson
2d60e102fa Fixed octal printing of bytearrays
- Now with 50% less '&' and 100% fewer build breakages!

Change-Id: Icf0283220f75cd14b8564b51bd55973e5b7da56b
2014-08-29 11:25:48 +01:00
Max Cai
2b69e07cf3 Merge "Revert "Fixed octal printing of bytearrays"" 2014-08-28 18:19:36 +00:00
Max Cai
42da25e969 Revert "Fixed octal printing of bytearrays"
This reverts commit 8b8481868877c9db407d04bdf4843e50d8920806.

Change-Id: I0876235b79cd7745312879d0f1b00c6d1c1a1b7a
2014-08-28 18:18:46 +00:00
Max Cai
04f70ef5c7 Merge "Fixed octal printing of bytearrays" 2014-08-28 17:28:22 +00:00
Linus Tufvesson
32a45d0921 Fixed octal printing of bytearrays
Change-Id: Ia848d7fae9aeab89e65b00f05cee6c1e6d649d94
2014-08-28 16:20:02 +01:00
Max Cai
ec0e1c00e0 Merge "Fix how getRepeatedFieldArrayLength works" 2014-08-05 00:20:55 +00:00
Leandro Gracia Gil
a174231837 Merge "Fix the aprotoc target for Windows." 2014-07-29 21:36:05 +00:00
Leandro Gracia Gil
b596f9c7b4 Fix the aprotoc target for Windows.
Allows aprotoc.exe to be cross-compiled when building the Windows SDK.

Change-Id: I7e1eec945b5578e1fe6c368b128fe1f9396f491c
2014-07-28 15:27:21 -07:00
Brian Duff
23c5978a76 Merge "Don't return NULL from {Boxed}PrimitiveTypeName." 2014-07-21 15:45:44 +00:00
Brian Duff
7acc0f831f Don't return NULL from {Boxed}PrimitiveTypeName.
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
2014-07-21 14:31:07 -07:00
Max Cai
2a5f3f97a0 Merge "Add a hasExtension method to ExtendableMessageNano." 2014-07-17 22:36:58 +00:00
Juan Silveira
c052b50388 Add a hasExtension method to ExtendableMessageNano.
It allows checking for the presence of an extension without having to
deserialize the field.

Change-Id: Id542d20274b2435b7bc2b322740e9984cb8639a1
2014-07-17 18:47:58 +01:00
Max Cai
7a83d3482a Merge "Fix access around unknownFieldData." 2014-07-14 20:58:48 +00:00
Max Cai
d1a8a8f6f1 Fix access around unknownFieldData.
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
2014-07-15 15:38:04 +01:00
Max Cai
30b1454d8b Merge "Keep pointers to extension values." 2014-07-14 21:03:45 +00:00
Juan Silveira
79f19eb9f1 Keep pointers to extension values.
The current implementation of getExtension deserialises the field from bytes
and returns a new object every time. This means that changes to those objects
are reflected when the messages is serialised unless setExtension is called. It
also means that every call to getExtension and setExtension is expensive.

This change introduces a FieldData class that contains everything that's known
about the field at the time. This can be all the tag/byte[] pairs associated
with a given field or an Extension and a value object. This is so that two
messages with a repeated extension can be compared even if the extension
has been deserialised in one of them but not the other.

This change also adds FieldArray class based on SparseArray from the Android
compatibility library. This is used in ExtendableMessageNano to make lookup
of FieldDatas by their field number faster.

Implications:
* calling getExtension multiple times deserialises the field only once and
  returns the same object.
* calling setExtension doesn't cause the object to be serialised immediately,
  that only happens when the container message is serialised.
* getExtension is no longer a read-only thread-safe operation. README.txt has
  been updated to relfect that.
* comparison using equals and hashCode continues to work.

Bug: 10863158

Change-Id: I81c7cb0c73cc0611a1f7c1eabf5eed259738e8bc
2014-07-14 16:54:28 +01:00
Max Cai
9ceb3d4acc Fix how getRepeatedFieldArrayLength works
Change-Id: I01921eff008a8e3f7b1fbeb653d15ff8038d3220
2014-07-03 12:27:04 +01:00
Ying Wang
70ef74aaa6 am 49512cb0: Merge "You CANNOT change the global WITH_DEXPREOPT"
* commit '49512cb01065b41c0113248c2c02800de1156d50':
  You CANNOT change the global WITH_DEXPREOPT
2014-05-02 04:00:31 +00:00
Ying Wang
b54018a23c Merge "You CANNOT change the global WITH_DEXPREOPT" 2014-05-02 03:57:04 +00:00
Ying Wang
d75027090c You CANNOT change the global WITH_DEXPREOPT
Bug: 14380196
Change-Id: I2b9e6db081558687afd5c20c7084824dfe1bb26e
2014-05-01 20:45:22 -07:00
Jan-Willem Maarse
3e46c9b5da am d20f0a42: Merge "Fix NPE when clearing an extension in nano protos"
* commit 'd20f0a4260763531acf5de677e4830afe0bfc53e':
  Fix NPE when clearing an extension in nano protos
2014-05-01 18:36:30 +00:00
Jan-Willem Maarse
4aecb2b6d5 Merge "Fix NPE when clearing an extension in nano protos" 2014-05-01 18:33:28 +00:00
Jan-Willem Maarse
b24fdd476f Fix NPE when clearing an extension in nano protos
If ExtendableMessageNano doesn't have any unknown fields, trying to
clear an extension by setting it to null would throw an NPE.

Change-Id: I6abcdfcc0193de44f97b21dd6cc2f40604938a1a
2014-05-01 11:08:38 -07:00
Bill Yi
af802cd274 Merge commit 'ba89934bdae7f4256c94a0a24992903a114e764f' into HEAD 2014-04-29 11:34:12 -07:00
Jeff Davidson
a2724e7cf3 Merge "Support generation of Parcelable nano messages." 2014-04-25 22:11:04 +00:00
Jeff Davidson
ec4b1ce0b6 Support generation of Parcelable nano messages.
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
2014-04-25 14:34:55 -07:00
Max Cai
f1019531a6 Merge "Adds --ignore_service nano proto compiler flag" 2014-04-24 18:51:56 +00:00
Jie Dai
d9425a6218 Adds --ignore_service nano proto compiler flag
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
2014-04-23 09:27:07 -07:00
Max Cai
56cba8eeae Merge "Don't reset cachedSize to 0 in getSerializedSize" 2014-04-14 14:57:54 +00:00
Dave Hawkey
598087ef53 Don't reset cachedSize to 0 in getSerializedSize
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
2014-04-10 08:21:44 -06:00
Wink Saville
6ba01e2439 am ce2f5991: Merge "Revert "Don\'t reset cachedSize to 0 in getSerializedSize""
* commit 'ce2f59915e0b41c935e3f72a2b7b71b6c19b6860':
  Revert "Don't reset cachedSize to 0 in getSerializedSize"
2014-03-22 01:20:45 +00:00
Wink Saville
dc2ab87569 Merge "Revert "Don't reset cachedSize to 0 in getSerializedSize"" 2014-03-22 01:09:34 +00:00
Wink Saville
b7dd7d9294 Revert "Don't reset cachedSize to 0 in getSerializedSize"
This reverts commit c6e12c6702ca764486f952654ba1568f00efe813.
2014-03-21 18:05:10 -07:00
Wink Saville
9d89464330 am ec0b12c3: Merge "Don\'t reset cachedSize to 0 in getSerializedSize"
* commit 'ec0b12c34a6329d2f98003e9102fe2d75726c797':
  Don't reset cachedSize to 0 in getSerializedSize
2014-03-21 17:17:27 +00:00
Wink Saville
ddc98d6dd0 Merge "Don't reset cachedSize to 0 in getSerializedSize" 2014-03-21 17:08:31 +00:00
Dave Hawkey
5090f19ea7 Don't reset cachedSize to 0 in getSerializedSize
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
2014-03-21 09:27:23 -06:00
Wink Saville
66ec7d4151 am 51ef8f39: Merge "Fix compile error on mac 10.9"
* commit '51ef8f39de376fe71ce5d2c682abe4f974cf8074':
  Fix compile error on mac 10.9
2014-03-08 01:52:05 +00:00
Max Cai
e73c4a02a9 am afc1553a: Merge "Extension overhaul."
* commit 'afc1553a9eb56eff742828c9c819eafa363cdcc9':
  Extension overhaul.
2014-03-07 19:39:30 +00:00
Max Cai
b97d258c9f am 447f664a: Merge changes I9fecff3c,I2c1eb07f
* commit '447f664aef6694bb9fb3db85d6166d908cde8a8d':
  Fix repeated packed field merging code for non-packed data.
  Add validation when parsing enum fields.
2014-03-07 02:25:57 +00:00
Max Cai
3a2109246f Merge "Extension overhaul." 2014-02-17 15:28:08 +00:00
Max Cai
a2d72a5853 Merge changes I9fecff3c,I2c1eb07f
* changes:
  Fix repeated packed field merging code for non-packed data.
  Add validation when parsing enum fields.
2014-02-10 14:04:23 +00:00
Max Cai
74959d4796 Fix repeated packed field merging code for non-packed data.
Enum fix is already included in the previous commit.

Bug: https://code.google.com/p/android/issues/detail?id=64893
Change-Id: I9fecff3c8822918a019028eb57fa39b361a2c960
2014-01-16 12:41:26 +00:00
Max Cai
e005be6554 Add validation when parsing enum fields.
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
2014-01-16 12:41:15 +00:00
Max Cai
14ae5639b3 am a8af729b: Merge "Allow whitespace in nano codegen options."
* commit 'a8af729b5ef822971f025a7e8ff197545986910d':
  Allow whitespace in nano codegen options.
2014-01-14 10:14:47 -08:00
Max Cai
a793c09b6f Merge "Allow whitespace in nano codegen options." 2014-01-14 18:08:45 +00:00
Max Cai
bc8eec3d2b Allow whitespace in nano codegen options.
So we don't need to keep all option in a single line in the .mk files.

Change-Id: I786b879b334cac4cd13b32fabcb76efe53b4ac80
2014-01-14 15:03:05 +00:00
Max Cai
d44a519d8f am 4b5874fa: Merge "Correctness: floating point equality using bits instead of ==."
* commit '4b5874fad099faefb469c632e4c7b854cea733ae':
  Correctness: floating point equality using bits instead of ==.
2014-01-13 05:25:49 -08:00