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 "base/logging.h" |
9 #include "gin/converter.h" | 10 #include "gin/converter.h" |
10 #include "gin/gin_export.h" | 11 #include "gin/gin_export.h" |
11 | 12 |
12 namespace gin { | 13 namespace gin { |
13 | 14 |
14 // Arguments is a wrapper around v8::FunctionCallbackInfo that integrates | 15 // Arguments is a wrapper around v8::FunctionCallbackInfo that integrates |
15 // with Converter to make it easier to marshall arguments and return values | 16 // with Converter to make it easier to marshall arguments and return values |
16 // between V8 and C++. | 17 // between V8 and C++. |
17 class GIN_EXPORT Arguments { | 18 class GIN_EXPORT Arguments { |
18 public: | 19 public: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 for (int i = 0; i < remaining; ++i) { | 52 for (int i = 0; i < remaining; ++i) { |
52 v8::Handle<v8::Value> val = (*info_)[next_++]; | 53 v8::Handle<v8::Value> val = (*info_)[next_++]; |
53 if (!ConvertFromV8(isolate_, val, &out->at(i))) | 54 if (!ConvertFromV8(isolate_, val, &out->at(i))) |
54 return false; | 55 return false; |
55 } | 56 } |
56 return true; | 57 return true; |
57 } | 58 } |
58 | 59 |
59 template<typename T> | 60 template<typename T> |
60 void Return(T val) { | 61 void Return(T val) { |
61 info_->GetReturnValue().Set(ConvertToV8(isolate_, val)); | 62 v8::Handle<v8::Value> r(ConvertToV8(isolate_, val)); |
| 63 LOG(ERROR) << "v8 return value: " << r->Int32Value(); |
| 64 info_->GetReturnValue().Set(r); |
62 } | 65 } |
63 | 66 |
64 v8::Handle<v8::Value> PeekNext() const; | 67 v8::Handle<v8::Value> PeekNext() const; |
65 | 68 |
66 void ThrowError() const; | 69 void ThrowError() const; |
67 void ThrowTypeError(const std::string& message) const; | 70 void ThrowTypeError(const std::string& message) const; |
68 | 71 |
69 v8::Isolate* isolate() const { return isolate_; } | 72 v8::Isolate* isolate() const { return isolate_; } |
70 | 73 |
71 private: | 74 private: |
72 v8::Isolate* isolate_; | 75 v8::Isolate* isolate_; |
73 const v8::FunctionCallbackInfo<v8::Value>* info_; | 76 const v8::FunctionCallbackInfo<v8::Value>* info_; |
74 int next_; | 77 int next_; |
75 bool insufficient_arguments_; | 78 bool insufficient_arguments_; |
76 }; | 79 }; |
77 | 80 |
78 } // namespace gin | 81 } // namespace gin |
79 | 82 |
80 #endif // GIN_ARGUMENTS_H_ | 83 #endif // GIN_ARGUMENTS_H_ |
OLD | NEW |