aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/javanano/javanano_helpers.cc
Commit message (Collapse)AuthorAge
* Remove javanano.Gravatar Feng Xiao2018-03-26
|
* 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.
* 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
* 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
|
* Adds a primitive enum mode for reftypes.Gravatar Brian Duff2014-09-30
| | | | | | This is a compatibility shim. Change-Id: Ia0b417d4621e391ede618d0b3b1c470c9896e0ff
* 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
* Merge "Extension overhaul."Gravatar Max Cai2014-02-17
|\
* | 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
| * 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
* Avoid class initializers to help ProGuard.Gravatar Max Cai2013-12-10
| | | | | | | | | | | | | | | | | | | Class initializers prevent ProGuard from inlining any methods because it thinks the class initializer may have side effects. This is true for static methods, but instance methods can still be inlined, because to have an instance you will have touched the class and any class initializers would have run. But ProGuard only starts inlining instance methods of classes with class initializers from v4.11b6, and Android uses v4.4 now. This change tries to avoid the class initializers as much as possible, by delaying the initialization of the empty array and some fields' saved defaults until when they're needed. However, if the message hosts any extensions, they must be public static final and therefore introducing the class initializer. In that case we won't bother with lazy initialization. Change-Id: I00d8296f6eb0023112b93ee135cdb28dbd52b0b8
* Implement hashCode() and equals() behind a generator option.Gravatar Brian Duff2013-10-25
| | | | | | | | | | | | | | | | The option is only called 'generate_equals' because: - equals() is the main thing; hashCode() is there only to complement equals(); - it's shorter; - toString() should not be included in this option because it's more for debugging and it's more likely to stop ProGuard from working well. Also shortened the "has bit" expression; was ((bitField & mask) == mask), now ((bitField & mask) != 0). Both the Java code and the bytecode are slightly shorter. Change-Id: Ic309a08a60883bf454eb6612679aa99611620e76
* Add reftypes field generator option.Gravatar Brian Duff2013-10-07
| | | | | | | | This option generates fields as reference types, and serializes based on nullness. Change-Id: Ic32e0eebff59d14016cc9a19e15a9bb08ae0bba5 Signed-off-by: Brian Duff <bduff@google.com>
* Implement enum_style=java option.Gravatar Max Cai2013-09-25
| | | | | | | | | | This javanano_out command line option creates a container interface at the normal place where the enum constants would reside, per enum definition. The java_multiple_files flag would now affect the file- scope enums with the shells. If the flag is true then file-scope container interfaces are created in their own files. Change-Id: Id52258fcff8d3dee9db8f3d8022147a811bf3565
* Accessor style for optional fields.Gravatar Max Cai2013-09-23
| | | | | | | | | | | This CL implements the 'optional_field_style=accessors' option. All optional fields will now be 1 Java field and 1 bit in a shared bitfield behind get/set/has/clear accessor methods. The setter performs null check for reference types (Strings and byte[]s). Also decentralized the clear code generation. Change-Id: I60ac78329e352e76c2f8139fba1f292383080ad3
* Add some bitfield helper methods from 2.4Gravatar Max Cai2013-09-20
| | | | Change-Id: Ib9bb549602f71a451d2107fb04de17877553860e
* Fix outer classname for javamicro/javanano.Gravatar Max Cai2013-08-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - File class name is defined as the java_outer_classname option value or the file name ToCamelCase; never the single message's ClassName. - File-scope enums are translated to constants in the file class, regardless of java_multiple_files. - If java_multiple_files=true, and file's class name equals a message's class name, no error. This is done by detecting that the outer class is not needed and skipping the outer class codegen and clash checks. Note: there is a disparity between java[lite] and the previous java{micr|nan}o: when generating code for a single-message proto, the outer class is omitted by java{micr|nan}o if the file does not have java_outer_classname. This change makes java{micr|nan}o align with java[lite] codegen and create the outer class, but will print some info to warn of potential change of code. - Also fixed the "is_own_file" detection and made all parseX() methods static. Previously, all messages in a java_multiple_files=true file are (incorrectly) considered to be in their own files, including nested messages, causing them to become inner classes (instance- bound) and forcing the parseX() methods to lose the static modifier. - This change supersedes c/60164 and c/60086, which causes javanano to put enum values into enum shell classes if java_multiple_files=true. We now always use the parent class to host the enum values. A future change will add a command line option to provide more flexibility. - Elaborated in java/README.txt. Change-Id: I684932f90e0a028ef37c662b221def5ffa202439
* Per-file java_multiple_files flag.Gravatar Max Cai2013-07-25
| | | | | | | | | | | | | | | Imported source files may have different values for the 'java_multiple_files' option to the main source file's. Whether the fully qualified Java name of an entity should include the outer class name depends on the flag value in the file defining the referenced entity, not the main file. This CL loads the flag values from the main and all transitively imported files into the params, and generates the fully qualified Java names accordingly. If the generator option 'java_multiple_files' is set, its value overrides any in-file values in all source/imported files. This is because this generator option is typically used on either none or all source files. Change-Id: Id6a4a42426d68961dc669487d38f35530deb7d8e
* Allow NaN/+inf/-inf defaults in micro/nano.Gravatar Chris Smith2013-07-23
| | | | | | | | Adds support for default values of NaN, infinity and negative infinity for floats and doubles in both the nano and micro java compiler. Change-Id: Ibc43e5ebb073e51d9a8181f3aa23b72e10015dca
* Update nano to serialize java keywords properly.Gravatar Tom Chao2013-07-19
| | | | Change-Id: I7407d0fab609c336ecd73499e725aed0dd50f555
* Fix enum field references with java_multiple_files.Gravatar Brian Duff2013-06-07
| | | | | | | | | When the java_multiple_files option is on, enums are placed in java class files based on the name of the original enum type. This fixes field references to such enum values to point to the correct class name when setting the default. Change-Id: I51a2e251c0d0ab1e45a182ba849d314232a74bac
* Nano protobufs.Gravatar Ulas Kirazci2013-04-01
Like micro protobufs except: - No setter/getter/hazzer functions. - Has state is not available. Outputs all fields != their default. - CodedInputStream can only take byte[] (not InputStream). - Repeated fields are in arrays, not ArrayList or Vector. - Unset messages/groups are null, not "defaultInstance()". - Required fields are always serialized. To use: - Link libprotobuf-java-2.3.0-nano runtime. - Use LOCAL_PROTOC_OPTIMIZE_TYPE := nano Change-Id: I7429015b3c5f7f38b7be01eb2d4927f7a9999c80