| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 | 1121 |
| 1122 static void visit(Visitor* v, Collection& collection) | 1122 static void visit(Visitor* v, Collection& collection) |
| 1123 { | 1123 { |
| 1124 for (typename Collection::iterator it = collection.begin(), end = collec
tion.end(); it != end; ++it) { | 1124 for (typename Collection::iterator it = collection.begin(), end = collec
tion.end(); it != end; ++it) { |
| 1125 IfMemberTrait<K>::visit(v, it->key); | 1125 IfMemberTrait<K>::visit(v, it->key); |
| 1126 IfMemberTrait<V>::visit(v, it->value); | 1126 IfMemberTrait<V>::visit(v, it->value); |
| 1127 } | 1127 } |
| 1128 } | 1128 } |
| 1129 }; | 1129 }; |
| 1130 | 1130 |
| 1131 template<typename Collection> class CollectionRoot; |
| 1132 |
| 1133 // Used to inject correctly typed operator[] into CollectionRoot when we are wra
pping Vector. |
| 1134 template<typename T> class IndexingBehavior { }; |
| 1135 |
| 1136 template<typename T, size_t inlineCapacity, typename Allocator> |
| 1137 class IndexingBehavior<CollectionRoot<Vector<T, inlineCapacity, Allocator> > > { |
| 1138 typedef CollectionRoot<Vector<T, inlineCapacity, Allocator> > CollectionRoot
Type; |
| 1139 public: |
| 1140 T& operator[] (size_t i) { return (**static_cast<CollectionRootType*>(this))
[i]; } |
| 1141 const T& operator[] (size_t i) const { return (**static_cast<const Collectio
nRootType*>(this))[i]; } |
| 1142 }; |
| 1143 |
| 1131 template<typename Collection> | 1144 template<typename Collection> |
| 1132 class CollectionRoot : public PersistentBase { | 1145 class CollectionRoot : public PersistentBase, public IndexingBehavior<Collection
Root<Collection> > { |
| 1133 public: | 1146 public: |
| 1134 typedef Collection CollectionType; | 1147 typedef Collection CollectionType; |
| 1148 typedef typename Collection::iterator iterator; |
| 1149 typedef typename Collection::const_iterator const_iterator; |
| 1135 | 1150 |
| 1136 CollectionRoot() { } | 1151 CollectionRoot() { } |
| 1137 explicit CollectionRoot(size_t size) : m_collection(Collection(size)) { } | 1152 explicit CollectionRoot(size_t size) : m_collection(Collection(size)) { } |
| 1138 // FIXME(oilpan): this constructor might be extremely ineffecient. | 1153 // FIXME(oilpan): this constructor might be extremely ineffecient. |
| 1139 explicit CollectionRoot(const Collection& collection) : m_collection(collect
ion) { } | 1154 explicit CollectionRoot(const Collection& collection) : m_collection(collect
ion) { } |
| 1140 | 1155 |
| 1141 Collection* operator->() { return &m_collection; } | 1156 Collection* operator->() { return &m_collection; } |
| 1142 const Collection* operator->() const { return &m_collection; } | 1157 const Collection* operator->() const { return &m_collection; } |
| 1143 Collection& operator*() { return m_collection; } | 1158 Collection& operator*() { return m_collection; } |
| 1144 const Collection& operator*() const { return m_collection; } | 1159 const Collection& operator*() const { return m_collection; } |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1410 typedef PtrHash<WebCore::Member<T> > Hash; | 1425 typedef PtrHash<WebCore::Member<T> > Hash; |
| 1411 }; | 1426 }; |
| 1412 | 1427 |
| 1413 #define DEFINE_SELF_HANDLE(Type) \ | 1428 #define DEFINE_SELF_HANDLE(Type) \ |
| 1414 Result<Type> selfHandle() { return adoptRawResult(this); } \ | 1429 Result<Type> selfHandle() { return adoptRawResult(this); } \ |
| 1415 Result<const Type> selfHandle() const { return adoptRawResult(this); } | 1430 Result<const Type> selfHandle() const { return adoptRawResult(this); } |
| 1416 | 1431 |
| 1417 } | 1432 } |
| 1418 | 1433 |
| 1419 #endif | 1434 #endif |
| OLD | NEW |