Index: third_party/protobuf/ruby/src/main/java/com/google/protobuf/jruby/RubyProtobuf.java |
diff --git a/third_party/WebKit/Source/core/animation/AnimationClock.cpp b/third_party/protobuf/ruby/src/main/java/com/google/protobuf/jruby/RubyProtobuf.java |
similarity index 52% |
copy from third_party/WebKit/Source/core/animation/AnimationClock.cpp |
copy to third_party/protobuf/ruby/src/main/java/com/google/protobuf/jruby/RubyProtobuf.java |
index 8350e211e7d5e5c4f7aad8cc6b6b2675dce51a7c..2cf210d26f58548e03805eef04114c5c337e85d6 100644 |
--- a/third_party/WebKit/Source/core/animation/AnimationClock.cpp |
+++ b/third_party/protobuf/ruby/src/main/java/com/google/protobuf/jruby/RubyProtobuf.java |
@@ -1,5 +1,7 @@ |
/* |
- * Copyright (c) 2014, 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 |
@@ -28,54 +30,39 @@ |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
-#include "core/animation/AnimationClock.h" |
+package com.google.protobuf.jruby; |
-#include "wtf/CurrentTime.h" |
-#include <math.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 { |
+@JRubyModule(name = "Protobuf") |
+public class RubyProtobuf { |
-// FIXME: This is an approximation of time between frames, used when |
-// ticking the animation clock outside of animation frame callbacks. |
-// Ideally this would be generated by the compositor. |
-const double approximateFrameTime = 1 / 60.0; |
- |
-} |
- |
-namespace blink { |
- |
-unsigned AnimationClock::s_currentTask = 0; |
- |
-void AnimationClock::updateTime(double time) |
-{ |
- if (time > m_time) |
- m_time = time; |
- m_currentTask = s_currentTask; |
-} |
+ public static void createProtobuf(Ruby runtime) { |
+ RubyModule mGoogle = runtime.getModule("Google"); |
+ RubyModule mProtobuf = mGoogle.defineModuleUnder("Protobuf"); |
+ mProtobuf.defineAnnotatedMethods(RubyProtobuf.class); |
+ } |
-double AnimationClock::currentTime() |
-{ |
- if (m_currentTask != s_currentTask) { |
- const double currentTime = m_monotonicallyIncreasingTime(); |
- if (m_time < currentTime) { |
- // Advance to the first estimated frame after the current time. |
- const double frameShift = fmod(currentTime - m_time, approximateFrameTime); |
- const double newTime = currentTime + (approximateFrameTime - frameShift); |
- ASSERT(newTime >= currentTime); |
- ASSERT(newTime <= currentTime + approximateFrameTime); |
- updateTime(newTime); |
+ /* |
+ * 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 { |
- m_currentTask = s_currentTask; |
+ return ((RubyMap) message).deepCopy(context); |
} |
} |
- return m_time; |
} |
- |
-void AnimationClock::resetTimeForTesting(double time) |
-{ |
- m_time = time; |
- m_currentTask = 0; |
- s_currentTask = 0; |
-} |
- |
-} // namespace blink |