OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef GIN_ARGUMENTS_H_ | |
6 #define GIN_ARGUMENTS_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "gin/converter.h" | |
10 | |
11 namespace gin { | |
12 | |
13 class Arguments { | |
14 public: | |
15 explicit Arguments(const v8::FunctionCallbackInfo<v8::Value>& info); | |
16 ~Arguments(); | |
17 | |
18 template<typename T> | |
19 bool Holder(T* out) { | |
20 return ConvertFromV8(info_.Holder(), out); | |
21 } | |
22 | |
23 template<typename T> | |
24 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.
| |
25 if (current_ >= info_.Length()) | |
26 return false; | |
27 v8::Handle<v8::Value> val = info_[current_++]; | |
28 return ConvertFromV8(val, out); | |
29 } | |
30 | |
31 template<typename T> | |
32 void Return(T val) { | |
33 info_.GetReturnValue().Set(ConvertToV8(isolate_, val)); | |
34 } | |
35 | |
36 void ThrowTypeError(const char* message); | |
37 | |
38 v8::Isolate* isolate() const { return isolate_; } | |
39 | |
40 private: | |
41 v8::Isolate* isolate_; | |
42 const v8::FunctionCallbackInfo<v8::Value>& info_; | |
43 int current_; | |
44 | |
45 DISALLOW_COPY_AND_ASSIGN(Arguments); | |
46 }; | |
47 | |
48 } // namespace gin | |
49 | |
50 #endif // GIN_ARGUMENTS_H_ | |
OLD | NEW |