Imported protobuf-csharp-port into csharp/ tree
diff --git a/.gitignore b/.gitignore
index 76c414f..cb0347f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,40 +1,75 @@
-#
-# Untracked directories
-#
-src/AddressBook/bin
-src/AddressBook/obj
-src/ProtocolBuffers/bin/
-src/ProtocolBuffers/obj/
-src/ProtocolBuffers/objCF
-src/ProtocolBuffers.Test/bin/
-src/ProtocolBuffers.Test/obj/
-src/ProtocolBuffersLite.Test/bin/
-src/ProtocolBuffersLite.Test/obj/
-src/ProtoBench/bin/
-src/ProtoBench/obj/
-src/ProtoDump/bin/
-src/ProtoDump/obj/
-src/ProtoGen/bin/
-src/ProtoGen/obj/
-src/ProtoGen.Test/bin/
-src/ProtoGen.Test/obj/
-src/ProtoMunge/bin/
-src/ProtoMunge/obj/
-mono/bin
-mono/tmp
-mono/protoc
-build_output
-build_temp
-build/msbuild*.log
+# autogen.sh-generated files
+Makefile.in
+src/Makefile.in
+config.guess
+config.h.in
+config.sub
+configure
+depcomp
+install-sh
+ltmain.sh
+missing
-#
-# Untracked files
-#
-*.user
-*.suo
-_ReSharper.*
-*.sln.cache
-mono/TestResult.xml
-mono/.libs
-mono/*.exe
-mono/*.dll
+aclocal.m4
+m4/libtool.m4
+m4/ltoptions.m4
+m4/ltsugar.m4
+m4/ltversion.m4
+m4/lt~obsolete.m4
+autom4te.cache
+
+# downloaded files
+gtest
+
+# 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
+
+map*unittest.pb.*
+unittest*.pb.*
+cpp_test*.pb.*
+
+*.pyc
+*.egg-info
+*_pb2.py
+python/.eggs/
+python/build/
+python/google/protobuf/compiler/
+
+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
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..93013b8
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,4 @@
+language: cpp
+script: ./autogen.sh && ./configure && make distcheck
+notifications:
+ email: false
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..18bdd09
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,486 @@
+# Copyright (C) 2009 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+LOCAL_PATH := $(call my-dir)
+
+IGNORED_WARNINGS := -Wno-sign-compare -Wno-unused-parameter -Wno-sign-promo
+
+CC_LITE_SRC_FILES := \
+ src/google/protobuf/stubs/common.cc \
+ src/google/protobuf/stubs/once.cc \
+ src/google/protobuf/stubs/hash.cc \
+ src/google/protobuf/stubs/hash.h \
+ src/google/protobuf/stubs/map-util.h \
+ src/google/protobuf/stubs/stl_util-inl.h \
+ src/google/protobuf/extension_set.cc \
+ src/google/protobuf/generated_message_util.cc \
+ src/google/protobuf/message_lite.cc \
+ src/google/protobuf/repeated_field.cc \
+ src/google/protobuf/wire_format_lite.cc \
+ src/google/protobuf/io/coded_stream.cc \
+ src/google/protobuf/io/coded_stream_inl.h \
+ src/google/protobuf/io/zero_copy_stream.cc \
+ src/google/protobuf/io/zero_copy_stream_impl_lite.cc
+
+JAVA_LITE_SRC_FILES := \
+ java/src/main/java/com/google/protobuf/UninitializedMessageException.java \
+ java/src/main/java/com/google/protobuf/MessageLite.java \
+ java/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java \
+ java/src/main/java/com/google/protobuf/CodedOutputStream.java \
+ java/src/main/java/com/google/protobuf/ByteString.java \
+ java/src/main/java/com/google/protobuf/CodedInputStream.java \
+ java/src/main/java/com/google/protobuf/ExtensionRegistryLite.java \
+ java/src/main/java/com/google/protobuf/AbstractMessageLite.java \
+ java/src/main/java/com/google/protobuf/FieldSet.java \
+ java/src/main/java/com/google/protobuf/Internal.java \
+ java/src/main/java/com/google/protobuf/WireFormat.java \
+ java/src/main/java/com/google/protobuf/GeneratedMessageLite.java
+
+COMPILER_SRC_FILES := \
+ 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.cc \
+ src/google/protobuf/extension_set_heavy.cc \
+ src/google/protobuf/generated_message_reflection.cc \
+ src/google/protobuf/generated_message_util.cc \
+ src/google/protobuf/message.cc \
+ src/google/protobuf/message_lite.cc \
+ src/google/protobuf/reflection_ops.cc \
+ src/google/protobuf/repeated_field.cc \
+ src/google/protobuf/service.cc \
+ src/google/protobuf/text_format.cc \
+ src/google/protobuf/unknown_field_set.cc \
+ src/google/protobuf/wire_format.cc \
+ src/google/protobuf/wire_format_lite.cc \
+ src/google/protobuf/compiler/code_generator.cc \
+ src/google/protobuf/compiler/command_line_interface.cc \
+ src/google/protobuf/compiler/importer.cc \
+ src/google/protobuf/compiler/main.cc \
+ src/google/protobuf/compiler/parser.cc \
+ src/google/protobuf/compiler/plugin.cc \
+ src/google/protobuf/compiler/plugin.pb.cc \
+ src/google/protobuf/compiler/subprocess.cc \
+ src/google/protobuf/compiler/zip_writer.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_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/java/java_enum.cc \
+ src/google/protobuf/compiler/java/java_enum_field.cc \
+ src/google/protobuf/compiler/java/java_extension.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_helpers.cc \
+ src/google/protobuf/compiler/java/java_message.cc \
+ src/google/protobuf/compiler/java/java_message_field.cc \
+ src/google/protobuf/compiler/java/java_primitive_field.cc \
+ src/google/protobuf/compiler/java/java_service.cc \
+ src/google/protobuf/compiler/javamicro/javamicro_enum.cc \
+ src/google/protobuf/compiler/javamicro/javamicro_enum_field.cc \
+ src/google/protobuf/compiler/javamicro/javamicro_field.cc \
+ src/google/protobuf/compiler/javamicro/javamicro_file.cc \
+ src/google/protobuf/compiler/javamicro/javamicro_generator.cc \
+ src/google/protobuf/compiler/javamicro/javamicro_helpers.cc \
+ src/google/protobuf/compiler/javamicro/javamicro_message.cc \
+ src/google/protobuf/compiler/javamicro/javamicro_message_field.cc \
+ src/google/protobuf/compiler/javamicro/javamicro_primitive_field.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_message.cc \
+ src/google/protobuf/compiler/javanano/javanano_message_field.cc \
+ src/google/protobuf/compiler/javanano/javanano_primitive_field.cc \
+ src/google/protobuf/compiler/python/python_generator.cc \
+ src/google/protobuf/io/coded_stream.cc \
+ 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.cc \
+ src/google/protobuf/io/zero_copy_stream_impl.cc \
+ src/google/protobuf/io/zero_copy_stream_impl_lite.cc \
+ src/google/protobuf/stubs/common.cc \
+ src/google/protobuf/stubs/hash.cc \
+ src/google/protobuf/stubs/once.cc \
+ src/google/protobuf/stubs/structurally_valid.cc \
+ src/google/protobuf/stubs/strutil.cc \
+ src/google/protobuf/stubs/substitute.cc
+
+# Java nano library (for device-side users)
+# =======================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libprotobuf-java-nano
+LOCAL_MODULE_TAGS := optional
+LOCAL_SDK_VERSION := 8
+
+LOCAL_SRC_FILES := $(call all-java-files-under, java/src/main/java/com/google/protobuf/nano)
+LOCAL_SRC_FILES += $(call all-java-files-under, java/src/device/main/java/com/google/protobuf/nano)
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+# Java nano library (for host-side users)
+# =======================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := host-libprotobuf-java-nano
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-java-files-under, java/src/main/java/com/google/protobuf/nano)
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+# Java micro library (for device-side users)
+# =======================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libprotobuf-java-micro
+LOCAL_MODULE_TAGS := optional
+LOCAL_SDK_VERSION := 8
+
+LOCAL_SRC_FILES := $(call all-java-files-under, java/src/main/java/com/google/protobuf/micro)
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+# Java micro library (for host-side users)
+# =======================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := host-libprotobuf-java-micro
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-java-files-under, java/src/main/java/com/google/protobuf/micro)
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+# Java lite library (for device-side users)
+# =======================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libprotobuf-java-lite
+LOCAL_MODULE_TAGS := optional
+LOCAL_SDK_VERSION := 8
+
+LOCAL_SRC_FILES := $(JAVA_LITE_SRC_FILES)
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+# Java lite library (for host-side users)
+# =======================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := host-libprotobuf-java-lite
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(JAVA_LITE_SRC_FILES)
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+# C++ lite library
+# =======================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libprotobuf-cpp-lite
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_CPP_EXTENSION := .cc
+
+LOCAL_SRC_FILES := $(CC_LITE_SRC_FILES)
+
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/android \
+ $(LOCAL_PATH)/src
+
+# Define the header files to be copied
+#LOCAL_COPY_HEADERS := \
+# src/google/protobuf/stubs/once.h \
+# src/google/protobuf/stubs/common.h \
+# src/google/protobuf/io/coded_stream.h \
+# src/google/protobuf/generated_message_util.h \
+# src/google/protobuf/repeated_field.h \
+# src/google/protobuf/extension_set.h \
+# src/google/protobuf/wire_format_lite_inl.h
+#
+#LOCAL_COPY_HEADERS_TO := $(LOCAL_MODULE)
+
+LOCAL_CFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI $(IGNORED_WARNINGS)
+
+# These are the minimum versions and don't need to be update.
+ifeq ($(TARGET_ARCH),arm)
+LOCAL_SDK_VERSION := 8
+else
+# x86/mips support only available from API 9.
+LOCAL_SDK_VERSION := 9
+endif
+LOCAL_NDK_STL_VARIANT := stlport_static
+
+include $(BUILD_STATIC_LIBRARY)
+
+# C++ lite library (libc++ flavored for the platform)
+# =======================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libprotobuf-cpp-lite
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_CPP_EXTENSION := .cc
+
+LOCAL_SRC_FILES := $(CC_LITE_SRC_FILES)
+
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/android \
+ $(LOCAL_PATH)/src
+
+LOCAL_CFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI $(IGNORED_WARNINGS)
+
+include $(BUILD_SHARED_LIBRARY)
+
+# C++ full library
+# =======================================================
+protobuf_cc_full_src_files := \
+ $(CC_LITE_SRC_FILES) \
+ src/google/protobuf/stubs/strutil.cc \
+ src/google/protobuf/stubs/strutil.h \
+ src/google/protobuf/stubs/substitute.cc \
+ src/google/protobuf/stubs/substitute.h \
+ src/google/protobuf/stubs/structurally_valid.cc \
+ 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/unknown_field_set.cc \
+ src/google/protobuf/wire_format.cc \
+ 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
+
+# C++ full library - stlport version
+# =======================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libprotobuf-cpp-full
+LOCAL_MODULE_TAGS := optional
+LOCAL_CPP_EXTENSION := .cc
+LOCAL_SRC_FILES := $(protobuf_cc_full_src_files)
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/android \
+ external/zlib \
+ $(LOCAL_PATH)/src
+
+# Define the header files to be copied
+#LOCAL_COPY_HEADERS := \
+# src/google/protobuf/stubs/once.h \
+# src/google/protobuf/stubs/common.h \
+# src/google/protobuf/io/coded_stream.h \
+# src/google/protobuf/generated_message_util.h \
+# src/google/protobuf/repeated_field.h \
+# src/google/protobuf/extension_set.h \
+# src/google/protobuf/wire_format_lite_inl.h
+#
+#LOCAL_COPY_HEADERS_TO := $(LOCAL_MODULE)
+
+LOCAL_CFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI $(IGNORED_WARNINGS)
+
+# These are the minimum versions and don't need to be update.
+ifeq ($(TARGET_ARCH),arm)
+LOCAL_SDK_VERSION := 8
+else
+# x86/mips support only available from API 9.
+LOCAL_SDK_VERSION := 9
+endif
+LOCAL_NDK_STL_VARIANT := stlport_static
+
+include $(BUILD_STATIC_LIBRARY)
+
+# C++ full library - Gnustl+rtti version
+# =======================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libprotobuf-cpp-full-gnustl-rtti
+LOCAL_MODULE_TAGS := optional
+LOCAL_CPP_EXTENSION := .cc
+LOCAL_SRC_FILES := $(protobuf_cc_full_src_files)
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/android \
+ external/zlib \
+ $(LOCAL_PATH)/src
+
+LOCAL_CFLAGS := -frtti $(IGNORED_WARNINGS)
+LOCAL_SDK_VERSION := 14
+LOCAL_NDK_STL_VARIANT := gnustl_static
+
+include $(BUILD_STATIC_LIBRARY)
+
+# C++ full library - libc++ version for the platform
+# =======================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libprotobuf-cpp-full
+LOCAL_MODULE_TAGS := optional
+LOCAL_CPP_EXTENSION := .cc
+LOCAL_SRC_FILES := $(protobuf_cc_full_src_files)
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/android \
+ external/zlib \
+ $(LOCAL_PATH)/src
+
+LOCAL_CFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI $(IGNORED_WARNINGS)
+LOCAL_SHARED_LIBRARIES := libz
+
+include $(BUILD_SHARED_LIBRARY)
+
+# Clean temp vars
+protobuf_cc_full_src_files :=
+
+
+# Android Protocol buffer compiler, aprotoc (host executable)
+# used by the build systems as $(PROTOC) defined in
+# build/core/config.mk
+# =======================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := aprotoc
+LOCAL_MODULE_CLASS := EXECUTABLES
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_CPP_EXTENSION := .cc
+LOCAL_SRC_FILES := $(COMPILER_SRC_FILES)
+
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/android \
+ external/zlib \
+ $(LOCAL_PATH)/src
+
+LOCAL_STATIC_LIBRARIES += libz
+
+ifneq ($(HOST_OS),windows)
+LOCAL_LDLIBS := -lpthread
+endif
+
+LOCAL_CFLAGS := $(IGNORED_WARNINGS)
+
+include $(BUILD_HOST_EXECUTABLE)
+
+# To test java proto params build rules.
+# =======================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := aprotoc-test-nano-params
+LOCAL_MODULE_TAGS := tests
+LOCAL_SDK_VERSION := current
+
+LOCAL_PROTOC_OPTIMIZE_TYPE := nano
+
+LOCAL_SRC_FILES := \
+ src/google/protobuf/unittest_import_nano.proto \
+ src/google/protobuf/unittest_simple_nano.proto \
+ src/google/protobuf/unittest_stringutf8_nano.proto \
+ src/google/protobuf/unittest_recursive_nano.proto
+
+
+LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/src
+
+LOCAL_PROTO_JAVA_OUTPUT_PARAMS := \
+ java_package = $(LOCAL_PATH)/src/google/protobuf/unittest_import_nano.proto|com.google.protobuf.nano, \
+ java_outer_classname = $(LOCAL_PATH)/src/google/protobuf/unittest_import_nano.proto|UnittestImportNano
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+# To test Android-specific nanoproto features.
+# =======================================================
+include $(CLEAR_VARS)
+
+# Parcelable messages
+LOCAL_MODULE := android-nano-test-parcelable
+LOCAL_MODULE_TAGS := tests
+LOCAL_SDK_VERSION := current
+
+LOCAL_PROTOC_OPTIMIZE_TYPE := nano
+
+LOCAL_SRC_FILES := src/google/protobuf/unittest_simple_nano.proto
+
+LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/src
+
+LOCAL_PROTO_JAVA_OUTPUT_PARAMS := \
+ parcelable_messages = true
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+include $(CLEAR_VARS)
+
+# Parcelable and extendable messages
+LOCAL_MODULE := android-nano-test-parcelable-extendable
+LOCAL_MODULE_TAGS := tests
+LOCAL_SDK_VERSION := current
+
+LOCAL_PROTOC_OPTIMIZE_TYPE := nano
+
+LOCAL_SRC_FILES := src/google/protobuf/unittest_extension_nano.proto
+
+LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/src
+
+LOCAL_PROTO_JAVA_OUTPUT_PARAMS := \
+ parcelable_messages = true, \
+ store_unknown_fields = true
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+include $(CLEAR_VARS)
+
+# Test APK
+LOCAL_PACKAGE_NAME := NanoAndroidTest
+
+LOCAL_SDK_VERSION := 8
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, java/src/device/test/java/com/google/protobuf/nano)
+
+LOCAL_MANIFEST_FILE := java/src/device/test/AndroidManifest.xml
+
+LOCAL_STATIC_JAVA_LIBRARIES := libprotobuf-java-nano \
+ android-nano-test-parcelable \
+ android-nano-test-parcelable-extendable
+
+LOCAL_DEX_PREOPT := false
+
+include $(BUILD_PACKAGE)
+
+# 2.3.0 prebuilts for backwards compatibility.
+include $(LOCAL_PATH)/prebuilts/Android.mk
diff --git a/CHANGES.txt b/CHANGES.txt
index 90e9d77..ac42aa5 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,144 +1,779 @@
-===============================================================================
-Welcome to the C# port of Google Protocol Buffers, written by Jon Skeet
-(skeet@pobox.com) based on the work of many talented people.
+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
-For more information about this port, visit its homepage:
-http://protobuf-csharp-port.googlecode.com
+ 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.
-For more information about Protocol Buffers in general, visit the project page
-for the C++, Java and Python project:
-http://protobuf.googlecode.com
-===============================================================================
-RELEASE NOTES - Version 2.4.1.555
-===============================================================================
+ 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.
-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.
+ Ruby:
+ We have added proto3 support for Ruby via a native C extension.
-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
+ 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.
-===============================================================================
-RELEASE NOTES - Version 2.4.1.521
-===============================================================================
+ 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:
-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
+ - 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.
-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.
+ 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.
-===============================================================================
-RELEASE NOTES - Version 2.4.1.473
-===============================================================================
+ See ruby/README.md for details.
-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
+ 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:
-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.
+ - 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[].
-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
+ See javanano/README.txt for details.
-===============================================================================
-RELEASE NOTES - Version 2.3.0.277
-===============================================================================
+2014-12-01 version 3.0.0-alpha-1 (C++/Java):
-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.
+ General
+ * Introduced Protocol Buffers language version 3 (aka proto3).
-Fixes:
-- Issue 9: Class cannot be static and sealed error
-- Issue 12: default value for enumerate fields must be filled out
+ 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.
-Other:
-- Rewrite of build using MSBbuild instead of NAnt
-- Moved to NUnit Version 2.2.8.0
-- Changed to using secure .snk for releases
+ 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.
-===============================================================================
-RELEASE NOTES - Version 0.9.1
-===============================================================================
+ The following are the main new features in language version 3:
-Fixes:
-- issue 10: Incorrect encoding of packed fields when serialized
+ 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.
-===============================================================================
-RELEASE NOTES - Version 0.9.0
-===============================================================================
+ 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 impelmented.
-- Initial release
+ A new notion "syntax" is introduced to specify whether a .proto file
+ uses proto2 or proto3:
-===============================================================================
\ No newline at end of file
+ // 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 mesaages, 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
+ it imports to its importers. For example,
+ // foo.proto
+ import public "bar.proto";
+ import "baz.proto";
+
+ // qux.proto
+ import "foo.proto";
+ // Stuff defined in bar.proto may be used in this file, but stuff from
+ // baz.proto may NOT be used without importing it explicitly.
+ This is useful for moving proto files. To move a proto file, just leave
+ a single "import public" in the old proto file.
+ * New enum option "allow_alias" that specifies whether different symbols can
+ 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
+ fields. This method allows you to set the field to a pre-allocated object
+ and the containing message takes the ownership of that object.
+ * Added SetAllocatedExtension() and ReleaseExtension() to extensions API.
+ * Custom options are now formatted correctly when descriptors are printed in
+ text format.
+ * Various speed optimizations.
+
+ Java
+ * Comments in proto files are now collected and put into generated code as
+ comments for corresponding classes and data members.
+ * Added Parser to parse directly into messages without a Builder. For
+ example,
+ 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.
+ * ByteString now supports more operations: substring(), prepend(), and
+ append(). The implementation of ByteString uses a binary tree structure
+ to support these operations efficiently.
+ * New method findInitializationErrors() that lists all missing required
+ fields.
+ * Various code size and speed optimizations.
+
+ Python
+ * Added support for dynamic message creation. DescriptorDatabase,
+ DescriptorPool, and MessageFactory work like their C++ couterparts to
+ simplify Descriptor construction from *DescriptorProtos, and MessageFactory
+ provides a message instance from a Descriptor.
+ * Added pickle support for protobuf messages.
+ * Unknown fields are now preserved after parsing.
+ * Fixed bug where custom options were not correctly populated. Custom
+ options can be accessed now.
+ * Added EnumTypeWrapper that provides better accessibility to enum types.
+ * Added ParseMessage(descriptor, bytes) to generate a new Message instance
+ from a descriptor and a byte string.
+
+2011-05-01 version 2.4.1:
+
+ C++
+ * Fixed the frendship problem for old compilers to make the library now gcc 3
+ compatible again.
+ * Fixed vcprojects/extract_includes.bat to extract compiler/plugin.h.
+
+ Java
+ * Removed usages of JDK 1.6 only features to make the library now JDK 1.5
+ compatible again.
+ * Fixed a bug about negative enum values.
+ * serialVersionUID is now defined in generated messages for java serializing.
+ * Fixed protoc to use java.lang.Object, which makes "Object" now a valid
+ message name again.
+
+ Python
+ * Experimental C++ implementation now requires C++ protobuf library installed.
+ See the README.txt in the python directory for details.
+
+2011-02-02 version 2.4.0:
+
+ General
+ * The RPC (cc|java|py)_generic_services default value is now false instead of
+ true.
+ * Custom options can have aggregate types. For example,
+ message MyOption {
+ optional string comment = 1;
+ optional string author = 2;
+ }
+ extend google.protobuf.FieldOptions {
+ optional MyOption myoption = 12345;
+ }
+ This option can now be set as follows:
+ message SomeType {
+ optional int32 field = 1 [(myoption) = { comment:'x' author:'y' }];
+ }
+
+ C++
+ * Various speed and code size optimizations.
+ * Added a release_foo() method on string and message fields.
+ * Fixed gzip_output_stream sub-stream handling.
+
+ Java
+ * Builders now maintain sub-builders for sub-messages. Use getFooBuilder() to
+ get the builder for the sub-message "foo". This allows you to repeatedly
+ modify deeply-nested sub-messages without rebuilding them.
+ * Builder.build() no longer invalidates the Builder for generated messages
+ (You may continue to modify it and then build another message).
+ * Code generator will generate efficient equals() and hashCode()
+ implementations if new option java_generate_equals_and_hash is enabled.
+ (Otherwise, reflection-based implementations are used.)
+ * Generated messages now implement Serializable.
+ * Fields with [deprecated=true] will be marked with @Deprecated in Java.
+ * Added lazy conversion of UTF-8 encoded strings to String objects to improve
+ performance.
+ * Various optimizations.
+ * Enum value can be accessed directly, instead of calling getNumber() on the
+ enum member.
+ * For each enum value, an integer constant is also generated with the suffix
+ _VALUE.
+
+ Python
+ * Added an experimental C++ implementation for Python messages via a Python
+ extension. Implementation type is controlled by an environment variable
+ PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION (valid values: "cpp" and "python")
+ The default value is currently "python" but will be changed to "cpp" in
+ future release.
+ * Improved performance on message instantiation significantly.
+ Most of the work on message instantiation is done just once per message
+ class, instead of once per message instance.
+ * Improved performance on text message parsing.
+ * Allow add() to forward keyword arguments to the concrete class.
+ E.g. instead of
+ item = repeated_field.add()
+ item.foo = bar
+ item.baz = quux
+ You can do:
+ repeated_field.add(foo=bar, baz=quux)
+ * Added a sort() interface to the BaseContainer.
+ * Added an extend() method to repeated composite fields.
+ * Added UTF8 debug string support.
+
+2010-01-08 version 2.3.0:
+
+ General
+ * Parsers for repeated numeric fields now always accept both packed and
+ unpacked input. The [packed=true] option only affects serializers.
+ Therefore, it is possible to switch a field to packed format without
+ breaking backwards-compatibility -- as long as all parties are using
+ protobuf 2.3.0 or above, at least.
+ * The generic RPC service code generated by the C++, Java, and Python
+ generators can be disabled via file options:
+ option cc_generic_services = false;
+ option java_generic_services = false;
+ option py_generic_services = false;
+ This allows plugins to generate alternative code, possibly specific to some
+ particular RPC implementation.
+
+ protoc
+ * Now supports a plugin system for code generators. Plugins can generate
+ code for new languages or inject additional code into the output of other
+ code generators. Plugins are just binaries which accept a protocol buffer
+ on stdin and write a protocol buffer to stdout, so they may be written in
+ any language. See src/google/protobuf/compiler/plugin.proto.
+ **WARNING**: Plugins are experimental. The interface may change in a
+ future version.
+ * If the output location ends in .zip or .jar, protoc will write its output
+ to a zip/jar archive instead of a directory. For example:
+ protoc --java_out=myproto_srcs.jar --python_out=myproto.zip myproto.proto
+ Currently the archive contents are not compressed, though this could change
+ in the future.
+ * inf, -inf, and nan can now be used as default values for float and double
+ fields.
+
+ C++
+ * Various speed and code size optimizations.
+ * DynamicMessageFactory is now fully thread-safe.
+ * Message::Utf8DebugString() method is like DebugString() but avoids escaping
+ UTF-8 bytes.
+ * Compiled-in message types can now contain dynamic extensions, through use
+ of CodedInputStream::SetExtensionRegistry().
+ * Now compiles shared libraries (DLLs) by default on Cygwin and MinGW, to
+ match other platforms. Use --disable-shared to avoid this.
+
+ Java
+ * parseDelimitedFrom() and mergeDelimitedFrom() now detect EOF and return
+ false/null instead of throwing an exception.
+ * Fixed some initialization ordering bugs.
+ * Fixes for OpenJDK 7.
+
+ Python
+ * 10-25 times faster than 2.2.0, still pure-Python.
+ * Calling a mutating method on a sub-message always instantiates the message
+ in its parent even if the mutating method doesn't actually mutate anything
+ (e.g. parsing from an empty string).
+ * Expanded descriptors a bit.
+
+2009-08-11 version 2.2.0:
+
+ C++
+ * Lite mode: The "optimize_for = LITE_RUNTIME" option causes the compiler
+ to generate code which only depends libprotobuf-lite, which is much smaller
+ than libprotobuf but lacks descriptors, reflection, and some other features.
+ * Fixed bug where Message.Swap(Message) was only implemented for
+ optimize_for_speed. Swap now properly implemented in both modes
+ (Issue 91).
+ * Added RemoveLast and SwapElements(index1, index2) to Reflection
+ interface for repeated elements.
+ * Added Swap(Message) to Reflection interface.
+ * Floating-point literals in generated code that are intended to be
+ single-precision now explicitly have 'f' suffix to avoid pedantic warnings
+ produced by some compilers.
+ * The [deprecated=true] option now causes the C++ code generator to generate
+ a GCC-style deprecation annotation (no-op on other compilers).
+ * google::protobuf::GetEnumDescriptor<SomeGeneratedEnumType>() returns the
+ EnumDescriptor for that type -- useful for templates which cannot call
+ SomeGeneratedEnumType_descriptor().
+ * Various optimizations and obscure bug fixes.
+
+ Java
+ * Lite mode: The "optimize_for = LITE_RUNTIME" option causes the compiler
+ to generate code which only depends libprotobuf-lite, which is much smaller
+ than libprotobuf but lacks descriptors, reflection, and some other features.
+ * Lots of style cleanups.
+
+ Python
+ * Fixed endianness bug with floats and doubles.
+ * Text format parsing support.
+ * Fix bug with parsing packed repeated fields in embedded messages.
+ * Ability to initialize fields by passing keyword args to constructor.
+ * Support iterators in extend and __setslice__ for containers.
+
+2009-05-13 version 2.1.0:
+
+ General
+ * Repeated fields of primitive types (types other that string, group, and
+ nested messages) may now use the option [packed = true] to get a more
+ efficient encoding. In the new encoding, the entire list is written
+ as a single byte blob using the "length-delimited" wire type. Within
+ this blob, the individual values are encoded the same way they would
+ be normally except without a tag before each value (thus, they are
+ tightly "packed").
+ * For each field, the generated code contains an integer constant assigned
+ to the field number. For example, the .proto file:
+ message Foo { optional int bar_baz = 123; }
+ would generate the following constants, all with the integer value 123:
+ C++: Foo::kBarBazFieldNumber
+ Java: Foo.BAR_BAZ_FIELD_NUMBER
+ Python: Foo.BAR_BAZ_FIELD_NUMBER
+ Constants are also generated for extensions, with the same naming scheme.
+ These constants may be used as switch cases.
+ * Updated bundled Google Test to version 1.3.0. Google Test is now bundled
+ in its verbatim form as a nested autoconf package, so you can drop in any
+ other version of Google Test if needed.
+ * optimize_for = SPEED is now the default, by popular demand. Use
+ optimize_for = CODE_SIZE if code size is more important in your app.
+ * It is now an error to define a default value for a repeated field.
+ Previously, this was silently ignored (it had no effect on the generated
+ code).
+ * Fields can now be marked deprecated like:
+ optional int32 foo = 1 [deprecated = true];
+ Currently this does not have any actual effect, but in the future the code
+ generators may generate deprecation annotations in each language.
+ * Cross-compiling should now be possible using the --with-protoc option to
+ configure. See README.txt for more info.
+
+ protoc
+ * --error_format=msvs option causes errors to be printed in Visual Studio
+ format, which should allow them to be clicked on in the build log to go
+ directly to the error location.
+ * The type name resolver will no longer resolve type names to fields. For
+ example, this now works:
+ message Foo {}
+ message Bar {
+ optional int32 Foo = 1;
+ optional Foo baz = 2;
+ }
+ Previously, the type of "baz" would resolve to "Bar.Foo", and you'd get
+ an error because Bar.Foo is a field, not a type. Now the type of "baz"
+ resolves to the message type Foo. This change is unlikely to make a
+ difference to anyone who follows the Protocol Buffers style guide.
+
+ C++
+ * Several optimizations, including but not limited to:
+ - Serialization, especially to flat arrays, is 10%-50% faster, possibly
+ more for small objects.
+ - Several descriptor operations which previously required locking no longer
+ do.
+ - Descriptors are now constructed lazily on first use, rather than at
+ process startup time. This should save memory in programs which do not
+ use descriptors or reflection.
+ - UnknownFieldSet completely redesigned to be more efficient (especially in
+ terms of memory usage).
+ - Various optimizations to reduce code size (though the serialization speed
+ optimizations increased code size).
+ * Message interface has method ParseFromBoundedZeroCopyStream() which parses
+ a limited number of bytes from an input stream rather than parsing until
+ EOF.
+ * GzipInputStream and GzipOutputStream support reading/writing gzip- or
+ zlib-compressed streams if zlib is available.
+ (google/protobuf/io/gzip_stream.h)
+ * DescriptorPool::FindAllExtensions() and corresponding
+ DescriptorDatabase::FindAllExtensions() can be used to enumerate all
+ extensions of a given type.
+ * For each enum type Foo, protoc will generate functions:
+ const string& Foo_Name(Foo value);
+ bool Foo_Parse(const string& name, Foo* result);
+ The former returns the name of the enum constant corresponding to the given
+ value while the latter finds the value corresponding to a name.
+ * RepeatedField and RepeatedPtrField now have back-insertion iterators.
+ * String fields now have setters that take a char* and a size, in addition
+ to the existing ones that took char* or const string&.
+ * DescriptorPool::AllowUnknownDependencies() may be used to tell
+ DescriptorPool to create placeholder descriptors for unknown entities
+ referenced in a FileDescriptorProto. This can allow you to parse a .proto
+ file without having access to other .proto files that it imports, for
+ example.
+ * Updated gtest to latest version. The gtest package is now included as a
+ nested autoconf package, so it should be able to drop new versions into the
+ "gtest" subdirectory without modification.
+
+ Java
+ * Fixed bug where Message.mergeFrom(Message) failed to merge extensions.
+ * Message interface has new method toBuilder() which is equivalent to
+ newBuilderForType().mergeFrom(this).
+ * All enums now implement the ProtocolMessageEnum interface.
+ * Setting a field to null now throws NullPointerException.
+ * 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
+ 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
+ defined methods. Foo.newReflectiveService() can be called to wrap an
+ instance of this interface in a class that implements the generic
+ RpcService interface, which provides reflection support that is usually
+ needed by RPC server implementations.
+ * RPC interfaces now support blocking operation in addition to non-blocking.
+ The protocol compiler generates separate blocking and non-blocking stubs
+ which operate against separate blocking and non-blocking RPC interfaces.
+ 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,
+ 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.
+ * Throw a more descriptive exception when build() is double-called.
+ * Add a method to query whether CodedInputStream is at the end of the input
+ stream.
+ * Add a method to reset a CodedInputStream's size counter; useful when
+ reading many messages with the same stream.
+ * equals() and hashCode() now account for unknown fields.
+
+ Python
+ * Added slicing support for repeated scalar fields. Added slice retrieval and
+ removal of repeated composite fields.
+ * Updated RPC interfaces to allow for blocking operation. A client may
+ now pass None for a callback when making an RPC, in which case the
+ call will block until the response is received, and the response
+ object will be returned directly to the caller. This interface change
+ cannot be used in practice until RPC implementations are updated to
+ implement it.
+ * Changes to input_stream.py should make protobuf compatible with appengine.
+
+2008-11-25 version 2.0.3:
+
+ protoc
+ * Enum values may now have custom options, using syntax similar to field
+ options.
+ * Fixed bug where .proto files which use custom options but don't actually
+ define them (i.e. they import another .proto file defining the options)
+ had to explicitly import descriptor.proto.
+ * Adjacent string literals in .proto files will now be concatenated, like in
+ C.
+ * If an input file is a Windows absolute path (e.g. "C:\foo\bar.proto") and
+ the import path only contains "." (or contains "." but does not contain
+ the file), protoc incorrectly thought that the file was under ".", because
+ it thought that the path was relative (since it didn't start with a slash).
+ This has been fixed.
+
+ C++
+ * Generated message classes now have a Swap() method which efficiently swaps
+ the contents of two objects.
+ * All message classes now have a SpaceUsed() method which returns an estimate
+ of the number of bytes of allocated memory currently owned by the object.
+ This is particularly useful when you are reusing a single message object
+ to improve performance but want to make sure it doesn't bloat up too large.
+ * New method Message::SerializeAsString() returns a string containing the
+ serialized data. May be more convenient than calling
+ SerializeToString(string*).
+ * In debug mode, log error messages when string-type fields are found to
+ contain bytes that are not valid UTF-8.
+ * Fixed bug where a message with multiple extension ranges couldn't parse
+ extensions.
+ * Fixed bug where MergeFrom(const Message&) didn't do anything if invoked on
+ a message that contained no fields (but possibly contained extensions).
+ * Fixed ShortDebugString() to not be O(n^2). Durr.
+ * Fixed crash in TextFormat parsing if the first token in the input caused a
+ tokenization error.
+ * Fixed obscure bugs in zero_copy_stream_impl.cc.
+ * Added support for HP C++ on Tru64.
+ * Only build tests on "make check", not "make".
+ * Fixed alignment issue that caused crashes when using DynamicMessage on
+ 64-bit Sparc machines.
+ * Simplify template usage to work with MSVC 2003.
+ * Work around GCC 4.3.x x86_64 compiler bug that caused crashes on startup.
+ (This affected Fedora 9 in particular.)
+ * Now works on "Solaris 10 using recent Sun Studio".
+
+ Java
+ * New overload of mergeFrom() which parses a slice of a byte array instead
+ of the whole thing.
+ * New method ByteString.asReadOnlyByteBuffer() does what it sounds like.
+ * Improved performance of isInitialized() when optimizing for code size.
+
+ Python
+ * Corrected ListFields() signature in Message base class to match what
+ subclasses actually implement.
+ * Some minor refactoring.
+ * Don't pass self as first argument to superclass constructor (no longer
+ allowed in Python 2.6).
+
+2008-09-29 version 2.0.2:
+
+ General
+ * License changed from Apache 2.0 to New BSD.
+ * It is now possible to define custom "options", which are basically
+ annotations which may be placed on definitions in a .proto file.
+ For example, you might define a field option called "foo" like so:
+ import "google/protobuf/descriptor.proto"
+ extend google.protobuf.FieldOptions {
+ optional string foo = 12345;
+ }
+ Then you annotate a field using the "foo" option:
+ message MyMessage {
+ optional int32 some_field = 1 [(foo) = "bar"]
+ }
+ The value of this option is then visible via the message's
+ Descriptor:
+ const FieldDescriptor* field =
+ MyMessage::descriptor()->FindFieldByName("some_field");
+ assert(field->options().GetExtension(foo) == "bar");
+ This feature has been implemented and tested in C++ and Java.
+ Other languages may or may not need to do extra work to support
+ custom options, depending on how they construct descriptors.
+
+ C++
+ * Fixed some GCC warnings that only occur when using -pedantic.
+ * Improved static initialization code, making ordering more
+ predictable among other things.
+ * TextFormat will no longer accept messages which contain multiple
+ instances of a singular field. Previously, the latter instance
+ would overwrite the former.
+ * Now works on systems that don't have hash_map.
+
+ Java
+ * Print @Override annotation in generated code where appropriate.
+
+ Python
+ * Strings now use the "unicode" type rather than the "str" type.
+ String fields may still be assigned ASCII "str" values; they will
+ automatically be converted.
+ * Adding a property to an object representing a repeated field now
+ raises an exception. For example:
+ # No longer works (and never should have).
+ message.some_repeated_field.foo = 1
+
+ Windows
+ * We now build static libraries rather than DLLs by default on MSVC.
+ See vsprojects/readme.txt for more information.
+
+2008-08-15 version 2.0.1:
+
+ protoc
+ * New flags --encode and --decode can be used to convert between protobuf text
+ format and binary format from the command-line.
+ * New flag --descriptor_set_out can be used to write FileDescriptorProtos for
+ all parsed files directly into a single output file. This is particularly
+ useful if you wish to parse .proto files from programs written in languages
+ other than C++: just run protoc as a background process and have it output
+ a FileDescriptorList, then parse that natively.
+ * Improved error message when an enum value's name conflicts with another
+ symbol defined in the enum type's scope, e.g. if two enum types declared
+ in the same scope have values with the same name. This is disallowed for
+ compatibility with C++, but this wasn't clear from the error.
+ * Fixed absolute output paths on Windows.
+ * Allow trailing slashes in --proto_path mappings.
+
+ C++
+ * Reflection objects are now per-class rather than per-instance. To make this
+ possible, the Reflection interface had to be changed such that all methods
+ take the Message instance as a parameter. This change improves performance
+ significantly in memory-bandwidth-limited use cases, since it makes the
+ message objects smaller. Note that source-incompatible interface changes
+ like this will not be made again after the library leaves beta.
+ * Heuristically detect sub-messages when printing unknown fields.
+ * Fix static initialization ordering bug that caused crashes at startup when
+ compiling on Mac with static linking.
+ * Fixed TokenizerTest when compiling with -DNDEBUG on Linux.
+ * Fixed incorrect definition of kint32min.
+ * Fix bytes type setter to work with byte sequences with embedded NULLs.
+ * Other irrelevant tweaks.
+
+ Java
+ * Fixed UnknownFieldSet's parsing of varints larger than 32 bits.
+ * Fixed TextFormat's parsing of "inf" and "nan".
+ * Fixed TextFormat's parsing of comments.
+ * Added info to Java POM that will be required when we upload the
+ package to a Maven repo.
+
+ Python
+ * MergeFrom(message) and CopyFrom(message) are now implemented.
+ * SerializeToString() raises an exception if the message is missing required
+ fields.
+ * Code organization improvements.
+ * Fixed doc comments for RpcController and RpcChannel, which had somehow been
+ swapped.
+ * Fixed text_format_test on Windows where floating-point exponents sometimes
+ contain extra zeros.
+ * Fix Python service CallMethod() implementation.
+
+ Other
+ * Improved readmes.
+ * VIM syntax highlighting improvements.
+
+2008-07-07 version 2.0.0:
+
+ * First public release.
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
new file mode 100644
index 0000000..b8d97fc
--- /dev/null
+++ b/CONTRIBUTORS.txt
@@ -0,0 +1,102 @@
+This file contains a list of people who have made large contributions
+to the public version of Protocol Buffers.
+
+Original Protocol Buffers design and implementation:
+ Sanjay Ghemawat <sanjay@google.com>
+ Jeff Dean <jeff@google.com>
+ Daniel Dulitz <daniel@google.com>
+ Craig Silverstein
+ Paul Haahr <haahr@google.com>
+ Corey Anderson <corin@google.com>
+ (and many others)
+
+Proto2 C++ and Java primary author:
+ Kenton Varda <kenton@google.com>
+
+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>
+ Wenbo Zhu <wenboz@google.com>
+
+Large quantity of code reviews:
+ Scott Bruce <sbruce@google.com>
+ Frank Yellin
+ Neal Norwitz <nnorwitz@google.com>
+ Jeffrey Yasskin <jyasskin@google.com>
+ Ambrose Feinstein <ambrose@google.com>
+
+Documentation:
+ Lisa Carey <lcarey@google.com>
+
+Maven packaging:
+ Gregory Kick <gak@google.com>
+
+Patch contributors:
+ Kevin Ko <kevin.s.ko@gmail.com>
+ * Small patch to handle trailing slashes in --proto_path flag.
+ Johan Euphrosine <proppy@aminche.com>
+ * Small patch to fix Python CallMethod().
+ Ulrich Kunitz <kune@deine-taler.de>
+ * Small optimizations to Python serialization.
+ Leandro Lucarella <llucax@gmail.com>
+ * VI syntax highlighting tweaks.
+ * Fix compiler to not make output executable.
+ Dilip Joseph <dilip.antony.joseph@gmail.com>
+ * Heuristic detection of sub-messages when printing unknown fields in
+ text format.
+ Brian Atkinson <nairb774@gmail.com>
+ * Added @Override annotation to generated Java code where appropriate.
+ Vincent Choinière <Choiniere.Vincent@hydro.qc.ca>
+ * Tru64 support.
+ Monty Taylor <monty.taylor@gmail.com>
+ * Solaris 10 + Sun Studio fixes.
+ Alek Storm <alek.storm@gmail.com>
+ * Slicing support for repeated scalar fields for the Python API.
+ Oleg Smolsky <oleg.smolsky@gmail.com>
+ * MS Visual Studio error format option.
+ * Detect unordered_map in stl_hash.m4.
+ Brian Olson <brianolson@google.com>
+ * gzip/zlib I/O support.
+ Michael Poole <mdpoole@troilus.org>
+ * Fixed warnings about generated constructors not explicitly initializing
+ all fields (only present with certain compiler settings).
+ * Added generation of field number constants.
+ Wink Saville <wink@google.com>
+ * Fixed initialization ordering problem in logging code.
+ Will Pierce <willp@nuclei.com>
+ * Small patch improving performance of in Python serialization.
+ Alexandre Vassalotti <alexandre@peadrop.com>
+ * Emacs mode for Protocol Buffers (editors/protobuf-mode.el).
+ Scott Stafford <scott.stafford@gmail.com>
+ * Added Swap(), SwapElements(), and RemoveLast() to Reflection interface.
+ Alexander Melnikov <alm@sibmail.ru>
+ * HPUX support.
+ Oliver Jowett <oliver.jowett@gmail.com>
+ * Detect whether zlib is new enough in configure script.
+ * Fixes for Solaris 10 32/64-bit confusion.
+ Evan Jones <evanj@mit.edu>
+ * Optimize Java serialization code when writing a small message to a stream.
+ * Optimize Java serialization of strings so that UTF-8 encoding happens only
+ once per string per serialization call.
+ * Clean up some Java warnings.
+ * 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)
diff --git a/INSTALL.txt b/INSTALL.txt
new file mode 100644
index 0000000..ce3b094
--- /dev/null
+++ b/INSTALL.txt
@@ -0,0 +1,237 @@
+This file contains detailed but generic information on building and
+installing the C++ part of this project. For shorter instructions,
+as well as instructions for compiling and installing the Java or
+Python parts, see README.
+
+======================================================================
+
+Copyright 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
+Foundation, Inc.
+
+ This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+
+Basic Installation
+==================
+
+ These are generic installation instructions.
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions. Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+ It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring. (Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.)
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+ The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'. You only need
+`configure.ac' if you want to change it or regenerate `configure' using
+a newer version of `autoconf'.
+
+The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system. If you're
+ using `csh' on an old version of System V, you might need to type
+ `sh ./configure' instead to prevent `csh' from trying to execute
+ `configure' itself.
+
+ Running `configure' takes awhile. While running, it prints some
+ messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation.
+
+ 5. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'. To also remove the
+ files that `configure' created (so you can compile the package for
+ a different kind of computer), type `make distclean'. There is
+ also a `make maintainer-clean' target, but that is intended mainly
+ for the package's developers. If you use it, you may have to get
+ all sorts of other programs in order to regenerate files that came
+ with the distribution.
+
+Compilers and Options
+=====================
+
+ Some systems require unusual options for compilation or linking that
+the `configure' script does not know about. Run `./configure --help'
+for details on some of the pertinent environment variables.
+
+ You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment. Here
+is an example:
+
+ ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
+
+ *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+ You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory. To do this, you must use a version of `make' that
+supports the `VPATH' variable, such as GNU `make'. `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script. `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+ If you have to use a `make' that does not support the `VPATH'
+variable, you have to compile the package for one architecture at a
+time in the source code directory. After you have installed the
+package for one architecture, use `make distclean' before reconfiguring
+for another architecture.
+
+Installation Names
+==================
+
+ By default, `make install' will install the package's files in
+`/usr/local/bin', `/usr/local/man', etc. You can specify an
+installation prefix other than `/usr/local' by giving `configure' the
+option `--prefix=PATH'.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+give `configure' the option `--exec-prefix=PATH', the package will use
+PATH as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=PATH' to specify different values for particular
+kinds of files. Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+ Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+ There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on. Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
+`--build=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+ CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+ OS KERNEL-OS
+
+ See the file `config.sub' for the possible values of each field. If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+ If you are _building_ compiler tools for cross-compiling, you should
+use the `--target=TYPE' option to select the type of system they will
+produce code for.
+
+ If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+ If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+ Variables not defined in a site shell script can be set in the
+environment passed to `configure'. However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost. In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'. For example:
+
+ ./configure CC=/usr/local2/bin/gcc
+
+will cause the specified gcc to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+`configure' Invocation
+======================
+
+ `configure' recognizes the following options to control how it
+operates.
+
+`--help'
+`-h'
+ Print a summary of the options to `configure', and exit.
+
+`--version'
+`-V'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`--cache-file=FILE'
+ Enable the cache: use and save the results of the tests in FILE,
+ traditionally `config.cache'. FILE defaults to `/dev/null' to
+ disable caching.
+
+`--config-cache'
+`-C'
+ Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made. To
+ suppress all normal output, redirect it to `/dev/null' (any error
+ messages will still be shown).
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`configure' also accepts some other, not widely useful, options. Run
+`configure --help' for more details.
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..f086efd
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,44 @@
+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_aix.h.
+ This file is copyrighted by Bloomberg Finance LP.
+
+ - Andorid.mk, which is copyrighted by The Android Open Source Project.
+
+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.
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..1c03923
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,359 @@
+## 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 gtest in distributions.
+DIST_SUBDIRS = $(subdirs) src
+
+# Build gtest before we build protobuf tests. We don't add gtest to SUBDIRS
+# because then "make check" would also build and run all of gtest'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 gtest since we don't want to overwrite
+# the installed version of gtest if there is one.
+check-local:
+ @echo "Making lib/libgtest.a lib/libgtest_main.a in gtest"
+ @cd gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la
+
+# We would like to clean gtest 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 gtest because it's listed among the
+# DIST_SUBDIRS. distclean will delete gtest/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 gtest/Makefile; then \
+ echo "Making clean in gtest"; \
+ cd gtest && $(MAKE) $(AM_MAKEFLAGS) clean; \
+ fi
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = protobuf.pc protobuf-lite.pc
+
+java_EXTRA_DIST= \
+ java/src/main/java/com/google/protobuf/AbstractMessage.java \
+ java/src/main/java/com/google/protobuf/AbstractMessageLite.java \
+ java/src/main/java/com/google/protobuf/AbstractParser.java \
+ java/src/main/java/com/google/protobuf/BlockingRpcChannel.java \
+ java/src/main/java/com/google/protobuf/BlockingService.java \
+ java/src/main/java/com/google/protobuf/BoundedByteString.java \
+ java/src/main/java/com/google/protobuf/ByteString.java \
+ java/src/main/java/com/google/protobuf/CodedInputStream.java \
+ java/src/main/java/com/google/protobuf/CodedOutputStream.java \
+ java/src/main/java/com/google/protobuf/Descriptors.java \
+ java/src/main/java/com/google/protobuf/DynamicMessage.java \
+ java/src/main/java/com/google/protobuf/Extension.java \
+ java/src/main/java/com/google/protobuf/ExtensionLite.java \
+ java/src/main/java/com/google/protobuf/ExtensionRegistry.java \
+ java/src/main/java/com/google/protobuf/ExtensionRegistryLite.java \
+ java/src/main/java/com/google/protobuf/FieldSet.java \
+ java/src/main/java/com/google/protobuf/GeneratedMessage.java \
+ java/src/main/java/com/google/protobuf/GeneratedMessageLite.java \
+ java/src/main/java/com/google/protobuf/Internal.java \
+ java/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java \
+ java/src/main/java/com/google/protobuf/LazyField.java \
+ java/src/main/java/com/google/protobuf/LazyFieldLite.java \
+ java/src/main/java/com/google/protobuf/LazyStringArrayList.java \
+ java/src/main/java/com/google/protobuf/LazyStringList.java \
+ java/src/main/java/com/google/protobuf/LiteralByteString.java \
+ java/src/main/java/com/google/protobuf/MapEntry.java \
+ java/src/main/java/com/google/protobuf/MapEntryLite.java \
+ java/src/main/java/com/google/protobuf/MapField.java \
+ java/src/main/java/com/google/protobuf/MapFieldLite.java \
+ java/src/main/java/com/google/protobuf/Message.java \
+ java/src/main/java/com/google/protobuf/MessageLite.java \
+ java/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java \
+ java/src/main/java/com/google/protobuf/MessageOrBuilder.java \
+ java/src/main/java/com/google/protobuf/MessageReflection.java \
+ java/src/main/java/com/google/protobuf/Parser.java \
+ java/src/main/java/com/google/protobuf/ProtocolMessageEnum.java \
+ java/src/main/java/com/google/protobuf/ProtocolStringList.java \
+ java/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java \
+ java/src/main/java/com/google/protobuf/RopeByteString.java \
+ java/src/main/java/com/google/protobuf/RpcCallback.java \
+ java/src/main/java/com/google/protobuf/RpcChannel.java \
+ java/src/main/java/com/google/protobuf/RpcController.java \
+ java/src/main/java/com/google/protobuf/RpcUtil.java \
+ java/src/main/java/com/google/protobuf/ServiceException.java \
+ java/src/main/java/com/google/protobuf/Service.java \
+ java/src/main/java/com/google/protobuf/SingleFieldBuilder.java \
+ java/src/main/java/com/google/protobuf/SmallSortedMap.java \
+ java/src/main/java/com/google/protobuf/TextFormat.java \
+ java/src/main/java/com/google/protobuf/UninitializedMessageException.java \
+ java/src/main/java/com/google/protobuf/UnknownFieldSet.java \
+ java/src/main/java/com/google/protobuf/UnknownFieldSetLite.java \
+ java/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java \
+ java/src/main/java/com/google/protobuf/Utf8.java \
+ java/src/main/java/com/google/protobuf/WireFormat.java \
+ java/src/test/java/com/google/protobuf/AbstractMessageTest.java \
+ java/src/test/java/com/google/protobuf/BoundedByteStringTest.java \
+ java/src/test/java/com/google/protobuf/ByteStringTest.java \
+ java/src/test/java/com/google/protobuf/CheckUtf8Test.java \
+ java/src/test/java/com/google/protobuf/CodedInputStreamTest.java \
+ java/src/test/java/com/google/protobuf/CodedOutputStreamTest.java \
+ java/src/test/java/com/google/protobuf/DeprecatedFieldTest.java \
+ java/src/test/java/com/google/protobuf/DescriptorsTest.java \
+ java/src/test/java/com/google/protobuf/DynamicMessageTest.java \
+ java/src/test/java/com/google/protobuf/FieldPresenceTest.java \
+ java/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java \
+ java/src/test/java/com/google/protobuf/GeneratedMessageTest.java \
+ java/src/test/java/com/google/protobuf/IsValidUtf8Test.java \
+ java/src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java \
+ java/src/test/java/com/google/protobuf/LazyFieldLiteTest.java \
+ java/src/test/java/com/google/protobuf/LazyFieldTest.java \
+ java/src/test/java/com/google/protobuf/LazyMessageLiteTest.java \
+ java/src/test/java/com/google/protobuf/LazyStringArrayListTest.java \
+ java/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java \
+ java/src/test/java/com/google/protobuf/LiteEqualsAndHashTest.java \
+ java/src/test/java/com/google/protobuf/LiteralByteStringTest.java \
+ java/src/test/java/com/google/protobuf/LiteTest.java \
+ java/src/test/java/com/google/protobuf/MapForProto2LiteTest.java \
+ java/src/test/java/com/google/protobuf/MapForProto2Test.java \
+ java/src/test/java/com/google/protobuf/MapTest.java \
+ java/src/test/java/com/google/protobuf/MessageTest.java \
+ java/src/test/java/com/google/protobuf/NestedBuildersTest.java \
+ java/src/test/java/com/google/protobuf/ParserTest.java \
+ java/src/test/java/com/google/protobuf/RepeatedFieldBuilderTest.java \
+ java/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java \
+ java/src/test/java/com/google/protobuf/RopeByteStringTest.java \
+ java/src/test/java/com/google/protobuf/ServiceTest.java \
+ java/src/test/java/com/google/protobuf/SingleFieldBuilderTest.java \
+ java/src/test/java/com/google/protobuf/SmallSortedMapTest.java \
+ java/src/test/java/com/google/protobuf/TestBadIdentifiers.java \
+ java/src/test/java/com/google/protobuf/TestUtil.java \
+ java/src/test/java/com/google/protobuf/TextFormatTest.java \
+ java/src/test/java/com/google/protobuf/UnknownEnumValueTest.java \
+ java/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java \
+ java/src/test/java/com/google/protobuf/UnknownFieldSetTest.java \
+ java/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java \
+ java/src/test/java/com/google/protobuf/WireFormatTest.java \
+ java/src/test/java/com/google/protobuf/field_presence_test.proto \
+ java/src/test/java/com/google/protobuf/lazy_fields_lite.proto \
+ java/src/test/java/com/google/protobuf/lite_equals_and_hash.proto \
+ java/src/test/java/com/google/protobuf/map_for_proto2_lite_test.proto \
+ java/src/test/java/com/google/protobuf/map_for_proto2_test.proto \
+ java/src/test/java/com/google/protobuf/map_test.proto \
+ java/src/test/java/com/google/protobuf/multiple_files_test.proto \
+ java/src/test/java/com/google/protobuf/nested_builders_test.proto \
+ java/src/test/java/com/google/protobuf/nested_extension_lite.proto \
+ java/src/test/java/com/google/protobuf/nested_extension.proto \
+ java/src/test/java/com/google/protobuf/non_nested_extension_lite.proto \
+ java/src/test/java/com/google/protobuf/non_nested_extension.proto \
+ java/src/test/java/com/google/protobuf/outer_class_name_test2.proto \
+ java/src/test/java/com/google/protobuf/outer_class_name_test3.proto \
+ java/src/test/java/com/google/protobuf/outer_class_name_test.proto \
+ java/src/test/java/com/google/protobuf/test_bad_identifiers.proto \
+ java/src/test/java/com/google/protobuf/test_check_utf8.proto \
+ java/src/test/java/com/google/protobuf/test_check_utf8_size.proto \
+ java/src/test/java/com/google/protobuf/test_custom_options.proto \
+ java/pom.xml \
+ java/README.txt
+
+javanano_EXTRA_DIST= \
+ javanano/src/main/java/com/google/protobuf/nano/CodedOutputByteBufferNano.java \
+ javanano/src/main/java/com/google/protobuf/nano/FieldData.java \
+ javanano/src/main/java/com/google/protobuf/nano/FieldArray.java \
+ javanano/src/main/java/com/google/protobuf/nano/WireFormatNano.java \
+ javanano/src/main/java/com/google/protobuf/nano/Extension.java \
+ javanano/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java \
+ javanano/src/main/java/com/google/protobuf/nano/UnknownFieldData.java \
+ javanano/src/main/java/com/google/protobuf/nano/MessageNano.java \
+ javanano/src/main/java/com/google/protobuf/nano/InternalNano.java \
+ javanano/src/main/java/com/google/protobuf/nano/InvalidProtocolBufferNanoException.java \
+ javanano/src/main/java/com/google/protobuf/nano/MapFactories.java \
+ javanano/src/main/java/com/google/protobuf/nano/ExtendableMessageNano.java \
+ javanano/src/main/java/com/google/protobuf/nano/MessageNanoPrinter.java \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_accessors_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_enum_class_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_reference_types_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_extension_repeated_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_has_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_multiple_nameclash_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_single_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/NanoTest.java \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_simple_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_import_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_repeated_merge_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_extension_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_repeated_packables_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_extension_singular_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_recursive_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_extension_packed_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_enum_validity_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_stringutf8_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_multiple_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/unittest_enum_class_multiple_nano.proto \
+ javanano/src/test/java/com/google/protobuf/nano/map_test.proto \
+ javanano/README.txt \
+ javanano/pom.xml
+
+
+python_EXTRA_DIST= \
+ python/google/protobuf/internal/api_implementation.cc \
+ python/google/protobuf/internal/api_implementation.py \
+ python/google/protobuf/internal/containers.py \
+ python/google/protobuf/internal/cpp_message.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_python_test.py \
+ 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/message_factory_python_test.py \
+ python/google/protobuf/internal/message_factory_test.py \
+ python/google/protobuf/internal/message_listener.py \
+ python/google/protobuf/internal/message_python_test.py \
+ 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/_parameterized.py \
+ 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/wire_format.py \
+ python/google/protobuf/internal/wire_format_test.py \
+ python/google/protobuf/internal/__init__.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/pyext/README \
+ python/google/protobuf/pyext/cpp_message.py \
+ python/google/protobuf/pyext/descriptor.h \
+ python/google/protobuf/pyext/descriptor.cc \
+ python/google/protobuf/pyext/descriptor_pool.h \
+ python/google/protobuf/pyext/descriptor_pool.cc \
+ python/google/protobuf/pyext/descriptor_containers.h \
+ python/google/protobuf/pyext/descriptor_containers.cc \
+ python/google/protobuf/pyext/extension_dict.h \
+ python/google/protobuf/pyext/extension_dict.cc \
+ python/google/protobuf/pyext/message.h \
+ python/google/protobuf/pyext/message.cc \
+ 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.h \
+ python/google/protobuf/pyext/repeated_composite_container.cc \
+ python/google/protobuf/pyext/repeated_scalar_container.h \
+ python/google/protobuf/pyext/repeated_scalar_container.cc \
+ python/google/protobuf/pyext/scoped_pyobject_ptr.h \
+ python/google/protobuf/pyext/__init__.py \
+ python/google/protobuf/descriptor.py \
+ python/google/protobuf/descriptor_database.py \
+ python/google/protobuf/descriptor_pool.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 \
+ python/google/protobuf/__init__.py \
+ python/google/__init__.py \
+ python/ez_setup.py \
+ python/setup.py \
+ python/mox.py \
+ python/stubout.py \
+ python/README.txt
+
+ruby_EXTRA_DIST= \
+ 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.rb \
+ ruby/tests/basic.rb \
+ ruby/tests/stress.rb \
+ ruby/tests/generated_code.proto \
+ ruby/tests/generated_code.rb \
+ ruby/tests/generated_code_test.rb
+
+all_EXTRA_DIST=$(java_EXTRA_DIST) $(javanano_EXTRA_DIST) $(python_EXTRA_DIST) $(ruby_EXTRA_DIST)
+
+EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
+ autogen.sh \
+ generate_descriptor_proto.sh \
+ README.md \
+ INSTALL.txt \
+ LICENSE \
+ CONTRIBUTORS.txt \
+ CHANGES.txt \
+ config.h.include \
+ editors/README.txt \
+ editors/proto.vim \
+ editors/protobuf-mode.el \
+ vsprojects/config.h \
+ vsprojects/google/protobuf/stubs/pbconfig.h \
+ vsprojects/extract_includes.bat \
+ vsprojects/libprotobuf.vcproj \
+ vsprojects/libprotobuf-lite.vcproj \
+ vsprojects/libprotoc.vcproj \
+ vsprojects/protobuf.sln \
+ vsprojects/protoc.vcproj \
+ vsprojects/readme.txt \
+ vsprojects/test_plugin.vcproj \
+ vsprojects/tests.vcproj \
+ vsprojects/lite-test.vcproj \
+ vsprojects/convert2008to2005.sh \
+ examples/README.txt \
+ examples/Makefile \
+ examples/addressbook.proto \
+ examples/add_person.cc \
+ examples/list_people.cc \
+ examples/AddPerson.java \
+ examples/ListPeople.java \
+ examples/add_person.py \
+ examples/list_people.py
+
+# Deletes all the files generated by autogen.sh.
+MAINTAINERCLEANFILES = \
+ aclocal.m4 \
+ 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
diff --git a/README.md b/README.md
index 7844062..5ea6aff 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,193 @@
-This repo was originally exported from http://code.google.com/p/protobuf-csharp-port,
-and represents the latest "legacy" version of protobuf-csharp-port.
+Protocol Buffers - Google's data interchange format
+===================================================
-This project has now been folded into the [main Google Protocol Buffers project](http://github.com/google/protobuf),
-and is being revamped to support proto3. It is not expected to be fully backwardly-compatible with
-the code in this repo - in particular, some of the C#-specific options may not be supported in the new
-codebase, and some of the generated code may differ. A new major version offers an opportunity to spring-clean,
-as it were.
+[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf)
-This repo exists as an acknowledgement that not everyone will want to immediately use the newer codebase,
-and that they may wish to make changes to the legacy codebase. I do not expect to make any changes within this
-repo, but it can be forked for further changes.
+Copyright 2008 Google Inc.
+
+https://developers.google.com/protocol-buffers/
+
+C++ Installation - Unix
+-----------------------
+
+If you get the source from github, you need to generate the configure script
+first:
+
+ $ ./autogen.sh
+
+This will download gtest source (which is used for C++ Protocol Buffer
+unit-tests) to the current directory and run automake, autoconf, etc.
+to generate the configure script and various template makefiles.
+
+You can skip this step if you are using a release package (which already
+contains gtest and the configure script).
+
+To build and install the C++ Protocol Buffer runtime and the Protocol
+Buffer compiler (protoc) execute the following:
+
+ $ ./configure
+ $ make
+ $ make check
+ $ make install
+
+If "make check" fails, you can still install, but it is likely that
+some features of this library will not work correctly on your system.
+Proceed at your own risk.
+
+"make install" may require superuser privileges.
+
+For advanced usage information on configure and make, see INSTALL.txt.
+
+**Hint on install location**
+
+ By default, the package will be installed to /usr/local. However,
+ on many platforms, /usr/local/lib is not part of LD_LIBRARY_PATH.
+ You can add it, but it may be easier to just install to /usr
+ instead. To do this, invoke configure as follows:
+
+ ./configure --prefix=/usr
+
+ If you already built the package with a different prefix, make sure
+ to run "make clean" before building again.
+
+**Compiling dependent packages**
+
+ To compile a package that uses Protocol Buffers, you need to pass
+ various flags to your compiler and linker. As of version 2.2.0,
+ Protocol Buffers integrates with pkg-config to manage this. If you
+ have pkg-config installed, then you can invoke it to get a list of
+ flags like so:
+
+ pkg-config --cflags protobuf # print compiler flags
+ pkg-config --libs protobuf # print linker flags
+ pkg-config --cflags --libs protobuf # print both
+
+ For example:
+
+ c++ my_program.cc my_proto.pb.cc `pkg-config --cflags --libs protobuf`
+
+ Note that packages written prior to the 2.2.0 release of Protocol
+ Buffers may not yet integrate with pkg-config to get flags, and may
+ not pass the correct set of flags to correctly link against
+ libprotobuf. If the package in question uses autoconf, you can
+ often fix the problem by invoking its configure script like:
+
+ configure CXXFLAGS="$(pkg-config --cflags protobuf)" \
+ LIBS="$(pkg-config --libs protobuf)"
+
+ This will force it to use the correct flags.
+
+ If you are writing an autoconf-based package that uses Protocol
+ Buffers, you should probably use the PKG_CHECK_MODULES macro in your
+ configure script like:
+
+ PKG_CHECK_MODULES([protobuf], [protobuf])
+
+ See the pkg-config man page for more info.
+
+ If you only want protobuf-lite, substitute "protobuf-lite" in place
+ of "protobuf" in these examples.
+
+**Note for Mac users**
+
+ For a Mac system, Unix tools are not available by default. You will first need
+ to install Xcode from the Mac AppStore and then run the following command from
+ a terminal:
+
+ $ sudo xcode-select --install
+
+ To install Unix tools, you can install "port" following the instructions at
+ https://www.macports.org . This will reside in /opt/local/bin/port for most
+ Mac installations.
+
+ $ sudo /opt/local/bin/port install autoconf automake libtool
+
+ Then follow the Unix instructions above.
+
+**Note for cross-compiling**
+
+ The makefiles normally invoke the protoc executable that they just
+ built in order to build tests. When cross-compiling, the protoc
+ executable may not be executable on the host machine. In this case,
+ you must build a copy of protoc for the host machine first, then use
+ the --with-protoc option to tell configure to use it instead. For
+ example:
+
+ ./configure --with-protoc=protoc
+
+ This will use the installed protoc (found in your $PATH) instead of
+ trying to execute the one built during the build process. You can
+ also use an executable that hasn't been installed. For example, if
+ you built the protobuf package for your host machine in ../host,
+ you might do:
+
+ ./configure --with-protoc=../host/src/protoc
+
+ Either way, you must make sure that the protoc executable you use
+ has the same version as the protobuf source code you are trying to
+ use it with.
+
+**Note for Solaris users**
+
+ Solaris 10 x86 has a bug that will make linking fail, complaining
+ about libstdc++.la being invalid. We have included a work-around
+ in this package. To use the work-around, run configure as follows:
+
+ ./configure LDFLAGS=-L$PWD/src/solaris
+
+ See src/solaris/libstdc++.la for more info on this bug.
+
+**Note for HP C++ Tru64 users**
+
+ To compile invoke configure as follows:
+
+ ./configure CXXFLAGS="-O -std ansi -ieee -D__USE_STD_IOSTREAM"
+
+ Also, you will need to use gmake instead of make.
+
+**Note for AIX users**
+
+ Compile using the IBM xlC C++ compiler as follows:
+
+ ./configure CXX=xlC
+
+ Also, you will need to use GNU `make` (`gmake`) instead of AIX `make`.
+
+C++ Installation - Windows
+--------------------------
+
+If you are using Microsoft Visual C++, see vsprojects/readme.txt.
+
+If you are using Cygwin or MinGW, follow the Unix installation
+instructions, above.
+
+Binary Compatibility Warning
+----------------------------
+
+Due to the nature of C++, it is unlikely that any two versions of the
+Protocol Buffers C++ runtime libraries will have compatible ABIs.
+That is, if you linked an executable against an older version of
+libprotobuf, it is unlikely to work with a newer version without
+re-compiling. This problem, when it occurs, will normally be detected
+immediately on startup of your app. Still, you may want to consider
+using static linkage. You can configure this package to install
+static libraries only using:
+
+ ./configure --disable-shared
+
+Java and Python Installation
+----------------------------
+
+The Java and Python runtime libraries for Protocol Buffers are located
+in the java and python directories. See the README file in each
+directory for more information on how to compile and install them.
+Note that both of them require you to first install the Protocol
+Buffer compiler (protoc), which is part of the C++ package.
+
+Usage
+-----
+
+The complete documentation for Protocol Buffers is available via the
+web at:
+
+ https://developers.google.com/protocol-buffers/
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..08966c6
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,43 @@
+#!/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
+
+# 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 gtest is present. Usually it is already there since the
+# directory is set up as an SVN external.
+if test ! -e gtest; then
+ echo "Google Test not present. Fetching gtest-1.7.0 from the web..."
+ curl -O https://googletest.googlecode.com/files/gtest-1.7.0.zip
+ unzip -q gtest-1.7.0.zip
+ rm gtest-1.7.0.zip
+ mv gtest-1.7.0 gtest
+fi
+
+set -ex
+
+# Temporary hack: Must change C runtime library to "multi-threaded DLL",
+# otherwise it will be set to "multi-threaded static" when MSVC upgrades
+# the project file to MSVC 2005/2008. vladl of Google Test says gtest will
+# probably change their default to match, then this will be unnecessary.
+# One of these mappings converts the debug configuration and the other
+# converts the release configuration. I don't know which is which.
+sed -i -e 's/RuntimeLibrary="5"/RuntimeLibrary="3"/g;
+ s/RuntimeLibrary="4"/RuntimeLibrary="2"/g;' gtest/msvc/*.vcproj
+
+# 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
diff --git a/benchmarks/ProtoBench.java b/benchmarks/ProtoBench.java
new file mode 100644
index 0000000..86d62fe
--- /dev/null
+++ b/benchmarks/ProtoBench.java
@@ -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;
+ }
+}
diff --git a/src/ProtoBench/google_message1.dat b/benchmarks/google_message1.dat
similarity index 100%
copy from src/ProtoBench/google_message1.dat
copy to benchmarks/google_message1.dat
Binary files differ
diff --git a/src/ProtoBench/google_message2.dat b/benchmarks/google_message2.dat
similarity index 100%
copy from src/ProtoBench/google_message2.dat
copy to benchmarks/google_message2.dat
Binary files differ
diff --git a/benchmarks/google_size.proto b/benchmarks/google_size.proto
new file mode 100644
index 0000000..3e6fbdb
--- /dev/null
+++ b/benchmarks/google_size.proto
@@ -0,0 +1,136 @@
+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;
+}
diff --git a/benchmarks/google_speed.proto b/benchmarks/google_speed.proto
new file mode 100644
index 0000000..d6cd032
--- /dev/null
+++ b/benchmarks/google_speed.proto
@@ -0,0 +1,136 @@
+package benchmarks;
+
+option java_outer_classname = "GoogleSpeed";
+option optimize_for = SPEED;
+
+message SpeedMessage1 {
+ 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 SpeedMessage1SubMessage 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 SpeedMessage1SubMessage {
+ 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 SpeedMessage2 {
+ 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 SpeedMessage2GroupedMessage 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 SpeedMessage2GroupedMessage {
+ 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;
+}
diff --git a/benchmarks/readme.txt b/benchmarks/readme.txt
new file mode 100644
index 0000000..2c836d0
--- /dev/null
+++ b/benchmarks/readme.txt
@@ -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.
diff --git a/config.h.include b/config.h.include
new file mode 100644
index 0000000..0c557fb
--- /dev/null
+++ b/config.h.include
@@ -0,0 +1,7 @@
+HASH_MAP_CLASS
+HASH_MAP_H
+HASH_NAMESPACE
+HASH_SET_CLASS
+HASH_SET_H
+HAVE_HASH_MAP
+HAVE_HASH_SET
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..14351a8
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,168 @@
+## 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-alpha-3-pre],[protobuf@googlegroups.com],[protobuf])
+
+AM_MAINTAINER_MODE([enable])
+
+AC_CONFIG_SRCDIR(src/google/protobuf/message.cc)
+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 | java | python | javanano | ruby) ;;
+ *) 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
+
+# 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
+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
+
+# HACK: Make gtest's configure script pick up our copy of CFLAGS and CXXFLAGS,
+# since the flags added by ACX_CHECK_SUNCC must be used when compiling gtest
+# too.
+export CFLAGS
+export CXXFLAGS
+AC_CONFIG_SUBDIRS([gtest])
+
+AC_CONFIG_FILES([Makefile src/Makefile protobuf.pc protobuf-lite.pc])
+AC_OUTPUT
diff --git a/csharp/.gitignore b/csharp/.gitignore
new file mode 100644
index 0000000..76c414f
--- /dev/null
+++ b/csharp/.gitignore
@@ -0,0 +1,40 @@
+#
+# Untracked directories
+#
+src/AddressBook/bin
+src/AddressBook/obj
+src/ProtocolBuffers/bin/
+src/ProtocolBuffers/obj/
+src/ProtocolBuffers/objCF
+src/ProtocolBuffers.Test/bin/
+src/ProtocolBuffers.Test/obj/
+src/ProtocolBuffersLite.Test/bin/
+src/ProtocolBuffersLite.Test/obj/
+src/ProtoBench/bin/
+src/ProtoBench/obj/
+src/ProtoDump/bin/
+src/ProtoDump/obj/
+src/ProtoGen/bin/
+src/ProtoGen/obj/
+src/ProtoGen.Test/bin/
+src/ProtoGen.Test/obj/
+src/ProtoMunge/bin/
+src/ProtoMunge/obj/
+mono/bin
+mono/tmp
+mono/protoc
+build_output
+build_temp
+build/msbuild*.log
+
+#
+# Untracked files
+#
+*.user
+*.suo
+_ReSharper.*
+*.sln.cache
+mono/TestResult.xml
+mono/.libs
+mono/*.exe
+mono/*.dll
diff --git a/.hgignore b/csharp/.hgignore
similarity index 100%
rename from .hgignore
rename to csharp/.hgignore
diff --git a/csharp/CHANGES.txt b/csharp/CHANGES.txt
new file mode 100644
index 0000000..90e9d77
--- /dev/null
+++ b/csharp/CHANGES.txt
@@ -0,0 +1,144 @@
+===============================================================================
+Welcome to the C# port of Google Protocol Buffers, written by Jon Skeet
+(skeet@pobox.com) based on the work of many talented people.
+
+For more information about this port, visit its homepage:
+http://protobuf-csharp-port.googlecode.com
+
+For more information about Protocol Buffers in general, visit the project page
+for the C++, Java and Python project:
+http://protobuf.googlecode.com
+===============================================================================
+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 MSBbuild 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
+
+===============================================================================
\ No newline at end of file
diff --git a/csharp/README.md b/csharp/README.md
new file mode 100644
index 0000000..7844062
--- /dev/null
+++ b/csharp/README.md
@@ -0,0 +1,12 @@
+This repo was originally exported from http://code.google.com/p/protobuf-csharp-port,
+and represents the latest "legacy" version of protobuf-csharp-port.
+
+This project has now been folded into the [main Google Protocol Buffers project](http://github.com/google/protobuf),
+and is being revamped to support proto3. It is not expected to be fully backwardly-compatible with
+the code in this repo - in particular, some of the C#-specific options may not be supported in the new
+codebase, and some of the generated code may differ. A new major version offers an opportunity to spring-clean,
+as it were.
+
+This repo exists as an acknowledgement that not everyone will want to immediately use the newer codebase,
+and that they may wish to make changes to the legacy codebase. I do not expect to make any changes within this
+repo, but it can be forked for further changes.
diff --git a/build/BuildAll.bat b/csharp/build/BuildAll.bat
similarity index 100%
rename from build/BuildAll.bat
rename to csharp/build/BuildAll.bat
diff --git a/build/Common.targets b/csharp/build/Common.targets
similarity index 100%
rename from build/Common.targets
rename to csharp/build/Common.targets
diff --git a/build/Google.ProtocolBuffers.nuspec b/csharp/build/Google.ProtocolBuffers.nuspec
similarity index 100%
rename from build/Google.ProtocolBuffers.nuspec
rename to csharp/build/Google.ProtocolBuffers.nuspec
diff --git a/build/Google.ProtocolBuffersLite.nuspec b/csharp/build/Google.ProtocolBuffersLite.nuspec
similarity index 100%
rename from build/Google.ProtocolBuffersLite.nuspec
rename to csharp/build/Google.ProtocolBuffersLite.nuspec
diff --git a/build/RunBenchmarks.bat b/csharp/build/RunBenchmarks.bat
similarity index 100%
rename from build/RunBenchmarks.bat
rename to csharp/build/RunBenchmarks.bat
diff --git a/build/build.bat b/csharp/build/build.bat
similarity index 100%
rename from build/build.bat
rename to csharp/build/build.bat
diff --git a/build/build.csproj b/csharp/build/build.csproj
similarity index 100%
rename from build/build.csproj
rename to csharp/build/build.csproj
diff --git a/build/googlecode_upload.py b/csharp/build/googlecode_upload.py
similarity index 100%
rename from build/googlecode_upload.py
rename to csharp/build/googlecode_upload.py
diff --git a/build/nuspec.xsd b/csharp/build/nuspec.xsd
similarity index 100%
rename from build/nuspec.xsd
rename to csharp/build/nuspec.xsd
diff --git a/build/publish.csproj b/csharp/build/publish.csproj
similarity index 100%
rename from build/publish.csproj
rename to csharp/build/publish.csproj
diff --git a/build/target.csproj b/csharp/build/target.csproj
similarity index 100%
rename from build/target.csproj
rename to csharp/build/target.csproj
diff --git a/csproj_templates/CF20.csproj b/csharp/csproj_templates/CF20.csproj
similarity index 100%
rename from csproj_templates/CF20.csproj
rename to csharp/csproj_templates/CF20.csproj
diff --git a/csproj_templates/CF35.csproj b/csharp/csproj_templates/CF35.csproj
similarity index 100%
rename from csproj_templates/CF35.csproj
rename to csharp/csproj_templates/CF35.csproj
diff --git a/csproj_templates/NET20.csproj b/csharp/csproj_templates/NET20.csproj
similarity index 100%
rename from csproj_templates/NET20.csproj
rename to csharp/csproj_templates/NET20.csproj
diff --git a/csproj_templates/NET35.csproj b/csharp/csproj_templates/NET35.csproj
similarity index 100%
rename from csproj_templates/NET35.csproj
rename to csharp/csproj_templates/NET35.csproj
diff --git a/csproj_templates/NET40.csproj b/csharp/csproj_templates/NET40.csproj
similarity index 100%
rename from csproj_templates/NET40.csproj
rename to csharp/csproj_templates/NET40.csproj
diff --git a/csproj_templates/PL40.csproj b/csharp/csproj_templates/PL40.csproj
similarity index 100%
rename from csproj_templates/PL40.csproj
rename to csharp/csproj_templates/PL40.csproj
diff --git a/csproj_templates/SL20.csproj b/csharp/csproj_templates/SL20.csproj
similarity index 100%
rename from csproj_templates/SL20.csproj
rename to csharp/csproj_templates/SL20.csproj
diff --git a/csproj_templates/SL30.csproj b/csharp/csproj_templates/SL30.csproj
similarity index 100%
rename from csproj_templates/SL30.csproj
rename to csharp/csproj_templates/SL30.csproj
diff --git a/csproj_templates/SL40.csproj b/csharp/csproj_templates/SL40.csproj
similarity index 100%
rename from csproj_templates/SL40.csproj
rename to csharp/csproj_templates/SL40.csproj
diff --git a/csproj_templates/SLTest.targets b/csharp/csproj_templates/SLTest.targets
similarity index 100%
rename from csproj_templates/SLTest.targets
rename to csharp/csproj_templates/SLTest.targets
diff --git a/keys/Google.ProtocolBuffers.snk b/csharp/keys/Google.ProtocolBuffers.snk
similarity index 100%
rename from keys/Google.ProtocolBuffers.snk
rename to csharp/keys/Google.ProtocolBuffers.snk
Binary files differ
diff --git a/keys/generate_new_key.bat b/csharp/keys/generate_new_key.bat
similarity index 100%
rename from keys/generate_new_key.bat
rename to csharp/keys/generate_new_key.bat
diff --git a/lib/7-Zip 9.20/7-zip.chm b/csharp/lib/7-Zip 9.20/7-zip.chm
similarity index 100%
rename from lib/7-Zip 9.20/7-zip.chm
rename to csharp/lib/7-Zip 9.20/7-zip.chm
Binary files differ
diff --git a/lib/7-Zip 9.20/7za.exe b/csharp/lib/7-Zip 9.20/7za.exe
similarity index 100%
rename from lib/7-Zip 9.20/7za.exe
rename to csharp/lib/7-Zip 9.20/7za.exe
Binary files differ
diff --git a/lib/7-Zip 9.20/license.txt b/csharp/lib/7-Zip 9.20/license.txt
similarity index 100%
rename from lib/7-Zip 9.20/license.txt
rename to csharp/lib/7-Zip 9.20/license.txt
diff --git a/lib/7-Zip 9.20/readme.txt b/csharp/lib/7-Zip 9.20/readme.txt
similarity index 100%
rename from lib/7-Zip 9.20/readme.txt
rename to csharp/lib/7-Zip 9.20/readme.txt
diff --git a/lib/CsProjectProjector/CsProjectProjector.exe b/csharp/lib/CsProjectProjector/CsProjectProjector.exe
similarity index 100%
rename from lib/CsProjectProjector/CsProjectProjector.exe
rename to csharp/lib/CsProjectProjector/CsProjectProjector.exe
Binary files differ
diff --git a/lib/Microsoft.Silverlight.Testing/April2010/EULA.rtf b/csharp/lib/Microsoft.Silverlight.Testing/April2010/EULA.rtf
similarity index 100%
rename from lib/Microsoft.Silverlight.Testing/April2010/EULA.rtf
rename to csharp/lib/Microsoft.Silverlight.Testing/April2010/EULA.rtf
Binary files differ
diff --git a/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.Silverlight.Testing.dll b/csharp/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.Silverlight.Testing.dll
similarity index 100%
rename from lib/Microsoft.Silverlight.Testing/April2010/Microsoft.Silverlight.Testing.dll
rename to csharp/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.Silverlight.Testing.dll
Binary files differ
diff --git a/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.Silverlight.Testing.extmap.xml b/csharp/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.Silverlight.Testing.extmap.xml
similarity index 100%
rename from lib/Microsoft.Silverlight.Testing/April2010/Microsoft.Silverlight.Testing.extmap.xml
rename to csharp/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.Silverlight.Testing.extmap.xml
diff --git a/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.Silverlight.Testing.pdb b/csharp/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.Silverlight.Testing.pdb
similarity index 100%
rename from lib/Microsoft.Silverlight.Testing/April2010/Microsoft.Silverlight.Testing.pdb
rename to csharp/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.Silverlight.Testing.pdb
Binary files differ
diff --git a/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.Silverlight.Testing.xml b/csharp/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.Silverlight.Testing.xml
similarity index 100%
rename from lib/Microsoft.Silverlight.Testing/April2010/Microsoft.Silverlight.Testing.xml
rename to csharp/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.Silverlight.Testing.xml
diff --git a/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll b/csharp/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll
similarity index 100%
rename from lib/Microsoft.Silverlight.Testing/April2010/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll
rename to csharp/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll
Binary files differ
diff --git a/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.extmap.xml b/csharp/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.extmap.xml
similarity index 100%
rename from lib/Microsoft.Silverlight.Testing/April2010/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.extmap.xml
rename to csharp/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.extmap.xml
diff --git a/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.pdb b/csharp/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.pdb
similarity index 100%
rename from lib/Microsoft.Silverlight.Testing/April2010/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.pdb
rename to csharp/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.pdb
Binary files differ
diff --git a/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.xml b/csharp/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.xml
similarity index 100%
rename from lib/Microsoft.Silverlight.Testing/April2010/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.xml
rename to csharp/lib/Microsoft.Silverlight.Testing/April2010/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.xml
diff --git a/lib/NUnit-config/Microsoft.VisualStudio.TestTools.cs b/csharp/lib/NUnit-config/Microsoft.VisualStudio.TestTools.cs
similarity index 100%
rename from lib/NUnit-config/Microsoft.VisualStudio.TestTools.cs
rename to csharp/lib/NUnit-config/Microsoft.VisualStudio.TestTools.cs
diff --git a/lib/NUnit-config/nunit-console.v2.0.config b/csharp/lib/NUnit-config/nunit-console.v2.0.config
similarity index 100%
rename from lib/NUnit-config/nunit-console.v2.0.config
rename to csharp/lib/NUnit-config/nunit-console.v2.0.config
diff --git a/lib/NUnit-config/nunit-console.v3.5.config b/csharp/lib/NUnit-config/nunit-console.v3.5.config
similarity index 100%
rename from lib/NUnit-config/nunit-console.v3.5.config
rename to csharp/lib/NUnit-config/nunit-console.v3.5.config
diff --git a/lib/NUnit-config/nunit-console.v4.0.config b/csharp/lib/NUnit-config/nunit-console.v4.0.config
similarity index 100%
rename from lib/NUnit-config/nunit-console.v4.0.config
rename to csharp/lib/NUnit-config/nunit-console.v4.0.config
diff --git a/lib/NUnit/Logo.ico b/csharp/lib/NUnit/Logo.ico
similarity index 100%
rename from lib/NUnit/Logo.ico
rename to csharp/lib/NUnit/Logo.ico
Binary files differ
diff --git a/lib/NUnit/NUnit.nupkg b/csharp/lib/NUnit/NUnit.nupkg
similarity index 100%
rename from lib/NUnit/NUnit.nupkg
rename to csharp/lib/NUnit/NUnit.nupkg
Binary files differ
diff --git a/lib/NUnit/NUnitFitTests.html b/csharp/lib/NUnit/NUnitFitTests.html
similarity index 100%
rename from lib/NUnit/NUnitFitTests.html
rename to csharp/lib/NUnit/NUnitFitTests.html
diff --git a/lib/NUnit/fit-license.txt b/csharp/lib/NUnit/fit-license.txt
similarity index 100%
rename from lib/NUnit/fit-license.txt
rename to csharp/lib/NUnit/fit-license.txt
Binary files differ
diff --git a/lib/NUnit/lib/nunit.framework.dll b/csharp/lib/NUnit/lib/nunit.framework.dll
similarity index 100%
rename from lib/NUnit/lib/nunit.framework.dll
rename to csharp/lib/NUnit/lib/nunit.framework.dll
Binary files differ
diff --git a/lib/NUnit/lib/nunit.framework.xml b/csharp/lib/NUnit/lib/nunit.framework.xml
similarity index 100%
rename from lib/NUnit/lib/nunit.framework.xml
rename to csharp/lib/NUnit/lib/nunit.framework.xml
diff --git a/lib/NUnit/lib/nunit.mocks.dll b/csharp/lib/NUnit/lib/nunit.mocks.dll
similarity index 100%
rename from lib/NUnit/lib/nunit.mocks.dll
rename to csharp/lib/NUnit/lib/nunit.mocks.dll
Binary files differ
diff --git a/lib/NUnit/lib/pnunit.framework.dll b/csharp/lib/NUnit/lib/pnunit.framework.dll
similarity index 100%
rename from lib/NUnit/lib/pnunit.framework.dll
rename to csharp/lib/NUnit/lib/pnunit.framework.dll
Binary files differ
diff --git a/lib/NUnit/license.txt b/csharp/lib/NUnit/license.txt
similarity index 100%
rename from lib/NUnit/license.txt
rename to csharp/lib/NUnit/license.txt
diff --git a/lib/NUnit/tools/NUnitTests.VisualState.xml b/csharp/lib/NUnit/tools/NUnitTests.VisualState.xml
similarity index 100%
rename from lib/NUnit/tools/NUnitTests.VisualState.xml
rename to csharp/lib/NUnit/tools/NUnitTests.VisualState.xml
diff --git a/lib/NUnit/tools/NUnitTests.config b/csharp/lib/NUnit/tools/NUnitTests.config
similarity index 100%
rename from lib/NUnit/tools/NUnitTests.config
rename to csharp/lib/NUnit/tools/NUnitTests.config
diff --git a/lib/NUnit/tools/NUnitTests.nunit b/csharp/lib/NUnit/tools/NUnitTests.nunit
similarity index 100%
rename from lib/NUnit/tools/NUnitTests.nunit
rename to csharp/lib/NUnit/tools/NUnitTests.nunit
diff --git a/lib/NUnit/tools/TestResult.xml b/csharp/lib/NUnit/tools/TestResult.xml
similarity index 100%
rename from lib/NUnit/tools/TestResult.xml
rename to csharp/lib/NUnit/tools/TestResult.xml
diff --git a/lib/NUnit/tools/agent.conf b/csharp/lib/NUnit/tools/agent.conf
similarity index 100%
rename from lib/NUnit/tools/agent.conf
rename to csharp/lib/NUnit/tools/agent.conf
diff --git a/lib/NUnit/tools/agent.log.conf b/csharp/lib/NUnit/tools/agent.log.conf
similarity index 100%
rename from lib/NUnit/tools/agent.log.conf
rename to csharp/lib/NUnit/tools/agent.log.conf
diff --git a/lib/NUnit/tools/launcher.log.conf b/csharp/lib/NUnit/tools/launcher.log.conf
similarity index 100%
rename from lib/NUnit/tools/launcher.log.conf
rename to csharp/lib/NUnit/tools/launcher.log.conf
diff --git a/lib/NUnit/tools/lib/Failure.png b/csharp/lib/NUnit/tools/lib/Failure.png
similarity index 100%
rename from lib/NUnit/tools/lib/Failure.png
rename to csharp/lib/NUnit/tools/lib/Failure.png
Binary files differ
diff --git a/lib/NUnit/tools/lib/Ignored.png b/csharp/lib/NUnit/tools/lib/Ignored.png
similarity index 100%
rename from lib/NUnit/tools/lib/Ignored.png
rename to csharp/lib/NUnit/tools/lib/Ignored.png
Binary files differ
diff --git a/lib/NUnit/tools/lib/Inconclusive.png b/csharp/lib/NUnit/tools/lib/Inconclusive.png
similarity index 100%
rename from lib/NUnit/tools/lib/Inconclusive.png
rename to csharp/lib/NUnit/tools/lib/Inconclusive.png
Binary files differ
diff --git a/lib/NUnit/tools/lib/Skipped.png b/csharp/lib/NUnit/tools/lib/Skipped.png
similarity index 100%
rename from lib/NUnit/tools/lib/Skipped.png
rename to csharp/lib/NUnit/tools/lib/Skipped.png
Binary files differ
diff --git a/lib/NUnit/tools/lib/Success.png b/csharp/lib/NUnit/tools/lib/Success.png
similarity index 100%
rename from lib/NUnit/tools/lib/Success.png
rename to csharp/lib/NUnit/tools/lib/Success.png
Binary files differ
diff --git a/lib/NUnit/tools/lib/fit.dll b/csharp/lib/NUnit/tools/lib/fit.dll
similarity index 100%
rename from lib/NUnit/tools/lib/fit.dll
rename to csharp/lib/NUnit/tools/lib/fit.dll
Binary files differ
diff --git a/lib/NUnit/tools/lib/log4net.dll b/csharp/lib/NUnit/tools/lib/log4net.dll
similarity index 100%
rename from lib/NUnit/tools/lib/log4net.dll
rename to csharp/lib/NUnit/tools/lib/log4net.dll
Binary files differ
diff --git a/lib/NUnit/tools/lib/nunit-console-runner.dll b/csharp/lib/NUnit/tools/lib/nunit-console-runner.dll
similarity index 100%
rename from lib/NUnit/tools/lib/nunit-console-runner.dll
rename to csharp/lib/NUnit/tools/lib/nunit-console-runner.dll
Binary files differ
diff --git a/lib/NUnit/tools/lib/nunit-gui-runner.dll b/csharp/lib/NUnit/tools/lib/nunit-gui-runner.dll
similarity index 100%
rename from lib/NUnit/tools/lib/nunit-gui-runner.dll
rename to csharp/lib/NUnit/tools/lib/nunit-gui-runner.dll
Binary files differ
diff --git a/lib/NUnit/tools/lib/nunit.core.dll b/csharp/lib/NUnit/tools/lib/nunit.core.dll
similarity index 100%
rename from lib/NUnit/tools/lib/nunit.core.dll
rename to csharp/lib/NUnit/tools/lib/nunit.core.dll
Binary files differ
diff --git a/lib/NUnit/tools/lib/nunit.core.interfaces.dll b/csharp/lib/NUnit/tools/lib/nunit.core.interfaces.dll
similarity index 100%
rename from lib/NUnit/tools/lib/nunit.core.interfaces.dll
rename to csharp/lib/NUnit/tools/lib/nunit.core.interfaces.dll
Binary files differ
diff --git a/lib/NUnit/tools/lib/nunit.fixtures.dll b/csharp/lib/NUnit/tools/lib/nunit.fixtures.dll
similarity index 100%
rename from lib/NUnit/tools/lib/nunit.fixtures.dll
rename to csharp/lib/NUnit/tools/lib/nunit.fixtures.dll
Binary files differ
diff --git a/lib/NUnit/tools/lib/nunit.uiexception.dll b/csharp/lib/NUnit/tools/lib/nunit.uiexception.dll
similarity index 100%
rename from lib/NUnit/tools/lib/nunit.uiexception.dll
rename to csharp/lib/NUnit/tools/lib/nunit.uiexception.dll
Binary files differ
diff --git a/lib/NUnit/tools/lib/nunit.uikit.dll b/csharp/lib/NUnit/tools/lib/nunit.uikit.dll
similarity index 100%
rename from lib/NUnit/tools/lib/nunit.uikit.dll
rename to csharp/lib/NUnit/tools/lib/nunit.uikit.dll
Binary files differ
diff --git a/lib/NUnit/tools/lib/nunit.util.dll b/csharp/lib/NUnit/tools/lib/nunit.util.dll
similarity index 100%
rename from lib/NUnit/tools/lib/nunit.util.dll
rename to csharp/lib/NUnit/tools/lib/nunit.util.dll
Binary files differ
diff --git a/lib/NUnit/tools/nunit-agent-x86.exe b/csharp/lib/NUnit/tools/nunit-agent-x86.exe
similarity index 100%
rename from lib/NUnit/tools/nunit-agent-x86.exe
rename to csharp/lib/NUnit/tools/nunit-agent-x86.exe
Binary files differ
diff --git a/lib/NUnit/tools/nunit-agent-x86.exe.config b/csharp/lib/NUnit/tools/nunit-agent-x86.exe.config
similarity index 100%
rename from lib/NUnit/tools/nunit-agent-x86.exe.config
rename to csharp/lib/NUnit/tools/nunit-agent-x86.exe.config
diff --git a/lib/NUnit/tools/nunit-agent.exe b/csharp/lib/NUnit/tools/nunit-agent.exe
similarity index 100%
rename from lib/NUnit/tools/nunit-agent.exe
rename to csharp/lib/NUnit/tools/nunit-agent.exe
Binary files differ
diff --git a/lib/NUnit/tools/nunit-agent.exe.config b/csharp/lib/NUnit/tools/nunit-agent.exe.config
similarity index 100%
rename from lib/NUnit/tools/nunit-agent.exe.config
rename to csharp/lib/NUnit/tools/nunit-agent.exe.config
diff --git a/lib/NUnit/tools/nunit-console-x86.exe b/csharp/lib/NUnit/tools/nunit-console-x86.exe
similarity index 100%
rename from lib/NUnit/tools/nunit-console-x86.exe
rename to csharp/lib/NUnit/tools/nunit-console-x86.exe
Binary files differ
diff --git a/lib/NUnit/tools/nunit-console-x86.exe.config b/csharp/lib/NUnit/tools/nunit-console-x86.exe.config
similarity index 100%
rename from lib/NUnit/tools/nunit-console-x86.exe.config
rename to csharp/lib/NUnit/tools/nunit-console-x86.exe.config
diff --git a/lib/NUnit/tools/nunit-console.exe b/csharp/lib/NUnit/tools/nunit-console.exe
similarity index 100%
rename from lib/NUnit/tools/nunit-console.exe
rename to csharp/lib/NUnit/tools/nunit-console.exe
Binary files differ
diff --git a/lib/NUnit/tools/nunit-x86.exe b/csharp/lib/NUnit/tools/nunit-x86.exe
similarity index 100%
rename from lib/NUnit/tools/nunit-x86.exe
rename to csharp/lib/NUnit/tools/nunit-x86.exe
Binary files differ
diff --git a/lib/NUnit/tools/nunit-x86.exe.config b/csharp/lib/NUnit/tools/nunit-x86.exe.config
similarity index 100%
rename from lib/NUnit/tools/nunit-x86.exe.config
rename to csharp/lib/NUnit/tools/nunit-x86.exe.config
diff --git a/lib/NUnit/tools/nunit.exe b/csharp/lib/NUnit/tools/nunit.exe
similarity index 100%
rename from lib/NUnit/tools/nunit.exe
rename to csharp/lib/NUnit/tools/nunit.exe
Binary files differ
diff --git a/lib/NUnit/tools/nunit.exe.config b/csharp/lib/NUnit/tools/nunit.exe.config
similarity index 100%
rename from lib/NUnit/tools/nunit.exe.config
rename to csharp/lib/NUnit/tools/nunit.exe.config
diff --git a/lib/NUnit/tools/nunit.framework.dll b/csharp/lib/NUnit/tools/nunit.framework.dll
similarity index 100%
rename from lib/NUnit/tools/nunit.framework.dll
rename to csharp/lib/NUnit/tools/nunit.framework.dll
Binary files differ
diff --git a/lib/NUnit/tools/pnunit-agent.exe b/csharp/lib/NUnit/tools/pnunit-agent.exe
similarity index 100%
rename from lib/NUnit/tools/pnunit-agent.exe
rename to csharp/lib/NUnit/tools/pnunit-agent.exe
Binary files differ
diff --git a/lib/NUnit/tools/pnunit-agent.exe.config b/csharp/lib/NUnit/tools/pnunit-agent.exe.config
similarity index 100%
rename from lib/NUnit/tools/pnunit-agent.exe.config
rename to csharp/lib/NUnit/tools/pnunit-agent.exe.config
diff --git a/lib/NUnit/tools/pnunit-launcher.exe b/csharp/lib/NUnit/tools/pnunit-launcher.exe
similarity index 100%
rename from lib/NUnit/tools/pnunit-launcher.exe
rename to csharp/lib/NUnit/tools/pnunit-launcher.exe
Binary files differ
diff --git a/lib/NUnit/tools/pnunit-launcher.exe.config b/csharp/lib/NUnit/tools/pnunit-launcher.exe.config
similarity index 100%
rename from lib/NUnit/tools/pnunit-launcher.exe.config
rename to csharp/lib/NUnit/tools/pnunit-launcher.exe.config
diff --git a/lib/NUnit/tools/pnunit.framework.dll b/csharp/lib/NUnit/tools/pnunit.framework.dll
similarity index 100%
rename from lib/NUnit/tools/pnunit.framework.dll
rename to csharp/lib/NUnit/tools/pnunit.framework.dll
Binary files differ
diff --git a/lib/NUnit/tools/pnunit.tests.dll b/csharp/lib/NUnit/tools/pnunit.tests.dll
similarity index 100%
rename from lib/NUnit/tools/pnunit.tests.dll
rename to csharp/lib/NUnit/tools/pnunit.tests.dll
Binary files differ
diff --git a/lib/NUnit/tools/runFile.exe b/csharp/lib/NUnit/tools/runFile.exe
similarity index 100%
rename from lib/NUnit/tools/runFile.exe
rename to csharp/lib/NUnit/tools/runFile.exe
Binary files differ
diff --git a/lib/NUnit/tools/runFile.exe.config b/csharp/lib/NUnit/tools/runFile.exe.config
similarity index 100%
rename from lib/NUnit/tools/runFile.exe.config
rename to csharp/lib/NUnit/tools/runFile.exe.config
diff --git a/lib/NUnit/tools/runpnunit.bat b/csharp/lib/NUnit/tools/runpnunit.bat
similarity index 100%
rename from lib/NUnit/tools/runpnunit.bat
rename to csharp/lib/NUnit/tools/runpnunit.bat
diff --git a/lib/NUnit/tools/test.conf b/csharp/lib/NUnit/tools/test.conf
similarity index 100%
rename from lib/NUnit/tools/test.conf
rename to csharp/lib/NUnit/tools/test.conf
diff --git a/lib/NuGet.exe b/csharp/lib/NuGet.exe
similarity index 100%
rename from lib/NuGet.exe
rename to csharp/lib/NuGet.exe
Binary files differ
diff --git a/lib/StampVersion.License.txt b/csharp/lib/StampVersion.License.txt
similarity index 100%
rename from lib/StampVersion.License.txt
rename to csharp/lib/StampVersion.License.txt
diff --git a/lib/StampVersion.exe b/csharp/lib/StampVersion.exe
similarity index 100%
rename from lib/StampVersion.exe
rename to csharp/lib/StampVersion.exe
Binary files differ
diff --git a/lib/StatLight/StatLight.nupkg b/csharp/lib/StatLight/StatLight.nupkg
similarity index 100%
rename from lib/StatLight/StatLight.nupkg
rename to csharp/lib/StatLight/StatLight.nupkg
Binary files differ
diff --git a/lib/StatLight/tools/Ionic.Zip.Reduced.dll b/csharp/lib/StatLight/tools/Ionic.Zip.Reduced.dll
similarity index 100%
rename from lib/StatLight/tools/Ionic.Zip.Reduced.dll
rename to csharp/lib/StatLight/tools/Ionic.Zip.Reduced.dll
Binary files differ
diff --git a/lib/StatLight/tools/Microsoft.Silverlight.Testing.License.txt b/csharp/lib/StatLight/tools/Microsoft.Silverlight.Testing.License.txt
similarity index 100%
rename from lib/StatLight/tools/Microsoft.Silverlight.Testing.License.txt
rename to csharp/lib/StatLight/tools/Microsoft.Silverlight.Testing.License.txt
diff --git a/lib/StatLight/tools/StatLight.Client.For.April2010.xap b/csharp/lib/StatLight/tools/StatLight.Client.For.April2010.xap
similarity index 100%
rename from lib/StatLight/tools/StatLight.Client.For.April2010.xap
rename to csharp/lib/StatLight/tools/StatLight.Client.For.April2010.xap
Binary files differ
diff --git a/lib/StatLight/tools/StatLight.Client.For.Feb2011.xap b/csharp/lib/StatLight/tools/StatLight.Client.For.Feb2011.xap
similarity index 100%
rename from lib/StatLight/tools/StatLight.Client.For.Feb2011.xap
rename to csharp/lib/StatLight/tools/StatLight.Client.For.Feb2011.xap
Binary files differ
diff --git a/lib/StatLight/tools/StatLight.Client.For.July2009.xap b/csharp/lib/StatLight/tools/StatLight.Client.For.July2009.xap
similarity index 100%
rename from lib/StatLight/tools/StatLight.Client.For.July2009.xap
rename to csharp/lib/StatLight/tools/StatLight.Client.For.July2009.xap
Binary files differ
diff --git a/lib/StatLight/tools/StatLight.Client.For.June2011.xap b/csharp/lib/StatLight/tools/StatLight.Client.For.June2011.xap
similarity index 100%
rename from lib/StatLight/tools/StatLight.Client.For.June2011.xap
rename to csharp/lib/StatLight/tools/StatLight.Client.For.June2011.xap
Binary files differ
diff --git a/lib/StatLight/tools/StatLight.Client.For.March2010.xap b/csharp/lib/StatLight/tools/StatLight.Client.For.March2010.xap
similarity index 100%
rename from lib/StatLight/tools/StatLight.Client.For.March2010.xap
rename to csharp/lib/StatLight/tools/StatLight.Client.For.March2010.xap
Binary files differ
diff --git a/lib/StatLight/tools/StatLight.Client.For.May2010.xap b/csharp/lib/StatLight/tools/StatLight.Client.For.May2010.xap
similarity index 100%
rename from lib/StatLight/tools/StatLight.Client.For.May2010.xap
rename to csharp/lib/StatLight/tools/StatLight.Client.For.May2010.xap
Binary files differ
diff --git a/lib/StatLight/tools/StatLight.Client.For.November2009.xap b/csharp/lib/StatLight/tools/StatLight.Client.For.November2009.xap
similarity index 100%
rename from lib/StatLight/tools/StatLight.Client.For.November2009.xap
rename to csharp/lib/StatLight/tools/StatLight.Client.For.November2009.xap
Binary files differ
diff --git a/lib/StatLight/tools/StatLight.Client.For.October2009.xap b/csharp/lib/StatLight/tools/StatLight.Client.For.October2009.xap
similarity index 100%
rename from lib/StatLight/tools/StatLight.Client.For.October2009.xap
rename to csharp/lib/StatLight/tools/StatLight.Client.For.October2009.xap
Binary files differ
diff --git a/lib/StatLight/tools/StatLight.Client.For.UnitDrivenDecember2009.xap b/csharp/lib/StatLight/tools/StatLight.Client.For.UnitDrivenDecember2009.xap
similarity index 100%
rename from lib/StatLight/tools/StatLight.Client.For.UnitDrivenDecember2009.xap
rename to csharp/lib/StatLight/tools/StatLight.Client.For.UnitDrivenDecember2009.xap
Binary files differ
diff --git a/lib/StatLight/tools/StatLight.Client.For.XUnitContribApril2011.xap b/csharp/lib/StatLight/tools/StatLight.Client.For.XUnitContribApril2011.xap
similarity index 100%
rename from lib/StatLight/tools/StatLight.Client.For.XUnitContribApril2011.xap
rename to csharp/lib/StatLight/tools/StatLight.Client.For.XUnitContribApril2011.xap
Binary files differ
diff --git a/lib/StatLight/tools/StatLight.Core.dll b/csharp/lib/StatLight/tools/StatLight.Core.dll
similarity index 100%
rename from lib/StatLight/tools/StatLight.Core.dll
rename to csharp/lib/StatLight/tools/StatLight.Core.dll
Binary files differ
diff --git a/lib/StatLight/tools/StatLight.EULA.txt b/csharp/lib/StatLight/tools/StatLight.EULA.txt
similarity index 100%
rename from lib/StatLight/tools/StatLight.EULA.txt
rename to csharp/lib/StatLight/tools/StatLight.EULA.txt
diff --git a/lib/StatLight/tools/StatLight.exe b/csharp/lib/StatLight/tools/StatLight.exe
similarity index 100%
rename from lib/StatLight/tools/StatLight.exe
rename to csharp/lib/StatLight/tools/StatLight.exe
Binary files differ
diff --git a/lib/protoc-license.txt b/csharp/lib/protoc-license.txt
similarity index 100%
rename from lib/protoc-license.txt
rename to csharp/lib/protoc-license.txt
diff --git a/lib/protoc.exe b/csharp/lib/protoc.exe
similarity index 100%
rename from lib/protoc.exe
rename to csharp/lib/protoc.exe
Binary files differ
diff --git a/license.txt b/csharp/license.txt
similarity index 100%
rename from license.txt
rename to csharp/license.txt
diff --git a/mono/buildall.sh b/csharp/mono/buildall.sh
similarity index 100%
rename from mono/buildall.sh
rename to csharp/mono/buildall.sh
diff --git a/mono/generatesource.sh b/csharp/mono/generatesource.sh
similarity index 100%
rename from mono/generatesource.sh
rename to csharp/mono/generatesource.sh
diff --git a/mono/readme.txt b/csharp/mono/readme.txt
similarity index 100%
rename from mono/readme.txt
rename to csharp/mono/readme.txt
diff --git a/protos/benchmarks/google_size.proto b/csharp/protos/benchmarks/google_size.proto
similarity index 100%
rename from protos/benchmarks/google_size.proto
rename to csharp/protos/benchmarks/google_size.proto
diff --git a/protos/benchmarks/google_speed.proto b/csharp/protos/benchmarks/google_speed.proto
similarity index 100%
rename from protos/benchmarks/google_speed.proto
rename to csharp/protos/benchmarks/google_speed.proto
diff --git a/protos/extest/unittest_extras.proto b/csharp/protos/extest/unittest_extras.proto
similarity index 100%
rename from protos/extest/unittest_extras.proto
rename to csharp/protos/extest/unittest_extras.proto
diff --git a/protos/extest/unittest_extras_full.proto b/csharp/protos/extest/unittest_extras_full.proto
similarity index 100%
rename from protos/extest/unittest_extras_full.proto
rename to csharp/protos/extest/unittest_extras_full.proto
diff --git a/protos/extest/unittest_extras_lite.proto b/csharp/protos/extest/unittest_extras_lite.proto
similarity index 100%
rename from protos/extest/unittest_extras_lite.proto
rename to csharp/protos/extest/unittest_extras_lite.proto
diff --git a/protos/extest/unittest_extras_xmltest.proto b/csharp/protos/extest/unittest_extras_xmltest.proto
similarity index 100%
rename from protos/extest/unittest_extras_xmltest.proto
rename to csharp/protos/extest/unittest_extras_xmltest.proto
diff --git a/protos/extest/unittest_generic_services.proto b/csharp/protos/extest/unittest_generic_services.proto
similarity index 100%
rename from protos/extest/unittest_generic_services.proto
rename to csharp/protos/extest/unittest_generic_services.proto
diff --git a/protos/extest/unittest_issues.proto b/csharp/protos/extest/unittest_issues.proto
similarity index 100%
rename from protos/extest/unittest_issues.proto
rename to csharp/protos/extest/unittest_issues.proto
diff --git a/protos/extest/unittest_rpc_interop.proto b/csharp/protos/extest/unittest_rpc_interop.proto
similarity index 100%
rename from protos/extest/unittest_rpc_interop.proto
rename to csharp/protos/extest/unittest_rpc_interop.proto
diff --git a/protos/extest/unittest_rpc_interop_lite.proto b/csharp/protos/extest/unittest_rpc_interop_lite.proto
similarity index 100%
rename from protos/extest/unittest_rpc_interop_lite.proto
rename to csharp/protos/extest/unittest_rpc_interop_lite.proto
diff --git a/protos/google/protobuf/compiler/plugin.proto b/csharp/protos/google/protobuf/compiler/plugin.proto
similarity index 100%
rename from protos/google/protobuf/compiler/plugin.proto
rename to csharp/protos/google/protobuf/compiler/plugin.proto
diff --git a/protos/google/protobuf/csharp_options.proto b/csharp/protos/google/protobuf/csharp_options.proto
similarity index 100%
rename from protos/google/protobuf/csharp_options.proto
rename to csharp/protos/google/protobuf/csharp_options.proto
diff --git a/protos/google/protobuf/descriptor.proto b/csharp/protos/google/protobuf/descriptor.proto
similarity index 100%
rename from protos/google/protobuf/descriptor.proto
rename to csharp/protos/google/protobuf/descriptor.proto
diff --git a/protos/google/protobuf/unittest.proto b/csharp/protos/google/protobuf/unittest.proto
similarity index 100%
rename from protos/google/protobuf/unittest.proto
rename to csharp/protos/google/protobuf/unittest.proto
diff --git a/protos/google/protobuf/unittest_csharp_options.proto b/csharp/protos/google/protobuf/unittest_csharp_options.proto
similarity index 100%
rename from protos/google/protobuf/unittest_csharp_options.proto
rename to csharp/protos/google/protobuf/unittest_csharp_options.proto
diff --git a/protos/google/protobuf/unittest_custom_options.proto b/csharp/protos/google/protobuf/unittest_custom_options.proto
similarity index 100%
rename from protos/google/protobuf/unittest_custom_options.proto
rename to csharp/protos/google/protobuf/unittest_custom_options.proto
diff --git a/protos/google/protobuf/unittest_embed_optimize_for.proto b/csharp/protos/google/protobuf/unittest_embed_optimize_for.proto
similarity index 100%
rename from protos/google/protobuf/unittest_embed_optimize_for.proto
rename to csharp/protos/google/protobuf/unittest_embed_optimize_for.proto
diff --git a/protos/google/protobuf/unittest_empty.proto b/csharp/protos/google/protobuf/unittest_empty.proto
similarity index 100%
rename from protos/google/protobuf/unittest_empty.proto
rename to csharp/protos/google/protobuf/unittest_empty.proto
diff --git a/protos/google/protobuf/unittest_enormous_descriptor.proto b/csharp/protos/google/protobuf/unittest_enormous_descriptor.proto
similarity index 100%
rename from protos/google/protobuf/unittest_enormous_descriptor.proto
rename to csharp/protos/google/protobuf/unittest_enormous_descriptor.proto
diff --git a/protos/google/protobuf/unittest_import.proto b/csharp/protos/google/protobuf/unittest_import.proto
similarity index 100%
rename from protos/google/protobuf/unittest_import.proto
rename to csharp/protos/google/protobuf/unittest_import.proto
diff --git a/protos/google/protobuf/unittest_import_lite.proto b/csharp/protos/google/protobuf/unittest_import_lite.proto
similarity index 100%
rename from protos/google/protobuf/unittest_import_lite.proto
rename to csharp/protos/google/protobuf/unittest_import_lite.proto
diff --git a/protos/google/protobuf/unittest_lite.proto b/csharp/protos/google/protobuf/unittest_lite.proto
similarity index 100%
rename from protos/google/protobuf/unittest_lite.proto
rename to csharp/protos/google/protobuf/unittest_lite.proto
diff --git a/protos/google/protobuf/unittest_lite_imports_nonlite.proto b/csharp/protos/google/protobuf/unittest_lite_imports_nonlite.proto
similarity index 100%
rename from protos/google/protobuf/unittest_lite_imports_nonlite.proto
rename to csharp/protos/google/protobuf/unittest_lite_imports_nonlite.proto
diff --git a/protos/google/protobuf/unittest_mset.proto b/csharp/protos/google/protobuf/unittest_mset.proto
similarity index 100%
rename from protos/google/protobuf/unittest_mset.proto
rename to csharp/protos/google/protobuf/unittest_mset.proto
diff --git a/protos/google/protobuf/unittest_no_generic_services.proto b/csharp/protos/google/protobuf/unittest_no_generic_services.proto
similarity index 100%
rename from protos/google/protobuf/unittest_no_generic_services.proto
rename to csharp/protos/google/protobuf/unittest_no_generic_services.proto
diff --git a/protos/google/protobuf/unittest_optimize_for.proto b/csharp/protos/google/protobuf/unittest_optimize_for.proto
similarity index 100%
rename from protos/google/protobuf/unittest_optimize_for.proto
rename to csharp/protos/google/protobuf/unittest_optimize_for.proto
diff --git a/protos/google/test/google_size.proto b/csharp/protos/google/test/google_size.proto
similarity index 100%
rename from protos/google/test/google_size.proto
rename to csharp/protos/google/test/google_size.proto
diff --git a/protos/google/test/google_speed.proto b/csharp/protos/google/test/google_speed.proto
similarity index 100%
rename from protos/google/test/google_speed.proto
rename to csharp/protos/google/test/google_speed.proto
diff --git a/protos/npp.language.xml b/csharp/protos/npp.language.xml
similarity index 100%
rename from protos/npp.language.xml
rename to csharp/protos/npp.language.xml
diff --git a/protos/tutorial/addressbook.proto b/csharp/protos/tutorial/addressbook.proto
similarity index 100%
rename from protos/tutorial/addressbook.proto
rename to csharp/protos/tutorial/addressbook.proto
diff --git a/src/AddressBook/AddPerson.cs b/csharp/src/AddressBook/AddPerson.cs
similarity index 100%
rename from src/AddressBook/AddPerson.cs
rename to csharp/src/AddressBook/AddPerson.cs
diff --git a/src/AddressBook/AddressBook.csproj b/csharp/src/AddressBook/AddressBook.csproj
similarity index 100%
rename from src/AddressBook/AddressBook.csproj
rename to csharp/src/AddressBook/AddressBook.csproj
diff --git a/src/AddressBook/AddressBookProtos.cs b/csharp/src/AddressBook/AddressBookProtos.cs
similarity index 100%
rename from src/AddressBook/AddressBookProtos.cs
rename to csharp/src/AddressBook/AddressBookProtos.cs
diff --git a/src/AddressBook/ListPeople.cs b/csharp/src/AddressBook/ListPeople.cs
similarity index 100%
rename from src/AddressBook/ListPeople.cs
rename to csharp/src/AddressBook/ListPeople.cs
diff --git a/src/AddressBook/Program.cs b/csharp/src/AddressBook/Program.cs
similarity index 100%
rename from src/AddressBook/Program.cs
rename to csharp/src/AddressBook/Program.cs
diff --git a/src/AddressBook/Properties/AssemblyInfo.cs b/csharp/src/AddressBook/Properties/AssemblyInfo.cs
similarity index 100%
rename from src/AddressBook/Properties/AssemblyInfo.cs
rename to csharp/src/AddressBook/Properties/AssemblyInfo.cs
diff --git a/src/AddressBook/SampleUsage.cs b/csharp/src/AddressBook/SampleUsage.cs
similarity index 100%
rename from src/AddressBook/SampleUsage.cs
rename to csharp/src/AddressBook/SampleUsage.cs
diff --git a/src/AddressBook/app.config b/csharp/src/AddressBook/app.config
similarity index 100%
rename from src/AddressBook/app.config
rename to csharp/src/AddressBook/app.config
diff --git a/src/ProtoBench/Program.cs b/csharp/src/ProtoBench/Program.cs
similarity index 100%
rename from src/ProtoBench/Program.cs
rename to csharp/src/ProtoBench/Program.cs
diff --git a/src/ProtoBench/Properties/AssemblyInfo.cs b/csharp/src/ProtoBench/Properties/AssemblyInfo.cs
similarity index 100%
rename from src/ProtoBench/Properties/AssemblyInfo.cs
rename to csharp/src/ProtoBench/Properties/AssemblyInfo.cs
diff --git a/src/ProtoBench/ProtoBench.csproj b/csharp/src/ProtoBench/ProtoBench.csproj
similarity index 100%
rename from src/ProtoBench/ProtoBench.csproj
rename to csharp/src/ProtoBench/ProtoBench.csproj
diff --git a/src/ProtoBench/TestProtos/GoogleSizeProtoFile.cs b/csharp/src/ProtoBench/TestProtos/GoogleSizeProtoFile.cs
similarity index 100%
rename from src/ProtoBench/TestProtos/GoogleSizeProtoFile.cs
rename to csharp/src/ProtoBench/TestProtos/GoogleSizeProtoFile.cs
diff --git a/src/ProtoBench/TestProtos/GoogleSpeedProtoFile.cs b/csharp/src/ProtoBench/TestProtos/GoogleSpeedProtoFile.cs
similarity index 100%
rename from src/ProtoBench/TestProtos/GoogleSpeedProtoFile.cs
rename to csharp/src/ProtoBench/TestProtos/GoogleSpeedProtoFile.cs
diff --git a/src/ProtoBench/TestProtos/UnitTestImportProtoFile.cs b/csharp/src/ProtoBench/TestProtos/UnitTestImportProtoFile.cs
similarity index 100%
rename from src/ProtoBench/TestProtos/UnitTestImportProtoFile.cs
rename to csharp/src/ProtoBench/TestProtos/UnitTestImportProtoFile.cs
diff --git a/src/ProtoBench/TestProtos/UnitTestProtoFile.cs b/csharp/src/ProtoBench/TestProtos/UnitTestProtoFile.cs
similarity index 100%
rename from src/ProtoBench/TestProtos/UnitTestProtoFile.cs
rename to csharp/src/ProtoBench/TestProtos/UnitTestProtoFile.cs
diff --git a/src/ProtoBench/google_message1.dat b/csharp/src/ProtoBench/google_message1.dat
similarity index 100%
rename from src/ProtoBench/google_message1.dat
rename to csharp/src/ProtoBench/google_message1.dat
Binary files differ
diff --git a/src/ProtoBench/google_message2.dat b/csharp/src/ProtoBench/google_message2.dat
similarity index 100%
rename from src/ProtoBench/google_message2.dat
rename to csharp/src/ProtoBench/google_message2.dat
Binary files differ
diff --git a/src/ProtoDump/Program.cs b/csharp/src/ProtoDump/Program.cs
similarity index 100%
rename from src/ProtoDump/Program.cs
rename to csharp/src/ProtoDump/Program.cs
diff --git a/src/ProtoDump/Properties/AssemblyInfo.cs b/csharp/src/ProtoDump/Properties/AssemblyInfo.cs
similarity index 100%
rename from src/ProtoDump/Properties/AssemblyInfo.cs
rename to csharp/src/ProtoDump/Properties/AssemblyInfo.cs
diff --git a/src/ProtoDump/ProtoDump.csproj b/csharp/src/ProtoDump/ProtoDump.csproj
similarity index 100%
rename from src/ProtoDump/ProtoDump.csproj
rename to csharp/src/ProtoDump/ProtoDump.csproj
diff --git a/src/ProtoGen.Test/DependencyResolutionTest.cs b/csharp/src/ProtoGen.Test/DependencyResolutionTest.cs
similarity index 100%
rename from src/ProtoGen.Test/DependencyResolutionTest.cs
rename to csharp/src/ProtoGen.Test/DependencyResolutionTest.cs
diff --git a/src/ProtoGen.Test/Properties/AssemblyInfo.cs b/csharp/src/ProtoGen.Test/Properties/AssemblyInfo.cs
similarity index 100%
rename from src/ProtoGen.Test/Properties/AssemblyInfo.cs
rename to csharp/src/ProtoGen.Test/Properties/AssemblyInfo.cs
diff --git a/src/ProtoGen.Test/ProtoGen.Test.csproj b/csharp/src/ProtoGen.Test/ProtoGen.Test.csproj
similarity index 100%
rename from src/ProtoGen.Test/ProtoGen.Test.csproj
rename to csharp/src/ProtoGen.Test/ProtoGen.Test.csproj
diff --git a/src/ProtoGen.Test/ProtocGenCsUnittests.cs b/csharp/src/ProtoGen.Test/ProtocGenCsUnittests.cs
similarity index 100%
rename from src/ProtoGen.Test/ProtocGenCsUnittests.cs
rename to csharp/src/ProtoGen.Test/ProtocGenCsUnittests.cs
diff --git a/src/ProtoGen.Test/TempFile.cs b/csharp/src/ProtoGen.Test/TempFile.cs
similarity index 100%
rename from src/ProtoGen.Test/TempFile.cs
rename to csharp/src/ProtoGen.Test/TempFile.cs
diff --git a/src/ProtoGen.Test/TestPreprocessing.cs b/csharp/src/ProtoGen.Test/TestPreprocessing.cs
similarity index 100%
rename from src/ProtoGen.Test/TestPreprocessing.cs
rename to csharp/src/ProtoGen.Test/TestPreprocessing.cs
diff --git a/src/ProtoGen.Test/protoc-gen-cs.Test.csproj b/csharp/src/ProtoGen.Test/protoc-gen-cs.Test.csproj
similarity index 100%
rename from src/ProtoGen.Test/protoc-gen-cs.Test.csproj
rename to csharp/src/ProtoGen.Test/protoc-gen-cs.Test.csproj
diff --git a/src/ProtoGen/DependencyResolutionException.cs b/csharp/src/ProtoGen/DependencyResolutionException.cs
similarity index 100%
rename from src/ProtoGen/DependencyResolutionException.cs
rename to csharp/src/ProtoGen/DependencyResolutionException.cs
diff --git a/src/ProtoGen/DescriptorUtil.cs b/csharp/src/ProtoGen/DescriptorUtil.cs
similarity index 100%
rename from src/ProtoGen/DescriptorUtil.cs
rename to csharp/src/ProtoGen/DescriptorUtil.cs
diff --git a/src/ProtoGen/EnumFieldGenerator.cs b/csharp/src/ProtoGen/EnumFieldGenerator.cs
similarity index 100%
rename from src/ProtoGen/EnumFieldGenerator.cs
rename to csharp/src/ProtoGen/EnumFieldGenerator.cs
diff --git a/src/ProtoGen/EnumGenerator.cs b/csharp/src/ProtoGen/EnumGenerator.cs
similarity index 100%
rename from src/ProtoGen/EnumGenerator.cs
rename to csharp/src/ProtoGen/EnumGenerator.cs
diff --git a/src/ProtoGen/ExtensionGenerator.cs b/csharp/src/ProtoGen/ExtensionGenerator.cs
similarity index 100%
rename from src/ProtoGen/ExtensionGenerator.cs
rename to csharp/src/ProtoGen/ExtensionGenerator.cs
diff --git a/src/ProtoGen/FieldGeneratorBase.cs b/csharp/src/ProtoGen/FieldGeneratorBase.cs
similarity index 100%
rename from src/ProtoGen/FieldGeneratorBase.cs
rename to csharp/src/ProtoGen/FieldGeneratorBase.cs
diff --git a/src/ProtoGen/Generator.cs b/csharp/src/ProtoGen/Generator.cs
similarity index 100%
rename from src/ProtoGen/Generator.cs
rename to csharp/src/ProtoGen/Generator.cs
diff --git a/src/ProtoGen/GeneratorOptions.cs b/csharp/src/ProtoGen/GeneratorOptions.cs
similarity index 100%
rename from src/ProtoGen/GeneratorOptions.cs
rename to csharp/src/ProtoGen/GeneratorOptions.cs
diff --git a/src/ProtoGen/Helpers.cs b/csharp/src/ProtoGen/Helpers.cs
similarity index 100%
rename from src/ProtoGen/Helpers.cs
rename to csharp/src/ProtoGen/Helpers.cs
diff --git a/src/ProtoGen/IFieldSourceGenerator.cs b/csharp/src/ProtoGen/IFieldSourceGenerator.cs
similarity index 100%
rename from src/ProtoGen/IFieldSourceGenerator.cs
rename to csharp/src/ProtoGen/IFieldSourceGenerator.cs
diff --git a/src/ProtoGen/ISourceGenerator.cs b/csharp/src/ProtoGen/ISourceGenerator.cs
similarity index 100%
rename from src/ProtoGen/ISourceGenerator.cs
rename to csharp/src/ProtoGen/ISourceGenerator.cs
diff --git a/src/ProtoGen/InvalidOptionsException.cs b/csharp/src/ProtoGen/InvalidOptionsException.cs
similarity index 100%
rename from src/ProtoGen/InvalidOptionsException.cs
rename to csharp/src/ProtoGen/InvalidOptionsException.cs
diff --git a/src/ProtoGen/MessageFieldGenerator.cs b/csharp/src/ProtoGen/MessageFieldGenerator.cs
similarity index 100%
rename from src/ProtoGen/MessageFieldGenerator.cs
rename to csharp/src/ProtoGen/MessageFieldGenerator.cs
diff --git a/src/ProtoGen/MessageGenerator.cs b/csharp/src/ProtoGen/MessageGenerator.cs
similarity index 100%
rename from src/ProtoGen/MessageGenerator.cs
rename to csharp/src/ProtoGen/MessageGenerator.cs
diff --git a/src/ProtoGen/PluginProtoFile.cs b/csharp/src/ProtoGen/PluginProtoFile.cs
similarity index 100%
rename from src/ProtoGen/PluginProtoFile.cs
rename to csharp/src/ProtoGen/PluginProtoFile.cs
diff --git a/src/ProtoGen/PrimitiveFieldGenerator.cs b/csharp/src/ProtoGen/PrimitiveFieldGenerator.cs
similarity index 100%
rename from src/ProtoGen/PrimitiveFieldGenerator.cs
rename to csharp/src/ProtoGen/PrimitiveFieldGenerator.cs
diff --git a/src/ProtoGen/Program.cs b/csharp/src/ProtoGen/Program.cs
similarity index 100%
rename from src/ProtoGen/Program.cs
rename to csharp/src/ProtoGen/Program.cs
diff --git a/src/ProtoGen/ProgramPreprocess.cs b/csharp/src/ProtoGen/ProgramPreprocess.cs
similarity index 100%
rename from src/ProtoGen/ProgramPreprocess.cs
rename to csharp/src/ProtoGen/ProgramPreprocess.cs
diff --git a/src/ProtoGen/Properties/AssemblyInfo.cs b/csharp/src/ProtoGen/Properties/AssemblyInfo.cs
similarity index 100%
rename from src/ProtoGen/Properties/AssemblyInfo.cs
rename to csharp/src/ProtoGen/Properties/AssemblyInfo.cs
diff --git a/src/ProtoGen/ProtoGen.csproj b/csharp/src/ProtoGen/ProtoGen.csproj
similarity index 100%
rename from src/ProtoGen/ProtoGen.csproj
rename to csharp/src/ProtoGen/ProtoGen.csproj
diff --git a/src/ProtoGen/ProtocGenCs.cs b/csharp/src/ProtoGen/ProtocGenCs.cs
similarity index 100%
rename from src/ProtoGen/ProtocGenCs.cs
rename to csharp/src/ProtoGen/ProtocGenCs.cs
diff --git a/src/ProtoGen/RepeatedEnumFieldGenerator.cs b/csharp/src/ProtoGen/RepeatedEnumFieldGenerator.cs
similarity index 100%
rename from src/ProtoGen/RepeatedEnumFieldGenerator.cs
rename to csharp/src/ProtoGen/RepeatedEnumFieldGenerator.cs
diff --git a/src/ProtoGen/RepeatedMessageFieldGenerator.cs b/csharp/src/ProtoGen/RepeatedMessageFieldGenerator.cs
similarity index 100%
rename from src/ProtoGen/RepeatedMessageFieldGenerator.cs
rename to csharp/src/ProtoGen/RepeatedMessageFieldGenerator.cs
diff --git a/src/ProtoGen/RepeatedPrimitiveFieldGenerator.cs b/csharp/src/ProtoGen/RepeatedPrimitiveFieldGenerator.cs
similarity index 100%
rename from src/ProtoGen/RepeatedPrimitiveFieldGenerator.cs
rename to csharp/src/ProtoGen/RepeatedPrimitiveFieldGenerator.cs
diff --git a/src/ProtoGen/ServiceGenerator.cs b/csharp/src/ProtoGen/ServiceGenerator.cs
similarity index 100%
rename from src/ProtoGen/ServiceGenerator.cs
rename to csharp/src/ProtoGen/ServiceGenerator.cs
diff --git a/src/ProtoGen/ServiceInterfaceGenerator.cs b/csharp/src/ProtoGen/ServiceInterfaceGenerator.cs
similarity index 100%
rename from src/ProtoGen/ServiceInterfaceGenerator.cs
rename to csharp/src/ProtoGen/ServiceInterfaceGenerator.cs
diff --git a/src/ProtoGen/SourceGeneratorBase.cs b/csharp/src/ProtoGen/SourceGeneratorBase.cs
similarity index 100%
rename from src/ProtoGen/SourceGeneratorBase.cs
rename to csharp/src/ProtoGen/SourceGeneratorBase.cs
diff --git a/src/ProtoGen/SourceGenerators.cs b/csharp/src/ProtoGen/SourceGenerators.cs
similarity index 100%
rename from src/ProtoGen/SourceGenerators.cs
rename to csharp/src/ProtoGen/SourceGenerators.cs
diff --git a/src/ProtoGen/UmbrellaClassGenerator.cs b/csharp/src/ProtoGen/UmbrellaClassGenerator.cs
similarity index 100%
rename from src/ProtoGen/UmbrellaClassGenerator.cs
rename to csharp/src/ProtoGen/UmbrellaClassGenerator.cs
diff --git a/src/ProtoGen/app.config b/csharp/src/ProtoGen/app.config
similarity index 100%
rename from src/ProtoGen/app.config
rename to csharp/src/ProtoGen/app.config
diff --git a/src/ProtoGen/protoc-gen-cs.csproj b/csharp/src/ProtoGen/protoc-gen-cs.csproj
similarity index 100%
rename from src/ProtoGen/protoc-gen-cs.csproj
rename to csharp/src/ProtoGen/protoc-gen-cs.csproj
diff --git a/src/ProtoMunge/Program.cs b/csharp/src/ProtoMunge/Program.cs
similarity index 100%
rename from src/ProtoMunge/Program.cs
rename to csharp/src/ProtoMunge/Program.cs
diff --git a/src/ProtoMunge/Properties/AssemblyInfo.cs b/csharp/src/ProtoMunge/Properties/AssemblyInfo.cs
similarity index 100%
rename from src/ProtoMunge/Properties/AssemblyInfo.cs
rename to csharp/src/ProtoMunge/Properties/AssemblyInfo.cs
diff --git a/src/ProtoMunge/ProtoMunge.csproj b/csharp/src/ProtoMunge/ProtoMunge.csproj
similarity index 100%
rename from src/ProtoMunge/ProtoMunge.csproj
rename to csharp/src/ProtoMunge/ProtoMunge.csproj
diff --git a/src/ProtocolBuffers.Serialization/AbstractReader.cs b/csharp/src/ProtocolBuffers.Serialization/AbstractReader.cs
similarity index 100%
rename from src/ProtocolBuffers.Serialization/AbstractReader.cs
rename to csharp/src/ProtocolBuffers.Serialization/AbstractReader.cs
diff --git a/src/ProtocolBuffers.Serialization/AbstractTextReader.cs b/csharp/src/ProtocolBuffers.Serialization/AbstractTextReader.cs
similarity index 100%
rename from src/ProtocolBuffers.Serialization/AbstractTextReader.cs
rename to csharp/src/ProtocolBuffers.Serialization/AbstractTextReader.cs
diff --git a/src/ProtocolBuffers.Serialization/AbstractTextWriter.cs b/csharp/src/ProtocolBuffers.Serialization/AbstractTextWriter.cs
similarity index 100%
rename from src/ProtocolBuffers.Serialization/AbstractTextWriter.cs
rename to csharp/src/ProtocolBuffers.Serialization/AbstractTextWriter.cs
diff --git a/src/ProtocolBuffers.Serialization/AbstractWriter.cs b/csharp/src/ProtocolBuffers.Serialization/AbstractWriter.cs
similarity index 100%
rename from src/ProtocolBuffers.Serialization/AbstractWriter.cs
rename to csharp/src/ProtocolBuffers.Serialization/AbstractWriter.cs
diff --git a/src/ProtocolBuffers.Serialization/DictionaryReader.cs b/csharp/src/ProtocolBuffers.Serialization/DictionaryReader.cs
similarity index 100%
rename from src/ProtocolBuffers.Serialization/DictionaryReader.cs
rename to csharp/src/ProtocolBuffers.Serialization/DictionaryReader.cs
diff --git a/src/ProtocolBuffers.Serialization/DictionaryWriter.cs b/csharp/src/ProtocolBuffers.Serialization/DictionaryWriter.cs
similarity index 100%
rename from src/ProtocolBuffers.Serialization/DictionaryWriter.cs
rename to csharp/src/ProtocolBuffers.Serialization/DictionaryWriter.cs
diff --git a/src/ProtocolBuffers.Serialization/Extensions.cs b/csharp/src/ProtocolBuffers.Serialization/Extensions.cs
similarity index 100%
rename from src/ProtocolBuffers.Serialization/Extensions.cs
rename to csharp/src/ProtocolBuffers.Serialization/Extensions.cs
diff --git a/src/ProtocolBuffers.Serialization/Http/FormUrlEncodedReader.cs b/csharp/src/ProtocolBuffers.Serialization/Http/FormUrlEncodedReader.cs
similarity index 100%
rename from src/ProtocolBuffers.Serialization/Http/FormUrlEncodedReader.cs
rename to csharp/src/ProtocolBuffers.Serialization/Http/FormUrlEncodedReader.cs
diff --git a/src/ProtocolBuffers.Serialization/Http/MessageFormatFactory.cs b/csharp/src/ProtocolBuffers.Serialization/Http/MessageFormatFactory.cs
similarity index 100%
rename from src/ProtocolBuffers.Serialization/Http/MessageFormatFactory.cs
rename to csharp/src/ProtocolBuffers.Serialization/Http/MessageFormatFactory.cs
diff --git a/src/ProtocolBuffers.Serialization/Http/MessageFormatOptions.cs b/csharp/src/ProtocolBuffers.Serialization/Http/MessageFormatOptions.cs
similarity index 100%
rename from src/ProtocolBuffers.Serialization/Http/MessageFormatOptions.cs
rename to csharp/src/ProtocolBuffers.Serialization/Http/MessageFormatOptions.cs
diff --git a/src/ProtocolBuffers.Serialization/JsonFormatReader.cs b/csharp/src/ProtocolBuffers.Serialization/JsonFormatReader.cs
similarity index 100%
rename from src/ProtocolBuffers.Serialization/JsonFormatReader.cs
rename to csharp/src/ProtocolBuffers.Serialization/JsonFormatReader.cs
diff --git a/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs b/csharp/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs
similarity index 100%
rename from src/ProtocolBuffers.Serialization/JsonFormatWriter.cs
rename to csharp/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs
diff --git a/src/ProtocolBuffers.Serialization/JsonTextCursor.cs b/csharp/src/ProtocolBuffers.Serialization/JsonTextCursor.cs
similarity index 100%
rename from src/ProtocolBuffers.Serialization/JsonTextCursor.cs
rename to csharp/src/ProtocolBuffers.Serialization/JsonTextCursor.cs
diff --git a/src/ProtocolBuffers.Serialization/Properties/AssemblyInfo.cs b/csharp/src/ProtocolBuffers.Serialization/Properties/AssemblyInfo.cs
similarity index 100%
rename from src/ProtocolBuffers.Serialization/Properties/AssemblyInfo.cs
rename to csharp/src/ProtocolBuffers.Serialization/Properties/AssemblyInfo.cs
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.CF20.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.CF20.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.CF20.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.CF20.csproj
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.CF35.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.CF35.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.CF35.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.CF35.csproj
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.NET20.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.NET20.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.NET20.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.NET20.csproj
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.NET35.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.NET35.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.NET35.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.NET35.csproj
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.NET40.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.NET40.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.NET40.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.NET40.csproj
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.PL40.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.PL40.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.PL40.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.PL40.csproj
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.SL20.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.SL20.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.SL20.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.SL20.csproj
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.SL30.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.SL30.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.SL30.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.SL30.csproj
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.SL40.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.SL40.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.SL40.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.SL40.csproj
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.csproj
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.CF20.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.CF20.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.CF20.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.CF20.csproj
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.CF35.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.CF35.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.CF35.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.CF35.csproj
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.NET20.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.NET20.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.NET20.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.NET20.csproj
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.NET35.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.NET35.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.NET35.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.NET35.csproj
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.NET40.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.NET40.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.NET40.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.NET40.csproj
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.PL40.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.PL40.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.PL40.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.PL40.csproj
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.SL20.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.SL20.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.SL20.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.SL20.csproj
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.SL30.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.SL30.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.SL30.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.SL30.csproj
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.SL40.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.SL40.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.SL40.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.SL40.csproj
diff --git a/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.csproj
similarity index 100%
rename from src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.csproj
rename to csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.csproj
diff --git a/src/ProtocolBuffers.Serialization/RecursionLimitExceeded.cs b/csharp/src/ProtocolBuffers.Serialization/RecursionLimitExceeded.cs
similarity index 100%
rename from src/ProtocolBuffers.Serialization/RecursionLimitExceeded.cs
rename to csharp/src/ProtocolBuffers.Serialization/RecursionLimitExceeded.cs
diff --git a/src/ProtocolBuffers.Serialization/XmlFormatReader.cs b/csharp/src/ProtocolBuffers.Serialization/XmlFormatReader.cs
similarity index 100%
rename from src/ProtocolBuffers.Serialization/XmlFormatReader.cs
rename to csharp/src/ProtocolBuffers.Serialization/XmlFormatReader.cs
diff --git a/src/ProtocolBuffers.Serialization/XmlFormatWriter.cs b/csharp/src/ProtocolBuffers.Serialization/XmlFormatWriter.cs
similarity index 100%
rename from src/ProtocolBuffers.Serialization/XmlFormatWriter.cs
rename to csharp/src/ProtocolBuffers.Serialization/XmlFormatWriter.cs
diff --git a/src/ProtocolBuffers.Serialization/XmlReaderOptions.cs b/csharp/src/ProtocolBuffers.Serialization/XmlReaderOptions.cs
similarity index 100%
rename from src/ProtocolBuffers.Serialization/XmlReaderOptions.cs
rename to csharp/src/ProtocolBuffers.Serialization/XmlReaderOptions.cs
diff --git a/src/ProtocolBuffers.Serialization/XmlWriterOptions.cs b/csharp/src/ProtocolBuffers.Serialization/XmlWriterOptions.cs
similarity index 100%
rename from src/ProtocolBuffers.Serialization/XmlWriterOptions.cs
rename to csharp/src/ProtocolBuffers.Serialization/XmlWriterOptions.cs
diff --git a/src/ProtocolBuffers.Test/AbstractMessageTest.cs b/csharp/src/ProtocolBuffers.Test/AbstractMessageTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/AbstractMessageTest.cs
rename to csharp/src/ProtocolBuffers.Test/AbstractMessageTest.cs
diff --git a/src/ProtocolBuffers.Test/App.xaml b/csharp/src/ProtocolBuffers.Test/App.xaml
similarity index 100%
rename from src/ProtocolBuffers.Test/App.xaml
rename to csharp/src/ProtocolBuffers.Test/App.xaml
diff --git a/src/ProtocolBuffers.Test/App.xaml.cs b/csharp/src/ProtocolBuffers.Test/App.xaml.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/App.xaml.cs
rename to csharp/src/ProtocolBuffers.Test/App.xaml.cs
diff --git a/src/ProtocolBuffers.Test/ByteStringTest.cs b/csharp/src/ProtocolBuffers.Test/ByteStringTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/ByteStringTest.cs
rename to csharp/src/ProtocolBuffers.Test/ByteStringTest.cs
diff --git a/src/ProtocolBuffers.Test/CSharpOptionsTest.cs b/csharp/src/ProtocolBuffers.Test/CSharpOptionsTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/CSharpOptionsTest.cs
rename to csharp/src/ProtocolBuffers.Test/CSharpOptionsTest.cs
diff --git a/src/ProtocolBuffers.Test/CodedInputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/CodedInputStreamTest.cs
rename to csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs
diff --git a/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/CodedOutputStreamTest.cs
rename to csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs
diff --git a/src/ProtocolBuffers.Test/Collections/PopsicleListTest.cs b/csharp/src/ProtocolBuffers.Test/Collections/PopsicleListTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/Collections/PopsicleListTest.cs
rename to csharp/src/ProtocolBuffers.Test/Collections/PopsicleListTest.cs
diff --git a/src/ProtocolBuffers.Test/Compatibility/BinaryCompatibilityTests.cs b/csharp/src/ProtocolBuffers.Test/Compatibility/BinaryCompatibilityTests.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/Compatibility/BinaryCompatibilityTests.cs
rename to csharp/src/ProtocolBuffers.Test/Compatibility/BinaryCompatibilityTests.cs
diff --git a/src/ProtocolBuffers.Test/Compatibility/CompatibilityTests.cs b/csharp/src/ProtocolBuffers.Test/Compatibility/CompatibilityTests.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/Compatibility/CompatibilityTests.cs
rename to csharp/src/ProtocolBuffers.Test/Compatibility/CompatibilityTests.cs
diff --git a/src/ProtocolBuffers.Test/Compatibility/DictionaryCompatibilityTests.cs b/csharp/src/ProtocolBuffers.Test/Compatibility/DictionaryCompatibilityTests.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/Compatibility/DictionaryCompatibilityTests.cs
rename to csharp/src/ProtocolBuffers.Test/Compatibility/DictionaryCompatibilityTests.cs
diff --git a/src/ProtocolBuffers.Test/Compatibility/JsonCompatibilityTests.cs b/csharp/src/ProtocolBuffers.Test/Compatibility/JsonCompatibilityTests.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/Compatibility/JsonCompatibilityTests.cs
rename to csharp/src/ProtocolBuffers.Test/Compatibility/JsonCompatibilityTests.cs
diff --git a/src/ProtocolBuffers.Test/Compatibility/TestResources.cs b/csharp/src/ProtocolBuffers.Test/Compatibility/TestResources.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/Compatibility/TestResources.cs
rename to csharp/src/ProtocolBuffers.Test/Compatibility/TestResources.cs
diff --git a/src/ProtocolBuffers.Test/Compatibility/TextCompatibilityTests.cs b/csharp/src/ProtocolBuffers.Test/Compatibility/TextCompatibilityTests.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/Compatibility/TextCompatibilityTests.cs
rename to csharp/src/ProtocolBuffers.Test/Compatibility/TextCompatibilityTests.cs
diff --git a/src/ProtocolBuffers.Test/Compatibility/XmlCompatibilityTests.cs b/csharp/src/ProtocolBuffers.Test/Compatibility/XmlCompatibilityTests.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/Compatibility/XmlCompatibilityTests.cs
rename to csharp/src/ProtocolBuffers.Test/Compatibility/XmlCompatibilityTests.cs
diff --git a/src/ProtocolBuffers.Test/Compatibility/google_message1.dat b/csharp/src/ProtocolBuffers.Test/Compatibility/google_message1.dat
similarity index 100%
rename from src/ProtocolBuffers.Test/Compatibility/google_message1.dat
rename to csharp/src/ProtocolBuffers.Test/Compatibility/google_message1.dat
Binary files differ
diff --git a/src/ProtocolBuffers.Test/Compatibility/google_message2.dat b/csharp/src/ProtocolBuffers.Test/Compatibility/google_message2.dat
similarity index 100%
rename from src/ProtocolBuffers.Test/Compatibility/google_message2.dat
rename to csharp/src/ProtocolBuffers.Test/Compatibility/google_message2.dat
Binary files differ
diff --git a/src/ProtocolBuffers.Test/DeprecatedMemberTest.cs b/csharp/src/ProtocolBuffers.Test/DeprecatedMemberTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/DeprecatedMemberTest.cs
rename to csharp/src/ProtocolBuffers.Test/DeprecatedMemberTest.cs
diff --git a/src/ProtocolBuffers.Test/Descriptors/MessageDescriptorTest.cs b/csharp/src/ProtocolBuffers.Test/Descriptors/MessageDescriptorTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/Descriptors/MessageDescriptorTest.cs
rename to csharp/src/ProtocolBuffers.Test/Descriptors/MessageDescriptorTest.cs
diff --git a/src/ProtocolBuffers.Test/DescriptorsTest.cs b/csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/DescriptorsTest.cs
rename to csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs
diff --git a/src/ProtocolBuffers.Test/DynamicMessageTest.cs b/csharp/src/ProtocolBuffers.Test/DynamicMessageTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/DynamicMessageTest.cs
rename to csharp/src/ProtocolBuffers.Test/DynamicMessageTest.cs
diff --git a/src/ProtocolBuffers.Test/ExtendableMessageTest.cs b/csharp/src/ProtocolBuffers.Test/ExtendableMessageTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/ExtendableMessageTest.cs
rename to csharp/src/ProtocolBuffers.Test/ExtendableMessageTest.cs
diff --git a/src/ProtocolBuffers.Test/GeneratedBuilderTest.cs b/csharp/src/ProtocolBuffers.Test/GeneratedBuilderTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/GeneratedBuilderTest.cs
rename to csharp/src/ProtocolBuffers.Test/GeneratedBuilderTest.cs
diff --git a/src/ProtocolBuffers.Test/GeneratedMessageTest.cs b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/GeneratedMessageTest.cs
rename to csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs
diff --git a/src/ProtocolBuffers.Test/IssuesTest.cs b/csharp/src/ProtocolBuffers.Test/IssuesTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/IssuesTest.cs
rename to csharp/src/ProtocolBuffers.Test/IssuesTest.cs
diff --git a/src/ProtocolBuffers.Test/MessageStreamIteratorTest.cs b/csharp/src/ProtocolBuffers.Test/MessageStreamIteratorTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/MessageStreamIteratorTest.cs
rename to csharp/src/ProtocolBuffers.Test/MessageStreamIteratorTest.cs
diff --git a/src/ProtocolBuffers.Test/MessageStreamWriterTest.cs b/csharp/src/ProtocolBuffers.Test/MessageStreamWriterTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/MessageStreamWriterTest.cs
rename to csharp/src/ProtocolBuffers.Test/MessageStreamWriterTest.cs
diff --git a/src/ProtocolBuffers.Test/MessageTest.cs b/csharp/src/ProtocolBuffers.Test/MessageTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/MessageTest.cs
rename to csharp/src/ProtocolBuffers.Test/MessageTest.cs
diff --git a/src/ProtocolBuffers.Test/MessageUtilTest.cs b/csharp/src/ProtocolBuffers.Test/MessageUtilTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/MessageUtilTest.cs
rename to csharp/src/ProtocolBuffers.Test/MessageUtilTest.cs
diff --git a/src/ProtocolBuffers.Test/NameHelpersTest.cs b/csharp/src/ProtocolBuffers.Test/NameHelpersTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/NameHelpersTest.cs
rename to csharp/src/ProtocolBuffers.Test/NameHelpersTest.cs
diff --git a/src/ProtocolBuffers.Test/Properties/AppManifest.xml b/csharp/src/ProtocolBuffers.Test/Properties/AppManifest.xml
similarity index 100%
rename from src/ProtocolBuffers.Test/Properties/AppManifest.xml
rename to csharp/src/ProtocolBuffers.Test/Properties/AppManifest.xml
diff --git a/src/ProtocolBuffers.Test/Properties/AssemblyInfo.cs b/csharp/src/ProtocolBuffers.Test/Properties/AssemblyInfo.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/Properties/AssemblyInfo.cs
rename to csharp/src/ProtocolBuffers.Test/Properties/AssemblyInfo.cs
diff --git a/src/ProtocolBuffers.Test/Properties/OutOfBrowserSettings.xml b/csharp/src/ProtocolBuffers.Test/Properties/OutOfBrowserSettings.xml
similarity index 100%
rename from src/ProtocolBuffers.Test/Properties/OutOfBrowserSettings.xml
rename to csharp/src/ProtocolBuffers.Test/Properties/OutOfBrowserSettings.xml
diff --git a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.CF20.csproj b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.CF20.csproj
similarity index 100%
rename from src/ProtocolBuffers.Test/ProtocolBuffers.Test.CF20.csproj
rename to csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.CF20.csproj
diff --git a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.CF35.csproj b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.CF35.csproj
similarity index 100%
rename from src/ProtocolBuffers.Test/ProtocolBuffers.Test.CF35.csproj
rename to csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.CF35.csproj
diff --git a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.NET20.csproj b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.NET20.csproj
similarity index 100%
rename from src/ProtocolBuffers.Test/ProtocolBuffers.Test.NET20.csproj
rename to csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.NET20.csproj
diff --git a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.NET35.csproj b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.NET35.csproj
similarity index 100%
rename from src/ProtocolBuffers.Test/ProtocolBuffers.Test.NET35.csproj
rename to csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.NET35.csproj
diff --git a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.NET40.csproj b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.NET40.csproj
similarity index 100%
rename from src/ProtocolBuffers.Test/ProtocolBuffers.Test.NET40.csproj
rename to csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.NET40.csproj
diff --git a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.PL40.csproj b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.PL40.csproj
similarity index 100%
rename from src/ProtocolBuffers.Test/ProtocolBuffers.Test.PL40.csproj
rename to csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.PL40.csproj
diff --git a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.SL20.csproj b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.SL20.csproj
similarity index 100%
rename from src/ProtocolBuffers.Test/ProtocolBuffers.Test.SL20.csproj
rename to csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.SL20.csproj
diff --git a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.SL30.csproj b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.SL30.csproj
similarity index 100%
rename from src/ProtocolBuffers.Test/ProtocolBuffers.Test.SL30.csproj
rename to csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.SL30.csproj
diff --git a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.SL40.csproj b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.SL40.csproj
similarity index 100%
rename from src/ProtocolBuffers.Test/ProtocolBuffers.Test.SL40.csproj
rename to csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.SL40.csproj
diff --git a/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj
similarity index 100%
rename from src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj
rename to csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj
diff --git a/src/ProtocolBuffers.Test/ReflectionTester.cs b/csharp/src/ProtocolBuffers.Test/ReflectionTester.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/ReflectionTester.cs
rename to csharp/src/ProtocolBuffers.Test/ReflectionTester.cs
diff --git a/src/ProtocolBuffers.Test/ReusableBuilderTest.cs b/csharp/src/ProtocolBuffers.Test/ReusableBuilderTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/ReusableBuilderTest.cs
rename to csharp/src/ProtocolBuffers.Test/ReusableBuilderTest.cs
diff --git a/src/ProtocolBuffers.Test/SerializableAttribute.cs b/csharp/src/ProtocolBuffers.Test/SerializableAttribute.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/SerializableAttribute.cs
rename to csharp/src/ProtocolBuffers.Test/SerializableAttribute.cs
diff --git a/src/ProtocolBuffers.Test/SerializableTest.cs b/csharp/src/ProtocolBuffers.Test/SerializableTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/SerializableTest.cs
rename to csharp/src/ProtocolBuffers.Test/SerializableTest.cs
diff --git a/src/ProtocolBuffers.Test/ServiceTest.cs b/csharp/src/ProtocolBuffers.Test/ServiceTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/ServiceTest.cs
rename to csharp/src/ProtocolBuffers.Test/ServiceTest.cs
diff --git a/src/ProtocolBuffers.Test/TestCornerCases.cs b/csharp/src/ProtocolBuffers.Test/TestCornerCases.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestCornerCases.cs
rename to csharp/src/ProtocolBuffers.Test/TestCornerCases.cs
diff --git a/src/ProtocolBuffers.Test/TestMimeMessageFormats.cs b/csharp/src/ProtocolBuffers.Test/TestMimeMessageFormats.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestMimeMessageFormats.cs
rename to csharp/src/ProtocolBuffers.Test/TestMimeMessageFormats.cs
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs
rename to csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs
rename to csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs
rename to csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestEmptyProtoFile.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestEmptyProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestProtos/UnitTestEmptyProtoFile.cs
rename to csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestEmptyProtoFile.cs
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasIssuesProtoFile.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasIssuesProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasIssuesProtoFile.cs
rename to csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasIssuesProtoFile.cs
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasProtoFile.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasProtoFile.cs
rename to csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasProtoFile.cs
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestGenericServices.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestGenericServices.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestProtos/UnitTestGenericServices.cs
rename to csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestGenericServices.cs
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSizeProtoFile.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSizeProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSizeProtoFile.cs
rename to csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSizeProtoFile.cs
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSpeedProtoFile.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSpeedProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSpeedProtoFile.cs
rename to csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSpeedProtoFile.cs
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestImportLiteProtoFile.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestImportLiteProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestProtos/UnitTestImportLiteProtoFile.cs
rename to csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestImportLiteProtoFile.cs
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs
rename to csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs
rename to csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestNoGenericServicesProtoFile.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestNoGenericServicesProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestProtos/UnitTestNoGenericServicesProtoFile.cs
rename to csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestNoGenericServicesProtoFile.cs
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs
rename to csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestOptimizeForProtoFile.cs
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs
rename to csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestRpcInterop.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestRpcInterop.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestProtos/UnitTestRpcInterop.cs
rename to csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestRpcInterop.cs
diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestXmlSerializerTestProtoFile.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestXmlSerializerTestProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestProtos/UnitTestXmlSerializerTestProtoFile.cs
rename to csharp/src/ProtocolBuffers.Test/TestProtos/UnitTestXmlSerializerTestProtoFile.cs
diff --git a/src/ProtocolBuffers.Test/TestReaderForUrlEncoded.cs b/csharp/src/ProtocolBuffers.Test/TestReaderForUrlEncoded.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestReaderForUrlEncoded.cs
rename to csharp/src/ProtocolBuffers.Test/TestReaderForUrlEncoded.cs
diff --git a/src/ProtocolBuffers.Test/TestResources.cs b/csharp/src/ProtocolBuffers.Test/TestResources.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestResources.cs
rename to csharp/src/ProtocolBuffers.Test/TestResources.cs
diff --git a/src/ProtocolBuffers.Test/TestRpcForMimeTypes.cs b/csharp/src/ProtocolBuffers.Test/TestRpcForMimeTypes.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestRpcForMimeTypes.cs
rename to csharp/src/ProtocolBuffers.Test/TestRpcForMimeTypes.cs
diff --git a/src/ProtocolBuffers.Test/TestRpcGenerator.cs b/csharp/src/ProtocolBuffers.Test/TestRpcGenerator.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestRpcGenerator.cs
rename to csharp/src/ProtocolBuffers.Test/TestRpcGenerator.cs
diff --git a/src/ProtocolBuffers.Test/TestUtil.cs b/csharp/src/ProtocolBuffers.Test/TestUtil.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestUtil.cs
rename to csharp/src/ProtocolBuffers.Test/TestUtil.cs
diff --git a/src/ProtocolBuffers.Test/TestWriterFormatJson.cs b/csharp/src/ProtocolBuffers.Test/TestWriterFormatJson.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestWriterFormatJson.cs
rename to csharp/src/ProtocolBuffers.Test/TestWriterFormatJson.cs
diff --git a/src/ProtocolBuffers.Test/TestWriterFormatXml.cs b/csharp/src/ProtocolBuffers.Test/TestWriterFormatXml.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TestWriterFormatXml.cs
rename to csharp/src/ProtocolBuffers.Test/TestWriterFormatXml.cs
diff --git a/src/ProtocolBuffers.Test/TextFormatTest.cs b/csharp/src/ProtocolBuffers.Test/TextFormatTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/TextFormatTest.cs
rename to csharp/src/ProtocolBuffers.Test/TextFormatTest.cs
diff --git a/src/ProtocolBuffers.Test/UnknownFieldSetTest.cs b/csharp/src/ProtocolBuffers.Test/UnknownFieldSetTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/UnknownFieldSetTest.cs
rename to csharp/src/ProtocolBuffers.Test/UnknownFieldSetTest.cs
diff --git a/src/ProtocolBuffers.Test/WireFormatTest.cs b/csharp/src/ProtocolBuffers.Test/WireFormatTest.cs
similarity index 100%
rename from src/ProtocolBuffers.Test/WireFormatTest.cs
rename to csharp/src/ProtocolBuffers.Test/WireFormatTest.cs
diff --git a/src/ProtocolBuffers.sln b/csharp/src/ProtocolBuffers.sln
similarity index 100%
rename from src/ProtocolBuffers.sln
rename to csharp/src/ProtocolBuffers.sln
diff --git a/src/ProtocolBuffers/AbstractBuilder.cs b/csharp/src/ProtocolBuffers/AbstractBuilder.cs
similarity index 100%
rename from src/ProtocolBuffers/AbstractBuilder.cs
rename to csharp/src/ProtocolBuffers/AbstractBuilder.cs
diff --git a/src/ProtocolBuffers/AbstractBuilderLite.cs b/csharp/src/ProtocolBuffers/AbstractBuilderLite.cs
similarity index 100%
rename from src/ProtocolBuffers/AbstractBuilderLite.cs
rename to csharp/src/ProtocolBuffers/AbstractBuilderLite.cs
diff --git a/src/ProtocolBuffers/AbstractMessage.cs b/csharp/src/ProtocolBuffers/AbstractMessage.cs
similarity index 100%
rename from src/ProtocolBuffers/AbstractMessage.cs
rename to csharp/src/ProtocolBuffers/AbstractMessage.cs
diff --git a/src/ProtocolBuffers/AbstractMessageLite.cs b/csharp/src/ProtocolBuffers/AbstractMessageLite.cs
similarity index 100%
rename from src/ProtocolBuffers/AbstractMessageLite.cs
rename to csharp/src/ProtocolBuffers/AbstractMessageLite.cs
diff --git a/src/ProtocolBuffers/ByteArray.cs b/csharp/src/ProtocolBuffers/ByteArray.cs
similarity index 100%
rename from src/ProtocolBuffers/ByteArray.cs
rename to csharp/src/ProtocolBuffers/ByteArray.cs
diff --git a/src/ProtocolBuffers/ByteString.cs b/csharp/src/ProtocolBuffers/ByteString.cs
similarity index 100%
rename from src/ProtocolBuffers/ByteString.cs
rename to csharp/src/ProtocolBuffers/ByteString.cs
diff --git a/src/ProtocolBuffers/CodedInputStream.cs b/csharp/src/ProtocolBuffers/CodedInputStream.cs
similarity index 100%
rename from src/ProtocolBuffers/CodedInputStream.cs
rename to csharp/src/ProtocolBuffers/CodedInputStream.cs
diff --git a/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs
similarity index 100%
rename from src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs
rename to csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs
diff --git a/src/ProtocolBuffers/CodedOutputStream.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.cs
similarity index 100%
rename from src/ProtocolBuffers/CodedOutputStream.cs
rename to csharp/src/ProtocolBuffers/CodedOutputStream.cs
diff --git a/src/ProtocolBuffers/Collections/Dictionaries.cs b/csharp/src/ProtocolBuffers/Collections/Dictionaries.cs
similarity index 100%
rename from src/ProtocolBuffers/Collections/Dictionaries.cs
rename to csharp/src/ProtocolBuffers/Collections/Dictionaries.cs
diff --git a/src/ProtocolBuffers/Collections/Enumerables.cs b/csharp/src/ProtocolBuffers/Collections/Enumerables.cs
similarity index 100%
rename from src/ProtocolBuffers/Collections/Enumerables.cs
rename to csharp/src/ProtocolBuffers/Collections/Enumerables.cs
diff --git a/src/ProtocolBuffers/Collections/IPopsicleList.cs b/csharp/src/ProtocolBuffers/Collections/IPopsicleList.cs
similarity index 100%
rename from src/ProtocolBuffers/Collections/IPopsicleList.cs
rename to csharp/src/ProtocolBuffers/Collections/IPopsicleList.cs
diff --git a/src/ProtocolBuffers/Collections/Lists.cs b/csharp/src/ProtocolBuffers/Collections/Lists.cs
similarity index 100%
rename from src/ProtocolBuffers/Collections/Lists.cs
rename to csharp/src/ProtocolBuffers/Collections/Lists.cs
diff --git a/src/ProtocolBuffers/Collections/PopsicleList.cs b/csharp/src/ProtocolBuffers/Collections/PopsicleList.cs
similarity index 100%
rename from src/ProtocolBuffers/Collections/PopsicleList.cs
rename to csharp/src/ProtocolBuffers/Collections/PopsicleList.cs
diff --git a/src/ProtocolBuffers/Collections/ReadOnlyDictionary.cs b/csharp/src/ProtocolBuffers/Collections/ReadOnlyDictionary.cs
similarity index 100%
rename from src/ProtocolBuffers/Collections/ReadOnlyDictionary.cs
rename to csharp/src/ProtocolBuffers/Collections/ReadOnlyDictionary.cs
diff --git a/src/ProtocolBuffers/CustomSerialization.cs b/csharp/src/ProtocolBuffers/CustomSerialization.cs
similarity index 100%
rename from src/ProtocolBuffers/CustomSerialization.cs
rename to csharp/src/ProtocolBuffers/CustomSerialization.cs
diff --git a/src/ProtocolBuffers/Delegates.cs b/csharp/src/ProtocolBuffers/Delegates.cs
similarity index 100%
rename from src/ProtocolBuffers/Delegates.cs
rename to csharp/src/ProtocolBuffers/Delegates.cs
diff --git a/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs
similarity index 100%
rename from src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs
rename to csharp/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs
diff --git a/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
rename to csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
diff --git a/src/ProtocolBuffers/DescriptorProtos/IDescriptorProto.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/IDescriptorProto.cs
similarity index 100%
rename from src/ProtocolBuffers/DescriptorProtos/IDescriptorProto.cs
rename to csharp/src/ProtocolBuffers/DescriptorProtos/IDescriptorProto.cs
diff --git a/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs
similarity index 100%
rename from src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs
rename to csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs
diff --git a/src/ProtocolBuffers/Descriptors/DescriptorBase.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs
similarity index 100%
rename from src/ProtocolBuffers/Descriptors/DescriptorBase.cs
rename to csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs
diff --git a/src/ProtocolBuffers/Descriptors/DescriptorPool.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs
similarity index 100%
rename from src/ProtocolBuffers/Descriptors/DescriptorPool.cs
rename to csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs
diff --git a/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs
similarity index 100%
rename from src/ProtocolBuffers/Descriptors/DescriptorUtil.cs
rename to csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs
diff --git a/src/ProtocolBuffers/Descriptors/DescriptorValidationException.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorValidationException.cs
similarity index 100%
rename from src/ProtocolBuffers/Descriptors/DescriptorValidationException.cs
rename to csharp/src/ProtocolBuffers/Descriptors/DescriptorValidationException.cs
diff --git a/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs
similarity index 100%
rename from src/ProtocolBuffers/Descriptors/EnumDescriptor.cs
rename to csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs
diff --git a/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs
similarity index 100%
rename from src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs
rename to csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs
diff --git a/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs
similarity index 100%
rename from src/ProtocolBuffers/Descriptors/FieldDescriptor.cs
rename to csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs
diff --git a/src/ProtocolBuffers/Descriptors/FieldMappingAttribute.cs b/csharp/src/ProtocolBuffers/Descriptors/FieldMappingAttribute.cs
similarity index 100%
rename from src/ProtocolBuffers/Descriptors/FieldMappingAttribute.cs
rename to csharp/src/ProtocolBuffers/Descriptors/FieldMappingAttribute.cs
diff --git a/src/ProtocolBuffers/Descriptors/FieldType.cs b/csharp/src/ProtocolBuffers/Descriptors/FieldType.cs
similarity index 100%
rename from src/ProtocolBuffers/Descriptors/FieldType.cs
rename to csharp/src/ProtocolBuffers/Descriptors/FieldType.cs
diff --git a/src/ProtocolBuffers/Descriptors/FileDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs
similarity index 100%
rename from src/ProtocolBuffers/Descriptors/FileDescriptor.cs
rename to csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs
diff --git a/src/ProtocolBuffers/Descriptors/IDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs
similarity index 100%
rename from src/ProtocolBuffers/Descriptors/IDescriptor.cs
rename to csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs
diff --git a/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs b/csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs
similarity index 100%
rename from src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs
rename to csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs
diff --git a/src/ProtocolBuffers/Descriptors/MappedType.cs b/csharp/src/ProtocolBuffers/Descriptors/MappedType.cs
similarity index 100%
rename from src/ProtocolBuffers/Descriptors/MappedType.cs
rename to csharp/src/ProtocolBuffers/Descriptors/MappedType.cs
diff --git a/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs
similarity index 100%
rename from src/ProtocolBuffers/Descriptors/MessageDescriptor.cs
rename to csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs
diff --git a/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs
similarity index 100%
rename from src/ProtocolBuffers/Descriptors/MethodDescriptor.cs
rename to csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs
diff --git a/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs
similarity index 100%
rename from src/ProtocolBuffers/Descriptors/PackageDescriptor.cs
rename to csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs
diff --git a/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs
similarity index 100%
rename from src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs
rename to csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs
diff --git a/src/ProtocolBuffers/DynamicMessage.cs b/csharp/src/ProtocolBuffers/DynamicMessage.cs
similarity index 100%
rename from src/ProtocolBuffers/DynamicMessage.cs
rename to csharp/src/ProtocolBuffers/DynamicMessage.cs
diff --git a/src/ProtocolBuffers/EnumLite.cs b/csharp/src/ProtocolBuffers/EnumLite.cs
similarity index 100%
rename from src/ProtocolBuffers/EnumLite.cs
rename to csharp/src/ProtocolBuffers/EnumLite.cs
diff --git a/src/ProtocolBuffers/ExtendableBuilder.cs b/csharp/src/ProtocolBuffers/ExtendableBuilder.cs
similarity index 100%
rename from src/ProtocolBuffers/ExtendableBuilder.cs
rename to csharp/src/ProtocolBuffers/ExtendableBuilder.cs
diff --git a/src/ProtocolBuffers/ExtendableBuilderLite.cs b/csharp/src/ProtocolBuffers/ExtendableBuilderLite.cs
similarity index 100%
rename from src/ProtocolBuffers/ExtendableBuilderLite.cs
rename to csharp/src/ProtocolBuffers/ExtendableBuilderLite.cs
diff --git a/src/ProtocolBuffers/ExtendableMessage.cs b/csharp/src/ProtocolBuffers/ExtendableMessage.cs
similarity index 100%
rename from src/ProtocolBuffers/ExtendableMessage.cs
rename to csharp/src/ProtocolBuffers/ExtendableMessage.cs
diff --git a/src/ProtocolBuffers/ExtendableMessageLite.cs b/csharp/src/ProtocolBuffers/ExtendableMessageLite.cs
similarity index 100%
rename from src/ProtocolBuffers/ExtendableMessageLite.cs
rename to csharp/src/ProtocolBuffers/ExtendableMessageLite.cs
diff --git a/src/ProtocolBuffers/ExtensionInfo.cs b/csharp/src/ProtocolBuffers/ExtensionInfo.cs
similarity index 100%
rename from src/ProtocolBuffers/ExtensionInfo.cs
rename to csharp/src/ProtocolBuffers/ExtensionInfo.cs
diff --git a/src/ProtocolBuffers/ExtensionRegistry.cs b/csharp/src/ProtocolBuffers/ExtensionRegistry.cs
similarity index 100%
rename from src/ProtocolBuffers/ExtensionRegistry.cs
rename to csharp/src/ProtocolBuffers/ExtensionRegistry.cs
diff --git a/src/ProtocolBuffers/ExtensionRegistryLite.cs b/csharp/src/ProtocolBuffers/ExtensionRegistryLite.cs
similarity index 100%
rename from src/ProtocolBuffers/ExtensionRegistryLite.cs
rename to csharp/src/ProtocolBuffers/ExtensionRegistryLite.cs
diff --git a/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs
similarity index 100%
rename from src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs
rename to csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs
diff --git a/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs
similarity index 100%
rename from src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs
rename to csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs
diff --git a/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs b/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs
similarity index 100%
rename from src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs
rename to csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs
diff --git a/src/ProtocolBuffers/FieldAccess/RepeatedEnumAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/RepeatedEnumAccessor.cs
similarity index 100%
rename from src/ProtocolBuffers/FieldAccess/RepeatedEnumAccessor.cs
rename to csharp/src/ProtocolBuffers/FieldAccess/RepeatedEnumAccessor.cs
diff --git a/src/ProtocolBuffers/FieldAccess/RepeatedMessageAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/RepeatedMessageAccessor.cs
similarity index 100%
rename from src/ProtocolBuffers/FieldAccess/RepeatedMessageAccessor.cs
rename to csharp/src/ProtocolBuffers/FieldAccess/RepeatedMessageAccessor.cs
diff --git a/src/ProtocolBuffers/FieldAccess/RepeatedPrimitiveAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/RepeatedPrimitiveAccessor.cs
similarity index 100%
rename from src/ProtocolBuffers/FieldAccess/RepeatedPrimitiveAccessor.cs
rename to csharp/src/ProtocolBuffers/FieldAccess/RepeatedPrimitiveAccessor.cs
diff --git a/src/ProtocolBuffers/FieldAccess/SingleEnumAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/SingleEnumAccessor.cs
similarity index 100%
rename from src/ProtocolBuffers/FieldAccess/SingleEnumAccessor.cs
rename to csharp/src/ProtocolBuffers/FieldAccess/SingleEnumAccessor.cs
diff --git a/src/ProtocolBuffers/FieldAccess/SingleMessageAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/SingleMessageAccessor.cs
similarity index 100%
rename from src/ProtocolBuffers/FieldAccess/SingleMessageAccessor.cs
rename to csharp/src/ProtocolBuffers/FieldAccess/SingleMessageAccessor.cs
diff --git a/src/ProtocolBuffers/FieldAccess/SinglePrimitiveAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/SinglePrimitiveAccessor.cs
similarity index 100%
rename from src/ProtocolBuffers/FieldAccess/SinglePrimitiveAccessor.cs
rename to csharp/src/ProtocolBuffers/FieldAccess/SinglePrimitiveAccessor.cs
diff --git a/src/ProtocolBuffers/FieldSet.cs b/csharp/src/ProtocolBuffers/FieldSet.cs
similarity index 100%
rename from src/ProtocolBuffers/FieldSet.cs
rename to csharp/src/ProtocolBuffers/FieldSet.cs
diff --git a/src/ProtocolBuffers/FrameworkPortability.cs b/csharp/src/ProtocolBuffers/FrameworkPortability.cs
similarity index 100%
rename from src/ProtocolBuffers/FrameworkPortability.cs
rename to csharp/src/ProtocolBuffers/FrameworkPortability.cs
diff --git a/src/ProtocolBuffers/GeneratedBuilder.cs b/csharp/src/ProtocolBuffers/GeneratedBuilder.cs
similarity index 100%
rename from src/ProtocolBuffers/GeneratedBuilder.cs
rename to csharp/src/ProtocolBuffers/GeneratedBuilder.cs
diff --git a/src/ProtocolBuffers/GeneratedBuilderLite.cs b/csharp/src/ProtocolBuffers/GeneratedBuilderLite.cs
similarity index 100%
rename from src/ProtocolBuffers/GeneratedBuilderLite.cs
rename to csharp/src/ProtocolBuffers/GeneratedBuilderLite.cs
diff --git a/src/ProtocolBuffers/GeneratedExtensionBase.cs b/csharp/src/ProtocolBuffers/GeneratedExtensionBase.cs
similarity index 100%
rename from src/ProtocolBuffers/GeneratedExtensionBase.cs
rename to csharp/src/ProtocolBuffers/GeneratedExtensionBase.cs
diff --git a/src/ProtocolBuffers/GeneratedExtensionLite.cs b/csharp/src/ProtocolBuffers/GeneratedExtensionLite.cs
similarity index 100%
rename from src/ProtocolBuffers/GeneratedExtensionLite.cs
rename to csharp/src/ProtocolBuffers/GeneratedExtensionLite.cs
diff --git a/src/ProtocolBuffers/GeneratedMessage.cs b/csharp/src/ProtocolBuffers/GeneratedMessage.cs
similarity index 100%
rename from src/ProtocolBuffers/GeneratedMessage.cs
rename to csharp/src/ProtocolBuffers/GeneratedMessage.cs
diff --git a/src/ProtocolBuffers/GeneratedMessageLite.cs b/csharp/src/ProtocolBuffers/GeneratedMessageLite.cs
similarity index 100%
rename from src/ProtocolBuffers/GeneratedMessageLite.cs
rename to csharp/src/ProtocolBuffers/GeneratedMessageLite.cs
diff --git a/src/ProtocolBuffers/GeneratedRepeatExtension.cs b/csharp/src/ProtocolBuffers/GeneratedRepeatExtension.cs
similarity index 100%
rename from src/ProtocolBuffers/GeneratedRepeatExtension.cs
rename to csharp/src/ProtocolBuffers/GeneratedRepeatExtension.cs
diff --git a/src/ProtocolBuffers/GeneratedSingleExtension.cs b/csharp/src/ProtocolBuffers/GeneratedSingleExtension.cs
similarity index 100%
rename from src/ProtocolBuffers/GeneratedSingleExtension.cs
rename to csharp/src/ProtocolBuffers/GeneratedSingleExtension.cs
diff --git a/src/ProtocolBuffers/IBuilder.cs b/csharp/src/ProtocolBuffers/IBuilder.cs
similarity index 100%
rename from src/ProtocolBuffers/IBuilder.cs
rename to csharp/src/ProtocolBuffers/IBuilder.cs
diff --git a/src/ProtocolBuffers/IBuilderLite.cs b/csharp/src/ProtocolBuffers/IBuilderLite.cs
similarity index 100%
rename from src/ProtocolBuffers/IBuilderLite.cs
rename to csharp/src/ProtocolBuffers/IBuilderLite.cs
diff --git a/src/ProtocolBuffers/ICodedInputStream.cs b/csharp/src/ProtocolBuffers/ICodedInputStream.cs
similarity index 100%
rename from src/ProtocolBuffers/ICodedInputStream.cs
rename to csharp/src/ProtocolBuffers/ICodedInputStream.cs
diff --git a/src/ProtocolBuffers/ICodedOutputStream.cs b/csharp/src/ProtocolBuffers/ICodedOutputStream.cs
similarity index 100%
rename from src/ProtocolBuffers/ICodedOutputStream.cs
rename to csharp/src/ProtocolBuffers/ICodedOutputStream.cs
diff --git a/src/ProtocolBuffers/IMessage.cs b/csharp/src/ProtocolBuffers/IMessage.cs
similarity index 100%
rename from src/ProtocolBuffers/IMessage.cs
rename to csharp/src/ProtocolBuffers/IMessage.cs
diff --git a/src/ProtocolBuffers/IMessageLite.cs b/csharp/src/ProtocolBuffers/IMessageLite.cs
similarity index 100%
rename from src/ProtocolBuffers/IMessageLite.cs
rename to csharp/src/ProtocolBuffers/IMessageLite.cs
diff --git a/src/ProtocolBuffers/IRpcChannel.cs b/csharp/src/ProtocolBuffers/IRpcChannel.cs
similarity index 100%
rename from src/ProtocolBuffers/IRpcChannel.cs
rename to csharp/src/ProtocolBuffers/IRpcChannel.cs
diff --git a/src/ProtocolBuffers/IRpcController.cs b/csharp/src/ProtocolBuffers/IRpcController.cs
similarity index 100%
rename from src/ProtocolBuffers/IRpcController.cs
rename to csharp/src/ProtocolBuffers/IRpcController.cs
diff --git a/src/ProtocolBuffers/IRpcDispatch.cs b/csharp/src/ProtocolBuffers/IRpcDispatch.cs
similarity index 100%
rename from src/ProtocolBuffers/IRpcDispatch.cs
rename to csharp/src/ProtocolBuffers/IRpcDispatch.cs
diff --git a/src/ProtocolBuffers/IService.cs b/csharp/src/ProtocolBuffers/IService.cs
similarity index 100%
rename from src/ProtocolBuffers/IService.cs
rename to csharp/src/ProtocolBuffers/IService.cs
diff --git a/src/ProtocolBuffers/InvalidProtocolBufferException.cs b/csharp/src/ProtocolBuffers/InvalidProtocolBufferException.cs
similarity index 100%
rename from src/ProtocolBuffers/InvalidProtocolBufferException.cs
rename to csharp/src/ProtocolBuffers/InvalidProtocolBufferException.cs
diff --git a/src/ProtocolBuffers/MessageStreamIterator.cs b/csharp/src/ProtocolBuffers/MessageStreamIterator.cs
similarity index 100%
rename from src/ProtocolBuffers/MessageStreamIterator.cs
rename to csharp/src/ProtocolBuffers/MessageStreamIterator.cs
diff --git a/src/ProtocolBuffers/MessageStreamWriter.cs b/csharp/src/ProtocolBuffers/MessageStreamWriter.cs
similarity index 100%
rename from src/ProtocolBuffers/MessageStreamWriter.cs
rename to csharp/src/ProtocolBuffers/MessageStreamWriter.cs
diff --git a/src/ProtocolBuffers/MessageUtil.cs b/csharp/src/ProtocolBuffers/MessageUtil.cs
similarity index 100%
rename from src/ProtocolBuffers/MessageUtil.cs
rename to csharp/src/ProtocolBuffers/MessageUtil.cs
diff --git a/src/ProtocolBuffers/NameHelpers.cs b/csharp/src/ProtocolBuffers/NameHelpers.cs
similarity index 100%
rename from src/ProtocolBuffers/NameHelpers.cs
rename to csharp/src/ProtocolBuffers/NameHelpers.cs
diff --git a/src/ProtocolBuffers/Properties/AssemblyInfo.cs b/csharp/src/ProtocolBuffers/Properties/AssemblyInfo.cs
similarity index 100%
rename from src/ProtocolBuffers/Properties/AssemblyInfo.cs
rename to csharp/src/ProtocolBuffers/Properties/AssemblyInfo.cs
diff --git a/src/ProtocolBuffers/ProtocolBuffers.CF20.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.CF20.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffers.CF20.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffers.CF20.csproj
diff --git a/src/ProtocolBuffers/ProtocolBuffers.CF35.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.CF35.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffers.CF35.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffers.CF35.csproj
diff --git a/src/ProtocolBuffers/ProtocolBuffers.NET20.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.NET20.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffers.NET20.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffers.NET20.csproj
diff --git a/src/ProtocolBuffers/ProtocolBuffers.NET35.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.NET35.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffers.NET35.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffers.NET35.csproj
diff --git a/src/ProtocolBuffers/ProtocolBuffers.NET40.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.NET40.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffers.NET40.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffers.NET40.csproj
diff --git a/src/ProtocolBuffers/ProtocolBuffers.PL40.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.PL40.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffers.PL40.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffers.PL40.csproj
diff --git a/src/ProtocolBuffers/ProtocolBuffers.SL20.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.SL20.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffers.SL20.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffers.SL20.csproj
diff --git a/src/ProtocolBuffers/ProtocolBuffers.SL30.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.SL30.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffers.SL30.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffers.SL30.csproj
diff --git a/src/ProtocolBuffers/ProtocolBuffers.SL40.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.SL40.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffers.SL40.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffers.SL40.csproj
diff --git a/src/ProtocolBuffers/ProtocolBuffers.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffers.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffers.csproj
diff --git a/src/ProtocolBuffers/ProtocolBuffersLite.CF20.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffersLite.CF20.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffersLite.CF20.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffersLite.CF20.csproj
diff --git a/src/ProtocolBuffers/ProtocolBuffersLite.CF35.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffersLite.CF35.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffersLite.CF35.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffersLite.CF35.csproj
diff --git a/src/ProtocolBuffers/ProtocolBuffersLite.NET20.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffersLite.NET20.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffersLite.NET20.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffersLite.NET20.csproj
diff --git a/src/ProtocolBuffers/ProtocolBuffersLite.NET35.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffersLite.NET35.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffersLite.NET35.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffersLite.NET35.csproj
diff --git a/src/ProtocolBuffers/ProtocolBuffersLite.NET40.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffersLite.NET40.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffersLite.NET40.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffersLite.NET40.csproj
diff --git a/src/ProtocolBuffers/ProtocolBuffersLite.PL40.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffersLite.PL40.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffersLite.PL40.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffersLite.PL40.csproj
diff --git a/src/ProtocolBuffers/ProtocolBuffersLite.SL20.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffersLite.SL20.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffersLite.SL20.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffersLite.SL20.csproj
diff --git a/src/ProtocolBuffers/ProtocolBuffersLite.SL30.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffersLite.SL30.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffersLite.SL30.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffersLite.SL30.csproj
diff --git a/src/ProtocolBuffers/ProtocolBuffersLite.SL40.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffersLite.SL40.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffersLite.SL40.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffersLite.SL40.csproj
diff --git a/src/ProtocolBuffers/ProtocolBuffersLite.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffersLite.csproj
similarity index 100%
rename from src/ProtocolBuffers/ProtocolBuffersLite.csproj
rename to csharp/src/ProtocolBuffers/ProtocolBuffersLite.csproj
diff --git a/src/ProtocolBuffers/RpcUtil.cs b/csharp/src/ProtocolBuffers/RpcUtil.cs
similarity index 100%
rename from src/ProtocolBuffers/RpcUtil.cs
rename to csharp/src/ProtocolBuffers/RpcUtil.cs
diff --git a/src/ProtocolBuffers/SortedList.cs b/csharp/src/ProtocolBuffers/SortedList.cs
similarity index 100%
rename from src/ProtocolBuffers/SortedList.cs
rename to csharp/src/ProtocolBuffers/SortedList.cs
diff --git a/src/ProtocolBuffers/TextFormat.cs b/csharp/src/ProtocolBuffers/TextFormat.cs
similarity index 100%
rename from src/ProtocolBuffers/TextFormat.cs
rename to csharp/src/ProtocolBuffers/TextFormat.cs
diff --git a/src/ProtocolBuffers/TextGenerator.cs b/csharp/src/ProtocolBuffers/TextGenerator.cs
similarity index 100%
rename from src/ProtocolBuffers/TextGenerator.cs
rename to csharp/src/ProtocolBuffers/TextGenerator.cs
diff --git a/src/ProtocolBuffers/TextTokenizer.cs b/csharp/src/ProtocolBuffers/TextTokenizer.cs
similarity index 100%
rename from src/ProtocolBuffers/TextTokenizer.cs
rename to csharp/src/ProtocolBuffers/TextTokenizer.cs
diff --git a/src/ProtocolBuffers/ThrowHelper.cs b/csharp/src/ProtocolBuffers/ThrowHelper.cs
similarity index 100%
rename from src/ProtocolBuffers/ThrowHelper.cs
rename to csharp/src/ProtocolBuffers/ThrowHelper.cs
diff --git a/src/ProtocolBuffers/UninitializedMessageException.cs b/csharp/src/ProtocolBuffers/UninitializedMessageException.cs
similarity index 100%
rename from src/ProtocolBuffers/UninitializedMessageException.cs
rename to csharp/src/ProtocolBuffers/UninitializedMessageException.cs
diff --git a/src/ProtocolBuffers/UnknownField.cs b/csharp/src/ProtocolBuffers/UnknownField.cs
similarity index 100%
rename from src/ProtocolBuffers/UnknownField.cs
rename to csharp/src/ProtocolBuffers/UnknownField.cs
diff --git a/src/ProtocolBuffers/UnknownFieldSet.cs b/csharp/src/ProtocolBuffers/UnknownFieldSet.cs
similarity index 100%
rename from src/ProtocolBuffers/UnknownFieldSet.cs
rename to csharp/src/ProtocolBuffers/UnknownFieldSet.cs
diff --git a/src/ProtocolBuffers/WireFormat.cs b/csharp/src/ProtocolBuffers/WireFormat.cs
similarity index 100%
rename from src/ProtocolBuffers/WireFormat.cs
rename to csharp/src/ProtocolBuffers/WireFormat.cs
diff --git a/src/ProtocolBuffersLibrary.CF20.sln b/csharp/src/ProtocolBuffersLibrary.CF20.sln
similarity index 100%
rename from src/ProtocolBuffersLibrary.CF20.sln
rename to csharp/src/ProtocolBuffersLibrary.CF20.sln
diff --git a/src/ProtocolBuffersLibrary.CF35.sln b/csharp/src/ProtocolBuffersLibrary.CF35.sln
similarity index 100%
rename from src/ProtocolBuffersLibrary.CF35.sln
rename to csharp/src/ProtocolBuffersLibrary.CF35.sln
diff --git a/src/ProtocolBuffersLibrary.NET20.sln b/csharp/src/ProtocolBuffersLibrary.NET20.sln
similarity index 100%
rename from src/ProtocolBuffersLibrary.NET20.sln
rename to csharp/src/ProtocolBuffersLibrary.NET20.sln
diff --git a/src/ProtocolBuffersLibrary.NET35.sln b/csharp/src/ProtocolBuffersLibrary.NET35.sln
similarity index 100%
rename from src/ProtocolBuffersLibrary.NET35.sln
rename to csharp/src/ProtocolBuffersLibrary.NET35.sln
diff --git a/src/ProtocolBuffersLibrary.NET40.sln b/csharp/src/ProtocolBuffersLibrary.NET40.sln
similarity index 100%
rename from src/ProtocolBuffersLibrary.NET40.sln
rename to csharp/src/ProtocolBuffersLibrary.NET40.sln
diff --git a/src/ProtocolBuffersLibrary.PL40.sln b/csharp/src/ProtocolBuffersLibrary.PL40.sln
similarity index 100%
rename from src/ProtocolBuffersLibrary.PL40.sln
rename to csharp/src/ProtocolBuffersLibrary.PL40.sln
diff --git a/src/ProtocolBuffersLibrary.SL20.sln b/csharp/src/ProtocolBuffersLibrary.SL20.sln
similarity index 100%
rename from src/ProtocolBuffersLibrary.SL20.sln
rename to csharp/src/ProtocolBuffersLibrary.SL20.sln
diff --git a/src/ProtocolBuffersLibrary.SL30.sln b/csharp/src/ProtocolBuffersLibrary.SL30.sln
similarity index 100%
rename from src/ProtocolBuffersLibrary.SL30.sln
rename to csharp/src/ProtocolBuffersLibrary.SL30.sln
diff --git a/src/ProtocolBuffersLibrary.SL40.sln b/csharp/src/ProtocolBuffersLibrary.SL40.sln
similarity index 100%
rename from src/ProtocolBuffersLibrary.SL40.sln
rename to csharp/src/ProtocolBuffersLibrary.SL40.sln
diff --git a/src/ProtocolBuffersLibrary.sln b/csharp/src/ProtocolBuffersLibrary.sln
similarity index 100%
rename from src/ProtocolBuffersLibrary.sln
rename to csharp/src/ProtocolBuffersLibrary.sln
diff --git a/src/ProtocolBuffersLite.Test/AbstractBuilderLiteTest.cs b/csharp/src/ProtocolBuffersLite.Test/AbstractBuilderLiteTest.cs
similarity index 100%
rename from src/ProtocolBuffersLite.Test/AbstractBuilderLiteTest.cs
rename to csharp/src/ProtocolBuffersLite.Test/AbstractBuilderLiteTest.cs
diff --git a/src/ProtocolBuffersLite.Test/AbstractMessageLiteTest.cs b/csharp/src/ProtocolBuffersLite.Test/AbstractMessageLiteTest.cs
similarity index 100%
rename from src/ProtocolBuffersLite.Test/AbstractMessageLiteTest.cs
rename to csharp/src/ProtocolBuffersLite.Test/AbstractMessageLiteTest.cs
diff --git a/src/ProtocolBuffersLite.Test/App.xaml b/csharp/src/ProtocolBuffersLite.Test/App.xaml
similarity index 100%
rename from src/ProtocolBuffersLite.Test/App.xaml
rename to csharp/src/ProtocolBuffersLite.Test/App.xaml
diff --git a/src/ProtocolBuffersLite.Test/App.xaml.cs b/csharp/src/ProtocolBuffersLite.Test/App.xaml.cs
similarity index 100%
rename from src/ProtocolBuffersLite.Test/App.xaml.cs
rename to csharp/src/ProtocolBuffersLite.Test/App.xaml.cs
diff --git a/src/ProtocolBuffersLite.Test/ExtendableBuilderLiteTest.cs b/csharp/src/ProtocolBuffersLite.Test/ExtendableBuilderLiteTest.cs
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ExtendableBuilderLiteTest.cs
rename to csharp/src/ProtocolBuffersLite.Test/ExtendableBuilderLiteTest.cs
diff --git a/src/ProtocolBuffersLite.Test/ExtendableMessageLiteTest.cs b/csharp/src/ProtocolBuffersLite.Test/ExtendableMessageLiteTest.cs
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ExtendableMessageLiteTest.cs
rename to csharp/src/ProtocolBuffersLite.Test/ExtendableMessageLiteTest.cs
diff --git a/src/ProtocolBuffersLite.Test/InteropLiteTest.cs b/csharp/src/ProtocolBuffersLite.Test/InteropLiteTest.cs
similarity index 100%
rename from src/ProtocolBuffersLite.Test/InteropLiteTest.cs
rename to csharp/src/ProtocolBuffersLite.Test/InteropLiteTest.cs
diff --git a/src/ProtocolBuffersLite.Test/LiteTest.cs b/csharp/src/ProtocolBuffersLite.Test/LiteTest.cs
similarity index 100%
rename from src/ProtocolBuffersLite.Test/LiteTest.cs
rename to csharp/src/ProtocolBuffersLite.Test/LiteTest.cs
diff --git a/src/ProtocolBuffersLite.Test/MissingFieldAndExtensionTest.cs b/csharp/src/ProtocolBuffersLite.Test/MissingFieldAndExtensionTest.cs
similarity index 100%
rename from src/ProtocolBuffersLite.Test/MissingFieldAndExtensionTest.cs
rename to csharp/src/ProtocolBuffersLite.Test/MissingFieldAndExtensionTest.cs
diff --git a/src/ProtocolBuffersLite.Test/Properties/AppManifest.xml b/csharp/src/ProtocolBuffersLite.Test/Properties/AppManifest.xml
similarity index 100%
rename from src/ProtocolBuffersLite.Test/Properties/AppManifest.xml
rename to csharp/src/ProtocolBuffersLite.Test/Properties/AppManifest.xml
diff --git a/src/ProtocolBuffersLite.Test/Properties/OutOfBrowserSettings.xml b/csharp/src/ProtocolBuffersLite.Test/Properties/OutOfBrowserSettings.xml
similarity index 100%
rename from src/ProtocolBuffersLite.Test/Properties/OutOfBrowserSettings.xml
rename to csharp/src/ProtocolBuffersLite.Test/Properties/OutOfBrowserSettings.xml
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.CF20.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.CF20.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.CF20.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.CF20.csproj
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.CF35.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.CF35.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.CF35.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.CF35.csproj
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.NET20.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.NET20.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.NET20.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.NET20.csproj
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.NET35.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.NET35.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.NET35.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.NET35.csproj
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.NET40.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.NET40.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.NET40.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.NET40.csproj
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.PL40.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.PL40.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.PL40.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.PL40.csproj
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.SL20.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.SL20.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.SL20.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.SL20.csproj
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.SL30.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.SL30.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.SL30.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.SL30.csproj
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.SL40.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.SL40.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.SL40.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.SL40.csproj
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.csproj
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.CF20.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.CF20.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.CF20.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.CF20.csproj
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.CF35.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.CF35.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.CF35.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.CF35.csproj
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.NET20.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.NET20.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.NET20.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.NET20.csproj
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.NET35.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.NET35.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.NET35.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.NET35.csproj
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.NET40.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.NET40.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.NET40.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.NET40.csproj
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.PL40.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.PL40.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.PL40.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.PL40.csproj
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.SL20.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.SL20.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.SL20.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.SL20.csproj
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.SL30.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.SL30.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.SL30.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.SL30.csproj
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.SL40.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.SL40.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.SL40.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.SL40.csproj
diff --git a/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj
similarity index 100%
rename from src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj
rename to csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj
diff --git a/src/ProtocolBuffersLite.Test/SerializableLiteTest.cs b/csharp/src/ProtocolBuffersLite.Test/SerializableLiteTest.cs
similarity index 100%
rename from src/ProtocolBuffersLite.Test/SerializableLiteTest.cs
rename to csharp/src/ProtocolBuffersLite.Test/SerializableLiteTest.cs
diff --git a/src/ProtocolBuffersLite.Test/TestLiteByApi.cs b/csharp/src/ProtocolBuffersLite.Test/TestLiteByApi.cs
similarity index 100%
rename from src/ProtocolBuffersLite.Test/TestLiteByApi.cs
rename to csharp/src/ProtocolBuffersLite.Test/TestLiteByApi.cs
diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasFullProtoFile.cs b/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasFullProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasFullProtoFile.cs
rename to csharp/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasFullProtoFile.cs
diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs b/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs
rename to csharp/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs
diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportLiteProtoFile.cs b/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportLiteProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportLiteProtoFile.cs
rename to csharp/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportLiteProtoFile.cs
diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportProtoFile.cs b/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportProtoFile.cs
rename to csharp/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportProtoFile.cs
diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteImportNonLiteProtoFile.cs b/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteImportNonLiteProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteImportNonLiteProtoFile.cs
rename to csharp/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteImportNonLiteProtoFile.cs
diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteProtoFile.cs b/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteProtoFile.cs
rename to csharp/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteProtoFile.cs
diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestProtoFile.cs b/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnitTestProtoFile.cs
similarity index 100%
rename from src/ProtocolBuffersLite.Test/TestProtos/UnitTestProtoFile.cs
rename to csharp/src/ProtocolBuffersLite.Test/TestProtos/UnitTestProtoFile.cs
diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestRpcInteropLite.cs b/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnitTestRpcInteropLite.cs
similarity index 100%
rename from src/ProtocolBuffersLite.Test/TestProtos/UnitTestRpcInteropLite.cs
rename to csharp/src/ProtocolBuffersLite.Test/TestProtos/UnitTestRpcInteropLite.cs
diff --git a/src/ProtocolBuffersLite.Test/TestUtil.cs b/csharp/src/ProtocolBuffersLite.Test/TestUtil.cs
similarity index 100%
rename from src/ProtocolBuffersLite.Test/TestUtil.cs
rename to csharp/src/ProtocolBuffersLite.Test/TestUtil.cs
diff --git a/src/UseVS2008.bat b/csharp/src/UseVS2008.bat
similarity index 100%
rename from src/UseVS2008.bat
rename to csharp/src/UseVS2008.bat
diff --git a/src/UseVS2010.bat b/csharp/src/UseVS2010.bat
similarity index 100%
rename from src/UseVS2010.bat
rename to csharp/src/UseVS2010.bat
diff --git a/testdata/golden_message b/csharp/testdata/golden_message
similarity index 100%
rename from testdata/golden_message
rename to csharp/testdata/golden_message
Binary files differ
diff --git a/testdata/golden_packed_fields_message b/csharp/testdata/golden_packed_fields_message
similarity index 100%
rename from testdata/golden_packed_fields_message
rename to csharp/testdata/golden_packed_fields_message
Binary files differ
diff --git a/testdata/text_format_unittest_data.txt b/csharp/testdata/text_format_unittest_data.txt
similarity index 100%
rename from testdata/text_format_unittest_data.txt
rename to csharp/testdata/text_format_unittest_data.txt
diff --git a/testdata/text_format_unittest_extensions_data.txt b/csharp/testdata/text_format_unittest_extensions_data.txt
similarity index 100%
rename from testdata/text_format_unittest_extensions_data.txt
rename to csharp/testdata/text_format_unittest_extensions_data.txt
diff --git a/editors/README.txt b/editors/README.txt
new file mode 100644
index 0000000..3e9fc79
--- /dev/null
+++ b/editors/README.txt
@@ -0,0 +1,5 @@
+This directory contains syntax highlighting and configuration files for editors
+to properly display Protocol Buffer files.
+
+See each file's header comment for directions on how to use it with the
+appropriate editor.
diff --git a/editors/proto.vim b/editors/proto.vim
new file mode 100644
index 0000000..23085a2
--- /dev/null
+++ b/editors/proto.vim
@@ -0,0 +1,105 @@
+" 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 is the Vim syntax file for Google Protocol Buffers.
+"
+" Usage:
+"
+" 1. cp proto.vim ~/.vim/syntax/
+" 2. Add the following to ~/.vimrc:
+"
+" augroup filetype
+" au! BufRead,BufNewFile *.proto setfiletype proto
+" augroup end
+"
+" Or just create a new file called ~/.vim/ftdetect/proto.vim with the
+" previous lines on it.
+
+if version < 600
+ syntax clear
+elseif exists("b:current_syntax")
+ finish
+endif
+
+syn case match
+
+syn keyword pbTodo contained TODO FIXME XXX
+syn cluster pbCommentGrp contains=pbTodo
+
+syn keyword pbSyntax syntax import option
+syn keyword pbStructure package message group oneof
+syn keyword pbRepeat optional required repeated
+syn keyword pbDefault default
+syn keyword pbExtend extend extensions to max
+syn keyword pbRPC service rpc returns
+
+syn keyword pbType int32 int64 uint32 uint64 sint32 sint64
+syn keyword pbType fixed32 fixed64 sfixed32 sfixed64
+syn keyword pbType float double bool string bytes
+syn keyword pbTypedef enum
+syn keyword pbBool true false
+
+syn match pbInt /-\?\<\d\+\>/
+syn match pbInt /\<0[xX]\x+\>/
+syn match pbFloat /\<-\?\d*\(\.\d*\)\?/
+syn region pbComment start="\/\*" end="\*\/" contains=@pbCommentGrp
+syn region pbComment start="//" skip="\\$" end="$" keepend contains=@pbCommentGrp
+syn region pbString start=/"/ skip=/\\./ end=/"/
+syn region pbString start=/'/ skip=/\\./ end=/'/
+
+if version >= 508 || !exists("did_proto_syn_inits")
+ if version < 508
+ let did_proto_syn_inits = 1
+ command -nargs=+ HiLink hi link <args>
+ else
+ command -nargs=+ HiLink hi def link <args>
+ endif
+
+ HiLink pbTodo Todo
+
+ HiLink pbSyntax Include
+ HiLink pbStructure Structure
+ HiLink pbRepeat Repeat
+ HiLink pbDefault Keyword
+ HiLink pbExtend Keyword
+ HiLink pbRPC Keyword
+ HiLink pbType Type
+ HiLink pbTypedef Typedef
+ HiLink pbBool Boolean
+
+ HiLink pbInt Number
+ HiLink pbFloat Float
+ HiLink pbComment Comment
+ HiLink pbString String
+
+ delcommand HiLink
+endif
+
+let b:current_syntax = "proto"
diff --git a/editors/protobuf-mode.el b/editors/protobuf-mode.el
new file mode 100644
index 0000000..09aecc9
--- /dev/null
+++ b/editors/protobuf-mode.el
@@ -0,0 +1,220 @@
+;;; protobuf-mode.el --- major mode for editing protocol buffers.
+
+;; Author: Alexandre Vassalotti <alexandre@peadrop.com>
+;; Created: 23-Apr-2009
+;; Version: 0.3
+;; Keywords: google protobuf languages
+
+;; 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.
+
+;;; Commentary:
+
+;; Installation:
+;; - Put `protobuf-mode.el' in your Emacs load-path.
+;; - Add this line to your .emacs file:
+;; (require 'protobuf-mode)
+;;
+;; You can customize this mode just like any mode derived from CC Mode. If
+;; you want to add customizations specific to protobuf-mode, you can use the
+;; `protobuf-mode-hook'. For example, the following would make protocol-mode
+;; use 2-space indentation:
+;;
+;; (defconst my-protobuf-style
+;; '((c-basic-offset . 2)
+;; (indent-tabs-mode . nil)))
+;;
+;; (add-hook 'protobuf-mode-hook
+;; (lambda () (c-add-style "my-style" my-protobuf-style t)))
+;;
+;; Refer to the documentation of CC Mode for more information about
+;; customization details and how to use this mode.
+;;
+;; TODO:
+;; - Make highlighting for enum values work properly.
+;; - Fix the parser to recognize extensions as identifiers and not
+;; as casts.
+;; - Improve the parsing of option assignment lists. For example:
+;; optional int32 foo = 1 [(my_field_option) = 4.5];
+;; - Add support for fully-qualified identifiers (e.g., with a leading ".").
+
+;;; Code:
+
+(require 'cc-mode)
+
+(eval-when-compile
+ (require 'cc-langs)
+ (require 'cc-fonts))
+
+;; This mode does not inherit properties from other modes. So, we do not use
+;; the usual `c-add-language' function.
+(eval-and-compile
+ (put 'protobuf-mode 'c-mode-prefix "protobuf-"))
+
+;; The following code uses of the `c-lang-defconst' macro define syntactic
+;; features of protocol buffer language. Refer to the documentation in the
+;; cc-langs.el file for information about the meaning of the -kwds variables.
+
+(c-lang-defconst c-primitive-type-kwds
+ protobuf '("double" "float" "int32" "int64" "uint32" "uint64" "sint32"
+ "sint64" "fixed32" "fixed64" "sfixed32" "sfixed64" "bool"
+ "string" "bytes" "group"))
+
+(c-lang-defconst c-modifier-kwds
+ protobuf '("required" "optional" "repeated"))
+
+(c-lang-defconst c-class-decl-kwds
+ protobuf '("message" "enum" "service"))
+
+(c-lang-defconst c-constant-kwds
+ protobuf '("true" "false"))
+
+(c-lang-defconst c-other-decl-kwds
+ protobuf '("package" "import"))
+
+(c-lang-defconst c-other-kwds
+ protobuf '("default" "max"))
+
+(c-lang-defconst c-identifier-ops
+ ;; Handle extended identifiers like google.protobuf.MessageOptions
+ protobuf '((left-assoc ".")))
+
+;; The following keywords do not fit well in keyword classes defined by
+;; cc-mode. So, we approximate as best we can.
+
+(c-lang-defconst c-type-list-kwds
+ protobuf '("extensions" "to"))
+
+(c-lang-defconst c-typeless-decl-kwds
+ protobuf '("extend" "rpc" "option" "returns"))
+
+
+;; Here we remove default syntax for loops, if-statements and other C
+;; syntactic features that are not supported by the protocol buffer language.
+
+(c-lang-defconst c-brace-list-decl-kwds
+ ;; Remove syntax for C-style enumerations.
+ protobuf nil)
+
+(c-lang-defconst c-block-stmt-1-kwds
+ ;; Remove syntax for "do" and "else" keywords.
+ protobuf nil)
+
+(c-lang-defconst c-block-stmt-2-kwds
+ ;; Remove syntax for "for", "if", "switch" and "while" keywords.
+ protobuf nil)
+
+(c-lang-defconst c-simple-stmt-kwds
+ ;; Remove syntax for "break", "continue", "goto" and "return" keywords.
+ protobuf nil)
+
+(c-lang-defconst c-paren-stmt-kwds
+ ;; Remove special case for the "(;;)" in for-loops.
+ protobuf nil)
+
+(c-lang-defconst c-label-kwds
+ ;; Remove case label syntax for the "case" and "default" keywords.
+ protobuf nil)
+
+(c-lang-defconst c-before-label-kwds
+ ;; Remove special case for the label in a goto statement.
+ protobuf nil)
+
+(c-lang-defconst c-cpp-matchers
+ ;; Disable all the C preprocessor syntax.
+ protobuf nil)
+
+(c-lang-defconst c-decl-prefix-re
+ ;; Same as for C, except it does not match "(". This is needed for disabling
+ ;; the syntax for casts.
+ protobuf "\\([\{\};,]+\\)")
+
+
+;; Add support for variable levels of syntax highlighting.
+
+(defconst protobuf-font-lock-keywords-1 (c-lang-const c-matchers-1 protobuf)
+ "Minimal highlighting for protobuf-mode.")
+
+(defconst protobuf-font-lock-keywords-2 (c-lang-const c-matchers-2 protobuf)
+ "Fast normal highlighting for protobuf-mode.")
+
+(defconst protobuf-font-lock-keywords-3 (c-lang-const c-matchers-3 protobuf)
+ "Accurate normal highlighting for protobuf-mode.")
+
+(defvar protobuf-font-lock-keywords protobuf-font-lock-keywords-3
+ "Default expressions to highlight in protobuf-mode.")
+
+;; Our syntax table is auto-generated from the keyword classes we defined
+;; previously with the `c-lang-const' macro.
+(defvar protobuf-mode-syntax-table nil
+ "Syntax table used in protobuf-mode buffers.")
+(or protobuf-mode-syntax-table
+ (setq protobuf-mode-syntax-table
+ (funcall (c-lang-const c-make-mode-syntax-table protobuf))))
+
+(defvar protobuf-mode-abbrev-table nil
+ "Abbreviation table used in protobuf-mode buffers.")
+
+(defvar protobuf-mode-map nil
+ "Keymap used in protobuf-mode buffers.")
+(or protobuf-mode-map
+ (setq protobuf-mode-map (c-make-inherited-keymap)))
+
+(easy-menu-define protobuf-menu protobuf-mode-map
+ "Protocol Buffers Mode Commands"
+ (cons "Protocol Buffers" (c-lang-const c-mode-menu protobuf)))
+
+;;;###autoload (add-to-list 'auto-mode-alist '("\\.proto\\'" . protobuf-mode))
+
+;;;###autoload
+(defun protobuf-mode ()
+ "Major mode for editing Protocol Buffers description language.
+
+The hook `c-mode-common-hook' is run with no argument at mode
+initialization, then `protobuf-mode-hook'.
+
+Key bindings:
+\\{protobuf-mode-map}"
+ (interactive)
+ (kill-all-local-variables)
+ (set-syntax-table protobuf-mode-syntax-table)
+ (setq major-mode 'protobuf-mode
+ mode-name "Protocol-Buffers"
+ local-abbrev-table protobuf-mode-abbrev-table
+ abbrev-mode t)
+ (use-local-map protobuf-mode-map)
+ (c-initialize-cc-mode t)
+ (if (fboundp 'c-make-emacs-variables-local)
+ (c-make-emacs-variables-local))
+ (c-init-language-vars protobuf-mode)
+ (c-common-init 'protobuf-mode)
+ (easy-menu-add protobuf-menu)
+ (c-run-mode-hooks 'c-mode-common-hook 'protobuf-mode-hook)
+ (c-update-modeline))
+
+(provide 'protobuf-mode)
+
+;;; protobuf-mode.el ends here
diff --git a/examples/AddPerson.java b/examples/AddPerson.java
new file mode 100644
index 0000000..ca5ac27
--- /dev/null
+++ b/examples/AddPerson.java
@@ -0,0 +1,95 @@
+// See README.txt for information and build instructions.
+
+import com.example.tutorial.AddressBookProtos.AddressBook;
+import com.example.tutorial.AddressBookProtos.Person;
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.PrintStream;
+
+class AddPerson {
+ // This function fills in a Person message based on user input.
+ static Person PromptForAddress(BufferedReader stdin,
+ PrintStream stdout) throws IOException {
+ Person.Builder person = Person.newBuilder();
+
+ stdout.print("Enter person ID: ");
+ person.setId(Integer.valueOf(stdin.readLine()));
+
+ stdout.print("Enter name: ");
+ person.setName(stdin.readLine());
+
+ stdout.print("Enter email address (blank for none): ");
+ String email = stdin.readLine();
+ if (email.length() > 0) {
+ person.setEmail(email);
+ }
+
+ while (true) {
+ stdout.print("Enter a phone number (or leave blank to finish): ");
+ String number = stdin.readLine();
+ if (number.length() == 0) {
+ break;
+ }
+
+ Person.PhoneNumber.Builder phoneNumber =
+ Person.PhoneNumber.newBuilder().setNumber(number);
+
+ stdout.print("Is this a mobile, home, or work phone? ");
+ String type = stdin.readLine();
+ if (type.equals("mobile")) {
+ phoneNumber.setType(Person.PhoneType.MOBILE);
+ } else if (type.equals("home")) {
+ phoneNumber.setType(Person.PhoneType.HOME);
+ } else if (type.equals("work")) {
+ phoneNumber.setType(Person.PhoneType.WORK);
+ } else {
+ stdout.println("Unknown phone type. Using default.");
+ }
+
+ person.addPhone(phoneNumber);
+ }
+
+ return person.build();
+ }
+
+ // Main function: Reads the entire address book from a file,
+ // adds one person based on user input, then writes it back out to the same
+ // file.
+ public static void main(String[] args) throws Exception {
+ if (args.length != 1) {
+ System.err.println("Usage: AddPerson ADDRESS_BOOK_FILE");
+ System.exit(-1);
+ }
+
+ AddressBook.Builder addressBook = AddressBook.newBuilder();
+
+ // Read the existing address book.
+ try {
+ FileInputStream input = new FileInputStream(args[0]);
+ try {
+ addressBook.mergeFrom(input);
+ } finally {
+ try { input.close(); } catch (Throwable ignore) {}
+ }
+ } catch (FileNotFoundException e) {
+ System.out.println(args[0] + ": File not found. Creating a new file.");
+ }
+
+ // Add an address.
+ addressBook.addPerson(
+ PromptForAddress(new BufferedReader(new InputStreamReader(System.in)),
+ System.out));
+
+ // Write the new address book back to disk.
+ FileOutputStream output = new FileOutputStream(args[0]);
+ try {
+ addressBook.build().writeTo(output);
+ } finally {
+ output.close();
+ }
+ }
+}
diff --git a/examples/ListPeople.java b/examples/ListPeople.java
new file mode 100644
index 0000000..b2f153a
--- /dev/null
+++ b/examples/ListPeople.java
@@ -0,0 +1,50 @@
+// See README.txt for information and build instructions.
+
+import com.example.tutorial.AddressBookProtos.AddressBook;
+import com.example.tutorial.AddressBookProtos.Person;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+
+class ListPeople {
+ // Iterates though all people in the AddressBook and prints info about them.
+ static void Print(AddressBook addressBook) {
+ for (Person person: addressBook.getPersonList()) {
+ System.out.println("Person ID: " + person.getId());
+ System.out.println(" Name: " + person.getName());
+ if (person.hasEmail()) {
+ System.out.println(" E-mail address: " + person.getEmail());
+ }
+
+ for (Person.PhoneNumber phoneNumber : person.getPhoneList()) {
+ switch (phoneNumber.getType()) {
+ case MOBILE:
+ System.out.print(" Mobile phone #: ");
+ break;
+ case HOME:
+ System.out.print(" Home phone #: ");
+ break;
+ case WORK:
+ System.out.print(" Work phone #: ");
+ break;
+ }
+ System.out.println(phoneNumber.getNumber());
+ }
+ }
+ }
+
+ // Main function: Reads the entire address book from a file and prints all
+ // the information inside.
+ public static void main(String[] args) throws Exception {
+ if (args.length != 1) {
+ System.err.println("Usage: ListPeople ADDRESS_BOOK_FILE");
+ System.exit(-1);
+ }
+
+ // Read the existing address book.
+ AddressBook addressBook =
+ AddressBook.parseFrom(new FileInputStream(args[0]));
+
+ Print(addressBook);
+ }
+}
diff --git a/examples/Makefile b/examples/Makefile
new file mode 100644
index 0000000..8dc9083
--- /dev/null
+++ b/examples/Makefile
@@ -0,0 +1,58 @@
+# See README.txt.
+
+.PHONY: all cpp java python clean
+
+all: cpp java python
+
+cpp: add_person_cpp list_people_cpp
+java: add_person_java list_people_java
+python: add_person_python list_people_python
+
+clean:
+ rm -f add_person_cpp list_people_cpp add_person_java list_people_java add_person_python list_people_python
+ rm -f javac_middleman AddPerson*.class ListPeople*.class com/example/tutorial/*.class
+ rm -f protoc_middleman addressbook.pb.cc addressbook.pb.h addressbook_pb2.py com/example/tutorial/AddressBookProtos.java
+ rm -f *.pyc
+ rmdir com/example/tutorial 2>/dev/null || true
+ rmdir com/example 2>/dev/null || true
+ rmdir com 2>/dev/null || true
+
+protoc_middleman: addressbook.proto
+ protoc --cpp_out=. --java_out=. --python_out=. addressbook.proto
+ @touch protoc_middleman
+
+add_person_cpp: add_person.cc protoc_middleman
+ pkg-config --cflags protobuf # fails if protobuf is not installed
+ c++ add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf`
+
+list_people_cpp: list_people.cc protoc_middleman
+ pkg-config --cflags protobuf # fails if protobuf is not installed
+ c++ list_people.cc addressbook.pb.cc -o list_people_cpp `pkg-config --cflags --libs protobuf`
+
+javac_middleman: AddPerson.java ListPeople.java protoc_middleman
+ javac AddPerson.java ListPeople.java com/example/tutorial/AddressBookProtos.java
+ @touch javac_middleman
+
+add_person_java: javac_middleman
+ @echo "Writing shortcut script add_person_java..."
+ @echo '#! /bin/sh' > add_person_java
+ @echo 'java -classpath .:$$CLASSPATH AddPerson "$$@"' >> add_person_java
+ @chmod +x add_person_java
+
+list_people_java: javac_middleman
+ @echo "Writing shortcut script list_people_java..."
+ @echo '#! /bin/sh' > list_people_java
+ @echo 'java -classpath .:$$CLASSPATH ListPeople "$$@"' >> list_people_java
+ @chmod +x list_people_java
+
+add_person_python: add_person.py protoc_middleman
+ @echo "Writing shortcut script add_person_python..."
+ @echo '#! /bin/sh' > add_person_python
+ @echo './add_person.py "$$@"' >> add_person_python
+ @chmod +x add_person_python
+
+list_people_python: list_people.py protoc_middleman
+ @echo "Writing shortcut script list_people_python..."
+ @echo '#! /bin/sh' > list_people_python
+ @echo './list_people.py "$$@"' >> list_people_python
+ @chmod +x list_people_python
diff --git a/examples/README.txt b/examples/README.txt
new file mode 100644
index 0000000..f5530a5
--- /dev/null
+++ b/examples/README.txt
@@ -0,0 +1,29 @@
+This directory contains example code that uses Protocol Buffers to manage an
+address book. Two programs are provided, each with three different
+implementations, one written in each of C++, Java, and Python. The add_person
+example adds a new person to an address book, prompting the user to input
+the person's information. The list_people example lists people already in the
+address book. The examples use the exact same format in all three languages,
+so you can, for example, use add_person_java to create an address book and then
+use list_people_python to read it.
+
+You must install the protobuf package before you can build these.
+
+To build all the examples (on a unix-like system), simply run "make". This
+creates the following executable files in the current directory:
+ add_person_cpp list_people_cpp
+ add_person_java list_people_java
+ add_person_python list_people_python
+
+If you only want to compile examples in one language, use "make cpp"*,
+"make java", or "make python".
+
+All of these programs simply take an address book file as their parameter.
+The add_person programs will create the file if it doesn't already exist.
+
+These examples are part of the Protocol Buffers tutorial, located at:
+ https://developers.google.com/protocol-buffers/docs/tutorials
+
+* Note that on some platforms you may have to edit the Makefile and remove
+"-lpthread" from the linker commands (perhaps replacing it with something else).
+We didn't do this automatically because we wanted to keep the example simple.
diff --git a/examples/add_person.cc b/examples/add_person.cc
new file mode 100644
index 0000000..b9ca44f
--- /dev/null
+++ b/examples/add_person.cc
@@ -0,0 +1,95 @@
+// See README.txt for information and build instructions.
+
+#include <iostream>
+#include <fstream>
+#include <string>
+#include "addressbook.pb.h"
+using namespace std;
+
+// This function fills in a Person message based on user input.
+void PromptForAddress(tutorial::Person* person) {
+ cout << "Enter person ID number: ";
+ int id;
+ cin >> id;
+ person->set_id(id);
+ cin.ignore(256, '\n');
+
+ cout << "Enter name: ";
+ getline(cin, *person->mutable_name());
+
+ cout << "Enter email address (blank for none): ";
+ string email;
+ getline(cin, email);
+ if (!email.empty()) {
+ person->set_email(email);
+ }
+
+ while (true) {
+ cout << "Enter a phone number (or leave blank to finish): ";
+ string number;
+ getline(cin, number);
+ if (number.empty()) {
+ break;
+ }
+
+ tutorial::Person::PhoneNumber* phone_number = person->add_phone();
+ phone_number->set_number(number);
+
+ cout << "Is this a mobile, home, or work phone? ";
+ string type;
+ getline(cin, type);
+ if (type == "mobile") {
+ phone_number->set_type(tutorial::Person::MOBILE);
+ } else if (type == "home") {
+ phone_number->set_type(tutorial::Person::HOME);
+ } else if (type == "work") {
+ phone_number->set_type(tutorial::Person::WORK);
+ } else {
+ cout << "Unknown phone type. Using default." << endl;
+ }
+ }
+}
+
+// Main function: Reads the entire address book from a file,
+// adds one person based on user input, then writes it back out to the same
+// file.
+int main(int argc, char* argv[]) {
+ // Verify that the version of the library that we linked against is
+ // compatible with the version of the headers we compiled against.
+ GOOGLE_PROTOBUF_VERIFY_VERSION;
+
+ if (argc != 2) {
+ cerr << "Usage: " << argv[0] << " ADDRESS_BOOK_FILE" << endl;
+ return -1;
+ }
+
+ tutorial::AddressBook address_book;
+
+ {
+ // Read the existing address book.
+ fstream input(argv[1], ios::in | ios::binary);
+ if (!input) {
+ cout << argv[1] << ": File not found. Creating a new file." << endl;
+ } else if (!address_book.ParseFromIstream(&input)) {
+ cerr << "Failed to parse address book." << endl;
+ return -1;
+ }
+ }
+
+ // Add an address.
+ PromptForAddress(address_book.add_person());
+
+ {
+ // Write the new address book back to disk.
+ fstream output(argv[1], ios::out | ios::trunc | ios::binary);
+ if (!address_book.SerializeToOstream(&output)) {
+ cerr << "Failed to write address book." << endl;
+ return -1;
+ }
+ }
+
+ // Optional: Delete all global objects allocated by libprotobuf.
+ google::protobuf::ShutdownProtobufLibrary();
+
+ return 0;
+}
diff --git a/examples/add_person.py b/examples/add_person.py
new file mode 100755
index 0000000..78e5696
--- /dev/null
+++ b/examples/add_person.py
@@ -0,0 +1,58 @@
+#! /usr/bin/python
+
+# See README.txt for information and build instructions.
+
+import addressbook_pb2
+import sys
+
+# This function fills in a Person message based on user input.
+def PromptForAddress(person):
+ person.id = int(raw_input("Enter person ID number: "))
+ person.name = raw_input("Enter name: ")
+
+ email = raw_input("Enter email address (blank for none): ")
+ if email != "":
+ person.email = email
+
+ while True:
+ number = raw_input("Enter a phone number (or leave blank to finish): ")
+ if number == "":
+ break
+
+ phone_number = person.phone.add()
+ phone_number.number = number
+
+ type = raw_input("Is this a mobile, home, or work phone? ")
+ if type == "mobile":
+ phone_number.type = addressbook_pb2.Person.MOBILE
+ elif type == "home":
+ phone_number.type = addressbook_pb2.Person.HOME
+ elif type == "work":
+ phone_number.type = addressbook_pb2.Person.WORK
+ else:
+ print "Unknown phone type; leaving as default value."
+
+# Main procedure: Reads the entire address book from a file,
+# adds one person based on user input, then writes it back out to the same
+# file.
+if len(sys.argv) != 2:
+ print "Usage:", sys.argv[0], "ADDRESS_BOOK_FILE"
+ sys.exit(-1)
+
+address_book = addressbook_pb2.AddressBook()
+
+# Read the existing address book.
+try:
+ f = open(sys.argv[1], "rb")
+ address_book.ParseFromString(f.read())
+ f.close()
+except IOError:
+ print sys.argv[1] + ": File not found. Creating a new file."
+
+# Add an address.
+PromptForAddress(address_book.person.add())
+
+# Write the new address book back to disk.
+f = open(sys.argv[1], "wb")
+f.write(address_book.SerializeToString())
+f.close()
diff --git a/examples/addressbook.proto b/examples/addressbook.proto
new file mode 100644
index 0000000..b14829e
--- /dev/null
+++ b/examples/addressbook.proto
@@ -0,0 +1,30 @@
+// See README.txt for information and build instructions.
+
+package tutorial;
+
+option java_package = "com.example.tutorial";
+option java_outer_classname = "AddressBookProtos";
+
+message Person {
+ required string name = 1;
+ required int32 id = 2; // Unique ID number for this person.
+ optional string email = 3;
+
+ enum PhoneType {
+ MOBILE = 0;
+ HOME = 1;
+ WORK = 2;
+ }
+
+ message PhoneNumber {
+ required string number = 1;
+ optional PhoneType type = 2 [default = HOME];
+ }
+
+ repeated PhoneNumber phone = 4;
+}
+
+// Our address book file is just one of these.
+message AddressBook {
+ repeated Person person = 1;
+}
diff --git a/examples/list_people.cc b/examples/list_people.cc
new file mode 100644
index 0000000..5363152
--- /dev/null
+++ b/examples/list_people.cc
@@ -0,0 +1,68 @@
+// See README.txt for information and build instructions.
+
+#include <iostream>
+#include <fstream>
+#include <string>
+#include "addressbook.pb.h"
+using namespace std;
+
+// Iterates though all people in the AddressBook and prints info about them.
+void ListPeople(const tutorial::AddressBook& address_book) {
+ for (int i = 0; i < address_book.person_size(); i++) {
+ const tutorial::Person& person = address_book.person(i);
+
+ cout << "Person ID: " << person.id() << endl;
+ cout << " Name: " << person.name() << endl;
+ if (person.has_email()) {
+ cout << " E-mail address: " << person.email() << endl;
+ }
+
+ for (int j = 0; j < person.phone_size(); j++) {
+ const tutorial::Person::PhoneNumber& phone_number = person.phone(j);
+
+ switch (phone_number.type()) {
+ case tutorial::Person::MOBILE:
+ cout << " Mobile phone #: ";
+ break;
+ case tutorial::Person::HOME:
+ cout << " Home phone #: ";
+ break;
+ case tutorial::Person::WORK:
+ cout << " Work phone #: ";
+ break;
+ }
+ cout << phone_number.number() << endl;
+ }
+ }
+}
+
+// Main function: Reads the entire address book from a file and prints all
+// the information inside.
+int main(int argc, char* argv[]) {
+ // Verify that the version of the library that we linked against is
+ // compatible with the version of the headers we compiled against.
+ GOOGLE_PROTOBUF_VERIFY_VERSION;
+
+ if (argc != 2) {
+ cerr << "Usage: " << argv[0] << " ADDRESS_BOOK_FILE" << endl;
+ return -1;
+ }
+
+ tutorial::AddressBook address_book;
+
+ {
+ // Read the existing address book.
+ fstream input(argv[1], ios::in | ios::binary);
+ if (!address_book.ParseFromIstream(&input)) {
+ cerr << "Failed to parse address book." << endl;
+ return -1;
+ }
+ }
+
+ ListPeople(address_book);
+
+ // Optional: Delete all global objects allocated by libprotobuf.
+ google::protobuf::ShutdownProtobufLibrary();
+
+ return 0;
+}
diff --git a/examples/list_people.py b/examples/list_people.py
new file mode 100755
index 0000000..f9f36b9
--- /dev/null
+++ b/examples/list_people.py
@@ -0,0 +1,38 @@
+#! /usr/bin/python
+
+# See README.txt for information and build instructions.
+
+import addressbook_pb2
+import sys
+
+# Iterates though all people in the AddressBook and prints info about them.
+def ListPeople(address_book):
+ for person in address_book.person:
+ print "Person ID:", person.id
+ print " Name:", person.name
+ if person.HasField('email'):
+ print " E-mail address:", person.email
+
+ for phone_number in person.phone:
+ if phone_number.type == addressbook_pb2.Person.MOBILE:
+ print " Mobile phone #:",
+ elif phone_number.type == addressbook_pb2.Person.HOME:
+ print " Home phone #:",
+ elif phone_number.type == addressbook_pb2.Person.WORK:
+ print " Work phone #:",
+ print phone_number.number
+
+# Main procedure: Reads the entire address book from a file and prints all
+# the information inside.
+if len(sys.argv) != 2:
+ print "Usage:", sys.argv[0], "ADDRESS_BOOK_FILE"
+ sys.exit(-1)
+
+address_book = addressbook_pb2.AddressBook()
+
+# Read the existing address book.
+f = open(sys.argv[1], "rb")
+address_book.ParseFromString(f.read())
+f.close()
+
+ListPeople(address_book)
diff --git a/generate_descriptor_proto.sh b/generate_descriptor_proto.sh
new file mode 100755
index 0000000..b25a3c6
--- /dev/null
+++ b/generate_descriptor_proto.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+# Run this script to regenerate descriptor.pb.{h,cc} after the protocol
+# compiler changes. Since these files are compiled into the protocol compiler
+# itself, they cannot be generated automatically by a make rule. "make check"
+# will fail if these files do not match what the protocol compiler would
+# generate.
+#
+# HINT: Flags passed to generate_descriptor_proto.sh will be passed directly
+# to make when building protoc. This is particularly useful for passing
+# -j4 to run 4 jobs simultaneously.
+
+if test ! -e 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
+
+if test ! -e src/Makefile; then
+ cat >&2 << __EOF__
+Could not find src/Makefile. You must run ./configure (and perhaps
+./autogen.sh) first.
+__EOF__
+ exit 1
+fi
+
+cd src
+CORE_PROTO_IS_CORRECT=0
+while [ $CORE_PROTO_IS_CORRECT -ne 1 ]
+do
+ CORE_PROTO_IS_CORRECT=1
+ cp google/protobuf/descriptor.pb.h google/protobuf/descriptor.pb.h.tmp
+ cp google/protobuf/descriptor.pb.cc google/protobuf/descriptor.pb.cc.tmp
+ cp google/protobuf/compiler/plugin.pb.h google/protobuf/compiler/plugin.pb.h.tmp
+ cp google/protobuf/compiler/plugin.pb.cc google/protobuf/compiler/plugin.pb.cc.tmp
+
+ make $@ protoc &&
+ ./protoc --cpp_out=dllexport_decl=LIBPROTOBUF_EXPORT:. google/protobuf/descriptor.proto && \
+ ./protoc --cpp_out=dllexport_decl=LIBPROTOC_EXPORT:. google/protobuf/compiler/plugin.proto
+
+ diff google/protobuf/descriptor.pb.h google/protobuf/descriptor.pb.h.tmp > /dev/null
+ if test $? -ne 0; then
+ CORE_PROTO_IS_CORRECT=0
+ fi
+ diff google/protobuf/descriptor.pb.cc google/protobuf/descriptor.pb.cc.tmp > /dev/null
+ if test $? -ne 0; then
+ CORE_PROTO_IS_CORRECT=0
+ fi
+ diff google/protobuf/compiler/plugin.pb.h google/protobuf/compiler/plugin.pb.h.tmp > /dev/null
+ if test $? -ne 0; then
+ CORE_PROTO_IS_CORRECT=0
+ fi
+ diff google/protobuf/compiler/plugin.pb.cc google/protobuf/compiler/plugin.pb.cc.tmp > /dev/null
+ if test $? -ne 0; then
+ CORE_PROTO_IS_CORRECT=0
+ fi
+
+ rm google/protobuf/descriptor.pb.h.tmp
+ rm google/protobuf/descriptor.pb.cc.tmp
+ rm google/protobuf/compiler/plugin.pb.h.tmp
+ rm google/protobuf/compiler/plugin.pb.cc.tmp
+done
+cd ..
diff --git a/java/README.txt b/java/README.txt
new file mode 100644
index 0000000..57e26a9
--- /dev/null
+++ b/java/README.txt
@@ -0,0 +1,96 @@
+Protocol Buffers - Google's data interchange format
+Copyright 2008 Google Inc.
+
+This directory contains the Java Protocol Buffers runtime library.
+
+Installation - With Maven
+=========================
+
+The Protocol Buffers build is managed using Maven. If you would
+rather build without Maven, see below.
+
+1) Install Apache Maven if you don't have it:
+
+ http://maven.apache.org/
+
+2) Build the C++ code, or obtain a binary distribution of protoc. If
+ you install a binary distribution, make sure that it is the same
+ version as this package. If in doubt, run:
+
+ $ protoc --version
+
+ You will need to place the protoc executable in ../src. (If you
+ built it yourself, it should already be there.)
+
+3) Run the tests:
+
+ $ mvn test
+
+ If some tests fail, this library may not work correctly on your
+ system. Continue at your own risk.
+
+4) Install the library into your Maven repository:
+
+ $ mvn install
+
+5) If you do not use Maven to manage your own build, you can build a
+ .jar file to use:
+
+ $ mvn package
+
+ The .jar will be placed in the "target" directory.
+
+Installation - 'Lite' Version - With Maven
+==========================================
+
+Building the 'lite' version of the Java Protocol Buffers library is
+the same as building the full version, except that all commands are
+run using the 'lite' profile. (see
+http://maven.apache.org/guides/introduction/introduction-to-profiles.html)
+
+E.g. to install the lite version of the jar, you would run:
+
+ $ mvn install -P lite
+
+The resulting artifact has the 'lite' classifier. To reference it
+for dependency resolution, you would specify it as:
+
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ <version>${version}</version>
+ <classifier>lite</classifier>
+ </dependency>
+
+Installation - Without Maven
+============================
+
+If you would rather not install Maven to build the library, you may
+follow these instructions instead. Note that these instructions skip
+running unit tests.
+
+1) Build the C++ code, or obtain a binary distribution of protoc. If
+ you install a binary distribution, make sure that it is the same
+ version as this package. If in doubt, run:
+
+ $ protoc --version
+
+ If you built the C++ code without installing, the compiler binary
+ should be located in ../src.
+
+2) Invoke protoc to build DescriptorProtos.java:
+
+ $ protoc --java_out=src/main/java -I../src \
+ ../src/google/protobuf/descriptor.proto
+
+3) Compile the code in src/main/java using whatever means you prefer.
+
+4) Install the classes wherever you prefer.
+
+Usage
+=====
+
+The complete documentation for Protocol Buffers is available via the
+web at:
+
+ https://developers.google.com/protocol-buffers/
diff --git a/java/pom.xml b/java/pom.xml
new file mode 100644
index 0000000..3eb7a70
--- /dev/null
+++ b/java/pom.xml
@@ -0,0 +1,284 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.google</groupId>
+ <artifactId>google</artifactId>
+ <version>1</version>
+ </parent>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ <version>3.0.0-alpha-3-pre</version>
+ <packaging>bundle</packaging>
+ <name>Protocol Buffer Java API</name>
+ <description>
+ Protocol Buffers are a way of encoding structured data in an efficient yet
+ extensible format.
+ </description>
+ <inceptionYear>2008</inceptionYear>
+ <url>https://developers.google.com/protocol-buffers/</url>
+ <licenses>
+ <license>
+ <name>New BSD license</name>
+ <url>http://www.opensource.org/licenses/bsd-license.php</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+ <scm>
+ <url>https://github.com/google/protobuf</url>
+ <connection>
+ scm:git:https://github.com/google/protobuf.git
+ </connection>
+ </scm>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ <version>2.2.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-sources</id>
+ <phase>generate-sources</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="target/generated-sources" />
+ <exec executable="../src/protoc">
+ <arg value="--java_out=target/generated-sources" />
+ <arg value="--proto_path=../src" />
+ <arg value="../src/google/protobuf/descriptor.proto" />
+ </exec>
+ </tasks>
+ <sourceRoot>target/generated-sources</sourceRoot>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>generate-test-sources</id>
+ <phase>generate-test-sources</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="target/generated-test-sources" />
+ <exec executable="../src/protoc">
+ <arg value="--java_out=target/generated-test-sources" />
+ <arg value="--proto_path=../src" />
+ <arg value="--proto_path=src/test/java" />
+ <arg value="../src/google/protobuf/unittest.proto" />
+ <arg value="../src/google/protobuf/unittest_import.proto" />
+ <arg value="../src/google/protobuf/unittest_import_public.proto" />
+ <arg value="../src/google/protobuf/unittest_mset.proto" />
+ <arg value="src/test/java/com/google/protobuf/lazy_fields_lite.proto" />
+ <arg value="src/test/java/com/google/protobuf/lite_equals_and_hash.proto" />
+ <arg
+ value="src/test/java/com/google/protobuf/multiple_files_test.proto" />
+ <arg value="src/test/java/com/google/protobuf/nested_builders_test.proto" />
+ <arg value="src/test/java/com/google/protobuf/nested_extension.proto" />
+ <arg value="src/test/java/com/google/protobuf/nested_extension_lite.proto" />
+ <arg value="src/test/java/com/google/protobuf/non_nested_extension.proto" />
+ <arg value="src/test/java/com/google/protobuf/non_nested_extension_lite.proto" />
+ <arg value="src/test/java/com/google/protobuf/outer_class_name_test.proto" />
+ <arg value="src/test/java/com/google/protobuf/outer_class_name_test2.proto" />
+ <arg value="src/test/java/com/google/protobuf/outer_class_name_test3.proto" />
+ <arg value="src/test/java/com/google/protobuf/test_bad_identifiers.proto" />
+ <arg value="src/test/java/com/google/protobuf/test_check_utf8.proto" />
+ <arg value="src/test/java/com/google/protobuf/test_check_utf8_size.proto" />
+ <arg value="src/test/java/com/google/protobuf/test_custom_options.proto" />
+ <arg
+ value="../src/google/protobuf/unittest_optimize_for.proto" />
+ <arg
+ value="../src/google/protobuf/unittest_custom_options.proto" />
+ <arg value="../src/google/protobuf/unittest_lite.proto" />
+ <arg value="../src/google/protobuf/unittest_import_lite.proto" />
+ <arg value="../src/google/protobuf/unittest_import_public_lite.proto" />
+ <arg value="../src/google/protobuf/unittest_lite_imports_nonlite.proto" />
+ <arg value="../src/google/protobuf/unittest_enormous_descriptor.proto" />
+ <arg value="../src/google/protobuf/unittest_no_generic_services.proto" />
+ <arg value="src/test/java/com/google/protobuf/field_presence_test.proto" />
+ <arg value="src/test/java/com/google/protobuf/map_for_proto2_lite_test.proto" />
+ <arg value="src/test/java/com/google/protobuf/map_for_proto2_test.proto" />
+ <arg value="src/test/java/com/google/protobuf/map_test.proto" />
+ </exec>
+ </tasks>
+ <testSourceRoot>target/generated-test-sources</testSourceRoot>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-DocURL>https://developers.google.com/protocol-buffers/</Bundle-DocURL>
+ <Bundle-SymbolicName>com.google.protobuf</Bundle-SymbolicName>
+ <Export-Package>com.google.protobuf;version=3.0.0-alpha-3-pre</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <profiles>
+ <profile>
+ <id>release</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.2.1</version>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar-no-fork</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.9.1</version>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-gpg-plugin</artifactId>
+ <version>1.5</version>
+ <executions>
+ <execution>
+ <id>sign-artifacts</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>sign</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.sonatype.plugins</groupId>
+ <artifactId>nexus-staging-maven-plugin</artifactId>
+ <version>1.6.3</version>
+ <extensions>true</extensions>
+ <configuration>
+ <serverId>sonatype-nexus-staging</serverId>
+ <nexusUrl>https://oss.sonatype.org/</nexusUrl>
+ <autoReleaseAfterClose>false</autoReleaseAfterClose>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>lite</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/AbstractMessageLite.java</include>
+ <include>**/AbstractParser.java</include>
+ <include>**/BoundedByteString.java</include>
+ <include>**/ByteString.java</include>
+ <include>**/CodedInputStream.java</include>
+ <include>**/CodedOutputStream.java</include>
+ <include>**/ExtensionLite.java</include>
+ <include>**/ExtensionRegistryLite.java</include>
+ <include>**/FieldSet.java</include>
+ <include>**/GeneratedMessageLite.java</include>
+ <include>**/Internal.java</include>
+ <include>**/InvalidProtocolBufferException.java</include>
+ <include>**/LazyFieldLite.java</include>
+ <include>**/LazyStringArrayList.java</include>
+ <include>**/LazyStringList.java</include>
+ <include>**/LiteralByteString.java</include>
+ <include>**/MapEntryLite.java</include>
+ <include>**/MapFieldLite.java</include>
+ <include>**/MessageLite.java</include>
+ <include>**/MessageLiteOrBuilder.java</include>
+ <include>**/Parser.java</include>
+ <include>**/ProtocolStringList.java</include>
+ <include>**/RopeByteString.java</include>
+ <include>**/SmallSortedMap.java</include>
+ <include>**/UninitializedMessageException.java</include>
+ <include>**/UnknownFieldSetLite.java</include>
+ <include>**/UnmodifiableLazyStringList.java</include>
+ <include>**/Utf8.java</include>
+ <include>**/WireFormat.java</include>
+ </includes>
+ <testIncludes>
+ <testInclude>**/*Lite.java</testInclude>
+ <testInclude>**/LazyMessageLiteTest.java</testInclude>
+ <testInclude>**/LiteTest.java</testInclude>
+ <testInclude>**/UnknownFieldSetLiteTest.java</testInclude>
+ </testIncludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <classifier>lite</classifier>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/java/src/main/java/com/google/protobuf/AbstractMessage.java b/java/src/main/java/com/google/protobuf/AbstractMessage.java
new file mode 100644
index 0000000..cc89173
--- /dev/null
+++ b/java/src/main/java/com/google/protobuf/AbstractMessage.java
@@ -0,0 +1,524 @@
+// 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.
+
+package com.google.protobuf;
+
+import com.google.protobuf.Descriptors.FieldDescriptor;
+import com.google.protobuf.Descriptors.OneofDescriptor;
+import com.google.protobuf.Internal.EnumLite;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A partial implementation of the {@link Message} interface which implements
+ * as many methods of that interface as possible in terms of other methods.
+ *
+ * @author kenton@google.com Kenton Varda
+ */
+public abstract class AbstractMessage extends AbstractMessageLite
+ implements Message {
+ public boolean isInitialized() {
+ return MessageReflection.isInitialized(this);
+ }
+
+
+ public List<String> findInitializationErrors() {
+ return MessageReflection.findMissingFields(this);
+ }
+
+ public String getInitializationErrorString() {
+ return MessageReflection.delimitWithCommas(findInitializationErrors());
+ }
+
+ /** TODO(jieluo): Clear it when all subclasses have implemented this method. */
+ @Override
+ public boolean hasOneof(OneofDescriptor oneof) {
+ throw new UnsupportedOperationException("hasOneof() is not implemented.");
+ }
+
+ /** TODO(jieluo): Clear it when all subclasses have implemented this method. */
+ @Override
+ public FieldDescriptor getOneofFieldDescriptor(OneofDescriptor oneof) {
+ throw new UnsupportedOperationException(
+ "getOneofFieldDescriptor() is not implemented.");
+ }
+
+ @Override
+ public final String toString() {
+ return TextFormat.printToString(this);
+ }
+
+ public void writeTo(final CodedOutputStream output) throws IOException {
+ MessageReflection.writeMessageTo(this, getAllFields(), output, false);
+ }
+
+ protected int memoizedSize = -1;
+
+ public int getSerializedSize() {
+ int size = memoizedSize;
+ if (size != -1) {
+ return size;
+ }
+
+ memoizedSize = MessageReflection.getSerializedSize(this, getAllFields());
+ return memoizedSize;
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ if (other == this) {
+ return true;
+ }
+ if (!(other instanceof Message)) {
+ return false;
+ }
+ final Message otherMessage = (Message) other;
+ if (getDescriptorForType() != otherMessage.getDescriptorForType()) {
+ return false;
+ }
+ return compareFields(getAllFields(), otherMessage.getAllFields()) &&
+ getUnknownFields().equals(otherMessage.getUnknownFields());
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = memoizedHashCode;
+ if (hash == 0) {
+ hash = 41;
+ hash = (19 * hash) + getDescriptorForType().hashCode();
+ hash = hashFields(hash, getAllFields());
+ hash = (29 * hash) + getUnknownFields().hashCode();
+ memoizedHashCode = hash;
+ }
+ return hash;
+ }
+
+ private static ByteString toByteString(Object value) {
+ if (value instanceof byte[]) {
+ return ByteString.copyFrom((byte[]) value);
+ } else {
+ return (ByteString) value;
+ }
+ }
+
+ /**
+ * Compares two bytes fields. The parameters must be either a byte array or a
+ * ByteString object. They can be of different type though.
+ */
+ private static boolean compareBytes(Object a, Object b) {
+ if (a instanceof byte[] && b instanceof byte[]) {
+ return Arrays.equals((byte[])a, (byte[])b);
+ }
+ return toByteString(a).equals(toByteString(b));
+ }
+
+ /**
+ * Converts a list of MapEntry messages into a Map used for equals() and
+ * hashCode().
+ */
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ private static Map convertMapEntryListToMap(List list) {
+ if (list.isEmpty()) {
+ return Collections.emptyMap();
+ }
+ Map result = new HashMap();
+ Iterator iterator = list.iterator();
+ Message entry = (Message) iterator.next();
+ Descriptors.Descriptor descriptor = entry.getDescriptorForType();
+ Descriptors.FieldDescriptor key = descriptor.findFieldByName("key");
+ Descriptors.FieldDescriptor value = descriptor.findFieldByName("value");
+ result.put(entry.getField(key), entry.getField(value));
+ while (iterator.hasNext()) {
+ entry = (Message) iterator.next();
+ result.put(entry.getField(key), entry.getField(value));
+ }
+ return result;
+ }
+
+ /**
+ * Compares two map fields. The parameters must be a list of MapEntry
+ * messages.
+ */
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ private static boolean compareMapField(Object a, Object b) {
+ Map ma = convertMapEntryListToMap((List) a);
+ Map mb = convertMapEntryListToMap((List) b);
+ return MapFieldLite.equals(ma, mb);
+ }
+
+ /**
+ * Compares two set of fields.
+ * This method is used to implement {@link AbstractMessage#equals(Object)}
+ * and {@link AbstractMutableMessage#equals(Object)}. It takes special care
+ * of bytes fields because immutable messages and mutable messages use
+ * different Java type to reprensent a bytes field and this method should be
+ * able to compare immutable messages, mutable messages and also an immutable
+ * message to a mutable message.
+ */
+ static boolean compareFields(Map<FieldDescriptor, Object> a,
+ Map<FieldDescriptor, Object> b) {
+ if (a.size() != b.size()) {
+ return false;
+ }
+ for (FieldDescriptor descriptor : a.keySet()) {
+ if (!b.containsKey(descriptor)) {
+ return false;
+ }
+ Object value1 = a.get(descriptor);
+ Object value2 = b.get(descriptor);
+ if (descriptor.getType() == FieldDescriptor.Type.BYTES) {
+ if (descriptor.isRepeated()) {
+ List list1 = (List) value1;
+ List list2 = (List) value2;
+ if (list1.size() != list2.size()) {
+ return false;
+ }
+ for (int i = 0; i < list1.size(); i++) {
+ if (!compareBytes(list1.get(i), list2.get(i))) {
+ return false;
+ }
+ }
+ } else {
+ // Compares a singular bytes field.
+ if (!compareBytes(value1, value2)) {
+ return false;
+ }
+ }
+ } else if (descriptor.isMapField()) {
+ if (!compareMapField(value1, value2)) {
+ return false;
+ }
+ } else {
+ // Compare non-bytes fields.
+ if (!value1.equals(value2)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Calculates the hash code of a map field. {@code value} must be a list of
+ * MapEntry messages.
+ */
+ @SuppressWarnings("unchecked")
+ private static int hashMapField(Object value) {
+ return MapFieldLite.calculateHashCodeForMap(convertMapEntryListToMap((List) value));
+ }
+
+ /** Get a hash code for given fields and values, using the given seed. */
+ @SuppressWarnings("unchecked")
+ protected static int hashFields(int hash, Map<FieldDescriptor, Object> map) {
+ for (Map.Entry<FieldDescriptor, Object> entry : map.entrySet()) {
+ FieldDescriptor field = entry.getKey();
+ Object value = entry.getValue();
+ hash = (37 * hash) + field.getNumber();
+ if (field.isMapField()) {
+ hash = (53 * hash) + hashMapField(value);
+ } else if (field.getType() != FieldDescriptor.Type.ENUM){
+ hash = (53 * hash) + value.hashCode();
+ } else if (field.isRepeated()) {
+ List<? extends EnumLite> list = (List<? extends EnumLite>) value;
+ hash = (53 * hash) + Internal.hashEnumList(list);
+ } else {
+ hash = (53 * hash) + Internal.hashEnum((EnumLite) value);
+ }
+ }
+ return hash;
+ }
+
+ /**
+ * Package private helper method for AbstractParser to create
+ * UninitializedMessageException with missing field information.
+ */
+ @Override
+ UninitializedMessageException newUninitializedMessageException() {
+ return Builder.newUninitializedMessageException(this);
+ }
+
+ // =================================================================
+
+ /**
+ * A partial implementation of the {@link Message.Builder} interface which
+ * implements as many methods of that interface as possible in terms of
+ * other methods.
+ */
+ @SuppressWarnings("unchecked")
+ public static abstract class Builder<BuilderType extends Builder>
+ extends AbstractMessageLite.Builder<BuilderType>
+ implements Message.Builder {
+ // The compiler produces an error if this is not declared explicitly.
+ @Override
+ public abstract BuilderType clone();
+
+ /** TODO(jieluo): Clear it when all subclasses have implemented this method. */
+ @Override
+ public boolean hasOneof(OneofDescriptor oneof) {
+ throw new UnsupportedOperationException("hasOneof() is not implemented.");
+ }
+
+ /** TODO(jieluo): Clear it when all subclasses have implemented this method. */
+ @Override
+ public FieldDescriptor getOneofFieldDescriptor(OneofDescriptor oneof) {
+ throw new UnsupportedOperationException(
+ "getOneofFieldDescriptor() is not implemented.");
+ }
+
+ /** TODO(jieluo): Clear it when all subclasses have implemented this method. */
+ @Override
+ public BuilderType clearOneof(OneofDescriptor oneof) {
+ throw new UnsupportedOperationException("clearOneof() is not implemented.");
+ }
+
+ public BuilderType clear() {
+ for (final Map.Entry<FieldDescriptor, Object> entry :
+ getAllFields().entrySet()) {
+ clearField(entry.getKey());
+ }
+ return (BuilderType) this;
+ }
+
+ public List<String> findInitializationErrors() {
+ return MessageReflection.findMissingFields(this);
+ }
+
+ public String getInitializationErrorString() {
+ return MessageReflection.delimitWithCommas(findInitializationErrors());
+ }
+
+ public BuilderType mergeFrom(final Message other) {
+ if (other.getDescriptorForType() != getDescriptorForType()) {
+ throw new IllegalArgumentException(
+ "mergeFrom(Message) can only merge messages of the same type.");
+ }
+
+ // Note: We don't attempt to verify that other's fields have valid
+ // types. Doing so would be a losing battle. We'd have to verify
+ // all sub-messages as well, and we'd have to make copies of all of
+ // them to insure that they don't change after verification (since
+ // the Message interface itself cannot enforce immutability of
+ // implementations).
+ // TODO(kenton): Provide a function somewhere called makeDeepCopy()
+ // which allows people to make secure deep copies of messages.
+
+ for (final Map.Entry<FieldDescriptor, Object> entry :
+ other.getAllFields().entrySet()) {
+ final FieldDescriptor field = entry.getKey();
+ if (field.isRepeated()) {
+ for (final Object element : (List)entry.getValue()) {
+ addRepeatedField(field, element);
+ }
+ } else if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
+ final Message existingValue = (Message)getField(field);
+ if (existingValue == existingValue.getDefaultInstanceForType()) {
+ setField(field, entry.getValue());
+ } else {
+ setField(field,
+ existingValue.newBuilderForType()
+ .mergeFrom(existingValue)
+ .mergeFrom((Message)entry.getValue())
+ .build());
+ }
+ } else {
+ setField(field, entry.getValue());
+ }
+ }
+
+ mergeUnknownFields(other.getUnknownFields());
+
+ return (BuilderType) this;
+ }
+
+ @Override
+ public BuilderType mergeFrom(final CodedInputStream input)
+ throws IOException {
+ return mergeFrom(input, ExtensionRegistry.getEmptyRegistry());
+ }
+
+ @Override
+ public BuilderType mergeFrom(
+ final CodedInputStream input,
+ final ExtensionRegistryLite extensionRegistry)
+ throws IOException {
+ final UnknownFieldSet.Builder unknownFields =
+ UnknownFieldSet.newBuilder(getUnknownFields());
+ while (true) {
+ final int tag = input.readTag();
+ if (tag == 0) {
+ break;
+ }
+
+ MessageReflection.BuilderAdapter builderAdapter =
+ new MessageReflection.BuilderAdapter(this);
+ if (!MessageReflection.mergeFieldFrom(input, unknownFields,
+ extensionRegistry,
+ getDescriptorForType(),
+ builderAdapter,
+ tag)) {
+ // end group tag
+ break;
+ }
+ }
+ setUnknownFields(unknownFields.build());
+ return (BuilderType) this;
+ }
+
+ public BuilderType mergeUnknownFields(final UnknownFieldSet unknownFields) {
+ setUnknownFields(
+ UnknownFieldSet.newBuilder(getUnknownFields())
+ .mergeFrom(unknownFields)
+ .build());
+ return (BuilderType) this;
+ }
+
+ public Message.Builder getFieldBuilder(final FieldDescriptor field) {
+ throw new UnsupportedOperationException(
+ "getFieldBuilder() called on an unsupported message type.");
+ }
+
+ public Message.Builder getRepeatedFieldBuilder(final FieldDescriptor field,
+ int index) {
+ throw new UnsupportedOperationException(
+ "getRepeatedFieldBuilder() called on an unsupported message type.");
+ }
+
+ public String toString() {
+ return TextFormat.printToString(this);
+ }
+
+ /**
+ * Construct an UninitializedMessageException reporting missing fields in
+ * the given message.
+ */
+ protected static UninitializedMessageException
+ newUninitializedMessageException(Message message) {
+ return new UninitializedMessageException(
+ MessageReflection.findMissingFields(message));
+ }
+
+ // ===============================================================
+ // The following definitions seem to be required in order to make javac
+ // not produce weird errors like:
+ //
+ // java/com/google/protobuf/DynamicMessage.java:203: types
+ // com.google.protobuf.AbstractMessage.Builder<
+ // com.google.protobuf.DynamicMessage.Builder> and
+ // com.google.protobuf.AbstractMessage.Builder<
+ // com.google.protobuf.DynamicMessage.Builder> are incompatible; both
+ // define mergeFrom(com.google.protobuf.ByteString), but with unrelated
+ // return types.
+ //
+ // Strangely, these lines are only needed if javac is invoked separately
+ // on AbstractMessage.java and AbstractMessageLite.java. If javac is
+ // invoked on both simultaneously, it works. (Or maybe the important
+ // point is whether or not DynamicMessage.java is compiled together with
+ // AbstractMessageLite.java -- not sure.) I suspect this is a compiler
+ // bug.
+
+ @Override
+ public BuilderType mergeFrom(final ByteString data)
+ throws InvalidProtocolBufferException {
+ return super.mergeFrom(data);
+ }
+
+ @Override
+ public BuilderType mergeFrom(
+ final ByteString data,
+ final ExtensionRegistryLite extensionRegistry)
+ throws InvalidProtocolBufferException {
+ return super.mergeFrom(data, extensionRegistry);
+ }
+
+ @Override
+ public BuilderType mergeFrom(final byte[] data)
+ throws InvalidProtocolBufferException {
+ return super.mergeFrom(data);
+ }
+
+ @Override
+ public BuilderType mergeFrom(
+ final byte[] data, final int off, final int len)
+ throws InvalidProtocolBufferException {
+ return super.mergeFrom(data, off, len);
+ }
+
+ @Override
+ public BuilderType mergeFrom(
+ final byte[] data,
+ final ExtensionRegistryLite extensionRegistry)
+ throws InvalidProtocolBufferException {
+ return super.mergeFrom(data, extensionRegistry);
+ }
+
+ @Override
+ public BuilderType mergeFrom(
+ final byte[] data, final int off, final int len,
+ final ExtensionRegistryLite extensionRegistry)
+ throws InvalidProtocolBufferException {
+ return super.mergeFrom(data, off, len, extensionRegistry);
+ }
+
+ @Override
+ public BuilderType mergeFrom(final InputStream input)
+ throws IOException {
+ return super.mergeFrom(input);
+ }
+
+ @Override
+ public BuilderType mergeFrom(
+ final InputStream input,
+ final ExtensionRegistryLite extensionRegistry)
+ throws IOException {
+ return super.mergeFrom(input, extensionRegistry);
+ }
+
+ @Override
+ public boolean mergeDelimitedFrom(final InputStream input)
+ throws IOException {
+ return super.mergeDelimitedFrom(input);
+ }
+
+ @Override
+ public boolean mergeDelimitedFrom(
+ final InputStream input,
+ final ExtensionRegistryLite extensionRegistry)
+ throws IOException {
+ return super.mergeDelimitedFrom(input, extensionRegistry);
+ }
+ }
+}
diff --git a/java/src/main/java/com/google/protobuf/AbstractMessageLite.java b/java/src/main/java/com/google/protobuf/AbstractMessageLite.java
new file mode 100644
index 0000000..aac4fa7
--- /dev/null
+++ b/java/src/main/java/com/google/protobuf/AbstractMessageLite.java
@@ -0,0 +1,355 @@
+// 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.
+
+package com.google.protobuf;
+
+import java.io.FilterInputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Collection;
+
+/**
+ * A partial implementation of the {@link MessageLite} interface which
+ * implements as many methods of that interface as possible in terms of other
+ * methods.
+ *
+ * @author kenton@google.com Kenton Varda
+ */
+public abstract class AbstractMessageLite implements MessageLite {
+ protected int memoizedHashCode = 0;
+
+ public ByteString toByteString() {
+ try {
+ final ByteString.CodedBuilder out =
+ ByteString.newCodedBuilder(getSerializedSize());
+ writeTo(out.getCodedOutput());
+ return out.build();
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "Serializing to a ByteString threw an IOException (should " +
+ "never happen).", e);
+ }
+ }
+
+ public byte[] toByteArray() {
+ try {
+ final byte[] result = new byte[getSerializedSize()];
+ final CodedOutputStream output = CodedOutputStream.newInstance(result);
+ writeTo(output);
+ output.checkNoSpaceLeft();
+ return result;
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "Serializing to a byte array threw an IOException " +
+ "(should never happen).", e);
+ }
+ }
+
+ public void writeTo(final OutputStream output) throws IOException {
+ final int bufferSize =
+ CodedOutputStream.computePreferredBufferSize(getSerializedSize());
+ final CodedOutputStream codedOutput =
+ CodedOutputStream.newInstance(output, bufferSize);
+ writeTo(codedOutput);
+ codedOutput.flush();
+ }
+
+ public void writeDelimitedTo(final OutputStream output) throws IOException {
+ final int serialized = getSerializedSize();
+ final int bufferSize = CodedOutputStream.computePreferredBufferSize(
+ CodedOutputStream.computeRawVarint32Size(serialized) + serialized);
+ final CodedOutputStream codedOutput =
+ CodedOutputStream.newInstance(output, bufferSize);
+ codedOutput.writeRawVarint32(serialized);
+ writeTo(codedOutput);
+ codedOutput.flush();
+ }
+
+
+ /**
+ * Package private helper method for AbstractParser to create
+ * UninitializedMessageException.
+ */
+ UninitializedMessageException newUninitializedMessageException() {
+ return new UninitializedMessageException(this);
+ }
+
+ protected static void checkByteStringIsUtf8(ByteString byteString)
+ throws IllegalArgumentException {
+ if (!byteString.isValidUtf8()) {
+ throw new IllegalArgumentException("Byte string is not UTF-8.");
+ }
+ }
+
+ /**
+ * A partial implementation of the {@link Message.Builder} interface which
+ * implements as many methods of that interface as possible in terms of
+ * other methods.
+ */
+ @SuppressWarnings("unchecked")
+ public static abstract class Builder<BuilderType extends Builder>
+ implements MessageLite.Builder {
+ // The compiler produces an error if this is not declared explicitly.
+ @Override
+ public abstract BuilderType clone();
+
+ public BuilderType mergeFrom(final CodedInputStream input)
+ throws IOException {
+ return mergeFrom(input, ExtensionRegistryLite.getEmptyRegistry());
+ }
+
+ // Re-defined here for return type covariance.
+ public abstract BuilderType mergeFrom(
+ final CodedInputStream input,
+ final ExtensionRegistryLite extensionRegistry)
+ throws IOException;
+
+ public BuilderType mergeFrom(final ByteString data)
+ throws InvalidProtocolBufferException {
+ try {
+ final CodedInputStream input = data.newCodedInput();
+ mergeFrom(input);
+ input.checkLastTagWas(0);
+ return (BuilderType) this;
+ } catch (InvalidProtocolBufferException e) {
+ throw e;
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "Reading from a ByteString threw an IOException (should " +
+ "never happen).", e);
+ }
+ }
+
+ public BuilderType mergeFrom(
+ final ByteString data,
+ final ExtensionRegistryLite extensionRegistry)
+ throws InvalidProtocolBufferException {
+ try {
+ final CodedInputStream input = data.newCodedInput();
+ mergeFrom(input, extensionRegistry);
+ input.checkLastTagWas(0);
+ return (BuilderType) this;
+ } catch (InvalidProtocolBufferException e) {
+ throw e;
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "Reading from a ByteString threw an IOException (should " +
+ "never happen).", e);
+ }
+ }
+
+ public BuilderType mergeFrom(final byte[] data)
+ throws InvalidProtocolBufferException {
+ return mergeFrom(data, 0, data.length);
+ }
+
+ public BuilderType mergeFrom(final byte[] data, final int off,
+ final int len)
+ throws InvalidProtocolBufferException {
+ try {
+ final CodedInputStream input =
+ CodedInputStream.newInstance(data, off, len);
+ mergeFrom(input);
+ input.checkLastTagWas(0);
+ return (BuilderType) this;
+ } catch (InvalidProtocolBufferException e) {
+ throw e;
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "Reading from a byte array threw an IOException (should " +
+ "never happen).", e);
+ }
+ }
+
+ public BuilderType mergeFrom(
+ final byte[] data,
+ final ExtensionRegistryLite extensionRegistry)
+ throws InvalidProtocolBufferException {
+ return mergeFrom(data, 0, data.length, extensionRegistry);
+ }
+
+ public BuilderType mergeFrom(
+ final byte[] data, final int off, final int len,
+ final ExtensionRegistryLite extensionRegistry)
+ throws InvalidProtocolBufferException {
+ try {
+ final CodedInputStream input =
+ CodedInputStream.newInstance(data, off, len);
+ mergeFrom(input, extensionRegistry);
+ input.checkLastTagWas(0);
+ return (BuilderType) this;
+ } catch (InvalidProtocolBufferException e) {
+ throw e;
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "Reading from a byte array threw an IOException (should " +
+ "never happen).", e);
+ }
+ }
+
+ public BuilderType mergeFrom(final InputStream input) throws IOException {
+ final CodedInputStream codedInput = CodedInputStream.newInstance(input);
+ mergeFrom(codedInput);
+ codedInput.checkLastTagWas(0);
+ return (BuilderType) this;
+ }
+
+ public BuilderType mergeFrom(
+ final InputStream input,
+ final ExtensionRegistryLite extensionRegistry)
+ throws IOException {
+ final CodedInputStream codedInput = CodedInputStream.newInstance(input);
+ mergeFrom(codedInput, extensionRegistry);
+ codedInput.checkLastTagWas(0);
+ return (BuilderType) this;
+ }
+
+ /**
+ * An InputStream implementations which reads from some other InputStream
+ * but is limited to a particular number of bytes. Used by
+ * mergeDelimitedFrom(). This is intentionally package-private so that
+ * UnknownFieldSet can share it.
+ */
+ static final class LimitedInputStream extends FilterInputStream {
+ private int limit;
+
+ LimitedInputStream(InputStream in, int limit) {
+ super(in);
+ this.limit = limit;
+ }
+
+ @Override
+ public int available() throws IOException {
+ return Math.min(super.available(), limit);
+ }
+
+ @Override
+ public int read() throws IOException {
+ if (limit <= 0) {
+ return -1;
+ }
+ final int result = super.read();
+ if (result >= 0) {
+ --limit;
+ }
+ return result;
+ }
+
+ @Override
+ public int read(final byte[] b, final int off, int len)
+ throws IOException {
+ if (limit <= 0) {
+ return -1;
+ }
+ len = Math.min(len, limit);
+ final int result = super.read(b, off, len);
+ if (result >= 0) {
+ limit -= result;
+ }
+ return result;
+ }
+
+ @Override
+ public long skip(final long n) throws IOException {
+ final long result = super.skip(Math.min(n, limit));
+ if (result >= 0) {
+ limit -= result;
+ }
+ return result;
+ }
+ }
+
+ public boolean mergeDelimitedFrom(
+ final InputStream input,
+ final ExtensionRegistryLite extensionRegistry)
+ throws IOException {
+ final int firstByte = input.read();
+ if (firstByte == -1) {
+ return false;
+ }
+ final int size = CodedInputStream.readRawVarint32(firstByte, input);
+ final InputStream limitedInput = new LimitedInputStream(input, size);
+ mergeFrom(limitedInput, extensionRegistry);
+ return true;
+ }
+
+ public boolean mergeDelimitedFrom(final InputStream input)
+ throws IOException {
+ return mergeDelimitedFrom(input,
+ ExtensionRegistryLite.getEmptyRegistry());
+ }
+
+ /**
+ * Construct an UninitializedMessageException reporting missing fields in
+ * the given message.
+ */
+ protected static UninitializedMessageException
+ newUninitializedMessageException(MessageLite message) {
+ return new UninitializedMessageException(message);
+ }
+
+ /**
+ * Adds the {@code values} to the {@code list}. This is a helper method
+ * used by generated code. Users should ignore it.
+ *
+ * @throws NullPointerException if any of the elements of {@code values} is
+ * null. When that happens, some elements of {@code values} may have already
+ * been added to the result {@code list}.
+ */
+ protected static <T> void addAll(final Iterable<T> values,
+ final Collection<? super T> list) {
+ if (values instanceof LazyStringList) {
+ // For StringOrByteStringLists, check the underlying elements to avoid
+ // forcing conversions of ByteStrings to Strings.
+ checkForNullValues(((LazyStringList) values).getUnderlyingElements());
+ list.addAll((Collection<T>) values);
+ } else if (values instanceof Collection) {
+ checkForNullValues(values);
+ list.addAll((Collection<T>) values);
+ } else {
+ for (final T value : values) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ list.add(value);
+ }
+ }
+ }
+
+ private static void checkForNullValues(final Iterable<?> values) {
+ for (final Object value : values) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ }
+ }
+ }
+}
diff --git a/java/src/main/java/com/google/protobuf/AbstractParser.java b/java/src/main/java/com/google/protobuf/AbstractParser.java
new file mode 100644
index 0000000..1a4c631
--- /dev/null
+++ b/java/src/main/java/com/google/protobuf/AbstractParser.java
@@ -0,0 +1,253 @@
+// 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.
+
+package com.google.protobuf;
+
+import com.google.protobuf.AbstractMessageLite.Builder.LimitedInputStream;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * A partial implementation of the {@link Parser} interface which implements
+ * as many methods of that interface as possible in terms of other methods.
+ *
+ * Note: This class implements all the convenience methods in the
+ * {@link Parser} interface. See {@link Parser} for related javadocs.
+ * Subclasses need to implement
+ * {@link Parser#parsePartialFrom(CodedInputStream, ExtensionRegistryLite)}
+ *
+ * @author liujisi@google.com (Pherl Liu)
+ */
+public abstract class AbstractParser<MessageType extends MessageLite>
+ implements Parser<MessageType> {
+ /**
+ * Creates an UninitializedMessageException for MessageType.
+ */
+ private UninitializedMessageException
+ newUninitializedMessageException(MessageType message) {
+ if (message instanceof AbstractMessageLite) {
+ return ((AbstractMessageLite) message).newUninitializedMessageException();
+ }
+ return new UninitializedMessageException(message);
+ }
+
+ /**
+ * Helper method to check if message is initialized.
+ *
+ * @throws InvalidProtocolBufferException if it is not initialized.
+ * @return The message to check.
+ */
+ private MessageType checkMessageInitialized(MessageType message)
+ throws InvalidProtocolBufferException {
+ if (message != null && !message.isInitialized()) {
+ throw newUninitializedMessageException(message)
+ .asInvalidProtocolBufferException()
+ .setUnfinishedMessage(message);
+ }
+ return message;
+ }
+
+ private static final ExtensionRegistryLite EMPTY_REGISTRY
+ = ExtensionRegistryLite.getEmptyRegistry();
+
+ public MessageType parsePartialFrom(CodedInputStream input)
+ throws InvalidProtocolBufferException {
+ return parsePartialFrom(input, EMPTY_REGISTRY);
+ }
+
+ public MessageType parseFrom(CodedInputStream input,
+ ExtensionRegistryLite extensionRegistry)
+ throws InvalidProtocolBufferException {
+ return checkMessageInitialized(
+ parsePartialFrom(input, extensionRegistry));
+ }
+
+ public MessageType parseFrom(CodedInputStream input)
+ throws InvalidProtocolBufferException {
+ return parseFrom(input, EMPTY_REGISTRY);
+ }
+
+ public MessageType parsePartialFrom(ByteString data,
+ ExtensionRegistryLite extensionRegistry)
+ throws InvalidProtocolBufferException {
+ MessageType message;
+ try {
+ CodedInputStream input = data.newCodedInput();
+ message = parsePartialFrom(input, extensionRegistry);
+ try {
+ input.checkLastTagWas(0);
+ } catch (InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(message);
+ }
+ return message;
+ } catch (InvalidProtocolBufferException e) {
+ throw e;
+ }
+ }
+
+ public MessageType parsePartialFrom(ByteString data)
+ throws InvalidProtocolBufferException {
+ return parsePartialFrom(data, EMPTY_REGISTRY);
+ }
+
+ public MessageType parseFrom(ByteString data,
+ ExtensionRegistryLite extensionRegistry)
+ throws InvalidProtocolBufferException {
+ return checkMessageInitialized(parsePartialFrom(data, extensionRegistry));
+ }
+
+ public MessageType parseFrom(ByteString data)
+ throws InvalidProtocolBufferException {
+ return parseFrom(data, EMPTY_REGISTRY);
+ }
+
+ public MessageType parsePartialFrom(byte[] data, int off, int len,
+ ExtensionRegistryLite extensionRegistry)
+ throws InvalidProtocolBufferException {
+ try {
+ CodedInputStream input = CodedInputStream.newInstance(data, off, len);
+ MessageType message = parsePartialFrom(input, extensionRegistry);
+ try {
+ input.checkLastTagWas(0);
+ } catch (InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(message);
+ }
+ return message;
+ } catch (InvalidProtocolBufferException e) {
+ throw e;
+ }
+ }
+
+ public MessageType parsePartialFrom(byte[] data, int off, int len)
+ throws InvalidProtocolBufferException {
+ return parsePartialFrom(data, off, len, EMPTY_REGISTRY);
+ }
+
+ public MessageType parsePartialFrom(byte[] data,
+ ExtensionRegistryLite extensionRegistry)
+ throws InvalidProtocolBufferException {
+ return parsePartialFrom(data, 0, data.length, extensionRegistry);
+ }
+
+ public MessageType parsePartialFrom(byte[] data)
+ throws InvalidProtocolBufferException {
+ return parsePartialFrom(data, 0, data.length, EMPTY_REGISTRY);
+ }
+
+ public MessageType parseFrom(byte[] data, int off, int len,
+ ExtensionRegistryLite extensionRegistry)
+ throws InvalidProtocolBufferException {
+ return checkMessageInitialized(
+ parsePartialFrom(data, off, len, extensionRegistry));
+ }
+
+ public MessageType parseFrom(byte[] data, int off, int len)
+ throws InvalidProtocolBufferException {
+ return parseFrom(data, off, len, EMPTY_REGISTRY);
+ }
+
+ public MessageType parseFrom(byte[] data,
+ ExtensionRegistryLite extensionRegistry)
+ throws InvalidProtocolBufferException {
+ return parseFrom(data, 0, data.length, extensionRegistry);
+ }
+
+ public MessageType parseFrom(byte[] data)
+ throws InvalidProtocolBufferException {
+ return parseFrom(data, EMPTY_REGISTRY);
+ }
+
+ public MessageType parsePartialFrom(InputStream input,
+ ExtensionRegistryLite extensionRegistry)
+ throws InvalidProtocolBufferException {
+ CodedInputStream codedInput = CodedInputStream.newInstance(input);
+ MessageType message = parsePartialFrom(codedInput, extensionRegistry);
+ try {
+ codedInput.checkLastTagWas(0);
+ } catch (InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(message);
+ }
+ return message;
+ }
+
+ public MessageType parsePartialFrom(InputStream input)
+ throws InvalidProtocolBufferException {
+ return parsePartialFrom(input, EMPTY_REGISTRY);
+ }
+
+ public MessageType parseFrom(InputStream input,
+ ExtensionRegistryLite extensionRegistry)
+ throws InvalidProtocolBufferException {
+ return checkMessageInitialized(
+ parsePartialFrom(input, extensionRegistry));
+ }
+
+ public MessageType parseFrom(InputStream input)
+ throws InvalidProtocolBufferException {
+ return parseFrom(input, EMPTY_REGISTRY);
+ }
+
+ public MessageType parsePartialDelimitedFrom(
+ InputStream input,
+ ExtensionRegistryLite extensionRegistry)
+ throws InvalidProtocolBufferException {
+ int size;
+ try {
+ int firstByte = input.read();
+ if (firstByte == -1) {
+ return null;
+ }
+ size = CodedInputStream.readRawVarint32(firstByte, input);
+ } catch (IOException e) {
+ throw new InvalidProtocolBufferException(e.getMessage());
+ }
+ InputStream limitedInput = new LimitedInputStream(input, size);
+ return parsePartialFrom(limitedInput, extensionRegistry);
+ }
+
+ public MessageType parsePartialDelimitedFrom(InputStream input)
+ throws InvalidProtocolBufferException {
+ return parsePartialDelimitedFrom(input, EMPTY_REGISTRY);
+ }
+
+ public MessageType parseDelimitedFrom(
+ InputStream input,
+ ExtensionRegistryLite extensionRegistry)
+ throws InvalidProtocolBufferException {
+ return checkMessageInitialized(
+ parsePartialDelimitedFrom(input, extensionRegistry));
+ }
+
+ public MessageType parseDelimitedFrom(InputStream input)
+ throws InvalidProtocolBufferException {
+ return parseDelimitedFrom(input, EMPTY_REGISTRY);
+ }
+}
diff --git a/java/src/main/java/com/google/protobuf/BlockingRpcChannel.java b/java/src/main/java/com/google/protobuf/BlockingRpcChannel.java
new file mode 100644
index 0000000..d535efb
--- /dev/null
+++ b/java/src/main/java/com/google/protobuf/BlockingRpcChannel.java
@@ -0,0 +1,51 @@
+// 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.
+
+package com.google.protobuf;
+
+/**
+ * <p>Abstract interface for a blocking RPC channel. {@code BlockingRpcChannel}
+ * is the blocking equivalent to {@link RpcChannel}.
+ *
+ * @author kenton@google.com Kenton Varda
+ * @author cpovirk@google.com Chris Povirk
+ */
+public interface BlockingRpcChannel {
+ /**
+ * Call the given method of the remote service and blocks until it returns.
+ * {@code callBlockingMethod()} is the blocking equivalent to
+ * {@link RpcChannel#callMethod}.
+ */
+ Message callBlockingMethod(
+ Descriptors.MethodDescriptor method,
+ RpcController controller,
+ Message request,
+ Message responsePrototype) throws ServiceException;
+}
diff --git a/java/src/main/java/com/google/protobuf/BlockingService.java b/java/src/main/java/com/google/protobuf/BlockingService.java
new file mode 100644
index 0000000..d01f0b8
--- /dev/null
+++ b/java/src/main/java/com/google/protobuf/BlockingService.java
@@ -0,0 +1,64 @@
+// 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.
+
+package com.google.protobuf;
+
+/**
+ * Blocking equivalent to {@link Service}.
+ *
+ * @author kenton@google.com Kenton Varda
+ * @author cpovirk@google.com Chris Povirk
+ */
+public interface BlockingService {
+ /**
+ * Equivalent to {@link Service#getDescriptorForType}.
+ */
+ Descriptors.ServiceDescriptor getDescriptorForType();
+
+ /**
+ * Equivalent to {@link Service#callMethod}, except that
+ * {@code callBlockingMethod()} returns the result of the RPC or throws a
+ * {@link ServiceException} if there is a failure, rather than passing the
+ * information to a callback.
+ */
+ Message callBlockingMethod(Descriptors.MethodDescriptor method,
+ RpcController controller,
+ Message request) throws ServiceException;
+
+ /**
+ * Equivalent to {@link Service#getRequestPrototype}.
+ */
+ Message getRequestPrototype(Descriptors.MethodDescriptor method);
+
+ /**
+ * Equivalent to {@link Service#getResponsePrototype}.
+ */
+ Message getResponsePrototype(Descriptors.MethodDescriptor method);
+}
diff --git a/java/src/main/java/com/google/protobuf/BoundedByteString.java b/java/src/main/java/com/google/protobuf/BoundedByteString.java
new file mode 100644
index 0000000..b4c3fb1
--- /dev/null
+++ b/java/src/main/java/com/google/protobuf/BoundedByteString.java
@@ -0,0 +1,180 @@
+// 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.
+
+package com.google.protobuf;
+
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.util.NoSuchElementException;
+
+/**
+ * This class is used to represent the substring of a {@link ByteString} over a
+ * single byte array. In terms of the public API of {@link ByteString}, you end
+ * up here by calling {@link ByteString#copyFrom(byte[])} followed by {@link
+ * ByteString#substring(int, int)}.
+ *
+ * <p>This class contains most of the overhead involved in creating a substring
+ * from a {@link LiteralByteString}. The overhead involves some range-checking
+ * and two extra fields.
+ *
+ * @author carlanton@google.com (Carl Haverl)
+ */
+class BoundedByteString extends LiteralByteString {
+
+ private final int bytesOffset;
+ private final int bytesLength;
+
+ /**
+ * Creates a {@code BoundedByteString} backed by the sub-range of given array,
+ * without copying.
+ *
+ * @param bytes array to wrap
+ * @param offset index to first byte to use in bytes
+ * @param length number of bytes to use from bytes
+ * @throws IllegalArgumentException if {@code offset < 0}, {@code length < 0},
+ * or if {@code offset + length >
+ * bytes.length}.
+ */
+ BoundedByteString(byte[] bytes, int offset, int length) {
+ super(bytes);
+ if (offset < 0) {
+ throw new IllegalArgumentException("Offset too small: " + offset);
+ }
+ if (length < 0) {
+ throw new IllegalArgumentException("Length too small: " + offset);
+ }
+ if ((long) offset + length > bytes.length) {
+ throw new IllegalArgumentException(
+ "Offset+Length too large: " + offset + "+" + length);
+ }
+
+ this.bytesOffset = offset;
+ this.bytesLength = length;
+ }
+
+ /**
+ * Gets the byte at the given index.
+ * Throws {@link ArrayIndexOutOfBoundsException}
+ * for backwards-compatibility reasons although it would more properly be
+ * {@link IndexOutOfBoundsException}.
+ *
+ * @param index index of byte
+ * @return the value
+ * @throws ArrayIndexOutOfBoundsException {@code index} is < 0 or >= size
+ */
+ @Override
+ public byte byteAt(int index) {
+ // We must check the index ourselves as we cannot rely on Java array index
+ // checking for substrings.
+ if (index < 0) {
+ throw new ArrayIndexOutOfBoundsException("Index too small: " + index);
+ }
+ if (index >= size()) {
+ throw new ArrayIndexOutOfBoundsException(
+ "Index too large: " + index + ", " + size());
+ }
+
+ return bytes[bytesOffset + index];
+ }
+
+ @Override
+ public int size() {
+ return bytesLength;
+ }
+
+ @Override
+ protected int getOffsetIntoBytes() {
+ return bytesOffset;
+ }
+
+ // =================================================================
+ // ByteString -> byte[]
+
+ @Override
+ protected void copyToInternal(byte[] target, int sourceOffset,
+ int targetOffset, int numberToCopy) {
+ System.arraycopy(bytes, getOffsetIntoBytes() + sourceOffset, target,
+ targetOffset, numberToCopy);
+ }
+
+ // =================================================================
+ // Serializable
+
+ private static final long serialVersionUID = 1L;
+
+ Object writeReplace() {
+ return new LiteralByteString(toByteArray());
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException {
+ throw new InvalidObjectException(
+ "BoundedByteStream instances are not to be serialized directly");
+ }
+
+ // =================================================================
+ // ByteIterator
+
+ @Override
+ public ByteIterator iterator() {
+ return new BoundedByteIterator();
+ }
+
+ private class BoundedByteIterator implements ByteIterator {
+
+ private int position;
+ private final int limit;
+
+ private BoundedByteIterator() {
+ position = getOffsetIntoBytes();
+ limit = position + size();
+ }
+
+ public boolean hasNext() {
+ return (position < limit);
+ }
+
+ public Byte next() {
+ // Boxing calls Byte.valueOf(byte), which does not instantiate.
+ return nextByte();
+ }
+
+ public byte nextByte() {
+ if (position >= limit) {
+ throw new NoSuchElementException();
+ }
+ return bytes[position++];
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
diff --git a/java/src/main/java/com/google/protobuf/ByteString.java b/java/src/main/java/com/google/protobuf/ByteString.java
new file mode 100644
index 0000000..9b0a524
--- /dev/null
+++ b/java/src/main/java/com/google/protobuf/ByteString.java
@@ -0,0 +1,1026 @@
+// 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.
+
+package com.google.protobuf;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+/**
+ * Immutable sequence of bytes. Substring is supported by sharing the reference
+ * to the immutable underlying bytes, as with {@link String}. Concatenation is
+ * likewise supported without copying (long strings) by building a tree of
+ * pieces in {@link RopeByteString}.
+ * <p>
+ * Like {@link String}, the contents of a {@link ByteString} can never be
+ * observed to change, not even in the presence of a data race or incorrect
+ * API usage in the client code.
+ *
+ * @author crazybob@google.com Bob Lee
+ * @author kenton@google.com Kenton Varda
+ * @author carlanton@google.com Carl Haverl
+ * @author martinrb@google.com Martin Buchholz
+ */
+public abstract class ByteString implements Iterable<Byte>, Serializable {
+
+ /**
+ * When two strings to be concatenated have a combined length shorter than
+ * this, we just copy their bytes on {@link #concat(ByteString)}.
+ * The trade-off is copy size versus the overhead of creating tree nodes
+ * in {@link RopeByteString}.
+ */
+ static final int CONCATENATE_BY_COPY_SIZE = 128;
+
+ /**
+ * When copying an InputStream into a ByteString with .readFrom(),
+ * the chunks in the underlying rope start at 256 bytes, but double
+ * each iteration up to 8192 bytes.
+ */
+ static final int MIN_READ_FROM_CHUNK_SIZE = 0x100; // 256b
+ static final int MAX_READ_FROM_CHUNK_SIZE = 0x2000; // 8k
+
+ // Defined by java.nio.charset.Charset
+ protected static final String UTF_8 = "UTF-8";
+
+ /**
+ * Empty {@code ByteString}.
+ */
+ public static final ByteString EMPTY = new LiteralByteString(new byte[0]);
+
+ // This constructor is here to prevent subclassing outside of this package,
+ ByteString() {}
+
+ /**
+ * Gets the byte at the given index. This method should be used only for
+ * random access to individual bytes. To access bytes sequentially, use the
+ * {@link ByteIterator} returned by {@link #iterator()}, and call {@link
+ * #substring(int, int)} first if necessary.
+ *
+ * @param index index of byte
+ * @return the value
+ * @throws ArrayIndexOutOfBoundsException {@code index} is < 0 or >= size
+ */
+ public abstract byte byteAt(int index);
+
+ /**
+ * Return a {@link ByteString.ByteIterator} over the bytes in the ByteString.
+ * To avoid auto-boxing, you may get the iterator manually and call
+ * {@link ByteIterator#nextByte()}.
+ *
+ * @return the iterator
+ */
+ public abstract ByteIterator iterator();
+
+ /**
+ * This interface extends {@code Iterator<Byte>}, so that we can return an
+ * unboxed {@code byte}.
+ */
+ public interface ByteIterator extends Iterator<Byte> {
+ /**
+ * An alternative to {@link Iterator#next()} that returns an
+ * unboxed primitive {@code byte}.
+ *
+ * @return the next {@code byte} in the iteration
+ * @throws NoSuchElementException if the iteration has no more elements
+ */
+ byte nextByte();
+ }
+
+ /**
+ * Gets the number of bytes.
+ *
+ * @return size in bytes
+ */
+ public abstract int size();
+
+ /**
+ * Returns {@code true} if the size is {@code 0}, {@code false} otherwise.
+ *
+ * @return true if this is zero bytes long
+ */
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ // =================================================================
+ // ByteString -> substring
+
+ /**
+ * Return the substring from {@code beginIndex}, inclusive, to the end of the
+ * string.
+ *
+ * @param beginIndex start at this index
+ * @return substring sharing underlying data
+ * @throws IndexOutOfBoundsException if {@code beginIndex < 0} or
+ * {@code beginIndex > size()}.
+ */
+ public ByteString substring(int beginIndex) {
+ return substring(beginIndex, size());
+ }
+
+ /**
+ * Return the substring from {@code beginIndex}, inclusive, to {@code
+ * endIndex}, exclusive.
+ *
+ * @param beginIndex start at this index
+ * @param endIndex the last character is the one before this index
+ * @return substring sharing underlying data
+ * @throws IndexOutOfBoundsException if {@code beginIndex < 0},
+ * {@code endIndex > size()}, or {@code beginIndex > endIndex}.
+ */
+ public abstract ByteString substring(int beginIndex, int endIndex);
+
+ /**
+ * Tests if this bytestring starts with the specified prefix.
+ * Similar to {@link String#startsWith(String)}
+ *
+ * @param prefix the prefix.
+ * @return <code>true</code> if the byte sequence represented by the
+ * argument is a prefix of the byte sequence represented by
+ * this string; <code>false</code> otherwise.
+ */
+ public boolean startsWith(ByteString prefix) {
+ return size() >= prefix.size() &&
+ substring(0, prefix.size()).equals(prefix);
+ }
+
+ /**
+ * Tests if this bytestring ends with the specified suffix.
+ * Similar to {@link String#endsWith(String)}
+ *
+ * @param suffix the suffix.
+ * @return <code>true</code> if the byte sequence represented by the
+ * argument is a suffix of the byte sequence represented by
+ * this string; <code>false</code> otherwise.
+ */
+ public boolean endsWith(ByteString suffix) {
+ return size() >= suffix.size() &&
+ substring(size() - suffix.size()).equals(suffix);
+ }
+
+ // =================================================================
+ // byte[] -> ByteString
+
+ /**
+ * Copies the given bytes into a {@code ByteString}.
+ *
+ * @param bytes source array
+ * @param offset offset in source array
+ * @param size number of bytes to copy
+ * @return new {@code ByteString}
+ */
+ public static ByteString copyFrom(byte[] bytes, int offset, int size) {
+ byte[] copy = new byte[size];
+ System.arraycopy(bytes, offset, copy, 0, size);
+ return new LiteralByteString(copy);
+ }
+
+ /**
+ * Copies the given bytes into a {@code ByteString}.
+ *
+ * @param bytes to copy
+ * @return new {@code ByteString}
+ */
+ public static ByteString copyFrom(byte[] bytes) {
+ return copyFrom(bytes, 0, bytes.length);
+ }
+
+ /**
+ * Copies the next {@code size} bytes from a {@code java.nio.ByteBuffer} into
+ * a {@code ByteString}.
+ *
+ * @param bytes source buffer
+ * @param size number of bytes to copy
+ * @return new {@code ByteString}
+ */
+ public static ByteString copyFrom(ByteBuffer bytes, int size) {
+ byte[] copy = new byte[size];
+ bytes.get(copy);
+ return new LiteralByteString(copy);
+ }
+
+ /**
+ * Copies the remaining bytes from a {@code java.nio.ByteBuffer} into
+ * a {@code ByteString}.
+ *
+ * @param bytes sourceBuffer
+ * @return new {@code ByteString}
+ */
+ public static ByteString copyFrom(ByteBuffer bytes) {
+ return copyFrom(bytes, bytes.remaining());
+ }
+
+ /**
+ * Encodes {@code text} into a sequence of bytes using the named charset
+ * and returns the result as a {@code ByteString}.
+ *
+ * @param text source string
+ * @param charsetName encoding to use
+ * @return new {@code ByteString}
+ * @throws UnsupportedEncodingException if the encoding isn't found
+ */
+ public static ByteString copyFrom(String text, String charsetName)
+ throws UnsupportedEncodingException {
+ return new LiteralByteString(text.getBytes(charsetName));
+ }
+
+ /**
+ * Encodes {@code text} into a sequence of UTF-8 bytes and returns the
+ * result as a {@code ByteString}.
+ *
+ * @param text source string
+ * @return new {@code ByteString}
+ */
+ public static ByteString copyFromUtf8(String text) {
+ try {
+ return new LiteralByteString(text.getBytes(UTF_8));
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException("UTF-8 not supported?", e);
+ }
+ }
+
+ // =================================================================
+ // InputStream -> ByteString
+
+ /**
+ * Completely reads the given stream's bytes into a
+ * {@code ByteString}, blocking if necessary until all bytes are
+ * read through to the end of the stream.
+ *
+ * <b>Performance notes:</b> The returned {@code ByteString} is an
+ * immutable tree of byte arrays ("chunks") of the stream data. The
+ * first chunk is small, with subsequent chunks each being double
+ * the size, up to 8K. If the caller knows the precise length of
+ * the stream and wishes to avoid all unnecessary copies and
+ * allocations, consider using the two-argument version of this
+ * method, below.
+ *
+ * @param streamToDrain The source stream, which is read completely
+ * but not closed.
+ * @return A new {@code ByteString} which is made up of chunks of
+ * various sizes, depending on the behavior of the underlying
+ * stream.
+ * @throws IOException IOException is thrown if there is a problem
+ * reading the underlying stream.
+ */
+ public static ByteString readFrom(InputStream streamToDrain)
+ throws IOException {
+ return readFrom(
+ streamToDrain, MIN_READ_FROM_CHUNK_SIZE, MAX_READ_FROM_CHUNK_SIZE);
+ }
+
+ /**
+ * Completely reads the given stream's bytes into a
+ * {@code ByteString}, blocking if necessary until all bytes are
+ * read through to the end of the stream.
+ *
+ * <b>Performance notes:</b> The returned {@code ByteString} is an
+ * immutable tree of byte arrays ("chunks") of the stream data. The
+ * chunkSize parameter sets the size of these byte arrays. In
+ * particular, if the chunkSize is precisely the same as the length
+ * of the stream, unnecessary allocations and copies will be
+ * avoided. Otherwise, the chunks will be of the given size, except
+ * for the last chunk, which will be resized (via a reallocation and
+ * copy) to contain the remainder of the stream.
+ *
+ * @param streamToDrain The source stream, which is read completely
+ * but not closed.
+ * @param chunkSize The size of the chunks in which to read the
+ * stream.
+ * @return A new {@code ByteString} which is made up of chunks of
+ * the given size.
+ * @throws IOException IOException is thrown if there is a problem
+ * reading the underlying stream.
+ */
+ public static ByteString readFrom(InputStream streamToDrain, int chunkSize)
+ throws IOException {
+ return readFrom(streamToDrain, chunkSize, chunkSize);
+ }
+
+ // Helper method that takes the chunk size range as a parameter.
+ public static ByteString readFrom(InputStream streamToDrain, int minChunkSize,
+ int maxChunkSize) throws IOException {
+ Collection<ByteString> results = new ArrayList<ByteString>();
+
+ // copy the inbound bytes into a list of chunks; the chunk size
+ // grows exponentially to support both short and long streams.
+ int chunkSize = minChunkSize;
+ while (true) {
+ ByteString chunk = readChunk(streamToDrain, chunkSize);
+ if (chunk == null) {
+ break;
+ }
+ results.add(chunk);
+ chunkSize = Math.min(chunkSize * 2, maxChunkSize);
+ }
+
+ return ByteString.copyFrom(results);
+ }
+
+ /**
+ * Blocks until a chunk of the given size can be made from the
+ * stream, or EOF is reached. Calls read() repeatedly in case the
+ * given stream implementation doesn't completely fill the given
+ * buffer in one read() call.
+ *
+ * @return A chunk of the desired size, or else a chunk as large as
+ * was available when end of stream was reached. Returns null if the
+ * given stream had no more data in it.
+ */
+ private static ByteString readChunk(InputStream in, final int chunkSize)
+ throws IOException {
+ final byte[] buf = new byte[chunkSize];
+ int bytesRead = 0;
+ while (bytesRead < chunkSize) {
+ final int count = in.read(buf, bytesRead, chunkSize - bytesRead);
+ if (count == -1) {
+ break;
+ }
+ bytesRead += count;
+ }
+
+ if (bytesRead == 0) {
+ return null;
+ } else {
+ return ByteString.copyFrom(buf, 0, bytesRead);
+ }
+ }
+
+ // =================================================================
+ // Multiple ByteStrings -> One ByteString
+
+ /**
+ * Concatenate the given {@code ByteString} to this one. Short concatenations,
+ * of total size smaller than {@link ByteString#CONCATENATE_BY_COPY_SIZE}, are
+ * produced by copying the underlying bytes (as per Rope.java, <a
+ * href="http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol25/issue12/spe986.pdf">
+ * BAP95 </a>. In general, the concatenate involves no copying.
+ *
+ * @param other string to concatenate
+ * @return a new {@code ByteString} instance
+ */
+ public ByteString concat(ByteString other) {
+ int thisSize = size();
+ int otherSize = other.size();
+ if ((long) thisSize + otherSize >= Integer.MAX_VALUE) {
+ throw new IllegalArgumentException("ByteString would be too long: " +
+ thisSize + "+" + otherSize);
+ }
+
+ return RopeByteString.concatenate(this, other);
+ }
+
+ /**
+ * Concatenates all byte strings in the iterable and returns the result.
+ * This is designed to run in O(list size), not O(total bytes).
+ *
+ * <p>The returned {@code ByteString} is not necessarily a unique object.
+ * If the list is empty, the returned object is the singleton empty
+ * {@code ByteString}. If the list has only one element, that
+ * {@code ByteString} will be returned without copying.
+ *
+ * @param byteStrings strings to be concatenated
+ * @return new {@code ByteString}
+ */
+ public static ByteString copyFrom(Iterable<ByteString> byteStrings) {
+ Collection<ByteString> collection;
+ if (!(byteStrings instanceof Collection)) {
+ collection = new ArrayList<ByteString>();
+ for (ByteString byteString : byteStrings) {
+ collection.add(byteString);
+ }
+ } else {
+ collection = (Collection<ByteString>) byteStrings;
+ }
+ ByteString result;
+ if (collection.isEmpty()) {
+ result = EMPTY;
+ } else {
+ result = balancedConcat(collection.iterator(), collection.size());
+ }
+ return result;
+ }
+
+ // Internal function used by copyFrom(Iterable<ByteString>).
+ // Create a balanced concatenation of the next "length" elements from the
+ // iterable.
+ private static ByteString balancedConcat(Iterator<ByteString> iterator,
+ int length) {
+ assert length >= 1;
+ ByteString result;
+ if (length == 1) {
+ result = iterator.next();
+ } else {
+ int halfLength = length >>> 1;
+ ByteString left = balancedConcat(iterator, halfLength);
+ ByteString right = balancedConcat(iterator, length - halfLength);
+ result = left.concat(right);
+ }
+ return result;
+ }
+
+ // =================================================================
+ // ByteString -> byte[]
+
+ /**
+ * Copies bytes into a buffer at the given offset.
+ *
+ * @param target buffer to copy into
+ * @param offset in the target buffer
+ * @throws IndexOutOfBoundsException if the offset is negative or too large
+ */
+ public void copyTo(byte[] target, int offset) {
+ copyTo(target, 0, offset, size());
+ }
+
+ /**
+ * Copies bytes into a buffer.
+ *
+ * @param target buffer to copy into
+ * @param sourceOffset offset within these bytes
+ * @param targetOffset offset within the target buffer
+ * @param numberToCopy number of bytes to copy
+ * @throws IndexOutOfBoundsException if an offset or size is negative or too
+ * large
+ */
+ public void copyTo(byte[] target, int sourceOffset, int targetOffset,
+ int numberToCopy) {
+ if (sourceOffset < 0) {
+ throw new IndexOutOfBoundsException("Source offset < 0: " + sourceOffset);
+ }
+ if (targetOffset < 0) {
+ throw new IndexOutOfBoundsException("Target offset < 0: " + targetOffset);
+ }
+ if (numberToCopy < 0) {
+ throw new IndexOutOfBoundsException("Length < 0: " + numberToCopy);
+ }
+ if (sourceOffset + numberToCopy > size()) {
+ throw new IndexOutOfBoundsException(
+ "Source end offset < 0: " + (sourceOffset + numberToCopy));
+ }
+ if (targetOffset + numberToCopy > target.length) {
+ throw new IndexOutOfBoundsException(
+ "Target end offset < 0: " + (targetOffset + numberToCopy));
+ }
+ if (numberToCopy > 0) {
+ copyToInternal(target, sourceOffset, targetOffset, numberToCopy);
+ }
+ }
+
+ /**
+ * Internal (package private) implementation of
+ * {@link #copyTo(byte[],int,int,int)}.
+ * It assumes that all error checking has already been performed and that
+ * {@code numberToCopy > 0}.
+ */
+ protected abstract void copyToInternal(byte[] target, int sourceOffset,
+ int targetOffset, int numberToCopy);
+
+ /**
+ * Copies bytes into a ByteBuffer.
+ *
+ * @param target ByteBuffer to copy into.
+ * @throws java.nio.ReadOnlyBufferException if the {@code target} is read-only
+ * @throws java.nio.BufferOverflowException if the {@code target}'s
+ * remaining() space is not large enough to hold the data.
+ */
+ public abstract void copyTo(ByteBuffer target);
+
+ /**
+ * Copies bytes to a {@code byte[]}.
+ *
+ * @return copied bytes
+ */
+ public byte[] toByteArray() {
+ int size = size();
+ if (size == 0) {
+ return Internal.EMPTY_BYTE_ARRAY;
+ }
+ byte[] result = new byte[size];
+ copyToInternal(result, 0, 0, size);
+ return result;
+ }
+
+ /**
+ * Writes the complete contents of this byte string to
+ * the specified output stream argument.
+ *
+ * @param out the output stream to which to write the data.
+ * @throws IOException if an I/O error occurs.
+ */
+ public abstract void writeTo(OutputStream out) throws IOException;
+
+ /**
+ * Writes a specified part of this byte string to an output stream.
+ *
+ * @param out the output stream to which to write the data.
+ * @param sourceOffset offset within these bytes
+ * @param numberToWrite number of bytes to write
+ * @throws IOException if an I/O error occurs.
+ * @throws IndexOutOfBoundsException if an offset or size is negative or too
+ * large
+ */
+ void writeTo(OutputStream out, int sourceOffset, int numberToWrite)
+ throws IOException {
+ if (sourceOffset < 0) {
+ throw new IndexOutOfBoundsException("Source offset < 0: " + sourceOffset);
+ }
+ if (numberToWrite < 0) {
+ throw new IndexOutOfBoundsException("Length < 0: " + numberToWrite);
+ }
+ if (sourceOffset + numberToWrite > size()) {
+ throw new IndexOutOfBoundsException(
+ "Source end offset exceeded: " + (sourceOffset + numberToWrite));
+ }
+ if (numberToWrite > 0) {
+ writeToInternal(out, sourceOffset, numberToWrite);
+ }
+
+ }
+
+ /**
+ * Internal version of {@link #writeTo(OutputStream,int,int)} that assumes
+ * all error checking has already been done.
+ */
+ abstract void writeToInternal(OutputStream out, int sourceOffset,
+ int numberToWrite) throws IOException;
+
+ /**
+ * Constructs a read-only {@code java.nio.ByteBuffer} whose content
+ * is equal to the contents of this byte string.
+ * The result uses the same backing array as the byte string, if possible.
+ *
+ * @return wrapped bytes
+ */
+ public abstract ByteBuffer asReadOnlyByteBuffer();
+
+ /**
+ * Constructs a list of read-only {@code java.nio.ByteBuffer} objects
+ * such that the concatenation of their contents is equal to the contents
+ * of this byte string. The result uses the same backing arrays as the
+ * byte string.
+ * <p>
+ * By returning a list, implementations of this method may be able to avoid
+ * copying even when there are multiple backing arrays.
+ *
+ * @return a list of wrapped bytes
+ */
+ public abstract List<ByteBuffer> asReadOnlyByteBufferList();
+
+ /**
+ * Constructs a new {@code String} by decoding the bytes using the
+ * specified charset.
+ *
+ * @param charsetName encode using this charset
+ * @return new string
+ * @throws UnsupportedEncodingException if charset isn't recognized
+ */
+ public abstract String toString(String charsetName)
+ throws UnsupportedEncodingException;
+
+ // =================================================================
+ // UTF-8 decoding
+
+ /**
+ * Constructs a new {@code String} by decoding the bytes as UTF-8.
+ *
+ * @return new string using UTF-8 encoding
+ */
+ public String toStringUtf8() {
+ try {
+ return toString(UTF_8);
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException("UTF-8 not supported?", e);
+ }
+ }
+
+ /**
+ * Tells whether this {@code ByteString} represents a well-formed UTF-8
+ * byte sequence, such that the original bytes can be converted to a
+ * String object and then round tripped back to bytes without loss.
+ *
+ * <p>More precisely, returns {@code true} whenever: <pre> {@code
+ * Arrays.equals(byteString.toByteArray(),
+ * new String(byteString.toByteArray(), "UTF-8").getBytes("UTF-8"))
+ * }</pre>
+ *
+ * <p>This method returns {@code false} for "overlong" byte sequences,
+ * as well as for 3-byte sequences that would map to a surrogate
+ * character, in accordance with the restricted definition of UTF-8
+ * introduced in Unicode 3.1. Note that the UTF-8 decoder included in
+ * Oracle's JDK has been modified to also reject "overlong" byte
+ * sequences, but (as of 2011) still accepts 3-byte surrogate
+ * character byte sequences.
+ *
+ * <p>See the Unicode Standard,</br>
+ * Table 3-6. <em>UTF-8 Bit Distribution</em>,</br>
+ * Table 3-7. <em>Well Formed UTF-8 Byte Sequences</em>.
+ *
+ * @return whether the bytes in this {@code ByteString} are a
+ * well-formed UTF-8 byte sequence
+ */
+ public abstract boolean isValidUtf8();
+
+ /**
+ * Tells whether the given byte sequence is a well-formed, malformed, or
+ * incomplete UTF-8 byte sequence. This method accepts and returns a partial
+ * state result, allowing the bytes for a complete UTF-8 byte sequence to be
+ * composed from multiple {@code ByteString} segments.
+ *
+ * @param state either {@code 0} (if this is the initial decoding operation)
+ * or the value returned from a call to a partial decoding method for the
+ * previous bytes
+ * @param offset offset of the first byte to check
+ * @param length number of bytes to check
+ *
+ * @return {@code -1} if the partial byte sequence is definitely malformed,
+ * {@code 0} if it is well-formed (no additional input needed), or, if the
+ * byte sequence is "incomplete", i.e. apparently terminated in the middle of
+ * a character, an opaque integer "state" value containing enough information
+ * to decode the character when passed to a subsequent invocation of a
+ * partial decoding method.
+ */
+ protected abstract int partialIsValidUtf8(int state, int offset, int length);
+
+ // =================================================================
+ // equals() and hashCode()
+
+ @Override
+ public abstract boolean equals(Object o);
+
+ /**
+ * Return a non-zero hashCode depending only on the sequence of bytes
+ * in this ByteString.
+ *
+ * @return hashCode value for this object
+ */
+ @Override
+ public abstract int hashCode();
+
+ // =================================================================
+ // Input stream
+
+ /**
+ * Creates an {@code InputStream} which can be used to read the bytes.
+ * <p>
+ * The {@link InputStream} returned by this method is guaranteed to be
+ * completely non-blocking. The method {@link InputStream#available()}
+ * returns the number of bytes remaining in the stream. The methods
+ * {@link InputStream#read(byte[])}, {@link InputStream#read(byte[],int,int)}
+ * and {@link InputStream#skip(long)} will read/skip as many bytes as are
+ * available.
+ * <p>
+ * The methods in the returned {@link InputStream} might <b>not</b> be
+ * thread safe.
+ *
+ * @return an input stream that returns the bytes of this byte string.
+ */
+ public abstract InputStream newInput();
+
+ /**
+ * Creates a {@link CodedInputStream} which can be used to read the bytes.
+ * Using this is often more efficient than creating a {@link CodedInputStream}
+ * that wraps the result of {@link #newInput()}.
+ *
+ * @return stream based on wrapped data
+ */
+ public abstract CodedInputStream newCodedInput();
+
+ // =================================================================
+ // Output stream
+
+ /**
+ * Creates a new {@link Output} with the given initial capacity. Call {@link
+ * Output#toByteString()} to create the {@code ByteString} instance.
+ * <p>
+ * A {@link ByteString.Output} offers the same functionality as a
+ * {@link ByteArrayOutputStream}, except that it returns a {@link ByteString}
+ * rather than a {@code byte} array.
+ *
+ * @param initialCapacity estimate of number of bytes to be written
+ * @return {@code OutputStream} for building a {@code ByteString}
+ */
+ public static Output newOutput(int initialCapacity) {
+ return new Output(initialCapacity);
+ }
+
+ /**
+ * Creates a new {@link Output}. Call {@link Output#toByteString()} to create
+ * the {@code ByteString} instance.
+ * <p>
+ * A {@link ByteString.Output} offers the same functionality as a
+ * {@link ByteArrayOutputStream}, except that it returns a {@link ByteString}
+ * rather than a {@code byte array}.
+ *
+ * @return {@code OutputStream} for building a {@code ByteString}
+ */
+ public static Output newOutput() {
+ return new Output(CONCATENATE_BY_COPY_SIZE);
+ }
+
+ /**
+ * Outputs to a {@code ByteString} instance. Call {@link #toByteString()} to
+ * create the {@code ByteString} instance.
+ */
+ public static final class Output extends OutputStream {
+ // Implementation note.
+ // The public methods of this class must be synchronized. ByteStrings
+ // are guaranteed to be immutable. Without some sort of locking, it could
+ // be possible for one thread to call toByteSring(), while another thread
+ // is still modifying the underlying byte array.
+
+ private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
+ // argument passed by user, indicating initial capacity.
+ private final int initialCapacity;
+ // ByteStrings to be concatenated to create the result
+ private final ArrayList<ByteString> flushedBuffers;
+ // Total number of bytes in the ByteStrings of flushedBuffers
+ private int flushedBuffersTotalBytes;
+ // Current buffer to which we are writing
+ private byte[] buffer;
+ // Location in buffer[] to which we write the next byte.
+ private int bufferPos;
+
+ /**
+ * Creates a new ByteString output stream with the specified
+ * initial capacity.
+ *
+ * @param initialCapacity the initial capacity of the output stream.
+ */
+ Output(int initialCapacity) {
+ if (initialCapacity < 0) {
+ throw new IllegalArgumentException("Buffer size < 0");
+ }
+ this.initialCapacity = initialCapacity;
+ this.flushedBuffers = new ArrayList<ByteString>();
+ this.buffer = new byte[initialCapacity];
+ }
+
+ @Override
+ public synchronized void write(int b) {
+ if (bufferPos == buffer.length) {
+ flushFullBuffer(1);
+ }
+ buffer[bufferPos++] = (byte)b;
+ }
+
+ @Override
+ public synchronized void write(byte[] b, int offset, int length) {
+ if (length <= buffer.length - bufferPos) {
+ // The bytes can fit into the current buffer.
+ System.arraycopy(b, offset, buffer, bufferPos, length);
+ bufferPos += length;
+ } else {
+ // Use up the current buffer
+ int copySize = buffer.length - bufferPos;
+ System.arraycopy(b, offset, buffer, bufferPos, copySize);
+ offset += copySize;
+ length -= copySize;
+ // Flush the buffer, and get a new buffer at least big enough to cover
+ // what we still need to output
+ flushFullBuffer(length);
+ System.arraycopy(b, offset, buffer, 0 /* count */, length);
+ bufferPos = length;
+ }
+ }
+
+ /**
+ * Creates a byte string. Its size is the current size of this output
+ * stream and its output has been copied to it.
+ *
+ * @return the current contents of this output stream, as a byte string.
+ */
+ public synchronized ByteString toByteString() {
+ flushLastBuffer();
+ return ByteString.copyFrom(flushedBuffers);
+ }
+
+ /**
+ * Implement java.util.Arrays.copyOf() for jdk 1.5.
+ */
+ private byte[] copyArray(byte[] buffer, int length) {
+ byte[] result = new byte[length];
+ System.arraycopy(buffer, 0, result, 0, Math.min(buffer.length, length));
+ return result;
+ }
+
+ /**
+ * Writes the complete contents of this byte array output stream to
+ * the specified output stream argument.
+ *
+ * @param out the output stream to which to write the data.
+ * @throws IOException if an I/O error occurs.
+ */
+ public void writeTo(OutputStream out) throws IOException {
+ ByteString[] cachedFlushBuffers;
+ byte[] cachedBuffer;
+ int cachedBufferPos;
+ synchronized (this) {
+ // Copy the information we need into local variables so as to hold
+ // the lock for as short a time as possible.
+ cachedFlushBuffers =
+ flushedBuffers.toArray(new ByteString[flushedBuffers.size()]);
+ cachedBuffer = buffer;
+ cachedBufferPos = bufferPos;
+ }
+ for (ByteString byteString : cachedFlushBuffers) {
+ byteString.writeTo(out);
+ }
+
+ out.write(copyArray(cachedBuffer, cachedBufferPos));
+ }
+
+ /**
+ * Returns the current size of the output stream.
+ *
+ * @return the current size of the output stream
+ */
+ public synchronized int size() {
+ return flushedBuffersTotalBytes + bufferPos;
+ }
+
+ /**
+ * Resets this stream, so that all currently accumulated output in the
+ * output stream is discarded. The output stream can be used again,
+ * reusing the already allocated buffer space.
+ */
+ public synchronized void reset() {
+ flushedBuffers.clear();
+ flushedBuffersTotalBytes = 0;
+ bufferPos = 0;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("<ByteString.Output@%s size=%d>",
+ Integer.toHexString(System.identityHashCode(this)), size());
+ }
+
+ /**
+ * Internal function used by writers. The current buffer is full, and the
+ * writer needs a new buffer whose size is at least the specified minimum
+ * size.
+ */
+ private void flushFullBuffer(int minSize) {
+ flushedBuffers.add(new LiteralByteString(buffer));
+ flushedBuffersTotalBytes += buffer.length;
+ // We want to increase our total capacity by 50%, but as a minimum,
+ // the new buffer should also at least be >= minSize and
+ // >= initial Capacity.
+ int newSize = Math.max(initialCapacity,
+ Math.max(minSize, flushedBuffersTotalBytes >>> 1));
+ buffer = new byte[newSize];
+ bufferPos = 0;
+ }
+
+ /**
+ * Internal function used by {@link #toByteString()}. The current buffer may
+ * or may not be full, but it needs to be flushed.
+ */
+ private void flushLastBuffer() {
+ if (bufferPos < buffer.length) {
+ if (bufferPos > 0) {
+ byte[] bufferCopy = copyArray(buffer, bufferPos);
+ flushedBuffers.add(new LiteralByteString(bufferCopy));
+ }
+ // We reuse this buffer for further writes.
+ } else {
+ // Buffer is completely full. Huzzah.
+ flushedBuffers.add(new LiteralByteString(buffer));
+ // 99% of the time, we're not going to use this OutputStream again.
+ // We set buffer to an empty byte stream so that we're handling this
+ // case without wasting space. In the rare case that more writes
+ // *do* occur, this empty buffer will be flushed and an appropriately
+ // sized new buffer will be created.
+ buffer = EMPTY_BYTE_ARRAY;
+ }
+ flushedBuffersTotalBytes += bufferPos;
+ bufferPos = 0;
+ }
+ }
+
+ /**
+ * Constructs a new {@code ByteString} builder, which allows you to
+ * efficiently construct a {@code ByteString} by writing to a {@link
+ * CodedOutputStream}. Using this is much more efficient than calling {@code
+ * newOutput()} and wrapping that in a {@code CodedOutputStream}.
+ *
+ * <p>This is package-private because it's a somewhat confusing interface.
+ * Users can call {@link Message#toByteString()} instead of calling this
+ * directly.
+ *
+ * @param size The target byte size of the {@code ByteString}. You must write
+ * exactly this many bytes before building the result.
+ * @return the builder
+ */
+ static CodedBuilder newCodedBuilder(int size) {
+ return new CodedBuilder(size);
+ }
+
+ /** See {@link ByteString#newCodedBuilder(int)}. */
+ static final class CodedBuilder {
+ private final CodedOutputStream output;
+ private final byte[] buffer;
+
+ private CodedBuilder(int size) {
+ buffer = new byte[size];
+ output = CodedOutputStream.newInstance(buffer);
+ }
+
+ public ByteString build() {
+ output.checkNoSpaceLeft();
+
+ // We can be confident that the CodedOutputStream will not modify the
+ // underlying bytes anymore because it already wrote all of them. So,
+ // no need to make a copy.
+ return new LiteralByteString(buffer);
+ }
+
+ public CodedOutputStream getCodedOutput() {
+ return output;
+ }
+ }
+
+ // =================================================================
+ // Methods {@link RopeByteString} needs on instances, which aren't part of the
+ // public API.
+
+ /**
+ * Return the depth of the tree representing this {@code ByteString}, if any,
+ * whose root is this node. If this is a leaf node, return 0.
+ *
+ * @return tree depth or zero
+ */
+ protected abstract int getTreeDepth();
+
+ /**
+ * Return {@code true} if this ByteString is literal (a leaf node) or a
+ * flat-enough tree in the sense of {@link RopeByteString}.
+ *
+ * @return true if the tree is flat enough
+ */
+ protected abstract boolean isBalanced();
+
+ /**
+ * Return the cached hash code if available.
+ *
+ * @return value of cached hash code or 0 if not computed yet
+ */
+ protected abstract int peekCachedHashCode();
+
+ /**
+ * Compute the hash across the value bytes starting with the given hash, and
+ * return the result. This is used to compute the hash across strings
+ * represented as a set of pieces by allowing the hash computation to be
+ * continued from piece to piece.
+ *
+ * @param h starting hash value
+ * @param offset offset into this value to start looking at data values
+ * @param length number of data values to include in the hash computation
+ * @return ending hash value
+ */
+ protected abstract int partialHash(int h, int offset, int length);
+
+ @Override
+ public String toString() {
+ return String.format("<ByteString@%s size=%d>",
+ Integer.toHexString(System.identityHashCode(this)), size());
+ }
+}
diff --git a/java/src/main/java/com/google/protobuf/CodedInputStream.java b/java/src/main/java/com/google/protobuf/CodedInputStream.java
new file mode 100644
index 0000000..0ca00ba
--- /dev/null
+++ b/java/src/main/java/com/google/protobuf/CodedInputStream.java
@@ -0,0 +1,1311 @@
+// 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.
+
+package com.google.protobuf;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Reads and decodes protocol message fields.
+ *
+ * This class contains two kinds of methods: methods that read specific
+ * protocol message constructs and field types (e.g. {@link #readTag()} and
+ * {@link #readInt32()}) and methods that read low-level values (e.g.
+ * {@link #readRawVarint32()} and {@link #readRawBytes}). If you are reading
+ * encoded protocol messages, you should use the former methods, but if you are
+ * reading some other format of your own design, use the latter.
+ *
+ * @author kenton@google.com Kenton Varda
+ */
+public final class CodedInputStream {
+ /**
+ * Create a new CodedInputStream wrapping the given InputStream.
+ */
+ public static CodedInputStream newInstance(final InputStream input) {
+ return new CodedInputStream(input);
+ }
+
+ /**
+ * Create a new CodedInputStream wrapping the given byte array.
+ */
+ public static CodedInputStream newInstance(final byte[] buf) {
+ return newInstance(buf, 0, buf.length);
+ }
+
+ /**
+ * Create a new CodedInputStream wrapping the given byte array slice.
+ */
+ public static CodedInputStream newInstance(final byte[] buf, final int off,
+ final int len) {
+ CodedInputStream result = new CodedInputStream(buf, off, len);
+ try {
+ // Some uses of CodedInputStream can be more efficient if they know
+ // exactly how many bytes are available. By pushing the end point of the
+ // buffer as a limit, we allow them to get this information via
+ // getBytesUntilLimit(). Pushing a limit that we know is at the end of
+ // the stream can never hurt, since we can never past that point anyway.
+ result.pushLimit(len);
+ } catch (InvalidProtocolBufferException ex) {
+ // The only reason pushLimit() might throw an exception here is if len
+ // is negative. Normally pushLimit()'s parameter comes directly off the
+ // wire, so it's important to catch exceptions in case of corrupt or
+ // malicious data. However, in this case, we expect that len is not a
+ // user-supplied value, so we can assume that it being negative indicates
+ // a programming error. Therefore, throwing an unchecked exception is
+ // appropriate.
+ throw new IllegalArgumentException(ex);
+ }
+ return result;
+ }
+
+ /**
+ * Create a new CodedInputStream wrapping the given ByteBuffer. The data
+ * starting from the ByteBuffer's current position to its limit will be read.
+ * The returned CodedInputStream may or may not share the underlying data
+ * in the ByteBuffer, therefore the ByteBuffer cannot be changed while the
+ * CodedInputStream is in use.
+ * Note that the ByteBuffer's position won't be changed by this function.
+ * Concurrent calls with the same ByteBuffer object are safe if no other
+ * thread is trying to alter the ByteBuffer's status.
+ */
+ public static CodedInputStream newInstance(ByteBuffer buf) {
+ if (buf.hasArray()) {
+ return newInstance(buf.array(), buf.arrayOffset() + buf.position(),
+ buf.remaining());
+ } else {
+ ByteBuffer temp = buf.duplicate();
+ byte[] buffer = new byte[temp.remaining()];
+ temp.get(buffer);
+ return newInstance(buffer);
+ }
+ }
+
+ /**
+ * Create a new CodedInputStream wrapping a LiteralByteString.
+ */
+ static CodedInputStream newInstance(LiteralByteString byteString) {
+ CodedInputStream result = new CodedInputStream(byteString);
+ try {
+ // Some uses of CodedInputStream can be more efficient if they know
+ // exactly how many bytes are available. By pushing the end point of the
+ // buffer as a limit, we allow them to get this information via
+ // getBytesUntilLimit(). Pushing a limit that we know is at the end of
+ // the stream can never hurt, since we can never past that point anyway.
+ result.pushLimit(byteString.size());
+ } catch (InvalidProtocolBufferException ex) {
+ // The only reason pushLimit() might throw an exception here is if len
+ // is negative. Normally pushLimit()'s parameter comes directly off the
+ // wire, so it's important to catch exceptions in case of corrupt or
+ // malicious data. However, in this case, we expect that len is not a
+ // user-supplied value, so we can assume that it being negative indicates
+ // a programming error. Therefore, throwing an unchecked exception is
+ // appropriate.
+ throw new IllegalArgumentException(ex);
+ }
+ return result;
+ }
+
+ // -----------------------------------------------------------------
+
+ /**
+ * Attempt to read a field tag, returning zero if we have reached EOF.
+ * Protocol message parsers use this to read tags, since a protocol message
+ * may legally end wherever a tag occurs, and zero is not a valid tag number.
+ */
+ public int readTag() throws IOException {
+ if (isAtEnd()) {
+ lastTag = 0;
+ return 0;
+ }
+
+ lastTag = readRawVarint32();
+ if (WireFormat.getTagFieldNumber(lastTag) == 0) {
+ // If we actually read zero (or any tag number corresponding to field
+ // number zero), that's not a valid tag.
+ throw InvalidProtocolBufferException.invalidTag();
+ }
+ return lastTag;
+ }
+
+ /**
+ * Verifies that the last call to readTag() returned the given tag value.
+ * This is used to verify that a nested group ended with the correct
+ * end tag.
+ *
+ * @throws InvalidProtocolBufferException {@code value} does not match the
+ * last tag.
+ */
+ public void checkLastTagWas(final int value)
+ throws InvalidProtocolBufferException {
+ if (lastTag != value) {
+ throw InvalidProtocolBufferException.invalidEndTag();
+ }
+ }
+
+ public int getLastTag() {
+ return lastTag;
+ }
+
+ /**
+ * Reads and discards a single field, given its tag value.
+ *
+ * @return {@code false} if the tag is an endgroup tag, in which case
+ * nothing is skipped. Otherwise, returns {@code true}.
+ */
+ public boolean skipField(final int tag) throws IOException {
+ switch (WireFormat.getTagWireType(tag)) {
+ case WireFormat.WIRETYPE_VARINT:
+ skipRawVarint();
+ return true;
+ case WireFormat.WIRETYPE_FIXED64:
+ skipRawBytes(8);
+ return true;
+ case WireFormat.WIRETYPE_LENGTH_DELIMITED:
+ skipRawBytes(readRawVarint32());
+ return true;
+ case WireFormat.WIRETYPE_START_GROUP:
+ skipMessage();
+ checkLastTagWas(
+ WireFormat.makeTag(WireFormat.getTagFieldNumber(tag),
+ WireFormat.WIRETYPE_END_GROUP));
+ return true;
+ case WireFormat.WIRETYPE_END_GROUP:
+ return false;
+ case WireFormat.WIRETYPE_FIXED32:
+ skipRawBytes(4);
+ return true;
+ default:
+ throw InvalidProtocolBufferException.invalidWireType();
+ }
+ }
+
+ /**
+ * Reads a single field and writes it to output in wire format,
+ * given its tag value.
+ *
+ * @return {@code false} if the tag is an endgroup tag, in which case
+ * nothing is skipped. Otherwise, returns {@code true}.
+ */
+ public boolean skipField(final int tag, final CodedOutputStream output)
+ throws IOException {
+ switch (WireFormat.getTagWireType(tag)) {
+ case WireFormat.WIRETYPE_VARINT: {
+ long value = readInt64();
+ output.writeRawVarint32(tag);
+ output.writeUInt64NoTag(value);
+ return true;
+ }
+ case WireFormat.WIRETYPE_FIXED64: {
+ long value = readRawLittleEndian64();
+ output.writeRawVarint32(tag);
+ output.writeFixed64NoTag(value);
+ return true;
+ }
+ case WireFormat.WIRETYPE_LENGTH_DELIMITED: {
+ ByteString value = readBytes();
+ output.writeRawVarint32(tag);
+ output.writeBytesNoTag(value);
+ return true;
+ }
+ case WireFormat.WIRETYPE_START_GROUP: {
+ output.writeRawVarint32(tag);
+ skipMessage(output);
+ int endtag = WireFormat.makeTag(WireFormat.getTagFieldNumber(tag),
+ WireFormat.WIRETYPE_END_GROUP);
+ checkLastTagWas(endtag);
+ output.writeRawVarint32(endtag);
+ return true;
+ }
+ case WireFormat.WIRETYPE_END_GROUP: {
+ return false;
+ }
+ case WireFormat.WIRETYPE_FIXED32: {
+ int value = readRawLittleEndian32();
+ output.writeRawVarint32(tag);
+ output.writeFixed32NoTag(value);
+ return true;
+ }
+ default:
+ throw InvalidProtocolBufferException.invalidWireType();
+ }
+ }
+
+ /**
+ * Reads and discards an entire message. This will read either until EOF
+ * or until an endgroup tag, whichever comes first.
+ */
+ public void skipMessage() throws IOException {
+ while (true) {
+ final int tag = readTag();
+ if (tag == 0 || !skipField(tag)) {
+ return;
+ }
+ }
+ }
+
+ /**
+ * Reads an entire message and writes it to output in wire format.
+ * This will read either until EOF or until an endgroup tag,
+ * whichever comes first.
+ */
+ public void skipMessage(CodedOutputStream output) throws IOException {
+ while (true) {
+ final int tag = readTag();
+ if (tag == 0 || !skipField(tag, output)) {
+ return;
+ }
+ }
+ }
+
+ /**
+ * Collects the bytes skipped and returns the data in a ByteBuffer.
+ */
+ private class SkippedDataSink implements RefillCallback {
+ private int lastPos = bufferPos;
+ private ByteArrayOutputStream byteArrayStream;
+
+ @Override
+ public void onRefill() {
+ if (byteArrayStream == null) {
+ byteArrayStream = new ByteArrayOutputStream();
+ }
+ byteArrayStream.write(buffer, lastPos, bufferPos - lastPos);
+ lastPos = 0;
+ }
+
+ /**
+ * Gets skipped data in a ByteBuffer. This method should only be
+ * called once.
+ */
+ ByteBuffer getSkippedData() {
+ if (byteArrayStream == null) {
+ return ByteBuffer.wrap(buffer, lastPos, bufferPos - lastPos);
+ } else {
+ byteArrayStream.write(buffer, lastPos, bufferPos);
+ return ByteBuffer.wrap(byteArrayStream.toByteArray());
+ }
+ }
+ }
+
+
+ // -----------------------------------------------------------------
+
+ /** Read a {@code double} field value from the stream. */
+ public double readDouble() throws IOException {
+ return Double.longBitsToDouble(readRawLittleEndian64());
+ }
+
+ /** Read a {@code float} field value from the stream. */
+ public float readFloat() throws IOException {
+ return Float.intBitsToFloat(readRawLittleEndian32());
+ }
+
+ /** Read a {@code uint64} field value from the stream. */
+ public long readUInt64() throws IOException {
+ return readRawVarint64();
+ }
+
+ /** Read an {@code int64} field value from the stream. */
+ public long readInt64() throws IOException {
+ return readRawVarint64();
+ }
+
+ /** Read an {@code int32} field value from the stream. */
+ public int readInt32() throws IOException {
+ return readRawVarint32();
+ }
+
+ /** Read a {@code fixed64} field value from the stream. */
+ public long readFixed64() throws IOException {
+ return readRawLittleEndian64();
+ }
+
+ /** Read a {@code fixed32} field value from the stream. */
+ public int readFixed32() throws IOException {
+ return readRawLittleEndian32();
+ }
+
+ /** Read a {@code bool} field value from the stream. */
+ public boolean readBool() throws IOException {
+ return readRawVarint64() != 0;
+ }
+
+ /**
+ * Read a {@code string} field value from the stream.
+ * If the stream contains malformed UTF-8,
+ * replace the offending bytes with the standard UTF-8 replacement character.
+ */
+ public String readString() throws IOException {
+ final int size = readRawVarint32();
+ if (size <= (bufferSize - bufferPos) && size > 0) {
+ // Fast path: We already have the bytes in a contiguous buffer, so
+ // just copy directly from it.
+ final String result = new String(buffer, bufferPos, size, "UTF-8");
+ bufferPos += size;
+ return result;
+ } else if (size == 0) {
+ return "";
+ } else {
+ // Slow path: Build a byte array first then copy it.
+ return new String(readRawBytesSlowPath(size), "UTF-8");
+ }
+ }
+
+ /**
+ * Read a {@code string} field value from the stream.
+ * If the stream contains malformed UTF-8,
+ * throw exception {@link InvalidProtocolBufferException}.
+ */
+ public String readStringRequireUtf8() throws IOException {
+ final int size = readRawVarint32();
+ final byte[] bytes;
+ int pos = bufferPos;
+ if (size <= (bufferSize - pos) && size > 0) {
+ // Fast path: We already have the bytes in a contiguous buffer, so
+ // just copy directly from it.
+ bytes = buffer;
+ bufferPos = pos + size;
+ } else if (size == 0) {
+ return "";
+ } else {
+ // Slow path: Build a byte array first then copy it.
+ bytes = readRawBytesSlowPath(size);
+ pos = 0;
+ }
+ // TODO(martinrb): We could save a pass by validating while decoding.
+ if (!Utf8.isValidUtf8(bytes, pos, pos + size)) {
+ throw InvalidProtocolBufferException.invalidUtf8();
+ }
+ return new String(bytes, pos, size, "UTF-8");
+ }
+
+ /** Read a {@code group} field value from the stream. */
+ public void readGroup(final int fieldNumber,
+ final MessageLite.Builder builder,
+ final ExtensionRegistryLite extensionRegistry)
+ throws IOException {
+ if (recursionDepth >= recursionLimit) {
+ throw InvalidProtocolBufferException.recursionLimitExceeded();
+ }
+ ++recursionDepth;
+ builder.mergeFrom(this, extensionRegistry);
+ checkLastTagWas(
+ WireFormat.makeTag(fieldNumber, WireFormat.WIRETYPE_END_GROUP));
+ --recursionDepth;
+ }
+
+
+ /** Read a {@code group} field value from the stream. */
+ public <T extends MessageLite> T readGroup(
+ final int fieldNumber,
+ final Parser<T> parser,
+ final ExtensionRegistryLite extensionRegistry)
+ throws IOException {
+ if (recursionDepth >= recursionLimit) {
+ throw InvalidProtocolBufferException.recursionLimitExceeded();
+ }
+ ++recursionDepth;
+ T result = parser.parsePartialFrom(this, extensionRegistry);
+ checkLastTagWas(
+ WireFormat.makeTag(fieldNumber, WireFormat.WIRETYPE_END_GROUP));
+ --recursionDepth;
+ return result;
+ }
+
+ /**
+ * Reads a {@code group} field value from the stream and merges it into the
+ * given {@link UnknownFieldSet}.
+ *
+ * @deprecated UnknownFieldSet.Builder now implements MessageLite.Builder, so
+ * you can just call {@link #readGroup}.
+ */
+ @Deprecated
+ public void readUnknownGroup(final int fieldNumber,
+ final MessageLite.Builder builder)
+ throws IOException {
+ // We know that UnknownFieldSet will ignore any ExtensionRegistry so it
+ // is safe to pass null here. (We can't call
+ // ExtensionRegistry.getEmptyRegistry() because that would make this
+ // class depend on ExtensionRegistry, which is not part of the lite
+ // library.)
+ readGroup(fieldNumber, builder, null);
+ }
+
+ /** Read an embedded message field value from the stream. */
+ public void readMessage(final MessageLite.Builder builder,
+ final ExtensionRegistryLite extensionRegistry)
+ throws IOException {
+ final int length = readRawVarint32();
+ if (recursionDepth >= recursionLimit) {
+ throw InvalidProtocolBufferException.recursionLimitExceeded();
+ }
+ final int oldLimit = pushLimit(length);
+ ++recursionDepth;
+ builder.mergeFrom(this, extensionRegistry);
+ checkLastTagWas(0);
+ --recursionDepth;
+ popLimit(oldLimit);
+ }
+
+
+ /** Read an embedded message field value from the stream. */
+ public <T extends MessageLite> T readMessage(
+ final Parser<T> parser,
+ final ExtensionRegistryLite extensionRegistry)
+ throws IOException {
+ int length = readRawVarint32();
+ if (recursionDepth >= recursionLimit) {
+ throw InvalidProtocolBufferException.recursionLimitExceeded();
+ }
+ final int oldLimit = pushLimit(length);
+ ++recursionDepth;
+ T result = parser.parsePartialFrom(this, extensionRegistry);
+ checkLastTagWas(0);
+ --recursionDepth;
+ popLimit(oldLimit);
+ return result;
+ }
+
+ /** Read a {@code bytes} field value from the stream. */
+ public ByteString readBytes() throws IOException {
+ final int size = readRawVarint32();
+ if (size <= (bufferSize - bufferPos) && size > 0) {
+ // Fast path: We already have the bytes in a contiguous buffer, so
+ // just copy directly from it.
+ final ByteString result = bufferIsImmutable && enableAliasing
+ ? new BoundedByteString(buffer, bufferPos, size)
+ : ByteString.copyFrom(buffer, bufferPos, size);
+ bufferPos += size;
+ return result;
+ } else if (size == 0) {
+ return ByteString.EMPTY;
+ } else {
+ // Slow path: Build a byte array first then copy it.
+ return new LiteralByteString(readRawBytesSlowPath(size));
+ }
+ }
+
+ /** Read a {@code bytes} field value from the stream. */
+ public byte[] readByteArray() throws IOException {
+ final int size = readRawVarint32();
+ if (size <= (bufferSize - bufferPos) && size > 0) {
+ // Fast path: We already have the bytes in a contiguous buffer, so
+ // just copy directly from it.
+ final byte[] result =
+ Arrays.copyOfRange(buffer, bufferPos, bufferPos + size);
+ bufferPos += size;
+ return result;
+ } else {
+ // Slow path: Build a byte array first then copy it.
+ return readRawBytesSlowPath(size);
+ }
+ }
+
+ /** Read a {@code bytes} field value from the stream. */
+ public ByteBuffer readByteBuffer() throws IOException {
+ final int size = readRawVarint32();
+ if (size <= (bufferSize - bufferPos) && size > 0) {
+ // Fast path: We already have the bytes in a contiguous buffer.
+ // When aliasing is enabled, we can return a ByteBuffer pointing directly
+ // into the underlying byte array without copy if the CodedInputStream is
+ // constructed from a byte array. If aliasing is disabled or the input is
+ // from an InputStream or ByteString, we have to make a copy of the bytes.
+ ByteBuffer result = input == null && !bufferIsImmutable && enableAliasing
+ ? ByteBuffer.wrap(buffer, bufferPos, size).slice()
+ : ByteBuffer.wrap(Arrays.copyOfRange(
+ buffer, bufferPos, bufferPos + size));
+ bufferPos += size;
+ return result;
+ } else if (size == 0) {
+ return Internal.EMPTY_BYTE_BUFFER;
+ } else {
+ // Slow path: Build a byte array first then copy it.
+ return ByteBuffer.wrap(readRawBytesSlowPath(size));
+ }
+ }
+
+ /** Read a {@code uint32} field value from the stream. */
+ public int readUInt32() throws IOException {
+ return readRawVarint32();
+ }
+
+ /**
+ * Read an enum field value from the stream. Caller is responsible
+ * for converting the numeric value to an actual enum.
+ */
+ public int readEnum() throws IOException {
+ return readRawVarint32();
+ }
+
+ /** Read an {@code sfixed32} field value from the stream. */
+ public int readSFixed32() throws IOException {
+ return readRawLittleEndian32();
+ }
+
+ /** Read an {@code sfixed64} field value from the stream. */
+ public long readSFixed64() throws IOException {
+ return readRawLittleEndian64();
+ }
+
+ /** Read an {@code sint32} field value from the stream. */
+ public int readSInt32() throws IOException {
+ return decodeZigZag32(readRawVarint32());
+ }
+
+ /** Read an {@code sint64} field value from the stream. */
+ public long readSInt64() throws IOException {
+ return decodeZigZag64(readRawVarint64());
+ }
+
+ // =================================================================
+
+ /**
+ * Read a raw Varint from the stream. If larger than 32 bits, discard the
+ * upper bits.
+ */
+ public int readRawVarint32() throws IOException {
+ // See implementation notes for readRawVarint64
+ fastpath: {
+ int pos = bufferPos;
+
+ if (bufferSize == pos) {
+ break fastpath;
+ }
+
+ final byte[] buffer = this.buffer;
+ int x;
+ if ((x = buffer[pos++]) >= 0) {
+ bufferPos = pos;
+ return x;
+ } else if (bufferSize - pos < 9) {
+ break fastpath;
+ } else if ((x ^= (buffer[pos++] << 7)) < 0) {
+ x ^= (~0 << 7);
+ } else if ((x ^= (buffer[pos++] << 14)) >= 0) {
+ x ^= (~0 << 7) ^ (~0 << 14);
+ } else if ((x ^= (buffer[pos++] << 21)) < 0) {
+ x ^= (~0 << 7) ^ (~0 << 14) ^ (~0 << 21);
+ } else {
+ int y = buffer[pos++];
+ x ^= y << 28;
+ x ^= (~0 << 7) ^ (~0 << 14) ^ (~0 << 21) ^ (~0 << 28);
+ if (y < 0 &&
+ buffer[pos++] < 0 &&
+ buffer[pos++] < 0 &&
+ buffer[pos++] < 0 &&
+ buffer[pos++] < 0 &&
+ buffer[pos++] < 0) {
+ break fastpath; // Will throw malformedVarint()
+ }
+ }
+ bufferPos = pos;
+ return x;
+ }
+ return (int) readRawVarint64SlowPath();
+ }
+
+ private void skipRawVarint() throws IOException {
+ if (bufferSize - bufferPos >= 10) {
+ final byte[] buffer = this.buffer;
+ int pos = bufferPos;
+ for (int i = 0; i < 10; i++) {
+ if (buffer[pos++] >= 0) {
+ bufferPos = pos;
+ return;
+ }
+ }
+ }
+ skipRawVarintSlowPath();
+ }
+
+ private void skipRawVarintSlowPath() throws IOException {
+ for (int i = 0; i < 10; i++) {
+ if (readRawByte() >= 0) {
+ return;
+ }
+ }
+ throw InvalidProtocolBufferException.malformedVarint();
+ }
+
+ /**
+ * Reads a varint from the input one byte at a time, so that it does not
+ * read any bytes after the end of the varint. If you simply wrapped the
+ * stream in a CodedInputStream and used {@link #readRawVarint32(InputStream)}
+ * then you would probably end up reading past the end of the varint since
+ * CodedInputStream buffers its input.
+ */
+ static int readRawVarint32(final InputStream input) throws IOException {
+ final int firstByte = input.read();
+ if (firstByte == -1) {
+ throw InvalidProtocolBufferException.truncatedMessage();
+ }
+ return readRawVarint32(firstByte, input);
+ }
+
+ /**
+ * Like {@link #readRawVarint32(InputStream)}, but expects that the caller
+ * has already read one byte. This allows the caller to determine if EOF
+ * has been reached before attempting to read.
+ */
+ public static int readRawVarint32(
+ final int firstByte, final InputStream input) throws IOException {
+ if ((firstByte & 0x80) == 0) {
+ return firstByte;
+ }
+
+ int result = firstByte & 0x7f;
+ int offset = 7;
+ for (; offset < 32; offset += 7) {
+ final int b = input.read();
+ if (b == -1) {
+ throw InvalidProtocolBufferException.truncatedMessage();
+ }
+ result |= (b & 0x7f) << offset;
+ if ((b & 0x80) == 0) {
+ return result;
+ }
+ }
+ // Keep reading up to 64 bits.
+ for (; offset < 64; offset += 7) {
+ final int b = input.read();
+ if (b == -1) {
+ throw InvalidProtocolBufferException.truncatedMessage();
+ }
+ if ((b & 0x80) == 0) {
+ return result;
+ }
+ }
+ throw InvalidProtocolBufferException.malformedVarint();
+ }
+
+ /** Read a raw Varint from the stream. */
+ public long readRawVarint64() throws IOException {
+ // Implementation notes:
+ //
+ // Optimized for one-byte values, expected to be common.
+ // The particular code below was selected from various candidates
+ // empirically, by winning VarintBenchmark.
+ //
+ // Sign extension of (signed) Java bytes is usually a nuisance, but
+ // we exploit it here to more easily obtain the sign of bytes read.
+ // Instead of cleaning up the sign extension bits by masking eagerly,
+ // we delay until we find the final (positive) byte, when we clear all
+ // accumulated bits with one xor. We depend on javac to constant fold.
+ fastpath: {
+ int pos = bufferPos;
+
+ if (bufferSize == pos) {
+ break fastpath;
+ }
+
+ final byte[] buffer = this.buffer;
+ long x;
+ int y;
+ if ((y = buffer[pos++]) >= 0) {
+ bufferPos = pos;
+ return y;
+ } else if (bufferSize - pos < 9) {
+ break fastpath;
+ } else if ((y ^= (buffer[pos++] << 7)) < 0) {
+ x = y ^ (~0 << 7);
+ } else if ((y ^= (buffer[pos++] << 14)) >= 0) {
+ x = y ^ ((~0 << 7) ^ (~0 << 14));
+ } else if ((y ^= (buffer[pos++] << 21)) < 0) {
+ x = y ^ ((~0 << 7) ^ (~0 << 14) ^ (~0 << 21));
+ } else if ((x = ((long) y) ^ ((long) buffer[pos++] << 28)) >= 0L) {
+ x ^= (~0L << 7) ^ (~0L << 14) ^ (~0L << 21) ^ (~0L << 28);
+ } else if ((x ^= ((long) buffer[pos++] << 35)) < 0L) {
+ x ^= (~0L << 7) ^ (~0L << 14) ^ (~0L << 21) ^ (~0L << 28) ^ (~0L << 35);
+ } else if ((x ^= ((long) buffer[pos++] << 42)) >= 0L) {
+ x ^= (~0L << 7) ^ (~0L << 14) ^ (~0L << 21) ^ (~0L << 28) ^ (~0L << 35) ^ (~0L << 42);
+ } else if ((x ^= ((long) buffer[pos++] << 49)) < 0L) {
+ x ^= (~0L << 7) ^ (~0L << 14) ^ (~0L << 21) ^ (~0L << 28) ^ (~0L << 35) ^ (~0L << 42)
+ ^ (~0L << 49);
+ } else {
+ x ^= ((long) buffer[pos++] << 56);
+ x ^= (~0L << 7) ^ (~0L << 14) ^ (~0L << 21) ^ (~0L << 28) ^ (~0L << 35) ^ (~0L << 42)
+ ^ (~0L << 49) ^ (~0L << 56);
+ if (x < 0L) {
+ if (buffer[pos++] < 0L) {
+ break fastpath; // Will throw malformedVarint()
+ }
+ }
+ }
+ bufferPos = pos;
+ return x;
+ }
+ return readRawVarint64SlowPath();
+ }
+
+ /** Variant of readRawVarint64 for when uncomfortably close to the limit. */
+ /* Visible for testing */
+ long readRawVarint64SlowPath() throws IOException {
+ long result = 0;
+ for (int shift = 0; shift < 64; shift += 7) {
+ final byte b = readRawByte();
+ result |= (long) (b & 0x7F) << shift;
+ if ((b & 0x80) == 0) {
+ return result;
+ }
+ }
+ throw InvalidProtocolBufferException.malformedVarint();
+ }
+
+ /** Read a 32-bit little-endian integer from the stream. */
+ public int readRawLittleEndian32() throws IOException {
+ int pos = bufferPos;
+
+ // hand-inlined ensureAvailable(4);
+ if (bufferSize - pos < 4) {
+ refillBuffer(4);
+ pos = bufferPos;
+ }
+
+ final byte[] buffer = this.buffer;
+ bufferPos = pos + 4;
+ return (((buffer[pos] & 0xff)) |
+ ((buffer[pos + 1] & 0xff) << 8) |
+ ((buffer[pos + 2] & 0xff) << 16) |
+ ((buffer[pos + 3] & 0xff) << 24));
+ }
+
+ /** Read a 64-bit little-endian integer from the stream. */
+ public long readRawLittleEndian64() throws IOException {
+ int pos = bufferPos;
+
+ // hand-inlined ensureAvailable(8);
+ if (bufferSize - pos < 8) {
+ refillBuffer(8);
+ pos = bufferPos;
+ }
+
+ final byte[] buffer = this.buffer;
+ bufferPos = pos + 8;
+ return ((((long) buffer[pos] & 0xffL)) |
+ (((long) buffer[pos + 1] & 0xffL) << 8) |
+ (((long) buffer[pos + 2] & 0xffL) << 16) |
+ (((long) buffer[pos + 3] & 0xffL) << 24) |
+ (((long) buffer[pos + 4] & 0xffL) << 32) |
+ (((long) buffer[pos + 5] & 0xffL) << 40) |
+ (((long) buffer[pos + 6] & 0xffL) << 48) |
+ (((long) buffer[pos + 7] & 0xffL) << 56));
+ }
+
+ /**
+ * Decode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers
+ * into values that can be efficiently encoded with varint. (Otherwise,
+ * negative values must be sign-extended to 64 bits to be varint encoded,
+ * thus always taking 10 bytes on the wire.)
+ *
+ * @param n An unsigned 32-bit integer, stored in a signed int because
+ * Java has no explicit unsigned support.
+ * @return A signed 32-bit integer.
+ */
+ public static int decodeZigZag32(final int n) {
+ return (n >>> 1) ^ -(n & 1);
+ }
+
+ /**
+ * Decode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers
+ * into values that can be efficiently encoded with varint. (Otherwise,
+ * negative values must be sign-extended to 64 bits to be varint encoded,
+ * thus always taking 10 bytes on the wire.)
+ *
+ * @param n An unsigned 64-bit integer, stored in a signed int because
+ * Java has no explicit unsigned support.
+ * @return A signed 64-bit integer.
+ */
+ public static long decodeZigZag64(final long n) {
+ return (n >>> 1) ^ -(n & 1);
+ }
+
+ // -----------------------------------------------------------------
+
+ private final byte[] buffer;
+ private final boolean bufferIsImmutable;
+ private int bufferSize;
+ private int bufferSizeAfterLimit;
+ private int bufferPos;
+ private final InputStream input;
+ private int lastTag;
+ private boolean enableAliasing = false;
+
+ /**
+ * The total number of bytes read before the current buffer. The total
+ * bytes read up to the current position can be computed as
+ * {@code totalBytesRetired + bufferPos}. This value may be negative if
+ * reading started in the middle of the current buffer (e.g. if the
+ * constructor that takes a byte array and an offset was used).
+ */
+ private int totalBytesRetired;
+
+ /** The absolute position of the end of the current message. */
+ private int currentLimit = Integer.MAX_VALUE;
+
+ /** See setRecursionLimit() */
+ private int recursionDepth;
+ private int recursionLimit = DEFAULT_RECURSION_LIMIT;
+
+ /** See setSizeLimit() */
+ private int sizeLimit = DEFAULT_SIZE_LIMIT;
+
+ private static final int DEFAULT_RECURSION_LIMIT = 100;
+ private static final int DEFAULT_SIZE_LIMIT = 64 << 20; // 64MB
+ private static final int BUFFER_SIZE = 4096;
+
+ private CodedInputStream(final byte[] buffer, final int off, final int len) {
+ this.buffer = buffer;
+ bufferSize = off + len;
+ bufferPos = off;
+ totalBytesRetired = -off;
+ input = null;
+ bufferIsImmutable = false;
+ }
+
+ private CodedInputStream(final InputStream input) {
+ buffer = new byte[BUFFER_SIZE];
+ bufferSize = 0;
+ bufferPos = 0;
+ totalBytesRetired = 0;
+ this.input = input;
+ bufferIsImmutable = false;
+ }
+
+ private CodedInputStream(final LiteralByteString byteString) {
+ buffer = byteString.bytes;
+ bufferPos = byteString.getOffsetIntoBytes();
+ bufferSize = bufferPos + byteString.size();
+ totalBytesRetired = -bufferPos;
+ input = null;
+ bufferIsImmutable = true;
+ }
+
+ public void enableAliasing(boolean enabled) {
+ this.enableAliasing = enabled;
+ }
+
+ /**
+ * Set the maximum message recursion depth. In order to prevent malicious
+ * messages from causing stack overflows, {@code CodedInputStream} limits
+ * how deeply messages may be nested. The default limit is 64.
+ *
+ * @return the old limit.
+ */
+ public int setRecursionLimit(final int limit) {
+ if (limit < 0) {
+ throw new IllegalArgumentException(
+ "Recursion limit cannot be negative: " + limit);
+ }
+ final int oldLimit = recursionLimit;
+ recursionLimit = limit;
+ return oldLimit;
+ }
+
+ /**
+ * Set the maximum message size. In order to prevent malicious
+ * messages from exhausting memory or causing integer overflows,
+ * {@code CodedInputStream} limits how large a message may be.
+ * The default limit is 64MB. You should set this limit as small
+ * as you can without harming your app's functionality. Note that
+ * size limits only apply when reading from an {@code InputStream}, not
+ * when constructed around a raw byte array (nor with
+ * {@link ByteString#newCodedInput}).
+ * <p>
+ * If you want to read several messages from a single CodedInputStream, you
+ * could call {@link #resetSizeCounter()} after each one to avoid hitting the
+ * size limit.
+ *
+ * @return the old limit.
+ */
+ public int setSizeLimit(final int limit) {
+ if (limit < 0) {
+ throw new IllegalArgumentException(
+ "Size limit cannot be negative: " + limit);
+ }
+ final int oldLimit = sizeLimit;
+ sizeLimit = limit;
+ return oldLimit;
+ }
+
+ /**
+ * Resets the current size counter to zero (see {@link #setSizeLimit(int)}).
+ */
+ public void resetSizeCounter() {
+ totalBytesRetired = -bufferPos;
+ }
+
+ /**
+ * Sets {@code currentLimit} to (current position) + {@code byteLimit}. This
+ * is called when descending into a length-delimited embedded message.
+ *
+ * <p>Note that {@code pushLimit()} does NOT affect how many bytes the
+ * {@code CodedInputStream} reads from an underlying {@code InputStream} when
+ * refreshing its buffer. If you need to prevent reading past a certain
+ * point in the underlying {@code InputStream} (e.g. because you expect it to
+ * contain more data after the end of the message which you need to handle
+ * differently) then you must place a wrapper around your {@code InputStream}
+ * which limits the amount of data that can be read from it.
+ *
+ * @return the old limit.
+ */
+ public int pushLimit(int byteLimit) throws InvalidProtocolBufferException {
+ if (byteLimit < 0) {
+ throw InvalidProtocolBufferException.negativeSize();
+ }
+ byteLimit += totalBytesRetired + bufferPos;
+ final int oldLimit = currentLimit;
+ if (byteLimit > oldLimit) {
+ throw InvalidProtocolBufferException.truncatedMessage();
+ }
+ currentLimit = byteLimit;
+
+ recomputeBufferSizeAfterLimit();
+
+ return oldLimit;
+ }
+
+ private void recomputeBufferSizeAfterLimit() {
+ bufferSize += bufferSizeAfterLimit;
+ final int bufferEnd = totalBytesRetired + bufferSize;
+ if (bufferEnd > currentLimit) {
+ // Limit is in current buffer.
+ bufferSizeAfterLimit = bufferEnd - currentLimit;
+ bufferSize -= bufferSizeAfterLimit;
+ } else {
+ bufferSizeAfterLimit = 0;
+ }
+ }
+
+ /**
+ * Discards the current limit, returning to the previous limit.
+ *
+ * @param oldLimit The old limit, as returned by {@code pushLimit}.
+ */
+ public void popLimit(final int oldLimit) {
+ currentLimit = oldLimit;
+ recomputeBufferSizeAfterLimit();
+ }
+
+ /**
+ * Returns the number of bytes to be read before the current limit.
+ * If no limit is set, returns -1.
+ */
+ public int getBytesUntilLimit() {
+ if (currentLimit == Integer.MAX_VALUE) {
+ return -1;
+ }
+
+ final int currentAbsolutePosition = totalBytesRetired + bufferPos;
+ return currentLimit - currentAbsolutePosition;
+ }
+
+ /**
+ * Returns true if the stream has reached the end of the input. This is the
+ * case if either the end of the underlying input source has been reached or
+ * if the stream has reached a limit created using {@link #pushLimit(int)}.
+ */
+ public boolean isAtEnd() throws IOException {
+ return bufferPos == bufferSize && !tryRefillBuffer(1);
+ }
+
+ /**
+ * The total bytes read up to the current position. Calling
+ * {@link #resetSizeCounter()} resets this value to zero.
+ */
+ public int getTotalBytesRead() {
+ return totalBytesRetired + bufferPos;
+ }
+
+ private interface RefillCallback {
+ void onRefill();
+ }
+
+ private RefillCallback refillCallback = null;
+
+ /**
+ * Ensures that at least {@code n} bytes are available in the buffer, reading
+ * more bytes from the input if necessary to make it so. Caller must ensure
+ * that the requested space is less than BUFFER_SIZE.
+ *
+ * @throws InvalidProtocolBufferException The end of the stream or the current
+ * limit was reached.
+ */
+ private void ensureAvailable(int n) throws IOException {
+ if (bufferSize - bufferPos < n) {
+ refillBuffer(n);
+ }
+ }
+
+ /**
+ * Reads more bytes from the input, making at least {@code n} bytes available
+ * in the buffer. Caller must ensure that the requested space is not yet
+ * available, and that the requested space is less than BUFFER_SIZE.
+ *
+ * @throws InvalidProtocolBufferException The end of the stream or the current
+ * limit was reached.
+ */
+ private void refillBuffer(int n) throws IOException {
+ if (!tryRefillBuffer(n)) {
+ throw InvalidProtocolBufferException.truncatedMessage();
+ }
+ }
+
+ /**
+ * Tries to read more bytes from the input, making at least {@code n} bytes
+ * available in the buffer. Caller must ensure that the requested space is
+ * not yet available, and that the requested space is less than BUFFER_SIZE.
+ *
+ * @return {@code true} if the bytes could be made available; {@code false}
+ * if the end of the stream or the current limit was reached.
+ */
+ private boolean tryRefillBuffer(int n) throws IOException {
+ if (bufferPos + n <= bufferSize) {
+ throw new IllegalStateException(
+ "refillBuffer() called when " + n +
+ " bytes were already available in buffer");
+ }
+
+ if (totalBytesRetired + bufferPos + n > currentLimit) {
+ // Oops, we hit a limit.
+ return false;
+ }
+
+ if (refillCallback != null) {
+ refillCallback.onRefill();
+ }
+
+ if (input != null) {
+ int pos = bufferPos;
+ if (pos > 0) {
+ if (bufferSize > pos) {
+ System.arraycopy(buffer, pos, buffer, 0, bufferSize - pos);
+ }
+ totalBytesRetired += pos;
+ bufferSize -= pos;
+ bufferPos = 0;
+ }
+
+ int bytesRead = input.read(buffer, bufferSize, buffer.length - bufferSize);
+ if (bytesRead == 0 || bytesRead < -1 || bytesRead > buffer.length) {
+ throw new IllegalStateException(
+ "InputStream#read(byte[]) returned invalid result: " + bytesRead +
+ "\nThe InputStream implementation is buggy.");
+ }
+ if (bytesRead > 0) {
+ bufferSize += bytesRead;
+ // Integer-overflow-conscious check against sizeLimit
+ if (totalBytesRetired + n - sizeLimit > 0) {
+ throw InvalidProtocolBufferException.sizeLimitExceeded();
+ }
+ recomputeBufferSizeAfterLimit();
+ return (bufferSize >= n) ? true : tryRefillBuffer(n);
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Read one byte from the input.
+ *
+ * @throws InvalidProtocolBufferException The end of the stream or the current
+ * limit was reached.
+ */
+ public byte readRawByte() throws IOException {
+ if (bufferPos == bufferSize) {
+ refillBuffer(1);
+ }
+ return buffer[bufferPos++];
+ }
+
+ /**
+ * Read a fixed size of bytes from the input.
+ *
+ * @throws InvalidProtocolBufferException The end of the stream or the current
+ * limit was reached.
+ */
+ public byte[] readRawBytes(final int size) throws IOException {
+ final int pos = bufferPos;
+ if (size <= (bufferSize - pos) && size > 0) {
+ bufferPos = pos + size;
+ return Arrays.copyOfRange(buffer, pos, pos + size);
+ } else {
+ return readRawBytesSlowPath(size);
+ }
+ }
+
+ /**
+ * Exactly like readRawBytes, but caller must have already checked the fast
+ * path: (size <= (bufferSize - pos) && size > 0)
+ */
+ private byte[] readRawBytesSlowPath(final int size) throws IOException {
+ if (size <= 0) {
+ if (size == 0) {
+ return Internal.EMPTY_BYTE_ARRAY;
+ } else {
+ throw InvalidProtocolBufferException.negativeSize();
+ }
+ }
+
+ if (totalBytesRetired + bufferPos + size > currentLimit) {
+ // Read to the end of the stream anyway.
+ skipRawBytes(currentLimit - totalBytesRetired - bufferPos);
+ // Then fail.
+ throw InvalidProtocolBufferException.truncatedMessage();
+ }
+
+ if (size < BUFFER_SIZE) {
+ // Reading more bytes than are in the buffer, but not an excessive number
+ // of bytes. We can safely allocate the resulting array ahead of time.
+
+ // First copy what we have.
+ final byte[] bytes = new byte[size];
+ int pos = bufferSize - bufferPos;
+ System.arraycopy(buffer, bufferPos, bytes, 0, pos);
+ bufferPos = bufferSize;
+
+ // We want to refill the buffer and then copy from the buffer into our
+ // byte array rather than reading directly into our byte array because
+ // the input may be unbuffered.
+ ensureAvailable(size - pos);
+ System.arraycopy(buffer, 0, bytes, pos, size - pos);
+ bufferPos = size - pos;
+
+ return bytes;
+ } else {
+ // The size is very large. For security reasons, we can't allocate the
+ // entire byte array yet. The size comes directly from the input, so a
+ // maliciously-crafted message could provide a bogus very large size in
+ // order to trick the app into allocating a lot of memory. We avoid this
+ // by allocating and reading only a small chunk at a time, so that the
+ // malicious message must actually *be* extremely large to cause
+ // problems. Meanwhile, we limit the allowed size of a message elsewhere.
+
+ // Remember the buffer markers since we'll have to copy the bytes out of
+ // it later.
+ final int originalBufferPos = bufferPos;
+ final int originalBufferSize = bufferSize;
+
+ // Mark the current buffer consumed.
+ totalBytesRetired += bufferSize;
+ bufferPos = 0;
+ bufferSize = 0;
+
+ // Read all the rest of the bytes we need.
+ int sizeLeft = size - (originalBufferSize - originalBufferPos);
+ final List<byte[]> chunks = new ArrayList<byte[]>();
+
+ while (sizeLeft > 0) {
+ final byte[] chunk = new byte[Math.min(sizeLeft, BUFFER_SIZE)];
+ int pos = 0;
+ while (pos < chunk.length) {
+ final int n = (input == null) ? -1 :
+ input.read(chunk, pos, chunk.length - pos);
+ if (n == -1) {
+ throw InvalidProtocolBufferException.truncatedMessage();
+ }
+ totalBytesRetired += n;
+ pos += n;
+ }
+ sizeLeft -= chunk.length;
+ chunks.add(chunk);
+ }
+
+ // OK, got everything. Now concatenate it all into one buffer.
+ final byte[] bytes = new byte[size];
+
+ // Start by copying the leftover bytes from this.buffer.
+ int pos = originalBufferSize - originalBufferPos;
+ System.arraycopy(buffer, originalBufferPos, bytes, 0, pos);
+
+ // And now all the chunks.
+ for (final byte[] chunk : chunks) {
+ System.arraycopy(chunk, 0, bytes, pos, chunk.length);
+ pos += chunk.length;
+ }
+
+ // Done.
+ return bytes;
+ }
+ }
+
+ /**
+ * Reads and discards {@code size} bytes.
+ *
+ * @throws InvalidProtocolBufferException The end of the stream or the current
+ * limit was reached.
+ */
+ public void skipRawBytes(final int size) throws IOException {
+ if (size <= (bufferSize - bufferPos) && size >= 0) {
+ // We have all the bytes we need already.
+ bufferPos += size;
+ } else {
+ skipRawBytesSlowPath(size);
+ }
+ }
+
+ /**
+ * Exactly like skipRawBytes, but caller must have already checked the fast
+ * path: (size <= (bufferSize - pos) && size >= 0)
+ */
+ private void skipRawBytesSlowPath(final int size) throws IOException {
+ if (size < 0) {
+ throw InvalidProtocolBufferException.negativeSize();
+ }
+
+ if (totalBytesRetired + bufferPos + size > currentLimit) {
+ // Read to the end of the stream anyway.
+ skipRawBytes(currentLimit - totalBytesRetired - bufferPos);
+ // Then fail.
+ throw InvalidProtocolBufferException.truncatedMessage();
+ }
+
+ // Skipping more bytes than are in the buffer. First skip what we have.
+ int pos = bufferSize - bufferPos;
+ bufferPos = bufferSize;
+
+ // Keep refilling the buffer until we get to the point we wanted to skip to.
+ // This has the side effect of ensuring the limits are updated correctly.
+ refillBuffer(1);
+ while (size - pos > bufferSize) {
+ pos += bufferSize;
+ bufferPos = bufferSize;
+ refillBuffer(1);
+ }
+
+ bufferPos = size - pos;
+ }
+}
diff --git a/java/src/main/java/com/google/protobuf/CodedOutputStream.java b/java/src/main/java/com/google/protobuf/CodedOutputStream.java
new file mode 100644
index 0000000..fafe035
--- /dev/null
+++ b/java/src/main/java/com/google/protobuf/CodedOutputStream.java
@@ -0,0 +1,1297 @@
+// 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.
+
+package com.google.protobuf;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+
+/**
+ * Encodes and writes protocol message fields.
+ *
+ * <p>This class contains two kinds of methods: methods that write specific
+ * protocol message constructs and field types (e.g. {@link #writeTag} and
+ * {@link #writeInt32}) and methods that write low-level values (e.g.
+ * {@link #writeRawVarint32} and {@link #writeRawBytes}). If you are
+ * writing encoded protocol messages, you should use the former methods, but if
+ * you are writing some other format of your own design, use the latter.
+ *
+ * <p>This class is totally unsynchronized.
+ *
+ * @author kneton@google.com Kenton Varda
+ */
+public final class CodedOutputStream {
+ private final byte[] buffer;
+ private final int limit;
+ private int position;
+ private int totalBytesWritten = 0;
+
+ private final OutputStream output;
+
+ /**
+ * The buffer size used in {@link #newInstance(OutputStream)}.
+ */
+ public static final int DEFAULT_BUFFER_SIZE = 4096;
+
+ /**
+ * Returns the buffer size to efficiently write dataLength bytes to this
+ * CodedOutputStream. Used by AbstractMessageLite.
+ *
+ * @return the buffer size to efficiently write dataLength bytes to this
+ * CodedOutputStream.
+ */
+ static int computePreferredBufferSize(int dataLength) {
+ if (dataLength > DEFAULT_BUFFER_SIZE) return DEFAULT_BUFFER_SIZE;
+ return dataLength;
+ }
+
+ private CodedOutputStream(final byte[] buffer, final int offset,
+ final int length) {
+ output = null;
+ this.buffer = buffer;
+ position = offset;
+ limit = offset + length;
+ }
+
+ private CodedOutputStream(final OutputStream output, final byte[] buffer) {
+ this.output = output;
+ this.buffer = buffer;
+ position = 0;
+ limit = buffer.length;
+ }
+
+ /**
+ * Create a new {@code CodedOutputStream} wrapping the given
+ * {@code OutputStream}.
+ */
+ public static CodedOutputStream newInstance(final OutputStream output) {
+ return newInstance(output, DEFAULT_BUFFER_SIZE);
+ }
+
+ /**
+ * Create a new {@code CodedOutputStream} wrapping the given
+ * {@code OutputStream} with a given buffer size.
+ */
+ public static CodedOutputStream newInstance(final OutputStream output,
+ final int bufferSize) {
+ return new CodedOutputStream(output, new byte[bufferSize]);
+ }
+
+ /**
+ * Create a new {@code CodedOutputStream} that writes directly to the given
+ * byte array. If more bytes are written than fit in the array,
+ * {@link OutOfSpaceException} will be thrown. Writing directly to a flat
+ * array is faster than writing to an {@code OutputStream}. See also
+ * {@link ByteString#newCodedBuilder}.
+ */
+ public static CodedOutputStream newInstance(final byte[] flatArray) {
+ return newInstance(flatArray, 0, flatArray.length);
+ }
+
+ /**
+ * Create a new {@code CodedOutputStream} that writes directly to the given
+ * byte array slice. If more bytes are written than fit in the slice,
+ * {@link OutOfSpaceException} will be thrown. Writing directly to a flat
+ * array is faster than writing to an {@code OutputStream}. See also
+ * {@link ByteString#newCodedBuilder}.
+ */
+ public static CodedOutputStream newInstance(final byte[] flatArray,
+ final int offset,
+ final int length) {
+ return new CodedOutputStream(flatArray, offset, length);
+ }
+
+ /**
+ * Create a new {@code CodedOutputStream} that writes to the given ByteBuffer.
+ */
+ public static CodedOutputStream newInstance(ByteBuffer byteBuffer) {
+ return newInstance(byteBuffer, DEFAULT_BUFFER_SIZE);
+ }
+
+ /**
+ * Create a new {@code CodedOutputStream} that writes to the given ByteBuffer.
+ */
+ public static CodedOutputStream newInstance(ByteBuffer byteBuffer,
+ int bufferSize) {
+ return newInstance(new ByteBufferOutputStream(byteBuffer), bufferSize);
+ }
+
+ private static class ByteBufferOutputStream extends OutputStream {
+ private final ByteBuffer byteBuffer;
+ public ByteBufferOutputStream(ByteBuffer byteBuffer) {
+ this.byteBuffer = byteBuffer;
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ byteBuffer.put((byte) b);
+ }
+
+ @Override
+ public void write(byte[] data, int offset, int length) throws IOException {
+ byteBuffer.put(data, offset, length);
+ }
+ }
+
+ // -----------------------------------------------------------------
+
+ /** Write a {@code double} field, including tag, to the stream. */
+ public void writeDouble(final int fieldNumber, final double value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_FIXED64);
+ writeDoubleNoTag(value);
+ }
+
+ /** Write a {@code float} field, including tag, to the stream. */
+ public void writeFloat(final int fieldNumber, final float value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_FIXED32);
+ writeFloatNoTag(value);
+ }
+
+ /** Write a {@code uint64} field, including tag, to the stream. */
+ public void writeUInt64(final int fieldNumber, final long value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_VARINT);
+ writeUInt64NoTag(value);
+ }
+
+ /** Write an {@code int64} field, including tag, to the stream. */
+ public void writeInt64(final int fieldNumber, final long value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_VARINT);
+ writeInt64NoTag(value);
+ }
+
+ /** Write an {@code int32} field, including tag, to the stream. */
+ public void writeInt32(final int fieldNumber, final int value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_VARINT);
+ writeInt32NoTag(value);
+ }
+
+ /** Write a {@code fixed64} field, including tag, to the stream. */
+ public void writeFixed64(final int fieldNumber, final long value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_FIXED64);
+ writeFixed64NoTag(value);
+ }
+
+ /** Write a {@code fixed32} field, including tag, to the stream. */
+ public void writeFixed32(final int fieldNumber, final int value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_FIXED32);
+ writeFixed32NoTag(value);
+ }
+
+ /** Write a {@code bool} field, including tag, to the stream. */
+ public void writeBool(final int fieldNumber, final boolean value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_VARINT);
+ writeBoolNoTag(value);
+ }
+
+ /** Write a {@code string} field, including tag, to the stream. */
+ public void writeString(final int fieldNumber, final String value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_LENGTH_DELIMITED);
+ writeStringNoTag(value);
+ }
+
+ /** Write a {@code group} field, including tag, to the stream. */
+ public void writeGroup(final int fieldNumber, final MessageLite value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_START_GROUP);
+ writeGroupNoTag(value);
+ writeTag(fieldNumber, WireFormat.WIRETYPE_END_GROUP);
+ }
+
+
+ /**
+ * Write a group represented by an {@link UnknownFieldSet}.
+ *
+ * @deprecated UnknownFieldSet now implements MessageLite, so you can just
+ * call {@link #writeGroup}.
+ */
+ @Deprecated
+ public void writeUnknownGroup(final int fieldNumber,
+ final MessageLite value)
+ throws IOException {
+ writeGroup(fieldNumber, value);
+ }
+
+ /** Write an embedded message field, including tag, to the stream. */
+ public void writeMessage(final int fieldNumber, final MessageLite value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_LENGTH_DELIMITED);
+ writeMessageNoTag(value);
+ }
+
+
+ /** Write a {@code bytes} field, including tag, to the stream. */
+ public void writeBytes(final int fieldNumber, final ByteString value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_LENGTH_DELIMITED);
+ writeBytesNoTag(value);
+ }
+
+ /** Write a {@code bytes} field, including tag, to the stream. */
+ public void writeByteArray(final int fieldNumber, final byte[] value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_LENGTH_DELIMITED);
+ writeByteArrayNoTag(value);
+ }
+
+ /** Write a {@code bytes} field, including tag, to the stream. */
+ public void writeByteArray(final int fieldNumber,
+ final byte[] value,
+ final int offset,
+ final int length)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_LENGTH_DELIMITED);
+ writeByteArrayNoTag(value, offset, length);
+ }
+
+ /**
+ * Write a {@code bytes} field, including tag, to the stream.
+ * This method will write all content of the ByteBuffer regardless of the
+ * current position and limit (i.e., the number of bytes to be written is
+ * value.capacity(), not value.remaining()). Furthermore, this method doesn't
+ * alter the state of the passed-in ByteBuffer. Its position, limit, mark,
+ * etc. will remain unchanged. If you only want to write the remaining bytes
+ * of a ByteBuffer, you can call
+ * {@code writeByteBuffer(fieldNumber, byteBuffer.slice())}.
+ */
+ public void writeByteBuffer(final int fieldNumber, final ByteBuffer value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_LENGTH_DELIMITED);
+ writeByteBufferNoTag(value);
+ }
+
+ /** Write a {@code uint32} field, including tag, to the stream. */
+ public void writeUInt32(final int fieldNumber, final int value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_VARINT);
+ writeUInt32NoTag(value);
+ }
+
+ /**
+ * Write an enum field, including tag, to the stream. Caller is responsible
+ * for converting the enum value to its numeric value.
+ */
+ public void writeEnum(final int fieldNumber, final int value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_VARINT);
+ writeEnumNoTag(value);
+ }
+
+ /** Write an {@code sfixed32} field, including tag, to the stream. */
+ public void writeSFixed32(final int fieldNumber, final int value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_FIXED32);
+ writeSFixed32NoTag(value);
+ }
+
+ /** Write an {@code sfixed64} field, including tag, to the stream. */
+ public void writeSFixed64(final int fieldNumber, final long value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_FIXED64);
+ writeSFixed64NoTag(value);
+ }
+
+ /** Write an {@code sint32} field, including tag, to the stream. */
+ public void writeSInt32(final int fieldNumber, final int value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_VARINT);
+ writeSInt32NoTag(value);
+ }
+
+ /** Write an {@code sint64} field, including tag, to the stream. */
+ public void writeSInt64(final int fieldNumber, final long value)
+ throws IOException {
+ writeTag(fieldNumber, WireFormat.WIRETYPE_VARINT);
+ writeSInt64NoTag(value);
+ }
+
+ /**
+ * Write a MessageSet extension field to the stream. For historical reasons,
+ * the wire format differs from normal fields.
+ */
+ public void writeMessageSetExtension(final int fieldNumber,
+ final MessageLite value)
+ throws IOException {
+ writeTag(WireFormat.MESSAGE_SET_ITEM, WireFormat.WIRETYPE_START_GROUP);
+ writeUInt32(WireFormat.MESSAGE_SET_TYPE_ID, fieldNumber);
+ writeMessage(WireFormat.MESSAGE_SET_MESSAGE, value);
+ writeTag(WireFormat.MESSAGE_SET_ITEM, WireFormat.WIRETYPE_END_GROUP);
+ }
+
+ /**
+ * Write an unparsed MessageSet extension field to the stream. For
+ * historical reasons, the wire format differs from normal fields.
+ */
+ public void writeRawMessageSetExtension(final int fieldNumber,
+ final ByteString value)
+ throws IOException {
+ writeTag(WireFormat.MESSAGE_SET_ITEM, WireFormat.WIRETYPE_START_GROUP);
+ writeUInt32(WireFormat.MESSAGE_SET_TYPE_ID, fieldNumber);
+ writeBytes(WireFormat.MESSAGE_SET_MESSAGE, value);
+ writeTag(WireFormat.MESSAGE_SET_ITEM, WireFormat.WIRETYPE_END_GROUP);
+ }
+
+ // -----------------------------------------------------------------
+
+ /** Write a {@code double} field to the stream. */
+ public void writeDoubleNoTag(final double value) throws IOException {
+ writeRawLittleEndian64(Double.doubleToRawLongBits(value));
+ }
+
+ /** Write a {@code float} field to the stream. */
+ public void writeFloatNoTag(final float value) throws IOException {
+ writeRawLittleEndian32(Float.floatToRawIntBits(value));
+ }
+
+ /** Write a {@code uint64} field to the stream. */
+ public void writeUInt64NoTag(final long value) throws IOException {
+ writeRawVarint64(value);
+ }
+
+ /** Write an {@code int64} field to the stream. */
+ public void writeInt64NoTag(final long value) throws IOException {
+ writeRawVarint64(value);
+ }
+
+ /** Write an {@code int32} field to the stream. */
+ public void writeInt32NoTag(final int value) throws IOException {
+ if (value >= 0) {
+ writeRawVarint32(value);
+ } else {
+ // Must sign-extend.
+ writeRawVarint64(value);
+ }
+ }
+
+ /** Write a {@code fixed64} field to the stream. */
+ public void writeFixed64NoTag(final long value) throws IOException {
+ writeRawLittleEndian64(value);
+ }
+
+ /** Write a {@code fixed32} field to the stream. */
+ public void writeFixed32NoTag(final int value) throws IOException {
+ writeRawLittleEndian32(value);
+ }
+
+ /** Write a {@code bool} field to the stream. */
+ public void writeBoolNoTag(final boolean value) throws IOException {
+ writeRawByte(value ? 1 : 0);
+ }
+
+ /** Write a {@code string} field to the stream. */
+ public void writeStringNoTag(final String value) throws IOException {
+ // Unfortunately there does not appear to be any way to tell Java to encode
+ // UTF-8 directly into our buffer, so we have to let it create its own byte
+ // array and then copy.
+ final byte[] bytes = value.getBytes("UTF-8");
+ writeRawVarint32(bytes.length);
+ writeRawBytes(bytes);
+ }
+
+ /** Write a {@code group} field to the stream. */
+ public void writeGroupNoTag(final MessageLite value) throws IOException {
+ value.writeTo(this);
+ }
+
+
+ /**
+ * Write a group represented by an {@link UnknownFieldSet}.
+ *
+ * @deprecated UnknownFieldSet now implements MessageLite, so you can just
+ * call {@link #writeGroupNoTag}.
+ */
+ @Deprecated
+ public void writeUnknownGroupNoTag(final MessageLite value)
+ throws IOException {
+ writeGroupNoTag(value);
+ }
+
+ /** Write an embedded message field to the stream. */
+ public void writeMessageNoTag(final MessageLite value) throws IOException {
+ writeRawVarint32(value.getSerializedSize());
+ value.writeTo(this);
+ }
+
+
+ /** Write a {@code bytes} field to the stream. */
+ public void writeBytesNoTag(final ByteString value) throws IOException {
+ writeRawVarint32(value.size());
+ writeRawBytes(value);
+ }
+
+ /** Write a {@code bytes} field to the stream. */
+ public void writeByteArrayNoTag(final byte[] value) throws IOException {
+ writeRawVarint32(value.length);
+ writeRawBytes(value);
+ }
+
+ /** Write a {@code bytes} field to the stream. */
+ public void writeByteArrayNoTag(final byte[] value,
+ final int offset,
+ final int length) throws IOException {
+ writeRawVarint32(length);
+ writeRawBytes(value, offset, length);
+ }
+
+ /**
+ * Write a {@code bytes} field to the stream. This method will write all
+ * content of the ByteBuffer regardless of the current position and limit
+ * (i.e., the number of bytes to be written is value.capacity(), not
+ * value.remaining()). Furthermore, this method doesn't alter the state of
+ * the passed-in ByteBuffer. Its position, limit, mark, etc. will remain
+ * unchanged. If you only want to write the remaining bytes of a ByteBuffer,
+ * you can call {@code writeByteBufferNoTag(byteBuffer.slice())}.
+ */
+ public void writeByteBufferNoTag(final ByteBuffer value) throws IOException {
+ writeRawVarint32(value.capacity());
+ writeRawBytes(value);
+ }
+
+ /** Write a {@code uint32} field to the stream. */
+ public void writeUInt32NoTag(final int value) throws IOException {
+ writeRawVarint32(value);
+ }
+
+ /**
+ * Write an enum field to the stream. Caller is responsible
+ * for converting the enum value to its numeric value.
+ */
+ public void writeEnumNoTag(final int value) throws IOException {
+ writeInt32NoTag(value);
+ }
+
+ /** Write an {@code sfixed32} field to the stream. */
+ public void writeSFixed32NoTag(final int value) throws IOException {
+ writeRawLittleEndian32(value);
+ }
+
+ /** Write an {@code sfixed64} field to the stream. */
+ public void writeSFixed64NoTag(final long value) throws IOException {
+ writeRawLittleEndian64(value);
+ }
+
+ /** Write an {@code sint32} field to the stream. */
+ public void writeSInt32NoTag(final int value) throws IOException {
+ writeRawVarint32(encodeZigZag32(value));
+ }
+
+ /** Write an {@code sint64} field to the stream. */
+ public void writeSInt64NoTag(final long value) throws IOException {
+ writeRawVarint64(encodeZigZag64(value));
+ }
+
+ // =================================================================
+
+ /**
+ * Compute the number of bytes that would be needed to encode a
+ * {@code double} field, including tag.
+ */
+ public static int computeDoubleSize(final int fieldNumber,
+ final double value) {
+ return computeTagSize(fieldNumber) + computeDoubleSizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode a
+ * {@code float} field, including tag.
+ */
+ public static int computeFloatSize(final int fieldNumber, final float value) {
+ return computeTagSize(fieldNumber) + computeFloatSizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode a
+ * {@code uint64} field, including tag.
+ */
+ public static int computeUInt64Size(final int fieldNumber, final long value) {
+ return computeTagSize(fieldNumber) + computeUInt64SizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode an
+ * {@code int64} field, including tag.
+ */
+ public static int computeInt64Size(final int fieldNumber, final long value) {
+ return computeTagSize(fieldNumber) + computeInt64SizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode an
+ * {@code int32} field, including tag.
+ */
+ public static int computeInt32Size(final int fieldNumber, final int value) {
+ return computeTagSize(fieldNumber) + computeInt32SizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode a
+ * {@code fixed64} field, including tag.
+ */
+ public static int computeFixed64Size(final int fieldNumber,
+ final long value) {
+ return computeTagSize(fieldNumber) + computeFixed64SizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode a
+ * {@code fixed32} field, including tag.
+ */
+ public static int computeFixed32Size(final int fieldNumber,
+ final int value) {
+ return computeTagSize(fieldNumber) + computeFixed32SizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode a
+ * {@code bool} field, including tag.
+ */
+ public static int computeBoolSize(final int fieldNumber,
+ final boolean value) {
+ return computeTagSize(fieldNumber) + computeBoolSizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode a
+ * {@code string} field, including tag.
+ */
+ public static int computeStringSize(final int fieldNumber,
+ final String value) {
+ return computeTagSize(fieldNumber) + computeStringSizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode a
+ * {@code group} field, including tag.
+ */
+ public static int computeGroupSize(final int fieldNumber,
+ final MessageLite value) {
+ return computeTagSize(fieldNumber) * 2 + computeGroupSizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode a
+ * {@code group} field represented by an {@code UnknownFieldSet}, including
+ * tag.
+ *
+ * @deprecated UnknownFieldSet now implements MessageLite, so you can just
+ * call {@link #computeGroupSize}.
+ */
+ @Deprecated
+ public static int computeUnknownGroupSize(final int fieldNumber,
+ final MessageLite value) {
+ return computeGroupSize(fieldNumber, value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode an
+ * embedded message field, including tag.
+ */
+ public static int computeMessageSize(final int fieldNumber,
+ final MessageLite value) {
+ return computeTagSize(fieldNumber) + computeMessageSizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode a
+ * {@code bytes} field, including tag.
+ */
+ public static int computeBytesSize(final int fieldNumber,
+ final ByteString value) {
+ return computeTagSize(fieldNumber) + computeBytesSizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode a
+ * {@code bytes} field, including tag.
+ */
+ public static int computeByteArraySize(final int fieldNumber,
+ final byte[] value) {
+ return computeTagSize(fieldNumber) + computeByteArraySizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode a
+ * {@code bytes} field, including tag.
+ */
+ public static int computeByteBufferSize(final int fieldNumber,
+ final ByteBuffer value) {
+ return computeTagSize(fieldNumber) + computeByteBufferSizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode an
+ * embedded message in lazy field, including tag.
+ */
+ public static int computeLazyFieldSize(final int fieldNumber,
+ final LazyFieldLite value) {
+ return computeTagSize(fieldNumber) + computeLazyFieldSizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode a
+ * {@code uint32} field, including tag.
+ */
+ public static int computeUInt32Size(final int fieldNumber, final int value) {
+ return computeTagSize(fieldNumber) + computeUInt32SizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode an
+ * enum field, including tag. Caller is responsible for converting the
+ * enum value to its numeric value.
+ */
+ public static int computeEnumSize(final int fieldNumber, final int value) {
+ return computeTagSize(fieldNumber) + computeEnumSizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode an
+ * {@code sfixed32} field, including tag.
+ */
+ public static int computeSFixed32Size(final int fieldNumber,
+ final int value) {
+ return computeTagSize(fieldNumber) + computeSFixed32SizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode an
+ * {@code sfixed64} field, including tag.
+ */
+ public static int computeSFixed64Size(final int fieldNumber,
+ final long value) {
+ return computeTagSize(fieldNumber) + computeSFixed64SizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode an
+ * {@code sint32} field, including tag.
+ */
+ public static int computeSInt32Size(final int fieldNumber, final int value) {
+ return computeTagSize(fieldNumber) + computeSInt32SizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode an
+ * {@code sint64} field, including tag.
+ */
+ public static int computeSInt64Size(final int fieldNumber, final long value) {
+ return computeTagSize(fieldNumber) + computeSInt64SizeNoTag(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode a
+ * MessageSet extension to the stream. For historical reasons,
+ * the wire format differs from normal fields.
+ */
+ public static int computeMessageSetExtensionSize(
+ final int fieldNumber, final MessageLite value) {
+ return computeTagSize(WireFormat.MESSAGE_SET_ITEM) * 2 +
+ computeUInt32Size(WireFormat.MESSAGE_SET_TYPE_ID, fieldNumber) +
+ computeMessageSize(WireFormat.MESSAGE_SET_MESSAGE, value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode an
+ * unparsed MessageSet extension field to the stream. For
+ * historical reasons, the wire format differs from normal fields.
+ */
+ public static int computeRawMessageSetExtensionSize(
+ final int fieldNumber, final ByteString value) {
+ return computeTagSize(WireFormat.MESSAGE_SET_ITEM) * 2 +
+ computeUInt32Size(WireFormat.MESSAGE_SET_TYPE_ID, fieldNumber) +
+ computeBytesSize(WireFormat.MESSAGE_SET_MESSAGE, value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode an
+ * lazily parsed MessageSet extension field to the stream. For
+ * historical reasons, the wire format differs from normal fields.
+ */
+ public static int computeLazyFieldMessageSetExtensionSize(
+ final int fieldNumber, final LazyFieldLite value) {
+ return computeTagSize(WireFormat.MESSAGE_SET_ITEM) * 2 +
+ computeUInt32Size(WireFormat.MESSAGE_SET_TYPE_ID, fieldNumber) +
+ computeLazyFieldSize(WireFormat.MESSAGE_SET_MESSAGE, value);
+ }
+
+ // -----------------------------------------------------------------
+
+ /**
+ * Compute the number of bytes that would be needed to encode a
+ * {@code double} field, including tag.
+ */
+ public static int computeDoubleSizeNoTag(final double value) {
+ return LITTLE_ENDIAN_64_SIZE;
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode a
+ * {@code float} field, including tag.
+ */
+ public static int computeFloatSizeNoTag(final float value) {
+ return LITTLE_ENDIAN_32_SIZE;
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode a
+ * {@code uint64} field, including tag.
+ */
+ public static int computeUInt64SizeNoTag(final long value) {
+ return computeRawVarint64Size(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode an
+ * {@code int64} field, including tag.
+ */
+ public static int computeInt64SizeNoTag(final long value) {
+ return computeRawVarint64Size(value);
+ }
+
+ /**
+ * Compute the number of bytes that would be needed to encode an
+ * {@code int32} field, including tag.
+ */
+ public static int computeInt32SizeNoTag(final int value) {