| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project 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 V8_UTIL_H_ | 5 #ifndef V8_UTIL_H_ |
| 6 #define V8_UTIL_H_ | 6 #define V8_UTIL_H_ |
| 7 | 7 |
| 8 #include "v8.h" // NOLINT(build/include) | 8 #include "v8.h" // NOLINT(build/include) |
| 9 #include <assert.h> |
| 9 #include <map> | 10 #include <map> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 /** | 13 /** |
| 13 * Support for Persistent containers. | 14 * Support for Persistent containers. |
| 14 * | 15 * |
| 15 * C++11 embedders can use STL containers with Global values, | 16 * C++11 embedders can use STL containers with Global values, |
| 16 * but pre-C++11 does not support the required move semantic and hence | 17 * but pre-C++11 does not support the required move semantic and hence |
| 17 * may want these container classes. | 18 * may want these container classes. |
| 18 */ | 19 */ |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 GetIsolate()->SetReference( | 204 GetIsolate()->SetReference( |
| 204 reinterpret_cast<internal::Object**>(parent.val_), | 205 reinterpret_cast<internal::Object**>(parent.val_), |
| 205 reinterpret_cast<internal::Object**>(FromVal(Traits::Get(&impl_, key)))); | 206 reinterpret_cast<internal::Object**>(FromVal(Traits::Get(&impl_, key)))); |
| 206 } | 207 } |
| 207 | 208 |
| 208 /** | 209 /** |
| 209 * Call V8::RegisterExternallyReferencedObject with the map value for given | 210 * Call V8::RegisterExternallyReferencedObject with the map value for given |
| 210 * key. | 211 * key. |
| 211 */ | 212 */ |
| 212 void RegisterExternallyReferencedObject(K& key) { | 213 void RegisterExternallyReferencedObject(K& key) { |
| 213 DCHECK(Contains(key)); | 214 assert(Contains(key)); |
| 214 V8::RegisterExternallyReferencedObject( | 215 V8::RegisterExternallyReferencedObject( |
| 215 reinterpret_cast<internal::Object**>(FromVal(Traits::Get(&impl_, key))), | 216 reinterpret_cast<internal::Object**>(FromVal(Traits::Get(&impl_, key))), |
| 216 reinterpret_cast<internal::Isolate*>(GetIsolate())); | 217 reinterpret_cast<internal::Isolate*>(GetIsolate())); |
| 217 } | 218 } |
| 218 | 219 |
| 219 /** | 220 /** |
| 220 * Return value for key and remove it from the map. | 221 * Return value for key and remove it from the map. |
| 221 */ | 222 */ |
| 222 Global<V> Remove(const K& key) { | 223 Global<V> Remove(const K& key) { |
| 223 return Release(Traits::Remove(&impl_, key)).Pass(); | 224 return Release(Traits::Remove(&impl_, key)).Pass(); |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 return reinterpret_cast<V*>(v); | 646 return reinterpret_cast<V*>(v); |
| 646 } | 647 } |
| 647 | 648 |
| 648 Isolate* isolate_; | 649 Isolate* isolate_; |
| 649 typename Traits::Impl impl_; | 650 typename Traits::Impl impl_; |
| 650 }; | 651 }; |
| 651 | 652 |
| 652 } // namespace v8 | 653 } // namespace v8 |
| 653 | 654 |
| 654 #endif // V8_UTIL_H | 655 #endif // V8_UTIL_H |
| OLD | NEW |