| 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_CONVERTER_H_ | 5 #ifndef GIN_CONVERTER_H_ |
| 6 #define GIN_CONVERTER_H_ | 6 #define GIN_CONVERTER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
| 13 #include "gin/gin_export.h" | 13 #include "gin/gin_export.h" |
| 14 #include "v8/include/v8.h" | 14 #include "v8/include/v8.h" |
| 15 | 15 |
| 16 namespace gin { | 16 namespace gin { |
| 17 | 17 |
| 18 template<typename KeyType> | 18 template<typename KeyType> |
| 19 bool SetProperty(v8::Isolate* isolate, | 19 bool SetProperty(v8::Isolate* isolate, |
| 20 v8::Local<v8::Object> object, | 20 v8::Local<v8::Object> object, |
| 21 KeyType key, | 21 KeyType key, |
| 22 v8::Local<v8::Value> value) { | 22 v8::Local<v8::Value> value) { |
| 23 auto maybe = object->Set(isolate->GetCurrentContext(), key, value); | 23 auto maybe = |
| 24 object->DefineOwnProperty(isolate->GetCurrentContext(), key, value); |
| 24 return !maybe.IsNothing() && maybe.FromJust(); | 25 return !maybe.IsNothing() && maybe.FromJust(); |
| 25 } | 26 } |
| 26 | 27 |
| 27 template<typename T> | 28 template<typename T> |
| 28 struct ToV8ReturnsMaybe { | 29 struct ToV8ReturnsMaybe { |
| 29 static const bool value = false; | 30 static const bool value = false; |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 template<typename T, typename Enable = void> | 33 template<typename T, typename Enable = void> |
| 33 struct Converter {}; | 34 struct Converter {}; |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 bool ConvertFromV8(v8::Isolate* isolate, v8::Local<v8::Value> input, | 261 bool ConvertFromV8(v8::Isolate* isolate, v8::Local<v8::Value> input, |
| 261 T* result) { | 262 T* result) { |
| 262 return Converter<T>::FromV8(isolate, input, result); | 263 return Converter<T>::FromV8(isolate, input, result); |
| 263 } | 264 } |
| 264 | 265 |
| 265 GIN_EXPORT std::string V8ToString(v8::Local<v8::Value> value); | 266 GIN_EXPORT std::string V8ToString(v8::Local<v8::Value> value); |
| 266 | 267 |
| 267 } // namespace gin | 268 } // namespace gin |
| 268 | 269 |
| 269 #endif // GIN_CONVERTER_H_ | 270 #endif // GIN_CONVERTER_H_ |
| OLD | NEW |