Index: third_party/protobuf/ruby/src/main/java/com/google/protobuf/jruby/RubyProtobuf.java |
diff --git a/third_party/tcmalloc/chromium/src/base/synchronization_profiling.h b/third_party/protobuf/ruby/src/main/java/com/google/protobuf/jruby/RubyProtobuf.java |
similarity index 51% |
copy from third_party/tcmalloc/chromium/src/base/synchronization_profiling.h |
copy to third_party/protobuf/ruby/src/main/java/com/google/protobuf/jruby/RubyProtobuf.java |
index cf02c218a111806189f71f7b528a83b5ceb164a4..2cf210d26f58548e03805eef04114c5c337e85d6 100644 |
--- a/third_party/tcmalloc/chromium/src/base/synchronization_profiling.h |
+++ b/third_party/protobuf/ruby/src/main/java/com/google/protobuf/jruby/RubyProtobuf.java |
@@ -1,5 +1,7 @@ |
-/* Copyright (c) 2010, Google Inc. |
- * All rights reserved. |
+/* |
+ * Protocol Buffers - Google's data interchange format |
+ * Copyright 2014 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 |
@@ -26,25 +28,41 @@ |
* 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: Chris Ruemmler |
*/ |
-#ifndef BASE_AUXILIARY_SYNCHRONIZATION_PROFILING_H_ |
-#define BASE_AUXILIARY_SYNCHRONIZATION_PROFILING_H_ |
+package com.google.protobuf.jruby; |
-#include "base/basictypes.h" |
+import org.jruby.Ruby; |
+import org.jruby.RubyModule; |
+import org.jruby.anno.JRubyMethod; |
+import org.jruby.anno.JRubyModule; |
+import org.jruby.runtime.ThreadContext; |
+import org.jruby.runtime.builtin.IRubyObject; |
-namespace base { |
+@JRubyModule(name = "Protobuf") |
+public class RubyProtobuf { |
-// We can do contention-profiling of SpinLocks, but the code is in |
-// mutex.cc, which is not always linked in with spinlock. Hence we |
-// provide a weak definition, which are used if mutex.cc isn't linked in. |
+ public static void createProtobuf(Ruby runtime) { |
+ RubyModule mGoogle = runtime.getModule("Google"); |
+ RubyModule mProtobuf = mGoogle.defineModuleUnder("Protobuf"); |
+ mProtobuf.defineAnnotatedMethods(RubyProtobuf.class); |
+ } |
-// Submit the number of cycles the spinlock spent contending. |
-ATTRIBUTE_WEAK extern void SubmitSpinLockProfileData(const void *, int64); |
-extern void SubmitSpinLockProfileData(const void *contendedlock, |
- int64 wait_cycles) {} |
+ /* |
+ * call-seq: |
+ * Google::Protobuf.deep_copy(obj) => copy_of_obj |
+ * |
+ * Performs a deep copy of either a RepeatedField instance or a message object, |
+ * recursively copying its members. |
+ */ |
+ @JRubyMethod(name = "deep_copy", meta = true) |
+ public static IRubyObject deepCopy(ThreadContext context, IRubyObject self, IRubyObject message) { |
+ if (message instanceof RubyMessage) { |
+ return ((RubyMessage) message).deepCopy(context); |
+ } else if (message instanceof RubyRepeatedField) { |
+ return ((RubyRepeatedField) message).deepCopy(context); |
+ } else { |
+ return ((RubyMap) message).deepCopy(context); |
+ } |
+ } |
} |
-#endif // BASE_AUXILIARY_SYNCHRONIZATION_PROFILING_H_ |