Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Unified Diff: third_party/protobuf/csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs

Issue 1842653006: Update //third_party/protobuf to version 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}

Powered by Google App Engine
This is Rietveld 408576698