PROTOBUF_SYNC_PIPER
pull/7583/head
Joshua Haberman 5 years ago
commit 183cdec7cd
  1. 30
      BUILD
  2. 25
      CHANGES.txt
  3. 7
      Makefile.am
  4. 2
      Protobuf-C++.podspec
  5. 2
      Protobuf.podspec
  6. 33
      cmake/CMakeLists.txt
  7. 10
      cmake/conformance.cmake
  8. 4
      cmake/tests.cmake
  9. 2
      configure.ac
  10. 1
      conformance/failure_list_python.txt
  11. 1
      conformance/failure_list_python_cpp.txt
  12. 2
      csharp/Google.Protobuf.Tools.nuspec
  13. 4
      csharp/src/Google.Protobuf/Google.Protobuf.csproj
  14. 3
      global.json
  15. 2
      java/bom/pom.xml
  16. 2
      java/core/pom.xml
  17. 2
      java/lite/pom.xml
  18. 2
      java/pom.xml
  19. 2
      java/util/pom.xml
  20. 6
      js/message.js
  21. 2
      js/package.json
  22. 3
      kokoro/linux/bazel/build.sh
  23. 36
      php/ext/google/protobuf/package.xml
  24. 2
      php/ext/google/protobuf/protobuf.h
  25. 4
      php/release.sh
  26. 13
      php/tests/compatibility_test.sh
  27. 15
      php/tests/compile_extension.sh
  28. 6
      php/tests/gdb_test.sh
  29. 10
      php/tests/multirequest.sh
  30. 9
      php/tests/test.sh
  31. 10
      protobuf.bzl
  32. 6
      protobuf_deps.bzl
  33. 2
      protoc-artifacts/pom.xml
  34. 2
      python/google/protobuf/__init__.py
  35. 11
      python/google/protobuf/internal/json_format_test.py
  36. 4
      python/google/protobuf/internal/well_known_types.py
  37. 2
      ruby/google-protobuf.gemspec
  38. 2
      src/Makefile.am
  39. 62
      src/google/protobuf/any.pb.h
  40. 202
      src/google/protobuf/api.pb.h
  41. 57
      src/google/protobuf/arena_unittest.cc
  42. 2
      src/google/protobuf/compiler/code_generator.h
  43. 6
      src/google/protobuf/compiler/cpp/cpp_file.cc
  44. 2
      src/google/protobuf/compiler/cpp/cpp_generator.h
  45. 16
      src/google/protobuf/compiler/cpp/cpp_message.cc
  46. 75
      src/google/protobuf/compiler/cpp/cpp_string_field.cc
  47. 2
      src/google/protobuf/compiler/java/java_generator.cc
  48. 2
      src/google/protobuf/compiler/java/java_generator.h
  49. 2
      src/google/protobuf/compiler/mock_code_generator.cc
  50. 2
      src/google/protobuf/compiler/mock_code_generator.h
  51. 174
      src/google/protobuf/compiler/plugin.pb.h
  52. 2
      src/google/protobuf/compiler/python/python_generator.cc
  53. 2
      src/google/protobuf/compiler/python/python_generator.h
  54. 143
      src/google/protobuf/descriptor.cc
  55. 93
      src/google/protobuf/descriptor.h
  56. 930
      src/google/protobuf/descriptor.pb.h
  57. 193
      src/google/protobuf/descriptor_database.cc
  58. 6
      src/google/protobuf/duration.pb.h
  59. 6
      src/google/protobuf/empty.pb.h
  60. 6
      src/google/protobuf/field_mask.pb.h
  61. 4
      src/google/protobuf/generated_enum_reflection.h
  62. 2
      src/google/protobuf/generated_message_reflection.cc
  63. 24
      src/google/protobuf/generated_message_table_driven.h
  64. 4
      src/google/protobuf/generated_message_table_driven_lite.h
  65. 4
      src/google/protobuf/map.h
  66. 6
      src/google/protobuf/message.cc
  67. 3
      src/google/protobuf/message.h
  68. 18
      src/google/protobuf/parse_context.h
  69. 224
      src/google/protobuf/port_def.inc
  70. 13
      src/google/protobuf/port_undef.inc
  71. 24
      src/google/protobuf/repeated_field.cc
  72. 23
      src/google/protobuf/repeated_field.h
  73. 34
      src/google/protobuf/source_context.pb.h
  74. 38
      src/google/protobuf/struct.pb.h
  75. 18
      src/google/protobuf/stubs/common.h
  76. 11
      src/google/protobuf/stubs/hash.h
  77. 4
      src/google/protobuf/stubs/stringpiece.cc
  78. 23
      src/google/protobuf/stubs/stringpiece.h
  79. 5
      src/google/protobuf/stubs/structurally_valid.cc
  80. 39
      src/google/protobuf/stubs/strutil.cc
  81. 21
      src/google/protobuf/stubs/strutil.h
  82. 6
      src/google/protobuf/timestamp.pb.h
  83. 230
      src/google/protobuf/type.pb.h
  84. 2
      src/google/protobuf/util/field_mask_util.h
  85. 27
      src/google/protobuf/util/internal/expecting_objectwriter.h
  86. 62
      src/google/protobuf/wrappers.pb.h
  87. 100
      tests.sh

30
BUILD

@ -966,6 +966,16 @@ alias(
objc_library(
name = "protobuf_objc",
hdrs = [
"objectivec/GPBAny.pbobjc.h",
"objectivec/GPBApi.pbobjc.h",
"objectivec/GPBDuration.pbobjc.h",
"objectivec/GPBEmpty.pbobjc.h",
"objectivec/GPBFieldMask.pbobjc.h",
"objectivec/GPBSourceContext.pbobjc.h",
"objectivec/GPBStruct.pbobjc.h",
"objectivec/GPBTimestamp.pbobjc.h",
"objectivec/GPBType.pbobjc.h",
"objectivec/GPBWrappers.pbobjc.h",
"objectivec/GPBArray.h",
"objectivec/GPBBootstrap.h",
"objectivec/GPBCodedInputStream.h",
@ -1014,6 +1024,16 @@ objc_library(
"objectivec",
],
non_arc_srcs = [
"objectivec/GPBAny.pbobjc.m",
"objectivec/GPBApi.pbobjc.m",
"objectivec/GPBDuration.pbobjc.m",
"objectivec/GPBEmpty.pbobjc.m",
"objectivec/GPBFieldMask.pbobjc.m",
"objectivec/GPBSourceContext.pbobjc.m",
"objectivec/GPBStruct.pbobjc.m",
"objectivec/GPBTimestamp.pbobjc.m",
"objectivec/GPBType.pbobjc.m",
"objectivec/GPBWrappers.pbobjc.m",
"objectivec/GPBArray.m",
"objectivec/GPBCodedInputStream.m",
"objectivec/GPBCodedOutputStream.m",
@ -1028,16 +1048,6 @@ objc_library(
"objectivec/GPBUtilities.m",
"objectivec/GPBWellKnownTypes.m",
"objectivec/GPBWireFormat.m",
"objectivec/google/protobuf/Any.pbobjc.m",
"objectivec/google/protobuf/Api.pbobjc.m",
"objectivec/google/protobuf/Duration.pbobjc.m",
"objectivec/google/protobuf/Empty.pbobjc.m",
"objectivec/google/protobuf/FieldMask.pbobjc.m",
"objectivec/google/protobuf/SourceContext.pbobjc.m",
"objectivec/google/protobuf/Struct.pbobjc.m",
"objectivec/google/protobuf/Timestamp.pbobjc.m",
"objectivec/google/protobuf/Type.pbobjc.m",
"objectivec/google/protobuf/Wrappers.pbobjc.m",
],
visibility = ["//visibility:public"],
)

@ -1,3 +1,28 @@
Unreleased Changes
C++:
* Enabled heterogeneous lookup for std::string keys in maps.
* Improved the randomness of map ordering.
Python:
* Improved the error message when AttributeError is returned from __getattr__
in EnumTypeWrapper.
2020-05-26 version 3.12.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
C++
* Simplified the template export macros to fix the build for mingw32. (#7539)
Objective-C
* Fix for the :protobuf_objc target in the Bazel BUILD file. (#7538)
2020-05-20 version 3.12.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
Ruby
* Re-add binary gems for Ruby 2.3 and 2.4. These are EOL upstream, however
many people still use them and dropping support will require more
coordination.
2020-05-12 version 3.12.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
Protocol Compiler

@ -78,6 +78,7 @@ csharp_EXTRA_DIST= \
csharp/protos/unittest_import.proto \
csharp/protos/unittest_issues.proto \
csharp/protos/unittest_proto3.proto \
csharp/protos/unittest_selfreferential_options.proto \
csharp/protos/unittest.proto \
csharp/src/AddressBook/AddPerson.cs \
csharp/src/AddressBook/Addressbook.cs \
@ -153,6 +154,7 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.cs \
csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3.cs \
csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.cs \
csharp/src/Google.Protobuf.Test.TestProtos/UnittestSelfreferentialOptions.cs \
csharp/src/Google.Protobuf.Test.TestProtos/UnittestWellKnownTypes.cs \
csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs \
csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs \
@ -260,7 +262,6 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf/UnknownFieldSet.cs
java_EXTRA_DIST= \
java/BUILD \
java/README.md \
java/bom/pom.xml \
java/core/BUILD \
@ -1205,6 +1206,10 @@ js_EXTRA_DIST= \
js/data.proto \
js/debug.js \
js/debug_test.js \
js/experimental/runtime/kernel/message_set.js \
js/experimental/runtime/kernel/message_set_test.js \
js/experimental/runtime/kernel/tag.js \
js/experimental/runtime/kernel/tag_test.js \
js/gulpfile.js \
js/jasmine.json \
js/map.js \

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Protobuf-C++'
s.version = '3.11.4'
s.version = '3.12.2'
s.summary = 'Protocol Buffers v3 runtime library for C++.'
s.homepage = 'https://github.com/google/protobuf'
s.license = '3-Clause BSD License'

@ -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.12.0'
s.version = '3.12.2'
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
s.homepage = 'https://github.com/protocolbuffers/protobuf'
s.license = '3-Clause BSD License'

@ -37,6 +37,9 @@ if (CMAKE_CXX_COMPILER_ID MATCHES Intel)
endif()
# Options
if(WITH_PROTOC)
set(protobuf_PROTOC_EXE ${WITH_PROTOC} CACHE FILEPATH "Protocol Buffer Compiler executable" FORCE)
endif()
option(protobuf_BUILD_TESTS "Build tests" ON)
option(protobuf_BUILD_CONFORMANCE "Build conformance tests" OFF)
option(protobuf_BUILD_EXAMPLES "Build examples" OFF)
@ -58,6 +61,12 @@ mark_as_advanced(protobuf_DEBUG_POSTFIX)
# User options
include(protobuf-options.cmake)
# Overrides for option dependencies
if (protobuf_BUILD_PROTOC_BINARIES OR protobuf_BUILD_TESTS)
set(protobuf_BUILD_LIBPROTOC ON)
else()
set(protobuf_BUILD_LIBPROTOC OFF)
endif ()
# Path to main configure script
set(protobuf_CONFIGURE_SCRIPT "../configure.ac")
@ -242,11 +251,29 @@ endif (protobuf_UNICODE)
include(libprotobuf-lite.cmake)
include(libprotobuf.cmake)
if (protobuf_BUILD_PROTOC_BINARIES)
if (protobuf_BUILD_LIBPROTOC)
include(libprotoc.cmake)
endif (protobuf_BUILD_LIBPROTOC)
if (protobuf_BUILD_PROTOC_BINARIES)
include(protoc.cmake)
if (NOT DEFINED protobuf_PROTOC_EXE)
set(protobuf_PROTOC_EXE protoc)
endif (NOT DEFINED protobuf_PROTOC_EXE)
endif (protobuf_BUILD_PROTOC_BINARIES)
# Ensure we have a protoc executable if we need one
if (protobuf_BUILD_TESTS OR protobuf_BUILD_CONFORMANCE OR protobuf_BUILD_EXAMPLES)
if (NOT DEFINED protobuf_PROTOC_EXE)
find_program(protobuf_PROTOC_EXE protoc)
if (NOT protobuf_PROTOC_EXE)
message(FATAL "Build requires 'protoc' but binary not found and not building protoc.")
endif ()
endif ()
if(protobuf_VERBOSE)
message(STATUS "Using protoc : ${protobuf_PROTOC_EXE}")
endif(protobuf_VERBOSE)
endif ()
if (protobuf_BUILD_TESTS)
include(tests.cmake)
endif (protobuf_BUILD_TESTS)
@ -262,5 +289,5 @@ if (protobuf_BUILD_EXAMPLES)
endif (protobuf_BUILD_EXAMPLES)
if(protobuf_VERBOSE)
message(STATUS "Protocol Buffers Configuring done")
endif()
message(STATUS "Protocol Buffers Configuring done")
endif(protobuf_VERBOSE)

@ -1,8 +1,8 @@
add_custom_command(
OUTPUT ${protobuf_source_dir}/conformance/conformance.pb.cc
DEPENDS protoc ${protobuf_source_dir}/conformance/conformance.proto
COMMAND protoc ${protobuf_source_dir}/conformance/conformance.proto
DEPENDS ${protobuf_PROTOC_EXE} ${protobuf_source_dir}/conformance/conformance.proto
COMMAND ${protobuf_PROTOC_EXE} ${protobuf_source_dir}/conformance/conformance.proto
--proto_path=${protobuf_source_dir}/conformance
--cpp_out=${protobuf_source_dir}/conformance
)
@ -10,9 +10,9 @@ add_custom_command(
add_custom_command(
OUTPUT ${protobuf_source_dir}/src/google/protobuf/test_messages_proto3.pb.cc
${protobuf_source_dir}/src/google/protobuf/test_messages_proto2.pb.cc
DEPENDS protoc ${protobuf_source_dir}/src/google/protobuf/test_messages_proto3.proto
protoc ${protobuf_source_dir}/src/google/protobuf/test_messages_proto2.proto
COMMAND protoc ${protobuf_source_dir}/src/google/protobuf/test_messages_proto3.proto
DEPENDS ${protobuf_PROTOC_EXE} ${protobuf_source_dir}/src/google/protobuf/test_messages_proto3.proto
${protobuf_PROTOC_EXE} ${protobuf_source_dir}/src/google/protobuf/test_messages_proto2.proto
COMMAND ${protobuf_PROTOC_EXE} ${protobuf_source_dir}/src/google/protobuf/test_messages_proto3.proto
${protobuf_source_dir}/src/google/protobuf/test_messages_proto2.proto
--proto_path=${protobuf_source_dir}/src
--cpp_out=${protobuf_source_dir}/src

@ -87,8 +87,8 @@ macro(compile_proto_file filename)
get_filename_component(basename ${filename} NAME_WE)
add_custom_command(
OUTPUT ${protobuf_source_dir}/src/${dirname}/${basename}.pb.cc
DEPENDS protoc ${protobuf_source_dir}/src/${dirname}/${basename}.proto
COMMAND protoc ${protobuf_source_dir}/src/${dirname}/${basename}.proto
DEPENDS ${protobuf_PROTOC_EXE} ${protobuf_source_dir}/src/${dirname}/${basename}.proto
COMMAND ${protobuf_PROTOC_EXE} ${protobuf_source_dir}/src/${dirname}/${basename}.proto
--proto_path=${protobuf_source_dir}/src
--cpp_out=${protobuf_source_dir}/src
--experimental_allow_proto3_optional

@ -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.11.4],[protobuf@googlegroups.com],[protobuf])
AC_INIT([Protocol Buffers],[3.12.2],[protobuf@googlegroups.com],[protobuf])
AM_MAINTAINER_MODE([enable])

@ -28,4 +28,3 @@ Required.Proto3.JsonInput.DoubleFieldTooSmall
Required.Proto3.JsonInput.FloatFieldTooLarge
Required.Proto3.JsonInput.FloatFieldTooSmall
Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
Required.Proto3.JsonInput.TimestampJsonInputLowercaseT

@ -19,4 +19,3 @@ Required.Proto3.JsonInput.DoubleFieldTooSmall
Required.Proto3.JsonInput.FloatFieldTooLarge
Required.Proto3.JsonInput.FloatFieldTooSmall
Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
Required.Proto3.JsonInput.TimestampJsonInputLowercaseT

@ -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.12.0</version>
<version>3.12.2</version>
<authors>Google Inc.</authors>
<owners>protobuf-packages</owners>
<licenseUrl>https://github.com/protocolbuffers/protobuf/blob/master/LICENSE</licenseUrl>

@ -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.12.0</VersionPrefix>
<VersionPrefix>3.12.2</VersionPrefix>
<!-- C# 7.2 is required for Span/BufferWriter/ReadOnlySequence -->
<LangVersion>7.2</LangVersion>
<Authors>Google Inc.</Authors>
@ -31,7 +31,7 @@
<ItemGroup>
<PackageReference Include="System.Memory" Version="4.5.2"/>
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" Version="1.0.0-beta2-18618-05"/>
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" Version="1.0.0"/>
<!-- Needed for the net45 build to work on Unix. See https://github.com/dotnet/designs/pull/33 -->
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0"/>
</ItemGroup>

@ -1,5 +1,6 @@
{
"sdk": {
"version": "3.0.100"
"version": "3.0.100",
"rollForward": "latestMinor"
}
}

@ -4,7 +4,7 @@
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-bom</artifactId>
<version>3.12.0</version>
<version>3.12.2</version>
<packaging>pom</packaging>
<name>Protocol Buffers [BOM]</name>

@ -4,7 +4,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.12.0</version>
<version>3.12.2</version>
</parent>
<artifactId>protobuf-java</artifactId>

@ -4,7 +4,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.12.0</version>
<version>3.12.2</version>
</parent>
<artifactId>protobuf-javalite</artifactId>

@ -4,7 +4,7 @@
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.12.0</version>
<version>3.12.2</version>
<packaging>pom</packaging>
<name>Protocol Buffers [Parent]</name>

@ -4,7 +4,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.12.0</version>
<version>3.12.2</version>
</parent>
<artifactId>protobuf-java-util</artifactId>

@ -417,7 +417,7 @@ jspb.Message.EMPTY_LIST_SENTINEL_ = goog.DEBUG && Object.freeze ?
*/
jspb.Message.isArray_ = function(o) {
return jspb.Message.ASSUME_LOCAL_ARRAYS ? o instanceof Array :
goog.isArray(o);
Array.isArray(o);
};
/**
@ -1433,7 +1433,7 @@ jspb.Message.prototype.syncMapFields_ = function() {
if (this.wrappers_) {
for (var fieldNumber in this.wrappers_) {
var val = this.wrappers_[fieldNumber];
if (goog.isArray(val)) {
if (Array.isArray(val)) {
for (var i = 0; i < val.length; i++) {
if (val[i]) {
val[i].toArray();
@ -1823,7 +1823,7 @@ jspb.Message.copyInto = function(fromMessage, toMessage) {
*/
jspb.Message.clone_ = function(obj) {
var o;
if (goog.isArray(obj)) {
if (Array.isArray(obj)) {
// Allocate array of correct size.
var clonedArray = new Array(obj.length);
// Use array iteration where possible because it is faster than for-in.

@ -1,6 +1,6 @@
{
"name": "google-protobuf",
"version": "3.11.4",
"version": "3.12.2",
"description": "Protocol Buffers for JavaScript",
"main": "google-protobuf.js",
"files": [

@ -26,6 +26,9 @@ trap print_test_logs EXIT
bazel test --copt=-Werror --host_copt=-Werror \
//:build_files_updated_unittest \
//java/... \
//:protoc \
//:protobuf \
//:protobuf_python \
//:protobuf_test \
@com_google_protobuf//:cc_proto_blacklist_test
trap - EXIT

@ -10,11 +10,11 @@
<email>protobuf-opensource@google.com</email>
<active>yes</active>
</lead>
<date>2020-05-15</date>
<time>13:26:23</time>
<date>2020-05-26</date>
<time>13:57:10</time>
<version>
<release>3.12.0</release>
<api>3.12.0</api>
<release>3.12.2</release>
<api>3.12.2</api>
</version>
<stability>
<release>stable</release>
@ -571,5 +571,33 @@ G A release.
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
<notes>GA release.</notes>
</release>
<release>
<version>
<release>3.12.1</release>
<api>3.12.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2020-05-20</date>
<time>10:18:13</time>
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
<notes>GA release.</notes>
</release>
<release>
<version>
<release>3.12.2</release>
<api>3.12.2</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2020-05-26</date>
<time>13:57:10</time>
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
<notes>GA release.</notes>
</release>
</changelog>
</package>

@ -37,7 +37,7 @@
#include "upb.h"
#define PHP_PROTOBUF_EXTNAME "protobuf"
#define PHP_PROTOBUF_VERSION "3.12.0"
#define PHP_PROTOBUF_VERSION "3.12.2"
#define MAX_LENGTH_OF_INT64 20
#define SIZEOF_INT64 8

@ -10,8 +10,8 @@ set -ex
VERSION=$1
git clone https://github.com/protocolbuffers/protobuf-php.git
git clone https://github.com/protocolbuffers/protobuf.git
git clone git@github.com:protocolbuffers/protobuf-php.git
git clone git@github.com:protocolbuffers/protobuf.git
# Clean old files
pushd protobuf-php

@ -1,17 +1,5 @@
#!/bin/bash
function use_php() {
VERSION=$1
OLD_PATH=$PATH
OLD_CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH
OLD_C_INCLUDE_PATH=$C_INCLUDE_PATH
export PATH=/usr/local/php-${VERSION}/bin:$OLD_PATH
export CPLUS_INCLUDE_PATH=/usr/local/php-${VERSION}/include/php/main:/usr/local/php-${VERSION}/include/php/:$OLD_CPLUS_INCLUDE_PATH
export C_INCLUDE_PATH=/usr/local/php-${VERSION}/include/php/main:/usr/local/php-${VERSION}/include/php/:$OLD_C_INCLUDE_PATH
}
function generate_proto() {
PROTOC1=$1
PROTOC2=$2
@ -92,7 +80,6 @@ git checkout v$OLD_VERSION
popd
# Build and copy the new runtime
use_php 7.1
pushd ../ext/google/protobuf
make clean || true
phpize && ./configure && make

@ -1,14 +1,17 @@
#!/bin/bash
VERSION=$2
cd $(dirname $0)
export PATH=/usr/local/php-$VERSION/bin:$PATH
export C_INCLUDE_PATH=/usr/local/php-$VERSION/include/php/main:/usr/local/php-$VERSION/include/php:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/usr/local/php-$VERSION/include/php/main:/usr/local/php-$VERSION/include/php:$CPLUS_INCLUDE_PATH
if [ "$1" = "--release"]; then
CFLAGS="-Wall"
else
# To get debugging symbols in PHP itself, build PHP with:
# $ ./configure --enable-debug CFLAGS='-g -O0'
CFLAGS="-g -O0 -Wall"
fi
pushd ../ext/google/protobuf
make clean || true
set -e
# Add following in configure for debug: --enable-debug CFLAGS='-g -O0'
phpize && ./configure CFLAGS='-g -O0 -Wall' && make
phpize && ./configure --with-php-config=$(which php-config) CFLAGS="$CFLAGS" && make
popd

@ -1,11 +1,5 @@
#!/bin/bash
VERSION=$1
export PATH=/usr/local/php-$VERSION/bin:$PATH
export C_INCLUDE_PATH=/usr/local/php-$VERSION/include/php/main:/usr/local/php-$VERSION/include/php:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/usr/local/php-$VERSION/include/php/main:/usr/local/php-$VERSION/include/php:$CPLUS_INCLUDE_PATH
php -i | grep "Configuration"
# gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so `which

@ -1,14 +1,12 @@
#!/bin/bash
cd $(dirname $0)
set -e
# Compile c extension
VERSION=7.4
PORT=12345
export PATH=/usr/local/php-$VERSION/bin:$PATH
export C_INCLUDE_PATH=/usr/local/php-$VERSION/include/php/main:/usr/local/php-$VERSION/include/php:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/usr/local/php-$VERSION/include/php/main:/usr/local/php-$VERSION/include/php:$CPLUS_INCLUDE_PATH
/bin/bash ./compile_extension.sh $VERSION
./compile_extension.sh
nohup php -d protobuf.keep_descriptor_pool_after_request=1 -dextension=../ext/google/protobuf/modules/protobuf.so -S localhost:$PORT multirequest.php 2>&1 &

@ -1,13 +1,8 @@
#!/bin/bash
VERSION=$1
cd $(dirname $0)
export PATH=/usr/local/php-$VERSION/bin:$PATH
export C_INCLUDE_PATH=/usr/local/php-$VERSION/include/php/main:/usr/local/php-$VERSION/include/php:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/usr/local/php-$VERSION/include/php/main:/usr/local/php-$VERSION/include/php:$CPLUS_INCLUDE_PATH
# Compile c extension
/bin/bash ./compile_extension.sh $VERSION
./compile_extension.sh
tests=( array_test.php encode_decode_test.php generated_class_test.php map_field_test.php well_known_test.php descriptors_test.php wrapper_type_setters_test.php)

@ -85,8 +85,14 @@ def _proto_gen_impl(ctx):
import_flags = depset(direct=["-I."])
for dep in ctx.attr.deps:
import_flags = depset(transitive=[import_flags, depset(direct=dep.proto.import_flags)])
deps = depset(transitive=[deps, depset(direct=dep.proto.deps)])
if type(dep.proto.import_flags) == "list":
import_flags = depset(transitive=[import_flags], direct=dep.proto.import_flags)
else:
import_flags = depset(transitive=[import_flags, dep.proto.import_flags])
if type(dep.proto.deps) == "list":
deps = depset(transitive=[deps], direct=dep.proto.deps)
else:
deps = depset(transitive=[deps, dep.proto.deps])
if not ctx.attr.gen_cc and not ctx.attr.gen_py and not ctx.executable.plugin:
return struct(

@ -35,9 +35,9 @@ def protobuf_deps():
if not native.existing_rule("rules_cc"):
http_archive(
name = "rules_cc",
sha256 = "29daf0159f0cf552fcff60b49d8bcd4f08f08506d2da6e41b07058ec50cfeaec",
strip_prefix = "rules_cc-b7fe9697c0c76ab2fd431a891dbb9a6a32ed7c3e",
urls = ["https://github.com/bazelbuild/rules_cc/archive/b7fe9697c0c76ab2fd431a891dbb9a6a32ed7c3e.tar.gz"],
sha256 = "9d48151ea71b3e225adfb6867e6d2c7d0dce46cbdc8710d9a9a628574dfd40a0",
strip_prefix = "rules_cc-818289e5613731ae410efb54218a4077fb9dbb03",
urls = ["https://github.com/bazelbuild/rules_cc/archive/818289e5613731ae410efb54218a4077fb9dbb03.tar.gz"],
)
if not native.existing_rule("rules_java"):

@ -8,7 +8,7 @@
</parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protoc</artifactId>
<version>3.12.0</version>
<version>3.12.2</version>
<packaging>pom</packaging>
<name>Protobuf Compiler</name>
<description>

@ -30,7 +30,7 @@
# Copyright 2007 Google Inc. All Rights Reserved.
__version__ = '3.11.4'
__version__ = '3.12.2'
if __name__ != '__main__':
try:

@ -269,7 +269,6 @@ class JsonFormatTest(JsonFormatBase):
}
self.assertEqual(expected_dict, message_dict)
def testExtensionSerializationJsonMatchesProto3Spec(self):
"""See go/proto3-json-spec for spec.
"""
@ -295,7 +294,6 @@ class JsonFormatTest(JsonFormatBase):
'}}') % (ext1_text, ext2_text)
self.assertEqual(json.loads(golden_text), json.loads(message_text))
def testJsonEscapeString(self):
message = json_format_proto3_pb2.TestMessage()
if sys.version_info[0] < 3:
@ -1036,6 +1034,15 @@ class JsonFormatTest(JsonFormatBase):
OverflowError,
'date value out of range',
json_format.MessageToJson, message)
# Lower case t does not accept.
text = '{"value": "0001-01-01t00:00:00Z"}'
with self.assertRaises(json_format.ParseError) as e:
json_format.Parse(text, message)
self.assertEqual(
'Failed to parse value field: '
'time data \'0001-01-01t00:00:00\' does not match format '
'\'%Y-%m-%dT%H:%M:%S\', lowercase \'t\' is not accepted.',
str(e.exception))
def testInvalidOneof(self):
message = json_format_proto3_pb2.TestOneof()

@ -160,6 +160,10 @@ class Timestamp(object):
else:
second_value = time_value[:point_position]
nano_value = time_value[point_position + 1:]
if 't' in second_value:
raise ValueError(
'time data \'{0}\' does not match format \'%Y-%m-%dT%H:%M:%S\', '
'lowercase \'t\' is not accepted'.format(second_value))
date_object = datetime.strptime(second_value, _TIMESTAMPFOMAT)
td = date_object - datetime(1970, 1, 1)
seconds = td.seconds + td.days * _SECONDS_PER_DAY

@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "google-protobuf"
s.version = "3.12.0"
s.version = "3.12.2"
git_tag = "v#{s.version.to_s.sub('.rc.', '-rc')}" # Converts X.Y.Z.rc.N to vX.Y.Z-rcN, used for the git tag
s.licenses = ["BSD-3-Clause"]
s.summary = "Protocol Buffers"

@ -18,7 +18,7 @@ else
PTHREAD_DEF =
endif
PROTOBUF_VERSION = 22:4:0
PROTOBUF_VERSION = 23:2:0
if GCC
# Turn on all warnings except for sign comparison (we ignore sign comparison

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3011000
#if PROTOBUF_VERSION < 3012000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3011004 < PROTOBUF_MIN_PROTOC_VERSION
#if 3012002 < 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.
@ -45,7 +45,7 @@ PROTOBUF_NAMESPACE_CLOSE
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fany_2eproto {
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxillaryParseTableField aux[]
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
@ -225,15 +225,6 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL :
std::string* mutable_type_url();
std::string* release_type_url();
void set_allocated_type_url(std::string* type_url);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_type_url();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_type_url(
std::string* type_url);
private:
const std::string& _internal_type_url() const;
void _internal_set_type_url(const std::string& value);
@ -250,15 +241,6 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL :
std::string* mutable_value();
std::string* release_value();
void set_allocated_value(std::string* value);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_value();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_value(
std::string* value);
private:
const std::string& _internal_value() const;
void _internal_set_value(const std::string& value);
@ -350,25 +332,6 @@ inline void Any::set_allocated_type_url(std::string* type_url) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url)
}
inline std::string* Any::unsafe_arena_release_type_url() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Any.type_url)
GOOGLE_DCHECK(GetArena() != nullptr);
return type_url_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void Any::unsafe_arena_set_allocated_type_url(
std::string* type_url) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (type_url != nullptr) {
} else {
}
type_url_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
type_url, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Any.type_url)
}
// bytes value = 2;
inline void Any::clear_value() {
@ -431,25 +394,6 @@ inline void Any::set_allocated_value(std::string* value) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value)
}
inline std::string* Any::unsafe_arena_release_value() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Any.value)
GOOGLE_DCHECK(GetArena() != nullptr);
return value_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void Any::unsafe_arena_set_allocated_value(
std::string* value) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (value != nullptr) {
} else {
}
value_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
value, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Any.value)
}
#ifdef __GNUC__
#pragma GCC diagnostic pop

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3011000
#if PROTOBUF_VERSION < 3012000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3011004 < PROTOBUF_MIN_PROTOC_VERSION
#if 3012002 < 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.
@ -47,7 +47,7 @@ PROTOBUF_NAMESPACE_CLOSE
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fapi_2eproto {
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxillaryParseTableField aux[]
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[3]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
@ -261,15 +261,6 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL :
std::string* mutable_name();
std::string* release_name();
void set_allocated_name(std::string* name);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_name();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_name(
std::string* name);
private:
const std::string& _internal_name() const;
void _internal_set_name(const std::string& value);
@ -286,15 +277,6 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL :
std::string* mutable_version();
std::string* release_version();
void set_allocated_version(std::string* version);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_version();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_version(
std::string* version);
private:
const std::string& _internal_version() const;
void _internal_set_version(const std::string& value);
@ -496,15 +478,6 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
std::string* mutable_name();
std::string* release_name();
void set_allocated_name(std::string* name);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_name();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_name(
std::string* name);
private:
const std::string& _internal_name() const;
void _internal_set_name(const std::string& value);
@ -521,15 +494,6 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
std::string* mutable_request_type_url();
std::string* release_request_type_url();
void set_allocated_request_type_url(std::string* request_type_url);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_request_type_url();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_request_type_url(
std::string* request_type_url);
private:
const std::string& _internal_request_type_url() const;
void _internal_set_request_type_url(const std::string& value);
@ -546,15 +510,6 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL :
std::string* mutable_response_type_url();
std::string* release_response_type_url();
void set_allocated_response_type_url(std::string* response_type_url);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_response_type_url();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_response_type_url(
std::string* response_type_url);
private:
const std::string& _internal_response_type_url() const;
void _internal_set_response_type_url(const std::string& value);
@ -733,15 +688,6 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL :
std::string* mutable_name();
std::string* release_name();
void set_allocated_name(std::string* name);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_name();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_name(
std::string* name);
private:
const std::string& _internal_name() const;
void _internal_set_name(const std::string& value);
@ -758,15 +704,6 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL :
std::string* mutable_root();
std::string* release_root();
void set_allocated_root(std::string* root);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_root();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_root(
std::string* root);
private:
const std::string& _internal_root() const;
void _internal_set_root(const std::string& value);
@ -857,25 +794,6 @@ inline void Api::set_allocated_name(std::string* name) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.name)
}
inline std::string* Api::unsafe_arena_release_name() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Api.name)
GOOGLE_DCHECK(GetArena() != nullptr);
return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void Api::unsafe_arena_set_allocated_name(
std::string* name) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (name != nullptr) {
} else {
}
name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
name, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Api.name)
}
// repeated .google.protobuf.Method methods = 2;
inline int Api::_internal_methods_size() const {
@ -1013,25 +931,6 @@ inline void Api::set_allocated_version(std::string* version) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version)
}
inline std::string* Api::unsafe_arena_release_version() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Api.version)
GOOGLE_DCHECK(GetArena() != nullptr);
return version_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void Api::unsafe_arena_set_allocated_version(
std::string* version) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (version != nullptr) {
} else {
}
version_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
version, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Api.version)
}
// .google.protobuf.SourceContext source_context = 5;
inline bool Api::_internal_has_source_context() const {
@ -1234,25 +1133,6 @@ inline void Method::set_allocated_name(std::string* name) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name)
}
inline std::string* Method::unsafe_arena_release_name() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Method.name)
GOOGLE_DCHECK(GetArena() != nullptr);
return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void Method::unsafe_arena_set_allocated_name(
std::string* name) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (name != nullptr) {
} else {
}
name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
name, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Method.name)
}
// string request_type_url = 2;
inline void Method::clear_request_type_url() {
@ -1315,25 +1195,6 @@ inline void Method::set_allocated_request_type_url(std::string* request_type_url
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url)
}
inline std::string* Method::unsafe_arena_release_request_type_url() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Method.request_type_url)
GOOGLE_DCHECK(GetArena() != nullptr);
return request_type_url_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void Method::unsafe_arena_set_allocated_request_type_url(
std::string* request_type_url) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (request_type_url != nullptr) {
} else {
}
request_type_url_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
request_type_url, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Method.request_type_url)
}
// bool request_streaming = 3;
inline void Method::clear_request_streaming() {
@ -1416,25 +1277,6 @@ inline void Method::set_allocated_response_type_url(std::string* response_type_u
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url)
}
inline std::string* Method::unsafe_arena_release_response_type_url() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Method.response_type_url)
GOOGLE_DCHECK(GetArena() != nullptr);
return response_type_url_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void Method::unsafe_arena_set_allocated_response_type_url(
std::string* response_type_url) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (response_type_url != nullptr) {
} else {
}
response_type_url_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
response_type_url, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Method.response_type_url)
}
// bool response_streaming = 5;
inline void Method::clear_response_streaming() {
@ -1577,25 +1419,6 @@ inline void Mixin::set_allocated_name(std::string* name) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name)
}
inline std::string* Mixin::unsafe_arena_release_name() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Mixin.name)
GOOGLE_DCHECK(GetArena() != nullptr);
return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void Mixin::unsafe_arena_set_allocated_name(
std::string* name) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (name != nullptr) {
} else {
}
name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
name, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Mixin.name)
}
// string root = 2;
inline void Mixin::clear_root() {
@ -1658,25 +1481,6 @@ inline void Mixin::set_allocated_root(std::string* root) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root)
}
inline std::string* Mixin::unsafe_arena_release_root() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Mixin.root)
GOOGLE_DCHECK(GetArena() != nullptr);
return root_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void Mixin::unsafe_arena_set_allocated_root(
std::string* root) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (root != nullptr) {
} else {
}
root_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
root, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Mixin.root)
}
#ifdef __GNUC__
#pragma GCC diagnostic pop

@ -858,23 +858,6 @@ TEST(ArenaTest, ReleaseLastRepeatedField) {
}
}
TEST(ArenaTest, UnsafeArenaReleaseAdd) {
// Use unsafe_arena_release() and unsafe_arena_set_allocated() to transfer an
// arena-allocated string from one message to another.
const char kContent[] = "Test content";
Arena arena;
TestAllTypes* message1 = Arena::CreateMessage<TestAllTypes>(&arena);
TestAllTypes* message2 = Arena::CreateMessage<TestAllTypes>(&arena);
std::string* arena_string = Arena::Create<std::string>(&arena);
*arena_string = kContent;
message1->unsafe_arena_set_allocated_optional_string(arena_string);
message2->unsafe_arena_set_allocated_optional_string(
message1->unsafe_arena_release_optional_string());
EXPECT_EQ(kContent, message2->optional_string());
}
TEST(ArenaTest, UnsafeArenaAddAllocated) {
Arena arena;
TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena);
@ -885,43 +868,20 @@ TEST(ArenaTest, UnsafeArenaAddAllocated) {
}
}
TEST(ArenaTest, UnsafeArenaRelease) {
Arena arena;
TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena);
std::string* s = new std::string("test string");
message->unsafe_arena_set_allocated_optional_string(s);
EXPECT_TRUE(message->has_optional_string());
EXPECT_EQ("test string", message->optional_string());
s = message->unsafe_arena_release_optional_string();
EXPECT_FALSE(message->has_optional_string());
delete s;
s = new std::string("test string");
message->unsafe_arena_set_allocated_oneof_string(s);
EXPECT_TRUE(message->has_oneof_string());
EXPECT_EQ("test string", message->oneof_string());
s = message->unsafe_arena_release_oneof_string();
EXPECT_FALSE(message->has_oneof_string());
delete s;
}
TEST(ArenaTest, OneofMerge) {
Arena arena;
TestAllTypes* message0 = Arena::CreateMessage<TestAllTypes>(&arena);
TestAllTypes* message1 = Arena::CreateMessage<TestAllTypes>(&arena);
message0->unsafe_arena_set_allocated_oneof_string(new std::string("x"));
message0->set_oneof_string("x");
ASSERT_TRUE(message0->has_oneof_string());
message1->unsafe_arena_set_allocated_oneof_string(new std::string("y"));
message1->set_oneof_string("y");
ASSERT_TRUE(message1->has_oneof_string());
EXPECT_EQ("x", message0->oneof_string());
EXPECT_EQ("y", message1->oneof_string());
message0->MergeFrom(*message1);
EXPECT_EQ("y", message0->oneof_string());
EXPECT_EQ("y", message1->oneof_string());
delete message0->unsafe_arena_release_oneof_string();
delete message1->unsafe_arena_release_oneof_string();
}
TEST(ArenaTest, ArenaOneofReflection) {
@ -1345,19 +1305,6 @@ TEST(ArenaTest, AddCleanup) {
}
}
TEST(ArenaTest, UnsafeSetAllocatedOnArena) {
Arena arena;
TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena);
EXPECT_FALSE(message->has_optional_string());
std::string owned_string = "test with long enough content to heap-allocate";
message->unsafe_arena_set_allocated_optional_string(&owned_string);
EXPECT_TRUE(message->has_optional_string());
message->unsafe_arena_set_allocated_optional_string(NULL);
EXPECT_FALSE(message->has_optional_string());
}
// A helper utility class to only contain static hook functions, some
// counters to be used to verify the counters have been called and a cookie
// value to be verified.

@ -110,7 +110,7 @@ class PROTOC_EXPORT CodeGenerator {
// Implement this to indicate what features this code generator supports.
// This should be a bitwise OR of features from the Features enum in
// plugin.proto.
virtual uint64 GetSupportedFeatures() const { return 0; }
virtual uint64_t GetSupportedFeatures() const { return 0; }
// This is no longer used, but this class is part of the opensource protobuf
// library, so it has to remain to keep vtables the same for the current

@ -1046,7 +1046,7 @@ void FileGenerator::GenerateTables(io::Printer* printer) {
"};\n"
"\n"
"PROTOBUF_CONSTEXPR_VAR "
"::$proto_ns$::internal::AuxillaryParseTableField\n"
"::$proto_ns$::internal::AuxiliaryParseTableField\n"
" const $tablename$::aux[] "
"PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n");
format.Indent();
@ -1060,7 +1060,7 @@ void FileGenerator::GenerateTables(io::Printer* printer) {
}
if (count == 0) {
format("::$proto_ns$::internal::AuxillaryParseTableField(),\n");
format("::$proto_ns$::internal::AuxiliaryParseTableField(),\n");
}
format.Outdent();
@ -1406,7 +1406,7 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations(
// for table driven code.
" static const ::$proto_ns$::internal::ParseTableField entries[]\n"
" PROTOBUF_SECTION_VARIABLE(protodesc_cold);\n"
" static const ::$proto_ns$::internal::AuxillaryParseTableField aux[]\n"
" static const ::$proto_ns$::internal::AuxiliaryParseTableField aux[]\n"
" PROTOBUF_SECTION_VARIABLE(protodesc_cold);\n"
" static const ::$proto_ns$::internal::ParseTable schema[$1$]\n"
" PROTOBUF_SECTION_VARIABLE(protodesc_cold);\n"

@ -84,7 +84,7 @@ class PROTOC_EXPORT CppGenerator : public CodeGenerator {
GeneratorContext* generator_context,
std::string* error) const override;
uint64 GetSupportedFeatures() const override {
uint64_t GetSupportedFeatures() const override {
// We don't fully support this yet, but this is needed to unblock the tests,
// and we will have full support before the experimental flag is removed.
return FEATURE_PROTO3_OPTIONAL;

@ -1706,7 +1706,7 @@ bool MessageGenerator::GenerateParseTable(io::Printer* printer, size_t offset,
}
// TODO(ckennelly): Consolidate this with the calculation for
// AuxillaryParseTableField.
// AuxiliaryParseTableField.
format(
"PROTOBUF_FIELD_OFFSET($classtype$, _internal_metadata_),\n"
"&$package_ns$::_$classname$_default_instance_,\n");
@ -2302,14 +2302,14 @@ size_t MessageGenerator::GenerateParseAuxTable(io::Printer* printer) {
std::vector<const FieldDescriptor*> ordered_fields =
SortFieldsByNumber(descriptor_);
format("::$proto_ns$::internal::AuxillaryParseTableField(),\n");
format("::$proto_ns$::internal::AuxiliaryParseTableField(),\n");
int last_field_number = 1;
for (auto field : ordered_fields) {
Formatter::SaveState saver(&format);
GOOGLE_CHECK_GE(field->number(), last_field_number);
for (; last_field_number < field->number(); last_field_number++) {
format("::$proto_ns$::internal::AuxillaryParseTableField(),\n");
format("::$proto_ns$::internal::AuxiliaryParseTableField(),\n");
}
std::map<std::string, std::string> vars;
@ -2320,11 +2320,11 @@ size_t MessageGenerator::GenerateParseAuxTable(io::Printer* printer) {
case FieldDescriptor::CPPTYPE_ENUM:
if (HasPreservingUnknownEnumSemantics(field)) {
format(
"{::$proto_ns$::internal::AuxillaryParseTableField::enum_aux{"
"{::$proto_ns$::internal::AuxiliaryParseTableField::enum_aux{"
"nullptr}},\n");
} else {
format(
"{::$proto_ns$::internal::AuxillaryParseTableField::enum_aux{"
"{::$proto_ns$::internal::AuxiliaryParseTableField::enum_aux{"
"$1$_IsValid}},\n",
ClassName(field->enum_type(), true));
}
@ -2333,7 +2333,7 @@ size_t MessageGenerator::GenerateParseAuxTable(io::Printer* printer) {
case FieldDescriptor::CPPTYPE_MESSAGE: {
if (field->is_map()) {
format(
"{::$proto_ns$::internal::AuxillaryParseTableField::map_"
"{::$proto_ns$::internal::AuxiliaryParseTableField::map_"
"aux{&::$proto_ns$::internal::ParseMap<$1$>}},\n",
QualifiedClassName(field->message_type(), options_));
last_field_number++;
@ -2344,7 +2344,7 @@ size_t MessageGenerator::GenerateParseAuxTable(io::Printer* printer) {
field->message_type(), options_));
format(
"{::$proto_ns$::internal::AuxillaryParseTableField::message_aux{\n"
"{::$proto_ns$::internal::AuxiliaryParseTableField::message_aux{\n"
" &$default_instance$}},\n");
last_field_number++;
break;
@ -2367,7 +2367,7 @@ size_t MessageGenerator::GenerateParseAuxTable(io::Printer* printer) {
break;
}
format(
"{::$proto_ns$::internal::AuxillaryParseTableField::string_aux{\n"
"{::$proto_ns$::internal::AuxiliaryParseTableField::string_aux{\n"
" $1$,\n"
" \"$2$\"\n"
"}},\n",

@ -179,23 +179,6 @@ void StringFieldGenerator::GenerateAccessorDeclarations(
"$deprecated_attr$void ${1$set_allocated_$name$$}$(std::string* "
"$name$);\n",
descriptor_);
if (options_.opensource_runtime) {
if (SupportsArenas(descriptor_)) {
format(
"$GOOGLE_PROTOBUF$_RUNTIME_DEPRECATED(\"The unsafe_arena_ accessors "
"for\"\n"
"\" string fields are deprecated and will be removed in a\"\n"
"\" future release.\")\n"
"std::string* ${1$unsafe_arena_release_$name$$}$();\n"
"$GOOGLE_PROTOBUF$_RUNTIME_DEPRECATED(\"The unsafe_arena_ accessors "
"for\"\n"
"\" string fields are deprecated and will be removed in a\"\n"
"\" future release.\")\n"
"void ${1$unsafe_arena_set_allocated_$name$$}$(\n"
" std::string* $name$);\n",
descriptor_);
}
}
format(
"private:\n"
"const std::string& _internal_$name$() const;\n"
@ -307,32 +290,6 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
" GetArena());\n"
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
"}\n");
if (options_.opensource_runtime) {
format(
"inline std::string* $classname$::unsafe_arena_release_$name$() {\n"
"$annotate_accessor$"
" // "
"@@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n"
" $DCHK$(GetArena() != nullptr);\n"
" $clear_hasbit$\n"
" return $name$_.UnsafeArenaRelease($default_variable$,\n"
" GetArena());\n"
"}\n"
"inline void $classname$::unsafe_arena_set_allocated_$name$(\n"
"$annotate_accessor$"
" std::string* $name$) {\n"
" $DCHK$(GetArena() != nullptr);\n"
" if ($name$ != nullptr) {\n"
" $set_hasbit$\n"
" } else {\n"
" $clear_hasbit$\n"
" }\n"
" $name$_.UnsafeArenaSetAllocated($default_variable$,\n"
" $name$, GetArena());\n"
" // @@protoc_insertion_point(field_unsafe_arena_set_allocated:"
"$full_name$)\n"
"}\n");
}
} else {
// No-arena case.
format(
@ -761,38 +718,6 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" }\n"
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
"}\n");
if (options_.opensource_runtime) {
format(
"inline std::string* $classname$::unsafe_arena_release_$name$() {\n"
"$annotate_accessor$"
" // "
"@@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n"
" $DCHK$(GetArena() != nullptr);\n"
" if (_internal_has_$name$()) {\n"
" clear_has_$oneof_name$();\n"
" return $field_member$.UnsafeArenaRelease(\n"
" $default_variable$, GetArena());\n"
" } else {\n"
" return nullptr;\n"
" }\n"
"}\n"
"inline void $classname$::unsafe_arena_set_allocated_$name$("
"std::string* $name$) {\n"
"$annotate_accessor$"
" $DCHK$(GetArena() != nullptr);\n"
" if (!_internal_has_$name$()) {\n"
" $field_member$.UnsafeSetDefault($default_variable$);\n"
" }\n"
" clear_$oneof_name$();\n"
" if ($name$) {\n"
" set_has_$name$();\n"
" $field_member$.UnsafeArenaSetAllocated($default_variable$, "
"$name$, GetArena());\n"
" }\n"
" // @@protoc_insertion_point(field_unsafe_arena_set_allocated:"
"$full_name$)\n"
"}\n");
}
} else {
// No-arena case.
format(

@ -58,7 +58,7 @@ namespace java {
JavaGenerator::JavaGenerator() {}
JavaGenerator::~JavaGenerator() {}
uint64 JavaGenerator::GetSupportedFeatures() const {
uint64_t JavaGenerator::GetSupportedFeatures() const {
return CodeGenerator::Feature::FEATURE_PROTO3_OPTIONAL;
}

@ -60,7 +60,7 @@ class PROTOC_EXPORT JavaGenerator : public CodeGenerator {
bool Generate(const FileDescriptor* file, const std::string& parameter,
GeneratorContext* context, std::string* error) const override;
uint64 GetSupportedFeatures() const override;
uint64_t GetSupportedFeatures() const override;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JavaGenerator);

@ -87,7 +87,7 @@ MockCodeGenerator::MockCodeGenerator(const std::string& name) : name_(name) {}
MockCodeGenerator::~MockCodeGenerator() {}
uint64 MockCodeGenerator::GetSupportedFeatures() const {
uint64_t MockCodeGenerator::GetSupportedFeatures() const {
uint64 all_features = CodeGenerator::FEATURE_PROTO3_OPTIONAL;
return all_features & ~suppressed_features_;
}

@ -109,7 +109,7 @@ class MockCodeGenerator : public CodeGenerator {
bool Generate(const FileDescriptor* file, const std::string& parameter,
GeneratorContext* context, std::string* error) const override;
uint64 GetSupportedFeatures() const override;
uint64_t GetSupportedFeatures() const override;
void SuppressFeatures(uint64 features);
private:

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3011000
#if PROTOBUF_VERSION < 3012000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3011004 < PROTOBUF_MIN_PROTOC_VERSION
#if 3012002 < 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.
@ -53,7 +53,7 @@ PROTOBUF_NAMESPACE_CLOSE
struct PROTOC_EXPORT TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto {
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxillaryParseTableField aux[]
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[4]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
@ -251,15 +251,6 @@ class PROTOC_EXPORT Version PROTOBUF_FINAL :
std::string* mutable_suffix();
std::string* release_suffix();
void set_allocated_suffix(std::string* suffix);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_suffix();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_suffix(
std::string* suffix);
private:
const std::string& _internal_suffix() const;
void _internal_set_suffix(const std::string& value);
@ -503,15 +494,6 @@ class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL :
std::string* mutable_parameter();
std::string* release_parameter();
void set_allocated_parameter(std::string* parameter);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_parameter();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_parameter(
std::string* parameter);
private:
const std::string& _internal_parameter() const;
void _internal_set_parameter(const std::string& value);
@ -691,15 +673,6 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL :
std::string* mutable_name();
std::string* release_name();
void set_allocated_name(std::string* name);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_name();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_name(
std::string* name);
private:
const std::string& _internal_name() const;
void _internal_set_name(const std::string& value);
@ -720,15 +693,6 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL :
std::string* mutable_insertion_point();
std::string* release_insertion_point();
void set_allocated_insertion_point(std::string* insertion_point);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_insertion_point();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_insertion_point(
std::string* insertion_point);
private:
const std::string& _internal_insertion_point() const;
void _internal_set_insertion_point(const std::string& value);
@ -749,15 +713,6 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL :
std::string* mutable_content();
std::string* release_content();
void set_allocated_content(std::string* content);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_content();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_content(
std::string* content);
private:
const std::string& _internal_content() const;
void _internal_set_content(const std::string& value);
@ -968,15 +923,6 @@ class PROTOC_EXPORT CodeGeneratorResponse PROTOBUF_FINAL :
std::string* mutable_error();
std::string* release_error();
void set_allocated_error(std::string* error);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_error();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_error(
std::string* error);
private:
const std::string& _internal_error() const;
void _internal_set_error(const std::string& value);
@ -1178,25 +1124,6 @@ inline void Version::set_allocated_suffix(std::string* suffix) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix)
}
inline std::string* Version::unsafe_arena_release_suffix() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.compiler.Version.suffix)
GOOGLE_DCHECK(GetArena() != nullptr);
_has_bits_[0] &= ~0x00000001u;
return suffix_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void Version::unsafe_arena_set_allocated_suffix(
std::string* suffix) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (suffix != nullptr) {
_has_bits_[0] |= 0x00000001u;
} else {
_has_bits_[0] &= ~0x00000001u;
}
suffix_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
suffix, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.Version.suffix)
}
// -------------------------------------------------------------------
@ -1349,25 +1276,6 @@ inline void CodeGeneratorRequest::set_allocated_parameter(std::string* parameter
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.parameter)
}
inline std::string* CodeGeneratorRequest::unsafe_arena_release_parameter() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.compiler.CodeGeneratorRequest.parameter)
GOOGLE_DCHECK(GetArena() != nullptr);
_has_bits_[0] &= ~0x00000001u;
return parameter_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void CodeGeneratorRequest::unsafe_arena_set_allocated_parameter(
std::string* parameter) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (parameter != nullptr) {
_has_bits_[0] |= 0x00000001u;
} else {
_has_bits_[0] &= ~0x00000001u;
}
parameter_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
parameter, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.parameter)
}
// repeated .google.protobuf.FileDescriptorProto proto_file = 15;
inline int CodeGeneratorRequest::_internal_proto_file_size() const {
@ -1565,25 +1473,6 @@ inline void CodeGeneratorResponse_File::set_allocated_name(std::string* name) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name)
}
inline std::string* CodeGeneratorResponse_File::unsafe_arena_release_name() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.compiler.CodeGeneratorResponse.File.name)
GOOGLE_DCHECK(GetArena() != nullptr);
_has_bits_[0] &= ~0x00000001u;
return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void CodeGeneratorResponse_File::unsafe_arena_set_allocated_name(
std::string* name) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (name != nullptr) {
_has_bits_[0] |= 0x00000001u;
} else {
_has_bits_[0] &= ~0x00000001u;
}
name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
name, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name)
}
// optional string insertion_point = 2;
inline bool CodeGeneratorResponse_File::_internal_has_insertion_point() const {
@ -1658,25 +1547,6 @@ inline void CodeGeneratorResponse_File::set_allocated_insertion_point(std::strin
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
}
inline std::string* CodeGeneratorResponse_File::unsafe_arena_release_insertion_point() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
GOOGLE_DCHECK(GetArena() != nullptr);
_has_bits_[0] &= ~0x00000002u;
return insertion_point_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void CodeGeneratorResponse_File::unsafe_arena_set_allocated_insertion_point(
std::string* insertion_point) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (insertion_point != nullptr) {
_has_bits_[0] |= 0x00000002u;
} else {
_has_bits_[0] &= ~0x00000002u;
}
insertion_point_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
insertion_point, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
}
// optional string content = 15;
inline bool CodeGeneratorResponse_File::_internal_has_content() const {
@ -1751,25 +1621,6 @@ inline void CodeGeneratorResponse_File::set_allocated_content(std::string* conte
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content)
}
inline std::string* CodeGeneratorResponse_File::unsafe_arena_release_content() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.compiler.CodeGeneratorResponse.File.content)
GOOGLE_DCHECK(GetArena() != nullptr);
_has_bits_[0] &= ~0x00000004u;
return content_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void CodeGeneratorResponse_File::unsafe_arena_set_allocated_content(
std::string* content) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (content != nullptr) {
_has_bits_[0] |= 0x00000004u;
} else {
_has_bits_[0] &= ~0x00000004u;
}
content_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
content, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content)
}
// -------------------------------------------------------------------
@ -1848,25 +1699,6 @@ inline void CodeGeneratorResponse::set_allocated_error(std::string* error) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.error)
}
inline std::string* CodeGeneratorResponse::unsafe_arena_release_error() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.compiler.CodeGeneratorResponse.error)
GOOGLE_DCHECK(GetArena() != nullptr);
_has_bits_[0] &= ~0x00000001u;
return error_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void CodeGeneratorResponse::unsafe_arena_set_allocated_error(
std::string* error) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (error != nullptr) {
_has_bits_[0] |= 0x00000001u;
} else {
_has_bits_[0] &= ~0x00000001u;
}
error_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
error, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.error)
}
// optional uint64 supported_features = 2;
inline bool CodeGeneratorResponse::_internal_has_supported_features() const {

@ -301,7 +301,7 @@ Generator::Generator() : file_(nullptr) {}
Generator::~Generator() {}
uint64 Generator::GetSupportedFeatures() const {
uint64_t Generator::GetSupportedFeatures() const {
return CodeGenerator::Feature::FEATURE_PROTO3_OPTIONAL;
}

@ -73,7 +73,7 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
GeneratorContext* generator_context,
std::string* error) const override;
uint64 GetSupportedFeatures() const override;
uint64_t GetSupportedFeatures() const override;
private:
void PrintImports() const;

@ -434,14 +434,14 @@ struct PointerStringPairHash {
const Symbol kNullSymbol;
typedef HASH_MAP<const char*, Symbol, HASH_FXN<const char*>, streq>
typedef HASH_MAP<StringPiece, Symbol, HASH_FXN<StringPiece>>
SymbolsByNameMap;
typedef HASH_MAP<PointerStringPair, Symbol, PointerStringPairHash>
SymbolsByParentMap;
typedef HASH_MAP<const char*, const FileDescriptor*, HASH_FXN<const char*>,
streq>
typedef HASH_MAP<StringPiece, const FileDescriptor*,
HASH_FXN<StringPiece>>
FilesByNameMap;
typedef HASH_MAP<PointerStringPair, const FieldDescriptor*,
@ -576,16 +576,16 @@ class DescriptorPool::Tables {
// Find symbols. This returns a null Symbol (symbol.IsNull() is true)
// if not found.
inline Symbol FindSymbol(const std::string& key) const;
inline Symbol FindSymbol(StringPiece key) const;
// This implements the body of DescriptorPool::Find*ByName(). It should
// really be a private method of DescriptorPool, but that would require
// declaring Symbol in descriptor.h, which would drag all kinds of other
// stuff into the header. Yay C++.
Symbol FindByNameHelper(const DescriptorPool* pool, const std::string& name);
Symbol FindByNameHelper(const DescriptorPool* pool, StringPiece name);
// These return nullptr if not found.
inline const FileDescriptor* FindFile(const std::string& key) const;
inline const FileDescriptor* FindFile(StringPiece key) const;
inline const FieldDescriptor* FindExtension(const Descriptor* extendee,
int number) const;
inline void FindAllExtensions(const Descriptor* extendee,
@ -619,7 +619,7 @@ class DescriptorPool::Tables {
// Allocate a string which will be destroyed when the pool is destroyed.
// The string is initialized to the given value for convenience.
std::string* AllocateString(const std::string& value);
std::string* AllocateString(StringPiece value);
// Allocate empty string which will be destroyed when the pool is destroyed.
std::string* AllocateEmptyString();
@ -715,9 +715,9 @@ class FileDescriptorTables {
inline const FieldDescriptor* FindFieldByNumber(const Descriptor* parent,
int number) const;
inline const FieldDescriptor* FindFieldByLowercaseName(
const void* parent, const std::string& lowercase_name) const;
const void* parent, StringPiece lowercase_name) const;
inline const FieldDescriptor* FindFieldByCamelcaseName(
const void* parent, const std::string& camelcase_name) const;
const void* parent, StringPiece camelcase_name) const;
inline const EnumValueDescriptor* FindEnumValueByNumber(
const EnumDescriptor* parent, int number) const;
// This creates a new EnumValueDescriptor if not found, in a thread-safe way.
@ -884,8 +884,8 @@ void DescriptorPool::Tables::RollbackToLastCheckpoint() {
// -------------------------------------------------------------------
inline Symbol DescriptorPool::Tables::FindSymbol(const std::string& key) const {
const Symbol* result = FindOrNull(symbols_by_name_, key.c_str());
inline Symbol DescriptorPool::Tables::FindSymbol(StringPiece key) const {
const Symbol* result = FindOrNull(symbols_by_name_, key);
if (result == nullptr) {
return kNullSymbol;
} else {
@ -912,7 +912,7 @@ inline Symbol FileDescriptorTables::FindNestedSymbolOfType(
}
Symbol DescriptorPool::Tables::FindByNameHelper(const DescriptorPool* pool,
const std::string& name) {
StringPiece name) {
if (pool->mutex_ != nullptr) {
// Fast path: the Symbol is already cached. This is just a hash lookup.
ReaderMutexLock lock(pool->mutex_);
@ -944,8 +944,8 @@ Symbol DescriptorPool::Tables::FindByNameHelper(const DescriptorPool* pool,
}
inline const FileDescriptor* DescriptorPool::Tables::FindFile(
const std::string& key) const {
return FindPtrOrNull(files_by_name_, key.c_str());
StringPiece key) const {
return FindPtrOrNull(files_by_name_, key);
}
inline const FieldDescriptor* FileDescriptorTables::FindFieldByNumber(
@ -982,12 +982,12 @@ void FileDescriptorTables::FieldsByLowercaseNamesLazyInitInternal() const {
}
inline const FieldDescriptor* FileDescriptorTables::FindFieldByLowercaseName(
const void* parent, const std::string& lowercase_name) const {
const void* parent, StringPiece lowercase_name) const {
internal::call_once(
fields_by_lowercase_name_once_,
&FileDescriptorTables::FieldsByLowercaseNamesLazyInitStatic, this);
return FindPtrOrNull(fields_by_lowercase_name_,
PointerStringPair(parent, lowercase_name.c_str()));
PointerStringPair(parent, lowercase_name));
}
void FileDescriptorTables::FieldsByCamelcaseNamesLazyInitStatic(
@ -1006,12 +1006,12 @@ void FileDescriptorTables::FieldsByCamelcaseNamesLazyInitInternal() const {
}
inline const FieldDescriptor* FileDescriptorTables::FindFieldByCamelcaseName(
const void* parent, const std::string& camelcase_name) const {
const void* parent, StringPiece camelcase_name) const {
internal::call_once(
fields_by_camelcase_name_once_,
FileDescriptorTables::FieldsByCamelcaseNamesLazyInitStatic, this);
return FindPtrOrNull(fields_by_camelcase_name_,
PointerStringPair(parent, camelcase_name.c_str()));
PointerStringPair(parent, camelcase_name));
}
inline const EnumValueDescriptor* FileDescriptorTables::FindEnumValueByNumber(
@ -1181,7 +1181,7 @@ Type* DescriptorPool::Tables::AllocateArray(int count) {
return reinterpret_cast<Type*>(AllocateBytes(sizeof(Type) * count));
}
std::string* DescriptorPool::Tables::AllocateString(const std::string& value) {
std::string* DescriptorPool::Tables::AllocateString(StringPiece value) {
std::string* result = new std::string(value);
strings_.emplace_back(result);
return result;
@ -1293,16 +1293,16 @@ void DescriptorPool::InternalDontEnforceDependencies() {
enforce_dependencies_ = false;
}
void DescriptorPool::AddUnusedImportTrackFile(const std::string& file_name,
void DescriptorPool::AddUnusedImportTrackFile(ConstStringParam file_name,
bool is_error) {
unused_import_track_files_[file_name] = is_error;
unused_import_track_files_[std::string(file_name)] = is_error;
}
void DescriptorPool::ClearUnusedImportTrackFiles() {
unused_import_track_files_.clear();
}
bool DescriptorPool::InternalIsFileLoaded(const std::string& filename) const {
bool DescriptorPool::InternalIsFileLoaded(ConstStringParam filename) const {
MutexLockMaybe lock(mutex_);
return tables_->FindFile(filename) != nullptr;
}
@ -1379,7 +1379,7 @@ void DescriptorPool::InternalAddGeneratedFile(
// there's nothing more important to do (read: never).
const FileDescriptor* DescriptorPool::FindFileByName(
const std::string& name) const {
ConstStringParam name) const {
MutexLockMaybe lock(mutex_);
if (fallback_database_ != nullptr) {
tables_->known_bad_symbols_.clear();
@ -1399,7 +1399,7 @@ const FileDescriptor* DescriptorPool::FindFileByName(
}
const FileDescriptor* DescriptorPool::FindFileContainingSymbol(
const std::string& symbol_name) const {
ConstStringParam symbol_name) const {
MutexLockMaybe lock(mutex_);
if (fallback_database_ != nullptr) {
tables_->known_bad_symbols_.clear();
@ -1420,13 +1420,13 @@ const FileDescriptor* DescriptorPool::FindFileContainingSymbol(
}
const Descriptor* DescriptorPool::FindMessageTypeByName(
const std::string& name) const {
ConstStringParam name) const {
Symbol result = tables_->FindByNameHelper(this, name);
return (result.type == Symbol::MESSAGE) ? result.descriptor : nullptr;
}
const FieldDescriptor* DescriptorPool::FindFieldByName(
const std::string& name) const {
ConstStringParam name) const {
Symbol result = tables_->FindByNameHelper(this, name);
if (result.type == Symbol::FIELD &&
!result.field_descriptor->is_extension()) {
@ -1437,7 +1437,7 @@ const FieldDescriptor* DescriptorPool::FindFieldByName(
}
const FieldDescriptor* DescriptorPool::FindExtensionByName(
const std::string& name) const {
ConstStringParam name) const {
Symbol result = tables_->FindByNameHelper(this, name);
if (result.type == Symbol::FIELD && result.field_descriptor->is_extension()) {
return result.field_descriptor;
@ -1447,32 +1447,32 @@ const FieldDescriptor* DescriptorPool::FindExtensionByName(
}
const OneofDescriptor* DescriptorPool::FindOneofByName(
const std::string& name) const {
ConstStringParam name) const {
Symbol result = tables_->FindByNameHelper(this, name);
return (result.type == Symbol::ONEOF) ? result.oneof_descriptor : nullptr;
}
const EnumDescriptor* DescriptorPool::FindEnumTypeByName(
const std::string& name) const {
ConstStringParam name) const {
Symbol result = tables_->FindByNameHelper(this, name);
return (result.type == Symbol::ENUM) ? result.enum_descriptor : nullptr;
}
const EnumValueDescriptor* DescriptorPool::FindEnumValueByName(
const std::string& name) const {
ConstStringParam name) const {
Symbol result = tables_->FindByNameHelper(this, name);
return (result.type == Symbol::ENUM_VALUE) ? result.enum_value_descriptor
: nullptr;
}
const ServiceDescriptor* DescriptorPool::FindServiceByName(
const std::string& name) const {
ConstStringParam name) const {
Symbol result = tables_->FindByNameHelper(this, name);
return (result.type == Symbol::SERVICE) ? result.service_descriptor : nullptr;
}
const MethodDescriptor* DescriptorPool::FindMethodByName(
const std::string& name) const {
ConstStringParam name) const {
Symbol result = tables_->FindByNameHelper(this, name);
return (result.type == Symbol::METHOD) ? result.method_descriptor : nullptr;
}
@ -1529,7 +1529,7 @@ const FieldDescriptor* DescriptorPool::InternalFindExtensionByNumberNoLock(
}
const FieldDescriptor* DescriptorPool::FindExtensionByPrintableName(
const Descriptor* extendee, const std::string& printable_name) const {
const Descriptor* extendee, ConstStringParam printable_name) const {
if (extendee->extension_range_count() == 0) return nullptr;
const FieldDescriptor* result = FindExtensionByName(printable_name);
if (result != nullptr && result->containing_type() == extendee) {
@ -1600,7 +1600,7 @@ const FieldDescriptor* Descriptor::FindFieldByNumber(int key) const {
}
const FieldDescriptor* Descriptor::FindFieldByLowercaseName(
const std::string& key) const {
ConstStringParam key) const {
const FieldDescriptor* result =
file()->tables_->FindFieldByLowercaseName(this, key);
if (result == nullptr || result->is_extension()) {
@ -1611,7 +1611,7 @@ const FieldDescriptor* Descriptor::FindFieldByLowercaseName(
}
const FieldDescriptor* Descriptor::FindFieldByCamelcaseName(
const std::string& key) const {
ConstStringParam key) const {
const FieldDescriptor* result =
file()->tables_->FindFieldByCamelcaseName(this, key);
if (result == nullptr || result->is_extension()) {
@ -1621,8 +1621,7 @@ const FieldDescriptor* Descriptor::FindFieldByCamelcaseName(
}
}
const FieldDescriptor* Descriptor::FindFieldByName(
const std::string& key) const {
const FieldDescriptor* Descriptor::FindFieldByName(ConstStringParam key) const {
Symbol result =
file()->tables_->FindNestedSymbolOfType(this, key, Symbol::FIELD);
if (!result.IsNull() && !result.field_descriptor->is_extension()) {
@ -1632,8 +1631,7 @@ const FieldDescriptor* Descriptor::FindFieldByName(
}
}
const OneofDescriptor* Descriptor::FindOneofByName(
const std::string& key) const {
const OneofDescriptor* Descriptor::FindOneofByName(ConstStringParam key) const {
Symbol result =
file()->tables_->FindNestedSymbolOfType(this, key, Symbol::ONEOF);
if (!result.IsNull()) {
@ -1644,7 +1642,7 @@ const OneofDescriptor* Descriptor::FindOneofByName(
}
const FieldDescriptor* Descriptor::FindExtensionByName(
const std::string& key) const {
ConstStringParam key) const {
Symbol result =
file()->tables_->FindNestedSymbolOfType(this, key, Symbol::FIELD);
if (!result.IsNull() && result.field_descriptor->is_extension()) {
@ -1655,7 +1653,7 @@ const FieldDescriptor* Descriptor::FindExtensionByName(
}
const FieldDescriptor* Descriptor::FindExtensionByLowercaseName(
const std::string& key) const {
ConstStringParam key) const {
const FieldDescriptor* result =
file()->tables_->FindFieldByLowercaseName(this, key);
if (result == nullptr || !result->is_extension()) {
@ -1666,7 +1664,7 @@ const FieldDescriptor* Descriptor::FindExtensionByLowercaseName(
}
const FieldDescriptor* Descriptor::FindExtensionByCamelcaseName(
const std::string& key) const {
ConstStringParam key) const {
const FieldDescriptor* result =
file()->tables_->FindFieldByCamelcaseName(this, key);
if (result == nullptr || !result->is_extension()) {
@ -1676,8 +1674,7 @@ const FieldDescriptor* Descriptor::FindExtensionByCamelcaseName(
}
}
const Descriptor* Descriptor::FindNestedTypeByName(
const std::string& key) const {
const Descriptor* Descriptor::FindNestedTypeByName(ConstStringParam key) const {
Symbol result =
file()->tables_->FindNestedSymbolOfType(this, key, Symbol::MESSAGE);
if (!result.IsNull()) {
@ -1688,7 +1685,7 @@ const Descriptor* Descriptor::FindNestedTypeByName(
}
const EnumDescriptor* Descriptor::FindEnumTypeByName(
const std::string& key) const {
ConstStringParam key) const {
Symbol result =
file()->tables_->FindNestedSymbolOfType(this, key, Symbol::ENUM);
if (!result.IsNull()) {
@ -1699,7 +1696,7 @@ const EnumDescriptor* Descriptor::FindEnumTypeByName(
}
const EnumValueDescriptor* Descriptor::FindEnumValueByName(
const std::string& key) const {
ConstStringParam key) const {
Symbol result =
file()->tables_->FindNestedSymbolOfType(this, key, Symbol::ENUM_VALUE);
if (!result.IsNull()) {
@ -1742,7 +1739,7 @@ const EnumValueDescriptor* EnumDescriptor::FindValueByNumberCreatingIfUnknown(
}
const MethodDescriptor* ServiceDescriptor::FindMethodByName(
const std::string& key) const {
ConstStringParam key) const {
Symbol result =
file()->tables_->FindNestedSymbolOfType(this, key, Symbol::METHOD);
if (!result.IsNull()) {
@ -1753,7 +1750,7 @@ const MethodDescriptor* ServiceDescriptor::FindMethodByName(
}
const Descriptor* FileDescriptor::FindMessageTypeByName(
const std::string& key) const {
ConstStringParam key) const {
Symbol result = tables_->FindNestedSymbolOfType(this, key, Symbol::MESSAGE);
if (!result.IsNull()) {
return result.descriptor;
@ -1763,7 +1760,7 @@ const Descriptor* FileDescriptor::FindMessageTypeByName(
}
const EnumDescriptor* FileDescriptor::FindEnumTypeByName(
const std::string& key) const {
ConstStringParam key) const {
Symbol result = tables_->FindNestedSymbolOfType(this, key, Symbol::ENUM);
if (!result.IsNull()) {
return result.enum_descriptor;
@ -1773,7 +1770,7 @@ const EnumDescriptor* FileDescriptor::FindEnumTypeByName(
}
const EnumValueDescriptor* FileDescriptor::FindEnumValueByName(
const std::string& key) const {
ConstStringParam key) const {
Symbol result =
tables_->FindNestedSymbolOfType(this, key, Symbol::ENUM_VALUE);
if (!result.IsNull()) {
@ -1784,7 +1781,7 @@ const EnumValueDescriptor* FileDescriptor::FindEnumValueByName(
}
const ServiceDescriptor* FileDescriptor::FindServiceByName(
const std::string& key) const {
ConstStringParam key) const {
Symbol result = tables_->FindNestedSymbolOfType(this, key, Symbol::SERVICE);
if (!result.IsNull()) {
return result.service_descriptor;
@ -1794,7 +1791,7 @@ const ServiceDescriptor* FileDescriptor::FindServiceByName(
}
const FieldDescriptor* FileDescriptor::FindExtensionByName(
const std::string& key) const {
ConstStringParam key) const {
Symbol result = tables_->FindNestedSymbolOfType(this, key, Symbol::FIELD);
if (!result.IsNull() && result.field_descriptor->is_extension()) {
return result.field_descriptor;
@ -1804,7 +1801,7 @@ const FieldDescriptor* FileDescriptor::FindExtensionByName(
}
const FieldDescriptor* FileDescriptor::FindExtensionByLowercaseName(
const std::string& key) const {
ConstStringParam key) const {
const FieldDescriptor* result = tables_->FindFieldByLowercaseName(this, key);
if (result == nullptr || !result->is_extension()) {
return nullptr;
@ -1814,7 +1811,7 @@ const FieldDescriptor* FileDescriptor::FindExtensionByLowercaseName(
}
const FieldDescriptor* FileDescriptor::FindExtensionByCamelcaseName(
const std::string& key) const {
ConstStringParam key) const {
const FieldDescriptor* result = tables_->FindFieldByCamelcaseName(this, key);
if (result == nullptr || !result->is_extension()) {
return nullptr;
@ -1871,22 +1868,23 @@ EnumDescriptor::FindReservedRangeContainingNumber(int number) const {
// -------------------------------------------------------------------
bool DescriptorPool::TryFindFileInFallbackDatabase(
const std::string& name) const {
StringPiece name) const {
if (fallback_database_ == nullptr) return false;
if (tables_->known_bad_files_.count(name) > 0) return false;
auto name_string = std::string(name);
if (tables_->known_bad_files_.count(name_string) > 0) return false;
FileDescriptorProto file_proto;
if (!fallback_database_->FindFileByName(name, &file_proto) ||
if (!fallback_database_->FindFileByName(name_string, &file_proto) ||
BuildFileFromDatabase(file_proto) == nullptr) {
tables_->known_bad_files_.insert(name);
tables_->known_bad_files_.insert(std::move(name_string));
return false;
}
return true;
}
bool DescriptorPool::IsSubSymbolOfBuiltType(const std::string& name) const {
std::string prefix = name;
bool DescriptorPool::IsSubSymbolOfBuiltType(StringPiece name) const {
auto prefix = std::string(name);
for (;;) {
std::string::size_type dot_pos = prefix.find_last_of('.');
if (dot_pos == std::string::npos) {
@ -1908,10 +1906,11 @@ bool DescriptorPool::IsSubSymbolOfBuiltType(const std::string& name) const {
}
bool DescriptorPool::TryFindSymbolInFallbackDatabase(
const std::string& name) const {
StringPiece name) const {
if (fallback_database_ == nullptr) return false;
if (tables_->known_bad_symbols_.count(name) > 0) return false;
auto name_string = std::string(name);
if (tables_->known_bad_symbols_.count(name_string) > 0) return false;
FileDescriptorProto file_proto;
if ( // We skip looking in the fallback database if the name is a sub-symbol
@ -1933,7 +1932,7 @@ bool DescriptorPool::TryFindSymbolInFallbackDatabase(
IsSubSymbolOfBuiltType(name)
// Look up file containing this symbol in fallback database.
|| !fallback_database_->FindFileContainingSymbol(name, &file_proto)
|| !fallback_database_->FindFileContainingSymbol(name_string, &file_proto)
// Check if we've already built this file. If so, it apparently doesn't
// contain the symbol we're looking for. Some DescriptorDatabases
@ -1942,7 +1941,7 @@ bool DescriptorPool::TryFindSymbolInFallbackDatabase(
// Build the file.
|| BuildFileFromDatabase(file_proto) == nullptr) {
tables_->known_bad_symbols_.insert(name);
tables_->known_bad_symbols_.insert(std::move(name_string));
return false;
}
@ -3864,7 +3863,7 @@ Symbol DescriptorBuilder::LookupSymbol(
return result;
}
static bool ValidateQualifiedName(const std::string& name) {
static bool ValidateQualifiedName(StringPiece name) {
bool last_was_period = false;
for (int i = 0; i < name.size(); i++) {
@ -3884,14 +3883,14 @@ static bool ValidateQualifiedName(const std::string& name) {
return !name.empty() && !last_was_period;
}
Symbol DescriptorPool::NewPlaceholder(const std::string& name,
Symbol DescriptorPool::NewPlaceholder(StringPiece name,
PlaceholderType placeholder_type) const {
MutexLockMaybe lock(mutex_);
return NewPlaceholderWithMutexHeld(name, placeholder_type);
}
Symbol DescriptorPool::NewPlaceholderWithMutexHeld(
const std::string& name, PlaceholderType placeholder_type) const {
StringPiece name, PlaceholderType placeholder_type) const {
if (mutex_) {
mutex_->AssertHeld();
}
@ -3989,13 +3988,13 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld(
}
FileDescriptor* DescriptorPool::NewPlaceholderFile(
const std::string& name) const {
StringPiece name) const {
MutexLockMaybe lock(mutex_);
return NewPlaceholderFileWithMutexHeld(name);
}
FileDescriptor* DescriptorPool::NewPlaceholderFileWithMutexHeld(
const std::string& name) const {
StringPiece name) const {
if (mutex_) {
mutex_->AssertHeld();
}
@ -7269,9 +7268,9 @@ void DescriptorBuilder::LogUnusedDependency(const FileDescriptorProto& proto,
}
}
Symbol DescriptorPool::CrossLinkOnDemandHelper(const std::string& name,
Symbol DescriptorPool::CrossLinkOnDemandHelper(StringPiece name,
bool expecting_enum) const {
std::string lookup_name = name;
auto lookup_name = std::string(name);
if (!lookup_name.empty() && lookup_name[0] == '.') {
lookup_name = lookup_name.substr(1);
}
@ -7399,7 +7398,7 @@ void LazyDescriptor::Set(const Descriptor* descriptor) {
descriptor_ = descriptor;
}
void LazyDescriptor::SetLazy(const std::string& name,
void LazyDescriptor::SetLazy(StringPiece name,
const FileDescriptor* file) {
// verify Init() has been called and Set hasn't been called yet.
GOOGLE_CHECK(!descriptor_);

@ -203,7 +203,7 @@ class PROTOBUF_EXPORT LazyDescriptor {
// build time if the symbol wasn't found and building of the file containing
// that type is delayed because lazily_build_dependencies_ is set on the pool.
// Should not be called after Set() has been called.
void SetLazy(const std::string& name, const FileDescriptor* file);
void SetLazy(StringPiece name, const FileDescriptor* file);
// Returns the current value of the descriptor, thread-safe. If SetLazy(...)
// has been called, will do a one-time cross link of the type specified,
@ -321,20 +321,20 @@ class PROTOBUF_EXPORT Descriptor {
// exists.
const FieldDescriptor* FindFieldByNumber(int number) const;
// Looks up a field by name. Returns nullptr if no such field exists.
const FieldDescriptor* FindFieldByName(const std::string& name) const;
const FieldDescriptor* FindFieldByName(ConstStringParam name) const;
// Looks up a field by lowercased name (as returned by lowercase_name()).
// This lookup may be ambiguous if multiple field names differ only by case,
// in which case the field returned is chosen arbitrarily from the matches.
const FieldDescriptor* FindFieldByLowercaseName(
const std::string& lowercase_name) const;
ConstStringParam lowercase_name) const;
// Looks up a field by camel-case name (as returned by camelcase_name()).
// This lookup may be ambiguous if multiple field names differ in a way that
// leads them to have identical camel-case names, in which case the field
// returned is chosen arbitrarily from the matches.
const FieldDescriptor* FindFieldByCamelcaseName(
const std::string& camelcase_name) const;
ConstStringParam camelcase_name) const;
// The number of oneofs in this message type.
int oneof_decl_count() const;
@ -347,7 +347,7 @@ class PROTOBUF_EXPORT Descriptor {
const OneofDescriptor* oneof_decl(int index) const;
// Looks up a oneof by name. Returns nullptr if no such oneof exists.
const OneofDescriptor* FindOneofByName(const std::string& name) const;
const OneofDescriptor* FindOneofByName(ConstStringParam name) const;
// Nested type stuff -----------------------------------------------
@ -359,7 +359,7 @@ class PROTOBUF_EXPORT Descriptor {
// Looks up a nested type by name. Returns nullptr if no such nested type
// exists.
const Descriptor* FindNestedTypeByName(const std::string& name) const;
const Descriptor* FindNestedTypeByName(ConstStringParam name) const;
// Enum stuff ------------------------------------------------------
@ -371,11 +371,11 @@ class PROTOBUF_EXPORT Descriptor {
// Looks up an enum type by name. Returns nullptr if no such enum type
// exists.
const EnumDescriptor* FindEnumTypeByName(const std::string& name) const;
const EnumDescriptor* FindEnumTypeByName(ConstStringParam name) const;
// Looks up an enum value by name, among all enum types in this message.
// Returns nullptr if no such value exists.
const EnumValueDescriptor* FindEnumValueByName(const std::string& name) const;
const EnumValueDescriptor* FindEnumValueByName(ConstStringParam name) const;
// Extensions ------------------------------------------------------
@ -439,17 +439,17 @@ class PROTOBUF_EXPORT Descriptor {
// Looks up a named extension (which extends some *other* message type)
// defined within this message type's scope.
const FieldDescriptor* FindExtensionByName(const std::string& name) const;
const FieldDescriptor* FindExtensionByName(ConstStringParam name) const;
// Similar to FindFieldByLowercaseName(), but finds extensions defined within
// this message type's scope.
const FieldDescriptor* FindExtensionByLowercaseName(
const std::string& name) const;
ConstStringParam name) const;
// Similar to FindFieldByCamelcaseName(), but finds extensions defined within
// this message type's scope.
const FieldDescriptor* FindExtensionByCamelcaseName(
const std::string& name) const;
ConstStringParam name) const;
// Reserved fields -------------------------------------------------
@ -479,7 +479,7 @@ class PROTOBUF_EXPORT Descriptor {
const std::string& reserved_name(int index) const;
// Returns true if the field name is reserved.
bool IsReservedName(const std::string& name) const;
bool IsReservedName(ConstStringParam name) const;
// Source Location ---------------------------------------------------
@ -1088,7 +1088,7 @@ class PROTOBUF_EXPORT EnumDescriptor {
const std::string& reserved_name(int index) const;
// Returns true if the field name is reserved.
bool IsReservedName(const std::string& name) const;
bool IsReservedName(ConstStringParam name) const;
// Source Location ---------------------------------------------------
@ -1267,7 +1267,7 @@ class PROTOBUF_EXPORT ServiceDescriptor {
const MethodDescriptor* method(int index) const;
// Look up a MethodDescriptor by name.
const MethodDescriptor* FindMethodByName(const std::string& name) const;
const MethodDescriptor* FindMethodByName(ConstStringParam name) const;
// See Descriptor::CopyTo().
void CopyTo(ServiceDescriptorProto* proto) const;
@ -1488,25 +1488,25 @@ class PROTOBUF_EXPORT FileDescriptor {
static const char* SyntaxName(Syntax syntax);
// Find a top-level message type by name. Returns nullptr if not found.
const Descriptor* FindMessageTypeByName(const std::string& name) const;
const Descriptor* FindMessageTypeByName(ConstStringParam name) const;
// Find a top-level enum type by name. Returns nullptr if not found.
const EnumDescriptor* FindEnumTypeByName(const std::string& name) const;
const EnumDescriptor* FindEnumTypeByName(ConstStringParam name) const;
// Find an enum value defined in any top-level enum by name. Returns nullptr
// if not found.
const EnumValueDescriptor* FindEnumValueByName(const std::string& name) const;
const EnumValueDescriptor* FindEnumValueByName(ConstStringParam name) const;
// Find a service definition by name. Returns nullptr if not found.
const ServiceDescriptor* FindServiceByName(const std::string& name) const;
const ServiceDescriptor* FindServiceByName(ConstStringParam name) const;
// Find a top-level extension definition by name. Returns nullptr if not
// found.
const FieldDescriptor* FindExtensionByName(const std::string& name) const;
const FieldDescriptor* FindExtensionByName(ConstStringParam name) const;
// Similar to FindExtensionByName(), but searches by lowercased-name. See
// Descriptor::FindFieldByLowercaseName().
const FieldDescriptor* FindExtensionByLowercaseName(
const std::string& name) const;
ConstStringParam name) const;
// Similar to FindExtensionByName(), but searches by camelcased-name. See
// Descriptor::FindFieldByCamelcaseName().
const FieldDescriptor* FindExtensionByCamelcaseName(
const std::string& name) const;
ConstStringParam name) const;
// See Descriptor::CopyTo().
// Notes:
@ -1669,28 +1669,28 @@ class PROTOBUF_EXPORT DescriptorPool {
// Find a FileDescriptor in the pool by file name. Returns nullptr if not
// found.
const FileDescriptor* FindFileByName(const std::string& name) const;
const FileDescriptor* FindFileByName(ConstStringParam name) const;
// Find the FileDescriptor in the pool which defines the given symbol.
// If any of the Find*ByName() methods below would succeed, then this is
// equivalent to calling that method and calling the result's file() method.
// Otherwise this returns nullptr.
const FileDescriptor* FindFileContainingSymbol(
const std::string& symbol_name) const;
ConstStringParam symbol_name) const;
// Looking up descriptors ------------------------------------------
// These find descriptors by fully-qualified name. These will find both
// top-level descriptors and nested descriptors. They return nullptr if not
// found.
const Descriptor* FindMessageTypeByName(const std::string& name) const;
const FieldDescriptor* FindFieldByName(const std::string& name) const;
const FieldDescriptor* FindExtensionByName(const std::string& name) const;
const OneofDescriptor* FindOneofByName(const std::string& name) const;
const EnumDescriptor* FindEnumTypeByName(const std::string& name) const;
const EnumValueDescriptor* FindEnumValueByName(const std::string& name) const;
const ServiceDescriptor* FindServiceByName(const std::string& name) const;
const MethodDescriptor* FindMethodByName(const std::string& name) const;
const Descriptor* FindMessageTypeByName(ConstStringParam name) const;
const FieldDescriptor* FindFieldByName(ConstStringParam name) const;
const FieldDescriptor* FindExtensionByName(ConstStringParam name) const;
const OneofDescriptor* FindOneofByName(ConstStringParam name) const;
const EnumDescriptor* FindEnumTypeByName(ConstStringParam name) const;
const EnumValueDescriptor* FindEnumValueByName(ConstStringParam name) const;
const ServiceDescriptor* FindServiceByName(ConstStringParam name) const;
const MethodDescriptor* FindMethodByName(ConstStringParam name) const;
// Finds an extension of the given type by number. The extendee must be
// a member of this DescriptorPool or one of its underlays.
@ -1703,7 +1703,7 @@ class PROTOBUF_EXPORT DescriptorPool {
// or one of its underlays. Returns nullptr if there is no known message
// extension with the given printable name.
const FieldDescriptor* FindExtensionByPrintableName(
const Descriptor* extendee, const std::string& printable_name) const;
const Descriptor* extendee, ConstStringParam printable_name) const;
// Finds extensions of extendee. The extensions will be appended to
// out in an undefined order. Only extensions defined directly in
@ -1876,11 +1876,11 @@ class PROTOBUF_EXPORT DescriptorPool {
// For internal (unit test) use only: Returns true if a FileDescriptor has
// been constructed for the given file, false otherwise. Useful for testing
// lazy descriptor initialization behavior.
bool InternalIsFileLoaded(const std::string& filename) const;
bool InternalIsFileLoaded(ConstStringParam filename) const;
// Add a file to unused_import_track_files_. DescriptorBuilder will log
// warnings or errors for those files if there is any unused import.
void AddUnusedImportTrackFile(const std::string& file_name,
void AddUnusedImportTrackFile(ConstStringParam file_name,
bool is_error = false);
void ClearUnusedImportTrackFiles();
@ -1899,14 +1899,14 @@ class PROTOBUF_EXPORT DescriptorPool {
// Return true if the given name is a sub-symbol of any non-package
// descriptor that already exists in the descriptor pool. (The full
// definition of such types is already known.)
bool IsSubSymbolOfBuiltType(const std::string& name) const;
bool IsSubSymbolOfBuiltType(StringPiece name) const;
// Tries to find something in the fallback database and link in the
// corresponding proto file. Returns true if successful, in which case
// the caller should search for the thing again. These are declared
// const because they are called by (semantically) const methods.
bool TryFindFileInFallbackDatabase(const std::string& name) const;
bool TryFindSymbolInFallbackDatabase(const std::string& name) const;
bool TryFindFileInFallbackDatabase(StringPiece name) const;
bool TryFindSymbolInFallbackDatabase(StringPiece name) const;
bool TryFindExtensionInFallbackDatabase(const Descriptor* containing_type,
int field_number) const;
@ -1927,13 +1927,12 @@ class PROTOBUF_EXPORT DescriptorPool {
// symbol is defined if necessary. Will create a placeholder if the type
// doesn't exist in the fallback database, or the file doesn't build
// successfully.
Symbol CrossLinkOnDemandHelper(const std::string& name,
Symbol CrossLinkOnDemandHelper(StringPiece name,
bool expecting_enum) const;
// Create a placeholder FileDescriptor of the specified name
FileDescriptor* NewPlaceholderFile(const std::string& name) const;
FileDescriptor* NewPlaceholderFileWithMutexHeld(
const std::string& name) const;
FileDescriptor* NewPlaceholderFile(StringPiece name) const;
FileDescriptor* NewPlaceholderFileWithMutexHeld(StringPiece name) const;
enum PlaceholderType {
PLACEHOLDER_MESSAGE,
@ -1941,9 +1940,9 @@ class PROTOBUF_EXPORT DescriptorPool {
PLACEHOLDER_EXTENDABLE_MESSAGE
};
// Create a placeholder Descriptor of the specified name
Symbol NewPlaceholder(const std::string& name,
Symbol NewPlaceholder(StringPiece name,
PlaceholderType placeholder_type) const;
Symbol NewPlaceholderWithMutexHeld(const std::string& name,
Symbol NewPlaceholderWithMutexHeld(StringPiece name,
PlaceholderType placeholder_type) const;
// If fallback_database_ is nullptr, this is nullptr. Otherwise, this is a
@ -2126,9 +2125,9 @@ inline bool Descriptor::IsReservedNumber(int number) const {
return FindReservedRangeContainingNumber(number) != nullptr;
}
inline bool Descriptor::IsReservedName(const std::string& name) const {
inline bool Descriptor::IsReservedName(ConstStringParam name) const {
for (int i = 0; i < reserved_name_count(); i++) {
if (name == reserved_name(i)) {
if (name == static_cast<ConstStringParam>(reserved_name(i))) {
return true;
}
}
@ -2145,9 +2144,9 @@ inline bool EnumDescriptor::IsReservedNumber(int number) const {
return FindReservedRangeContainingNumber(number) != nullptr;
}
inline bool EnumDescriptor::IsReservedName(const std::string& name) const {
inline bool EnumDescriptor::IsReservedName(ConstStringParam name) const {
for (int i = 0; i < reserved_name_count(); i++) {
if (name == reserved_name(i)) {
if (name == static_cast<ConstStringParam>(reserved_name(i))) {
return true;
}
}

File diff suppressed because it is too large Load Diff

@ -390,8 +390,6 @@ bool SimpleDescriptorDatabase::MaybeCopy(const FileDescriptorProto* file,
// -------------------------------------------------------------------
class EncodedDescriptorDatabase::DescriptorIndex {
using String = std::string;
public:
using Value = std::pair<const void*, int>;
// Helpers to recursively add particular descriptors and all their contents
@ -410,15 +408,13 @@ class EncodedDescriptorDatabase::DescriptorIndex {
private:
friend class EncodedDescriptorDatabase;
bool AddSymbol(StringPiece package, StringPiece symbol,
Value value);
bool AddSymbol(StringPiece symbol);
template <typename DescProto>
bool AddNestedExtensions(StringPiece filename,
const DescProto& message_type, Value value);
const DescProto& message_type);
template <typename FieldProto>
bool AddExtension(StringPiece filename, const FieldProto& field,
Value value);
bool AddExtension(StringPiece filename, const FieldProto& field);
// All the maps below have two representations:
// - a std::set<> where we insert initially.
@ -429,47 +425,80 @@ class EncodedDescriptorDatabase::DescriptorIndex {
void EnsureFlat();
using String = std::string;
String EncodeString(StringPiece str) const { return String(str); }
StringPiece DecodeString(const String& str, int) const { return str; }
struct EncodedEntry {
// Do not use `Value` here to avoid the padding of that object.
const void* data;
int size;
// Keep the package here instead of each SymbolEntry to save space.
String encoded_package;
Value value() const { return {data, size}; }
};
std::vector<EncodedEntry> all_values_;
struct FileEntry {
String name;
Value data;
int data_offset;
String encoded_name;
StringPiece name(const DescriptorIndex& index) const {
return index.DecodeString(encoded_name, data_offset);
}
};
struct FileCompare {
const DescriptorIndex& index;
bool operator()(const FileEntry& a, const FileEntry& b) const {
return a.name < b.name;
return a.name(index) < b.name(index);
}
bool operator()(const FileEntry& a, StringPiece b) const {
return a.name < b;
return a.name(index) < b;
}
bool operator()(StringPiece a, const FileEntry& b) const {
return a < b.name;
return a < b.name(index);
}
};
std::set<FileEntry, FileCompare> by_name_;
std::set<FileEntry, FileCompare> by_name_{FileCompare{*this}};
std::vector<FileEntry> by_name_flat_;
struct SymbolEntry {
String package;
String symbol;
Value data;
int data_offset;
String encoded_symbol;
std::string AsString() const {
return StrCat(package, package.empty() ? "" : ".", symbol);
StringPiece package(const DescriptorIndex& index) const {
return index.DecodeString(index.all_values_[data_offset].encoded_package,
data_offset);
}
StringPiece symbol(const DescriptorIndex& index) const {
return index.DecodeString(encoded_symbol, data_offset);
}
std::string AsString(const DescriptorIndex& index) const {
auto p = package(index);
return StrCat(p, p.empty() ? "" : ".", symbol(index));
}
};
struct SymbolCompare {
static std::string AsString(const SymbolEntry& entry) {
return entry.AsString();
const DescriptorIndex& index;
std::string AsString(const SymbolEntry& entry) const {
return entry.AsString(index);
}
static StringPiece AsString(StringPiece str) { return str; }
static std::pair<StringPiece, StringPiece> GetParts(
const SymbolEntry& entry) {
if (entry.package.empty()) return {entry.symbol, StringPiece{}};
return {entry.package, entry.symbol};
std::pair<StringPiece, StringPiece> GetParts(
const SymbolEntry& entry) const {
auto package = entry.package(index);
if (package.empty()) return {entry.symbol(index), StringPiece{}};
return {package, entry.symbol(index)};
}
static std::pair<StringPiece, StringPiece> GetParts(
StringPiece str) {
std::pair<StringPiece, StringPiece> GetParts(
StringPiece str) const {
return {str, {}};
}
@ -490,29 +519,35 @@ class EncodedDescriptorDatabase::DescriptorIndex {
return AsString(lhs) < AsString(rhs);
}
};
std::set<SymbolEntry, SymbolCompare> by_symbol_;
std::set<SymbolEntry, SymbolCompare> by_symbol_{SymbolCompare{*this}};
std::vector<SymbolEntry> by_symbol_flat_;
struct ExtensionEntry {
String extendee;
int data_offset;
String encoded_extendee;
StringPiece extendee(const DescriptorIndex& index) const {
return index.DecodeString(encoded_extendee, data_offset).substr(1);
}
int extension_number;
Value data;
};
struct ExtensionCompare {
const DescriptorIndex& index;
bool operator()(const ExtensionEntry& a, const ExtensionEntry& b) const {
return std::tie(a.extendee, a.extension_number) <
std::tie(b.extendee, b.extension_number);
return std::make_tuple(a.extendee(index), a.extension_number) <
std::make_tuple(b.extendee(index), b.extension_number);
}
bool operator()(const ExtensionEntry& a,
std::tuple<StringPiece, int> b) const {
return std::tie(a.extendee, a.extension_number) < b;
return std::make_tuple(a.extendee(index), a.extension_number) < b;
}
bool operator()(std::tuple<StringPiece, int> a,
const ExtensionEntry& b) const {
return a < std::tie(b.extendee, b.extension_number);
return a < std::make_tuple(b.extendee(index), b.extension_number);
}
};
std::set<ExtensionEntry, ExtensionCompare> by_extension_;
std::set<ExtensionEntry, ExtensionCompare> by_extension_{
ExtensionCompare{*this}};
std::vector<ExtensionEntry> by_extension_flat_;
};
@ -591,40 +626,51 @@ bool EncodedDescriptorDatabase::FindAllExtensionNumbers(
template <typename FileProto>
bool EncodedDescriptorDatabase::DescriptorIndex::AddFile(const FileProto& file,
Value value) {
if (!InsertIfNotPresent(&by_name_, FileEntry{file.name(), value}) ||
// We push `value` into the array first. This is important because the AddXXX
// functions below will expect it to be there.
all_values_.push_back({value.first, value.second});
if (!ValidateSymbolName(file.package())) {
GOOGLE_LOG(ERROR) << "Invalid package name: " << file.package();
return false;
}
all_values_.back().encoded_package = EncodeString(file.package());
if (!InsertIfNotPresent(
&by_name_, FileEntry{static_cast<int>(all_values_.size() - 1),
EncodeString(file.name())}) ||
std::binary_search(by_name_flat_.begin(), by_name_flat_.end(),
file.name(), by_name_.key_comp())) {
GOOGLE_LOG(ERROR) << "File already exists in database: " << file.name();
return false;
}
StringPiece package = file.package();
for (const auto& message_type : file.message_type()) {
if (!AddSymbol(package, message_type.name(), value)) return false;
if (!AddNestedExtensions(file.name(), message_type, value)) return false;
if (!AddSymbol(message_type.name())) return false;
if (!AddNestedExtensions(file.name(), message_type)) return false;
}
for (const auto& enum_type : file.enum_type()) {
if (!AddSymbol(package, enum_type.name(), value)) return false;
if (!AddSymbol(enum_type.name())) return false;
}
for (const auto& extension : file.extension()) {
if (!AddSymbol(package, extension.name(), value)) return false;
if (!AddExtension(file.name(), extension, value)) return false;
if (!AddSymbol(extension.name())) return false;
if (!AddExtension(file.name(), extension)) return false;
}
for (const auto& service : file.service()) {
if (!AddSymbol(package, service.name(), value)) return false;
if (!AddSymbol(service.name())) return false;
}
return true;
}
template <typename Iter, typename Iter2>
template <typename Iter, typename Iter2, typename Index>
static bool CheckForMutualSubsymbols(StringPiece symbol_name, Iter* iter,
Iter2 end) {
Iter2 end, const Index& index) {
if (*iter != end) {
if (IsSubSymbol((*iter)->AsString(), symbol_name)) {
if (IsSubSymbol((*iter)->AsString(index), symbol_name)) {
GOOGLE_LOG(ERROR) << "Symbol name \"" << symbol_name
<< "\" conflicts with the existing symbol \""
<< (*iter)->AsString() << "\".";
<< (*iter)->AsString(index) << "\".";
return false;
}
@ -635,10 +681,10 @@ static bool CheckForMutualSubsymbols(StringPiece symbol_name, Iter* iter,
// to increment it.
++*iter;
if (*iter != end && IsSubSymbol(symbol_name, (*iter)->AsString())) {
if (*iter != end && IsSubSymbol(symbol_name, (*iter)->AsString(index))) {
GOOGLE_LOG(ERROR) << "Symbol name \"" << symbol_name
<< "\" conflicts with the existing symbol \""
<< (*iter)->AsString() << "\".";
<< (*iter)->AsString(index) << "\".";
return false;
}
}
@ -646,22 +692,24 @@ static bool CheckForMutualSubsymbols(StringPiece symbol_name, Iter* iter,
}
bool EncodedDescriptorDatabase::DescriptorIndex::AddSymbol(
StringPiece package, StringPiece symbol, Value value) {
SymbolEntry entry = {String(package), String(symbol), value};
std::string entry_as_string = entry.AsString();
StringPiece symbol) {
SymbolEntry entry = {static_cast<int>(all_values_.size() - 1),
EncodeString(symbol)};
std::string entry_as_string = entry.AsString(*this);
// We need to make sure not to violate our map invariant.
// If the symbol name is invalid it could break our lookup algorithm (which
// relies on the fact that '.' sorts before all other characters that are
// valid in symbol names).
if (!ValidateSymbolName(package) || !ValidateSymbolName(symbol)) {
if (!ValidateSymbolName(symbol)) {
GOOGLE_LOG(ERROR) << "Invalid symbol name: " << entry_as_string;
return false;
}
auto iter = FindLastLessOrEqual(&by_symbol_, entry);
if (!CheckForMutualSubsymbols(entry_as_string, &iter, by_symbol_.end())) {
if (!CheckForMutualSubsymbols(entry_as_string, &iter, by_symbol_.end(),
*this)) {
return false;
}
@ -669,7 +717,7 @@ bool EncodedDescriptorDatabase::DescriptorIndex::AddSymbol(
auto flat_iter =
FindLastLessOrEqual(&by_symbol_flat_, entry, by_symbol_.key_comp());
if (!CheckForMutualSubsymbols(entry_as_string, &flat_iter,
by_symbol_flat_.end())) {
by_symbol_flat_.end(), *this)) {
return false;
}
@ -684,25 +732,26 @@ bool EncodedDescriptorDatabase::DescriptorIndex::AddSymbol(
template <typename DescProto>
bool EncodedDescriptorDatabase::DescriptorIndex::AddNestedExtensions(
StringPiece filename, const DescProto& message_type, Value value) {
StringPiece filename, const DescProto& message_type) {
for (const auto& nested_type : message_type.nested_type()) {
if (!AddNestedExtensions(filename, nested_type, value)) return false;
if (!AddNestedExtensions(filename, nested_type)) return false;
}
for (const auto& extension : message_type.extension()) {
if (!AddExtension(filename, extension, value)) return false;
if (!AddExtension(filename, extension)) return false;
}
return true;
}
template <typename FieldProto>
bool EncodedDescriptorDatabase::DescriptorIndex::AddExtension(
StringPiece filename, const FieldProto& field, Value value) {
StringPiece filename, const FieldProto& field) {
if (!field.extendee().empty() && field.extendee()[0] == '.') {
// The extension is fully-qualified. We can use it as a lookup key in
// the by_symbol_ table.
if (!InsertIfNotPresent(&by_extension_,
ExtensionEntry{field.extendee().substr(1),
field.number(), value}) ||
if (!InsertIfNotPresent(
&by_extension_,
ExtensionEntry{static_cast<int>(all_values_.size() - 1),
EncodeString(field.extendee()), field.number()}) ||
std::binary_search(
by_extension_flat_.begin(), by_extension_flat_.end(),
std::make_pair(field.extendee().substr(1), field.number()),
@ -733,8 +782,9 @@ EncodedDescriptorDatabase::DescriptorIndex::FindSymbolOnlyFlat(
auto iter =
FindLastLessOrEqual(&by_symbol_flat_, name, by_symbol_.key_comp());
return iter != by_symbol_flat_.end() && IsSubSymbol(iter->AsString(), name)
? iter->data
return iter != by_symbol_flat_.end() &&
IsSubSymbol(iter->AsString(*this), name)
? all_values_[iter->data_offset].value()
: Value();
}
@ -746,10 +796,11 @@ EncodedDescriptorDatabase::DescriptorIndex::FindExtension(
auto it = std::lower_bound(
by_extension_flat_.begin(), by_extension_flat_.end(),
std::make_tuple(containing_type, field_number), by_extension_.key_comp());
return it == by_extension_flat_.end() || it->extendee != containing_type ||
return it == by_extension_flat_.end() ||
it->extendee(*this) != containing_type ||
it->extension_number != field_number
? std::make_pair(nullptr, 0)
: it->data;
: all_values_[it->data_offset].value();
}
template <typename T, typename Less>
@ -763,6 +814,7 @@ static void MergeIntoFlat(std::set<T, Less>* s, std::vector<T>* flat) {
}
void EncodedDescriptorDatabase::DescriptorIndex::EnsureFlat() {
all_values_.shrink_to_fit();
// Merge each of the sets into their flat counterpart.
MergeIntoFlat(&by_name_, &by_name_flat_);
MergeIntoFlat(&by_symbol_, &by_symbol_flat_);
@ -777,7 +829,8 @@ bool EncodedDescriptorDatabase::DescriptorIndex::FindAllExtensionNumbers(
auto it = std::lower_bound(
by_extension_flat_.begin(), by_extension_flat_.end(),
std::make_tuple(containing_type, 0), by_extension_.key_comp());
for (; it != by_extension_flat_.end() && it->extendee == containing_type;
for (;
it != by_extension_flat_.end() && it->extendee(*this) == containing_type;
++it) {
output->push_back(it->extension_number);
success = true;
@ -791,11 +844,11 @@ void EncodedDescriptorDatabase::DescriptorIndex::FindAllFileNames(
output->resize(by_name_.size() + by_name_flat_.size());
int i = 0;
for (const auto& entry : by_name_) {
(*output)[i] = std::string(entry.name);
(*output)[i] = std::string(entry.name(*this));
i++;
}
for (const auto& entry : by_name_flat_) {
(*output)[i] = std::string(entry.name);
(*output)[i] = std::string(entry.name(*this));
i++;
}
}
@ -807,9 +860,9 @@ EncodedDescriptorDatabase::DescriptorIndex::FindFile(
auto it = std::lower_bound(by_name_flat_.begin(), by_name_flat_.end(),
filename, by_name_.key_comp());
return it == by_name_flat_.end() || it->name != filename
return it == by_name_flat_.end() || it->name(*this) != filename
? std::make_pair(nullptr, 0)
: it->data;
: all_values_[it->data_offset].value();
}

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3011000
#if PROTOBUF_VERSION < 3012000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3011004 < PROTOBUF_MIN_PROTOC_VERSION
#if 3012002 < 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.
@ -45,7 +45,7 @@ PROTOBUF_NAMESPACE_CLOSE
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fduration_2eproto {
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxillaryParseTableField aux[]
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3011000
#if PROTOBUF_VERSION < 3012000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3011004 < PROTOBUF_MIN_PROTOC_VERSION
#if 3012002 < 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.
@ -45,7 +45,7 @@ PROTOBUF_NAMESPACE_CLOSE
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fempty_2eproto {
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxillaryParseTableField aux[]
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3011000
#if PROTOBUF_VERSION < 3012000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3011004 < PROTOBUF_MIN_PROTOC_VERSION
#if 3012002 < 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.
@ -45,7 +45,7 @@ PROTOBUF_NAMESPACE_CLOSE
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto {
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxillaryParseTableField aux[]
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);

@ -72,10 +72,10 @@ namespace internal {
// an enum name of the given type, returning true and filling in value on
// success, or returning false and leaving value unchanged on failure.
PROTOBUF_EXPORT bool ParseNamedEnum(const EnumDescriptor* descriptor,
StringPiece name, int* value);
ConstStringParam name, int* value);
template <typename EnumType>
bool ParseNamedEnum(const EnumDescriptor* descriptor, StringPiece name,
bool ParseNamedEnum(const EnumDescriptor* descriptor, ConstStringParam name,
EnumType* value) {
int tmp;
if (!ParseNamedEnum(descriptor, name, &tmp)) return false;

@ -82,7 +82,7 @@ bool IsMapFieldInApi(const FieldDescriptor* field) { return field->is_map(); }
namespace internal {
bool ParseNamedEnum(const EnumDescriptor* descriptor, StringPiece name,
bool ParseNamedEnum(const EnumDescriptor* descriptor, ConstStringParam name,
int* value) {
const EnumValueDescriptor* d = descriptor->FindValueByName(name);
if (d == nullptr) return false;

@ -120,7 +120,7 @@ struct PROTOBUF_EXPORT FieldMetadata {
// ParseTableField is kept small to help simplify instructions for computing
// offsets, as we will always need this information to parse a field.
// Additional data, needed for some types, is stored in
// AuxillaryParseTableField.
// AuxiliaryParseTableField.
struct ParseTableField {
uint32 offset;
// The presence_index ordinarily represents a has_bit index, but for fields
@ -138,7 +138,7 @@ struct ParseTableField {
struct ParseTable;
union AuxillaryParseTableField {
union AuxiliaryParseTableField {
typedef bool (*EnumValidator)(int);
// Enums
@ -169,20 +169,20 @@ union AuxillaryParseTableField {
};
map_aux maps;
AuxillaryParseTableField() = default;
constexpr AuxillaryParseTableField(AuxillaryParseTableField::enum_aux e)
AuxiliaryParseTableField() = default;
constexpr AuxiliaryParseTableField(AuxiliaryParseTableField::enum_aux e)
: enums(e) {}
constexpr AuxillaryParseTableField(AuxillaryParseTableField::message_aux m)
constexpr AuxiliaryParseTableField(AuxiliaryParseTableField::message_aux m)
: messages(m) {}
constexpr AuxillaryParseTableField(AuxillaryParseTableField::string_aux s)
constexpr AuxiliaryParseTableField(AuxiliaryParseTableField::string_aux s)
: strings(s) {}
constexpr AuxillaryParseTableField(AuxillaryParseTableField::map_aux m)
constexpr AuxiliaryParseTableField(AuxiliaryParseTableField::map_aux m)
: maps(m) {}
};
struct ParseTable {
const ParseTableField* fields;
const AuxillaryParseTableField* aux;
const AuxiliaryParseTableField* aux;
int max_field_number;
// TODO(ckennelly): Do something with this padding.
@ -207,10 +207,10 @@ static_assert(sizeof(ParseTableField) <= 16, "ParseTableField is too large");
// The tables must be composed of POD components to ensure link-time
// initialization.
static_assert(std::is_pod<ParseTableField>::value, "");
static_assert(std::is_pod<AuxillaryParseTableField>::value, "");
static_assert(std::is_pod<AuxillaryParseTableField::enum_aux>::value, "");
static_assert(std::is_pod<AuxillaryParseTableField::message_aux>::value, "");
static_assert(std::is_pod<AuxillaryParseTableField::string_aux>::value, "");
static_assert(std::is_pod<AuxiliaryParseTableField>::value, "");
static_assert(std::is_pod<AuxiliaryParseTableField::enum_aux>::value, "");
static_assert(std::is_pod<AuxiliaryParseTableField::message_aux>::value, "");
static_assert(std::is_pod<AuxiliaryParseTableField::string_aux>::value, "");
static_assert(std::is_pod<ParseTable>::value, "");
// TODO(ckennelly): Consolidate these implementations into a single one, using

@ -309,7 +309,7 @@ inline bool HandleEnum(const ParseTable& table, io::CodedInputStream* input,
return false;
}
AuxillaryParseTableField::EnumValidator validator =
AuxiliaryParseTableField::EnumValidator validator =
table.aux[field_number].enums.validator;
if (validator == nullptr || validator(value)) {
switch (cardinality) {
@ -794,7 +794,7 @@ bool MergePartialFromCodedStreamInlined(MessageLite* msg,
return false;
}
AuxillaryParseTableField::EnumValidator validator =
AuxiliaryParseTableField::EnumValidator validator =
table.aux[field_number].enums.validator;
RepeatedField<int>* values = Raw<RepeatedField<int>>(msg, offset);

@ -343,8 +343,8 @@ class Map {
}
~Map() {
clear();
if (arena_ == nullptr) {
clear();
delete elements_;
}
}
@ -1218,7 +1218,7 @@ class Map {
first = erase(first);
}
}
void clear() { erase(begin(), end()); }
void clear() { elements_->clear(); }
// Assign
Map& operator=(const Map& other) {

@ -171,7 +171,7 @@ namespace {
#define HASH_MAP std::unordered_map
#define HASH_FXN hash
#define STR_HASH_FXN hash<const char*>
class GeneratedMessageFactory : public MessageFactory {
@ -186,8 +186,8 @@ class GeneratedMessageFactory : public MessageFactory {
private:
// Only written at static init time, so does not require locking.
HASH_MAP<const char*, const google::protobuf::internal::DescriptorTable*,
HASH_FXN<const char*>, streq>
HASH_MAP<const char*, const google::protobuf::internal::DescriptorTable*, STR_HASH_FXN,
streq>
file_map_;
internal::WrappedMutex mutex_;

@ -740,8 +740,7 @@ class PROTOBUF_EXPORT Reflection final {
// long as the message is not destroyed.
//
// Note that to use this method users need to include the header file
// "net/proto2/public/reflection.h" (which defines the RepeatedFieldRef
// class templates).
// "reflection.h" (which defines the RepeatedFieldRef class templates).
template <typename T>
RepeatedFieldRef<T> GetRepeatedFieldRef(const Message& message,
const FieldDescriptor* field) const;

@ -744,11 +744,9 @@ PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedEnumParser(
void* object, const char* ptr, ParseContext* ctx);
template <typename T>
PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT)
PROTOBUF_MUST_USE_RESULT const
char* PackedEnumParser(void* object, const char* ptr, ParseContext* ctx,
bool (*is_valid)(int), InternalMetadata* metadata,
int field_num) {
PROTOBUF_MUST_USE_RESULT const char* PackedEnumParser(
void* object, const char* ptr, ParseContext* ctx, bool (*is_valid)(int),
InternalMetadata* metadata, int field_num) {
return ctx->ReadPackedVarint(
ptr, [object, is_valid, metadata, field_num](uint64 val) {
if (is_valid(val)) {
@ -760,12 +758,10 @@ PROTOBUF_MUST_USE_RESULT const
}
template <typename T>
PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT)
PROTOBUF_MUST_USE_RESULT const
char* PackedEnumParserArg(void* object, const char* ptr, ParseContext* ctx,
bool (*is_valid)(const void*, int),
const void* data, InternalMetadata* metadata,
int field_num) {
PROTOBUF_MUST_USE_RESULT const char* PackedEnumParserArg(
void* object, const char* ptr, ParseContext* ctx,
bool (*is_valid)(const void*, int), const void* data,
InternalMetadata* metadata, int field_num) {
return ctx->ReadPackedVarint(
ptr, [object, is_valid, data, metadata, field_num](uint64 val) {
if (is_valid(data, val)) {

@ -300,14 +300,14 @@
// Shared google3/opensource definitions. //////////////////////////////////////
#define PROTOBUF_VERSION 3011004
#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3011000
#define PROTOBUF_MIN_PROTOC_VERSION 3011000
#define PROTOBUF_VERSION 3012002
#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3012000
#define PROTOBUF_MIN_PROTOC_VERSION 3012000
#define PROTOBUF_VERSION_SUFFIX ""
// The minimum library version which works with the current version of the
// headers.
#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3011000
#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3012000
#if defined(GOOGLE_PROTOBUF_NO_RTTI) && GOOGLE_PROTOBUF_NO_RTTI
#define PROTOBUF_RTTI 0
@ -358,192 +358,42 @@
#if defined(PROTOBUF_USE_DLLS)
#if defined(_MSC_VER)
#ifdef LIBPROTOBUF_EXPORTS
#define PROTOBUF_EXPORT __declspec(dllexport)
#else
#define PROTOBUF_EXPORT __declspec(dllimport)
#endif
#ifdef LIBPROTOC_EXPORTS
#define PROTOC_EXPORT __declspec(dllexport)
#else
#define PROTOC_EXPORT __declspec(dllimport)
#endif
#else // defined(_MSC_VER)
#ifdef LIBPROTOBUF_EXPORTS
#define PROTOBUF_EXPORT __attribute__((visibility("default")))
#else
#define PROTOBUF_EXPORT
#endif
#ifdef LIBPROTOC_EXPORTS
#define PROTOC_EXPORT __attribute__((visibility("default")))
#else
#define PROTOC_EXPORT
#endif
#endif
#define PROTOBUF_EXPORT __declspec(dllexport)
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllexport)
#else
#define PROTOBUF_EXPORT __declspec(dllimport)
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllimport)
#endif
#ifdef LIBPROTOC_EXPORTS
#define PROTOC_EXPORT __declspec(dllexport)
#else
#define PROTOC_EXPORT __declspec(dllimport)
#endif
#else // defined(_MSC_VER)
#ifdef LIBPROTOBUF_EXPORTS
#define PROTOBUF_EXPORT __attribute__((visibility("default")))
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE __attribute__((visibility("default")))
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE
#else
#define PROTOBUF_EXPORT
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE
#endif
#ifdef LIBPROTOC_EXPORTS
#define PROTOC_EXPORT __attribute__((visibility("default")))
#else
#define PROTOC_EXPORT
#endif
#endif
#else // defined(PROTOBUF_USE_DLLS)
#define PROTOBUF_EXPORT
#define PROTOC_EXPORT
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE
#endif
// This portion provides macros for using FOO_EXPORT macros with explicit
// template instantiation declarations and definitions.
// Generally, the FOO_EXPORT macros are used at declarations,
// and GCC requires them to be used at explicit instantiation declarations,
// but MSVC requires __declspec(dllexport) to be used at the explicit
// instantiation definitions instead.
// Usage
//
// In a header file, write:
//
// extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(FOO_EXPORT) foo<bar>;
//
// In a source file, write:
//
// template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(FOO_EXPORT) foo<bar>;
//
// Where FOO_EXPORT is either PROTOBUF_EXPORT or PROTOC_EXPORT
// Implementation notes
//
// The implementation of these macros uses some subtle macro semantics to
// detect what the provided FOO_EXPORT value was defined as and then
// to dispatch to appropriate macro definitions. Unfortunately,
// MSVC's C preprocessor is rather non-compliant and requires special
// care to make it work.
//
// Issue 1.
//
// #define F(x)
// F()
//
// MSVC emits warning C4003 ("not enough actual parameters for macro
// 'F'), even though it's a valid macro invocation. This affects the
// macros below that take just an "export" parameter, because export
// may be empty.
//
// As a workaround, we can add a dummy parameter and arguments:
//
// #define F(x,_)
// F(,)
//
// Issue 2.
//
// #define F(x) G##x
// #define Gj() ok
// F(j())
//
// The correct replacement for "F(j())" is "ok", but MSVC replaces it
// with "Gj()". As a workaround, we can pass the result to an
// identity macro to force MSVC to look for replacements again. (This
// is why PROTOBUF_EXPORT_TEMPLATE_STYLE_3 exists.)
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE(export) \
PROTOBUF_EXPORT_TEMPLATE_INVOKE( \
DECLARE, PROTOBUF_EXPORT_TEMPLATE_STYLE(export, ), export)
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE(export) \
PROTOBUF_EXPORT_TEMPLATE_INVOKE( \
DEFINE, PROTOBUF_EXPORT_TEMPLATE_STYLE(export, ), export)
// INVOKE is an internal helper macro to perform parameter replacements
// and token pasting to chain invoke another macro. E.g.,
// PROTOBUF_EXPORT_TEMPLATE_INVOKE(DECLARE, DEFAULT, FOO_EXPORT)
// will export to call
// PROTOBUF_EXPORT_TEMPLATE_DECLARE_DEFAULT(FOO_EXPORT, )
// (but with FOO_EXPORT expanded too).
#define PROTOBUF_EXPORT_TEMPLATE_INVOKE(which, style, export) \
PROTOBUF_EXPORT_TEMPLATE_INVOKE_2(which, style, export)
#define PROTOBUF_EXPORT_TEMPLATE_INVOKE_2(which, style, export) \
PROTOBUF_EXPORT_TEMPLATE_##which##_##style(export, )
// Default style is to apply the FOO_EXPORT macro at declaration sites.
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE_DEFAULT(export, _) export
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE_DEFAULT(export, _)
// The "MSVC hack" style is used when FOO_EXPORT is defined
// as __declspec(dllexport), which MSVC requires to be used at
// definition sites instead.
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE_MSVC_HACK(export, _)
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE_MSVC_HACK(export, _) export
// PROTOBUF_EXPORT_TEMPLATE_STYLE is an internal helper macro that identifies
// which export style needs to be used for the provided FOO_EXPORT macro
// definition. "", "__attribute__(...)", and "__declspec(dllimport)" are
// mapped to "DEFAULT"; while "__declspec(dllexport)" is mapped to "MSVC_HACK".
//
// It's implemented with token pasting to transform the __attribute__ and
// __declspec annotations into macro invocations. E.g., if FOO_EXPORT is
// defined as "__declspec(dllimport)", it undergoes the following sequence of
// macro substitutions:
// PROTOBUF_EXPORT_TEMPLATE_STYLE(FOO_EXPORT, )
// PROTOBUF_EXPORT_TEMPLATE_STYLE_2(__declspec(dllimport), )
// PROTOBUF_EXPORT_TEMPLATE_STYLE_3(
// PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH__declspec(dllimport))
// PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH__declspec(dllimport)
// PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_dllimport
// DEFAULT
#define PROTOBUF_EXPORT_TEMPLATE_STYLE(export, _) \
PROTOBUF_EXPORT_TEMPLATE_STYLE_2(export, )
#define PROTOBUF_EXPORT_TEMPLATE_STYLE_2(export, _) \
PROTOBUF_EXPORT_TEMPLATE_STYLE_3( \
PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA##export)
#define PROTOBUF_EXPORT_TEMPLATE_STYLE_3(style) style
// Internal helper macros for PROTOBUF_EXPORT_TEMPLATE_STYLE.
//
// XXX: C++ reserves all identifiers containing "__" for the implementation,
// but "__attribute__" and "__declspec" already contain "__" and the token-paste
// operator can only add characters; not remove them. To minimize the risk of
// conflict with implementations, we include "foj3FJo5StF0OvIzl7oMxA" (a random
// 128-bit string, encoded in Base64) in the macro name.
#define PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA DEFAULT
#define PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA__attribute__(...) \
DEFAULT
#define PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA__declspec(arg) \
PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_##arg
// Internal helper macros for PROTOBUF_EXPORT_TEMPLATE_STYLE.
#define PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_dllexport MSVC_HACK
#define PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_dllimport DEFAULT
// Sanity checks.
//
// PROTOBUF_EXPORT_TEMPLATE_TEST uses the same macro invocation pattern as
// PROTOBUF_EXPORT_TEMPLATE_DECLARE and PROTOBUF_EXPORT_TEMPLATE_DEFINE do to
// check that they're working correctly. When they're working correctly, the
// sequence of macro replacements should go something like:
//
// PROTOBUF_EXPORT_TEMPLATE_TEST(DEFAULT, __declspec(dllimport));
//
// static_assert(PROTOBUF_EXPORT_TEMPLATE_INVOKE(TEST_DEFAULT,
// PROTOBUF_EXPORT_TEMPLATE_STYLE(__declspec(dllimport), ),
// __declspec(dllimport)), "__declspec(dllimport)");
//
// static_assert(PROTOBUF_EXPORT_TEMPLATE_INVOKE(TEST_DEFAULT,
// DEFAULT, __declspec(dllimport)), "__declspec(dllimport)");
//
// static_assert(PROTOBUF_EXPORT_TEMPLATE_TEST_DEFAULT_DEFAULT(
// __declspec(dllimport)), "__declspec(dllimport)");
//
// static_assert(true, "__declspec(dllimport)");
//
// When they're not working correctly, a syntax error should occur instead.
#define PROTOBUF_EXPORT_TEMPLATE_TEST(want, export) \
static_assert(PROTOBUF_EXPORT_TEMPLATE_INVOKE( \
TEST_##want, PROTOBUF_EXPORT_TEMPLATE_STYLE(export, ), \
export), #export)
#define PROTOBUF_EXPORT_TEMPLATE_TEST_DEFAULT_DEFAULT(...) true
#define PROTOBUF_EXPORT_TEMPLATE_TEST_MSVC_HACK_MSVC_HACK(...) true
PROTOBUF_EXPORT_TEMPLATE_TEST(DEFAULT, );
PROTOBUF_EXPORT_TEMPLATE_TEST(DEFAULT, __attribute__((visibility("default"))));
PROTOBUF_EXPORT_TEMPLATE_TEST(MSVC_HACK, __declspec(dllexport));
PROTOBUF_EXPORT_TEMPLATE_TEST(DEFAULT, __declspec(dllimport));
#undef PROTOBUF_EXPORT_TEMPLATE_TEST
#undef PROTOBUF_EXPORT_TEMPLATE_TEST_DEFAULT_DEFAULT
#undef PROTOBUF_EXPORT_TEMPLATE_TEST_MSVC_HACK_MSVC_HACK
// Windows declares several inconvenient macro names. We #undef them and then
// restore them in port_undef.inc.
#ifdef _MSC_VER
@ -671,4 +521,6 @@ PROTOBUF_EXPORT_TEMPLATE_TEST(DEFAULT, __declspec(dllimport));
// ownership of arena. However, we cannot do that for nested messages. In order
// to tell how many usages of nested messages affected by message owned arena,
// we need to simulate the arena ownership.
#define PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT
// This experiment is purely for the purpose of gathering data. All code guarded
// by this flag is supposed to be removed after this experiment.
// #define PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT

@ -69,19 +69,6 @@
#undef PROTOBUF_EXPORT_TEMPLATE_DECLARE
#undef PROTOBUF_EXPORT_TEMPLATE_DEFINE
#undef PROTOBUF_ALIGNAS
#undef PROTOBUF_EXPORT_TEMPLATE_INVOKE_2
#undef PROTOBUF_EXPORT_TEMPLATE_DECLARE_DEFAULT
#undef PROTOBUF_EXPORT_TEMPLATE_DEFINE_DEFAULT
#undef PROTOBUF_EXPORT_TEMPLATE_DECLARE_MSVC_HACK
#undef PROTOBUF_EXPORT_TEMPLATE_DEFINE_MSVC_HACK
#undef PROTOBUF_EXPORT_TEMPLATE_STYLE
#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_2
#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_3
#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA
#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA__attribute__
#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA__declspec
#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_dllexport
#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_dllimport
#undef PROTOBUF_FINAL
#undef PROTOBUF_THREAD_LOCAL
#undef PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT

@ -123,22 +123,14 @@ MessageLite* RepeatedPtrFieldBase::AddWeak(const MessageLite* prototype) {
} // namespace internal
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT)
RepeatedField<bool>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT)
RepeatedField<int32>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT)
RepeatedField<uint32>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT)
RepeatedField<int64>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT)
RepeatedField<uint64>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT)
RepeatedField<float>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT)
RepeatedField<double>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT)
RepeatedPtrField<std::string>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<bool>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<int32>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<uint32>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<int64>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<uint64>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<float>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<double>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedPtrField<std::string>;
} // namespace protobuf
} // namespace google

@ -2816,21 +2816,14 @@ UnsafeArenaAllocatedRepeatedPtrFieldBackInserter(
}
// Extern declarations of common instantiations to reduce library bloat.
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT)
RepeatedField<bool>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT)
RepeatedField<int32>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT)
RepeatedField<uint32>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT)
RepeatedField<int64>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT)
RepeatedField<uint64>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT)
RepeatedField<float>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT)
RepeatedField<double>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT)
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<bool>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<int32>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<uint32>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<int64>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<uint64>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<float>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<double>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE
RepeatedPtrField<std::string>;
} // namespace protobuf

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3011000
#if PROTOBUF_VERSION < 3012000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3011004 < PROTOBUF_MIN_PROTOC_VERSION
#if 3012002 < 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.
@ -45,7 +45,7 @@ PROTOBUF_NAMESPACE_CLOSE
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto {
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxillaryParseTableField aux[]
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
@ -191,15 +191,6 @@ class PROTOBUF_EXPORT SourceContext PROTOBUF_FINAL :
std::string* mutable_file_name();
std::string* release_file_name();
void set_allocated_file_name(std::string* file_name);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_file_name();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_file_name(
std::string* file_name);
private:
const std::string& _internal_file_name() const;
void _internal_set_file_name(const std::string& value);
@ -289,25 +280,6 @@ inline void SourceContext::set_allocated_file_name(std::string* file_name) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name)
}
inline std::string* SourceContext::unsafe_arena_release_file_name() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.SourceContext.file_name)
GOOGLE_DCHECK(GetArena() != nullptr);
return file_name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void SourceContext::unsafe_arena_set_allocated_file_name(
std::string* file_name) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (file_name != nullptr) {
} else {
}
file_name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
file_name, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.SourceContext.file_name)
}
#ifdef __GNUC__
#pragma GCC diagnostic pop

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3011000
#if PROTOBUF_VERSION < 3012000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3011004 < PROTOBUF_MIN_PROTOC_VERSION
#if 3012002 < 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.
@ -49,7 +49,7 @@ PROTOBUF_NAMESPACE_CLOSE
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fstruct_2eproto {
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxillaryParseTableField aux[]
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[4]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
@ -456,15 +456,6 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL :
std::string* mutable_string_value();
std::string* release_string_value();
void set_allocated_string_value(std::string* string_value);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_string_value();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_string_value(
std::string* string_value);
private:
const std::string& _internal_string_value() const;
void _internal_set_string_value(const std::string& value);
@ -918,29 +909,6 @@ inline void Value::set_allocated_string_value(std::string* string_value) {
}
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.string_value)
}
inline std::string* Value::unsafe_arena_release_string_value() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.string_value)
GOOGLE_DCHECK(GetArena() != nullptr);
if (_internal_has_string_value()) {
clear_has_kind();
return kind_.string_value_.UnsafeArenaRelease(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
} else {
return nullptr;
}
}
inline void Value::unsafe_arena_set_allocated_string_value(std::string* string_value) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (!_internal_has_string_value()) {
kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}
clear_kind();
if (string_value) {
set_has_string_value();
kind_.string_value_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), string_value, GetArena());
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.string_value)
}
// bool bool_value = 4;
inline bool Value::_internal_has_bool_value() const {

@ -43,9 +43,10 @@
#include <string>
#include <vector>
#include <google/protobuf/stubs/port.h>
#include <google/protobuf/stubs/macros.h>
#include <google/protobuf/stubs/platform_macros.h>
#include <google/protobuf/stubs/port.h>
#include <google/protobuf/stubs/stringpiece.h>
#ifndef PROTOBUF_USE_EXCEPTIONS
#if defined(_MSC_VER) && defined(_CPPUNWIND)
@ -81,7 +82,7 @@ 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 3011004
#define GOOGLE_PROTOBUF_VERSION 3012002
// A suffix string for alpha, beta or rc releases. Empty for stable releases.
#define GOOGLE_PROTOBUF_VERSION_SUFFIX ""
@ -89,15 +90,15 @@ namespace internal {
// 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 = 3011000;
static const int kMinHeaderVersionForLibrary = 3012000;
// The minimum protoc version which works with the current version of the
// headers.
#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3011000
#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3012000
// The minimum header version which works with the current version of
// protoc. This constant should only be used in VerifyVersion().
static const int kMinHeaderVersionForProtoc = 3011000;
static const int kMinHeaderVersionForProtoc = 3012000;
// Verifies that the headers and libraries are compatible. Use the macro
// below to call this.
@ -129,12 +130,12 @@ namespace internal {
// structurally_valid.cc.
PROTOBUF_EXPORT bool IsStructurallyValidUTF8(const char* buf, int len);
inline bool IsStructurallyValidUTF8(const std::string& str) {
inline bool IsStructurallyValidUTF8(StringPiece str) {
return IsStructurallyValidUTF8(str.data(), static_cast<int>(str.length()));
}
// Returns initial number of bytes of structurally valid UTF-8.
PROTOBUF_EXPORT int UTF8SpnStructurallyValid(const StringPiece& str);
PROTOBUF_EXPORT int UTF8SpnStructurallyValid(StringPiece str);
// Coerce UTF-8 byte string in src_str to be
// a structurally-valid equal-length string by selectively
@ -148,8 +149,7 @@ PROTOBUF_EXPORT int UTF8SpnStructurallyValid(const StringPiece& str);
//
// Optimized for: all structurally valid and no byte copying is done.
//
PROTOBUF_EXPORT char* UTF8CoerceToStructurallyValid(const StringPiece& str,
char* dst,
PROTOBUF_EXPORT char* UTF8CoerceToStructurallyValid(StringPiece str, char* dst,
char replace_char);
} // namespace internal

@ -33,9 +33,8 @@
#ifndef GOOGLE_PROTOBUF_STUBS_HASH_H__
#define GOOGLE_PROTOBUF_STUBS_HASH_H__
#include <string.h>
#include <google/protobuf/stubs/common.h>
#include <cstring>
#include <string>
#include <unordered_map>
#include <unordered_set>
@ -78,14 +77,14 @@ struct hash<bool> {
};
template <>
struct hash<string> {
inline size_t operator()(const string& key) const {
struct hash<std::string> {
inline size_t operator()(const std::string& key) const {
return hash<const char*>()(key.c_str());
}
static const size_t bucket_size = 4;
static const size_t min_buckets = 8;
inline bool operator()(const string& a, const string& b) const {
inline bool operator()(const std::string& a, const std::string& b) const {
return a < b;
}
};

@ -64,11 +64,11 @@ StringPiece::StringPiece(StringPiece x,
GOOGLE_DCHECK_GE(len, 0);
}
void StringPiece::CopyToString(string* target) const {
void StringPiece::CopyToString(std::string* target) const {
target->assign(ptr_, length_);
}
void StringPiece::AppendToString(string* target) const {
void StringPiece::AppendToString(std::string* target) const {
target->append(ptr_, length_);
}

@ -148,7 +148,6 @@
#include <limits>
#include <string>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/hash.h>
#include <google/protobuf/port_def.inc>
@ -165,7 +164,7 @@ namespace protobuf {
// is 32 bits in LP32, 64 bits in LP64, 64 bits in LLP64
// future changes intended: http://go/64BitStringPiece
//
typedef string::difference_type stringpiece_ssize_type;
typedef std::string::difference_type stringpiece_ssize_type;
// STRINGPIECE_CHECK_SIZE protects us from 32-bit overflows.
// TODO(mec): delete this after stringpiece_ssize_type goes 64 bit.
@ -302,25 +301,21 @@ class PROTOBUF_EXPORT StringPiece {
return 0;
}
string as_string() const {
return ToString();
}
std::string as_string() const { return ToString(); }
// We also define ToString() here, since many other string-like
// interfaces name the routine that converts to a C++ string
// "ToString", and it's confusing to have the method that does that
// for a StringPiece be called "as_string()". We also leave the
// "as_string()" method defined here for existing code.
string ToString() const {
if (ptr_ == nullptr) return string();
return string(data(), static_cast<size_type>(size()));
std::string ToString() const {
if (ptr_ == nullptr) return "";
return std::string(data(), static_cast<size_type>(size()));
}
operator string() const {
return ToString();
}
explicit operator std::string() const { return ToString(); }
void CopyToString(string* target) const;
void AppendToString(string* target) const;
void CopyToString(std::string* target) const;
void AppendToString(std::string* target) const;
bool starts_with(StringPiece x) const {
return (length_ >= x.length_) &&
@ -466,7 +461,7 @@ struct StringPiecePod {
return std::string(data_, static_cast<size_t>(size_));
}
operator string() const { return ToString(); }
explicit operator std::string() const { return ToString(); }
private:
const char* data_;

@ -561,7 +561,7 @@ bool IsStructurallyValidUTF8(const char* buf, int len) {
return (bytes_consumed == len);
}
int UTF8SpnStructurallyValid(const StringPiece& str) {
int UTF8SpnStructurallyValid(StringPiece str) {
if (!module_initialized_) return str.size();
int bytes_consumed = 0;
@ -582,8 +582,7 @@ int UTF8SpnStructurallyValid(const StringPiece& str) {
//
// Fast case: all is structurally valid and no byte copying is done.
//
char* UTF8CoerceToStructurallyValid(const StringPiece& src_str,
char* idst,
char* UTF8CoerceToStructurallyValid(StringPiece src_str, char* idst,
const char replace_char) {
const char* isrc = src_str.data();
const int len = src_str.length();

@ -176,10 +176,8 @@ string StringReplace(const string& s, const string& oldsub,
// the characters in the string, not the entire string as a single delimiter.
// ----------------------------------------------------------------------
template <typename ITR>
static inline
void SplitStringToIteratorUsing(const string& full,
const char* delim,
ITR& result) {
static inline void SplitStringToIteratorUsing(StringPiece full,
const char *delim, ITR &result) {
// Optimize the common case where delim is a single character.
if (delim[0] != '\0' && delim[1] == '\0') {
char c = delim[0];
@ -191,7 +189,7 @@ void SplitStringToIteratorUsing(const string& full,
} else {
const char* start = p;
while (++p != end && *p != c);
*result++ = string(start, p - start);
*result++ = std::string(start, p - start);
}
}
return;
@ -202,17 +200,17 @@ void SplitStringToIteratorUsing(const string& full,
while (begin_index != string::npos) {
end_index = full.find_first_of(delim, begin_index);
if (end_index == string::npos) {
*result++ = full.substr(begin_index);
*result++ = std::string(full.substr(begin_index));
return;
}
*result++ = full.substr(begin_index, (end_index - begin_index));
*result++ =
std::string(full.substr(begin_index, (end_index - begin_index)));
begin_index = full.find_first_not_of(delim, end_index);
}
}
void SplitStringUsing(const string& full,
const char* delim,
std::vector<string>* result) {
void SplitStringUsing(StringPiece full, const char *delim,
std::vector<string> *result) {
std::back_insert_iterator< std::vector<string> > it(*result);
SplitStringToIteratorUsing(full, delim, it);
}
@ -228,29 +226,28 @@ void SplitStringUsing(const string& full,
//
// If "pieces" is negative for some reason, it returns the whole string
// ----------------------------------------------------------------------
template <typename StringType, typename ITR>
static inline
void SplitStringToIteratorAllowEmpty(const StringType& full,
const char* delim,
int pieces,
ITR& result) {
template <typename ITR>
static inline void SplitStringToIteratorAllowEmpty(StringPiece full,
const char *delim,
int pieces, ITR &result) {
string::size_type begin_index, end_index;
begin_index = 0;
for (int i = 0; (i < pieces-1) || (pieces == 0); i++) {
end_index = full.find_first_of(delim, begin_index);
if (end_index == string::npos) {
*result++ = full.substr(begin_index);
*result++ = std::string(full.substr(begin_index));
return;
}
*result++ = full.substr(begin_index, (end_index - begin_index));
*result++ =
std::string(full.substr(begin_index, (end_index - begin_index)));
begin_index = end_index + 1;
}
*result++ = full.substr(begin_index);
*result++ = std::string(full.substr(begin_index));
}
void SplitStringAllowEmpty(const string& full, const char* delim,
std::vector<string>* result) {
void SplitStringAllowEmpty(StringPiece full, const char *delim,
std::vector<string> *result) {
std::back_insert_iterator<std::vector<string> > it(*result);
SplitStringToIteratorAllowEmpty(full, delim, 0, it);
}

@ -113,12 +113,6 @@ inline int hex_digit_to_int(char c) {
// prefix string if the prefix matches, otherwise the original
// string.
// ----------------------------------------------------------------------
inline bool HasPrefixString(const string& str,
const string& prefix) {
return str.size() >= prefix.size() &&
str.compare(0, prefix.size(), prefix) == 0;
}
inline bool HasPrefixString(StringPiece str, StringPiece prefix) {
return str.size() >= prefix.size() &&
memcmp(str.data(), prefix.data(), prefix.size()) == 0;
@ -140,10 +134,10 @@ inline string StripPrefixString(const string& str, const string& prefix) {
// suffix string if the suffix matches, otherwise the original
// string.
// ----------------------------------------------------------------------
inline bool HasSuffixString(const string& str,
const string& suffix) {
inline bool HasSuffixString(StringPiece str, StringPiece suffix) {
return str.size() >= suffix.size() &&
str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
memcmp(str.data() + str.size() - suffix.size(), suffix.data(),
suffix.size()) == 0;
}
inline string StripSuffixString(const string& str, const string& suffix) {
@ -219,7 +213,7 @@ PROTOBUF_EXPORT string StringReplace(const string& s, const string& oldsub,
// to 'result'. If there are consecutive delimiters, this function skips
// over all of them.
// ----------------------------------------------------------------------
PROTOBUF_EXPORT void SplitStringUsing(const string& full, const char* delim,
PROTOBUF_EXPORT void SplitStringUsing(StringPiece full, const char* delim,
std::vector<string>* res);
// Split a string using one or more byte delimiters, presented
@ -230,16 +224,15 @@ PROTOBUF_EXPORT void SplitStringUsing(const string& full, const char* delim,
//
// If "full" is the empty string, yields an empty string as the only value.
// ----------------------------------------------------------------------
PROTOBUF_EXPORT void SplitStringAllowEmpty(const string& full,
const char* delim,
PROTOBUF_EXPORT void SplitStringAllowEmpty(StringPiece full, const char* delim,
std::vector<string>* result);
// ----------------------------------------------------------------------
// Split()
// Split a string using a character delimiter.
// ----------------------------------------------------------------------
inline std::vector<string> Split(
const string& full, const char* delim, bool skip_empty = true) {
inline std::vector<string> Split(StringPiece full, const char* delim,
bool skip_empty = true) {
std::vector<string> result;
if (skip_empty) {
SplitStringUsing(full, delim, &result);

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3011000
#if PROTOBUF_VERSION < 3012000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3011004 < PROTOBUF_MIN_PROTOC_VERSION
#if 3012002 < 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.
@ -45,7 +45,7 @@ PROTOBUF_NAMESPACE_CLOSE
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ftimestamp_2eproto {
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxillaryParseTableField aux[]
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3011000
#if PROTOBUF_VERSION < 3012000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3011004 < PROTOBUF_MIN_PROTOC_VERSION
#if 3012002 < 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.
@ -48,7 +48,7 @@ PROTOBUF_NAMESPACE_CLOSE
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ftype_2eproto {
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxillaryParseTableField aux[]
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[5]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
@ -369,15 +369,6 @@ class PROTOBUF_EXPORT Type PROTOBUF_FINAL :
std::string* mutable_name();
std::string* release_name();
void set_allocated_name(std::string* name);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_name();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_name(
std::string* name);
private:
const std::string& _internal_name() const;
void _internal_set_name(const std::string& value);
@ -679,15 +670,6 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
std::string* mutable_name();
std::string* release_name();
void set_allocated_name(std::string* name);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_name();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_name(
std::string* name);
private:
const std::string& _internal_name() const;
void _internal_set_name(const std::string& value);
@ -704,15 +686,6 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
std::string* mutable_type_url();
std::string* release_type_url();
void set_allocated_type_url(std::string* type_url);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_type_url();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_type_url(
std::string* type_url);
private:
const std::string& _internal_type_url() const;
void _internal_set_type_url(const std::string& value);
@ -729,15 +702,6 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
std::string* mutable_json_name();
std::string* release_json_name();
void set_allocated_json_name(std::string* json_name);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_json_name();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_json_name(
std::string* json_name);
private:
const std::string& _internal_json_name() const;
void _internal_set_json_name(const std::string& value);
@ -754,15 +718,6 @@ class PROTOBUF_EXPORT Field PROTOBUF_FINAL :
std::string* mutable_default_value();
std::string* release_default_value();
void set_allocated_default_value(std::string* default_value);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_default_value();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_default_value(
std::string* default_value);
private:
const std::string& _internal_default_value() const;
void _internal_set_default_value(const std::string& value);
@ -1001,15 +956,6 @@ class PROTOBUF_EXPORT Enum PROTOBUF_FINAL :
std::string* mutable_name();
std::string* release_name();
void set_allocated_name(std::string* name);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_name();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_name(
std::string* name);
private:
const std::string& _internal_name() const;
void _internal_set_name(const std::string& value);
@ -1205,15 +1151,6 @@ class PROTOBUF_EXPORT EnumValue PROTOBUF_FINAL :
std::string* mutable_name();
std::string* release_name();
void set_allocated_name(std::string* name);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_name();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_name(
std::string* name);
private:
const std::string& _internal_name() const;
void _internal_set_name(const std::string& value);
@ -1370,15 +1307,6 @@ class PROTOBUF_EXPORT Option PROTOBUF_FINAL :
std::string* mutable_name();
std::string* release_name();
void set_allocated_name(std::string* name);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_name();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_name(
std::string* name);
private:
const std::string& _internal_name() const;
void _internal_set_name(const std::string& value);
@ -1487,25 +1415,6 @@ inline void Type::set_allocated_name(std::string* name) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.name)
}
inline std::string* Type::unsafe_arena_release_name() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Type.name)
GOOGLE_DCHECK(GetArena() != nullptr);
return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void Type::unsafe_arena_set_allocated_name(
std::string* name) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (name != nullptr) {
} else {
}
name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
name, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Type.name)
}
// repeated .google.protobuf.Field fields = 2;
inline int Type::_internal_fields_size() const {
@ -1881,25 +1790,6 @@ inline void Field::set_allocated_name(std::string* name) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.name)
}
inline std::string* Field::unsafe_arena_release_name() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.name)
GOOGLE_DCHECK(GetArena() != nullptr);
return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void Field::unsafe_arena_set_allocated_name(
std::string* name) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (name != nullptr) {
} else {
}
name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
name, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.name)
}
// string type_url = 6;
inline void Field::clear_type_url() {
@ -1962,25 +1852,6 @@ inline void Field::set_allocated_type_url(std::string* type_url) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.type_url)
}
inline std::string* Field::unsafe_arena_release_type_url() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.type_url)
GOOGLE_DCHECK(GetArena() != nullptr);
return type_url_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void Field::unsafe_arena_set_allocated_type_url(
std::string* type_url) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (type_url != nullptr) {
} else {
}
type_url_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
type_url, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.type_url)
}
// int32 oneof_index = 7;
inline void Field::clear_oneof_index() {
@ -2122,25 +1993,6 @@ inline void Field::set_allocated_json_name(std::string* json_name) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.json_name)
}
inline std::string* Field::unsafe_arena_release_json_name() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.json_name)
GOOGLE_DCHECK(GetArena() != nullptr);
return json_name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void Field::unsafe_arena_set_allocated_json_name(
std::string* json_name) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (json_name != nullptr) {
} else {
}
json_name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
json_name, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.json_name)
}
// string default_value = 11;
inline void Field::clear_default_value() {
@ -2203,25 +2055,6 @@ inline void Field::set_allocated_default_value(std::string* default_value) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.default_value)
}
inline std::string* Field::unsafe_arena_release_default_value() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Field.default_value)
GOOGLE_DCHECK(GetArena() != nullptr);
return default_value_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void Field::unsafe_arena_set_allocated_default_value(
std::string* default_value) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (default_value != nullptr) {
} else {
}
default_value_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
default_value, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.default_value)
}
// -------------------------------------------------------------------
@ -2288,25 +2121,6 @@ inline void Enum::set_allocated_name(std::string* name) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.name)
}
inline std::string* Enum::unsafe_arena_release_name() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Enum.name)
GOOGLE_DCHECK(GetArena() != nullptr);
return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void Enum::unsafe_arena_set_allocated_name(
std::string* name) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (name != nullptr) {
} else {
}
name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
name, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Enum.name)
}
// repeated .google.protobuf.EnumValue enumvalue = 2;
inline int Enum::_internal_enumvalue_size() const {
@ -2548,25 +2362,6 @@ inline void EnumValue::set_allocated_name(std::string* name) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValue.name)
}
inline std::string* EnumValue::unsafe_arena_release_name() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.EnumValue.name)
GOOGLE_DCHECK(GetArena() != nullptr);
return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void EnumValue::unsafe_arena_set_allocated_name(
std::string* name) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (name != nullptr) {
} else {
}
name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
name, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumValue.name)
}
// int32 number = 2;
inline void EnumValue::clear_number() {
@ -2692,25 +2487,6 @@ inline void Option::set_allocated_name(std::string* name) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.name)
}
inline std::string* Option::unsafe_arena_release_name() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Option.name)
GOOGLE_DCHECK(GetArena() != nullptr);
return name_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void Option::unsafe_arena_set_allocated_name(
std::string* name) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (name != nullptr) {
} else {
}
name_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
name, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Option.name)
}
// .google.protobuf.Any value = 2;
inline bool Option::_internal_has_value() const {

@ -106,7 +106,7 @@ class PROTOBUF_EXPORT FieldMaskUtil {
template <typename T>
static void AddPathToFieldMask(StringPiece path, FieldMask* mask) {
GOOGLE_CHECK(IsValidPath<T>(path)) << path;
mask->add_paths(path);
mask->add_paths(std::string(path));
}
// Creates a FieldMask with all fields of type T. This FieldMask only

@ -60,6 +60,7 @@ namespace protobuf {
namespace util {
namespace converter {
using testing::Eq;
using testing::IsEmpty;
using testing::NanSensitiveDoubleEq;
using testing::NanSensitiveFloatEq;
@ -100,7 +101,7 @@ class ExpectingObjectWriter : public ObjectWriter {
virtual ObjectWriter* StartObject(StringPiece name) {
(name.empty() ? EXPECT_CALL(*mock_, StartObject(IsEmpty()))
: EXPECT_CALL(*mock_, StartObject(StrEq(std::string(name)))))
: EXPECT_CALL(*mock_, StartObject(Eq(std::string(name)))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
return this;
@ -115,7 +116,7 @@ class ExpectingObjectWriter : public ObjectWriter {
virtual ObjectWriter* StartList(StringPiece name) {
(name.empty() ? EXPECT_CALL(*mock_, StartList(IsEmpty()))
: EXPECT_CALL(*mock_, StartList(StrEq(std::string(name)))))
: EXPECT_CALL(*mock_, StartList(Eq(std::string(name)))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
return this;
@ -131,8 +132,8 @@ class ExpectingObjectWriter : public ObjectWriter {
virtual ObjectWriter* RenderBool(StringPiece name, bool value) {
(name.empty()
? EXPECT_CALL(*mock_, RenderBool(IsEmpty(), TypedEq<bool>(value)))
: EXPECT_CALL(*mock_, RenderBool(StrEq(std::string(name)),
TypedEq<bool>(value))))
: EXPECT_CALL(*mock_,
RenderBool(Eq(std::string(name)), TypedEq<bool>(value))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
return this;
@ -141,7 +142,7 @@ class ExpectingObjectWriter : public ObjectWriter {
virtual ObjectWriter* RenderInt32(StringPiece name, int32 value) {
(name.empty()
? EXPECT_CALL(*mock_, RenderInt32(IsEmpty(), TypedEq<int32>(value)))
: EXPECT_CALL(*mock_, RenderInt32(StrEq(std::string(name)),
: EXPECT_CALL(*mock_, RenderInt32(Eq(std::string(name)),
TypedEq<int32>(value))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
@ -151,7 +152,7 @@ class ExpectingObjectWriter : public ObjectWriter {
virtual ObjectWriter* RenderUint32(StringPiece name, uint32 value) {
(name.empty()
? EXPECT_CALL(*mock_, RenderUint32(IsEmpty(), TypedEq<uint32>(value)))
: EXPECT_CALL(*mock_, RenderUint32(StrEq(std::string(name)),
: EXPECT_CALL(*mock_, RenderUint32(Eq(std::string(name)),
TypedEq<uint32>(value))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
@ -161,7 +162,7 @@ class ExpectingObjectWriter : public ObjectWriter {
virtual ObjectWriter* RenderInt64(StringPiece name, int64 value) {
(name.empty()
? EXPECT_CALL(*mock_, RenderInt64(IsEmpty(), TypedEq<int64>(value)))
: EXPECT_CALL(*mock_, RenderInt64(StrEq(std::string(name)),
: EXPECT_CALL(*mock_, RenderInt64(Eq(std::string(name)),
TypedEq<int64>(value))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
@ -171,7 +172,7 @@ class ExpectingObjectWriter : public ObjectWriter {
virtual ObjectWriter* RenderUint64(StringPiece name, uint64 value) {
(name.empty()
? EXPECT_CALL(*mock_, RenderUint64(IsEmpty(), TypedEq<uint64>(value)))
: EXPECT_CALL(*mock_, RenderUint64(StrEq(std::string(name)),
: EXPECT_CALL(*mock_, RenderUint64(Eq(std::string(name)),
TypedEq<uint64>(value))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
@ -182,7 +183,7 @@ class ExpectingObjectWriter : public ObjectWriter {
(name.empty()
? EXPECT_CALL(*mock_,
RenderDouble(IsEmpty(), NanSensitiveDoubleEq(value)))
: EXPECT_CALL(*mock_, RenderDouble(StrEq(std::string(name)),
: EXPECT_CALL(*mock_, RenderDouble(Eq(std::string(name)),
NanSensitiveDoubleEq(value))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
@ -193,7 +194,7 @@ class ExpectingObjectWriter : public ObjectWriter {
(name.empty()
? EXPECT_CALL(*mock_,
RenderFloat(IsEmpty(), NanSensitiveFloatEq(value)))
: EXPECT_CALL(*mock_, RenderFloat(StrEq(std::string(name)),
: EXPECT_CALL(*mock_, RenderFloat(Eq(std::string(name)),
NanSensitiveFloatEq(value))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
@ -205,7 +206,7 @@ class ExpectingObjectWriter : public ObjectWriter {
(name.empty() ? EXPECT_CALL(*mock_, RenderString(IsEmpty(),
TypedEq<StringPiece>(
std::string(value))))
: EXPECT_CALL(*mock_, RenderString(StrEq(std::string(name)),
: EXPECT_CALL(*mock_, RenderString(Eq(std::string(name)),
TypedEq<StringPiece>(
std::string(value)))))
.WillOnce(Return(mock_))
@ -217,7 +218,7 @@ class ExpectingObjectWriter : public ObjectWriter {
? EXPECT_CALL(*mock_, RenderBytes(IsEmpty(), TypedEq<StringPiece>(
value.ToString())))
: EXPECT_CALL(*mock_,
RenderBytes(StrEq(name.ToString()),
RenderBytes(Eq(std::string(name)),
TypedEq<StringPiece>(value.ToString()))))
.WillOnce(Return(mock_))
.RetiresOnSaturation();
@ -226,7 +227,7 @@ class ExpectingObjectWriter : public ObjectWriter {
virtual ObjectWriter* RenderNull(StringPiece name) {
(name.empty() ? EXPECT_CALL(*mock_, RenderNull(IsEmpty()))
: EXPECT_CALL(*mock_, RenderNull(StrEq(std::string(name))))
: EXPECT_CALL(*mock_, RenderNull(Eq(std::string(name))))
.WillOnce(Return(mock_))
.RetiresOnSaturation());
return this;

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3011000
#if PROTOBUF_VERSION < 3012000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3011004 < PROTOBUF_MIN_PROTOC_VERSION
#if 3012002 < 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.
@ -45,7 +45,7 @@ PROTOBUF_NAMESPACE_CLOSE
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fwrappers_2eproto {
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxillaryParseTableField aux[]
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[9]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
@ -1182,15 +1182,6 @@ class PROTOBUF_EXPORT StringValue PROTOBUF_FINAL :
std::string* mutable_value();
std::string* release_value();
void set_allocated_value(std::string* value);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_value();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_value(
std::string* value);
private:
const std::string& _internal_value() const;
void _internal_set_value(const std::string& value);
@ -1335,15 +1326,6 @@ class PROTOBUF_EXPORT BytesValue PROTOBUF_FINAL :
std::string* mutable_value();
std::string* release_value();
void set_allocated_value(std::string* value);
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
std::string* unsafe_arena_release_value();
GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for"
" string fields are deprecated and will be removed in a"
" future release.")
void unsafe_arena_set_allocated_value(
std::string* value);
private:
const std::string& _internal_value() const;
void _internal_set_value(const std::string& value);
@ -1601,25 +1583,6 @@ inline void StringValue::set_allocated_value(std::string* value) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.StringValue.value)
}
inline std::string* StringValue::unsafe_arena_release_value() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.StringValue.value)
GOOGLE_DCHECK(GetArena() != nullptr);
return value_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void StringValue::unsafe_arena_set_allocated_value(
std::string* value) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (value != nullptr) {
} else {
}
value_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
value, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.StringValue.value)
}
// -------------------------------------------------------------------
@ -1686,25 +1649,6 @@ inline void BytesValue::set_allocated_value(std::string* value) {
GetArena());
// @@protoc_insertion_point(field_set_allocated:google.protobuf.BytesValue.value)
}
inline std::string* BytesValue::unsafe_arena_release_value() {
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.BytesValue.value)
GOOGLE_DCHECK(GetArena() != nullptr);
return value_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
GetArena());
}
inline void BytesValue::unsafe_arena_set_allocated_value(
std::string* value) {
GOOGLE_DCHECK(GetArena() != nullptr);
if (value != nullptr) {
} else {
}
value_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
value, GetArena());
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.BytesValue.value)
}
#ifdef __GNUC__
#pragma GCC diagnostic pop

@ -492,24 +492,12 @@ generate_php_test_proto() {
use_php() {
VERSION=$1
export PATH=/usr/local/php-${VERSION}/bin:$PATH
export CPLUS_INCLUDE_PATH=/usr/local/php-${VERSION}/include/php/main:/usr/local/php-${VERSION}/include/php/:$CPLUS_INCLUDE_PATH
export C_INCLUDE_PATH=/usr/local/php-${VERSION}/include/php/main:/usr/local/php-${VERSION}/include/php/:$C_INCLUDE_PATH
generate_php_test_proto
}
use_php_zts() {
VERSION=$1
export PATH=/usr/local/php-${VERSION}-zts/bin:$PATH
export CPLUS_INCLUDE_PATH=/usr/local/php-${VERSION}-zts/include/php/main:/usr/local/php-${VERSION}-zts/include/php/:$CPLUS_INCLUDE_PATH
export C_INCLUDE_PATH=/usr/local/php-${VERSION}-zts/include/php/main:/usr/local/php-${VERSION}-zts/include/php/:$C_INCLUDE_PATH
generate_php_test_proto
}
use_php_bc() {
VERSION=$1
export PATH=/usr/local/php-${VERSION}-bc/bin:$PATH
export CPLUS_INCLUDE_PATH=/usr/local/php-${VERSION}-bc/include/php/main:/usr/local/php-${VERSION}-bc/include/php/:$CPLUS_INCLUDE_PATH
export C_INCLUDE_PATH=/usr/local/php-${VERSION}-bc/include/php/main:/usr/local/php-${VERSION}-bc/include/php/:$C_INCLUDE_PATH
generate_php_test_proto
}
@ -529,9 +517,7 @@ build_php5.5() {
build_php5.5_c() {
IS_64BIT=$1
use_php 5.5
pushd php/tests
/bin/bash ./test.sh 5.5
popd
php/tests/test.sh
pushd conformance
if [ "$IS_64BIT" = "true" ]
then
@ -547,9 +533,7 @@ build_php5.5_mixed() {
pushd php
rm -rf vendor
composer update
pushd tests
/bin/bash ./compile_extension.sh 5.5
popd
tests/compile_extension.sh
php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
popd
}
@ -557,7 +541,7 @@ build_php5.5_mixed() {
build_php5.5_zts_c() {
IS_64BIT=$1
use_php_zts 5.5
cd php/tests && /bin/bash ./test.sh 5.5-zts && cd ../..
php/tests/test.sh
pushd conformance
if [ "$IS_64BIT" = "true" ]
then
@ -583,7 +567,7 @@ build_php5.6() {
build_php5.6_c() {
IS_64BIT=$1
use_php 5.6
cd php/tests && /bin/bash ./test.sh 5.6 && cd ../..
php/tests/test.sh
pushd conformance
if [ "$IS_64BIT" = "true" ]
then
@ -599,9 +583,7 @@ build_php5.6_mixed() {
pushd php
rm -rf vendor
composer update
pushd tests
/bin/bash ./compile_extension.sh 5.6
popd
tests/compile_extension.sh
php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
popd
}
@ -609,7 +591,7 @@ build_php5.6_mixed() {
build_php5.6_zts_c() {
IS_64BIT=$1
use_php_zts 5.6
cd php/tests && /bin/bash ./test.sh 5.6-zts && cd ../..
php/tests/test.sh
pushd conformance
if [ "$IS_64BIT" = "true" ]
then
@ -639,10 +621,8 @@ build_php5.6_mac() {
sudo mv valgrind /usr/local/bin/valgrind
# Test
cd php/tests && /bin/bash ./test.sh && cd ../..
pushd conformance
make test_php_c
popd
php/tests/test.sh
(cd conformance && make test_php_c)
}
build_php7.0() {
@ -652,15 +632,13 @@ build_php7.0() {
composer update
./vendor/bin/phpunit
popd
pushd conformance
make test_php
popd
(cd conformance && make test_php)
}
build_php7.0_c() {
IS_64BIT=$1
use_php 7.0
cd php/tests && /bin/bash ./test.sh 7.0 && cd ../..
php/tests/test.sh
pushd conformance
if [ "$IS_64BIT" = "true" ]
then
@ -676,9 +654,7 @@ build_php7.0_mixed() {
pushd php
rm -rf vendor
composer update
pushd tests
/bin/bash ./compile_extension.sh 7.0
popd
tests/compile_extension.sh
php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
popd
}
@ -686,7 +662,7 @@ build_php7.0_mixed() {
build_php7.0_zts_c() {
IS_64BIT=$1
use_php_zts 7.0
cd php/tests && /bin/bash ./test.sh 7.0-zts && cd ../..
php/tests/test.sh
pushd conformance
if [ "$IS_64BIT" = "true" ]
then
@ -716,10 +692,8 @@ build_php7.0_mac() {
sudo mv valgrind /usr/local/bin/valgrind
# Test
cd php/tests && /bin/bash ./test.sh && cd ../..
pushd conformance
make test_php_c
popd
php/tests/test.sh
(cd conformance && make test_php_c)
}
build_php7.3_mac() {
@ -743,10 +717,8 @@ build_php7.3_mac() {
sudo mv valgrind /usr/local/bin/valgrind
# Test
cd php/tests && /bin/bash ./test.sh && cd ../..
pushd conformance
make test_php_c
popd
php/tests/test.sh
(cd conformance && make test_php_c)
}
build_php_compatibility() {
@ -756,9 +728,7 @@ build_php_compatibility() {
build_php_multirequest() {
use_php 7.4
pushd php/tests
./multirequest.sh
popd
php/tests/multirequest.sh
}
build_php7.1() {
@ -768,15 +738,13 @@ build_php7.1() {
composer update
./vendor/bin/phpunit
popd
pushd conformance
make test_php
popd
(cd conformance && make test_php)
}
build_php7.1_c() {
IS_64BIT=$1
use_php 7.1
cd php/tests && /bin/bash ./test.sh 7.1 && cd ../..
php/tests/test.sh
pushd conformance
if [ "$IS_64BIT" = "true" ]
then
@ -792,9 +760,7 @@ build_php7.1_mixed() {
pushd php
rm -rf vendor
composer update
pushd tests
/bin/bash ./compile_extension.sh 7.1
popd
tests/compile_extension.sh
php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
popd
}
@ -802,7 +768,7 @@ build_php7.1_mixed() {
build_php7.1_zts_c() {
IS_64BIT=$1
use_php_zts 7.1
cd php/tests && /bin/bash ./test.sh 7.1-zts && cd ../..
php/tests/test.sh
pushd conformance
if [ "$IS_64BIT" = "true" ]
then
@ -820,15 +786,13 @@ build_php7.4() {
composer update
./vendor/bin/phpunit
popd
pushd conformance
make test_php
popd
(cd conformance && make test_php)
}
build_php7.4_c() {
IS_64BIT=$1
use_php 7.4
cd php/tests && /bin/bash ./test.sh 7.4 && cd ../..
php/tests/test.sh
pushd conformance
if [ "$IS_64BIT" = "true" ]
then
@ -837,9 +801,7 @@ build_php7.4_c() {
make test_php_c_32
fi
popd
pushd php/ext/google/protobuf
phpize --clean
popd
(cd php/ext/google/protobuf && phpize --clean)
}
build_php7.4_mixed() {
@ -847,20 +809,16 @@ build_php7.4_mixed() {
pushd php
rm -rf vendor
composer update
pushd tests
/bin/bash ./compile_extension.sh 7.4
popd
tests/compile_extension.sh
php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
popd
pushd php/ext/google/protobuf
phpize --clean
popd
(cd php/ext/google/protobuf && phpize --clean)
}
build_php7.4_zts_c() {
IS_64BIT=$1
use_php_zts 7.4
cd php/tests && /bin/bash ./test.sh 7.4-zts && cd ../..
php/tests/test.sh
pushd conformance
if [ "$IS_64BIT" = "true" ]
then
@ -869,9 +827,7 @@ build_php7.4_zts_c() {
make test_php_c_32
fi
popd
pushd php/ext/google/protobuf
phpize --clean
popd
(cd php/ext/google/protobuf && phpize --clean)
}
build_php_all_32() {

Loading…
Cancel
Save