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

changes/13/217213/1
Jisi Liu 10 years ago
commit 581be24606
  1. 65
      CHANGES.txt
  2. 42
      Makefile.am
  3. 4
      configure.ac
  4. 4
      java/pom.xml
  5. 6
      java/src/main/java/com/google/protobuf/GeneratedMessage.java
  6. 14
      java/src/test/java/com/google/protobuf/GeneratedMessageTest.java
  7. 39
      java/src/test/java/com/google/protobuf/MapTest.java
  8. 20
      javanano/README.txt
  9. 4
      javanano/pom.xml
  10. 2
      post_process_dist.sh
  11. 2
      python/setup.py
  12. 48
      ruby/README.md
  13. 2
      ruby/google-protobuf.gemspec
  14. 6
      src/google/protobuf/compiler/command_line_interface_unittest.cc
  15. 1
      src/google/protobuf/compiler/java/java_message_field.cc
  16. 6
      src/google/protobuf/generated_message_reflection.cc
  17. 24
      src/google/protobuf/message.cc
  18. 6
      src/google/protobuf/stubs/singleton.h
  19. 4
      vsprojects/extract_includes.bat
  20. 24
      vsprojects/libprotoc.vcproj

@ -1,3 +1,68 @@
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= \
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= \
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)
# 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"],
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 @@
</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 @@
<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>

@ -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
} }
public void clear(Builder builder) { public void clear(Builder builder) {
builder.onChanged();
getMapField(builder).getMutableList().clear(); getMapField(builder).getMutableList().clear();
} }
@ -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 =

@ -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 {
} }
} }
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();

@ -301,6 +301,45 @@ public class MapTest extends TestCase {
assertEquals(0, message.getOptionalMessage().getInt32ToInt32Field().size()); assertEquals(0, message.getOptionalMessage().getInt32ToInt32Field().size());
} }
public void testNestedBuilderOnChangeEventPropagationReflection() {
FieldDescriptor intMapField = f("int32_to_int32_field");
// Create an outer message builder with nested builder.
TestOnChangeEventPropagation.Builder parentBuilder =
TestOnChangeEventPropagation.newBuilder();
TestMap.Builder testMapBuilder = parentBuilder.getOptionalMessageBuilder();
// Create a map entry message.
TestMap.Builder entryBuilder = TestMap.newBuilder();
entryBuilder.getMutableInt32ToInt32Field().put(1, 1);
// Put the entry into the nested builder.
testMapBuilder.addRepeatedField(
intMapField, entryBuilder.getRepeatedField(intMapField, 0));
// Should be able to observe the change.
TestOnChangeEventPropagation message = parentBuilder.build();
assertEquals(1, message.getOptionalMessage().getInt32ToInt32Field().size());
// Change the entry value.
entryBuilder.getMutableInt32ToInt32Field().put(1, 4);
testMapBuilder = parentBuilder.getOptionalMessageBuilder();
testMapBuilder.setRepeatedField(
intMapField, 0, entryBuilder.getRepeatedField(intMapField, 0));
// Should be able to observe the change.
message = parentBuilder.build();
assertEquals(4,
message.getOptionalMessage().getInt32ToInt32Field().get(1).intValue());
// Clear the nested builder.
testMapBuilder = parentBuilder.getOptionalMessageBuilder();
testMapBuilder.clearField(intMapField);
// Should be able to observe the change.
message = parentBuilder.build();
assertEquals(0, message.getOptionalMessage().getInt32ToInt32Field().size());
}
// The following methods are used to test reflection API. // The following methods are used to test reflection API.
private static FieldDescriptor f(String name) { private static FieldDescriptor f(String name) {

@ -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:
- 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

@ -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 @@
<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
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__':
)) ))
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
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:
* 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
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 @@
#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) {
} // 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 {
" $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 {
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(
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 {
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>
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
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
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

@ -223,10 +223,6 @@
RelativePath="..\src\google\protobuf\compiler\cpp\cpp_string_field.h" RelativePath="..\src\google\protobuf\compiler\cpp\cpp_string_field.h"
> >
</File> </File>
<File
RelativePath="..\src\google\protobuf\compiler\ruby\ruby_generator.h"
>
</File>
<File <File
RelativePath="..\src\google\protobuf\compiler\java\java_context.h" RelativePath="..\src\google\protobuf\compiler\java\java_context.h"
> >
@ -303,10 +299,26 @@
RelativePath="..\src\google\protobuf\compiler\java\java_doc_comment.cc" RelativePath="..\src\google\protobuf\compiler\java\java_doc_comment.cc"
> >
</File> </File>
<File RelativePath="..\src\google\protobuf\compiler\javanano\javanano_enum_field.h"></File>
<File RelativePath="..\src\google\protobuf\compiler\javanano\javanano_enum.h"></File>
<File RelativePath="..\src\google\protobuf\compiler\javanano\javanano_extension.h"></File>
<File RelativePath="..\src\google\protobuf\compiler\javanano\javanano_field.h"></File>
<File RelativePath="..\src\google\protobuf\compiler\javanano\javanano_file.h"></File>
<File RelativePath="..\src\google\protobuf\compiler\javanano\javanano_generator.h"></File>
<File RelativePath="..\src\google\protobuf\compiler\javanano\javanano_helpers.h"></File>
<File RelativePath="..\src\google\protobuf\compiler\javanano\javanano_map_field.h"></File>
<File RelativePath="..\src\google\protobuf\compiler\javanano\javanano_message_field.h"></File>
<File RelativePath="..\src\google\protobuf\compiler\javanano\javanano_message.h"></File>
<File RelativePath="..\src\google\protobuf\compiler\javanano\javanano_params.h"></File>
<File RelativePath="..\src\google\protobuf\compiler\javanano\javanano_primitive_field.h"></File>
<File <File
RelativePath="..\src\google\protobuf\compiler\python\python_generator.h" RelativePath="..\src\google\protobuf\compiler\python\python_generator.h"
> >
</File> </File>
<File
RelativePath="..\src\google\protobuf\compiler\ruby\ruby_generator.h"
>
</File>
</Filter> </Filter>
<Filter <Filter
Name="Resource Files" Name="Resource Files"
@ -487,6 +499,10 @@
RelativePath="..\src\google\protobuf\compiler\javanano\javanano_helpers.cc" RelativePath="..\src\google\protobuf\compiler\javanano\javanano_helpers.cc"
> >
</File> </File>
<File
RelativePath="..\src\google\protobuf\compiler\javanano\javanano_map_field.cc"
>
</File>
<File <File
RelativePath="..\src\google\protobuf\compiler\javanano\javanano_message.cc" RelativePath="..\src\google\protobuf\compiler\javanano\javanano_message.cc"
> >

Loading…
Cancel
Save