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 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 }; | 80 }; |
81 | 81 |
82 template<> | 82 template<> |
83 struct Converter<v8::Handle<v8::Object> > { | 83 struct Converter<v8::Handle<v8::Object> > { |
84 static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate, | 84 static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate, |
85 v8::Handle<v8::Object> val); | 85 v8::Handle<v8::Object> val); |
86 static bool FromV8(v8::Handle<v8::Value> val, | 86 static bool FromV8(v8::Handle<v8::Value> val, |
87 v8::Handle<v8::Object>* out); | 87 v8::Handle<v8::Object>* out); |
88 }; | 88 }; |
89 | 89 |
| 90 template<> |
| 91 struct Converter<v8::Handle<v8::Value> > { |
| 92 static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate, |
| 93 v8::Handle<v8::Value> val); |
| 94 static bool FromV8(v8::Handle<v8::Value> val, |
| 95 v8::Handle<v8::Value>* out); |
| 96 }; |
| 97 |
90 template<typename T> | 98 template<typename T> |
91 struct Converter<std::vector<T> > { | 99 struct Converter<std::vector<T> > { |
92 static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate, | 100 static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate, |
93 const std::vector<T>& val) { | 101 const std::vector<T>& val) { |
94 v8::Handle<v8::Array> result(v8::Array::New(static_cast<int>(val.size()))); | 102 v8::Handle<v8::Array> result(v8::Array::New(static_cast<int>(val.size()))); |
95 for (size_t i = 0; i < val.size(); ++i) { | 103 for (size_t i = 0; i < val.size(); ++i) { |
96 result->Set(static_cast<int>(i), Converter<T>::ToV8(isolate, val[i])); | 104 result->Set(static_cast<int>(i), Converter<T>::ToV8(isolate, val[i])); |
97 } | 105 } |
98 return result; | 106 return result; |
99 } | 107 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 const std::string& val); | 142 const std::string& val); |
135 | 143 |
136 template<typename T> | 144 template<typename T> |
137 bool ConvertFromV8(v8::Handle<v8::Value> input, T* result) { | 145 bool ConvertFromV8(v8::Handle<v8::Value> input, T* result) { |
138 return Converter<T>::FromV8(input, result); | 146 return Converter<T>::FromV8(input, result); |
139 } | 147 } |
140 | 148 |
141 } // namespace gin | 149 } // namespace gin |
142 | 150 |
143 #endif // GIN_CONVERTER_H_ | 151 #endif // GIN_CONVERTER_H_ |
OLD | NEW |