diff options
85 files changed, 525 insertions, 379 deletions
@@ -53,7 +53,7 @@ src/google/protobuf/util/**/*.pb.h *.pyc *.egg-info *_pb2.py -python/*.egg +python/**/*.egg python/.eggs/ python/.tox python/build/ @@ -186,3 +186,6 @@ cmake/cmake-build-debug/ # Common build subdirectories. ./.build/ ./_build/ + +# Visual Studio 2017 +.vs diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 74d4ea7b..00000000 --- a/.travis.yml +++ /dev/null @@ -1,90 +0,0 @@ -# Everything is driven by the test.sh, so the language doesn't really -# matter, it just controls the default install/script/etc. steps on -# travis. -language: cpp -script: ./tests.sh $CONFIG - -# The test matrix is manually built to cover a mix of linux and macOS -# hosted setups; this lets some extra settings be done specific to each -# host/language instead of forcing common values on all the tests. -matrix: - include: - # ----------------------------------------------------------------- - # macOS hosted tests for Objective-C - - - os: osx - env: CONFIG=objectivec_osx - osx_image: xcode9.3 - language: objective-c - # iOS build log was starting to choke travis UI, so split to cover the - # Xcode Debug and Release Configurations independently. - - os: osx - env: CONFIG=objectivec_ios_debug - osx_image: xcode9.3 - language: objective-c - - os: osx - env: CONFIG=objectivec_ios_release - osx_image: xcode9.3 - language: objective-c - - os: osx - env: CONFIG=objectivec_cocoapods_integration - osx_image: xcode9.3 - language: objective-c - - # ----------------------------------------------------------------- - # macOS hosted tests for other languages. - - - os: osx - env: CONFIG=cpp - - os: osx - env: CONFIG=cpp_distcheck - - os: osx - env: CONFIG=javascript - - os: osx - env: CONFIG=python - - os: osx - env: CONFIG=python_cpp - - os: osx - env: CONFIG=php5.6_mac - - os: osx - env: CONFIG=php7.0_mac - - # ----------------------------------------------------------------- - # Linux hosted tests - - # The dotnet environment requires Ubuntu 14.04 or 16.04. This - # configuration is effectively an "extra" one, outside the - # autogenerated matrix. - - os: linux - env: CONFIG=csharp - language: csharp - dist: trusty - dotnet: 2.0.3 - mono: none - # Install the .NET Core 1.0 runtime as that's what we test against - addons: - apt: - sources: - - sourceline: 'deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main' - key_url: 'https://packages.microsoft.com/keys/microsoft.asc' - packages: - - dotnet-sharedframework-microsoft.netcore.app-1.0.5 - # This test is kept on travis because it doesn't play nicely with other - # tests on jenkins running in parallel. - - os: linux - env: CONFIG=cpp_distcheck - # The Java compatibility test currently only runs on Linux because it will - # fetch pre-built Linux protoc binaries in the test. - - os: linux - env: CONFIG=java_compatibility - sudo: required - dist: trusty - # The Python compatibility test currently only runs on Linux because it will - # fetch pre-built Linux protoc binaries in the test. - - os: linux - env: CONFIG=python_compatibility - sudo: required - dist: trusty - -notifications: - email: false diff --git a/CHANGES.txt b/CHANGES.txt index c18c6377..a381084a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,15 @@ +2018-07-27 version 3.6.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + + C++ + * Introduced workaround for Windows issue with std::atomic and std::once_flag + initialization (#4777, #4773). + + PHP + * Added compatibility with PHP 7.3 (#4898). + + Ruby + * Fixed Ruby crash involving Any encoding (#4718). + 2018-06-01 version 3.6.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) C++ diff --git a/Protobuf.podspec b/Protobuf.podspec index b5bb673e..f282f540 100644 --- a/Protobuf.podspec +++ b/Protobuf.podspec @@ -5,7 +5,7 @@ # dependent projects use the :git notation to refer to the library. Pod::Spec.new do |s| s.name = 'Protobuf' - s.version = '3.6.0' + s.version = '3.6.1' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.homepage = 'https://github.com/google/protobuf' s.license = '3-Clause BSD License' diff --git a/benchmarks/Makefile.am b/benchmarks/Makefile.am index 4bf57026..4f7df646 100644 --- a/benchmarks/Makefile.am +++ b/benchmarks/Makefile.am @@ -90,8 +90,7 @@ $(benchmarks_protoc_outputs_proto2_header): protoc_middleman2 initialize_submodule: oldpwd=`pwd` - cd $(top_srcdir)/third_party - git submodule update --init -r + cd $(top_srcdir) && git submodule update --init -r third_party/benchmark cd $(top_srcdir)/third_party/benchmark && cmake -DCMAKE_BUILD_TYPE=Release && make cd $$oldpwd touch initialize_submodule diff --git a/cmake/tests.cmake b/cmake/tests.cmake index b77a5ebe..001b4200 100644 --- a/cmake/tests.cmake +++ b/cmake/tests.cmake @@ -208,6 +208,13 @@ endif() if(MINGW) set_source_files_properties(${tests_files} PROPERTIES COMPILE_FLAGS "-Wno-narrowing") + + # required for tests on MinGW Win64 + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,16777216") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj") + endif() + endif() add_executable(tests ${tests_files} ${common_test_files} ${tests_proto_files} ${lite_test_proto_files}) diff --git a/configure.ac b/configure.ac index 69b3fe30..8e1c308c 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ AC_PREREQ(2.59) # 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 # the size of one file name in the dist tarfile over the 99-char limit.) -AC_INIT([Protocol Buffers],[3.6.0],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.6.1],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) diff --git a/conformance/README.md b/conformance/README.md index 971fe8f6..a5419bf0 100644 --- a/conformance/README.md +++ b/conformance/README.md @@ -1,8 +1,6 @@ Protocol Buffers - Google's data interchange format =================================================== -[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf) - Copyright 2008 Google Inc. This directory contains conformance tests for testing completeness and diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index 0ba7cc9f..901d5ce9 100644 --- a/csharp/Google.Protobuf.Tools.nuspec +++ b/csharp/Google.Protobuf.Tools.nuspec @@ -5,7 +5,7 @@ <title>Google Protocol Buffers tools</title> <summary>Tools for Protocol Buffers - Google's data interchange format.</summary> <description>See project site for more info.</description> - <version>3.6.0</version> + <version>3.6.1</version> <authors>Google Inc.</authors> <owners>protobuf-packages</owners> <licenseUrl>https://github.com/google/protobuf/blob/master/LICENSE</licenseUrl> diff --git a/csharp/src/Google.Protobuf.Conformance/Conformance.cs b/csharp/src/Google.Protobuf.Conformance/Conformance.cs index 77284824..6ca52c32 100644 --- a/csharp/src/Google.Protobuf.Conformance/Conformance.cs +++ b/csharp/src/Google.Protobuf.Conformance/Conformance.cs @@ -24,22 +24,24 @@ namespace Conformance { static ConformanceReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "ChFjb25mb3JtYW5jZS5wcm90bxILY29uZm9ybWFuY2UiwAEKEkNvbmZvcm1h", + "ChFjb25mb3JtYW5jZS5wcm90bxILY29uZm9ybWFuY2Ui1QEKEkNvbmZvcm1h", "bmNlUmVxdWVzdBIaChBwcm90b2J1Zl9wYXlsb2FkGAEgASgMSAASFgoManNv", "bl9wYXlsb2FkGAIgASgJSAASOAoXcmVxdWVzdGVkX291dHB1dF9mb3JtYXQY", "AyABKA4yFy5jb25mb3JtYW5jZS5XaXJlRm9ybWF0EhQKDG1lc3NhZ2VfdHlw", - "ZRgEIAEoCRIbChNpZ25vcmVfdW5rbm93bl9qc29uGAUgASgIQgkKB3BheWxv", - "YWQisQEKE0NvbmZvcm1hbmNlUmVzcG9uc2USFQoLcGFyc2VfZXJyb3IYASAB", - "KAlIABIZCg9zZXJpYWxpemVfZXJyb3IYBiABKAlIABIXCg1ydW50aW1lX2Vy", - "cm9yGAIgASgJSAASGgoQcHJvdG9idWZfcGF5bG9hZBgDIAEoDEgAEhYKDGpz", - "b25fcGF5bG9hZBgEIAEoCUgAEhEKB3NraXBwZWQYBSABKAlIAEIICgZyZXN1", - "bHQqNQoKV2lyZUZvcm1hdBIPCgtVTlNQRUNJRklFRBAAEgwKCFBST1RPQlVG", - "EAESCAoESlNPThACQiEKH2NvbS5nb29nbGUucHJvdG9idWYuY29uZm9ybWFu", - "Y2ViBnByb3RvMw==")); + "ZRgEIAEoCRIwCg10ZXN0X2NhdGVnb3J5GAUgASgOMhkuY29uZm9ybWFuY2Uu", + "VGVzdENhdGVnb3J5QgkKB3BheWxvYWQisQEKE0NvbmZvcm1hbmNlUmVzcG9u", + "c2USFQoLcGFyc2VfZXJyb3IYASABKAlIABIZCg9zZXJpYWxpemVfZXJyb3IY", + "BiABKAlIABIXCg1ydW50aW1lX2Vycm9yGAIgASgJSAASGgoQcHJvdG9idWZf", + "cGF5bG9hZBgDIAEoDEgAEhYKDGpzb25fcGF5bG9hZBgEIAEoCUgAEhEKB3Nr", + "aXBwZWQYBSABKAlIAEIICgZyZXN1bHQqNQoKV2lyZUZvcm1hdBIPCgtVTlNQ", + "RUNJRklFRBAAEgwKCFBST1RPQlVGEAESCAoESlNPThACKlQKDFRlc3RDYXRl", + "Z29yeRIPCgtCSU5BUllfVEVTVBAAEg0KCUpTT05fVEVTVBABEiQKIEpTT05f", + "SUdOT1JFX1VOS05PV05fUEFSU0lOR19URVNUEAJCIQofY29tLmdvb2dsZS5w", + "cm90b2J1Zi5jb25mb3JtYW5jZWIGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Conformance.WireFormat), }, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ConformanceRequest), global::Conformance.ConformanceRequest.Parser, new[]{ "ProtobufPayload", "JsonPayload", "RequestedOutputFormat", "MessageType", "IgnoreUnknownJson" }, new[]{ "Payload" }, null, null), + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Conformance.WireFormat), typeof(global::Conformance.TestCategory), }, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ConformanceRequest), global::Conformance.ConformanceRequest.Parser, new[]{ "ProtobufPayload", "JsonPayload", "RequestedOutputFormat", "MessageType", "TestCategory" }, new[]{ "Payload" }, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ConformanceResponse), global::Conformance.ConformanceResponse.Parser, new[]{ "ParseError", "SerializeError", "RuntimeError", "ProtobufPayload", "JsonPayload", "Skipped" }, new[]{ "Result" }, null, null) })); } @@ -53,6 +55,25 @@ namespace Conformance { [pbr::OriginalName("JSON")] Json = 2, } + public enum TestCategory { + /// <summary> + /// Test binary wire format. + /// </summary> + [pbr::OriginalName("BINARY_TEST")] BinaryTest = 0, + /// <summary> + /// Test json wire format. + /// </summary> + [pbr::OriginalName("JSON_TEST")] JsonTest = 1, + /// <summary> + /// Similar to JSON_TEST. However, during parsing json, testee should ignore + /// unknown fields. This feature is optional. Each implementation can descide + /// whether to support it. See + /// https://developers.google.com/protocol-buffers/docs/proto3#json_options + /// for more detail. + /// </summary> + [pbr::OriginalName("JSON_IGNORE_UNKNOWN_PARSING_TEST")] JsonIgnoreUnknownParsingTest = 2, + } + #endregion #region Messages @@ -90,7 +111,7 @@ namespace Conformance { public ConformanceRequest(ConformanceRequest other) : this() { requestedOutputFormat_ = other.requestedOutputFormat_; messageType_ = other.messageType_; - ignoreUnknownJson_ = other.ignoreUnknownJson_; + testCategory_ = other.testCategory_; switch (other.PayloadCase) { case PayloadOneofCase.ProtobufPayload: ProtobufPayload = other.ProtobufPayload; @@ -160,14 +181,19 @@ namespace Conformance { } } - /// <summary>Field number for the "ignore_unknown_json" field.</summary> - public const int IgnoreUnknownJsonFieldNumber = 5; - private bool ignoreUnknownJson_; + /// <summary>Field number for the "test_category" field.</summary> + public const int TestCategoryFieldNumber = 5; + private global::Conformance.TestCategory testCategory_ = 0; + /// <summary> + /// Each test is given a specific test category. Some category may need spedific + /// support in testee programs. Refer to the defintion of TestCategory for + /// more information. + /// </summary> [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool IgnoreUnknownJson { - get { return ignoreUnknownJson_; } + public global::Conformance.TestCategory TestCategory { + get { return testCategory_; } set { - ignoreUnknownJson_ = value; + testCategory_ = value; } } @@ -207,7 +233,7 @@ namespace Conformance { if (JsonPayload != other.JsonPayload) return false; if (RequestedOutputFormat != other.RequestedOutputFormat) return false; if (MessageType != other.MessageType) return false; - if (IgnoreUnknownJson != other.IgnoreUnknownJson) return false; + if (TestCategory != other.TestCategory) return false; if (PayloadCase != other.PayloadCase) return false; return Equals(_unknownFields, other._unknownFields); } @@ -219,7 +245,7 @@ namespace Conformance { if (payloadCase_ == PayloadOneofCase.JsonPayload) hash ^= JsonPayload.GetHashCode(); if (RequestedOutputFormat != 0) hash ^= RequestedOutputFormat.GetHashCode(); if (MessageType.Length != 0) hash ^= MessageType.GetHashCode(); - if (IgnoreUnknownJson != false) hash ^= IgnoreUnknownJson.GetHashCode(); + if (TestCategory != 0) hash ^= TestCategory.GetHashCode(); hash ^= (int) payloadCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); @@ -250,9 +276,9 @@ namespace Conformance { output.WriteRawTag(34); output.WriteString(MessageType); } - if (IgnoreUnknownJson != false) { + if (TestCategory != 0) { output.WriteRawTag(40); - output.WriteBool(IgnoreUnknownJson); + output.WriteEnum((int) TestCategory); } if (_unknownFields != null) { _unknownFields.WriteTo(output); @@ -274,8 +300,8 @@ namespace Conformance { if (MessageType.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(MessageType); } - if (IgnoreUnknownJson != false) { - size += 1 + 1; + if (TestCategory != 0) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) TestCategory); } if (_unknownFields != null) { size += _unknownFields.CalculateSize(); @@ -294,8 +320,8 @@ namespace Conformance { if (other.MessageType.Length != 0) { MessageType = other.MessageType; } - if (other.IgnoreUnknownJson != false) { - IgnoreUnknownJson = other.IgnoreUnknownJson; + if (other.TestCategory != 0) { + TestCategory = other.TestCategory; } switch (other.PayloadCase) { case PayloadOneofCase.ProtobufPayload: @@ -334,7 +360,7 @@ namespace Conformance { break; } case 40: { - IgnoreUnknownJson = input.ReadBool(); + testCategory_ = (global::Conformance.TestCategory) input.ReadEnum(); break; } } diff --git a/csharp/src/Google.Protobuf.Conformance/Program.cs b/csharp/src/Google.Protobuf.Conformance/Program.cs index 96dc354e..1eac00be 100644 --- a/csharp/src/Google.Protobuf.Conformance/Program.cs +++ b/csharp/src/Google.Protobuf.Conformance/Program.cs @@ -87,6 +87,9 @@ namespace Google.Protobuf.Conformance switch (request.PayloadCase) { case ConformanceRequest.PayloadOneofCase.JsonPayload: + if (request.TestCategory == global::Conformance.TestCategory.JsonIgnoreUnknownParsingTest) { + return new ConformanceResponse { Skipped = "CSharp doesn't support skipping unknown fields in json parsing." }; + } var parser = new JsonParser(new JsonParser.Settings(20, typeRegistry)); message = parser.Parse<ProtobufTestMessages.Proto3.TestAllTypesProto3>(request.JsonPayload); break; diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index 46728b72..a056b435 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -4,7 +4,7 @@ <Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description> <Copyright>Copyright 2015, Google Inc.</Copyright> <AssemblyTitle>Google Protocol Buffers</AssemblyTitle> - <VersionPrefix>3.6.0</VersionPrefix> + <VersionPrefix>3.6.1</VersionPrefix> <Authors>Google Inc.</Authors> <TargetFrameworks>netstandard1.0;net45</TargetFrameworks> <GenerateDocumentationFile>true</GenerateDocumentationFile> diff --git a/docs/options.md b/docs/options.md index c9b2290a..529cce5d 100644 --- a/docs/options.md +++ b/docs/options.md @@ -184,3 +184,7 @@ with info about your project (name and website) so we can add an entry for you. 1. API client generators * Website: ??? * Extensions: 1048-1056 + +1. Netifi Proteus + * Website: https://github.com/netifi-proteus + * Extensions: 1057 diff --git a/docs/third_party.md b/docs/third_party.md index 7b0fb2df..f710b51a 100644 --- a/docs/third_party.md +++ b/docs/third_party.md @@ -129,6 +129,7 @@ GRPC (http://www.grpc.io/) is Google's RPC implementation for Protocol Buffers. * https://github.com/awakesecurity/gRPC-haskell (Haskell) * https://github.com/Yeolar/raster (C++) * https://github.com/jnordberg/wsrpc (JavaScript Node.js/Browser) +* https://github.com/ppissias/xsrpcj (Java) ## Other Utilities diff --git a/java/core/pom.xml b/java/core/pom.xml index a7d4ea37..0c0fd8ff 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml @@ -6,7 +6,7 @@ <parent> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-parent</artifactId> - <version>3.6.0</version> + <version>3.6.1</version> </parent> <artifactId>protobuf-java</artifactId> diff --git a/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java b/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java index 35b31f15..ff670fd8 100644 --- a/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java +++ b/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java @@ -1406,7 +1406,7 @@ public abstract class GeneratedMessageLite< /** * A serialized (serializable) form of the generated message. Stores the - * message as a class name and a byte array. + * message as a class and a byte array. */ protected static final class SerializedForm implements Serializable { @@ -1416,6 +1416,9 @@ public abstract class GeneratedMessageLite< private static final long serialVersionUID = 0L; + // since v3.6.1 + private final Class<?> messageClass; + // only included for backwards compatibility before messageClass was added private final String messageClassName; private final byte[] asBytes; @@ -1424,7 +1427,8 @@ public abstract class GeneratedMessageLite< * @param regularForm the message to serialize */ SerializedForm(MessageLite regularForm) { - messageClassName = regularForm.getClass().getName(); + messageClass = regularForm.getClass(); + messageClassName = messageClass.getName(); asBytes = regularForm.toByteArray(); } @@ -1436,7 +1440,7 @@ public abstract class GeneratedMessageLite< @SuppressWarnings("unchecked") protected Object readResolve() throws ObjectStreamException { try { - Class<?> messageClass = Class.forName(messageClassName); + Class<?> messageClass = resolveMessageClass(); java.lang.reflect.Field defaultInstanceField = messageClass.getDeclaredField("DEFAULT_INSTANCE"); defaultInstanceField.setAccessible(true); @@ -1463,7 +1467,7 @@ public abstract class GeneratedMessageLite< @Deprecated private Object readResolveFallback() throws ObjectStreamException { try { - Class<?> messageClass = Class.forName(messageClassName); + Class<?> messageClass = resolveMessageClass(); java.lang.reflect.Field defaultInstanceField = messageClass.getDeclaredField("defaultInstance"); defaultInstanceField.setAccessible(true); @@ -1483,6 +1487,10 @@ public abstract class GeneratedMessageLite< throw new RuntimeException("Unable to understand proto buffer", e); } } + + private Class<?> resolveMessageClass() throws ClassNotFoundException { + return messageClass != null ? messageClass : Class.forName(messageClassName); + } } /** diff --git a/java/core/src/test/java/com/google/protobuf/GeneratedMessageTest.java b/java/core/src/test/java/com/google/protobuf/GeneratedMessageTest.java index a4143cd4..4489dace 100644 --- a/java/core/src/test/java/com/google/protobuf/GeneratedMessageTest.java +++ b/java/core/src/test/java/com/google/protobuf/GeneratedMessageTest.java @@ -32,6 +32,7 @@ package com.google.protobuf; import com.google.protobuf.Descriptors.Descriptor; import com.google.protobuf.Descriptors.FieldDescriptor; +import com.google.protobuf.Int32Value; import com.google.protobuf.test.UnittestImport; import protobuf_unittest.EnumWithNoOuter; import protobuf_unittest.MessageWithNoOuter; @@ -853,6 +854,75 @@ public class GeneratedMessageTest extends TestCase { assertEquals(expected, actual); } + public void testDeserializeWithoutClassField() throws Exception { + // serialized form for version <=3.6.0 + // just includes messageClassName and asBytes + + // Int32Value.newBuilder().setValue(123).build() + byte[] int32ValueBytes = new byte[]{ + -84, -19, 0, 5, 115, 114, 0, 55, 99, 111, 109, 46, 103, 111, 111, + 103, 108, 101, 46, 112, 114, 111, 116, 111, 98, 117, 102, 46, 71, + 101, 110, 101, 114, 97, 116, 101, 100, 77, 101, 115, 115, 97, 103, + 101, 76, 105, 116, 101, 36, 83, 101, 114, 105, 97, 108, 105, 122, + 101, 100, 70, 111, 114, 109, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 91, + 0, 7, 97, 115, 66, 121, 116, 101, 115, 116, 0, 2, 91, 66, 76, 0, + 16, 109, 101, 115, 115, 97, 103, 101, 67, 108, 97, 115, 115, 78, + 97, 109, 101, 116, 0, 18, 76, 106, 97, 118, 97, 47, 108, 97, 110, + 103, 47, 83, 116, 114, 105, 110, 103, 59, 120, 112, 117, 114, 0, + 2, 91, 66, -84, -13, 23, -8, 6, 8, 84, -32, 2, 0, 0, 120, 112, 0, + 0, 0, 2, 8, 123, 116, 0, 30, 99, 111, 109, 46, 103, 111, 111, 103, + 108, 101, 46, 112, 114, 111, 116, 111, 98, 117, 102, 46, 73, 110, + 116, 51, 50, 86, 97, 108, 117, 101 + }; + + ByteArrayInputStream bais = new ByteArrayInputStream(int32ValueBytes); + ObjectInputStream in = new ObjectInputStream(bais); + Int32Value int32Value = (Int32Value) in.readObject(); + assertEquals(123, int32Value.getValue()); + } + + public void testDeserializeWithClassField() throws Exception { + // serialized form for version > 3.6.0 + // includes messageClass, messageClassName (for compatibility), and asBytes + + // Int32Value.newBuilder().setValue(123).build() + byte[] int32ValueBytes = new byte[]{ + -84, -19, 0, 5, 115, 114, 0, 55, 99, 111, 109, 46, 103, 111, 111, + 103, 108, 101, 46, 112, 114, 111, 116, 111, 98, 117, 102, 46, 71, + 101, 110, 101, 114, 97, 116, 101, 100, 77, 101, 115, 115, 97, 103, + 101, 76, 105, 116, 101, 36, 83, 101, 114, 105, 97, 108, 105, 122, + 101, 100, 70, 111, 114, 109, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 91, + 0, 7, 97, 115, 66, 121, 116, 101, 115, 116, 0, 2, 91, 66, 76, 0, + 12, 109, 101, 115, 115, 97, 103, 101, 67, 108, 97, 115, 115, 116, + 0, 17, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 67, 108, + 97, 115, 115, 59, 76, 0, 16, 109, 101, 115, 115, 97, 103, 101, 67, + 108, 97, 115, 115, 78, 97, 109, 101, 116, 0, 18, 76, 106, 97, 118, + 97, 47, 108, 97, 110, 103, 47, 83, 116, 114, 105, 110, 103, 59, + 120, 112, 117, 114, 0, 2, 91, 66, -84, -13, 23, -8, 6, 8, 84, -32, + 2, 0, 0, 120, 112, 0, 0, 0, 2, 8, 123, 118, 114, 0, 30, 99, 111, + 109, 46, 103, 111, 111, 103, 108, 101, 46, 112, 114, 111, 116, 111, + 98, 117, 102, 46, 73, 110, 116, 51, 50, 86, 97, 108, 117, 101, 0, 0, + 0, 0, 0, 0, 0, 0, 2, 0, 2, 66, 0, 21, 109, 101, 109, 111, 105, 122, + 101, 100, 73, 115, 73, 110, 105, 116, 105, 97, 108, 105, 122, 101, + 100, 73, 0, 6, 118, 97, 108, 117, 101, 95, 120, 114, 0, 38, 99, 111, + 109, 46, 103, 111, 111, 103, 108, 101, 46, 112, 114, 111, 116, 111, + 98, 117, 102, 46, 71, 101, 110, 101, 114, 97, 116, 101, 100, 77, + 101, 115, 115, 97, 103, 101, 86, 51, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, + 1, 76, 0, 13, 117, 110, 107, 110, 111, 119, 110, 70, 105, 101, 108, + 100, 115, 116, 0, 37, 76, 99, 111, 109, 47, 103, 111, 111, 103, 108, + 101, 47, 112, 114, 111, 116, 111, 98, 117, 102, 47, 85, 110, 107, + 110, 111, 119, 110, 70, 105, 101, 108, 100, 83, 101, 116, 59, 120, + 112, 116, 0, 30, 99, 111, 109, 46, 103, 111, 111, 103, 108, 101, 46, + 112, 114, 111, 116, 111, 98, 117, 102, 46, 73, 110, 116, 51, 50, 86, + 97, 108, 117, 101 + }; + + ByteArrayInputStream bais = new ByteArrayInputStream(int32ValueBytes); + ObjectInputStream in = new ObjectInputStream(bais); + Int32Value int32Value = (Int32Value) in.readObject(); + assertEquals(123, int32Value.getValue()); + } + public void testEnumValues() { assertEquals(TestAllTypes.NestedEnum.BAR_VALUE, TestAllTypes.NestedEnum.BAR.getNumber()); assertEquals(TestAllTypes.NestedEnum.BAZ_VALUE, TestAllTypes.NestedEnum.BAZ.getNumber()); diff --git a/java/pom.xml b/java/pom.xml index 35d653b4..6526b650 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -11,7 +11,7 @@ <groupId>com.google.protobuf</groupId> <artifactId>protobuf-parent</artifactId> - <version>3.6.0</version> + <version>3.6.1</version> <packaging>pom</packaging> <name>Protocol Buffers [Parent]</name> @@ -92,7 +92,7 @@ <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> - <version>3.6.0</version> + <version>3.6.1</version> <configuration> <source>1.7</source> <target>1.7</target> diff --git a/java/util/pom.xml b/java/util/pom.xml index 8ea4a40d..f175cf15 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -6,7 +6,7 @@ <parent> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-parent</artifactId> - <version>3.6.0</version> + <version>3.6.1</version> </parent> <artifactId>protobuf-java-util</artifactId> diff --git a/java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java b/java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java index 7b4facc1..86f56ad9 100644 --- a/java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java +++ b/java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java @@ -240,7 +240,7 @@ final class FieldMaskTree { "Field \"" + field.getFullName() + "\" is not a " - + "singluar message field and cannot have sub-fields."); + + "singular message field and cannot have sub-fields."); continue; } if (!source.hasField(field) && !destination.hasField(field)) { diff --git a/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java b/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java index 973f1517..955dfd86 100644 --- a/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java +++ b/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java @@ -50,6 +50,7 @@ import com.google.protobuf.Descriptors.Descriptor; import com.google.protobuf.Descriptors.EnumDescriptor; import com.google.protobuf.Descriptors.EnumValueDescriptor; import com.google.protobuf.Descriptors.FieldDescriptor; +import com.google.protobuf.Descriptors.FieldDescriptor.Type; import com.google.protobuf.Descriptors.FileDescriptor; import com.google.protobuf.Descriptors.OneofDescriptor; import com.google.protobuf.DoubleValue; @@ -1539,7 +1540,11 @@ public class JsonFormat { Object key = parseFieldValue(keyField, new JsonPrimitive(entry.getKey()), entryBuilder); Object value = parseFieldValue(valueField, entry.getValue(), entryBuilder); if (value == null) { - throw new InvalidProtocolBufferException("Map value cannot be null."); + if(ignoringUnknownFields && valueField.getType() == Type.ENUM) { + continue; + } else { + throw new InvalidProtocolBufferException("Map value cannot be null."); + } } entryBuilder.setField(keyField, key); entryBuilder.setField(valueField, value); @@ -1557,8 +1562,12 @@ public class JsonFormat { for (int i = 0; i < array.size(); ++i) { Object value = parseFieldValue(field, array.get(i), builder); if (value == null) { - throw new InvalidProtocolBufferException( - "Repeated field elements cannot be null in field: " + field.getFullName()); + if(ignoringUnknownFields && field.getType() == Type.ENUM) { + continue; + } else { + throw new InvalidProtocolBufferException( + "Repeated field elements cannot be null in field: " + field.getFullName()); + } } builder.addRepeatedField(field, value); } @@ -1748,7 +1757,7 @@ public class JsonFormat { // an exception later. } - if (result == null) { + if (result == null && !ignoringUnknownFields) { throw new InvalidProtocolBufferException( "Invalid enum value: " + value + " for enum type: " + enumDescriptor.getFullName()); } diff --git a/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java b/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java index d9bbe587..7637c267 100644 --- a/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java +++ b/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java @@ -161,6 +161,10 @@ public class JsonFormatTest extends TestCase { JsonFormat.parser().merge(json, builder); } + private void mergeFromJsonIgnoringUnknownFields(String json, Message.Builder builder) throws IOException { + JsonFormat.parser().ignoringUnknownFields().merge(json, builder); + } + public void testAllFields() throws Exception { TestAllTypes.Builder builder = TestAllTypes.newBuilder(); setAllFields(builder); @@ -668,10 +672,22 @@ public class JsonFormatTest extends TestCase { + "}", builder); fail(); + } catch (InvalidProtocolBufferException e) { // Exception expected. } } + + public void testMapEnumNullValueIsIgnored() throws Exception { + TestMap.Builder builder = TestMap.newBuilder(); + mergeFromJsonIgnoringUnknownFields( + "{\n" + + " \"int32ToEnumMap\": {\"1\": null}\n" + + "}", + builder); + TestMap map = builder.build(); + assertEquals(0, map.getInt32ToEnumMapMap().entrySet().size()); + } public void testParserAcceptNonQuotedObjectKey() throws Exception { TestMap.Builder builder = TestMap.newBuilder(); @@ -1172,7 +1188,40 @@ public class JsonFormatTest extends TestCase { String json = "{\n" + " \"unknownField\": \"XXX\"\n" + "}"; JsonFormat.parser().ignoringUnknownFields().merge(json, builder); } - + + public void testParserIgnoringUnknownEnums() throws Exception { + TestAllTypes.Builder builder = TestAllTypes.newBuilder(); + String json = "{\n" + " \"optionalNestedEnum\": \"XXX\"\n" + "}"; + JsonFormat.parser().ignoringUnknownFields().merge(json, builder); + assertEquals(0, builder.getOptionalNestedEnumValue()); + } + + public void testUnknownEnumMap() throws Exception { + TestMap.Builder builder = TestMap.newBuilder(); + JsonFormat.parser().ignoringUnknownFields().merge( + "{\n" + + " \"int32ToEnumMap\": {1: XXX, 2: FOO}" + + "}", + builder); + + assertEquals(NestedEnum.FOO, builder.getInt32ToEnumMapMap().get(2)); + assertEquals(1, builder.getInt32ToEnumMapMap().size()); + } + + public void testRepeatedUnknownEnum() throws Exception { + TestAllTypes.Builder builder = TestAllTypes.newBuilder(); + JsonFormat.parser().ignoringUnknownFields().merge( + "{\n" + + " \"repeatedNestedEnum\": [XXX, FOO, BAR, BAZ]" + + "}", + builder); + + assertEquals(NestedEnum.FOO, builder.getRepeatedNestedEnum(0)); + assertEquals(NestedEnum.BAR, builder.getRepeatedNestedEnum(1)); + assertEquals(NestedEnum.BAZ, builder.getRepeatedNestedEnum(2)); + assertEquals(3, builder.getRepeatedNestedEnumList().size()); + } + public void testParserIntegerEnumValue() throws Exception { TestAllTypes.Builder actualBuilder = TestAllTypes.newBuilder(); mergeFromJson("{\n" + " \"optionalNestedEnum\": 2\n" + "}", actualBuilder); diff --git a/js/README.md b/js/README.md index d8edca37..97fa7e29 100644 --- a/js/README.md +++ b/js/README.md @@ -1,7 +1,7 @@ Protocol Buffers - Google's data interchange format =================================================== -[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf) +[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-javascript.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fjavascript%2Fcontinuous) [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-javascript.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fjavascript%2Fcontinuous) Copyright 2008 Google Inc. diff --git a/js/package.json b/js/package.json index 325f2dcc..dd5b6371 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "google-protobuf", - "version": "3.6.0", + "version": "3.6.1", "description": "Protocol Buffers for JavaScript", "main": "google-protobuf.js", "files": [ @@ -22,5 +22,5 @@ "url": "https://github.com/google/protobuf/tree/master/js" }, "author": "Google Protocol Buffers Team", - "license" : "BSD-3-Clause" + "license": "BSD-3-Clause" } diff --git a/kokoro/release/protoc/linux/build.sh b/kokoro/release/protoc/linux/build.sh index 6c7049d7..f0cde494 100755 --- a/kokoro/release/protoc/linux/build.sh +++ b/kokoro/release/protoc/linux/build.sh @@ -11,6 +11,16 @@ git submodule update --init --recursive # Generate the configure script. ./autogen.sh +# Cross-build for aarch64 and ppc64le. Note: we do these builds first to avoid +# file permission issues. The Docker builds will create directories owned by +# root, which causes problems if we try to add new artifacts to those +# directories afterward. +sudo apt install -y g++-aarch64-linux-gnu +protoc-artifacts/build-protoc.sh linux aarch_64 protoc + +sudo apt install -y g++-powerpc64le-linux-gnu +protoc-artifacts/build-protoc.sh linux ppcle_64 protoc + # Use docker image to build linux artifacts. DOCKER_IMAGE_NAME=protobuf/protoc_$(sha1sum protoc-artifacts/Dockerfile | cut -f1 -d " ") docker pull $DOCKER_IMAGE_NAME @@ -28,9 +38,3 @@ docker run -v $(pwd):/var/local/protobuf --rm $DOCKER_IMAGE_NAME \ echo "Failed to build protoc for linux + x86_32." exit 1 } - -# Cross-build for some architectures. -# TODO(xiaofeng): It currently fails with "machine `aarch64' not recognized" -# error. -# sudo apt install -y g++-aarch64-linux-gnu -# protoc-artifacts/build-protoc.sh linux aarch_64 protoc diff --git a/objectivec/GPBUnknownField.m b/objectivec/GPBUnknownField.m index 9d5c97f3..7fa8cade 100644 --- a/objectivec/GPBUnknownField.m +++ b/objectivec/GPBUnknownField.m @@ -32,6 +32,7 @@ #import "GPBArray.h" #import "GPBCodedOutputStream_PackagePrivate.h" +#import "GPBUnknownFieldSet.h" @implementation GPBUnknownField { @protected diff --git a/objectivec/README.md b/objectivec/README.md index 21ac07d8..528f5472 100644 --- a/objectivec/README.md +++ b/objectivec/README.md @@ -1,7 +1,7 @@ Protocol Buffers - Google's data interchange format =================================================== -[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf) +[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-objectivec_cocoapods_integration.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fobjectivec_cocoapods_integration%2Fcontinuous) [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-objectivec_ios_debug.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fobjectivec_ios_debug%2Fcontinuous) [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-objectivec_ios_release.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fobjectivec_ios_release%2Fcontinuous) [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-objectivec_osx.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fobjectivec_osx%2Fcontinuous) Copyright 2008 Google Inc. diff --git a/php/README.md b/php/README.md index 967250a7..e307768d 100644 --- a/php/README.md +++ b/php/README.md @@ -17,7 +17,7 @@ generation functionality. To use PHP runtime library requires: - C extension: PHP 5.5, 5.6, or 7. -- PHP package: PHP 5.5, 5.6 or 7. +- [PHP package](http://php.net/downloads.php): PHP 5.5, 5.6 or 7. ## Installation diff --git a/php/composer.json b/php/composer.json index 34e0447c..20f6a45e 100644 --- a/php/composer.json +++ b/php/composer.json @@ -9,13 +9,20 @@ "php": ">=5.5.0" }, "require-dev": { - "phpunit/phpunit": ">=4.8.0" + "phpunit/phpunit": "^5|^4.8.0" }, "autoload": { "psr-4": { "Google\\Protobuf\\": "src/Google/Protobuf", - "GPBMetadata\\Google\\Protobuf\\": "src/GPBMetadata/Google/Protobuf", + "GPBMetadata\\Google\\Protobuf\\": "src/GPBMetadata/Google/Protobuf" + } + }, + "autoload-dev": { + "psr-4": { "": "tests/generated" } + }, + "scripts": { + "test": "(cd tests && rm -rf generated && mkdir -p generated && ../../src/protoc --php_out=generated proto/empty/echo.proto proto/test.proto proto/test_include.proto proto/test_no_namespace.proto proto/test_prefix.proto proto/test_php_namespace.proto proto/test_empty_php_namespace.proto proto/test_reserved_enum_lower.proto proto/test_reserved_enum_upper.proto proto/test_reserved_enum_value_lower.proto proto/test_reserved_enum_value_upper.proto proto/test_reserved_message_lower.proto proto/test_reserved_message_upper.proto proto/test_service.proto proto/test_service_namespace.proto proto/test_descriptors.proto) && (cd ../src && ./protoc --php_out=../php/tests/generated -I../php/tests -I. ../php/tests/proto/test_import_descriptor_proto.proto) && vendor/bin/phpunit" } } diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c index fa33830b..238a9247 100644 --- a/php/ext/google/protobuf/def.c +++ b/php/ext/google/protobuf/def.c @@ -253,7 +253,7 @@ PHP_METHOD(Descriptor, getField) { #else field_hashtable_value = field_descriptor_type->create_object(field_descriptor_type TSRMLS_CC); - --GC_REFCOUNT(field_hashtable_value); + GC_DELREF(field_hashtable_value); #endif FieldDescriptor *field_php = UNBOX_HASHTABLE_VALUE(FieldDescriptor, field_hashtable_value); @@ -264,7 +264,7 @@ PHP_METHOD(Descriptor, getField) { #if PHP_MAJOR_VERSION < 7 RETURN_ZVAL(field_hashtable_value, 1, 0); #else - ++GC_REFCOUNT(field_hashtable_value); + GC_ADDREF(field_hashtable_value); RETURN_OBJ(field_hashtable_value); #endif } @@ -492,7 +492,7 @@ PHP_METHOD(FieldDescriptor, getEnumType) { #if PHP_MAJOR_VERSION < 7 RETURN_ZVAL(desc, 1, 0); #else - ++GC_REFCOUNT(desc); + GC_ADDREF(desc); RETURN_OBJ(desc); #endif } @@ -512,7 +512,7 @@ PHP_METHOD(FieldDescriptor, getMessageType) { #if PHP_MAJOR_VERSION < 7 RETURN_ZVAL(desc, 1, 0); #else - ++GC_REFCOUNT(desc); + GC_ADDREF(desc); RETURN_OBJ(desc); #endif } @@ -585,7 +585,7 @@ PHP_METHOD(Oneof, getField) { #if PHP_MAJOR_VERSION < 7 RETURN_ZVAL(field_hashtable_value, 1, 0); #else - ++GC_REFCOUNT(field_hashtable_value); + GC_ADDREF(field_hashtable_value); RETURN_OBJ(field_hashtable_value); #endif } @@ -703,7 +703,7 @@ PHP_METHOD(DescriptorPool, getGeneratedPool) { #if PHP_MAJOR_VERSION < 7 RETURN_ZVAL(generated_pool_php, 1, 0); #else - ++GC_REFCOUNT(generated_pool_php); + GC_ADDREF(generated_pool_php); RETURN_OBJ(generated_pool_php); #endif } @@ -713,7 +713,7 @@ PHP_METHOD(InternalDescriptorPool, getGeneratedPool) { #if PHP_MAJOR_VERSION < 7 RETURN_ZVAL(internal_generated_pool_php, 1, 0); #else - ++GC_REFCOUNT(internal_generated_pool_php); + GC_ADDREF(internal_generated_pool_php); RETURN_OBJ(internal_generated_pool_php); #endif } @@ -1033,7 +1033,7 @@ PHP_METHOD(DescriptorPool, getDescriptorByClassName) { #if PHP_MAJOR_VERSION < 7 RETURN_ZVAL(desc, 1, 0); #else - ++GC_REFCOUNT(desc); + GC_ADDREF(desc); RETURN_OBJ(desc); #endif } @@ -1070,7 +1070,7 @@ PHP_METHOD(DescriptorPool, getEnumDescriptorByClassName) { #if PHP_MAJOR_VERSION < 7 RETURN_ZVAL(desc, 1, 0); #else - ++GC_REFCOUNT(desc); + GC_ADDREF(desc); RETURN_OBJ(desc); #endif } diff --git a/php/ext/google/protobuf/encode_decode.c b/php/ext/google/protobuf/encode_decode.c index 31a345b3..899b99f0 100644 --- a/php/ext/google/protobuf/encode_decode.c +++ b/php/ext/google/protobuf/encode_decode.c @@ -577,7 +577,7 @@ static void map_slot_value(upb_fieldtype_t type, const void* from, break; case UPB_TYPE_MESSAGE: *(zend_object**)to = Z_OBJ_P(*(zval**)from); - ++GC_REFCOUNT(*(zend_object**)to); + GC_ADDREF(*(zend_object**)to); break; #endif default: diff --git a/php/ext/google/protobuf/map.c b/php/ext/google/protobuf/map.c index ab8a518a..c5b500b5 100644 --- a/php/ext/google/protobuf/map.c +++ b/php/ext/google/protobuf/map.c @@ -192,7 +192,8 @@ static inline void php_proto_map_string_release(void *value) { } static inline void php_proto_map_object_release(void *value) { zend_object* object = *(zend_object**)value; - if(--GC_REFCOUNT(object) == 0) { + GC_DELREF(object); + if(GC_REFCOUNT(object) == 0) { zend_objects_store_del(object); } } @@ -302,7 +303,8 @@ static bool map_index_unset(Map *intern, const char* keyval, int length) { zval_ptr_dtor(upb_value_memory(&old_value)); #else zend_object* object = *(zend_object**)upb_value_memory(&old_value); - if(--GC_REFCOUNT(object) == 0) { + GC_DELREF(object); + if(GC_REFCOUNT(object) == 0) { zend_objects_store_del(object); } #endif diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c index 76d85ab0..0efe090d 100644 --- a/php/ext/google/protobuf/message.c +++ b/php/ext/google/protobuf/message.c @@ -223,13 +223,7 @@ static zval* message_get_property_ptr_ptr(zval* object, zval* member, int type, } static HashTable* message_get_properties(zval* object TSRMLS_DC) { - // User cannot get property directly (e.g., $a = $m->a) - zend_error(E_USER_ERROR, "Cannot access private properties."); -#if PHP_MAJOR_VERSION < 7 - return zend_std_get_properties(object TSRMLS_CC); -#else - return zend_std_get_properties(object); -#endif + return NULL; } static HashTable* message_get_gc(zval* object, CACHED_VALUE** table, @@ -871,7 +865,11 @@ PHP_PROTO_INIT_ENUMCLASS_START("Google\\Protobuf\\Field\\Cardinality", zend_declare_class_constant_long(field_cardinality_type, "CARDINALITY_REPEATED", 20, 3 TSRMLS_CC); const char *alias = "Google\\Protobuf\\Field_Cardinality"; +#if PHP_VERSION_ID < 70300 zend_register_class_alias_ex(alias, strlen(alias), field_cardinality_type TSRMLS_CC); +#else + zend_register_class_alias_ex(alias, strlen(alias), field_cardinality_type, 1); +#endif PHP_PROTO_INIT_ENUMCLASS_END // ----------------------------------------------------------------------------- @@ -926,7 +924,11 @@ PHP_PROTO_INIT_ENUMCLASS_START("Google\\Protobuf\\Field\\Kind", zend_declare_class_constant_long(field_kind_type, "TYPE_SINT64", 11, 18 TSRMLS_CC); const char *alias = "Google\\Protobuf\\Field_Kind"; +#if PHP_VERSION_ID < 70300 zend_register_class_alias_ex(alias, strlen(alias), field_kind_type TSRMLS_CC); +#else + zend_register_class_alias_ex(alias, strlen(alias), field_kind_type, 1); +#endif PHP_PROTO_INIT_ENUMCLASS_END // ----------------------------------------------------------------------------- diff --git a/php/ext/google/protobuf/protobuf.c b/php/ext/google/protobuf/protobuf.c index da00302f..19cc5efb 100644 --- a/php/ext/google/protobuf/protobuf.c +++ b/php/ext/google/protobuf/protobuf.c @@ -104,7 +104,7 @@ void add_def_obj(const void* def, PHP_PROTO_HASHTABLE_VALUE value) { #if PHP_MAJOR_VERSION < 7 Z_ADDREF_P(value); #else - ++GC_REFCOUNT(value); + GC_ADDREF(value); #endif add_to_table(upb_def_to_php_obj_map, def, value); } @@ -117,7 +117,7 @@ void add_ce_obj(const void* ce, PHP_PROTO_HASHTABLE_VALUE value) { #if PHP_MAJOR_VERSION < 7 Z_ADDREF_P(value); #else - ++GC_REFCOUNT(value); + GC_ADDREF(value); #endif add_to_table(ce_to_php_obj_map, ce, value); } @@ -134,7 +134,7 @@ void add_proto_obj(const char* proto, PHP_PROTO_HASHTABLE_VALUE value) { #if PHP_MAJOR_VERSION < 7 Z_ADDREF_P(value); #else - ++GC_REFCOUNT(value); + GC_ADDREF(value); #endif add_to_strtable(proto_to_php_obj_map, proto, strlen(proto), value); } @@ -235,7 +235,8 @@ static PHP_GSHUTDOWN_FUNCTION(protobuf) { static void php_proto_hashtable_descriptor_release(zval* value) { void* ptr = Z_PTR_P(value); zend_object* object = *(zend_object**)ptr; - if(--GC_REFCOUNT(object) == 0) { + GC_DELREF(object); + if(GC_REFCOUNT(object) == 0) { zend_objects_store_del(object); } efree(ptr); diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 3ef4c84b..9cb36dc2 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -37,7 +37,7 @@ #include "upb.h" #define PHP_PROTOBUF_EXTNAME "protobuf" -#define PHP_PROTOBUF_VERSION "3.6.0" +#define PHP_PROTOBUF_VERSION "3.6.1" #define MAX_LENGTH_OF_INT64 20 #define SIZEOF_INT64 8 @@ -50,6 +50,11 @@ // PHP7 Wrappers // ---------------------------------------------------------------------------- +#if PHP_VERSION_ID < 70300 +#define GC_ADDREF(h) ++GC_REFCOUNT(h) +#define GC_DELREF(h) --GC_REFCOUNT(h) +#endif + #if PHP_MAJOR_VERSION < 7 #define php_proto_zend_literal const zend_literal* @@ -500,7 +505,7 @@ static inline int php_proto_zend_hash_get_current_data_ex(HashTable* ht, PHP_PROTO_HASHTABLE_VALUE WRAPPED_OBJ; \ WRAPPED_OBJ = OBJ_CLASS_ENTRY->create_object(OBJ_CLASS_ENTRY); \ OBJ = UNBOX_HASHTABLE_VALUE(OBJ_TYPE, WRAPPED_OBJ); \ - --GC_REFCOUNT(WRAPPED_OBJ); + GC_DELREF(WRAPPED_OBJ); #define PHP_PROTO_CE_DECLARE zend_class_entry* #define PHP_PROTO_CE_UNREF(ce) (ce) diff --git a/php/ext/google/protobuf/storage.c b/php/ext/google/protobuf/storage.c index e7910c85..a60fbe39 100644 --- a/php/ext/google/protobuf/storage.c +++ b/php/ext/google/protobuf/storage.c @@ -200,7 +200,7 @@ bool native_slot_set_by_array(upb_fieldtype_t type, } #else DEREF(memory, zval*) = value; - ++GC_REFCOUNT(Z_OBJ_P(value)); + GC_ADDREF(Z_OBJ_P(value)); #endif break; } @@ -251,7 +251,7 @@ bool native_slot_set_by_map(upb_fieldtype_t type, const zend_class_entry* klass, } #else DEREF(memory, zend_object*) = Z_OBJ_P(value); - ++GC_REFCOUNT(Z_OBJ_P(value)); + GC_ADDREF(Z_OBJ_P(value)); #endif break; } @@ -428,7 +428,7 @@ void native_slot_get_by_map_value(upb_fieldtype_t type, const void* memory, ZVAL_ZVAL(CACHED_PTR_TO_ZVAL_PTR(cache), value, 1, 0); } #else - ++GC_REFCOUNT(*(zend_object**)memory); + GC_ADDREF(*(zend_object**)memory); ZVAL_OBJ(cache, *(zend_object**)memory); #endif return; diff --git a/php/tests/generated_class_test.php b/php/tests/generated_class_test.php index 9f20bddc..8bac4e5e 100644 --- a/php/tests/generated_class_test.php +++ b/php/tests/generated_class_test.php @@ -1342,4 +1342,17 @@ class GeneratedClassTest extends TestBase TestUtil::assertTestMessage($m); } + + ######################################################### + # Test message equals. + ######################################################### + + public function testMessageEquals() + { + $m = new TestMessage(); + TestUtil::setTestMessage($m); + $n = new TestMessage(); + TestUtil::setTestMessage($n); + $this->assertEquals($m, $n); + } } diff --git a/protoc-artifacts/README.md b/protoc-artifacts/README.md index c25406dd..79fa30b8 100644 --- a/protoc-artifacts/README.md +++ b/protoc-artifacts/README.md @@ -119,7 +119,9 @@ target directory layout: protoc.exe + x86_32 protoc.exe - + macos + + aarch_64 + protoc.exe + + osx + x86_64 protoc.exe + x86_32 @@ -137,7 +139,7 @@ Use the following command to deploy artifacts for the host platform to a staging repository. ``` -$ mvn clean deploy -P release +$ mvn deploy -P release ``` It creates a new staging repository. Go to @@ -152,17 +154,19 @@ and upload these zip packages to the download section of the github release. For example: ``` -$ ./build-zip.sh 3.6.0 +$ ./build-zip.sh protoc 3.6.0 ``` -The above command will create 5 zip files: +The above command will create 7 zip files: ``` -dist/protoc-3.0.0-beta-4-win32.zip -dist/protoc-3.0.0-beta-4-osx-x86_32.zip -dist/protoc-3.0.0-beta-4-osx-x86_64.zip -dist/protoc-3.0.0-beta-4-linux-x86_32.zip -dist/protoc-3.0.0-beta-4-linux-x86_64.zip +dist/protoc-3.6.0-win32.zip +dist/protoc-3.6.0-osx-x86_32.zip +dist/protoc-3.6.0-osx-x86_64.zip +dist/protoc-3.6.0-linux-x86_32.zip +dist/protoc-3.6.0-linux-x86_64.zip +dist/protoc-3.6.0-linux-aarch_64.zip +dist/protoc-3.6.0-linux-ppcle_64.zip ``` Before running the script, make sure the artifacts are accessible from: diff --git a/protoc-artifacts/build-protoc.sh b/protoc-artifacts/build-protoc.sh index d6a3cfa3..b8d2eb87 100755 --- a/protoc-artifacts/build-protoc.sh +++ b/protoc-artifacts/build-protoc.sh @@ -86,6 +86,7 @@ checkArch () format="$(objdump -f "$1" | grep -o "file format .*$" | grep -o "[^ ]*$")" echo Format=$format if [[ "$OS" == linux ]]; then + host_machine="$(uname -m)"; if [[ "$ARCH" == x86_32 ]]; then assertEq $format "elf32-i386" $LINENO elif [[ "$ARCH" == x86_64 ]]; then @@ -93,7 +94,11 @@ checkArch () elif [[ "$ARCH" == aarch_64 ]]; then assertEq $format "elf64-little" $LINENO elif [[ "$ARCH" == ppcle_64 ]]; then - assertEq $format "elf64-powerpcle" $LINENO + if [[ $host_machine == ppc64le ]];then + assertEq $format "elf64-powerpcle" $LINENO + else + assertEq $format "elf64-little" $LINENO + fi else fail "Unsupported arch: $ARCH" fi @@ -132,12 +137,16 @@ checkDependencies () dump_cmd='objdump -x '"$1"' | fgrep "DLL Name"' white_list="KERNEL32\.dll\|msvcrt\.dll" elif [[ "$OS" == linux ]]; then + host_machine="$(uname -m)"; dump_cmd='ldd '"$1" if [[ "$ARCH" == x86_32 ]]; then white_list="linux-gate\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|ld-linux\.so\.2" elif [[ "$ARCH" == x86_64 ]]; then white_list="linux-vdso\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|ld-linux-x86-64\.so\.2" elif [[ "$ARCH" == ppcle_64 ]]; then + if [[ $host_machine != ppc64le ]];then + dump_cmd='objdump -p '"$1"' | grep NEEDED' + fi white_list="linux-vdso64\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|libz\.so\.1\|ld64\.so\.2" elif [[ "$ARCH" == aarch_64 ]]; then dump_cmd='objdump -p '"$1"' | grep NEEDED' @@ -205,6 +214,7 @@ elif [[ "$(uname)" == Linux* ]]; then CONFIGURE_ARGS="$CONFIGURE_ARGS --host=aarch64-linux-gnu" elif [[ "$ARCH" == ppcle_64 ]]; then CXXFLAGS="$CXXFLAGS -m64" + CONFIGURE_ARGS="$CONFIGURE_ARGS --host=powerpc64le-linux-gnu" else fail "Unsupported arch: $ARCH" fi diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index 390cd220..55d9e91a 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -10,7 +10,7 @@ </parent> <groupId>com.google.protobuf</groupId> <artifactId>protoc</artifactId> - <version>3.6.0</version> + <version>3.6.1</version> <packaging>pom</packaging> <name>Protobuf Compiler</name> <description> diff --git a/python/README.md b/python/README.md index 4b48225a..3eb78e56 100644 --- a/python/README.md +++ b/python/README.md @@ -1,7 +1,7 @@ Protocol Buffers - Google's data interchange format =================================================== -[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf) +[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython%2Fcontinuous) [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python_compatibility.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython_compatibility%2Fcontinuous) [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-python_cpp.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fpython_cpp%2Fcontinuous) [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-python.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fpython%2Fcontinuous) [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-python_cpp.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fpython_cpp%2Fcontinuous) Copyright 2008 Google Inc. diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index 58a3f040..249e18aa 100755 --- a/python/google/protobuf/__init__.py +++ b/python/google/protobuf/__init__.py @@ -30,7 +30,7 @@ # Copyright 2007 Google Inc. All Rights Reserved. -__version__ = '3.6.0' +__version__ = '3.6.1' if __name__ != '__main__': try: diff --git a/python/setup.py b/python/setup.py index 335e9114..5ec4dcbd 100755 --- a/python/setup.py +++ b/python/setup.py @@ -185,6 +185,7 @@ if __name__ == '__main__': extra_compile_args.append('-Wno-write-strings') extra_compile_args.append('-Wno-invalid-offsetof') extra_compile_args.append('-Wno-sign-compare') + extra_compile_args.append('-std=c++11') # https://github.com/Theano/Theano/issues/4926 if sys.platform == 'win32': @@ -201,12 +202,6 @@ if __name__ == '__main__': if "clang" in os.popen('$CC --version 2> /dev/null').read(): extra_compile_args.append('-Wno-shorten-64-to-32') - v, _, _ = platform.mac_ver() - if v: - extra_compile_args.append('-std=c++11') - elif os.getenv('KOKORO_BUILD_NUMBER') or os.getenv('KOKORO_BUILD_ID'): - extra_compile_args.append('-std=c++11') - if warnings_as_errors in sys.argv: extra_compile_args.append('-Werror') sys.argv.remove(warnings_as_errors) diff --git a/ruby/ext/google/protobuf_c/encode_decode.c b/ruby/ext/google/protobuf_c/encode_decode.c index c7a7aa1a..d5842051 100644 --- a/ruby/ext/google/protobuf_c/encode_decode.c +++ b/ruby/ext/google/protobuf_c/encode_decode.c @@ -1109,7 +1109,7 @@ static void putmsg(VALUE msg_rb, const Descriptor* desc, TypedData_Get_Struct(msg_rb, MessageHeader, &Message_type, msg); if (desc != msg->descriptor) { - rb_raise(cTypeError, + rb_raise(rb_eArgError, "The type of given msg is '%s', expect '%s'.", upb_msgdef_fullname(msg->descriptor->msgdef), upb_msgdef_fullname(desc->msgdef)); diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index cc7625d4..00a7ff36 100644 --- a/ruby/google-protobuf.gemspec +++ b/ruby/google-protobuf.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "google-protobuf" - s.version = "3.6.0" + s.version = "3.6.1" s.licenses = ["BSD-3-Clause"] s.summary = "Protocol Buffers" s.description = "Protocol Buffers are Google's data interchange format." diff --git a/ruby/tests/encode_decode_test.rb b/ruby/tests/encode_decode_test.rb index 95c2cfa4..f8b991cd 100644 --- a/ruby/tests/encode_decode_test.rb +++ b/ruby/tests/encode_decode_test.rb @@ -86,7 +86,7 @@ class EncodeDecodeTest < Test::Unit::TestCase end def test_encode_wrong_msg - e = assert_raise Google::Protobuf::TypeError do + e = assert_raise ::ArgumentError do m = A::B::C::TestMessage.new( :optional_int32 => 1, ) diff --git a/src/Makefile.am b/src/Makefile.am index 9e55261a..af264a95 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -164,7 +164,7 @@ nobase_include_HEADERS = \ lib_LTLIBRARIES = libprotobuf-lite.la libprotobuf.la libprotoc.la libprotobuf_lite_la_LIBADD = $(PTHREAD_LIBS) -libprotobuf_lite_la_LDFLAGS = -version-info 16:0:0 -export-dynamic -no-undefined +libprotobuf_lite_la_LDFLAGS = -version-info 17:0:0 -export-dynamic -no-undefined if HAVE_LD_VERSION_SCRIPT libprotobuf_lite_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotobuf-lite.map EXTRA_libprotobuf_lite_la_DEPENDENCIES = libprotobuf-lite.map @@ -210,7 +210,7 @@ libprotobuf_lite_la_SOURCES = \ google/protobuf/io/zero_copy_stream_impl_lite.cc libprotobuf_la_LIBADD = $(PTHREAD_LIBS) -libprotobuf_la_LDFLAGS = -version-info 16:0:0 -export-dynamic -no-undefined +libprotobuf_la_LDFLAGS = -version-info 17:0:0 -export-dynamic -no-undefined if HAVE_LD_VERSION_SCRIPT libprotobuf_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotobuf.map EXTRA_libprotobuf_la_DEPENDENCIES = libprotobuf.map @@ -301,7 +301,7 @@ libprotobuf_la_SOURCES = \ nodist_libprotobuf_la_SOURCES = $(nodist_libprotobuf_lite_la_SOURCES) libprotoc_la_LIBADD = $(PTHREAD_LIBS) libprotobuf.la -libprotoc_la_LDFLAGS = -version-info 16:0:0 -export-dynamic -no-undefined +libprotoc_la_LDFLAGS = -version-info 17:0:0 -export-dynamic -no-undefined if HAVE_LD_VERSION_SCRIPT libprotoc_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotoc.map EXTRA_libprotoc_la_DEPENDENCIES = libprotoc.map diff --git a/src/README.md b/src/README.md index 3cbeb3e6..4ca9a02a 100644 --- a/src/README.md +++ b/src/README.md @@ -1,7 +1,7 @@ Protocol Buffers - Google's data interchange format =================================================== -[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf) [![Build status](https://ci.appveyor.com/api/projects/status/73ctee6ua4w2ruin?svg=true)](https://ci.appveyor.com/project/protobuf/protobuf) +[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-cpp_distcheck.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fcpp_distcheck%2Fcontinuous) [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-cpp.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fcpp%2Fcontinuous) [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-cpp_distcheck.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fcpp_distcheck%2Fcontinuous) [![Build status](https://ci.appveyor.com/api/projects/status/73ctee6ua4w2ruin?svg=true)](https://ci.appveyor.com/project/protobuf/protobuf) Copyright 2008 Google Inc. diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index a47000c8..60d2e4cc 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index 38e43dff..cea0ffe1 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 8ccdeae2..55569b5e 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index b7ef7afc..99d66d00 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index fabc5b00..b66e343a 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index 13a4ab0b..7d88bb92 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 1db37eb2..b46d4997 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index d6b45155..5d4dae81 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index 1ccabb08..7ff4465b 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/stubs/bytestream.cc b/src/google/protobuf/stubs/bytestream.cc index f4af6a50..8df2566a 100644 --- a/src/google/protobuf/stubs/bytestream.cc +++ b/src/google/protobuf/stubs/bytestream.cc @@ -113,7 +113,7 @@ char* GrowingArrayByteSink::GetBuffer(size_t* nbytes) { ShrinkToFit(); char* b = buf_; *nbytes = size_; - buf_ = NULL; + buf_ = nullptr; size_ = capacity_ = 0; return b; } diff --git a/src/google/protobuf/stubs/casts.h b/src/google/protobuf/stubs/casts.h index 35e2dba0..b509f68c 100644 --- a/src/google/protobuf/stubs/casts.h +++ b/src/google/protobuf/stubs/casts.h @@ -89,7 +89,7 @@ inline To down_cast(From* f) { // so we only accept pointers } #if !defined(NDEBUG) && !defined(GOOGLE_PROTOBUF_NO_RTTI) - assert(f == NULL || dynamic_cast<To>(f) != NULL); // RTTI: debug mode only! + assert(f == nullptr || dynamic_cast<To>(f) != nullptr); // RTTI: debug mode only! #endif return static_cast<To>(f); } @@ -107,7 +107,7 @@ inline To down_cast(From& f) { #if !defined(NDEBUG) && !defined(GOOGLE_PROTOBUF_NO_RTTI) // RTTI: debug mode only! - assert(dynamic_cast<ToAsPointer>(&f) != NULL); + assert(dynamic_cast<ToAsPointer>(&f) != nullptr); #endif return *static_cast<ToAsPointer>(&f); } diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc index b54fd1c8..4b65eb89 100644 --- a/src/google/protobuf/stubs/common.cc +++ b/src/google/protobuf/stubs/common.cc @@ -175,12 +175,12 @@ void NullLogHandler(LogLevel /* level */, const char* /* filename */, static LogHandler* log_handler_ = &DefaultLogHandler; static int log_silencer_count_ = 0; -static Mutex* log_silencer_count_mutex_ = NULL; +static Mutex* log_silencer_count_mutex_ = nullptr; GOOGLE_PROTOBUF_DECLARE_ONCE(log_silencer_count_init_); void DeleteLogSilencerCount() { delete log_silencer_count_mutex_; - log_silencer_count_mutex_ = NULL; + log_silencer_count_mutex_ = nullptr; } void InitLogSilencerCount() { log_silencer_count_mutex_ = new Mutex; @@ -281,9 +281,9 @@ void LogFinisher::operator=(LogMessage& other) { LogHandler* SetLogHandler(LogHandler* new_func) { LogHandler* old = internal::log_handler_; if (old == &internal::NullLogHandler) { - old = NULL; + old = nullptr; } - if (new_func == NULL) { + if (new_func == nullptr) { internal::log_handler_ = &internal::NullLogHandler; } else { internal::log_handler_ = new_func; diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index c5256d32..585e0128 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -101,27 +101,27 @@ namespace internal { // The current version, represented as a single integer to make comparison // easier: major * 10^6 + minor * 10^3 + micro -#define GOOGLE_PROTOBUF_VERSION 3006000 +#define GOOGLE_PROTOBUF_VERSION 3006001 // A suffix string for alpha, beta or rc releases. Empty for stable releases. #define GOOGLE_PROTOBUF_VERSION_SUFFIX "" // The minimum library version which works with the current version of the // headers. -#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3006000 +#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3006001 // The minimum header version which works with the current version of // the library. This constant should only be used by protoc's C++ code // generator. -static const int kMinHeaderVersionForLibrary = 3006000; +static const int kMinHeaderVersionForLibrary = 3006001; // The minimum protoc version which works with the current version of the // headers. -#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3006000 +#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3006001 // The minimum header version which works with the current version of // protoc. This constant should only be used in VerifyVersion(). -static const int kMinHeaderVersionForProtoc = 3006000; +static const int kMinHeaderVersionForProtoc = 3006001; // Verifies that the headers and libraries are compatible. Use the macro // below to call this. diff --git a/src/google/protobuf/stubs/common_unittest.cc b/src/google/protobuf/stubs/common_unittest.cc index 798a2a27..3ce1c49a 100644 --- a/src/google/protobuf/stubs/common_unittest.cc +++ b/src/google/protobuf/stubs/common_unittest.cc @@ -100,14 +100,14 @@ TEST(LoggingTest, DefaultLogging) { } TEST(LoggingTest, NullLogging) { - LogHandler* old_handler = SetLogHandler(NULL); + LogHandler* old_handler = SetLogHandler(nullptr); CaptureTestStderr(); GOOGLE_LOG(INFO ) << "A message."; GOOGLE_LOG(WARNING) << "A warning."; GOOGLE_LOG(ERROR ) << "An error."; - EXPECT_TRUE(SetLogHandler(old_handler) == NULL); + EXPECT_TRUE(SetLogHandler(old_handler) == nullptr); string text = GetCapturedTestStderr(); EXPECT_EQ("", text); @@ -179,9 +179,9 @@ class ClosureTest : public testing::Test { virtual void SetUp() { current_instance_ = this; a_ = 0; - b_ = NULL; + b_ = nullptr; c_.clear(); - permanent_closure_ = NULL; + permanent_closure_ = nullptr; } void DeleteClosureInCallback() { @@ -196,7 +196,7 @@ class ClosureTest : public testing::Test { static ClosureTest* current_instance_; }; -ClosureTest* ClosureTest::current_instance_ = NULL; +ClosureTest* ClosureTest::current_instance_ = nullptr; TEST_F(ClosureTest, TestClosureFunction0) { Closure* closure = NewCallback(&SetA123Function); @@ -321,7 +321,7 @@ TEST_F(ClosureTest, TestPermanentClosureFunction2) { EXPECT_EQ(789, a_); EXPECT_EQ(cstr, b_); a_ = 0; - b_ = NULL; + b_ = nullptr; closure->Run(); EXPECT_EQ(789, a_); EXPECT_EQ(cstr, b_); @@ -338,7 +338,7 @@ TEST_F(ClosureTest, TestPermanentClosureMethod2) { EXPECT_EQ(789, a_); EXPECT_EQ(cstr, b_); a_ = 0; - b_ = NULL; + b_ = nullptr; closure->Run(); EXPECT_EQ(789, a_); EXPECT_EQ(cstr, b_); diff --git a/src/google/protobuf/stubs/io_win32.cc b/src/google/protobuf/stubs/io_win32.cc index 4407facb..f00a268f 100644 --- a/src/google/protobuf/stubs/io_win32.cc +++ b/src/google/protobuf/stubs/io_win32.cc @@ -91,7 +91,7 @@ struct CharTraits<wchar_t> { template <typename char_type> bool null_or_empty(const char_type* s) { - return s == NULL || *s == 0; + return s == nullptr || *s == 0; } // Returns true if the path starts with a drive letter, e.g. "c:". @@ -225,7 +225,7 @@ bool as_windows_path(const char* path, wstring* result) { if (!is_path_absolute(wpath.c_str())) { - int size = ::GetCurrentDirectoryW(0, NULL); + int size = ::GetCurrentDirectoryW(0, nullptr); if (size == 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER) { return false; } @@ -316,17 +316,17 @@ FILE* fopen(const char* path, const char* mode) { #ifdef SUPPORT_LONGPATHS if (null_or_empty(path)) { errno = EINVAL; - return NULL; + return nullptr; } wstring wpath; if (!as_windows_path(path, &wpath)) { errno = ENOENT; - return NULL; + return nullptr; } wstring wmode; if (!strings::utf8_to_wcs(mode, &wmode)) { errno = EINVAL; - return NULL; + return nullptr; } return ::_wfopen(wpath.c_str(), wmode.c_str()); #else @@ -365,15 +365,15 @@ bool wcs_to_mbs(const WCHAR* s, string* out, bool outUtf8) { BOOL usedDefaultChar = FALSE; SetLastError(0); int size = WideCharToMultiByte( - outUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, NULL, 0, NULL, - outUtf8 ? NULL : &usedDefaultChar); + outUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, nullptr, 0, nullptr, + outUtf8 ? nullptr : &usedDefaultChar); if ((size == 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER) || usedDefaultChar) { return false; } std::unique_ptr<CHAR[]> astr(new CHAR[size]); WideCharToMultiByte( - outUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, astr.get(), size, NULL, NULL); + outUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, astr.get(), size, nullptr, nullptr); out->assign(astr.get()); return true; } @@ -386,7 +386,7 @@ bool mbs_to_wcs(const char* s, wstring* out, bool inUtf8) { SetLastError(0); int size = - MultiByteToWideChar(inUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, NULL, 0); + MultiByteToWideChar(inUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, nullptr, 0); if (size == 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER) { return false; } diff --git a/src/google/protobuf/stubs/io_win32_unittest.cc b/src/google/protobuf/stubs/io_win32_unittest.cc index 9085ed91..6c70d461 100644 --- a/src/google/protobuf/stubs/io_win32_unittest.cc +++ b/src/google/protobuf/stubs/io_win32_unittest.cc @@ -112,7 +112,7 @@ void StripTrailingSlashes(string* str) { } bool GetEnvVarAsUtf8(const WCHAR* name, string* result) { - DWORD size = ::GetEnvironmentVariableW(name, NULL, 0); + DWORD size = ::GetEnvironmentVariableW(name, nullptr, 0); if (size > 0 && GetLastError() != ERROR_ENVVAR_NOT_FOUND) { std::unique_ptr<WCHAR[]> wcs(new WCHAR[size]); ::GetEnvironmentVariableW(name, wcs.get(), size); @@ -128,7 +128,7 @@ bool GetEnvVarAsUtf8(const WCHAR* name, string* result) { } bool GetCwdAsUtf8(string* result) { - DWORD size = ::GetCurrentDirectoryW(0, NULL); + DWORD size = ::GetCurrentDirectoryW(0, nullptr); if (size > 0) { std::unique_ptr<WCHAR[]> wcs(new WCHAR[size]); ::GetCurrentDirectoryW(size, wcs.get()); @@ -201,7 +201,7 @@ bool IoWin32Test::CreateAllUnder(wstring path) { if (path.find(L"\\\\?\\") != 0) { path = wstring(L"\\\\?\\") + path; } - if (::CreateDirectoryW(path.c_str(), NULL) || + if (::CreateDirectoryW(path.c_str(), nullptr) || GetLastError() == ERROR_ALREADY_EXISTS || GetLastError() == ERROR_ACCESS_DENIED) { return true; @@ -210,7 +210,7 @@ bool IoWin32Test::CreateAllUnder(wstring path) { size_t pos = path.find_last_of(L'\\'); if (pos != wstring::npos) { wstring parent(path, 0, pos); - if (CreateAllUnder(parent) && CreateDirectoryW(path.c_str(), NULL)) { + if (CreateAllUnder(parent) && CreateDirectoryW(path.c_str(), nullptr)) { return true; } } @@ -352,8 +352,8 @@ TEST_F(IoWin32Test, MkdirTestNonAscii) { // Create a non-ASCII path. // Ensure that we can create the directory using SetCurrentDirectoryW. - EXPECT_TRUE(CreateDirectoryW((wtest_tmpdir + L"\\1").c_str(), NULL)); - EXPECT_TRUE(CreateDirectoryW((wtest_tmpdir + L"\\1\\" + kUtf16Text).c_str(), NULL)); + EXPECT_TRUE(CreateDirectoryW((wtest_tmpdir + L"\\1").c_str(), nullptr)); + EXPECT_TRUE(CreateDirectoryW((wtest_tmpdir + L"\\1\\" + kUtf16Text).c_str(), nullptr)); // Ensure that we can create a very similarly named directory using mkdir. // We don't attemp to delete and recreate the same directory, because on // Windows, deleting files and directories seems to be asynchronous. @@ -386,7 +386,7 @@ TEST_F(IoWin32Test, ChdirTestNonAscii) { wstring wNonAscii(wtest_tmpdir + L"\\" + kUtf16Text); string nonAscii; EXPECT_TRUE(strings::wcs_to_utf8(wNonAscii.c_str(), &nonAscii)); - EXPECT_TRUE(CreateDirectoryW(wNonAscii.c_str(), NULL)); + EXPECT_TRUE(CreateDirectoryW(wNonAscii.c_str(), nullptr)); WCHAR cwd[MAX_PATH]; EXPECT_TRUE(GetCurrentDirectoryW(MAX_PATH, cwd)); // Ensure that we can cd into the path using SetCurrentDirectoryW. @@ -400,7 +400,7 @@ TEST_F(IoWin32Test, ChdirTestNonAscii) { } TEST_F(IoWin32Test, AsWindowsPathTest) { - DWORD size = GetCurrentDirectoryW(0, NULL); + DWORD size = GetCurrentDirectoryW(0, nullptr); std::unique_ptr<wchar_t[]> cwd_str(new wchar_t[size]); EXPECT_GT(GetCurrentDirectoryW(size, cwd_str.get()), 0); wstring cwd = wstring(L"\\\\?\\") + cwd_str.get(); diff --git a/src/google/protobuf/stubs/logging.h b/src/google/protobuf/stubs/logging.h index f69605d9..f7c6d6a8 100644 --- a/src/google/protobuf/stubs/logging.h +++ b/src/google/protobuf/stubs/logging.h @@ -162,7 +162,7 @@ namespace internal { template<typename T> T* CheckNotNull(const char* /* file */, int /* line */, const char* name, T* val) { - if (val == NULL) { + if (val == nullptr) { GOOGLE_LOG(FATAL) << name; } return val; @@ -170,7 +170,7 @@ T* CheckNotNull(const char* /* file */, int /* line */, } // namespace internal #define GOOGLE_CHECK_NOTNULL(A) \ ::google::protobuf::internal::CheckNotNull(\ - __FILE__, __LINE__, "'" #A "' must not be NULL", (A)) + __FILE__, __LINE__, "'" #A "' must not be nullptr", (A)) #ifdef NDEBUG @@ -208,7 +208,7 @@ typedef void LogHandler(LogLevel level, const char* filename, int line, // also help end users figure out a problem. If you would prefer that // these messages be sent somewhere other than stderr, call SetLogHandler() // to set your own handler. This returns the old handler. Set the handler -// to NULL to ignore log messages (but see also LogSilencer, below). +// to nullptr to ignore log messages (but see also LogSilencer, below). // // Obviously, SetLogHandler is not thread-safe. You should only call it // at initialization time, and probably not from library code. If you diff --git a/src/google/protobuf/stubs/map_util.h b/src/google/protobuf/stubs/map_util.h index 3e6d381f..2313e1f5 100644 --- a/src/google/protobuf/stubs/map_util.h +++ b/src/google/protobuf/stubs/map_util.h @@ -131,7 +131,7 @@ FindWithDefault(const Collection& collection, } // Returns a pointer to the const value associated with the given key if it -// exists, or NULL otherwise. +// exists, or nullptr otherwise. template <class Collection> const typename Collection::value_type::second_type* FindOrNull(const Collection& collection, @@ -156,11 +156,11 @@ FindOrNull(Collection& collection, // NOLINT } // Returns the pointer value associated with the given key. If none is found, -// NULL is returned. The function is designed to be used with a map of keys to +// nullptr is returned. The function is designed to be used with a map of keys to // pointers. // // This function does not distinguish between a missing key and a key mapped -// to a NULL value. +// to nullptr. template <class Collection> typename Collection::value_type::second_type FindPtrOrNull(const Collection& collection, @@ -188,7 +188,7 @@ FindPtrOrNull(Collection& collection, // NOLINT } // Finds the pointer value associated with the given key in a map whose values -// are linked_ptrs. Returns NULL if key is not found. +// are linked_ptrs. Returns nullptr if key is not found. template <class Collection> typename Collection::value_type::second_type::element_type* FindLinkedPtrOrNull(const Collection& collection, @@ -215,7 +215,7 @@ FindLinkedPtrOrDie(const Collection& collection, } // Finds the value associated with the given key and copies it to *value (if not -// NULL). Returns false if the key was not found, true otherwise. +// nullptr). Returns false if the key was not found, true otherwise. template <class Collection, class Key, class Value> bool FindCopy(const Collection& collection, const Key& key, @@ -447,7 +447,7 @@ LookupOrInsertNew(Collection* const collection, std::pair<typename Collection::iterator, bool> ret = collection->insert(typename Collection::value_type( key, - static_cast<typename Collection::value_type::second_type>(NULL))); + static_cast<typename Collection::value_type::second_type>(nullptr))); if (ret.second) { ret.first->second = new Element(); } @@ -466,7 +466,7 @@ LookupOrInsertNew(Collection* const collection, std::pair<typename Collection::iterator, bool> ret = collection->insert(typename Collection::value_type( key, - static_cast<typename Collection::value_type::second_type>(NULL))); + static_cast<typename Collection::value_type::second_type>(nullptr))); if (ret.second) { ret.first->second = new Element(arg); } @@ -612,7 +612,7 @@ bool UpdateReturnCopy(Collection* const collection, return false; } -// Tries to insert the given key-value pair into the collection. Returns NULL if +// Tries to insert the given key-value pair into the collection. Returns nullptr if // the insert succeeds. Otherwise, returns a pointer to the existing value. // // This complements UpdateReturnCopy in that it allows to update only after @@ -625,7 +625,7 @@ InsertOrReturnExisting(Collection* const collection, const typename Collection::value_type& vt) { std::pair<typename Collection::iterator, bool> ret = collection->insert(vt); if (ret.second) { - return NULL; // Inserted, no existing previous value. + return nullptr; // Inserted, no existing previous value. } else { return &ret.first->second; // Return address of already existing value. } @@ -644,7 +644,7 @@ InsertOrReturnExisting( // Erases the collection item identified by the given key, and returns the value // associated with that key. It is assumed that the value (i.e., the -// mapped_type) is a pointer. Returns NULL if the key was not found in the +// mapped_type) is a pointer. Returns nullptr if the key was not found in the // collection. // // Examples: @@ -665,7 +665,7 @@ typename Collection::value_type::second_type EraseKeyReturnValuePtr( const typename Collection::value_type::first_type& key) { typename Collection::iterator it = collection->find(key); if (it == collection->end()) { - return NULL; + return nullptr; } typename Collection::value_type::second_type v = it->second; collection->erase(it); @@ -679,7 +679,7 @@ typename Collection::value_type::second_type EraseKeyReturnValuePtr( template <class MapContainer, class KeyContainer> void InsertKeysFromMap(const MapContainer& map_container, KeyContainer* key_container) { - GOOGLE_CHECK(key_container != NULL); + GOOGLE_CHECK(key_container != nullptr); for (typename MapContainer::const_iterator it = map_container.begin(); it != map_container.end(); ++it) { key_container->insert(it->first); @@ -693,7 +693,7 @@ void InsertKeysFromMap(const MapContainer& map_container, template <class MapContainer, class KeyContainer> void AppendKeysFromMap(const MapContainer& map_container, KeyContainer* key_container) { - GOOGLE_CHECK(key_container != NULL); + GOOGLE_CHECK(key_container != nullptr); for (typename MapContainer::const_iterator it = map_container.begin(); it != map_container.end(); ++it) { key_container->push_back(it->first); @@ -710,7 +710,7 @@ void AppendKeysFromMap(const MapContainer& map_container, template <class MapContainer, class KeyType> void AppendKeysFromMap(const MapContainer& map_container, std::vector<KeyType>* key_container) { - GOOGLE_CHECK(key_container != NULL); + GOOGLE_CHECK(key_container != nullptr); // We now have the opportunity to call reserve(). Calling reserve() every // time is a bad idea for some use cases: libstdc++'s implementation of // vector<>::reserve() resizes the vector's backing store to exactly the @@ -737,7 +737,7 @@ void AppendKeysFromMap(const MapContainer& map_container, template <class MapContainer, class ValueContainer> void AppendValuesFromMap(const MapContainer& map_container, ValueContainer* value_container) { - GOOGLE_CHECK(value_container != NULL); + GOOGLE_CHECK(value_container != nullptr); for (typename MapContainer::const_iterator it = map_container.begin(); it != map_container.end(); ++it) { value_container->push_back(it->second); @@ -754,7 +754,7 @@ void AppendValuesFromMap(const MapContainer& map_container, template <class MapContainer, class ValueType> void AppendValuesFromMap(const MapContainer& map_container, std::vector<ValueType>* value_container) { - GOOGLE_CHECK(value_container != NULL); + GOOGLE_CHECK(value_container != nullptr); // See AppendKeysFromMap for why this is done. if (value_container->empty()) { value_container->reserve(map_container.size()); diff --git a/src/google/protobuf/stubs/mutex.h b/src/google/protobuf/stubs/mutex.h index 47edb7a3..2b1aab87 100644 --- a/src/google/protobuf/stubs/mutex.h +++ b/src/google/protobuf/stubs/mutex.h @@ -86,12 +86,12 @@ class LIBPROTOBUF_EXPORT MutexLock { typedef MutexLock ReaderMutexLock; typedef MutexLock WriterMutexLock; -// MutexLockMaybe is like MutexLock, but is a no-op when mu is NULL. +// MutexLockMaybe is like MutexLock, but is a no-op when mu is nullptr. class LIBPROTOBUF_EXPORT MutexLockMaybe { public: explicit MutexLockMaybe(Mutex *mu) : - mu_(mu) { if (this->mu_ != NULL) { this->mu_->Lock(); } } - ~MutexLockMaybe() { if (this->mu_ != NULL) { this->mu_->Unlock(); } } + mu_(mu) { if (this->mu_ != nullptr) { this->mu_->Lock(); } } + ~MutexLockMaybe() { if (this->mu_ != nullptr) { this->mu_->Unlock(); } } private: Mutex *const mu_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MutexLockMaybe); @@ -109,7 +109,7 @@ class ThreadLocalStorage { } T* Get() { T* result = static_cast<T*>(pthread_getspecific(key_)); - if (result == NULL) { + if (result == nullptr) { result = new T(); pthread_setspecific(key_, result); } diff --git a/src/google/protobuf/stubs/singleton.h b/src/google/protobuf/stubs/singleton.h index 2e6ccbdb..5f0f4610 100644 --- a/src/google/protobuf/stubs/singleton.h +++ b/src/google/protobuf/stubs/singleton.h @@ -45,7 +45,7 @@ class Singleton { } static void ShutDown() { delete instance_; - instance_ = NULL; + instance_ = nullptr; } private: static void Init() { @@ -59,7 +59,7 @@ template<typename T> ProtobufOnceType Singleton<T>::once_; template<typename T> -T* Singleton<T>::instance_ = NULL; +T* Singleton<T>::instance_ = nullptr; } // namespace internal } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/stubs/statusor.h b/src/google/protobuf/stubs/statusor.h index 29f869ad..b1c1e6b4 100644 --- a/src/google/protobuf/stubs/statusor.h +++ b/src/google/protobuf/stubs/statusor.h @@ -33,7 +33,7 @@ // usable value, or an error Status explaining why such a value is // not present. To this end, StatusOr<T> does not allow its Status // value to be Status::OK. Further, StatusOr<T*> does not allow the -// contained pointer to be NULL. +// contained pointer to be nullptr. // // The primary use-case for StatusOr<T> is as the return value of a // function which may fail. @@ -114,15 +114,15 @@ class StatusOr { StatusOr(const Status& status); // NOLINT // Construct a new StatusOr with the given value. If T is a plain pointer, - // value must not be NULL. After calling this constructor, calls to + // value must not be nullptr. After calling this constructor, calls to // ValueOrDie() will succeed, and calls to status() will return OK. // // NOTE: Not explicit - we want to use StatusOr<T> as a return type // so it is convenient and sensible to be able to do 'return T()' // when when the return type is StatusOr<T>. // - // REQUIRES: if T is a plain pointer, value != NULL. This requirement is - // DCHECKed. In optimized builds, passing a NULL pointer here will have + // REQUIRES: if T is a plain pointer, value != nullptr. This requirement is + // DCHECKed. In optimized builds, passing a null pointer here will have // the effect of passing PosixErrorSpace::EINVAL as a fallback. StatusOr(const T& value); // NOLINT @@ -174,13 +174,13 @@ class LIBPROTOBUF_EXPORT StatusOrHelper { template<typename T> struct StatusOrHelper::Specialize { - // For non-pointer T, a reference can never be NULL. + // For non-pointer T, a reference can never be nullptr. static inline bool IsValueNull(const T& t) { return false; } }; template<typename T> struct StatusOrHelper::Specialize<T*> { - static inline bool IsValueNull(const T* t) { return t == NULL; } + static inline bool IsValueNull(const T* t) { return t == nullptr; } }; } // namespace internal @@ -202,7 +202,7 @@ inline StatusOr<T>::StatusOr(const Status& status) { template<typename T> inline StatusOr<T>::StatusOr(const T& value) { if (internal::StatusOrHelper::Specialize<T>::IsValueNull(value)) { - status_ = Status(error::INTERNAL, "NULL is not a vaild argument."); + status_ = Status(error::INTERNAL, "nullptr is not a vaild argument."); } else { status_ = Status::OK; value_ = value; diff --git a/src/google/protobuf/stubs/stl_util.h b/src/google/protobuf/stubs/stl_util.h index 9e4c82a4..2c265e92 100644 --- a/src/google/protobuf/stubs/stl_util.h +++ b/src/google/protobuf/stubs/stl_util.h @@ -82,7 +82,7 @@ inline void STLStringResizeUninitialized(string* s, size_t new_size) { // already work on all current implementations. inline char* string_as_array(string* str) { // DO NOT USE const_cast<char*>(str->data())! See the unittest for why. - return str->empty() ? NULL : &*str->begin(); + return str->empty() ? nullptr : &*str->begin(); } // STLDeleteElements() deletes all the elements in an STL container and clears @@ -90,7 +90,7 @@ inline char* string_as_array(string* str) { // hash_set, or any other STL container which defines sensible begin(), end(), // and clear() methods. // -// If container is NULL, this function is a no-op. +// If container is nullptr, this function is a no-op. // // As an alternative to calling STLDeleteElements() directly, consider // ElementDeleter (defined below), which ensures that your container's elements @@ -104,7 +104,7 @@ void STLDeleteElements(T *container) { // Given an STL container consisting of (key, value) pairs, STLDeleteValues // deletes all the "value" components and clears the container. Does nothing -// in the case it's given a NULL pointer. +// in the case it's given a null pointer. template <class T> void STLDeleteValues(T *v) { diff --git a/src/google/protobuf/stubs/stringpiece.cc b/src/google/protobuf/stubs/stringpiece.cc index 989474b7..96a7d3da 100644 --- a/src/google/protobuf/stubs/stringpiece.cc +++ b/src/google/protobuf/stubs/stringpiece.cc @@ -115,7 +115,7 @@ stringpiece_ssize_type StringPiece::find(char c, size_type pos) const { } const char* result = static_cast<const char*>( memchr(ptr_ + pos, c, length_ - pos)); - return result != NULL ? result - ptr_ : npos; + return result != nullptr ? result - ptr_ : npos; } stringpiece_ssize_type StringPiece::rfind(StringPiece s, size_type pos) const { diff --git a/src/google/protobuf/stubs/stringpiece.h b/src/google/protobuf/stubs/stringpiece.h index c7bdd810..6ab985cc 100644 --- a/src/google/protobuf/stubs/stringpiece.h +++ b/src/google/protobuf/stubs/stringpiece.h @@ -76,30 +76,30 @@ // // There are several ways to create a null StringPiece: // StringPiece() -// StringPiece(NULL) -// StringPiece(NULL, 0) -// For all of the above, sp.data() == NULL, sp.length() == 0, +// StringPiece(nullptr) +// StringPiece(nullptr, 0) +// For all of the above, sp.data() == nullptr, sp.length() == 0, // and sp.empty() == true. Also, if you create a StringPiece with -// a non-NULL pointer then sp.data() != NULL. Once created, -// sp.data() will stay either NULL or not-NULL, except if you call +// a non-null pointer then sp.data() != nullptr. Once created, +// sp.data() will stay either nullptr or not-nullptr, except if you call // sp.clear() or sp.set(). // -// Thus, you can use StringPiece(NULL) to signal an out-of-band value +// Thus, you can use StringPiece(nullptr) to signal an out-of-band value // that is different from other StringPiece values. This is similar -// to the way that const char* p1 = NULL; is different from +// to the way that const char* p1 = nullptr; is different from // const char* p2 = "";. // // There are many ways to create an empty StringPiece: // StringPiece() -// StringPiece(NULL) -// StringPiece(NULL, 0) +// StringPiece(nullptr) +// StringPiece(nullptr, 0) // StringPiece("") // StringPiece("", 0) // StringPiece("abcdef", 0) // StringPiece("abcdef"+6, 0) // For all of the above, sp.length() will be 0 and sp.empty() will be true. -// For some empty StringPiece values, sp.data() will be NULL. -// For some empty StringPiece values, sp.data() will not be NULL. +// For some empty StringPiece values, sp.data() will be nullptr. +// For some empty StringPiece values, sp.data() will not be nullptr. // // Be careful not to confuse: null StringPiece and empty StringPiece. // The set of empty StringPieces properly includes the set of null StringPieces. @@ -109,20 +109,20 @@ // All empty StringPiece values compare equal to each other. // Even a null StringPieces compares equal to a non-null empty StringPiece: // StringPiece() == StringPiece("", 0) -// StringPiece(NULL) == StringPiece("abc", 0) -// StringPiece(NULL, 0) == StringPiece("abcdef"+6, 0) +// StringPiece(nullptr) == StringPiece("abc", 0) +// StringPiece(nullptr, 0) == StringPiece("abcdef"+6, 0) // // Look carefully at this example: -// StringPiece("") == NULL +// StringPiece("") == nullptr // True or false? TRUE, because StringPiece::operator== converts -// the right-hand side from NULL to StringPiece(NULL), +// the right-hand side from nullptr to StringPiece(nullptr), // and then compares two zero-length spans of characters. // However, we are working to make this example produce a compile error. // // Suppose you want to write: -// bool TestWhat?(StringPiece sp) { return sp == NULL; } // BAD +// bool TestWhat?(StringPiece sp) { return sp == nullptr; } // BAD // Do not do that. Write one of these instead: -// bool TestNull(StringPiece sp) { return sp.data() == NULL; } +// bool TestNull(StringPiece sp) { return sp.data() == nullptr; } // bool TestEmpty(StringPiece sp) { return sp.empty(); } // The intent of TestWhat? is unclear. Did you mean TestNull or TestEmpty? // Right now, TestWhat? behaves likes TestEmpty. @@ -207,11 +207,11 @@ class LIBPROTOBUF_EXPORT StringPiece { // // Style guide exception granted: // http://goto/style-guide-exception-20978288 - StringPiece() : ptr_(NULL), length_(0) {} + StringPiece() : ptr_(nullptr), length_(0) {} StringPiece(const char* str) // NOLINT(runtime/explicit) : ptr_(str), length_(0) { - if (str != NULL) { + if (str != nullptr) { length_ = CheckedSsizeTFromSizeT(strlen(str)); } } @@ -248,7 +248,7 @@ class LIBPROTOBUF_EXPORT StringPiece { bool empty() const { return length_ == 0; } void clear() { - ptr_ = NULL; + ptr_ = nullptr; length_ = 0; } @@ -260,7 +260,7 @@ class LIBPROTOBUF_EXPORT StringPiece { void set(const char* str) { ptr_ = str; - if (str != NULL) + if (str != nullptr) length_ = CheckedSsizeTFromSizeT(strlen(str)); else length_ = 0; @@ -309,7 +309,7 @@ class LIBPROTOBUF_EXPORT StringPiece { // for a StringPiece be called "as_string()". We also leave the // "as_string()" method defined here for existing code. string ToString() const { - if (ptr_ == NULL) return string(); + if (ptr_ == nullptr) return string(); return string(data(), static_cast<size_type>(size())); } diff --git a/src/google/protobuf/stubs/stringpiece_unittest.cc b/src/google/protobuf/stubs/stringpiece_unittest.cc index a6a87595..d9a32d03 100644 --- a/src/google/protobuf/stubs/stringpiece_unittest.cc +++ b/src/google/protobuf/stubs/stringpiece_unittest.cc @@ -46,7 +46,7 @@ TEST(StringPiece, Ctor) { { // Null. StringPiece s10; - EXPECT_TRUE(s10.data() == NULL); + EXPECT_TRUE(s10.data() == nullptr); EXPECT_EQ(0, s10.length()); } @@ -148,8 +148,8 @@ TEST(StringPiece, ComparisonOperators) { EXPECT_EQ(result, StringPiece((x)).compare(StringPiece((y))) op 0) COMPARE(true, ==, "", ""); - COMPARE(true, ==, "", NULL); - COMPARE(true, ==, NULL, ""); + COMPARE(true, ==, "", nullptr); + COMPARE(true, ==, nullptr, ""); COMPARE(true, ==, "a", "a"); COMPARE(true, ==, "aa", "aa"); COMPARE(false, ==, "a", ""); @@ -253,7 +253,7 @@ TEST(StringPiece, STL1) { EXPECT_EQ(*d.data(), 'f'); EXPECT_EQ(d.data()[5], 'r'); - EXPECT_TRUE(e.data() == NULL); + EXPECT_TRUE(e.data() == nullptr); EXPECT_EQ(*a.begin(), 'a'); EXPECT_EQ(*(b.begin() + 2), 'c'); @@ -312,7 +312,7 @@ TEST(StringPiece, STL2) { d.clear(); EXPECT_EQ(d.size(), 0); EXPECT_TRUE(d.empty()); - EXPECT_TRUE(d.data() == NULL); + EXPECT_TRUE(d.data() == nullptr); EXPECT_TRUE(d.begin() == d.end()); EXPECT_EQ(StringPiece::npos, string::npos); @@ -707,17 +707,17 @@ TEST(StringPiece, Contains) { EXPECT_TRUE(!a.contains(d)); } -TEST(StringPiece, NULLInput) { +TEST(StringPiece, NullInput) { // we used to crash here, but now we don't. - StringPiece s(NULL); - EXPECT_EQ(s.data(), (const char*)NULL); + StringPiece s(nullptr); + EXPECT_EQ(s.data(), (const char*)nullptr); EXPECT_EQ(s.size(), 0); - s.set(NULL); - EXPECT_EQ(s.data(), (const char*)NULL); + s.set(nullptr); + EXPECT_EQ(s.data(), (const char*)nullptr); EXPECT_EQ(s.size(), 0); - // .ToString() on a StringPiece with NULL should produce the empty string. + // .ToString() on a StringPiece with nullptr should produce the empty string. EXPECT_EQ("", s.ToString()); EXPECT_EQ("", s.as_string()); } diff --git a/src/google/protobuf/stubs/stringprintf.cc b/src/google/protobuf/stubs/stringprintf.cc index d98b9b87..820bfe7f 100644 --- a/src/google/protobuf/stubs/stringprintf.cc +++ b/src/google/protobuf/stubs/stringprintf.cc @@ -76,7 +76,7 @@ void StringAppendV(string* dst, const char* format, va_list ap) { // Error or MSVC running out of space. MSVC 8.0 and higher // can be asked about space needed with the special idiom below: va_copy(backup_ap, ap); - result = vsnprintf(NULL, 0, format, backup_ap); + result = vsnprintf(nullptr, 0, format, backup_ap); va_end(backup_ap); } diff --git a/src/google/protobuf/stubs/stringprintf_unittest.cc b/src/google/protobuf/stubs/stringprintf_unittest.cc index 15895e59..7fcbf500 100644 --- a/src/google/protobuf/stubs/stringprintf_unittest.cc +++ b/src/google/protobuf/stubs/stringprintf_unittest.cc @@ -91,7 +91,7 @@ TEST(StringPrintfTest, Multibyte) { // out of memory while trying to determine destination buffer size. // see b/4194543. - char* old_locale = setlocale(LC_CTYPE, NULL); + char* old_locale = setlocale(LC_CTYPE, nullptr); // Push locale with multibyte mode setlocale(LC_CTYPE, "en_US.utf8"); @@ -120,7 +120,7 @@ TEST(StringPrintfTest, Multibyte) { TEST(StringPrintfTest, NoMultibyte) { // No multibyte handling, but the string contains funny chars. - char* old_locale = setlocale(LC_CTYPE, NULL); + char* old_locale = setlocale(LC_CTYPE, nullptr); setlocale(LC_CTYPE, "POSIX"); string value = StringPrintf("%.*s", 3, "\375\067s"); setlocale(LC_CTYPE, old_locale); diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc index 65f22a96..5bf9f2e6 100644 --- a/src/google/protobuf/stubs/strutil.cc +++ b/src/google/protobuf/stubs/strutil.cc @@ -87,7 +87,7 @@ void StripString(string* s, const char* remove, char replacewith) { const char * str_start = s->c_str(); const char * str = str_start; for (str = strpbrk(str, remove); - str != NULL; + str != nullptr; str = strpbrk(str + 1, remove)) { (*s)[str - str_start] = replacewith; } @@ -102,7 +102,7 @@ void ReplaceCharacters(string *s, const char *remove, char replacewith) { const char *str_start = s->c_str(); const char *str = str_start; for (str = strpbrk(str, remove); - str != NULL; + str != nullptr; str = strpbrk(str + 1, remove)) { (*s)[str - str_start] = replacewith; } @@ -280,7 +280,7 @@ static void JoinStringsIterator(const ITERATOR& start, const ITERATOR& end, const char* delim, string* result) { - GOOGLE_CHECK(result != NULL); + GOOGLE_CHECK(result != nullptr); result->clear(); int delim_length = strlen(delim); @@ -318,7 +318,7 @@ void JoinStrings(const std::vector<string>& components, // result is truncated to 8 bits. // // The second call stores its errors in a supplied string vector. -// If the string vector pointer is NULL, it reports the errors with LOG(). +// If the string vector pointer is nullptr, it reports the errors with LOG(). // ---------------------------------------------------------------------- #define IS_OCTAL_DIGIT(c) (((c) >= '0') && ((c) <= '7')) @@ -328,12 +328,12 @@ void JoinStrings(const std::vector<string>& components, #define LOG_STRING(LEVEL, VECTOR) GOOGLE_LOG_IF(LEVEL, false) int UnescapeCEscapeSequences(const char* source, char* dest) { - return UnescapeCEscapeSequences(source, dest, NULL); + return UnescapeCEscapeSequences(source, dest, nullptr); } int UnescapeCEscapeSequences(const char* source, char* dest, std::vector<string> *errors) { - GOOGLE_DCHECK(errors == NULL) << "Error reporting not implemented."; + GOOGLE_DCHECK(errors == nullptr) << "Error reporting not implemented."; char* d = dest; const char* p = source; @@ -458,13 +458,13 @@ int UnescapeCEscapeSequences(const char* source, char* dest, // to be the same. // // The second call stores its errors in a supplied string vector. -// If the string vector pointer is NULL, it reports the errors with LOG(). +// If the string vector pointer is nullptr, it reports the errors with LOG(). // // In the first and second calls, the length of dest is returned. In the // the third call, the new string is returned. // ---------------------------------------------------------------------- int UnescapeCEscapeString(const string& src, string* dest) { - return UnescapeCEscapeString(src, dest, NULL); + return UnescapeCEscapeString(src, dest, nullptr); } int UnescapeCEscapeString(const string& src, string* dest, @@ -478,7 +478,7 @@ int UnescapeCEscapeString(const string& src, string* dest, string UnescapeCEscapeString(const string& src) { std::unique_ptr<char[]> unescaped(new char[src.size() + 1]); - int len = UnescapeCEscapeSequences(src.c_str(), unescaped.get(), NULL); + int len = UnescapeCEscapeSequences(src.c_str(), unescaped.get(), nullptr); return string(unescaped.get(), len); } @@ -982,7 +982,7 @@ static const char two_ASCII_digits[100][2] = { char* FastUInt32ToBufferLeft(uint32 u, char* buffer) { uint32 digits; - const char *ASCII_digits = NULL; + const char *ASCII_digits = nullptr; // The idea of this implementation is to trim the number of divides to as few // as possible by using multiplication and subtraction rather than mod (%), // and by outputting two digits at a time rather than one. @@ -1073,7 +1073,7 @@ char* FastInt32ToBufferLeft(int32 i, char* buffer) { char* FastUInt64ToBufferLeft(uint64 u64, char* buffer) { int digits; - const char *ASCII_digits = NULL; + const char *ASCII_digits = nullptr; uint32 u = static_cast<uint32>(u64); if (u == u64) return FastUInt32ToBufferLeft(u, buffer); @@ -1231,7 +1231,7 @@ static inline bool IsValidFloatChar(char c) { void DelocalizeRadix(char* buffer) { // Fast check: if the buffer has a normal decimal point, assume no // translation is needed. - if (strchr(buffer, '.') != NULL) return; + if (strchr(buffer, '.') != nullptr) return; // Find the first unknown character. while (IsValidFloatChar(*buffer)) ++buffer; @@ -1286,7 +1286,7 @@ char* DoubleToBuffer(double value, char* buffer) { // of a double. This long double may have extra bits that make it compare // unequal to "value" even though it would be exactly equal if it were // truncated to a double. - volatile double parsed_value = strtod(buffer, NULL); + volatile double parsed_value = strtod(buffer, nullptr); if (parsed_value != value) { int snprintf_result = snprintf(buffer, kDoubleToBufferSize, "%.*g", DBL_DIG+2, value); @@ -1318,7 +1318,7 @@ inline bool CaseEqual(StringPiece s1, StringPiece s2) { } bool safe_strtob(StringPiece str, bool* value) { - GOOGLE_CHECK(value != NULL) << "NULL output boolean given."; + GOOGLE_CHECK(value != nullptr) << "nullptr output boolean given."; if (CaseEqual(str, "true") || CaseEqual(str, "t") || CaseEqual(str, "yes") || CaseEqual(str, "y") || CaseEqual(str, "1")) { @@ -1619,7 +1619,7 @@ void StrAppend(string *result, int GlobalReplaceSubstring(const string& substring, const string& replacement, string* s) { - GOOGLE_CHECK(s != NULL); + GOOGLE_CHECK(s != nullptr); if (s->empty() || substring.empty()) return 0; string tmp; @@ -1969,7 +1969,7 @@ int Base64UnescapeInternal(const char *src_param, int szsrc, // for (i = 0; i < 255; i += 8) { // for (j = i; j < i + 8; j++) { // pos = strchr(Base64, j); -// if ((pos == NULL) || (j == 0)) +// if ((pos == nullptr) || (j == 0)) // idx = -1; // else // idx = pos - Base64; diff --git a/src/google/protobuf/stubs/strutil.h b/src/google/protobuf/stubs/strutil.h index d16ffc34..d6bcbc32 100644 --- a/src/google/protobuf/stubs/strutil.h +++ b/src/google/protobuf/stubs/strutil.h @@ -285,7 +285,7 @@ inline string JoinStrings(const std::vector<string>& components, // // Errors: In the first form of the call, errors are reported with // LOG(ERROR). The same is true for the second form of the call if -// the pointer to the string std::vector is NULL; otherwise, error +// the pointer to the string std::vector is nullptr; otherwise, error // messages are stored in the std::vector. In either case, the effect on // the dest array is not defined, but rest of the source will be // processed. @@ -304,7 +304,7 @@ LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest, // to be the same. // // The second call stores its errors in a supplied string vector. -// If the string vector pointer is NULL, it reports the errors with LOG(). +// If the string vector pointer is nullptr, it reports the errors with LOG(). // // In the first and second calls, the length of dest is returned. In the // the third call, the new string is returned. diff --git a/src/google/protobuf/stubs/strutil_unittest.cc b/src/google/protobuf/stubs/strutil_unittest.cc index 6bf0f598..9460a665 100644 --- a/src/google/protobuf/stubs/strutil_unittest.cc +++ b/src/google/protobuf/stubs/strutil_unittest.cc @@ -50,18 +50,18 @@ namespace { TEST(StringUtilityTest, ImmuneToLocales) { // Remember the old locale. - char* old_locale_cstr = setlocale(LC_NUMERIC, NULL); - ASSERT_TRUE(old_locale_cstr != NULL); + char* old_locale_cstr = setlocale(LC_NUMERIC, nullptr); + ASSERT_TRUE(old_locale_cstr != nullptr); string old_locale = old_locale_cstr; // Set the locale to "C". - ASSERT_TRUE(setlocale(LC_NUMERIC, "C") != NULL); + ASSERT_TRUE(setlocale(LC_NUMERIC, "C") != nullptr); EXPECT_EQ("1.5", SimpleDtoa(1.5)); EXPECT_EQ("1.5", SimpleFtoa(1.5)); - if (setlocale(LC_NUMERIC, "es_ES") == NULL && - setlocale(LC_NUMERIC, "es_ES.utf8") == NULL) { + if (setlocale(LC_NUMERIC, "es_ES") == nullptr && + setlocale(LC_NUMERIC, "es_ES.utf8") == nullptr) { // Some systems may not have the desired locale available. GOOGLE_LOG(WARNING) << "Couldn't set locale to es_ES. Skipping this test."; diff --git a/src/google/protobuf/stubs/substitute.cc b/src/google/protobuf/stubs/substitute.cc index 7194a5b1..1ac9ab45 100644 --- a/src/google/protobuf/stubs/substitute.cc +++ b/src/google/protobuf/stubs/substitute.cc @@ -44,7 +44,7 @@ using internal::SubstituteArg; // to Substitute(). static int CountSubstituteArgs(const SubstituteArg* const* args_array) { int count = 0; - while (args_array[count] != NULL && args_array[count]->size() != -1) { + while (args_array[count] != nullptr && args_array[count]->size() != -1) { ++count; } return count; @@ -71,7 +71,7 @@ void SubstituteAndAppend( const SubstituteArg& arg6, const SubstituteArg& arg7, const SubstituteArg& arg8, const SubstituteArg& arg9) { const SubstituteArg* const args_array[] = { - &arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, NULL + &arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, nullptr }; // Determine total size needed. diff --git a/src/google/protobuf/stubs/substitute.h b/src/google/protobuf/stubs/substitute.h index 7ee442af..e05ca8d8 100644 --- a/src/google/protobuf/stubs/substitute.h +++ b/src/google/protobuf/stubs/substitute.h @@ -93,7 +93,7 @@ class SubstituteArg { // Indicates that no argument was given. inline explicit SubstituteArg() - : text_(NULL), size_(-1) {} + : text_(nullptr), size_(-1) {} // Primitives // We don't overload for signed and unsigned char because if people are diff --git a/src/google/protobuf/stubs/time.cc b/src/google/protobuf/stubs/time.cc index 6def637e..a1e5e1e2 100644 --- a/src/google/protobuf/stubs/time.cc +++ b/src/google/protobuf/stubs/time.cc @@ -142,12 +142,12 @@ string FormatNanos(int32 nanos) { // Parses an integer from a null-terminated char sequence. The method // consumes at most "width" chars. Returns a pointer after the consumed -// integer, or NULL if the data does not start with an integer or the +// integer, or nullptr if the data does not start with an integer or the // integer value does not fall in the range of [min_value, max_value]. const char* ParseInt(const char* data, int width, int min_value, int max_value, int* result) { if (!ascii_isdigit(*data)) { - return NULL; + return nullptr; } int value = 0; for (int i = 0; i < width; ++i, ++data) { @@ -161,7 +161,7 @@ const char* ParseInt(const char* data, int width, int min_value, *result = value; return data; } else { - return NULL; + return nullptr; } } @@ -169,7 +169,7 @@ const char* ParseInt(const char* data, int width, int min_value, // "010" will be parsed to 10000000 nanos. const char* ParseNanos(const char* data, int32* nanos) { if (!ascii_isdigit(*data)) { - return NULL; + return nullptr; } int value = 0; int len = 0; @@ -193,15 +193,15 @@ const char* ParseNanos(const char* data, int32* nanos) { const char* ParseTimezoneOffset(const char* data, int64* offset) { // Accept format "HH:MM". E.g., "08:00" int hour; - if ((data = ParseInt(data, 2, 0, 23, &hour)) == NULL) { - return NULL; + if ((data = ParseInt(data, 2, 0, 23, &hour)) == nullptr) { + return nullptr; } if (*data++ != ':') { - return NULL; + return nullptr; } int minute; - if ((data = ParseInt(data, 2, 0, 59, &minute)) == NULL) { - return NULL; + if ((data = ParseInt(data, 2, 0, 59, &minute)) == nullptr) { + return nullptr; } *offset = (hour * 60 + minute) * 60; return data; @@ -264,7 +264,7 @@ bool DateTimeToSeconds(const DateTime& time, int64* seconds) { void GetCurrentTime(int64* seconds, int32* nanos) { // TODO(xiaofeng): Improve the accuracy of this implementation (or just // remove this method from protobuf). - *seconds = time(NULL); + *seconds = time(nullptr); *nanos = 0; } @@ -290,37 +290,37 @@ bool ParseTime(const string& value, int64* seconds, int32* nanos) { // With UTC offset: 2015-05-20T13:29:35.120-08:00 // Parse year - if ((data = ParseInt(data, 4, 1, 9999, &time.year)) == NULL) { + if ((data = ParseInt(data, 4, 1, 9999, &time.year)) == nullptr) { return false; } // Expect '-' if (*data++ != '-') return false; // Parse month - if ((data = ParseInt(data, 2, 1, 12, &time.month)) == NULL) { + if ((data = ParseInt(data, 2, 1, 12, &time.month)) == nullptr) { return false; } // Expect '-' if (*data++ != '-') return false; // Parse day - if ((data = ParseInt(data, 2, 1, 31, &time.day)) == NULL) { + if ((data = ParseInt(data, 2, 1, 31, &time.day)) == nullptr) { return false; } // Expect 'T' if (*data++ != 'T') return false; // Parse hour - if ((data = ParseInt(data, 2, 0, 23, &time.hour)) == NULL) { + if ((data = ParseInt(data, 2, 0, 23, &time.hour)) == nullptr) { return false; } // Expect ':' if (*data++ != ':') return false; // Parse minute - if ((data = ParseInt(data, 2, 0, 59, &time.minute)) == NULL) { + if ((data = ParseInt(data, 2, 0, 59, &time.minute)) == nullptr) { return false; } // Expect ':' if (*data++ != ':') return false; // Parse second - if ((data = ParseInt(data, 2, 0, 59, &time.second)) == NULL) { + if ((data = ParseInt(data, 2, 0, 59, &time.second)) == nullptr) { return false; } if (!DateTimeToSeconds(time, seconds)) { @@ -330,7 +330,7 @@ bool ParseTime(const string& value, int64* seconds, int32* nanos) { if (*data == '.') { ++data; // Parse nanoseconds. - if ((data = ParseNanos(data, nanos)) == NULL) { + if ((data = ParseNanos(data, nanos)) == nullptr) { return false; } } else { @@ -342,14 +342,14 @@ bool ParseTime(const string& value, int64* seconds, int32* nanos) { } else if (*data == '+') { ++data; int64 offset; - if ((data = ParseTimezoneOffset(data, &offset)) == NULL) { + if ((data = ParseTimezoneOffset(data, &offset)) == nullptr) { return false; } *seconds -= offset; } else if (*data == '-') { ++data; int64 offset; - if ((data = ParseTimezoneOffset(data, &offset)) == NULL) { + if ((data = ParseTimezoneOffset(data, &offset)) == nullptr) { return false; } *seconds += offset; diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index 2800ecdd..88b22b23 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index dfecb835..b155a8fd 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index a7b38162..7e3b7d40 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -507,18 +507,21 @@ build_php7.1() { phpunit popd pushd conformance - # TODO(teboring): Add it back - # make test_php + make test_php popd } build_php7.1_c() { + ENABLE_CONFORMANCE_TEST=$1 use_php 7.1 wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit cd php/tests && /bin/bash ./test.sh 7.1 && cd ../.. - pushd conformance - # make test_php_c - popd + if [ "$ENABLE_CONFORMANCE_TEST" = "true" ] + then + pushd conformance + make test_php_c + popd + fi } build_php7.1_zts_c() { @@ -538,7 +541,7 @@ build_php_all_32() { build_php5.5_c build_php5.6_c build_php7.0_c - build_php7.1_c + build_php7.1_c $1 build_php5.5_zts_c build_php5.6_zts_c build_php7.0_zts_c @@ -546,7 +549,7 @@ build_php_all_32() { } build_php_all() { - build_php_all_32 + build_php_all_32 true build_php_compatibility } |