| 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 "gin/converter.h" | 8 #include "gin/converter.h" |
| 9 #include "gin/gin_export.h" | 9 #include "gin/gin_export.h" |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 67 } |
| 68 | 68 |
| 69 template<typename T> | 69 template<typename T> |
| 70 void Return(T val) { | 70 void Return(T val) { |
| 71 v8::Local<v8::Value> v8_value; | 71 v8::Local<v8::Value> v8_value; |
| 72 if (!TryConvertToV8(isolate_, val, &v8_value)) | 72 if (!TryConvertToV8(isolate_, val, &v8_value)) |
| 73 return; | 73 return; |
| 74 info_->GetReturnValue().Set(v8_value); | 74 info_->GetReturnValue().Set(v8_value); |
| 75 } | 75 } |
| 76 | 76 |
| 77 // Returns the creation context of the Holder. |
| 78 v8::Local<v8::Context> GetHolderCreationContext(); |
| 79 |
| 77 // Always check the return value whether the handle is empty before | 80 // Always check the return value whether the handle is empty before |
| 78 // dereferencing the handle. | 81 // dereferencing the handle. |
| 79 v8::Local<v8::Value> PeekNext() const; | 82 v8::Local<v8::Value> PeekNext() const; |
| 80 | 83 |
| 81 void ThrowError() const; | 84 void ThrowError() const; |
| 82 void ThrowTypeError(const std::string& message) const; | 85 void ThrowTypeError(const std::string& message) const; |
| 83 | 86 |
| 84 v8::Isolate* isolate() const { return isolate_; } | 87 v8::Isolate* isolate() const { return isolate_; } |
| 85 | 88 |
| 86 // Allows the function handler to distinguish between normal invocation | 89 // Allows the function handler to distinguish between normal invocation |
| 87 // and object construction. | 90 // and object construction. |
| 88 bool IsConstructCall() const; | 91 bool IsConstructCall() const; |
| 89 | 92 |
| 90 private: | 93 private: |
| 91 v8::Isolate* isolate_; | 94 v8::Isolate* isolate_; |
| 92 const v8::FunctionCallbackInfo<v8::Value>* info_; | 95 const v8::FunctionCallbackInfo<v8::Value>* info_; |
| 93 int next_; | 96 int next_; |
| 94 bool insufficient_arguments_; | 97 bool insufficient_arguments_; |
| 95 }; | 98 }; |
| 96 | 99 |
| 97 } // namespace gin | 100 } // namespace gin |
| 98 | 101 |
| 99 #endif // GIN_ARGUMENTS_H_ | 102 #endif // GIN_ARGUMENTS_H_ |
| OLD | NEW |