Commit b0f66118 authored by Jisi Liu's avatar Jisi Liu

Down-integrate from internal branch.

Change-Id: Ieb7a2c2fbf35bc2a8fa65b915a5ecb68c83863e4
parent d119a275
# Only test one combination: "Visual Studio 12 + Win64 + Debug + DLL". We can # Only test one combination: "Visual Studio 12 + Win64 + Debug + DLL". We can
# test more combinations but AppVeyor just takes too long to finish (each # test more combinations but AppVeyor just takes too long to finish (each
# combination takes ~15mins). # combination takes ~15mins).
platform: platform:
- Win64 - Win64
configuration: configuration:
- Debug - Debug
environment: environment:
matrix: matrix:
- BUILD_DLL: ON - BUILD_DLL: ON
install: install:
- ps: Start-FileDownload https://googlemock.googlecode.com/files/gmock-1.7.0.zip - ps: Start-FileDownload https://googlemock.googlecode.com/files/gmock-1.7.0.zip
- 7z x gmock-1.7.0.zip - 7z x gmock-1.7.0.zip
- rename gmock-1.7.0 gmock - rename gmock-1.7.0 gmock
before_build: before_build:
- if %platform%==Win32 set generator=Visual Studio 12 - if %platform%==Win32 set generator=Visual Studio 12
- if %platform%==Win64 set generator=Visual Studio 12 Win64 - if %platform%==Win64 set generator=Visual Studio 12 Win64
- if %platform%==Win32 set vcplatform=Win32 - if %platform%==Win32 set vcplatform=Win32
- if %platform%==Win64 set vcplatform=x64 - if %platform%==Win64 set vcplatform=x64
build_script: build_script:
- mkdir build_msvc - mkdir build_msvc
- cd build_msvc - cd build_msvc
- cmake -G "%generator%" -DBUILD_SHARED_LIBS=%BUILD_DLL% ../cmake - cmake -G "%generator%" -DBUILD_SHARED_LIBS=%BUILD_DLL% ../cmake
- msbuild protobuf.sln /p:Platform=%vcplatform% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - msbuild protobuf.sln /p:Platform=%vcplatform% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- cd %configuration% - cd %configuration%
- tests.exe - tests.exe
skip_commits: skip_commits:
message: /.*\[skip appveyor\].*/ message: /.*\[skip appveyor\].*/
...@@ -109,8 +109,10 @@ copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\timestamp.pb.h include ...@@ -109,8 +109,10 @@ copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\timestamp.pb.h include
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\type.pb.h include\google\protobuf\type.pb.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\type.pb.h include\google\protobuf\type.pb.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\unknown_field_set.h include\google\protobuf\unknown_field_set.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\unknown_field_set.h include\google\protobuf\unknown_field_set.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\field_comparator.h include\google\protobuf\util\field_comparator.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\field_comparator.h include\google\protobuf\util\field_comparator.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\field_mask_util.h include\google\protobuf\util\field_mask_util.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\json_util.h include\google\protobuf\util\json_util.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\json_util.h include\google\protobuf\util\json_util.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\message_differencer.h include\google\protobuf\util\message_differencer.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\message_differencer.h include\google\protobuf\util\message_differencer.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\time_util.h include\google\protobuf\util\time_util.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\type_resolver.h include\google\protobuf\util\type_resolver.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\type_resolver.h include\google\protobuf\util\type_resolver.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\type_resolver_util.h include\google\protobuf\util\type_resolver_util.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\type_resolver_util.h include\google\protobuf\util\type_resolver_util.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format.h include\google\protobuf\wire_format.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format.h include\google\protobuf\wire_format.h
......
...@@ -12,6 +12,7 @@ set(libprotobuf_lite_files ...@@ -12,6 +12,7 @@ set(libprotobuf_lite_files
${protobuf_source_dir}/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc ${protobuf_source_dir}/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc
${protobuf_source_dir}/src/google/protobuf/stubs/bytestream.cc ${protobuf_source_dir}/src/google/protobuf/stubs/bytestream.cc
${protobuf_source_dir}/src/google/protobuf/stubs/common.cc ${protobuf_source_dir}/src/google/protobuf/stubs/common.cc
${protobuf_source_dir}/src/google/protobuf/stubs/int128.cc
${protobuf_source_dir}/src/google/protobuf/stubs/once.cc ${protobuf_source_dir}/src/google/protobuf/stubs/once.cc
${protobuf_source_dir}/src/google/protobuf/stubs/status.cc ${protobuf_source_dir}/src/google/protobuf/stubs/status.cc
${protobuf_source_dir}/src/google/protobuf/stubs/statusor.cc ${protobuf_source_dir}/src/google/protobuf/stubs/statusor.cc
......
...@@ -32,6 +32,7 @@ set(libprotobuf_files ...@@ -32,6 +32,7 @@ set(libprotobuf_files
${protobuf_source_dir}/src/google/protobuf/type.pb.cc ${protobuf_source_dir}/src/google/protobuf/type.pb.cc
${protobuf_source_dir}/src/google/protobuf/unknown_field_set.cc ${protobuf_source_dir}/src/google/protobuf/unknown_field_set.cc
${protobuf_source_dir}/src/google/protobuf/util/field_comparator.cc ${protobuf_source_dir}/src/google/protobuf/util/field_comparator.cc
${protobuf_source_dir}/src/google/protobuf/util/field_mask_util.cc
${protobuf_source_dir}/src/google/protobuf/util/internal/datapiece.cc ${protobuf_source_dir}/src/google/protobuf/util/internal/datapiece.cc
${protobuf_source_dir}/src/google/protobuf/util/internal/default_value_objectwriter.cc ${protobuf_source_dir}/src/google/protobuf/util/internal/default_value_objectwriter.cc
${protobuf_source_dir}/src/google/protobuf/util/internal/error_listener.cc ${protobuf_source_dir}/src/google/protobuf/util/internal/error_listener.cc
...@@ -47,6 +48,7 @@ set(libprotobuf_files ...@@ -47,6 +48,7 @@ set(libprotobuf_files
${protobuf_source_dir}/src/google/protobuf/util/internal/utility.cc ${protobuf_source_dir}/src/google/protobuf/util/internal/utility.cc
${protobuf_source_dir}/src/google/protobuf/util/json_util.cc ${protobuf_source_dir}/src/google/protobuf/util/json_util.cc
${protobuf_source_dir}/src/google/protobuf/util/message_differencer.cc ${protobuf_source_dir}/src/google/protobuf/util/message_differencer.cc
${protobuf_source_dir}/src/google/protobuf/util/time_util.cc
${protobuf_source_dir}/src/google/protobuf/util/type_resolver_util.cc ${protobuf_source_dir}/src/google/protobuf/util/type_resolver_util.cc
${protobuf_source_dir}/src/google/protobuf/wire_format.cc ${protobuf_source_dir}/src/google/protobuf/wire_format.cc
${protobuf_source_dir}/src/google/protobuf/wrappers.pb.cc ${protobuf_source_dir}/src/google/protobuf/wrappers.pb.cc
......
...@@ -34,6 +34,7 @@ set(libprotoc_files ...@@ -34,6 +34,7 @@ set(libprotoc_files
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field_lite.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field_lite.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_lite.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_extension.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_extension.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_file.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_file.cc
......
...@@ -21,6 +21,7 @@ set(lite_test_protos ...@@ -21,6 +21,7 @@ set(lite_test_protos
google/protobuf/unittest_import_lite.proto google/protobuf/unittest_import_lite.proto
google/protobuf/unittest_import_public_lite.proto google/protobuf/unittest_import_public_lite.proto
google/protobuf/unittest_lite.proto google/protobuf/unittest_lite.proto
google/protobuf/unittest_no_arena_lite.proto
) )
set(tests_protos set(tests_protos
...@@ -40,6 +41,7 @@ set(tests_protos ...@@ -40,6 +41,7 @@ set(tests_protos
google/protobuf/unittest_import_public.proto google/protobuf/unittest_import_public.proto
google/protobuf/unittest_lite_imports_nonlite.proto google/protobuf/unittest_lite_imports_nonlite.proto
google/protobuf/unittest_mset.proto google/protobuf/unittest_mset.proto
google/protobuf/unittest_mset_wire_format.proto
google/protobuf/unittest_no_arena.proto google/protobuf/unittest_no_arena.proto
google/protobuf/unittest_no_arena_import.proto google/protobuf/unittest_no_arena_import.proto
google/protobuf/unittest_no_field_presence.proto google/protobuf/unittest_no_field_presence.proto
...@@ -55,6 +57,7 @@ set(tests_protos ...@@ -55,6 +57,7 @@ set(tests_protos
google/protobuf/util/internal/testdata/default_value_test.proto google/protobuf/util/internal/testdata/default_value_test.proto
google/protobuf/util/internal/testdata/field_mask.proto google/protobuf/util/internal/testdata/field_mask.proto
google/protobuf/util/internal/testdata/maps.proto google/protobuf/util/internal/testdata/maps.proto
google/protobuf/util/internal/testdata/oneofs.proto
google/protobuf/util/internal/testdata/struct.proto google/protobuf/util/internal/testdata/struct.proto
google/protobuf/util/internal/testdata/timestamp_duration.proto google/protobuf/util/internal/testdata/timestamp_duration.proto
google/protobuf/util/json_format_proto3.proto google/protobuf/util/json_format_proto3.proto
...@@ -134,6 +137,7 @@ set(tests_files ...@@ -134,6 +137,7 @@ set(tests_files
${protobuf_source_dir}/src/google/protobuf/repeated_field_unittest.cc ${protobuf_source_dir}/src/google/protobuf/repeated_field_unittest.cc
${protobuf_source_dir}/src/google/protobuf/stubs/bytestream_unittest.cc ${protobuf_source_dir}/src/google/protobuf/stubs/bytestream_unittest.cc
${protobuf_source_dir}/src/google/protobuf/stubs/common_unittest.cc ${protobuf_source_dir}/src/google/protobuf/stubs/common_unittest.cc
${protobuf_source_dir}/src/google/protobuf/stubs/int128_unittest.cc
${protobuf_source_dir}/src/google/protobuf/stubs/once_unittest.cc ${protobuf_source_dir}/src/google/protobuf/stubs/once_unittest.cc
${protobuf_source_dir}/src/google/protobuf/stubs/status_test.cc ${protobuf_source_dir}/src/google/protobuf/stubs/status_test.cc
${protobuf_source_dir}/src/google/protobuf/stubs/statusor_test.cc ${protobuf_source_dir}/src/google/protobuf/stubs/statusor_test.cc
...@@ -147,6 +151,7 @@ set(tests_files ...@@ -147,6 +151,7 @@ set(tests_files
${protobuf_source_dir}/src/google/protobuf/text_format_unittest.cc ${protobuf_source_dir}/src/google/protobuf/text_format_unittest.cc
${protobuf_source_dir}/src/google/protobuf/unknown_field_set_unittest.cc ${protobuf_source_dir}/src/google/protobuf/unknown_field_set_unittest.cc
${protobuf_source_dir}/src/google/protobuf/util/field_comparator_test.cc ${protobuf_source_dir}/src/google/protobuf/util/field_comparator_test.cc
${protobuf_source_dir}/src/google/protobuf/util/field_mask_util_test.cc
${protobuf_source_dir}/src/google/protobuf/util/internal/default_value_objectwriter_test.cc ${protobuf_source_dir}/src/google/protobuf/util/internal/default_value_objectwriter_test.cc
${protobuf_source_dir}/src/google/protobuf/util/internal/json_objectwriter_test.cc ${protobuf_source_dir}/src/google/protobuf/util/internal/json_objectwriter_test.cc
${protobuf_source_dir}/src/google/protobuf/util/internal/json_stream_parser_test.cc ${protobuf_source_dir}/src/google/protobuf/util/internal/json_stream_parser_test.cc
...@@ -154,6 +159,7 @@ set(tests_files ...@@ -154,6 +159,7 @@ set(tests_files
${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectwriter_test.cc ${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectwriter_test.cc
${protobuf_source_dir}/src/google/protobuf/util/internal/type_info_test_helper.cc ${protobuf_source_dir}/src/google/protobuf/util/internal/type_info_test_helper.cc
${protobuf_source_dir}/src/google/protobuf/util/json_util_test.cc ${protobuf_source_dir}/src/google/protobuf/util/json_util_test.cc
${protobuf_source_dir}/src/google/protobuf/util/time_util_test.cc
${protobuf_source_dir}/src/google/protobuf/util/type_resolver_util_test.cc ${protobuf_source_dir}/src/google/protobuf/util/type_resolver_util_test.cc
${protobuf_source_dir}/src/google/protobuf/well_known_types_unittest.cc ${protobuf_source_dir}/src/google/protobuf/well_known_types_unittest.cc
${protobuf_source_dir}/src/google/protobuf/wire_format_unittest.cc ${protobuf_source_dir}/src/google/protobuf/wire_format_unittest.cc
......
...@@ -114,6 +114,7 @@ ...@@ -114,6 +114,7 @@
<arg value="../src/google/protobuf/unittest_import.proto" /> <arg value="../src/google/protobuf/unittest_import.proto" />
<arg value="../src/google/protobuf/unittest_import_public.proto" /> <arg value="../src/google/protobuf/unittest_import_public.proto" />
<arg value="../src/google/protobuf/unittest_mset.proto" /> <arg value="../src/google/protobuf/unittest_mset.proto" />
<arg value="../src/google/protobuf/unittest_mset_wire_format.proto" />
<arg value="src/test/java/com/google/protobuf/lazy_fields_lite.proto" /> <arg value="src/test/java/com/google/protobuf/lazy_fields_lite.proto" />
<arg value="src/test/java/com/google/protobuf/lite_equals_and_hash.proto" /> <arg value="src/test/java/com/google/protobuf/lite_equals_and_hash.proto" />
<arg <arg
......
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This file contains messages that extend MessageSet.
syntax = "proto2";
package google.protobuf.internal;
// A message with message_set_wire_format.
message TestMessageSet {
option message_set_wire_format = true;
extensions 4 to max;
}
message TestMessageSetExtension1 {
extend TestMessageSet {
optional TestMessageSetExtension1 message_set_extension = 98418603;
}
optional int32 i = 15;
}
message TestMessageSetExtension2 {
extend TestMessageSet {
optional TestMessageSetExtension2 message_set_extension = 98418634;
}
optional string str = 25;
}
// This message was used to generate
// //net/proto2/python/internal/testdata/message_set_message, but is commented
// out since it must not actually exist in code, to simulate an "unknown"
// extension.
// message TestMessageSetUnknownExtension {
// extend TestMessageSet {
// optional TestMessageSetUnknownExtension message_set_extension = 56141421;
// }
// optional int64 a = 1;
// }
...@@ -91,11 +91,15 @@ def generate_proto(source, require = True): ...@@ -91,11 +91,15 @@ def generate_proto(source, require = True):
def GenerateUnittestProtos(): def GenerateUnittestProtos():
generate_proto("../src/google/protobuf/map_unittest.proto", False) generate_proto("../src/google/protobuf/map_unittest.proto", False)
generate_proto("../src/google/protobuf/unittest_arena.proto", False)
generate_proto("../src/google/protobuf/unittest_no_arena.proto", False)
generate_proto("../src/google/protobuf/unittest_no_arena_import.proto", False)
generate_proto("../src/google/protobuf/unittest.proto", False) generate_proto("../src/google/protobuf/unittest.proto", False)
generate_proto("../src/google/protobuf/unittest_custom_options.proto", False) generate_proto("../src/google/protobuf/unittest_custom_options.proto", False)
generate_proto("../src/google/protobuf/unittest_import.proto", False) generate_proto("../src/google/protobuf/unittest_import.proto", False)
generate_proto("../src/google/protobuf/unittest_import_public.proto", False) generate_proto("../src/google/protobuf/unittest_import_public.proto", False)
generate_proto("../src/google/protobuf/unittest_mset.proto", False) generate_proto("../src/google/protobuf/unittest_mset.proto", False)
generate_proto("../src/google/protobuf/unittest_mset_wire_format.proto", False)
generate_proto("../src/google/protobuf/unittest_no_generic_services.proto", False) generate_proto("../src/google/protobuf/unittest_no_generic_services.proto", False)
generate_proto("../src/google/protobuf/unittest_proto3_arena.proto", False) generate_proto("../src/google/protobuf/unittest_proto3_arena.proto", False)
generate_proto("google/protobuf/internal/descriptor_pool_test1.proto", False) generate_proto("google/protobuf/internal/descriptor_pool_test1.proto", False)
...@@ -105,9 +109,11 @@ def GenerateUnittestProtos(): ...@@ -105,9 +109,11 @@ def GenerateUnittestProtos():
generate_proto("google/protobuf/internal/import_test_package/inner.proto", False) generate_proto("google/protobuf/internal/import_test_package/inner.proto", False)
generate_proto("google/protobuf/internal/import_test_package/outer.proto", False) generate_proto("google/protobuf/internal/import_test_package/outer.proto", False)
generate_proto("google/protobuf/internal/missing_enum_values.proto", False) generate_proto("google/protobuf/internal/missing_enum_values.proto", False)
generate_proto("google/protobuf/internal/message_set_extensions.proto", False)
generate_proto("google/protobuf/internal/more_extensions.proto", False) generate_proto("google/protobuf/internal/more_extensions.proto", False)
generate_proto("google/protobuf/internal/more_extensions_dynamic.proto", False) generate_proto("google/protobuf/internal/more_extensions_dynamic.proto", False)
generate_proto("google/protobuf/internal/more_messages.proto", False) generate_proto("google/protobuf/internal/more_messages.proto", False)
generate_proto("google/protobuf/internal/packed_field_test.proto", False)
generate_proto("google/protobuf/internal/test_bad_identifiers.proto", False) generate_proto("google/protobuf/internal/test_bad_identifiers.proto", False)
generate_proto("google/protobuf/pyext/python.proto", False) generate_proto("google/protobuf/pyext/python.proto", False)
......
...@@ -157,9 +157,11 @@ nobase_include_HEADERS = \ ...@@ -157,9 +157,11 @@ nobase_include_HEADERS = \
google/protobuf/compiler/ruby/ruby_generator.h \ google/protobuf/compiler/ruby/ruby_generator.h \
google/protobuf/compiler/csharp/csharp_generator.h \ google/protobuf/compiler/csharp/csharp_generator.h \
google/protobuf/util/type_resolver.h \ google/protobuf/util/type_resolver.h \
google/protobuf/util/type_resolver_util.h \
google/protobuf/util/json_util.h \
google/protobuf/util/field_comparator.h \ google/protobuf/util/field_comparator.h \
google/protobuf/util/field_mask_util.h \
google/protobuf/util/json_util.h \
google/protobuf/util/time_util.h \
google/protobuf/util/type_resolver_util.h \
google/protobuf/util/message_differencer.h google/protobuf/util/message_differencer.h
lib_LTLIBRARIES = libprotobuf-lite.la libprotobuf.la libprotoc.la lib_LTLIBRARIES = libprotobuf-lite.la libprotobuf.la libprotoc.la
...@@ -173,6 +175,8 @@ libprotobuf_lite_la_SOURCES = \ ...@@ -173,6 +175,8 @@ libprotobuf_lite_la_SOURCES = \
google/protobuf/stubs/bytestream.h \ google/protobuf/stubs/bytestream.h \
google/protobuf/stubs/common.cc \ google/protobuf/stubs/common.cc \
google/protobuf/stubs/hash.h \ google/protobuf/stubs/hash.h \
google/protobuf/stubs/int128.cc \
google/protobuf/stubs/int128.h \
google/protobuf/stubs/map_util.h \ google/protobuf/stubs/map_util.h \
google/protobuf/stubs/mathutil.h \ google/protobuf/stubs/mathutil.h \
google/protobuf/stubs/once.cc \ google/protobuf/stubs/once.cc \
...@@ -208,8 +212,8 @@ libprotobuf_la_SOURCES = \ ...@@ -208,8 +212,8 @@ libprotobuf_la_SOURCES = \
$(libprotobuf_lite_la_SOURCES) \ $(libprotobuf_lite_la_SOURCES) \
google/protobuf/any.pb.cc \ google/protobuf/any.pb.cc \
google/protobuf/api.pb.cc \ google/protobuf/api.pb.cc \
google/protobuf/stubs/mathlimits.h \
google/protobuf/stubs/mathlimits.cc \ google/protobuf/stubs/mathlimits.cc \
google/protobuf/stubs/mathlimits.h \
google/protobuf/any.cc \ google/protobuf/any.cc \
google/protobuf/descriptor.cc \ google/protobuf/descriptor.cc \
google/protobuf/descriptor_database.cc \ google/protobuf/descriptor_database.cc \
...@@ -244,6 +248,7 @@ libprotobuf_la_SOURCES = \ ...@@ -244,6 +248,7 @@ libprotobuf_la_SOURCES = \
google/protobuf/compiler/importer.cc \ google/protobuf/compiler/importer.cc \
google/protobuf/compiler/parser.cc \ google/protobuf/compiler/parser.cc \
google/protobuf/util/field_comparator.cc \ google/protobuf/util/field_comparator.cc \
google/protobuf/util/field_mask_util.cc \
google/protobuf/util/internal/constants.h \ google/protobuf/util/internal/constants.h \
google/protobuf/util/internal/datapiece.cc \ google/protobuf/util/internal/datapiece.cc \
google/protobuf/util/internal/datapiece.h \ google/protobuf/util/internal/datapiece.h \
...@@ -280,8 +285,10 @@ libprotobuf_la_SOURCES = \ ...@@ -280,8 +285,10 @@ libprotobuf_la_SOURCES = \
google/protobuf/util/internal/utility.cc \ google/protobuf/util/internal/utility.cc \
google/protobuf/util/internal/utility.h \ google/protobuf/util/internal/utility.h \
google/protobuf/util/json_util.cc \ google/protobuf/util/json_util.cc \
google/protobuf/util/type_resolver_util.cc \ google/protobuf/util/message_differencer.cc \
google/protobuf/util/message_differencer.cc google/protobuf/util/time_util.cc \
google/protobuf/util/type_resolver_util.cc
nodist_libprotobuf_la_SOURCES = $(nodist_libprotobuf_lite_la_SOURCES) nodist_libprotobuf_la_SOURCES = $(nodist_libprotobuf_lite_la_SOURCES)
libprotoc_la_LIBADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc_la_LIBADD = $(PTHREAD_LIBS) libprotobuf.la
...@@ -324,11 +331,13 @@ libprotoc_la_SOURCES = \ ...@@ -324,11 +331,13 @@ libprotoc_la_SOURCES = \
google/protobuf/compiler/java/java_context.cc \ google/protobuf/compiler/java/java_context.cc \
google/protobuf/compiler/java/java_context.h \ google/protobuf/compiler/java/java_context.h \
google/protobuf/compiler/java/java_enum.cc \ google/protobuf/compiler/java/java_enum.cc \
google/protobuf/compiler/java/java_enum_lite.cc \
google/protobuf/compiler/java/java_enum_field.cc \ google/protobuf/compiler/java/java_enum_field.cc \
google/protobuf/compiler/java/java_enum_field.h \ google/protobuf/compiler/java/java_enum_field.h \
google/protobuf/compiler/java/java_enum_field_lite.cc \ google/protobuf/compiler/java/java_enum_field_lite.cc \
google/protobuf/compiler/java/java_enum_field_lite.h \ google/protobuf/compiler/java/java_enum_field_lite.h \
google/protobuf/compiler/java/java_enum.h \ google/protobuf/compiler/java/java_enum.h \
google/protobuf/compiler/java/java_enum_lite.h \
google/protobuf/compiler/java/java_extension.cc \ google/protobuf/compiler/java/java_extension.cc \
google/protobuf/compiler/java/java_extension.h \ google/protobuf/compiler/java/java_extension.h \
google/protobuf/compiler/java/java_field.cc \ google/protobuf/compiler/java/java_field.cc \
...@@ -479,6 +488,8 @@ protoc_inputs = \ ...@@ -479,6 +488,8 @@ protoc_inputs = \
google/protobuf/unittest_lite_imports_nonlite.proto \ google/protobuf/unittest_lite_imports_nonlite.proto \
google/protobuf/unittest_lite.proto \ google/protobuf/unittest_lite.proto \
google/protobuf/unittest_mset.proto \ google/protobuf/unittest_mset.proto \
google/protobuf/unittest_mset_wire_format.proto \
google/protobuf/unittest_no_arena_lite.proto \
google/protobuf/unittest_no_arena_import.proto \ google/protobuf/unittest_no_arena_import.proto \
google/protobuf/unittest_no_arena.proto \ google/protobuf/unittest_no_arena.proto \
google/protobuf/unittest_no_field_presence.proto \ google/protobuf/unittest_no_field_presence.proto \
...@@ -495,6 +506,7 @@ protoc_inputs = \ ...@@ -495,6 +506,7 @@ protoc_inputs = \
google/protobuf/util/internal/testdata/default_value_test.proto \ google/protobuf/util/internal/testdata/default_value_test.proto \
google/protobuf/util/internal/testdata/field_mask.proto \ google/protobuf/util/internal/testdata/field_mask.proto \
google/protobuf/util/internal/testdata/maps.proto \ google/protobuf/util/internal/testdata/maps.proto \
google/protobuf/util/internal/testdata/oneofs.proto \
google/protobuf/util/internal/testdata/struct.proto \ google/protobuf/util/internal/testdata/struct.proto \
google/protobuf/util/internal/testdata/timestamp_duration.proto \ google/protobuf/util/internal/testdata/timestamp_duration.proto \
google/protobuf/util/json_format_proto3.proto \ google/protobuf/util/json_format_proto3.proto \
...@@ -529,6 +541,8 @@ protoc_lite_outputs = \ ...@@ -529,6 +541,8 @@ protoc_lite_outputs = \
google/protobuf/map_lite_unittest.pb.h \ google/protobuf/map_lite_unittest.pb.h \
google/protobuf/unittest_lite.pb.cc \ google/protobuf/unittest_lite.pb.cc \
google/protobuf/unittest_lite.pb.h \ google/protobuf/unittest_lite.pb.h \
google/protobuf/unittest_no_arena_lite.pb.cc \
google/protobuf/unittest_no_arena_lite.pb.h \
google/protobuf/unittest_import_lite.pb.cc \ google/protobuf/unittest_import_lite.pb.cc \
google/protobuf/unittest_import_lite.pb.h \ google/protobuf/unittest_import_lite.pb.h \
google/protobuf/unittest_import_public_lite.pb.cc \ google/protobuf/unittest_import_public_lite.pb.cc \
...@@ -566,6 +580,8 @@ protoc_outputs = \ ...@@ -566,6 +580,8 @@ protoc_outputs = \
google/protobuf/unittest_lite_imports_nonlite.pb.h \ google/protobuf/unittest_lite_imports_nonlite.pb.h \
google/protobuf/unittest_mset.pb.cc \ google/protobuf/unittest_mset.pb.cc \
google/protobuf/unittest_mset.pb.h \ google/protobuf/unittest_mset.pb.h \
google/protobuf/unittest_mset_wire_format.pb.cc \
google/protobuf/unittest_mset_wire_format.pb.h \
google/protobuf/unittest_no_arena_import.pb.cc \ google/protobuf/unittest_no_arena_import.pb.cc \
google/protobuf/unittest_no_arena_import.pb.h \ google/protobuf/unittest_no_arena_import.pb.h \
google/protobuf/unittest_no_arena.pb.cc \ google/protobuf/unittest_no_arena.pb.cc \
...@@ -598,6 +614,8 @@ protoc_outputs = \ ...@@ -598,6 +614,8 @@ protoc_outputs = \
google/protobuf/util/internal/testdata/field_mask.pb.h \ google/protobuf/util/internal/testdata/field_mask.pb.h \
google/protobuf/util/internal/testdata/maps.pb.cc \ google/protobuf/util/internal/testdata/maps.pb.cc \
google/protobuf/util/internal/testdata/maps.pb.h \ google/protobuf/util/internal/testdata/maps.pb.h \
google/protobuf/util/internal/testdata/oneofs.pb.cc \
google/protobuf/util/internal/testdata/oneofs.pb.h \
google/protobuf/util/internal/testdata/struct.pb.cc \ google/protobuf/util/internal/testdata/struct.pb.cc \
google/protobuf/util/internal/testdata/struct.pb.h \ google/protobuf/util/internal/testdata/struct.pb.h \
google/protobuf/util/internal/testdata/timestamp_duration.pb.cc \ google/protobuf/util/internal/testdata/timestamp_duration.pb.cc \
...@@ -654,6 +672,7 @@ protobuf_test_CXXFLAGS = $(NO_OPT_CXXFLAGS) ...@@ -654,6 +672,7 @@ protobuf_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)
protobuf_test_SOURCES = \ protobuf_test_SOURCES = \
google/protobuf/stubs/bytestream_unittest.cc \ google/protobuf/stubs/bytestream_unittest.cc \
google/protobuf/stubs/common_unittest.cc \ google/protobuf/stubs/common_unittest.cc \
google/protobuf/stubs/int128_unittest.cc \
google/protobuf/stubs/once_unittest.cc \ google/protobuf/stubs/once_unittest.cc \
google/protobuf/stubs/statusor_test.cc \ google/protobuf/stubs/statusor_test.cc \
google/protobuf/stubs/status_test.cc \ google/protobuf/stubs/status_test.cc \
...@@ -706,6 +725,7 @@ protobuf_test_SOURCES = \ ...@@ -706,6 +725,7 @@ protobuf_test_SOURCES = \
google/protobuf/compiler/ruby/ruby_generator_unittest.cc \ google/protobuf/compiler/ruby/ruby_generator_unittest.cc \
google/protobuf/compiler/csharp/csharp_generator_unittest.cc \ google/protobuf/compiler/csharp/csharp_generator_unittest.cc \
google/protobuf/util/field_comparator_test.cc \ google/protobuf/util/field_comparator_test.cc \
google/protobuf/util/field_mask_util_test.cc \
google/protobuf/util/internal/default_value_objectwriter_test.cc \ google/protobuf/util/internal/default_value_objectwriter_test.cc \
google/protobuf/util/internal/json_objectwriter_test.cc \ google/protobuf/util/internal/json_objectwriter_test.cc \
google/protobuf/util/internal/json_stream_parser_test.cc \ google/protobuf/util/internal/json_stream_parser_test.cc \
...@@ -713,6 +733,7 @@ protobuf_test_SOURCES = \ ...@@ -713,6 +733,7 @@ protobuf_test_SOURCES = \
google/protobuf/util/internal/protostream_objectwriter_test.cc \ google/protobuf/util/internal/protostream_objectwriter_test.cc \
google/protobuf/util/internal/type_info_test_helper.cc \ google/protobuf/util/internal/type_info_test_helper.cc \
google/protobuf/util/json_util_test.cc \ google/protobuf/util/json_util_test.cc \
google/protobuf/util/time_util_test.cc \
google/protobuf/util/type_resolver_util_test.cc \ google/protobuf/util/type_resolver_util_test.cc \
$(COMMON_TEST_SOURCES) $(COMMON_TEST_SOURCES)
......
...@@ -42,10 +42,8 @@ option objc_class_prefix = "GPB"; ...@@ -42,10 +42,8 @@ option objc_class_prefix = "GPB";
// `Any` contains an arbitrary serialized message along with a URL // `Any` contains an arbitrary serialized message along with a URL
// that describes the type of the serialized message. // that describes the type of the serialized message.
// //
// The proto runtimes and/or compiler will eventually // JSON
// provide utilities to pack/unpack Any values (projected Q1/15). // ====
//
// # JSON
// The JSON representation of an `Any` value uses the regular // The JSON representation of an `Any` value uses the regular
// representation of the deserialized, embedded message, with an // representation of the deserialized, embedded message, with an
// additional field `@type` which contains the type URL. Example: // additional field `@type` which contains the type URL. Example:
...@@ -93,10 +91,6 @@ message Any { ...@@ -93,10 +91,6 @@ message Any {
// Schemas other than `http`, `https` (or the empty schema) might be // Schemas other than `http`, `https` (or the empty schema) might be
// used with implementation specific semantics. // used with implementation specific semantics.
// //
// Types originating from the `google.*` package
// namespace should use `type.googleapis.com/full.type.name` (without
// schema and path). A type service will eventually become available which
// serves those URLs (projected Q2/15).
string type_url = 1; string type_url = 1;
// Must be valid serialized data of the above specified type. // Must be valid serialized data of the above specified type.
......
This diff is collapsed.
This diff is collapsed.
...@@ -34,14 +34,15 @@ package google.protobuf; ...@@ -34,14 +34,15 @@ package google.protobuf;
import "google/protobuf/source_context.proto"; import "google/protobuf/source_context.proto";
import "google/protobuf/type.proto"; import "google/protobuf/type.proto";
option java_multiple_files = true;
option java_outer_classname = "ApiProto";
option java_package = "com.google.protobuf"; option java_package = "com.google.protobuf";
option java_outer_classname = "ApiProto";
option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB"; option objc_class_prefix = "GPB";
// Api is a light-weight descriptor for a protocol buffer service. // Api is a light-weight descriptor for a protocol buffer service.
message Api { message Api {
// The fully qualified name of this api, including package name // The fully qualified name of this api, including package name
// followed by the api's simple name. // followed by the api's simple name.
string name = 1; string name = 1;
...@@ -73,18 +74,22 @@ message Api { ...@@ -73,18 +74,22 @@ message Api {
// be omitted. Zero major versions must only be used for // be omitted. Zero major versions must only be used for
// experimental, none-GA apis. // experimental, none-GA apis.
// //
// See also: [design doc](http://go/api-versioning).
//
//
string version = 4; string version = 4;
// Source context for the protocol buffer service represented by this // Source context for the protocol buffer service represented by this
// message. // message.
SourceContext source_context = 5; SourceContext source_context = 5;
// Included APIs. See [Mixin][].
repeated Mixin mixins = 6;
// The source syntax of the service.
Syntax syntax = 7;
} }
// Method represents a method of an api. // Method represents a method of an api.
message Method { message Method {
// The simple name of this method. // The simple name of this method.
string name = 1; string name = 1;
...@@ -102,4 +107,94 @@ message Method { ...@@ -102,4 +107,94 @@ message Method {
// Any metadata attached to the method. // Any metadata attached to the method.
repeated Option options = 6; repeated Option options = 6;
// The source syntax of this method.
Syntax syntax = 7;
}
// Declares an API to be included in this API. The including API must
// redeclare all the methods from the included API, but documentation
// and options are inherited as follows:
//
// - If after comment and whitespace stripping, the documentation
// string of the redeclared method is empty, it will be inherited
// from the original method.
//
// - Each annotation belonging to the service config (http,
// visibility) which is not set in the redeclared method will be
// inherited.
//
// - If an http annotation is inherited, the path pattern will be
// modified as follows. Any version prefix will be replaced by the
// version of the including API plus the [root][] path if specified.
//
// Example of a simple mixin:
//
// package google.acl.v1;
// service AccessControl {
// // Get the underlying ACL object.
// rpc GetAcl(GetAclRequest) returns (Acl) {
// option (google.api.http).get = "/v1/{resource=**}:getAcl";
// }
// }
//
// package google.storage.v2;
// service Storage {
// // (-- see AccessControl.GetAcl --)
// rpc GetAcl(GetAclRequest) returns (Acl);
//
// // Get a data record.
// rpc GetData(GetDataRequest) returns (Data) {
// option (google.api.http).get = "/v2/{resource=**}";
// }
// }
//
// Example of a mixin configuration:
//
// apis:
// - name: google.storage.v2.Storage
// mixins:
// - name: google.acl.v1.AccessControl
//
// The mixin construct implies that all methods in `AccessControl` are
// also declared with same name and request/response types in
// `Storage`. A documentation generator or annotation processor will
// see the effective `Storage.GetAcl` method after inherting
// documentation and annotations as follows:
//
// service Storage {
// // Get the underlying ACL object.
// rpc GetAcl(GetAclRequest) returns (Acl) {
// option (google.api.http).get = "/v2/{resource=**}:getAcl";
// }
// ...
// }
//
// Note how the version in the path pattern changed from `v1` to `v2`.
//
// If the `root` field in the mixin is specified, it should be a
// relative path under which inherited HTTP paths are placed. Example:
//
// apis:
// - name: google.storage.v2.Storage
// mixins:
// - name: google.acl.v1.AccessControl
// root: acls
//
// This implies the following inherited HTTP annotation:
//
// service Storage {
// // Get the underlying ACL object.
// rpc GetAcl(GetAclRequest) returns (Acl) {
// option (google.api.http).get = "/v2/acls/{resource=**}:getAcl";
// }
// ...
// }
message Mixin {
// The fully qualified name of the API which is included.
string name = 1;
// If non-empty specifies a path under which inherited HTTP paths
// are rooted.
string root = 2;
} }
...@@ -80,6 +80,7 @@ option objc_class_prefix = "GPB"; ...@@ -80,6 +80,7 @@ option objc_class_prefix = "GPB";
// } // }
// //
message Duration { message Duration {
// Signed seconds of the span of time. Must be from -315,576,000,000 // Signed seconds of the span of time. Must be from -315,576,000,000
// to +315,576,000,000 inclusive. // to +315,576,000,000 inclusive.
int64 seconds = 1; int64 seconds = 1;
......
...@@ -79,8 +79,8 @@ void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto() { ...@@ -79,8 +79,8 @@ void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto() {
::google::protobuf::DescriptorPool::InternalAddGeneratedFile( ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
"\n\033google/protobuf/empty.proto\022\017google.pr" "\n\033google/protobuf/empty.proto\022\017google.pr"
"otobuf\"\007\n\005EmptyB)\n\023com.google.protobufB\n" "otobuf\"\007\n\005EmptyB,\n\023com.google.protobufB\n"
"EmptyProtoP\001\242\002\003GPBb\006proto3", 106); "EmptyProtoP\001\240\001\001\242\002\003GPBb\006proto3", 109);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"google/protobuf/empty.proto", &protobuf_RegisterTypes); "google/protobuf/empty.proto", &protobuf_RegisterTypes);
Empty::default_instance_ = new Empty(); Empty::default_instance_ = new Empty();
......
...@@ -31,12 +31,12 @@ syntax = "proto3"; ...@@ -31,12 +31,12 @@ syntax = "proto3";
package google.protobuf; package google.protobuf;
option java_multiple_files = true;
option java_outer_classname = "EmptyProto";
option java_package = "com.google.protobuf"; option java_package = "com.google.protobuf";
option java_outer_classname = "EmptyProto";
option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB"; option objc_class_prefix = "GPB";
// A generic empty message that you can re-use to avoid defining duplicated // A generic empty message that you can re-use to avoid defining duplicated
// empty messages in your APIs. A typical example is to use it as the request // empty messages in your APIs. A typical example is to use it as the request
// or the response type of an API method. For instance: // or the response type of an API method. For instance:
...@@ -45,6 +45,5 @@ option objc_class_prefix = "GPB"; ...@@ -45,6 +45,5 @@ option objc_class_prefix = "GPB";
// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); // rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
// } // }
// //
message Empty { // The JSON representation for `Empty` is empty JSON object `{}`.
message Empty {}
}
...@@ -81,8 +81,9 @@ void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto() { ...@@ -81,8 +81,9 @@ void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto() {
::google::protobuf::DescriptorPool::InternalAddGeneratedFile( ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
"\n google/protobuf/field_mask.proto\022\017goog" "\n google/protobuf/field_mask.proto\022\017goog"
"le.protobuf\"\032\n\tFieldMask\022\r\n\005paths\030\001 \003(\tB" "le.protobuf\"\032\n\tFieldMask\022\r\n\005paths\030\001 \003(\tB"
"F\n\023com.google.protobufB\016FieldMaskProtoP\001" "I\n\023com.google.protobufB\016FieldMaskProtoP\001"
"\242\002\003GPB\252\002\026Google.ProtocolBuffersb\006proto3", 159); "\240\001\001\242\002\003GPB\252\002\026Google.ProtocolBuffersb\006prot"
"o3", 162);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"google/protobuf/field_mask.proto", &protobuf_RegisterTypes); "google/protobuf/field_mask.proto", &protobuf_RegisterTypes);
FieldMask::default_instance_ = new FieldMask(); FieldMask::default_instance_ = new FieldMask();
......
...@@ -31,13 +31,13 @@ syntax = "proto3"; ...@@ -31,13 +31,13 @@ syntax = "proto3";
package google.protobuf; package google.protobuf;
option csharp_namespace = "Google.ProtocolBuffers";
option java_generate_equals_and_hash = true;
option java_multiple_files = true; option java_multiple_files = true;
option java_outer_classname = "FieldMaskProto"; option java_outer_classname = "FieldMaskProto";
option java_package = "com.google.protobuf"; option java_package = "com.google.protobuf";
option csharp_namespace = "Google.ProtocolBuffers";
option objc_class_prefix = "GPB"; option objc_class_prefix = "GPB";
// `FieldMask` represents a set of symbolic field paths, for example: // `FieldMask` represents a set of symbolic field paths, for example:
// //
// paths: "f.a" // paths: "f.a"
...@@ -52,6 +52,7 @@ option objc_class_prefix = "GPB"; ...@@ -52,6 +52,7 @@ option objc_class_prefix = "GPB";
// Field masks also have a custom JSON encoding (see below). // Field masks also have a custom JSON encoding (see below).
// //
// # Field Masks in Projections // # Field Masks in Projections
//
// When used in the context of a projection, a response message or // When used in the context of a projection, a response message or
// sub-message is filtered by the API to only contain those fields as // sub-message is filtered by the API to only contain those fields as
// specified in the mask. For example, if the mask in the previous // specified in the mask. For example, if the mask in the previous
...@@ -97,6 +98,7 @@ option objc_class_prefix = "GPB"; ...@@ -97,6 +98,7 @@ option objc_class_prefix = "GPB";
// behavior for APIs. // behavior for APIs.
// //
// # Field Masks in Update Operations // # Field Masks in Update Operations
//
// A field mask in update operations specifies which fields of the // A field mask in update operations specifies which fields of the
// targeted resource are going to be updated. The API is required // targeted resource are going to be updated. The API is required
// to only change the values of the fields as specified in the mask // to only change the values of the fields as specified in the mask
...@@ -124,11 +126,13 @@ option objc_class_prefix = "GPB"; ...@@ -124,11 +126,13 @@ option objc_class_prefix = "GPB";
// required to be honored by the API. // required to be honored by the API.
// //
// ## Considerations for HTTP REST // ## Considerations for HTTP REST
//
// The HTTP kind of an update operation which uses a field mask must // The HTTP kind of an update operation which uses a field mask must
// be set to PATCH instead of PUT in order to satisfy HTTP semantics // be set to PATCH instead of PUT in order to satisfy HTTP semantics
// (PUT must only be used for full updates). // (PUT must only be used for full updates).
// //
// # JSON Encoding of Field Masks // # JSON Encoding of Field Masks
//
// In JSON, a field mask is encoded as a single string where paths are // In JSON, a field mask is encoded as a single string where paths are
// separated by a comma. Fields name in each path are converted // separated by a comma. Fields name in each path are converted
// to/from lower-camel naming conventions. // to/from lower-camel naming conventions.
......
...@@ -81,8 +81,8 @@ void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() { ...@@ -81,8 +81,8 @@ void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() {
::google::protobuf::DescriptorPool::InternalAddGeneratedFile( ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
"\n$google/protobuf/source_context.proto\022\017" "\n$google/protobuf/source_context.proto\022\017"
"google.protobuf\"\"\n\rSourceContext\022\021\n\tfile" "google.protobuf\"\"\n\rSourceContext\022\021\n\tfile"
"_name\030\001 \001(\tB1\n\023com.google.protobufB\022Sour" "_name\030\001 \001(\tB4\n\023com.google.protobufB\022Sour"
"ceContextProtoP\001\242\002\003GPBb\006proto3", 150); "ceContextProtoP\001\240\001\001\242\002\003GPBb\006proto3", 153);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"google/protobuf/source_context.proto", &protobuf_RegisterTypes); "google/protobuf/source_context.proto", &protobuf_RegisterTypes);
SourceContext::default_instance_ = new SourceContext(); SourceContext::default_instance_ = new SourceContext();
......
...@@ -31,12 +31,12 @@ syntax = "proto3"; ...@@ -31,12 +31,12 @@ syntax = "proto3";
package google.protobuf; package google.protobuf;
option java_multiple_files = true;
option java_outer_classname = "SourceContextProto";
option java_package = "com.google.protobuf"; option java_package = "com.google.protobuf";
option java_outer_classname = "SourceContextProto";
option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB"; option objc_class_prefix = "GPB";
// `SourceContext` represents information about the source of a // `SourceContext` represents information about the source of a
// protobuf element, like the file in which it is defined. // protobuf element, like the file in which it is defined.
message SourceContext { message SourceContext {
......
...@@ -45,6 +45,8 @@ option objc_class_prefix = "GPB"; ...@@ -45,6 +45,8 @@ option objc_class_prefix = "GPB";
// scripting languages like JS a struct is represented as an // scripting languages like JS a struct is represented as an
// object. The details of that representation are described together // object. The details of that representation are described together
// with the proto support for the language. // with the proto support for the language.
//
// The JSON representation for `Struct` is JSON object.
message Struct { message Struct {
// Map of dynamically typed values. // Map of dynamically typed values.
map<string, Value> fields = 1; map<string, Value> fields = 1;
...@@ -54,37 +56,39 @@ message Struct { ...@@ -54,37 +56,39 @@ message Struct {
// null, a number, a string, a boolean, a recursive struct value, or a // null, a number, a string, a boolean, a recursive struct value, or a
// list of values. A producer of value is expected to set one of that // list of values. A producer of value is expected to set one of that
// variants, absence of any variant indicates an error. // variants, absence of any variant indicates an error.
//
// The JSON representation for `Value` is JSON value.
message Value { message Value {
// The kind of value.
oneof kind { oneof kind {
// Represents a null value. // Represents a null value.
NullValue null_value = 1; NullValue null_value = 1;
// Represents a double value. // Represents a double value.
double number_value = 2; double number_value = 2;
// Represents a string value. // Represents a string value.
string string_value = 3; string string_value = 3;
// Represents a boolean value. // Represents a boolean value.
bool bool_value = 4; bool bool_value = 4;
// Represents a structured value. // Represents a structured value.
Struct struct_value = 5; Struct struct_value = 5;
// Represents a repeated `Value`. // Represents a repeated `Value`.
ListValue list_value = 6; ListValue list_value = 6;
} }
} }
// `NullValue` is a singleton enumeration to represent the null value for the
// `Value` type union.
//
// The JSON representation for `NullValue` is JSON `null`.
enum NullValue {
// Null value.
NULL_VALUE = 0;
}
// `ListValue` is a wrapper around a repeated field of values. // `ListValue` is a wrapper around a repeated field of values.
//
// The JSON representation for `ListValue` is JSON array.
message ListValue { message ListValue {
// Repeated field of dynamically typed values. // Repeated field of dynamically typed values.
repeated Value values = 1; repeated Value values = 1;
} }
// `NullValue` is a singleton enumeration to represent the null
// value for the `Value` type union.
enum NullValue {
// Null value.
NULL_VALUE = 0;
}
...@@ -35,8 +35,10 @@ ...@@ -35,8 +35,10 @@
#include <google/protobuf/stubs/status.h> #include <google/protobuf/stubs/status.h>
#include <google/protobuf/stubs/stringpiece.h> #include <google/protobuf/stubs/stringpiece.h>
#include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/strutil.h>
#include <stdio.h> #include <google/protobuf/stubs/int128.h>
#include <errno.h> #include <errno.h>
#include <sstream>
#include <stdio.h>
#include <vector> #include <vector>
#ifdef _WIN32 #ifdef _WIN32
...@@ -48,6 +50,9 @@ ...@@ -48,6 +50,9 @@
#else #else
#error "No suitable threading library available." #error "No suitable threading library available."
#endif #endif
#if defined(__ANDROID__)
#include <android/log.h>
#endif
namespace google { namespace google {
namespace protobuf { namespace protobuf {
...@@ -104,7 +109,43 @@ string VersionString(int version) { ...@@ -104,7 +109,43 @@ string VersionString(int version) {
// emulates google3/base/logging.cc // emulates google3/base/logging.cc
namespace internal { namespace internal {
#if defined(__ANDROID__)
inline void DefaultLogHandler(LogLevel level, const char* filename, int line,
const string& message) {
#ifdef GOOGLE_PROTOBUF_MIN_LOG_LEVEL
if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) {
return;
}
static const char* level_names[] = {"INFO", "WARNING", "ERROR", "FATAL"};
static const int android_log_levels[] = {
ANDROID_LOG_INFO, // LOG(INFO),
ANDROID_LOG_WARN, // LOG(WARNING)
ANDROID_LOG_ERROR, // LOG(ERROR)
ANDROID_LOG_FATAL, // LOG(FATAL)
};
// Bound the logging level.
const int android_log_level = android_log_levels[level];
::std::ostringstream ostr;
ostr << "[libprotobuf " << level_names[level] << " " << filename << ":"
<< line << "] " << message.c_str();
// Output the log string the Android log at the appropriate level.
__android_log_write(android_log_level, "libprotobuf-native",
ostr.str().c_str());
// Also output to std::cerr.
fprintf(stderr, "%s", ostr.str().c_str());
fflush(stderr);
// Indicate termination if needed.
if (android_log_level == ANDROID_LOG_FATAL) {
__android_log_write(ANDROID_LOG_FATAL, "libprotobuf-native",
"terminating.\n");
}
#endif
}
#else
void DefaultLogHandler(LogLevel level, const char* filename, int line, void DefaultLogHandler(LogLevel level, const char* filename, int line,
const string& message) { const string& message) {
static const char* level_names[] = { "INFO", "WARNING", "ERROR", "FATAL" }; static const char* level_names[] = { "INFO", "WARNING", "ERROR", "FATAL" };
...@@ -115,6 +156,7 @@ void DefaultLogHandler(LogLevel level, const char* filename, int line, ...@@ -115,6 +156,7 @@ void DefaultLogHandler(LogLevel level, const char* filename, int line,
level_names[level], filename, line, message.c_str()); level_names[level], filename, line, message.c_str());
fflush(stderr); // Needed on MSVC. fflush(stderr); // Needed on MSVC.
} }
#endif
void NullLogHandler(LogLevel /* level */, const char* /* filename */, void NullLogHandler(LogLevel /* level */, const char* /* filename */,
int /* line */, const string& /* message */) { int /* line */, const string& /* message */) {
...@@ -154,22 +196,19 @@ LogMessage& LogMessage::operator<<(const StringPiece& value) { ...@@ -154,22 +196,19 @@ LogMessage& LogMessage::operator<<(const StringPiece& value) {
return *this; return *this;
} }
LogMessage& LogMessage::operator<<(long long value) {
message_ += SimpleItoa(value);
return *this;
}
LogMessage& LogMessage::operator<<(unsigned long long value) {
message_ += SimpleItoa(value);
return *this;
}
LogMessage& LogMessage::operator<<( LogMessage& LogMessage::operator<<(
const ::google::protobuf::util::Status& status) { const ::google::protobuf::util::Status& status) {
message_ += status.ToString(); message_ += status.ToString();
return *this; return *this;
} }
LogMessage& LogMessage::operator<<(const uint128& value) {
std::ostringstream str;
str << value;
message_ += str.str();
return *this;
}
// Since this is just for logging, we don't care if the current locale changes // Since this is just for logging, we don't care if the current locale changes
// the results -- in fact, we probably prefer that. So we use snprintf() // the results -- in fact, we probably prefer that. So we use snprintf()
// instead of Simple*toa(). // instead of Simple*toa().
...@@ -194,6 +233,8 @@ DECLARE_STREAM_OPERATOR(long , "%ld") ...@@ -194,6 +233,8 @@ DECLARE_STREAM_OPERATOR(long , "%ld")
DECLARE_STREAM_OPERATOR(unsigned long, "%lu") DECLARE_STREAM_OPERATOR(unsigned long, "%lu")
DECLARE_STREAM_OPERATOR(double , "%g" ) DECLARE_STREAM_OPERATOR(double , "%g" )
DECLARE_STREAM_OPERATOR(void* , "%p" ) DECLARE_STREAM_OPERATOR(void* , "%p" )
DECLARE_STREAM_OPERATOR(long long , "%" GOOGLE_LL_FORMAT "d")
DECLARE_STREAM_OPERATOR(unsigned long long, "%" GOOGLE_LL_FORMAT "u")
#undef DECLARE_STREAM_OPERATOR #undef DECLARE_STREAM_OPERATOR
LogMessage::LogMessage(LogLevel level, const char* filename, int line) LogMessage::LogMessage(LogLevel level, const char* filename, int line)
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#ifndef GOOGLE_PROTOBUF_COMMON_H__ #ifndef GOOGLE_PROTOBUF_COMMON_H__
#define GOOGLE_PROTOBUF_COMMON_H__ #define GOOGLE_PROTOBUF_COMMON_H__
#include <string>
#include <google/protobuf/stubs/port.h> #include <google/protobuf/stubs/port.h>
#include <google/protobuf/stubs/macros.h> #include <google/protobuf/stubs/macros.h>
...@@ -137,12 +138,35 @@ std::string LIBPROTOBUF_EXPORT VersionString(int version); ...@@ -137,12 +138,35 @@ std::string LIBPROTOBUF_EXPORT VersionString(int version);
// =================================================================== // ===================================================================
// from google3/util/utf8/public/unilib.h // from google3/util/utf8/public/unilib.h
class StringPiece;
namespace internal { namespace internal {
// Checks if the buffer contains structurally-valid UTF-8. Implemented in // Checks if the buffer contains structurally-valid UTF-8. Implemented in
// structurally_valid.cc. // structurally_valid.cc.
LIBPROTOBUF_EXPORT bool IsStructurallyValidUTF8(const char* buf, int len); LIBPROTOBUF_EXPORT bool IsStructurallyValidUTF8(const char* buf, int len);
inline bool IsStructurallyValidUTF8(const std::string& str) {
return IsStructurallyValidUTF8(str.data(), str.length());
}
// Returns initial number of bytes of structually valid UTF-8.
LIBPROTOBUF_EXPORT int UTF8SpnStructurallyValid(const StringPiece& str);
// Coerce UTF-8 byte string in src_str to be
// a structurally-valid equal-length string by selectively
// overwriting illegal bytes with replace_char (typically ' ' or '?').
// replace_char must be legal printable 7-bit Ascii 0x20..0x7e.
// src_str is read-only.
//
// Returns pointer to output buffer, src_str.data() if no changes were made,
// or idst if some bytes were changed. idst is allocated by the caller
// and must be at least as big as src_str
//
// Optimized for: all structurally valid and no byte copying is done.
//
LIBPROTOBUF_EXPORT char* UTF8CoerceToStructurallyValid(
const StringPiece& str, char* dst, char replace_char);
} // namespace internal } // namespace internal
......
...@@ -143,6 +143,21 @@ ...@@ -143,6 +143,21 @@
# define GOOGLE_PROTOBUF_HASH_SET_CLASS unordered_set # define GOOGLE_PROTOBUF_HASH_SET_CLASS unordered_set
#endif #endif
#ifndef GOOGLE_PROTOBUF_HASH_NAMESPACE
# define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_START
# define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END
#elif !defined(GOOGLE_PROTOBUF_HAS_CXX11_HASH) && \
defined(GOOGLE_PROTOBUF_HAS_TR1)
# define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_START \
namespace std { \
namespace tr1 {
# define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END }}
#else
# define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_START \
namespace GOOGLE_PROTOBUF_HASH_NAMESPACE {
# define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END }
#endif
#undef GOOGLE_PROTOBUF_HAS_CXX11_HASH #undef GOOGLE_PROTOBUF_HAS_CXX11_HASH
#undef GOOGLE_PROTOBUF_HAS_TR1 #undef GOOGLE_PROTOBUF_HAS_TR1
......
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <google/protobuf/stubs/int128.h>
#include <iomanip>
#include <iostream> // NOLINT(readability/streams)
#include <sstream>
namespace google {
namespace protobuf {
const uint128_pod kuint128max = {
static_cast<uint64>(GOOGLE_LONGLONG(0xFFFFFFFFFFFFFFFF)),
static_cast<uint64>(GOOGLE_LONGLONG(0xFFFFFFFFFFFFFFFF))
};
// Returns the 0-based position of the last set bit (i.e., most significant bit)
// in the given uint64. The argument may not be 0.
//
// For example:
// Given: 5 (decimal) == 101 (binary)
// Returns: 2
#define STEP(T, n, pos, sh) \
do { \
if ((n) >= (static_cast<T>(1) << (sh))) { \
(n) = (n) >> (sh); \
(pos) |= (sh); \
} \
} while (0)
static inline int Fls64(uint64 n) {
GOOGLE_DCHECK_NE(0, n);
int pos = 0;
STEP(uint64, n, pos, 0x20);
uint32 n32 = n;
STEP(uint32, n32, pos, 0x10);
STEP(uint32, n32, pos, 0x08);
STEP(uint32, n32, pos, 0x04);
return pos + ((GOOGLE_ULONGLONG(0x3333333322221100) >> (n32 << 2)) & 0x3);
}
#undef STEP
// Like Fls64() above, but returns the 0-based position of the last set bit
// (i.e., most significant bit) in the given uint128. The argument may not be 0.
static inline int Fls128(uint128 n) {
if (uint64 hi = Uint128High64(n)) {
return Fls64(hi) + 64;
}
return Fls64(Uint128Low64(n));
}
// Long division/modulo for uint128 implemented using the shift-subtract
// division algorithm adapted from:
// http://stackoverflow.com/questions/5386377/division-without-using
void uint128::DivModImpl(uint128 dividend, uint128 divisor,
uint128* quotient_ret, uint128* remainder_ret) {
if (divisor == 0) {
GOOGLE_LOG(FATAL) << "Division or mod by zero: dividend.hi=" << dividend.hi_
<< ", lo=" << dividend.lo_;
}
if (divisor > dividend) {
*quotient_ret = 0;
*remainder_ret = dividend;
return;
}
if (divisor == dividend) {
*quotient_ret = 1;
*remainder_ret = 0;
return;
}
uint128 denominator = divisor;
uint128 position = 1;
uint128 quotient = 0;
// Left aligns the MSB of the denominator and the dividend.
int shift = Fls128(dividend) - Fls128(denominator);
denominator <<= shift;
position <<= shift;
// Uses shift-subtract algorithm to divide dividend by denominator. The
// remainder will be left in dividend.
while (position > 0) {
if (dividend >= denominator) {
dividend -= denominator;
quotient |= position;
}
position >>= 1;
denominator >>= 1;
}
*quotient_ret = quotient;
*remainder_ret = dividend;
}
uint128& uint128::operator/=(const uint128& divisor) {
uint128 quotient = 0;
uint128 remainder = 0;
DivModImpl(*this, divisor, &quotient, &remainder);
*this = quotient;
return *this;
}
uint128& uint128::operator%=(const uint128& divisor) {
uint128 quotient = 0;
uint128 remainder = 0;
DivModImpl(*this, divisor, &quotient, &remainder);
*this = remainder;
return *this;
}
std::ostream& operator<<(std::ostream& o, const uint128& b) {
std::ios_base::fmtflags flags = o.flags();
// Select a divisor which is the largest power of the base < 2^64.
uint128 div;
std::streamsize div_base_log;
switch (flags & std::ios::basefield) {
case std::ios::hex:
div = GOOGLE_ULONGLONG(0x1000000000000000); // 16^15
div_base_log = 15;
break;
case std::ios::oct:
div = GOOGLE_ULONGLONG(01000000000000000000000); // 8^21
div_base_log = 21;
break;
default: // std::ios::dec
div = GOOGLE_ULONGLONG(10000000000000000000); // 10^19
div_base_log = 19;
break;
}
// Now piece together the uint128 representation from three chunks of
// the original value, each less than "div" and therefore representable
// as a uint64.
std::ostringstream os;
std::ios_base::fmtflags copy_mask =
std::ios::basefield | std::ios::showbase | std::ios::uppercase;
os.setf(flags & copy_mask, copy_mask);
uint128 high = b;
uint128 low;
uint128::DivModImpl(high, div, &high, &low);
uint128 mid;
uint128::DivModImpl(high, div, &high, &mid);
if (high.lo_ != 0) {
os << high.lo_;
os << std::noshowbase << std::setfill('0') << std::setw(div_base_log);
os << mid.lo_;
os << std::setw(div_base_log);
} else if (mid.lo_ != 0) {
os << mid.lo_;
os << std::noshowbase << std::setfill('0') << std::setw(div_base_log);
}
os << low.lo_;
std::string rep = os.str();
// Add the requisite padding.
std::streamsize width = o.width(0);
if (width > rep.size()) {
if ((flags & std::ios::adjustfield) == std::ios::left) {
rep.append(width - rep.size(), o.fill());
} else {
rep.insert(0, width - rep.size(), o.fill());
}
}
// Stream the final representation in a single "<<" call.
return o << rep;
}
} // namespace protobuf
} // namespace google
This diff is collapsed.
This diff is collapsed.
...@@ -65,6 +65,7 @@ class StringPiece; ...@@ -65,6 +65,7 @@ class StringPiece;
namespace util { namespace util {
class Status; class Status;
} }
class uint128;
namespace internal { namespace internal {
class LogFinisher; class LogFinisher;
...@@ -78,7 +79,7 @@ class LIBPROTOBUF_EXPORT LogMessage { ...@@ -78,7 +79,7 @@ class LIBPROTOBUF_EXPORT LogMessage {
LogMessage& operator<<(const char* value); LogMessage& operator<<(const char* value);
LogMessage& operator<<(char value); LogMessage& operator<<(char value);
LogMessage& operator<<(int value); LogMessage& operator<<(int value);
LogMessage& operator<<(unsigned int value); LogMessage& operator<<(uint value);
LogMessage& operator<<(long value); LogMessage& operator<<(long value);
LogMessage& operator<<(unsigned long value); LogMessage& operator<<(unsigned long value);
LogMessage& operator<<(long long value); LogMessage& operator<<(long long value);
...@@ -87,6 +88,7 @@ class LIBPROTOBUF_EXPORT LogMessage { ...@@ -87,6 +88,7 @@ class LIBPROTOBUF_EXPORT LogMessage {
LogMessage& operator<<(void* value); LogMessage& operator<<(void* value);
LogMessage& operator<<(const StringPiece& value); LogMessage& operator<<(const StringPiece& value);
LogMessage& operator<<(const ::google::protobuf::util::Status& status); LogMessage& operator<<(const ::google::protobuf::util::Status& status);
LogMessage& operator<<(const uint128& value);
private: private:
friend class LogFinisher; friend class LogFinisher;
......
...@@ -100,20 +100,12 @@ typedef unsigned __int64 uint64; ...@@ -100,20 +100,12 @@ typedef unsigned __int64 uint64;
typedef signed char int8; typedef signed char int8;
typedef short int16; typedef short int16;
typedef int int32; typedef int int32;
// NOTE: This should be "long long" for consistency with upstream, but typedef long long int64;
// something is stacked against this particular type for 64bit hashing.
// Switching it causes an obvious missing hash function (with an unobvious
// cause) when building the tests.
typedef int64_t int64;
typedef unsigned char uint8; typedef unsigned char uint8;
typedef unsigned short uint16; typedef unsigned short uint16;
typedef unsigned int uint32; typedef unsigned int uint32;
// NOTE: This should be "unsigned long long" for consistency with upstream, but typedef unsigned long long uint64;
// something is stacked against this particular type for 64bit hashing.
// Switching it causes an obvious missing hash function (with an unobvious
// cause) when building the tests.
typedef uint64_t uint64;
#endif #endif
// long long macros to be used because gcc and vc++ use different suffixes, // long long macros to be used because gcc and vc++ use different suffixes,
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
#include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/stringpiece.h>
namespace google { namespace google {
namespace protobuf { namespace protobuf {
namespace internal { namespace internal {
...@@ -531,6 +533,56 @@ bool IsStructurallyValidUTF8(const char* buf, int len) { ...@@ -531,6 +533,56 @@ bool IsStructurallyValidUTF8(const char* buf, int len) {
return (bytes_consumed == len); return (bytes_consumed == len);
} }
int UTF8SpnStructurallyValid(const StringPiece& str) {
if (!module_initialized_) return str.size();
int bytes_consumed = 0;
UTF8GenericScanFastAscii(&utf8acceptnonsurrogates_obj,
str.data(), str.size(), &bytes_consumed);
return bytes_consumed;
}
// Coerce UTF-8 byte string in src_str to be
// a structurally-valid equal-length string by selectively
// overwriting illegal bytes with replace_char (typically blank).
// replace_char must be legal printable 7-bit Ascii 0x20..0x7e.
// src_str is read-only. If any overwriting is needed, a modified byte string
// is created in idst, length isrclen.
//
// Returns pointer to output buffer, isrc if no changes were made,
// or idst if some bytes were changed.
//
// Fast case: all is structurally valid and no byte copying is done.
//
char* UTF8CoerceToStructurallyValid(const StringPiece& src_str,
char* idst,
const char replace_char) {
const char* isrc = src_str.data();
const int len = src_str.length();
int n = UTF8SpnStructurallyValid(src_str);
if (n == len) { // Normal case -- all is cool, return
return const_cast<char*>(isrc);
} else { // Unusual case -- copy w/o bad bytes
const char* src = isrc;
const char* srclimit = isrc + len;
char* dst = idst;
memmove(dst, src, n); // Copy initial good chunk
src += n;
dst += n;
while (src < srclimit) { // src points to bogus byte or is off the end
dst[0] = replace_char; // replace one bad byte
src++;
dst++;
StringPiece str2(src, srclimit - src);
n = UTF8SpnStructurallyValid(str2); // scan the remainder
memmove(dst, src, n); // copy next good chunk
src += n;
dst += n;
}
}
return idst;
}
} // namespace internal } // namespace internal
} // namespace protobuf } // namespace protobuf
} // namespace google } // namespace google
...@@ -38,7 +38,6 @@ option java_package = "com.google.protobuf"; ...@@ -38,7 +38,6 @@ option java_package = "com.google.protobuf";
option csharp_namespace = "Google.ProtocolBuffers"; option csharp_namespace = "Google.ProtocolBuffers";
option objc_class_prefix = "GPB"; option objc_class_prefix = "GPB";
// A Timestamp represents a point in time independent of any time zone // A Timestamp represents a point in time independent of any time zone
// or calendar, represented as seconds and fractions of seconds at // or calendar, represented as seconds and fractions of seconds at
// nanosecond resolution in UTC Epoch time. It is encoded using the // nanosecond resolution in UTC Epoch time. It is encoded using the
...@@ -85,14 +84,16 @@ option objc_class_prefix = "GPB"; ...@@ -85,14 +84,16 @@ option objc_class_prefix = "GPB";
// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) // Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
// .setNanos((int) ((millis % 1000) * 1000000)).build(); // .setNanos((int) ((millis % 1000) * 1000000)).build();
// //
// Example 5: Compute Timestamp from Python `datetime.datetime`.
// //
// now = datetime.datetime.utcnow() // Example 5: Compute Timestamp from current time in Python.
// seconds = int(time.mktime(now.timetuple())) //
// nanos = now.microsecond * 1000 // now = time.time()
// seconds = int(now)
// nanos = int((now - seconds) * 10**9)
// timestamp = Timestamp(seconds=seconds, nanos=nanos) // timestamp = Timestamp(seconds=seconds, nanos=nanos)
// //
message Timestamp { message Timestamp {
// Represents seconds of UTC time since Unix epoch // Represents seconds of UTC time since Unix epoch
// 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to // 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to
// 9999-12-31T23:59:59Z inclusive. // 9999-12-31T23:59:59Z inclusive.
......
This diff is collapsed.
...@@ -57,6 +57,7 @@ enum Field_Kind { ...@@ -57,6 +57,7 @@ enum Field_Kind {
Field_Kind_TYPE_FIXED32 = 7, Field_Kind_TYPE_FIXED32 = 7,
Field_Kind_TYPE_BOOL = 8, Field_Kind_TYPE_BOOL = 8,
Field_Kind_TYPE_STRING = 9, Field_Kind_TYPE_STRING = 9,
Field_Kind_TYPE_GROUP = 10,
Field_Kind_TYPE_MESSAGE = 11, Field_Kind_TYPE_MESSAGE = 11,
Field_Kind_TYPE_BYTES = 12, Field_Kind_TYPE_BYTES = 12,
Field_Kind_TYPE_UINT32 = 13, Field_Kind_TYPE_UINT32 = 13,
...@@ -106,6 +107,27 @@ inline bool Field_Cardinality_Parse( ...@@ -106,6 +107,27 @@ inline bool Field_Cardinality_Parse(
return ::google::protobuf::internal::ParseNamedEnum<Field_Cardinality>( return ::google::protobuf::internal::ParseNamedEnum<Field_Cardinality>(
Field_Cardinality_descriptor(), name, value); Field_Cardinality_descriptor(), name, value);
} }
enum Syntax {
SYNTAX_PROTO2 = 0,
SYNTAX_PROTO3 = 1,
Syntax_INT_MIN_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32min,
Syntax_INT_MAX_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32max
};
LIBPROTOBUF_EXPORT bool Syntax_IsValid(int value);
const Syntax Syntax_MIN = SYNTAX_PROTO2;
const Syntax Syntax_MAX = SYNTAX_PROTO3;
const int Syntax_ARRAYSIZE = Syntax_MAX + 1;
LIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* Syntax_descriptor();
inline const ::std::string& Syntax_Name(Syntax value) {
return ::google::protobuf::internal::NameOfEnum(
Syntax_descriptor(), value);
}
inline bool Syntax_Parse(
const ::std::string& name, Syntax* value) {
return ::google::protobuf::internal::ParseNamedEnum<Syntax>(
Syntax_descriptor(), name, value);
}
// =================================================================== // ===================================================================
class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message { class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message {
...@@ -224,6 +246,12 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message { ...@@ -224,6 +246,12 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message {
::google::protobuf::SourceContext* release_source_context(); ::google::protobuf::SourceContext* release_source_context();
void set_allocated_source_context(::google::protobuf::SourceContext* source_context); void set_allocated_source_context(::google::protobuf::SourceContext* source_context);
// optional .google.protobuf.Syntax syntax = 6;
void clear_syntax();
static const int kSyntaxFieldNumber = 6;
::google::protobuf::Syntax syntax() const;
void set_syntax(::google::protobuf::Syntax value);
// @@protoc_insertion_point(class_scope:google.protobuf.Type) // @@protoc_insertion_point(class_scope:google.protobuf.Type)
private: private:
...@@ -234,6 +262,7 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message { ...@@ -234,6 +262,7 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message {
::google::protobuf::RepeatedPtrField< ::std::string> oneofs_; ::google::protobuf::RepeatedPtrField< ::std::string> oneofs_;
::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_;
::google::protobuf::SourceContext* source_context_; ::google::protobuf::SourceContext* source_context_;
int syntax_;
mutable int _cached_size_; mutable int _cached_size_;
friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();
friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto();
...@@ -309,6 +338,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message { ...@@ -309,6 +338,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message {
static const Kind TYPE_FIXED32 = Field_Kind_TYPE_FIXED32; static const Kind TYPE_FIXED32 = Field_Kind_TYPE_FIXED32;
static const Kind TYPE_BOOL = Field_Kind_TYPE_BOOL; static const Kind TYPE_BOOL = Field_Kind_TYPE_BOOL;
static const Kind TYPE_STRING = Field_Kind_TYPE_STRING; static const Kind TYPE_STRING = Field_Kind_TYPE_STRING;
static const Kind TYPE_GROUP = Field_Kind_TYPE_GROUP;
static const Kind TYPE_MESSAGE = Field_Kind_TYPE_MESSAGE; static const Kind TYPE_MESSAGE = Field_Kind_TYPE_MESSAGE;
static const Kind TYPE_BYTES = Field_Kind_TYPE_BYTES; static const Kind TYPE_BYTES = Field_Kind_TYPE_BYTES;
static const Kind TYPE_UINT32 = Field_Kind_TYPE_UINT32; static const Kind TYPE_UINT32 = Field_Kind_TYPE_UINT32;
...@@ -430,6 +460,17 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message { ...@@ -430,6 +460,17 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message {
::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >* ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
mutable_options(); mutable_options();
// optional string json_name = 10;
void clear_json_name();
static const int kJsonNameFieldNumber = 10;
const ::std::string& json_name() const;
void set_json_name(const ::std::string& value);
void set_json_name(const char* value);
void set_json_name(const char* value, size_t size);
::std::string* mutable_json_name();
::std::string* release_json_name();
void set_allocated_json_name(::std::string* json_name);
// @@protoc_insertion_point(class_scope:google.protobuf.Field) // @@protoc_insertion_point(class_scope:google.protobuf.Field)
private: private:
...@@ -442,6 +483,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message { ...@@ -442,6 +483,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message {
::google::protobuf::int32 oneof_index_; ::google::protobuf::int32 oneof_index_;
::google::protobuf::internal::ArenaStringPtr type_url_; ::google::protobuf::internal::ArenaStringPtr type_url_;
::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_;
::google::protobuf::internal::ArenaStringPtr json_name_;
bool packed_; bool packed_;
mutable int _cached_size_; mutable int _cached_size_;
friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();
...@@ -553,6 +595,12 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message { ...@@ -553,6 +595,12 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message {
::google::protobuf::SourceContext* release_source_context(); ::google::protobuf::SourceContext* release_source_context();
void set_allocated_source_context(::google::protobuf::SourceContext* source_context); void set_allocated_source_context(::google::protobuf::SourceContext* source_context);
// optional .google.protobuf.Syntax syntax = 5;
void clear_syntax();
static const int kSyntaxFieldNumber = 5;
::google::protobuf::Syntax syntax() const;
void set_syntax(::google::protobuf::Syntax value);
// @@protoc_insertion_point(class_scope:google.protobuf.Enum) // @@protoc_insertion_point(class_scope:google.protobuf.Enum)
private: private:
...@@ -562,6 +610,7 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message { ...@@ -562,6 +610,7 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message {
::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue > enumvalue_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue > enumvalue_;
::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_;
::google::protobuf::SourceContext* source_context_; ::google::protobuf::SourceContext* source_context_;
int syntax_;
mutable int _cached_size_; mutable int _cached_size_;
friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();
friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto();
...@@ -968,6 +1017,20 @@ inline void Type::set_allocated_source_context(::google::protobuf::SourceContext ...@@ -968,6 +1017,20 @@ inline void Type::set_allocated_source_context(::google::protobuf::SourceContext
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.source_context) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.source_context)
} }
// optional .google.protobuf.Syntax syntax = 6;
inline void Type::clear_syntax() {
syntax_ = 0;
}
inline ::google::protobuf::Syntax Type::syntax() const {
// @@protoc_insertion_point(field_get:google.protobuf.Type.syntax)
return static_cast< ::google::protobuf::Syntax >(syntax_);
}
inline void Type::set_syntax(::google::protobuf::Syntax value) {
syntax_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.Type.syntax)
}
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Field // Field
...@@ -1158,6 +1221,49 @@ Field::mutable_options() { ...@@ -1158,6 +1221,49 @@ Field::mutable_options() {
return &options_; return &options_;
} }
// optional string json_name = 10;
inline void Field::clear_json_name() {
json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline const ::std::string& Field::json_name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Field.json_name)
return json_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline void Field::set_json_name(const ::std::string& value) {
json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.Field.json_name)
}
inline void Field::set_json_name(const char* value) {
json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.Field.json_name)
}
inline void Field::set_json_name(const char* value, size_t size) {
json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.json_name)
}
inline ::std::string* Field::mutable_json_name() {
// @@protoc_insertion_point(field_mutable:google.protobuf.Field.json_name)
return json_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline ::std::string* Field::release_json_name() {
return json_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline void Field::set_allocated_json_name(::std::string* json_name) {
if (json_name != NULL) {
} else {
}
json_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), json_name);
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.json_name)
}
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Enum // Enum
...@@ -1302,6 +1408,20 @@ inline void Enum::set_allocated_source_context(::google::protobuf::SourceContext ...@@ -1302,6 +1408,20 @@ inline void Enum::set_allocated_source_context(::google::protobuf::SourceContext
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.source_context) // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.source_context)
} }
// optional .google.protobuf.Syntax syntax = 5;
inline void Enum::clear_syntax() {
syntax_ = 0;
}
inline ::google::protobuf::Syntax Enum::syntax() const {
// @@protoc_insertion_point(field_get:google.protobuf.Enum.syntax)
return static_cast< ::google::protobuf::Syntax >(syntax_);
}
inline void Enum::set_syntax(::google::protobuf::Syntax value) {
syntax_ = value;
// @@protoc_insertion_point(field_set:google.protobuf.Enum.syntax)
}
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// EnumValue // EnumValue
...@@ -1506,6 +1626,11 @@ template <> ...@@ -1506,6 +1626,11 @@ template <>
inline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::Field_Cardinality>() { inline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::Field_Cardinality>() {
return ::google::protobuf::Field_Cardinality_descriptor(); return ::google::protobuf::Field_Cardinality_descriptor();
} }
template <> struct is_proto_enum< ::google::protobuf::Syntax> : ::google::protobuf::internal::true_type {};
template <>
inline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::Syntax>() {
return ::google::protobuf::Syntax_descriptor();
}
} // namespace protobuf } // namespace protobuf
} // namespace google } // namespace google
......
...@@ -34,29 +34,26 @@ package google.protobuf; ...@@ -34,29 +34,26 @@ package google.protobuf;
import "google/protobuf/any.proto"; import "google/protobuf/any.proto";
import "google/protobuf/source_context.proto"; import "google/protobuf/source_context.proto";
option java_multiple_files = true;
option java_outer_classname = "TypeProto";
option java_package = "com.google.protobuf"; option java_package = "com.google.protobuf";
option java_outer_classname = "TypeProto";
option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB"; option objc_class_prefix = "GPB";
// A light-weight descriptor for a proto message type. // A light-weight descriptor for a proto message type.
message Type { message Type {
// The fully qualified message name. // The fully qualified message name.
string name = 1; string name = 1;
// The list of fields. // The list of fields.
repeated Field fields = 2; repeated Field fields = 2;
// The list of oneof definitions. // The list of oneof definitions.
// The list of oneofs declared in this Type repeated string oneofs = 3; // The list of oneofs declared in this Type
repeated string oneofs = 3;
// The proto options. // The proto options.
repeated Option options = 4; repeated Option options = 4;
// The source context. // The source context.
SourceContext source_context = 5; SourceContext source_context = 5;
// The source syntax.
Syntax syntax = 6;
} }
// Field represents a single field of a message type. // Field represents a single field of a message type.
...@@ -64,125 +61,99 @@ message Field { ...@@ -64,125 +61,99 @@ message Field {
// Kind represents a basic field type. // Kind represents a basic field type.
enum Kind { enum Kind {
// Field type unknown. // Field type unknown.
TYPE_UNKNOWN = 0; TYPE_UNKNOWN = 0;
// Field type double. // Field type double.
TYPE_DOUBLE = 1; TYPE_DOUBLE = 1;
// Field type float. // Field type float.
TYPE_FLOAT = 2; TYPE_FLOAT = 2;
// Field type int64. // Field type int64.
TYPE_INT64 = 3; TYPE_INT64 = 3;
// Field type uint64. // Field type uint64.
TYPE_UINT64 = 4; TYPE_UINT64 = 4;
// Field type int32. // Field type int32.
TYPE_INT32 = 5; TYPE_INT32 = 5;
// Field type fixed64. // Field type fixed64.
TYPE_FIXED64 = 6; TYPE_FIXED64 = 6;
// Field type fixed32. // Field type fixed32.
TYPE_FIXED32 = 7; TYPE_FIXED32 = 7;
// Field type bool. // Field type bool.
TYPE_BOOL = 8; TYPE_BOOL = 8;
// Field type string. // Field type string.
TYPE_STRING = 9; TYPE_STRING = 9;
// Field type group (deprecated proto2 type)
TYPE_GROUP = 10;
// Field type message. // Field type message.
TYPE_MESSAGE = 11; TYPE_MESSAGE = 11;
// Field type bytes. // Field type bytes.
TYPE_BYTES = 12; TYPE_BYTES = 12;
// Field type uint32. // Field type uint32.
TYPE_UINT32 = 13; TYPE_UINT32 = 13;
// Field type enum. // Field type enum.
TYPE_ENUM = 14; TYPE_ENUM = 14;
// Field type sfixed32. // Field type sfixed32.
TYPE_SFIXED32 = 15; TYPE_SFIXED32 = 15;
// Field type sfixed64. // Field type sfixed64.
TYPE_SFIXED64 = 16; TYPE_SFIXED64 = 16;
// Field type sint32. // Field type sint32.
TYPE_SINT32 = 17; TYPE_SINT32 = 17;
// Field type sint64. // Field type sint64.
TYPE_SINT64 = 18; TYPE_SINT64 = 18;
} };
// Cardinality represents whether a field is optional, required, or // Cardinality represents whether a field is optional, required, or
// repeated. // repeated.
enum Cardinality { enum Cardinality {
// The field cardinality is unknown. Typically an error condition. // The field cardinality is unknown. Typically an error condition.
CARDINALITY_UNKNOWN = 0; CARDINALITY_UNKNOWN = 0;
// For optional fields. // For optional fields.
CARDINALITY_OPTIONAL = 1; CARDINALITY_OPTIONAL = 1;
// For required fields. Not used for proto3. // For required fields. Not used for proto3.
CARDINALITY_REQUIRED = 2; CARDINALITY_REQUIRED = 2;
// For repeated fields. // For repeated fields.
CARDINALITY_REPEATED = 3; CARDINALITY_REPEATED = 3;
} };
// The field kind. // The field kind.
Kind kind = 1; Kind kind = 1;
// The field cardinality, i.e. optional/required/repeated. // The field cardinality, i.e. optional/required/repeated.
Cardinality cardinality = 2; Cardinality cardinality = 2;
// The proto field number. // The proto field number.
int32 number = 3; int32 number = 3;
// The field name. // The field name.
string name = 4; string name = 4;
// The type URL (without the scheme) when the type is MESSAGE or ENUM, // The type URL (without the scheme) when the type is MESSAGE or ENUM,
// such as `type.googleapis.com/google.protobuf.Empty`. // such as `type.googleapis.com/google.protobuf.Empty`.
string type_url = 6; string type_url = 6;
// Index in Type.oneofs. Starts at 1. Zero means no oneof mapping. // Index in Type.oneofs. Starts at 1. Zero means no oneof mapping.
int32 oneof_index = 7; int32 oneof_index = 7;
// Whether to use alternative packed wire representation. // Whether to use alternative packed wire representation.
bool packed = 8; bool packed = 8;
// The proto options. // The proto options.
repeated Option options = 9; repeated Option options = 9;
// The JSON name for this field.
string json_name = 10;
} }
// Enum type definition. // Enum type definition.
message Enum { message Enum {
// Enum type name. // Enum type name.
string name = 1; string name = 1;
// Enum value definitions. // Enum value definitions.
repeated EnumValue enumvalue = 2; repeated EnumValue enumvalue = 2;
// Proto options for the enum type. // Proto options for the enum type.
repeated Option options = 3; repeated Option options = 3;
// The source context. // The source context.
SourceContext source_context = 4; SourceContext source_context = 4;
// The source syntax.
Syntax syntax = 5;
} }
// Enum value definition. // Enum value definition.
message EnumValue { message EnumValue {
// Enum value name. // Enum value name.
string name = 1; string name = 1;
// Enum value number. // Enum value number.
int32 number = 2; int32 number = 2;
// Proto options for the enum value. // Proto options for the enum value.
repeated Option options = 3; repeated Option options = 3;
} }
...@@ -191,7 +162,14 @@ message EnumValue { ...@@ -191,7 +162,14 @@ message EnumValue {
message Option { message Option {
// Proto option name. // Proto option name.
string name = 1; string name = 1;
// Proto option value. // Proto option value.
Any value = 2; Any value = 2;
} }
// Syntax specifies the syntax in which a service element was defined.
enum Syntax {
// Syntax "proto2"
SYNTAX_PROTO2 = 0;
// Syntax "proto3"
SYNTAX_PROTO3 = 1;
}
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Author: kenton@google.com (Kenton Varda)
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
//
// This file contains messages for testing message_set_wire_format.
syntax = "proto2";
package proto2_wireformat_unittest;
option cc_enable_arenas = true;
option optimize_for = SPEED;
option csharp_namespace = "Google.ProtocolBuffers.TestProtos";
// A message with message_set_wire_format.
message TestMessageSet {
option message_set_wire_format = true;
extensions 4 to max;
}
message TestMessageSetWireFormatContainer {
optional TestMessageSet message_set = 1;
}
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
option optimize_for = LITE_RUNTIME;
// We don't put this in a package within proto2 because we need to make sure
// that the generated code doesn't depend on being in the proto2 namespace.
// In test_util.h we do "using namespace unittest = protobuf_unittest".
package protobuf_unittest_no_arena;
message ForeignMessageLite {
optional int32 c = 1;
}
This diff is collapsed.
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef GOOGLE_PROTOBUF_UTIL_FIELD_MASK_UTIL_H__
#define GOOGLE_PROTOBUF_UTIL_FIELD_MASK_UTIL_H__
#include <string>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/field_mask.pb.h>
namespace google {
namespace protobuf {
namespace util {
class LIBPROTOBUF_EXPORT FieldMaskUtil {
typedef google::protobuf::FieldMask FieldMask;
public:
// Converts FieldMask to/from string, formatted according to proto3 JSON
// spec for FieldMask (e.g., "foo,bar,baz.quz").
static string ToString(const FieldMask& mask);
static void FromString(const string& str, FieldMask* out);
// Checks whether the given path is valid for type T.
template <typename T>
static bool IsValidPath(const string& path) {
return InternalIsValidPath(T::descriptor(), path);
}
// Checks whether the given FieldMask is valid for type T.
template <typename T>
static bool IsValidFieldMask(const FieldMask& mask) {
for (int i = 0; i < mask.paths_size(); ++i) {
if (!InternalIsValidPath(T::descriptor(), mask.paths(i))) return false;
}
return true;
}
// Adds a path to FieldMask after checking whether the given path is valid.
// This method check-fails if the path is not a valid path for type T.
template <typename T>
static void AddPathToFieldMask(const string& path, FieldMask* mask) {
GOOGLE_CHECK(IsValidPath<T>(path));
mask->add_paths(path);
}
// Creates a FieldMask with all fields of type T. This FieldMask only
// contains fields of T but not any sub-message fields.
template <typename T>
static void GetFieldMaskForAllFields(FieldMask* out) {
InternalGetFieldMaskForAllFields(T::descriptor(), out);
}
// Converts a FieldMask to the canonical form. It will:
// 1. Remove paths that are covered by another path. For example,
// "foo.bar" is covered by "foo" and will be removed if "foo"
// is also in the FieldMask.
// 2. Sort all paths in alphabetical order.
static void ToCanonicalForm(const FieldMask& mask, FieldMask* out);
// Creates an union of two FieldMasks.
static void Union(const FieldMask& mask1, const FieldMask& mask2,
FieldMask* out);
// Creates an intersection of two FieldMasks.
static void Intersect(const FieldMask& mask1, const FieldMask& mask2,
FieldMask* out);
// Returns true if path is covered by the given FieldMask. Note that path
// "foo.bar" covers all paths like "foo.bar.baz", "foo.bar.quz.x", etc.
static bool IsPathInFieldMask(const string& path, const FieldMask& mask);
class MergeOptions;
// Merges fields specified in a FieldMask into another message.
static void MergeMessageTo(const Message& source, const FieldMask& mask,
const MergeOptions& options, Message* destination);
private:
static bool InternalIsValidPath(const Descriptor* descriptor,
const string& path);
static void InternalGetFieldMaskForAllFields(const Descriptor* descriptor,
FieldMask* out);
};
class LIBPROTOBUF_EXPORT FieldMaskUtil::MergeOptions {
public:
MergeOptions()
: replace_message_fields_(false), replace_repeated_fields_(false) {}
// When merging message fields, the default behavior is to merge the
// content of two message fields together. If you instead want to use
// the field from the source message to replace the corresponding field
// in the destination message, set this flag to true. When this flag is set,
// specified submessage fields that are missing in source will be cleared in
// destination.
void set_replace_message_fields(bool value) {
replace_message_fields_ = value;
}
bool replace_message_fields() const { return replace_message_fields_; }
// The default merging behavior will append entries from the source
// repeated field to the destination repeated field. If you only want
// to keep the entries from the source repeated field, set this flag
// to true.
void set_replace_repeated_fields(bool value) {
replace_repeated_fields_ = value;
}
bool replace_repeated_fields() const { return replace_repeated_fields_; }
private:
bool replace_message_fields_;
bool replace_repeated_fields_;
};
} // namespace util
} // namespace protobuf
} // namespace google
#endif // GOOGLE_PROTOBUF_UTIL_FIELD_MASK_UTIL_H__
This diff is collapsed.
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Proto to test oneofs.
syntax = "proto3";
import "google/protobuf/any.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
package google.protobuf.testing.oneofs;
option java_package = "com.google.protobuf.testing.oneofs";
message OneOfsRequest {
string value = 1;
oneof data {
string str_data = 2;
int32 int_data = 3;
// Simple message
Data message_data = 4;
// Well known types
google.protobuf.Struct struct_data = 5;
google.protobuf.Value value_data = 6;
google.protobuf.ListValue list_value_data = 7;
google.protobuf.Timestamp ts_data = 8;
}
google.protobuf.Any any_data = 19;
}
message Data {
int32 data_value = 1;
}
message Response {
string value = 1;
}
service TestService {
// Test call.
rpc Call(OneOfsRequest) returns (Response);
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -262,9 +262,9 @@ void protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto() { ...@@ -262,9 +262,9 @@ void protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto() {
"e\030\001 \001(\004\"\033\n\nInt32Value\022\r\n\005value\030\001 \001(\005\"\034\n\013" "e\030\001 \001(\004\"\033\n\nInt32Value\022\r\n\005value\030\001 \001(\005\"\034\n\013"
"UInt32Value\022\r\n\005value\030\001 \001(\r\"\032\n\tBoolValue\022" "UInt32Value\022\r\n\005value\030\001 \001(\r\"\032\n\tBoolValue\022"
"\r\n\005value\030\001 \001(\010\"\034\n\013StringValue\022\r\n\005value\030\001" "\r\n\005value\030\001 \001(\010\"\034\n\013StringValue\022\r\n\005value\030\001"
" \001(\t\"\033\n\nBytesValue\022\r\n\005value\030\001 \001(\014BE\n\023com" " \001(\t\"\033\n\nBytesValue\022\r\n\005value\030\001 \001(\014BH\n\023com"
".google.protobufB\rWrappersProtoP\001\242\002\003GPB\252" ".google.protobufB\rWrappersProtoP\001\240\001\001\242\002\003G"
"\002\026Google.ProtocolBuffersb\006proto3", 392); "PB\252\002\026Google.ProtocolBuffersb\006proto3", 395);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"google/protobuf/wrappers.proto", &protobuf_RegisterTypes); "google/protobuf/wrappers.proto", &protobuf_RegisterTypes);
DoubleValue::default_instance_ = new DoubleValue(); DoubleValue::default_instance_ = new DoubleValue();
......
This diff is collapsed.
...@@ -133,11 +133,6 @@ done ...@@ -133,11 +133,6 @@ done
# Update bazel BUILD files. # Update bazel BUILD files.
################################################################################ ################################################################################
BAZEL_BUILD=./BUILD
[ -f "$BAZEL_BUILD" ] || {
echo "Cannot find: $BAZEL_BUILD"
exit 1
}
set_bazel_value() { set_bazel_value() {
local FILENAME=$1 local FILENAME=$1
local VARNAME=$2 local VARNAME=$2
...@@ -169,14 +164,19 @@ set_bazel_value() { ...@@ -169,14 +164,19 @@ set_bazel_value() {
} }
BAZEL_BUILD=./BUILD
BAZEL_PREFIX="src/" BAZEL_PREFIX="src/"
set_bazel_value $BAZEL_BUILD protobuf_lite_srcs $BAZEL_PREFIX $LIBPROTOBUF_LITE_SOURCES if [ -f "$BAZEL_BUILD" ]; then
set_bazel_value $BAZEL_BUILD protobuf_srcs $BAZEL_PREFIX $LIBPROTOBUF_SOURCES set_bazel_value $BAZEL_BUILD protobuf_lite_srcs $BAZEL_PREFIX $LIBPROTOBUF_LITE_SOURCES
set_bazel_value $BAZEL_BUILD protoc_lib_srcs $BAZEL_PREFIX $LIBPROTOC_SOURCES set_bazel_value $BAZEL_BUILD protobuf_srcs $BAZEL_PREFIX $LIBPROTOBUF_SOURCES
set_bazel_value $BAZEL_BUILD lite_test_protos "" $LITE_PROTOS set_bazel_value $BAZEL_BUILD protoc_lib_srcs $BAZEL_PREFIX $LIBPROTOC_SOURCES
set_bazel_value $BAZEL_BUILD well_known_protos "" $WKT_PROTOS set_bazel_value $BAZEL_BUILD lite_test_protos "" $LITE_PROTOS
set_bazel_value $BAZEL_BUILD test_protos "" $PROTOS set_bazel_value $BAZEL_BUILD well_known_protos "" $WKT_PROTOS
set_bazel_value $BAZEL_BUILD common_test_srcs $BAZEL_PREFIX $COMMON_TEST_SOURCES set_bazel_value $BAZEL_BUILD test_protos "" $PROTOS
set_bazel_value $BAZEL_BUILD test_srcs $BAZEL_PREFIX $TEST_SOURCES set_bazel_value $BAZEL_BUILD common_test_srcs $BAZEL_PREFIX $COMMON_TEST_SOURCES
set_bazel_value $BAZEL_BUILD test_plugin_srcs $BAZEL_PREFIX $TEST_PLUGIN_SOURCES set_bazel_value $BAZEL_BUILD test_srcs $BAZEL_PREFIX $TEST_SOURCES
set_bazel_value $BAZEL_BUILD test_plugin_srcs $BAZEL_PREFIX $TEST_PLUGIN_SOURCES
else
echo "Skipped BUILD file update."
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment