Commit 581be246 authored by Jisi Liu's avatar Jisi Liu

Merge alpha branch 'review/v3.0.0-alpha-2'

parents 7c43f170 e70329c6
2015-02-22 version 3.0.0-alpha-2 (Ruby/JavaNano):
General
* Introduced two new language implementations (Ruby and JavaNano) to proto3.
* Various bug fixes since 3.0.0-alpha-1
Ruby:
We have added proto3 support for Ruby via a native C extension.
The Ruby extension itself is included in the ruby/ directory, and details on
building and installing the extension are in ruby/README.md. The extension
will also be published as a Ruby gem. Code generator support is included as
part of `protoc` with the `--ruby_out` flag.
The Ruby extension implements a user-friendly DSL to define message types
(also generated by the code generator from `.proto` files). Once a message
type is defined, the user may create instances of the message that behave in
ways idiomatic to Ruby. For example:
- Message fields are present as ordinary Ruby properties (getter method
`foo` and setter method `foo=`).
- Repeated field elements are stored in a container that acts like a native
Ruby array, and map elements are stored in a container that acts like a
native Ruby hashmap.
- The usual well-known methods, such as `#to_s`, `#dup`, and the like, are
present.
Unlike several existing third-party Ruby extensions for protobuf, this
extension is built on a "strongly-typed" philosophy: message fields and
array/map containers will throw exceptions eagerly when values of the
incorrect type are inserted.
See ruby/README.md for details.
JavaNano:
JavaNano is a special code generator and runtime library designed especially
for resource-restricted systems, like Android. It is very resource-friendly
in both the amount of code and the runtime overhead. Here is an an overview
of JavaNano features compared with the official Java protobuf:
- No descriptors or message builders.
- All messages are mutable; fields are public Java fields.
- For optional fields only, encapsulation behind setter/getter/hazzer/
clearer functions is opt-in, which provide proper 'has' state support.
- For proto2, if not opted in, has state (field presence) is not available.
Serialization outputs all fields not equal to their defaults.
The behavior is consistent with proto3 semantics.
- Required fields (proto2 only) are always serialized.
- Enum constants are integers; protection against invalid values only
when parsing from the wire.
- Enum constants can be generated into container interfaces bearing
the enum's name (so the referencing code is in Java style).
- CodedInputByteBufferNano can only take byte[] (not InputStream).
- Similarly CodedOutputByteBufferNano can only write to byte[].
- Repeated fields are in arrays, not ArrayList or Vector. Null array
elements are allowed and silently ignored.
- Full support for serializing/deserializing repeated packed fields.
- Support extensions (in proto2).
- Unset messages/groups are null, not an immutable empty default
instance.
- toByteArray(...) and mergeFrom(...) are now static functions of
MessageNano.
- The 'bytes' type translates to the Java type byte[].
See javanano/README.txt for details.
2014-12-01 version 3.0.0-alpha-1 (C++/Java): 2014-12-01 version 3.0.0-alpha-1 (C++/Java):
General General
......
...@@ -154,6 +154,46 @@ java_EXTRA_DIST= \ ...@@ -154,6 +154,46 @@ java_EXTRA_DIST= \
java/pom.xml \ java/pom.xml \
java/README.txt java/README.txt
javanano_EXTRA_DIST= \
javanano/src/main/java/com/google/protobuf/nano/CodedOutputByteBufferNano.java \
javanano/src/main/java/com/google/protobuf/nano/FieldData.java \
javanano/src/main/java/com/google/protobuf/nano/FieldArray.java \
javanano/src/main/java/com/google/protobuf/nano/WireFormatNano.java \
javanano/src/main/java/com/google/protobuf/nano/Extension.java \
javanano/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java \
javanano/src/main/java/com/google/protobuf/nano/UnknownFieldData.java \
javanano/src/main/java/com/google/protobuf/nano/MessageNano.java \
javanano/src/main/java/com/google/protobuf/nano/InternalNano.java \
javanano/src/main/java/com/google/protobuf/nano/InvalidProtocolBufferNanoException.java \
javanano/src/main/java/com/google/protobuf/nano/MapFactories.java \
javanano/src/main/java/com/google/protobuf/nano/ExtendableMessageNano.java \
javanano/src/main/java/com/google/protobuf/nano/MessageNanoPrinter.java \
javanano/src/test/java/com/google/protobuf/nano/unittest_accessors_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/unittest_enum_class_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/unittest_reference_types_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/unittest_extension_repeated_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/unittest_has_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/unittest_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/unittest_multiple_nameclash_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/unittest_single_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/NanoTest.java \
javanano/src/test/java/com/google/protobuf/nano/unittest_simple_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/unittest_import_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/unittest_repeated_merge_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/unittest_extension_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/unittest_repeated_packables_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/unittest_extension_singular_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/unittest_recursive_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/unittest_extension_packed_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/unittest_enum_validity_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/unittest_stringutf8_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/unittest_multiple_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/unittest_enum_class_multiple_nano.proto \
javanano/src/test/java/com/google/protobuf/nano/map_test.proto \
javanano/README.txt \
javanano/pom.xml
python_EXTRA_DIST= \ python_EXTRA_DIST= \
python/google/protobuf/internal/api_implementation.cc \ python/google/protobuf/internal/api_implementation.cc \
python/google/protobuf/internal/api_implementation.py \ python/google/protobuf/internal/api_implementation.py \
...@@ -260,7 +300,7 @@ ruby_EXTRA_DIST= \ ...@@ -260,7 +300,7 @@ ruby_EXTRA_DIST= \
ruby/tests/generated_code.rb \ ruby/tests/generated_code.rb \
ruby/tests/generated_code_test.rb ruby/tests/generated_code_test.rb
all_EXTRA_DIST=$(java_EXTRA_DIST) $(python_EXTRA_DIST) $(ruby_EXTRA_DIST) all_EXTRA_DIST=$(java_EXTRA_DIST) $(javanano_EXTRA_DIST) $(python_EXTRA_DIST) $(ruby_EXTRA_DIST)
EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
autogen.sh \ autogen.sh \
......
...@@ -12,7 +12,7 @@ AC_PREREQ(2.59) ...@@ -12,7 +12,7 @@ AC_PREREQ(2.59)
# In the SVN trunk, the version should always be the next anticipated release # In the SVN trunk, the version should always be the next anticipated release
# version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed # version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed
# the size of one file name in the dist tarfile over the 99-char limit.) # the size of one file name in the dist tarfile over the 99-char limit.)
AC_INIT([Protocol Buffers],[3.0.0-pre],[protobuf@googlegroups.com],[protobuf]) AC_INIT([Protocol Buffers],[3.0.0-alpha-2],[protobuf@googlegroups.com],[protobuf])
AM_MAINTAINER_MODE([enable]) AM_MAINTAINER_MODE([enable])
...@@ -37,7 +37,7 @@ AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"], ...@@ -37,7 +37,7 @@ AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
AC_CANONICAL_TARGET AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([subdir-objects]) AM_INIT_AUTOMAKE([1.9 tar-ustar subdir-objects])
AC_ARG_WITH([zlib], AC_ARG_WITH([zlib],
[AS_HELP_STRING([--with-zlib], [AS_HELP_STRING([--with-zlib],
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</parent> </parent>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId> <artifactId>protobuf-java</artifactId>
<version>3.0.0-pre</version> <version>3.0.0-alpha-2</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>Protocol Buffer Java API</name> <name>Protocol Buffer Java API</name>
<description> <description>
...@@ -152,7 +152,7 @@ ...@@ -152,7 +152,7 @@
<instructions> <instructions>
<Bundle-DocURL>https://developers.google.com/protocol-buffers/</Bundle-DocURL> <Bundle-DocURL>https://developers.google.com/protocol-buffers/</Bundle-DocURL>
<Bundle-SymbolicName>com.google.protobuf</Bundle-SymbolicName> <Bundle-SymbolicName>com.google.protobuf</Bundle-SymbolicName>
<Export-Package>com.google.protobuf;version=3.0.0-pre</Export-Package> <Export-Package>com.google.protobuf;version=3.0.0-alpha-2</Export-Package>
</instructions> </instructions>
</configuration> </configuration>
</plugin> </plugin>
......
...@@ -73,7 +73,7 @@ public abstract class GeneratedMessage extends AbstractMessage ...@@ -73,7 +73,7 @@ public abstract class GeneratedMessage extends AbstractMessage
/** For use by generated code only. */ /** For use by generated code only. */
protected UnknownFieldSet unknownFields; protected UnknownFieldSet unknownFields;
protected GeneratedMessage() { protected GeneratedMessage() {
unknownFields = UnknownFieldSet.getDefaultInstance(); unknownFields = UnknownFieldSet.getDefaultInstance();
} }
...@@ -549,12 +549,12 @@ public abstract class GeneratedMessage extends AbstractMessage ...@@ -549,12 +549,12 @@ public abstract class GeneratedMessage extends AbstractMessage
* Gets the map field with the given field number. This method should be * Gets the map field with the given field number. This method should be
* overridden in the generated message class if the message contains map * overridden in the generated message class if the message contains map
* fields. * fields.
* *
* Unlike other field types, reflection support for map fields can't be * Unlike other field types, reflection support for map fields can't be
* implemented based on generated public API because we need to access a * implemented based on generated public API because we need to access a
* map field as a list in reflection API but the generated API only allows * map field as a list in reflection API but the generated API only allows
* us to access it as a map. This method returns the underlying map field * us to access it as a map. This method returns the underlying map field
* directly and thus enables us to access the map field as a list. * directly and thus enables us to access the map field as a list.
*/ */
@SuppressWarnings({"unused", "rawtypes"}) @SuppressWarnings({"unused", "rawtypes"})
protected MapField internalGetMapField(int fieldNumber) { protected MapField internalGetMapField(int fieldNumber) {
...@@ -683,7 +683,7 @@ public abstract class GeneratedMessage extends AbstractMessage ...@@ -683,7 +683,7 @@ public abstract class GeneratedMessage extends AbstractMessage
public final <Type> Type getExtension( public final <Type> Type getExtension(
final ExtensionLite<MessageType, Type> extensionLite) { final ExtensionLite<MessageType, Type> extensionLite) {
Extension<MessageType, Type> extension = checkNotLite(extensionLite); Extension<MessageType, Type> extension = checkNotLite(extensionLite);
verifyExtensionContainingType(extension); verifyExtensionContainingType(extension);
FieldDescriptor descriptor = extension.getDescriptor(); FieldDescriptor descriptor = extension.getDescriptor();
final Object value = extensions.getField(descriptor); final Object value = extensions.getField(descriptor);
...@@ -1313,7 +1313,7 @@ public abstract class GeneratedMessage extends AbstractMessage ...@@ -1313,7 +1313,7 @@ public abstract class GeneratedMessage extends AbstractMessage
implements ExtensionDescriptorRetriever { implements ExtensionDescriptorRetriever {
private volatile FieldDescriptor descriptor; private volatile FieldDescriptor descriptor;
protected abstract FieldDescriptor loadDescriptor(); protected abstract FieldDescriptor loadDescriptor();
public FieldDescriptor getDescriptor() { public FieldDescriptor getDescriptor() {
if (descriptor == null) { if (descriptor == null) {
synchronized (this) { synchronized (this) {
...@@ -1651,17 +1651,17 @@ public abstract class GeneratedMessage extends AbstractMessage ...@@ -1651,17 +1651,17 @@ public abstract class GeneratedMessage extends AbstractMessage
} }
} }
} }
/** /**
* Gets the map field with the given field number. This method should be * Gets the map field with the given field number. This method should be
* overridden in the generated message class if the message contains map * overridden in the generated message class if the message contains map
* fields. * fields.
* *
* Unlike other field types, reflection support for map fields can't be * Unlike other field types, reflection support for map fields can't be
* implemented based on generated public API because we need to access a * implemented based on generated public API because we need to access a
* map field as a list in reflection API but the generated API only allows * map field as a list in reflection API but the generated API only allows
* us to access it as a map. This method returns the underlying map field * us to access it as a map. This method returns the underlying map field
* directly and thus enables us to access the map field as a list. * directly and thus enables us to access the map field as a list.
*/ */
@SuppressWarnings({"rawtypes", "unused"}) @SuppressWarnings({"rawtypes", "unused"})
protected MapField internalGetMapField(int fieldNumber) { protected MapField internalGetMapField(int fieldNumber) {
...@@ -1709,7 +1709,7 @@ public abstract class GeneratedMessage extends AbstractMessage ...@@ -1709,7 +1709,7 @@ public abstract class GeneratedMessage extends AbstractMessage
oneofs = new OneofAccessor[descriptor.getOneofs().size()]; oneofs = new OneofAccessor[descriptor.getOneofs().size()];
initialized = false; initialized = false;
} }
private boolean isMapFieldEnabled(FieldDescriptor field) { private boolean isMapFieldEnabled(FieldDescriptor field) {
boolean result = true; boolean result = true;
return result; return result;
...@@ -1934,11 +1934,11 @@ public abstract class GeneratedMessage extends AbstractMessage ...@@ -1934,11 +1934,11 @@ public abstract class GeneratedMessage extends AbstractMessage
protected final FieldDescriptor field; protected final FieldDescriptor field;
protected final boolean isOneofField; protected final boolean isOneofField;
protected final boolean hasHasMethod; protected final boolean hasHasMethod;
private int getOneofFieldNumber(final GeneratedMessage message) { private int getOneofFieldNumber(final GeneratedMessage message) {
return ((Internal.EnumLite) invokeOrDie(caseMethod, message)).getNumber(); return ((Internal.EnumLite) invokeOrDie(caseMethod, message)).getNumber();
} }
private int getOneofFieldNumber(final GeneratedMessage.Builder builder) { private int getOneofFieldNumber(final GeneratedMessage.Builder builder) {
return ((Internal.EnumLite) invokeOrDie(caseMethodBuilder, builder)).getNumber(); return ((Internal.EnumLite) invokeOrDie(caseMethodBuilder, builder)).getNumber();
} }
...@@ -2130,15 +2130,15 @@ public abstract class GeneratedMessage extends AbstractMessage ...@@ -2130,15 +2130,15 @@ public abstract class GeneratedMessage extends AbstractMessage
private final FieldDescriptor field; private final FieldDescriptor field;
private final Message mapEntryMessageDefaultInstance; private final Message mapEntryMessageDefaultInstance;
private MapField<?, ?> getMapField(GeneratedMessage message) { private MapField<?, ?> getMapField(GeneratedMessage message) {
return (MapField<?, ?>) message.internalGetMapField(field.getNumber()); return (MapField<?, ?>) message.internalGetMapField(field.getNumber());
} }
private MapField<?, ?> getMapField(GeneratedMessage.Builder builder) { private MapField<?, ?> getMapField(GeneratedMessage.Builder builder) {
return (MapField<?, ?>) builder.internalGetMapField(field.getNumber()); return (MapField<?, ?>) builder.internalGetMapField(field.getNumber());
} }
public Object get(GeneratedMessage message) { public Object get(GeneratedMessage message) {
List result = new ArrayList(); List result = new ArrayList();
for (int i = 0; i < getRepeatedCount(message); i++) { for (int i = 0; i < getRepeatedCount(message); i++) {
...@@ -2171,10 +2171,12 @@ public abstract class GeneratedMessage extends AbstractMessage ...@@ -2171,10 +2171,12 @@ public abstract class GeneratedMessage extends AbstractMessage
} }
public void setRepeated(Builder builder, int index, Object value) { public void setRepeated(Builder builder, int index, Object value) {
builder.onChanged();
getMapField(builder).getMutableList().set(index, (Message) value); getMapField(builder).getMutableList().set(index, (Message) value);
} }
public void addRepeated(Builder builder, Object value) { public void addRepeated(Builder builder, Object value) {
builder.onChanged();
getMapField(builder).getMutableList().add((Message) value); getMapField(builder).getMutableList().add((Message) value);
} }
...@@ -2197,6 +2199,7 @@ public abstract class GeneratedMessage extends AbstractMessage ...@@ -2197,6 +2199,7 @@ public abstract class GeneratedMessage extends AbstractMessage
} }
public void clear(Builder builder) { public void clear(Builder builder) {
builder.onChanged();
getMapField(builder).getMutableList().clear(); getMapField(builder).getMutableList().clear();
} }
...@@ -2208,7 +2211,7 @@ public abstract class GeneratedMessage extends AbstractMessage ...@@ -2208,7 +2211,7 @@ public abstract class GeneratedMessage extends AbstractMessage
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"Nested builder not supported for map fields."); "Nested builder not supported for map fields.");
} }
public com.google.protobuf.Message.Builder getRepeatedBuilder( public com.google.protobuf.Message.Builder getRepeatedBuilder(
Builder builder, int index) { Builder builder, int index) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
...@@ -2226,7 +2229,7 @@ public abstract class GeneratedMessage extends AbstractMessage ...@@ -2226,7 +2229,7 @@ public abstract class GeneratedMessage extends AbstractMessage
final Class<? extends Builder> builderClass, final Class<? extends Builder> builderClass,
final String containingOneofCamelCaseName) { final String containingOneofCamelCaseName) {
super(descriptor, camelCaseName, messageClass, builderClass, containingOneofCamelCaseName); super(descriptor, camelCaseName, messageClass, builderClass, containingOneofCamelCaseName);
enumDescriptor = descriptor.getEnumType(); enumDescriptor = descriptor.getEnumType();
valueOfMethod = getMethodOrDie(type, "valueOf", valueOfMethod = getMethodOrDie(type, "valueOf",
...@@ -2244,12 +2247,12 @@ public abstract class GeneratedMessage extends AbstractMessage ...@@ -2244,12 +2247,12 @@ public abstract class GeneratedMessage extends AbstractMessage
getMethodOrDie(builderClass, "set" + camelCaseName + "Value", int.class); getMethodOrDie(builderClass, "set" + camelCaseName + "Value", int.class);
} }
} }
private EnumDescriptor enumDescriptor; private EnumDescriptor enumDescriptor;
private Method valueOfMethod; private Method valueOfMethod;
private Method getValueDescriptorMethod; private Method getValueDescriptorMethod;
private boolean supportUnknownEnumValue; private boolean supportUnknownEnumValue;
private Method getValueMethod; private Method getValueMethod;
private Method getValueMethodBuilder; private Method getValueMethodBuilder;
...@@ -2291,7 +2294,7 @@ public abstract class GeneratedMessage extends AbstractMessage ...@@ -2291,7 +2294,7 @@ public abstract class GeneratedMessage extends AbstractMessage
final Class<? extends GeneratedMessage> messageClass, final Class<? extends GeneratedMessage> messageClass,
final Class<? extends Builder> builderClass) { final Class<? extends Builder> builderClass) {
super(descriptor, camelCaseName, messageClass, builderClass); super(descriptor, camelCaseName, messageClass, builderClass);
enumDescriptor = descriptor.getEnumType(); enumDescriptor = descriptor.getEnumType();
valueOfMethod = getMethodOrDie(type, "valueOf", valueOfMethod = getMethodOrDie(type, "valueOf",
...@@ -2315,7 +2318,7 @@ public abstract class GeneratedMessage extends AbstractMessage ...@@ -2315,7 +2318,7 @@ public abstract class GeneratedMessage extends AbstractMessage
private final Method valueOfMethod; private final Method valueOfMethod;
private final Method getValueDescriptorMethod; private final Method getValueDescriptorMethod;
private boolean supportUnknownEnumValue; private boolean supportUnknownEnumValue;
private Method getRepeatedValueMethod; private Method getRepeatedValueMethod;
private Method getRepeatedValueMethodBuilder; private Method getRepeatedValueMethodBuilder;
...@@ -2395,7 +2398,8 @@ public abstract class GeneratedMessage extends AbstractMessage ...@@ -2395,7 +2398,8 @@ public abstract class GeneratedMessage extends AbstractMessage
final Class<? extends GeneratedMessage> messageClass, final Class<? extends GeneratedMessage> messageClass,
final Class<? extends Builder> builderClass, final Class<? extends Builder> builderClass,
final String containingOneofCamelCaseName) { final String containingOneofCamelCaseName) {
super(descriptor, camelCaseName, messageClass, builderClass, containingOneofCamelCaseName); super(descriptor, camelCaseName, messageClass, builderClass,
containingOneofCamelCaseName);
newBuilderMethod = getMethodOrDie(type, "newBuilder"); newBuilderMethod = getMethodOrDie(type, "newBuilder");
getBuilderMethodBuilder = getBuilderMethodBuilder =
...@@ -2492,7 +2496,7 @@ public abstract class GeneratedMessage extends AbstractMessage ...@@ -2492,7 +2496,7 @@ public abstract class GeneratedMessage extends AbstractMessage
protected Object writeReplace() throws ObjectStreamException { protected Object writeReplace() throws ObjectStreamException {
return new GeneratedMessageLite.SerializedForm(this); return new GeneratedMessageLite.SerializedForm(this);
} }
/** /**
* Checks that the {@link Extension} is non-Lite and returns it as a * Checks that the {@link Extension} is non-Lite and returns it as a
* {@link GeneratedExtension}. * {@link GeneratedExtension}.
...@@ -2503,7 +2507,7 @@ public abstract class GeneratedMessage extends AbstractMessage ...@@ -2503,7 +2507,7 @@ public abstract class GeneratedMessage extends AbstractMessage
if (extension.isLite()) { if (extension.isLite()) {
throw new IllegalArgumentException("Expected non-lite extension."); throw new IllegalArgumentException("Expected non-lite extension.");
} }
return (Extension<MessageType, T>) extension; return (Extension<MessageType, T>) extension;
} }
} }
...@@ -56,9 +56,10 @@ import protobuf_unittest.UnittestProto; ...@@ -56,9 +56,10 @@ import protobuf_unittest.UnittestProto;
import protobuf_unittest.UnittestProto.ForeignEnum; import protobuf_unittest.UnittestProto.ForeignEnum;
import protobuf_unittest.UnittestProto.ForeignMessage; import protobuf_unittest.UnittestProto.ForeignMessage;
import protobuf_unittest.UnittestProto.ForeignMessageOrBuilder; import protobuf_unittest.UnittestProto.ForeignMessageOrBuilder;
import protobuf_unittest.UnittestProto.NestedTestAllTypes;
import protobuf_unittest.UnittestProto.TestAllExtensions; import protobuf_unittest.UnittestProto.TestAllExtensions;
import protobuf_unittest.UnittestProto.TestAllTypes;
import protobuf_unittest.UnittestProto.TestAllTypes.NestedMessage; import protobuf_unittest.UnittestProto.TestAllTypes.NestedMessage;
import protobuf_unittest.UnittestProto.TestAllTypes;
import protobuf_unittest.UnittestProto.TestAllTypesOrBuilder; import protobuf_unittest.UnittestProto.TestAllTypesOrBuilder;
import protobuf_unittest.UnittestProto.TestExtremeDefaultValues; import protobuf_unittest.UnittestProto.TestExtremeDefaultValues;
import protobuf_unittest.UnittestProto.TestOneof2; import protobuf_unittest.UnittestProto.TestOneof2;
...@@ -1510,6 +1511,17 @@ public class GeneratedMessageTest extends TestCase { ...@@ -1510,6 +1511,17 @@ public class GeneratedMessageTest extends TestCase {
} }
} }
public void testOneofNestedBuilderOnChangePropagation() {
NestedTestAllTypes.Builder parentBuilder = NestedTestAllTypes.newBuilder();
TestAllTypes.Builder builder = parentBuilder.getPayloadBuilder();
builder.getOneofNestedMessageBuilder();
assertTrue(builder.hasOneofNestedMessage());
assertTrue(parentBuilder.hasPayload());
NestedTestAllTypes message = parentBuilder.build();
assertTrue(message.hasPayload());
assertTrue(message.getPayload().hasOneofNestedMessage());
}
public void testGetRepeatedFieldBuilder() { public void testGetRepeatedFieldBuilder() {
Descriptor descriptor = TestAllTypes.getDescriptor(); Descriptor descriptor = TestAllTypes.getDescriptor();
......
...@@ -68,18 +68,20 @@ running unit tests. ...@@ -68,18 +68,20 @@ running unit tests.
Nano version Nano version
============================ ============================
Nano is a special code generator and runtime library designed specially JavaNano is a special code generator and runtime library designed specially for
for Android, and is very resource-friendly in both the amount of code resource-restricted systems, like Android. It is very resource-friendly in both
and the runtime overhead. An overview of Nano features: the amount of code and the runtime overhead. Here is an overview of JavaNano
features compared with the official Java protobuf:
- No descriptors or message builders. - No descriptors or message builders.
- All messages are mutable; fields are public Java fields. - All messages are mutable; fields are public Java fields.
- For optional fields only, encapsulation behind setter/getter/hazzer/ - For optional fields only, encapsulation behind setter/getter/hazzer/
clearer functions is opt-in, which provide proper 'has' state support. clearer functions is opt-in, which provide proper 'has' state support.
- If not opted in, has state is not available. Serialization outputs - For proto2, if not opted in, has state (field presence) is not available.
all fields not equal to their defaults (see important implications Serialization outputs all fields not equal to their defaults
below). (see important implications below).
- Required fields are always serialized. The behavior is consistent with proto3 semantics.
- Required fields (proto2 only) are always serialized.
- Enum constants are integers; protection against invalid values only - Enum constants are integers; protection against invalid values only
when parsing from the wire. when parsing from the wire.
- Enum constants can be generated into container interfaces bearing - Enum constants can be generated into container interfaces bearing
...@@ -88,8 +90,8 @@ and the runtime overhead. An overview of Nano features: ...@@ -88,8 +90,8 @@ and the runtime overhead. An overview of Nano features:
- Similarly CodedOutputByteBufferNano can only write to byte[]. - Similarly CodedOutputByteBufferNano can only write to byte[].
- Repeated fields are in arrays, not ArrayList or Vector. Null array - Repeated fields are in arrays, not ArrayList or Vector. Null array
elements are allowed and silently ignored. elements are allowed and silently ignored.
- Full support of serializing/deserializing repeated packed fields. - Full support for serializing/deserializing repeated packed fields.
- Support of extensions. - Support extensions (in proto2).
- Unset messages/groups are null, not an immutable empty default - Unset messages/groups are null, not an immutable empty default
instance. instance.
- toByteArray(...) and mergeFrom(...) are now static functions of - toByteArray(...) and mergeFrom(...) are now static functions of
...@@ -200,7 +202,7 @@ optional_field_style={default,accessors,reftypes} (default: default) ...@@ -200,7 +202,7 @@ optional_field_style={default,accessors,reftypes} (default: default)
In the default style, optional fields translate into public mutable In the default style, optional fields translate into public mutable
Java fields, and the serialization process is as discussed in the Java fields, and the serialization process is as discussed in the
"IMPORTANT" section above. "IMPORTANT" section above.
* accessors * * accessors *
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</parent> </parent>
<groupId>com.google.protobuf.nano</groupId> <groupId>com.google.protobuf.nano</groupId>
<artifactId>protobuf-javanano</artifactId> <artifactId>protobuf-javanano</artifactId>
<version>2.6.2-pre</version> <version>3.0.0-alpha-2</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>Protocol Buffer JavaNano API</name> <name>Protocol Buffer JavaNano API</name>
<description> <description>
...@@ -156,7 +156,7 @@ ...@@ -156,7 +156,7 @@
<instructions> <instructions>
<Bundle-DocURL>https://developers.google.com/protocol-buffers/</Bundle-DocURL> <Bundle-DocURL>https://developers.google.com/protocol-buffers/</Bundle-DocURL>
<Bundle-SymbolicName>com.google.protobuf</Bundle-SymbolicName> <Bundle-SymbolicName>com.google.protobuf</Bundle-SymbolicName>
<Export-Package>com.google.protobuf;version=2.6.2-pre</Export-Package> <Export-Package>com.google.protobuf;version=3.0.0-alpha-2</Export-Package>
</instructions> </instructions>
</configuration> </configuration>
</plugin> </plugin>
......
...@@ -27,7 +27,7 @@ fi ...@@ -27,7 +27,7 @@ fi
set -ex set -ex
LANGUAGES="cpp java python" LANGUAGES="cpp java javanano python ruby"
BASENAME=`basename $1 .tar.gz` BASENAME=`basename $1 .tar.gz`
VERSION=${BASENAME:9} VERSION=${BASENAME:9}
......
...@@ -163,7 +163,7 @@ if __name__ == '__main__': ...@@ -163,7 +163,7 @@ if __name__ == '__main__':
)) ))
setup(name = 'protobuf', setup(name = 'protobuf',
version = '3.0.0-pre', version = '3.0.0-alpha-2',
packages = [ 'google' ], packages = [ 'google' ],
namespace_packages = [ 'google' ], namespace_packages = [ 'google' ],
test_suite = 'setup.MakeTestSuite', test_suite = 'setup.MakeTestSuite',
......
...@@ -7,8 +7,51 @@ we recommend using protoc's Ruby generation support with .proto files. The ...@@ -7,8 +7,51 @@ we recommend using protoc's Ruby generation support with .proto files. The
build process in this directory only installs the extension; you need to build process in this directory only installs the extension; you need to
install protoc as well to have Ruby code generation functionality. install protoc as well to have Ruby code generation functionality.
Installation Installation from Gem
------------ ---------------------
When we release a version of Protocol Buffers, we will upload a Gem to
[RubyGems](https://www.rubygems.org/). To use this pre-packaged gem, simply
install it as you would any other gem:
$ gem install [--prerelease] google-protobuf
The `--pre` flag is necessary if we have not yet made a non-alpha/beta release
of the Ruby extension; it allows `gem` to consider these "pre-release"
alpha/beta versions.
Once the gem is installed, you may or may not need `protoc`. If you write your
message type descriptions directly in the Ruby DSL, you do not need it.
However, if you wish to generate the Ruby DSL from a `.proto` file, you will
also want to install Protocol Buffers itself, as described in this repository's
main `README` file. The version of `protoc` included in the latest release
supports the `--ruby_out` option to generate Ruby code.
A simple example of using the Ruby extension follows. More extensive
documentation may be found in the RubyDoc comments (`call-seq` tags) in the
source, and we plan to release separate, more detailed, documentation at a
later date.
require 'google/protobuf'
# generated from my_proto_types.proto with protoc:
# $ protoc --ruby_out=. my_proto_types.proto
require 'my_proto_types'
mymessage = MyTestMessage.new(:field1 => 42, :field2 => ["a", "b", "c"])
mymessage.field1 = 43
mymessage.field2.push("d")
mymessage.field3 = SubMessage.new(:foo => 100)
encoded_data = MyTestMessage.encode(mymessage)
decoded = MyTestMessage.decode(encoded_data)
assert decoded == mymessage
puts "JSON:"
puts MyTestMessage.encode_json(mymessage)
Installation from Source (Building Gem)
---------------------------------------
To build this Ruby extension, you will need: To build this Ruby extension, you will need:
...@@ -16,7 +59,6 @@ To build this Ruby extension, you will need: ...@@ -16,7 +59,6 @@ To build this Ruby extension, you will need:
* Bundler * Bundler
* Ruby development headers * Ruby development headers
* a C compiler * a C compiler
* the upb submodule
First, install the required Ruby gems: First, install the required Ruby gems:
......
...@@ -7,7 +7,7 @@ end ...@@ -7,7 +7,7 @@ end
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "google-protobuf" s.name = "google-protobuf"
s.version = "3.0.0.alpha.2" s.version = "3.0.0.alpha.2.0"
s.licenses = ["BSD"] s.licenses = ["BSD"]
s.summary = "Protocol Buffers" s.summary = "Protocol Buffers"
s.description = "Protocol Buffers are Google's data interchange format." s.description = "Protocol Buffers are Google's data interchange format."
......
...@@ -64,6 +64,10 @@ ...@@ -64,6 +64,10 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
// Disable the whole test when we use tcmalloc for "draconian" heap checks, in
// which case tcmalloc will print warnings that fail the plugin tests.
#if !GOOGLE_PROTOBUF_HEAP_CHECK_DRACONIAN
namespace google { namespace google {
namespace protobuf { namespace protobuf {
namespace compiler { namespace compiler {
...@@ -1663,3 +1667,5 @@ TEST_F(EncodeDecodeTest, ProtoParseError) { ...@@ -1663,3 +1667,5 @@ TEST_F(EncodeDecodeTest, ProtoParseError) {
} // namespace compiler } // namespace compiler
} // namespace protobuf } // namespace protobuf
} // namespace google } // namespace google
#endif // !GOOGLE_PROTOBUF_HEAP_CHECK_DRACONIAN
...@@ -718,6 +718,7 @@ GenerateBuilderMembers(io::Printer* printer) const { ...@@ -718,6 +718,7 @@ GenerateBuilderMembers(io::Printer* printer) const {
" $oneof_name$_ = null;\n" " $oneof_name$_ = null;\n"
" }\n" " }\n"
" $set_oneof_case_message$;\n" " $set_oneof_case_message$;\n"
" $on_changed$;\n"
" return $name$Builder_;\n" " return $name$Builder_;\n"
"}\n"); "}\n");
} }
......
...@@ -247,8 +247,14 @@ namespace { ...@@ -247,8 +247,14 @@ namespace {
UnknownFieldSet* empty_unknown_field_set_ = NULL; UnknownFieldSet* empty_unknown_field_set_ = NULL;
GOOGLE_PROTOBUF_DECLARE_ONCE(empty_unknown_field_set_once_); GOOGLE_PROTOBUF_DECLARE_ONCE(empty_unknown_field_set_once_);
void DeleteEmptyUnknownFieldSet() {
delete empty_unknown_field_set_;
empty_unknown_field_set_ = NULL;
}
void InitEmptyUnknownFieldSet() { void InitEmptyUnknownFieldSet() {
empty_unknown_field_set_ = new UnknownFieldSet; empty_unknown_field_set_ = new UnknownFieldSet;
internal::OnShutdown(&DeleteEmptyUnknownFieldSet);
} }
const UnknownFieldSet& GetEmptyUnknownFieldSet() { const UnknownFieldSet& GetEmptyUnknownFieldSet() {
......
...@@ -440,6 +440,30 @@ const internal::RepeatedFieldAccessor* Reflection::RepeatedFieldAccessor( ...@@ -440,6 +440,30 @@ const internal::RepeatedFieldAccessor* Reflection::RepeatedFieldAccessor(
return NULL; return NULL;
} }
namespace internal {
namespace {
void ShutdownRepeatedFieldAccessor() {
Singleton<internal::RepeatedFieldPrimitiveAccessor<int32> >::ShutDown();
Singleton<internal::RepeatedFieldPrimitiveAccessor<uint32> >::ShutDown();
Singleton<internal::RepeatedFieldPrimitiveAccessor<int64> >::ShutDown();
Singleton<internal::RepeatedFieldPrimitiveAccessor<uint64> >::ShutDown();
Singleton<internal::RepeatedFieldPrimitiveAccessor<float> >::ShutDown();
Singleton<internal::RepeatedFieldPrimitiveAccessor<double> >::ShutDown();
Singleton<internal::RepeatedFieldPrimitiveAccessor<bool> >::ShutDown();
Singleton<internal::RepeatedPtrFieldStringAccessor>::ShutDown();
Singleton<internal::RepeatedPtrFieldMessageAccessor>::ShutDown();
Singleton<internal::MapFieldAccessor>::ShutDown();
};
struct ShutdownRepeatedFieldRegister {
ShutdownRepeatedFieldRegister() {
OnShutdown(&ShutdownRepeatedFieldAccessor);
}
} shutdown_;
} // namesapce
} // namespace internal
namespace internal { namespace internal {
// Macro defined in repeated_field.h. We can only define the Message-specific // Macro defined in repeated_field.h. We can only define the Message-specific
// GenericTypeHandler specializations here because we depend on Message, which // GenericTypeHandler specializations here because we depend on Message, which
......
...@@ -44,6 +44,10 @@ class Singleton { ...@@ -44,6 +44,10 @@ class Singleton {
GoogleOnceInit(&once_, &Singleton<T>::Init); GoogleOnceInit(&once_, &Singleton<T>::Init);
return instance_; return instance_;
} }
static void ShutDown() {
delete instance_;
instance_ = NULL;
}
private: private:
static void Init() { static void Init() {
instance_ = new T(); instance_ = new T();
...@@ -56,7 +60,7 @@ template<typename T> ...@@ -56,7 +60,7 @@ template<typename T>
ProtobufOnceType Singleton<T>::once_; ProtobufOnceType Singleton<T>::once_;
template<typename T> template<typename T>
T* Singleton<T>::instance_; T* Singleton<T>::instance_ = NULL;
} // namespace internal } // namespace internal
} // namespace protobuf } // namespace protobuf
} // namespace google } // namespace google
......
...@@ -6,7 +6,9 @@ md include\google\protobuf\io ...@@ -6,7 +6,9 @@ md include\google\protobuf\io
md include\google\protobuf\compiler md include\google\protobuf\compiler
md include\google\protobuf\compiler\cpp md include\google\protobuf\compiler\cpp
md include\google\protobuf\compiler\java md include\google\protobuf\compiler\java
md include\google\protobuf\compiler\javanano
md include\google\protobuf\compiler\python md include\google\protobuf\compiler\python
md include\google\protobuf\compiler\ruby
copy ..\src\google\protobuf\arena.h include\google\protobuf\arena.h copy ..\src\google\protobuf\arena.h include\google\protobuf\arena.h
copy ..\src\google\protobuf\arenastring.h include\google\protobuf\arenastring.h copy ..\src\google\protobuf\arenastring.h include\google\protobuf\arenastring.h
copy ..\src\google\protobuf\compiler\code_generator.h include\google\protobuf\compiler\code_generator.h copy ..\src\google\protobuf\compiler\code_generator.h include\google\protobuf\compiler\code_generator.h
...@@ -14,10 +16,12 @@ copy ..\src\google\protobuf\compiler\command_line_interface.h include\google\pro ...@@ -14,10 +16,12 @@ copy ..\src\google\protobuf\compiler\command_line_interface.h include\google\pro
copy ..\src\google\protobuf\compiler\cpp\cpp_generator.h include\google\protobuf\compiler\cpp\cpp_generator.h copy ..\src\google\protobuf\compiler\cpp\cpp_generator.h include\google\protobuf\compiler\cpp\cpp_generator.h
copy ..\src\google\protobuf\compiler\importer.h include\google\protobuf\compiler\importer.h copy ..\src\google\protobuf\compiler\importer.h include\google\protobuf\compiler\importer.h
copy ..\src\google\protobuf\compiler\java\java_generator.h include\google\protobuf\compiler\java\java_generator.h copy ..\src\google\protobuf\compiler\java\java_generator.h include\google\protobuf\compiler\java\java_generator.h
copy ..\src\google\protobuf\compiler\javanano\javanano_generator.h include\google\protobuf\compiler\javanano\javanano_generator.h
copy ..\src\google\protobuf\compiler\parser.h include\google\protobuf\compiler\parser.h copy ..\src\google\protobuf\compiler\parser.h include\google\protobuf\compiler\parser.h
copy ..\src\google\protobuf\compiler\plugin.h include\google\protobuf\compiler\plugin.h copy ..\src\google\protobuf\compiler\plugin.h include\google\protobuf\compiler\plugin.h
copy ..\src\google\protobuf\compiler\plugin.pb.h include\google\protobuf\compiler\plugin.pb.h copy ..\src\google\protobuf\compiler\plugin.pb.h include\google\protobuf\compiler\plugin.pb.h
copy ..\src\google\protobuf\compiler\python\python_generator.h include\google\protobuf\compiler\python\python_generator.h copy ..\src\google\protobuf\compiler\python\python_generator.h include\google\protobuf\compiler\python\python_generator.h
copy ..\src\google\protobuf\compiler\ruby\ruby_generator.h include\google\protobuf\compiler\ruby\ruby_generator.h
copy ..\src\google\protobuf\descriptor_database.h include\google\protobuf\descriptor_database.h copy ..\src\google\protobuf\descriptor_database.h include\google\protobuf\descriptor_database.h
copy ..\src\google\protobuf\descriptor.h include\google\protobuf\descriptor.h copy ..\src\google\protobuf\descriptor.h include\google\protobuf\descriptor.h
copy ..\src\google\protobuf\descriptor.pb.h include\google\protobuf\descriptor.pb.h copy ..\src\google\protobuf\descriptor.pb.h include\google\protobuf\descriptor.pb.h
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment