| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 /** \mainpage V8 API Reference Guide | 5 /** \mainpage V8 API Reference Guide |
| 6 * | 6 * |
| 7 * V8 is Google's open source JavaScript engine. | 7 * V8 is Google's open source JavaScript engine. |
| 8 * | 8 * |
| 9 * This set of documents provides reference material generated from the | 9 * This set of documents provides reference material generated from the |
| 10 * V8 header file, include/v8.h. | 10 * V8 header file, include/v8.h. |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 template<typename P> | 509 template<typename P> |
| 510 V8_INLINE void SetWeak( | 510 V8_INLINE void SetWeak( |
| 511 P* parameter, | 511 P* parameter, |
| 512 typename WeakCallbackData<T, P>::Callback callback); | 512 typename WeakCallbackData<T, P>::Callback callback); |
| 513 | 513 |
| 514 template<typename S, typename P> | 514 template<typename S, typename P> |
| 515 V8_INLINE void SetWeak( | 515 V8_INLINE void SetWeak( |
| 516 P* parameter, | 516 P* parameter, |
| 517 typename WeakCallbackData<S, P>::Callback callback); | 517 typename WeakCallbackData<S, P>::Callback callback); |
| 518 | 518 |
| 519 // Phantom persistents work like weak persistents, except that the pointer to |
| 520 // the object being collected is not available in the finalization callback. |
| 521 // This enables the garbage collector to collect the object and any objects |
| 522 // it references transitively in one GC cycle. |
| 523 template <typename P> |
| 524 V8_INLINE void SetPhantom(P* parameter, |
| 525 typename WeakCallbackData<T, P>::Callback callback); |
| 526 |
| 527 template <typename S, typename P> |
| 528 V8_INLINE void SetPhantom(P* parameter, |
| 529 typename WeakCallbackData<S, P>::Callback callback); |
| 530 |
| 519 template<typename P> | 531 template<typename P> |
| 520 V8_INLINE P* ClearWeak(); | 532 V8_INLINE P* ClearWeak(); |
| 521 | 533 |
| 522 // TODO(dcarney): remove this. | 534 // TODO(dcarney): remove this. |
| 523 V8_INLINE void ClearWeak() { ClearWeak<void>(); } | 535 V8_INLINE void ClearWeak() { ClearWeak<void>(); } |
| 524 | 536 |
| 525 /** | 537 /** |
| 526 * Marks the reference to this object independent. Garbage collector is free | 538 * Marks the reference to this object independent. Garbage collector is free |
| 527 * to ignore any object groups containing this object. Weak callback for an | 539 * to ignore any object groups containing this object. Weak callback for an |
| 528 * independent handle should not assume that it will be preceded by a global | 540 * independent handle should not assume that it will be preceded by a global |
| (...skipping 4794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5323 | 5335 |
| 5324 /** | 5336 /** |
| 5325 * Clears all references to the v8::Platform. This should be invoked after | 5337 * Clears all references to the v8::Platform. This should be invoked after |
| 5326 * V8 was disposed. | 5338 * V8 was disposed. |
| 5327 */ | 5339 */ |
| 5328 static void ShutdownPlatform(); | 5340 static void ShutdownPlatform(); |
| 5329 | 5341 |
| 5330 private: | 5342 private: |
| 5331 V8(); | 5343 V8(); |
| 5332 | 5344 |
| 5345 enum WeakHandleType { PhantomHandle, NonphantomHandle }; |
| 5346 |
| 5333 static internal::Object** GlobalizeReference(internal::Isolate* isolate, | 5347 static internal::Object** GlobalizeReference(internal::Isolate* isolate, |
| 5334 internal::Object** handle); | 5348 internal::Object** handle); |
| 5335 static internal::Object** CopyPersistent(internal::Object** handle); | 5349 static internal::Object** CopyPersistent(internal::Object** handle); |
| 5336 static void DisposeGlobal(internal::Object** global_handle); | 5350 static void DisposeGlobal(internal::Object** global_handle); |
| 5337 typedef WeakCallbackData<Value, void>::Callback WeakCallback; | 5351 typedef WeakCallbackData<Value, void>::Callback WeakCallback; |
| 5338 static void MakeWeak(internal::Object** global_handle, | 5352 static void MakeWeak(internal::Object** global_handle, void* data, |
| 5339 void* data, | 5353 WeakCallback weak_callback, WeakHandleType phantom); |
| 5340 WeakCallback weak_callback); | |
| 5341 static void* ClearWeak(internal::Object** global_handle); | 5354 static void* ClearWeak(internal::Object** global_handle); |
| 5342 static void Eternalize(Isolate* isolate, | 5355 static void Eternalize(Isolate* isolate, |
| 5343 Value* handle, | 5356 Value* handle, |
| 5344 int* index); | 5357 int* index); |
| 5345 static Local<Value> GetEternal(Isolate* isolate, int index); | 5358 static Local<Value> GetEternal(Isolate* isolate, int index); |
| 5346 | 5359 |
| 5347 template <class T> friend class Handle; | 5360 template <class T> friend class Handle; |
| 5348 template <class T> friend class Local; | 5361 template <class T> friend class Local; |
| 5349 template <class T> friend class Eternal; | 5362 template <class T> friend class Eternal; |
| 5350 template <class T> friend class PersistentBase; | 5363 template <class T> friend class PersistentBase; |
| (...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6193 } | 6206 } |
| 6194 | 6207 |
| 6195 | 6208 |
| 6196 template <class T> | 6209 template <class T> |
| 6197 template <typename S, typename P> | 6210 template <typename S, typename P> |
| 6198 void PersistentBase<T>::SetWeak( | 6211 void PersistentBase<T>::SetWeak( |
| 6199 P* parameter, | 6212 P* parameter, |
| 6200 typename WeakCallbackData<S, P>::Callback callback) { | 6213 typename WeakCallbackData<S, P>::Callback callback) { |
| 6201 TYPE_CHECK(S, T); | 6214 TYPE_CHECK(S, T); |
| 6202 typedef typename WeakCallbackData<Value, void>::Callback Callback; | 6215 typedef typename WeakCallbackData<Value, void>::Callback Callback; |
| 6203 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), | 6216 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter, |
| 6204 parameter, | 6217 reinterpret_cast<Callback>(callback), V8::NonphantomHandle); |
| 6205 reinterpret_cast<Callback>(callback)); | |
| 6206 } | 6218 } |
| 6207 | 6219 |
| 6208 | 6220 |
| 6209 template <class T> | 6221 template <class T> |
| 6210 template <typename P> | 6222 template <typename P> |
| 6211 void PersistentBase<T>::SetWeak( | 6223 void PersistentBase<T>::SetWeak( |
| 6212 P* parameter, | 6224 P* parameter, |
| 6213 typename WeakCallbackData<T, P>::Callback callback) { | 6225 typename WeakCallbackData<T, P>::Callback callback) { |
| 6214 SetWeak<T, P>(parameter, callback); | 6226 SetWeak<T, P>(parameter, callback); |
| 6215 } | 6227 } |
| 6216 | 6228 |
| 6217 | 6229 |
| 6218 template <class T> | 6230 template <class T> |
| 6219 template<typename P> | 6231 template <typename S, typename P> |
| 6232 void PersistentBase<T>::SetPhantom( |
| 6233 P* parameter, typename WeakCallbackData<S, P>::Callback callback) { |
| 6234 TYPE_CHECK(S, T); |
| 6235 typedef typename WeakCallbackData<Value, void>::Callback Callback; |
| 6236 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter, |
| 6237 reinterpret_cast<Callback>(callback), V8::PhantomHandle); |
| 6238 } |
| 6239 |
| 6240 |
| 6241 template <class T> |
| 6242 template <typename P> |
| 6243 void PersistentBase<T>::SetPhantom( |
| 6244 P* parameter, typename WeakCallbackData<T, P>::Callback callback) { |
| 6245 SetPhantom<T, P>(parameter, callback); |
| 6246 } |
| 6247 |
| 6248 |
| 6249 template <class T> |
| 6250 template <typename P> |
| 6220 P* PersistentBase<T>::ClearWeak() { | 6251 P* PersistentBase<T>::ClearWeak() { |
| 6221 return reinterpret_cast<P*>( | 6252 return reinterpret_cast<P*>( |
| 6222 V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_))); | 6253 V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_))); |
| 6223 } | 6254 } |
| 6224 | 6255 |
| 6225 | 6256 |
| 6226 template <class T> | 6257 template <class T> |
| 6227 void PersistentBase<T>::MarkIndependent() { | 6258 void PersistentBase<T>::MarkIndependent() { |
| 6228 typedef internal::Internals I; | 6259 typedef internal::Internals I; |
| 6229 if (this->IsEmpty()) return; | 6260 if (this->IsEmpty()) return; |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7088 */ | 7119 */ |
| 7089 | 7120 |
| 7090 | 7121 |
| 7091 } // namespace v8 | 7122 } // namespace v8 |
| 7092 | 7123 |
| 7093 | 7124 |
| 7094 #undef TYPE_CHECK | 7125 #undef TYPE_CHECK |
| 7095 | 7126 |
| 7096 | 7127 |
| 7097 #endif // V8_H_ | 7128 #endif // V8_H_ |
| OLD | NEW |