| 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 <map> | 9 #include <map> | 
| 10 #include <vector> | 10 #include <vector> | 
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 88   // Weak callback & friends: | 88   // Weak callback & friends: | 
| 89   static const PersistentContainerCallbackType kCallbackType = kNotWeak; | 89   static const PersistentContainerCallbackType kCallbackType = kNotWeak; | 
| 90   typedef PersistentValueMap<K, V, DefaultPersistentValueMapTraits<K, V> > | 90   typedef PersistentValueMap<K, V, DefaultPersistentValueMapTraits<K, V> > | 
| 91       MapType; | 91       MapType; | 
| 92   typedef void WeakCallbackDataType; | 92   typedef void WeakCallbackDataType; | 
| 93 | 93 | 
| 94   static WeakCallbackDataType* WeakCallbackParameter( | 94   static WeakCallbackDataType* WeakCallbackParameter( | 
| 95       MapType* map, const K& key, Local<V> value) { | 95       MapType* map, const K& key, Local<V> value) { | 
| 96     return NULL; | 96     return NULL; | 
| 97   } | 97   } | 
| 98   static MapType* MapFromWeakCallbackData( | 98   static MapType* MapFromWeakCallbackInfo( | 
| 99           const WeakCallbackData<V, WeakCallbackDataType>& data) { | 99       const WeakCallbackInfo<WeakCallbackDataType>& data) { | 
| 100     return NULL; | 100     return NULL; | 
| 101   } | 101   } | 
| 102   static K KeyFromWeakCallbackData( | 102   static K KeyFromWeakCallbackInfo( | 
| 103       const WeakCallbackData<V, WeakCallbackDataType>& data) { | 103       const WeakCallbackInfo<WeakCallbackDataType>& data) { | 
| 104     return K(); | 104     return K(); | 
| 105   } | 105   } | 
| 106   static void DisposeCallbackData(WeakCallbackDataType* data) { } | 106   static void DisposeCallbackData(WeakCallbackDataType* data) { } | 
| 107   static void Dispose(Isolate* isolate, Global<V> value, K key) {} | 107   static void Dispose(Isolate* isolate, Global<V> value, K key) {} | 
| 108 }; | 108 }; | 
| 109 | 109 | 
| 110 | 110 | 
| 111 template <typename K, typename V> | 111 template <typename K, typename V> | 
| 112 class DefaultGlobalMapTraits : public StdMapTraits<K, V> { | 112 class DefaultGlobalMapTraits : public StdMapTraits<K, V> { | 
| 113  private: | 113  private: | 
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 406    * Restrictions of GetReference apply here as well. | 406    * Restrictions of GetReference apply here as well. | 
| 407    */ | 407    */ | 
| 408   Global<V> Set(const K& key, Global<V> value, | 408   Global<V> Set(const K& key, Global<V> value, | 
| 409                 PersistentValueReference* reference) { | 409                 PersistentValueReference* reference) { | 
| 410     *reference = this->Leak(&value); | 410     *reference = this->Leak(&value); | 
| 411     return SetUnique(key, &value); | 411     return SetUnique(key, &value); | 
| 412   } | 412   } | 
| 413 | 413 | 
| 414  private: | 414  private: | 
| 415   static void WeakCallback( | 415   static void WeakCallback( | 
| 416       const WeakCallbackData<V, typename Traits::WeakCallbackDataType>& data) { | 416       const WeakCallbackInfo<typename Traits::WeakCallbackDataType>& data) { | 
| 417     if (Traits::kCallbackType != kNotWeak) { | 417     if (Traits::kCallbackType != kNotWeak) { | 
| 418       PersistentValueMap<K, V, Traits>* persistentValueMap = | 418       PersistentValueMap<K, V, Traits>* persistentValueMap = | 
| 419           Traits::MapFromWeakCallbackData(data); | 419           Traits::MapFromWeakCallbackInfo(data); | 
| 420       K key = Traits::KeyFromWeakCallbackData(data); | 420       K key = Traits::KeyFromWeakCallbackInfo(data); | 
| 421       Traits::Dispose(data.GetIsolate(), | 421       Traits::Dispose(data.GetIsolate(), | 
| 422                       persistentValueMap->Remove(key).Pass(), key); | 422                       persistentValueMap->Remove(key).Pass(), key); | 
| 423       Traits::DisposeCallbackData(data.GetParameter()); | 423       Traits::DisposeCallbackData(data.GetParameter()); | 
| 424     } | 424     } | 
| 425   } | 425   } | 
| 426 }; | 426 }; | 
| 427 | 427 | 
| 428 | 428 | 
| 429 template <typename K, typename V, typename Traits> | 429 template <typename K, typename V, typename Traits> | 
| 430 class GlobalValueMap : public PersistentValueMapBase<K, V, Traits> { | 430 class GlobalValueMap : public PersistentValueMapBase<K, V, Traits> { | 
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 645     return reinterpret_cast<V*>(v); | 645     return reinterpret_cast<V*>(v); | 
| 646   } | 646   } | 
| 647 | 647 | 
| 648   Isolate* isolate_; | 648   Isolate* isolate_; | 
| 649   typename Traits::Impl impl_; | 649   typename Traits::Impl impl_; | 
| 650 }; | 650 }; | 
| 651 | 651 | 
| 652 }  // namespace v8 | 652 }  // namespace v8 | 
| 653 | 653 | 
| 654 #endif  // V8_UTIL_H | 654 #endif  // V8_UTIL_H | 
| OLD | NEW | 
|---|