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

Unified Diff: gin/arguments.h

Issue 59153005: Begin implementing V8 bindings for Mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix skipped comment Created 7 years, 1 month 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
« no previous file with comments | « no previous file | gin/arguments.cc » ('j') | gin/arguments.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gin/arguments.h
diff --git a/gin/arguments.h b/gin/arguments.h
new file mode 100644
index 0000000000000000000000000000000000000000..c5335cc1926a041b208220d90290a12f15768aae
--- /dev/null
+++ b/gin/arguments.h
@@ -0,0 +1,54 @@
+// 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 GetNext(T* out) {
+ if (next_ >= info_.Length()) {
+ insufficient_arguments_ = true;
+ return false;
+ }
+ v8::Handle<v8::Value> val = info_[next_++];
+ return ConvertFromV8(val, out);
+ }
+
+ template<typename T>
+ void Return(T val) {
+ info_.GetReturnValue().Set(ConvertToV8(isolate_, val));
+ }
+
+ void ThrowError();
+ void ThrowTypeError(const std::string& message);
+
+ v8::Isolate* isolate() const { return isolate_; }
+
+ private:
+ v8::Isolate* isolate_;
+ const v8::FunctionCallbackInfo<v8::Value>& info_;
+ int next_;
+ bool insufficient_arguments_;
+
+ DISALLOW_COPY_AND_ASSIGN(Arguments);
+};
+
+} // namespace gin
+
+#endif // GIN_ARGUMENTS_H_
« no previous file with comments | « no previous file | gin/arguments.cc » ('j') | gin/arguments.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698