Index: gin/arguments.h |
diff --git a/gin/arguments.h b/gin/arguments.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8b494baf0a11ad067b17bb78dcf7bbbac8137e16 |
--- /dev/null |
+++ b/gin/arguments.h |
@@ -0,0 +1,50 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef GIN_ARGUMENTS_H_ |
+#define GIN_ARGUMENTS_H_ |
+ |
+#include "base/basictypes.h" |
+#include "gin/converter.h" |
+ |
+namespace gin { |
+ |
+class Arguments { |
+ public: |
+ explicit Arguments(const v8::FunctionCallbackInfo<v8::Value>& info); |
+ ~Arguments(); |
+ |
+ template<typename T> |
+ bool Holder(T* out) { |
+ return ConvertFromV8(info_.Holder(), out); |
+ } |
+ |
+ template<typename T> |
+ bool Next(T* out) { |
Aaron Boodman
2013/11/11 19:01:08
I think we'll eventually need Get(index) too, but
Aaron Boodman
2013/11/11 19:01:08
I feel like it is Chromium (or Google) style to us
abarth-chromium
2013/11/11 20:17:42
Will do.
|
+ if (current_ >= info_.Length()) |
+ return false; |
+ v8::Handle<v8::Value> val = info_[current_++]; |
+ return ConvertFromV8(val, out); |
+ } |
+ |
+ template<typename T> |
+ void Return(T val) { |
+ info_.GetReturnValue().Set(ConvertToV8(isolate_, val)); |
+ } |
+ |
+ void ThrowTypeError(const char* message); |
+ |
+ v8::Isolate* isolate() const { return isolate_; } |
+ |
+ private: |
+ v8::Isolate* isolate_; |
+ const v8::FunctionCallbackInfo<v8::Value>& info_; |
+ int current_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(Arguments); |
+}; |
+ |
+} // namespace gin |
+ |
+#endif // GIN_ARGUMENTS_H_ |