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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 next_++; | 62 next_++; |
63 return true; | 63 return true; |
64 } | 64 } |
65 | 65 |
66 int Length() const { | 66 int Length() const { |
67 return info_->Length(); | 67 return info_->Length(); |
68 } | 68 } |
69 | 69 |
70 template<typename T> | 70 template<typename T> |
71 void Return(T val) { | 71 void Return(T val) { |
72 v8::Local<v8::Value> v8_value; | 72 info_->GetReturnValue().Set(ConvertToV8(isolate_, val)); |
73 if (!TryConvertToV8(isolate_, val, &v8_value)) | |
74 return; | |
75 info_->GetReturnValue().Set(v8_value); | |
76 } | 73 } |
77 | 74 |
78 v8::Local<v8::Value> PeekNext() const; | 75 v8::Local<v8::Value> PeekNext() const; |
79 | 76 |
80 void ThrowError() const; | 77 void ThrowError() const; |
81 void ThrowTypeError(const std::string& message) const; | 78 void ThrowTypeError(const std::string& message) const; |
82 | 79 |
83 v8::Isolate* isolate() const { return isolate_; } | 80 v8::Isolate* isolate() const { return isolate_; } |
84 | 81 |
85 // Allows the function handler to distinguish between normal invocation | 82 // Allows the function handler to distinguish between normal invocation |
86 // and object construction. | 83 // and object construction. |
87 bool IsConstructCall() const; | 84 bool IsConstructCall() const; |
88 | 85 |
89 private: | 86 private: |
90 v8::Isolate* isolate_; | 87 v8::Isolate* isolate_; |
91 const v8::FunctionCallbackInfo<v8::Value>* info_; | 88 const v8::FunctionCallbackInfo<v8::Value>* info_; |
92 int next_; | 89 int next_; |
93 bool insufficient_arguments_; | 90 bool insufficient_arguments_; |
94 }; | 91 }; |
95 | 92 |
96 } // namespace gin | 93 } // namespace gin |
97 | 94 |
98 #endif // GIN_ARGUMENTS_H_ | 95 #endif // GIN_ARGUMENTS_H_ |
OLD | NEW |