Updated protobuf library.
Change-Id: I09705df523ba4d0954925845a1619b25d70fd90f
This commit is contained in:
parent
16d8583735
commit
1fbc410489
|
@ -0,0 +1,117 @@
|
|||
# autogen.sh-generated files
|
||||
Makefile.in
|
||||
src/Makefile.in
|
||||
config.guess
|
||||
config.h.in
|
||||
config.sub
|
||||
configure
|
||||
depcomp
|
||||
install-sh
|
||||
ltmain.sh
|
||||
missing
|
||||
|
||||
aclocal.m4
|
||||
m4/libtool.m4
|
||||
m4/ltoptions.m4
|
||||
m4/ltsugar.m4
|
||||
m4/ltversion.m4
|
||||
m4/lt~obsolete.m4
|
||||
autom4te.cache
|
||||
|
||||
# downloaded files
|
||||
gmock
|
||||
|
||||
# in-tree configure-generated files
|
||||
Makefile
|
||||
src/Makefile
|
||||
/config.h
|
||||
config.log
|
||||
config.status
|
||||
|
||||
libtool
|
||||
protobuf-lite.pc
|
||||
protobuf.pc
|
||||
.deps
|
||||
stamp-h1
|
||||
|
||||
# in-tree build products
|
||||
*.o
|
||||
*.lo
|
||||
*.la
|
||||
src/.libs
|
||||
*.so
|
||||
|
||||
.dirstamp
|
||||
|
||||
any_test.pb.*
|
||||
map*unittest.pb.*
|
||||
unittest*.pb.*
|
||||
cpp_test*.pb.*
|
||||
src/google/protobuf/util/**/*.pb.cc
|
||||
src/google/protobuf/util/**/*.pb.h
|
||||
|
||||
*.pyc
|
||||
*.egg-info
|
||||
*_pb2.py
|
||||
python/*.egg
|
||||
python/.eggs/
|
||||
python/.tox
|
||||
python/build/
|
||||
python/google/protobuf/compiler/
|
||||
python/google/protobuf/util/
|
||||
|
||||
src/protoc
|
||||
src/unittest_proto_middleman
|
||||
|
||||
# Generated test scaffolding
|
||||
src/protobuf*-test
|
||||
src/test_plugin
|
||||
src/testzip.*
|
||||
src/zcg*zip
|
||||
ar-lib
|
||||
|
||||
test-driver
|
||||
compile
|
||||
|
||||
src/**/*.log
|
||||
src/**/*.trs
|
||||
|
||||
# JavaBuild output.
|
||||
java/target
|
||||
javanano/target
|
||||
|
||||
# Windows native output.
|
||||
cmake/build
|
||||
build_msvc
|
||||
|
||||
# NuGet packages: we want the repository configuration, but not the
|
||||
# packages themselves.
|
||||
/csharp/src/packages/*/
|
||||
|
||||
# Directories created by opening the Objective C Xcode projects.
|
||||
objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/xcuserdata/
|
||||
objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/xcshareddata/ProtocolBuffers_OSX.xccheckout
|
||||
objectivec/ProtocolBuffers_OSX.xcodeproj/xcuserdata/
|
||||
objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcuserdata/
|
||||
objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcshareddata/ProtocolBuffers_iOS.xccheckout
|
||||
objectivec/ProtocolBuffers_iOS.xcodeproj/xcuserdata/
|
||||
# OS X's Finder creates these for state about opened windows/etc.
|
||||
**/.DS_Store
|
||||
|
||||
# Comformance test output
|
||||
conformance/.libs/
|
||||
conformance/com/
|
||||
conformance/conformance-cpp
|
||||
conformance/conformance-csharp
|
||||
conformance/conformance-java
|
||||
conformance/conformance-objc
|
||||
conformance/conformance-test-runner
|
||||
conformance/conformance.pb.cc
|
||||
conformance/conformance.pb.h
|
||||
conformance/Conformance.pbobjc.h
|
||||
conformance/Conformance.pbobjc.m
|
||||
conformance/conformance.rb
|
||||
conformance/google/
|
||||
conformance/javac_middleman
|
||||
conformance/lite/
|
||||
conformance/protoc_middleman
|
|
@ -0,0 +1,84 @@
|
|||
sudo: required
|
||||
# Note: travis currently does not support listing more than one language so
|
||||
# this cheats and claims to only be cpp. If they add multiple language
|
||||
# support, this should probably get updated to install steps and/or
|
||||
# rvm/gemfile/jdk/etc. entries rather than manually doing the work.
|
||||
language: cpp
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
# The Objective C build needs Xcode 7.0 or later.
|
||||
osx_image: xcode7.2
|
||||
script:
|
||||
- ./tests.sh $CONFIG
|
||||
env:
|
||||
- CONFIG=cpp
|
||||
- CONFIG=cpp_distcheck
|
||||
- CONFIG=csharp
|
||||
- CONFIG=golang
|
||||
- CONFIG=java_jdk6
|
||||
- CONFIG=java_jdk7
|
||||
- CONFIG=java_oracle7
|
||||
- CONFIG=javanano_jdk6
|
||||
- CONFIG=javanano_jdk7
|
||||
- CONFIG=javanano_oracle7
|
||||
- CONFIG=javascript
|
||||
- CONFIG=python
|
||||
- CONFIG=python_cpp
|
||||
- CONFIG=ruby19
|
||||
- CONFIG=ruby20
|
||||
- CONFIG=ruby21
|
||||
- CONFIG=ruby22
|
||||
- CONFIG=jruby
|
||||
matrix:
|
||||
exclude:
|
||||
# It's nontrivial to programmatically install a new JDK from the command
|
||||
# line on OS X, so we rely on testing on Linux for Java code.
|
||||
- os: osx
|
||||
env: CONFIG=java_jdk6
|
||||
- os: osx
|
||||
env: CONFIG=java_jdk7
|
||||
- os: osx
|
||||
env: CONFIG=java_oracle7
|
||||
- os: osx
|
||||
env: CONFIG=javanano_jdk6
|
||||
- os: osx
|
||||
env: CONFIG=javanano_jdk7
|
||||
- os: osx
|
||||
env: CONFIG=javanano_oracle7
|
||||
# Requires installing mono, currently travis.sh is doing that with apt-get
|
||||
# which doesn't work on OS X.
|
||||
- os: osx
|
||||
env: CONFIG=csharp
|
||||
# Requires installing golang, currently travis.sh is doing that with apt-get
|
||||
# which doesn't work on OS X.
|
||||
- os: osx
|
||||
env: CONFIG=golang
|
||||
# Add into the matrix OS X tests of Objective C (needs Xcode, so it won't
|
||||
# work on other platforms). These are split so it doesn't take as long to run.
|
||||
include:
|
||||
- os: osx
|
||||
env: CONFIG=objectivec_ios
|
||||
- os: osx
|
||||
env: CONFIG=objectivec_osx
|
||||
allow_failures:
|
||||
# These currently do not work on OS X but are being worked on by @haberman.
|
||||
- os: osx
|
||||
env: CONFIG=ruby22
|
||||
- os: osx
|
||||
env: CONFIG=jruby
|
||||
# https://github.com/google/protobuf/issues/1253 - Started failing when
|
||||
# we moved to an OS X image that is 10.11.
|
||||
- os: osx
|
||||
env: CONFIG=python_cpp
|
||||
# xctool 0.2.8 seems to have a bug where it randomly kills tests saying
|
||||
# they failed.
|
||||
# https://github.com/facebook/xctool/issues/619
|
||||
# https://github.com/google/protobuf/issues/1232
|
||||
# travis updated their images to include 0.2.8:
|
||||
# https://blog.travis-ci.com/2016-03-23-xcode-image-updates
|
||||
# Mark the iOS test as flakey so these failures don't turn things red.
|
||||
- os: osx
|
||||
env: CONFIG=objectivec_ios
|
||||
notifications:
|
||||
email: false
|
|
@ -0,0 +1,709 @@
|
|||
# Bazel (http://bazel.io/) BUILD file for Protobuf.
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
################################################################################
|
||||
# Protobuf Runtime Library
|
||||
################################################################################
|
||||
|
||||
COPTS = [
|
||||
"-DHAVE_PTHREAD",
|
||||
"-Wall",
|
||||
"-Wwrite-strings",
|
||||
"-Woverloaded-virtual",
|
||||
"-Wno-sign-compare",
|
||||
"-Wno-error=unused-function",
|
||||
]
|
||||
|
||||
config_setting(
|
||||
name = "android",
|
||||
values = {
|
||||
"crosstool_top": "//external:android/crosstool",
|
||||
},
|
||||
)
|
||||
|
||||
# Android builds do not need to link in a separate pthread library.
|
||||
LINK_OPTS = select({
|
||||
":android": [],
|
||||
"//conditions:default": ["-lpthread"],
|
||||
})
|
||||
|
||||
load(
|
||||
"protobuf",
|
||||
"cc_proto_library",
|
||||
"py_proto_library",
|
||||
"internal_gen_well_known_protos_java",
|
||||
"internal_protobuf_py_tests",
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "ios_armv7",
|
||||
values = {
|
||||
"ios_cpu": "armv7",
|
||||
},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "ios_armv7s",
|
||||
values = {
|
||||
"ios_cpu": "armv7s",
|
||||
},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "ios_arm64",
|
||||
values = {
|
||||
"ios_cpu": "arm64",
|
||||
},
|
||||
)
|
||||
|
||||
IOS_ARM_COPTS = COPTS + [
|
||||
"-DOS_IOS",
|
||||
"-miphoneos-version-min=7.0",
|
||||
"-arch armv7",
|
||||
"-arch armv7s",
|
||||
"-arch arm64",
|
||||
"-D__thread=",
|
||||
"-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/",
|
||||
]
|
||||
|
||||
cc_library(
|
||||
name = "protobuf_lite",
|
||||
srcs = [
|
||||
# AUTOGEN(protobuf_lite_srcs)
|
||||
"src/google/protobuf/arena.cc",
|
||||
"src/google/protobuf/arenastring.cc",
|
||||
"src/google/protobuf/extension_set.cc",
|
||||
"src/google/protobuf/generated_message_util.cc",
|
||||
"src/google/protobuf/io/coded_stream.cc",
|
||||
"src/google/protobuf/io/zero_copy_stream.cc",
|
||||
"src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
|
||||
"src/google/protobuf/message_lite.cc",
|
||||
"src/google/protobuf/repeated_field.cc",
|
||||
"src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
|
||||
"src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
|
||||
"src/google/protobuf/stubs/bytestream.cc",
|
||||
"src/google/protobuf/stubs/common.cc",
|
||||
"src/google/protobuf/stubs/int128.cc",
|
||||
"src/google/protobuf/stubs/once.cc",
|
||||
"src/google/protobuf/stubs/status.cc",
|
||||
"src/google/protobuf/stubs/statusor.cc",
|
||||
"src/google/protobuf/stubs/stringpiece.cc",
|
||||
"src/google/protobuf/stubs/stringprintf.cc",
|
||||
"src/google/protobuf/stubs/structurally_valid.cc",
|
||||
"src/google/protobuf/stubs/strutil.cc",
|
||||
"src/google/protobuf/stubs/time.cc",
|
||||
"src/google/protobuf/wire_format_lite.cc",
|
||||
],
|
||||
hdrs = glob(["src/google/protobuf/**/*.h"]),
|
||||
copts = select({
|
||||
":ios_armv7": IOS_ARM_COPTS,
|
||||
":ios_armv7s": IOS_ARM_COPTS,
|
||||
":ios_arm64": IOS_ARM_COPTS,
|
||||
"//conditions:default": COPTS,
|
||||
}),
|
||||
includes = ["src/"],
|
||||
linkopts = LINK_OPTS,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "protobuf",
|
||||
srcs = [
|
||||
# AUTOGEN(protobuf_srcs)
|
||||
"src/google/protobuf/any.cc",
|
||||
"src/google/protobuf/any.pb.cc",
|
||||
"src/google/protobuf/api.pb.cc",
|
||||
"src/google/protobuf/compiler/importer.cc",
|
||||
"src/google/protobuf/compiler/parser.cc",
|
||||
"src/google/protobuf/descriptor.cc",
|
||||
"src/google/protobuf/descriptor.pb.cc",
|
||||
"src/google/protobuf/descriptor_database.cc",
|
||||
"src/google/protobuf/duration.pb.cc",
|
||||
"src/google/protobuf/dynamic_message.cc",
|
||||
"src/google/protobuf/empty.pb.cc",
|
||||
"src/google/protobuf/extension_set_heavy.cc",
|
||||
"src/google/protobuf/field_mask.pb.cc",
|
||||
"src/google/protobuf/generated_message_reflection.cc",
|
||||
"src/google/protobuf/io/gzip_stream.cc",
|
||||
"src/google/protobuf/io/printer.cc",
|
||||
"src/google/protobuf/io/strtod.cc",
|
||||
"src/google/protobuf/io/tokenizer.cc",
|
||||
"src/google/protobuf/io/zero_copy_stream_impl.cc",
|
||||
"src/google/protobuf/map_field.cc",
|
||||
"src/google/protobuf/message.cc",
|
||||
"src/google/protobuf/reflection_ops.cc",
|
||||
"src/google/protobuf/service.cc",
|
||||
"src/google/protobuf/source_context.pb.cc",
|
||||
"src/google/protobuf/struct.pb.cc",
|
||||
"src/google/protobuf/stubs/mathlimits.cc",
|
||||
"src/google/protobuf/stubs/substitute.cc",
|
||||
"src/google/protobuf/text_format.cc",
|
||||
"src/google/protobuf/timestamp.pb.cc",
|
||||
"src/google/protobuf/type.pb.cc",
|
||||
"src/google/protobuf/unknown_field_set.cc",
|
||||
"src/google/protobuf/util/field_comparator.cc",
|
||||
"src/google/protobuf/util/field_mask_util.cc",
|
||||
"src/google/protobuf/util/internal/datapiece.cc",
|
||||
"src/google/protobuf/util/internal/default_value_objectwriter.cc",
|
||||
"src/google/protobuf/util/internal/error_listener.cc",
|
||||
"src/google/protobuf/util/internal/field_mask_utility.cc",
|
||||
"src/google/protobuf/util/internal/json_escaping.cc",
|
||||
"src/google/protobuf/util/internal/json_objectwriter.cc",
|
||||
"src/google/protobuf/util/internal/json_stream_parser.cc",
|
||||
"src/google/protobuf/util/internal/object_writer.cc",
|
||||
"src/google/protobuf/util/internal/proto_writer.cc",
|
||||
"src/google/protobuf/util/internal/protostream_objectsource.cc",
|
||||
"src/google/protobuf/util/internal/protostream_objectwriter.cc",
|
||||
"src/google/protobuf/util/internal/type_info.cc",
|
||||
"src/google/protobuf/util/internal/type_info_test_helper.cc",
|
||||
"src/google/protobuf/util/internal/utility.cc",
|
||||
"src/google/protobuf/util/json_util.cc",
|
||||
"src/google/protobuf/util/message_differencer.cc",
|
||||
"src/google/protobuf/util/time_util.cc",
|
||||
"src/google/protobuf/util/type_resolver_util.cc",
|
||||
"src/google/protobuf/wire_format.cc",
|
||||
"src/google/protobuf/wrappers.pb.cc",
|
||||
],
|
||||
hdrs = glob(["src/**/*.h"]),
|
||||
copts = select({
|
||||
":ios_armv7": IOS_ARM_COPTS,
|
||||
":ios_armv7s": IOS_ARM_COPTS,
|
||||
":ios_arm64": IOS_ARM_COPTS,
|
||||
"//conditions:default": COPTS,
|
||||
}),
|
||||
includes = ["src/"],
|
||||
linkopts = LINK_OPTS,
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [":protobuf_lite"],
|
||||
)
|
||||
|
||||
objc_library(
|
||||
name = "protobuf_objc",
|
||||
hdrs = ["objectivec/GPBProtocolBuffers.h"],
|
||||
includes = ["objectivec"],
|
||||
non_arc_srcs = ["objectivec/GPBProtocolBuffers.m"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
RELATIVE_WELL_KNOWN_PROTOS = [
|
||||
# AUTOGEN(well_known_protos)
|
||||
"google/protobuf/any.proto",
|
||||
"google/protobuf/api.proto",
|
||||
"google/protobuf/compiler/plugin.proto",
|
||||
"google/protobuf/descriptor.proto",
|
||||
"google/protobuf/duration.proto",
|
||||
"google/protobuf/empty.proto",
|
||||
"google/protobuf/field_mask.proto",
|
||||
"google/protobuf/source_context.proto",
|
||||
"google/protobuf/struct.proto",
|
||||
"google/protobuf/timestamp.proto",
|
||||
"google/protobuf/type.proto",
|
||||
"google/protobuf/wrappers.proto",
|
||||
]
|
||||
|
||||
WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
|
||||
|
||||
filegroup(
|
||||
name = "well_known_protos",
|
||||
srcs = WELL_KNOWN_PROTOS,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
cc_proto_library(
|
||||
name = "cc_wkt_protos",
|
||||
srcs = WELL_KNOWN_PROTOS,
|
||||
include = "src",
|
||||
default_runtime = ":protobuf",
|
||||
internal_bootstrap_hack = 1,
|
||||
protoc = ":protoc",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
################################################################################
|
||||
# Protocol Buffers Compiler
|
||||
################################################################################
|
||||
|
||||
cc_library(
|
||||
name = "protoc_lib",
|
||||
srcs = [
|
||||
# AUTOGEN(protoc_lib_srcs)
|
||||
"src/google/protobuf/compiler/code_generator.cc",
|
||||
"src/google/protobuf/compiler/command_line_interface.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_enum.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_extension.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_field.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_file.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_generator.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_helpers.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_map_field.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_message.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_message_field.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_service.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_string_field.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_enum.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_field_base.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_generator.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_helpers.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_map_field.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_message.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_message_field.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
|
||||
"src/google/protobuf/compiler/java/java_context.cc",
|
||||
"src/google/protobuf/compiler/java/java_doc_comment.cc",
|
||||
"src/google/protobuf/compiler/java/java_enum.cc",
|
||||
"src/google/protobuf/compiler/java/java_enum_field.cc",
|
||||
"src/google/protobuf/compiler/java/java_enum_field_lite.cc",
|
||||
"src/google/protobuf/compiler/java/java_enum_lite.cc",
|
||||
"src/google/protobuf/compiler/java/java_extension.cc",
|
||||
"src/google/protobuf/compiler/java/java_extension_lite.cc",
|
||||
"src/google/protobuf/compiler/java/java_field.cc",
|
||||
"src/google/protobuf/compiler/java/java_file.cc",
|
||||
"src/google/protobuf/compiler/java/java_generator.cc",
|
||||
"src/google/protobuf/compiler/java/java_generator_factory.cc",
|
||||
"src/google/protobuf/compiler/java/java_helpers.cc",
|
||||
"src/google/protobuf/compiler/java/java_lazy_message_field.cc",
|
||||
"src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
|
||||
"src/google/protobuf/compiler/java/java_map_field.cc",
|
||||
"src/google/protobuf/compiler/java/java_map_field_lite.cc",
|
||||
"src/google/protobuf/compiler/java/java_message.cc",
|
||||
"src/google/protobuf/compiler/java/java_message_builder.cc",
|
||||
"src/google/protobuf/compiler/java/java_message_builder_lite.cc",
|
||||
"src/google/protobuf/compiler/java/java_message_field.cc",
|
||||
"src/google/protobuf/compiler/java/java_message_field_lite.cc",
|
||||
"src/google/protobuf/compiler/java/java_message_lite.cc",
|
||||
"src/google/protobuf/compiler/java/java_name_resolver.cc",
|
||||
"src/google/protobuf/compiler/java/java_primitive_field.cc",
|
||||
"src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
|
||||
"src/google/protobuf/compiler/java/java_service.cc",
|
||||
"src/google/protobuf/compiler/java/java_shared_code_generator.cc",
|
||||
"src/google/protobuf/compiler/java/java_string_field.cc",
|
||||
"src/google/protobuf/compiler/java/java_string_field_lite.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_enum.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_enum_field.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_extension.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_field.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_file.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_generator.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_helpers.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_map_field.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_message.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_message_field.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
|
||||
"src/google/protobuf/compiler/js/js_generator.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_field.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_file.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_message.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
|
||||
"src/google/protobuf/compiler/plugin.cc",
|
||||
"src/google/protobuf/compiler/plugin.pb.cc",
|
||||
"src/google/protobuf/compiler/python/python_generator.cc",
|
||||
"src/google/protobuf/compiler/ruby/ruby_generator.cc",
|
||||
"src/google/protobuf/compiler/subprocess.cc",
|
||||
"src/google/protobuf/compiler/zip_writer.cc",
|
||||
],
|
||||
copts = COPTS,
|
||||
includes = ["src/"],
|
||||
linkopts = LINK_OPTS,
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [":protobuf"],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "protoc",
|
||||
srcs = ["src/google/protobuf/compiler/main.cc"],
|
||||
linkopts = LINK_OPTS,
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [":protoc_lib"],
|
||||
)
|
||||
|
||||
################################################################################
|
||||
# Tests
|
||||
################################################################################
|
||||
|
||||
RELATIVE_LITE_TEST_PROTOS = [
|
||||
# AUTOGEN(lite_test_protos)
|
||||
"google/protobuf/map_lite_unittest.proto",
|
||||
"google/protobuf/unittest_import_lite.proto",
|
||||
"google/protobuf/unittest_import_public_lite.proto",
|
||||
"google/protobuf/unittest_lite.proto",
|
||||
"google/protobuf/unittest_no_arena_lite.proto",
|
||||
]
|
||||
|
||||
LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS]
|
||||
|
||||
RELATIVE_TEST_PROTOS = [
|
||||
# AUTOGEN(test_protos)
|
||||
"google/protobuf/any_test.proto",
|
||||
"google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto",
|
||||
"google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto",
|
||||
"google/protobuf/map_proto2_unittest.proto",
|
||||
"google/protobuf/map_unittest.proto",
|
||||
"google/protobuf/unittest.proto",
|
||||
"google/protobuf/unittest_arena.proto",
|
||||
"google/protobuf/unittest_custom_options.proto",
|
||||
"google/protobuf/unittest_drop_unknown_fields.proto",
|
||||
"google/protobuf/unittest_embed_optimize_for.proto",
|
||||
"google/protobuf/unittest_empty.proto",
|
||||
"google/protobuf/unittest_enormous_descriptor.proto",
|
||||
"google/protobuf/unittest_import.proto",
|
||||
"google/protobuf/unittest_import_public.proto",
|
||||
"google/protobuf/unittest_lite_imports_nonlite.proto",
|
||||
"google/protobuf/unittest_mset.proto",
|
||||
"google/protobuf/unittest_mset_wire_format.proto",
|
||||
"google/protobuf/unittest_no_arena.proto",
|
||||
"google/protobuf/unittest_no_arena_import.proto",
|
||||
"google/protobuf/unittest_no_field_presence.proto",
|
||||
"google/protobuf/unittest_no_generic_services.proto",
|
||||
"google/protobuf/unittest_optimize_for.proto",
|
||||
"google/protobuf/unittest_preserve_unknown_enum.proto",
|
||||
"google/protobuf/unittest_preserve_unknown_enum2.proto",
|
||||
"google/protobuf/unittest_proto3_arena.proto",
|
||||
"google/protobuf/unittest_proto3_arena_lite.proto",
|
||||
"google/protobuf/unittest_proto3_lite.proto",
|
||||
"google/protobuf/unittest_well_known_types.proto",
|
||||
"google/protobuf/util/internal/testdata/anys.proto",
|
||||
"google/protobuf/util/internal/testdata/books.proto",
|
||||
"google/protobuf/util/internal/testdata/default_value.proto",
|
||||
"google/protobuf/util/internal/testdata/default_value_test.proto",
|
||||
"google/protobuf/util/internal/testdata/field_mask.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/timestamp_duration.proto",
|
||||
"google/protobuf/util/json_format_proto3.proto",
|
||||
"google/protobuf/util/message_differencer_unittest.proto",
|
||||
]
|
||||
|
||||
TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS]
|
||||
|
||||
cc_proto_library(
|
||||
name = "cc_test_protos",
|
||||
srcs = LITE_TEST_PROTOS + TEST_PROTOS,
|
||||
include = "src",
|
||||
default_runtime = ":protobuf",
|
||||
protoc = ":protoc",
|
||||
deps = [":cc_wkt_protos"],
|
||||
)
|
||||
|
||||
COMMON_TEST_SRCS = [
|
||||
# AUTOGEN(common_test_srcs)
|
||||
"src/google/protobuf/arena_test_util.cc",
|
||||
"src/google/protobuf/map_test_util.cc",
|
||||
"src/google/protobuf/test_util.cc",
|
||||
"src/google/protobuf/testing/file.cc",
|
||||
"src/google/protobuf/testing/googletest.cc",
|
||||
]
|
||||
|
||||
cc_binary(
|
||||
name = "test_plugin",
|
||||
srcs = [
|
||||
# AUTOGEN(test_plugin_srcs)
|
||||
"src/google/protobuf/compiler/mock_code_generator.cc",
|
||||
"src/google/protobuf/compiler/test_plugin.cc",
|
||||
"src/google/protobuf/testing/file.cc",
|
||||
],
|
||||
deps = [
|
||||
":protobuf",
|
||||
":protoc_lib",
|
||||
"//external:gtest",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "protobuf_test",
|
||||
srcs = COMMON_TEST_SRCS + [
|
||||
# AUTOGEN(test_srcs)
|
||||
"src/google/protobuf/any_test.cc",
|
||||
"src/google/protobuf/arena_unittest.cc",
|
||||
"src/google/protobuf/arenastring_unittest.cc",
|
||||
"src/google/protobuf/compiler/command_line_interface_unittest.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_unittest.cc",
|
||||
"src/google/protobuf/compiler/cpp/metadata_test.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
|
||||
"src/google/protobuf/compiler/importer_unittest.cc",
|
||||
"src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
|
||||
"src/google/protobuf/compiler/java/java_plugin_unittest.cc",
|
||||
"src/google/protobuf/compiler/mock_code_generator.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
|
||||
"src/google/protobuf/compiler/parser_unittest.cc",
|
||||
"src/google/protobuf/compiler/python/python_plugin_unittest.cc",
|
||||
"src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
|
||||
"src/google/protobuf/descriptor_database_unittest.cc",
|
||||
"src/google/protobuf/descriptor_unittest.cc",
|
||||
"src/google/protobuf/drop_unknown_fields_test.cc",
|
||||
"src/google/protobuf/dynamic_message_unittest.cc",
|
||||
"src/google/protobuf/extension_set_unittest.cc",
|
||||
"src/google/protobuf/generated_message_reflection_unittest.cc",
|
||||
"src/google/protobuf/io/coded_stream_unittest.cc",
|
||||
"src/google/protobuf/io/printer_unittest.cc",
|
||||
"src/google/protobuf/io/tokenizer_unittest.cc",
|
||||
"src/google/protobuf/io/zero_copy_stream_unittest.cc",
|
||||
"src/google/protobuf/map_field_test.cc",
|
||||
"src/google/protobuf/map_test.cc",
|
||||
"src/google/protobuf/message_unittest.cc",
|
||||
"src/google/protobuf/no_field_presence_test.cc",
|
||||
"src/google/protobuf/preserve_unknown_enum_test.cc",
|
||||
"src/google/protobuf/proto3_arena_lite_unittest.cc",
|
||||
"src/google/protobuf/proto3_arena_unittest.cc",
|
||||
"src/google/protobuf/proto3_lite_unittest.cc",
|
||||
"src/google/protobuf/reflection_ops_unittest.cc",
|
||||
"src/google/protobuf/repeated_field_reflection_unittest.cc",
|
||||
"src/google/protobuf/repeated_field_unittest.cc",
|
||||
"src/google/protobuf/stubs/bytestream_unittest.cc",
|
||||
"src/google/protobuf/stubs/common_unittest.cc",
|
||||
"src/google/protobuf/stubs/int128_unittest.cc",
|
||||
"src/google/protobuf/stubs/once_unittest.cc",
|
||||
"src/google/protobuf/stubs/status_test.cc",
|
||||
"src/google/protobuf/stubs/statusor_test.cc",
|
||||
"src/google/protobuf/stubs/stringpiece_unittest.cc",
|
||||
"src/google/protobuf/stubs/stringprintf_unittest.cc",
|
||||
"src/google/protobuf/stubs/structurally_valid_unittest.cc",
|
||||
"src/google/protobuf/stubs/strutil_unittest.cc",
|
||||
"src/google/protobuf/stubs/template_util_unittest.cc",
|
||||
"src/google/protobuf/stubs/time_test.cc",
|
||||
"src/google/protobuf/stubs/type_traits_unittest.cc",
|
||||
"src/google/protobuf/text_format_unittest.cc",
|
||||
"src/google/protobuf/unknown_field_set_unittest.cc",
|
||||
"src/google/protobuf/util/field_comparator_test.cc",
|
||||
"src/google/protobuf/util/field_mask_util_test.cc",
|
||||
"src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
|
||||
"src/google/protobuf/util/internal/json_objectwriter_test.cc",
|
||||
"src/google/protobuf/util/internal/json_stream_parser_test.cc",
|
||||
"src/google/protobuf/util/internal/protostream_objectsource_test.cc",
|
||||
"src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
|
||||
"src/google/protobuf/util/internal/type_info_test_helper.cc",
|
||||
"src/google/protobuf/util/json_util_test.cc",
|
||||
"src/google/protobuf/util/message_differencer_unittest.cc",
|
||||
"src/google/protobuf/util/time_util_test.cc",
|
||||
"src/google/protobuf/util/type_resolver_util_test.cc",
|
||||
"src/google/protobuf/well_known_types_unittest.cc",
|
||||
"src/google/protobuf/wire_format_unittest.cc",
|
||||
],
|
||||
copts = COPTS,
|
||||
data = [
|
||||
":test_plugin",
|
||||
] + glob([
|
||||
"src/google/protobuf/**/*",
|
||||
]),
|
||||
includes = [
|
||||
"src/",
|
||||
],
|
||||
linkopts = LINK_OPTS,
|
||||
deps = [
|
||||
":cc_test_protos",
|
||||
":protobuf",
|
||||
":protoc_lib",
|
||||
"//external:gtest_main",
|
||||
],
|
||||
)
|
||||
|
||||
################################################################################
|
||||
# Java support
|
||||
################################################################################
|
||||
internal_gen_well_known_protos_java(
|
||||
srcs = WELL_KNOWN_PROTOS,
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = "protobuf_java",
|
||||
srcs = glob([
|
||||
"java/core/src/main/java/com/google/protobuf/*.java",
|
||||
]) + [
|
||||
":gen_well_known_protos_java",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = "protobuf_java_util",
|
||||
srcs = glob([
|
||||
"java/util/src/main/java/com/google/protobuf/util/*.java",
|
||||
]),
|
||||
deps = [
|
||||
"protobuf_java",
|
||||
"//external:gson",
|
||||
"//external:guava",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
################################################################################
|
||||
# Python support
|
||||
################################################################################
|
||||
|
||||
py_library(
|
||||
name = "python_srcs",
|
||||
srcs = glob(
|
||||
[
|
||||
"python/google/protobuf/*.py",
|
||||
"python/google/protobuf/**/*.py",
|
||||
],
|
||||
exclude = [
|
||||
"python/google/protobuf/internal/*_test.py",
|
||||
"python/google/protobuf/internal/test_util.py",
|
||||
],
|
||||
),
|
||||
srcs_version = "PY2AND3",
|
||||
imports = ["python"],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "internal/_api_implementation.so",
|
||||
srcs = ["python/google/protobuf/internal/api_implementation.cc"],
|
||||
copts = COPTS + [
|
||||
"-DPYTHON_PROTO2_CPP_IMPL_V2",
|
||||
],
|
||||
linkshared = 1,
|
||||
linkstatic = 1,
|
||||
deps = select({
|
||||
"//conditions:default": [],
|
||||
":use_fast_cpp_protos": ["//external:python_headers"],
|
||||
}),
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "pyext/_message.so",
|
||||
srcs = glob([
|
||||
"python/google/protobuf/pyext/*.cc",
|
||||
"python/google/protobuf/pyext/*.h",
|
||||
]),
|
||||
copts = COPTS + [
|
||||
"-DGOOGLE_PROTOBUF_HAS_ONEOF=1",
|
||||
] + select({
|
||||
"//conditions:default": [],
|
||||
":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"],
|
||||
}),
|
||||
includes = [
|
||||
"python/",
|
||||
"src/",
|
||||
],
|
||||
linkshared = 1,
|
||||
linkstatic = 1,
|
||||
deps = [
|
||||
":protobuf",
|
||||
] + select({
|
||||
"//conditions:default": [],
|
||||
":use_fast_cpp_protos": ["//external:python_headers"],
|
||||
}),
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "use_fast_cpp_protos",
|
||||
values = {
|
||||
"define": "use_fast_cpp_protos=true",
|
||||
},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "allow_oversize_protos",
|
||||
values = {
|
||||
"define": "allow_oversize_protos=true",
|
||||
},
|
||||
)
|
||||
|
||||
py_proto_library(
|
||||
name = "protobuf_python",
|
||||
srcs = WELL_KNOWN_PROTOS,
|
||||
include = "src",
|
||||
data = select({
|
||||
"//conditions:default": [],
|
||||
":use_fast_cpp_protos": [
|
||||
":internal/_api_implementation.so",
|
||||
":pyext/_message.so",
|
||||
],
|
||||
}),
|
||||
default_runtime = "",
|
||||
protoc = ":protoc",
|
||||
py_libs = [
|
||||
":python_srcs",
|
||||
"//external:six"
|
||||
],
|
||||
srcs_version = "PY2AND3",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
py_proto_library(
|
||||
name = "python_common_test_protos",
|
||||
srcs = LITE_TEST_PROTOS + TEST_PROTOS,
|
||||
include = "src",
|
||||
default_runtime = "",
|
||||
protoc = ":protoc",
|
||||
srcs_version = "PY2AND3",
|
||||
deps = [":protobuf_python"],
|
||||
)
|
||||
|
||||
py_proto_library(
|
||||
name = "python_specific_test_protos",
|
||||
srcs = glob([
|
||||
"python/google/protobuf/internal/*.proto",
|
||||
"python/google/protobuf/internal/import_test_package/*.proto",
|
||||
]),
|
||||
include = "python",
|
||||
default_runtime = ":protobuf_python",
|
||||
protoc = ":protoc",
|
||||
srcs_version = "PY2AND3",
|
||||
deps = [":python_common_test_protos"],
|
||||
)
|
||||
|
||||
py_library(
|
||||
name = "python_tests",
|
||||
srcs = glob(
|
||||
[
|
||||
"python/google/protobuf/internal/*_test.py",
|
||||
"python/google/protobuf/internal/test_util.py",
|
||||
],
|
||||
),
|
||||
imports = ["python"],
|
||||
srcs_version = "PY2AND3",
|
||||
deps = [
|
||||
":protobuf_python",
|
||||
":python_common_test_protos",
|
||||
":python_specific_test_protos",
|
||||
],
|
||||
)
|
||||
|
||||
internal_protobuf_py_tests(
|
||||
name = "python_tests_batch",
|
||||
data = glob([
|
||||
"src/google/protobuf/**/*",
|
||||
]),
|
||||
modules = [
|
||||
"descriptor_database_test",
|
||||
"descriptor_pool_test",
|
||||
"descriptor_test",
|
||||
"generator_test",
|
||||
"json_format_test",
|
||||
"message_factory_test",
|
||||
"message_test",
|
||||
"proto_builder_test",
|
||||
"reflection_test",
|
||||
"service_reflection_test",
|
||||
"symbol_database_test",
|
||||
"text_encoding_test",
|
||||
"text_format_test",
|
||||
"unknown_fields_test",
|
||||
"wire_format_test",
|
||||
],
|
||||
deps = [":python_tests"],
|
||||
)
|
|
@ -2,38 +2,45 @@
|
|||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
if (is_win) {
|
||||
config_h_dir = "vsprojects"
|
||||
} else {
|
||||
config_h_dir = "."
|
||||
}
|
||||
|
||||
config("protobuf_config") {
|
||||
include_dirs = [
|
||||
"src",
|
||||
config_h_dir,
|
||||
]
|
||||
include_dirs = [ "src" ]
|
||||
defines = [
|
||||
"PROTOBUF_USE_DLLS",
|
||||
"GOOGLE_PROTOBUF_NO_RTTI",
|
||||
"GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
|
||||
]
|
||||
|
||||
if (is_win) {
|
||||
# TODO(jschuh): http://crbug.com/167187 size_t -> int.
|
||||
cflags = [ "/wd4267" ]
|
||||
if (!is_win) {
|
||||
defines += [ "HAVE_PTHREAD" ]
|
||||
}
|
||||
}
|
||||
|
||||
# This condif should be applied to targets using generated code from the proto
|
||||
config("protobuf_warnings") {
|
||||
cflags = []
|
||||
if (is_clang) {
|
||||
# protobuf-3 contains a few functions that are unused.
|
||||
cflags += [ "-Wno-unused-function" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (is_component_build) {
|
||||
config("protobuf_use_dlls") {
|
||||
defines = [ "PROTOBUF_USE_DLLS" ]
|
||||
}
|
||||
}
|
||||
|
||||
# This config should be applied to targets using generated code from the proto
|
||||
# compiler. It sets up the include directories properly.
|
||||
config("using_proto") {
|
||||
include_dirs = [
|
||||
"src",
|
||||
"$root_gen_dir/protoc_out",
|
||||
]
|
||||
}
|
||||
|
||||
protobuf_lite_sources = [
|
||||
"src/google/protobuf/arena.cc",
|
||||
"src/google/protobuf/arena.h",
|
||||
"src/google/protobuf/arenastring.cc",
|
||||
"src/google/protobuf/arenastring.h",
|
||||
"src/google/protobuf/extension_set.cc",
|
||||
"src/google/protobuf/extension_set.h",
|
||||
"src/google/protobuf/generated_message_util.cc",
|
||||
|
@ -45,146 +52,298 @@ protobuf_lite_sources = [
|
|||
"src/google/protobuf/io/zero_copy_stream.h",
|
||||
"src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
|
||||
"src/google/protobuf/io/zero_copy_stream_impl_lite.h",
|
||||
"src/google/protobuf/map.h",
|
||||
"src/google/protobuf/map_entry_lite.h",
|
||||
"src/google/protobuf/map_field_lite.h",
|
||||
"src/google/protobuf/map_type_handler.h",
|
||||
"src/google/protobuf/message_lite.cc",
|
||||
"src/google/protobuf/message_lite.h",
|
||||
"src/google/protobuf/repeated_field.cc",
|
||||
"src/google/protobuf/repeated_field.h",
|
||||
"src/google/protobuf/stubs/atomicops.h",
|
||||
"src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h",
|
||||
"src/google/protobuf/stubs/atomicops_internals_arm_gcc.h",
|
||||
"src/google/protobuf/stubs/atomicops_internals_arm_qnx.h",
|
||||
"src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h",
|
||||
"src/google/protobuf/stubs/atomicops_internals_generic_gcc.h",
|
||||
"src/google/protobuf/stubs/atomicops_internals_macosx.h",
|
||||
"src/google/protobuf/stubs/atomicops_internals_mips_gcc.h",
|
||||
"src/google/protobuf/stubs/atomicops_internals_pnacl.h",
|
||||
"src/google/protobuf/stubs/atomicops_internals_power.h",
|
||||
"src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h",
|
||||
"src/google/protobuf/stubs/atomicops_internals_solaris.h",
|
||||
"src/google/protobuf/stubs/atomicops_internals_tsan.h",
|
||||
"src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
|
||||
"src/google/protobuf/stubs/atomicops_internals_x86_gcc.h",
|
||||
"src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
|
||||
"src/google/protobuf/stubs/atomicops_internals_x86_msvc.h",
|
||||
"src/google/protobuf/stubs/atomic_sequence_num.h",
|
||||
"src/google/protobuf/stubs/bytestream.cc",
|
||||
"src/google/protobuf/stubs/bytestream.h",
|
||||
"src/google/protobuf/stubs/callback.h",
|
||||
"src/google/protobuf/stubs/casts.h",
|
||||
"src/google/protobuf/stubs/common.cc",
|
||||
"src/google/protobuf/stubs/common.h",
|
||||
"src/google/protobuf/stubs/fastmem.h",
|
||||
"src/google/protobuf/stubs/hash.h",
|
||||
"src/google/protobuf/stubs/map-util.h",
|
||||
"src/google/protobuf/stubs/int128.cc",
|
||||
"src/google/protobuf/stubs/int128.h",
|
||||
"src/google/protobuf/stubs/logging.h",
|
||||
"src/google/protobuf/stubs/macros.h",
|
||||
"src/google/protobuf/stubs/map_util.h",
|
||||
"src/google/protobuf/stubs/mutex.h",
|
||||
"src/google/protobuf/stubs/once.cc",
|
||||
"src/google/protobuf/stubs/once.h",
|
||||
"src/google/protobuf/stubs/platform_macros.h",
|
||||
"src/google/protobuf/unknown_field_set.cc",
|
||||
"src/google/protobuf/unknown_field_set.h",
|
||||
"src/google/protobuf/stubs/port.h",
|
||||
"src/google/protobuf/stubs/scoped_ptr.h",
|
||||
"src/google/protobuf/stubs/shared_ptr.h",
|
||||
"src/google/protobuf/stubs/status.cc",
|
||||
"src/google/protobuf/stubs/status.h",
|
||||
"src/google/protobuf/stubs/status_macros.h",
|
||||
"src/google/protobuf/stubs/statusor.cc",
|
||||
"src/google/protobuf/stubs/statusor.h",
|
||||
"src/google/protobuf/stubs/stl_util.h",
|
||||
"src/google/protobuf/stubs/stringpiece.cc",
|
||||
"src/google/protobuf/stubs/stringpiece.h",
|
||||
"src/google/protobuf/stubs/stringprintf.cc",
|
||||
"src/google/protobuf/stubs/stringprintf.h",
|
||||
"src/google/protobuf/stubs/structurally_valid.cc",
|
||||
"src/google/protobuf/stubs/strutil.cc",
|
||||
"src/google/protobuf/stubs/strutil.h",
|
||||
"src/google/protobuf/stubs/template_util.h",
|
||||
"src/google/protobuf/stubs/type_traits.h",
|
||||
"src/google/protobuf/stubs/time.cc",
|
||||
"src/google/protobuf/stubs/time.h",
|
||||
"src/google/protobuf/wire_format_lite.cc",
|
||||
"src/google/protobuf/wire_format_lite.h",
|
||||
"src/google/protobuf/wire_format_lite_inl.h",
|
||||
"$config_h_dir/config.h",
|
||||
]
|
||||
|
||||
protobuf_lite_cflags = []
|
||||
if (is_win) {
|
||||
protobuf_lite_cflags = [
|
||||
"/wd4018", # signed/unsigned mismatch in comparison
|
||||
"/wd4065", # switch statement contains 'default' but no 'case' labels
|
||||
"/wd4146", # unary minus operator applied to unsigned type
|
||||
"/wd4244", # implicit conversion, possible loss of data
|
||||
"/wd4355", # 'this' used in base member initializer list
|
||||
"/wd4267", # size_t to int truncation
|
||||
"/wd4291", # no matching operator delete for a placement new
|
||||
"/wd4291", # no matching operator delete for a placement new.
|
||||
"/wd4305", # double to float truncation
|
||||
"/wd4355", # 'this' used in base member initializer list
|
||||
"/wd4506", # no definition for inline function (protobuf issue #240)
|
||||
"/wd4715", # not all control paths return a value (fixed in trunk)
|
||||
]
|
||||
}
|
||||
|
||||
source_set("protobuf_lite") {
|
||||
component("protobuf_lite") {
|
||||
sources = protobuf_lite_sources
|
||||
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
configs += [
|
||||
"//build/config/compiler:no_chromium_code",
|
||||
|
||||
# Must be after no_chromium_code for warning flags to be ordered
|
||||
# correctly.
|
||||
":protobuf_warnings",
|
||||
]
|
||||
|
||||
if (is_win) {
|
||||
configs -= [ "//build/config/win:lean_and_mean" ]
|
||||
}
|
||||
direct_dependent_configs = [ ":protobuf_config" ]
|
||||
|
||||
public_configs = [
|
||||
":protobuf_config",
|
||||
|
||||
# TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
|
||||
"//build/config/compiler:no_size_t_to_int_warning",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//build/config/sanitizers:deps",
|
||||
]
|
||||
|
||||
cflags = protobuf_lite_cflags
|
||||
|
||||
# Required for component builds. See http://crbug.com/172800.
|
||||
if (is_component_build) {
|
||||
public_configs += [ ":protobuf_use_dlls" ]
|
||||
defines = [ "LIBPROTOBUF_EXPORTS" ]
|
||||
}
|
||||
}
|
||||
|
||||
# This is the full, heavy protobuf lib that's needed for c++ .protos that don't
|
||||
# specify the LITE_RUNTIME option. The protocol compiler itself (protoc) falls
|
||||
# into that category. Do not use in Chrome code.
|
||||
|
||||
source_set("protobuf_full") {
|
||||
visibility = ":*" # Prevent people from depending on this outside our file.
|
||||
static_library("protobuf_full") {
|
||||
# Prevent people from depending on this outside our file.
|
||||
visibility = [ ":*" ]
|
||||
|
||||
sources = protobuf_lite_sources
|
||||
sources += [
|
||||
"src/google/protobuf/descriptor.h",
|
||||
"src/google/protobuf/descriptor.pb.h",
|
||||
"src/google/protobuf/descriptor_database.h",
|
||||
"src/google/protobuf/dynamic_message.h",
|
||||
"src/google/protobuf/generated_enum_reflection.h",
|
||||
"src/google/protobuf/generated_message_reflection.h",
|
||||
"src/google/protobuf/message.h",
|
||||
"src/google/protobuf/reflection_ops.h",
|
||||
"src/google/protobuf/service.h",
|
||||
"src/google/protobuf/text_format.h",
|
||||
"src/google/protobuf/wire_format.h",
|
||||
"src/google/protobuf/io/gzip_stream.h",
|
||||
"src/google/protobuf/io/printer.h",
|
||||
"src/google/protobuf/io/tokenizer.h",
|
||||
"src/google/protobuf/io/zero_copy_stream_impl.h",
|
||||
"src/google/protobuf/compiler/code_generator.h",
|
||||
"src/google/protobuf/compiler/command_line_interface.h",
|
||||
"src/google/protobuf/any.cc",
|
||||
"src/google/protobuf/any.h",
|
||||
"src/google/protobuf/any.pb.cc",
|
||||
"src/google/protobuf/any.pb.h",
|
||||
"src/google/protobuf/api.pb.cc",
|
||||
"src/google/protobuf/api.pb.h",
|
||||
"src/google/protobuf/compiler/importer.cc",
|
||||
"src/google/protobuf/compiler/importer.h",
|
||||
"src/google/protobuf/compiler/java/java_doc_comment.cc",
|
||||
"src/google/protobuf/compiler/java/java_doc_comment.h",
|
||||
"src/google/protobuf/compiler/parser.cc",
|
||||
"src/google/protobuf/compiler/parser.h",
|
||||
"src/google/protobuf/descriptor.cc",
|
||||
"src/google/protobuf/descriptor.h",
|
||||
"src/google/protobuf/descriptor.pb.cc",
|
||||
"src/google/protobuf/descriptor.pb.h",
|
||||
"src/google/protobuf/descriptor_database.cc",
|
||||
"src/google/protobuf/descriptor_database.h",
|
||||
"src/google/protobuf/duration.pb.cc",
|
||||
"src/google/protobuf/duration.pb.h",
|
||||
"src/google/protobuf/dynamic_message.cc",
|
||||
"src/google/protobuf/dynamic_message.h",
|
||||
"src/google/protobuf/empty.pb.cc",
|
||||
"src/google/protobuf/empty.pb.h",
|
||||
"src/google/protobuf/extension_set_heavy.cc",
|
||||
"src/google/protobuf/field_mask.pb.cc",
|
||||
"src/google/protobuf/field_mask.pb.h",
|
||||
"src/google/protobuf/generated_enum_reflection.h",
|
||||
"src/google/protobuf/generated_enum_util.h",
|
||||
"src/google/protobuf/generated_message_reflection.cc",
|
||||
"src/google/protobuf/generated_message_reflection.h",
|
||||
|
||||
"src/google/protobuf/stubs/strutil.cc",
|
||||
"src/google/protobuf/stubs/strutil.h",
|
||||
# gzip_stream.cc pulls in zlib, but it's not actually used by protoc, just
|
||||
# by test code, so instead of compiling zlib for the host, let's just
|
||||
# exclude this.
|
||||
# "src/google/protobuf/io/gzip_stream.cc",
|
||||
# "src/google/protobuf/io/gzip_stream.h",
|
||||
|
||||
"src/google/protobuf/io/printer.cc",
|
||||
"src/google/protobuf/io/printer.h",
|
||||
"src/google/protobuf/io/strtod.cc",
|
||||
"src/google/protobuf/io/strtod.h",
|
||||
"src/google/protobuf/io/tokenizer.cc",
|
||||
"src/google/protobuf/io/tokenizer.h",
|
||||
"src/google/protobuf/io/zero_copy_stream_impl.cc",
|
||||
"src/google/protobuf/io/zero_copy_stream_impl.h",
|
||||
"src/google/protobuf/map_entry.h",
|
||||
"src/google/protobuf/map_field.cc",
|
||||
"src/google/protobuf/map_field.h",
|
||||
"src/google/protobuf/map_field_inl.h",
|
||||
"src/google/protobuf/message.cc",
|
||||
"src/google/protobuf/message.h",
|
||||
"src/google/protobuf/metadata.h",
|
||||
"src/google/protobuf/reflection.h",
|
||||
"src/google/protobuf/reflection_internal.h",
|
||||
"src/google/protobuf/reflection_ops.cc",
|
||||
"src/google/protobuf/reflection_ops.h",
|
||||
"src/google/protobuf/service.cc",
|
||||
"src/google/protobuf/service.h",
|
||||
"src/google/protobuf/source_context.pb.cc",
|
||||
"src/google/protobuf/source_context.pb.h",
|
||||
"src/google/protobuf/struct.pb.cc",
|
||||
"src/google/protobuf/struct.pb.h",
|
||||
"src/google/protobuf/stubs/mathlimits.cc",
|
||||
"src/google/protobuf/stubs/mathlimits.h",
|
||||
"src/google/protobuf/stubs/mathutil.h",
|
||||
"src/google/protobuf/stubs/singleton.h",
|
||||
"src/google/protobuf/stubs/substitute.cc",
|
||||
"src/google/protobuf/stubs/substitute.h",
|
||||
"src/google/protobuf/stubs/stl_util.h",
|
||||
"src/google/protobuf/stubs/stringprintf.cc",
|
||||
"src/google/protobuf/stubs/stringprintf.h",
|
||||
"src/google/protobuf/stubs/structurally_valid.cc",
|
||||
"src/google/protobuf/stubs/template_util.h",
|
||||
"src/google/protobuf/stubs/type_traits.h",
|
||||
|
||||
"src/google/protobuf/descriptor.cc",
|
||||
"src/google/protobuf/descriptor.pb.cc",
|
||||
"src/google/protobuf/descriptor_database.cc",
|
||||
"src/google/protobuf/dynamic_message.cc",
|
||||
"src/google/protobuf/extension_set_heavy.cc",
|
||||
"src/google/protobuf/generated_message_reflection.cc",
|
||||
"src/google/protobuf/message.cc",
|
||||
"src/google/protobuf/reflection_ops.cc",
|
||||
"src/google/protobuf/service.cc",
|
||||
"src/google/protobuf/text_format.cc",
|
||||
"src/google/protobuf/text_format.h",
|
||||
"src/google/protobuf/timestamp.pb.cc",
|
||||
"src/google/protobuf/timestamp.pb.h",
|
||||
"src/google/protobuf/type.pb.cc",
|
||||
"src/google/protobuf/type.pb.h",
|
||||
"src/google/protobuf/unknown_field_set.cc",
|
||||
"src/google/protobuf/unknown_field_set.h",
|
||||
"src/google/protobuf/util/field_comparator.cc",
|
||||
"src/google/protobuf/util/field_comparator.h",
|
||||
"src/google/protobuf/util/field_mask_util.cc",
|
||||
"src/google/protobuf/util/field_mask_util.h",
|
||||
"src/google/protobuf/util/internal/constants.h",
|
||||
"src/google/protobuf/util/internal/datapiece.cc",
|
||||
"src/google/protobuf/util/internal/datapiece.h",
|
||||
"src/google/protobuf/util/internal/default_value_objectwriter.cc",
|
||||
"src/google/protobuf/util/internal/default_value_objectwriter.h",
|
||||
"src/google/protobuf/util/internal/error_listener.cc",
|
||||
"src/google/protobuf/util/internal/error_listener.h",
|
||||
"src/google/protobuf/util/internal/field_mask_utility.cc",
|
||||
"src/google/protobuf/util/internal/field_mask_utility.h",
|
||||
"src/google/protobuf/util/internal/json_escaping.cc",
|
||||
"src/google/protobuf/util/internal/json_escaping.h",
|
||||
"src/google/protobuf/util/internal/json_objectwriter.cc",
|
||||
"src/google/protobuf/util/internal/json_objectwriter.h",
|
||||
"src/google/protobuf/util/internal/json_stream_parser.cc",
|
||||
"src/google/protobuf/util/internal/json_stream_parser.h",
|
||||
"src/google/protobuf/util/internal/location_tracker.h",
|
||||
"src/google/protobuf/util/internal/object_location_tracker.h",
|
||||
"src/google/protobuf/util/internal/object_source.h",
|
||||
"src/google/protobuf/util/internal/object_writer.cc",
|
||||
"src/google/protobuf/util/internal/object_writer.h",
|
||||
"src/google/protobuf/util/internal/proto_writer.cc",
|
||||
"src/google/protobuf/util/internal/proto_writer.h",
|
||||
"src/google/protobuf/util/internal/protostream_objectsource.cc",
|
||||
"src/google/protobuf/util/internal/protostream_objectsource.h",
|
||||
"src/google/protobuf/util/internal/protostream_objectwriter.cc",
|
||||
"src/google/protobuf/util/internal/protostream_objectwriter.h",
|
||||
"src/google/protobuf/util/internal/structured_objectwriter.h",
|
||||
"src/google/protobuf/util/internal/type_info.cc",
|
||||
"src/google/protobuf/util/internal/type_info.h",
|
||||
"src/google/protobuf/util/internal/type_info_test_helper.cc",
|
||||
"src/google/protobuf/util/internal/type_info_test_helper.h",
|
||||
"src/google/protobuf/util/internal/utility.cc",
|
||||
"src/google/protobuf/util/internal/utility.h",
|
||||
"src/google/protobuf/util/json_util.cc",
|
||||
"src/google/protobuf/util/json_util.h",
|
||||
"src/google/protobuf/util/message_differencer.cc",
|
||||
"src/google/protobuf/util/message_differencer.h",
|
||||
"src/google/protobuf/util/time_util.cc",
|
||||
"src/google/protobuf/util/time_util.h",
|
||||
"src/google/protobuf/util/type_resolver.h",
|
||||
"src/google/protobuf/util/type_resolver_util.cc",
|
||||
"src/google/protobuf/util/type_resolver_util.h",
|
||||
"src/google/protobuf/wire_format.cc",
|
||||
# This file pulls in zlib, but it's not actually used by protoc, so
|
||||
# instead of compiling zlib for the host, let's just exclude this.
|
||||
# "src/src/google/protobuf/io/gzip_stream.cc",
|
||||
"src/google/protobuf/io/printer.cc",
|
||||
"src/google/protobuf/io/tokenizer.cc",
|
||||
"src/google/protobuf/io/zero_copy_stream_impl.cc",
|
||||
"src/google/protobuf/compiler/importer.cc",
|
||||
"src/google/protobuf/compiler/parser.cc",
|
||||
"src/google/protobuf/wire_format.h",
|
||||
"src/google/protobuf/wrappers.pb.cc",
|
||||
"src/google/protobuf/wrappers.pb.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//build/config/sanitizers:deps",
|
||||
]
|
||||
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
configs += [
|
||||
"//build/config/compiler:no_chromium_code",
|
||||
|
||||
# Must be after no_chromium_code for warning flags to be ordered
|
||||
# correctly.
|
||||
":protobuf_warnings",
|
||||
]
|
||||
if (is_win) {
|
||||
configs -= [ "//build/config/win:lean_and_mean" ]
|
||||
}
|
||||
direct_dependent_configs = [ ":protobuf_config" ]
|
||||
public_configs = [
|
||||
":protobuf_config",
|
||||
|
||||
# TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
|
||||
"//build/config/compiler:no_size_t_to_int_warning",
|
||||
]
|
||||
|
||||
cflags = protobuf_lite_cflags
|
||||
}
|
||||
|
||||
# Only compile the compiler for the host architecture.
|
||||
if (current_toolchain == host_toolchain) {
|
||||
executable("protoc") {
|
||||
# protoc compiler is separated into protoc library and executable targets to
|
||||
# support protoc plugins that need to link libprotoc, but not the main()
|
||||
# itself. See src/google/protobuf/compiler/plugin.h
|
||||
static_library("protoc_lib") {
|
||||
sources = [
|
||||
"src/google/protobuf/compiler/code_generator.cc",
|
||||
"src/google/protobuf/compiler/code_generator.h",
|
||||
"src/google/protobuf/compiler/command_line_interface.cc",
|
||||
"src/google/protobuf/compiler/plugin.cc",
|
||||
"src/google/protobuf/compiler/plugin.pb.cc",
|
||||
"src/google/protobuf/compiler/subprocess.cc",
|
||||
"src/google/protobuf/compiler/subprocess.h",
|
||||
"src/google/protobuf/compiler/zip_writer.cc",
|
||||
"src/google/protobuf/compiler/zip_writer.h",
|
||||
"src/google/protobuf/compiler/command_line_interface.h",
|
||||
"src/google/protobuf/compiler/cpp/cpp_enum.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_enum.h",
|
||||
"src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
|
||||
|
@ -196,56 +355,298 @@ if (current_toolchain == host_toolchain) {
|
|||
"src/google/protobuf/compiler/cpp/cpp_file.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_file.h",
|
||||
"src/google/protobuf/compiler/cpp/cpp_generator.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_generator.h",
|
||||
"src/google/protobuf/compiler/cpp/cpp_helpers.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_helpers.h",
|
||||
"src/google/protobuf/compiler/cpp/cpp_map_field.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_map_field.h",
|
||||
"src/google/protobuf/compiler/cpp/cpp_message.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_message.h",
|
||||
"src/google/protobuf/compiler/cpp/cpp_message_field.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_message_field.h",
|
||||
"src/google/protobuf/compiler/cpp/cpp_options.h",
|
||||
"src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_primitive_field.h",
|
||||
"src/google/protobuf/compiler/cpp/cpp_service.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_service.h",
|
||||
"src/google/protobuf/compiler/cpp/cpp_string_field.cc",
|
||||
"src/google/protobuf/compiler/cpp/cpp_string_field.h",
|
||||
"src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_doc_comment.h",
|
||||
"src/google/protobuf/compiler/csharp/csharp_enum.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_enum.h",
|
||||
"src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_enum_field.h",
|
||||
"src/google/protobuf/compiler/csharp/csharp_field_base.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_field_base.h",
|
||||
"src/google/protobuf/compiler/csharp/csharp_generator.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_generator.h",
|
||||
"src/google/protobuf/compiler/csharp/csharp_helpers.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_helpers.h",
|
||||
"src/google/protobuf/compiler/csharp/csharp_map_field.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_map_field.h",
|
||||
"src/google/protobuf/compiler/csharp/csharp_message.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_message.h",
|
||||
"src/google/protobuf/compiler/csharp/csharp_message_field.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_message_field.h",
|
||||
"src/google/protobuf/compiler/csharp/csharp_options.h",
|
||||
"src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_primitive_field.h",
|
||||
"src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_reflection_class.h",
|
||||
"src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h",
|
||||
"src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h",
|
||||
"src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h",
|
||||
"src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_source_generator_base.h",
|
||||
"src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
|
||||
"src/google/protobuf/compiler/csharp/csharp_wrapper_field.h",
|
||||
"src/google/protobuf/compiler/java/java_context.cc",
|
||||
"src/google/protobuf/compiler/java/java_context.h",
|
||||
"src/google/protobuf/compiler/java/java_doc_comment.cc",
|
||||
"src/google/protobuf/compiler/java/java_doc_comment.h",
|
||||
"src/google/protobuf/compiler/java/java_enum.cc",
|
||||
"src/google/protobuf/compiler/java/java_enum.h",
|
||||
"src/google/protobuf/compiler/java/java_enum_field.cc",
|
||||
"src/google/protobuf/compiler/java/java_enum_field.h",
|
||||
"src/google/protobuf/compiler/java/java_enum_field_lite.cc",
|
||||
"src/google/protobuf/compiler/java/java_enum_field_lite.h",
|
||||
"src/google/protobuf/compiler/java/java_enum_lite.cc",
|
||||
"src/google/protobuf/compiler/java/java_enum_lite.h",
|
||||
"src/google/protobuf/compiler/java/java_extension.cc",
|
||||
"src/google/protobuf/compiler/java/java_extension.h",
|
||||
"src/google/protobuf/compiler/java/java_extension_lite.cc",
|
||||
"src/google/protobuf/compiler/java/java_extension_lite.h",
|
||||
"src/google/protobuf/compiler/java/java_field.cc",
|
||||
"src/google/protobuf/compiler/java/java_field.h",
|
||||
"src/google/protobuf/compiler/java/java_file.cc",
|
||||
"src/google/protobuf/compiler/java/java_file.h",
|
||||
"src/google/protobuf/compiler/java/java_generator.cc",
|
||||
"src/google/protobuf/compiler/java/java_generator.h",
|
||||
"src/google/protobuf/compiler/java/java_generator_factory.cc",
|
||||
"src/google/protobuf/compiler/java/java_generator_factory.h",
|
||||
"src/google/protobuf/compiler/java/java_helpers.cc",
|
||||
"src/google/protobuf/compiler/java/java_helpers.h",
|
||||
"src/google/protobuf/compiler/java/java_lazy_message_field.cc",
|
||||
"src/google/protobuf/compiler/java/java_lazy_message_field.h",
|
||||
"src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
|
||||
"src/google/protobuf/compiler/java/java_lazy_message_field_lite.h",
|
||||
"src/google/protobuf/compiler/java/java_map_field.cc",
|
||||
"src/google/protobuf/compiler/java/java_map_field.h",
|
||||
"src/google/protobuf/compiler/java/java_map_field_lite.cc",
|
||||
"src/google/protobuf/compiler/java/java_map_field_lite.h",
|
||||
"src/google/protobuf/compiler/java/java_message.cc",
|
||||
"src/google/protobuf/compiler/java/java_message.h",
|
||||
"src/google/protobuf/compiler/java/java_message_builder.cc",
|
||||
"src/google/protobuf/compiler/java/java_message_builder.h",
|
||||
"src/google/protobuf/compiler/java/java_message_builder_lite.cc",
|
||||
"src/google/protobuf/compiler/java/java_message_builder_lite.h",
|
||||
"src/google/protobuf/compiler/java/java_message_field.cc",
|
||||
"src/google/protobuf/compiler/java/java_message_field.h",
|
||||
"src/google/protobuf/compiler/java/java_message_field_lite.cc",
|
||||
"src/google/protobuf/compiler/java/java_message_field_lite.h",
|
||||
"src/google/protobuf/compiler/java/java_message_lite.cc",
|
||||
"src/google/protobuf/compiler/java/java_message_lite.h",
|
||||
"src/google/protobuf/compiler/java/java_name_resolver.cc",
|
||||
"src/google/protobuf/compiler/java/java_name_resolver.h",
|
||||
"src/google/protobuf/compiler/java/java_primitive_field.cc",
|
||||
"src/google/protobuf/compiler/java/java_primitive_field.h",
|
||||
"src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
|
||||
"src/google/protobuf/compiler/java/java_primitive_field_lite.h",
|
||||
"src/google/protobuf/compiler/java/java_service.cc",
|
||||
"src/google/protobuf/compiler/java/java_service.h",
|
||||
"src/google/protobuf/compiler/java/java_shared_code_generator.cc",
|
||||
"src/google/protobuf/compiler/java/java_shared_code_generator.h",
|
||||
"src/google/protobuf/compiler/java/java_string_field.cc",
|
||||
"src/google/protobuf/compiler/java/java_string_field.h",
|
||||
"src/google/protobuf/compiler/java/java_string_field_lite.cc",
|
||||
"src/google/protobuf/compiler/java/java_string_field_lite.h",
|
||||
"src/google/protobuf/compiler/javanano/javanano_enum.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_enum.h",
|
||||
"src/google/protobuf/compiler/javanano/javanano_enum_field.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_enum_field.h",
|
||||
"src/google/protobuf/compiler/javanano/javanano_extension.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_extension.h",
|
||||
"src/google/protobuf/compiler/javanano/javanano_field.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_field.h",
|
||||
"src/google/protobuf/compiler/javanano/javanano_file.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_file.h",
|
||||
"src/google/protobuf/compiler/javanano/javanano_generator.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_generator.h",
|
||||
"src/google/protobuf/compiler/javanano/javanano_helpers.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_helpers.h",
|
||||
"src/google/protobuf/compiler/javanano/javanano_map_field.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_map_field.h",
|
||||
"src/google/protobuf/compiler/javanano/javanano_message.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_message.h",
|
||||
"src/google/protobuf/compiler/javanano/javanano_message_field.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_message_field.h",
|
||||
"src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
|
||||
"src/google/protobuf/compiler/javanano/javanano_primitive_field.h",
|
||||
"src/google/protobuf/compiler/js/js_generator.cc",
|
||||
"src/google/protobuf/compiler/js/js_generator.h",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_enum.h",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_enum_field.h",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_extension.h",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_field.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_field.h",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_file.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_file.h",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_generator.h",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_helpers.h",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_map_field.h",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_message.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_message.h",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_message_field.h",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_oneof.h",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
|
||||
"src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h",
|
||||
"src/google/protobuf/compiler/plugin.cc",
|
||||
"src/google/protobuf/compiler/plugin.h",
|
||||
"src/google/protobuf/compiler/plugin.pb.cc",
|
||||
"src/google/protobuf/compiler/plugin.pb.h",
|
||||
"src/google/protobuf/compiler/python/python_generator.cc",
|
||||
"src/google/protobuf/compiler/main.cc",
|
||||
"src/google/protobuf/compiler/python/python_generator.h",
|
||||
"src/google/protobuf/compiler/ruby/ruby_generator.cc",
|
||||
"src/google/protobuf/compiler/ruby/ruby_generator.h",
|
||||
"src/google/protobuf/compiler/subprocess.cc",
|
||||
"src/google/protobuf/compiler/subprocess.h",
|
||||
"src/google/protobuf/compiler/zip_writer.cc",
|
||||
"src/google/protobuf/compiler/zip_writer.h",
|
||||
]
|
||||
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
configs += [
|
||||
"//build/config/compiler:no_chromium_code",
|
||||
|
||||
# Must be after no_chromium_code for warning flags to be ordered
|
||||
# correctly.
|
||||
":protobuf_warnings",
|
||||
]
|
||||
if (is_win) {
|
||||
# This is defined internally, don't warn on duplicate.
|
||||
configs -= [ "//build/config/win:lean_and_mean" ]
|
||||
}
|
||||
|
||||
public_configs = [ ":protobuf_config" ]
|
||||
|
||||
cflags = protobuf_lite_cflags
|
||||
|
||||
deps = [
|
||||
public_deps = [
|
||||
":protobuf_full",
|
||||
]
|
||||
}
|
||||
|
||||
executable("protoc") {
|
||||
sources = [
|
||||
"src/google/protobuf/compiler/main.cc",
|
||||
]
|
||||
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
|
||||
cflags = protobuf_lite_cflags
|
||||
|
||||
deps = [
|
||||
":protoc_lib",
|
||||
|
||||
# Default manifest on Windows (a no-op elsewhere).
|
||||
"//build/win:default_exe_manifest",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
google_python_dir = "$root_out_dir/pyproto/google"
|
||||
|
||||
copy("copy_google") {
|
||||
sources = [
|
||||
"__init__.py",
|
||||
]
|
||||
outputs = [
|
||||
"$google_python_dir/{{source_file_part}}",
|
||||
]
|
||||
}
|
||||
|
||||
copy("copy_six") {
|
||||
sources = [
|
||||
"third_party/six/six.py",
|
||||
]
|
||||
outputs = [
|
||||
"$google_python_dir/third_party/six/{{source_file_part}}",
|
||||
]
|
||||
}
|
||||
|
||||
copy("copy_google_protobuf") {
|
||||
sources = [
|
||||
"python/google/protobuf/__init__.py",
|
||||
"python/google/protobuf/descriptor.py",
|
||||
"python/google/protobuf/descriptor_database.py",
|
||||
"python/google/protobuf/descriptor_pool.py",
|
||||
"python/google/protobuf/json_format.py",
|
||||
"python/google/protobuf/message.py",
|
||||
"python/google/protobuf/message_factory.py",
|
||||
"python/google/protobuf/proto_builder.py",
|
||||
"python/google/protobuf/reflection.py",
|
||||
"python/google/protobuf/service.py",
|
||||
"python/google/protobuf/service_reflection.py",
|
||||
"python/google/protobuf/symbol_database.py",
|
||||
"python/google/protobuf/text_encoding.py",
|
||||
"python/google/protobuf/text_format.py",
|
||||
|
||||
# TODO(ncarter): protoc's python generator treats descriptor.proto
|
||||
# specially, but only when the input path is exactly
|
||||
# "google/protobuf/descriptor.proto". I'm not sure how to execute a rule
|
||||
# from a different directory. For now, use a manually-generated copy of
|
||||
# descriptor_pb2.py.
|
||||
"python/google/protobuf/descriptor_pb2.py",
|
||||
]
|
||||
outputs = [
|
||||
"$google_python_dir/protobuf/{{source_file_part}}",
|
||||
]
|
||||
}
|
||||
|
||||
copy("copy_google_protobuf_internal") {
|
||||
sources = [
|
||||
"python/google/protobuf/internal/__init__.py",
|
||||
"python/google/protobuf/internal/_parameterized.py",
|
||||
"python/google/protobuf/internal/api_implementation.py",
|
||||
"python/google/protobuf/internal/containers.py",
|
||||
"python/google/protobuf/internal/decoder.py",
|
||||
"python/google/protobuf/internal/encoder.py",
|
||||
"python/google/protobuf/internal/enum_type_wrapper.py",
|
||||
"python/google/protobuf/internal/message_listener.py",
|
||||
"python/google/protobuf/internal/python_message.py",
|
||||
"python/google/protobuf/internal/type_checkers.py",
|
||||
"python/google/protobuf/internal/well_known_types.py",
|
||||
"python/google/protobuf/internal/wire_format.py",
|
||||
]
|
||||
outputs = [
|
||||
"$google_python_dir/protobuf/internal/{{source_file_part}}",
|
||||
]
|
||||
}
|
||||
|
||||
group("py_proto") {
|
||||
public_deps = [
|
||||
":copy_google",
|
||||
":copy_google_protobuf",
|
||||
":copy_google_protobuf_internal",
|
||||
":copy_six",
|
||||
]
|
||||
|
||||
# Targets that depend on this should depend on the copied data files.
|
||||
data = get_target_outputs(":copy_google")
|
||||
data += get_target_outputs(":copy_six")
|
||||
data += get_target_outputs(":copy_google_protobuf")
|
||||
data += get_target_outputs(":copy_google_protobuf_internal")
|
||||
}
|
||||
|
|
|
@ -1,4 +1,655 @@
|
|||
2012-09-19 version 2.5.0:
|
||||
2016-05-16 version 3.0.0-beta-3 (C++/Java/Python/Ruby/Nano/Objective-C/C#/JavaScript)
|
||||
General
|
||||
* Supported Proto3 lite-runtime in C++/Java for mobile platforms.
|
||||
* Any type now supports APIs to specify prefixes other than
|
||||
type.googleapis.com
|
||||
* Removed javanano_use_deprecated_package option; Nano will always has its own
|
||||
".nano" package.
|
||||
|
||||
C++ (Beta)
|
||||
* Improved hash maps.
|
||||
- Improved hash maps comments. In particular, please note that equal hash
|
||||
maps will not necessarily have the same iteration order and
|
||||
serialization.
|
||||
- Added a new hash maps implementation that will become the default in a
|
||||
later release.
|
||||
* Arenas
|
||||
- Several inlined methods in Arena were moved to out-of-line to improve
|
||||
build performance and code size.
|
||||
- Added SpaceAllocatedAndUsed() to report both space used and allocated
|
||||
- Added convenient class UnsafeArenaAllocatedRepeatedPtrFieldBackInserter
|
||||
* Any
|
||||
- Allow custom type URL prefixes in Any packing.
|
||||
- TextFormat now expand the Any type rather than printing bytes.
|
||||
* Performance optimizations and various bug fixes.
|
||||
|
||||
Java (Beta)
|
||||
* Introduced an ExperimentalApi annotation. Annotated APIs are experimental
|
||||
and are subject to change in a backward incompatible way in future releases.
|
||||
* Introduced zero-copy serialization as an ExperimentalApi
|
||||
- Introduction of the `ByteOutput` interface. This is similar to
|
||||
`OutputStream` but provides semantics for lazy writing (i.e. no
|
||||
immediate copy required) of fields that are considered to be immutable.
|
||||
- `ByteString` now supports writing to a `ByteOutput`, which will directly
|
||||
expose the internals of the `ByteString` (i.e. `byte[]` or `ByteBuffer`)
|
||||
to the `ByteOutput` without copying.
|
||||
- `CodedOutputStream` now supports writing to a `ByteOutput`. `ByteString`
|
||||
instances that are too large to fit in the internal buffer will be
|
||||
(lazily) written to the `ByteOutput` directly.
|
||||
- This allows applications using large `ByteString` fields to avoid
|
||||
duplication of these fields entirely. Such an application can supply a
|
||||
`ByteOutput` that chains together the chunks received from
|
||||
`CodedOutputStream` before forwarding them onto the IO system.
|
||||
* Other related changes to `CodedOutputStream`
|
||||
- Additional use of `sun.misc.Unsafe` where possible to perform fast
|
||||
access to `byte[]` and `ByteBuffer` values and avoiding unnecessary
|
||||
range checking.
|
||||
- `ByteBuffer`-backed `CodedOutputStream` now writes directly to the
|
||||
`ByteBuffer` rather than to an intermediate array.
|
||||
* Improved lite-runtime.
|
||||
- Lite protos now implement deep equals/hashCode/toString
|
||||
- Significantly improved the performance of Builder#mergeFrom() and
|
||||
Builder#mergeDelimitedFrom()
|
||||
* Various bug fixes and small feature enhancement.
|
||||
- Fixed stack overflow when in hashCode() for infinite recursive oneofs.
|
||||
- Fixed the lazy field parsing in lite to merge rather than overwrite.
|
||||
- TextFormat now supports reporting line/column numbers on errors.
|
||||
- Updated to add appropriate @Override for better compiler errors.
|
||||
|
||||
Python (Beta)
|
||||
* Added JSON format for Any, Struct, Value and ListValue
|
||||
* [ ] is now accepted for both repeated scalar fields and repeated message
|
||||
fields in text format parser.
|
||||
* Numerical field name is now supported in text format.
|
||||
* Added DiscardUnknownFields API for python protobuf message.
|
||||
|
||||
Objective-C (Beta)
|
||||
* Proto comments now come over as HeaderDoc comments in the generated sources
|
||||
so Xcode can pick them up and display them.
|
||||
* The library headers have been updated to use HeaderDoc comments so Xcode can
|
||||
pick them up and display them.
|
||||
* The per message and per field overhead in both generated code and runtime
|
||||
object sizes was reduced.
|
||||
* Generated code now include deprecated annotations when the proto file
|
||||
included them.
|
||||
|
||||
C# (Beta)
|
||||
In general: some changes are breaking, which require regenerating messages.
|
||||
Most user-written code will not be impacted *except* for the renaming of enum
|
||||
values.
|
||||
|
||||
* Allow custom type URL prefixes in `Any` packing, and ignore them when
|
||||
unpacking
|
||||
* `protoc` is now in a separate NuGet package (Google.Protobuf.Tools)
|
||||
* New option: `internal_access` to generate internal classes
|
||||
* Enum values are now PascalCased, and if there's a prefix which matches the
|
||||
name of the enum, that is removed (so an enum `COLOR` with a value
|
||||
`COLOR_BLUE` would generate a value of just `Blue`). An option
|
||||
(`legacy_enum_values`) is temporarily available to disable this, but the
|
||||
option will be removed for GA.
|
||||
* `json_name` option is now honored
|
||||
* If group tags are encountered when parsing, they are validated more
|
||||
thoroughly (although we don't support actual groups)
|
||||
* NuGet dependencies are better specified
|
||||
* Breaking: `Preconditions` is renamed to `ProtoPreconditions`
|
||||
* Breaking: `GeneratedCodeInfo` is renamed to `GeneratedClrTypeInfo`
|
||||
* `JsonFormatter` now allows writing to a `TextWriter`
|
||||
* New interface, `ICustomDiagnosticMessage` to allow more compact
|
||||
representations from `ToString`
|
||||
* `CodedInputStream` and `CodedOutputStream` now implement `IDisposable`,
|
||||
which simply disposes of the streams they were constructed with
|
||||
* Map fields no longer support null values (in line with other languages)
|
||||
* Improvements in JSON formatting and parsing
|
||||
|
||||
Javascript (Alpha)
|
||||
* Better support for "bytes" fields: bytes fields can be read as either a
|
||||
base64 string or UInt8Array (in environments where TypedArray is supported).
|
||||
* New support for CommonJS imports. This should make it easier to use the
|
||||
JavaScript support in Node.js and tools like WebPack. See js/README.md for
|
||||
more information.
|
||||
* Some significant internal refactoring to simplify and modularize the code.
|
||||
|
||||
Ruby (Alpha)
|
||||
* JSON serialization now properly uses camelCased names, with a runtime option
|
||||
that will preserve original names from .proto files instead.
|
||||
* Well-known types are now included in the distribution.
|
||||
* Release now includes binary gems for Windows, Mac, and Linux instead of just
|
||||
source gems.
|
||||
* Bugfix for serializing oneofs.
|
||||
|
||||
C++/Java Lite (Alpha)
|
||||
A new "lite" generator parameter was introduced in the protoc for C++ and
|
||||
Java for Proto3 syntax messages. Example usage:
|
||||
|
||||
./protoc --cpp_out=lite:$OUTPUT_PATH foo.proto
|
||||
|
||||
The protoc will treat the current input and all the transitive dependencies
|
||||
as LITE. The same generator parameter must be used to generate the
|
||||
dependencies.
|
||||
|
||||
In Proto3 syntax files, "optimized_for=LITE_RUNTIME" is no longer supported.
|
||||
|
||||
|
||||
2015-12-30 version 3.0.0-beta-2 (C++/Java/Python/Ruby/Nano/Objective-C/C#/JavaScript)
|
||||
General
|
||||
* Introduced a new language implementation: JavaScript.
|
||||
* Added a new field option "json_name". By default proto field names are
|
||||
converted to "lowerCamelCase" in proto3 JSON format. This option can be
|
||||
used to override this behavior and specify a different JSON name for the
|
||||
field.
|
||||
* Added conformance tests to ensure implementations are following proto3 JSON
|
||||
specification.
|
||||
|
||||
C++ (Beta)
|
||||
* Various bug fixes and improvements to the JSON support utility:
|
||||
- Duplicate map keys in JSON are now rejected (i.e., translation will
|
||||
fail).
|
||||
- Fixed wire-format for google.protobuf.Value/ListValue.
|
||||
- Fixed precision loss when converting google.protobuf.Timestamp.
|
||||
- Fixed a bug when parsing invalid UTF-8 code points.
|
||||
- Fixed a memory leak.
|
||||
- Reduced call stack usage.
|
||||
|
||||
Java (Beta)
|
||||
* Cleaned up some unused methods on CodedOutputStream.
|
||||
* Presized lists for packed fields during parsing in the lite runtime to
|
||||
reduce allocations and improve performance.
|
||||
* Improved the performance of unknown fields in the lite runtime.
|
||||
* Introduced UnsafeByteStrings to support zero-copy ByteString creation.
|
||||
* Various bug fixes and improvements to the JSON support utility:
|
||||
- Fixed a thread-safety bug.
|
||||
- Added a new option “preservingProtoFieldNames” to JsonFormat.
|
||||
- Added a new option “includingDefaultValueFields” to JsonFormat.
|
||||
- Updated the JSON utility to comply with proto3 JSON specification.
|
||||
|
||||
Python (Beta)
|
||||
* Added proto3 JSON format utility. It includes support for all field types
|
||||
and a few well-known types except for Any and Struct.
|
||||
* Added runtime support for Any, Timestamp, Duration and FieldMask.
|
||||
* [ ] is now accepted for repeated scalar fields in text format parser.
|
||||
* Map fields now have proper O(1) performance for lookup/insert/delete
|
||||
when using the Python/C++ implementation. They were previously using O(n)
|
||||
search-based algorithms because the C++ reflection interface didn't
|
||||
support true map operations.
|
||||
|
||||
Objective-C (Beta)
|
||||
* Various bug-fixes and code tweaks to pass more strict compiler warnings.
|
||||
* Now has conformance test coverage and is passing all tests.
|
||||
|
||||
C# (Beta)
|
||||
* Various bug-fixes.
|
||||
* Code generation: Files generated in directories based on namespace.
|
||||
* Code generation: Include comments from .proto files in XML doc
|
||||
comments (naively)
|
||||
* Code generation: Change organization/naming of "reflection class" (access
|
||||
to file descriptor)
|
||||
* Code generation and library: Add Parser property to MessageDescriptor,
|
||||
and introduce a non-generic parser type.
|
||||
* Library: Added TypeRegistry to support JSON parsing/formatting of Any.
|
||||
* Library: Added Any.Pack/Unpack support.
|
||||
* Library: Implemented JSON parsing.
|
||||
|
||||
Javascript (Alpha)
|
||||
* Added proto3 support for JavaScript. The runtime is written in pure
|
||||
JavaScript and works in browsers and in Node.js. To generate JavaScript
|
||||
code for your proto, invoke protoc with "--js_out". See js/README.md
|
||||
for more build instructions.
|
||||
|
||||
2015-08-26 version 3.0.0-beta-1 (C++/Java/Python/Ruby/Nano/Objective-C/C#)
|
||||
About Beta
|
||||
* This is the first beta release of protobuf v3.0.0. Not all languages
|
||||
have reached beta stage. Languages not marked as beta are still in
|
||||
alpha (i.e., be prepared for API breaking changes).
|
||||
|
||||
General
|
||||
* Proto3 JSON is supported in several languages (fully supported in C++
|
||||
and Java, partially supported in Ruby/C#). The JSON spec is defined in
|
||||
the proto3 language guide:
|
||||
|
||||
https://developers.google.com/protocol-buffers/docs/proto3#json
|
||||
|
||||
We will publish a more detailed spec to define the exact behavior of
|
||||
proto3-conformant JSON serializers and parsers. Until then, do not rely
|
||||
on specific behaviors of the implementation if it’s not documented in
|
||||
the above spec. More specifically, the behavior is not yet finalized for
|
||||
the following:
|
||||
- Parsing invalid JSON input (e.g., input with trailing commas).
|
||||
- Non-camelCase names in JSON input.
|
||||
- The same field appears multiple times in JSON input.
|
||||
- JSON arrays contain “null” values.
|
||||
- The message has unknown fields.
|
||||
|
||||
* Proto3 now enforces strict UTF-8 checking. Parsing will fail if a string
|
||||
field contains non UTF-8 data.
|
||||
|
||||
C++ (Beta)
|
||||
* Introduced new utility functions/classes in the google/protobuf/util
|
||||
directory:
|
||||
- MessageDifferencer: compare two proto messages and report their
|
||||
differences.
|
||||
- JsonUtil: support converting protobuf binary format to/from JSON.
|
||||
- TimeUtil: utility functions to work with well-known types Timestamp
|
||||
and Duration.
|
||||
- FieldMaskUtil: utility functions to work with FieldMask.
|
||||
|
||||
* Performance optimization of arena construction and destruction.
|
||||
* Bug fixes for arena and maps support.
|
||||
* Changed to use cmake for Windows Visual Studio builds.
|
||||
* Added Bazel support.
|
||||
|
||||
Java (Beta)
|
||||
* Introduced a new util package that will be distributed as a separate
|
||||
artifact in maven. It contains:
|
||||
- JsonFormat: convert proto messages to/from JSON.
|
||||
- TimeUtil: utility functions to work with Timestamp and Duration.
|
||||
- FieldMaskUtil: utility functions to work with FieldMask.
|
||||
|
||||
* The static PARSER in each generated message is deprecated, and it will
|
||||
be removed in a future release. A static parser() getter is generated
|
||||
for each message type instead.
|
||||
* Performance optimizations for String fields serialization.
|
||||
* Performance optimizations for Lite runtime on Android:
|
||||
- Reduced allocations
|
||||
- Reduced method overhead after ProGuarding
|
||||
- Reduced code size after ProGuarding
|
||||
|
||||
Python (Alpha)
|
||||
* Removed legacy Python 2.5 support.
|
||||
* Moved to a single Python 2.x/3.x-compatible codebase, instead of using 2to3.
|
||||
* Fixed build/tests on Python 2.6, 2.7, 3.3, and 3.4.
|
||||
- Pure-Python works on all four.
|
||||
- Python/C++ implementation works on all but 3.4, due to changes in the
|
||||
Python/C++ API in 3.4.
|
||||
* Some preliminary work has been done to allow for multiple DescriptorPools
|
||||
with Python/C++.
|
||||
|
||||
Ruby (Alpha)
|
||||
* Many bugfixes:
|
||||
- fixed parsing/serialization of bytes, sint, sfixed types
|
||||
- other parser bugfixes
|
||||
- fixed memory leak affecting Ruby 2.2
|
||||
|
||||
JavaNano (Alpha)
|
||||
* JavaNano generated code now will be put in a nano package by default to
|
||||
avoid conflicts with Java generated code.
|
||||
|
||||
Objective-C (Alpha)
|
||||
* Added non-null markup to ObjC library. Requires SDK 8.4+ to build.
|
||||
* Many bugfixes:
|
||||
- Removed the class/enum filter.
|
||||
- Renamed some internal types to avoid conflicts with the well-known types
|
||||
protos.
|
||||
- Added missing support for parsing repeated primitive fields in packed or
|
||||
unpacked forms.
|
||||
- Added *Count for repeated and map<> fields to avoid auto-create when
|
||||
checking for them being set.
|
||||
|
||||
C# (Alpha)
|
||||
* Namespace changed to Google.Protobuf (and NuGet package will be named
|
||||
correspondingly).
|
||||
* Target platforms now .NET 4.5 and selected portable subsets only.
|
||||
* Removed lite runtime.
|
||||
* Reimplementation to use mutable message types.
|
||||
* Null references used to represent "no value" for message type fields.
|
||||
* Proto3 semantics supported; proto2 files are prohibited for C# codegen.
|
||||
Most proto3 features supported:
|
||||
- JSON formatting (a.k.a. serialization to JSON), including well-known
|
||||
types (except for Any).
|
||||
- Wrapper types mapped to nullable value types (or string/ByteString
|
||||
allowing nullability). JSON parsing is not supported yet.
|
||||
- maps
|
||||
- oneof
|
||||
- enum unknown value preservation
|
||||
|
||||
2015-05-25 version 3.0.0-alpha-3 (Objective-C/C#):
|
||||
General
|
||||
* Introduced two new language implementations (Objective-C, C#) to proto3.
|
||||
* Explicit "optional" keyword are disallowed in proto3 syntax, as fields are
|
||||
optional by default.
|
||||
* Group fields are no longer supported in proto3 syntax.
|
||||
* Changed repeated primitive fields to use packed serialization by default in
|
||||
proto3 (implemented for C++, Java, Python in this release). The user can
|
||||
still disable packed serialization by setting packed to false for now.
|
||||
* Added well-known type protos (any.proto, empty.proto, timestamp.proto,
|
||||
duration.proto, etc.). Users can import and use these protos just like
|
||||
regular proto files. Additional runtime support will be added for them in
|
||||
future releases (in the form of utility helper functions, or having them
|
||||
replaced by language specific types in generated code).
|
||||
* Added a "reserved" keyword in both proto2 and proto3 syntax. User can use
|
||||
this keyword to declare reserved field numbers and names to prevent them
|
||||
from being reused by other fields in the same message.
|
||||
|
||||
To reserve field numbers, add a reserved declaration in your message:
|
||||
|
||||
message TestMessage {
|
||||
reserved 2, 15, 9 to 11, 3;
|
||||
}
|
||||
|
||||
This reserves field numbers 2, 3, 9, 10, 11 and 15. If a user uses any of
|
||||
these as field numbers, the protocol buffer compiler will report an error.
|
||||
|
||||
Field names can also be reserved:
|
||||
|
||||
message TestMessage {
|
||||
reserved "foo", "bar";
|
||||
}
|
||||
|
||||
* Various bug fixes since 3.0.0-alpha-2
|
||||
|
||||
Objective-C
|
||||
Objective-C includes a code generator and a native objective-c runtime
|
||||
library. By adding “--objc_out” to protoc, the code generator will generate
|
||||
a header(*.pbobjc.h) and an implementation file(*.pbobjc.m) for each proto
|
||||
file.
|
||||
|
||||
In this first release, the generated interface provides: enums, messages,
|
||||
field support(single, repeated, map, oneof), proto2 and proto3 syntax
|
||||
support, parsing and serialization. It’s compatible with ARC and non-ARC
|
||||
usage. Besides, user can also access it via the swift bridging header.
|
||||
|
||||
See objectivec/README.md for details.
|
||||
|
||||
C#
|
||||
* C# protobufs are based on project
|
||||
https://github.com/jskeet/protobuf-csharp-port. The original project was
|
||||
frozen and all the new development will happen here.
|
||||
* Codegen plugin for C# was completely rewritten to C++ and is now an
|
||||
integral part of protoc.
|
||||
* Some refactorings and cleanup has been applied to the C# runtime library.
|
||||
* Only proto2 is supported in C# at the moment, proto3 support is in
|
||||
progress and will likely bring significant breaking changes to the API.
|
||||
|
||||
See csharp/README.md for details.
|
||||
|
||||
C++
|
||||
* Added runtime support for Any type. To use Any in your proto file, first
|
||||
import the definition of Any:
|
||||
|
||||
// foo.proto
|
||||
import "google/protobuf/any.proto";
|
||||
message Foo {
|
||||
google.protobuf.Any any_field = 1;
|
||||
}
|
||||
message Bar {
|
||||
int32 value = 1;
|
||||
}
|
||||
|
||||
Then in C++ you can access the Any field using PackFrom()/UnpackTo()
|
||||
methods:
|
||||
|
||||
Foo foo;
|
||||
Bar bar = ...;
|
||||
foo.mutable_any_field()->PackFrom(bar);
|
||||
...
|
||||
if (foo.any_field().IsType<Bar>()) {
|
||||
foo.any_field().UnpackTo(&bar);
|
||||
...
|
||||
}
|
||||
* In text format, entries of a map field will be sorted by key.
|
||||
|
||||
Java
|
||||
* Continued optimizations on the lite runtime to improve performance for
|
||||
Android.
|
||||
|
||||
Python
|
||||
* Added map support.
|
||||
- maps now have a dict-like interface (msg.map_field[key] = value)
|
||||
- existing code that modifies maps via the repeated field interface
|
||||
will need to be updated.
|
||||
|
||||
Ruby
|
||||
* Improvements to RepeatedField's emulation of the Ruby Array API.
|
||||
* Various speedups and internal cleanups.
|
||||
|
||||
2015-02-26 version 3.0.0-alpha-2 (Python/Ruby/JavaNano):
|
||||
General
|
||||
* Introduced three new language implementations (Ruby, JavaNano, and
|
||||
Python) to proto3.
|
||||
* Various bug fixes since 3.0.0-alpha-1
|
||||
|
||||
Python:
|
||||
Python has received several updates, most notably support for proto3
|
||||
semantics in any .proto file that declares syntax="proto3".
|
||||
Messages declared in proto3 files no longer represent field presence
|
||||
for scalar fields (number, enums, booleans, or strings). You can
|
||||
no longer call HasField() for such fields, and they are serialized
|
||||
based on whether they have a non-zero/empty/false value.
|
||||
|
||||
One other notable change is in the C++-accelerated implementation.
|
||||
Descriptor objects (which describe the protobuf schema and allow
|
||||
reflection over it) are no longer duplicated between the Python
|
||||
and C++ layers. The Python descriptors are now simple wrappers
|
||||
around the C++ descriptors. This change should significantly
|
||||
reduce the memory usage of programs that use a lot of message
|
||||
types.
|
||||
|
||||
Ruby:
|
||||
We have added proto3 support for Ruby via a native C extension.
|
||||
|
||||
The Ruby extension itself is included in the ruby/ directory, and details on
|
||||
building and installing the extension are in ruby/README.md. The extension
|
||||
will also be published as a Ruby gem. Code generator support is included as
|
||||
part of `protoc` with the `--ruby_out` flag.
|
||||
|
||||
The Ruby extension implements a user-friendly DSL to define message types
|
||||
(also generated by the code generator from `.proto` files). Once a message
|
||||
type is defined, the user may create instances of the message that behave in
|
||||
ways idiomatic to Ruby. For example:
|
||||
|
||||
- Message fields are present as ordinary Ruby properties (getter method
|
||||
`foo` and setter method `foo=`).
|
||||
- Repeated field elements are stored in a container that acts like a native
|
||||
Ruby array, and map elements are stored in a container that acts like a
|
||||
native Ruby hashmap.
|
||||
- The usual well-known methods, such as `#to_s`, `#dup`, and the like, are
|
||||
present.
|
||||
|
||||
Unlike several existing third-party Ruby extensions for protobuf, this
|
||||
extension is built on a "strongly-typed" philosophy: message fields and
|
||||
array/map containers will throw exceptions eagerly when values of the
|
||||
incorrect type are inserted.
|
||||
|
||||
See ruby/README.md for details.
|
||||
|
||||
JavaNano:
|
||||
JavaNano is a special code generator and runtime library designed especially
|
||||
for resource-restricted systems, like Android. It is very resource-friendly
|
||||
in both the amount of code and the runtime overhead. Here is an an overview
|
||||
of JavaNano features compared with the official Java protobuf:
|
||||
|
||||
- No descriptors or message builders.
|
||||
- All messages are mutable; fields are public Java fields.
|
||||
- For optional fields only, encapsulation behind setter/getter/hazzer/
|
||||
clearer functions is opt-in, which provide proper 'has' state support.
|
||||
- For proto2, if not opted in, has state (field presence) is not available.
|
||||
Serialization outputs all fields not equal to their defaults.
|
||||
The behavior is consistent with proto3 semantics.
|
||||
- Required fields (proto2 only) are always serialized.
|
||||
- Enum constants are integers; protection against invalid values only
|
||||
when parsing from the wire.
|
||||
- Enum constants can be generated into container interfaces bearing
|
||||
the enum's name (so the referencing code is in Java style).
|
||||
- CodedInputByteBufferNano can only take byte[] (not InputStream).
|
||||
- Similarly CodedOutputByteBufferNano can only write to byte[].
|
||||
- Repeated fields are in arrays, not ArrayList or Vector. Null array
|
||||
elements are allowed and silently ignored.
|
||||
- Full support for serializing/deserializing repeated packed fields.
|
||||
- Support extensions (in proto2).
|
||||
- Unset messages/groups are null, not an immutable empty default
|
||||
instance.
|
||||
- toByteArray(...) and mergeFrom(...) are now static functions of
|
||||
MessageNano.
|
||||
- The 'bytes' type translates to the Java type byte[].
|
||||
|
||||
See javanano/README.txt for details.
|
||||
|
||||
2014-12-01 version 3.0.0-alpha-1 (C++/Java):
|
||||
|
||||
General
|
||||
* Introduced Protocol Buffers language version 3 (aka proto3).
|
||||
|
||||
When protobuf was initially opensourced it implemented Protocol Buffers
|
||||
language version 2 (aka proto2), which is why the version number
|
||||
started from v2.0.0. From v3.0.0, a new language version (proto3) is
|
||||
introduced while the old version (proto2) will continue to be supported.
|
||||
|
||||
The main intent of introducing proto3 is to clean up protobuf before
|
||||
pushing the language as the foundation of Google's new API platform.
|
||||
In proto3, the language is simplified, both for ease of use and to
|
||||
make it available in a wider range of programming languages. At the
|
||||
same time a few features are added to better support common idioms
|
||||
found in APIs.
|
||||
|
||||
The following are the main new features in language version 3:
|
||||
|
||||
1. Removal of field presence logic for primitive value fields, removal
|
||||
of required fields, and removal of default values. This makes proto3
|
||||
significantly easier to implement with open struct representations,
|
||||
as in languages like Android Java, Objective C, or Go.
|
||||
2. Removal of unknown fields.
|
||||
3. Removal of extensions, which are instead replaced by a new standard
|
||||
type called Any.
|
||||
4. Fix semantics for unknown enum values.
|
||||
5. Addition of maps.
|
||||
6. Addition of a small set of standard types for representation of time,
|
||||
dynamic data, etc.
|
||||
7. A well-defined encoding in JSON as an alternative to binary proto
|
||||
encoding.
|
||||
|
||||
This release (v3.0.0-alpha-1) includes partial proto3 support for C++ and
|
||||
Java. Items 6 (well-known types) and 7 (JSON format) in the above feature
|
||||
list are not implemented.
|
||||
|
||||
A new notion "syntax" is introduced to specify whether a .proto file
|
||||
uses proto2 or proto3:
|
||||
|
||||
// foo.proto
|
||||
syntax = "proto3";
|
||||
message Bar {...}
|
||||
|
||||
If omitted, the protocol compiler will generate a warning and "proto2" will
|
||||
be used as the default. This warning will be turned into an error in a
|
||||
future release.
|
||||
|
||||
We recommend that new Protocol Buffers users use proto3. However, we do not
|
||||
generally recommend that existing users migrate from proto2 from proto3 due
|
||||
to API incompatibility, and we will continue to support proto2 for a long
|
||||
time.
|
||||
|
||||
* Added support for map fields (implemented in C++/Java for both proto2 and
|
||||
proto3).
|
||||
|
||||
Map fields can be declared using the following syntax:
|
||||
|
||||
message Foo {
|
||||
map<string, string> values = 1;
|
||||
}
|
||||
|
||||
Data of a map field will be stored in memory as an unordered map and it
|
||||
can be accessed through generated accessors.
|
||||
|
||||
C++
|
||||
* Added arena allocation support (for both proto2 and proto3).
|
||||
|
||||
Profiling shows memory allocation and deallocation constitutes a significant
|
||||
fraction of CPU-time spent in protobuf code and arena allocation is a
|
||||
technique introduced to reduce this cost. With arena allocation, new
|
||||
objects will be allocated from a large piece of preallocated memory and
|
||||
deallocation of these objects is almost free. Early adoption shows 20% to
|
||||
50% improvement in some Google binaries.
|
||||
|
||||
To enable arena support, add the following option to your .proto file:
|
||||
|
||||
option cc_enable_arenas = true;
|
||||
|
||||
Protocol compiler will generate additional code to make the generated
|
||||
message classes work with arenas. This does not change the existing API
|
||||
of protobuf messages and does not affect wire format. Your existing code
|
||||
should continue to work after adding this option. In the future we will
|
||||
make this option enabled by default.
|
||||
|
||||
To actually take advantage of arena allocation, you need to use the arena
|
||||
APIs when creating messages. A quick example of using the arena API:
|
||||
|
||||
{
|
||||
google::protobuf::Arena arena;
|
||||
// Allocate a protobuf message in the arena.
|
||||
MyMessage* message = Arena::CreateMessage<MyMessage>(&arena);
|
||||
// All submessages will be allocated in the same arena.
|
||||
if (!message->ParseFromString(data)) {
|
||||
// Deal with malformed input data.
|
||||
}
|
||||
// Must not delete the message here. It will be deleted automatically
|
||||
// when the arena is destroyed.
|
||||
}
|
||||
|
||||
Currently arena does not work with map fields. Enabling arena in a .proto
|
||||
file containing map fields will result in compile errors in the generated
|
||||
code. This will be addressed in a future release.
|
||||
|
||||
2014-10-20 version 2.6.1:
|
||||
|
||||
C++
|
||||
* Added atomicops support for Solaris.
|
||||
* Released memory allocated by InitializeDefaultRepeatedFields() and
|
||||
GetEmptyString(). Some memory sanitizers reported them as memory leaks.
|
||||
|
||||
Java
|
||||
* Updated DynamicMessage.setField() to handle repeated enum values
|
||||
correctly.
|
||||
* Fixed a bug that caused NullPointerException to be thrown when
|
||||
converting manually constructed FileDescriptorProto to
|
||||
FileDescriptor.
|
||||
|
||||
Python
|
||||
* Fixed WhichOneof() to work with de-serialized protobuf messages.
|
||||
* Fixed a missing file problem of Python C++ implementation.
|
||||
|
||||
2014-08-15 version 2.6.0:
|
||||
|
||||
General
|
||||
* Added oneofs(unions) feature. Fields in the same oneof will share
|
||||
memory and at most one field can be set at the same time. Use the
|
||||
oneof keyword to define a oneof like:
|
||||
message SampleMessage {
|
||||
oneof test_oneof {
|
||||
string name = 4;
|
||||
YourMessage sub_message = 9;
|
||||
}
|
||||
}
|
||||
* Files, services, enums, messages, methods and enum values can be marked
|
||||
as deprecated now.
|
||||
* Added Support for list values, including lists of messages, when
|
||||
parsing text-formatted protos in C++ and Java.
|
||||
For example: foo: [1, 2, 3]
|
||||
|
||||
C++
|
||||
* Enhanced customization on TestFormat printing.
|
||||
* Added SwapFields() in reflection API to swap a subset of fields.
|
||||
Added SetAllocatedMessage() in reflection API.
|
||||
* Repeated primitive extensions are now packable. The
|
||||
[packed=true] option only affects serializers. Therefore, it is
|
||||
possible to switch a repeated extension field to packed format
|
||||
without breaking backwards-compatibility.
|
||||
* Various speed optimizations.
|
||||
|
||||
Java
|
||||
* writeTo() method in ByteString can now write a substring to an
|
||||
output stream. Added endWith() method for ByteString.
|
||||
* ByteString and ByteBuffer are now supported in CodedInputStream
|
||||
and CodedOutputStream.
|
||||
* java_generate_equals_and_hash can now be used with the LITE_RUNTIME.
|
||||
|
||||
Python
|
||||
* A new C++-backed extension module (aka "cpp api v2") that replaces the
|
||||
old ("cpp api v1") one. Much faster than the pure Python code. This one
|
||||
resolves many bugs and is recommended for general use over the
|
||||
pure Python when possible.
|
||||
* Descriptors now have enum_types_by_name and extension_types_by_name dict
|
||||
attributes.
|
||||
* Support for Python 3.
|
||||
|
||||
2013-02-27 version 2.5.0:
|
||||
|
||||
General
|
||||
* New notion "import public" that allows a proto file to forward the content
|
||||
|
@ -17,6 +668,9 @@
|
|||
be assigned the same numeric value. Default value is "true". Setting it to
|
||||
false causes the compiler to reject enum definitions where multiple symbols
|
||||
have the same numeric value.
|
||||
Note: We plan to flip the default value to "false" in a future release.
|
||||
Projects using enum aliases should set the option to "true" in their .proto
|
||||
files.
|
||||
|
||||
C++
|
||||
* New generated method set_allocated_foo(Type* foo) for message and string
|
||||
|
@ -32,7 +686,7 @@
|
|||
comments for corresponding classes and data members.
|
||||
* Added Parser to parse directly into messages without a Builder. For
|
||||
example,
|
||||
Foo foo = Foo.getParser().ParseFrom(input);
|
||||
Foo foo = Foo.PARSER.ParseFrom(input);
|
||||
Using Parser is ~25% faster than using Builder to parse messages.
|
||||
* Added getters/setters to access the underlying ByteString of a string field
|
||||
directly.
|
||||
|
@ -45,7 +699,7 @@
|
|||
|
||||
Python
|
||||
* Added support for dynamic message creation. DescriptorDatabase,
|
||||
DescriptorPool, and MessageFactory work like their C++ couterparts to
|
||||
DescriptorPool, and MessageFactory work like their C++ counterparts to
|
||||
simplify Descriptor construction from *DescriptorProtos, and MessageFactory
|
||||
provides a message instance from a Descriptor.
|
||||
* Added pickle support for protobuf messages.
|
||||
|
@ -59,7 +713,7 @@
|
|||
2011-05-01 version 2.4.1:
|
||||
|
||||
C++
|
||||
* Fixed the frendship problem for old compilers to make the library now gcc 3
|
||||
* Fixed the friendship problem for old compilers to make the library now gcc 3
|
||||
compatible again.
|
||||
* Fixed vcprojects/extract_includes.bat to extract compiler/plugin.h.
|
||||
|
||||
|
@ -326,7 +980,7 @@
|
|||
* Fixed tendency for TextFormat's parsing to overflow the stack when
|
||||
parsing large string values. The underlying problem is with Java's
|
||||
regex implementation (which unfortunately uses recursive backtracking
|
||||
rather than building an NFA). Worked around by making use of possesive
|
||||
rather than building an NFA). Worked around by making use of possessive
|
||||
quantifiers.
|
||||
* Generated service classes now also generate pure interfaces. For a service
|
||||
Foo, Foo.Interface is a pure interface containing all of the service's
|
||||
|
@ -340,7 +994,7 @@
|
|||
RPC implementations will have to implement the new interfaces in order to
|
||||
support blocking mode.
|
||||
* New I/O methods parseDelimitedFrom(), mergeDelimitedFrom(), and
|
||||
writeDelimitedTo() read and write "delemited" messages from/to a stream,
|
||||
writeDelimitedTo() read and write "delimited" messages from/to a stream,
|
||||
meaning that the message size precedes the data. This way, you can write
|
||||
multiple messages to a stream without having to worry about delimiting
|
||||
them yourself.
|
||||
|
|
|
@ -17,6 +17,12 @@ Proto2 Python primary authors:
|
|||
Will Robinson <robinson@google.com>
|
||||
Petar Petrov <petar@google.com>
|
||||
|
||||
Java Nano primary authors:
|
||||
Brian Duff <bduff@google.com>
|
||||
Tom Chao <chaot@google.com>
|
||||
Max Cai <maxtroy@google.com>
|
||||
Ulas Kirazci <ulas@google.com>
|
||||
|
||||
Large code contributions:
|
||||
Jason Hsueh <jasonh@google.com>
|
||||
Joseph Schorr <jschorr@google.com>
|
||||
|
@ -50,7 +56,7 @@ Patch contributors:
|
|||
text format.
|
||||
Brian Atkinson <nairb774@gmail.com>
|
||||
* Added @Override annotation to generated Java code where appropriate.
|
||||
Vincent Choinière <Choiniere.Vincent@hydro.qc.ca>
|
||||
Vincent Choinière <Choiniere.Vincent@hydro.qc.ca>
|
||||
* Tru64 support.
|
||||
Monty Taylor <monty.taylor@gmail.com>
|
||||
* Solaris 10 + Sun Studio fixes.
|
||||
|
@ -86,3 +92,11 @@ Patch contributors:
|
|||
* Fix bug with permanent callbacks that delete themselves when run.
|
||||
Michael Kucharski <m.kucharski@gmail.com>
|
||||
* Added CodedInputStream.getTotalBytesRead().
|
||||
Kacper Kowalik <xarthisius.kk@gmail.com>
|
||||
* Fixed m4/acx_pthread.m4 problem for some Linux distributions.
|
||||
William Orr <will@worrbase.com>
|
||||
* Fixed detection of sched_yield on Solaris.
|
||||
* Added atomicops for Solaris
|
||||
Andrew Paprocki <andrew@ishiboo.com>
|
||||
* Fixed minor IBM xlC compiler build issues
|
||||
* Added atomicops for AIX (POWER)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
skip_child_includes = [
|
||||
'objectivec',
|
||||
]
|
|
@ -0,0 +1,42 @@
|
|||
This license applies to all parts of Protocol Buffers except the following:
|
||||
|
||||
- Atomicops support for generic gcc, located in
|
||||
src/google/protobuf/stubs/atomicops_internals_generic_gcc.h.
|
||||
This file is copyrighted by Red Hat Inc.
|
||||
|
||||
- Atomicops support for AIX/POWER, located in
|
||||
src/google/protobuf/stubs/atomicops_internals_power.h.
|
||||
This file is copyrighted by Bloomberg Finance LP.
|
||||
|
||||
Copyright 2014, Google Inc. All rights reserved.
|
||||
|
||||
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.
|
||||
|
||||
Code generated by the Protocol Buffer compiler is owned by the owner
|
||||
of the input file used when generating it. This code is not
|
||||
standalone and requires a support library to be linked with it. This
|
||||
support library is itself covered by the above license.
|
|
@ -0,0 +1,769 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
|
||||
# Build . before src so that our all-local and clean-local hooks kicks in at
|
||||
# the right time.
|
||||
SUBDIRS = . src
|
||||
|
||||
# Always include gmock in distributions.
|
||||
DIST_SUBDIRS = $(subdirs) src conformance benchmarks
|
||||
|
||||
# Build gmock before we build protobuf tests. We don't add gmock to SUBDIRS
|
||||
# because then "make check" would also build and run all of gmock's own tests,
|
||||
# which takes a lot of time and is generally not useful to us. Also, we don't
|
||||
# want "make install" to recurse into gmock since we don't want to overwrite
|
||||
# the installed version of gmock if there is one.
|
||||
check-local:
|
||||
@echo "Making lib/libgmock.a lib/libgmock_main.a in gmock"
|
||||
@cd gmock && $(MAKE) $(AM_MAKEFLAGS) lib/libgmock.la lib/libgmock_main.la
|
||||
@cd gmock/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la
|
||||
|
||||
# We would like to clean gmock when "make clean" is invoked. But we have to
|
||||
# be careful because clean-local is also invoked during "make distclean", but
|
||||
# "make distclean" already recurses into gmock because it's listed among the
|
||||
# DIST_SUBDIRS. distclean will delete gmock/Makefile, so if we then try to
|
||||
# cd to the directory again and "make clean" it will fail. So, check that the
|
||||
# Makefile exists before recursing.
|
||||
clean-local:
|
||||
@if test -e gmock/Makefile; then \
|
||||
echo "Making clean in gmock"; \
|
||||
cd gmock && $(MAKE) $(AM_MAKEFLAGS) clean; \
|
||||
fi; \
|
||||
if test -e conformance/Makefile; then \
|
||||
echo "Making clean in conformance"; \
|
||||
cd conformance && $(MAKE) $(AM_MAKEFLAGS) clean; \
|
||||
fi; \
|
||||
if test -e benchmarks/Makefile; then \
|
||||
echo "Making clean in benchmarks"; \
|
||||
cd benchmarks && $(MAKE) $(AM_MAKEFLAGS) clean; \
|
||||
fi; \
|
||||
if test -e objectivec/DevTools; then \
|
||||
echo "Cleaning any ObjC pyc files"; \
|
||||
rm -f objectivec/DevTools/*.pyc; \
|
||||
fi
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = protobuf.pc protobuf-lite.pc
|
||||
|
||||
csharp_EXTRA_DIST= \
|
||||
csharp/.gitignore \
|
||||
csharp/CHANGES.txt \
|
||||
csharp/README.md \
|
||||
csharp/build_packages.bat \
|
||||
csharp/buildall.sh \
|
||||
csharp/generate_protos.sh \
|
||||
csharp/keys/Google.Protobuf.public.snk \
|
||||
csharp/keys/README.md \
|
||||
csharp/protos/unittest_issues.proto \
|
||||
csharp/src/AddressBook/AddPerson.cs \
|
||||
csharp/src/AddressBook/AddressBook.csproj \
|
||||
csharp/src/AddressBook/Addressbook.cs \
|
||||
csharp/src/AddressBook/ListPeople.cs \
|
||||
csharp/src/AddressBook/Program.cs \
|
||||
csharp/src/AddressBook/Properties/AssemblyInfo.cs \
|
||||
csharp/src/AddressBook/SampleUsage.cs \
|
||||
csharp/src/AddressBook/app.config \
|
||||
csharp/src/Google.Protobuf.Conformance/App.config \
|
||||
csharp/src/Google.Protobuf.Conformance/Conformance.cs \
|
||||
csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj \
|
||||
csharp/src/Google.Protobuf.Conformance/Program.cs \
|
||||
csharp/src/Google.Protobuf.Conformance/Properties/AssemblyInfo.cs \
|
||||
csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj \
|
||||
csharp/src/Google.Protobuf.JsonDump/Program.cs \
|
||||
csharp/src/Google.Protobuf.JsonDump/Properties/AssemblyInfo.cs \
|
||||
csharp/src/Google.Protobuf.JsonDump/app.config \
|
||||
csharp/src/Google.Protobuf.Test/ByteStringTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs \
|
||||
csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/Compatibility/PropertyInfoExtensionsTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/EqualityTester.cs \
|
||||
csharp/src/Google.Protobuf.Test/FieldCodecTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj \
|
||||
csharp/src/Google.Protobuf.Test/IssuesTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/JsonParserTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/Properties/AppManifest.xml \
|
||||
csharp/src/Google.Protobuf.Test/Properties/AssemblyInfo.cs \
|
||||
csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/Reflection/TypeRegistryTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/SampleEnum.cs \
|
||||
csharp/src/Google.Protobuf.Test/SampleMessages.cs \
|
||||
csharp/src/Google.Protobuf.Test/TestCornerCases.cs \
|
||||
csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs \
|
||||
csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs \
|
||||
csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs \
|
||||
csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs \
|
||||
csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs \
|
||||
csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs \
|
||||
csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs \
|
||||
csharp/src/Google.Protobuf.Test/packages.config \
|
||||
csharp/src/Google.Protobuf.sln \
|
||||
csharp/src/Google.Protobuf/ByteArray.cs \
|
||||
csharp/src/Google.Protobuf/ByteString.cs \
|
||||
csharp/src/Google.Protobuf/CodedInputStream.cs \
|
||||
csharp/src/Google.Protobuf/CodedOutputStream.ComputeSize.cs \
|
||||
csharp/src/Google.Protobuf/CodedOutputStream.cs \
|
||||
csharp/src/Google.Protobuf/Collections/MapField.cs \
|
||||
csharp/src/Google.Protobuf/Collections/ReadOnlyDictionary.cs \
|
||||
csharp/src/Google.Protobuf/Collections/RepeatedField.cs \
|
||||
csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs \
|
||||
csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs \
|
||||
csharp/src/Google.Protobuf/FieldCodec.cs \
|
||||
csharp/src/Google.Protobuf/FrameworkPortability.cs \
|
||||
csharp/src/Google.Protobuf/Google.Protobuf.csproj \
|
||||
csharp/src/Google.Protobuf/Google.Protobuf.nuspec \
|
||||
csharp/src/Google.Protobuf/IDeepCloneable.cs \
|
||||
csharp/src/Google.Protobuf/IMessage.cs \
|
||||
csharp/src/Google.Protobuf/InvalidJsonException.cs \
|
||||
csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs \
|
||||
csharp/src/Google.Protobuf/JsonFormatter.cs \
|
||||
csharp/src/Google.Protobuf/JsonParser.cs \
|
||||
csharp/src/Google.Protobuf/JsonToken.cs \
|
||||
csharp/src/Google.Protobuf/JsonTokenizer.cs \
|
||||
csharp/src/Google.Protobuf/LimitedInputStream.cs \
|
||||
csharp/src/Google.Protobuf/MessageExtensions.cs \
|
||||
csharp/src/Google.Protobuf/MessageParser.cs \
|
||||
csharp/src/Google.Protobuf/ProtoPreconditions.cs \
|
||||
csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/Descriptor.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/DescriptorBase.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/DescriptorPool.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/DescriptorUtil.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/DescriptorValidationException.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/FieldType.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/GeneratedClrTypeInfo.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/IDescriptor.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/IFieldAccessor.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/MapFieldAccessor.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/OriginalNameAttribute.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/PackageDescriptor.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/PartialClasses.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs \
|
||||
csharp/src/Google.Protobuf/Reflection/TypeRegistry.cs \
|
||||
csharp/src/Google.Protobuf/WellKnownTypes/Any.cs \
|
||||
csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs \
|
||||
csharp/src/Google.Protobuf/WellKnownTypes/Api.cs \
|
||||
csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs \
|
||||
csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs \
|
||||
csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs \
|
||||
csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs \
|
||||
csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs \
|
||||
csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs \
|
||||
csharp/src/Google.Protobuf/WellKnownTypes/TimeExtensions.cs \
|
||||
csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs \
|
||||
csharp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs \
|
||||
csharp/src/Google.Protobuf/WellKnownTypes/Type.cs \
|
||||
csharp/src/Google.Protobuf/WellKnownTypes/ValuePartial.cs \
|
||||
csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs \
|
||||
csharp/src/Google.Protobuf/WellKnownTypes/WrappersPartial.cs \
|
||||
csharp/src/Google.Protobuf/WireFormat.cs \
|
||||
csharp/src/Google.Protobuf/packages.config \
|
||||
csharp/src/packages/repositories.config
|
||||
|
||||
java_EXTRA_DIST= \
|
||||
java/README.md \
|
||||
java/core/generate-sources-build.xml \
|
||||
java/core/generate-test-sources-build.xml \
|
||||
java/core/pom.xml \
|
||||
java/core/src/main/java/com/google/protobuf/AbstractMessage.java \
|
||||
java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java \
|
||||
java/core/src/main/java/com/google/protobuf/AbstractParser.java \
|
||||
java/core/src/main/java/com/google/protobuf/AbstractProtobufList.java \
|
||||
java/core/src/main/java/com/google/protobuf/BlockingRpcChannel.java \
|
||||
java/core/src/main/java/com/google/protobuf/BlockingService.java \
|
||||
java/core/src/main/java/com/google/protobuf/BooleanArrayList.java \
|
||||
java/core/src/main/java/com/google/protobuf/ByteBufferWriter.java \
|
||||
java/core/src/main/java/com/google/protobuf/ByteOutput.java \
|
||||
java/core/src/main/java/com/google/protobuf/ByteString.java \
|
||||
java/core/src/main/java/com/google/protobuf/CodedInputStream.java \
|
||||
java/core/src/main/java/com/google/protobuf/CodedOutputStream.java \
|
||||
java/core/src/main/java/com/google/protobuf/Descriptors.java \
|
||||
java/core/src/main/java/com/google/protobuf/DoubleArrayList.java \
|
||||
java/core/src/main/java/com/google/protobuf/DynamicMessage.java \
|
||||
java/core/src/main/java/com/google/protobuf/Extension.java \
|
||||
java/core/src/main/java/com/google/protobuf/ExtensionLite.java \
|
||||
java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java \
|
||||
java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java \
|
||||
java/core/src/main/java/com/google/protobuf/FieldSet.java \
|
||||
java/core/src/main/java/com/google/protobuf/FloatArrayList.java \
|
||||
java/core/src/main/java/com/google/protobuf/GeneratedMessage.java \
|
||||
java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java \
|
||||
java/core/src/main/java/com/google/protobuf/IntArrayList.java \
|
||||
java/core/src/main/java/com/google/protobuf/Internal.java \
|
||||
java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java \
|
||||
java/core/src/main/java/com/google/protobuf/LazyField.java \
|
||||
java/core/src/main/java/com/google/protobuf/LazyFieldLite.java \
|
||||
java/core/src/main/java/com/google/protobuf/LazyStringArrayList.java \
|
||||
java/core/src/main/java/com/google/protobuf/LazyStringList.java \
|
||||
java/core/src/main/java/com/google/protobuf/LongArrayList.java \
|
||||
java/core/src/main/java/com/google/protobuf/MapEntry.java \
|
||||
java/core/src/main/java/com/google/protobuf/MapEntryLite.java \
|
||||
java/core/src/main/java/com/google/protobuf/MapField.java \
|
||||
java/core/src/main/java/com/google/protobuf/MapFieldLite.java \
|
||||
java/core/src/main/java/com/google/protobuf/Message.java \
|
||||
java/core/src/main/java/com/google/protobuf/MessageLite.java \
|
||||
java/core/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java \
|
||||
java/core/src/main/java/com/google/protobuf/MessageLiteToString.java \
|
||||
java/core/src/main/java/com/google/protobuf/MessageOrBuilder.java \
|
||||
java/core/src/main/java/com/google/protobuf/MessageReflection.java \
|
||||
java/core/src/main/java/com/google/protobuf/MutabilityOracle.java \
|
||||
java/core/src/main/java/com/google/protobuf/NioByteString.java \
|
||||
java/core/src/main/java/com/google/protobuf/Parser.java \
|
||||
java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java \
|
||||
java/core/src/main/java/com/google/protobuf/ProtocolMessageEnum.java \
|
||||
java/core/src/main/java/com/google/protobuf/ProtocolStringList.java \
|
||||
java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java \
|
||||
java/core/src/main/java/com/google/protobuf/RopeByteString.java \
|
||||
java/core/src/main/java/com/google/protobuf/RpcCallback.java \
|
||||
java/core/src/main/java/com/google/protobuf/RpcChannel.java \
|
||||
java/core/src/main/java/com/google/protobuf/RpcController.java \
|
||||
java/core/src/main/java/com/google/protobuf/RpcUtil.java \
|
||||
java/core/src/main/java/com/google/protobuf/Service.java \
|
||||
java/core/src/main/java/com/google/protobuf/ServiceException.java \
|
||||
java/core/src/main/java/com/google/protobuf/SingleFieldBuilder.java \
|
||||
java/core/src/main/java/com/google/protobuf/SmallSortedMap.java \
|
||||
java/core/src/main/java/com/google/protobuf/TextFormat.java \
|
||||
java/core/src/main/java/com/google/protobuf/TextFormatEscaper.java \
|
||||
java/core/src/main/java/com/google/protobuf/TextFormatParseInfoTree.java \
|
||||
java/core/src/main/java/com/google/protobuf/TextFormatParseLocation.java \
|
||||
java/core/src/main/java/com/google/protobuf/UninitializedMessageException.java \
|
||||
java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java \
|
||||
java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java \
|
||||
java/core/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java \
|
||||
java/core/src/main/java/com/google/protobuf/UnsafeByteOperations.java \
|
||||
java/core/src/main/java/com/google/protobuf/Utf8.java \
|
||||
java/core/src/main/java/com/google/protobuf/WireFormat.java \
|
||||
java/core/src/test/java/com/google/protobuf/AbstractMessageTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/AnyTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/BooleanArrayListTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/BoundedByteStringTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/ByteBufferWriterTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/ByteStringTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/CheckUtf8Test.java \
|
||||
java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/CodedOutputStreamTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/DeprecatedFieldTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/DescriptorsTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/DoubleArrayListTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/DynamicMessageTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/EnumTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/FloatArrayListTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java \
|
||||
java/core/src/test/java/com/google/protobuf/GeneratedMessageTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/IntArrayListTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/IsValidUtf8Test.java \
|
||||
java/core/src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java \
|
||||
java/core/src/test/java/com/google/protobuf/LazyFieldLiteTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/LazyFieldTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/LazyMessageLiteTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/LazyStringArrayListTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/LiteEqualsAndHashTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/LiteTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/LiteralByteStringTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/LongArrayListTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/MapForProto2Test.java \
|
||||
java/core/src/test/java/com/google/protobuf/MapTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/MessageTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/NestedBuildersTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/NioByteStringTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/ParserTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/ProtobufArrayListTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/RepeatedFieldBuilderTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/RopeByteStringTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/ServiceTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/SingleFieldBuilderTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/SmallSortedMapTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/TestBadIdentifiers.java \
|
||||
java/core/src/test/java/com/google/protobuf/TestUtil.java \
|
||||
java/core/src/test/java/com/google/protobuf/TextFormatParseInfoTreeTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/TextFormatParseLocationTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/TextFormatTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/UnknownEnumValueTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/UnknownFieldSetTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/WellKnownTypesTest.java \
|
||||
java/core/src/test/java/com/google/protobuf/WireFormatTest.java \
|
||||
java/core/src/test/proto/com/google/protobuf/any_test.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/field_presence_test.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/lazy_fields_lite.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/lite_equals_and_hash.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/map_for_proto2_test.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/map_initialization_order_test.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/map_test.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/multiple_files_test.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/nested_builders_test.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/nested_extension.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/nested_extension_lite.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/non_nested_extension.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/non_nested_extension_lite.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/outer_class_name_test.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/outer_class_name_test2.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/outer_class_name_test3.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/test_bad_identifiers.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/test_check_utf8.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/test_check_utf8_size.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/test_custom_options.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/test_extra_interfaces.proto \
|
||||
java/lite/pom.xml \
|
||||
java/pom.xml \
|
||||
java/util/pom.xml \
|
||||
java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java \
|
||||
java/util/src/main/java/com/google/protobuf/util/FieldMaskUtil.java \
|
||||
java/util/src/main/java/com/google/protobuf/util/JsonFormat.java \
|
||||
java/util/src/main/java/com/google/protobuf/util/TimeUtil.java \
|
||||
java/util/src/test/java/com/google/protobuf/util/FieldMaskTreeTest.java \
|
||||
java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java \
|
||||
java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java \
|
||||
java/util/src/test/java/com/google/protobuf/util/TimeUtilTest.java \
|
||||
java/util/src/test/proto/com/google/protobuf/util/json_test.proto
|
||||
|
||||
javanano_EXTRA_DIST= \
|
||||
javanano/src/main/java/com/google/protobuf/nano/CodedOutputByteBufferNano.java \
|
||||
javanano/src/main/java/com/google/protobuf/nano/FieldData.java \
|
||||
javanano/src/main/java/com/google/protobuf/nano/FieldArray.java \
|
||||
javanano/src/main/java/com/google/protobuf/nano/WireFormatNano.java \
|
||||
javanano/src/main/java/com/google/protobuf/nano/Extension.java \
|
||||
javanano/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java \
|
||||
javanano/src/main/java/com/google/protobuf/nano/UnknownFieldData.java \
|
||||
javanano/src/main/java/com/google/protobuf/nano/MessageNano.java \
|
||||
javanano/src/main/java/com/google/protobuf/nano/InternalNano.java \
|
||||
javanano/src/main/java/com/google/protobuf/nano/InvalidProtocolBufferNanoException.java \
|
||||
javanano/src/main/java/com/google/protobuf/nano/MapFactories.java \
|
||||
javanano/src/main/java/com/google/protobuf/nano/ExtendableMessageNano.java \
|
||||
javanano/src/main/java/com/google/protobuf/nano/MessageNanoPrinter.java \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_accessors_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_enum_class_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_reference_types_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_extension_repeated_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_has_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_multiple_nameclash_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_single_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/NanoTest.java \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_simple_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_import_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_repeated_merge_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_extension_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_repeated_packables_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_extension_singular_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_recursive_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_extension_packed_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_enum_validity_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_stringutf8_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_multiple_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/unittest_enum_class_multiple_nano.proto \
|
||||
javanano/src/test/java/com/google/protobuf/nano/map_test.proto \
|
||||
javanano/README.md \
|
||||
javanano/pom.xml
|
||||
|
||||
objectivec_EXTRA_DIST= \
|
||||
objectivec/DevTools/check_version_stamps.sh \
|
||||
objectivec/DevTools/compile_testing_protos.sh \
|
||||
objectivec/DevTools/full_mac_build.sh \
|
||||
objectivec/DevTools/pddm.py \
|
||||
objectivec/DevTools/pddm_tests.py \
|
||||
objectivec/generate_well_known_types.sh \
|
||||
objectivec/google/protobuf/Any.pbobjc.h \
|
||||
objectivec/google/protobuf/Any.pbobjc.m \
|
||||
objectivec/google/protobuf/Api.pbobjc.h \
|
||||
objectivec/google/protobuf/Api.pbobjc.m \
|
||||
objectivec/google/protobuf/Duration.pbobjc.h \
|
||||
objectivec/google/protobuf/Duration.pbobjc.m \
|
||||
objectivec/google/protobuf/Empty.pbobjc.h \
|
||||
objectivec/google/protobuf/Empty.pbobjc.m \
|
||||
objectivec/google/protobuf/FieldMask.pbobjc.h \
|
||||
objectivec/google/protobuf/FieldMask.pbobjc.m \
|
||||
objectivec/google/protobuf/SourceContext.pbobjc.h \
|
||||
objectivec/google/protobuf/SourceContext.pbobjc.m \
|
||||
objectivec/google/protobuf/Struct.pbobjc.h \
|
||||
objectivec/google/protobuf/Struct.pbobjc.m \
|
||||
objectivec/google/protobuf/Timestamp.pbobjc.h \
|
||||
objectivec/google/protobuf/Timestamp.pbobjc.m \
|
||||
objectivec/google/protobuf/Type.pbobjc.h \
|
||||
objectivec/google/protobuf/Type.pbobjc.m \
|
||||
objectivec/google/protobuf/Wrappers.pbobjc.h \
|
||||
objectivec/google/protobuf/Wrappers.pbobjc.m \
|
||||
objectivec/GPBArray.h \
|
||||
objectivec/GPBArray.m \
|
||||
objectivec/GPBArray_PackagePrivate.h \
|
||||
objectivec/GPBBootstrap.h \
|
||||
objectivec/GPBCodedInputStream.h \
|
||||
objectivec/GPBCodedInputStream.m \
|
||||
objectivec/GPBCodedInputStream_PackagePrivate.h \
|
||||
objectivec/GPBCodedOutputStream.h \
|
||||
objectivec/GPBCodedOutputStream.m \
|
||||
objectivec/GPBCodedOutputStream_PackagePrivate.h \
|
||||
objectivec/GPBDescriptor.h \
|
||||
objectivec/GPBDescriptor.m \
|
||||
objectivec/GPBDescriptor_PackagePrivate.h \
|
||||
objectivec/GPBDictionary.h \
|
||||
objectivec/GPBDictionary.m \
|
||||
objectivec/GPBDictionary_PackagePrivate.h \
|
||||
objectivec/GPBExtensionInternals.h \
|
||||
objectivec/GPBExtensionInternals.m \
|
||||
objectivec/GPBExtensionRegistry.h \
|
||||
objectivec/GPBExtensionRegistry.m \
|
||||
objectivec/GPBMessage.h \
|
||||
objectivec/GPBMessage.m \
|
||||
objectivec/GPBMessage_PackagePrivate.h \
|
||||
objectivec/GPBProtocolBuffers.h \
|
||||
objectivec/GPBProtocolBuffers.m \
|
||||
objectivec/GPBProtocolBuffers_RuntimeSupport.h \
|
||||
objectivec/GPBRootObject.h \
|
||||
objectivec/GPBRootObject.m \
|
||||
objectivec/GPBRootObject_PackagePrivate.h \
|
||||
objectivec/GPBRuntimeTypes.h \
|
||||
objectivec/GPBUnknownField.h \
|
||||
objectivec/GPBUnknownField.m \
|
||||
objectivec/GPBUnknownField_PackagePrivate.h \
|
||||
objectivec/GPBUnknownFieldSet.h \
|
||||
objectivec/GPBUnknownFieldSet.m \
|
||||
objectivec/GPBUnknownFieldSet_PackagePrivate.h \
|
||||
objectivec/GPBUtilities.h \
|
||||
objectivec/GPBUtilities.m \
|
||||
objectivec/GPBUtilities_PackagePrivate.h \
|
||||
objectivec/GPBWellKnownTypes.h \
|
||||
objectivec/GPBWellKnownTypes.m \
|
||||
objectivec/GPBWireFormat.h \
|
||||
objectivec/GPBWireFormat.m \
|
||||
objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj \
|
||||
objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/contents.xcworkspacedata \
|
||||
objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings \
|
||||
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcbaselines/8BBEA4A5147C727100C4ADB7.xcbaseline/FFE465CA-0E74-40E8-9F09-500B66B7DCB2.plist \
|
||||
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcbaselines/8BBEA4A5147C727100C4ADB7.xcbaseline/Info.plist \
|
||||
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme \
|
||||
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme \
|
||||
objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj \
|
||||
objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/contents.xcworkspacedata \
|
||||
objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings \
|
||||
objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme \
|
||||
objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme \
|
||||
objectivec/README.md \
|
||||
objectivec/Tests/golden_message \
|
||||
objectivec/Tests/golden_packed_fields_message \
|
||||
objectivec/Tests/GPBARCUnittestProtos.m \
|
||||
objectivec/Tests/GPBArrayTests.m \
|
||||
objectivec/Tests/GPBCodedInputStreamTests.m \
|
||||
objectivec/Tests/GPBCodedOuputStreamTests.m \
|
||||
objectivec/Tests/GPBConcurrencyTests.m \
|
||||
objectivec/Tests/GPBDescriptorTests.m \
|
||||
objectivec/Tests/GPBDictionaryTests+Bool.m \
|
||||
objectivec/Tests/GPBDictionaryTests+Int32.m \
|
||||
objectivec/Tests/GPBDictionaryTests+Int64.m \
|
||||
objectivec/Tests/GPBDictionaryTests+String.m \
|
||||
objectivec/Tests/GPBDictionaryTests+UInt32.m \
|
||||
objectivec/Tests/GPBDictionaryTests+UInt64.m \
|
||||
objectivec/Tests/GPBDictionaryTests.pddm \
|
||||
objectivec/Tests/GPBMessageTests+Merge.m \
|
||||
objectivec/Tests/GPBMessageTests+Runtime.m \
|
||||
objectivec/Tests/GPBMessageTests+Serialization.m \
|
||||
objectivec/Tests/GPBMessageTests.m \
|
||||
objectivec/Tests/GPBObjectiveCPlusPlusTest.mm \
|
||||
objectivec/Tests/GPBPerfTests.m \
|
||||
objectivec/Tests/GPBSwiftTests.swift \
|
||||
objectivec/Tests/GPBTestUtilities.h \
|
||||
objectivec/Tests/GPBTestUtilities.m \
|
||||
objectivec/Tests/GPBUnittestProtos.m \
|
||||
objectivec/Tests/GPBUnknownFieldSetTest.m \
|
||||
objectivec/Tests/GPBUtilitiesTests.m \
|
||||
objectivec/Tests/GPBWellKnownTypesTest.m \
|
||||
objectivec/Tests/GPBWireFormatTests.m \
|
||||
objectivec/Tests/iOSTestHarness/AppDelegate.m \
|
||||
objectivec/Tests/iOSTestHarness/en.lproj/InfoPlist.strings \
|
||||
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/Contents.json \
|
||||
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6.png \
|
||||
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6_2x.png \
|
||||
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7.png \
|
||||
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7_2x.png \
|
||||
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6.png \
|
||||
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6_2x.png \
|
||||
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_2x.png \
|
||||
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_3x.png \
|
||||
objectivec/Tests/iOSTestHarness/Images.xcassets/LaunchImage.launchimage/Contents.json \
|
||||
objectivec/Tests/iOSTestHarness/Info.plist \
|
||||
objectivec/Tests/iOSTestHarness/LaunchScreen.xib \
|
||||
objectivec/Tests/text_format_map_unittest_data.txt \
|
||||
objectivec/Tests/text_format_unittest_data.txt \
|
||||
objectivec/Tests/unittest_cycle.proto \
|
||||
objectivec/Tests/unittest_objc.proto \
|
||||
objectivec/Tests/unittest_objc_startup.proto \
|
||||
objectivec/Tests/unittest_runtime_proto2.proto \
|
||||
objectivec/Tests/unittest_runtime_proto3.proto \
|
||||
objectivec/Tests/UnitTests-Bridging-Header.h \
|
||||
objectivec/Tests/UnitTests-Info.plist \
|
||||
Protobuf.podspec
|
||||
|
||||
python_EXTRA_DIST= \
|
||||
python/MANIFEST.in \
|
||||
python/google/__init__.py \
|
||||
python/google/protobuf/__init__.py \
|
||||
python/google/protobuf/descriptor.py \
|
||||
python/google/protobuf/descriptor_database.py \
|
||||
python/google/protobuf/descriptor_pool.py \
|
||||
python/google/protobuf/internal/__init__.py \
|
||||
python/google/protobuf/internal/_parameterized.py \
|
||||
python/google/protobuf/internal/any_test.proto \
|
||||
python/google/protobuf/internal/any_test.proto \
|
||||
python/google/protobuf/internal/api_implementation.cc \
|
||||
python/google/protobuf/internal/api_implementation.py \
|
||||
python/google/protobuf/internal/containers.py \
|
||||
python/google/protobuf/internal/decoder.py \
|
||||
python/google/protobuf/internal/descriptor_database_test.py \
|
||||
python/google/protobuf/internal/descriptor_pool_test.py \
|
||||
python/google/protobuf/internal/descriptor_pool_test1.proto \
|
||||
python/google/protobuf/internal/descriptor_pool_test2.proto \
|
||||
python/google/protobuf/internal/descriptor_test.py \
|
||||
python/google/protobuf/internal/encoder.py \
|
||||
python/google/protobuf/internal/enum_type_wrapper.py \
|
||||
python/google/protobuf/internal/factory_test1.proto \
|
||||
python/google/protobuf/internal/factory_test2.proto \
|
||||
python/google/protobuf/internal/generator_test.py \
|
||||
python/google/protobuf/internal/import_test_package/__init__.py \
|
||||
python/google/protobuf/internal/import_test_package/inner.proto \
|
||||
python/google/protobuf/internal/import_test_package/outer.proto \
|
||||
python/google/protobuf/internal/json_format_test.py \
|
||||
python/google/protobuf/internal/message_factory_test.py \
|
||||
python/google/protobuf/internal/message_listener.py \
|
||||
python/google/protobuf/internal/message_set_extensions.proto \
|
||||
python/google/protobuf/internal/message_test.py \
|
||||
python/google/protobuf/internal/missing_enum_values.proto \
|
||||
python/google/protobuf/internal/more_extensions.proto \
|
||||
python/google/protobuf/internal/more_extensions_dynamic.proto \
|
||||
python/google/protobuf/internal/more_messages.proto \
|
||||
python/google/protobuf/internal/packed_field_test.proto \
|
||||
python/google/protobuf/internal/proto_builder_test.py \
|
||||
python/google/protobuf/internal/python_message.py \
|
||||
python/google/protobuf/internal/reflection_test.py \
|
||||
python/google/protobuf/internal/service_reflection_test.py \
|
||||
python/google/protobuf/internal/symbol_database_test.py \
|
||||
python/google/protobuf/internal/test_bad_identifiers.proto \
|
||||
python/google/protobuf/internal/test_util.py \
|
||||
python/google/protobuf/internal/text_encoding_test.py \
|
||||
python/google/protobuf/internal/text_format_test.py \
|
||||
python/google/protobuf/internal/type_checkers.py \
|
||||
python/google/protobuf/internal/unknown_fields_test.py \
|
||||
python/google/protobuf/internal/well_known_types.py \
|
||||
python/google/protobuf/internal/well_known_types.py \
|
||||
python/google/protobuf/internal/well_known_types_test.py \
|
||||
python/google/protobuf/internal/well_known_types_test.py \
|
||||
python/google/protobuf/internal/wire_format.py \
|
||||
python/google/protobuf/internal/wire_format_test.py \
|
||||
python/google/protobuf/json_format.py \
|
||||
python/google/protobuf/message.py \
|
||||
python/google/protobuf/message_factory.py \
|
||||
python/google/protobuf/proto_builder.py \
|
||||
python/google/protobuf/pyext/README \
|
||||
python/google/protobuf/pyext/__init__.py \
|
||||
python/google/protobuf/pyext/cpp_message.py \
|
||||
python/google/protobuf/pyext/descriptor.cc \
|
||||
python/google/protobuf/pyext/descriptor.h \
|
||||
python/google/protobuf/pyext/descriptor_containers.cc \
|
||||
python/google/protobuf/pyext/descriptor_containers.h \
|
||||
python/google/protobuf/pyext/descriptor_database.cc \
|
||||
python/google/protobuf/pyext/descriptor_database.h \
|
||||
python/google/protobuf/pyext/descriptor_pool.cc \
|
||||
python/google/protobuf/pyext/descriptor_pool.h \
|
||||
python/google/protobuf/pyext/extension_dict.cc \
|
||||
python/google/protobuf/pyext/extension_dict.h \
|
||||
python/google/protobuf/pyext/map_container.cc \
|
||||
python/google/protobuf/pyext/map_container.h \
|
||||
python/google/protobuf/pyext/message.cc \
|
||||
python/google/protobuf/pyext/message.h \
|
||||
python/google/protobuf/pyext/proto2_api_test.proto \
|
||||
python/google/protobuf/pyext/python.proto \
|
||||
python/google/protobuf/pyext/python_protobuf.h \
|
||||
python/google/protobuf/pyext/repeated_composite_container.cc \
|
||||
python/google/protobuf/pyext/repeated_composite_container.h \
|
||||
python/google/protobuf/pyext/repeated_scalar_container.cc \
|
||||
python/google/protobuf/pyext/repeated_scalar_container.h \
|
||||
python/google/protobuf/pyext/scoped_pyobject_ptr.h \
|
||||
python/google/protobuf/reflection.py \
|
||||
python/google/protobuf/service.py \
|
||||
python/google/protobuf/service_reflection.py \
|
||||
python/google/protobuf/symbol_database.py \
|
||||
python/google/protobuf/text_encoding.py \
|
||||
python/google/protobuf/text_format.py \
|
||||
python/mox.py \
|
||||
python/setup.py \
|
||||
python/stubout.py \
|
||||
python/tox.ini \
|
||||
python/README.md
|
||||
|
||||
ruby_EXTRA_DIST= \
|
||||
ruby/Gemfile \
|
||||
ruby/Gemfile.lock \
|
||||
ruby/.gitignore \
|
||||
ruby/README.md \
|
||||
ruby/Rakefile \
|
||||
ruby/ext/google/protobuf_c/defs.c \
|
||||
ruby/ext/google/protobuf_c/encode_decode.c \
|
||||
ruby/ext/google/protobuf_c/extconf.rb \
|
||||
ruby/ext/google/protobuf_c/map.c \
|
||||
ruby/ext/google/protobuf_c/message.c \
|
||||
ruby/ext/google/protobuf_c/protobuf.c \
|
||||
ruby/ext/google/protobuf_c/protobuf.h \
|
||||
ruby/ext/google/protobuf_c/repeated_field.c \
|
||||
ruby/ext/google/protobuf_c/storage.c \
|
||||
ruby/ext/google/protobuf_c/upb.c \
|
||||
ruby/ext/google/protobuf_c/upb.h \
|
||||
ruby/google-protobuf.gemspec \
|
||||
ruby/lib/google/protobuf/message_exts.rb \
|
||||
ruby/lib/google/protobuf/repeated_field.rb \
|
||||
ruby/lib/google/protobuf.rb \
|
||||
ruby/pom.xml \
|
||||
ruby/src/main/java/com/google/protobuf/jruby/RubyBuilder.java \
|
||||
ruby/src/main/java/com/google/protobuf/jruby/RubyDescriptor.java \
|
||||
ruby/src/main/java/com/google/protobuf/jruby/RubyDescriptorPool.java \
|
||||
ruby/src/main/java/com/google/protobuf/jruby/RubyEnumBuilderContext.java \
|
||||
ruby/src/main/java/com/google/protobuf/jruby/RubyEnumDescriptor.java \
|
||||
ruby/src/main/java/com/google/protobuf/jruby/RubyEnum.java \
|
||||
ruby/src/main/java/com/google/protobuf/jruby/RubyFieldDescriptor.java \
|
||||
ruby/src/main/java/com/google/protobuf/jruby/RubyMap.java \
|
||||
ruby/src/main/java/com/google/protobuf/jruby/RubyMessageBuilderContext.java \
|
||||
ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java \
|
||||
ruby/src/main/java/com/google/protobuf/jruby/RubyOneofBuilderContext.java \
|
||||
ruby/src/main/java/com/google/protobuf/jruby/RubyOneofDescriptor.java \
|
||||
ruby/src/main/java/com/google/protobuf/jruby/RubyProtobuf.java \
|
||||
ruby/src/main/java/com/google/protobuf/jruby/RubyRepeatedField.java \
|
||||
ruby/src/main/java/com/google/protobuf/jruby/SentinelOuterClass.java \
|
||||
ruby/src/main/java/com/google/protobuf/jruby/Utils.java \
|
||||
ruby/src/main/java/google/ProtobufJavaService.java \
|
||||
ruby/src/main/sentinel.proto \
|
||||
ruby/tests/basic.rb \
|
||||
ruby/tests/repeated_field_test.rb \
|
||||
ruby/tests/stress.rb \
|
||||
ruby/tests/generated_code.proto \
|
||||
ruby/tests/generated_code_test.rb \
|
||||
ruby/travis-test.sh
|
||||
|
||||
js_EXTRA_DIST= \
|
||||
js/README.md \
|
||||
js/binary/arith.js \
|
||||
js/binary/arith_test.js \
|
||||
js/binary/constants.js \
|
||||
js/binary/decoder.js \
|
||||
js/binary/decoder_test.js \
|
||||
js/binary/proto_test.js \
|
||||
js/binary/reader.js \
|
||||
js/binary/reader_test.js \
|
||||
js/binary/utils.js \
|
||||
js/binary/utils_test.js \
|
||||
js/binary/writer.js \
|
||||
js/binary/writer_test.js \
|
||||
js/data.proto \
|
||||
js/debug.js \
|
||||
js/debug_test.js \
|
||||
js/gulpfile.js \
|
||||
js/jasmine.json \
|
||||
js/message.js \
|
||||
js/message_test.js \
|
||||
js/node_loader.js \
|
||||
js/package.json \
|
||||
js/proto3_test.js \
|
||||
js/proto3_test.proto \
|
||||
js/test.proto \
|
||||
js/test2.proto \
|
||||
js/test3.proto \
|
||||
js/test4.proto \
|
||||
js/test5.proto \
|
||||
js/test_bootstrap.js \
|
||||
js/testbinary.proto \
|
||||
js/testempty.proto
|
||||
|
||||
all_EXTRA_DIST=$(csharp_EXTRA_DIST) $(java_EXTRA_DIST) $(javanano_EXTRA_DIST) $(objectivec_EXTRA_DIST) $(python_EXTRA_DIST) $(ruby_EXTRA_DIST) $(js_EXTRA_DIST)
|
||||
|
||||
EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
|
||||
autogen.sh \
|
||||
generate_descriptor_proto.sh \
|
||||
README.md \
|
||||
LICENSE \
|
||||
CONTRIBUTORS.txt \
|
||||
CHANGES.txt \
|
||||
update_file_lists.sh \
|
||||
BUILD \
|
||||
gmock.BUILD \
|
||||
WORKSPACE \
|
||||
cmake/CMakeLists.txt \
|
||||
cmake/README.md \
|
||||
cmake/extract_includes.bat.in \
|
||||
cmake/install.cmake \
|
||||
cmake/libprotobuf.cmake \
|
||||
cmake/libprotobuf-lite.cmake \
|
||||
cmake/libprotoc.cmake \
|
||||
cmake/protobuf-config-version.cmake.in \
|
||||
cmake/protobuf-config.cmake.in \
|
||||
cmake/protobuf-module.cmake.in \
|
||||
cmake/protoc.cmake \
|
||||
cmake/tests.cmake \
|
||||
editors/README.txt \
|
||||
editors/proto.vim \
|
||||
editors/protobuf-mode.el \
|
||||
examples/README.txt \
|
||||
examples/Makefile \
|
||||
examples/addressbook.proto \
|
||||
examples/add_person.cc \
|
||||
examples/add_person.go \
|
||||
examples/add_person_test.go \
|
||||
examples/list_people.cc \
|
||||
examples/list_people.go \
|
||||
examples/AddPerson.java \
|
||||
examples/ListPeople.java \
|
||||
examples/add_person.py \
|
||||
examples/list_people.py \
|
||||
examples/list_people_test.go \
|
||||
protobuf.bzl \
|
||||
six.BUILD \
|
||||
util/python/BUILD
|
||||
|
||||
# Deletes all the files generated by autogen.sh.
|
||||
MAINTAINERCLEANFILES = \
|
||||
aclocal.m4 \
|
||||
ar-lib \
|
||||
config.guess \
|
||||
config.sub \
|
||||
configure \
|
||||
depcomp \
|
||||
install-sh \
|
||||
ltmain.sh \
|
||||
Makefile.in \
|
||||
missing \
|
||||
mkinstalldirs \
|
||||
config.h.in \
|
||||
stamp.h.in \
|
||||
m4/ltsugar.m4 \
|
||||
m4/libtool.m4 \
|
||||
m4/ltversion.m4 \
|
||||
m4/lt~obsolete.m4 \
|
||||
m4/ltoptions.m4
|
|
@ -0,0 +1,2 @@
|
|||
pkasting@chromium.org
|
||||
xyzzyz@chromium.org
|
|
@ -0,0 +1,40 @@
|
|||
# This file describes to Cocoapods how to integrate the Objective-C runtime into a dependent
|
||||
# project.
|
||||
# Despite this file being specific to Objective-C, it needs to be on the root of the repository.
|
||||
# Otherwise, Cocoapods gives trouble like not picking up the license file correctly, or not letting
|
||||
# dependent projects use the :git notation to refer to the library.
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'Protobuf'
|
||||
s.version = '3.0.0-beta-2'
|
||||
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
|
||||
s.homepage = 'https://github.com/google/protobuf'
|
||||
s.license = 'New BSD'
|
||||
s.authors = { 'The Protocol Buffers contributors' => 'protobuf@googlegroups.com' }
|
||||
|
||||
s.source = { :git => 'https://github.com/google/protobuf.git',
|
||||
:tag => "v#{s.version}" }
|
||||
|
||||
s.source_files = 'objectivec/*.{h,m}',
|
||||
'objectivec/google/protobuf/Any.pbobjc.{h,m}',
|
||||
'objectivec/google/protobuf/Api.pbobjc.{h,m}',
|
||||
'objectivec/google/protobuf/Duration.pbobjc.h',
|
||||
'objectivec/google/protobuf/Empty.pbobjc.{h,m}',
|
||||
'objectivec/google/protobuf/FieldMask.pbobjc.{h,m}',
|
||||
'objectivec/google/protobuf/SourceContext.pbobjc.{h,m}',
|
||||
'objectivec/google/protobuf/Struct.pbobjc.{h,m}',
|
||||
'objectivec/google/protobuf/Timestamp.pbobjc.h',
|
||||
'objectivec/google/protobuf/Type.pbobjc.{h,m}',
|
||||
'objectivec/google/protobuf/Wrappers.pbobjc.{h,m}'
|
||||
# Timestamp.pbobjc.m and Duration.pbobjc.m are #imported by GPBWellKnownTypes.m. So we can't
|
||||
# compile them (duplicate symbols), but we need them available for the importing:
|
||||
s.preserve_paths = 'objectivec/google/protobuf/Duration.pbobjc.m',
|
||||
'objectivec/google/protobuf/Timestamp.pbobjc.m'
|
||||
# The following would cause duplicate symbol definitions. GPBProtocolBuffers is expected to be
|
||||
# left out, as it's an umbrella implementation file.
|
||||
s.exclude_files = 'objectivec/GPBProtocolBuffers.m'
|
||||
s.header_mappings_dir = 'objectivec'
|
||||
|
||||
s.ios.deployment_target = '7.1'
|
||||
s.osx.deployment_target = '10.9'
|
||||
s.requires_arc = false
|
||||
end
|
|
@ -1,45 +1,90 @@
|
|||
Name: Protocol Buffers
|
||||
Short Name: protobuf
|
||||
URL: http://protobuf.googlecode.com/svn/trunk
|
||||
URL: https://github.com/google/protobuf
|
||||
License: BSD
|
||||
License File: COPYING.txt
|
||||
Version: unknown
|
||||
Revision: r476
|
||||
License File: LICENSE
|
||||
Version: 3.0.0-beta-3
|
||||
Revision: 3470b6895aa659b7559ed678e029a5338e535f14
|
||||
Security Critical: yes
|
||||
|
||||
Local files (not taken from upstream):
|
||||
README.chromium
|
||||
config.h
|
||||
descriptor2_pb.py
|
||||
protobuf_lite_java_descriptor_proto.py
|
||||
protobuf_lite_java_parse_pom.py
|
||||
Steps used to create the current version:
|
||||
1. Pull the release from https://github.com/google/protobuf/releases
|
||||
2. Add build files (BUILD.gn, proto_library.gni, protobuf.gyp,
|
||||
protobuf_lite.gypi, protobuf_nacl.gyp).
|
||||
|
||||
A protobuf.gyp file has been added for building with Chromium.
|
||||
Be sure to update the list of source files, as additional .cc files and
|
||||
headers might have been added -- you need to find the transitive closure of
|
||||
include files required by targets.
|
||||
|
||||
This code has been patched to support unknown field retention in protobuf-lite.
|
||||
See r62331 for the patch.
|
||||
Other things to care about are defines required by protobuf on various
|
||||
platforms, warnings generated by compilers, and new dependencies introduced.
|
||||
3. Get open-source library six.py from https://pypi.python.org/pypi/six/ and add
|
||||
it to protobuf/third_party/six/six.py.
|
||||
4. Apply patches in patches/ (see the description below):
|
||||
|
||||
This code has been patched to ensure that files in the target protobuf_lite
|
||||
do not include headers from protobuf_full. See r173228 for the patch.
|
||||
$ for patch in patches/*; do patch -s -p1 < $patch; done
|
||||
|
||||
This code has been patched to make the target protobuf_lite a component so that
|
||||
targets that depend on it can be componentized. See http://crbug.com/172800 for
|
||||
details, and r179806 for the patch.
|
||||
For future releases, it will be worth looking into which patches still need
|
||||
to be applied.
|
||||
5. Generate descriptor_pb2.py using something like the following steps. Make
|
||||
sure you've regenerated your buildfiles and will build protoc from the
|
||||
newly-modified sources above.
|
||||
|
||||
Revision 504 was cherry-picked from upstream.
|
||||
Revision 512 was cherry-picked from upstream.
|
||||
Revision 516 was cherry-picked from upstream.
|
||||
Revision 517 was cherry-picked from upstream.
|
||||
Revision 522 was cherry-picked from upstream.
|
||||
Revision 523 was cherry-picked from upstream.
|
||||
Revision 524 was cherry-picked from upstream.
|
||||
The `&file->options() != NULL &&` was removed from descriptor.cc
|
||||
$ cd $SRC_DIR
|
||||
$ ninja -C out/Debug protoc
|
||||
$ cd third_party/protobuf/src
|
||||
$ ../../../out/Debug/protoc --python_out=../python google/protobuf/descriptor.proto
|
||||
|
||||
Notes about Java:
|
||||
We have not forked the Java version of protobuf-lite, so the Java version does
|
||||
not support unknown field retention.
|
||||
6. Add an __init__.py to protobuf/ that adds third_party/six/ to Python path.
|
||||
7. Update README.chromium.
|
||||
|
||||
The list of Java files included in the lite profile for Java is parsed from the
|
||||
maven java/pom.xml by the script protobuf_lite_java_parse_pom.py. See
|
||||
'javac_includes' variable in protobuf_lite_javalib GYP target.
|
||||
Description of the patches:
|
||||
|
||||
- 0001-ignore-option-retain-unknown-fields.patch
|
||||
|
||||
Previous versions of protobuf in Chromium carried a local patch that retained
|
||||
unknown fields in protobuf_lite mode. It was enabled by setting option
|
||||
retain_unknown_fields = true in .proto file. Now that it is enabled by
|
||||
default, this option is no longer recognized by protobuf, and so I had to
|
||||
patch it so that I don't have to fix all .proto files in Chromium in a single
|
||||
CL.
|
||||
|
||||
I plan to remove those occurences, and then this patch will no longer be
|
||||
necessary.
|
||||
|
||||
- 0003-remove-static-initializers.patch
|
||||
|
||||
This patch removes all static initializers from Chromium. The change in Status
|
||||
class is not completely compatible with upstream, but it's compatible enough
|
||||
to work in Chromium, which doesn't use this functionality yet. The work on
|
||||
upstreaming the removal of static initializers is in progress:
|
||||
https://github.com/google/protobuf/issues/1404
|
||||
|
||||
- 0004-fix-integer-types-and-shared-library-exports.patch
|
||||
|
||||
This patch makes protobuf int64 to be int64_t (as opposed to long long in
|
||||
upstream), and similarly for other integer types. It also allows exporting
|
||||
protobuf symbols in Linux .so libraries, so that protobuf can be built as a
|
||||
component (see http://crrev.com/179806).
|
||||
|
||||
- 0005-fix-include-js-generator.protobuf
|
||||
|
||||
During merge with internal branch, the <> in one of the #includes were
|
||||
accidentally replaced with "", which results in a failure in checkdeps.
|
||||
|
||||
Fixed in https://github.com/google/protobuf/pull/1547.
|
||||
|
||||
- 0007-uninline_googleonce.patch
|
||||
- 0008-uninline_get_empty_string.patch
|
||||
- 0009-uninline-arenastring.patch
|
||||
- 0010-uninline-generated-code.patch
|
||||
|
||||
These patches uninline some functions, resulting in a significant reduction
|
||||
(somewhere between 500 KB and 1 MB) of binary size.
|
||||
|
||||
- 0011-libprotobuf_export.patch
|
||||
|
||||
During merge with internal branch, the dll export attribute was accidentally
|
||||
removed in C++11 mode.
|
||||
|
||||
Fixed in https://github.com/google/protobuf/pull/1549
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
Protocol Buffers - Google's data interchange format
|
||||
===================================================
|
||||
|
||||
[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf) [![Build status](https://ci.appveyor.com/api/projects/status/73ctee6ua4w2ruin?svg=true)](https://ci.appveyor.com/project/protobuf/protobuf)
|
||||
|
||||
Copyright 2008 Google Inc.
|
||||
|
||||
https://developers.google.com/protocol-buffers/
|
||||
|
||||
Overview
|
||||
--------
|
||||
|
||||
Protocol Buffers (a.k.a., protobuf) are Google's language-neutral,
|
||||
platform-neutral, extensible mechanism for serializing structured data. You
|
||||
can find [protobuf's documentation on the Google Developers site](https://developers.google.com/protocol-buffers/).
|
||||
|
||||
This README file contains protobuf installation instructions. To install
|
||||
protobuf, you need to install the protocol compiler (used to compile .proto
|
||||
files) and the protobuf runtime for your chosen programming language.
|
||||
|
||||
Protocol Compiler Installation
|
||||
------------------------------
|
||||
|
||||
The protocol compiler is written in C++. If you are using C++, please follow
|
||||
the [C++ Installation Instructions](src/README.md) to install protoc along
|
||||
with the C++ runtime.
|
||||
|
||||
For non-C++ users, the simplest way to install the protocol compiler is to
|
||||
download a pre-built binary from our release page:
|
||||
|
||||
[https://github.com/google/protobuf/releases](https://github.com/google/protobuf/releases)
|
||||
|
||||
In the downloads section of each release, you can find pre-built binaries in
|
||||
zip packages: protoc-$VERSION-$PLATFORM.zip. It contains the protoc binary
|
||||
as well as a set of standard .proto files distributed along with protobuf.
|
||||
|
||||
If you are looking for an old version that is not available in the release
|
||||
page, check out the maven repo here:
|
||||
|
||||
[http://repo1.maven.org/maven2/com/google/protobuf/protoc/](http://repo1.maven.org/maven2/com/google/protobuf/protoc/)
|
||||
|
||||
These pre-built binaries are only provided for released versions. If you want
|
||||
to use the github master version at HEAD, or you need to modify protobuf code,
|
||||
or you are using C++, it's recommended to build your own protoc binary from
|
||||
source.
|
||||
|
||||
If you would like to build protoc binary from source, see the [C++ Installation
|
||||
Instructions](src/README.md).
|
||||
|
||||
Protobuf Runtime Installation
|
||||
-----------------------------
|
||||
|
||||
Protobuf supports several different programming languages. For each programming
|
||||
language, you can find instructions in the corresponding source directory about
|
||||
how to install protobuf runtime for that specific language:
|
||||
|
||||
| Language | Source |
|
||||
|--------------------------------------|-------------------------------------------------------|
|
||||
| C++ (include C++ runtime and protoc) | [src](src) |
|
||||
| Java | [java](java) |
|
||||
| Python | [python](python) |
|
||||
| Objective-C | [objectivec](objectivec) |
|
||||
| C# | [csharp](csharp) |
|
||||
| JavaNano | [javanano](javanano) |
|
||||
| JavaScript | [js](js) |
|
||||
| Ruby | [ruby](ruby) |
|
||||
| Go | [golang/protobuf](https://github.com/golang/protobuf) |
|
||||
| PHP | TBD |
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
The complete documentation for Protocol Buffers is available via the
|
||||
web at:
|
||||
|
||||
https://developers.google.com/protocol-buffers/
|
|
@ -0,0 +1,53 @@
|
|||
new_http_archive(
|
||||
name = "gmock_archive",
|
||||
url = "https://googlemock.googlecode.com/files/gmock-1.7.0.zip",
|
||||
sha256 = "26fcbb5925b74ad5fc8c26b0495dfc96353f4d553492eb97e85a8a6d2f43095b",
|
||||
build_file = "gmock.BUILD",
|
||||
)
|
||||
|
||||
new_http_archive(
|
||||
name = "six_archive",
|
||||
url = "https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55",
|
||||
sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a",
|
||||
build_file = "six.BUILD",
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "python_headers",
|
||||
actual = "//util/python:python_headers",
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "gtest",
|
||||
actual = "@gmock_archive//:gtest",
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "gtest_main",
|
||||
actual = "@gmock_archive//:gtest_main",
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "six",
|
||||
actual = "@six_archive//:six",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "guava_maven",
|
||||
artifact = "com.google.guava:guava:18.0",
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "guava",
|
||||
actual = "@guava_maven//jar",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "gson_maven",
|
||||
artifact = "com.google.code.gson:gson:2.3",
|
||||
)
|
||||
|
||||
bind(
|
||||
name = "gson",
|
||||
actual = "@gson_maven//jar",
|
||||
)
|
|
@ -1,2 +1,6 @@
|
|||
import sys
|
||||
import os
|
||||
|
||||
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
sys.path.insert(0, os.path.join(THIS_DIR, "third_party", "six"))
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
setlocal
|
||||
|
||||
IF %language%==cpp GOTO build_cpp
|
||||
IF %language%==csharp GOTO build_csharp
|
||||
|
||||
echo Unsupported language %language%. Exiting.
|
||||
goto :error
|
||||
|
||||
:build_cpp
|
||||
echo Building C++
|
||||
mkdir build_msvc
|
||||
cd build_msvc
|
||||
cmake -G "%generator%" -Dprotobuf_BUILD_SHARED_LIBS=%BUILD_DLL% ../cmake
|
||||
msbuild protobuf.sln /p:Platform=%vcplatform% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" || goto error
|
||||
cd %configuration%
|
||||
tests.exe || goto error
|
||||
goto :EOF
|
||||
|
||||
:build_csharp
|
||||
echo Building C#
|
||||
cd csharp\src
|
||||
nuget restore
|
||||
msbuild Google.Protobuf.sln /p:Platform="Any CPU" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" || goto error
|
||||
nunit-console Google.Protobuf.Test\bin\%configuration%\Google.Protobuf.Test.dll || goto error
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed!
|
||||
EXIT /b %ERRORLEVEL%
|
|
@ -0,0 +1,32 @@
|
|||
# Only test one combination: "Visual Studio 12 + Win64 + Debug + DLL". We can
|
||||
# test more combinations but AppVeyor just takes too long to finish (each
|
||||
# combination takes ~15mins).
|
||||
platform:
|
||||
- Win64
|
||||
|
||||
configuration:
|
||||
- Debug
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- language: cpp
|
||||
BUILD_DLL: ON
|
||||
|
||||
- language: csharp
|
||||
|
||||
install:
|
||||
- ps: Start-FileDownload https://googlemock.googlecode.com/files/gmock-1.7.0.zip
|
||||
- 7z x gmock-1.7.0.zip
|
||||
- rename gmock-1.7.0 gmock
|
||||
|
||||
before_build:
|
||||
- if %platform%==Win32 set generator=Visual Studio 12
|
||||
- if %platform%==Win64 set generator=Visual Studio 12 Win64
|
||||
- if %platform%==Win32 set vcplatform=Win32
|
||||
- if %platform%==Win64 set vcplatform=x64
|
||||
|
||||
build_script:
|
||||
- CALL appveyor.bat
|
||||
|
||||
skip_commits:
|
||||
message: /.*\[skip appveyor\].*/
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Run this script to generate the configure script and other files that will
|
||||
# be included in the distribution. These files are not checked in because they
|
||||
# are automatically generated.
|
||||
|
||||
set -e
|
||||
|
||||
if [ ! -z "$@" ]; then
|
||||
for argument in "$@"; do
|
||||
case $argument in
|
||||
# make curl silent
|
||||
"-s")
|
||||
curlopts="-s"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Check that we're being run from the right directory.
|
||||
if test ! -f src/google/protobuf/stubs/common.h; then
|
||||
cat >&2 << __EOF__
|
||||
Could not find source code. Make sure you are running this script from the
|
||||
root of the distribution tree.
|
||||
__EOF__
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check that gmock is present. Usually it is already there since the
|
||||
# directory is set up as an SVN external.
|
||||
if test ! -e gmock; then
|
||||
echo "Google Mock not present. Fetching gmock-1.7.0 from the web..."
|
||||
curl $curlopts -O https://googlemock.googlecode.com/files/gmock-1.7.0.zip
|
||||
unzip -q gmock-1.7.0.zip
|
||||
rm gmock-1.7.0.zip
|
||||
mv gmock-1.7.0 gmock
|
||||
fi
|
||||
|
||||
set -ex
|
||||
|
||||
# TODO(kenton): Remove the ",no-obsolete" part and fix the resulting warnings.
|
||||
autoreconf -f -i -Wall,no-obsolete
|
||||
|
||||
rm -rf autom4te.cache config.h.in~
|
||||
exit 0
|
|
@ -0,0 +1,69 @@
|
|||
|
||||
benchmarks_protoc_inputs = \
|
||||
benchmarks.proto \
|
||||
benchmark_messages_proto3.proto
|
||||
|
||||
benchmarks_protoc_inputs_proto2 = \
|
||||
benchmark_messages_proto2.proto
|
||||
|
||||
benchmarks_protoc_outputs = \
|
||||
benchmarks.pb.cc \
|
||||
benchmarks.pb.h \
|
||||
benchmark_messages_proto3.pb.cc \
|
||||
benchmark_messages_proto3.pb.h
|
||||
|
||||
benchmarks_protoc_outputs_proto2 = \
|
||||
benchmark_messages_proto2.pb.cc \
|
||||
benchmark_messages_proto2.pb.h
|
||||
|
||||
bin_PROGRAMS = generate-datasets
|
||||
|
||||
generate_datasets_LDADD = $(top_srcdir)/src/libprotobuf.la
|
||||
generate_datasets_SOURCES = generate_datasets.cc
|
||||
generate_datasets_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)
|
||||
nodist_generate_datasets_SOURCES = \
|
||||
$(benchmarks_protoc_outputs) \
|
||||
$(benchmarks_protoc_outputs_proto2)
|
||||
|
||||
# Explicit deps because BUILT_SOURCES are only done before a "make all/check"
|
||||
# so a direct "make test_cpp" could fail if parallel enough.
|
||||
# See: https://www.gnu.org/software/automake/manual/html_node/Built-Sources-Example.html#Recording-Dependencies-manually
|
||||
generate_datasets-generate_datasets.$(OBJEXT): benchmarks.pb.h
|
||||
|
||||
$(benchmarks_protoc_outputs): protoc_middleman
|
||||
$(benchmarks_protoc_outputs_proto2): protoc_middleman2
|
||||
|
||||
CLEANFILES = \
|
||||
$(benchmarks_protoc_outputs) \
|
||||
$(benchmarks_protoc_outputs_proto2) \
|
||||
protoc_middleman \
|
||||
protoc_middleman2 \
|
||||
dataset.*
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
Makefile.in
|
||||
|
||||
if USE_EXTERNAL_PROTOC
|
||||
|
||||
protoc_middleman: $(benchmarks_protoc_inputs)
|
||||
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. $(benchmarks_protoc_inputs)
|
||||
touch protoc_middleman
|
||||
|
||||
protoc_middleman2: $(benchmarks_protoc_inputs_proto2)
|
||||
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. $(benchmarks_protoc_inputs_proto2)
|
||||
touch protoc_middleman2
|
||||
|
||||
else
|
||||
|
||||
# We have to cd to $(srcdir) before executing protoc because $(protoc_inputs) is
|
||||
# relative to srcdir, which may not be the same as the current directory when
|
||||
# building out-of-tree.
|
||||
protoc_middleman: $(top_srcdir)/src/protoc$(EXEEXT) $(benchmarks_protoc_inputs) $(well_known_type_protoc_inputs)
|
||||
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd $(benchmarks_protoc_inputs) )
|
||||
touch protoc_middleman
|
||||
|
||||
protoc_middleman2: $(top_srcdir)/src/protoc$(EXEEXT) $(benchmarks_protoc_inputs_proto2) $(well_known_type_protoc_inputs)
|
||||
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd $(benchmarks_protoc_inputs_proto2) )
|
||||
touch protoc_middleman
|
||||
|
||||
endif
|
|
@ -0,0 +1,203 @@
|
|||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2009 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.
|
||||
|
||||
package com.google.protocolbuffers;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.CodedInputStream;
|
||||
import com.google.protobuf.CodedOutputStream;
|
||||
import com.google.protobuf.Message;
|
||||
|
||||
public class ProtoBench {
|
||||
|
||||
private static final long MIN_SAMPLE_TIME_MS = 2 * 1000;
|
||||
private static final long TARGET_TIME_MS = 30 * 1000;
|
||||
|
||||
private ProtoBench() {
|
||||
// Prevent instantiation
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length < 2 || (args.length % 2) != 0) {
|
||||
System.err.println("Usage: ProtoBench <descriptor type name> <input data>");
|
||||
System.err.println("The descriptor type name is the fully-qualified message name,");
|
||||
System.err.println("e.g. com.google.protocolbuffers.benchmark.Message1");
|
||||
System.err.println("(You can specify multiple pairs of descriptor type name and input data.)");
|
||||
System.exit(1);
|
||||
}
|
||||
boolean success = true;
|
||||
for (int i = 0; i < args.length; i += 2) {
|
||||
success &= runTest(args[i], args[i + 1]);
|
||||
}
|
||||
System.exit(success ? 0 : 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a single test. Error messages are displayed to stderr, and the return value
|
||||
* indicates general success/failure.
|
||||
*/
|
||||
public static boolean runTest(String type, String file) {
|
||||
System.out.println("Benchmarking " + type + " with file " + file);
|
||||
final Message defaultMessage;
|
||||
try {
|
||||
Class<?> clazz = Class.forName(type);
|
||||
Method method = clazz.getDeclaredMethod("getDefaultInstance");
|
||||
defaultMessage = (Message) method.invoke(null);
|
||||
} catch (Exception e) {
|
||||
// We want to do the same thing with all exceptions. Not generally nice,
|
||||
// but this is slightly different.
|
||||
System.err.println("Unable to get default message for " + type);
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
final byte[] inputData = readAllBytes(file);
|
||||
final ByteArrayInputStream inputStream = new ByteArrayInputStream(inputData);
|
||||
final ByteString inputString = ByteString.copyFrom(inputData);
|
||||
final Message sampleMessage = defaultMessage.newBuilderForType().mergeFrom(inputString).build();
|
||||
FileOutputStream devNullTemp = null;
|
||||
CodedOutputStream reuseDevNullTemp = null;
|
||||
try {
|
||||
devNullTemp = new FileOutputStream("/dev/null");
|
||||
reuseDevNullTemp = CodedOutputStream.newInstance(devNullTemp);
|
||||
} catch (FileNotFoundException e) {
|
||||
// ignore: this is probably Windows, where /dev/null does not exist
|
||||
}
|
||||
final FileOutputStream devNull = devNullTemp;
|
||||
final CodedOutputStream reuseDevNull = reuseDevNullTemp;
|
||||
benchmark("Serialize to byte string", inputData.length, new Action() {
|
||||
public void execute() { sampleMessage.toByteString(); }
|
||||
});
|
||||
benchmark("Serialize to byte array", inputData.length, new Action() {
|
||||
public void execute() { sampleMessage.toByteArray(); }
|
||||
});
|
||||
benchmark("Serialize to memory stream", inputData.length, new Action() {
|
||||
public void execute() throws IOException {
|
||||
sampleMessage.writeTo(new ByteArrayOutputStream());
|
||||
}
|
||||
});
|
||||
if (devNull != null) {
|
||||
benchmark("Serialize to /dev/null with FileOutputStream", inputData.length, new Action() {
|
||||
public void execute() throws IOException {
|
||||
sampleMessage.writeTo(devNull);
|
||||
}
|
||||
});
|
||||
benchmark("Serialize to /dev/null reusing FileOutputStream", inputData.length, new Action() {
|
||||
public void execute() throws IOException {
|
||||
sampleMessage.writeTo(reuseDevNull);
|
||||
reuseDevNull.flush(); // force the write to the OutputStream
|
||||
}
|
||||
});
|
||||
}
|
||||
benchmark("Deserialize from byte string", inputData.length, new Action() {
|
||||
public void execute() throws IOException {
|
||||
defaultMessage.newBuilderForType().mergeFrom(inputString).build();
|
||||
}
|
||||
});
|
||||
benchmark("Deserialize from byte array", inputData.length, new Action() {
|
||||
public void execute() throws IOException {
|
||||
defaultMessage.newBuilderForType()
|
||||
.mergeFrom(CodedInputStream.newInstance(inputData)).build();
|
||||
}
|
||||
});
|
||||
benchmark("Deserialize from memory stream", inputData.length, new Action() {
|
||||
public void execute() throws IOException {
|
||||
defaultMessage.newBuilderForType()
|
||||
.mergeFrom(CodedInputStream.newInstance(inputStream)).build();
|
||||
inputStream.reset();
|
||||
}
|
||||
});
|
||||
System.out.println();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error: " + e.getMessage());
|
||||
System.err.println("Detailed exception information:");
|
||||
e.printStackTrace(System.err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void benchmark(String name, long dataSize, Action action) throws IOException {
|
||||
// Make sure it's JITted "reasonably" hard before running the first progress test
|
||||
for (int i=0; i < 100; i++) {
|
||||
action.execute();
|
||||
}
|
||||
|
||||
// Run it progressively more times until we've got a reasonable sample
|
||||
int iterations = 1;
|
||||
long elapsed = timeAction(action, iterations);
|
||||
while (elapsed < MIN_SAMPLE_TIME_MS) {
|
||||
iterations *= 2;
|
||||
elapsed = timeAction(action, iterations);
|
||||
}
|
||||
|
||||
// Upscale the sample to the target time. Do this in floating point arithmetic
|
||||
// to avoid overflow issues.
|
||||
iterations = (int) ((TARGET_TIME_MS / (double) elapsed) * iterations);
|
||||
elapsed = timeAction(action, iterations);
|
||||
System.out.println(name + ": " + iterations + " iterations in "
|
||||
+ (elapsed/1000f) + "s; "
|
||||
+ (iterations * dataSize) / (elapsed * 1024 * 1024 / 1000f)
|
||||
+ "MB/s");
|
||||
}
|
||||
|
||||
private static long timeAction(Action action, int iterations) throws IOException {
|
||||
System.gc();
|
||||
long start = System.currentTimeMillis();
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
action.execute();
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
return end - start;
|
||||
}
|
||||
|
||||
private static byte[] readAllBytes(String filename) throws IOException {
|
||||
RandomAccessFile file = new RandomAccessFile(new File(filename), "r");
|
||||
byte[] content = new byte[(int) file.length()];
|
||||
file.readFully(content);
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface used to capture a single action to benchmark.
|
||||
*/
|
||||
interface Action {
|
||||
void execute() throws IOException;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
# Protocol Buffers Benchmarks
|
||||
|
||||
This directory contains benchmarking schemas and data sets that you
|
||||
can use to test a variety of performance scenarios against your
|
||||
protobuf language runtime.
|
||||
|
||||
The schema for the datasets is described in `benchmarks.proto`.
|
||||
|
||||
Generate the data sets like so:
|
||||
|
||||
```
|
||||
$ make
|
||||
$ ./generate-datasets
|
||||
Wrote dataset: dataset.google_message1_proto3.pb
|
||||
Wrote dataset: dataset.google_message1_proto2.pb
|
||||
Wrote dataset: dataset.google_message2.pb
|
||||
$
|
||||
```
|
||||
|
||||
Each data set will be written to its own file. Benchmarks will
|
||||
likely want to run several benchmarks against each data set (parse,
|
||||
serialize, possibly JSON, possibly using different APIs, etc).
|
||||
|
||||
We would like to add more data sets. In general we will favor data sets
|
||||
that make the overall suite diverse without being too large or having
|
||||
too many similar tests. Ideally everyone can run through the entire
|
||||
suite without the test run getting too long.
|
|
@ -0,0 +1,141 @@
|
|||
// Benchmark messages for proto2.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package benchmarks.proto2;
|
||||
option java_package = "com.google.protobuf.benchmarks";
|
||||
|
||||
// This is the default, but we specify it here explicitly.
|
||||
option optimize_for = SPEED;
|
||||
|
||||
message GoogleMessage1 {
|
||||
required string field1 = 1;
|
||||
optional string field9 = 9;
|
||||
optional string field18 = 18;
|
||||
optional bool field80 = 80 [default=false];
|
||||
optional bool field81 = 81 [default=true];
|
||||
required int32 field2 = 2;
|
||||
required int32 field3 = 3;
|
||||
optional int32 field280 = 280;
|
||||
optional int32 field6 = 6 [default=0];
|
||||
optional int64 field22 = 22;
|
||||
optional string field4 = 4;
|
||||
repeated fixed64 field5 = 5;
|
||||
optional bool field59 = 59 [default=false];
|
||||
optional string field7 = 7;
|
||||
optional int32 field16 = 16;
|
||||
optional int32 field130 = 130 [default=0];
|
||||
optional bool field12 = 12 [default=true];
|
||||
optional bool field17 = 17 [default=true];
|
||||
optional bool field13 = 13 [default=true];
|
||||
optional bool field14 = 14 [default=true];
|
||||
optional int32 field104 = 104 [default=0];
|
||||
optional int32 field100 = 100 [default=0];
|
||||
optional int32 field101 = 101 [default=0];
|
||||
optional string field102 = 102;
|
||||
optional string field103 = 103;
|
||||
optional int32 field29 = 29 [default=0];
|
||||
optional bool field30 = 30 [default=false];
|
||||
optional int32 field60 = 60 [default=-1];
|
||||
optional int32 field271 = 271 [default=-1];
|
||||
optional int32 field272 = 272 [default=-1];
|
||||
optional int32 field150 = 150;
|
||||
optional int32 field23 = 23 [default=0];
|
||||
optional bool field24 = 24 [default=false];
|
||||
optional int32 field25 = 25 [default=0];
|
||||
optional GoogleMessage1SubMessage field15 = 15;
|
||||
optional bool field78 = 78;
|
||||
optional int32 field67 = 67 [default=0];
|
||||
optional int32 field68 = 68;
|
||||
optional int32 field128 = 128 [default=0];
|
||||
optional string field129 = 129 [default="xxxxxxxxxxxxxxxxxxxxx"];
|
||||
optional int32 field131 = 131 [default=0];
|
||||
}
|
||||
|
||||
message GoogleMessage1SubMessage {
|
||||
optional int32 field1 = 1 [default=0];
|
||||
optional int32 field2 = 2 [default=0];
|
||||
optional int32 field3 = 3 [default=0];
|
||||
optional string field15 = 15;
|
||||
optional bool field12 = 12 [default=true];
|
||||
optional int64 field13 = 13;
|
||||
optional int64 field14 = 14;
|
||||
optional int32 field16 = 16;
|
||||
optional int32 field19 = 19 [default=2];
|
||||
optional bool field20 = 20 [default=true];
|
||||
optional bool field28 = 28 [default=true];
|
||||
optional fixed64 field21 = 21;
|
||||
optional int32 field22 = 22;
|
||||
optional bool field23 = 23 [ default=false ];
|
||||
optional bool field206 = 206 [default=false];
|
||||
optional fixed32 field203 = 203;
|
||||
optional int32 field204 = 204;
|
||||
optional string field205 = 205;
|
||||
optional uint64 field207 = 207;
|
||||
optional uint64 field300 = 300;
|
||||
}
|
||||
|
||||
message GoogleMessage2 {
|
||||
optional string field1 = 1;
|
||||
optional int64 field3 = 3;
|
||||
optional int64 field4 = 4;
|
||||
optional int64 field30 = 30;
|
||||
optional bool field75 = 75 [default=false];
|
||||
optional string field6 = 6;
|
||||
optional bytes field2 = 2;
|
||||
optional int32 field21 = 21 [default=0];
|
||||
optional int32 field71 = 71;
|
||||
optional float field25 = 25;
|
||||
optional int32 field109 = 109 [default=0];
|
||||
optional int32 field210 = 210 [default=0];
|
||||
optional int32 field211 = 211 [default=0];
|
||||
optional int32 field212 = 212 [default=0];
|
||||
optional int32 field213 = 213 [default=0];
|
||||
optional int32 field216 = 216 [default=0];
|
||||
optional int32 field217 = 217 [default=0];
|
||||
optional int32 field218 = 218 [default=0];
|
||||
optional int32 field220 = 220 [default=0];
|
||||
optional int32 field221 = 221 [default=0];
|
||||
optional float field222 = 222 [default=0.0];
|
||||
optional int32 field63 = 63;
|
||||
|
||||
repeated group Group1 = 10 {
|
||||
required float field11 = 11;
|
||||
optional float field26 = 26;
|
||||
optional string field12 = 12;
|
||||
optional string field13 = 13;
|
||||
repeated string field14 = 14;
|
||||
required uint64 field15 = 15;
|
||||
optional int32 field5 = 5;
|
||||
optional string field27 = 27;
|
||||
optional int32 field28 = 28;
|
||||
optional string field29 = 29;
|
||||
optional string field16 = 16;
|
||||
repeated string field22 = 22;
|
||||
repeated int32 field73 = 73;
|
||||
optional int32 field20 = 20 [default=0];
|
||||
optional string field24 = 24;
|
||||
optional GoogleMessage2GroupedMessage field31 = 31;
|
||||
}
|
||||
repeated string field128 = 128;
|
||||
optional int64 field131 = 131;
|
||||
repeated string field127 = 127;
|
||||
optional int32 field129 = 129;
|
||||
repeated int64 field130 = 130;
|
||||
optional bool field205 = 205 [default=false];
|
||||
optional bool field206 = 206 [default=false];
|
||||
}
|
||||
|
||||
message GoogleMessage2GroupedMessage {
|
||||
optional float field1 = 1;
|
||||
optional float field2 = 2;
|
||||
optional float field3 = 3 [default=0.0];
|
||||
optional bool field4 = 4;
|
||||
optional bool field5 = 5;
|
||||
optional bool field6 = 6 [default=true];
|
||||
optional bool field7 = 7 [default=false];
|
||||
optional float field8 = 8;
|
||||
optional bool field9 = 9;
|
||||
optional float field10 = 10;
|
||||
optional int64 field11 = 11;
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
// Benchmark messages for proto3.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package benchmarks.proto3;
|
||||
option java_package = "com.google.protobuf.benchmarks";
|
||||
|
||||
// This is the default, but we specify it here explicitly.
|
||||
option optimize_for = SPEED;
|
||||
|
||||
message GoogleMessage1 {
|
||||
string field1 = 1;
|
||||
string field9 = 9;
|
||||
string field18 = 18;
|
||||
bool field80 = 80;
|
||||
bool field81 = 81;
|
||||
int32 field2 = 2;
|
||||
int32 field3 = 3;
|
||||
int32 field280 = 280;
|
||||
int32 field6 = 6;
|
||||
int64 field22 = 22;
|
||||
string field4 = 4;
|
||||
repeated fixed64 field5 = 5;
|
||||
bool field59 = 59;
|
||||
string field7 = 7;
|
||||
int32 field16 = 16;
|
||||
int32 field130 = 130;
|
||||
bool field12 = 12;
|
||||
bool field17 = 17;
|
||||
bool field13 = 13;
|
||||
bool field14 = 14;
|
||||
int32 field104 = 104;
|
||||
int32 field100 = 100;
|
||||
int32 field101 = 101;
|
||||
string field102 = 102;
|
||||
string field103 = 103;
|
||||
int32 field29 = 29;
|
||||
bool field30 = 30;
|
||||
int32 field60 = 60;
|
||||
int32 field271 = 271;
|
||||
int32 field272 = 272;
|
||||
int32 field150 = 150;
|
||||
int32 field23 = 23;
|
||||
bool field24 = 24;
|
||||
int32 field25 = 25;
|
||||
GoogleMessage1SubMessage field15 = 15;
|
||||
bool field78 = 78;
|
||||
int32 field67 = 67;
|
||||
int32 field68 = 68;
|
||||
int32 field128 = 128;
|
||||
string field129 = 129;
|
||||
int32 field131 = 131;
|
||||
}
|
||||
|
||||
message GoogleMessage1SubMessage {
|
||||
int32 field1 = 1;
|
||||
int32 field2 = 2;
|
||||
int32 field3 = 3;
|
||||
string field15 = 15;
|
||||
bool field12 = 12;
|
||||
int64 field13 = 13;
|
||||
int64 field14 = 14;
|
||||
int32 field16 = 16;
|
||||
int32 field19 = 19;
|
||||
bool field20 = 20;
|
||||
bool field28 = 28;
|
||||
fixed64 field21 = 21;
|
||||
int32 field22 = 22;
|
||||
bool field23 = 23;
|
||||
bool field206 = 206;
|
||||
fixed32 field203 = 203;
|
||||
int32 field204 = 204;
|
||||
string field205 = 205;
|
||||
uint64 field207 = 207;
|
||||
uint64 field300 = 300;
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
// 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 = "proto3";
|
||||
package benchmarks;
|
||||
option java_package = "com.google.protobuf.benchmarks";
|
||||
|
||||
message BenchmarkDataset {
|
||||
// Name of the benchmark dataset. This should be unique across all datasets.
|
||||
// Should only contain word characters: [a-zA-Z0-9_]
|
||||
string name = 1;
|
||||
|
||||
// Fully-qualified name of the protobuf message for this dataset.
|
||||
// It will be one of the messages defined benchmark_messages_proto2.proto
|
||||
// or benchmark_messages_proto3.proto.
|
||||
//
|
||||
// Implementations that do not support reflection can implement this with
|
||||
// an explicit "if/else" chain that lists every known message defined
|
||||
// in those files.
|
||||
string message_name = 2;
|
||||
|
||||
// The payload(s) for this dataset. They should be parsed or serialized
|
||||
// in sequence, in a loop, ie.
|
||||
//
|
||||
// while (!benchmarkDone) { // Benchmark runner decides when to exit.
|
||||
// for (i = 0; i < benchmark.payload.length; i++) {
|
||||
// parse(benchmark.payload[i])
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// This is intended to let datasets include a variety of data to provide
|
||||
// potentially more realistic results than just parsing the same message
|
||||
// over and over. A single message parsed repeatedly could yield unusually
|
||||
// good branch prediction performance.
|
||||
repeated bytes payload = 3;
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
// 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 <fstream>
|
||||
#include <iostream>
|
||||
#include "benchmarks.pb.h"
|
||||
|
||||
using benchmarks::BenchmarkDataset;
|
||||
using google::protobuf::Descriptor;
|
||||
using google::protobuf::DescriptorPool;
|
||||
using google::protobuf::Message;
|
||||
using google::protobuf::MessageFactory;
|
||||
|
||||
std::set<std::string> names;
|
||||
|
||||
const char *file_prefix = "dataset.";
|
||||
const char *file_suffix = ".pb";
|
||||
|
||||
void WriteFileWithPayloads(const std::string& name,
|
||||
const std::string& message_name,
|
||||
const std::vector<std::string>& payload) {
|
||||
if (!names.insert(name).second) {
|
||||
std::cerr << "Duplicate test name: " << name << "\n";
|
||||
abort();
|
||||
}
|
||||
|
||||
// First verify that this message name exists in our set of benchmark messages
|
||||
// and that these payloads are valid for the given message.
|
||||
const Descriptor* d =
|
||||
DescriptorPool::generated_pool()->FindMessageTypeByName(message_name);
|
||||
|
||||
if (!d) {
|
||||
std::cerr << "For dataset " << name << ", no such message: "
|
||||
<< message_name << "\n";
|
||||
abort();
|
||||
}
|
||||
|
||||
Message* m = MessageFactory::generated_factory()->GetPrototype(d)->New();
|
||||
|
||||
for (size_t i = 0; i < payload.size(); i++) {
|
||||
if (!m->ParseFromString(payload[i])) {
|
||||
std::cerr << "For dataset " << name << ", payload[" << i << "] fails "
|
||||
<< "to parse\n";
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
BenchmarkDataset dataset;
|
||||
dataset.set_name(name);
|
||||
dataset.set_message_name(message_name);
|
||||
for (size_t i = 0; i < payload.size(); i++) {
|
||||
dataset.add_payload()->assign(payload[i]);
|
||||
}
|
||||
|
||||
std::ofstream writer;
|
||||
std::string fname = file_prefix + name + file_suffix;
|
||||
writer.open(fname.c_str());
|
||||
dataset.SerializeToOstream(&writer);
|
||||
writer.close();
|
||||
|
||||
std::cerr << "Wrote dataset: " << fname << "\n";
|
||||
}
|
||||
|
||||
void WriteFile(const std::string& name, const std::string& message_name,
|
||||
const std::string& payload) {
|
||||
std::vector<std::string> payloads;
|
||||
payloads.push_back(payload);
|
||||
WriteFileWithPayloads(name, message_name, payloads);
|
||||
}
|
||||
|
||||
std::string ReadFile(const std::string& name) {
|
||||
std::ifstream file(name.c_str());
|
||||
GOOGLE_CHECK(file.is_open()) << "Couldn't find file '" << name <<
|
||||
"', please make sure you are running "
|
||||
"this command from the benchmarks/ "
|
||||
"directory.\n";
|
||||
return std::string((std::istreambuf_iterator<char>(file)),
|
||||
std::istreambuf_iterator<char>());
|
||||
}
|
||||
|
||||
int main() {
|
||||
WriteFile("google_message1_proto3", "benchmarks.proto3.GoogleMessage1",
|
||||
ReadFile("google_message1.dat"));
|
||||
WriteFile("google_message1_proto2", "benchmarks.proto2.GoogleMessage1",
|
||||
ReadFile("google_message1.dat"));
|
||||
|
||||
// Not in proto3 because it has a group, which is not supported.
|
||||
WriteFile("google_message2", "benchmarks.proto2.GoogleMessage2",
|
||||
ReadFile("google_message2.dat"));
|
||||
}
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,138 @@
|
|||
syntax = "proto2";
|
||||
|
||||
package benchmarks;
|
||||
|
||||
option java_outer_classname = "GoogleSize";
|
||||
option optimize_for = CODE_SIZE;
|
||||
|
||||
message SizeMessage1 {
|
||||
required string field1 = 1;
|
||||
optional string field9 = 9;
|
||||
optional string field18 = 18;
|
||||
optional bool field80 = 80 [default=false];
|
||||
optional bool field81 = 81 [default=true];
|
||||
required int32 field2 = 2;
|
||||
required int32 field3 = 3;
|
||||
optional int32 field280 = 280;
|
||||
optional int32 field6 = 6 [default=0];
|
||||
optional int64 field22 = 22;
|
||||
optional string field4 = 4;
|
||||
repeated fixed64 field5 = 5;
|
||||
optional bool field59 = 59 [default=false];
|
||||
optional string field7 = 7;
|
||||
optional int32 field16 = 16;
|
||||
optional int32 field130 = 130 [default=0];
|
||||
optional bool field12 = 12 [default=true];
|
||||
optional bool field17 = 17 [default=true];
|
||||
optional bool field13 = 13 [default=true];
|
||||
optional bool field14 = 14 [default=true];
|
||||
optional int32 field104 = 104 [default=0];
|
||||
optional int32 field100 = 100 [default=0];
|
||||
optional int32 field101 = 101 [default=0];
|
||||
optional string field102 = 102;
|
||||
optional string field103 = 103;
|
||||
optional int32 field29 = 29 [default=0];
|
||||
optional bool field30 = 30 [default=false];
|
||||
optional int32 field60 = 60 [default=-1];
|
||||
optional int32 field271 = 271 [default=-1];
|
||||
optional int32 field272 = 272 [default=-1];
|
||||
optional int32 field150 = 150;
|
||||
optional int32 field23 = 23 [default=0];
|
||||
optional bool field24 = 24 [default=false];
|
||||
optional int32 field25 = 25 [default=0];
|
||||
optional SizeMessage1SubMessage field15 = 15;
|
||||
optional bool field78 = 78;
|
||||
optional int32 field67 = 67 [default=0];
|
||||
optional int32 field68 = 68;
|
||||
optional int32 field128 = 128 [default=0];
|
||||
optional string field129 = 129 [default="xxxxxxxxxxxxxxxxxxxxx"];
|
||||
optional int32 field131 = 131 [default=0];
|
||||
}
|
||||
|
||||
message SizeMessage1SubMessage {
|
||||
optional int32 field1 = 1 [default=0];
|
||||
optional int32 field2 = 2 [default=0];
|
||||
optional int32 field3 = 3 [default=0];
|
||||
optional string field15 = 15;
|
||||
optional bool field12 = 12 [default=true];
|
||||
optional int64 field13 = 13;
|
||||
optional int64 field14 = 14;
|
||||
optional int32 field16 = 16;
|
||||
optional int32 field19 = 19 [default=2];
|
||||
optional bool field20 = 20 [default=true];
|
||||
optional bool field28 = 28 [default=true];
|
||||
optional fixed64 field21 = 21;
|
||||
optional int32 field22 = 22;
|
||||
optional bool field23 = 23 [ default=false ];
|
||||
optional bool field206 = 206 [default=false];
|
||||
optional fixed32 field203 = 203;
|
||||
optional int32 field204 = 204;
|
||||
optional string field205 = 205;
|
||||
optional uint64 field207 = 207;
|
||||
optional uint64 field300 = 300;
|
||||
}
|
||||
|
||||
message SizeMessage2 {
|
||||
optional string field1 = 1;
|
||||
optional int64 field3 = 3;
|
||||
optional int64 field4 = 4;
|
||||
optional int64 field30 = 30;
|
||||
optional bool field75 = 75 [default=false];
|
||||
optional string field6 = 6;
|
||||
optional bytes field2 = 2;
|
||||
optional int32 field21 = 21 [default=0];
|
||||
optional int32 field71 = 71;
|
||||
optional float field25 = 25;
|
||||
optional int32 field109 = 109 [default=0];
|
||||
optional int32 field210 = 210 [default=0];
|
||||
optional int32 field211 = 211 [default=0];
|
||||
optional int32 field212 = 212 [default=0];
|
||||
optional int32 field213 = 213 [default=0];
|
||||
optional int32 field216 = 216 [default=0];
|
||||
optional int32 field217 = 217 [default=0];
|
||||
optional int32 field218 = 218 [default=0];
|
||||
optional int32 field220 = 220 [default=0];
|
||||
optional int32 field221 = 221 [default=0];
|
||||
optional float field222 = 222 [default=0.0];
|
||||
optional int32 field63 = 63;
|
||||
|
||||
repeated group Group1 = 10 {
|
||||
required float field11 = 11;
|
||||
optional float field26 = 26;
|
||||
optional string field12 = 12;
|
||||
optional string field13 = 13;
|
||||
repeated string field14 = 14;
|
||||
required uint64 field15 = 15;
|
||||
optional int32 field5 = 5;
|
||||
optional string field27 = 27;
|
||||
optional int32 field28 = 28;
|
||||
optional string field29 = 29;
|
||||
optional string field16 = 16;
|
||||
repeated string field22 = 22;
|
||||
repeated int32 field73 = 73;
|
||||
optional int32 field20 = 20 [default=0];
|
||||
optional string field24 = 24;
|
||||
optional SizeMessage2GroupedMessage field31 = 31;
|
||||
}
|
||||
repeated string field128 = 128;
|
||||
optional int64 field131 = 131;
|
||||
repeated string field127 = 127;
|
||||
optional int32 field129 = 129;
|
||||
repeated int64 field130 = 130;
|
||||
optional bool field205 = 205 [default=false];
|
||||
optional bool field206 = 206 [default=false];
|
||||
}
|
||||
|
||||
message SizeMessage2GroupedMessage {
|
||||
optional float field1 = 1;
|
||||
optional float field2 = 2;
|
||||
optional float field3 = 3 [default=0.0];
|
||||
optional bool field4 = 4;
|
||||
optional bool field5 = 5;
|
||||
optional bool field6 = 6 [default=true];
|
||||
optional bool field7 = 7 [default=false];
|
||||
optional float field8 = 8;
|
||||
optional bool field9 = 9;
|
||||
optional float field10 = 10;
|
||||
optional int64 field11 = 11;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
Contents
|
||||
--------
|
||||
|
||||
This folder contains three kinds of file:
|
||||
|
||||
- Code, such as ProtoBench.java, to build the benchmarking framework.
|
||||
- Protocol buffer definitions (.proto files)
|
||||
- Sample data files
|
||||
|
||||
If we end up with a lot of different benchmarks it may be worth
|
||||
separating these out info different directories, but while there are
|
||||
so few they might as well all be together.
|
||||
|
||||
Running a benchmark (Java)
|
||||
--------------------------
|
||||
|
||||
1) Build protoc and the Java protocol buffer library. The examples
|
||||
below assume a jar file (protobuf.jar) has been built and copied
|
||||
into this directory.
|
||||
|
||||
2) Build ProtoBench:
|
||||
$ javac -d tmp -cp protobuf.jar ProtoBench.java
|
||||
|
||||
3) Generate code for the relevant benchmark protocol buffer, e.g.
|
||||
$ protoc --java_out=tmp google_size.proto google_speed.proto
|
||||
|
||||
4) Build the generated code, e.g.
|
||||
$ cd tmp
|
||||
$ javac -d . -cp ../protobuf.jar benchmarks/*.java
|
||||
|
||||
5) Run the test. Arguments are given in pairs - the first argument
|
||||
is the descriptor type; the second is the filename. For example:
|
||||
$ java -cp .;../protobuf.jar com.google.protocolbuffers.ProtoBench
|
||||
benchmarks.GoogleSize$SizeMessage1 ../google_message1.dat
|
||||
benchmarks.GoogleSpeed$SpeedMessage1 ../google_message1.dat
|
||||
benchmarks.GoogleSize$SizeMessage2 ../google_message2.dat
|
||||
benchmarks.GoogleSpeed$SpeedMessage2 ../google_message2.dat
|
||||
|
||||
6) Wait! Each test runs for around 30 seconds, and there are 6 tests
|
||||
per class/data combination. The above command would therefore take
|
||||
about 12 minutes to run.
|
||||
|
||||
|
||||
Benchmarks available
|
||||
--------------------
|
||||
|
||||
From Google:
|
||||
google_size.proto and google_speed.proto, messages
|
||||
google_message1.dat and google_message2.dat. The proto files are
|
||||
equivalent, but optimized differently.
|
|
@ -0,0 +1,153 @@
|
|||
# Minimum CMake required
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
# Project
|
||||
project(protobuf C CXX)
|
||||
|
||||
# CMake policies
|
||||
cmake_policy(SET CMP0022 NEW)
|
||||
|
||||
# Options
|
||||
option(protobuf_VERBOSE "Enable for verbose output" OFF)
|
||||
option(protobuf_BUILD_TESTS "Build tests" ON)
|
||||
if (BUILD_SHARED_LIBS)
|
||||
set(protobuf_BUILD_SHARED_LIBS_DEFAULT ON)
|
||||
else (BUILD_SHARED_LIBS)
|
||||
set(protobuf_BUILD_SHARED_LIBS_DEFAULT OFF)
|
||||
endif (BUILD_SHARED_LIBS)
|
||||
option(protobuf_BUILD_SHARED_LIBS "Build Shared Libraries" ${protobuf_BUILD_SHARED_LIBS_DEFAULT})
|
||||
option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON)
|
||||
if (MSVC)
|
||||
set(protobuf_WITH_ZLIB_DEFAULT OFF)
|
||||
else (MSVC)
|
||||
set(protobuf_WITH_ZLIB_DEFAULT ON)
|
||||
endif (MSVC)
|
||||
option(protobuf_WITH_ZLIB "Build with zlib support" ${protobuf_WITH_ZLIB_DEFAULT})
|
||||
set(protobuf_DEBUG_POSTFIX "d"
|
||||
CACHE STRING "Default debug postfix")
|
||||
|
||||
# Path to main configure script
|
||||
set(protobuf_CONFIGURE_SCRIPT "../configure.ac")
|
||||
|
||||
# Parse configure script
|
||||
set(protobuf_AC_INIT_REGEX
|
||||
"^AC_INIT\\(\\[([^]]+)\\],\\[([^]]+)\\],\\[([^]]+)\\],\\[([^]]+)\\]\\)$")
|
||||
file(STRINGS "${protobuf_CONFIGURE_SCRIPT}" protobuf_AC_INIT_LINE
|
||||
LIMIT_COUNT 1 REGEX "^AC_INIT")
|
||||
# Description
|
||||
string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\1"
|
||||
protobuf_DESCRIPTION "${protobuf_AC_INIT_LINE}")
|
||||
# Version
|
||||
string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\2"
|
||||
protobuf_VERSION_STRING "${protobuf_AC_INIT_LINE}")
|
||||
# Contact
|
||||
string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\3"
|
||||
protobuf_CONTACT "${protobuf_AC_INIT_LINE}")
|
||||
# Parse version tweaks
|
||||
set(protobuf_VERSION_REGEX "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$")
|
||||
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\1"
|
||||
protobuf_VERSION_MAJOR "${protobuf_VERSION_STRING}")
|
||||
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\2"
|
||||
protobuf_VERSION_MINOR "${protobuf_VERSION_STRING}")
|
||||
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\3"
|
||||
protobuf_VERSION_PATCH "${protobuf_VERSION_STRING}")
|
||||
# Package version
|
||||
set(protobuf_VERSION
|
||||
"${protobuf_VERSION_MAJOR}.${protobuf_VERSION_MINOR}.${protobuf_VERSION_PATCH}")
|
||||
|
||||
if(protobuf_VERBOSE)
|
||||
message(STATUS "Configuration script parsing status [")
|
||||
message(STATUS " Description : ${protobuf_DESCRIPTION}")
|
||||
message(STATUS " Version : ${protobuf_VERSION} (${protobuf_VERSION_STRING})")
|
||||
message(STATUS " Contact : ${protobuf_CONTACT}")
|
||||
message(STATUS "]")
|
||||
endif()
|
||||
|
||||
add_definitions(-DGOOGLE_PROTOBUF_CMAKE_BUILD)
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
if (CMAKE_USE_PTHREADS_INIT)
|
||||
add_definitions(-DHAVE_PTHREAD)
|
||||
endif (CMAKE_USE_PTHREADS_INIT)
|
||||
|
||||
if (protobuf_WITH_ZLIB)
|
||||
find_package(ZLIB)
|
||||
if (ZLIB_FOUND)
|
||||
set(HAVE_ZLIB 1)
|
||||
# FindZLIB module define ZLIB_INCLUDE_DIRS variable
|
||||
# Set ZLIB_INCLUDE_DIRECTORIES for compatible
|
||||
set(ZLIB_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIRECTORIES} ${ZLIB_INCLUDE_DIRS})
|
||||
# Using imported target if exists
|
||||
if (TARGET ZLIB::ZLIB)
|
||||
set(ZLIB_LIBRARIES ZLIB::ZLIB)
|
||||
endif (TARGET ZLIB::ZLIB)
|
||||
else (ZLIB_FOUND)
|
||||
set(HAVE_ZLIB 0)
|
||||
# Explicitly set these to empty (override NOT_FOUND) so cmake doesn't
|
||||
# complain when we use them later.
|
||||
set(ZLIB_INCLUDE_DIRECTORIES)
|
||||
set(ZLIB_LIBRARIES)
|
||||
endif (ZLIB_FOUND)
|
||||
endif (protobuf_WITH_ZLIB)
|
||||
|
||||
if (HAVE_ZLIB)
|
||||
add_definitions(-DHAVE_ZLIB)
|
||||
endif (HAVE_ZLIB)
|
||||
|
||||
if (protobuf_BUILD_SHARED_LIBS)
|
||||
set(protobuf_SHARED_OR_STATIC "SHARED")
|
||||
else (protobuf_BUILD_SHARED_LIBS)
|
||||
set(protobuf_SHARED_OR_STATIC "STATIC")
|
||||
# In case we are building static libraries, link also the runtime library statically
|
||||
# so that MSVCR*.DLL is not required at runtime.
|
||||
# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
|
||||
# This is achieved by replacing msvc option /MD with /MT and /MDd with /MTd
|
||||
# http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
|
||||
if (MSVC AND protobuf_MSVC_STATIC_RUNTIME)
|
||||
foreach(flag_var
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
if(${flag_var} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||
endif(${flag_var} MATCHES "/MD")
|
||||
endforeach(flag_var)
|
||||
endif (MSVC AND protobuf_MSVC_STATIC_RUNTIME)
|
||||
endif (protobuf_BUILD_SHARED_LIBS)
|
||||
|
||||
if (MSVC)
|
||||
# Build with multiple processes
|
||||
add_definitions(/MP)
|
||||
add_definitions(/wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305)
|
||||
# Allow big object
|
||||
add_definitions(/bigobj)
|
||||
string(REPLACE "/" "\\" PROTOBUF_SOURCE_WIN32_PATH ${protobuf_SOURCE_DIR})
|
||||
string(REPLACE "/" "\\" PROTOBUF_BINARY_WIN32_PATH ${protobuf_BINARY_DIR})
|
||||
configure_file(extract_includes.bat.in extract_includes.bat)
|
||||
endif (MSVC)
|
||||
|
||||
get_filename_component(protobuf_source_dir ${protobuf_SOURCE_DIR} PATH)
|
||||
|
||||
include_directories(
|
||||
${ZLIB_INCLUDE_DIRECTORIES}
|
||||
${protobuf_BINARY_DIR}
|
||||
${protobuf_source_dir}/src)
|
||||
|
||||
if (MSVC)
|
||||
# Add the "lib" prefix for generated .lib outputs.
|
||||
set(LIB_PREFIX lib)
|
||||
else (MSVC)
|
||||
# When building with "make", "lib" prefix will be added automatically by
|
||||
# the build tool.
|
||||
set(LIB_PREFIX)
|
||||
endif (MSVC)
|
||||
|
||||
include(libprotobuf-lite.cmake)
|
||||
include(libprotobuf.cmake)
|
||||
include(libprotoc.cmake)
|
||||
include(protoc.cmake)
|
||||
|
||||
if (protobuf_BUILD_TESTS)
|
||||
include(tests.cmake)
|
||||
endif (protobuf_BUILD_TESTS)
|
||||
|
||||
include(install.cmake)
|
|
@ -0,0 +1,336 @@
|
|||
This directory contains *CMake* files that can be used to build protobuf
|
||||
with *MSVC* on *Windows*. You can build the project from *Command Prompt*
|
||||
and using an *Visual Studio* IDE.
|
||||
|
||||
You need to have [CMake](http://www.cmake.org), [Visual Studio](https://www.visualstudio.com)
|
||||
and optionally [Git](http://git-scm.com) installed on your computer before proceeding.
|
||||
|
||||
Most of the instructions will be given to the *Сommand Prompt*, but the same
|
||||
actions can be performed using appropriate GUI tools.
|
||||
|
||||
Environment Setup
|
||||
=================
|
||||
|
||||
Open the appropriate *Command Prompt* from the *Start* menu.
|
||||
|
||||
For example *VS2013 x64 Native Tools Command Prompt*:
|
||||
|
||||
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64>
|
||||
|
||||
Change to your working directory:
|
||||
|
||||
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64>cd C:\Path\to
|
||||
C:\Path\to>
|
||||
|
||||
Where *C:\Path\to* is path to your real working directory.
|
||||
|
||||
Create a folder where protobuf headers/libraries/binaries will be installed after built:
|
||||
|
||||
C:\Path\to>mkdir install
|
||||
|
||||
If *cmake* command is not available from *Command Prompt*, add it to system *PATH* variable:
|
||||
|
||||
C:\Path\to>set PATH=%PATH%;C:\Program Files (x86)\CMake\bin
|
||||
|
||||
If *git* command is not available from *Command Prompt*, add it to system *PATH* variable:
|
||||
|
||||
C:\Path\to>set PATH=%PATH%;C:\Program Files\Git\cmd
|
||||
|
||||
Good. Now you are ready to continue.
|
||||
|
||||
Getting Sources
|
||||
===============
|
||||
|
||||
You can get the latest stable source packages from the
|
||||
[releases](https://github.com/google/protobuf/releases) page.
|
||||
Or you can type:
|
||||
|
||||
C:\Path\to> git clone -b [release_tag] https://github.com/google/protobuf.git
|
||||
|
||||
Where *[release_tag]* is a git tag like *v3.0.0-beta-1* or a branch name like *master*
|
||||
if you want to get the latest code.
|
||||
|
||||
Go to the project folder:
|
||||
|
||||
C:\Path\to>cd protobuf
|
||||
C:\Path\to\protobuf>
|
||||
|
||||
Protobuf unit-tests require gmock to build. If you download protobuf source code
|
||||
from the *releases* page, the *gmock* directory should already be there. If you checkout
|
||||
the code via `git clone`, this *gmock* directory won't exist and you will have to
|
||||
download it manually or skip building protobuf unit-tests.
|
||||
|
||||
You can download gmock as follows:
|
||||
|
||||
C:\Path\to\protobuf>git clone -b release-1.7.0 https://github.com/google/googlemock.git gmock
|
||||
|
||||
Then go to *gmock* folder and download gtest:
|
||||
|
||||
C:\Path\to\protobuf>cd gmock
|
||||
C:\Path\to\protobuf\gmock>git clone -b release-1.7.0 https://github.com/google/googletest.git gtest
|
||||
|
||||
If you absolutely don't want to build and run protobuf unit-tests, skip
|
||||
this steps and use protobuf at your own risk.
|
||||
|
||||
Now go to *cmake* folder in protobuf sources:
|
||||
|
||||
C:\Path\to\protobuf\gmock>cd ..\cmake
|
||||
C:\Path\to\protobuf\cmake>
|
||||
|
||||
Good. Now you are ready to *CMake* configuration.
|
||||
|
||||
CMake Configuration
|
||||
===================
|
||||
|
||||
*CMake* supports a lot of different
|
||||
[generators](http://www.cmake.org/cmake/help/latest/manual/cmake-generators.7.html)
|
||||
for various native build systems.
|
||||
We are only interested in
|
||||
[Makefile](http://www.cmake.org/cmake/help/latest/manual/cmake-generators.7.html#makefile-generators)
|
||||
and
|
||||
[Visual Studio](http://www.cmake.org/cmake/help/latest/manual/cmake-generators.7.html#visual-studio-generators)
|
||||
generators.
|
||||
|
||||
We will use shadow building to separate the temporary files from the protobuf source code.
|
||||
|
||||
Create a temporary *build* folder and change your working directory to it:
|
||||
|
||||
C:\Path\to\protobuf\cmake>mkdir build & cd build
|
||||
C:\Path\to\protobuf\cmake\build>
|
||||
|
||||
The *Makefile* generator can build the project in only one configuration, so you need to build
|
||||
a separate folder for each configuration.
|
||||
|
||||
To start using a *Release* configuration:
|
||||
|
||||
C:\Path\to\protobuf\cmake\build>mkdir release & cd release
|
||||
C:\Path\to\protobuf\cmake\build\release>cmake -G "NMake Makefiles" ^
|
||||
-DCMAKE_BUILD_TYPE=Release ^
|
||||
-DCMAKE_INSTALL_PREFIX=../../../../install ^
|
||||
../..
|
||||
|
||||
It will generate *nmake* *Makefile* in current directory.
|
||||
|
||||
To use *Debug* configuration:
|
||||
|
||||
C:\Path\to\protobuf\cmake\build>mkdir debug & cd debug
|
||||
C:\Path\to\protobuf\cmake\build\debug>cmake -G "NMake Makefiles" ^
|
||||
-DCMAKE_BUILD_TYPE=Debug ^
|
||||
-DCMAKE_INSTALL_PREFIX=../../../../install ^
|
||||
../..
|
||||
|
||||
It will generate *nmake* *Makefile* in current directory.
|
||||
|
||||
To create *Visual Studio* solution file:
|
||||
|
||||
C:\Path\to\protobuf\cmake\build>mkdir solution & cd solution
|
||||
C:\Path\to\protobuf\cmake\build\solution>cmake -G "Visual Studio 12 2013 Win64" ^
|
||||
-DCMAKE_INSTALL_PREFIX=../../../../install ^
|
||||
../..
|
||||
|
||||
It will generate *Visual Studio* solution file *protobuf.sln* in current directory.
|
||||
|
||||
If the *gmock* directory does not exist, and you do not want to build protobuf unit tests,
|
||||
you need to add *cmake* command argument `-Dprotobuf_BUILD_TESTS=OFF` to disable testing.
|
||||
|
||||
Compiling
|
||||
=========
|
||||
|
||||
To compile protobuf:
|
||||
|
||||
C:\Path\to\protobuf\cmake\build\release>nmake
|
||||
|
||||
or
|
||||
|
||||
C:\Path\to\protobuf\cmake\build\debug>nmake
|
||||
|
||||
And wait for the compilation to finish.
|
||||
|
||||
If you prefer to use the IDE:
|
||||
|
||||
* Open the generated protobuf.sln file in Microsoft Visual Studio.
|
||||
* Choose "Debug" or "Release" configuration as desired.
|
||||
* From the Build menu, choose "Build Solution".
|
||||
|
||||
And wait for the compilation to finish.
|
||||
|
||||
Testing
|
||||
=======
|
||||
|
||||
To run unit-tests, first you must compile protobuf as described above.
|
||||
Then run:
|
||||
|
||||
C:\Path\to\protobuf\cmake\build\release>nmake check
|
||||
|
||||
or
|
||||
|
||||
C:\Path\to\protobuf\cmake\build\debug>nmake check
|
||||
|
||||
You can also build project *check* from Visual Studio solution.
|
||||
Yes, it may sound strange, but it works.
|
||||
|
||||
You should see output similar to:
|
||||
|
||||
Running main() from gmock_main.cc
|
||||
[==========] Running 1546 tests from 165 test cases.
|
||||
|
||||
...
|
||||
|
||||
[==========] 1546 tests from 165 test cases ran. (2529 ms total)
|
||||
[ PASSED ] 1546 tests.
|
||||
|
||||
To run specific tests:
|
||||
|
||||
C:\Path\to\protobuf>cmake\build\release\tests.exe --gtest_filter=AnyTest*
|
||||
Running main() from gmock_main.cc
|
||||
Note: Google Test filter = AnyTest*
|
||||
[==========] Running 3 tests from 1 test case.
|
||||
[----------] Global test environment set-up.
|
||||
[----------] 3 tests from AnyTest
|
||||
[ RUN ] AnyTest.TestPackAndUnpack
|
||||
[ OK ] AnyTest.TestPackAndUnpack (0 ms)
|
||||
[ RUN ] AnyTest.TestPackAndUnpackAny
|
||||
[ OK ] AnyTest.TestPackAndUnpackAny (0 ms)
|
||||
[ RUN ] AnyTest.TestIs
|
||||
[ OK ] AnyTest.TestIs (0 ms)
|
||||
[----------] 3 tests from AnyTest (1 ms total)
|
||||
|
||||
[----------] Global test environment tear-down
|
||||
[==========] 3 tests from 1 test case ran. (2 ms total)
|
||||
[ PASSED ] 3 tests.
|
||||
|
||||
Note that the tests must be run from the source folder.
|
||||
|
||||
If all tests are passed, safely continue.
|
||||
|
||||
Installing
|
||||
==========
|
||||
|
||||
To install protobuf to the specified *install* folder:
|
||||
|
||||
C:\Path\to\protobuf\cmake\build\release>nmake install
|
||||
|
||||
or
|
||||
|
||||
C:\Path\to\protobuf\cmake\build\debug>nmake install
|
||||
|
||||
You can also build project *INSTALL* from Visual Studio solution.
|
||||
It sounds not so strange and it works.
|
||||
|
||||
This will create the following folders under the *install* location:
|
||||
* bin - that contains protobuf *protoc.exe* compiler;
|
||||
* include - that contains C++ headers and protobuf *.proto files;
|
||||
* lib - that contains linking libraries and *CMake* configuration files for *protobuf* package.
|
||||
|
||||
Now you can if needed:
|
||||
* Copy the contents of the include directory to wherever you want to put headers.
|
||||
* Copy protoc.exe wherever you put build tools (probably somewhere in your PATH).
|
||||
* Copy linking libraries libprotobuf[d].lib, libprotobuf-lite[d].lib, and libprotoc[d].lib wherever you put libraries.
|
||||
|
||||
To avoid conflicts between the MSVC debug and release runtime libraries, when
|
||||
compiling a debug build of your application, you may need to link against a
|
||||
debug build of libprotobufd.lib with "d" postfix. Similarly, release builds should link against
|
||||
release libprotobuf.lib library.
|
||||
|
||||
DLLs vs. static linking
|
||||
=======================
|
||||
|
||||
Static linking is now the default for the Protocol Buffer libraries. Due to
|
||||
issues with Win32's use of a separate heap for each DLL, as well as binary
|
||||
compatibility issues between different versions of MSVC's STL library, it is
|
||||
recommended that you use static linkage only. However, it is possible to
|
||||
build libprotobuf and libprotoc as DLLs if you really want. To do this,
|
||||
do the following:
|
||||
|
||||
* Add an additional flag `-Dprotobuf_BUILD_SHARED_LIBS=ON` when invoking cmake
|
||||
* Follow the same steps as described in the above section.
|
||||
* When compiling your project, make sure to `#define PROTOBUF_USE_DLLS`.
|
||||
|
||||
When distributing your software to end users, we strongly recommend that you
|
||||
do NOT install libprotobuf.dll or libprotoc.dll to any shared location.
|
||||
Instead, keep these libraries next to your binaries, in your application's
|
||||
own install directory. C++ makes it very difficult to maintain binary
|
||||
compatibility between releases, so it is likely that future versions of these
|
||||
libraries will *not* be usable as drop-in replacements.
|
||||
|
||||
If your project is itself a DLL intended for use by third-party software, we
|
||||
recommend that you do NOT expose protocol buffer objects in your library's
|
||||
public interface, and that you statically link protocol buffers into your
|
||||
library.
|
||||
|
||||
ZLib support
|
||||
============
|
||||
|
||||
If you want to include GzipInputStream and GzipOutputStream
|
||||
(google/protobuf/io/gzip_stream.h) in libprotobuf, you will need to do a few
|
||||
additional steps.
|
||||
|
||||
Obtain a copy of the zlib library. The pre-compiled DLL at zlib.net works.
|
||||
You need prepare it:
|
||||
|
||||
* Make sure zlib's two headers are in your `C:\Path\to\install\include` path
|
||||
* Make sure zlib's linking libraries (*.lib file) is in your
|
||||
`C:\Path\to\install\lib` library path.
|
||||
|
||||
You can also compile it from source by yourself.
|
||||
|
||||
Getting sources:
|
||||
|
||||
C:\Path\to>git clone -b v1.2.8 https://github.com/madler/zlib.git
|
||||
C:\Path\to>cd zlib
|
||||
|
||||
Compiling and Installing:
|
||||
|
||||
C:\Path\to\zlib>mkdir build & cd build
|
||||
C:\Path\to\zlib\build>mkdir release & cd release
|
||||
C:\Path\to\zlib\build\release>cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release ^
|
||||
-DCMAKE_INSTALL_PREFIX=../../../install ../..
|
||||
C:\Path\to\zlib\build\release>nmake & nmake install
|
||||
|
||||
You can make *debug* version or use *Visual Studio* generator also as before for the
|
||||
protobuf project.
|
||||
|
||||
Now add *bin* folder from *install* to system *PATH*:
|
||||
|
||||
C:\Path\to>set PATH=%PATH%;C:\Path\to\install\bin
|
||||
|
||||
You need reconfigure protobuf with flag `-Dprotobuf_WITH_ZLIB=ON` when invoking cmake.
|
||||
|
||||
Note that if you have compiled ZLIB yourself, as stated above,
|
||||
further disable the option `-Dprotobuf_MSVC_STATIC_RUNTIME=OFF`.
|
||||
|
||||
If it reports NOTFOUND for zlib_include or zlib_lib, you might haven't put
|
||||
the headers or the .lib file in the right directory.
|
||||
|
||||
Build and testing protobuf as usual.
|
||||
|
||||
Notes on Compiler Warnings
|
||||
==========================
|
||||
|
||||
The following warnings have been disabled while building the protobuf libraries
|
||||
and compiler. You may have to disable some of them in your own project as
|
||||
well, or live with them.
|
||||
|
||||
* C4018 - 'expression' : signed/unsigned mismatch
|
||||
* C4146 - unary minus operator applied to unsigned type, result still unsigned
|
||||
* C4244 - Conversion from 'type1' to 'type2', possible loss of data.
|
||||
* C4251 - 'identifier' : class 'type' needs to have dll-interface to be used by
|
||||
clients of class 'type2'
|
||||
* C4267 - Conversion from 'size_t' to 'type', possible loss of data.
|
||||
* C4305 - 'identifier' : truncation from 'type1' to 'type2'
|
||||
* C4355 - 'this' : used in base member initializer list
|
||||
* C4800 - 'type' : forcing value to bool 'true' or 'false' (performance warning)
|
||||
* C4996 - 'function': was declared deprecated
|
||||
|
||||
C4251 is of particular note, if you are compiling the Protocol Buffer library
|
||||
as a DLL (see previous section). The protocol buffer library uses templates in
|
||||
its public interfaces. MSVC does not provide any reasonable way to export
|
||||
template classes from a DLL. However, in practice, it appears that exporting
|
||||
templates is not necessary anyway. Since the complete definition of any
|
||||
template is available in the header files, anyone importing the DLL will just
|
||||
end up compiling instances of the templates into their own binary. The
|
||||
Protocol Buffer implementation does not rely on static template members being
|
||||
unique, so there should be no problem with this, but MSVC prints warning
|
||||
nevertheless. So, we disable it. Unfortunately, this warning will also be
|
||||
produced when compiling code which merely uses protocol buffers, meaning you
|
||||
may have to disable it in your code too.
|
|
@ -0,0 +1,124 @@
|
|||
mkdir include
|
||||
mkdir include\google
|
||||
mkdir include\google\protobuf
|
||||
mkdir include\google\protobuf\compiler
|
||||
mkdir include\google\protobuf\compiler\cpp
|
||||
mkdir include\google\protobuf\compiler\csharp
|
||||
mkdir include\google\protobuf\compiler\java
|
||||
mkdir include\google\protobuf\compiler\javanano
|
||||
mkdir include\google\protobuf\compiler\js
|
||||
mkdir include\google\protobuf\compiler\objectivec
|
||||
mkdir include\google\protobuf\compiler\python
|
||||
mkdir include\google\protobuf\compiler\ruby
|
||||
mkdir include\google\protobuf\io
|
||||
mkdir include\google\protobuf\stubs
|
||||
mkdir include\google\protobuf\util
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\any.h include\google\protobuf\any.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\any.pb.h include\google\protobuf\any.pb.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\api.pb.h include\google\protobuf\api.pb.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arena.h include\google\protobuf\arena.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arenastring.h include\google\protobuf\arenastring.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\code_generator.h include\google\protobuf\compiler\code_generator.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\command_line_interface.h include\google\protobuf\compiler\command_line_interface.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\cpp\cpp_generator.h include\google\protobuf\compiler\cpp\cpp_generator.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_generator.h include\google\protobuf\compiler\csharp\csharp_generator.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_names.h include\google\protobuf\compiler\csharp\csharp_names.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\importer.h include\google\protobuf\compiler\importer.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_generator.h include\google\protobuf\compiler\java\java_generator.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_names.h include\google\protobuf\compiler\java\java_names.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\javanano\javanano_generator.h include\google\protobuf\compiler\javanano\javanano_generator.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\js\js_generator.h include\google\protobuf\compiler\js\js_generator.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_generator.h include\google\protobuf\compiler\objectivec\objectivec_generator.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_helpers.h include\google\protobuf\compiler\objectivec\objectivec_helpers.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\parser.h include\google\protobuf\compiler\parser.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.h include\google\protobuf\compiler\plugin.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.pb.h include\google\protobuf\compiler\plugin.pb.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\python\python_generator.h include\google\protobuf\compiler\python\python_generator.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\ruby\ruby_generator.h include\google\protobuf\compiler\ruby\ruby_generator.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.h include\google\protobuf\descriptor.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.pb.h include\google\protobuf\descriptor.pb.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor_database.h include\google\protobuf\descriptor_database.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\duration.pb.h include\google\protobuf\duration.pb.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\dynamic_message.h include\google\protobuf\dynamic_message.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\empty.pb.h include\google\protobuf\empty.pb.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\extension_set.h include\google\protobuf\extension_set.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\field_mask.pb.h include\google\protobuf\field_mask.pb.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_reflection.h include\google\protobuf\generated_enum_reflection.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_util.h include\google\protobuf\generated_enum_util.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_reflection.h include\google\protobuf\generated_message_reflection.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_util.h include\google\protobuf\generated_message_util.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\coded_stream.h include\google\protobuf\io\coded_stream.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\gzip_stream.h include\google\protobuf\io\gzip_stream.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\printer.h include\google\protobuf\io\printer.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\strtod.h include\google\protobuf\io\strtod.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\tokenizer.h include\google\protobuf\io\tokenizer.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream.h include\google\protobuf\io\zero_copy_stream.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream_impl.h include\google\protobuf\io\zero_copy_stream_impl.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream_impl_lite.h include\google\protobuf\io\zero_copy_stream_impl_lite.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map.h include\google\protobuf\map.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_entry.h include\google\protobuf\map_entry.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_entry_lite.h include\google\protobuf\map_entry_lite.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field.h include\google\protobuf\map_field.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field_inl.h include\google\protobuf\map_field_inl.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field_lite.h include\google\protobuf\map_field_lite.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_type_handler.h include\google\protobuf\map_type_handler.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\message.h include\google\protobuf\message.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\message_lite.h include\google\protobuf\message_lite.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\metadata.h include\google\protobuf\metadata.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\reflection.h include\google\protobuf\reflection.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\reflection_ops.h include\google\protobuf\reflection_ops.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\repeated_field.h include\google\protobuf\repeated_field.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\repeated_field_reflection.h include\google\protobuf\repeated_field_reflection.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\service.h include\google\protobuf\service.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\source_context.pb.h include\google\protobuf\source_context.pb.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\struct.pb.h include\google\protobuf\struct.pb.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomic_sequence_num.h include\google\protobuf\stubs\atomic_sequence_num.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops.h include\google\protobuf\stubs\atomicops.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm64_gcc.h include\google\protobuf\stubs\atomicops_internals_arm64_gcc.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm_gcc.h include\google\protobuf\stubs\atomicops_internals_arm_gcc.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm_qnx.h include\google\protobuf\stubs\atomicops_internals_arm_qnx.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_atomicword_compat.h include\google\protobuf\stubs\atomicops_internals_atomicword_compat.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_generic_gcc.h include\google\protobuf\stubs\atomicops_internals_generic_gcc.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_macosx.h include\google\protobuf\stubs\atomicops_internals_macosx.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_mips_gcc.h include\google\protobuf\stubs\atomicops_internals_mips_gcc.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_pnacl.h include\google\protobuf\stubs\atomicops_internals_pnacl.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_power.h include\google\protobuf\stubs\atomicops_internals_power.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_solaris.h include\google\protobuf\stubs\atomicops_internals_solaris.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_tsan.h include\google\protobuf\stubs\atomicops_internals_tsan.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_x86_gcc.h include\google\protobuf\stubs\atomicops_internals_x86_gcc.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_x86_msvc.h include\google\protobuf\stubs\atomicops_internals_x86_msvc.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\bytestream.h include\google\protobuf\stubs\bytestream.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\callback.h include\google\protobuf\stubs\callback.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\casts.h include\google\protobuf\stubs\casts.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\common.h include\google\protobuf\stubs\common.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\fastmem.h include\google\protobuf\stubs\fastmem.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\hash.h include\google\protobuf\stubs\hash.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\logging.h include\google\protobuf\stubs\logging.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\macros.h include\google\protobuf\stubs\macros.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\mutex.h include\google\protobuf\stubs\mutex.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\once.h include\google\protobuf\stubs\once.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\platform_macros.h include\google\protobuf\stubs\platform_macros.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\port.h include\google\protobuf\stubs\port.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\scoped_ptr.h include\google\protobuf\stubs\scoped_ptr.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\shared_ptr.h include\google\protobuf\stubs\shared_ptr.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\singleton.h include\google\protobuf\stubs\singleton.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\status.h include\google\protobuf\stubs\status.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\stl_util.h include\google\protobuf\stubs\stl_util.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\stringpiece.h include\google\protobuf\stubs\stringpiece.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\template_util.h include\google\protobuf\stubs\template_util.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\type_traits.h include\google\protobuf\stubs\type_traits.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\text_format.h include\google\protobuf\text_format.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\timestamp.pb.h include\google\protobuf\timestamp.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\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\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_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_lite.h include\google\protobuf\wire_format_lite.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format_lite_inl.h include\google\protobuf\wire_format_lite_inl.h
|
||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wrappers.pb.h include\google\protobuf\wrappers.pb.h
|
|
@ -0,0 +1,103 @@
|
|||
include(GNUInstallDirs)
|
||||
|
||||
foreach(_library
|
||||
libprotobuf-lite
|
||||
libprotobuf
|
||||
libprotoc)
|
||||
set_property(TARGET ${_library}
|
||||
PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||
install(TARGETS ${_library} EXPORT protobuf-targets
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${_library}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${_library}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${_library})
|
||||
endforeach()
|
||||
|
||||
install(TARGETS protoc EXPORT protobuf-targets
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc)
|
||||
|
||||
if(TRUE)
|
||||
file(STRINGS extract_includes.bat.in _extract_strings
|
||||
REGEX "^copy")
|
||||
foreach(_extract_string ${_extract_strings})
|
||||
string(REPLACE "copy \${PROTOBUF_SOURCE_WIN32_PATH}\\" ""
|
||||
_extract_string ${_extract_string})
|
||||
string(REPLACE "\\" "/" _extract_string ${_extract_string})
|
||||
string(REGEX MATCH "^[^ ]+"
|
||||
_extract_from ${_extract_string})
|
||||
string(REGEX REPLACE "^${_extract_from} ([^$]+)" "\\1"
|
||||
_extract_to ${_extract_string})
|
||||
get_filename_component(_extract_from "${protobuf_SOURCE_DIR}/${_extract_from}" ABSOLUTE)
|
||||
get_filename_component(_extract_name ${_extract_to} NAME)
|
||||
get_filename_component(_extract_to ${_extract_to} PATH)
|
||||
string(REPLACE "include/" "${CMAKE_INSTALL_INCLUDEDIR}/"
|
||||
_extract_to "${_extract_to}")
|
||||
if(EXISTS "${_extract_from}")
|
||||
install(FILES "${_extract_from}"
|
||||
DESTINATION "${_extract_to}"
|
||||
COMPONENT protobuf-headers
|
||||
RENAME "${_extract_name}")
|
||||
else()
|
||||
message(AUTHOR_WARNING "The file \"${_extract_from}\" is listed in "
|
||||
"\"${protobuf_SOURCE_DIR}/cmake/extract_includes.bat.in\" "
|
||||
"but there not exists. The file will not be installed.")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Internal function for parsing auto tools scripts
|
||||
function(_protobuf_auto_list FILE_NAME VARIABLE)
|
||||
file(STRINGS ${FILE_NAME} _strings)
|
||||
set(_list)
|
||||
foreach(_string ${_strings})
|
||||
set(_found)
|
||||
string(REGEX MATCH "^[ \t]*${VARIABLE}[ \t]*=[ \t]*" _found "${_string}")
|
||||
if(_found)
|
||||
string(LENGTH "${_found}" _length)
|
||||
string(SUBSTRING "${_string}" ${_length} -1 _draft_list)
|
||||
foreach(_item ${_draft_list})
|
||||
string(STRIP "${_item}" _item)
|
||||
list(APPEND _list "${_item}")
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
set(${VARIABLE} ${_list} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Install well-known type proto files
|
||||
_protobuf_auto_list("../src/Makefile.am" nobase_dist_proto_DATA)
|
||||
foreach(_file ${nobase_dist_proto_DATA})
|
||||
get_filename_component(_file_from "../src/${_file}" ABSOLUTE)
|
||||
get_filename_component(_file_name ${_file} NAME)
|
||||
get_filename_component(_file_path ${_file} PATH)
|
||||
if(EXISTS "${_file_from}")
|
||||
install(FILES "${_file_from}"
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_file_path}"
|
||||
COMPONENT protobuf-protos
|
||||
RENAME "${_file_name}")
|
||||
else()
|
||||
message(AUTHOR_WARNING "The file \"${_file_from}\" is listed in "
|
||||
"\"${protobuf_SOURCE_DIR}/../src/Makefile.am\" as nobase_dist_proto_DATA "
|
||||
"but there not exists. The file will not be installed.")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Export configuration
|
||||
|
||||
install(EXPORT protobuf-targets
|
||||
DESTINATION "lib/cmake/protobuf"
|
||||
COMPONENT protobuf-export)
|
||||
|
||||
configure_file(protobuf-config.cmake.in
|
||||
protobuf-config.cmake @ONLY)
|
||||
configure_file(protobuf-config-version.cmake.in
|
||||
protobuf-config-version.cmake @ONLY)
|
||||
configure_file(protobuf-module.cmake.in
|
||||
protobuf-module.cmake @ONLY)
|
||||
|
||||
install(FILES
|
||||
"${protobuf_BINARY_DIR}/protobuf-config.cmake"
|
||||
"${protobuf_BINARY_DIR}/protobuf-config-version.cmake"
|
||||
"${protobuf_BINARY_DIR}/protobuf-module.cmake"
|
||||
DESTINATION "lib/cmake/protobuf"
|
||||
COMPONENT protobuf-export)
|
|
@ -0,0 +1,38 @@
|
|||
set(libprotobuf_lite_files
|
||||
${protobuf_source_dir}/src/google/protobuf/arena.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/arenastring.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/extension_set.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_message_util.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/io/coded_stream.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/message_lite.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/repeated_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/stubs/atomicops_internals_x86_gcc.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/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/status.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/stubs/statusor.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/stubs/stringpiece.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/stubs/stringprintf.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/stubs/structurally_valid.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/stubs/strutil.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/stubs/time.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/wire_format_lite.cc
|
||||
)
|
||||
|
||||
add_library(libprotobuf-lite ${protobuf_SHARED_OR_STATIC}
|
||||
${libprotobuf_lite_files})
|
||||
target_link_libraries(libprotobuf-lite ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_include_directories(libprotobuf-lite PUBLIC ${protobuf_source_dir}/src)
|
||||
if(MSVC AND protobuf_BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(libprotobuf-lite
|
||||
PUBLIC PROTOBUF_USE_DLLS
|
||||
PRIVATE LIBPROTOBUF_EXPORTS)
|
||||
endif()
|
||||
set_target_properties(libprotobuf-lite PROPERTIES
|
||||
OUTPUT_NAME ${LIB_PREFIX}protobuf-lite
|
||||
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
|
|
@ -0,0 +1,68 @@
|
|||
set(libprotobuf_files
|
||||
${protobuf_source_dir}/src/google/protobuf/any.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/any.pb.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/api.pb.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/importer.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/parser.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/descriptor.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/descriptor.pb.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/descriptor_database.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/duration.pb.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/dynamic_message.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/empty.pb.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/extension_set_heavy.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/field_mask.pb.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_message_reflection.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/io/gzip_stream.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/io/printer.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/io/strtod.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/io/tokenizer.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/map_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/message.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/reflection_ops.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/service.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/source_context.pb.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/struct.pb.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/stubs/mathlimits.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/stubs/substitute.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/text_format.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/timestamp.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/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/default_value_objectwriter.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/util/internal/error_listener.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/util/internal/field_mask_utility.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/util/internal/json_escaping.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/util/internal/json_objectwriter.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/util/internal/json_stream_parser.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/util/internal/object_writer.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/util/internal/proto_writer.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectsource.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectwriter.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/util/internal/type_info.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/util/internal/type_info_test_helper.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/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/wire_format.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/wrappers.pb.cc
|
||||
)
|
||||
|
||||
add_library(libprotobuf ${protobuf_SHARED_OR_STATIC}
|
||||
${libprotobuf_lite_files} ${libprotobuf_files})
|
||||
target_link_libraries(libprotobuf ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARIES})
|
||||
target_include_directories(libprotobuf PUBLIC ${protobuf_source_dir}/src)
|
||||
if(MSVC AND protobuf_BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(libprotobuf
|
||||
PUBLIC PROTOBUF_USE_DLLS
|
||||
PRIVATE LIBPROTOBUF_EXPORTS)
|
||||
endif()
|
||||
set_target_properties(libprotobuf PROPERTIES
|
||||
OUTPUT_NAME ${LIB_PREFIX}protobuf
|
||||
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
|
|
@ -0,0 +1,106 @@
|
|||
set(libprotoc_files
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/code_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/command_line_interface.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_enum.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_extension.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_file.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_helpers.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_map_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_message.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_message_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_service.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_string_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_enum.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_enum_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_field_base.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_helpers.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_map_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_message.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_message_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_context.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_doc_comment.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_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_lite.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_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_generator_factory.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_helpers.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_lazy_message_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_map_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_map_field_lite.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_builder.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_builder_lite.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_field_lite.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_lite.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_name_resolver.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_primitive_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_service.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_shared_code_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_string_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_string_field_lite.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_enum.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_enum_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_extension.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_file.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_helpers.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_map_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_message.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_message_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/js/js_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_extension.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_file.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/plugin.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/plugin.pb.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/python/python_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/ruby/ruby_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/subprocess.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/zip_writer.cc
|
||||
)
|
||||
|
||||
add_library(libprotoc ${protobuf_SHARED_OR_STATIC}
|
||||
${libprotoc_files})
|
||||
target_link_libraries(libprotoc libprotobuf)
|
||||
if(MSVC AND protobuf_BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(libprotoc
|
||||
PUBLIC PROTOBUF_USE_DLLS
|
||||
PRIVATE LIBPROTOC_EXPORTS)
|
||||
endif()
|
||||
set_target_properties(libprotoc PROPERTIES
|
||||
COMPILE_DEFINITIONS LIBPROTOC_EXPORTS
|
||||
OUTPUT_NAME ${LIB_PREFIX}protoc
|
||||
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
|
|
@ -0,0 +1 @@
|
|||
set(PACKAGE_VERSION @protobuf_VERSION@)
|
|
@ -0,0 +1,27 @@
|
|||
# Version info variables
|
||||
set(PROTOBUF_VERSION "@protobuf_VERSION@")
|
||||
set(PROTOBUF_VERSION_STRING "@protobuf_VERSION_STRING@")
|
||||
|
||||
# Current dir
|
||||
get_filename_component(_PROTOBUF_PACKAGE_PREFIX
|
||||
"${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
|
||||
# Imported targets
|
||||
include("${_PROTOBUF_PACKAGE_PREFIX}/protobuf-targets.cmake")
|
||||
|
||||
# Compute the installation prefix relative to this file.
|
||||
get_filename_component(_PROTOBUF_IMPORT_PREFIX
|
||||
"${_PROTOBUF_PACKAGE_PREFIX}" PATH)
|
||||
get_filename_component(_PROTOBUF_IMPORT_PREFIX
|
||||
"${_PROTOBUF_IMPORT_PREFIX}" PATH)
|
||||
get_filename_component(_PROTOBUF_IMPORT_PREFIX
|
||||
"${_PROTOBUF_IMPORT_PREFIX}" PATH)
|
||||
|
||||
# CMake FindProtobuf module compatible file
|
||||
if(NOT DEFINED PROTOBUF_MODULE_COMPATIBLE OR "${PROTOBUF_MODULE_COMPATIBLE}")
|
||||
include("${_PROTOBUF_PACKAGE_PREFIX}/protobuf-module.cmake")
|
||||
endif()
|
||||
|
||||
# Cleanup temporary variables.
|
||||
set(_PROTOBUF_PACKAGE_PREFIX)
|
||||
set(_PROTOBUF_IMPORT_PREFIX)
|
|
@ -0,0 +1,139 @@
|
|||
if(PROTOBUF_SRC_ROOT_FOLDER)
|
||||
message(AUTHOR_WARNING "Variable PROTOBUF_SRC_ROOT_FOLDER defined, but not"
|
||||
" used in CONFIG mode")
|
||||
endif()
|
||||
|
||||
function(PROTOBUF_GENERATE_CPP SRCS HDRS)
|
||||
if(NOT ARGN)
|
||||
message(SEND_ERROR "Error: PROTOBUF_GENERATE_CPP() called without any proto files")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(PROTOBUF_GENERATE_CPP_APPEND_PATH)
|
||||
# Create an include path for each file specified
|
||||
foreach(FIL ${ARGN})
|
||||
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
|
||||
get_filename_component(ABS_PATH ${ABS_FIL} PATH)
|
||||
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
|
||||
if(${_contains_already} EQUAL -1)
|
||||
list(APPEND _protobuf_include_path -I ${ABS_PATH})
|
||||
endif()
|
||||
endforeach()
|
||||
else()
|
||||
set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
# Add well-known type protos include path
|
||||
list(APPEND _protobuf_include_path
|
||||
-I "${_PROTOBUF_IMPORT_PREFIX}/@CMAKE_INSTALL_INCLUDEDIR@")
|
||||
|
||||
if(DEFINED PROTOBUF_IMPORT_DIRS)
|
||||
foreach(DIR ${PROTOBUF_IMPORT_DIRS})
|
||||
get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
|
||||
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
|
||||
if(${_contains_already} EQUAL -1)
|
||||
list(APPEND _protobuf_include_path -I ${ABS_PATH})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set(${SRCS})
|
||||
set(${HDRS})
|
||||
foreach(FIL ${ARGN})
|
||||
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
|
||||
get_filename_component(FIL_WE ${FIL} NAME_WE)
|
||||
|
||||
list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc")
|
||||
list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h"
|
||||
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
|
||||
ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL}
|
||||
DEPENDS ${ABS_FIL} ${PROTOBUF_PROTOC_EXECUTABLE}
|
||||
COMMENT "Running C++ protocol buffer compiler on ${FIL}"
|
||||
VERBATIM)
|
||||
endforeach()
|
||||
|
||||
set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
|
||||
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
|
||||
set(${HDRS} ${${HDRS}} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Internal function: search for normal library as well as a debug one
|
||||
# if the debug one is specified also include debug/optimized keywords
|
||||
# in *_LIBRARIES variable
|
||||
function(_protobuf_find_libraries name filename)
|
||||
get_target_property(${name}_LIBRARY lib${filename}
|
||||
IMPORTED_LOCATION_RELEASE)
|
||||
set(${name}_LIBRARY "${${name}_LIBRARY}" PARENT_SCOPE)
|
||||
get_target_property(${name}_LIBRARY_DEBUG lib${filename}
|
||||
IMPORTED_LOCATION_DEBUG)
|
||||
set(${name}_LIBRARY_DEBUG "${${name}_LIBRARY_DEBUG}" PARENT_SCOPE)
|
||||
|
||||
if(NOT ${name}_LIBRARY_DEBUG)
|
||||
# There is no debug library
|
||||
set(${name}_LIBRARY_DEBUG ${${name}_LIBRARY} PARENT_SCOPE)
|
||||
set(${name}_LIBRARIES ${${name}_LIBRARY} PARENT_SCOPE)
|
||||
else()
|
||||
# There IS a debug library
|
||||
set(${name}_LIBRARIES
|
||||
optimized ${${name}_LIBRARY}
|
||||
debug ${${name}_LIBRARY_DEBUG}
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Internal function: find threads library
|
||||
function(_protobuf_find_threads)
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
find_package(Threads)
|
||||
if(Threads_FOUND)
|
||||
list(APPEND PROTOBUF_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
||||
set(PROTOBUF_LIBRARIES "${PROTOBUF_LIBRARIES}" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#
|
||||
# Main.
|
||||
#
|
||||
|
||||
# By default have PROTOBUF_GENERATE_CPP macro pass -I to protoc
|
||||
# for each directory where a proto file is referenced.
|
||||
if(NOT DEFINED PROTOBUF_GENERATE_CPP_APPEND_PATH)
|
||||
set(PROTOBUF_GENERATE_CPP_APPEND_PATH TRUE)
|
||||
endif()
|
||||
|
||||
# The Protobuf library
|
||||
_protobuf_find_libraries(PROTOBUF protobuf)
|
||||
|
||||
# The Protobuf Lite library
|
||||
_protobuf_find_libraries(PROTOBUF_LITE protobuf-lite)
|
||||
|
||||
# The Protobuf Protoc Library
|
||||
_protobuf_find_libraries(PROTOBUF_PROTOC protoc)
|
||||
|
||||
if(UNIX)
|
||||
_protobuf_find_threads()
|
||||
endif()
|
||||
|
||||
# Set the include directory
|
||||
set(PROTOBUF_INCLUDE_DIR "${_PROTOBUF_IMPORT_PREFIX}/@CMAKE_INSTALL_INCLUDEDIR@")
|
||||
|
||||
# Set the protoc Executable
|
||||
get_target_property(PROTOBUF_PROTOC_EXECUTABLE protoc
|
||||
IMPORTED_LOCATION_RELEASE)
|
||||
if(NOT PROTOBUF_PROTOC_EXECUTABLE)
|
||||
get_target_property(PROTOBUF_PROTOC_EXECUTABLE protoc
|
||||
IMPORTED_LOCATION_DEBUG)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROTOBUF DEFAULT_MSG
|
||||
PROTOBUF_LIBRARY PROTOBUF_INCLUDE_DIR)
|
||||
|
||||
if(PROTOBUF_FOUND)
|
||||
set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIR})
|
||||
endif()
|
|
@ -0,0 +1,6 @@
|
|||
set(protoc_files
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/main.cc
|
||||
)
|
||||
|
||||
add_executable(protoc ${protoc_files})
|
||||
target_link_libraries(protoc libprotobuf libprotoc)
|
|
@ -0,0 +1,214 @@
|
|||
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/../gmock/CMakeLists.txt")
|
||||
message(FATAL_ERROR "Cannot find gmock directory.")
|
||||
endif()
|
||||
|
||||
option(protobuf_ABSOLUTE_TEST_PLUGIN_PATH
|
||||
"Using absolute test_plugin path in tests" ON)
|
||||
|
||||
include_directories(
|
||||
${protobuf_source_dir}/gmock
|
||||
${protobuf_source_dir}/gmock/gtest
|
||||
${protobuf_source_dir}/gmock/gtest/include
|
||||
${protobuf_source_dir}/gmock/include
|
||||
)
|
||||
|
||||
add_library(gmock STATIC
|
||||
${protobuf_source_dir}/gmock/src/gmock-all.cc
|
||||
${protobuf_source_dir}/gmock/gtest/src/gtest-all.cc
|
||||
)
|
||||
add_library(gmock_main STATIC ${protobuf_source_dir}/gmock/src/gmock_main.cc)
|
||||
target_link_libraries(gmock_main gmock)
|
||||
|
||||
set(lite_test_protos
|
||||
google/protobuf/map_lite_unittest.proto
|
||||
google/protobuf/unittest_import_lite.proto
|
||||
google/protobuf/unittest_import_public_lite.proto
|
||||
google/protobuf/unittest_lite.proto
|
||||
google/protobuf/unittest_no_arena_lite.proto
|
||||
)
|
||||
|
||||
set(tests_protos
|
||||
google/protobuf/any_test.proto
|
||||
google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto
|
||||
google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto
|
||||
google/protobuf/map_proto2_unittest.proto
|
||||
google/protobuf/map_unittest.proto
|
||||
google/protobuf/unittest.proto
|
||||
google/protobuf/unittest_arena.proto
|
||||
google/protobuf/unittest_custom_options.proto
|
||||
google/protobuf/unittest_drop_unknown_fields.proto
|
||||
google/protobuf/unittest_embed_optimize_for.proto
|
||||
google/protobuf/unittest_empty.proto
|
||||
google/protobuf/unittest_import.proto
|
||||
google/protobuf/unittest_import_public.proto
|
||||
google/protobuf/unittest_lite_imports_nonlite.proto
|
||||
google/protobuf/unittest_mset.proto
|
||||
google/protobuf/unittest_mset_wire_format.proto
|
||||
google/protobuf/unittest_no_arena.proto
|
||||
google/protobuf/unittest_no_arena_import.proto
|
||||
google/protobuf/unittest_no_field_presence.proto
|
||||
google/protobuf/unittest_no_generic_services.proto
|
||||
google/protobuf/unittest_optimize_for.proto
|
||||
google/protobuf/unittest_preserve_unknown_enum.proto
|
||||
google/protobuf/unittest_preserve_unknown_enum2.proto
|
||||
google/protobuf/unittest_proto3_arena.proto
|
||||
google/protobuf/unittest_proto3_arena_lite.proto
|
||||
google/protobuf/unittest_proto3_lite.proto
|
||||
google/protobuf/unittest_well_known_types.proto
|
||||
google/protobuf/util/internal/testdata/anys.proto
|
||||
google/protobuf/util/internal/testdata/books.proto
|
||||
google/protobuf/util/internal/testdata/default_value.proto
|
||||
google/protobuf/util/internal/testdata/default_value_test.proto
|
||||
google/protobuf/util/internal/testdata/field_mask.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/timestamp_duration.proto
|
||||
google/protobuf/util/json_format_proto3.proto
|
||||
google/protobuf/util/message_differencer_unittest.proto
|
||||
)
|
||||
|
||||
macro(compile_proto_file filename)
|
||||
get_filename_component(dirname ${filename} PATH)
|
||||
get_filename_component(basename ${filename} NAME_WE)
|
||||
add_custom_command(
|
||||
OUTPUT ${protobuf_source_dir}/src/${dirname}/${basename}.pb.cc
|
||||
DEPENDS protoc ${protobuf_source_dir}/src/${dirname}/${basename}.proto
|
||||
COMMAND protoc ${protobuf_source_dir}/src/${dirname}/${basename}.proto
|
||||
--proto_path=${protobuf_source_dir}/src
|
||||
--cpp_out=${protobuf_source_dir}/src
|
||||
)
|
||||
endmacro(compile_proto_file)
|
||||
|
||||
set(lite_test_proto_files)
|
||||
foreach(proto_file ${lite_test_protos})
|
||||
compile_proto_file(${proto_file})
|
||||
string(REPLACE .proto .pb.cc pb_file ${proto_file})
|
||||
set(lite_test_proto_files ${lite_test_proto_files}
|
||||
${protobuf_source_dir}/src/${pb_file})
|
||||
endforeach(proto_file)
|
||||
|
||||
set(tests_proto_files)
|
||||
foreach(proto_file ${tests_protos})
|
||||
compile_proto_file(${proto_file})
|
||||
string(REPLACE .proto .pb.cc pb_file ${proto_file})
|
||||
set(tests_proto_files ${tests_proto_files}
|
||||
${protobuf_source_dir}/src/${pb_file})
|
||||
endforeach(proto_file)
|
||||
|
||||
set(common_test_files
|
||||
${protobuf_source_dir}/src/google/protobuf/arena_test_util.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/map_test_util.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/test_util.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/testing/file.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/testing/googletest.cc
|
||||
)
|
||||
|
||||
set(common_lite_test_files
|
||||
${protobuf_source_dir}/src/google/protobuf/arena_test_util.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/map_lite_test_util.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/test_util_lite.cc
|
||||
)
|
||||
|
||||
set(tests_files
|
||||
${protobuf_source_dir}/src/google/protobuf/any_test.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/arena_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/arenastring_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/command_line_interface_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/metadata_test.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/importer_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_doc_comment_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_plugin_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/mock_code_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/parser_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/python/python_plugin_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/descriptor_database_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/descriptor_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/drop_unknown_fields_test.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/dynamic_message_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/extension_set_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_message_reflection_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/io/coded_stream_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/io/printer_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/io/tokenizer_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/map_field_test.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/map_test.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/message_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/no_field_presence_test.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/preserve_unknown_enum_test.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/proto3_arena_lite_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/proto3_arena_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/proto3_lite_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/reflection_ops_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/repeated_field_reflection_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/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/status_test.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/stubs/statusor_test.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/stubs/stringpiece_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/stubs/stringprintf_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/stubs/structurally_valid_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/stubs/strutil_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/stubs/template_util_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/stubs/time_test.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/stubs/type_traits_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/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/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/protostream_objectsource_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/json_util_test.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/util/message_differencer_unittest.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/well_known_types_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/wire_format_unittest.cc
|
||||
)
|
||||
|
||||
if(protobuf_ABSOLUTE_TEST_PLUGIN_PATH)
|
||||
add_compile_options(-DGOOGLE_PROTOBUF_TEST_PLUGIN_PATH="$<TARGET_FILE:test_plugin>")
|
||||
endif()
|
||||
|
||||
add_executable(tests ${tests_files} ${common_test_files} ${tests_proto_files} ${lite_test_proto_files})
|
||||
target_link_libraries(tests libprotoc libprotobuf gmock_main)
|
||||
|
||||
set(test_plugin_files
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/mock_code_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/testing/file.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/testing/file.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/test_plugin.cc
|
||||
)
|
||||
|
||||
add_executable(test_plugin ${test_plugin_files})
|
||||
target_link_libraries(test_plugin libprotoc libprotobuf gmock)
|
||||
|
||||
set(lite_test_files
|
||||
${protobuf_source_dir}/src/google/protobuf/lite_unittest.cc
|
||||
)
|
||||
add_executable(lite-test ${lite_test_files} ${common_lite_test_files} ${lite_test_proto_files})
|
||||
target_link_libraries(lite-test libprotobuf-lite)
|
||||
|
||||
set(lite_arena_test_files
|
||||
${protobuf_source_dir}/src/google/protobuf/lite_arena_unittest.cc
|
||||
)
|
||||
add_executable(lite-arena-test ${lite_arena_test_files} ${common_lite_test_files} ${lite_test_proto_files})
|
||||
target_link_libraries(lite-arena-test libprotobuf-lite gmock_main)
|
||||
|
||||
add_custom_target(check
|
||||
COMMAND tests
|
||||
WORKING_DIRECTORY ${protobuf_source_dir})
|
|
@ -0,0 +1,184 @@
|
|||
## Process this file with autoconf to produce configure.
|
||||
## In general, the safest way to proceed is to run ./autogen.sh
|
||||
|
||||
AC_PREREQ(2.59)
|
||||
|
||||
# Note: If you change the version, you must also update it in:
|
||||
# * java/pom.xml
|
||||
# * python/setup.py
|
||||
# * src/google/protobuf/stubs/common.h
|
||||
# * src/Makefile.am (Update -version-info for LDFLAGS if needed)
|
||||
#
|
||||
# In the SVN trunk, the version should always be the next anticipated release
|
||||
# version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed
|
||||
# the size of one file name in the dist tarfile over the 99-char limit.)
|
||||
AC_INIT([Protocol Buffers],[3.0.0-beta-3],[protobuf@googlegroups.com],[protobuf])
|
||||
|
||||
AM_MAINTAINER_MODE([enable])
|
||||
|
||||
AC_CONFIG_SRCDIR(src/google/protobuf/message.cc)
|
||||
# The config file is generated but not used by the source code, since we only
|
||||
# need very few of them, e.g. HAVE_PTHREAD and HAVE_ZLIB. Those macros are
|
||||
# passed down in CXXFLAGS manually in src/Makefile.am
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
AC_ARG_VAR(DIST_LANG, [language to include in the distribution package (i.e., make dist)])
|
||||
case "$DIST_LANG" in
|
||||
"") DIST_LANG=all ;;
|
||||
all | cpp | csharp | java | python | javanano | objectivec | ruby | js) ;;
|
||||
*) AC_MSG_FAILURE([unknown language: $DIST_LANG]) ;;
|
||||
esac
|
||||
AC_SUBST(DIST_LANG)
|
||||
|
||||
# autoconf's default CXXFLAGS are usually "-g -O2". These aren't necessarily
|
||||
# the best choice for libprotobuf.
|
||||
AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"],
|
||||
[CFLAGS=""])
|
||||
AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
|
||||
[CXXFLAGS=""])
|
||||
|
||||
AC_CANONICAL_TARGET
|
||||
|
||||
AM_INIT_AUTOMAKE([1.9 tar-ustar subdir-objects])
|
||||
|
||||
AC_ARG_WITH([zlib],
|
||||
[AS_HELP_STRING([--with-zlib],
|
||||
[include classes for streaming compressed data in and out @<:@default=check@:>@])],
|
||||
[],[with_zlib=check])
|
||||
|
||||
AC_ARG_WITH([protoc],
|
||||
[AS_HELP_STRING([--with-protoc=COMMAND],
|
||||
[use the given protoc command instead of building a new one when building tests (useful for cross-compiling)])],
|
||||
[],[with_protoc=no])
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
AC_LANG([C++])
|
||||
ACX_USE_SYSTEM_EXTENSIONS
|
||||
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
|
||||
AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
|
||||
AC_PROG_OBJC
|
||||
|
||||
# test_util.cc takes forever to compile with GCC and optimization turned on.
|
||||
AC_MSG_CHECKING([C++ compiler flags...])
|
||||
AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],[
|
||||
AS_IF([test "$GCC" = "yes"],[
|
||||
PROTOBUF_OPT_FLAG="-O2"
|
||||
CXXFLAGS="${CXXFLAGS} -g"
|
||||
])
|
||||
|
||||
# Protocol Buffers contains several checks that are intended to be used only
|
||||
# for debugging and which might hurt performance. Most users are probably
|
||||
# end users who don't want these checks, so add -DNDEBUG by default.
|
||||
CXXFLAGS="$CXXFLAGS -DNDEBUG"
|
||||
|
||||
AC_MSG_RESULT([use default: $PROTOBUF_OPT_FLAG $CXXFLAGS])
|
||||
],[
|
||||
AC_MSG_RESULT([use user-supplied: $CXXFLAGS])
|
||||
])
|
||||
|
||||
AC_SUBST(PROTOBUF_OPT_FLAG)
|
||||
|
||||
ACX_CHECK_SUNCC
|
||||
|
||||
# Have to do libtool after SUNCC, other wise it "helpfully" adds Crun Cstd
|
||||
# to the link
|
||||
AC_PROG_LIBTOOL
|
||||
|
||||
# Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h])
|
||||
|
||||
# Checks for library functions.
|
||||
AC_FUNC_MEMCMP
|
||||
AC_FUNC_STRTOD
|
||||
AC_CHECK_FUNCS([ftruncate memset mkdir strchr strerror strtol])
|
||||
|
||||
# Check for zlib.
|
||||
HAVE_ZLIB=0
|
||||
AS_IF([test "$with_zlib" != no], [
|
||||
AC_MSG_CHECKING([zlib version])
|
||||
|
||||
# First check the zlib header version.
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
#include <zlib.h>
|
||||
#if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1204)
|
||||
# error zlib version too old
|
||||
#endif
|
||||
]], [])], [
|
||||
AC_MSG_RESULT([ok (1.2.0.4 or later)])
|
||||
|
||||
# Also need to add -lz to the linker flags and make sure this succeeds.
|
||||
AC_SEARCH_LIBS([zlibVersion], [z], [
|
||||
AC_DEFINE([HAVE_ZLIB], [1], [Enable classes using zlib compression.])
|
||||
HAVE_ZLIB=1
|
||||
], [
|
||||
AS_IF([test "$with_zlib" != check], [
|
||||
AC_MSG_FAILURE([--with-zlib was given, but no working zlib library was found])
|
||||
])
|
||||
])
|
||||
], [
|
||||
AS_IF([test "$with_zlib" = check], [
|
||||
AC_MSG_RESULT([headers missing or too old (requires 1.2.0.4)])
|
||||
], [
|
||||
AC_MSG_FAILURE([--with-zlib was given, but zlib headers were not present or were too old (requires 1.2.0.4)])
|
||||
])
|
||||
])
|
||||
])
|
||||
AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1])
|
||||
|
||||
AS_IF([test "$with_protoc" != "no"], [
|
||||
PROTOC=$with_protoc
|
||||
AS_IF([test "$with_protoc" = "yes"], [
|
||||
# No argument given. Use system protoc.
|
||||
PROTOC=protoc
|
||||
])
|
||||
AS_IF([echo "$PROTOC" | grep -q '^@<:@^/@:>@.*/'], [
|
||||
# Does not start with a slash, but contains a slash. So, it's a relative
|
||||
# path (as opposed to an absolute path or an executable in $PATH).
|
||||
# Since it will actually be executed from the src directory, prefix with
|
||||
# the current directory. We also insert $ac_top_build_prefix in case this
|
||||
# is a nested package and --with-protoc was actually given on the outer
|
||||
# package's configure script.
|
||||
PROTOC=`pwd`/${ac_top_build_prefix}$PROTOC
|
||||
])
|
||||
AC_SUBST([PROTOC])
|
||||
])
|
||||
AM_CONDITIONAL([USE_EXTERNAL_PROTOC], [test "$with_protoc" != "no"])
|
||||
|
||||
ACX_PTHREAD
|
||||
AM_CONDITIONAL([HAVE_PTHREAD], [test "x$acx_pthread_ok" = "xyes"])
|
||||
|
||||
# We still keep this for improving pbconfig.h for unsupported platforms.
|
||||
AC_CXX_STL_HASH
|
||||
|
||||
case "$target_os" in
|
||||
mingw* | cygwin* | win*)
|
||||
;;
|
||||
*)
|
||||
# Need to link against rt on Solaris
|
||||
AC_SEARCH_LIBS([sched_yield], [rt], [], [AC_MSG_FAILURE([sched_yield was not found on your system])])
|
||||
;;
|
||||
esac
|
||||
|
||||
# Enable ObjC support for conformance directory on OS X.
|
||||
OBJC_CONFORMANCE_TEST=0
|
||||
case "$target_os" in
|
||||
darwin*)
|
||||
OBJC_CONFORMANCE_TEST=1
|
||||
;;
|
||||
esac
|
||||
AM_CONDITIONAL([OBJC_CONFORMANCE_TEST], [test $OBJC_CONFORMANCE_TEST = 1])
|
||||
|
||||
# HACK: Make gmock's configure script pick up our copy of CFLAGS and CXXFLAGS,
|
||||
# since the flags added by ACX_CHECK_SUNCC must be used when compiling gmock
|
||||
# too.
|
||||
export CFLAGS
|
||||
export CXXFLAGS
|
||||
AC_CONFIG_SUBDIRS([gmock])
|
||||
|
||||
AC_CONFIG_FILES([Makefile src/Makefile benchmarks/Makefile conformance/Makefile protobuf.pc protobuf-lite.pc])
|
||||
AC_OUTPUT
|
|
@ -0,0 +1,142 @@
|
|||
|
||||
import com.google.protobuf.conformance.Conformance;
|
||||
import com.google.protobuf.util.JsonFormat;
|
||||
import com.google.protobuf.util.JsonFormat.TypeRegistry;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
|
||||
class ConformanceJava {
|
||||
private int testCount = 0;
|
||||
private TypeRegistry typeRegistry;
|
||||
|
||||
private boolean readFromStdin(byte[] buf, int len) throws Exception {
|
||||
int ofs = 0;
|
||||
while (len > 0) {
|
||||
int read = System.in.read(buf, ofs, len);
|
||||
if (read == -1) {
|
||||
return false; // EOF
|
||||
}
|
||||
ofs += read;
|
||||
len -= read;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void writeToStdout(byte[] buf) throws Exception {
|
||||
System.out.write(buf);
|
||||
}
|
||||
|
||||
// Returns -1 on EOF (the actual values will always be positive).
|
||||
private int readLittleEndianIntFromStdin() throws Exception {
|
||||
byte[] buf = new byte[4];
|
||||
if (!readFromStdin(buf, 4)) {
|
||||
return -1;
|
||||
}
|
||||
return (buf[0] & 0xff)
|
||||
| ((buf[1] & 0xff) << 8)
|
||||
| ((buf[2] & 0xff) << 16)
|
||||
| ((buf[3] & 0xff) << 24);
|
||||
}
|
||||
|
||||
private void writeLittleEndianIntToStdout(int val) throws Exception {
|
||||
byte[] buf = new byte[4];
|
||||
buf[0] = (byte)val;
|
||||
buf[1] = (byte)(val >> 8);
|
||||
buf[2] = (byte)(val >> 16);
|
||||
buf[3] = (byte)(val >> 24);
|
||||
writeToStdout(buf);
|
||||
}
|
||||
|
||||
private Conformance.ConformanceResponse doTest(Conformance.ConformanceRequest request) {
|
||||
Conformance.TestAllTypes testMessage;
|
||||
|
||||
switch (request.getPayloadCase()) {
|
||||
case PROTOBUF_PAYLOAD: {
|
||||
try {
|
||||
testMessage = Conformance.TestAllTypes.parseFrom(request.getProtobufPayload());
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
return Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case JSON_PAYLOAD: {
|
||||
try {
|
||||
Conformance.TestAllTypes.Builder builder = Conformance.TestAllTypes.newBuilder();
|
||||
JsonFormat.parser().usingTypeRegistry(typeRegistry)
|
||||
.merge(request.getJsonPayload(), builder);
|
||||
testMessage = builder.build();
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
return Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PAYLOAD_NOT_SET: {
|
||||
throw new RuntimeException("Request didn't have payload.");
|
||||
}
|
||||
|
||||
default: {
|
||||
throw new RuntimeException("Unexpected payload case.");
|
||||
}
|
||||
}
|
||||
|
||||
switch (request.getRequestedOutputFormat()) {
|
||||
case UNSPECIFIED:
|
||||
throw new RuntimeException("Unspecified output format.");
|
||||
|
||||
case PROTOBUF:
|
||||
return Conformance.ConformanceResponse.newBuilder().setProtobufPayload(testMessage.toByteString()).build();
|
||||
|
||||
case JSON:
|
||||
try {
|
||||
return Conformance.ConformanceResponse.newBuilder().setJsonPayload(
|
||||
JsonFormat.printer().usingTypeRegistry(typeRegistry).print(testMessage)).build();
|
||||
} catch (InvalidProtocolBufferException | IllegalArgumentException e) {
|
||||
return Conformance.ConformanceResponse.newBuilder().setSerializeError(
|
||||
e.getMessage()).build();
|
||||
}
|
||||
|
||||
default: {
|
||||
throw new RuntimeException("Unexpected request output.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean doTestIo() throws Exception {
|
||||
int bytes = readLittleEndianIntFromStdin();
|
||||
|
||||
if (bytes == -1) {
|
||||
return false; // EOF
|
||||
}
|
||||
|
||||
byte[] serializedInput = new byte[bytes];
|
||||
|
||||
if (!readFromStdin(serializedInput, bytes)) {
|
||||
throw new RuntimeException("Unexpected EOF from test program.");
|
||||
}
|
||||
|
||||
Conformance.ConformanceRequest request =
|
||||
Conformance.ConformanceRequest.parseFrom(serializedInput);
|
||||
Conformance.ConformanceResponse response = doTest(request);
|
||||
byte[] serializedOutput = response.toByteArray();
|
||||
|
||||
writeLittleEndianIntToStdout(serializedOutput.length);
|
||||
writeToStdout(serializedOutput);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
typeRegistry = TypeRegistry.newBuilder().add(
|
||||
Conformance.TestAllTypes.getDescriptor()).build();
|
||||
while (doTestIo()) {
|
||||
this.testCount++;
|
||||
}
|
||||
|
||||
System.err.println("ConformanceJava: received EOF from test runner after " +
|
||||
this.testCount + " tests");
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new ConformanceJava().run();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
|
||||
import com.google.protobuf.conformance.Conformance;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
|
||||
class ConformanceJavaLite {
|
||||
private int testCount = 0;
|
||||
|
||||
private boolean readFromStdin(byte[] buf, int len) throws Exception {
|
||||
int ofs = 0;
|
||||
while (len > 0) {
|
||||
int read = System.in.read(buf, ofs, len);
|
||||
if (read == -1) {
|
||||
return false; // EOF
|
||||
}
|
||||
ofs += read;
|
||||
len -= read;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void writeToStdout(byte[] buf) throws Exception {
|
||||
System.out.write(buf);
|
||||
}
|
||||
|
||||
// Returns -1 on EOF (the actual values will always be positive).
|
||||
private int readLittleEndianIntFromStdin() throws Exception {
|
||||
byte[] buf = new byte[4];
|
||||
if (!readFromStdin(buf, 4)) {
|
||||
return -1;
|
||||
}
|
||||
return (buf[0] & 0xff)
|
||||
| ((buf[1] & 0xff) << 8)
|
||||
| ((buf[2] & 0xff) << 16)
|
||||
| ((buf[3] & 0xff) << 24);
|
||||
}
|
||||
|
||||
private void writeLittleEndianIntToStdout(int val) throws Exception {
|
||||
byte[] buf = new byte[4];
|
||||
buf[0] = (byte)val;
|
||||
buf[1] = (byte)(val >> 8);
|
||||
buf[2] = (byte)(val >> 16);
|
||||
buf[3] = (byte)(val >> 24);
|
||||
writeToStdout(buf);
|
||||
}
|
||||
|
||||
private Conformance.ConformanceResponse doTest(Conformance.ConformanceRequest request) {
|
||||
Conformance.TestAllTypes testMessage;
|
||||
|
||||
switch (request.getPayloadCase()) {
|
||||
case PROTOBUF_PAYLOAD: {
|
||||
try {
|
||||
testMessage = Conformance.TestAllTypes.parseFrom(request.getProtobufPayload());
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
return Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case JSON_PAYLOAD: {
|
||||
return Conformance.ConformanceResponse.newBuilder().setSkipped(
|
||||
"Lite runtime does not suport Json Formant.").build();
|
||||
}
|
||||
case PAYLOAD_NOT_SET: {
|
||||
throw new RuntimeException("Request didn't have payload.");
|
||||
}
|
||||
|
||||
default: {
|
||||
throw new RuntimeException("Unexpected payload case.");
|
||||
}
|
||||
}
|
||||
|
||||
switch (request.getRequestedOutputFormat()) {
|
||||
case UNSPECIFIED:
|
||||
throw new RuntimeException("Unspecified output format.");
|
||||
|
||||
case PROTOBUF:
|
||||
return Conformance.ConformanceResponse.newBuilder().setProtobufPayload(testMessage.toByteString()).build();
|
||||
|
||||
case JSON:
|
||||
return Conformance.ConformanceResponse.newBuilder().setSkipped(
|
||||
"Lite runtime does not suport Json Formant.").build();
|
||||
|
||||
default: {
|
||||
throw new RuntimeException("Unexpected request output.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean doTestIo() throws Exception {
|
||||
int bytes = readLittleEndianIntFromStdin();
|
||||
|
||||
if (bytes == -1) {
|
||||
return false; // EOF
|
||||
}
|
||||
|
||||
byte[] serializedInput = new byte[bytes];
|
||||
|
||||
if (!readFromStdin(serializedInput, bytes)) {
|
||||
throw new RuntimeException("Unexpected EOF from test program.");
|
||||
}
|
||||
|
||||
Conformance.ConformanceRequest request =
|
||||
Conformance.ConformanceRequest.parseFrom(serializedInput);
|
||||
Conformance.ConformanceResponse response = doTest(request);
|
||||
byte[] serializedOutput = response.toByteArray();
|
||||
|
||||
writeLittleEndianIntToStdout(serializedOutput.length);
|
||||
writeToStdout(serializedOutput);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
while (doTestIo()) {
|
||||
this.testCount++;
|
||||
}
|
||||
|
||||
System.err.println("ConformanceJavaLite: received EOF from test runner after " +
|
||||
this.testCount + " tests");
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new ConformanceJavaLite().run();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,281 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
conformance_protoc_inputs = \
|
||||
conformance.proto
|
||||
|
||||
well_known_type_protoc_inputs = \
|
||||
$(top_srcdir)/src/google/protobuf/any.proto \
|
||||
$(top_srcdir)/src/google/protobuf/duration.proto \
|
||||
$(top_srcdir)/src/google/protobuf/field_mask.proto \
|
||||
$(top_srcdir)/src/google/protobuf/struct.proto \
|
||||
$(top_srcdir)/src/google/protobuf/timestamp.proto \
|
||||
$(top_srcdir)/src/google/protobuf/wrappers.proto
|
||||
|
||||
|
||||
protoc_outputs = \
|
||||
conformance.pb.cc \
|
||||
conformance.pb.h
|
||||
|
||||
other_language_protoc_outputs = \
|
||||
conformance_pb2.py \
|
||||
Conformance.pbobjc.h \
|
||||
Conformance.pbobjc.m \
|
||||
conformance.rb \
|
||||
com/google/protobuf/Any.java \
|
||||
com/google/protobuf/AnyOrBuilder.java \
|
||||
com/google/protobuf/AnyProto.java \
|
||||
com/google/protobuf/BoolValue.java \
|
||||
com/google/protobuf/BoolValueOrBuilder.java \
|
||||
com/google/protobuf/BytesValue.java \
|
||||
com/google/protobuf/BytesValueOrBuilder.java \
|
||||
com/google/protobuf/conformance/Conformance.java \
|
||||
com/google/protobuf/DoubleValue.java \
|
||||
com/google/protobuf/DoubleValueOrBuilder.java \
|
||||
com/google/protobuf/Duration.java \
|
||||
com/google/protobuf/DurationOrBuilder.java \
|
||||
com/google/protobuf/DurationProto.java \
|
||||
com/google/protobuf/FieldMask.java \
|
||||
com/google/protobuf/FieldMaskOrBuilder.java \
|
||||
com/google/protobuf/FieldMaskProto.java \
|
||||
com/google/protobuf/FloatValue.java \
|
||||
com/google/protobuf/FloatValueOrBuilder.java \
|
||||
com/google/protobuf/Int32Value.java \
|
||||
com/google/protobuf/Int32ValueOrBuilder.java \
|
||||
com/google/protobuf/Int64Value.java \
|
||||
com/google/protobuf/Int64ValueOrBuilder.java \
|
||||
com/google/protobuf/ListValue.java \
|
||||
com/google/protobuf/ListValueOrBuilder.java \
|
||||
com/google/protobuf/NullValue.java \
|
||||
com/google/protobuf/StringValue.java \
|
||||
com/google/protobuf/StringValueOrBuilder.java \
|
||||
com/google/protobuf/Struct.java \
|
||||
com/google/protobuf/StructOrBuilder.java \
|
||||
com/google/protobuf/StructProto.java \
|
||||
com/google/protobuf/Timestamp.java \
|
||||
com/google/protobuf/TimestampOrBuilder.java \
|
||||
com/google/protobuf/TimestampProto.java \
|
||||
com/google/protobuf/UInt32Value.java \
|
||||
com/google/protobuf/UInt32ValueOrBuilder.java \
|
||||
com/google/protobuf/UInt64Value.java \
|
||||
com/google/protobuf/UInt64ValueOrBuilder.java \
|
||||
com/google/protobuf/Value.java \
|
||||
com/google/protobuf/ValueOrBuilder.java \
|
||||
com/google/protobuf/WrappersProto.java \
|
||||
google/protobuf/any.pb.cc \
|
||||
google/protobuf/any.pb.h \
|
||||
google/protobuf/any.rb \
|
||||
google/protobuf/any_pb2.py \
|
||||
google/protobuf/duration.pb.cc \
|
||||
google/protobuf/duration.pb.h \
|
||||
google/protobuf/duration.rb \
|
||||
google/protobuf/duration_pb2.py \
|
||||
google/protobuf/field_mask.pb.cc \
|
||||
google/protobuf/field_mask.pb.h \
|
||||
google/protobuf/field_mask.rb \
|
||||
google/protobuf/field_mask_pb2.py \
|
||||
google/protobuf/struct.pb.cc \
|
||||
google/protobuf/struct.pb.h \
|
||||
google/protobuf/struct.rb \
|
||||
google/protobuf/struct_pb2.py \
|
||||
google/protobuf/timestamp.pb.cc \
|
||||
google/protobuf/timestamp.pb.h \
|
||||
google/protobuf/timestamp.rb \
|
||||
google/protobuf/timestamp_pb2.py \
|
||||
google/protobuf/wrappers.pb.cc \
|
||||
google/protobuf/wrappers.pb.h \
|
||||
google/protobuf/wrappers.rb \
|
||||
google/protobuf/wrappers_pb2.py \
|
||||
lite/com/google/protobuf/Any.java \
|
||||
lite/com/google/protobuf/AnyOrBuilder.java \
|
||||
lite/com/google/protobuf/AnyProto.java \
|
||||
lite/com/google/protobuf/BoolValue.java \
|
||||
lite/com/google/protobuf/BoolValueOrBuilder.java \
|
||||
lite/com/google/protobuf/BytesValue.java \
|
||||
lite/com/google/protobuf/BytesValueOrBuilder.java \
|
||||
lite/com/google/protobuf/conformance/Conformance.java \
|
||||
lite/com/google/protobuf/DoubleValue.java \
|
||||
lite/com/google/protobuf/DoubleValueOrBuilder.java \
|
||||
lite/com/google/protobuf/Duration.java \
|
||||
lite/com/google/protobuf/DurationOrBuilder.java \
|
||||
lite/com/google/protobuf/DurationProto.java \
|
||||
lite/com/google/protobuf/FieldMask.java \
|
||||
lite/com/google/protobuf/FieldMaskOrBuilder.java \
|
||||
lite/com/google/protobuf/FieldMaskProto.java \
|
||||
lite/com/google/protobuf/FloatValue.java \
|
||||
lite/com/google/protobuf/FloatValueOrBuilder.java \
|
||||
lite/com/google/protobuf/Int32Value.java \
|
||||
lite/com/google/protobuf/Int32ValueOrBuilder.java \
|
||||
lite/com/google/protobuf/Int64Value.java \
|
||||
lite/com/google/protobuf/Int64ValueOrBuilder.java \
|
||||
lite/com/google/protobuf/ListValue.java \
|
||||
lite/com/google/protobuf/ListValueOrBuilder.java \
|
||||
lite/com/google/protobuf/NullValue.java \
|
||||
lite/com/google/protobuf/StringValue.java \
|
||||
lite/com/google/protobuf/StringValueOrBuilder.java \
|
||||
lite/com/google/protobuf/Struct.java \
|
||||
lite/com/google/protobuf/StructOrBuilder.java \
|
||||
lite/com/google/protobuf/StructProto.java \
|
||||
lite/com/google/protobuf/Timestamp.java \
|
||||
lite/com/google/protobuf/TimestampOrBuilder.java \
|
||||
lite/com/google/protobuf/TimestampProto.java \
|
||||
lite/com/google/protobuf/UInt32Value.java \
|
||||
lite/com/google/protobuf/UInt32ValueOrBuilder.java \
|
||||
lite/com/google/protobuf/UInt64Value.java \
|
||||
lite/com/google/protobuf/UInt64ValueOrBuilder.java \
|
||||
lite/com/google/protobuf/Value.java \
|
||||
lite/com/google/protobuf/ValueOrBuilder.java \
|
||||
lite/com/google/protobuf/WrappersProto.java
|
||||
|
||||
bin_PROGRAMS = conformance-test-runner conformance-cpp
|
||||
|
||||
# All source files excepet C++/Objective-C ones should be explicitly listed
|
||||
# here because the autoconf tools don't include files of other languages
|
||||
# automatically.
|
||||
EXTRA_DIST = \
|
||||
ConformanceJava.java \
|
||||
ConformanceJavaLite.java \
|
||||
README.md \
|
||||
conformance.proto \
|
||||
conformance_python.py \
|
||||
conformance_ruby.rb \
|
||||
failure_list_cpp.txt \
|
||||
failure_list_csharp.txt \
|
||||
failure_list_java.txt \
|
||||
failure_list_objc.txt \
|
||||
failure_list_python.txt \
|
||||
failure_list_python_cpp.txt \
|
||||
failure_list_python-post26.txt \
|
||||
failure_list_ruby.txt
|
||||
|
||||
conformance_test_runner_LDADD = $(top_srcdir)/src/libprotobuf.la
|
||||
conformance_test_runner_SOURCES = conformance_test.h conformance_test.cc \
|
||||
conformance_test_runner.cc \
|
||||
third_party/jsoncpp/json.h \
|
||||
third_party/jsoncpp/jsoncpp.cpp
|
||||
nodist_conformance_test_runner_SOURCES = conformance.pb.cc
|
||||
conformance_test_runner_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)
|
||||
conformance_test_runner_CXXFLAGS = -std=c++11
|
||||
# Explicit deps beacuse BUILT_SOURCES are only done before a "make all/check"
|
||||
# so a direct "make test_cpp" could fail if parallel enough.
|
||||
conformance_test_runner-conformance_test.$(OBJEXT): conformance.pb.h
|
||||
conformance_test_runner-conformance_test_runner.$(OBJEXT): conformance.pb.h
|
||||
|
||||
conformance_cpp_LDADD = $(top_srcdir)/src/libprotobuf.la
|
||||
conformance_cpp_SOURCES = conformance_cpp.cc
|
||||
nodist_conformance_cpp_SOURCES = conformance.pb.cc
|
||||
conformance_cpp_CPPFLAGS = -I$(top_srcdir)/src
|
||||
# Explicit dep beacuse BUILT_SOURCES are only done before a "make all/check"
|
||||
# so a direct "make test_cpp" could fail if parallel enough.
|
||||
conformance_cpp-conformance_cpp.$(OBJEXT): conformance.pb.h
|
||||
|
||||
if OBJC_CONFORMANCE_TEST
|
||||
|
||||
bin_PROGRAMS += conformance-objc
|
||||
|
||||
conformance_objc_SOURCES = conformance_objc.m ../objectivec/GPBProtocolBuffers.m
|
||||
nodist_conformance_objc_SOURCES = Conformance.pbobjc.m
|
||||
# On travis, the build fails without the isysroot because whatever system
|
||||
# headers are being found don't include generics support for
|
||||
# NSArray/NSDictionary, the only guess is their image at one time had an odd
|
||||
# setup for Xcode and old frameworks are being found.
|
||||
conformance_objc_CPPFLAGS = -I$(top_srcdir)/objectivec -isysroot `xcrun --sdk macosx --show-sdk-path`
|
||||
conformance_objc_LDFLAGS = -framework Foundation
|
||||
# Explicit dep beacuse BUILT_SOURCES are only done before a "make all/check"
|
||||
# so a direct "make test_objc" could fail if parallel enough.
|
||||
conformance_objc-conformance_objc.$(OBJEXT): Conformance.pbobjc.h
|
||||
|
||||
endif
|
||||
|
||||
if USE_EXTERNAL_PROTOC
|
||||
|
||||
# Some implementations include pre-generated versions of well-known types.
|
||||
protoc_middleman: $(conformance_protoc_inputs) $(well_known_type_protoc_inputs)
|
||||
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --objc_out=. --python_out=. $(conformance_protoc_inputs)
|
||||
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --python_out=. $(well_known_type_protoc_inputs)
|
||||
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --java_out=lite:lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs)
|
||||
touch protoc_middleman
|
||||
|
||||
else
|
||||
|
||||
# We have to cd to $(srcdir) before executing protoc because $(protoc_inputs) is
|
||||
# relative to srcdir, which may not be the same as the current directory when
|
||||
# building out-of-tree.
|
||||
protoc_middleman: $(top_srcdir)/src/protoc$(EXEEXT) $(conformance_protoc_inputs) $(well_known_type_protoc_inputs)
|
||||
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --objc_out=$$oldpwd --python_out=$$oldpwd $(conformance_protoc_inputs) )
|
||||
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --python_out=$$oldpwd $(well_known_type_protoc_inputs) )
|
||||
@mkdir -p lite
|
||||
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --java_out=lite:$$oldpwd/lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) )
|
||||
touch protoc_middleman
|
||||
|
||||
endif
|
||||
|
||||
$(protoc_outputs): protoc_middleman
|
||||
|
||||
$(other_language_protoc_outputs): protoc_middleman
|
||||
|
||||
BUILT_SOURCES = $(protoc_outputs) $(other_language_protoc_outputs)
|
||||
|
||||
CLEANFILES = $(protoc_outputs) protoc_middleman javac_middleman conformance-java javac_middleman_lite conformance-java-lite conformance-csharp $(other_language_protoc_outputs)
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
Makefile.in
|
||||
|
||||
javac_middleman: ConformanceJava.java protoc_middleman $(other_language_protoc_outputs)
|
||||
jar=`ls ../java/util/target/*jar-with-dependencies.jar` && javac -classpath ../java/target/classes:$$jar ConformanceJava.java com/google/protobuf/conformance/Conformance.java
|
||||
@touch javac_middleman
|
||||
|
||||
conformance-java: javac_middleman
|
||||
@echo "Writing shortcut script conformance-java..."
|
||||
@echo '#! /bin/sh' > conformance-java
|
||||
@jar=`ls ../java/util/target/*jar-with-dependencies.jar` && echo java -classpath .:../java/target/classes:$$jar ConformanceJava '$$@' >> conformance-java
|
||||
@chmod +x conformance-java
|
||||
|
||||
javac_middleman_lite: ConformanceJavaLite.java protoc_middleman $(other_language_protoc_outputs)
|
||||
javac -classpath ../java/lite/target/classes:lite ConformanceJavaLite.java lite/com/google/protobuf/conformance/Conformance.java
|
||||
@touch javac_middleman_lite
|
||||
|
||||
conformance-java-lite: javac_middleman_lite
|
||||
@echo "Writing shortcut script conformance-java-lite..."
|
||||
@echo '#! /bin/sh' > conformance-java-lite
|
||||
@echo java -classpath .:../java/lite/target/classes:lite ConformanceJavaLite '$$@' >> conformance-java-lite
|
||||
@chmod +x conformance-java-lite
|
||||
|
||||
# Currently the conformance code is alongside the rest of the C#
|
||||
# source, as it's easier to maintain there. We assume we've already
|
||||
# built that, so we just need a script to run it.
|
||||
conformance-csharp: $(other_language_protoc_outputs)
|
||||
@echo "Writing shortcut script conformance-csharp..."
|
||||
@echo '#! /bin/sh' > conformance-csharp
|
||||
@echo 'mono ../csharp/src/Google.Protobuf.Conformance/bin/Release/Google.Protobuf.Conformance.exe "$$@"' >> conformance-csharp
|
||||
@chmod +x conformance-csharp
|
||||
|
||||
# Targets for actually running tests.
|
||||
test_cpp: protoc_middleman conformance-test-runner conformance-cpp
|
||||
./conformance-test-runner --failure_list failure_list_cpp.txt ./conformance-cpp
|
||||
|
||||
test_java: protoc_middleman conformance-test-runner conformance-java
|
||||
./conformance-test-runner --failure_list failure_list_java.txt ./conformance-java
|
||||
|
||||
test_java_lite: protoc_middleman conformance-test-runner conformance-java-lite
|
||||
./conformance-test-runner ./conformance-java-lite
|
||||
|
||||
test_csharp: protoc_middleman conformance-test-runner conformance-csharp
|
||||
./conformance-test-runner --failure_list failure_list_csharp.txt ./conformance-csharp
|
||||
|
||||
test_ruby: protoc_middleman conformance-test-runner $(other_language_protoc_outputs)
|
||||
RUBYLIB=../ruby/lib:. ./conformance-test-runner --failure_list failure_list_ruby.txt ./conformance_ruby.rb
|
||||
|
||||
# These depend on library paths being properly set up. The easiest way to
|
||||
# run them is to just use "tox" from the python dir.
|
||||
test_python: protoc_middleman conformance-test-runner
|
||||
./conformance-test-runner --failure_list failure_list_python.txt $(CONFORMANCE_PYTHON_EXTRA_FAILURES) ./conformance_python.py
|
||||
|
||||
test_python_cpp: protoc_middleman conformance-test-runner
|
||||
./conformance-test-runner --failure_list failure_list_python_cpp.txt $(CONFORMANCE_PYTHON_EXTRA_FAILURES) ./conformance_python.py
|
||||
|
||||
if OBJC_CONFORMANCE_TEST
|
||||
|
||||
test_objc: protoc_middleman conformance-test-runner conformance-objc
|
||||
./conformance-test-runner --failure_list failure_list_objc.txt ./conformance-objc
|
||||
|
||||
endif
|
|
@ -0,0 +1,45 @@
|
|||
Protocol Buffers - Google's data interchange format
|
||||
===================================================
|
||||
|
||||
[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf)
|
||||
|
||||
Copyright 2008 Google Inc.
|
||||
|
||||
This directory contains conformance tests for testing completeness and
|
||||
correctness of Protocol Buffers implementations. These tests are designed
|
||||
to be easy to run against any Protocol Buffers implementation.
|
||||
|
||||
This directory contains the tester process `conformance-test`, which
|
||||
contains all of the tests themselves. Then separate programs written
|
||||
in whatever language you want to test communicate with the tester
|
||||
program over a pipe.
|
||||
|
||||
Before running any of these tests, make sure you run `make` in the base
|
||||
directory to build `protoc`, since all the tests depend on it.
|
||||
|
||||
$ make
|
||||
|
||||
Then to run the tests against the C++ implementation, run:
|
||||
|
||||
$ cd conformance && make test_cpp
|
||||
|
||||
More tests and languages will be added soon!
|
||||
|
||||
Testing other Protocol Buffer implementations
|
||||
---------------------------------------------
|
||||
|
||||
To run these tests against a new Protocol Buffers implementation, write a
|
||||
program in your language that uses the protobuf implementation you want
|
||||
to test. This program should implement the testing protocol defined in
|
||||
[conformance.proto](https://github.com/google/protobuf/blob/master/conformance/conformance.proto).
|
||||
This is designed to be as easy as possible: the C++ version is only
|
||||
150 lines and is a good example for what this program should look like
|
||||
(see [conformance_cpp.cc](https://github.com/google/protobuf/blob/master/conformance/conformance_cpp.cc)).
|
||||
The program only needs to be able to read from stdin and write to stdout.
|
||||
|
||||
Portability
|
||||
-----------
|
||||
|
||||
Note that the test runner currently does not work on Windows. Patches
|
||||
to fix this are welcome! (But please get in touch first to settle on
|
||||
a general implementation strategy).
|
|
@ -0,0 +1,273 @@
|
|||
// 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 = "proto3";
|
||||
package conformance;
|
||||
option java_package = "com.google.protobuf.conformance";
|
||||
|
||||
import "google/protobuf/any.proto";
|
||||
import "google/protobuf/duration.proto";
|
||||
import "google/protobuf/field_mask.proto";
|
||||
import "google/protobuf/struct.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/wrappers.proto";
|
||||
|
||||
// This defines the conformance testing protocol. This protocol exists between
|
||||
// the conformance test suite itself and the code being tested. For each test,
|
||||
// the suite will send a ConformanceRequest message and expect a
|
||||
// ConformanceResponse message.
|
||||
//
|
||||
// You can either run the tests in two different ways:
|
||||
//
|
||||
// 1. in-process (using the interface in conformance_test.h).
|
||||
//
|
||||
// 2. as a sub-process communicating over a pipe. Information about how to
|
||||
// do this is in conformance_test_runner.cc.
|
||||
//
|
||||
// Pros/cons of the two approaches:
|
||||
//
|
||||
// - running as a sub-process is much simpler for languages other than C/C++.
|
||||
//
|
||||
// - running as a sub-process may be more tricky in unusual environments like
|
||||
// iOS apps, where fork/stdin/stdout are not available.
|
||||
|
||||
enum WireFormat {
|
||||
UNSPECIFIED = 0;
|
||||
PROTOBUF = 1;
|
||||
JSON = 2;
|
||||
}
|
||||
|
||||
// Represents a single test case's input. The testee should:
|
||||
//
|
||||
// 1. parse this proto (which should always succeed)
|
||||
// 2. parse the protobuf or JSON payload in "payload" (which may fail)
|
||||
// 3. if the parse succeeded, serialize the message in the requested format.
|
||||
message ConformanceRequest {
|
||||
// The payload (whether protobuf of JSON) is always for a TestAllTypes proto
|
||||
// (see below).
|
||||
oneof payload {
|
||||
bytes protobuf_payload = 1;
|
||||
string json_payload = 2;
|
||||
}
|
||||
|
||||
// Which format should the testee serialize its message to?
|
||||
WireFormat requested_output_format = 3;
|
||||
}
|
||||
|
||||
// Represents a single test case's output.
|
||||
message ConformanceResponse {
|
||||
oneof result {
|
||||
// This string should be set to indicate parsing failed. The string can
|
||||
// provide more information about the parse error if it is available.
|
||||
//
|
||||
// Setting this string does not necessarily mean the testee failed the
|
||||
// test. Some of the test cases are intentionally invalid input.
|
||||
string parse_error = 1;
|
||||
|
||||
// If the input was successfully parsed but errors occurred when
|
||||
// serializing it to the requested output format, set the error message in
|
||||
// this field.
|
||||
string serialize_error = 6;
|
||||
|
||||
// This should be set if some other error occurred. This will always
|
||||
// indicate that the test failed. The string can provide more information
|
||||
// about the failure.
|
||||
string runtime_error = 2;
|
||||
|
||||
// If the input was successfully parsed and the requested output was
|
||||
// protobuf, serialize it to protobuf and set it in this field.
|
||||
bytes protobuf_payload = 3;
|
||||
|
||||
// If the input was successfully parsed and the requested output was JSON,
|
||||
// serialize to JSON and set it in this field.
|
||||
string json_payload = 4;
|
||||
|
||||
// For when the testee skipped the test, likely because a certain feature
|
||||
// wasn't supported, like JSON input/output.
|
||||
string skipped = 5;
|
||||
}
|
||||
}
|
||||
|
||||
// This proto includes every type of field in both singular and repeated
|
||||
// forms.
|
||||
message TestAllTypes {
|
||||
message NestedMessage {
|
||||
int32 a = 1;
|
||||
TestAllTypes corecursive = 2;
|
||||
}
|
||||
|
||||
enum NestedEnum {
|
||||
FOO = 0;
|
||||
BAR = 1;
|
||||
BAZ = 2;
|
||||
NEG = -1; // Intentionally negative.
|
||||
}
|
||||
|
||||
// Singular
|
||||
int32 optional_int32 = 1;
|
||||
int64 optional_int64 = 2;
|
||||
uint32 optional_uint32 = 3;
|
||||
uint64 optional_uint64 = 4;
|
||||
sint32 optional_sint32 = 5;
|
||||
sint64 optional_sint64 = 6;
|
||||
fixed32 optional_fixed32 = 7;
|
||||
fixed64 optional_fixed64 = 8;
|
||||
sfixed32 optional_sfixed32 = 9;
|
||||
sfixed64 optional_sfixed64 = 10;
|
||||
float optional_float = 11;
|
||||
double optional_double = 12;
|
||||
bool optional_bool = 13;
|
||||
string optional_string = 14;
|
||||
bytes optional_bytes = 15;
|
||||
|
||||
NestedMessage optional_nested_message = 18;
|
||||
ForeignMessage optional_foreign_message = 19;
|
||||
|
||||
NestedEnum optional_nested_enum = 21;
|
||||
ForeignEnum optional_foreign_enum = 22;
|
||||
|
||||
string optional_string_piece = 24 [ctype=STRING_PIECE];
|
||||
string optional_cord = 25 [ctype=CORD];
|
||||
|
||||
TestAllTypes recursive_message = 27;
|
||||
|
||||
// Repeated
|
||||
repeated int32 repeated_int32 = 31;
|
||||
repeated int64 repeated_int64 = 32;
|
||||
repeated uint32 repeated_uint32 = 33;
|
||||
repeated uint64 repeated_uint64 = 34;
|
||||
repeated sint32 repeated_sint32 = 35;
|
||||
repeated sint64 repeated_sint64 = 36;
|
||||
repeated fixed32 repeated_fixed32 = 37;
|
||||
repeated fixed64 repeated_fixed64 = 38;
|
||||
repeated sfixed32 repeated_sfixed32 = 39;
|
||||
repeated sfixed64 repeated_sfixed64 = 40;
|
||||
repeated float repeated_float = 41;
|
||||
repeated double repeated_double = 42;
|
||||
repeated bool repeated_bool = 43;
|
||||
repeated string repeated_string = 44;
|
||||
repeated bytes repeated_bytes = 45;
|
||||
|
||||
repeated NestedMessage repeated_nested_message = 48;
|
||||
repeated ForeignMessage repeated_foreign_message = 49;
|
||||
|
||||
repeated NestedEnum repeated_nested_enum = 51;
|
||||
repeated ForeignEnum repeated_foreign_enum = 52;
|
||||
|
||||
repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
|
||||
repeated string repeated_cord = 55 [ctype=CORD];
|
||||
|
||||
// Map
|
||||
map < int32, int32> map_int32_int32 = 56;
|
||||
map < int64, int64> map_int64_int64 = 57;
|
||||
map < uint32, uint32> map_uint32_uint32 = 58;
|
||||
map < uint64, uint64> map_uint64_uint64 = 59;
|
||||
map < sint32, sint32> map_sint32_sint32 = 60;
|
||||
map < sint64, sint64> map_sint64_sint64 = 61;
|
||||
map < fixed32, fixed32> map_fixed32_fixed32 = 62;
|
||||
map < fixed64, fixed64> map_fixed64_fixed64 = 63;
|
||||
map <sfixed32, sfixed32> map_sfixed32_sfixed32 = 64;
|
||||
map <sfixed64, sfixed64> map_sfixed64_sfixed64 = 65;
|
||||
map < int32, float> map_int32_float = 66;
|
||||
map < int32, double> map_int32_double = 67;
|
||||
map < bool, bool> map_bool_bool = 68;
|
||||
map < string, string> map_string_string = 69;
|
||||
map < string, bytes> map_string_bytes = 70;
|
||||
map < string, NestedMessage> map_string_nested_message = 71;
|
||||
map < string, ForeignMessage> map_string_foreign_message = 72;
|
||||
map < string, NestedEnum> map_string_nested_enum = 73;
|
||||
map < string, ForeignEnum> map_string_foreign_enum = 74;
|
||||
|
||||
oneof oneof_field {
|
||||
uint32 oneof_uint32 = 111;
|
||||
NestedMessage oneof_nested_message = 112;
|
||||
string oneof_string = 113;
|
||||
bytes oneof_bytes = 114;
|
||||
}
|
||||
|
||||
// Well-known types
|
||||
google.protobuf.BoolValue optional_bool_wrapper = 201;
|
||||
google.protobuf.Int32Value optional_int32_wrapper = 202;
|
||||
google.protobuf.Int64Value optional_int64_wrapper = 203;
|
||||
google.protobuf.UInt32Value optional_uint32_wrapper = 204;
|
||||
google.protobuf.UInt64Value optional_uint64_wrapper = 205;
|
||||
google.protobuf.FloatValue optional_float_wrapper = 206;
|
||||
google.protobuf.DoubleValue optional_double_wrapper = 207;
|
||||
google.protobuf.StringValue optional_string_wrapper = 208;
|
||||
google.protobuf.BytesValue optional_bytes_wrapper = 209;
|
||||
|
||||
repeated google.protobuf.BoolValue repeated_bool_wrapper = 211;
|
||||
repeated google.protobuf.Int32Value repeated_int32_wrapper = 212;
|
||||
repeated google.protobuf.Int64Value repeated_int64_wrapper = 213;
|
||||
repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 214;
|
||||
repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 215;
|
||||
repeated google.protobuf.FloatValue repeated_float_wrapper = 216;
|
||||
repeated google.protobuf.DoubleValue repeated_double_wrapper = 217;
|
||||
repeated google.protobuf.StringValue repeated_string_wrapper = 218;
|
||||
repeated google.protobuf.BytesValue repeated_bytes_wrapper = 219;
|
||||
|
||||
google.protobuf.Duration optional_duration = 301;
|
||||
google.protobuf.Timestamp optional_timestamp = 302;
|
||||
google.protobuf.FieldMask optional_field_mask = 303;
|
||||
google.protobuf.Struct optional_struct = 304;
|
||||
google.protobuf.Any optional_any = 305;
|
||||
google.protobuf.Value optional_value = 306;
|
||||
|
||||
repeated google.protobuf.Duration repeated_duration = 311;
|
||||
repeated google.protobuf.Timestamp repeated_timestamp = 312;
|
||||
repeated google.protobuf.FieldMask repeated_fieldmask = 313;
|
||||
repeated google.protobuf.Struct repeated_struct = 324;
|
||||
repeated google.protobuf.Any repeated_any = 315;
|
||||
repeated google.protobuf.Value repeated_value = 316;
|
||||
|
||||
// Test field-name-to-JSON-name convention.
|
||||
int32 fieldname1 = 401;
|
||||
int32 field_name2 = 402;
|
||||
int32 _field_name3 = 403;
|
||||
int32 field__name4_ = 404;
|
||||
int32 field0name5 = 405;
|
||||
int32 field_0_name6 = 406;
|
||||
int32 fieldName7 = 407;
|
||||
int32 FieldName8 = 408;
|
||||
int32 field_Name9 = 409;
|
||||
int32 Field_Name10 = 410;
|
||||
int32 FIELD_NAME11 = 411;
|
||||
int32 FIELD_name12 = 412;
|
||||
}
|
||||
|
||||
message ForeignMessage {
|
||||
int32 c = 1;
|
||||
}
|
||||
|
||||
enum ForeignEnum {
|
||||
FOREIGN_FOO = 0;
|
||||
FOREIGN_BAR = 1;
|
||||
FOREIGN_BAZ = 2;
|
||||
}
|
|
@ -0,0 +1,207 @@
|
|||
// 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 <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "conformance.pb.h"
|
||||
#include <google/protobuf/util/json_util.h>
|
||||
#include <google/protobuf/util/type_resolver_util.h>
|
||||
|
||||
using conformance::ConformanceRequest;
|
||||
using conformance::ConformanceResponse;
|
||||
using conformance::TestAllTypes;
|
||||
using google::protobuf::Descriptor;
|
||||
using google::protobuf::DescriptorPool;
|
||||
using google::protobuf::internal::scoped_ptr;
|
||||
using google::protobuf::util::BinaryToJsonString;
|
||||
using google::protobuf::util::JsonToBinaryString;
|
||||
using google::protobuf::util::NewTypeResolverForDescriptorPool;
|
||||
using google::protobuf::util::Status;
|
||||
using google::protobuf::util::TypeResolver;
|
||||
using std::string;
|
||||
|
||||
static const char kTypeUrlPrefix[] = "type.googleapis.com";
|
||||
|
||||
static string GetTypeUrl(const Descriptor* message) {
|
||||
return string(kTypeUrlPrefix) + "/" + message->full_name();
|
||||
}
|
||||
|
||||
int test_count = 0;
|
||||
bool verbose = false;
|
||||
TypeResolver* type_resolver;
|
||||
string* type_url;
|
||||
|
||||
|
||||
bool CheckedRead(int fd, void *buf, size_t len) {
|
||||
size_t ofs = 0;
|
||||
while (len > 0) {
|
||||
ssize_t bytes_read = read(fd, (char*)buf + ofs, len);
|
||||
|
||||
if (bytes_read == 0) return false;
|
||||
|
||||
if (bytes_read < 0) {
|
||||
GOOGLE_LOG(FATAL) << "Error reading from test runner: " << strerror(errno);
|
||||
}
|
||||
|
||||
len -= bytes_read;
|
||||
ofs += bytes_read;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CheckedWrite(int fd, const void *buf, size_t len) {
|
||||
if (write(fd, buf, len) != len) {
|
||||
GOOGLE_LOG(FATAL) << "Error writing to test runner: " << strerror(errno);
|
||||
}
|
||||
}
|
||||
|
||||
void DoTest(const ConformanceRequest& request, ConformanceResponse* response) {
|
||||
TestAllTypes test_message;
|
||||
|
||||
switch (request.payload_case()) {
|
||||
case ConformanceRequest::kProtobufPayload:
|
||||
if (!test_message.ParseFromString(request.protobuf_payload())) {
|
||||
// Getting parse details would involve something like:
|
||||
// http://stackoverflow.com/questions/22121922/how-can-i-get-more-details-about-errors-generated-during-protobuf-parsing-c
|
||||
response->set_parse_error("Parse error (no more details available).");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case ConformanceRequest::kJsonPayload: {
|
||||
string proto_binary;
|
||||
Status status = JsonToBinaryString(type_resolver, *type_url,
|
||||
request.json_payload(), &proto_binary);
|
||||
if (!status.ok()) {
|
||||
response->set_parse_error(string("Parse error: ") +
|
||||
status.error_message().as_string());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!test_message.ParseFromString(proto_binary)) {
|
||||
response->set_runtime_error(
|
||||
"Parsing JSON generates invalid proto output.");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ConformanceRequest::PAYLOAD_NOT_SET:
|
||||
GOOGLE_LOG(FATAL) << "Request didn't have payload.";
|
||||
break;
|
||||
}
|
||||
|
||||
switch (request.requested_output_format()) {
|
||||
case conformance::UNSPECIFIED:
|
||||
GOOGLE_LOG(FATAL) << "Unspecified output format";
|
||||
break;
|
||||
|
||||
case conformance::PROTOBUF:
|
||||
GOOGLE_CHECK(
|
||||
test_message.SerializeToString(response->mutable_protobuf_payload()));
|
||||
break;
|
||||
|
||||
case conformance::JSON: {
|
||||
string proto_binary;
|
||||
GOOGLE_CHECK(test_message.SerializeToString(&proto_binary));
|
||||
Status status = BinaryToJsonString(type_resolver, *type_url, proto_binary,
|
||||
response->mutable_json_payload());
|
||||
if (!status.ok()) {
|
||||
response->set_serialize_error(
|
||||
string("Failed to serialize JSON output: ") +
|
||||
status.error_message().as_string());
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
GOOGLE_LOG(FATAL) << "Unknown output format: "
|
||||
<< request.requested_output_format();
|
||||
}
|
||||
}
|
||||
|
||||
bool DoTestIo() {
|
||||
string serialized_input;
|
||||
string serialized_output;
|
||||
ConformanceRequest request;
|
||||
ConformanceResponse response;
|
||||
uint32_t bytes;
|
||||
|
||||
if (!CheckedRead(STDIN_FILENO, &bytes, sizeof(uint32_t))) {
|
||||
// EOF.
|
||||
return false;
|
||||
}
|
||||
|
||||
serialized_input.resize(bytes);
|
||||
|
||||
if (!CheckedRead(STDIN_FILENO, (char*)serialized_input.c_str(), bytes)) {
|
||||
GOOGLE_LOG(ERROR) << "Unexpected EOF on stdin. " << strerror(errno);
|
||||
}
|
||||
|
||||
if (!request.ParseFromString(serialized_input)) {
|
||||
GOOGLE_LOG(FATAL) << "Parse of ConformanceRequest proto failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
DoTest(request, &response);
|
||||
|
||||
response.SerializeToString(&serialized_output);
|
||||
|
||||
bytes = serialized_output.size();
|
||||
CheckedWrite(STDOUT_FILENO, &bytes, sizeof(uint32_t));
|
||||
CheckedWrite(STDOUT_FILENO, serialized_output.c_str(), bytes);
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "conformance-cpp: request=%s, response=%s\n",
|
||||
request.ShortDebugString().c_str(),
|
||||
response.ShortDebugString().c_str());
|
||||
}
|
||||
|
||||
test_count++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
type_resolver = NewTypeResolverForDescriptorPool(
|
||||
kTypeUrlPrefix, DescriptorPool::generated_pool());
|
||||
type_url = new string(GetTypeUrl(TestAllTypes::descriptor()));
|
||||
while (1) {
|
||||
if (!DoTestIo()) {
|
||||
fprintf(stderr, "conformance-cpp: received EOF from test runner "
|
||||
"after %d tests, exiting\n", test_count);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,179 @@
|
|||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2015 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.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "Conformance.pbobjc.h"
|
||||
|
||||
static void Die(NSString *format, ...) __dead2;
|
||||
|
||||
static BOOL verbose = NO;
|
||||
static int32_t testCount = 0;
|
||||
|
||||
static void Die(NSString *format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
NSString *msg = [[NSString alloc] initWithFormat:format arguments:args];
|
||||
NSLog(@"%@", msg);
|
||||
va_end(args);
|
||||
[msg release];
|
||||
exit(66);
|
||||
}
|
||||
|
||||
static NSData *CheckedReadDataOfLength(NSFileHandle *handle, NSUInteger numBytes) {
|
||||
NSData *data = [handle readDataOfLength:numBytes];
|
||||
NSUInteger dataLen = data.length;
|
||||
if (dataLen == 0) {
|
||||
return nil; // EOF.
|
||||
}
|
||||
if (dataLen != numBytes) {
|
||||
Die(@"Failed to read the request length (%d), only got: %@",
|
||||
numBytes, data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
static ConformanceResponse *DoTest(ConformanceRequest *request) {
|
||||
ConformanceResponse *response = [ConformanceResponse message];
|
||||
TestAllTypes *testMessage = nil;
|
||||
|
||||
switch (request.payloadOneOfCase) {
|
||||
case ConformanceRequest_Payload_OneOfCase_GPBUnsetOneOfCase:
|
||||
Die(@"Request didn't have a payload: %@", request);
|
||||
break;
|
||||
|
||||
case ConformanceRequest_Payload_OneOfCase_ProtobufPayload: {
|
||||
NSError *error = nil;
|
||||
testMessage = [TestAllTypes parseFromData:request.protobufPayload
|
||||
error:&error];
|
||||
if (!testMessage) {
|
||||
response.parseError =
|
||||
[NSString stringWithFormat:@"Parse error: %@", error];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ConformanceRequest_Payload_OneOfCase_JsonPayload:
|
||||
response.skipped = @"ObjC doesn't support parsing JSON";
|
||||
break;
|
||||
}
|
||||
|
||||
if (testMessage) {
|
||||
switch (request.requestedOutputFormat) {
|
||||
case WireFormat_GPBUnrecognizedEnumeratorValue:
|
||||
case WireFormat_Unspecified:
|
||||
Die(@"Unrecognized/unspecified output format: %@", request);
|
||||
break;
|
||||
|
||||
case WireFormat_Protobuf:
|
||||
response.protobufPayload = testMessage.data;
|
||||
if (!response.protobufPayload) {
|
||||
response.serializeError =
|
||||
[NSString stringWithFormat:@"Failed to make data from: %@", testMessage];
|
||||
}
|
||||
break;
|
||||
|
||||
case WireFormat_Json:
|
||||
response.skipped = @"ObjC doesn't support generating JSON";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
static uint32_t UInt32FromLittleEndianData(NSData *data) {
|
||||
if (data.length != sizeof(uint32_t)) {
|
||||
Die(@"Data not the right size for uint32_t: %@", data);
|
||||
}
|
||||
uint32_t value;
|
||||
memcpy(&value, data.bytes, sizeof(uint32_t));
|
||||
return CFSwapInt32LittleToHost(value);
|
||||
}
|
||||
|
||||
static NSData *UInt32ToLittleEndianData(uint32_t num) {
|
||||
uint32_t value = CFSwapInt32HostToLittle(num);
|
||||
return [NSData dataWithBytes:&value length:sizeof(uint32_t)];
|
||||
}
|
||||
|
||||
static BOOL DoTestIo(NSFileHandle *input, NSFileHandle *output) {
|
||||
// See conformance_test_runner.cc for the wire format.
|
||||
NSData *data = CheckedReadDataOfLength(input, sizeof(uint32_t));
|
||||
if (!data) {
|
||||
// EOF.
|
||||
return NO;
|
||||
}
|
||||
uint32_t numBytes = UInt32FromLittleEndianData(data);
|
||||
data = CheckedReadDataOfLength(input, numBytes);
|
||||
if (!data) {
|
||||
Die(@"Failed to read request");
|
||||
}
|
||||
|
||||
NSError *error = nil;
|
||||
ConformanceRequest *request = [ConformanceRequest parseFromData:data
|
||||
error:&error];
|
||||
if (!request) {
|
||||
Die(@"Failed to parse the message data: %@", error);
|
||||
}
|
||||
|
||||
ConformanceResponse *response = DoTest(request);
|
||||
if (!response) {
|
||||
Die(@"Failed to make a reply from %@", request);
|
||||
}
|
||||
|
||||
data = response.data;
|
||||
[output writeData:UInt32ToLittleEndianData((int32_t)data.length)];
|
||||
[output writeData:data];
|
||||
|
||||
if (verbose) {
|
||||
NSLog(@"Request: %@", request);
|
||||
NSLog(@"Response: %@", response);
|
||||
}
|
||||
|
||||
++testCount;
|
||||
return YES;
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
@autoreleasepool {
|
||||
NSFileHandle *input = [[NSFileHandle fileHandleWithStandardInput] retain];
|
||||
NSFileHandle *output = [[NSFileHandle fileHandleWithStandardOutput] retain];
|
||||
|
||||
BOOL notDone = YES;
|
||||
while (notDone) {
|
||||
@autoreleasepool {
|
||||
notDone = DoTestIo(input, output);
|
||||
}
|
||||
}
|
||||
|
||||
NSLog(@"Received EOF from test runner after %d tests, exiting.", testCount);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""A conformance test implementation for the Python protobuf library.
|
||||
|
||||
See conformance.proto for more information.
|
||||
"""
|
||||
|
||||
import struct
|
||||
import sys
|
||||
import os
|
||||
from google.protobuf import message
|
||||
from google.protobuf import json_format
|
||||
import conformance_pb2
|
||||
|
||||
sys.stdout = os.fdopen(sys.stdout.fileno(), 'wb', 0)
|
||||
sys.stdin = os.fdopen(sys.stdin.fileno(), 'rb', 0)
|
||||
|
||||
test_count = 0
|
||||
verbose = False
|
||||
|
||||
class ProtocolError(Exception):
|
||||
pass
|
||||
|
||||
def do_test(request):
|
||||
test_message = conformance_pb2.TestAllTypes()
|
||||
response = conformance_pb2.ConformanceResponse()
|
||||
test_message = conformance_pb2.TestAllTypes()
|
||||
|
||||
try:
|
||||
if request.WhichOneof('payload') == 'protobuf_payload':
|
||||
try:
|
||||
test_message.ParseFromString(request.protobuf_payload)
|
||||
except message.DecodeError as e:
|
||||
response.parse_error = str(e)
|
||||
return response
|
||||
|
||||
elif request.WhichOneof('payload') == 'json_payload':
|
||||
try:
|
||||
json_format.Parse(request.json_payload, test_message)
|
||||
except json_format.ParseError as e:
|
||||
response.parse_error = str(e)
|
||||
return response
|
||||
|
||||
else:
|
||||
raise ProtocolError("Request didn't have payload.")
|
||||
|
||||
if request.requested_output_format == conformance_pb2.UNSPECIFIED:
|
||||
raise ProtocolError("Unspecified output format")
|
||||
|
||||
elif request.requested_output_format == conformance_pb2.PROTOBUF:
|
||||
response.protobuf_payload = test_message.SerializeToString()
|
||||
|
||||
elif request.requested_output_format == conformance_pb2.JSON:
|
||||
response.json_payload = json_format.MessageToJson(test_message)
|
||||
|
||||
except Exception as e:
|
||||
response.runtime_error = str(e)
|
||||
|
||||
return response
|
||||
|
||||
def do_test_io():
|
||||
length_bytes = sys.stdin.read(4)
|
||||
if len(length_bytes) == 0:
|
||||
return False # EOF
|
||||
elif len(length_bytes) != 4:
|
||||
raise IOError("I/O error")
|
||||
|
||||
# "I" is "unsigned int", so this depends on running on a platform with
|
||||
# 32-bit "unsigned int" type. The Python struct module unfortunately
|
||||
# has no format specifier for uint32_t.
|
||||
length = struct.unpack("<I", length_bytes)[0]
|
||||
serialized_request = sys.stdin.read(length)
|
||||
if len(serialized_request) != length:
|
||||
raise IOError("I/O error")
|
||||
|
||||
request = conformance_pb2.ConformanceRequest()
|
||||
request.ParseFromString(serialized_request)
|
||||
|
||||
response = do_test(request)
|
||||
|
||||
serialized_response = response.SerializeToString()
|
||||
sys.stdout.write(struct.pack("<I", len(serialized_response)))
|
||||
sys.stdout.write(serialized_response)
|
||||
sys.stdout.flush()
|
||||
|
||||
if verbose:
|
||||
sys.stderr.write("conformance_python: request=%s, response=%s\n" % (
|
||||
request.ShortDebugString().c_str(),
|
||||
response.ShortDebugString().c_str()))
|
||||
|
||||
global test_count
|
||||
test_count += 1
|
||||
|
||||
return True
|
||||
|
||||
while True:
|
||||
if not do_test_io():
|
||||
sys.stderr.write("conformance_python: received EOF from test runner " +
|
||||
"after %s tests, exiting\n" % (test_count))
|
||||
sys.exit(0)
|
|
@ -0,0 +1,122 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# 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.
|
||||
|
||||
require 'conformance'
|
||||
|
||||
$test_count = 0
|
||||
$verbose = false
|
||||
|
||||
def do_test(request)
|
||||
test_message = Conformance::TestAllTypes.new
|
||||
response = Conformance::ConformanceResponse.new
|
||||
|
||||
begin
|
||||
case request.payload
|
||||
when :protobuf_payload
|
||||
begin
|
||||
test_message =
|
||||
Conformance::TestAllTypes.decode(request.protobuf_payload)
|
||||
rescue Google::Protobuf::ParseError => err
|
||||
response.parse_error = err.message.encode('utf-8')
|
||||
return response
|
||||
end
|
||||
|
||||
when :json_payload
|
||||
begin
|
||||
test_message = Conformance::TestAllTypes.decode_json(request.json_payload)
|
||||
rescue Google::Protobuf::ParseError => err
|
||||
response.parse_error = err.message.encode('utf-8')
|
||||
return response
|
||||
end
|
||||
|
||||
when nil
|
||||
fail "Request didn't have payload"
|
||||
end
|
||||
|
||||
case request.requested_output_format
|
||||
when :UNSPECIFIED
|
||||
fail 'Unspecified output format'
|
||||
|
||||
when :PROTOBUF
|
||||
response.protobuf_payload = test_message.to_proto
|
||||
|
||||
when :JSON
|
||||
response.json_payload = test_message.to_json
|
||||
|
||||
when nil
|
||||
fail "Request didn't have requested output format"
|
||||
end
|
||||
rescue StandardError => err
|
||||
response.runtime_error = err.message.encode('utf-8')
|
||||
end
|
||||
|
||||
response
|
||||
end
|
||||
|
||||
# Returns true if the test ran successfully, false on legitimate EOF.
|
||||
# If EOF is encountered in an unexpected place, raises IOError.
|
||||
def do_test_io
|
||||
length_bytes = STDIN.read(4)
|
||||
return false if length_bytes.nil?
|
||||
|
||||
length = length_bytes.unpack('V').first
|
||||
serialized_request = STDIN.read(length)
|
||||
if serialized_request.nil? || serialized_request.length != length
|
||||
fail IOError
|
||||
end
|
||||
|
||||
request = Conformance::ConformanceRequest.decode(serialized_request)
|
||||
|
||||
response = do_test(request)
|
||||
|
||||
serialized_response = Conformance::ConformanceResponse.encode(response)
|
||||
STDOUT.write([serialized_response.length].pack('V'))
|
||||
STDOUT.write(serialized_response)
|
||||
STDOUT.flush
|
||||
|
||||
if $verbose
|
||||
STDERR.puts("conformance_ruby: request=#{request.to_json}, " \
|
||||
"response=#{response.to_json}\n")
|
||||
end
|
||||
|
||||
$test_count += 1
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
loop do
|
||||
unless do_test_io
|
||||
STDERR.puts('conformance_ruby: received EOF from test runner ' \
|
||||
"after #{$test_count} tests, exiting")
|
||||
break
|
||||
end
|
||||
end
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,178 @@
|
|||
// 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 defines a protocol for running the conformance test suite
|
||||
// in-process. In other words, the suite itself will run in the same process as
|
||||
// the code under test.
|
||||
//
|
||||
// For pros and cons of this approach, please see conformance.proto.
|
||||
|
||||
#ifndef CONFORMANCE_CONFORMANCE_TEST_H
|
||||
#define CONFORMANCE_CONFORMANCE_TEST_H
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/util/type_resolver.h>
|
||||
#include <google/protobuf/wire_format_lite.h>
|
||||
|
||||
#include "third_party/jsoncpp/json.h"
|
||||
|
||||
namespace conformance {
|
||||
class ConformanceRequest;
|
||||
class ConformanceResponse;
|
||||
class TestAllTypes;
|
||||
} // namespace conformance
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
class ConformanceTestRunner {
|
||||
public:
|
||||
virtual ~ConformanceTestRunner() {}
|
||||
|
||||
// Call to run a single conformance test.
|
||||
//
|
||||
// "input" is a serialized conformance.ConformanceRequest.
|
||||
// "output" should be set to a serialized conformance.ConformanceResponse.
|
||||
//
|
||||
// If there is any error in running the test itself, set "runtime_error" in
|
||||
// the response.
|
||||
virtual void RunTest(const std::string& test_name,
|
||||
const std::string& input,
|
||||
std::string* output) = 0;
|
||||
};
|
||||
|
||||
// Class representing the test suite itself. To run it, implement your own
|
||||
// class derived from ConformanceTestRunner and then write code like:
|
||||
//
|
||||
// class MyConformanceTestRunner : public ConformanceTestRunner {
|
||||
// public:
|
||||
// virtual void RunTest(...) {
|
||||
// // INSERT YOUR FRAMEWORK-SPECIFIC CODE HERE.
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// int main() {
|
||||
// MyConformanceTestRunner runner;
|
||||
// google::protobuf::ConformanceTestSuite suite;
|
||||
//
|
||||
// std::string output;
|
||||
// suite.RunSuite(&runner, &output);
|
||||
// }
|
||||
//
|
||||
class ConformanceTestSuite {
|
||||
public:
|
||||
ConformanceTestSuite() : verbose_(false) {}
|
||||
|
||||
void SetVerbose(bool verbose) { verbose_ = verbose; }
|
||||
|
||||
// Sets the list of tests that are expected to fail when RunSuite() is called.
|
||||
// RunSuite() will fail unless the set of failing tests is exactly the same
|
||||
// as this list.
|
||||
void SetFailureList(const std::vector<std::string>& failure_list);
|
||||
|
||||
// Run all the conformance tests against the given test runner.
|
||||
// Test output will be stored in "output".
|
||||
//
|
||||
// Returns true if the set of failing tests was exactly the same as the
|
||||
// failure list. If SetFailureList() was not called, returns true if all
|
||||
// tests passed.
|
||||
bool RunSuite(ConformanceTestRunner* runner, std::string* output);
|
||||
|
||||
private:
|
||||
void ReportSuccess(const std::string& test_name);
|
||||
void ReportFailure(const string& test_name,
|
||||
const conformance::ConformanceRequest& request,
|
||||
const conformance::ConformanceResponse& response,
|
||||
const char* fmt, ...);
|
||||
void ReportSkip(const string& test_name,
|
||||
const conformance::ConformanceRequest& request,
|
||||
const conformance::ConformanceResponse& response);
|
||||
void RunTest(const std::string& test_name,
|
||||
const conformance::ConformanceRequest& request,
|
||||
conformance::ConformanceResponse* response);
|
||||
void RunValidInputTest(const string& test_name, const string& input,
|
||||
conformance::WireFormat input_format,
|
||||
const string& equivalent_text_format,
|
||||
conformance::WireFormat requested_output);
|
||||
void RunValidJsonTest(const string& test_name, const string& input_json,
|
||||
const string& equivalent_text_format);
|
||||
void RunValidJsonTestWithProtobufInput(const string& test_name,
|
||||
const conformance::TestAllTypes& input,
|
||||
const string& equivalent_text_format);
|
||||
|
||||
typedef std::function<bool(const Json::Value&)> Validator;
|
||||
void RunValidJsonTestWithValidator(const string& test_name,
|
||||
const string& input_json,
|
||||
const Validator& validator);
|
||||
void ExpectParseFailureForJson(const string& test_name,
|
||||
const string& input_json);
|
||||
void ExpectSerializeFailureForJson(const string& test_name,
|
||||
const string& text_format);
|
||||
void ExpectParseFailureForProto(const std::string& proto,
|
||||
const std::string& test_name);
|
||||
void ExpectHardParseFailureForProto(const std::string& proto,
|
||||
const std::string& test_name);
|
||||
void TestPrematureEOFForType(google::protobuf::FieldDescriptor::Type type);
|
||||
bool CheckSetEmpty(const set<string>& set_to_check, const char* msg);
|
||||
ConformanceTestRunner* runner_;
|
||||
int successes_;
|
||||
int expected_failures_;
|
||||
bool verbose_;
|
||||
std::string output_;
|
||||
|
||||
// The set of test names that are expected to fail in this run, but haven't
|
||||
// failed yet.
|
||||
std::set<std::string> expected_to_fail_;
|
||||
|
||||
// The set of test names that have been run. Used to ensure that there are no
|
||||
// duplicate names in the suite.
|
||||
std::set<std::string> test_names_;
|
||||
|
||||
// The set of tests that failed, but weren't expected to.
|
||||
std::set<std::string> unexpected_failing_tests_;
|
||||
|
||||
// The set of tests that succeeded, but weren't expected to.
|
||||
std::set<std::string> unexpected_succeeding_tests_;
|
||||
|
||||
// The set of tests that the testee opted out of;
|
||||
std::set<std::string> skipped_;
|
||||
|
||||
google::protobuf::internal::scoped_ptr<google::protobuf::util::TypeResolver>
|
||||
type_resolver_;
|
||||
std::string type_url_;
|
||||
};
|
||||
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#endif // CONFORMANCE_CONFORMANCE_TEST_H
|
|
@ -0,0 +1,312 @@
|
|||
// 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 a program for running the test suite in a separate
|
||||
// process. The other alternative is to run the suite in-process. See
|
||||
// conformance.proto for pros/cons of these two options.
|
||||
//
|
||||
// This program will fork the process under test and communicate with it over
|
||||
// its stdin/stdout:
|
||||
//
|
||||
// +--------+ pipe +----------+
|
||||
// | tester | <------> | testee |
|
||||
// | | | |
|
||||
// | C++ | | any lang |
|
||||
// +--------+ +----------+
|
||||
//
|
||||
// The tester contains all of the test cases and their expected output.
|
||||
// The testee is a simple program written in the target language that reads
|
||||
// each test case and attempts to produce acceptable output for it.
|
||||
//
|
||||
// Every test consists of a ConformanceRequest/ConformanceResponse
|
||||
// request/reply pair. The protocol on the pipe is simply:
|
||||
//
|
||||
// 1. tester sends 4-byte length N (little endian)
|
||||
// 2. tester sends N bytes representing a ConformanceRequest proto
|
||||
// 3. testee sends 4-byte length M (little endian)
|
||||
// 4. testee sends M bytes representing a ConformanceResponse proto
|
||||
|
||||
#include <algorithm>
|
||||
#include <errno.h>
|
||||
#include <fstream>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
#include <google/protobuf/stubs/stringprintf.h>
|
||||
|
||||
#include "conformance.pb.h"
|
||||
#include "conformance_test.h"
|
||||
|
||||
using conformance::ConformanceRequest;
|
||||
using conformance::ConformanceResponse;
|
||||
using google::protobuf::internal::scoped_array;
|
||||
using google::protobuf::StringAppendF;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
#define STRINGIFY(x) #x
|
||||
#define TOSTRING(x) STRINGIFY(x)
|
||||
#define CHECK_SYSCALL(call) \
|
||||
if (call < 0) { \
|
||||
perror(#call " " __FILE__ ":" TOSTRING(__LINE__)); \
|
||||
exit(1); \
|
||||
}
|
||||
|
||||
// Test runner that spawns the process being tested and communicates with it
|
||||
// over a pipe.
|
||||
class ForkPipeRunner : public google::protobuf::ConformanceTestRunner {
|
||||
public:
|
||||
ForkPipeRunner(const std::string &executable)
|
||||
: child_pid_(-1), executable_(executable) {}
|
||||
|
||||
virtual ~ForkPipeRunner() {}
|
||||
|
||||
void RunTest(const std::string& test_name,
|
||||
const std::string& request,
|
||||
std::string* response) {
|
||||
if (child_pid_ < 0) {
|
||||
SpawnTestProgram();
|
||||
}
|
||||
|
||||
current_test_name_ = test_name;
|
||||
|
||||
uint32_t len = request.size();
|
||||
CheckedWrite(write_fd_, &len, sizeof(uint32_t));
|
||||
CheckedWrite(write_fd_, request.c_str(), request.size());
|
||||
|
||||
if (!TryRead(read_fd_, &len, sizeof(uint32_t))) {
|
||||
// We failed to read from the child, assume a crash and try to reap.
|
||||
GOOGLE_LOG(INFO) << "Trying to reap child, pid=" << child_pid_;
|
||||
|
||||
int status;
|
||||
waitpid(child_pid_, &status, WEXITED);
|
||||
|
||||
string error_msg;
|
||||
if (WIFEXITED(status)) {
|
||||
StringAppendF(&error_msg,
|
||||
"child exited, status=%d", WEXITSTATUS(status));
|
||||
} else if (WIFSIGNALED(status)) {
|
||||
StringAppendF(&error_msg,
|
||||
"child killed by signal %d", WTERMSIG(status));
|
||||
}
|
||||
GOOGLE_LOG(INFO) << error_msg;
|
||||
child_pid_ = -1;
|
||||
|
||||
conformance::ConformanceResponse response_obj;
|
||||
response_obj.set_runtime_error(error_msg);
|
||||
response_obj.SerializeToString(response);
|
||||
return;
|
||||
}
|
||||
|
||||
response->resize(len);
|
||||
CheckedRead(read_fd_, (void*)response->c_str(), len);
|
||||
}
|
||||
|
||||
private:
|
||||
// TODO(haberman): make this work on Windows, instead of using these
|
||||
// UNIX-specific APIs.
|
||||
//
|
||||
// There is a platform-agnostic API in
|
||||
// src/google/protobuf/compiler/subprocess.h
|
||||
//
|
||||
// However that API only supports sending a single message to the subprocess.
|
||||
// We really want to be able to send messages and receive responses one at a
|
||||
// time:
|
||||
//
|
||||
// 1. Spawning a new process for each test would take way too long for thousands
|
||||
// of tests and subprocesses like java that can take 100ms or more to start
|
||||
// up.
|
||||
//
|
||||
// 2. Sending all the tests in one big message and receiving all results in one
|
||||
// big message would take away our visibility about which test(s) caused a
|
||||
// crash or other fatal error. It would also give us only a single failure
|
||||
// instead of all of them.
|
||||
void SpawnTestProgram() {
|
||||
int toproc_pipe_fd[2];
|
||||
int fromproc_pipe_fd[2];
|
||||
if (pipe(toproc_pipe_fd) < 0 || pipe(fromproc_pipe_fd) < 0) {
|
||||
perror("pipe");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pid_t pid = fork();
|
||||
if (pid < 0) {
|
||||
perror("fork");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (pid) {
|
||||
// Parent.
|
||||
CHECK_SYSCALL(close(toproc_pipe_fd[0]));
|
||||
CHECK_SYSCALL(close(fromproc_pipe_fd[1]));
|
||||
write_fd_ = toproc_pipe_fd[1];
|
||||
read_fd_ = fromproc_pipe_fd[0];
|
||||
child_pid_ = pid;
|
||||
} else {
|
||||
// Child.
|
||||
CHECK_SYSCALL(close(STDIN_FILENO));
|
||||
CHECK_SYSCALL(close(STDOUT_FILENO));
|
||||
CHECK_SYSCALL(dup2(toproc_pipe_fd[0], STDIN_FILENO));
|
||||
CHECK_SYSCALL(dup2(fromproc_pipe_fd[1], STDOUT_FILENO));
|
||||
|
||||
CHECK_SYSCALL(close(toproc_pipe_fd[0]));
|
||||
CHECK_SYSCALL(close(fromproc_pipe_fd[1]));
|
||||
CHECK_SYSCALL(close(toproc_pipe_fd[1]));
|
||||
CHECK_SYSCALL(close(fromproc_pipe_fd[0]));
|
||||
|
||||
scoped_array<char> executable(new char[executable_.size() + 1]);
|
||||
memcpy(executable.get(), executable_.c_str(), executable_.size());
|
||||
executable[executable_.size()] = '\0';
|
||||
|
||||
char *const argv[] = {executable.get(), NULL};
|
||||
CHECK_SYSCALL(execv(executable.get(), argv)); // Never returns.
|
||||
}
|
||||
}
|
||||
|
||||
void CheckedWrite(int fd, const void *buf, size_t len) {
|
||||
if (write(fd, buf, len) != len) {
|
||||
GOOGLE_LOG(FATAL) << current_test_name_
|
||||
<< ": error writing to test program: "
|
||||
<< strerror(errno);
|
||||
}
|
||||
}
|
||||
|
||||
bool TryRead(int fd, void *buf, size_t len) {
|
||||
size_t ofs = 0;
|
||||
while (len > 0) {
|
||||
ssize_t bytes_read = read(fd, (char*)buf + ofs, len);
|
||||
|
||||
if (bytes_read == 0) {
|
||||
GOOGLE_LOG(ERROR) << current_test_name_
|
||||
<< ": unexpected EOF from test program";
|
||||
return false;
|
||||
} else if (bytes_read < 0) {
|
||||
GOOGLE_LOG(ERROR) << current_test_name_
|
||||
<< ": error reading from test program: "
|
||||
<< strerror(errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
len -= bytes_read;
|
||||
ofs += bytes_read;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CheckedRead(int fd, void *buf, size_t len) {
|
||||
if (!TryRead(fd, buf, len)) {
|
||||
GOOGLE_LOG(FATAL) << current_test_name_
|
||||
<< ": error reading from test program: "
|
||||
<< strerror(errno);
|
||||
}
|
||||
}
|
||||
|
||||
int write_fd_;
|
||||
int read_fd_;
|
||||
pid_t child_pid_;
|
||||
std::string executable_;
|
||||
std::string current_test_name_;
|
||||
};
|
||||
|
||||
void UsageError() {
|
||||
fprintf(stderr,
|
||||
"Usage: conformance-test-runner [options] <test-program>\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "Options:\n");
|
||||
fprintf(stderr,
|
||||
" --failure_list <filename> Use to specify list of tests\n");
|
||||
fprintf(stderr,
|
||||
" that are expected to fail. File\n");
|
||||
fprintf(stderr,
|
||||
" should contain one test name per\n");
|
||||
fprintf(stderr,
|
||||
" line. Use '#' for comments.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void ParseFailureList(const char *filename, vector<string>* failure_list) {
|
||||
std::ifstream infile(filename);
|
||||
|
||||
if (!infile.is_open()) {
|
||||
fprintf(stderr, "Couldn't open failure list file: %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (string line; getline(infile, line);) {
|
||||
// Remove whitespace.
|
||||
line.erase(std::remove_if(line.begin(), line.end(), ::isspace),
|
||||
line.end());
|
||||
|
||||
// Remove comments.
|
||||
line = line.substr(0, line.find("#"));
|
||||
|
||||
if (!line.empty()) {
|
||||
failure_list->push_back(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
char *program;
|
||||
google::protobuf::ConformanceTestSuite suite;
|
||||
|
||||
vector<string> failure_list;
|
||||
|
||||
for (int arg = 1; arg < argc; ++arg) {
|
||||
if (strcmp(argv[arg], "--failure_list") == 0) {
|
||||
if (++arg == argc) UsageError();
|
||||
ParseFailureList(argv[arg], &failure_list);
|
||||
} else if (strcmp(argv[arg], "--verbose") == 0) {
|
||||
suite.SetVerbose(true);
|
||||
} else if (argv[arg][0] == '-') {
|
||||
fprintf(stderr, "Unknown option: %s\n", argv[arg]);
|
||||
UsageError();
|
||||
} else {
|
||||
if (arg != argc - 1) {
|
||||
fprintf(stderr, "Too many arguments.\n");
|
||||
UsageError();
|
||||
}
|
||||
program = argv[arg];
|
||||
}
|
||||
}
|
||||
|
||||
suite.SetFailureList(failure_list);
|
||||
ForkPipeRunner runner(program);
|
||||
|
||||
std::string output;
|
||||
bool ok = suite.RunSuite(&runner, &output);
|
||||
|
||||
fwrite(output.c_str(), 1, output.size(), stderr);
|
||||
|
||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
# This is the list of conformance tests that are known to fail for the C++
|
||||
# implementation right now. These should be fixed.
|
||||
#
|
||||
# By listing them here we can keep tabs on which ones are failing and be sure
|
||||
# that we don't introduce regressions in other tests.
|
||||
#
|
||||
# TODO(haberman): insert links to corresponding bugs tracking the issue.
|
||||
# Should we use GitHub issues or the Google-internal bug tracker?
|
||||
|
||||
FieldMaskNumbersDontRoundTrip.JsonOutput
|
||||
FieldMaskPathsDontRoundTrip.JsonOutput
|
||||
FieldMaskTooManyUnderscore.JsonOutput
|
||||
JsonInput.AnyUnorderedTypeTag.JsonOutput
|
||||
JsonInput.AnyUnorderedTypeTag.ProtobufOutput
|
||||
JsonInput.AnyWithValueForInteger.JsonOutput
|
||||
JsonInput.AnyWithValueForInteger.ProtobufOutput
|
||||
JsonInput.AnyWithValueForJsonObject.JsonOutput
|
||||
JsonInput.AnyWithValueForJsonObject.ProtobufOutput
|
||||
JsonInput.BoolFieldDoubleQuotedFalse
|
||||
JsonInput.BoolFieldDoubleQuotedTrue
|
||||
JsonInput.BoolFieldIntegerOne
|
||||
JsonInput.BoolFieldIntegerZero
|
||||
JsonInput.BytesFieldInvalidBase64Characters
|
||||
JsonInput.BytesFieldNoPadding
|
||||
JsonInput.DoubleFieldTooSmall
|
||||
JsonInput.DurationHasZeroFractionalDigit.Validator
|
||||
JsonInput.DurationJsonInputTooLarge
|
||||
JsonInput.DurationJsonInputTooSmall
|
||||
JsonInput.DurationMissingS
|
||||
JsonInput.EnumFieldUnknownValue.Validator
|
||||
JsonInput.FieldMaskInvalidCharacter
|
||||
JsonInput.FieldNameDuplicate
|
||||
JsonInput.FieldNameDuplicateDifferentCasing1
|
||||
JsonInput.FieldNameDuplicateDifferentCasing2
|
||||
JsonInput.FieldNameInLowerCamelCase.Validator
|
||||
JsonInput.FieldNameInSnakeCase.JsonOutput
|
||||
JsonInput.FieldNameInSnakeCase.ProtobufOutput
|
||||
JsonInput.FieldNameNotQuoted
|
||||
JsonInput.FloatFieldTooLarge
|
||||
JsonInput.FloatFieldTooSmall
|
||||
JsonInput.Int32FieldLeadingSpace
|
||||
JsonInput.Int32FieldLeadingZero
|
||||
JsonInput.Int32FieldMinFloatValue.JsonOutput
|
||||
JsonInput.Int32FieldMinFloatValue.ProtobufOutput
|
||||
JsonInput.Int32FieldMinValue.JsonOutput
|
||||
JsonInput.Int32FieldMinValue.ProtobufOutput
|
||||
JsonInput.Int32FieldNegativeWithLeadingZero
|
||||
JsonInput.Int32FieldNotInteger
|
||||
JsonInput.Int32FieldNotNumber
|
||||
JsonInput.Int32FieldTooLarge
|
||||
JsonInput.Int32FieldTooSmall
|
||||
JsonInput.Int32FieldTrailingSpace
|
||||
JsonInput.Int64FieldNotInteger
|
||||
JsonInput.Int64FieldNotNumber
|
||||
JsonInput.Int64FieldTooLarge
|
||||
JsonInput.Int64FieldTooSmall
|
||||
JsonInput.MapFieldValueIsNull
|
||||
JsonInput.OneofFieldDuplicate
|
||||
JsonInput.RepeatedFieldMessageElementIsNull
|
||||
JsonInput.RepeatedFieldPrimitiveElementIsNull
|
||||
JsonInput.RepeatedFieldTrailingComma
|
||||
JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
|
||||
JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotMessage
|
||||
JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotString
|
||||
JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotBool
|
||||
JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotInt
|
||||
JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotString
|
||||
JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool
|
||||
JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
|
||||
JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotMessage
|
||||
JsonInput.StringFieldNotAString
|
||||
JsonInput.StringFieldSurrogateInWrongOrder
|
||||
JsonInput.StringFieldSurrogatePair.JsonOutput
|
||||
JsonInput.StringFieldSurrogatePair.ProtobufOutput
|
||||
JsonInput.StringFieldUnpairedHighSurrogate
|
||||
JsonInput.StringFieldUnpairedLowSurrogate
|
||||
JsonInput.StringFieldUppercaseEscapeLetter
|
||||
JsonInput.TimestampJsonInputLowercaseT
|
||||
JsonInput.TimestampJsonInputLowercaseZ
|
||||
JsonInput.TimestampJsonInputMissingT
|
||||
JsonInput.TimestampJsonInputMissingZ
|
||||
JsonInput.TimestampJsonInputTooLarge
|
||||
JsonInput.TimestampJsonInputTooSmall
|
||||
JsonInput.TrailingCommaInAnObject
|
||||
JsonInput.Uint32FieldNotInteger
|
||||
JsonInput.Uint32FieldNotNumber
|
||||
JsonInput.Uint32FieldTooLarge
|
||||
JsonInput.Uint64FieldNotInteger
|
||||
JsonInput.Uint64FieldNotNumber
|
||||
JsonInput.Uint64FieldTooLarge
|
||||
JsonInput.WrapperTypesWithNullValue.JsonOutput
|
||||
JsonInput.WrapperTypesWithNullValue.ProtobufOutput
|
||||
ProtobufInput.PrematureEofBeforeKnownRepeatedValue.MESSAGE
|
||||
ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
|
||||
ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
|
||||
ProtobufInput.PrematureEofInPackedField.BOOL
|
||||
ProtobufInput.PrematureEofInPackedField.ENUM
|
||||
ProtobufInput.PrematureEofInPackedField.INT32
|
||||
ProtobufInput.PrematureEofInPackedField.INT64
|
||||
ProtobufInput.PrematureEofInPackedField.SINT32
|
||||
ProtobufInput.PrematureEofInPackedField.SINT64
|
||||
ProtobufInput.PrematureEofInPackedField.UINT32
|
||||
ProtobufInput.PrematureEofInPackedField.UINT64
|
||||
ProtobufInput.PrematureEofInsideKnownRepeatedValue.MESSAGE
|
||||
TimestampProtoInputTooLarge.JsonOutput
|
||||
TimestampProtoInputTooSmall.JsonOutput
|
|
@ -0,0 +1,16 @@
|
|||
JsonInput.AnyWithValueForInteger.JsonOutput
|
||||
JsonInput.AnyWithValueForJsonObject.JsonOutput
|
||||
JsonInput.FieldNameInLowerCamelCase.Validator
|
||||
JsonInput.FieldNameInSnakeCase.JsonOutput
|
||||
JsonInput.FieldNameInSnakeCase.ProtobufOutput
|
||||
JsonInput.FieldNameWithMixedCases.JsonOutput
|
||||
JsonInput.FieldNameWithMixedCases.ProtobufOutput
|
||||
JsonInput.FieldNameWithMixedCases.Validator
|
||||
JsonInput.Int32FieldMinFloatValue.JsonOutput
|
||||
JsonInput.Int32FieldMinValue.JsonOutput
|
||||
JsonInput.Int64FieldMaxValueNotQuoted.JsonOutput
|
||||
JsonInput.Int64FieldMaxValueNotQuoted.ProtobufOutput
|
||||
JsonInput.OriginalProtoFieldName.JsonOutput
|
||||
JsonInput.StringFieldSurrogatePair.JsonOutput
|
||||
JsonInput.Uint64FieldMaxValueNotQuoted.JsonOutput
|
||||
JsonInput.Uint64FieldMaxValueNotQuoted.ProtobufOutput
|
|
@ -0,0 +1,49 @@
|
|||
# This is the list of conformance tests that are known to fail for the Java
|
||||
# implementation right now. These should be fixed.
|
||||
#
|
||||
# By listing them here we can keep tabs on which ones are failing and be sure
|
||||
# that we don't introduce regressions in other tests.
|
||||
|
||||
FieldMaskNumbersDontRoundTrip.JsonOutput
|
||||
FieldMaskPathsDontRoundTrip.JsonOutput
|
||||
FieldMaskTooManyUnderscore.JsonOutput
|
||||
JsonInput.AnyWithFieldMask.ProtobufOutput
|
||||
JsonInput.AnyWithValueForInteger.JsonOutput
|
||||
JsonInput.AnyWithValueForJsonObject.JsonOutput
|
||||
JsonInput.BoolFieldAllCapitalFalse
|
||||
JsonInput.BoolFieldAllCapitalTrue
|
||||
JsonInput.BoolFieldCamelCaseFalse
|
||||
JsonInput.BoolFieldCamelCaseTrue
|
||||
JsonInput.BoolFieldDoubleQuotedFalse
|
||||
JsonInput.BoolFieldDoubleQuotedTrue
|
||||
JsonInput.BoolMapFieldKeyNotQuoted
|
||||
JsonInput.DoubleFieldInfinityNotQuoted
|
||||
JsonInput.DoubleFieldNanNotQuoted
|
||||
JsonInput.DoubleFieldNegativeInfinityNotQuoted
|
||||
JsonInput.EnumFieldNotQuoted
|
||||
JsonInput.FieldMask.ProtobufOutput
|
||||
JsonInput.FieldMaskInvalidCharacter
|
||||
JsonInput.FieldNameDuplicate
|
||||
JsonInput.FieldNameInSnakeCase.JsonOutput
|
||||
JsonInput.FieldNameNotQuoted
|
||||
JsonInput.FloatFieldInfinityNotQuoted
|
||||
JsonInput.FloatFieldNanNotQuoted
|
||||
JsonInput.FloatFieldNegativeInfinityNotQuoted
|
||||
JsonInput.Int32FieldLeadingZero
|
||||
JsonInput.Int32FieldMinFloatValue.JsonOutput
|
||||
JsonInput.Int32FieldMinValue.JsonOutput
|
||||
JsonInput.Int32FieldNegativeWithLeadingZero
|
||||
JsonInput.Int32FieldPlusSign
|
||||
JsonInput.Int32MapFieldKeyNotQuoted
|
||||
JsonInput.Int64MapFieldKeyNotQuoted
|
||||
JsonInput.JsonWithComments
|
||||
JsonInput.OriginalProtoFieldName.JsonOutput
|
||||
JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool
|
||||
JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
|
||||
JsonInput.StringFieldNotAString
|
||||
JsonInput.StringFieldSurrogateInWrongOrder
|
||||
JsonInput.StringFieldUnpairedHighSurrogate
|
||||
JsonInput.StringFieldUnpairedLowSurrogate
|
||||
JsonInput.StringFieldUppercaseEscapeLetter
|
||||
JsonInput.Uint32MapFieldKeyNotQuoted
|
||||
JsonInput.Uint64MapFieldKeyNotQuoted
|
|
@ -0,0 +1,4 @@
|
|||
# No tests currently failing.
|
||||
#
|
||||
# json input or output tests are skipped (in conformance_objc.m) as mobile
|
||||
# platforms don't support json wire format to avoid code bloat.
|
|
@ -0,0 +1,2 @@
|
|||
JsonInput.StringFieldSurrogateInWrongOrder
|
||||
JsonInput.StringFieldUnpairedHighSurrogate
|
|
@ -0,0 +1,85 @@
|
|||
DurationProtoInputTooLarge.JsonOutput
|
||||
DurationProtoInputTooSmall.JsonOutput
|
||||
FieldMaskNumbersDontRoundTrip.JsonOutput
|
||||
FieldMaskPathsDontRoundTrip.JsonOutput
|
||||
FieldMaskTooManyUnderscore.JsonOutput
|
||||
JsonInput.Any.JsonOutput
|
||||
JsonInput.Any.ProtobufOutput
|
||||
JsonInput.AnyNested.JsonOutput
|
||||
JsonInput.AnyNested.ProtobufOutput
|
||||
JsonInput.AnyUnorderedTypeTag.JsonOutput
|
||||
JsonInput.AnyUnorderedTypeTag.ProtobufOutput
|
||||
JsonInput.AnyWithDuration.JsonOutput
|
||||
JsonInput.AnyWithDuration.ProtobufOutput
|
||||
JsonInput.AnyWithFieldMask.JsonOutput
|
||||
JsonInput.AnyWithFieldMask.ProtobufOutput
|
||||
JsonInput.AnyWithInt32ValueWrapper.JsonOutput
|
||||
JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput
|
||||
JsonInput.AnyWithStruct.JsonOutput
|
||||
JsonInput.AnyWithStruct.ProtobufOutput
|
||||
JsonInput.AnyWithTimestamp.JsonOutput
|
||||
JsonInput.AnyWithTimestamp.ProtobufOutput
|
||||
JsonInput.AnyWithValueForInteger.JsonOutput
|
||||
JsonInput.AnyWithValueForInteger.ProtobufOutput
|
||||
JsonInput.AnyWithValueForJsonObject.JsonOutput
|
||||
JsonInput.AnyWithValueForJsonObject.ProtobufOutput
|
||||
JsonInput.BytesFieldInvalidBase64Characters
|
||||
JsonInput.DoubleFieldInfinityNotQuoted
|
||||
JsonInput.DoubleFieldNanNotQuoted
|
||||
JsonInput.DoubleFieldNegativeInfinityNotQuoted
|
||||
JsonInput.DoubleFieldTooSmall
|
||||
JsonInput.DurationJsonInputTooLarge
|
||||
JsonInput.DurationJsonInputTooSmall
|
||||
JsonInput.DurationMissingS
|
||||
JsonInput.EnumFieldNumericValueNonZero.JsonOutput
|
||||
JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput
|
||||
JsonInput.EnumFieldNumericValueZero.JsonOutput
|
||||
JsonInput.EnumFieldNumericValueZero.ProtobufOutput
|
||||
JsonInput.EnumFieldUnknownValue.Validator
|
||||
JsonInput.FieldMask.ProtobufOutput
|
||||
JsonInput.FieldMaskInvalidCharacter
|
||||
JsonInput.FieldNameInLowerCamelCase.Validator
|
||||
JsonInput.FieldNameInSnakeCase.JsonOutput
|
||||
JsonInput.FieldNameInSnakeCase.ProtobufOutput
|
||||
JsonInput.FloatFieldInfinityNotQuoted
|
||||
JsonInput.FloatFieldNanNotQuoted
|
||||
JsonInput.FloatFieldNegativeInfinityNotQuoted
|
||||
JsonInput.FloatFieldTooLarge
|
||||
JsonInput.FloatFieldTooSmall
|
||||
JsonInput.Int32FieldExponentialFormat.JsonOutput
|
||||
JsonInput.Int32FieldExponentialFormat.ProtobufOutput
|
||||
JsonInput.Int32FieldFloatTrailingZero.JsonOutput
|
||||
JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput
|
||||
JsonInput.Int32FieldMaxFloatValue.JsonOutput
|
||||
JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
|
||||
JsonInput.Int32FieldMinFloatValue.JsonOutput
|
||||
JsonInput.Int32FieldMinFloatValue.ProtobufOutput
|
||||
JsonInput.Int32FieldMinValue.JsonOutput
|
||||
JsonInput.OriginalProtoFieldName.JsonOutput
|
||||
JsonInput.OriginalProtoFieldName.ProtobufOutput
|
||||
JsonInput.RepeatedFieldMessageElementIsNull
|
||||
JsonInput.RepeatedFieldPrimitiveElementIsNull
|
||||
JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
|
||||
JsonInput.StringFieldSurrogatePair.JsonOutput
|
||||
JsonInput.StringFieldUnpairedLowSurrogate
|
||||
JsonInput.Struct.JsonOutput
|
||||
JsonInput.Struct.ProtobufOutput
|
||||
JsonInput.TimestampJsonInputLowercaseT
|
||||
JsonInput.Uint32FieldMaxFloatValue.JsonOutput
|
||||
JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
|
||||
JsonInput.ValueAcceptBool.JsonOutput
|
||||
JsonInput.ValueAcceptBool.ProtobufOutput
|
||||
JsonInput.ValueAcceptFloat.JsonOutput
|
||||
JsonInput.ValueAcceptFloat.ProtobufOutput
|
||||
JsonInput.ValueAcceptInteger.JsonOutput
|
||||
JsonInput.ValueAcceptInteger.ProtobufOutput
|
||||
JsonInput.ValueAcceptList.JsonOutput
|
||||
JsonInput.ValueAcceptList.ProtobufOutput
|
||||
JsonInput.ValueAcceptNull.JsonOutput
|
||||
JsonInput.ValueAcceptNull.ProtobufOutput
|
||||
JsonInput.ValueAcceptObject.JsonOutput
|
||||
JsonInput.ValueAcceptObject.ProtobufOutput
|
||||
JsonInput.ValueAcceptString.JsonOutput
|
||||
JsonInput.ValueAcceptString.ProtobufOutput
|
||||
TimestampProtoInputTooLarge.JsonOutput
|
||||
TimestampProtoInputTooSmall.JsonOutput
|
|
@ -0,0 +1,110 @@
|
|||
# This is the list of conformance tests that are known to fail for the
|
||||
# Python/C++ implementation right now. These should be fixed.
|
||||
#
|
||||
# By listing them here we can keep tabs on which ones are failing and be sure
|
||||
# that we don't introduce regressions in other tests.
|
||||
#
|
||||
# TODO(haberman): insert links to corresponding bugs tracking the issue.
|
||||
# Should we use GitHub issues or the Google-internal bug tracker?
|
||||
|
||||
DurationProtoInputTooLarge.JsonOutput
|
||||
DurationProtoInputTooSmall.JsonOutput
|
||||
FieldMaskNumbersDontRoundTrip.JsonOutput
|
||||
FieldMaskPathsDontRoundTrip.JsonOutput
|
||||
FieldMaskTooManyUnderscore.JsonOutput
|
||||
JsonInput.Any.JsonOutput
|
||||
JsonInput.Any.ProtobufOutput
|
||||
JsonInput.AnyNested.JsonOutput
|
||||
JsonInput.AnyNested.ProtobufOutput
|
||||
JsonInput.AnyUnorderedTypeTag.JsonOutput
|
||||
JsonInput.AnyUnorderedTypeTag.ProtobufOutput
|
||||
JsonInput.AnyWithDuration.JsonOutput
|
||||
JsonInput.AnyWithDuration.ProtobufOutput
|
||||
JsonInput.AnyWithFieldMask.JsonOutput
|
||||
JsonInput.AnyWithFieldMask.ProtobufOutput
|
||||
JsonInput.AnyWithInt32ValueWrapper.JsonOutput
|
||||
JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput
|
||||
JsonInput.AnyWithStruct.JsonOutput
|
||||
JsonInput.AnyWithStruct.ProtobufOutput
|
||||
JsonInput.AnyWithTimestamp.JsonOutput
|
||||
JsonInput.AnyWithTimestamp.ProtobufOutput
|
||||
JsonInput.AnyWithValueForInteger.JsonOutput
|
||||
JsonInput.AnyWithValueForInteger.ProtobufOutput
|
||||
JsonInput.AnyWithValueForJsonObject.JsonOutput
|
||||
JsonInput.AnyWithValueForJsonObject.ProtobufOutput
|
||||
JsonInput.BytesFieldInvalidBase64Characters
|
||||
JsonInput.DoubleFieldInfinityNotQuoted
|
||||
JsonInput.DoubleFieldNanNotQuoted
|
||||
JsonInput.DoubleFieldNegativeInfinityNotQuoted
|
||||
JsonInput.DoubleFieldTooSmall
|
||||
JsonInput.DurationJsonInputTooLarge
|
||||
JsonInput.DurationJsonInputTooSmall
|
||||
JsonInput.DurationMissingS
|
||||
JsonInput.EnumFieldNumericValueNonZero.JsonOutput
|
||||
JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput
|
||||
JsonInput.EnumFieldNumericValueZero.JsonOutput
|
||||
JsonInput.EnumFieldNumericValueZero.ProtobufOutput
|
||||
JsonInput.EnumFieldUnknownValue.Validator
|
||||
JsonInput.FieldMask.ProtobufOutput
|
||||
JsonInput.FieldMaskInvalidCharacter
|
||||
JsonInput.FieldNameInLowerCamelCase.Validator
|
||||
JsonInput.FieldNameInSnakeCase.JsonOutput
|
||||
JsonInput.FieldNameInSnakeCase.ProtobufOutput
|
||||
JsonInput.FloatFieldInfinityNotQuoted
|
||||
JsonInput.FloatFieldNanNotQuoted
|
||||
JsonInput.FloatFieldNegativeInfinityNotQuoted
|
||||
JsonInput.FloatFieldTooLarge
|
||||
JsonInput.FloatFieldTooSmall
|
||||
JsonInput.Int32FieldExponentialFormat.JsonOutput
|
||||
JsonInput.Int32FieldExponentialFormat.ProtobufOutput
|
||||
JsonInput.Int32FieldFloatTrailingZero.JsonOutput
|
||||
JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput
|
||||
JsonInput.Int32FieldMaxFloatValue.JsonOutput
|
||||
JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
|
||||
JsonInput.Int32FieldMinFloatValue.JsonOutput
|
||||
JsonInput.Int32FieldMinFloatValue.ProtobufOutput
|
||||
JsonInput.Int32FieldMinValue.JsonOutput
|
||||
JsonInput.OriginalProtoFieldName.JsonOutput
|
||||
JsonInput.OriginalProtoFieldName.ProtobufOutput
|
||||
JsonInput.RepeatedFieldMessageElementIsNull
|
||||
JsonInput.RepeatedFieldPrimitiveElementIsNull
|
||||
JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
|
||||
JsonInput.StringFieldSurrogatePair.JsonOutput
|
||||
JsonInput.StringFieldUnpairedLowSurrogate
|
||||
JsonInput.Struct.JsonOutput
|
||||
JsonInput.Struct.ProtobufOutput
|
||||
JsonInput.TimestampJsonInputLowercaseT
|
||||
JsonInput.Uint32FieldMaxFloatValue.JsonOutput
|
||||
JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
|
||||
JsonInput.ValueAcceptBool.JsonOutput
|
||||
JsonInput.ValueAcceptBool.ProtobufOutput
|
||||
JsonInput.ValueAcceptFloat.JsonOutput
|
||||
JsonInput.ValueAcceptFloat.ProtobufOutput
|
||||
JsonInput.ValueAcceptInteger.JsonOutput
|
||||
JsonInput.ValueAcceptInteger.ProtobufOutput
|
||||
JsonInput.ValueAcceptList.JsonOutput
|
||||
JsonInput.ValueAcceptList.ProtobufOutput
|
||||
JsonInput.ValueAcceptNull.JsonOutput
|
||||
JsonInput.ValueAcceptNull.ProtobufOutput
|
||||
JsonInput.ValueAcceptObject.JsonOutput
|
||||
JsonInput.ValueAcceptObject.ProtobufOutput
|
||||
JsonInput.ValueAcceptString.JsonOutput
|
||||
JsonInput.ValueAcceptString.ProtobufOutput
|
||||
ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
|
||||
ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
|
||||
ProtobufInput.PrematureEofInPackedField.BOOL
|
||||
ProtobufInput.PrematureEofInPackedField.DOUBLE
|
||||
ProtobufInput.PrematureEofInPackedField.ENUM
|
||||
ProtobufInput.PrematureEofInPackedField.FIXED32
|
||||
ProtobufInput.PrematureEofInPackedField.FIXED64
|
||||
ProtobufInput.PrematureEofInPackedField.FLOAT
|
||||
ProtobufInput.PrematureEofInPackedField.INT32
|
||||
ProtobufInput.PrematureEofInPackedField.INT64
|
||||
ProtobufInput.PrematureEofInPackedField.SFIXED32
|
||||
ProtobufInput.PrematureEofInPackedField.SFIXED64
|
||||
ProtobufInput.PrematureEofInPackedField.SINT32
|
||||
ProtobufInput.PrematureEofInPackedField.SINT64
|
||||
ProtobufInput.PrematureEofInPackedField.UINT32
|
||||
ProtobufInput.PrematureEofInPackedField.UINT64
|
||||
TimestampProtoInputTooLarge.JsonOutput
|
||||
TimestampProtoInputTooSmall.JsonOutput
|
|
@ -0,0 +1,199 @@
|
|||
DurationProtoInputTooLarge.JsonOutput
|
||||
DurationProtoInputTooSmall.JsonOutput
|
||||
FieldMaskNumbersDontRoundTrip.JsonOutput
|
||||
FieldMaskPathsDontRoundTrip.JsonOutput
|
||||
FieldMaskTooManyUnderscore.JsonOutput
|
||||
JsonInput.Any.JsonOutput
|
||||
JsonInput.Any.ProtobufOutput
|
||||
JsonInput.AnyNested.JsonOutput
|
||||
JsonInput.AnyNested.ProtobufOutput
|
||||
JsonInput.AnyUnorderedTypeTag.JsonOutput
|
||||
JsonInput.AnyUnorderedTypeTag.ProtobufOutput
|
||||
JsonInput.AnyWithDuration.JsonOutput
|
||||
JsonInput.AnyWithDuration.ProtobufOutput
|
||||
JsonInput.AnyWithFieldMask.JsonOutput
|
||||
JsonInput.AnyWithFieldMask.ProtobufOutput
|
||||
JsonInput.AnyWithInt32ValueWrapper.JsonOutput
|
||||
JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput
|
||||
JsonInput.AnyWithStruct.JsonOutput
|
||||
JsonInput.AnyWithStruct.ProtobufOutput
|
||||
JsonInput.AnyWithTimestamp.JsonOutput
|
||||
JsonInput.AnyWithTimestamp.ProtobufOutput
|
||||
JsonInput.AnyWithValueForInteger.JsonOutput
|
||||
JsonInput.AnyWithValueForInteger.ProtobufOutput
|
||||
JsonInput.AnyWithValueForJsonObject.JsonOutput
|
||||
JsonInput.AnyWithValueForJsonObject.ProtobufOutput
|
||||
JsonInput.BoolFieldIntegerOne
|
||||
JsonInput.BoolFieldIntegerZero
|
||||
JsonInput.DoubleFieldInfinity.JsonOutput
|
||||
JsonInput.DoubleFieldInfinity.ProtobufOutput
|
||||
JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
|
||||
JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput
|
||||
JsonInput.DoubleFieldMaxPositiveValue.JsonOutput
|
||||
JsonInput.DoubleFieldMaxPositiveValue.ProtobufOutput
|
||||
JsonInput.DoubleFieldMinNegativeValue.JsonOutput
|
||||
JsonInput.DoubleFieldMinNegativeValue.ProtobufOutput
|
||||
JsonInput.DoubleFieldMinPositiveValue.JsonOutput
|
||||
JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput
|
||||
JsonInput.DoubleFieldNan.JsonOutput
|
||||
JsonInput.DoubleFieldNan.ProtobufOutput
|
||||
JsonInput.DoubleFieldNegativeInfinity.JsonOutput
|
||||
JsonInput.DoubleFieldNegativeInfinity.ProtobufOutput
|
||||
JsonInput.DoubleFieldQuotedValue.JsonOutput
|
||||
JsonInput.DoubleFieldQuotedValue.ProtobufOutput
|
||||
JsonInput.DurationHas3FractionalDigits.Validator
|
||||
JsonInput.DurationHas6FractionalDigits.Validator
|
||||
JsonInput.DurationHas9FractionalDigits.Validator
|
||||
JsonInput.DurationHasZeroFractionalDigit.Validator
|
||||
JsonInput.DurationMaxValue.JsonOutput
|
||||
JsonInput.DurationMaxValue.ProtobufOutput
|
||||
JsonInput.DurationMinValue.JsonOutput
|
||||
JsonInput.DurationMinValue.ProtobufOutput
|
||||
JsonInput.DurationRepeatedValue.JsonOutput
|
||||
JsonInput.DurationRepeatedValue.ProtobufOutput
|
||||
JsonInput.EnumFieldNumericValueNonZero.JsonOutput
|
||||
JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput
|
||||
JsonInput.EnumFieldNumericValueZero.JsonOutput
|
||||
JsonInput.EnumFieldNumericValueZero.ProtobufOutput
|
||||
JsonInput.EnumFieldUnknownValue.Validator
|
||||
JsonInput.FieldMask.JsonOutput
|
||||
JsonInput.FieldMask.ProtobufOutput
|
||||
JsonInput.FieldNameInSnakeCase.JsonOutput
|
||||
JsonInput.FieldNameWithMixedCases.JsonOutput
|
||||
JsonInput.FieldNameWithMixedCases.ProtobufOutput
|
||||
JsonInput.FieldNameWithMixedCases.Validator
|
||||
JsonInput.FloatFieldInfinity.JsonOutput
|
||||
JsonInput.FloatFieldInfinity.ProtobufOutput
|
||||
JsonInput.FloatFieldNan.JsonOutput
|
||||
JsonInput.FloatFieldNan.ProtobufOutput
|
||||
JsonInput.FloatFieldNegativeInfinity.JsonOutput
|
||||
JsonInput.FloatFieldNegativeInfinity.ProtobufOutput
|
||||
JsonInput.FloatFieldQuotedValue.JsonOutput
|
||||
JsonInput.FloatFieldQuotedValue.ProtobufOutput
|
||||
JsonInput.FloatFieldTooLarge
|
||||
JsonInput.FloatFieldTooSmall
|
||||
JsonInput.Int32FieldExponentialFormat.JsonOutput
|
||||
JsonInput.Int32FieldExponentialFormat.ProtobufOutput
|
||||
JsonInput.Int32FieldFloatTrailingZero.JsonOutput
|
||||
JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput
|
||||
JsonInput.Int32FieldMaxFloatValue.JsonOutput
|
||||
JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
|
||||
JsonInput.Int32FieldMinFloatValue.JsonOutput
|
||||
JsonInput.Int32FieldMinFloatValue.ProtobufOutput
|
||||
JsonInput.Int32FieldStringValue.JsonOutput
|
||||
JsonInput.Int32FieldStringValue.ProtobufOutput
|
||||
JsonInput.Int32FieldStringValueEscaped.JsonOutput
|
||||
JsonInput.Int32FieldStringValueEscaped.ProtobufOutput
|
||||
JsonInput.Int32MapEscapedKey.JsonOutput
|
||||
JsonInput.Int32MapEscapedKey.ProtobufOutput
|
||||
JsonInput.Int32MapField.JsonOutput
|
||||
JsonInput.Int32MapField.ProtobufOutput
|
||||
JsonInput.Int64FieldBeString.Validator
|
||||
JsonInput.Int64FieldMaxValue.JsonOutput
|
||||
JsonInput.Int64FieldMaxValue.ProtobufOutput
|
||||
JsonInput.Int64FieldMinValue.JsonOutput
|
||||
JsonInput.Int64FieldMinValue.ProtobufOutput
|
||||
JsonInput.Int64MapEscapedKey.JsonOutput
|
||||
JsonInput.Int64MapEscapedKey.ProtobufOutput
|
||||
JsonInput.Int64MapField.JsonOutput
|
||||
JsonInput.Int64MapField.ProtobufOutput
|
||||
JsonInput.MessageField.JsonOutput
|
||||
JsonInput.MessageField.ProtobufOutput
|
||||
JsonInput.MessageMapField.JsonOutput
|
||||
JsonInput.MessageMapField.ProtobufOutput
|
||||
JsonInput.MessageRepeatedField.JsonOutput
|
||||
JsonInput.MessageRepeatedField.ProtobufOutput
|
||||
JsonInput.OptionalBoolWrapper.JsonOutput
|
||||
JsonInput.OptionalBoolWrapper.ProtobufOutput
|
||||
JsonInput.OptionalBytesWrapper.JsonOutput
|
||||
JsonInput.OptionalBytesWrapper.ProtobufOutput
|
||||
JsonInput.OptionalDoubleWrapper.JsonOutput
|
||||
JsonInput.OptionalDoubleWrapper.ProtobufOutput
|
||||
JsonInput.OptionalFloatWrapper.JsonOutput
|
||||
JsonInput.OptionalFloatWrapper.ProtobufOutput
|
||||
JsonInput.OptionalInt32Wrapper.JsonOutput
|
||||
JsonInput.OptionalInt32Wrapper.ProtobufOutput
|
||||
JsonInput.OptionalInt64Wrapper.JsonOutput
|
||||
JsonInput.OptionalInt64Wrapper.ProtobufOutput
|
||||
JsonInput.OptionalStringWrapper.JsonOutput
|
||||
JsonInput.OptionalStringWrapper.ProtobufOutput
|
||||
JsonInput.OptionalUint32Wrapper.JsonOutput
|
||||
JsonInput.OptionalUint32Wrapper.ProtobufOutput
|
||||
JsonInput.OptionalUint64Wrapper.JsonOutput
|
||||
JsonInput.OptionalUint64Wrapper.ProtobufOutput
|
||||
JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
|
||||
JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput
|
||||
JsonInput.OriginalProtoFieldName.JsonOutput
|
||||
JsonInput.PrimitiveRepeatedField.JsonOutput
|
||||
JsonInput.PrimitiveRepeatedField.ProtobufOutput
|
||||
JsonInput.RepeatedBoolWrapper.JsonOutput
|
||||
JsonInput.RepeatedBoolWrapper.ProtobufOutput
|
||||
JsonInput.RepeatedBytesWrapper.JsonOutput
|
||||
JsonInput.RepeatedBytesWrapper.ProtobufOutput
|
||||
JsonInput.RepeatedDoubleWrapper.JsonOutput
|
||||
JsonInput.RepeatedDoubleWrapper.ProtobufOutput
|
||||
JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
|
||||
JsonInput.RepeatedFloatWrapper.JsonOutput
|
||||
JsonInput.RepeatedFloatWrapper.ProtobufOutput
|
||||
JsonInput.RepeatedInt32Wrapper.JsonOutput
|
||||
JsonInput.RepeatedInt32Wrapper.ProtobufOutput
|
||||
JsonInput.RepeatedInt64Wrapper.JsonOutput
|
||||
JsonInput.RepeatedInt64Wrapper.ProtobufOutput
|
||||
JsonInput.RepeatedStringWrapper.JsonOutput
|
||||
JsonInput.RepeatedStringWrapper.ProtobufOutput
|
||||
JsonInput.RepeatedUint32Wrapper.JsonOutput
|
||||
JsonInput.RepeatedUint32Wrapper.ProtobufOutput
|
||||
JsonInput.RepeatedUint64Wrapper.JsonOutput
|
||||
JsonInput.RepeatedUint64Wrapper.ProtobufOutput
|
||||
JsonInput.StringFieldNotAString
|
||||
JsonInput.StringFieldSurrogateInWrongOrder
|
||||
JsonInput.StringFieldSurrogatePair.JsonOutput
|
||||
JsonInput.StringFieldSurrogatePair.ProtobufOutput
|
||||
JsonInput.StringFieldUnpairedHighSurrogate
|
||||
JsonInput.StringFieldUnpairedLowSurrogate
|
||||
JsonInput.Struct.JsonOutput
|
||||
JsonInput.Struct.ProtobufOutput
|
||||
JsonInput.TimestampHas3FractionalDigits.Validator
|
||||
JsonInput.TimestampHas6FractionalDigits.Validator
|
||||
JsonInput.TimestampHas9FractionalDigits.Validator
|
||||
JsonInput.TimestampHasZeroFractionalDigit.Validator
|
||||
JsonInput.TimestampMaxValue.JsonOutput
|
||||
JsonInput.TimestampMaxValue.ProtobufOutput
|
||||
JsonInput.TimestampMinValue.JsonOutput
|
||||
JsonInput.TimestampMinValue.ProtobufOutput
|
||||
JsonInput.TimestampRepeatedValue.JsonOutput
|
||||
JsonInput.TimestampRepeatedValue.ProtobufOutput
|
||||
JsonInput.TimestampWithNegativeOffset.JsonOutput
|
||||
JsonInput.TimestampWithNegativeOffset.ProtobufOutput
|
||||
JsonInput.TimestampWithPositiveOffset.JsonOutput
|
||||
JsonInput.TimestampWithPositiveOffset.ProtobufOutput
|
||||
JsonInput.TimestampZeroNormalized.Validator
|
||||
JsonInput.Uint32FieldMaxFloatValue.JsonOutput
|
||||
JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
|
||||
JsonInput.Uint32MapField.JsonOutput
|
||||
JsonInput.Uint32MapField.ProtobufOutput
|
||||
JsonInput.Uint64FieldBeString.Validator
|
||||
JsonInput.Uint64FieldMaxValue.JsonOutput
|
||||
JsonInput.Uint64FieldMaxValue.ProtobufOutput
|
||||
JsonInput.Uint64MapField.JsonOutput
|
||||
JsonInput.Uint64MapField.ProtobufOutput
|
||||
JsonInput.ValueAcceptBool.JsonOutput
|
||||
JsonInput.ValueAcceptBool.ProtobufOutput
|
||||
JsonInput.ValueAcceptFloat.JsonOutput
|
||||
JsonInput.ValueAcceptFloat.ProtobufOutput
|
||||
JsonInput.ValueAcceptInteger.JsonOutput
|
||||
JsonInput.ValueAcceptInteger.ProtobufOutput
|
||||
JsonInput.ValueAcceptList.JsonOutput
|
||||
JsonInput.ValueAcceptList.ProtobufOutput
|
||||
JsonInput.ValueAcceptNull.JsonOutput
|
||||
JsonInput.ValueAcceptNull.ProtobufOutput
|
||||
JsonInput.ValueAcceptObject.JsonOutput
|
||||
JsonInput.ValueAcceptObject.ProtobufOutput
|
||||
JsonInput.ValueAcceptString.JsonOutput
|
||||
JsonInput.ValueAcceptString.ProtobufOutput
|
||||
ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput
|
||||
ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput
|
||||
ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput
|
||||
ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput
|
||||
TimestampProtoInputTooLarge.JsonOutput
|
||||
TimestampProtoInputTooSmall.JsonOutput
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,36 @@
|
|||
#
|
||||
# Untracked directories
|
||||
#
|
||||
src/AddressBook/bin
|
||||
src/AddressBook/obj
|
||||
src/Google.Protobuf/bin/
|
||||
src/Google.Protobuf/obj/
|
||||
src/Google.Protobuf.Conformance/bin/
|
||||
src/Google.Protobuf.Conformance/obj/
|
||||
src/Google.Protobuf.Test/bin/
|
||||
src/Google.Protobuf.Test/obj/
|
||||
src/Google.Protobuf.JsonDump/bin/
|
||||
src/Google.Protobuf.JsonDump/obj/
|
||||
mono/bin
|
||||
mono/tmp
|
||||
mono/protoc
|
||||
build_output
|
||||
build_temp
|
||||
build/msbuild*.log
|
||||
lib/Microsoft.Silverlight.Testing
|
||||
lib/NUnit
|
||||
|
||||
#
|
||||
# Untracked files
|
||||
#
|
||||
*.user
|
||||
*.suo
|
||||
*.nupkg
|
||||
_ReSharper.*
|
||||
*.sln.cache
|
||||
mono/TestResult.xml
|
||||
mono/.libs
|
||||
mono/*.exe
|
||||
mono/*.dll
|
||||
lib/protoc.exe
|
||||
*.ncrunch*
|
|
@ -0,0 +1,148 @@
|
|||
===============================================================================
|
||||
Welcome to the C# port of Google Protocol Buffers, written by Jon Skeet
|
||||
(skeet@pobox.com) based on the work of many talented people.
|
||||
|
||||
===============================================================================
|
||||
RELEASE NOTES - Code imported into Google's main protobuf repository
|
||||
===============================================================================
|
||||
|
||||
Everything below note this represents history of protobuf-csharp-port project
|
||||
before the code was merged into csharp/ subtree of GitHub google/protobuf
|
||||
repository.
|
||||
Frozen legacy version of the original project is available in
|
||||
https://github.com/jskeet/protobuf-csharp-port.
|
||||
|
||||
===============================================================================
|
||||
RELEASE NOTES - Version 2.4.1.555
|
||||
===============================================================================
|
||||
|
||||
Changes:
|
||||
- Upgrade solution format to Visual Studio 2012.
|
||||
- Add the ability to print a builder (not just a message)
|
||||
- TextGenerator introduces a new overload of PrintTo
|
||||
- Munge protoc's error format into a VS-C#-compatible output format.
|
||||
- Work to make ProtoGen clone that acts as a protoc.exe plugin.
|
||||
- Added the AllowPartiallyTrustedCallers attribute
|
||||
- Optimized enum parsing.
|
||||
|
||||
Fixes:
|
||||
- Fix for bug in limited input stream's Position, Introduced Position on
|
||||
output stream
|
||||
- Fix for writing a character to a JSON output overflows allocated buffer
|
||||
- Optimize FromBase64String to return Empty when presented with empty string.
|
||||
- Use string.Concat instead of operator to avoid potential import problems
|
||||
- Issue 81: quoting for NUnit parameters.
|
||||
- Issue 56: NuGet package is noisy
|
||||
- Issue 70: Portable library project has some invalid Nunit-based code.
|
||||
- Issue 71: CodedInputStream.ReadBytes go to slow path unnecessarily
|
||||
- Issue 84: warning CS0219: The variable `size' is assigned but never used
|
||||
|
||||
===============================================================================
|
||||
RELEASE NOTES - Version 2.4.1.521
|
||||
===============================================================================
|
||||
|
||||
Changes:
|
||||
- Add generated_code_attributes option, defaulted to false
|
||||
- Added support for Portable library
|
||||
- Added 'Unsafe' static type in ByteString to allow direct buffer access
|
||||
|
||||
Fixes:
|
||||
- Issue 50: The XML serializer will fail to deserialize a message with empty
|
||||
child message
|
||||
- Issue 45: Use of 'item' as a field name causes AmbiguousMatchException
|
||||
- Issue 49: Generated nested static Types class should be partial
|
||||
- Issue 38: Disable CLSCompliant warnings (3021)
|
||||
- Issue 40: proto_path does not work for command-line file names
|
||||
- Issue 54: should retire all bytes in buffer (bufferSize)
|
||||
- Issue 43: Fix to correct identical 'umbrella_classname' options from trying
|
||||
to write to the same filename.
|
||||
|
||||
===============================================================================
|
||||
RELEASE NOTES - Version 2.4.1.473
|
||||
===============================================================================
|
||||
|
||||
Features:
|
||||
- Added option service_generator_type to control service generation with
|
||||
NONE, GENERIC, INTERFACE, or IRPCDISPATCH
|
||||
- Added interfaces IRpcDispatch and IRpcServerStub to provide for blocking
|
||||
services and implementations.
|
||||
- Added ProtoGen.exe command-line argument "--protoc_dir=" to specify the
|
||||
location of protoc.exe.
|
||||
- Extracted interfaces for ICodedInputStream and ICodedOutputStream to allow
|
||||
custom implementation of writers with both speed and size optimizations.
|
||||
- Addition of the "Google.ProtoBuffers.Serialization" assembly to support
|
||||
reading and writing messages to/from XML, JSON, IDictionary<,> and others.
|
||||
- Several performance related fixes and tweeks
|
||||
- Issue 3: Add option to mark generated code with attribute
|
||||
- Issue 20: Support for decorating classes [Serializable]
|
||||
- Issue 21: Decorate fields with [deprecated=true] as [System.Obsolete]
|
||||
- Issue 22: Reusable Builder classes
|
||||
- Issue 24: Support for using Json/Xml formats with ICodedInputStream
|
||||
- Issue 25: Added support for NuGet packages
|
||||
- Issue 31: Upgraded protoc.exe and descriptor to 2.4.1
|
||||
|
||||
Fixes:
|
||||
- Issue 13: Message with Field same name as message causes uncompilable .cs
|
||||
- Issue 16: Does not integrate well with other tooling
|
||||
- Issue 19: Support for negative enum values
|
||||
- Issue 26: AddRange in GeneratedBuilder iterates twice.
|
||||
- Issue 27: Remove XML documentation output from test projects to clear
|
||||
warnings/errors.
|
||||
- Issue 28: Circular message dependencies result in null default values for
|
||||
Message fields.
|
||||
- Issue 29: Message classes generated have a public default constructor. You
|
||||
can disable private ctor generation with the option generate_private_ctor.
|
||||
- Issue 35: Fixed a bug in ProtoGen handling of arguments with trailing \
|
||||
- Big-endian support for float, and double on Silverlight
|
||||
- Packed and Unpacked parsing allow for all repeated, as per version 2.3
|
||||
- Fix for leaving Builder a public ctor on internal classes for use with
|
||||
generic "where T: new()" constraints.
|
||||
|
||||
Other:
|
||||
- Changed the code signing key to a privately held key
|
||||
- Reformatted all code and line-endings to C# defaults
|
||||
- Reworking of performance benchmarks to produce reliable results, option /v2
|
||||
- Issue 34: Silverlight assemblies are now unit tested
|
||||
|
||||
===============================================================================
|
||||
RELEASE NOTES - Version 2.3.0.277
|
||||
===============================================================================
|
||||
|
||||
Features:
|
||||
- Added cls_compliance option to generate attributes indicating
|
||||
non-CLS-compliance.
|
||||
- Added file_extension option to control the generated output file's extension.
|
||||
- Added umbrella_namespace option to place the umbrella class into a nested
|
||||
namespace to address issues with proto files having the same name as a
|
||||
message it contains.
|
||||
- Added output_directory option to set the output path for the source file(s).
|
||||
- Added ignore_google_protobuf option to avoid generating code for includes
|
||||
from the google.protobuf package.
|
||||
- Added the LITE framework (Google.ProtoBuffersLite.dll) and the ability to
|
||||
generate code with "option optimize_for = LITE_RUNTIME;".
|
||||
- Added ability to invoke protoc.exe from within ProtoGen.exe.
|
||||
- Upgraded to protoc.exe (2.3) compiler.
|
||||
|
||||
Fixes:
|
||||
- Issue 9: Class cannot be static and sealed error
|
||||
- Issue 12: default value for enumerate fields must be filled out
|
||||
|
||||
Other:
|
||||
- Rewrite of build using MSbuild instead of NAnt
|
||||
- Moved to NUnit Version 2.2.8.0
|
||||
- Changed to using secure .snk for releases
|
||||
|
||||
===============================================================================
|
||||
RELEASE NOTES - Version 0.9.1
|
||||
===============================================================================
|
||||
|
||||
Fixes:
|
||||
- issue 10: Incorrect encoding of packed fields when serialized
|
||||
|
||||
===============================================================================
|
||||
RELEASE NOTES - Version 0.9.0
|
||||
===============================================================================
|
||||
|
||||
- Initial release
|
||||
|
||||
===============================================================================
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package>
|
||||
<metadata>
|
||||
<id>Google.Protobuf.Tools</id>
|
||||
<title>Google Protocol Buffers tools</title>
|
||||
<summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
|
||||
<description>See project site for more info.</description>
|
||||
<version>3.0.0-beta3</version>
|
||||
<authors>Google Inc.</authors>
|
||||
<owners>protobuf-packages</owners>
|
||||
<licenseUrl>https://github.com/google/protobuf/blob/master/LICENSE</licenseUrl>
|
||||
<projectUrl>https://github.com/google/protobuf</projectUrl>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<releaseNotes>Tools for Protocol Buffers</releaseNotes>
|
||||
<copyright>Copyright 2015, Google Inc.</copyright>
|
||||
<tags>Protocol Buffers Binary Serialization Format Google proto proto3</tags>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="protoc\windows_x86\protoc.exe" target="tools\windows_x86\protoc.exe" />
|
||||
<file src="protoc\windows_x64\protoc.exe" target="tools\windows_x64\protoc.exe" />
|
||||
<file src="protoc\linux_x86\protoc" target="tools\linux_x86\protoc" />
|
||||
<file src="protoc\linux_x64\protoc" target="tools\linux_x64\protoc" />
|
||||
<file src="protoc\macosx_x86\protoc" target="tools\macosx_x86\protoc" />
|
||||
<file src="protoc\macosx_x64\protoc" target="tools\macosx_x64\protoc" />
|
||||
<file src="..\src\google\protobuf\any.proto" target="tools\google\protobuf" />
|
||||
<file src="..\src\google\protobuf\api.proto" target="tools\google\protobuf" />
|
||||
<file src="..\src\google\protobuf\descriptor.proto" target="tools\google\protobuf" />
|
||||
<file src="..\src\google\protobuf\duration.proto" target="tools\google\protobuf" />
|
||||
<file src="..\src\google\protobuf\empty.proto" target="tools\google\protobuf" />
|
||||
<file src="..\src\google\protobuf\field_mask.proto" target="tools\google\protobuf" />
|
||||
<file src="..\src\google\protobuf\source_context.proto" target="tools\google\protobuf" />
|
||||
<file src="..\src\google\protobuf\struct.proto" target="tools\google\protobuf" />
|
||||
<file src="..\src\google\protobuf\timestamp.proto" target="tools\google\protobuf" />
|
||||
<file src="..\src\google\protobuf\type.proto" target="tools\google\protobuf" />
|
||||
<file src="..\src\google\protobuf\wrappers.proto" target="tools\google\protobuf" />
|
||||
</files>
|
||||
</package>
|
|
@ -0,0 +1,70 @@
|
|||
This directory contains the C# Protocol Buffers runtime library.
|
||||
|
||||
Status: Beta - ready for external testing
|
||||
=========================================
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
The easiest way how to use C# protobufs is via the `Google.Protobuf`
|
||||
NuGet package. Just add the NuGet package to your VS project.
|
||||
|
||||
Besides C# runtime library, the NuGet package also contains
|
||||
precompiled version of `protoc.exe` and a copy of well known `.proto`
|
||||
files under the package's `tools` directory.
|
||||
|
||||
To generate C# files from your `.proto` files, invoke `protoc` with the
|
||||
`--csharp_out` option.
|
||||
|
||||
Supported platforms
|
||||
===================
|
||||
|
||||
The runtime library is built as a portable class library, supporting:
|
||||
|
||||
- .NET 4.5
|
||||
- Windows 8
|
||||
- Windows Phone Silverlight 8
|
||||
- Windows Phone 8.1
|
||||
- .NET Core
|
||||
|
||||
You should be able to use Protocol Buffers in Visual Studio 2012 and
|
||||
all later versions. This includes all code generated by `protoc`,
|
||||
which only uses features from C# 3 and earlier.
|
||||
|
||||
Building
|
||||
========
|
||||
|
||||
Open the `src/Google.Protobuf.sln` solution in Visual Studio 2015 or
|
||||
later. You should be able to run the NUnit test from Test Explorer
|
||||
(you might need to install NUnit Visual Studio add-in).
|
||||
|
||||
Although *users* of this project are only expected to have Visual
|
||||
Studio 2012 or later, *developers* of the library are required to
|
||||
have Visual Studio 2015 or later, as the library uses C# 6 features
|
||||
in its implementation. These features have no impact when using the
|
||||
compiled code - they're only relevant when building the
|
||||
`Google.Protobuf` assembly.
|
||||
|
||||
History of C# protobufs
|
||||
=======================
|
||||
|
||||
This subtree was originally imported from https://github.com/jskeet/protobuf-csharp-port
|
||||
and represents the latest development version of C# protobufs, that will now be developed
|
||||
and maintained by Google. All the development will be done in open, under this repository
|
||||
(https://github.com/google/protobuf).
|
||||
|
||||
The previous project differs from this project in a number of ways:
|
||||
|
||||
- The old code only supported proto2; the new code only supports
|
||||
proto3 (so no unknown fields, no required/optional distinction, no
|
||||
extensions)
|
||||
- The old code was based on immutable message types and builders for
|
||||
them
|
||||
- The old code did not support maps or `oneof`
|
||||
- The old code had its own JSON representation, whereas the new code
|
||||
uses the standard protobuf JSON representation
|
||||
- The old code had no notion of the "well-known types" which have
|
||||
special support in the new code
|
||||
- The old project supported some older platforms (such as older
|
||||
versions of Silverlight) which are not currently supported in the
|
||||
new project
|
|
@ -0,0 +1,13 @@
|
|||
@rem Builds Google.Protobuf NuGet packages
|
||||
|
||||
@rem Adjust the location of nuget.exe
|
||||
set NUGET=C:\nuget\nuget.exe
|
||||
|
||||
@rem Build src/Google.Protobuf.sln solution in Release configuration first.
|
||||
%NUGET% pack src\Google.Protobuf\Google.Protobuf.nuspec -Symbols || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed!
|
||||
exit /b %errorlevel%
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
# Use mono to build solution and run all tests.
|
||||
|
||||
# Adjust these to reflect the location of nunit-console in your system.
|
||||
NUNIT_CONSOLE=nunit-console
|
||||
|
||||
# The rest you can leave intact
|
||||
CONFIG=Release
|
||||
SRC=$(dirname $0)/src
|
||||
|
||||
set -ex
|
||||
|
||||
echo Building the solution.
|
||||
xbuild /p:Configuration=$CONFIG $SRC/Google.Protobuf.sln
|
||||
|
||||
echo Running tests.
|
||||
$NUNIT_CONSOLE $SRC/Google.Protobuf.Test/bin/$CONFIG/Google.Protobuf.Test.dll
|
|
@ -0,0 +1,62 @@
|
|||
#!/bin/bash
|
||||
# Generates C# source files from .proto files.
|
||||
# You first need to make sure protoc has been built (see instructions on
|
||||
# building protoc in root of this repository)
|
||||
|
||||
set -ex
|
||||
|
||||
# cd to repository root
|
||||
pushd $(dirname $0)/..
|
||||
|
||||
# Protocol buffer compiler to use. If the PROTOC variable is set,
|
||||
# use that. Otherwise, probe for expected locations under both
|
||||
# Windows and Unix.
|
||||
if [ -z "$PROTOC" ]; then
|
||||
# TODO(jonskeet): Use an array and a for loop instead?
|
||||
if [ -x cmake/build/Debug/protoc.exe ]; then
|
||||
PROTOC=cmake/build/Debug/protoc.exe
|
||||
elif [ -x cmake/build/Release/protoc.exe ]; then
|
||||
PROTOC=cmake/build/Release/protoc.exe
|
||||
elif [ -x src/protoc ]; then
|
||||
PROTOC=src/protoc
|
||||
else
|
||||
echo "Unable to find protocol buffer compiler."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# descriptor.proto and well-known types
|
||||
$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \
|
||||
--csharp_opt=base_namespace=Google.Protobuf \
|
||||
src/google/protobuf/descriptor.proto \
|
||||
src/google/protobuf/any.proto \
|
||||
src/google/protobuf/api.proto \
|
||||
src/google/protobuf/duration.proto \
|
||||
src/google/protobuf/empty.proto \
|
||||
src/google/protobuf/field_mask.proto \
|
||||
src/google/protobuf/source_context.proto \
|
||||
src/google/protobuf/struct.proto \
|
||||
src/google/protobuf/timestamp.proto \
|
||||
src/google/protobuf/type.proto \
|
||||
src/google/protobuf/wrappers.proto
|
||||
|
||||
# Test protos where the namespace matches the target location
|
||||
$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf.Test \
|
||||
--csharp_opt=base_namespace=Google.Protobuf \
|
||||
src/google/protobuf/map_unittest_proto3.proto \
|
||||
src/google/protobuf/unittest_proto3.proto \
|
||||
src/google/protobuf/unittest_import_proto3.proto \
|
||||
src/google/protobuf/unittest_import_public_proto3.proto \
|
||||
src/google/protobuf/unittest_well_known_types.proto
|
||||
|
||||
# Different base namespace to the protos above
|
||||
$PROTOC -Icsharp/protos --csharp_out=csharp/src/Google.Protobuf.Test \
|
||||
--csharp_opt=base_namespace=UnitTest.Issues \
|
||||
csharp/protos/unittest_issues.proto
|
||||
|
||||
# AddressBook sample protos
|
||||
$PROTOC -Iexamples --csharp_out=csharp/src/AddressBook \
|
||||
examples/addressbook.proto
|
||||
|
||||
$PROTOC -Iconformance -Isrc --csharp_out=csharp/src/Google.Protobuf.Conformance \
|
||||
conformance/conformance.proto
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,9 @@
|
|||
Contents
|
||||
--------
|
||||
|
||||
- Google.Protobuf.public.snk:
|
||||
Public key to verify strong name of Google.Protobuf assemblies.
|
||||
- Google.Protobuf.snk:
|
||||
Signing key to provide strong name of Google.Protobuf assemblies.
|
||||
As per [Microsoft guidance](https://msdn.microsoft.com/en-us/library/wd40t7ad(v=vs.110).aspx)
|
||||
signing key should be checked into the repository.
|
|
@ -0,0 +1,126 @@
|
|||
syntax = "proto3";
|
||||
|
||||
// These proto descriptors have at one time been reported as an issue or defect.
|
||||
// They are kept here to replicate the issue, and continue to verify the fix.
|
||||
|
||||
// Issue: Non-"Google.Protobuffers" namespace will ensure that protobuffer library types are qualified
|
||||
option csharp_namespace = "UnitTest.Issues.TestProtos";
|
||||
|
||||
package unittest_issues;
|
||||
option optimize_for = SPEED;
|
||||
|
||||
// Issue 307: when generating doubly-nested types, any references
|
||||
// should be of the form A.Types.B.Types.C.
|
||||
message Issue307 {
|
||||
message NestedOnce {
|
||||
message NestedTwice {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Old issue 13: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=13
|
||||
// New issue 309: https://github.com/google/protobuf/issues/309
|
||||
|
||||
// message A {
|
||||
// optional int32 _A = 1;
|
||||
// }
|
||||
|
||||
// message B {
|
||||
// optional int32 B_ = 1;
|
||||
// }
|
||||
|
||||
//message AB {
|
||||
// optional int32 a_b = 1;
|
||||
//}
|
||||
|
||||
// Similar issue with numeric names
|
||||
// Java code failed too, so probably best for this to be a restriction.
|
||||
// See https://github.com/google/protobuf/issues/308
|
||||
// message NumberField {
|
||||
// optional int32 _01 = 1;
|
||||
// }
|
||||
|
||||
// issue 19 - negative enum values
|
||||
|
||||
enum NegativeEnum {
|
||||
NEGATIVE_ENUM_ZERO = 0;
|
||||
FiveBelow = -5;
|
||||
MinusOne = -1;
|
||||
}
|
||||
|
||||
message NegativeEnumMessage {
|
||||
NegativeEnum value = 1;
|
||||
repeated NegativeEnum values = 2 [packed = false];
|
||||
repeated NegativeEnum packed_values = 3 [packed=true];
|
||||
}
|
||||
|
||||
// Issue 21: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=21
|
||||
// Decorate fields with [deprecated=true] as [System.Obsolete]
|
||||
|
||||
message DeprecatedChild {
|
||||
}
|
||||
|
||||
enum DeprecatedEnum {
|
||||
DEPRECATED_ZERO = 0;
|
||||
one = 1;
|
||||
}
|
||||
|
||||
message DeprecatedFieldsMessage {
|
||||
int32 PrimitiveValue = 1 [deprecated = true];
|
||||
repeated int32 PrimitiveArray = 2 [deprecated = true];
|
||||
|
||||
DeprecatedChild MessageValue = 3 [deprecated = true];
|
||||
repeated DeprecatedChild MessageArray = 4 [deprecated = true];
|
||||
|
||||
DeprecatedEnum EnumValue = 5 [deprecated = true];
|
||||
repeated DeprecatedEnum EnumArray = 6 [deprecated = true];
|
||||
}
|
||||
|
||||
// Issue 45: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=45
|
||||
message ItemField {
|
||||
int32 item = 1;
|
||||
}
|
||||
|
||||
message ReservedNames {
|
||||
// Force a nested type called Types
|
||||
message SomeNestedType {
|
||||
}
|
||||
|
||||
int32 types = 1;
|
||||
int32 descriptor = 2;
|
||||
}
|
||||
|
||||
message TestJsonFieldOrdering {
|
||||
// These fields are deliberately not declared in numeric
|
||||
// order, and the oneof fields aren't contiguous either.
|
||||
// This allows for reasonably robust tests of JSON output
|
||||
// ordering.
|
||||
// TestFieldOrderings in unittest_proto3.proto is similar,
|
||||
// but doesn't include oneofs.
|
||||
// TODO: Consider adding oneofs to TestFieldOrderings, although
|
||||
// that will require fixing other tests in multiple platforms.
|
||||
// Alternatively, consider just adding this to
|
||||
// unittest_proto3.proto if multiple platforms want it.
|
||||
|
||||
int32 plain_int32 = 4;
|
||||
|
||||
oneof o1 {
|
||||
string o1_string = 2;
|
||||
int32 o1_int32 = 5;
|
||||
}
|
||||
|
||||
string plain_string = 1;
|
||||
|
||||
oneof o2 {
|
||||
int32 o2_int32 = 6;
|
||||
string o2_string = 3;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
message TestJsonName {
|
||||
// Message for testing the effects for of the json_name option
|
||||
string name = 1;
|
||||
string description = 2 [json_name = "desc"];
|
||||
string guid = 3 [json_name = "exid"];
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
#region Copyright notice and license
|
||||
// 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.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Google.Protobuf.Examples.AddressBook
|
||||
{
|
||||
internal class AddPerson
|
||||
{
|
||||
/// <summary>
|
||||
/// Builds a person based on user input
|
||||
/// </summary>
|
||||
private static Person PromptForAddress(TextReader input, TextWriter output)
|
||||
{
|
||||
Person person = new Person();
|
||||
|
||||
output.Write("Enter person ID: ");
|
||||
person.Id = int.Parse(input.ReadLine());
|
||||
|
||||
output.Write("Enter name: ");
|
||||
person.Name = input.ReadLine();
|
||||
|
||||
output.Write("Enter email address (blank for none): ");
|
||||
string email = input.ReadLine();
|
||||
if (email.Length > 0)
|
||||
{
|
||||
person.Email = email;
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
output.Write("Enter a phone number (or leave blank to finish): ");
|
||||
string number = input.ReadLine();
|
||||
if (number.Length == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Person.Types.PhoneNumber phoneNumber = new Person.Types.PhoneNumber { Number = number };
|
||||
|
||||
output.Write("Is this a mobile, home, or work phone? ");
|
||||
String type = input.ReadLine();
|
||||
switch (type)
|
||||
{
|
||||
case "mobile":
|
||||
phoneNumber.Type = Person.Types.PhoneType.Mobile;
|
||||
break;
|
||||
case "home":
|
||||
phoneNumber.Type = Person.Types.PhoneType.Home;
|
||||
break;
|
||||
case "work":
|
||||
phoneNumber.Type = Person.Types.PhoneType.Work;
|
||||
break;
|
||||
default:
|
||||
output.Write("Unknown phone type. Using default.");
|
||||
break;
|
||||
}
|
||||
|
||||
person.Phones.Add(phoneNumber);
|
||||
}
|
||||
return person;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Entry point - loads an existing addressbook or creates a new one,
|
||||
/// then writes it back to the file.
|
||||
/// </summary>
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
{
|
||||
Console.Error.WriteLine("Usage: AddPerson ADDRESS_BOOK_FILE");
|
||||
return -1;
|
||||
}
|
||||
|
||||
AddressBook addressBook;
|
||||
|
||||
if (File.Exists(args[0]))
|
||||
{
|
||||
using (Stream file = File.OpenRead(args[0]))
|
||||
{
|
||||
addressBook = AddressBook.Parser.ParseFrom(file);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("{0}: File not found. Creating a new file.", args[0]);
|
||||
addressBook = new AddressBook();
|
||||
}
|
||||
|
||||
// Add an address.
|
||||
addressBook.People.Add(PromptForAddress(Console.In, Console.Out));
|
||||
|
||||
// Write the new address book back to disk.
|
||||
using (Stream output = File.OpenWrite(args[0]))
|
||||
{
|
||||
addressBook.WriteTo(output);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{A31F5FB2-4FF3-432A-B35B-5CD203606311}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Google.Protobuf.Examples.AddressBook</RootNamespace>
|
||||
<AssemblyName>AddressBook</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<StartupObject>Google.Protobuf.Examples.AddressBook.Program</StartupObject>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<IntermediateOutputPath>obj\Debug\</IntermediateOutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<IntermediateOutputPath>obj\Release\</IntermediateOutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AddPerson.cs" />
|
||||
<Compile Include="Addressbook.cs" />
|
||||
<Compile Include="SampleUsage.cs" />
|
||||
<Compile Include="ListPeople.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Google.Protobuf\Google.Protobuf.csproj">
|
||||
<Project>{6908BDCE-D925-43F3-94AC-A531E6DF2591}</Project>
|
||||
<Name>Google.Protobuf</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,473 @@
|
|||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: addressbook.proto
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
using pbc = global::Google.Protobuf.Collections;
|
||||
using pbr = global::Google.Protobuf.Reflection;
|
||||
using scg = global::System.Collections.Generic;
|
||||
namespace Google.Protobuf.Examples.AddressBook {
|
||||
|
||||
/// <summary>Holder for reflection information generated from addressbook.proto</summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
public static partial class AddressbookReflection {
|
||||
|
||||
#region Descriptor
|
||||
/// <summary>File descriptor for addressbook.proto</summary>
|
||||
public static pbr::FileDescriptor Descriptor {
|
||||
get { return descriptor; }
|
||||
}
|
||||
private static pbr::FileDescriptor descriptor;
|
||||
|
||||
static AddressbookReflection() {
|
||||
byte[] descriptorData = global::System.Convert.FromBase64String(
|
||||
string.Concat(
|
||||
"ChFhZGRyZXNzYm9vay5wcm90bxIIdHV0b3JpYWwi1QEKBlBlcnNvbhIMCgRu",
|
||||
"YW1lGAEgASgJEgoKAmlkGAIgASgFEg0KBWVtYWlsGAMgASgJEiwKBnBob25l",
|
||||
"cxgEIAMoCzIcLnR1dG9yaWFsLlBlcnNvbi5QaG9uZU51bWJlchpHCgtQaG9u",
|
||||
"ZU51bWJlchIOCgZudW1iZXIYASABKAkSKAoEdHlwZRgCIAEoDjIaLnR1dG9y",
|
||||
"aWFsLlBlcnNvbi5QaG9uZVR5cGUiKwoJUGhvbmVUeXBlEgoKBk1PQklMRRAA",
|
||||
"EggKBEhPTUUQARIICgRXT1JLEAIiLwoLQWRkcmVzc0Jvb2sSIAoGcGVvcGxl",
|
||||
"GAEgAygLMhAudHV0b3JpYWwuUGVyc29uQlAKFGNvbS5leGFtcGxlLnR1dG9y",
|
||||
"aWFsQhFBZGRyZXNzQm9va1Byb3Rvc6oCJEdvb2dsZS5Qcm90b2J1Zi5FeGFt",
|
||||
"cGxlcy5BZGRyZXNzQm9va2IGcHJvdG8z"));
|
||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
||||
new pbr::FileDescriptor[] { },
|
||||
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Examples.AddressBook.Person), global::Google.Protobuf.Examples.AddressBook.Person.Parser, new[]{ "Name", "Id", "Email", "Phones" }, null, new[]{ typeof(global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType) }, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber), global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber.Parser, new[]{ "Number", "Type" }, null, null, null)}),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Examples.AddressBook.AddressBook), global::Google.Protobuf.Examples.AddressBook.AddressBook.Parser, new[]{ "People" }, null, null, null)
|
||||
}));
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
#region Messages
|
||||
/// <summary>
|
||||
/// [START messages]
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
public sealed partial class Person : pb::IMessage<Person> {
|
||||
private static readonly pb::MessageParser<Person> _parser = new pb::MessageParser<Person>(() => new Person());
|
||||
public static pb::MessageParser<Person> Parser { get { return _parser; } }
|
||||
|
||||
public static pbr::MessageDescriptor Descriptor {
|
||||
get { return global::Google.Protobuf.Examples.AddressBook.AddressbookReflection.Descriptor.MessageTypes[0]; }
|
||||
}
|
||||
|
||||
pbr::MessageDescriptor pb::IMessage.Descriptor {
|
||||
get { return Descriptor; }
|
||||
}
|
||||
|
||||
public Person() {
|
||||
OnConstruction();
|
||||
}
|
||||
|
||||
partial void OnConstruction();
|
||||
|
||||
public Person(Person other) : this() {
|
||||
name_ = other.name_;
|
||||
id_ = other.id_;
|
||||
email_ = other.email_;
|
||||
phones_ = other.phones_.Clone();
|
||||
}
|
||||
|
||||
public Person Clone() {
|
||||
return new Person(this);
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "name" field.</summary>
|
||||
public const int NameFieldNumber = 1;
|
||||
private string name_ = "";
|
||||
public string Name {
|
||||
get { return name_; }
|
||||
set {
|
||||
name_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "id" field.</summary>
|
||||
public const int IdFieldNumber = 2;
|
||||
private int id_;
|
||||
/// <summary>
|
||||
/// Unique ID number for this person.
|
||||
/// </summary>
|
||||
public int Id {
|
||||
get { return id_; }
|
||||
set {
|
||||
id_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "email" field.</summary>
|
||||
public const int EmailFieldNumber = 3;
|
||||
private string email_ = "";
|
||||
public string Email {
|
||||
get { return email_; }
|
||||
set {
|
||||
email_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "phones" field.</summary>
|
||||
public const int PhonesFieldNumber = 4;
|
||||
private static readonly pb::FieldCodec<global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber> _repeated_phones_codec
|
||||
= pb::FieldCodec.ForMessage(34, global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber.Parser);
|
||||
private readonly pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber> phones_ = new pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber>();
|
||||
public pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber> Phones {
|
||||
get { return phones_; }
|
||||
}
|
||||
|
||||
public override bool Equals(object other) {
|
||||
return Equals(other as Person);
|
||||
}
|
||||
|
||||
public bool Equals(Person other) {
|
||||
if (ReferenceEquals(other, null)) {
|
||||
return false;
|
||||
}
|
||||
if (ReferenceEquals(other, this)) {
|
||||
return true;
|
||||
}
|
||||
if (Name != other.Name) return false;
|
||||
if (Id != other.Id) return false;
|
||||
if (Email != other.Email) return false;
|
||||
if(!phones_.Equals(other.phones_)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetHashCode() {
|
||||
int hash = 1;
|
||||
if (Name.Length != 0) hash ^= Name.GetHashCode();
|
||||
if (Id != 0) hash ^= Id.GetHashCode();
|
||||
if (Email.Length != 0) hash ^= Email.GetHashCode();
|
||||
hash ^= phones_.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return pb::JsonFormatter.ToDiagnosticString(this);
|
||||
}
|
||||
|
||||
public void WriteTo(pb::CodedOutputStream output) {
|
||||
if (Name.Length != 0) {
|
||||
output.WriteRawTag(10);
|
||||
output.WriteString(Name);
|
||||
}
|
||||
if (Id != 0) {
|
||||
output.WriteRawTag(16);
|
||||
output.WriteInt32(Id);
|
||||
}
|
||||
if (Email.Length != 0) {
|
||||
output.WriteRawTag(26);
|
||||
output.WriteString(Email);
|
||||
}
|
||||
phones_.WriteTo(output, _repeated_phones_codec);
|
||||
}
|
||||
|
||||
public int CalculateSize() {
|
||||
int size = 0;
|
||||
if (Name.Length != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
|
||||
}
|
||||
if (Id != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(Id);
|
||||
}
|
||||
if (Email.Length != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(Email);
|
||||
}
|
||||
size += phones_.CalculateSize(_repeated_phones_codec);
|
||||
return size;
|
||||
}
|
||||
|
||||
public void MergeFrom(Person other) {
|
||||
if (other == null) {
|
||||
return;
|
||||
}
|
||||
if (other.Name.Length != 0) {
|
||||
Name = other.Name;
|
||||
}
|
||||
if (other.Id != 0) {
|
||||
Id = other.Id;
|
||||
}
|
||||
if (other.Email.Length != 0) {
|
||||
Email = other.Email;
|
||||
}
|
||||
phones_.Add(other.phones_);
|
||||
}
|
||||
|
||||
public void MergeFrom(pb::CodedInputStream input) {
|
||||
uint tag;
|
||||
while ((tag = input.ReadTag()) != 0) {
|
||||
switch(tag) {
|
||||
default:
|
||||
input.SkipLastField();
|
||||
break;
|
||||
case 10: {
|
||||
Name = input.ReadString();
|
||||
break;
|
||||
}
|
||||
case 16: {
|
||||
Id = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 26: {
|
||||
Email = input.ReadString();
|
||||
break;
|
||||
}
|
||||
case 34: {
|
||||
phones_.AddEntriesFrom(input, _repeated_phones_codec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Nested types
|
||||
/// <summary>Container for nested types declared in the Person message type.</summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
public static partial class Types {
|
||||
public enum PhoneType {
|
||||
[pbr::OriginalName("MOBILE")] Mobile = 0,
|
||||
[pbr::OriginalName("HOME")] Home = 1,
|
||||
[pbr::OriginalName("WORK")] Work = 2,
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
public sealed partial class PhoneNumber : pb::IMessage<PhoneNumber> {
|
||||
private static readonly pb::MessageParser<PhoneNumber> _parser = new pb::MessageParser<PhoneNumber>(() => new PhoneNumber());
|
||||
public static pb::MessageParser<PhoneNumber> Parser { get { return _parser; } }
|
||||
|
||||
public static pbr::MessageDescriptor Descriptor {
|
||||
get { return global::Google.Protobuf.Examples.AddressBook.Person.Descriptor.NestedTypes[0]; }
|
||||
}
|
||||
|
||||
pbr::MessageDescriptor pb::IMessage.Descriptor {
|
||||
get { return Descriptor; }
|
||||
}
|
||||
|
||||
public PhoneNumber() {
|
||||
OnConstruction();
|
||||
}
|
||||
|
||||
partial void OnConstruction();
|
||||
|
||||
public PhoneNumber(PhoneNumber other) : this() {
|
||||
number_ = other.number_;
|
||||
type_ = other.type_;
|
||||
}
|
||||
|
||||
public PhoneNumber Clone() {
|
||||
return new PhoneNumber(this);
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "number" field.</summary>
|
||||
public const int NumberFieldNumber = 1;
|
||||
private string number_ = "";
|
||||
public string Number {
|
||||
get { return number_; }
|
||||
set {
|
||||
number_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "type" field.</summary>
|
||||
public const int TypeFieldNumber = 2;
|
||||
private global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType type_ = 0;
|
||||
public global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType Type {
|
||||
get { return type_; }
|
||||
set {
|
||||
type_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object other) {
|
||||
return Equals(other as PhoneNumber);
|
||||
}
|
||||
|
||||
public bool Equals(PhoneNumber other) {
|
||||
if (ReferenceEquals(other, null)) {
|
||||
return false;
|
||||
}
|
||||
if (ReferenceEquals(other, this)) {
|
||||
return true;
|
||||
}
|
||||
if (Number != other.Number) return false;
|
||||
if (Type != other.Type) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetHashCode() {
|
||||
int hash = 1;
|
||||
if (Number.Length != 0) hash ^= Number.GetHashCode();
|
||||
if (Type != 0) hash ^= Type.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return pb::JsonFormatter.ToDiagnosticString(this);
|
||||
}
|
||||
|
||||
public void WriteTo(pb::CodedOutputStream output) {
|
||||
if (Number.Length != 0) {
|
||||
output.WriteRawTag(10);
|
||||
output.WriteString(Number);
|
||||
}
|
||||
if (Type != 0) {
|
||||
output.WriteRawTag(16);
|
||||
output.WriteEnum((int) Type);
|
||||
}
|
||||
}
|
||||
|
||||
public int CalculateSize() {
|
||||
int size = 0;
|
||||
if (Number.Length != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(Number);
|
||||
}
|
||||
if (Type != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
public void MergeFrom(PhoneNumber other) {
|
||||
if (other == null) {
|
||||
return;
|
||||
}
|
||||
if (other.Number.Length != 0) {
|
||||
Number = other.Number;
|
||||
}
|
||||
if (other.Type != 0) {
|
||||
Type = other.Type;
|
||||
}
|
||||
}
|
||||
|
||||
public void MergeFrom(pb::CodedInputStream input) {
|
||||
uint tag;
|
||||
while ((tag = input.ReadTag()) != 0) {
|
||||
switch(tag) {
|
||||
default:
|
||||
input.SkipLastField();
|
||||
break;
|
||||
case 10: {
|
||||
Number = input.ReadString();
|
||||
break;
|
||||
}
|
||||
case 16: {
|
||||
type_ = (global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType) input.ReadEnum();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Our address book file is just one of these.
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
public sealed partial class AddressBook : pb::IMessage<AddressBook> {
|
||||
private static readonly pb::MessageParser<AddressBook> _parser = new pb::MessageParser<AddressBook>(() => new AddressBook());
|
||||
public static pb::MessageParser<AddressBook> Parser { get { return _parser; } }
|
||||
|
||||
public static pbr::MessageDescriptor Descriptor {
|
||||
get { return global::Google.Protobuf.Examples.AddressBook.AddressbookReflection.Descriptor.MessageTypes[1]; }
|
||||
}
|
||||
|
||||
pbr::MessageDescriptor pb::IMessage.Descriptor {
|
||||
get { return Descriptor; }
|
||||
}
|
||||
|
||||
public AddressBook() {
|
||||
OnConstruction();
|
||||
}
|
||||
|
||||
partial void OnConstruction();
|
||||
|
||||
public AddressBook(AddressBook other) : this() {
|
||||
people_ = other.people_.Clone();
|
||||
}
|
||||
|
||||
public AddressBook Clone() {
|
||||
return new AddressBook(this);
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "people" field.</summary>
|
||||
public const int PeopleFieldNumber = 1;
|
||||
private static readonly pb::FieldCodec<global::Google.Protobuf.Examples.AddressBook.Person> _repeated_people_codec
|
||||
= pb::FieldCodec.ForMessage(10, global::Google.Protobuf.Examples.AddressBook.Person.Parser);
|
||||
private readonly pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person> people_ = new pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person>();
|
||||
public pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person> People {
|
||||
get { return people_; }
|
||||
}
|
||||
|
||||
public override bool Equals(object other) {
|
||||
return Equals(other as AddressBook);
|
||||
}
|
||||
|
||||
public bool Equals(AddressBook other) {
|
||||
if (ReferenceEquals(other, null)) {
|
||||
return false;
|
||||
}
|
||||
if (ReferenceEquals(other, this)) {
|
||||
return true;
|
||||
}
|
||||
if(!people_.Equals(other.people_)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetHashCode() {
|
||||
int hash = 1;
|
||||
hash ^= people_.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return pb::JsonFormatter.ToDiagnosticString(this);
|
||||
}
|
||||
|
||||
public void WriteTo(pb::CodedOutputStream output) {
|
||||
people_.WriteTo(output, _repeated_people_codec);
|
||||
}
|
||||
|
||||
public int CalculateSize() {
|
||||
int size = 0;
|
||||
size += people_.CalculateSize(_repeated_people_codec);
|
||||
return size;
|
||||
}
|
||||
|
||||
public void MergeFrom(AddressBook other) {
|
||||
if (other == null) {
|
||||
return;
|
||||
}
|
||||
people_.Add(other.people_);
|
||||
}
|
||||
|
||||
public void MergeFrom(pb::CodedInputStream input) {
|
||||
uint tag;
|
||||
while ((tag = input.ReadTag()) != 0) {
|
||||
switch(tag) {
|
||||
default:
|
||||
input.SkipLastField();
|
||||
break;
|
||||
case 10: {
|
||||
people_.AddEntriesFrom(input, _repeated_people_codec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
#endregion Designer generated code
|
|
@ -0,0 +1,99 @@
|
|||
#region Copyright notice and license
|
||||
// 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.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Google.Protobuf.Examples.AddressBook
|
||||
{
|
||||
internal class ListPeople
|
||||
{
|
||||
/// <summary>
|
||||
/// Iterates though all people in the AddressBook and prints info about them.
|
||||
/// </summary>
|
||||
private static void Print(AddressBook addressBook)
|
||||
{
|
||||
foreach (Person person in addressBook.People)
|
||||
{
|
||||
Console.WriteLine("Person ID: {0}", person.Id);
|
||||
Console.WriteLine(" Name: {0}", person.Name);
|
||||
if (person.Email != "")
|
||||
{
|
||||
Console.WriteLine(" E-mail address: {0}", person.Email);
|
||||
}
|
||||
|
||||
foreach (Person.Types.PhoneNumber phoneNumber in person.Phones)
|
||||
{
|
||||
switch (phoneNumber.Type)
|
||||
{
|
||||
case Person.Types.PhoneType.Mobile:
|
||||
Console.Write(" Mobile phone #: ");
|
||||
break;
|
||||
case Person.Types.PhoneType.Home:
|
||||
Console.Write(" Home phone #: ");
|
||||
break;
|
||||
case Person.Types.PhoneType.Work:
|
||||
Console.Write(" Work phone #: ");
|
||||
break;
|
||||
}
|
||||
Console.WriteLine(phoneNumber.Number);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Entry point - loads the addressbook and then displays it.
|
||||
/// </summary>
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
{
|
||||
Console.Error.WriteLine("Usage: ListPeople ADDRESS_BOOK_FILE");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!File.Exists(args[0]))
|
||||
{
|
||||
Console.WriteLine("{0} doesn't exist. Add a person to create the file first.", args[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Read the existing address book.
|
||||
using (Stream stream = File.OpenRead(args[0]))
|
||||
{
|
||||
AddressBook addressBook = AddressBook.Parser.ParseFrom(stream);
|
||||
Print(addressBook);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
#region Copyright notice and license
|
||||
// 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.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
||||
namespace Google.Protobuf.Examples.AddressBook
|
||||
{
|
||||
/// <summary>
|
||||
/// Entry point. Repeatedly prompts user for an action to take, delegating actual behaviour
|
||||
/// to individual actions. Each action has its own Main method, so that it can be used as an
|
||||
/// invidual complete program.
|
||||
/// </summary>
|
||||
internal class Program
|
||||
{
|
||||
private static int Main(string[] args)
|
||||
{
|
||||
if (args.Length > 1)
|
||||
{
|
||||
Console.Error.WriteLine("Usage: AddressBook [file]");
|
||||
Console.Error.WriteLine("If the filename isn't specified, \"addressbook.data\" is used instead.");
|
||||
return 1;
|
||||
}
|
||||
string addressBookFile = args.Length > 0 ? args[0] : "addressbook.data";
|
||||
|
||||
bool stopping = false;
|
||||
while (!stopping)
|
||||
{
|
||||
Console.WriteLine("Options:");
|
||||
Console.WriteLine(" L: List contents");
|
||||
Console.WriteLine(" A: Add new person");
|
||||
Console.WriteLine(" Q: Quit");
|
||||
Console.Write("Action? ");
|
||||
Console.Out.Flush();
|
||||
char choice = Console.ReadKey().KeyChar;
|
||||
Console.WriteLine();
|
||||
try
|
||||
{
|
||||
switch (choice)
|
||||
{
|
||||
case 'A':
|
||||
case 'a':
|
||||
AddPerson.Main(new string[] {addressBookFile});
|
||||
break;
|
||||
case 'L':
|
||||
case 'l':
|
||||
ListPeople.Main(new string[] {addressBookFile});
|
||||
break;
|
||||
case 'Q':
|
||||
case 'q':
|
||||
stopping = true;
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("Unknown option: {0}", choice);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("Exception executing action: {0}", e);
|
||||
}
|
||||
Console.WriteLine();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
18
packager/third_party/protobuf/csharp/src/AddressBook/Properties/AssemblyInfo.cs
vendored
Normal file
18
packager/third_party/protobuf/csharp/src/AddressBook/Properties/AssemblyInfo.cs
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
|
||||
[assembly: AssemblyTitle("AddressBook")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("AddressBook")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
[assembly: AssemblyVersion("3.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("3.0.0.0")]
|
|
@ -0,0 +1,73 @@
|
|||
#region Copyright notice and license
|
||||
// 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.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Google.Protobuf.Examples.AddressBook
|
||||
{
|
||||
internal class SampleUsage
|
||||
{
|
||||
private static void Main()
|
||||
{
|
||||
byte[] bytes;
|
||||
// Create a new person
|
||||
Person person = new Person
|
||||
{
|
||||
Id = 1,
|
||||
Name = "Foo",
|
||||
Email = "foo@bar",
|
||||
Phones = { new Person.Types.PhoneNumber { Number = "555-1212" } }
|
||||
};
|
||||
using (MemoryStream stream = new MemoryStream())
|
||||
{
|
||||
// Save the person to a stream
|
||||
person.WriteTo(stream);
|
||||
bytes = stream.ToArray();
|
||||
}
|
||||
Person copy = Person.Parser.ParseFrom(bytes);
|
||||
|
||||
AddressBook book = new AddressBook
|
||||
{
|
||||
People = { copy }
|
||||
};
|
||||
bytes = book.ToByteArray();
|
||||
// And read the address book back again
|
||||
AddressBook restored = AddressBook.Parser.ParseFrom(bytes);
|
||||
// The message performs a deep-comparison on equality:
|
||||
if (restored.People.Count != 1 || !person.Equals(restored.People[0]))
|
||||
{
|
||||
throw new ApplicationException("There is a bad person in here!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
|
6
packager/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/App.config
vendored
Normal file
6
packager/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/App.config
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
3708
packager/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Conformance.cs
vendored
Normal file
3708
packager/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Conformance.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,61 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{0607D1B8-80D6-4B35-9857-1263C1B32B94}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Google.Protobuf.Conformance</RootNamespace>
|
||||
<AssemblyName>Google.Protobuf.Conformance</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Conformance.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Google.Protobuf\Google.Protobuf.csproj">
|
||||
<Project>{6908bdce-d925-43f3-94ac-a531e6df2591}</Project>
|
||||
<Name>Google.Protobuf</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
142
packager/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Program.cs
vendored
Normal file
142
packager/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Program.cs
vendored
Normal file
|
@ -0,0 +1,142 @@
|
|||
#region Copyright notice and license
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2015 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.
|
||||
#endregion
|
||||
|
||||
using Conformance;
|
||||
using Google.Protobuf.Reflection;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Google.Protobuf.Conformance
|
||||
{
|
||||
/// <summary>
|
||||
/// Conformance tests. The test runner will provide JSON or proto data on stdin,
|
||||
/// and this program will produce its output on stdout.
|
||||
/// </summary>
|
||||
class Program
|
||||
{
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
// This way we get the binary streams instead of readers/writers.
|
||||
var input = new BinaryReader(Console.OpenStandardInput());
|
||||
var output = new BinaryWriter(Console.OpenStandardOutput());
|
||||
var typeRegistry = TypeRegistry.FromMessages(TestAllTypes.Descriptor);
|
||||
|
||||
int count = 0;
|
||||
while (RunTest(input, output, typeRegistry))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
Console.Error.WriteLine("Received EOF after {0} tests", count);
|
||||
}
|
||||
|
||||
private static bool RunTest(BinaryReader input, BinaryWriter output, TypeRegistry typeRegistry)
|
||||
{
|
||||
int? size = ReadInt32(input);
|
||||
if (size == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
byte[] inputData = input.ReadBytes(size.Value);
|
||||
if (inputData.Length != size.Value)
|
||||
{
|
||||
throw new EndOfStreamException("Read " + inputData.Length + " bytes of data when expecting " + size);
|
||||
}
|
||||
ConformanceRequest request = ConformanceRequest.Parser.ParseFrom(inputData);
|
||||
ConformanceResponse response = PerformRequest(request, typeRegistry);
|
||||
byte[] outputData = response.ToByteArray();
|
||||
output.Write(outputData.Length);
|
||||
output.Write(outputData);
|
||||
// Ready for another test...
|
||||
return true;
|
||||
}
|
||||
|
||||
private static ConformanceResponse PerformRequest(ConformanceRequest request, TypeRegistry typeRegistry)
|
||||
{
|
||||
TestAllTypes message;
|
||||
try
|
||||
{
|
||||
switch (request.PayloadCase)
|
||||
{
|
||||
case ConformanceRequest.PayloadOneofCase.JsonPayload:
|
||||
var parser = new JsonParser(new JsonParser.Settings(20, typeRegistry));
|
||||
message = parser.Parse<TestAllTypes>(request.JsonPayload);
|
||||
break;
|
||||
case ConformanceRequest.PayloadOneofCase.ProtobufPayload:
|
||||
message = TestAllTypes.Parser.ParseFrom(request.ProtobufPayload);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Unsupported request payload: " + request.PayloadCase);
|
||||
}
|
||||
}
|
||||
catch (InvalidProtocolBufferException e)
|
||||
{
|
||||
return new ConformanceResponse { ParseError = e.Message };
|
||||
}
|
||||
catch (InvalidJsonException e)
|
||||
{
|
||||
return new ConformanceResponse { ParseError = e.Message };
|
||||
}
|
||||
try
|
||||
{
|
||||
switch (request.RequestedOutputFormat)
|
||||
{
|
||||
case global::Conformance.WireFormat.Json:
|
||||
var formatter = new JsonFormatter(new JsonFormatter.Settings(false, typeRegistry));
|
||||
return new ConformanceResponse { JsonPayload = formatter.Format(message) };
|
||||
case global::Conformance.WireFormat.Protobuf:
|
||||
return new ConformanceResponse { ProtobufPayload = message.ToByteString() };
|
||||
default:
|
||||
throw new Exception("Unsupported request output format: " + request.PayloadCase);
|
||||
}
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
return new ConformanceResponse { SerializeError = e.Message };
|
||||
}
|
||||
}
|
||||
|
||||
private static int? ReadInt32(BinaryReader input)
|
||||
{
|
||||
byte[] bytes = input.ReadBytes(4);
|
||||
if (bytes.Length == 0)
|
||||
{
|
||||
// Cleanly reached the end of the stream
|
||||
return null;
|
||||
}
|
||||
if (bytes.Length != 4)
|
||||
{
|
||||
throw new EndOfStreamException("Read " + bytes.Length + " bytes of size when expecting 4");
|
||||
}
|
||||
return bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24);
|
||||
}
|
||||
}
|
||||
}
|
48
packager/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Properties/AssemblyInfo.cs
vendored
Normal file
48
packager/third_party/protobuf/csharp/src/Google.Protobuf.Conformance/Properties/AssemblyInfo.cs
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
#region Copyright notice and license
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2015 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.
|
||||
#endregion
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Google.Protobuf.Conformance")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Google.Protobuf.Conformance")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
[assembly: AssemblyVersion("3.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("3.0.0.0")]
|
|
@ -0,0 +1,68 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{D7282E99-2DC3-405B-946F-177DB2FD2AE2}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Google.Protobuf.JsonDump</RootNamespace>
|
||||
<AssemblyName>Google.Protobuf.JsonDump</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<IntermediateOutputPath>obj\Debug\</IntermediateOutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<IntermediateOutputPath>obj\Release\</IntermediateOutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Google.Protobuf\Google.Protobuf.csproj">
|
||||
<Project>{6908BDCE-D925-43F3-94AC-A531E6DF2591}</Project>
|
||||
<Name>Google.Protobuf</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
72
packager/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Program.cs
vendored
Normal file
72
packager/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Program.cs
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
#region Copyright notice and license
|
||||
// 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.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Google.Protobuf.ProtoDump
|
||||
{
|
||||
/// <summary>
|
||||
/// Small utility to load a binary message and dump it in JSON format.
|
||||
/// </summary>
|
||||
internal class Program
|
||||
{
|
||||
private static int Main(string[] args)
|
||||
{
|
||||
if (args.Length != 2)
|
||||
{
|
||||
Console.Error.WriteLine("Usage: Google.Protobuf.JsonDump <descriptor type name> <input data>");
|
||||
Console.Error.WriteLine("The descriptor type name is the fully-qualified message name,");
|
||||
Console.Error.WriteLine("including assembly e.g. ProjectNamespace.Message,Company.Project");
|
||||
return 1;
|
||||
}
|
||||
Type type = Type.GetType(args[0]);
|
||||
if (type == null)
|
||||
{
|
||||
Console.Error.WriteLine("Unable to load type {0}.", args[0]);
|
||||
return 1;
|
||||
}
|
||||
if (!typeof(IMessage).IsAssignableFrom(type))
|
||||
{
|
||||
Console.Error.WriteLine("Type {0} doesn't implement IMessage.", args[0]);
|
||||
return 1;
|
||||
}
|
||||
IMessage message = (IMessage) Activator.CreateInstance(type);
|
||||
using (var input = File.OpenRead(args[1]))
|
||||
{
|
||||
message.MergeFrom(input);
|
||||
}
|
||||
Console.WriteLine(message);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
19
packager/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Properties/AssemblyInfo.cs
vendored
Normal file
19
packager/third_party/protobuf/csharp/src/Google.Protobuf.JsonDump/Properties/AssemblyInfo.cs
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
|
||||
[assembly: AssemblyTitle("ProtoDump")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ProtoDump")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
[assembly: AssemblyVersion("3.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("3.0.0.0")]
|
|
@ -0,0 +1,3 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
|
171
packager/third_party/protobuf/csharp/src/Google.Protobuf.Test/ByteStringTest.cs
vendored
Normal file
171
packager/third_party/protobuf/csharp/src/Google.Protobuf.Test/ByteStringTest.cs
vendored
Normal file
|
@ -0,0 +1,171 @@
|
|||
#region Copyright notice and license
|
||||
// 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.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Google.Protobuf
|
||||
{
|
||||
public class ByteStringTest
|
||||
{
|
||||
[Test]
|
||||
public void Equality()
|
||||
{
|
||||
ByteString b1 = ByteString.CopyFrom(1, 2, 3);
|
||||
ByteString b2 = ByteString.CopyFrom(1, 2, 3);
|
||||
ByteString b3 = ByteString.CopyFrom(1, 2, 4);
|
||||
ByteString b4 = ByteString.CopyFrom(1, 2, 3, 4);
|
||||
EqualityTester.AssertEquality(b1, b1);
|
||||
EqualityTester.AssertEquality(b1, b2);
|
||||
EqualityTester.AssertInequality(b1, b3);
|
||||
EqualityTester.AssertInequality(b1, b4);
|
||||
EqualityTester.AssertInequality(b1, null);
|
||||
#pragma warning disable 1718 // Deliberately calling ==(b1, b1) and !=(b1, b1)
|
||||
Assert.IsTrue(b1 == b1);
|
||||
Assert.IsTrue(b1 == b2);
|
||||
Assert.IsFalse(b1 == b3);
|
||||
Assert.IsFalse(b1 == b4);
|
||||
Assert.IsFalse(b1 == null);
|
||||
Assert.IsTrue((ByteString) null == null);
|
||||
Assert.IsFalse(b1 != b1);
|
||||
Assert.IsFalse(b1 != b2);
|
||||
#pragma warning disable 1718
|
||||
Assert.IsTrue(b1 != b3);
|
||||
Assert.IsTrue(b1 != b4);
|
||||
Assert.IsTrue(b1 != null);
|
||||
Assert.IsFalse((ByteString) null != null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EmptyByteStringHasZeroSize()
|
||||
{
|
||||
Assert.AreEqual(0, ByteString.Empty.Length);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CopyFromStringWithExplicitEncoding()
|
||||
{
|
||||
ByteString bs = ByteString.CopyFrom("AB", Encoding.Unicode);
|
||||
Assert.AreEqual(4, bs.Length);
|
||||
Assert.AreEqual(65, bs[0]);
|
||||
Assert.AreEqual(0, bs[1]);
|
||||
Assert.AreEqual(66, bs[2]);
|
||||
Assert.AreEqual(0, bs[3]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsEmptyWhenEmpty()
|
||||
{
|
||||
Assert.IsTrue(ByteString.CopyFromUtf8("").IsEmpty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsEmptyWhenNotEmpty()
|
||||
{
|
||||
Assert.IsFalse(ByteString.CopyFromUtf8("X").IsEmpty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CopyFromByteArrayCopiesContents()
|
||||
{
|
||||
byte[] data = new byte[1];
|
||||
data[0] = 10;
|
||||
ByteString bs = ByteString.CopyFrom(data);
|
||||
Assert.AreEqual(10, bs[0]);
|
||||
data[0] = 5;
|
||||
Assert.AreEqual(10, bs[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToByteArrayCopiesContents()
|
||||
{
|
||||
ByteString bs = ByteString.CopyFromUtf8("Hello");
|
||||
byte[] data = bs.ToByteArray();
|
||||
Assert.AreEqual((byte)'H', data[0]);
|
||||
Assert.AreEqual((byte)'H', bs[0]);
|
||||
data[0] = 0;
|
||||
Assert.AreEqual(0, data[0]);
|
||||
Assert.AreEqual((byte)'H', bs[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CopyFromUtf8UsesUtf8()
|
||||
{
|
||||
ByteString bs = ByteString.CopyFromUtf8("\u20ac");
|
||||
Assert.AreEqual(3, bs.Length);
|
||||
Assert.AreEqual(0xe2, bs[0]);
|
||||
Assert.AreEqual(0x82, bs[1]);
|
||||
Assert.AreEqual(0xac, bs[2]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CopyFromPortion()
|
||||
{
|
||||
byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6};
|
||||
ByteString bs = ByteString.CopyFrom(data, 2, 3);
|
||||
Assert.AreEqual(3, bs.Length);
|
||||
Assert.AreEqual(2, bs[0]);
|
||||
Assert.AreEqual(3, bs[1]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToStringUtf8()
|
||||
{
|
||||
ByteString bs = ByteString.CopyFromUtf8("\u20ac");
|
||||
Assert.AreEqual("\u20ac", bs.ToStringUtf8());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToStringWithExplicitEncoding()
|
||||
{
|
||||
ByteString bs = ByteString.CopyFrom("\u20ac", Encoding.Unicode);
|
||||
Assert.AreEqual("\u20ac", bs.ToString(Encoding.Unicode));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FromBase64_WithText()
|
||||
{
|
||||
byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6};
|
||||
string base64 = Convert.ToBase64String(data);
|
||||
ByteString bs = ByteString.FromBase64(base64);
|
||||
Assert.AreEqual(data, bs.ToByteArray());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FromBase64_Empty()
|
||||
{
|
||||
// Optimization which also fixes issue 61.
|
||||
Assert.AreSame(ByteString.Empty, ByteString.FromBase64(""));
|
||||
}
|
||||
}
|
||||
}
|
53
packager/third_party/protobuf/csharp/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs
vendored
Normal file
53
packager/third_party/protobuf/csharp/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
#region Copyright notice and license
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2015 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.
|
||||
#endregion
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Google.Protobuf
|
||||
{
|
||||
internal static class CodedInputStreamExtensions
|
||||
{
|
||||
public static void AssertNextTag(this CodedInputStream input, uint expectedTag)
|
||||
{
|
||||
uint tag = input.ReadTag();
|
||||
Assert.AreEqual(expectedTag, tag);
|
||||
}
|
||||
|
||||
public static T ReadMessage<T>(this CodedInputStream stream, MessageParser<T> parser)
|
||||
where T : IMessage<T>
|
||||
{
|
||||
var message = parser.CreateTemplate();
|
||||
stream.ReadMessage(message);
|
||||
return message;
|
||||
}
|
||||
}
|
||||
}
|
598
packager/third_party/protobuf/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs
vendored
Normal file
598
packager/third_party/protobuf/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs
vendored
Normal file
|
@ -0,0 +1,598 @@
|
|||
#region Copyright notice and license
|
||||
// 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.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Google.Protobuf.TestProtos;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Google.Protobuf
|
||||
{
|
||||
public class CodedInputStreamTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper to construct a byte array from a bunch of bytes. The inputs are
|
||||
/// actually ints so that I can use hex notation and not get stupid errors
|
||||
/// about precision.
|
||||
/// </summary>
|
||||
private static byte[] Bytes(params int[] bytesAsInts)
|
||||
{
|
||||
byte[] bytes = new byte[bytesAsInts.Length];
|
||||
for (int i = 0; i < bytesAsInts.Length; i++)
|
||||
{
|
||||
bytes[i] = (byte) bytesAsInts[i];
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses the given bytes using ReadRawVarint32() and ReadRawVarint64()
|
||||
/// </summary>
|
||||
private static void AssertReadVarint(byte[] data, ulong value)
|
||||
{
|
||||
CodedInputStream input = new CodedInputStream(data);
|
||||
Assert.AreEqual((uint) value, input.ReadRawVarint32());
|
||||
|
||||
input = new CodedInputStream(data);
|
||||
Assert.AreEqual(value, input.ReadRawVarint64());
|
||||
Assert.IsTrue(input.IsAtEnd);
|
||||
|
||||
// Try different block sizes.
|
||||
for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2)
|
||||
{
|
||||
input = new CodedInputStream(new SmallBlockInputStream(data, bufferSize));
|
||||
Assert.AreEqual((uint) value, input.ReadRawVarint32());
|
||||
|
||||
input = new CodedInputStream(new SmallBlockInputStream(data, bufferSize));
|
||||
Assert.AreEqual(value, input.ReadRawVarint64());
|
||||
Assert.IsTrue(input.IsAtEnd);
|
||||
}
|
||||
|
||||
// Try reading directly from a MemoryStream. We want to verify that it
|
||||
// doesn't read past the end of the input, so write an extra byte - this
|
||||
// lets us test the position at the end.
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
memoryStream.Write(data, 0, data.Length);
|
||||
memoryStream.WriteByte(0);
|
||||
memoryStream.Position = 0;
|
||||
Assert.AreEqual((uint) value, CodedInputStream.ReadRawVarint32(memoryStream));
|
||||
Assert.AreEqual(data.Length, memoryStream.Position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses the given bytes using ReadRawVarint32() and ReadRawVarint64() and
|
||||
/// expects them to fail with an InvalidProtocolBufferException whose
|
||||
/// description matches the given one.
|
||||
/// </summary>
|
||||
private static void AssertReadVarintFailure(InvalidProtocolBufferException expected, byte[] data)
|
||||
{
|
||||
CodedInputStream input = new CodedInputStream(data);
|
||||
var exception = Assert.Throws<InvalidProtocolBufferException>(() => input.ReadRawVarint32());
|
||||
Assert.AreEqual(expected.Message, exception.Message);
|
||||
|
||||
input = new CodedInputStream(data);
|
||||
exception = Assert.Throws<InvalidProtocolBufferException>(() => input.ReadRawVarint64());
|
||||
Assert.AreEqual(expected.Message, exception.Message);
|
||||
|
||||
// Make sure we get the same error when reading directly from a Stream.
|
||||
exception = Assert.Throws<InvalidProtocolBufferException>(() => CodedInputStream.ReadRawVarint32(new MemoryStream(data)));
|
||||
Assert.AreEqual(expected.Message, exception.Message);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadVarint()
|
||||
{
|
||||
AssertReadVarint(Bytes(0x00), 0);
|
||||
AssertReadVarint(Bytes(0x01), 1);
|
||||
AssertReadVarint(Bytes(0x7f), 127);
|
||||
// 14882
|
||||
AssertReadVarint(Bytes(0xa2, 0x74), (0x22 << 0) | (0x74 << 7));
|
||||
// 2961488830
|
||||
AssertReadVarint(Bytes(0xbe, 0xf7, 0x92, 0x84, 0x0b),
|
||||
(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |
|
||||
(0x0bL << 28));
|
||||
|
||||
// 64-bit
|
||||
// 7256456126
|
||||
AssertReadVarint(Bytes(0xbe, 0xf7, 0x92, 0x84, 0x1b),
|
||||
(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |
|
||||
(0x1bL << 28));
|
||||
// 41256202580718336
|
||||
AssertReadVarint(Bytes(0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49),
|
||||
(0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) |
|
||||
(0x43L << 28) | (0x49L << 35) | (0x24L << 42) | (0x49L << 49));
|
||||
// 11964378330978735131
|
||||
AssertReadVarint(Bytes(0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01),
|
||||
(0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) |
|
||||
(0x3bUL << 28) | (0x56UL << 35) | (0x00UL << 42) |
|
||||
(0x05UL << 49) | (0x26UL << 56) | (0x01UL << 63));
|
||||
|
||||
// Failures
|
||||
AssertReadVarintFailure(
|
||||
InvalidProtocolBufferException.MalformedVarint(),
|
||||
Bytes(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x00));
|
||||
AssertReadVarintFailure(
|
||||
InvalidProtocolBufferException.TruncatedMessage(),
|
||||
Bytes(0x80));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses the given bytes using ReadRawLittleEndian32() and checks
|
||||
/// that the result matches the given value.
|
||||
/// </summary>
|
||||
private static void AssertReadLittleEndian32(byte[] data, uint value)
|
||||
{
|
||||
CodedInputStream input = new CodedInputStream(data);
|
||||
Assert.AreEqual(value, input.ReadRawLittleEndian32());
|
||||
Assert.IsTrue(input.IsAtEnd);
|
||||
|
||||
// Try different block sizes.
|
||||
for (int blockSize = 1; blockSize <= 16; blockSize *= 2)
|
||||
{
|
||||
input = new CodedInputStream(
|
||||
new SmallBlockInputStream(data, blockSize));
|
||||
Assert.AreEqual(value, input.ReadRawLittleEndian32());
|
||||
Assert.IsTrue(input.IsAtEnd);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses the given bytes using ReadRawLittleEndian64() and checks
|
||||
/// that the result matches the given value.
|
||||
/// </summary>
|
||||
private static void AssertReadLittleEndian64(byte[] data, ulong value)
|
||||
{
|
||||
CodedInputStream input = new CodedInputStream(data);
|
||||
Assert.AreEqual(value, input.ReadRawLittleEndian64());
|
||||
Assert.IsTrue(input.IsAtEnd);
|
||||
|
||||
// Try different block sizes.
|
||||
for (int blockSize = 1; blockSize <= 16; blockSize *= 2)
|
||||
{
|
||||
input = new CodedInputStream(
|
||||
new SmallBlockInputStream(data, blockSize));
|
||||
Assert.AreEqual(value, input.ReadRawLittleEndian64());
|
||||
Assert.IsTrue(input.IsAtEnd);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadLittleEndian()
|
||||
{
|
||||
AssertReadLittleEndian32(Bytes(0x78, 0x56, 0x34, 0x12), 0x12345678);
|
||||
AssertReadLittleEndian32(Bytes(0xf0, 0xde, 0xbc, 0x9a), 0x9abcdef0);
|
||||
|
||||
AssertReadLittleEndian64(Bytes(0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12),
|
||||
0x123456789abcdef0L);
|
||||
AssertReadLittleEndian64(
|
||||
Bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a), 0x9abcdef012345678UL);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecodeZigZag32()
|
||||
{
|
||||
Assert.AreEqual(0, CodedInputStream.DecodeZigZag32(0));
|
||||
Assert.AreEqual(-1, CodedInputStream.DecodeZigZag32(1));
|
||||
Assert.AreEqual(1, CodedInputStream.DecodeZigZag32(2));
|
||||
Assert.AreEqual(-2, CodedInputStream.DecodeZigZag32(3));
|
||||
Assert.AreEqual(0x3FFFFFFF, CodedInputStream.DecodeZigZag32(0x7FFFFFFE));
|
||||
Assert.AreEqual(unchecked((int) 0xC0000000), CodedInputStream.DecodeZigZag32(0x7FFFFFFF));
|
||||
Assert.AreEqual(0x7FFFFFFF, CodedInputStream.DecodeZigZag32(0xFFFFFFFE));
|
||||
Assert.AreEqual(unchecked((int) 0x80000000), CodedInputStream.DecodeZigZag32(0xFFFFFFFF));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DecodeZigZag64()
|
||||
{
|
||||
Assert.AreEqual(0, CodedInputStream.DecodeZigZag64(0));
|
||||
Assert.AreEqual(-1, CodedInputStream.DecodeZigZag64(1));
|
||||
Assert.AreEqual(1, CodedInputStream.DecodeZigZag64(2));
|
||||
Assert.AreEqual(-2, CodedInputStream.DecodeZigZag64(3));
|
||||
Assert.AreEqual(0x000000003FFFFFFFL, CodedInputStream.DecodeZigZag64(0x000000007FFFFFFEL));
|
||||
Assert.AreEqual(unchecked((long) 0xFFFFFFFFC0000000L), CodedInputStream.DecodeZigZag64(0x000000007FFFFFFFL));
|
||||
Assert.AreEqual(0x000000007FFFFFFFL, CodedInputStream.DecodeZigZag64(0x00000000FFFFFFFEL));
|
||||
Assert.AreEqual(unchecked((long) 0xFFFFFFFF80000000L), CodedInputStream.DecodeZigZag64(0x00000000FFFFFFFFL));
|
||||
Assert.AreEqual(0x7FFFFFFFFFFFFFFFL, CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFEL));
|
||||
Assert.AreEqual(unchecked((long) 0x8000000000000000L), CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFFL));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadWholeMessage_VaryingBlockSizes()
|
||||
{
|
||||
TestAllTypes message = SampleMessages.CreateFullTestAllTypes();
|
||||
|
||||
byte[] rawBytes = message.ToByteArray();
|
||||
Assert.AreEqual(rawBytes.Length, message.CalculateSize());
|
||||
TestAllTypes message2 = TestAllTypes.Parser.ParseFrom(rawBytes);
|
||||
Assert.AreEqual(message, message2);
|
||||
|
||||
// Try different block sizes.
|
||||
for (int blockSize = 1; blockSize < 256; blockSize *= 2)
|
||||
{
|
||||
message2 = TestAllTypes.Parser.ParseFrom(new SmallBlockInputStream(rawBytes, blockSize));
|
||||
Assert.AreEqual(message, message2);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadHugeBlob()
|
||||
{
|
||||
// Allocate and initialize a 1MB blob.
|
||||
byte[] blob = new byte[1 << 20];
|
||||
for (int i = 0; i < blob.Length; i++)
|
||||
{
|
||||
blob[i] = (byte) i;
|
||||
}
|
||||
|
||||
// Make a message containing it.
|
||||
var message = new TestAllTypes { SingleBytes = ByteString.CopyFrom(blob) };
|
||||
|
||||
// Serialize and parse it. Make sure to parse from an InputStream, not
|
||||
// directly from a ByteString, so that CodedInputStream uses buffered
|
||||
// reading.
|
||||
TestAllTypes message2 = TestAllTypes.Parser.ParseFrom(message.ToByteString());
|
||||
|
||||
Assert.AreEqual(message, message2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadMaliciouslyLargeBlob()
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
CodedOutputStream output = new CodedOutputStream(ms);
|
||||
|
||||
uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited);
|
||||
output.WriteRawVarint32(tag);
|
||||
output.WriteRawVarint32(0x7FFFFFFF);
|
||||
output.WriteRawBytes(new byte[32]); // Pad with a few random bytes.
|
||||
output.Flush();
|
||||
ms.Position = 0;
|
||||
|
||||
CodedInputStream input = new CodedInputStream(ms);
|
||||
Assert.AreEqual(tag, input.ReadTag());
|
||||
|
||||
Assert.Throws<InvalidProtocolBufferException>(() => input.ReadBytes());
|
||||
}
|
||||
|
||||
internal static TestRecursiveMessage MakeRecursiveMessage(int depth)
|
||||
{
|
||||
if (depth == 0)
|
||||
{
|
||||
return new TestRecursiveMessage { I = 5 };
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TestRecursiveMessage { A = MakeRecursiveMessage(depth - 1) };
|
||||
}
|
||||
}
|
||||
|
||||
internal static void AssertMessageDepth(TestRecursiveMessage message, int depth)
|
||||
{
|
||||
if (depth == 0)
|
||||
{
|
||||
Assert.IsNull(message.A);
|
||||
Assert.AreEqual(5, message.I);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.IsNotNull(message.A);
|
||||
AssertMessageDepth(message.A, depth - 1);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MaliciousRecursion()
|
||||
{
|
||||
ByteString data64 = MakeRecursiveMessage(64).ToByteString();
|
||||
ByteString data65 = MakeRecursiveMessage(65).ToByteString();
|
||||
|
||||
AssertMessageDepth(TestRecursiveMessage.Parser.ParseFrom(data64), 64);
|
||||
|
||||
Assert.Throws<InvalidProtocolBufferException>(() => TestRecursiveMessage.Parser.ParseFrom(data65));
|
||||
|
||||
CodedInputStream input = CodedInputStream.CreateWithLimits(new MemoryStream(data64.ToByteArray()), 1000000, 63);
|
||||
Assert.Throws<InvalidProtocolBufferException>(() => TestRecursiveMessage.Parser.ParseFrom(input));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SizeLimit()
|
||||
{
|
||||
// Have to use a Stream rather than ByteString.CreateCodedInput as SizeLimit doesn't
|
||||
// apply to the latter case.
|
||||
MemoryStream ms = new MemoryStream(SampleMessages.CreateFullTestAllTypes().ToByteArray());
|
||||
CodedInputStream input = CodedInputStream.CreateWithLimits(ms, 16, 100);
|
||||
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseFrom(input));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that if we read an string that contains invalid UTF-8, no exception
|
||||
/// is thrown. Instead, the invalid bytes are replaced with the Unicode
|
||||
/// "replacement character" U+FFFD.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void ReadInvalidUtf8()
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
CodedOutputStream output = new CodedOutputStream(ms);
|
||||
|
||||
uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited);
|
||||
output.WriteRawVarint32(tag);
|
||||
output.WriteRawVarint32(1);
|
||||
output.WriteRawBytes(new byte[] {0x80});
|
||||
output.Flush();
|
||||
ms.Position = 0;
|
||||
|
||||
CodedInputStream input = new CodedInputStream(ms);
|
||||
|
||||
Assert.AreEqual(tag, input.ReadTag());
|
||||
string text = input.ReadString();
|
||||
Assert.AreEqual('\ufffd', text[0]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A stream which limits the number of bytes it reads at a time.
|
||||
/// We use this to make sure that CodedInputStream doesn't screw up when
|
||||
/// reading in small blocks.
|
||||
/// </summary>
|
||||
private sealed class SmallBlockInputStream : MemoryStream
|
||||
{
|
||||
private readonly int blockSize;
|
||||
|
||||
public SmallBlockInputStream(byte[] data, int blockSize)
|
||||
: base(data)
|
||||
{
|
||||
this.blockSize = blockSize;
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
return base.Read(buffer, offset, Math.Min(count, blockSize));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNegativeEnum()
|
||||
{
|
||||
byte[] bytes = { 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01 };
|
||||
CodedInputStream input = new CodedInputStream(bytes);
|
||||
Assert.AreEqual((int)SampleEnum.NegativeValue, input.ReadEnum());
|
||||
Assert.IsTrue(input.IsAtEnd);
|
||||
}
|
||||
|
||||
//Issue 71: CodedInputStream.ReadBytes go to slow path unnecessarily
|
||||
[Test]
|
||||
public void TestSlowPathAvoidance()
|
||||
{
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
CodedOutputStream output = new CodedOutputStream(ms);
|
||||
output.WriteTag(1, WireFormat.WireType.LengthDelimited);
|
||||
output.WriteBytes(ByteString.CopyFrom(new byte[100]));
|
||||
output.WriteTag(2, WireFormat.WireType.LengthDelimited);
|
||||
output.WriteBytes(ByteString.CopyFrom(new byte[100]));
|
||||
output.Flush();
|
||||
|
||||
ms.Position = 0;
|
||||
CodedInputStream input = new CodedInputStream(ms, new byte[ms.Length / 2], 0, 0);
|
||||
|
||||
uint tag = input.ReadTag();
|
||||
Assert.AreEqual(1, WireFormat.GetTagFieldNumber(tag));
|
||||
Assert.AreEqual(100, input.ReadBytes().Length);
|
||||
|
||||
tag = input.ReadTag();
|
||||
Assert.AreEqual(2, WireFormat.GetTagFieldNumber(tag));
|
||||
Assert.AreEqual(100, input.ReadBytes().Length);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Tag0Throws()
|
||||
{
|
||||
var input = new CodedInputStream(new byte[] { 0 });
|
||||
Assert.Throws<InvalidProtocolBufferException>(() => input.ReadTag());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SkipGroup()
|
||||
{
|
||||
// Create an output stream with a group in:
|
||||
// Field 1: string "field 1"
|
||||
// Field 2: group containing:
|
||||
// Field 1: fixed int32 value 100
|
||||
// Field 2: string "ignore me"
|
||||
// Field 3: nested group containing
|
||||
// Field 1: fixed int64 value 1000
|
||||
// Field 3: string "field 3"
|
||||
var stream = new MemoryStream();
|
||||
var output = new CodedOutputStream(stream);
|
||||
output.WriteTag(1, WireFormat.WireType.LengthDelimited);
|
||||
output.WriteString("field 1");
|
||||
|
||||
// The outer group...
|
||||
output.WriteTag(2, WireFormat.WireType.StartGroup);
|
||||
output.WriteTag(1, WireFormat.WireType.Fixed32);
|
||||
output.WriteFixed32(100);
|
||||
output.WriteTag(2, WireFormat.WireType.LengthDelimited);
|
||||
output.WriteString("ignore me");
|
||||
// The nested group...
|
||||
output.WriteTag(3, WireFormat.WireType.StartGroup);
|
||||
output.WriteTag(1, WireFormat.WireType.Fixed64);
|
||||
output.WriteFixed64(1000);
|
||||
// Note: Not sure the field number is relevant for end group...
|
||||
output.WriteTag(3, WireFormat.WireType.EndGroup);
|
||||
|
||||
// End the outer group
|
||||
output.WriteTag(2, WireFormat.WireType.EndGroup);
|
||||
|
||||
output.WriteTag(3, WireFormat.WireType.LengthDelimited);
|
||||
output.WriteString("field 3");
|
||||
output.Flush();
|
||||
stream.Position = 0;
|
||||
|
||||
// Now act like a generated client
|
||||
var input = new CodedInputStream(stream);
|
||||
Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited), input.ReadTag());
|
||||
Assert.AreEqual("field 1", input.ReadString());
|
||||
Assert.AreEqual(WireFormat.MakeTag(2, WireFormat.WireType.StartGroup), input.ReadTag());
|
||||
input.SkipLastField(); // Should consume the whole group, including the nested one.
|
||||
Assert.AreEqual(WireFormat.MakeTag(3, WireFormat.WireType.LengthDelimited), input.ReadTag());
|
||||
Assert.AreEqual("field 3", input.ReadString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SkipGroup_WrongEndGroupTag()
|
||||
{
|
||||
// Create an output stream with:
|
||||
// Field 1: string "field 1"
|
||||
// Start group 2
|
||||
// Field 3: fixed int32
|
||||
// End group 4 (should give an error)
|
||||
var stream = new MemoryStream();
|
||||
var output = new CodedOutputStream(stream);
|
||||
output.WriteTag(1, WireFormat.WireType.LengthDelimited);
|
||||
output.WriteString("field 1");
|
||||
|
||||
// The outer group...
|
||||
output.WriteTag(2, WireFormat.WireType.StartGroup);
|
||||
output.WriteTag(3, WireFormat.WireType.Fixed32);
|
||||
output.WriteFixed32(100);
|
||||
output.WriteTag(4, WireFormat.WireType.EndGroup);
|
||||
output.Flush();
|
||||
stream.Position = 0;
|
||||
|
||||
// Now act like a generated client
|
||||
var input = new CodedInputStream(stream);
|
||||
Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited), input.ReadTag());
|
||||
Assert.AreEqual("field 1", input.ReadString());
|
||||
Assert.AreEqual(WireFormat.MakeTag(2, WireFormat.WireType.StartGroup), input.ReadTag());
|
||||
Assert.Throws<InvalidProtocolBufferException>(input.SkipLastField);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RogueEndGroupTag()
|
||||
{
|
||||
// If we have an end-group tag without a leading start-group tag, generated
|
||||
// code will just call SkipLastField... so that should fail.
|
||||
|
||||
var stream = new MemoryStream();
|
||||
var output = new CodedOutputStream(stream);
|
||||
output.WriteTag(1, WireFormat.WireType.EndGroup);
|
||||
output.Flush();
|
||||
stream.Position = 0;
|
||||
|
||||
var input = new CodedInputStream(stream);
|
||||
Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.EndGroup), input.ReadTag());
|
||||
Assert.Throws<InvalidProtocolBufferException>(input.SkipLastField);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EndOfStreamReachedWhileSkippingGroup()
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
var output = new CodedOutputStream(stream);
|
||||
output.WriteTag(1, WireFormat.WireType.StartGroup);
|
||||
output.WriteTag(2, WireFormat.WireType.StartGroup);
|
||||
output.WriteTag(2, WireFormat.WireType.EndGroup);
|
||||
|
||||
output.Flush();
|
||||
stream.Position = 0;
|
||||
|
||||
// Now act like a generated client
|
||||
var input = new CodedInputStream(stream);
|
||||
input.ReadTag();
|
||||
Assert.Throws<InvalidProtocolBufferException>(input.SkipLastField);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RecursionLimitAppliedWhileSkippingGroup()
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
var output = new CodedOutputStream(stream);
|
||||
for (int i = 0; i < CodedInputStream.DefaultRecursionLimit + 1; i++)
|
||||
{
|
||||
output.WriteTag(1, WireFormat.WireType.StartGroup);
|
||||
}
|
||||
for (int i = 0; i < CodedInputStream.DefaultRecursionLimit + 1; i++)
|
||||
{
|
||||
output.WriteTag(1, WireFormat.WireType.EndGroup);
|
||||
}
|
||||
output.Flush();
|
||||
stream.Position = 0;
|
||||
|
||||
// Now act like a generated client
|
||||
var input = new CodedInputStream(stream);
|
||||
Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.StartGroup), input.ReadTag());
|
||||
Assert.Throws<InvalidProtocolBufferException>(input.SkipLastField);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Construction_Invalid()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new CodedInputStream((byte[]) null));
|
||||
Assert.Throws<ArgumentNullException>(() => new CodedInputStream(null, 0, 0));
|
||||
Assert.Throws<ArgumentNullException>(() => new CodedInputStream((Stream) null));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => new CodedInputStream(new byte[10], 100, 0));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => new CodedInputStream(new byte[10], 5, 10));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateWithLimits_InvalidLimits()
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => CodedInputStream.CreateWithLimits(stream, 0, 1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => CodedInputStream.CreateWithLimits(stream, 1, 0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Dispose_DisposesUnderlyingStream()
|
||||
{
|
||||
var memoryStream = new MemoryStream();
|
||||
Assert.IsTrue(memoryStream.CanRead);
|
||||
using (var cis = new CodedInputStream(memoryStream))
|
||||
{
|
||||
}
|
||||
Assert.IsFalse(memoryStream.CanRead); // Disposed
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Dispose_WithLeaveOpen()
|
||||
{
|
||||
var memoryStream = new MemoryStream();
|
||||
Assert.IsTrue(memoryStream.CanRead);
|
||||
using (var cis = new CodedInputStream(memoryStream, true))
|
||||
{
|
||||
}
|
||||
Assert.IsTrue(memoryStream.CanRead); // We left the stream open
|
||||
}
|
||||
}
|
||||
}
|
419
packager/third_party/protobuf/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs
vendored
Normal file
419
packager/third_party/protobuf/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs
vendored
Normal file
|
@ -0,0 +1,419 @@
|
|||
#region Copyright notice and license
|
||||
// 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.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Google.Protobuf.TestProtos;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Google.Protobuf
|
||||
{
|
||||
public class CodedOutputStreamTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Writes the given value using WriteRawVarint32() and WriteRawVarint64() and
|
||||
/// checks that the result matches the given bytes
|
||||
/// </summary>
|
||||
private static void AssertWriteVarint(byte[] data, ulong value)
|
||||
{
|
||||
// Only do 32-bit write if the value fits in 32 bits.
|
||||
if ((value >> 32) == 0)
|
||||
{
|
||||
MemoryStream rawOutput = new MemoryStream();
|
||||
CodedOutputStream output = new CodedOutputStream(rawOutput);
|
||||
output.WriteRawVarint32((uint) value);
|
||||
output.Flush();
|
||||
Assert.AreEqual(data, rawOutput.ToArray());
|
||||
// Also try computing size.
|
||||
Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint32Size((uint) value));
|
||||
}
|
||||
|
||||
{
|
||||
MemoryStream rawOutput = new MemoryStream();
|
||||
CodedOutputStream output = new CodedOutputStream(rawOutput);
|
||||
output.WriteRawVarint64(value);
|
||||
output.Flush();
|
||||
Assert.AreEqual(data, rawOutput.ToArray());
|
||||
|
||||
// Also try computing size.
|
||||
Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint64Size(value));
|
||||
}
|
||||
|
||||
// Try different buffer sizes.
|
||||
for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2)
|
||||
{
|
||||
// Only do 32-bit write if the value fits in 32 bits.
|
||||
if ((value >> 32) == 0)
|
||||
{
|
||||
MemoryStream rawOutput = new MemoryStream();
|
||||
CodedOutputStream output =
|
||||
new CodedOutputStream(rawOutput, bufferSize);
|
||||
output.WriteRawVarint32((uint) value);
|
||||
output.Flush();
|
||||
Assert.AreEqual(data, rawOutput.ToArray());
|
||||
}
|
||||
|
||||
{
|
||||
MemoryStream rawOutput = new MemoryStream();
|
||||
CodedOutputStream output = new CodedOutputStream(rawOutput, bufferSize);
|
||||
output.WriteRawVarint64(value);
|
||||
output.Flush();
|
||||
Assert.AreEqual(data, rawOutput.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests WriteRawVarint32() and WriteRawVarint64()
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void WriteVarint()
|
||||
{
|
||||
AssertWriteVarint(new byte[] {0x00}, 0);
|
||||
AssertWriteVarint(new byte[] {0x01}, 1);
|
||||
AssertWriteVarint(new byte[] {0x7f}, 127);
|
||||
// 14882
|
||||
AssertWriteVarint(new byte[] {0xa2, 0x74}, (0x22 << 0) | (0x74 << 7));
|
||||
// 2961488830
|
||||
AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x0b},
|
||||
(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |
|
||||
(0x0bL << 28));
|
||||
|
||||
// 64-bit
|
||||
// 7256456126
|
||||
AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x1b},
|
||||
(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |
|
||||
(0x1bL << 28));
|
||||
// 41256202580718336
|
||||
AssertWriteVarint(
|
||||
new byte[] {0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49},
|
||||
(0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) |
|
||||
(0x43UL << 28) | (0x49L << 35) | (0x24UL << 42) | (0x49UL << 49));
|
||||
// 11964378330978735131
|
||||
AssertWriteVarint(
|
||||
new byte[] {0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01},
|
||||
unchecked((ulong)
|
||||
((0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) |
|
||||
(0x3bL << 28) | (0x56L << 35) | (0x00L << 42) |
|
||||
(0x05L << 49) | (0x26L << 56) | (0x01L << 63))));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses the given bytes using WriteRawLittleEndian32() and checks
|
||||
/// that the result matches the given value.
|
||||
/// </summary>
|
||||
private static void AssertWriteLittleEndian32(byte[] data, uint value)
|
||||
{
|
||||
MemoryStream rawOutput = new MemoryStream();
|
||||
CodedOutputStream output = new CodedOutputStream(rawOutput);
|
||||
output.WriteRawLittleEndian32(value);
|
||||
output.Flush();
|
||||
Assert.AreEqual(data, rawOutput.ToArray());
|
||||
|
||||
// Try different buffer sizes.
|
||||
for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2)
|
||||
{
|
||||
rawOutput = new MemoryStream();
|
||||
output = new CodedOutputStream(rawOutput, bufferSize);
|
||||
output.WriteRawLittleEndian32(value);
|
||||
output.Flush();
|
||||
Assert.AreEqual(data, rawOutput.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses the given bytes using WriteRawLittleEndian64() and checks
|
||||
/// that the result matches the given value.
|
||||
/// </summary>
|
||||
private static void AssertWriteLittleEndian64(byte[] data, ulong value)
|
||||
{
|
||||
MemoryStream rawOutput = new MemoryStream();
|
||||
CodedOutputStream output = new CodedOutputStream(rawOutput);
|
||||
output.WriteRawLittleEndian64(value);
|
||||
output.Flush();
|
||||
Assert.AreEqual(data, rawOutput.ToArray());
|
||||
|
||||
// Try different block sizes.
|
||||
for (int blockSize = 1; blockSize <= 16; blockSize *= 2)
|
||||
{
|
||||
rawOutput = new MemoryStream();
|
||||
output = new CodedOutputStream(rawOutput, blockSize);
|
||||
output.WriteRawLittleEndian64(value);
|
||||
output.Flush();
|
||||
Assert.AreEqual(data, rawOutput.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests writeRawLittleEndian32() and writeRawLittleEndian64().
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void WriteLittleEndian()
|
||||
{
|
||||
AssertWriteLittleEndian32(new byte[] {0x78, 0x56, 0x34, 0x12}, 0x12345678);
|
||||
AssertWriteLittleEndian32(new byte[] {0xf0, 0xde, 0xbc, 0x9a}, 0x9abcdef0);
|
||||
|
||||
AssertWriteLittleEndian64(
|
||||
new byte[] {0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12},
|
||||
0x123456789abcdef0L);
|
||||
AssertWriteLittleEndian64(
|
||||
new byte[] {0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a},
|
||||
0x9abcdef012345678UL);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WriteWholeMessage_VaryingBlockSizes()
|
||||
{
|
||||
TestAllTypes message = SampleMessages.CreateFullTestAllTypes();
|
||||
|
||||
byte[] rawBytes = message.ToByteArray();
|
||||
|
||||
// Try different block sizes.
|
||||
for (int blockSize = 1; blockSize < 256; blockSize *= 2)
|
||||
{
|
||||
MemoryStream rawOutput = new MemoryStream();
|
||||
CodedOutputStream output = new CodedOutputStream(rawOutput, blockSize);
|
||||
message.WriteTo(output);
|
||||
output.Flush();
|
||||
Assert.AreEqual(rawBytes, rawOutput.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EncodeZigZag32()
|
||||
{
|
||||
Assert.AreEqual(0u, CodedOutputStream.EncodeZigZag32(0));
|
||||
Assert.AreEqual(1u, CodedOutputStream.EncodeZigZag32(-1));
|
||||
Assert.AreEqual(2u, CodedOutputStream.EncodeZigZag32(1));
|
||||
Assert.AreEqual(3u, CodedOutputStream.EncodeZigZag32(-2));
|
||||
Assert.AreEqual(0x7FFFFFFEu, CodedOutputStream.EncodeZigZag32(0x3FFFFFFF));
|
||||
Assert.AreEqual(0x7FFFFFFFu, CodedOutputStream.EncodeZigZag32(unchecked((int) 0xC0000000)));
|
||||
Assert.AreEqual(0xFFFFFFFEu, CodedOutputStream.EncodeZigZag32(0x7FFFFFFF));
|
||||
Assert.AreEqual(0xFFFFFFFFu, CodedOutputStream.EncodeZigZag32(unchecked((int) 0x80000000)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EncodeZigZag64()
|
||||
{
|
||||
Assert.AreEqual(0u, CodedOutputStream.EncodeZigZag64(0));
|
||||
Assert.AreEqual(1u, CodedOutputStream.EncodeZigZag64(-1));
|
||||
Assert.AreEqual(2u, CodedOutputStream.EncodeZigZag64(1));
|
||||
Assert.AreEqual(3u, CodedOutputStream.EncodeZigZag64(-2));
|
||||
Assert.AreEqual(0x000000007FFFFFFEuL,
|
||||
CodedOutputStream.EncodeZigZag64(unchecked((long) 0x000000003FFFFFFFUL)));
|
||||
Assert.AreEqual(0x000000007FFFFFFFuL,
|
||||
CodedOutputStream.EncodeZigZag64(unchecked((long) 0xFFFFFFFFC0000000UL)));
|
||||
Assert.AreEqual(0x00000000FFFFFFFEuL,
|
||||
CodedOutputStream.EncodeZigZag64(unchecked((long) 0x000000007FFFFFFFUL)));
|
||||
Assert.AreEqual(0x00000000FFFFFFFFuL,
|
||||
CodedOutputStream.EncodeZigZag64(unchecked((long) 0xFFFFFFFF80000000UL)));
|
||||
Assert.AreEqual(0xFFFFFFFFFFFFFFFEL,
|
||||
CodedOutputStream.EncodeZigZag64(unchecked((long) 0x7FFFFFFFFFFFFFFFUL)));
|
||||
Assert.AreEqual(0xFFFFFFFFFFFFFFFFL,
|
||||
CodedOutputStream.EncodeZigZag64(unchecked((long) 0x8000000000000000UL)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RoundTripZigZag32()
|
||||
{
|
||||
// Some easier-to-verify round-trip tests. The inputs (other than 0, 1, -1)
|
||||
// were chosen semi-randomly via keyboard bashing.
|
||||
Assert.AreEqual(0, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(0)));
|
||||
Assert.AreEqual(1, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(1)));
|
||||
Assert.AreEqual(-1, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-1)));
|
||||
Assert.AreEqual(14927, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(14927)));
|
||||
Assert.AreEqual(-3612, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-3612)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RoundTripZigZag64()
|
||||
{
|
||||
Assert.AreEqual(0, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(0)));
|
||||
Assert.AreEqual(1, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(1)));
|
||||
Assert.AreEqual(-1, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-1)));
|
||||
Assert.AreEqual(14927, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(14927)));
|
||||
Assert.AreEqual(-3612, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-3612)));
|
||||
|
||||
Assert.AreEqual(856912304801416L,
|
||||
CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(856912304801416L)));
|
||||
Assert.AreEqual(-75123905439571256L,
|
||||
CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-75123905439571256L)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNegativeEnumNoTag()
|
||||
{
|
||||
Assert.AreEqual(10, CodedOutputStream.ComputeInt32Size(-2));
|
||||
Assert.AreEqual(10, CodedOutputStream.ComputeEnumSize((int) SampleEnum.NegativeValue));
|
||||
|
||||
byte[] bytes = new byte[10];
|
||||
CodedOutputStream output = new CodedOutputStream(bytes);
|
||||
output.WriteEnum((int) SampleEnum.NegativeValue);
|
||||
|
||||
Assert.AreEqual(0, output.SpaceLeft);
|
||||
Assert.AreEqual("FE-FF-FF-FF-FF-FF-FF-FF-FF-01", BitConverter.ToString(bytes));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCodedInputOutputPosition()
|
||||
{
|
||||
byte[] content = new byte[110];
|
||||
for (int i = 0; i < content.Length; i++)
|
||||
content[i] = (byte)i;
|
||||
|
||||
byte[] child = new byte[120];
|
||||
{
|
||||
MemoryStream ms = new MemoryStream(child);
|
||||
CodedOutputStream cout = new CodedOutputStream(ms, 20);
|
||||
// Field 11: numeric value: 500
|
||||
cout.WriteTag(11, WireFormat.WireType.Varint);
|
||||
Assert.AreEqual(1, cout.Position);
|
||||
cout.WriteInt32(500);
|
||||
Assert.AreEqual(3, cout.Position);
|
||||
//Field 12: length delimited 120 bytes
|
||||
cout.WriteTag(12, WireFormat.WireType.LengthDelimited);
|
||||
Assert.AreEqual(4, cout.Position);
|
||||
cout.WriteBytes(ByteString.CopyFrom(content));
|
||||
Assert.AreEqual(115, cout.Position);
|
||||
// Field 13: fixed numeric value: 501
|
||||
cout.WriteTag(13, WireFormat.WireType.Fixed32);
|
||||
Assert.AreEqual(116, cout.Position);
|
||||
cout.WriteSFixed32(501);
|
||||
Assert.AreEqual(120, cout.Position);
|
||||
cout.Flush();
|
||||
}
|
||||
|
||||
byte[] bytes = new byte[130];
|
||||
{
|
||||
CodedOutputStream cout = new CodedOutputStream(bytes);
|
||||
// Field 1: numeric value: 500
|
||||
cout.WriteTag(1, WireFormat.WireType.Varint);
|
||||
Assert.AreEqual(1, cout.Position);
|
||||
cout.WriteInt32(500);
|
||||
Assert.AreEqual(3, cout.Position);
|
||||
//Field 2: length delimited 120 bytes
|
||||
cout.WriteTag(2, WireFormat.WireType.LengthDelimited);
|
||||
Assert.AreEqual(4, cout.Position);
|
||||
cout.WriteBytes(ByteString.CopyFrom(child));
|
||||
Assert.AreEqual(125, cout.Position);
|
||||
// Field 3: fixed numeric value: 500
|
||||
cout.WriteTag(3, WireFormat.WireType.Fixed32);
|
||||
Assert.AreEqual(126, cout.Position);
|
||||
cout.WriteSFixed32(501);
|
||||
Assert.AreEqual(130, cout.Position);
|
||||
cout.Flush();
|
||||
}
|
||||
// Now test Input stream:
|
||||
{
|
||||
CodedInputStream cin = new CodedInputStream(new MemoryStream(bytes), new byte[50], 0, 0);
|
||||
Assert.AreEqual(0, cin.Position);
|
||||
// Field 1:
|
||||
uint tag = cin.ReadTag();
|
||||
Assert.AreEqual(1, tag >> 3);
|
||||
Assert.AreEqual(1, cin.Position);
|
||||
Assert.AreEqual(500, cin.ReadInt32());
|
||||
Assert.AreEqual(3, cin.Position);
|
||||
//Field 2:
|
||||
tag = cin.ReadTag();
|
||||
Assert.AreEqual(2, tag >> 3);
|
||||
Assert.AreEqual(4, cin.Position);
|
||||
int childlen = cin.ReadLength();
|
||||
Assert.AreEqual(120, childlen);
|
||||
Assert.AreEqual(5, cin.Position);
|
||||
int oldlimit = cin.PushLimit((int)childlen);
|
||||
Assert.AreEqual(5, cin.Position);
|
||||
// Now we are reading child message
|
||||
{
|
||||
// Field 11: numeric value: 500
|
||||
tag = cin.ReadTag();
|
||||
Assert.AreEqual(11, tag >> 3);
|
||||
Assert.AreEqual(6, cin.Position);
|
||||
Assert.AreEqual(500, cin.ReadInt32());
|
||||
Assert.AreEqual(8, cin.Position);
|
||||
//Field 12: length delimited 120 bytes
|
||||
tag = cin.ReadTag();
|
||||
Assert.AreEqual(12, tag >> 3);
|
||||
Assert.AreEqual(9, cin.Position);
|
||||
ByteString bstr = cin.ReadBytes();
|
||||
Assert.AreEqual(110, bstr.Length);
|
||||
Assert.AreEqual((byte) 109, bstr[109]);
|
||||
Assert.AreEqual(120, cin.Position);
|
||||
// Field 13: fixed numeric value: 501
|
||||
tag = cin.ReadTag();
|
||||
Assert.AreEqual(13, tag >> 3);
|
||||
// ROK - Previously broken here, this returned 126 failing to account for bufferSizeAfterLimit
|
||||
Assert.AreEqual(121, cin.Position);
|
||||
Assert.AreEqual(501, cin.ReadSFixed32());
|
||||
Assert.AreEqual(125, cin.Position);
|
||||
Assert.IsTrue(cin.IsAtEnd);
|
||||
}
|
||||
cin.PopLimit(oldlimit);
|
||||
Assert.AreEqual(125, cin.Position);
|
||||
// Field 3: fixed numeric value: 501
|
||||
tag = cin.ReadTag();
|
||||
Assert.AreEqual(3, tag >> 3);
|
||||
Assert.AreEqual(126, cin.Position);
|
||||
Assert.AreEqual(501, cin.ReadSFixed32());
|
||||
Assert.AreEqual(130, cin.Position);
|
||||
Assert.IsTrue(cin.IsAtEnd);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Dispose_DisposesUnderlyingStream()
|
||||
{
|
||||
var memoryStream = new MemoryStream();
|
||||
Assert.IsTrue(memoryStream.CanWrite);
|
||||
using (var cos = new CodedOutputStream(memoryStream))
|
||||
{
|
||||
cos.WriteRawByte(0);
|
||||
Assert.AreEqual(0, memoryStream.Position); // Not flushed yet
|
||||
}
|
||||
Assert.AreEqual(1, memoryStream.ToArray().Length); // Flushed data from CodedOutputStream to MemoryStream
|
||||
Assert.IsFalse(memoryStream.CanWrite); // Disposed
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Dispose_WithLeaveOpen()
|
||||
{
|
||||
var memoryStream = new MemoryStream();
|
||||
Assert.IsTrue(memoryStream.CanWrite);
|
||||
using (var cos = new CodedOutputStream(memoryStream, true))
|
||||
{
|
||||
cos.WriteRawByte(0);
|
||||
Assert.AreEqual(0, memoryStream.Position); // Not flushed yet
|
||||
}
|
||||
Assert.AreEqual(1, memoryStream.Position); // Flushed data from CodedOutputStream to MemoryStream
|
||||
Assert.IsTrue(memoryStream.CanWrite); // We left the stream open
|
||||
}
|
||||
}
|
||||
}
|
532
packager/third_party/protobuf/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
vendored
Normal file
532
packager/third_party/protobuf/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
vendored
Normal file
|
@ -0,0 +1,532 @@
|
|||
#region Copyright notice and license
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2015 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.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Google.Protobuf.TestProtos;
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
|
||||
namespace Google.Protobuf.Collections
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests for MapField which aren't reliant on the encoded format -
|
||||
/// tests for serialization/deserialization are part of GeneratedMessageTest.
|
||||
/// </summary>
|
||||
public class MapFieldTest
|
||||
{
|
||||
[Test]
|
||||
public void Clone_ClonesMessages()
|
||||
{
|
||||
var message = new ForeignMessage { C = 20 };
|
||||
var map = new MapField<string, ForeignMessage> { { "x", message } };
|
||||
var clone = map.Clone();
|
||||
map["x"].C = 30;
|
||||
Assert.AreEqual(20, clone["x"].C);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NullValuesProhibited()
|
||||
{
|
||||
TestNullValues<int?>(0);
|
||||
TestNullValues("");
|
||||
TestNullValues(new TestAllTypes());
|
||||
}
|
||||
|
||||
private void TestNullValues<T>(T nonNullValue)
|
||||
{
|
||||
var map = new MapField<int, T>();
|
||||
var nullValue = (T) (object) null;
|
||||
Assert.Throws<ArgumentNullException>(() => map.Add(0, nullValue));
|
||||
Assert.Throws<ArgumentNullException>(() => map[0] = nullValue);
|
||||
map.Add(1, nonNullValue);
|
||||
map[1] = nonNullValue;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Add_ForbidsNullKeys()
|
||||
{
|
||||
var map = new MapField<string, ForeignMessage>();
|
||||
Assert.Throws<ArgumentNullException>(() => map.Add(null, new ForeignMessage()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Indexer_ForbidsNullKeys()
|
||||
{
|
||||
var map = new MapField<string, ForeignMessage>();
|
||||
Assert.Throws<ArgumentNullException>(() => map[null] = new ForeignMessage());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddPreservesInsertionOrder()
|
||||
{
|
||||
var map = new MapField<string, string>();
|
||||
map.Add("a", "v1");
|
||||
map.Add("b", "v2");
|
||||
map.Add("c", "v3");
|
||||
map.Remove("b");
|
||||
map.Add("d", "v4");
|
||||
CollectionAssert.AreEqual(new[] { "a", "c", "d" }, map.Keys);
|
||||
CollectionAssert.AreEqual(new[] { "v1", "v3", "v4" }, map.Values);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EqualityIsOrderInsensitive()
|
||||
{
|
||||
var map1 = new MapField<string, string>();
|
||||
map1.Add("a", "v1");
|
||||
map1.Add("b", "v2");
|
||||
|
||||
var map2 = new MapField<string, string>();
|
||||
map2.Add("b", "v2");
|
||||
map2.Add("a", "v1");
|
||||
|
||||
EqualityTester.AssertEquality(map1, map2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EqualityIsKeySensitive()
|
||||
{
|
||||
var map1 = new MapField<string, string>();
|
||||
map1.Add("first key", "v1");
|
||||
map1.Add("second key", "v2");
|
||||
|
||||
var map2 = new MapField<string, string>();
|
||||
map2.Add("third key", "v1");
|
||||
map2.Add("fourth key", "v2");
|
||||
|
||||
EqualityTester.AssertInequality(map1, map2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Equality_Simple()
|
||||
{
|
||||
var map = new MapField<string, string>();
|
||||
EqualityTester.AssertEquality(map, map);
|
||||
EqualityTester.AssertInequality(map, null);
|
||||
Assert.IsFalse(map.Equals(new object()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EqualityIsValueSensitive()
|
||||
{
|
||||
// Note: Without some care, it's a little easier than one might
|
||||
// hope to see hash collisions, but only in some environments...
|
||||
var map1 = new MapField<string, string>();
|
||||
map1.Add("a", "first value");
|
||||
map1.Add("b", "second value");
|
||||
|
||||
var map2 = new MapField<string, string>();
|
||||
map2.Add("a", "third value");
|
||||
map2.Add("b", "fourth value");
|
||||
|
||||
EqualityTester.AssertInequality(map1, map2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Add_Dictionary()
|
||||
{
|
||||
var map1 = new MapField<string, string>
|
||||
{
|
||||
{ "x", "y" },
|
||||
{ "a", "b" }
|
||||
};
|
||||
var map2 = new MapField<string, string>
|
||||
{
|
||||
{ "before", "" },
|
||||
map1,
|
||||
{ "after", "" }
|
||||
};
|
||||
var expected = new MapField<string, string>
|
||||
{
|
||||
{ "before", "" },
|
||||
{ "x", "y" },
|
||||
{ "a", "b" },
|
||||
{ "after", "" }
|
||||
};
|
||||
Assert.AreEqual(expected, map2);
|
||||
CollectionAssert.AreEqual(new[] { "before", "x", "a", "after" }, map2.Keys);
|
||||
}
|
||||
|
||||
// General IDictionary<TKey, TValue> behavior tests
|
||||
[Test]
|
||||
public void Add_KeyAlreadyExists()
|
||||
{
|
||||
var map = new MapField<string, string>();
|
||||
map.Add("foo", "bar");
|
||||
Assert.Throws<ArgumentException>(() => map.Add("foo", "baz"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Add_Pair()
|
||||
{
|
||||
var map = new MapField<string, string>();
|
||||
ICollection<KeyValuePair<string, string>> collection = map;
|
||||
collection.Add(NewKeyValuePair("x", "y"));
|
||||
Assert.AreEqual("y", map["x"]);
|
||||
Assert.Throws<ArgumentException>(() => collection.Add(NewKeyValuePair("x", "z")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Contains_Pair()
|
||||
{
|
||||
var map = new MapField<string, string> { { "x", "y" } };
|
||||
ICollection<KeyValuePair<string, string>> collection = map;
|
||||
Assert.IsTrue(collection.Contains(NewKeyValuePair("x", "y")));
|
||||
Assert.IsFalse(collection.Contains(NewKeyValuePair("x", "z")));
|
||||
Assert.IsFalse(collection.Contains(NewKeyValuePair("z", "y")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Remove_Key()
|
||||
{
|
||||
var map = new MapField<string, string>();
|
||||
map.Add("foo", "bar");
|
||||
Assert.AreEqual(1, map.Count);
|
||||
Assert.IsFalse(map.Remove("missing"));
|
||||
Assert.AreEqual(1, map.Count);
|
||||
Assert.IsTrue(map.Remove("foo"));
|
||||
Assert.AreEqual(0, map.Count);
|
||||
Assert.Throws<ArgumentNullException>(() => map.Remove(null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Remove_Pair()
|
||||
{
|
||||
var map = new MapField<string, string>();
|
||||
map.Add("foo", "bar");
|
||||
ICollection<KeyValuePair<string, string>> collection = map;
|
||||
Assert.AreEqual(1, map.Count);
|
||||
Assert.IsFalse(collection.Remove(NewKeyValuePair("wrong key", "bar")));
|
||||
Assert.AreEqual(1, map.Count);
|
||||
Assert.IsFalse(collection.Remove(NewKeyValuePair("foo", "wrong value")));
|
||||
Assert.AreEqual(1, map.Count);
|
||||
Assert.IsTrue(collection.Remove(NewKeyValuePair("foo", "bar")));
|
||||
Assert.AreEqual(0, map.Count);
|
||||
Assert.Throws<ArgumentException>(() => collection.Remove(new KeyValuePair<string, string>(null, "")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CopyTo_Pair()
|
||||
{
|
||||
var map = new MapField<string, string>();
|
||||
map.Add("foo", "bar");
|
||||
ICollection<KeyValuePair<string, string>> collection = map;
|
||||
KeyValuePair<string, string>[] array = new KeyValuePair<string, string>[3];
|
||||
collection.CopyTo(array, 1);
|
||||
Assert.AreEqual(NewKeyValuePair("foo", "bar"), array[1]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Clear()
|
||||
{
|
||||
var map = new MapField<string, string> { { "x", "y" } };
|
||||
Assert.AreEqual(1, map.Count);
|
||||
map.Clear();
|
||||
Assert.AreEqual(0, map.Count);
|
||||
map.Add("x", "y");
|
||||
Assert.AreEqual(1, map.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Indexer_Get()
|
||||
{
|
||||
var map = new MapField<string, string> { { "x", "y" } };
|
||||
Assert.AreEqual("y", map["x"]);
|
||||
Assert.Throws<KeyNotFoundException>(() => { var ignored = map["z"]; });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Indexer_Set()
|
||||
{
|
||||
var map = new MapField<string, string>();
|
||||
map["x"] = "y";
|
||||
Assert.AreEqual("y", map["x"]);
|
||||
map["x"] = "z"; // This won't throw, unlike Add.
|
||||
Assert.AreEqual("z", map["x"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetEnumerator_NonGeneric()
|
||||
{
|
||||
IEnumerable map = new MapField<string, string> { { "x", "y" } };
|
||||
CollectionAssert.AreEqual(new[] { new KeyValuePair<string, string>("x", "y") },
|
||||
map.Cast<object>().ToList());
|
||||
}
|
||||
|
||||
// Test for the explicitly-implemented non-generic IDictionary interface
|
||||
[Test]
|
||||
public void IDictionary_GetEnumerator()
|
||||
{
|
||||
IDictionary map = new MapField<string, string> { { "x", "y" } };
|
||||
var enumerator = map.GetEnumerator();
|
||||
|
||||
// Commented assertions show an ideal situation - it looks like
|
||||
// the LinkedList enumerator doesn't throw when you ask for the current entry
|
||||
// at an inappropriate time; fixing this would be more work than it's worth.
|
||||
// Assert.Throws<InvalidOperationException>(() => enumerator.Current.GetHashCode());
|
||||
Assert.IsTrue(enumerator.MoveNext());
|
||||
Assert.AreEqual("x", enumerator.Key);
|
||||
Assert.AreEqual("y", enumerator.Value);
|
||||
Assert.AreEqual(new DictionaryEntry("x", "y"), enumerator.Current);
|
||||
Assert.AreEqual(new DictionaryEntry("x", "y"), enumerator.Entry);
|
||||
Assert.IsFalse(enumerator.MoveNext());
|
||||
// Assert.Throws<InvalidOperationException>(() => enumerator.Current.GetHashCode());
|
||||
enumerator.Reset();
|
||||
// Assert.Throws<InvalidOperationException>(() => enumerator.Current.GetHashCode());
|
||||
Assert.IsTrue(enumerator.MoveNext());
|
||||
Assert.AreEqual("x", enumerator.Key); // Assume the rest are okay
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IDictionary_Add()
|
||||
{
|
||||
var map = new MapField<string, string> { { "x", "y" } };
|
||||
IDictionary dictionary = map;
|
||||
dictionary.Add("a", "b");
|
||||
Assert.AreEqual("b", map["a"]);
|
||||
Assert.Throws<ArgumentException>(() => dictionary.Add("a", "duplicate"));
|
||||
Assert.Throws<InvalidCastException>(() => dictionary.Add(new object(), "key is bad"));
|
||||
Assert.Throws<InvalidCastException>(() => dictionary.Add("value is bad", new object()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IDictionary_Contains()
|
||||
{
|
||||
var map = new MapField<string, string> { { "x", "y" } };
|
||||
IDictionary dictionary = map;
|
||||
|
||||
Assert.IsFalse(dictionary.Contains("a"));
|
||||
Assert.IsFalse(dictionary.Contains(5));
|
||||
// Surprising, but IDictionary.Contains is only about keys.
|
||||
Assert.IsFalse(dictionary.Contains(new DictionaryEntry("x", "y")));
|
||||
Assert.IsTrue(dictionary.Contains("x"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IDictionary_Remove()
|
||||
{
|
||||
var map = new MapField<string, string> { { "x", "y" } };
|
||||
IDictionary dictionary = map;
|
||||
dictionary.Remove("a");
|
||||
Assert.AreEqual(1, dictionary.Count);
|
||||
dictionary.Remove(5);
|
||||
Assert.AreEqual(1, dictionary.Count);
|
||||
dictionary.Remove(new DictionaryEntry("x", "y"));
|
||||
Assert.AreEqual(1, dictionary.Count);
|
||||
dictionary.Remove("x");
|
||||
Assert.AreEqual(0, dictionary.Count);
|
||||
Assert.Throws<ArgumentNullException>(() => dictionary.Remove(null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IDictionary_CopyTo()
|
||||
{
|
||||
var map = new MapField<string, string> { { "x", "y" } };
|
||||
IDictionary dictionary = map;
|
||||
var array = new DictionaryEntry[3];
|
||||
dictionary.CopyTo(array, 1);
|
||||
CollectionAssert.AreEqual(new[] { default(DictionaryEntry), new DictionaryEntry("x", "y"), default(DictionaryEntry) },
|
||||
array);
|
||||
var objectArray = new object[3];
|
||||
dictionary.CopyTo(objectArray, 1);
|
||||
CollectionAssert.AreEqual(new object[] { null, new DictionaryEntry("x", "y"), null },
|
||||
objectArray);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IDictionary_IsFixedSize()
|
||||
{
|
||||
var map = new MapField<string, string> { { "x", "y" } };
|
||||
IDictionary dictionary = map;
|
||||
Assert.IsFalse(dictionary.IsFixedSize);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IDictionary_Keys()
|
||||
{
|
||||
IDictionary dictionary = new MapField<string, string> { { "x", "y" } };
|
||||
CollectionAssert.AreEqual(new[] { "x" }, dictionary.Keys);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IDictionary_Values()
|
||||
{
|
||||
IDictionary dictionary = new MapField<string, string> { { "x", "y" } };
|
||||
CollectionAssert.AreEqual(new[] { "y" }, dictionary.Values);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IDictionary_IsSynchronized()
|
||||
{
|
||||
IDictionary dictionary = new MapField<string, string> { { "x", "y" } };
|
||||
Assert.IsFalse(dictionary.IsSynchronized);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IDictionary_SyncRoot()
|
||||
{
|
||||
IDictionary dictionary = new MapField<string, string> { { "x", "y" } };
|
||||
Assert.AreSame(dictionary, dictionary.SyncRoot);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IDictionary_Indexer_Get()
|
||||
{
|
||||
IDictionary dictionary = new MapField<string, string> { { "x", "y" } };
|
||||
Assert.AreEqual("y", dictionary["x"]);
|
||||
Assert.IsNull(dictionary["a"]);
|
||||
Assert.IsNull(dictionary[5]);
|
||||
Assert.Throws<ArgumentNullException>(() => dictionary[null].GetHashCode());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IDictionary_Indexer_Set()
|
||||
{
|
||||
var map = new MapField<string, string> { { "x", "y" } };
|
||||
IDictionary dictionary = map;
|
||||
map["a"] = "b";
|
||||
Assert.AreEqual("b", map["a"]);
|
||||
map["a"] = "c";
|
||||
Assert.AreEqual("c", map["a"]);
|
||||
Assert.Throws<InvalidCastException>(() => dictionary[5] = "x");
|
||||
Assert.Throws<InvalidCastException>(() => dictionary["x"] = 5);
|
||||
Assert.Throws<ArgumentNullException>(() => dictionary[null] = "z");
|
||||
Assert.Throws<ArgumentNullException>(() => dictionary["x"] = null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void KeysReturnsLiveView()
|
||||
{
|
||||
var map = new MapField<string, string>();
|
||||
var keys = map.Keys;
|
||||
CollectionAssert.AreEqual(new string[0], keys);
|
||||
map["foo"] = "bar";
|
||||
map["x"] = "y";
|
||||
CollectionAssert.AreEqual(new[] { "foo", "x" }, keys);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ValuesReturnsLiveView()
|
||||
{
|
||||
var map = new MapField<string, string>();
|
||||
var values = map.Values;
|
||||
CollectionAssert.AreEqual(new string[0], values);
|
||||
map["foo"] = "bar";
|
||||
map["x"] = "y";
|
||||
CollectionAssert.AreEqual(new[] { "bar", "y" }, values);
|
||||
}
|
||||
|
||||
// Just test keys - we know the implementation is the same for values
|
||||
[Test]
|
||||
public void ViewsAreReadOnly()
|
||||
{
|
||||
var map = new MapField<string, string>();
|
||||
var keys = map.Keys;
|
||||
Assert.IsTrue(keys.IsReadOnly);
|
||||
Assert.Throws<NotSupportedException>(() => keys.Clear());
|
||||
Assert.Throws<NotSupportedException>(() => keys.Remove("a"));
|
||||
Assert.Throws<NotSupportedException>(() => keys.Add("a"));
|
||||
}
|
||||
|
||||
// Just test keys - we know the implementation is the same for values
|
||||
[Test]
|
||||
public void ViewCopyTo()
|
||||
{
|
||||
var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
|
||||
var keys = map.Keys;
|
||||
var array = new string[4];
|
||||
Assert.Throws<ArgumentException>(() => keys.CopyTo(array, 3));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => keys.CopyTo(array, -1));
|
||||
keys.CopyTo(array, 1);
|
||||
CollectionAssert.AreEqual(new[] { null, "foo", "x", null }, array);
|
||||
}
|
||||
|
||||
// Just test keys - we know the implementation is the same for values
|
||||
[Test]
|
||||
public void NonGenericViewCopyTo()
|
||||
{
|
||||
IDictionary map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
|
||||
ICollection keys = map.Keys;
|
||||
// Note the use of the Array type here rather than string[]
|
||||
Array array = new string[4];
|
||||
Assert.Throws<ArgumentException>(() => keys.CopyTo(array, 3));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => keys.CopyTo(array, -1));
|
||||
keys.CopyTo(array, 1);
|
||||
CollectionAssert.AreEqual(new[] { null, "foo", "x", null }, array);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void KeysContains()
|
||||
{
|
||||
var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
|
||||
var keys = map.Keys;
|
||||
Assert.IsTrue(keys.Contains("foo"));
|
||||
Assert.IsFalse(keys.Contains("bar")); // It's a value!
|
||||
Assert.IsFalse(keys.Contains("1"));
|
||||
// Keys can't be null, so we should prevent contains check
|
||||
Assert.Throws<ArgumentNullException>(() => keys.Contains(null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ValuesContains()
|
||||
{
|
||||
var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
|
||||
var values = map.Values;
|
||||
Assert.IsTrue(values.Contains("bar"));
|
||||
Assert.IsFalse(values.Contains("foo")); // It's a key!
|
||||
Assert.IsFalse(values.Contains("1"));
|
||||
// Values can be null, so this makes sense
|
||||
Assert.IsFalse(values.Contains(null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToString_StringToString()
|
||||
{
|
||||
var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
|
||||
Assert.AreEqual("{ \"foo\": \"bar\", \"x\": \"y\" }", map.ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToString_UnsupportedKeyType()
|
||||
{
|
||||
var map = new MapField<byte, string> { { 10, "foo" } };
|
||||
Assert.Throws<ArgumentException>(() => map.ToString());
|
||||
}
|
||||
|
||||
private static KeyValuePair<TKey, TValue> NewKeyValuePair<TKey, TValue>(TKey key, TValue value)
|
||||
{
|
||||
return new KeyValuePair<TKey, TValue>(key, value);
|
||||
}
|
||||
}
|
||||
}
|
660
packager/third_party/protobuf/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs
vendored
Normal file
660
packager/third_party/protobuf/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs
vendored
Normal file
|
@ -0,0 +1,660 @@
|
|||
#region Copyright notice and license
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2015 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.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Google.Protobuf.TestProtos;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Google.Protobuf.Collections
|
||||
{
|
||||
public class RepeatedFieldTest
|
||||
{
|
||||
[Test]
|
||||
public void NullValuesRejected()
|
||||
{
|
||||
var list = new RepeatedField<string>();
|
||||
Assert.Throws<ArgumentNullException>(() => list.Add((string)null));
|
||||
Assert.Throws<ArgumentNullException>(() => list.Add((IEnumerable<string>)null));
|
||||
Assert.Throws<ArgumentNullException>(() => list.Add((RepeatedField<string>)null));
|
||||
Assert.Throws<ArgumentNullException>(() => list.Contains(null));
|
||||
Assert.Throws<ArgumentNullException>(() => list.IndexOf(null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Add_SingleItem()
|
||||
{
|
||||
var list = new RepeatedField<string>();
|
||||
list.Add("foo");
|
||||
Assert.AreEqual(1, list.Count);
|
||||
Assert.AreEqual("foo", list[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Add_Sequence()
|
||||
{
|
||||
var list = new RepeatedField<string>();
|
||||
list.Add(new[] { "foo", "bar" });
|
||||
Assert.AreEqual(2, list.Count);
|
||||
Assert.AreEqual("foo", list[0]);
|
||||
Assert.AreEqual("bar", list[1]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Add_RepeatedField()
|
||||
{
|
||||
var list = new RepeatedField<string> { "original" };
|
||||
list.Add(new RepeatedField<string> { "foo", "bar" });
|
||||
Assert.AreEqual(3, list.Count);
|
||||
Assert.AreEqual("original", list[0]);
|
||||
Assert.AreEqual("foo", list[1]);
|
||||
Assert.AreEqual("bar", list[2]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveAt_Valid()
|
||||
{
|
||||
var list = new RepeatedField<string> { "first", "second", "third" };
|
||||
list.RemoveAt(1);
|
||||
CollectionAssert.AreEqual(new[] { "first", "third" }, list);
|
||||
// Just check that these don't throw...
|
||||
list.RemoveAt(list.Count - 1); // Now the count will be 1...
|
||||
list.RemoveAt(0);
|
||||
Assert.AreEqual(0, list.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveAt_Invalid()
|
||||
{
|
||||
var list = new RepeatedField<string> { "first", "second", "third" };
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(-1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(3));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Insert_Valid()
|
||||
{
|
||||
var list = new RepeatedField<string> { "first", "second" };
|
||||
list.Insert(1, "middle");
|
||||
CollectionAssert.AreEqual(new[] { "first", "middle", "second" }, list);
|
||||
list.Insert(3, "end");
|
||||
CollectionAssert.AreEqual(new[] { "first", "middle", "second", "end" }, list);
|
||||
list.Insert(0, "start");
|
||||
CollectionAssert.AreEqual(new[] { "start", "first", "middle", "second", "end" }, list);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Insert_Invalid()
|
||||
{
|
||||
var list = new RepeatedField<string> { "first", "second" };
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(-1, "foo"));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(3, "foo"));
|
||||
Assert.Throws<ArgumentNullException>(() => list.Insert(0, null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Equals_RepeatedField()
|
||||
{
|
||||
var list = new RepeatedField<string> { "first", "second" };
|
||||
Assert.IsFalse(list.Equals((RepeatedField<string>) null));
|
||||
Assert.IsTrue(list.Equals(list));
|
||||
Assert.IsFalse(list.Equals(new RepeatedField<string> { "first", "third" }));
|
||||
Assert.IsFalse(list.Equals(new RepeatedField<string> { "first" }));
|
||||
Assert.IsTrue(list.Equals(new RepeatedField<string> { "first", "second" }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Equals_Object()
|
||||
{
|
||||
var list = new RepeatedField<string> { "first", "second" };
|
||||
Assert.IsFalse(list.Equals((object) null));
|
||||
Assert.IsTrue(list.Equals((object) list));
|
||||
Assert.IsFalse(list.Equals((object) new RepeatedField<string> { "first", "third" }));
|
||||
Assert.IsFalse(list.Equals((object) new RepeatedField<string> { "first" }));
|
||||
Assert.IsTrue(list.Equals((object) new RepeatedField<string> { "first", "second" }));
|
||||
Assert.IsFalse(list.Equals(new object()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetEnumerator_GenericInterface()
|
||||
{
|
||||
IEnumerable<string> list = new RepeatedField<string> { "first", "second" };
|
||||
// Select gets rid of the optimizations in ToList...
|
||||
CollectionAssert.AreEqual(new[] { "first", "second" }, list.Select(x => x).ToList());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetEnumerator_NonGenericInterface()
|
||||
{
|
||||
IEnumerable list = new RepeatedField<string> { "first", "second" };
|
||||
CollectionAssert.AreEqual(new[] { "first", "second" }, list.Cast<object>().ToList());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CopyTo()
|
||||
{
|
||||
var list = new RepeatedField<string> { "first", "second" };
|
||||
string[] stringArray = new string[4];
|
||||
list.CopyTo(stringArray, 1);
|
||||
CollectionAssert.AreEqual(new[] { null, "first", "second", null }, stringArray);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Indexer_Get()
|
||||
{
|
||||
var list = new RepeatedField<string> { "first", "second" };
|
||||
Assert.AreEqual("first", list[0]);
|
||||
Assert.AreEqual("second", list[1]);
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => list[-1].GetHashCode());
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => list[2].GetHashCode());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Indexer_Set()
|
||||
{
|
||||
var list = new RepeatedField<string> { "first", "second" };
|
||||
list[0] = "changed";
|
||||
Assert.AreEqual("changed", list[0]);
|
||||
Assert.Throws<ArgumentNullException>(() => list[0] = null);
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => list[-1] = "bad");
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => list[2] = "bad");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Clone_ReturnsMutable()
|
||||
{
|
||||
var list = new RepeatedField<int> { 0 };
|
||||
var clone = list.Clone();
|
||||
clone[0] = 1;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Enumerator()
|
||||
{
|
||||
var list = new RepeatedField<string> { "first", "second" };
|
||||
using (var enumerator = list.GetEnumerator())
|
||||
{
|
||||
Assert.IsTrue(enumerator.MoveNext());
|
||||
Assert.AreEqual("first", enumerator.Current);
|
||||
Assert.IsTrue(enumerator.MoveNext());
|
||||
Assert.AreEqual("second", enumerator.Current);
|
||||
Assert.IsFalse(enumerator.MoveNext());
|
||||
Assert.IsFalse(enumerator.MoveNext());
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddEntriesFrom_PackedInt32()
|
||||
{
|
||||
uint packedTag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
|
||||
var stream = new MemoryStream();
|
||||
var output = new CodedOutputStream(stream);
|
||||
var length = CodedOutputStream.ComputeInt32Size(10)
|
||||
+ CodedOutputStream.ComputeInt32Size(999)
|
||||
+ CodedOutputStream.ComputeInt32Size(-1000);
|
||||
output.WriteTag(packedTag);
|
||||
output.WriteRawVarint32((uint) length);
|
||||
output.WriteInt32(10);
|
||||
output.WriteInt32(999);
|
||||
output.WriteInt32(-1000);
|
||||
output.Flush();
|
||||
stream.Position = 0;
|
||||
|
||||
// Deliberately "expecting" a non-packed tag, but we detect that the data is
|
||||
// actually packed.
|
||||
uint nonPackedTag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
|
||||
var field = new RepeatedField<int>();
|
||||
var input = new CodedInputStream(stream);
|
||||
input.AssertNextTag(packedTag);
|
||||
field.AddEntriesFrom(input, FieldCodec.ForInt32(nonPackedTag));
|
||||
CollectionAssert.AreEqual(new[] { 10, 999, -1000 }, field);
|
||||
Assert.IsTrue(input.IsAtEnd);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddEntriesFrom_NonPackedInt32()
|
||||
{
|
||||
uint nonPackedTag = WireFormat.MakeTag(10, WireFormat.WireType.Varint);
|
||||
var stream = new MemoryStream();
|
||||
var output = new CodedOutputStream(stream);
|
||||
output.WriteTag(nonPackedTag);
|
||||
output.WriteInt32(10);
|
||||
output.WriteTag(nonPackedTag);
|
||||
output.WriteInt32(999);
|
||||
output.WriteTag(nonPackedTag);
|
||||
output.WriteInt32(-1000); // Just for variety...
|
||||
output.Flush();
|
||||
stream.Position = 0;
|
||||
|
||||
// Deliberately "expecting" a packed tag, but we detect that the data is
|
||||
// actually not packed.
|
||||
uint packedTag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
|
||||
var field = new RepeatedField<int>();
|
||||
var input = new CodedInputStream(stream);
|
||||
input.AssertNextTag(nonPackedTag);
|
||||
field.AddEntriesFrom(input, FieldCodec.ForInt32(packedTag));
|
||||
CollectionAssert.AreEqual(new[] { 10, 999, -1000 }, field);
|
||||
Assert.IsTrue(input.IsAtEnd);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddEntriesFrom_String()
|
||||
{
|
||||
uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
|
||||
var stream = new MemoryStream();
|
||||
var output = new CodedOutputStream(stream);
|
||||
output.WriteTag(tag);
|
||||
output.WriteString("Foo");
|
||||
output.WriteTag(tag);
|
||||
output.WriteString("");
|
||||
output.WriteTag(tag);
|
||||
output.WriteString("Bar");
|
||||
output.Flush();
|
||||
stream.Position = 0;
|
||||
|
||||
var field = new RepeatedField<string>();
|
||||
var input = new CodedInputStream(stream);
|
||||
input.AssertNextTag(tag);
|
||||
field.AddEntriesFrom(input, FieldCodec.ForString(tag));
|
||||
CollectionAssert.AreEqual(new[] { "Foo", "", "Bar" }, field);
|
||||
Assert.IsTrue(input.IsAtEnd);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddEntriesFrom_Message()
|
||||
{
|
||||
var message1 = new ForeignMessage { C = 2000 };
|
||||
var message2 = new ForeignMessage { C = -250 };
|
||||
|
||||
uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
|
||||
var stream = new MemoryStream();
|
||||
var output = new CodedOutputStream(stream);
|
||||
output.WriteTag(tag);
|
||||
output.WriteMessage(message1);
|
||||
output.WriteTag(tag);
|
||||
output.WriteMessage(message2);
|
||||
output.Flush();
|
||||
stream.Position = 0;
|
||||
|
||||
var field = new RepeatedField<ForeignMessage>();
|
||||
var input = new CodedInputStream(stream);
|
||||
input.AssertNextTag(tag);
|
||||
field.AddEntriesFrom(input, FieldCodec.ForMessage(tag, ForeignMessage.Parser));
|
||||
CollectionAssert.AreEqual(new[] { message1, message2}, field);
|
||||
Assert.IsTrue(input.IsAtEnd);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WriteTo_PackedInt32()
|
||||
{
|
||||
uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
|
||||
var field = new RepeatedField<int> { 10, 1000, 1000000 };
|
||||
var stream = new MemoryStream();
|
||||
var output = new CodedOutputStream(stream);
|
||||
field.WriteTo(output, FieldCodec.ForInt32(tag));
|
||||
output.Flush();
|
||||
stream.Position = 0;
|
||||
|
||||
var input = new CodedInputStream(stream);
|
||||
input.AssertNextTag(tag);
|
||||
var length = input.ReadLength();
|
||||
Assert.AreEqual(10, input.ReadInt32());
|
||||
Assert.AreEqual(1000, input.ReadInt32());
|
||||
Assert.AreEqual(1000000, input.ReadInt32());
|
||||
Assert.IsTrue(input.IsAtEnd);
|
||||
Assert.AreEqual(1 + CodedOutputStream.ComputeLengthSize(length) + length, stream.Length);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WriteTo_NonPackedInt32()
|
||||
{
|
||||
uint tag = WireFormat.MakeTag(10, WireFormat.WireType.Varint);
|
||||
var field = new RepeatedField<int> { 10, 1000, 1000000};
|
||||
var stream = new MemoryStream();
|
||||
var output = new CodedOutputStream(stream);
|
||||
field.WriteTo(output, FieldCodec.ForInt32(tag));
|
||||
output.Flush();
|
||||
stream.Position = 0;
|
||||
|
||||
var input = new CodedInputStream(stream);
|
||||
input.AssertNextTag(tag);
|
||||
Assert.AreEqual(10, input.ReadInt32());
|
||||
input.AssertNextTag(tag);
|
||||
Assert.AreEqual(1000, input.ReadInt32());
|
||||
input.AssertNextTag(tag);
|
||||
Assert.AreEqual(1000000, input.ReadInt32());
|
||||
Assert.IsTrue(input.IsAtEnd);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WriteTo_String()
|
||||
{
|
||||
uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
|
||||
var field = new RepeatedField<string> { "Foo", "", "Bar" };
|
||||
var stream = new MemoryStream();
|
||||
var output = new CodedOutputStream(stream);
|
||||
field.WriteTo(output, FieldCodec.ForString(tag));
|
||||
output.Flush();
|
||||
stream.Position = 0;
|
||||
|
||||
var input = new CodedInputStream(stream);
|
||||
input.AssertNextTag(tag);
|
||||
Assert.AreEqual("Foo", input.ReadString());
|
||||
input.AssertNextTag(tag);
|
||||
Assert.AreEqual("", input.ReadString());
|
||||
input.AssertNextTag(tag);
|
||||
Assert.AreEqual("Bar", input.ReadString());
|
||||
Assert.IsTrue(input.IsAtEnd);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WriteTo_Message()
|
||||
{
|
||||
var message1 = new ForeignMessage { C = 20 };
|
||||
var message2 = new ForeignMessage { C = 25 };
|
||||
uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
|
||||
var field = new RepeatedField<ForeignMessage> { message1, message2 };
|
||||
var stream = new MemoryStream();
|
||||
var output = new CodedOutputStream(stream);
|
||||
field.WriteTo(output, FieldCodec.ForMessage(tag, ForeignMessage.Parser));
|
||||
output.Flush();
|
||||
stream.Position = 0;
|
||||
|
||||
var input = new CodedInputStream(stream);
|
||||
input.AssertNextTag(tag);
|
||||
Assert.AreEqual(message1, input.ReadMessage(ForeignMessage.Parser));
|
||||
input.AssertNextTag(tag);
|
||||
Assert.AreEqual(message2, input.ReadMessage(ForeignMessage.Parser));
|
||||
Assert.IsTrue(input.IsAtEnd);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CalculateSize_VariableSizeNonPacked()
|
||||
{
|
||||
var list = new RepeatedField<int> { 1, 500, 1 };
|
||||
var tag = WireFormat.MakeTag(1, WireFormat.WireType.Varint);
|
||||
// 2 bytes for the first entry, 3 bytes for the second, 2 bytes for the third
|
||||
Assert.AreEqual(7, list.CalculateSize(FieldCodec.ForInt32(tag)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CalculateSize_FixedSizeNonPacked()
|
||||
{
|
||||
var list = new RepeatedField<int> { 1, 500, 1 };
|
||||
var tag = WireFormat.MakeTag(1, WireFormat.WireType.Fixed32);
|
||||
// 5 bytes for the each entry
|
||||
Assert.AreEqual(15, list.CalculateSize(FieldCodec.ForSFixed32(tag)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CalculateSize_VariableSizePacked()
|
||||
{
|
||||
var list = new RepeatedField<int> { 1, 500, 1};
|
||||
var tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited);
|
||||
// 1 byte for the tag, 1 byte for the length,
|
||||
// 1 byte for the first entry, 2 bytes for the second, 1 byte for the third
|
||||
Assert.AreEqual(6, list.CalculateSize(FieldCodec.ForInt32(tag)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CalculateSize_FixedSizePacked()
|
||||
{
|
||||
var list = new RepeatedField<int> { 1, 500, 1 };
|
||||
var tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited);
|
||||
// 1 byte for the tag, 1 byte for the length, 4 bytes per entry
|
||||
Assert.AreEqual(14, list.CalculateSize(FieldCodec.ForSFixed32(tag)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNegativeEnumArray()
|
||||
{
|
||||
int arraySize = 1 + 1 + (11 * 5);
|
||||
int msgSize = arraySize;
|
||||
byte[] bytes = new byte[msgSize];
|
||||
CodedOutputStream output = new CodedOutputStream(bytes);
|
||||
uint tag = WireFormat.MakeTag(8, WireFormat.WireType.Varint);
|
||||
for (int i = 0; i >= -5; i--)
|
||||
{
|
||||
output.WriteTag(tag);
|
||||
output.WriteEnum(i);
|
||||
}
|
||||
|
||||
Assert.AreEqual(0, output.SpaceLeft);
|
||||
|
||||
CodedInputStream input = new CodedInputStream(bytes);
|
||||
tag = input.ReadTag();
|
||||
|
||||
RepeatedField<SampleEnum> values = new RepeatedField<SampleEnum>();
|
||||
values.AddEntriesFrom(input, FieldCodec.ForEnum(tag, x => (int)x, x => (SampleEnum)x));
|
||||
|
||||
Assert.AreEqual(6, values.Count);
|
||||
Assert.AreEqual(SampleEnum.None, values[0]);
|
||||
Assert.AreEqual(((SampleEnum)(-1)), values[1]);
|
||||
Assert.AreEqual(SampleEnum.NegativeValue, values[2]);
|
||||
Assert.AreEqual(((SampleEnum)(-3)), values[3]);
|
||||
Assert.AreEqual(((SampleEnum)(-4)), values[4]);
|
||||
Assert.AreEqual(((SampleEnum)(-5)), values[5]);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void TestNegativeEnumPackedArray()
|
||||
{
|
||||
int arraySize = 1 + (10 * 5);
|
||||
int msgSize = 1 + 1 + arraySize;
|
||||
byte[] bytes = new byte[msgSize];
|
||||
CodedOutputStream output = new CodedOutputStream(bytes);
|
||||
// Length-delimited to show we want the packed representation
|
||||
uint tag = WireFormat.MakeTag(8, WireFormat.WireType.LengthDelimited);
|
||||
output.WriteTag(tag);
|
||||
int size = 0;
|
||||
for (int i = 0; i >= -5; i--)
|
||||
{
|
||||
size += CodedOutputStream.ComputeEnumSize(i);
|
||||
}
|
||||
output.WriteRawVarint32((uint)size);
|
||||
for (int i = 0; i >= -5; i--)
|
||||
{
|
||||
output.WriteEnum(i);
|
||||
}
|
||||
Assert.AreEqual(0, output.SpaceLeft);
|
||||
|
||||
CodedInputStream input = new CodedInputStream(bytes);
|
||||
tag = input.ReadTag();
|
||||
|
||||
RepeatedField<SampleEnum> values = new RepeatedField<SampleEnum>();
|
||||
values.AddEntriesFrom(input, FieldCodec.ForEnum(tag, x => (int)x, x => (SampleEnum)x));
|
||||
|
||||
Assert.AreEqual(6, values.Count);
|
||||
Assert.AreEqual(SampleEnum.None, values[0]);
|
||||
Assert.AreEqual(((SampleEnum)(-1)), values[1]);
|
||||
Assert.AreEqual(SampleEnum.NegativeValue, values[2]);
|
||||
Assert.AreEqual(((SampleEnum)(-3)), values[3]);
|
||||
Assert.AreEqual(((SampleEnum)(-4)), values[4]);
|
||||
Assert.AreEqual(((SampleEnum)(-5)), values[5]);
|
||||
}
|
||||
|
||||
// Fairly perfunctory tests for the non-generic IList implementation
|
||||
[Test]
|
||||
public void IList_Indexer()
|
||||
{
|
||||
var field = new RepeatedField<string> { "first", "second" };
|
||||
IList list = field;
|
||||
Assert.AreEqual("first", list[0]);
|
||||
list[1] = "changed";
|
||||
Assert.AreEqual("changed", field[1]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IList_Contains()
|
||||
{
|
||||
IList list = new RepeatedField<string> { "first", "second" };
|
||||
Assert.IsTrue(list.Contains("second"));
|
||||
Assert.IsFalse(list.Contains("third"));
|
||||
Assert.IsFalse(list.Contains(new object()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IList_Add()
|
||||
{
|
||||
IList list = new RepeatedField<string> { "first", "second" };
|
||||
list.Add("third");
|
||||
CollectionAssert.AreEqual(new[] { "first", "second", "third" }, list);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IList_Remove()
|
||||
{
|
||||
IList list = new RepeatedField<string> { "first", "second" };
|
||||
list.Remove("third"); // No-op, no exception
|
||||
list.Remove(new object()); // No-op, no exception
|
||||
list.Remove("first");
|
||||
CollectionAssert.AreEqual(new[] { "second" }, list);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IList_IsFixedSize()
|
||||
{
|
||||
var field = new RepeatedField<string> { "first", "second" };
|
||||
IList list = field;
|
||||
Assert.IsFalse(list.IsFixedSize);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IList_IndexOf()
|
||||
{
|
||||
IList list = new RepeatedField<string> { "first", "second" };
|
||||
Assert.AreEqual(1, list.IndexOf("second"));
|
||||
Assert.AreEqual(-1, list.IndexOf("third"));
|
||||
Assert.AreEqual(-1, list.IndexOf(new object()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IList_SyncRoot()
|
||||
{
|
||||
IList list = new RepeatedField<string> { "first", "second" };
|
||||
Assert.AreSame(list, list.SyncRoot);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IList_CopyTo()
|
||||
{
|
||||
IList list = new RepeatedField<string> { "first", "second" };
|
||||
string[] stringArray = new string[4];
|
||||
list.CopyTo(stringArray, 1);
|
||||
CollectionAssert.AreEqual(new[] { null, "first", "second", null }, stringArray);
|
||||
|
||||
object[] objectArray = new object[4];
|
||||
list.CopyTo(objectArray, 1);
|
||||
CollectionAssert.AreEqual(new[] { null, "first", "second", null }, objectArray);
|
||||
|
||||
Assert.Throws<ArrayTypeMismatchException>(() => list.CopyTo(new StringBuilder[4], 1));
|
||||
Assert.Throws<ArrayTypeMismatchException>(() => list.CopyTo(new int[4], 1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IList_IsSynchronized()
|
||||
{
|
||||
IList list = new RepeatedField<string> { "first", "second" };
|
||||
Assert.IsFalse(list.IsSynchronized);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IList_Insert()
|
||||
{
|
||||
IList list = new RepeatedField<string> { "first", "second" };
|
||||
list.Insert(1, "middle");
|
||||
CollectionAssert.AreEqual(new[] { "first", "middle", "second" }, list);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToString_Integers()
|
||||
{
|
||||
var list = new RepeatedField<int> { 5, 10, 20 };
|
||||
var text = list.ToString();
|
||||
Assert.AreEqual("[ 5, 10, 20 ]", text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToString_Strings()
|
||||
{
|
||||
var list = new RepeatedField<string> { "x", "y", "z" };
|
||||
var text = list.ToString();
|
||||
Assert.AreEqual("[ \"x\", \"y\", \"z\" ]", text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToString_Messages()
|
||||
{
|
||||
var list = new RepeatedField<TestAllTypes> { new TestAllTypes { SingleDouble = 1.5 }, new TestAllTypes { SingleInt32 = 10 } };
|
||||
var text = list.ToString();
|
||||
Assert.AreEqual("[ { \"singleDouble\": 1.5 }, { \"singleInt32\": 10 } ]", text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToString_Empty()
|
||||
{
|
||||
var list = new RepeatedField<TestAllTypes> { };
|
||||
var text = list.ToString();
|
||||
Assert.AreEqual("[ ]", text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToString_InvalidElementType()
|
||||
{
|
||||
var list = new RepeatedField<decimal> { 15m };
|
||||
Assert.Throws<ArgumentException>(() => list.ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToString_Timestamp()
|
||||
{
|
||||
var list = new RepeatedField<Timestamp> { Timestamp.FromDateTime(new DateTime(2015, 10, 1, 12, 34, 56, DateTimeKind.Utc)) };
|
||||
var text = list.ToString();
|
||||
Assert.AreEqual("[ \"2015-10-01T12:34:56Z\" ]", text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToString_Struct()
|
||||
{
|
||||
var message = new Struct { Fields = { { "foo", new Value { NumberValue = 20 } } } };
|
||||
var list = new RepeatedField<Struct> { message };
|
||||
var text = list.ToString();
|
||||
Assert.AreEqual(text, "[ { \"foo\": 20 } ]", message.ToString());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
#region Copyright notice and license
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2015 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.
|
||||
#endregion
|
||||
|
||||
using NUnit.Framework;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Google.Protobuf.Compatibility
|
||||
{
|
||||
public class PropertyInfoExtensionsTest
|
||||
{
|
||||
public string PublicReadWrite { get; set; }
|
||||
private string PrivateReadWrite { get; set; }
|
||||
public string PublicReadPrivateWrite { get; private set; }
|
||||
public string PrivateReadPublicWrite { private get; set; }
|
||||
public string PublicReadOnly { get { return null; } }
|
||||
private string PrivateReadOnly { get { return null; } }
|
||||
public string PublicWriteOnly { set { } }
|
||||
private string PrivateWriteOnly { set { } }
|
||||
|
||||
[Test]
|
||||
[TestCase("PublicReadWrite")]
|
||||
[TestCase("PublicReadPrivateWrite")]
|
||||
[TestCase("PublicReadOnly")]
|
||||
public void GetGetMethod_Success(string name)
|
||||
{
|
||||
var propertyInfo = typeof(PropertyInfoExtensionsTest)
|
||||
.GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||
Assert.IsNotNull(PropertyInfoExtensions.GetGetMethod(propertyInfo));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase("PrivateReadWrite")]
|
||||
[TestCase("PrivateReadPublicWrite")]
|
||||
[TestCase("PrivateReadOnly")]
|
||||
[TestCase("PublicWriteOnly")]
|
||||
[TestCase("PrivateWriteOnly")]
|
||||
public void GetGetMethod_NoAccessibleGetter(string name)
|
||||
{
|
||||
var propertyInfo = typeof(PropertyInfoExtensionsTest)
|
||||
.GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||
Assert.IsNull(PropertyInfoExtensions.GetGetMethod(propertyInfo));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase("PublicReadWrite")]
|
||||
[TestCase("PrivateReadPublicWrite")]
|
||||
[TestCase("PublicWriteOnly")]
|
||||
public void GetSetMethod_Success(string name)
|
||||
{
|
||||
var propertyInfo = typeof(PropertyInfoExtensionsTest)
|
||||
.GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||
Assert.IsNotNull(PropertyInfoExtensions.GetSetMethod(propertyInfo));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase("PublicReadPrivateWrite")]
|
||||
[TestCase("PrivateReadWrite")]
|
||||
[TestCase("PrivateReadOnly")]
|
||||
[TestCase("PublicReadOnly")]
|
||||
[TestCase("PrivateWriteOnly")]
|
||||
public void GetSetMethod_NoAccessibleGetter(string name)
|
||||
{
|
||||
var propertyInfo = typeof(PropertyInfoExtensionsTest)
|
||||
.GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||
Assert.IsNull(PropertyInfoExtensions.GetSetMethod(propertyInfo));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
133
packager/third_party/protobuf/csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs
vendored
Normal file
133
packager/third_party/protobuf/csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs
vendored
Normal file
|
@ -0,0 +1,133 @@
|
|||
#region Copyright notice and license
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2015 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.
|
||||
#endregion
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Google.Protobuf.Compatibility
|
||||
{
|
||||
public class TypeExtensionsTest
|
||||
{
|
||||
public class DerivedList : List<string> { }
|
||||
public string PublicProperty { get; set; }
|
||||
private string PrivateProperty { get; set; }
|
||||
|
||||
public void PublicMethod()
|
||||
{
|
||||
}
|
||||
|
||||
private void PrivateMethod()
|
||||
{
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(typeof(int), true)]
|
||||
[TestCase(typeof(int?), true)]
|
||||
[TestCase(typeof(Nullable<>), true)]
|
||||
[TestCase(typeof(WireFormat.WireType), true)]
|
||||
[TestCase(typeof(string), false)]
|
||||
[TestCase(typeof(object), false)]
|
||||
[TestCase(typeof(Enum), false)]
|
||||
[TestCase(typeof(ValueType), false)]
|
||||
[TestCase(typeof(TypeExtensionsTest), false)]
|
||||
[TestCase(typeof(Action), false)]
|
||||
[TestCase(typeof(Action<>), false)]
|
||||
[TestCase(typeof(IDisposable), false)]
|
||||
public void IsValueType(Type type, bool expected)
|
||||
{
|
||||
Assert.AreEqual(expected, TypeExtensions.IsValueType(type));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(typeof(object), typeof(string), true)]
|
||||
[TestCase(typeof(object), typeof(int), true)]
|
||||
[TestCase(typeof(string), typeof(string), true)]
|
||||
[TestCase(typeof(string), typeof(object), false)]
|
||||
[TestCase(typeof(string), typeof(int), false)]
|
||||
[TestCase(typeof(int), typeof(int), true)]
|
||||
[TestCase(typeof(ValueType), typeof(int), true)]
|
||||
[TestCase(typeof(long), typeof(int), false)] //
|
||||
public void IsAssignableFrom(Type target, Type argument, bool expected)
|
||||
{
|
||||
Assert.AreEqual(expected, TypeExtensions.IsAssignableFrom(target, argument));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(typeof(DerivedList), "Count")] // Go up the type hierarchy
|
||||
[TestCase(typeof(List<string>), "Count")]
|
||||
[TestCase(typeof(List<>), "Count")]
|
||||
[TestCase(typeof(TypeExtensionsTest), "PublicProperty")]
|
||||
public void GetProperty_Success(Type type, string name)
|
||||
{
|
||||
var property = TypeExtensions.GetProperty(type, name);
|
||||
Assert.IsNotNull(property);
|
||||
Assert.AreEqual(name, property.Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(typeof(TypeExtensionsTest), "PrivateProperty")]
|
||||
[TestCase(typeof(TypeExtensionsTest), "Garbage")]
|
||||
public void GetProperty_NoSuchProperty(Type type, string name)
|
||||
{
|
||||
var property = TypeExtensions.GetProperty(type, name);
|
||||
Assert.IsNull(property);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(typeof(DerivedList), "RemoveAt")] // Go up the type hierarchy
|
||||
[TestCase(typeof(List<>), "RemoveAt")]
|
||||
[TestCase(typeof(TypeExtensionsTest), "PublicMethod")]
|
||||
public void GetMethod_Success(Type type, string name)
|
||||
{
|
||||
var method = TypeExtensions.GetMethod(type, name);
|
||||
Assert.IsNotNull(method);
|
||||
Assert.AreEqual(name, method.Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(typeof(TypeExtensionsTest), "PrivateMethod")]
|
||||
[TestCase(typeof(TypeExtensionsTest), "GarbageMethod")]
|
||||
public void GetMethod_NoSuchMethod(Type type, string name)
|
||||
{
|
||||
var method = TypeExtensions.GetMethod(type, name);
|
||||
Assert.IsNull(method);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(typeof(List<string>), "IndexOf")]
|
||||
public void GetMethod_Ambiguous(Type type, string name)
|
||||
{
|
||||
Assert.Throws<AmbiguousMatchException>(() => TypeExtensions.GetMethod(type, name));
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue