Chromium Code Reviews| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 class StackFrame; | 96 class StackFrame; |
| 97 class StackTrace; | 97 class StackTrace; |
| 98 class String; | 98 class String; |
| 99 class StringObject; | 99 class StringObject; |
| 100 class Symbol; | 100 class Symbol; |
| 101 class SymbolObject; | 101 class SymbolObject; |
| 102 class Private; | 102 class Private; |
| 103 class Uint32; | 103 class Uint32; |
| 104 class Utils; | 104 class Utils; |
| 105 class Value; | 105 class Value; |
| 106 template <class T> class Handle; | |
| 107 template <class T> class Local; | 106 template <class T> class Local; |
| 108 template <class T> class Eternal; | 107 template <class T> class Eternal; |
| 109 template<class T> class NonCopyablePersistentTraits; | 108 template<class T> class NonCopyablePersistentTraits; |
| 110 template<class T> class PersistentBase; | 109 template<class T> class PersistentBase; |
| 111 template<class T, | 110 template<class T, |
| 112 class M = NonCopyablePersistentTraits<T> > class Persistent; | 111 class M = NonCopyablePersistentTraits<T> > class Persistent; |
| 113 template<class T> class UniquePersistent; | 112 template<class T> class UniquePersistent; |
| 114 template<class K, class V, class T> class PersistentValueMap; | 113 template<class K, class V, class T> class PersistentValueMap; |
| 115 template<class V, class T> class PersistentValueVector; | 114 template<class V, class T> class PersistentValueVector; |
| 116 template<class T, class P> class WeakCallbackObject; | 115 template<class T, class P> class WeakCallbackObject; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 * | 188 * |
| 190 * There are two types of handles: local and persistent handles. | 189 * There are two types of handles: local and persistent handles. |
| 191 * Local handles are light-weight and transient and typically used in | 190 * Local handles are light-weight and transient and typically used in |
| 192 * local operations. They are managed by HandleScopes. Persistent | 191 * local operations. They are managed by HandleScopes. Persistent |
| 193 * handles can be used when storing objects across several independent | 192 * handles can be used when storing objects across several independent |
| 194 * operations and have to be explicitly deallocated when they're no | 193 * operations and have to be explicitly deallocated when they're no |
| 195 * longer used. | 194 * longer used. |
| 196 * | 195 * |
| 197 * It is safe to extract the object stored in the handle by | 196 * It is safe to extract the object stored in the handle by |
| 198 * dereferencing the handle (for instance, to extract the Object* from | 197 * dereferencing the handle (for instance, to extract the Object* from |
| 199 * a Handle<Object>); the value will still be governed by a handle | 198 * a Local<Object>); the value will still be governed by a handle |
| 200 * behind the scenes and the same rules apply to these values as to | 199 * behind the scenes and the same rules apply to these values as to |
| 201 * their handles. | 200 * their handles. |
| 202 */ | 201 */ |
| 203 template <class T> class Handle { | 202 template <class T> |
| 203 class Local { | |
| 204 public: | 204 public: |
| 205 /** | 205 V8_INLINE Local() : val_(0) {} |
| 206 * Creates an empty handle. | 206 template <class S> |
| 207 */ | 207 V8_INLINE Local(Local<S> that) |
| 208 V8_INLINE Handle() : val_(0) {} | |
| 209 | |
| 210 /** | |
| 211 * Creates a handle for the contents of the specified handle. This | |
| 212 * constructor allows you to pass handles as arguments by value and | |
| 213 * to assign between handles. However, if you try to assign between | |
| 214 * incompatible handles, for instance from a Handle<String> to a | |
| 215 * Handle<Number> it will cause a compile-time error. Assigning | |
| 216 * between compatible handles, for instance assigning a | |
| 217 * Handle<String> to a variable declared as Handle<Value>, is legal | |
| 218 * because String is a subclass of Value. | |
| 219 */ | |
| 220 template <class S> V8_INLINE Handle(Handle<S> that) | |
| 221 : val_(reinterpret_cast<T*>(*that)) { | 208 : val_(reinterpret_cast<T*>(*that)) { |
|
Sven Panne
2014/10/29 07:15:27
Not really related to this CL: I think that we can
| |
| 222 /** | 209 /** |
| 223 * This check fails when trying to convert between incompatible | 210 * This check fails when trying to convert between incompatible |
| 224 * handles. For example, converting from a Handle<String> to a | 211 * handles. For example, converting from a Handle<String> to a |
| 225 * Handle<Number>. | 212 * Handle<Number>. |
| 226 */ | 213 */ |
| 227 TYPE_CHECK(T, S); | 214 TYPE_CHECK(T, S); |
| 228 } | 215 } |
| 229 | 216 |
| 230 /** | 217 /** |
| 231 * Returns true if the handle is empty. | 218 * Returns true if the handle is empty. |
| 232 */ | 219 */ |
| 233 V8_INLINE bool IsEmpty() const { return val_ == 0; } | 220 V8_INLINE bool IsEmpty() const { return val_ == 0; } |
| 234 | 221 |
| 235 /** | 222 /** |
| 236 * Sets the handle to be empty. IsEmpty() will then return true. | 223 * Sets the handle to be empty. IsEmpty() will then return true. |
| 237 */ | 224 */ |
| 238 V8_INLINE void Clear() { val_ = 0; } | 225 V8_INLINE void Clear() { val_ = 0; } |
| 239 | 226 |
| 240 V8_INLINE T* operator->() const { return val_; } | 227 V8_INLINE T* operator->() const { return val_; } |
| 241 | 228 |
| 242 V8_INLINE T* operator*() const { return val_; } | 229 V8_INLINE T* operator*() const { return val_; } |
| 243 | 230 |
| 244 /** | 231 /** |
| 245 * Checks whether two handles are the same. | 232 * Checks whether two handles are the same. |
| 246 * Returns true if both are empty, or if the objects | 233 * Returns true if both are empty, or if the objects |
| 247 * to which they refer are identical. | 234 * to which they refer are identical. |
| 248 * The handles' references are not checked. | 235 * The handles' references are not checked. |
| 249 */ | 236 */ |
| 250 template <class S> V8_INLINE bool operator==(const Handle<S>& that) const { | 237 template <class S> |
| 238 V8_INLINE bool operator==(const Local<S>& that) const { | |
| 251 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_); | 239 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_); |
| 252 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_); | 240 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_); |
| 253 if (a == 0) return b == 0; | 241 if (a == 0) return b == 0; |
| 254 if (b == 0) return false; | 242 if (b == 0) return false; |
| 255 return *a == *b; | 243 return *a == *b; |
| 256 } | 244 } |
| 257 | 245 |
| 258 template <class S> V8_INLINE bool operator==( | 246 template <class S> V8_INLINE bool operator==( |
| 259 const PersistentBase<S>& that) const { | 247 const PersistentBase<S>& that) const { |
| 260 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_); | 248 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_); |
| 261 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_); | 249 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_); |
| 262 if (a == 0) return b == 0; | 250 if (a == 0) return b == 0; |
| 263 if (b == 0) return false; | 251 if (b == 0) return false; |
| 264 return *a == *b; | 252 return *a == *b; |
| 265 } | 253 } |
| 266 | 254 |
| 267 /** | 255 /** |
| 268 * Checks whether two handles are different. | 256 * Checks whether two handles are different. |
| 269 * Returns true if only one of the handles is empty, or if | 257 * Returns true if only one of the handles is empty, or if |
| 270 * the objects to which they refer are different. | 258 * the objects to which they refer are different. |
| 271 * The handles' references are not checked. | 259 * The handles' references are not checked. |
| 272 */ | 260 */ |
| 273 template <class S> V8_INLINE bool operator!=(const Handle<S>& that) const { | 261 template <class S> |
| 262 V8_INLINE bool operator!=(const Local<S>& that) const { | |
| 274 return !operator==(that); | 263 return !operator==(that); |
| 275 } | 264 } |
| 276 | 265 |
| 277 template <class S> V8_INLINE bool operator!=( | 266 template <class S> V8_INLINE bool operator!=( |
| 278 const Persistent<S>& that) const { | 267 const Persistent<S>& that) const { |
| 279 return !operator==(that); | 268 return !operator==(that); |
| 280 } | 269 } |
| 281 | 270 |
| 282 template <class S> V8_INLINE static Handle<T> Cast(Handle<S> that) { | |
| 283 #ifdef V8_ENABLE_CHECKS | |
| 284 // If we're going to perform the type check then we have to check | |
| 285 // that the handle isn't empty before doing the checked cast. | |
| 286 if (that.IsEmpty()) return Handle<T>(); | |
| 287 #endif | |
| 288 return Handle<T>(T::Cast(*that)); | |
| 289 } | |
| 290 | |
| 291 template <class S> V8_INLINE Handle<S> As() { | |
| 292 return Handle<S>::Cast(*this); | |
| 293 } | |
| 294 | |
| 295 V8_INLINE static Handle<T> New(Isolate* isolate, Handle<T> that) { | |
| 296 return New(isolate, that.val_); | |
| 297 } | |
| 298 V8_INLINE static Handle<T> New(Isolate* isolate, | |
| 299 const PersistentBase<T>& that) { | |
| 300 return New(isolate, that.val_); | |
| 301 } | |
| 302 | |
| 303 private: | |
| 304 friend class Utils; | |
| 305 template<class F, class M> friend class Persistent; | |
| 306 template<class F> friend class PersistentBase; | |
| 307 template<class F> friend class Handle; | |
| 308 template<class F> friend class Local; | |
| 309 template<class F> friend class FunctionCallbackInfo; | |
| 310 template<class F> friend class PropertyCallbackInfo; | |
| 311 template<class F> friend class internal::CustomArguments; | |
| 312 friend Handle<Primitive> Undefined(Isolate* isolate); | |
| 313 friend Handle<Primitive> Null(Isolate* isolate); | |
| 314 friend Handle<Boolean> True(Isolate* isolate); | |
| 315 friend Handle<Boolean> False(Isolate* isolate); | |
| 316 friend class Context; | |
| 317 friend class HandleScope; | |
| 318 friend class Object; | |
| 319 friend class Private; | |
| 320 | |
| 321 /** | |
| 322 * Creates a new handle for the specified value. | |
| 323 */ | |
| 324 V8_INLINE explicit Handle(T* val) : val_(val) {} | |
| 325 | |
| 326 V8_INLINE static Handle<T> New(Isolate* isolate, T* that); | |
| 327 | |
| 328 T* val_; | |
| 329 }; | |
| 330 | |
| 331 | |
| 332 /** | |
| 333 * A light-weight stack-allocated object handle. All operations | |
| 334 * that return objects from within v8 return them in local handles. They | |
| 335 * are created within HandleScopes, and all local handles allocated within a | |
| 336 * handle scope are destroyed when the handle scope is destroyed. Hence it | |
| 337 * is not necessary to explicitly deallocate local handles. | |
| 338 */ | |
| 339 template <class T> class Local : public Handle<T> { | |
| 340 public: | |
| 341 V8_INLINE Local(); | |
| 342 template <class S> V8_INLINE Local(Local<S> that) | |
| 343 : Handle<T>(reinterpret_cast<T*>(*that)) { | |
| 344 /** | |
| 345 * This check fails when trying to convert between incompatible | |
| 346 * handles. For example, converting from a Handle<String> to a | |
| 347 * Handle<Number>. | |
| 348 */ | |
| 349 TYPE_CHECK(T, S); | |
| 350 } | |
| 351 | |
| 352 | |
| 353 template <class S> V8_INLINE static Local<T> Cast(Local<S> that) { | 271 template <class S> V8_INLINE static Local<T> Cast(Local<S> that) { |
| 354 #ifdef V8_ENABLE_CHECKS | 272 #ifdef V8_ENABLE_CHECKS |
| 355 // If we're going to perform the type check then we have to check | 273 // If we're going to perform the type check then we have to check |
| 356 // that the handle isn't empty before doing the checked cast. | 274 // that the handle isn't empty before doing the checked cast. |
| 357 if (that.IsEmpty()) return Local<T>(); | 275 if (that.IsEmpty()) return Local<T>(); |
| 358 #endif | 276 #endif |
| 359 return Local<T>(T::Cast(*that)); | 277 return Local<T>(T::Cast(*that)); |
| 360 } | 278 } |
| 361 template <class S> V8_INLINE Local(Handle<S> that) | 279 |
| 362 : Handle<T>(reinterpret_cast<T*>(*that)) { | |
| 363 TYPE_CHECK(T, S); | |
| 364 } | |
| 365 | 280 |
| 366 template <class S> V8_INLINE Local<S> As() { | 281 template <class S> V8_INLINE Local<S> As() { |
| 367 return Local<S>::Cast(*this); | 282 return Local<S>::Cast(*this); |
| 368 } | 283 } |
| 369 | 284 |
| 370 /** | 285 /** |
| 371 * Create a local handle for the content of another handle. | 286 * Create a local handle for the content of another handle. |
| 372 * The referee is kept alive by the local handle even when | 287 * The referee is kept alive by the local handle even when |
| 373 * the original handle is destroyed/disposed. | 288 * the original handle is destroyed/disposed. |
| 374 */ | 289 */ |
| 375 V8_INLINE static Local<T> New(Isolate* isolate, Handle<T> that); | 290 V8_INLINE static Local<T> New(Isolate* isolate, Local<T> that); |
| 376 V8_INLINE static Local<T> New(Isolate* isolate, | 291 V8_INLINE static Local<T> New(Isolate* isolate, |
| 377 const PersistentBase<T>& that); | 292 const PersistentBase<T>& that); |
| 378 | 293 |
| 379 private: | 294 private: |
| 380 friend class Utils; | 295 friend class Utils; |
| 381 template<class F> friend class Eternal; | 296 template<class F> friend class Eternal; |
| 382 template<class F> friend class PersistentBase; | 297 template<class F> friend class PersistentBase; |
| 383 template<class F, class M> friend class Persistent; | 298 template<class F, class M> friend class Persistent; |
| 384 template<class F> friend class Handle; | |
| 385 template<class F> friend class Local; | 299 template<class F> friend class Local; |
| 386 template<class F> friend class FunctionCallbackInfo; | 300 template<class F> friend class FunctionCallbackInfo; |
| 387 template<class F> friend class PropertyCallbackInfo; | 301 template<class F> friend class PropertyCallbackInfo; |
| 388 friend class String; | 302 friend class String; |
| 389 friend class Object; | 303 friend class Object; |
| 390 friend class Context; | 304 friend class Context; |
| 305 friend class Private; | |
| 391 template<class F> friend class internal::CustomArguments; | 306 template<class F> friend class internal::CustomArguments; |
| 307 friend Local<Primitive> Undefined(Isolate* isolate); | |
| 308 friend Local<Primitive> Null(Isolate* isolate); | |
| 309 friend Local<Boolean> True(Isolate* isolate); | |
| 310 friend Local<Boolean> False(Isolate* isolate); | |
| 392 friend class HandleScope; | 311 friend class HandleScope; |
| 393 friend class EscapableHandleScope; | 312 friend class EscapableHandleScope; |
| 394 template<class F1, class F2, class F3> friend class PersistentValueMap; | 313 template<class F1, class F2, class F3> friend class PersistentValueMap; |
| 395 template<class F1, class F2> friend class PersistentValueVector; | 314 template<class F1, class F2> friend class PersistentValueVector; |
| 396 | 315 |
| 397 template <class S> V8_INLINE Local(S* that) : Handle<T>(that) { } | 316 template <class S> |
| 317 V8_INLINE Local(S* that) | |
| 318 : val_(that) {} | |
| 398 V8_INLINE static Local<T> New(Isolate* isolate, T* that); | 319 V8_INLINE static Local<T> New(Isolate* isolate, T* that); |
| 320 | |
| 321 T* val_; | |
| 399 }; | 322 }; |
| 400 | 323 |
| 401 | 324 |
| 325 // Handle is a synonym for Local for historical reason. | |
| 326 template <class T> | |
| 327 using Handle = Local<T>; | |
| 328 | |
| 329 | |
| 402 // Eternal handles are set-once handles that live for the life of the isolate. | 330 // Eternal handles are set-once handles that live for the life of the isolate. |
| 403 template <class T> class Eternal { | 331 template <class T> class Eternal { |
| 404 public: | 332 public: |
| 405 V8_INLINE Eternal() : index_(kInitialValue) { } | 333 V8_INLINE Eternal() : index_(kInitialValue) { } |
| 406 template<class S> | 334 template<class S> |
| 407 V8_INLINE Eternal(Isolate* isolate, Local<S> handle) : index_(kInitialValue) { | 335 V8_INLINE Eternal(Isolate* isolate, Local<S> handle) : index_(kInitialValue) { |
| 408 Set(isolate, handle); | 336 Set(isolate, handle); |
| 409 } | 337 } |
| 410 // Can only be safely called if already set. | 338 // Can only be safely called if already set. |
| 411 V8_INLINE Local<T> Get(Isolate* isolate); | 339 V8_INLINE Local<T> Get(Isolate* isolate); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 | 484 |
| 557 /** | 485 /** |
| 558 * Returns the class ID previously assigned to this handle or 0 if no class ID | 486 * Returns the class ID previously assigned to this handle or 0 if no class ID |
| 559 * was previously assigned. | 487 * was previously assigned. |
| 560 */ | 488 */ |
| 561 V8_INLINE uint16_t WrapperClassId() const; | 489 V8_INLINE uint16_t WrapperClassId() const; |
| 562 | 490 |
| 563 private: | 491 private: |
| 564 friend class Isolate; | 492 friend class Isolate; |
| 565 friend class Utils; | 493 friend class Utils; |
| 566 template<class F> friend class Handle; | |
| 567 template<class F> friend class Local; | 494 template<class F> friend class Local; |
| 568 template<class F1, class F2> friend class Persistent; | 495 template<class F1, class F2> friend class Persistent; |
| 569 template<class F> friend class UniquePersistent; | 496 template<class F> friend class UniquePersistent; |
| 570 template<class F> friend class PersistentBase; | 497 template<class F> friend class PersistentBase; |
| 571 template<class F> friend class ReturnValue; | 498 template<class F> friend class ReturnValue; |
| 572 template<class F1, class F2, class F3> friend class PersistentValueMap; | 499 template<class F1, class F2, class F3> friend class PersistentValueMap; |
| 573 template<class F1, class F2> friend class PersistentValueVector; | 500 template<class F1, class F2> friend class PersistentValueVector; |
| 574 friend class Object; | 501 friend class Object; |
| 575 | 502 |
| 576 explicit V8_INLINE PersistentBase(T* val) : val_(val) {} | 503 explicit V8_INLINE PersistentBase(T* val) : val_(val) {} |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 697 } | 624 } |
| 698 | 625 |
| 699 // TODO(dcarney): this is pretty useless, fix or remove | 626 // TODO(dcarney): this is pretty useless, fix or remove |
| 700 template <class S> V8_INLINE Persistent<S>& As() { // NOLINT | 627 template <class S> V8_INLINE Persistent<S>& As() { // NOLINT |
| 701 return Persistent<S>::Cast(*this); | 628 return Persistent<S>::Cast(*this); |
| 702 } | 629 } |
| 703 | 630 |
| 704 private: | 631 private: |
| 705 friend class Isolate; | 632 friend class Isolate; |
| 706 friend class Utils; | 633 friend class Utils; |
| 707 template<class F> friend class Handle; | |
| 708 template<class F> friend class Local; | 634 template<class F> friend class Local; |
| 709 template<class F1, class F2> friend class Persistent; | 635 template<class F1, class F2> friend class Persistent; |
| 710 template<class F> friend class ReturnValue; | 636 template<class F> friend class ReturnValue; |
| 711 | 637 |
| 712 template <class S> V8_INLINE Persistent(S* that) : PersistentBase<T>(that) { } | 638 template <class S> V8_INLINE Persistent(S* that) : PersistentBase<T>(that) { } |
| 713 V8_INLINE T* operator*() const { return this->val_; } | 639 V8_INLINE T* operator*() const { return this->val_; } |
| 714 template<class S, class M2> | 640 template<class S, class M2> |
| 715 V8_INLINE void Copy(const Persistent<S, M2>& that); | 641 V8_INLINE void Copy(const Persistent<S, M2>& that); |
| 716 }; | 642 }; |
| 717 | 643 |
| (...skipping 4619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5337 typedef WeakCallbackData<Value, void>::Callback WeakCallback; | 5263 typedef WeakCallbackData<Value, void>::Callback WeakCallback; |
| 5338 static void MakeWeak(internal::Object** global_handle, | 5264 static void MakeWeak(internal::Object** global_handle, |
| 5339 void* data, | 5265 void* data, |
| 5340 WeakCallback weak_callback); | 5266 WeakCallback weak_callback); |
| 5341 static void* ClearWeak(internal::Object** global_handle); | 5267 static void* ClearWeak(internal::Object** global_handle); |
| 5342 static void Eternalize(Isolate* isolate, | 5268 static void Eternalize(Isolate* isolate, |
| 5343 Value* handle, | 5269 Value* handle, |
| 5344 int* index); | 5270 int* index); |
| 5345 static Local<Value> GetEternal(Isolate* isolate, int index); | 5271 static Local<Value> GetEternal(Isolate* isolate, int index); |
| 5346 | 5272 |
| 5347 template <class T> friend class Handle; | |
| 5348 template <class T> friend class Local; | 5273 template <class T> friend class Local; |
| 5349 template <class T> friend class Eternal; | 5274 template <class T> friend class Eternal; |
| 5350 template <class T> friend class PersistentBase; | 5275 template <class T> friend class PersistentBase; |
| 5351 template <class T, class M> friend class Persistent; | 5276 template <class T, class M> friend class Persistent; |
| 5352 friend class Context; | 5277 friend class Context; |
| 5353 }; | 5278 }; |
| 5354 | 5279 |
| 5355 | 5280 |
| 5356 /** | 5281 /** |
| 5357 * An external exception handler. | 5282 * An external exception handler. |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6059 int value_offset = | 5984 int value_offset = |
| 6060 I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index); | 5985 I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index); |
| 6061 return I::ReadField<T>(embedder_data, value_offset); | 5986 return I::ReadField<T>(embedder_data, value_offset); |
| 6062 } | 5987 } |
| 6063 }; | 5988 }; |
| 6064 | 5989 |
| 6065 } // namespace internal | 5990 } // namespace internal |
| 6066 | 5991 |
| 6067 | 5992 |
| 6068 template <class T> | 5993 template <class T> |
| 6069 Local<T>::Local() : Handle<T>() { } | 5994 Local<T> Local<T>::New(Isolate* isolate, Local<T> that) { |
| 6070 | |
| 6071 | |
| 6072 template <class T> | |
| 6073 Local<T> Local<T>::New(Isolate* isolate, Handle<T> that) { | |
| 6074 return New(isolate, that.val_); | 5995 return New(isolate, that.val_); |
| 6075 } | 5996 } |
| 6076 | 5997 |
| 6077 template <class T> | 5998 template <class T> |
| 6078 Local<T> Local<T>::New(Isolate* isolate, const PersistentBase<T>& that) { | 5999 Local<T> Local<T>::New(Isolate* isolate, const PersistentBase<T>& that) { |
| 6079 return New(isolate, that.val_); | 6000 return New(isolate, that.val_); |
| 6080 } | 6001 } |
| 6081 | 6002 |
| 6082 template <class T> | |
| 6083 Handle<T> Handle<T>::New(Isolate* isolate, T* that) { | |
| 6084 if (that == NULL) return Handle<T>(); | |
| 6085 T* that_ptr = that; | |
| 6086 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); | |
| 6087 return Handle<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( | |
| 6088 reinterpret_cast<internal::Isolate*>(isolate), *p))); | |
| 6089 } | |
| 6090 | |
| 6091 | 6003 |
| 6092 template <class T> | 6004 template <class T> |
| 6093 Local<T> Local<T>::New(Isolate* isolate, T* that) { | 6005 Local<T> Local<T>::New(Isolate* isolate, T* that) { |
| 6094 if (that == NULL) return Local<T>(); | 6006 if (that == NULL) return Local<T>(); |
| 6095 T* that_ptr = that; | 6007 T* that_ptr = that; |
| 6096 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); | 6008 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); |
| 6097 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( | 6009 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( |
| 6098 reinterpret_cast<internal::Isolate*>(isolate), *p))); | 6010 reinterpret_cast<internal::Isolate*>(isolate), *p))); |
| 6099 } | 6011 } |
| 6100 | 6012 |
| (...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7088 */ | 7000 */ |
| 7089 | 7001 |
| 7090 | 7002 |
| 7091 } // namespace v8 | 7003 } // namespace v8 |
| 7092 | 7004 |
| 7093 | 7005 |
| 7094 #undef TYPE_CHECK | 7006 #undef TYPE_CHECK |
| 7095 | 7007 |
| 7096 | 7008 |
| 7097 #endif // V8_H_ | 7009 #endif // V8_H_ |
| OLD | NEW |