| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 */ | 36 */ |
| 37 | 37 |
| 38 #ifndef V8_H_ | 38 #ifndef V8_H_ |
| 39 #define V8_H_ | 39 #define V8_H_ |
| 40 | 40 |
| 41 #include "v8stdint.h" | 41 #include "v8stdint.h" |
| 42 | 42 |
| 43 // We reserve the V8_* prefix for macros defined in V8 public API and | 43 // We reserve the V8_* prefix for macros defined in V8 public API and |
| 44 // assume there are no name conflicts with the embedder's code. | 44 // assume there are no name conflicts with the embedder's code. |
| 45 | 45 |
| 46 #ifdef _WIN32 | 46 #ifdef V8_OS_WIN |
| 47 | 47 |
| 48 // Setup for Windows DLL export/import. When building the V8 DLL the | 48 // Setup for Windows DLL export/import. When building the V8 DLL the |
| 49 // BUILDING_V8_SHARED needs to be defined. When building a program which uses | 49 // BUILDING_V8_SHARED needs to be defined. When building a program which uses |
| 50 // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8 | 50 // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8 |
| 51 // static library or building a program which uses the V8 static library neither | 51 // static library or building a program which uses the V8 static library neither |
| 52 // BUILDING_V8_SHARED nor USING_V8_SHARED should be defined. | 52 // BUILDING_V8_SHARED nor USING_V8_SHARED should be defined. |
| 53 #if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED) | 53 #if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED) |
| 54 #error both BUILDING_V8_SHARED and USING_V8_SHARED are set - please check the\ | 54 #error both BUILDING_V8_SHARED and USING_V8_SHARED are set - please check the\ |
| 55 build configuration to ensure that at most one of these is set | 55 build configuration to ensure that at most one of these is set |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 #ifdef BUILDING_V8_SHARED | 58 #ifdef BUILDING_V8_SHARED |
| 59 #define V8_EXPORT __declspec(dllexport) | 59 # define V8_EXPORT __declspec(dllexport) |
| 60 #elif USING_V8_SHARED | 60 #elif USING_V8_SHARED |
| 61 #define V8_EXPORT __declspec(dllimport) | 61 # define V8_EXPORT __declspec(dllimport) |
| 62 #else | 62 #else |
| 63 #define V8_EXPORT | 63 # define V8_EXPORT |
| 64 #endif // BUILDING_V8_SHARED | 64 #endif // BUILDING_V8_SHARED |
| 65 | 65 |
| 66 #else // _WIN32 | 66 #else // V8_OS_WIN |
| 67 | 67 |
| 68 // Setup for Linux shared library export. | 68 // Setup for Linux shared library export. |
| 69 #if defined(__GNUC__) && ((__GNUC__ >= 4) || \ | 69 #if V8_HAS_ATTRIBUTE_VISIBILITY && defined(V8_SHARED) |
| 70 (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(V8_SHARED) | 70 # ifdef BUILDING_V8_SHARED |
| 71 #ifdef BUILDING_V8_SHARED | 71 # define V8_EXPORT __attribute__ ((visibility("default"))) |
| 72 #define V8_EXPORT __attribute__ ((visibility("default"))) | 72 # else |
| 73 # define V8_EXPORT |
| 74 # endif |
| 73 #else | 75 #else |
| 74 #define V8_EXPORT | 76 # define V8_EXPORT |
| 75 #endif | |
| 76 #else | |
| 77 #define V8_EXPORT | |
| 78 #endif | 77 #endif |
| 79 | 78 |
| 80 #endif // _WIN32 | 79 #endif // V8_OS_WIN |
| 81 | |
| 82 #if defined(__GNUC__) && !defined(DEBUG) | |
| 83 #define V8_INLINE(declarator) inline __attribute__((always_inline)) declarator | |
| 84 #elif defined(_MSC_VER) && !defined(DEBUG) | |
| 85 #define V8_INLINE(declarator) __forceinline declarator | |
| 86 #else | |
| 87 #define V8_INLINE(declarator) inline declarator | |
| 88 #endif | |
| 89 | |
| 90 #if defined(__GNUC__) && !V8_DISABLE_DEPRECATIONS | |
| 91 #define V8_DEPRECATED(declarator) declarator __attribute__ ((deprecated)) | |
| 92 #elif defined(_MSC_VER) && !V8_DISABLE_DEPRECATIONS | |
| 93 #define V8_DEPRECATED(declarator) __declspec(deprecated) declarator | |
| 94 #else | |
| 95 #define V8_DEPRECATED(declarator) declarator | |
| 96 #endif | |
| 97 | |
| 98 #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) | |
| 99 #define V8_UNLIKELY(condition) __builtin_expect((condition), 0) | |
| 100 #define V8_LIKELY(condition) __builtin_expect((condition), 1) | |
| 101 #else | |
| 102 #define V8_UNLIKELY(condition) (condition) | |
| 103 #define V8_LIKELY(condition) (condition) | |
| 104 #endif | |
| 105 | 80 |
| 106 /** | 81 /** |
| 107 * The v8 JavaScript engine. | 82 * The v8 JavaScript engine. |
| 108 */ | 83 */ |
| 109 namespace v8 { | 84 namespace v8 { |
| 110 | 85 |
| 111 class AccessorInfo; | |
| 112 class AccessorSignature; | 86 class AccessorSignature; |
| 113 class Array; | 87 class Array; |
| 114 class Boolean; | 88 class Boolean; |
| 115 class BooleanObject; | 89 class BooleanObject; |
| 116 class Context; | 90 class Context; |
| 117 class CpuProfiler; | 91 class CpuProfiler; |
| 118 class Data; | 92 class Data; |
| 119 class Date; | 93 class Date; |
| 120 class DeclaredAccessorDescriptor; | 94 class DeclaredAccessorDescriptor; |
| 121 class External; | 95 class External; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 138 class StackTrace; | 112 class StackTrace; |
| 139 class String; | 113 class String; |
| 140 class StringObject; | 114 class StringObject; |
| 141 class Symbol; | 115 class Symbol; |
| 142 class SymbolObject; | 116 class SymbolObject; |
| 143 class Uint32; | 117 class Uint32; |
| 144 class Utils; | 118 class Utils; |
| 145 class Value; | 119 class Value; |
| 146 template <class T> class Handle; | 120 template <class T> class Handle; |
| 147 template <class T> class Local; | 121 template <class T> class Local; |
| 122 template <class T> class Eternal; |
| 148 template <class T> class Persistent; | 123 template <class T> class Persistent; |
| 149 class FunctionTemplate; | 124 class FunctionTemplate; |
| 150 class ObjectTemplate; | 125 class ObjectTemplate; |
| 151 class Data; | 126 class Data; |
| 152 class AccessorInfo; | |
| 153 template<typename T> class PropertyCallbackInfo; | 127 template<typename T> class PropertyCallbackInfo; |
| 154 class StackTrace; | 128 class StackTrace; |
| 155 class StackFrame; | 129 class StackFrame; |
| 156 class Isolate; | 130 class Isolate; |
| 157 class DeclaredAccessorDescriptor; | 131 class DeclaredAccessorDescriptor; |
| 158 class ObjectOperationDescriptor; | 132 class ObjectOperationDescriptor; |
| 159 class RawOperationDescriptor; | 133 class RawOperationDescriptor; |
| 160 class CallHandlerHelper; | 134 class CallHandlerHelper; |
| 161 | 135 |
| 162 namespace internal { | 136 namespace internal { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 V8_INLINE(T* operator->() const) { return val_; } | 270 V8_INLINE(T* operator->() const) { return val_; } |
| 297 | 271 |
| 298 V8_INLINE(T* operator*() const) { return val_; } | 272 V8_INLINE(T* operator*() const) { return val_; } |
| 299 | 273 |
| 300 /** | 274 /** |
| 301 * Checks whether two handles are the same. | 275 * Checks whether two handles are the same. |
| 302 * Returns true if both are empty, or if the objects | 276 * Returns true if both are empty, or if the objects |
| 303 * to which they refer are identical. | 277 * to which they refer are identical. |
| 304 * The handles' references are not checked. | 278 * The handles' references are not checked. |
| 305 */ | 279 */ |
| 306 template <class S> V8_INLINE(bool operator==(const Handle<S> that) const) { | 280 template <class S> V8_INLINE(bool operator==(const Handle<S>& that) const) { |
| 307 internal::Object** a = reinterpret_cast<internal::Object**>(**this); | 281 internal::Object** a = reinterpret_cast<internal::Object**>(**this); |
| 308 internal::Object** b = reinterpret_cast<internal::Object**>(*that); | 282 internal::Object** b = reinterpret_cast<internal::Object**>(*that); |
| 309 if (a == 0) return b == 0; | 283 if (a == 0) return b == 0; |
| 310 if (b == 0) return false; | 284 if (b == 0) return false; |
| 311 return *a == *b; | 285 return *a == *b; |
| 312 } | 286 } |
| 313 | 287 |
| 314 #ifndef V8_USE_UNSAFE_HANDLES | 288 #ifndef V8_USE_UNSAFE_HANDLES |
| 315 template <class S> V8_INLINE( | 289 template <class S> V8_INLINE( |
| 316 bool operator==(const Persistent<S>& that) const) { | 290 bool operator==(const Persistent<S>& that) const) { |
| 317 internal::Object** a = reinterpret_cast<internal::Object**>(**this); | 291 internal::Object** a = reinterpret_cast<internal::Object**>(**this); |
| 318 internal::Object** b = reinterpret_cast<internal::Object**>(*that); | 292 internal::Object** b = reinterpret_cast<internal::Object**>(*that); |
| 319 if (a == 0) return b == 0; | 293 if (a == 0) return b == 0; |
| 320 if (b == 0) return false; | 294 if (b == 0) return false; |
| 321 return *a == *b; | 295 return *a == *b; |
| 322 } | 296 } |
| 323 #endif | 297 #endif |
| 324 | 298 |
| 325 /** | 299 /** |
| 326 * Checks whether two handles are different. | 300 * Checks whether two handles are different. |
| 327 * Returns true if only one of the handles is empty, or if | 301 * Returns true if only one of the handles is empty, or if |
| 328 * the objects to which they refer are different. | 302 * the objects to which they refer are different. |
| 329 * The handles' references are not checked. | 303 * The handles' references are not checked. |
| 330 */ | 304 */ |
| 331 template <class S> V8_INLINE(bool operator!=(Handle<S> that) const) { | 305 template <class S> V8_INLINE(bool operator!=(const Handle<S>& that) const) { |
| 332 return !operator==(that); | 306 return !operator==(that); |
| 333 } | 307 } |
| 334 | 308 |
| 309 #ifndef V8_USE_UNSAFE_HANDLES |
| 310 template <class S> V8_INLINE( |
| 311 bool operator!=(const Persistent<S>& that) const) { |
| 312 return !operator==(that); |
| 313 } |
| 314 #endif |
| 315 |
| 335 template <class S> V8_INLINE(static Handle<T> Cast(Handle<S> that)) { | 316 template <class S> V8_INLINE(static Handle<T> Cast(Handle<S> that)) { |
| 336 #ifdef V8_ENABLE_CHECKS | 317 #ifdef V8_ENABLE_CHECKS |
| 337 // If we're going to perform the type check then we have to check | 318 // If we're going to perform the type check then we have to check |
| 338 // that the handle isn't empty before doing the checked cast. | 319 // that the handle isn't empty before doing the checked cast. |
| 339 if (that.IsEmpty()) return Handle<T>(); | 320 if (that.IsEmpty()) return Handle<T>(); |
| 340 #endif | 321 #endif |
| 341 return Handle<T>(T::Cast(*that)); | 322 return Handle<T>(T::Cast(*that)); |
| 342 } | 323 } |
| 343 | 324 |
| 344 template <class S> V8_INLINE(Handle<S> As()) { | 325 template <class S> V8_INLINE(Handle<S> As()) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 361 /** | 342 /** |
| 362 * Creates a new handle for the specified value. | 343 * Creates a new handle for the specified value. |
| 363 */ | 344 */ |
| 364 V8_INLINE(explicit Handle(T* val)) : val_(val) {} | 345 V8_INLINE(explicit Handle(T* val)) : val_(val) {} |
| 365 #endif | 346 #endif |
| 366 | 347 |
| 367 private: | 348 private: |
| 368 friend class Utils; | 349 friend class Utils; |
| 369 template<class F> friend class Persistent; | 350 template<class F> friend class Persistent; |
| 370 template<class F> friend class Local; | 351 template<class F> friend class Local; |
| 371 friend class Arguments; | |
| 372 template<class F> friend class FunctionCallbackInfo; | 352 template<class F> friend class FunctionCallbackInfo; |
| 373 template<class F> friend class PropertyCallbackInfo; | 353 template<class F> friend class PropertyCallbackInfo; |
| 374 template<class F> friend class internal::CustomArguments; | 354 template<class F> friend class internal::CustomArguments; |
| 375 friend class AccessorInfo; | |
| 376 friend Handle<Primitive> Undefined(Isolate* isolate); | 355 friend Handle<Primitive> Undefined(Isolate* isolate); |
| 377 friend Handle<Primitive> Null(Isolate* isolate); | 356 friend Handle<Primitive> Null(Isolate* isolate); |
| 378 friend Handle<Boolean> True(Isolate* isolate); | 357 friend Handle<Boolean> True(Isolate* isolate); |
| 379 friend Handle<Boolean> False(Isolate* isolate); | 358 friend Handle<Boolean> False(Isolate* isolate); |
| 380 friend class Context; | 359 friend class Context; |
| 381 friend class HandleScope; | 360 friend class HandleScope; |
| 382 | 361 |
| 383 #ifndef V8_USE_UNSAFE_HANDLES | 362 #ifndef V8_USE_UNSAFE_HANDLES |
| 384 V8_INLINE(static Handle<T> New(Isolate* isolate, T* that)); | 363 V8_INLINE(static Handle<T> New(Isolate* isolate, T* that)); |
| 385 #endif | 364 #endif |
| 386 | 365 |
| 387 T* val_; | 366 T* val_; |
| 388 }; | 367 }; |
| 389 | 368 |
| 390 | 369 |
| 391 // A value which will never be returned by Local::Eternalize | |
| 392 // Useful for static initialization | |
| 393 const int kUninitializedEternalIndex = -1; | |
| 394 | |
| 395 | |
| 396 /** | 370 /** |
| 397 * A light-weight stack-allocated object handle. All operations | 371 * A light-weight stack-allocated object handle. All operations |
| 398 * that return objects from within v8 return them in local handles. They | 372 * that return objects from within v8 return them in local handles. They |
| 399 * are created within HandleScopes, and all local handles allocated within a | 373 * are created within HandleScopes, and all local handles allocated within a |
| 400 * handle scope are destroyed when the handle scope is destroyed. Hence it | 374 * handle scope are destroyed when the handle scope is destroyed. Hence it |
| 401 * is not necessary to explicitly deallocate local handles. | 375 * is not necessary to explicitly deallocate local handles. |
| 402 */ | 376 */ |
| 403 // TODO(dcarney): deprecate entire class | 377 // TODO(dcarney): deprecate entire class |
| 404 template <class T> class Local : public Handle<T> { | 378 template <class T> class Local : public Handle<T> { |
| 405 public: | 379 public: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 431 template <class S> V8_INLINE(Local(Handle<S> that)) | 405 template <class S> V8_INLINE(Local(Handle<S> that)) |
| 432 : Handle<T>(reinterpret_cast<T*>(*that)) { | 406 : Handle<T>(reinterpret_cast<T*>(*that)) { |
| 433 TYPE_CHECK(T, S); | 407 TYPE_CHECK(T, S); |
| 434 } | 408 } |
| 435 #endif | 409 #endif |
| 436 | 410 |
| 437 template <class S> V8_INLINE(Local<S> As()) { | 411 template <class S> V8_INLINE(Local<S> As()) { |
| 438 return Local<S>::Cast(*this); | 412 return Local<S>::Cast(*this); |
| 439 } | 413 } |
| 440 | 414 |
| 441 // Keep this Local alive for the lifetime of the Isolate. | |
| 442 // It remains retrievable via the returned index, | |
| 443 V8_INLINE(int Eternalize(Isolate* isolate)); | |
| 444 V8_INLINE(static Local<T> GetEternal(Isolate* isolate, int index)); | |
| 445 | |
| 446 /** | 415 /** |
| 447 * Create a local handle for the content of another handle. | 416 * Create a local handle for the content of another handle. |
| 448 * The referee is kept alive by the local handle even when | 417 * The referee is kept alive by the local handle even when |
| 449 * the original handle is destroyed/disposed. | 418 * the original handle is destroyed/disposed. |
| 450 */ | 419 */ |
| 451 V8_INLINE(static Local<T> New(Handle<T> that)); | 420 V8_INLINE(static Local<T> New(Handle<T> that)); |
| 452 V8_INLINE(static Local<T> New(Isolate* isolate, Handle<T> that)); | 421 V8_INLINE(static Local<T> New(Isolate* isolate, Handle<T> that)); |
| 453 #ifndef V8_USE_UNSAFE_HANDLES | 422 #ifndef V8_USE_UNSAFE_HANDLES |
| 454 // TODO(dcarney): remove before cutover | 423 // TODO(dcarney): remove before cutover |
| 455 V8_INLINE(static Local<T> New(Isolate* isolate, const Persistent<T>& that)); | 424 V8_INLINE(static Local<T> New(Isolate* isolate, const Persistent<T>& that)); |
| 456 | 425 |
| 457 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR | 426 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR |
| 458 | 427 |
| 459 private: | 428 private: |
| 460 #endif | 429 #endif |
| 461 template <class S> V8_INLINE(Local(S* that) : Handle<T>(that)) { } | 430 template <class S> V8_INLINE(Local(S* that) : Handle<T>(that)) { } |
| 462 #endif | 431 #endif |
| 463 | 432 |
| 464 private: | 433 private: |
| 465 friend class Utils; | 434 friend class Utils; |
| 435 template<class F> friend class Eternal; |
| 466 template<class F> friend class Persistent; | 436 template<class F> friend class Persistent; |
| 467 template<class F> friend class Handle; | 437 template<class F> friend class Handle; |
| 468 friend class Arguments; | |
| 469 template<class F> friend class FunctionCallbackInfo; | 438 template<class F> friend class FunctionCallbackInfo; |
| 470 template<class F> friend class PropertyCallbackInfo; | 439 template<class F> friend class PropertyCallbackInfo; |
| 471 friend class String; | 440 friend class String; |
| 472 friend class Object; | 441 friend class Object; |
| 473 friend class AccessorInfo; | |
| 474 friend class Context; | 442 friend class Context; |
| 475 template<class F> friend class internal::CustomArguments; | 443 template<class F> friend class internal::CustomArguments; |
| 476 friend class HandleScope; | 444 friend class HandleScope; |
| 477 | 445 |
| 478 V8_INLINE(static Local<T> New(Isolate* isolate, T* that)); | 446 V8_INLINE(static Local<T> New(Isolate* isolate, T* that)); |
| 479 }; | 447 }; |
| 480 | 448 |
| 449 |
| 450 // Eternal handles are set-once handles that live for the life of the isolate. |
| 451 template <class T> class Eternal { |
| 452 public: |
| 453 V8_INLINE(Eternal()) : index_(kInitialValue) { } |
| 454 template<class S> |
| 455 V8_INLINE(Eternal(Isolate* isolate, Local<S> handle)) |
| 456 : index_(kInitialValue) { |
| 457 Set(isolate, handle); |
| 458 } |
| 459 // Can only be safely called if already set. |
| 460 V8_INLINE(Local<T> Get(Isolate* isolate)); |
| 461 V8_INLINE(bool IsEmpty()) { return index_ != kInitialValue; } |
| 462 template<class S> |
| 463 V8_INLINE(void Set(Isolate* isolate, Local<S> handle)); |
| 464 |
| 465 private: |
| 466 static const int kInitialValue = -1; |
| 467 int index_; |
| 468 }; |
| 469 |
| 470 |
| 481 /** | 471 /** |
| 482 * An object reference that is independent of any handle scope. Where | 472 * An object reference that is independent of any handle scope. Where |
| 483 * a Local handle only lives as long as the HandleScope in which it was | 473 * a Local handle only lives as long as the HandleScope in which it was |
| 484 * allocated, a Persistent handle remains valid until it is explicitly | 474 * allocated, a Persistent handle remains valid until it is explicitly |
| 485 * disposed. | 475 * disposed. |
| 486 * | 476 * |
| 487 * A persistent handle contains a reference to a storage cell within | 477 * A persistent handle contains a reference to a storage cell within |
| 488 * the v8 engine which holds an object value and which is updated by | 478 * the v8 engine which holds an object value and which is updated by |
| 489 * the garbage collector whenever the object is moved. A new storage | 479 * the garbage collector whenever the object is moved. A new storage |
| 490 * cell can be created using Persistent::New and existing handles can | 480 * cell can be created using Persistent::New and existing handles can |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 #ifndef V8_USE_UNSAFE_HANDLES | 601 #ifndef V8_USE_UNSAFE_HANDLES |
| 612 template <class S> V8_INLINE( | 602 template <class S> V8_INLINE( |
| 613 bool operator==(const Persistent<S>& that) const) { | 603 bool operator==(const Persistent<S>& that) const) { |
| 614 internal::Object** a = reinterpret_cast<internal::Object**>(**this); | 604 internal::Object** a = reinterpret_cast<internal::Object**>(**this); |
| 615 internal::Object** b = reinterpret_cast<internal::Object**>(*that); | 605 internal::Object** b = reinterpret_cast<internal::Object**>(*that); |
| 616 if (a == 0) return b == 0; | 606 if (a == 0) return b == 0; |
| 617 if (b == 0) return false; | 607 if (b == 0) return false; |
| 618 return *a == *b; | 608 return *a == *b; |
| 619 } | 609 } |
| 620 | 610 |
| 621 template <class S> V8_INLINE(bool operator==(const Handle<S> that) const) { | 611 template <class S> V8_INLINE(bool operator==(const Handle<S>& that) const) { |
| 622 internal::Object** a = reinterpret_cast<internal::Object**>(**this); | 612 internal::Object** a = reinterpret_cast<internal::Object**>(**this); |
| 623 internal::Object** b = reinterpret_cast<internal::Object**>(*that); | 613 internal::Object** b = reinterpret_cast<internal::Object**>(*that); |
| 624 if (a == 0) return b == 0; | 614 if (a == 0) return b == 0; |
| 625 if (b == 0) return false; | 615 if (b == 0) return false; |
| 626 return *a == *b; | 616 return *a == *b; |
| 627 } | 617 } |
| 618 |
| 619 template <class S> V8_INLINE( |
| 620 bool operator!=(const Persistent<S>& that) const) { |
| 621 return !operator==(that); |
| 622 } |
| 623 |
| 624 template <class S> V8_INLINE(bool operator!=(const Handle<S>& that) const) { |
| 625 return !operator==(that); |
| 626 } |
| 628 #endif | 627 #endif |
| 629 | 628 |
| 630 V8_INLINE(void Dispose()); | 629 V8_INLINE(void Dispose()); |
| 631 | 630 |
| 632 /** | 631 /** |
| 633 * Releases the storage cell referenced by this persistent handle. | 632 * Releases the storage cell referenced by this persistent handle. |
| 634 * Does not remove the reference to the cell from any handles. | 633 * Does not remove the reference to the cell from any handles. |
| 635 * This handle's reference, and any other references to the storage | 634 * This handle's reference, and any other references to the storage |
| 636 * cell remain and IsEmpty will still return false. | 635 * cell remain and IsEmpty will still return false. |
| 637 */ | 636 */ |
| (...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2023 kExternalFloatArray, | 2022 kExternalFloatArray, |
| 2024 kExternalDoubleArray, | 2023 kExternalDoubleArray, |
| 2025 kExternalPixelArray | 2024 kExternalPixelArray |
| 2026 }; | 2025 }; |
| 2027 | 2026 |
| 2028 /** | 2027 /** |
| 2029 * Accessor[Getter|Setter] are used as callback functions when | 2028 * Accessor[Getter|Setter] are used as callback functions when |
| 2030 * setting|getting a particular property. See Object and ObjectTemplate's | 2029 * setting|getting a particular property. See Object and ObjectTemplate's |
| 2031 * method SetAccessor. | 2030 * method SetAccessor. |
| 2032 */ | 2031 */ |
| 2033 typedef Handle<Value> (*AccessorGetter)(Local<String> property, | |
| 2034 const AccessorInfo& info); | |
| 2035 typedef void (*AccessorGetterCallback)( | 2032 typedef void (*AccessorGetterCallback)( |
| 2036 Local<String> property, | 2033 Local<String> property, |
| 2037 const PropertyCallbackInfo<Value>& info); | 2034 const PropertyCallbackInfo<Value>& info); |
| 2038 | 2035 |
| 2039 | 2036 |
| 2040 typedef void (*AccessorSetter)(Local<String> property, | |
| 2041 Local<Value> value, | |
| 2042 const AccessorInfo& info); | |
| 2043 typedef void (*AccessorSetterCallback)( | 2037 typedef void (*AccessorSetterCallback)( |
| 2044 Local<String> property, | 2038 Local<String> property, |
| 2045 Local<Value> value, | 2039 Local<Value> value, |
| 2046 const PropertyCallbackInfo<void>& info); | 2040 const PropertyCallbackInfo<void>& info); |
| 2047 | 2041 |
| 2048 | 2042 |
| 2049 /** | 2043 /** |
| 2050 * Access control specifications. | 2044 * Access control specifications. |
| 2051 * | 2045 * |
| 2052 * Some accessors should be accessible across contexts. These | 2046 * Some accessors should be accessible across contexts. These |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2106 bool Delete(Handle<Value> key); | 2100 bool Delete(Handle<Value> key); |
| 2107 | 2101 |
| 2108 // Delete a property on this object bypassing interceptors and | 2102 // Delete a property on this object bypassing interceptors and |
| 2109 // ignoring dont-delete attributes. | 2103 // ignoring dont-delete attributes. |
| 2110 bool ForceDelete(Handle<Value> key); | 2104 bool ForceDelete(Handle<Value> key); |
| 2111 | 2105 |
| 2112 bool Has(uint32_t index); | 2106 bool Has(uint32_t index); |
| 2113 | 2107 |
| 2114 bool Delete(uint32_t index); | 2108 bool Delete(uint32_t index); |
| 2115 | 2109 |
| 2116 V8_DEPRECATED(bool SetAccessor(Handle<String> name, | |
| 2117 AccessorGetter getter, | |
| 2118 AccessorSetter setter = 0, | |
| 2119 Handle<Value> data = Handle<Value>(), | |
| 2120 AccessControl settings = DEFAULT, | |
| 2121 PropertyAttribute attribute = None)); | |
| 2122 bool SetAccessor(Handle<String> name, | 2110 bool SetAccessor(Handle<String> name, |
| 2123 AccessorGetterCallback getter, | 2111 AccessorGetterCallback getter, |
| 2124 AccessorSetterCallback setter = 0, | 2112 AccessorSetterCallback setter = 0, |
| 2125 Handle<Value> data = Handle<Value>(), | 2113 Handle<Value> data = Handle<Value>(), |
| 2126 AccessControl settings = DEFAULT, | 2114 AccessControl settings = DEFAULT, |
| 2127 PropertyAttribute attribute = None); | 2115 PropertyAttribute attribute = None); |
| 2128 | 2116 |
| 2129 // This function is not yet stable and should not be used at this time. | 2117 // This function is not yet stable and should not be used at this time. |
| 2130 bool SetAccessor(Handle<String> name, | 2118 bool SetAccessor(Handle<String> name, |
| 2131 Handle<DeclaredAccessorDescriptor> descriptor, | 2119 Handle<DeclaredAccessorDescriptor> descriptor, |
| (...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2970 | 2958 |
| 2971 /** | 2959 /** |
| 2972 * The superclass of object and function templates. | 2960 * The superclass of object and function templates. |
| 2973 */ | 2961 */ |
| 2974 class V8_EXPORT Template : public Data { | 2962 class V8_EXPORT Template : public Data { |
| 2975 public: | 2963 public: |
| 2976 /** Adds a property to each instance created by this template.*/ | 2964 /** Adds a property to each instance created by this template.*/ |
| 2977 void Set(Handle<String> name, Handle<Data> value, | 2965 void Set(Handle<String> name, Handle<Data> value, |
| 2978 PropertyAttribute attributes = None); | 2966 PropertyAttribute attributes = None); |
| 2979 V8_INLINE(void Set(const char* name, Handle<Data> value)); | 2967 V8_INLINE(void Set(const char* name, Handle<Data> value)); |
| 2968 |
| 2969 void SetAccessorProperty( |
| 2970 Local<String> name, |
| 2971 Local<FunctionTemplate> getter = Local<FunctionTemplate>(), |
| 2972 Local<FunctionTemplate> setter = Local<FunctionTemplate>(), |
| 2973 PropertyAttribute attribute = None, |
| 2974 AccessControl settings = DEFAULT); |
| 2975 |
| 2980 private: | 2976 private: |
| 2981 Template(); | 2977 Template(); |
| 2982 | 2978 |
| 2983 friend class ObjectTemplate; | 2979 friend class ObjectTemplate; |
| 2984 friend class FunctionTemplate; | 2980 friend class FunctionTemplate; |
| 2985 }; | 2981 }; |
| 2986 | 2982 |
| 2987 | 2983 |
| 2988 template<typename T> | 2984 template<typename T> |
| 2989 class ReturnValue { | 2985 class ReturnValue { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3052 internal::Object** values, | 3048 internal::Object** values, |
| 3053 int length, | 3049 int length, |
| 3054 bool is_construct_call)); | 3050 bool is_construct_call)); |
| 3055 internal::Object** implicit_args_; | 3051 internal::Object** implicit_args_; |
| 3056 internal::Object** values_; | 3052 internal::Object** values_; |
| 3057 int length_; | 3053 int length_; |
| 3058 bool is_construct_call_; | 3054 bool is_construct_call_; |
| 3059 }; | 3055 }; |
| 3060 | 3056 |
| 3061 | 3057 |
| 3062 class V8_EXPORT Arguments : public FunctionCallbackInfo<Value> { | |
| 3063 private: | |
| 3064 friend class internal::FunctionCallbackArguments; | |
| 3065 V8_INLINE(Arguments(internal::Object** implicit_args, | |
| 3066 internal::Object** values, | |
| 3067 int length, | |
| 3068 bool is_construct_call)); | |
| 3069 }; | |
| 3070 | |
| 3071 /** | 3058 /** |
| 3072 * The information passed to a property callback about the context | 3059 * The information passed to a property callback about the context |
| 3073 * of the property access. | 3060 * of the property access. |
| 3074 */ | 3061 */ |
| 3075 template<typename T> | 3062 template<typename T> |
| 3076 class PropertyCallbackInfo { | 3063 class PropertyCallbackInfo { |
| 3077 public: | 3064 public: |
| 3078 V8_INLINE(Isolate* GetIsolate() const); | 3065 V8_INLINE(Isolate* GetIsolate() const); |
| 3079 V8_INLINE(Local<Value> Data() const); | 3066 V8_INLINE(Local<Value> Data() const); |
| 3080 V8_INLINE(Local<Object> This() const); | 3067 V8_INLINE(Local<Object> This() const); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3093 static const int kReturnValueIndex = -3; | 3080 static const int kReturnValueIndex = -3; |
| 3094 static const int kReturnValueDefaultValueIndex = -4; | 3081 static const int kReturnValueDefaultValueIndex = -4; |
| 3095 static const int kIsolateIndex = -5; | 3082 static const int kIsolateIndex = -5; |
| 3096 | 3083 |
| 3097 V8_INLINE(PropertyCallbackInfo(internal::Object** args)) | 3084 V8_INLINE(PropertyCallbackInfo(internal::Object** args)) |
| 3098 : args_(args) { } | 3085 : args_(args) { } |
| 3099 internal::Object** args_; | 3086 internal::Object** args_; |
| 3100 }; | 3087 }; |
| 3101 | 3088 |
| 3102 | 3089 |
| 3103 class V8_EXPORT AccessorInfo : public PropertyCallbackInfo<Value> { | |
| 3104 private: | |
| 3105 friend class internal::PropertyCallbackArguments; | |
| 3106 V8_INLINE(AccessorInfo(internal::Object** args)) | |
| 3107 : PropertyCallbackInfo<Value>(args) { } | |
| 3108 }; | |
| 3109 | |
| 3110 | |
| 3111 typedef Handle<Value> (*InvocationCallback)(const Arguments& args); | |
| 3112 typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info); | 3090 typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info); |
| 3113 | 3091 |
| 3114 /** | 3092 /** |
| 3115 * NamedProperty[Getter|Setter] are used as interceptors on object. | 3093 * NamedProperty[Getter|Setter] are used as interceptors on object. |
| 3116 * See ObjectTemplate::SetNamedPropertyHandler. | 3094 * See ObjectTemplate::SetNamedPropertyHandler. |
| 3117 */ | 3095 */ |
| 3118 typedef Handle<Value> (*NamedPropertyGetter)(Local<String> property, | |
| 3119 const AccessorInfo& info); | |
| 3120 typedef void (*NamedPropertyGetterCallback)( | 3096 typedef void (*NamedPropertyGetterCallback)( |
| 3121 Local<String> property, | 3097 Local<String> property, |
| 3122 const PropertyCallbackInfo<Value>& info); | 3098 const PropertyCallbackInfo<Value>& info); |
| 3123 | 3099 |
| 3124 | 3100 |
| 3125 /** | 3101 /** |
| 3126 * Returns the value if the setter intercepts the request. | 3102 * Returns the value if the setter intercepts the request. |
| 3127 * Otherwise, returns an empty handle. | 3103 * Otherwise, returns an empty handle. |
| 3128 */ | 3104 */ |
| 3129 typedef Handle<Value> (*NamedPropertySetter)(Local<String> property, | |
| 3130 Local<Value> value, | |
| 3131 const AccessorInfo& info); | |
| 3132 typedef void (*NamedPropertySetterCallback)( | 3105 typedef void (*NamedPropertySetterCallback)( |
| 3133 Local<String> property, | 3106 Local<String> property, |
| 3134 Local<Value> value, | 3107 Local<Value> value, |
| 3135 const PropertyCallbackInfo<Value>& info); | 3108 const PropertyCallbackInfo<Value>& info); |
| 3136 | 3109 |
| 3137 | 3110 |
| 3138 /** | 3111 /** |
| 3139 * Returns a non-empty handle if the interceptor intercepts the request. | 3112 * Returns a non-empty handle if the interceptor intercepts the request. |
| 3140 * The result is an integer encoding property attributes (like v8::None, | 3113 * The result is an integer encoding property attributes (like v8::None, |
| 3141 * v8::DontEnum, etc.) | 3114 * v8::DontEnum, etc.) |
| 3142 */ | 3115 */ |
| 3143 typedef Handle<Integer> (*NamedPropertyQuery)(Local<String> property, | |
| 3144 const AccessorInfo& info); | |
| 3145 typedef void (*NamedPropertyQueryCallback)( | 3116 typedef void (*NamedPropertyQueryCallback)( |
| 3146 Local<String> property, | 3117 Local<String> property, |
| 3147 const PropertyCallbackInfo<Integer>& info); | 3118 const PropertyCallbackInfo<Integer>& info); |
| 3148 | 3119 |
| 3149 | 3120 |
| 3150 /** | 3121 /** |
| 3151 * Returns a non-empty handle if the deleter intercepts the request. | 3122 * Returns a non-empty handle if the deleter intercepts the request. |
| 3152 * The return value is true if the property could be deleted and false | 3123 * The return value is true if the property could be deleted and false |
| 3153 * otherwise. | 3124 * otherwise. |
| 3154 */ | 3125 */ |
| 3155 typedef Handle<Boolean> (*NamedPropertyDeleter)(Local<String> property, | |
| 3156 const AccessorInfo& info); | |
| 3157 typedef void (*NamedPropertyDeleterCallback)( | 3126 typedef void (*NamedPropertyDeleterCallback)( |
| 3158 Local<String> property, | 3127 Local<String> property, |
| 3159 const PropertyCallbackInfo<Boolean>& info); | 3128 const PropertyCallbackInfo<Boolean>& info); |
| 3160 | 3129 |
| 3161 | 3130 |
| 3162 /** | 3131 /** |
| 3163 * Returns an array containing the names of the properties the named | 3132 * Returns an array containing the names of the properties the named |
| 3164 * property getter intercepts. | 3133 * property getter intercepts. |
| 3165 */ | 3134 */ |
| 3166 typedef Handle<Array> (*NamedPropertyEnumerator)(const AccessorInfo& info); | |
| 3167 typedef void (*NamedPropertyEnumeratorCallback)( | 3135 typedef void (*NamedPropertyEnumeratorCallback)( |
| 3168 const PropertyCallbackInfo<Array>& info); | 3136 const PropertyCallbackInfo<Array>& info); |
| 3169 | 3137 |
| 3170 | 3138 |
| 3171 /** | 3139 /** |
| 3172 * Returns the value of the property if the getter intercepts the | 3140 * Returns the value of the property if the getter intercepts the |
| 3173 * request. Otherwise, returns an empty handle. | 3141 * request. Otherwise, returns an empty handle. |
| 3174 */ | 3142 */ |
| 3175 typedef Handle<Value> (*IndexedPropertyGetter)(uint32_t index, | |
| 3176 const AccessorInfo& info); | |
| 3177 typedef void (*IndexedPropertyGetterCallback)( | 3143 typedef void (*IndexedPropertyGetterCallback)( |
| 3178 uint32_t index, | 3144 uint32_t index, |
| 3179 const PropertyCallbackInfo<Value>& info); | 3145 const PropertyCallbackInfo<Value>& info); |
| 3180 | 3146 |
| 3181 | 3147 |
| 3182 /** | 3148 /** |
| 3183 * Returns the value if the setter intercepts the request. | 3149 * Returns the value if the setter intercepts the request. |
| 3184 * Otherwise, returns an empty handle. | 3150 * Otherwise, returns an empty handle. |
| 3185 */ | 3151 */ |
| 3186 typedef Handle<Value> (*IndexedPropertySetter)(uint32_t index, | |
| 3187 Local<Value> value, | |
| 3188 const AccessorInfo& info); | |
| 3189 typedef void (*IndexedPropertySetterCallback)( | 3152 typedef void (*IndexedPropertySetterCallback)( |
| 3190 uint32_t index, | 3153 uint32_t index, |
| 3191 Local<Value> value, | 3154 Local<Value> value, |
| 3192 const PropertyCallbackInfo<Value>& info); | 3155 const PropertyCallbackInfo<Value>& info); |
| 3193 | 3156 |
| 3194 | 3157 |
| 3195 /** | 3158 /** |
| 3196 * Returns a non-empty handle if the interceptor intercepts the request. | 3159 * Returns a non-empty handle if the interceptor intercepts the request. |
| 3197 * The result is an integer encoding property attributes. | 3160 * The result is an integer encoding property attributes. |
| 3198 */ | 3161 */ |
| 3199 typedef Handle<Integer> (*IndexedPropertyQuery)(uint32_t index, | |
| 3200 const AccessorInfo& info); | |
| 3201 typedef void (*IndexedPropertyQueryCallback)( | 3162 typedef void (*IndexedPropertyQueryCallback)( |
| 3202 uint32_t index, | 3163 uint32_t index, |
| 3203 const PropertyCallbackInfo<Integer>& info); | 3164 const PropertyCallbackInfo<Integer>& info); |
| 3204 | 3165 |
| 3205 | 3166 |
| 3206 /** | 3167 /** |
| 3207 * Returns a non-empty handle if the deleter intercepts the request. | 3168 * Returns a non-empty handle if the deleter intercepts the request. |
| 3208 * The return value is true if the property could be deleted and false | 3169 * The return value is true if the property could be deleted and false |
| 3209 * otherwise. | 3170 * otherwise. |
| 3210 */ | 3171 */ |
| 3211 typedef Handle<Boolean> (*IndexedPropertyDeleter)(uint32_t index, | |
| 3212 const AccessorInfo& info); | |
| 3213 typedef void (*IndexedPropertyDeleterCallback)( | 3172 typedef void (*IndexedPropertyDeleterCallback)( |
| 3214 uint32_t index, | 3173 uint32_t index, |
| 3215 const PropertyCallbackInfo<Boolean>& info); | 3174 const PropertyCallbackInfo<Boolean>& info); |
| 3216 | 3175 |
| 3217 | 3176 |
| 3218 /** | 3177 /** |
| 3219 * Returns an array containing the indices of the properties the | 3178 * Returns an array containing the indices of the properties the |
| 3220 * indexed property getter intercepts. | 3179 * indexed property getter intercepts. |
| 3221 */ | 3180 */ |
| 3222 typedef Handle<Array> (*IndexedPropertyEnumerator)(const AccessorInfo& info); | |
| 3223 typedef void (*IndexedPropertyEnumeratorCallback)( | 3181 typedef void (*IndexedPropertyEnumeratorCallback)( |
| 3224 const PropertyCallbackInfo<Array>& info); | 3182 const PropertyCallbackInfo<Array>& info); |
| 3225 | 3183 |
| 3226 | 3184 |
| 3227 /** | 3185 /** |
| 3228 * Access type specification. | 3186 * Access type specification. |
| 3229 */ | 3187 */ |
| 3230 enum AccessType { | 3188 enum AccessType { |
| 3231 ACCESS_GET, | 3189 ACCESS_GET, |
| 3232 ACCESS_SET, | 3190 ACCESS_SET, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3344 * | 3302 * |
| 3345 * \code | 3303 * \code |
| 3346 * child_func.prototype.__proto__ == function.prototype; | 3304 * child_func.prototype.__proto__ == function.prototype; |
| 3347 * child_instance.instance_accessor calls 'InstanceAccessorCallback' | 3305 * child_instance.instance_accessor calls 'InstanceAccessorCallback' |
| 3348 * child_instance.instance_property == 3; | 3306 * child_instance.instance_property == 3; |
| 3349 * \endcode | 3307 * \endcode |
| 3350 */ | 3308 */ |
| 3351 class V8_EXPORT FunctionTemplate : public Template { | 3309 class V8_EXPORT FunctionTemplate : public Template { |
| 3352 public: | 3310 public: |
| 3353 /** Creates a function template.*/ | 3311 /** Creates a function template.*/ |
| 3354 V8_DEPRECATED(static Local<FunctionTemplate> New( | |
| 3355 InvocationCallback callback, | |
| 3356 Handle<Value> data = Handle<Value>(), | |
| 3357 Handle<Signature> signature = Handle<Signature>(), | |
| 3358 int length = 0)); | |
| 3359 static Local<FunctionTemplate> New( | 3312 static Local<FunctionTemplate> New( |
| 3360 FunctionCallback callback = 0, | 3313 FunctionCallback callback = 0, |
| 3361 Handle<Value> data = Handle<Value>(), | 3314 Handle<Value> data = Handle<Value>(), |
| 3362 Handle<Signature> signature = Handle<Signature>(), | 3315 Handle<Signature> signature = Handle<Signature>(), |
| 3363 int length = 0); | 3316 int length = 0); |
| 3364 | 3317 |
| 3365 /** Returns the unique function instance in the current execution context.*/ | 3318 /** Returns the unique function instance in the current execution context.*/ |
| 3366 Local<Function> GetFunction(); | 3319 Local<Function> GetFunction(); |
| 3367 | 3320 |
| 3368 /** | 3321 /** |
| 3369 * Set the call-handler callback for a FunctionTemplate. This | 3322 * Set the call-handler callback for a FunctionTemplate. This |
| 3370 * callback is called whenever the function created from this | 3323 * callback is called whenever the function created from this |
| 3371 * FunctionTemplate is called. | 3324 * FunctionTemplate is called. |
| 3372 */ | 3325 */ |
| 3373 V8_DEPRECATED(void SetCallHandler(InvocationCallback callback, | |
| 3374 Handle<Value> data = Handle<Value>())); | |
| 3375 void SetCallHandler(FunctionCallback callback, | 3326 void SetCallHandler(FunctionCallback callback, |
| 3376 Handle<Value> data = Handle<Value>()); | 3327 Handle<Value> data = Handle<Value>()); |
| 3377 | 3328 |
| 3378 /** Set the predefined length property for the FunctionTemplate. */ | 3329 /** Set the predefined length property for the FunctionTemplate. */ |
| 3379 void SetLength(int length); | 3330 void SetLength(int length); |
| 3380 | 3331 |
| 3381 /** Get the InstanceTemplate. */ | 3332 /** Get the InstanceTemplate. */ |
| 3382 Local<ObjectTemplate> InstanceTemplate(); | 3333 Local<ObjectTemplate> InstanceTemplate(); |
| 3383 | 3334 |
| 3384 /** Causes the function template to inherit from a parent function template.*/ | 3335 /** Causes the function template to inherit from a parent function template.*/ |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3411 */ | 3362 */ |
| 3412 void SetHiddenPrototype(bool value); | 3363 void SetHiddenPrototype(bool value); |
| 3413 | 3364 |
| 3414 /** | 3365 /** |
| 3415 * Sets the ReadOnly flag in the attributes of the 'prototype' property | 3366 * Sets the ReadOnly flag in the attributes of the 'prototype' property |
| 3416 * of functions created from this FunctionTemplate to true. | 3367 * of functions created from this FunctionTemplate to true. |
| 3417 */ | 3368 */ |
| 3418 void ReadOnlyPrototype(); | 3369 void ReadOnlyPrototype(); |
| 3419 | 3370 |
| 3420 /** | 3371 /** |
| 3372 * Removes the prototype property from functions created from this |
| 3373 * FunctionTemplate. |
| 3374 */ |
| 3375 void RemovePrototype(); |
| 3376 |
| 3377 /** |
| 3421 * Returns true if the given object is an instance of this function | 3378 * Returns true if the given object is an instance of this function |
| 3422 * template. | 3379 * template. |
| 3423 */ | 3380 */ |
| 3424 bool HasInstance(Handle<Value> object); | 3381 bool HasInstance(Handle<Value> object); |
| 3425 | 3382 |
| 3426 private: | 3383 private: |
| 3427 FunctionTemplate(); | 3384 FunctionTemplate(); |
| 3428 // TODO(dcarney): Remove with SetCallHandler. | |
| 3429 friend class v8::CallHandlerHelper; | |
| 3430 void SetCallHandlerInternal(InvocationCallback callback, Handle<Value> data); | |
| 3431 friend class Context; | 3385 friend class Context; |
| 3432 friend class ObjectTemplate; | 3386 friend class ObjectTemplate; |
| 3433 }; | 3387 }; |
| 3434 | 3388 |
| 3435 | 3389 |
| 3436 /** | 3390 /** |
| 3437 * An ObjectTemplate is used to create objects at runtime. | 3391 * An ObjectTemplate is used to create objects at runtime. |
| 3438 * | 3392 * |
| 3439 * Properties added to an ObjectTemplate are added to each object | 3393 * Properties added to an ObjectTemplate are added to each object |
| 3440 * created from the ObjectTemplate. | 3394 * created from the ObjectTemplate. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3469 * The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all | 3423 * The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all |
| 3470 * cross-context access. | 3424 * cross-context access. |
| 3471 * \param attribute The attributes of the property for which an accessor | 3425 * \param attribute The attributes of the property for which an accessor |
| 3472 * is added. | 3426 * is added. |
| 3473 * \param signature The signature describes valid receivers for the accessor | 3427 * \param signature The signature describes valid receivers for the accessor |
| 3474 * and is used to perform implicit instance checks against them. If the | 3428 * and is used to perform implicit instance checks against them. If the |
| 3475 * receiver is incompatible (i.e. is not an instance of the constructor as | 3429 * receiver is incompatible (i.e. is not an instance of the constructor as |
| 3476 * defined by FunctionTemplate::HasInstance()), an implicit TypeError is | 3430 * defined by FunctionTemplate::HasInstance()), an implicit TypeError is |
| 3477 * thrown and no callback is invoked. | 3431 * thrown and no callback is invoked. |
| 3478 */ | 3432 */ |
| 3479 V8_DEPRECATED(void SetAccessor(Handle<String> name, | |
| 3480 AccessorGetter getter, | |
| 3481 AccessorSetter setter = 0, | |
| 3482 Handle<Value> data = Handle<Value>(), | |
| 3483 AccessControl settings = DEFAULT, | |
| 3484 PropertyAttribute attribute = None, | |
| 3485 Handle<AccessorSignature> signature = | |
| 3486 Handle<AccessorSignature>())); | |
| 3487 void SetAccessor(Handle<String> name, | 3433 void SetAccessor(Handle<String> name, |
| 3488 AccessorGetterCallback getter, | 3434 AccessorGetterCallback getter, |
| 3489 AccessorSetterCallback setter = 0, | 3435 AccessorSetterCallback setter = 0, |
| 3490 Handle<Value> data = Handle<Value>(), | 3436 Handle<Value> data = Handle<Value>(), |
| 3491 AccessControl settings = DEFAULT, | 3437 AccessControl settings = DEFAULT, |
| 3492 PropertyAttribute attribute = None, | 3438 PropertyAttribute attribute = None, |
| 3493 Handle<AccessorSignature> signature = | 3439 Handle<AccessorSignature> signature = |
| 3494 Handle<AccessorSignature>()); | 3440 Handle<AccessorSignature>()); |
| 3495 | 3441 |
| 3496 // This function is not yet stable and should not be used at this time. | 3442 // This function is not yet stable and should not be used at this time. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3511 * \param getter The callback to invoke when getting a property. | 3457 * \param getter The callback to invoke when getting a property. |
| 3512 * \param setter The callback to invoke when setting a property. | 3458 * \param setter The callback to invoke when setting a property. |
| 3513 * \param query The callback to invoke to check if a property is present, | 3459 * \param query The callback to invoke to check if a property is present, |
| 3514 * and if present, get its attributes. | 3460 * and if present, get its attributes. |
| 3515 * \param deleter The callback to invoke when deleting a property. | 3461 * \param deleter The callback to invoke when deleting a property. |
| 3516 * \param enumerator The callback to invoke to enumerate all the named | 3462 * \param enumerator The callback to invoke to enumerate all the named |
| 3517 * properties of an object. | 3463 * properties of an object. |
| 3518 * \param data A piece of data that will be passed to the callbacks | 3464 * \param data A piece of data that will be passed to the callbacks |
| 3519 * whenever they are invoked. | 3465 * whenever they are invoked. |
| 3520 */ | 3466 */ |
| 3521 V8_DEPRECATED(void SetNamedPropertyHandler( | |
| 3522 NamedPropertyGetter getter, | |
| 3523 NamedPropertySetter setter = 0, | |
| 3524 NamedPropertyQuery query = 0, | |
| 3525 NamedPropertyDeleter deleter = 0, | |
| 3526 NamedPropertyEnumerator enumerator = 0, | |
| 3527 Handle<Value> data = Handle<Value>())); | |
| 3528 void SetNamedPropertyHandler( | 3467 void SetNamedPropertyHandler( |
| 3529 NamedPropertyGetterCallback getter, | 3468 NamedPropertyGetterCallback getter, |
| 3530 NamedPropertySetterCallback setter = 0, | 3469 NamedPropertySetterCallback setter = 0, |
| 3531 NamedPropertyQueryCallback query = 0, | 3470 NamedPropertyQueryCallback query = 0, |
| 3532 NamedPropertyDeleterCallback deleter = 0, | 3471 NamedPropertyDeleterCallback deleter = 0, |
| 3533 NamedPropertyEnumeratorCallback enumerator = 0, | 3472 NamedPropertyEnumeratorCallback enumerator = 0, |
| 3534 Handle<Value> data = Handle<Value>()); | 3473 Handle<Value> data = Handle<Value>()); |
| 3535 | 3474 |
| 3536 /** | 3475 /** |
| 3537 * Sets an indexed property handler on the object template. | 3476 * Sets an indexed property handler on the object template. |
| 3538 * | 3477 * |
| 3539 * Whenever an indexed property is accessed on objects created from | 3478 * Whenever an indexed property is accessed on objects created from |
| 3540 * this object template, the provided callback is invoked instead of | 3479 * this object template, the provided callback is invoked instead of |
| 3541 * accessing the property directly on the JavaScript object. | 3480 * accessing the property directly on the JavaScript object. |
| 3542 * | 3481 * |
| 3543 * \param getter The callback to invoke when getting a property. | 3482 * \param getter The callback to invoke when getting a property. |
| 3544 * \param setter The callback to invoke when setting a property. | 3483 * \param setter The callback to invoke when setting a property. |
| 3545 * \param query The callback to invoke to check if an object has a property. | 3484 * \param query The callback to invoke to check if an object has a property. |
| 3546 * \param deleter The callback to invoke when deleting a property. | 3485 * \param deleter The callback to invoke when deleting a property. |
| 3547 * \param enumerator The callback to invoke to enumerate all the indexed | 3486 * \param enumerator The callback to invoke to enumerate all the indexed |
| 3548 * properties of an object. | 3487 * properties of an object. |
| 3549 * \param data A piece of data that will be passed to the callbacks | 3488 * \param data A piece of data that will be passed to the callbacks |
| 3550 * whenever they are invoked. | 3489 * whenever they are invoked. |
| 3551 */ | 3490 */ |
| 3552 V8_DEPRECATED(void SetIndexedPropertyHandler( | |
| 3553 IndexedPropertyGetter getter, | |
| 3554 IndexedPropertySetter setter = 0, | |
| 3555 IndexedPropertyQuery query = 0, | |
| 3556 IndexedPropertyDeleter deleter = 0, | |
| 3557 IndexedPropertyEnumerator enumerator = 0, | |
| 3558 Handle<Value> data = Handle<Value>())); | |
| 3559 void SetIndexedPropertyHandler( | 3491 void SetIndexedPropertyHandler( |
| 3560 IndexedPropertyGetterCallback getter, | 3492 IndexedPropertyGetterCallback getter, |
| 3561 IndexedPropertySetterCallback setter = 0, | 3493 IndexedPropertySetterCallback setter = 0, |
| 3562 IndexedPropertyQueryCallback query = 0, | 3494 IndexedPropertyQueryCallback query = 0, |
| 3563 IndexedPropertyDeleterCallback deleter = 0, | 3495 IndexedPropertyDeleterCallback deleter = 0, |
| 3564 IndexedPropertyEnumeratorCallback enumerator = 0, | 3496 IndexedPropertyEnumeratorCallback enumerator = 0, |
| 3565 Handle<Value> data = Handle<Value>()); | 3497 Handle<Value> data = Handle<Value>()); |
| 3566 | 3498 |
| 3567 /** | 3499 /** |
| 3568 * Sets the callback to be used when calling instances created from | 3500 * Sets the callback to be used when calling instances created from |
| 3569 * this template as a function. If no callback is set, instances | 3501 * this template as a function. If no callback is set, instances |
| 3570 * behave like normal JavaScript objects that cannot be called as a | 3502 * behave like normal JavaScript objects that cannot be called as a |
| 3571 * function. | 3503 * function. |
| 3572 */ | 3504 */ |
| 3573 V8_DEPRECATED(void SetCallAsFunctionHandler( | |
| 3574 InvocationCallback callback, | |
| 3575 Handle<Value> data = Handle<Value>())); | |
| 3576 void SetCallAsFunctionHandler(FunctionCallback callback, | 3505 void SetCallAsFunctionHandler(FunctionCallback callback, |
| 3577 Handle<Value> data = Handle<Value>()); | 3506 Handle<Value> data = Handle<Value>()); |
| 3578 | 3507 |
| 3579 /** | 3508 /** |
| 3580 * Mark object instances of the template as undetectable. | 3509 * Mark object instances of the template as undetectable. |
| 3581 * | 3510 * |
| 3582 * In many ways, undetectable objects behave as though they are not | 3511 * In many ways, undetectable objects behave as though they are not |
| 3583 * there. They behave like 'undefined' in conditionals and when | 3512 * there. They behave like 'undefined' in conditionals and when |
| 3584 * printed. However, properties can be accessed and called as on | 3513 * printed. However, properties can be accessed and called as on |
| 3585 * normal objects. | 3514 * normal objects. |
| (...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4790 V8(); | 4719 V8(); |
| 4791 | 4720 |
| 4792 static internal::Object** GlobalizeReference(internal::Isolate* isolate, | 4721 static internal::Object** GlobalizeReference(internal::Isolate* isolate, |
| 4793 internal::Object** handle); | 4722 internal::Object** handle); |
| 4794 static void DisposeGlobal(internal::Object** global_handle); | 4723 static void DisposeGlobal(internal::Object** global_handle); |
| 4795 typedef WeakReferenceCallbacks<Value, void>::Revivable RevivableCallback; | 4724 typedef WeakReferenceCallbacks<Value, void>::Revivable RevivableCallback; |
| 4796 static void MakeWeak(internal::Object** global_handle, | 4725 static void MakeWeak(internal::Object** global_handle, |
| 4797 void* data, | 4726 void* data, |
| 4798 RevivableCallback weak_reference_callback); | 4727 RevivableCallback weak_reference_callback); |
| 4799 static void ClearWeak(internal::Object** global_handle); | 4728 static void ClearWeak(internal::Object** global_handle); |
| 4800 static int Eternalize(internal::Isolate* isolate, | 4729 static void Eternalize(Isolate* isolate, |
| 4801 internal::Object** handle); | 4730 Value* handle, |
| 4802 static internal::Object** GetEternal(internal::Isolate* isolate, int index); | 4731 int* index); |
| 4732 static Local<Value> GetEternal(Isolate* isolate, int index); |
| 4803 | 4733 |
| 4804 template <class T> friend class Handle; | 4734 template <class T> friend class Handle; |
| 4805 template <class T> friend class Local; | 4735 template <class T> friend class Local; |
| 4736 template <class T> friend class Eternal; |
| 4806 template <class T> friend class Persistent; | 4737 template <class T> friend class Persistent; |
| 4807 friend class Context; | 4738 friend class Context; |
| 4808 }; | 4739 }; |
| 4809 | 4740 |
| 4810 | 4741 |
| 4811 /** | 4742 /** |
| 4812 * An external exception handler. | 4743 * An external exception handler. |
| 4813 */ | 4744 */ |
| 4814 class V8_EXPORT TryCatch { | 4745 class V8_EXPORT TryCatch { |
| 4815 public: | 4746 public: |
| (...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5657 Local<T> Local<T>::New(Isolate* isolate, T* that) { | 5588 Local<T> Local<T>::New(Isolate* isolate, T* that) { |
| 5658 if (that == NULL) return Local<T>(); | 5589 if (that == NULL) return Local<T>(); |
| 5659 T* that_ptr = that; | 5590 T* that_ptr = that; |
| 5660 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); | 5591 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); |
| 5661 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( | 5592 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( |
| 5662 reinterpret_cast<internal::Isolate*>(isolate), *p))); | 5593 reinterpret_cast<internal::Isolate*>(isolate), *p))); |
| 5663 } | 5594 } |
| 5664 | 5595 |
| 5665 | 5596 |
| 5666 template<class T> | 5597 template<class T> |
| 5667 int Local<T>::Eternalize(Isolate* isolate) { | 5598 template<class S> |
| 5668 return V8::Eternalize(reinterpret_cast<internal::Isolate*>(isolate), | 5599 void Eternal<T>::Set(Isolate* isolate, Local<S> handle) { |
| 5669 reinterpret_cast<internal::Object**>(this->val_)); | 5600 TYPE_CHECK(T, S); |
| 5601 V8::Eternalize(isolate, Value::Cast(*handle), &this->index_); |
| 5670 } | 5602 } |
| 5671 | 5603 |
| 5672 | 5604 |
| 5673 template<class T> | 5605 template<class T> |
| 5674 Local<T> Local<T>::GetEternal(Isolate* isolate, int index) { | 5606 Local<T> Eternal<T>::Get(Isolate* isolate) { |
| 5675 internal::Object** handle = | 5607 return Local<T>::Cast(V8::GetEternal(isolate, index_)); |
| 5676 V8::GetEternal(reinterpret_cast<internal::Isolate*>(isolate), index); | |
| 5677 return Local<T>(T::Cast(reinterpret_cast<Value*>(handle))); | |
| 5678 } | 5608 } |
| 5679 | 5609 |
| 5680 | 5610 |
| 5681 #ifdef V8_USE_UNSAFE_HANDLES | 5611 #ifdef V8_USE_UNSAFE_HANDLES |
| 5682 template <class T> | 5612 template <class T> |
| 5683 Persistent<T> Persistent<T>::New(Handle<T> that) { | 5613 Persistent<T> Persistent<T>::New(Handle<T> that) { |
| 5684 return New(Isolate::GetCurrent(), that.val_); | 5614 return New(Isolate::GetCurrent(), that.val_); |
| 5685 } | 5615 } |
| 5686 | 5616 |
| 5687 | 5617 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5986 FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args, | 5916 FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args, |
| 5987 internal::Object** values, | 5917 internal::Object** values, |
| 5988 int length, | 5918 int length, |
| 5989 bool is_construct_call) | 5919 bool is_construct_call) |
| 5990 : implicit_args_(implicit_args), | 5920 : implicit_args_(implicit_args), |
| 5991 values_(values), | 5921 values_(values), |
| 5992 length_(length), | 5922 length_(length), |
| 5993 is_construct_call_(is_construct_call) { } | 5923 is_construct_call_(is_construct_call) { } |
| 5994 | 5924 |
| 5995 | 5925 |
| 5996 Arguments::Arguments(internal::Object** args, | |
| 5997 internal::Object** values, | |
| 5998 int length, | |
| 5999 bool is_construct_call) | |
| 6000 : FunctionCallbackInfo<Value>(args, values, length, is_construct_call) { } | |
| 6001 | |
| 6002 | |
| 6003 template<typename T> | 5926 template<typename T> |
| 6004 Local<Value> FunctionCallbackInfo<T>::operator[](int i) const { | 5927 Local<Value> FunctionCallbackInfo<T>::operator[](int i) const { |
| 6005 if (i < 0 || length_ <= i) return Local<Value>(*Undefined()); | 5928 if (i < 0 || length_ <= i) return Local<Value>(*Undefined()); |
| 6006 return Local<Value>(reinterpret_cast<Value*>(values_ - i)); | 5929 return Local<Value>(reinterpret_cast<Value*>(values_ - i)); |
| 6007 } | 5930 } |
| 6008 | 5931 |
| 6009 | 5932 |
| 6010 template<typename T> | 5933 template<typename T> |
| 6011 Local<Function> FunctionCallbackInfo<T>::Callee() const { | 5934 Local<Function> FunctionCallbackInfo<T>::Callee() const { |
| 6012 return Local<Function>(reinterpret_cast<Function*>( | 5935 return Local<Function>(reinterpret_cast<Function*>( |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6586 */ | 6509 */ |
| 6587 | 6510 |
| 6588 | 6511 |
| 6589 } // namespace v8 | 6512 } // namespace v8 |
| 6590 | 6513 |
| 6591 | 6514 |
| 6592 #undef TYPE_CHECK | 6515 #undef TYPE_CHECK |
| 6593 | 6516 |
| 6594 | 6517 |
| 6595 #endif // V8_H_ | 6518 #endif // V8_H_ |
| OLD | NEW |