OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef GIN_ARGUMENTS_H_ | 5 #ifndef GIN_ARGUMENTS_H_ |
6 #define GIN_ARGUMENTS_H_ | 6 #define GIN_ARGUMENTS_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "gin/converter.h" | 9 #include "gin/converter.h" |
10 #include "gin/gin_export.h" | 10 #include "gin/gin_export.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 int remaining = info_->Length() - next_; | 49 int remaining = info_->Length() - next_; |
50 out->resize(remaining); | 50 out->resize(remaining); |
51 for (int i = 0; i < remaining; ++i) { | 51 for (int i = 0; i < remaining; ++i) { |
52 v8::Handle<v8::Value> val = (*info_)[next_++]; | 52 v8::Handle<v8::Value> val = (*info_)[next_++]; |
53 if (!ConvertFromV8(isolate_, val, &out->at(i))) | 53 if (!ConvertFromV8(isolate_, val, &out->at(i))) |
54 return false; | 54 return false; |
55 } | 55 } |
56 return true; | 56 return true; |
57 } | 57 } |
58 | 58 |
| 59 bool Skip() { |
| 60 if (next_ >= info_->Length()) |
| 61 return false; |
| 62 next_++; |
| 63 return true; |
| 64 } |
| 65 |
| 66 int Length() const { |
| 67 return info_->Length(); |
| 68 } |
| 69 |
59 template<typename T> | 70 template<typename T> |
60 void Return(T val) { | 71 void Return(T val) { |
61 info_->GetReturnValue().Set(ConvertToV8(isolate_, val)); | 72 info_->GetReturnValue().Set(ConvertToV8(isolate_, val)); |
62 } | 73 } |
63 | 74 |
64 v8::Handle<v8::Value> PeekNext() const; | 75 v8::Handle<v8::Value> PeekNext() const; |
65 | 76 |
66 void ThrowError() const; | 77 void ThrowError() const; |
67 void ThrowTypeError(const std::string& message) const; | 78 void ThrowTypeError(const std::string& message) const; |
68 | 79 |
69 v8::Isolate* isolate() const { return isolate_; } | 80 v8::Isolate* isolate() const { return isolate_; } |
70 | 81 |
71 private: | 82 private: |
72 v8::Isolate* isolate_; | 83 v8::Isolate* isolate_; |
73 const v8::FunctionCallbackInfo<v8::Value>* info_; | 84 const v8::FunctionCallbackInfo<v8::Value>* info_; |
74 int next_; | 85 int next_; |
75 bool insufficient_arguments_; | 86 bool insufficient_arguments_; |
76 }; | 87 }; |
77 | 88 |
78 } // namespace gin | 89 } // namespace gin |
79 | 90 |
80 #endif // GIN_ARGUMENTS_H_ | 91 #endif // GIN_ARGUMENTS_H_ |
OLD | NEW |