Commit Graph

2081 Commits

Author SHA1 Message Date
Feng Xiao
5a9863b584 Merge pull request #303 from xfxyjwf/wkt
Include well-known type protos in "make install".
2015-04-29 10:41:35 -07:00
Jon Skeet
0e916d09a3 Removing more C# project files. 2015-04-29 12:22:35 +01:00
Jon Skeet
f015b860b7 Remove CLS compliance from runtime code.
We need to remove it from the generator too; I'll raise a github issue for that.
2015-04-29 12:21:54 +01:00
Jon Skeet
5e0189ab94 Update C# solution and AddressBook project.
Move to a single solution file containing all of the C# projects, but no other solution folders - it's easier to edit those files outside VS than keep adding and removing them from the project.
The AddressBook protos have been regenerated (with a change to the example proto which I haven't included in this change - I'll wait for us to decide exactly what we're doing with namespaces before changing protos outside the csharp directory.

Note that now we've got Addressbook.cs which contains AddressBook and Addressbook classes. It's bad enough that we've got a class called AddressBook within a namespace of AddressBook (hard to get away from) but having things vary just by case is nasty.
This is more evidence that an option for renaming the file and descriptor class would be welcome. (A single option can probably handle both.)
2015-04-29 10:10:20 +01:00
Jon Skeet
f651f73a3c Remove support for Serializable.
This could potentially be added back in later, but its use is limited and it's a pain in terms of support in PCL environments.
One use that has been highlighted is passing objects between AppDomains; we'd recommend passing a byte array explicitly and reparsing on the other side.
2015-04-29 09:18:19 +01:00
Jon Skeet
cc058e1118 Remove RPC support.
It is expected that third parties will generate service/RPC code themselves - see gRPC as an example.
2015-04-29 08:55:07 +01:00
Jon Skeet
e8310aa259 Remove a bunch of files which are no longer relevant:
1) Project files for different configurations - we're going to look at all this again, ideally to just have a single PCL-compatible build
2) ProtoGen - the C++ generator is now the only one we care about
3) Proto files - these are mostly duplicates (or older versions) of the ones in the common directories
2015-04-29 06:55:51 +01:00
Jie Luo
8bae6c09bc Merge pull request #1 from google/csharp
Csharp update
2015-04-28 16:26:19 -07:00
Jie Luo
32ead755d1 Merge pull request #313 from jskeet/csharp
First steps to making the C# runtime work with new codegen
2015-04-28 14:23:18 -07:00
Jeff Davidson
9d546c85bd 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
2015-04-28 13:12:37 -07:00
Charles Munger
6732dd7e58 Throw OutOfSpaceException instead of IllegalArgumentException.
When a MessageNano containing a String is serialized into a buffer that
is too small to contain it, and the buffer's boundary happens to be
where the string field's length delimiting varint is serialized,
and the string's length and 3*length have the same length when
encoded as a varint, an IllegalArgumentException is thrown rather than
an OutOfSpaceException.

Github issue: https://github.com/google/protobuf/issues/292

Change-Id: If478d68cf15bfd0662252d008e42b2bf1ff1c75e
2015-04-28 13:10:49 -07:00
Brian Duff
a69b461e1e Inline unknownFieldData{Equals,HashCode} to generated code.
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
2015-04-28 13:02:33 -07:00
Brian Duff
dac7e02d2b Expose generate_clear as an option.
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
2015-04-28 13:01:48 -07:00
Jeff Davidson
ec19be2f3c Generate @IntDef annotations for nanoproto enums.
@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
2015-04-28 13:01:12 -07:00
Shai Barack
41f0294cd6 Add reset() and position() to CodedOutputByteBufferNano.
Change-Id: Ie2a9e36276ac35e10b3f8d379b5742d50a0374e9
2015-04-28 12:47:42 -07:00
Kweku Adams
2712c42136 DO NOT MERGE Overloading createMessageTyped to accept a tag as an integer.
When building, some instances expect createMessageTyped to have the signature
(int, Class, long), while others expect (int, Class, int). Simply having
the former signature meant that builds expecting the latter would fail.

This is a cherrypick of change b2a9d4321578139677c146ce37eba5e27e8f5c79
from master.

Change-Id: Ib02dbf66173510f4edea32c7b43e82c1a7a38aa2
2015-04-28 12:46:35 -07:00
Brian Duff
714dba3ab8 Exclude cachedSize when printing fields.
Change-Id: I85563b74237d38c1e447b7286f5f6e62d57e3d63
2015-04-28 12:44:08 -07:00
Brian Duff
d099a88685 Add clone() method support for nano.
Upstreamed from Another Place (cr/57247854).

Change-Id: I2aaf59544c0f5ae21a51891d8a5eeda1dc722c90
2015-04-28 12:42:55 -07:00
Brian Duff
fb96026b8d When no clear() is generated, still initialize fields.
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
2015-04-28 12:28:05 -07:00
Brian Duff
9ffaa50d55 Fix comments.
Forgot to update these in https://android-review.googlesource.com/#/c/109809/

Change-Id: I53f838e2f134f53964161d9620d5ead00c4a3939
2015-04-28 12:14:54 -07:00
Charles Munger
54511f701f Optimize measurement and serialization of nano protos.
Measuring the serialized size of nano protos is now a zero-alloc operation, and serializing a proto now allocates no memory (other than the output buffer) instead of O(total length of strings).

Change-Id: Id5e2ac3bdc4ac56c0bf13d725472da3a00c9baec
Signed-off-by: Charles Munger <clm@google.com>
2015-04-28 12:10:28 -07:00
Brian Duff
ec2f244554 Fix bug with large extension field numbers.
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
2015-04-28 11:42:01 -07:00
Jon Skeet
5ca6dd76fb Update DescriptorProtoFile.cs and UnitTest.cs to indicate manual changes.
(Having regenerated descriptor.proto relative to src, the earlier commented-out code checking that dependencies match may now be okay to uncomment again. Will experiment in later CLs.)
2015-04-28 18:47:47 +01:00
Jon Skeet
ce66c5f1b9 Updated set of unit tests and unit test protos.
This commit includes changes to the C#-specific protos, and rebuilt versions of the "stock" protos.
The stock protos have been locally updated to have a specific C# namespace, but this is expected to change soon, so hasn't been committed.
Four areas are currently not tested:
1) Serialization - we may restore this at some point, possibly optionally.
2) Services - currently nothing is generated for this; will need to see how it interacts with GRPC
3) Fields beginning with _{digit} - see https://github.com/google/protobuf/issues/308
4) Fields with names which conflict with the declaring type in nasty ways - see https://github.com/google/protobuf/issues/309
2015-04-28 15:06:59 +01:00
Jon Skeet
f3504cf3b1 First part of making the C# runtime work with the new codegen.
1) Remove CSharpOptions
2) A new version of DescriptorProtoFile (with manual changes from codegen - it would otherwise be Descriptor.cs)
3) Turn off CLS compliance (which we'll remove from the codebase entirely; I don't think it's actually relevant these days)
4) Add "public imports" to FileDescriptor, with code broadly copied from the Java codebase.
Lots more changes to commit before it will build and tests run, but one step at a time...
2015-04-28 14:53:24 +01:00
Behzad Tabibian
4b4770280d adding globals() to exec call for python3 compatibility 2015-04-28 11:09:05 +02:00
Bo Yang
46bd60b92f Modify directory to use in test
Change-Id: Iede1dc4e70427663e0d3c5304fa86b3aebf492b7
2015-04-27 17:44:45 -07:00
Jie Luo
8a3ec53e86 remove test proto for field presence 2015-04-27 15:38:13 -07:00
Bo Yang
9a12185323 Handle un-handled cases of TestOneof2 in unittest
Change-Id: I8f082ee3117ed873ab472a539867ff7cae58e8fd
2015-04-27 14:47:04 -07:00
Jie Luo
5a811ac6f9 fix bug for Field Presence 2015-04-27 14:27:21 -07:00
Jie Luo
856ced5d76 Field Presence: remove has methods for optional non-message fields in proto3 2015-04-27 14:00:47 -07:00
Jie Luo
b977c3ed63 Merge pull request #300 from jskeet/csharp
Add C# generator files to the VS project for libprotoc
2015-04-27 10:42:34 -07:00
Bo Yang
d6c9f644ac internal changes
Change-Id: I66f216c70a19f44637090878d7e442d4d0f8991b
2015-04-24 18:09:55 -07:00
Jon Skeet
8d7e9433b3 Add C# files to Visual Studio projects.
Also ignore Windows native build output files.
2015-04-24 09:21:31 +01:00
Feng Xiao
7ddbf87008 Include well-known type protos in "make install". 2015-04-23 20:23:58 -07:00
Jisi Liu
fe7b5667eb Merge pull request #287 from zhangkun83/protoc-artifacts-fixup
A few fix-ups for protoc-artifacts
2015-04-21 10:50:48 -07:00
Feng Xiao
ba05454041 Merge pull request #290 from xfxyjwf/wkt
Include all well-known type protos.
2015-04-20 13:53:44 -07:00
Feng Xiao
ca9d1a053a Include all well-known type protos.
Change-Id: I122f1cee71a8a739ea603e52582cb0fa9698f0ed
2015-04-20 11:30:31 -07:00
Jie Luo
7646eec9ce Merge pull request #288 from jtattermusch/csharp_protobuf_reviewed
C# protocol buffers (initial pull request)
2015-04-17 17:29:39 -07:00
Jan Tattermusch
7eaf438031 forgot to include header files into automake template 2015-04-17 16:51:43 -07:00
Jan Tattermusch
8394a8daef Merge pull request #1 from jtattermusch/csharp_protogen_rewrite
Rewrite of C# protogen to C++ (initial version)
2015-04-17 15:02:14 -07:00
Jan Tattermusch
01c8c35ca3 Merge pull request #2 from jtattermusch/csharp_protobuf_imported
Pulling protobuf-csharp-port into csharp/ directory
2015-04-17 14:15:52 -07:00
Jan Tattermusch
8e190d498c temporarily removing csharp_umbrella_namespace file option 2015-04-17 11:07:02 -07:00
Jan Tattermusch
83a5991d12 removing csharp_property_name field option 2015-04-17 10:53:06 -07:00
Jan Tattermusch
b36420addb one more fix to csharp_umbrella_namespace comment 2015-04-17 10:20:35 -07:00
Jan Tattermusch
b6555b1da0 fix: do not mention umbrella_classname in comment 2015-04-17 10:00:38 -07:00
Kun Zhang
90a7ed6fcc A few fix-ups.
1. make google/protobuf/stubs/pbconfig.h before making protoc, otherwise it
won't build a freshly checked-out code.
2. Document the build environments that have been tested to work.
3. Add support for MINGW64
2015-04-16 17:56:12 -07:00
Josh Haberman
420f938bac Added conformance test support for Java.
Change-Id: I4c81808e6ace77d2b5737a43417045321b0b10f0
2015-04-16 15:45:03 -07:00
Jan Tattermusch
abcde243fe Fixed comment for csharp_umbrella_namespace (nest_classes has been removed) 2015-04-16 15:32:36 -07:00
Jan Tattermusch
2c2f76c50f fixing field number of csharp_umbrella_namespace option 2015-04-16 15:28:32 -07:00