| Index: third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs
|
| diff --git a/third_party/protobuf/src/google/protobuf/testing/zcgunzip.cc b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs
|
| similarity index 58%
|
| copy from third_party/protobuf/src/google/protobuf/testing/zcgunzip.cc
|
| copy to third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs
|
| index a6197854bdef63dc11bbdf0b3cf1f7884348b0e3..82ce50518d8e999452493de6bd5efae4871bbdde 100644
|
| --- a/third_party/protobuf/src/google/protobuf/testing/zcgunzip.cc
|
| +++ b/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs
|
| @@ -1,6 +1,7 @@
|
| +#region Copyright notice and license
|
| // Protocol Buffers - Google's data interchange format
|
| -// Copyright 2009 Google Inc. All rights reserved.
|
| -// http://code.google.com/p/protobuf/
|
| +// Copyright 2015 Google Inc. All rights reserved.
|
| +// https://developers.google.com/protocol-buffers/
|
| //
|
| // Redistribution and use in source and binary forms, with or without
|
| // modification, are permitted provided that the following conditions are
|
| @@ -27,47 +28,36 @@
|
| // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| -
|
| -// Author: brianolson@google.com (Brian Olson)
|
| -// Based on original Protocol Buffers design by
|
| -// Sanjay Ghemawat, Jeff Dean, and others.
|
| -//
|
| -// Test program to verify that GzipInputStream is compatible with command line
|
| -// gunzip or java.util.zip.GzipInputStream
|
| -//
|
| -// Reads gzip stream on standard input and writes decompressed data to standard
|
| -// output.
|
| -
|
| -#include "config.h"
|
| -
|
| -#include <assert.h>
|
| -#include <stdio.h>
|
| -#include <stdlib.h>
|
| -#include <fcntl.h>
|
| -
|
| -#include <google/protobuf/io/gzip_stream.h>
|
| -#include <google/protobuf/io/zero_copy_stream_impl.h>
|
| -
|
| -using google::protobuf::io::FileInputStream;
|
| -using google::protobuf::io::GzipInputStream;
|
| -
|
| -int main(int argc, const char** argv) {
|
| - FileInputStream fin(STDIN_FILENO);
|
| - GzipInputStream in(&fin);
|
| -
|
| - while (true) {
|
| - const void* inptr;
|
| - int inlen;
|
| - bool ok;
|
| - ok = in.Next(&inptr, &inlen);
|
| - if (!ok) {
|
| - break;
|
| +#endregion
|
| +
|
| +using System;
|
| +using System.Reflection;
|
| +using Google.Protobuf.Compatibility;
|
| +
|
| +namespace Google.Protobuf.Reflection
|
| +{
|
| + /// <summary>
|
| + /// Base class for field accessors.
|
| + /// </summary>
|
| + internal abstract class FieldAccessorBase : IFieldAccessor
|
| + {
|
| + private readonly Func<IMessage, object> getValueDelegate;
|
| + private readonly FieldDescriptor descriptor;
|
| +
|
| + internal FieldAccessorBase(PropertyInfo property, FieldDescriptor descriptor)
|
| + {
|
| + this.descriptor = descriptor;
|
| + getValueDelegate = ReflectionUtil.CreateFuncIMessageObject(property.GetGetMethod());
|
| + }
|
| +
|
| + public FieldDescriptor Descriptor { get { return descriptor; } }
|
| +
|
| + public object GetValue(IMessage message)
|
| + {
|
| + return getValueDelegate(message);
|
| + }
|
| +
|
| + public abstract void Clear(IMessage message);
|
| + public abstract void SetValue(IMessage message, object value);
|
| }
|
| - if (inlen > 0) {
|
| - int err = write(STDOUT_FILENO, inptr, inlen);
|
| - assert(err == inlen);
|
| - }
|
| - }
|
| -
|
| - return 0;
|
| }
|
|
|