| OLD | NEW |
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 typedef int int32_t; | 44 typedef int int32_t; |
| 45 typedef unsigned int uint32_t; | 45 typedef unsigned int uint32_t; |
| 46 typedef unsigned short uint16_t; // NOLINT | 46 typedef unsigned short uint16_t; // NOLINT |
| 47 typedef long long int64_t; // NOLINT | 47 typedef long long int64_t; // NOLINT |
| 48 | 48 |
| 49 // Setup for Windows DLL export/import. When building the V8 DLL the | 49 // Setup for Windows DLL export/import. When building the V8 DLL the |
| 50 // BUILDING_V8_SHARED needs to be defined. When building a program which uses | 50 // BUILDING_V8_SHARED needs to be defined. When building a program which uses |
| 51 // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8 | 51 // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8 |
| 52 // static library or building a program which uses the V8 static library neither | 52 // static library or building a program which uses the V8 static library neither |
| 53 // BUILDING_V8_SHARED nor USING_V8_SHARED should be defined. | 53 // BUILDING_V8_SHARED nor USING_V8_SHARED should be defined. |
| 54 // The reason for having both EXPORT and EXPORT_INLINE is that classes which | 54 // The reason for having both V8EXPORT and V8EXPORT_INLINE is that classes which |
| 55 // have their code inside this header file needs to have __declspec(dllexport) | 55 // have their code inside this header file need to have __declspec(dllexport) |
| 56 // when building the DLL but cannot have __declspec(dllimport) when building | 56 // when building the DLL but cannot have __declspec(dllimport) when building |
| 57 // a program which uses the DLL. | 57 // a program which uses the DLL. |
| 58 #if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED) | 58 #if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED) |
| 59 #error both BUILDING_V8_SHARED and USING_V8_SHARED are set - please check the\ | 59 #error both BUILDING_V8_SHARED and USING_V8_SHARED are set - please check the\ |
| 60 build configuration to ensure that at most one of these is set | 60 build configuration to ensure that at most one of these is set |
| 61 #endif | 61 #endif |
| 62 | 62 |
| 63 #ifdef BUILDING_V8_SHARED | 63 #ifdef BUILDING_V8_SHARED |
| 64 #define EXPORT __declspec(dllexport) | 64 #define V8EXPORT __declspec(dllexport) |
| 65 #define EXPORT_INLINE __declspec(dllexport) | 65 #define V8EXPORT_INLINE __declspec(dllexport) |
| 66 #elif USING_V8_SHARED | 66 #elif USING_V8_SHARED |
| 67 #define EXPORT __declspec(dllimport) | 67 #define V8EXPORT __declspec(dllimport) |
| 68 #define EXPORT_INLINE | 68 #define V8EXPORT_INLINE |
| 69 #else | 69 #else |
| 70 #define EXPORT | 70 #define V8EXPORT |
| 71 #define EXPORT_INLINE | 71 #define V8EXPORT_INLINE |
| 72 #endif // BUILDING_V8_SHARED | 72 #endif // BUILDING_V8_SHARED |
| 73 | 73 |
| 74 #else // _WIN32 | 74 #else // _WIN32 |
| 75 | 75 |
| 76 #include <stdint.h> | 76 #include <stdint.h> |
| 77 | 77 |
| 78 // Setup for Linux shared library export. There is no need to destinguish | 78 // Setup for Linux shared library export. There is no need to destinguish |
| 79 // neither between building or using the V8 shared library nor between using | 79 // neither between building or using the V8 shared library nor between using |
| 80 // the shared or static V8 library as there is on Windows. Therefore there is | 80 // the shared or static V8 library as there is on Windows. Therefore there is |
| 81 // no checking of BUILDING_V8_SHARED and USING_V8_SHARED. | 81 // no checking of BUILDING_V8_SHARED and USING_V8_SHARED. |
| 82 #if defined(__GNUC__) && (__GNUC__ >= 4) | 82 #if defined(__GNUC__) && (__GNUC__ >= 4) |
| 83 #define EXPORT __attribute__ ((visibility("default"))) | 83 #define V8EXPORT __attribute__ ((visibility("default"))) |
| 84 #define EXPORT_INLINE __attribute__ ((visibility("default"))) | 84 #define V8EXPORT_INLINE __attribute__ ((visibility("default"))) |
| 85 #else // defined(__GNUC__) && (__GNUC__ >= 4) | 85 #else // defined(__GNUC__) && (__GNUC__ >= 4) |
| 86 #define EXPORT | 86 #define V8EXPORT |
| 87 #define EXPORT_INLINE | 87 #define V8EXPORT_INLINE |
| 88 #endif // defined(__GNUC__) && (__GNUC__ >= 4) | 88 #endif // defined(__GNUC__) && (__GNUC__ >= 4) |
| 89 | 89 |
| 90 #endif // _WIN32 | 90 #endif // _WIN32 |
| 91 | 91 |
| 92 /** | 92 /** |
| 93 * The v8 JavaScript engine. | 93 * The v8 JavaScript engine. |
| 94 */ | 94 */ |
| 95 namespace v8 { | 95 namespace v8 { |
| 96 | 96 |
| 97 class Context; | 97 class Context; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 * handles can be used when storing objects across several independent | 157 * handles can be used when storing objects across several independent |
| 158 * operations and have to be explicitly deallocated when they're no | 158 * operations and have to be explicitly deallocated when they're no |
| 159 * longer used. | 159 * longer used. |
| 160 * | 160 * |
| 161 * It is safe to extract the object stored in the handle by | 161 * It is safe to extract the object stored in the handle by |
| 162 * dereferencing the handle (for instance, to extract the Object* from | 162 * dereferencing the handle (for instance, to extract the Object* from |
| 163 * an Handle<Object>); the value will still be governed by a handle | 163 * an Handle<Object>); the value will still be governed by a handle |
| 164 * behind the scenes and the same rules apply to these values as to | 164 * behind the scenes and the same rules apply to these values as to |
| 165 * their handles. | 165 * their handles. |
| 166 */ | 166 */ |
| 167 template <class T> class EXPORT_INLINE Handle { | 167 template <class T> class V8EXPORT_INLINE Handle { |
| 168 public: | 168 public: |
| 169 | 169 |
| 170 /** | 170 /** |
| 171 * Creates an empty handle. | 171 * Creates an empty handle. |
| 172 */ | 172 */ |
| 173 Handle(); | 173 Handle(); |
| 174 | 174 |
| 175 /** | 175 /** |
| 176 * Creates a new handle for the specified value. | 176 * Creates a new handle for the specified value. |
| 177 */ | 177 */ |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 }; | 245 }; |
| 246 | 246 |
| 247 | 247 |
| 248 /** | 248 /** |
| 249 * A light-weight stack-allocated object handle. All operations | 249 * A light-weight stack-allocated object handle. All operations |
| 250 * that return objects from within v8 return them in local handles. They | 250 * that return objects from within v8 return them in local handles. They |
| 251 * are created within HandleScopes, and all local handles allocated within a | 251 * are created within HandleScopes, and all local handles allocated within a |
| 252 * handle scope are destroyed when the handle scope is destroyed. Hence it | 252 * handle scope are destroyed when the handle scope is destroyed. Hence it |
| 253 * is not necessary to explicitly deallocate local handles. | 253 * is not necessary to explicitly deallocate local handles. |
| 254 */ | 254 */ |
| 255 template <class T> class EXPORT_INLINE Local : public Handle<T> { | 255 template <class T> class V8EXPORT_INLINE Local : public Handle<T> { |
| 256 public: | 256 public: |
| 257 Local(); | 257 Local(); |
| 258 template <class S> inline Local(Local<S> that) | 258 template <class S> inline Local(Local<S> that) |
| 259 : Handle<T>(reinterpret_cast<T*>(*that)) { | 259 : Handle<T>(reinterpret_cast<T*>(*that)) { |
| 260 /** | 260 /** |
| 261 * This check fails when trying to convert between incompatible | 261 * This check fails when trying to convert between incompatible |
| 262 * handles. For example, converting from a Handle<String> to a | 262 * handles. For example, converting from a Handle<String> to a |
| 263 * Handle<Number>. | 263 * Handle<Number>. |
| 264 */ | 264 */ |
| 265 TYPE_CHECK(T, S); | 265 TYPE_CHECK(T, S); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 288 * the v8 engine which holds an object value and which is updated by | 288 * the v8 engine which holds an object value and which is updated by |
| 289 * the garbage collector whenever the object is moved. A new storage | 289 * the garbage collector whenever the object is moved. A new storage |
| 290 * cell can be created using Persistent::New and existing handles can | 290 * cell can be created using Persistent::New and existing handles can |
| 291 * be disposed using Persistent::Dispose. Since persistent handles | 291 * be disposed using Persistent::Dispose. Since persistent handles |
| 292 * are passed by value you may have many persistent handle objects | 292 * are passed by value you may have many persistent handle objects |
| 293 * that point to the same storage cell. For instance, if you pass a | 293 * that point to the same storage cell. For instance, if you pass a |
| 294 * persistent handle as an argument to a function you will not get two | 294 * persistent handle as an argument to a function you will not get two |
| 295 * different storage cells but rather two references to the same | 295 * different storage cells but rather two references to the same |
| 296 * storage cell. | 296 * storage cell. |
| 297 */ | 297 */ |
| 298 template <class T> class EXPORT_INLINE Persistent : public Handle<T> { | 298 template <class T> class V8EXPORT_INLINE Persistent : public Handle<T> { |
| 299 public: | 299 public: |
| 300 | 300 |
| 301 /** | 301 /** |
| 302 * Creates an empty persistent handle that doesn't point to any | 302 * Creates an empty persistent handle that doesn't point to any |
| 303 * storage cell. | 303 * storage cell. |
| 304 */ | 304 */ |
| 305 Persistent(); | 305 Persistent(); |
| 306 | 306 |
| 307 /** | 307 /** |
| 308 * Creates a persistent handle for the same storage cell as the | 308 * Creates a persistent handle for the same storage cell as the |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 * deleted or another handle scope is created. If there is already a | 387 * deleted or another handle scope is created. If there is already a |
| 388 * handle scope and a new one is created, all allocations will take | 388 * handle scope and a new one is created, all allocations will take |
| 389 * place in the new handle scope until it is deleted. After that, | 389 * place in the new handle scope until it is deleted. After that, |
| 390 * new handles will again be allocated in the original handle scope. | 390 * new handles will again be allocated in the original handle scope. |
| 391 * | 391 * |
| 392 * After the handle scope of a local handle has been deleted the | 392 * After the handle scope of a local handle has been deleted the |
| 393 * garbage collector will no longer track the object stored in the | 393 * garbage collector will no longer track the object stored in the |
| 394 * handle and may deallocate it. The behavior of accessing a handle | 394 * handle and may deallocate it. The behavior of accessing a handle |
| 395 * for which the handle scope has been deleted is undefined. | 395 * for which the handle scope has been deleted is undefined. |
| 396 */ | 396 */ |
| 397 class EXPORT HandleScope { | 397 class V8EXPORT HandleScope { |
| 398 public: | 398 public: |
| 399 HandleScope(); | 399 HandleScope(); |
| 400 | 400 |
| 401 ~HandleScope(); | 401 ~HandleScope(); |
| 402 | 402 |
| 403 /** | 403 /** |
| 404 * Closes the handle scope and returns the value as a handle in the | 404 * Closes the handle scope and returns the value as a handle in the |
| 405 * previous scope, which is the new current scope after the call. | 405 * previous scope, which is the new current scope after the call. |
| 406 */ | 406 */ |
| 407 template <class T> Local<T> Close(Handle<T> value); | 407 template <class T> Local<T> Close(Handle<T> value); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 419 private: | 419 private: |
| 420 // Make it impossible to create heap-allocated or illegal handle | 420 // Make it impossible to create heap-allocated or illegal handle |
| 421 // scopes by disallowing certain operations. | 421 // scopes by disallowing certain operations. |
| 422 HandleScope(const HandleScope&); | 422 HandleScope(const HandleScope&); |
| 423 void operator=(const HandleScope&); | 423 void operator=(const HandleScope&); |
| 424 void* operator new(size_t size); | 424 void* operator new(size_t size); |
| 425 void operator delete(void*, size_t); | 425 void operator delete(void*, size_t); |
| 426 | 426 |
| 427 // This Data class is accessible internally through a typedef in the | 427 // This Data class is accessible internally through a typedef in the |
| 428 // ImplementationUtilities class. | 428 // ImplementationUtilities class. |
| 429 class EXPORT Data { | 429 class V8EXPORT Data { |
| 430 public: | 430 public: |
| 431 int extensions; | 431 int extensions; |
| 432 void** next; | 432 void** next; |
| 433 void** limit; | 433 void** limit; |
| 434 inline void Initialize() { | 434 inline void Initialize() { |
| 435 extensions = -1; | 435 extensions = -1; |
| 436 next = limit = NULL; | 436 next = limit = NULL; |
| 437 } | 437 } |
| 438 }; | 438 }; |
| 439 | 439 |
| 440 Data previous_; | 440 Data previous_; |
| 441 | 441 |
| 442 // Allow for the active closing of HandleScopes which allows to pass a handle | 442 // Allow for the active closing of HandleScopes which allows to pass a handle |
| 443 // from the HandleScope being closed to the next top most HandleScope. | 443 // from the HandleScope being closed to the next top most HandleScope. |
| 444 bool is_closed_; | 444 bool is_closed_; |
| 445 void** RawClose(void** value); | 445 void** RawClose(void** value); |
| 446 | 446 |
| 447 friend class ImplementationUtilities; | 447 friend class ImplementationUtilities; |
| 448 }; | 448 }; |
| 449 | 449 |
| 450 | 450 |
| 451 // --- S p e c i a l o b j e c t s --- | 451 // --- S p e c i a l o b j e c t s --- |
| 452 | 452 |
| 453 | 453 |
| 454 /** | 454 /** |
| 455 * The superclass of values and API object templates. | 455 * The superclass of values and API object templates. |
| 456 */ | 456 */ |
| 457 class EXPORT Data { | 457 class V8EXPORT Data { |
| 458 private: | 458 private: |
| 459 Data(); | 459 Data(); |
| 460 }; | 460 }; |
| 461 | 461 |
| 462 | 462 |
| 463 /** | 463 /** |
| 464 * Pre-compilation data that can be associated with a script. This | 464 * Pre-compilation data that can be associated with a script. This |
| 465 * data can be calculated for a script in advance of actually | 465 * data can be calculated for a script in advance of actually |
| 466 * compiling it, and can be stored between compilations. When script | 466 * compiling it, and can be stored between compilations. When script |
| 467 * data is given to the compile method compilation will be faster. | 467 * data is given to the compile method compilation will be faster. |
| 468 */ | 468 */ |
| 469 class EXPORT ScriptData { // NOLINT | 469 class V8EXPORT ScriptData { // NOLINT |
| 470 public: | 470 public: |
| 471 virtual ~ScriptData() { } | 471 virtual ~ScriptData() { } |
| 472 static ScriptData* PreCompile(const char* input, int length); | 472 static ScriptData* PreCompile(const char* input, int length); |
| 473 static ScriptData* New(unsigned* data, int length); | 473 static ScriptData* New(unsigned* data, int length); |
| 474 | 474 |
| 475 virtual int Length() = 0; | 475 virtual int Length() = 0; |
| 476 virtual unsigned* Data() = 0; | 476 virtual unsigned* Data() = 0; |
| 477 }; | 477 }; |
| 478 | 478 |
| 479 | 479 |
| 480 /** | 480 /** |
| 481 * The origin, within a file, of a script. | 481 * The origin, within a file, of a script. |
| 482 */ | 482 */ |
| 483 class EXPORT ScriptOrigin { | 483 class V8EXPORT ScriptOrigin { |
| 484 public: | 484 public: |
| 485 ScriptOrigin(Handle<Value> resource_name, | 485 ScriptOrigin(Handle<Value> resource_name, |
| 486 Handle<Integer> resource_line_offset = Handle<Integer>(), | 486 Handle<Integer> resource_line_offset = Handle<Integer>(), |
| 487 Handle<Integer> resource_column_offset = Handle<Integer>()) | 487 Handle<Integer> resource_column_offset = Handle<Integer>()) |
| 488 : resource_name_(resource_name), | 488 : resource_name_(resource_name), |
| 489 resource_line_offset_(resource_line_offset), | 489 resource_line_offset_(resource_line_offset), |
| 490 resource_column_offset_(resource_column_offset) { } | 490 resource_column_offset_(resource_column_offset) { } |
| 491 inline Handle<Value> ResourceName() const; | 491 inline Handle<Value> ResourceName() const; |
| 492 inline Handle<Integer> ResourceLineOffset() const; | 492 inline Handle<Integer> ResourceLineOffset() const; |
| 493 inline Handle<Integer> ResourceColumnOffset() const; | 493 inline Handle<Integer> ResourceColumnOffset() const; |
| 494 private: | 494 private: |
| 495 Handle<Value> resource_name_; | 495 Handle<Value> resource_name_; |
| 496 Handle<Integer> resource_line_offset_; | 496 Handle<Integer> resource_line_offset_; |
| 497 Handle<Integer> resource_column_offset_; | 497 Handle<Integer> resource_column_offset_; |
| 498 }; | 498 }; |
| 499 | 499 |
| 500 | 500 |
| 501 /** | 501 /** |
| 502 * A compiled JavaScript script. | 502 * A compiled JavaScript script. |
| 503 */ | 503 */ |
| 504 class EXPORT Script { | 504 class V8EXPORT Script { |
| 505 public: | 505 public: |
| 506 | 506 |
| 507 /** | 507 /** |
| 508 * Compiles the specified script. The ScriptOrigin* and ScriptData* | 508 * Compiles the specified script. The ScriptOrigin* and ScriptData* |
| 509 * parameters are owned by the caller of Script::Compile. No | 509 * parameters are owned by the caller of Script::Compile. No |
| 510 * references to these objects are kept after compilation finishes. | 510 * references to these objects are kept after compilation finishes. |
| 511 */ | 511 */ |
| 512 static Local<Script> Compile(Handle<String> source, | 512 static Local<Script> Compile(Handle<String> source, |
| 513 ScriptOrigin* origin = NULL, | 513 ScriptOrigin* origin = NULL, |
| 514 ScriptData* pre_data = NULL); | 514 ScriptData* pre_data = NULL); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 528 /** | 528 /** |
| 529 * Returns the script id value. | 529 * Returns the script id value. |
| 530 */ | 530 */ |
| 531 Local<Value> Id(); | 531 Local<Value> Id(); |
| 532 }; | 532 }; |
| 533 | 533 |
| 534 | 534 |
| 535 /** | 535 /** |
| 536 * An error message. | 536 * An error message. |
| 537 */ | 537 */ |
| 538 class EXPORT Message { | 538 class V8EXPORT Message { |
| 539 public: | 539 public: |
| 540 Local<String> Get() const; | 540 Local<String> Get() const; |
| 541 Local<String> GetSourceLine() const; | 541 Local<String> GetSourceLine() const; |
| 542 | 542 |
| 543 Handle<Value> GetScriptResourceName() const; | 543 Handle<Value> GetScriptResourceName() const; |
| 544 | 544 |
| 545 /** | 545 /** |
| 546 * Returns the number, 1-based, of the line where the error occurred. | 546 * Returns the number, 1-based, of the line where the error occurred. |
| 547 */ | 547 */ |
| 548 int GetLineNumber() const; | 548 int GetLineNumber() const; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 575 static void PrintCurrentStackTrace(FILE* out); | 575 static void PrintCurrentStackTrace(FILE* out); |
| 576 }; | 576 }; |
| 577 | 577 |
| 578 | 578 |
| 579 // --- V a l u e --- | 579 // --- V a l u e --- |
| 580 | 580 |
| 581 | 581 |
| 582 /** | 582 /** |
| 583 * The superclass of all JavaScript values and objects. | 583 * The superclass of all JavaScript values and objects. |
| 584 */ | 584 */ |
| 585 class EXPORT Value : public Data { | 585 class V8EXPORT Value : public Data { |
| 586 public: | 586 public: |
| 587 | 587 |
| 588 /** | 588 /** |
| 589 * Returns true if this value is the undefined value. See ECMA-262 | 589 * Returns true if this value is the undefined value. See ECMA-262 |
| 590 * 4.3.10. | 590 * 4.3.10. |
| 591 */ | 591 */ |
| 592 bool IsUndefined() const; | 592 bool IsUndefined() const; |
| 593 | 593 |
| 594 /** | 594 /** |
| 595 * Returns true if this value is the null value. See ECMA-262 | 595 * Returns true if this value is the null value. See ECMA-262 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 | 676 |
| 677 /** JS == */ | 677 /** JS == */ |
| 678 bool Equals(Handle<Value> that) const; | 678 bool Equals(Handle<Value> that) const; |
| 679 bool StrictEquals(Handle<Value> that) const; | 679 bool StrictEquals(Handle<Value> that) const; |
| 680 }; | 680 }; |
| 681 | 681 |
| 682 | 682 |
| 683 /** | 683 /** |
| 684 * The superclass of primitive values. See ECMA-262 4.3.2. | 684 * The superclass of primitive values. See ECMA-262 4.3.2. |
| 685 */ | 685 */ |
| 686 class EXPORT Primitive : public Value { }; | 686 class V8EXPORT Primitive : public Value { }; |
| 687 | 687 |
| 688 | 688 |
| 689 /** | 689 /** |
| 690 * A primitive boolean value (ECMA-262, 4.3.14). Either the true | 690 * A primitive boolean value (ECMA-262, 4.3.14). Either the true |
| 691 * or false value. | 691 * or false value. |
| 692 */ | 692 */ |
| 693 class EXPORT Boolean : public Primitive { | 693 class V8EXPORT Boolean : public Primitive { |
| 694 public: | 694 public: |
| 695 bool Value() const; | 695 bool Value() const; |
| 696 static inline Handle<Boolean> New(bool value); | 696 static inline Handle<Boolean> New(bool value); |
| 697 }; | 697 }; |
| 698 | 698 |
| 699 | 699 |
| 700 /** | 700 /** |
| 701 * A JavaScript string value (ECMA-262, 4.3.17). | 701 * A JavaScript string value (ECMA-262, 4.3.17). |
| 702 */ | 702 */ |
| 703 class EXPORT String : public Primitive { | 703 class V8EXPORT String : public Primitive { |
| 704 public: | 704 public: |
| 705 | 705 |
| 706 /** | 706 /** |
| 707 * Returns the number of characters in this string. | 707 * Returns the number of characters in this string. |
| 708 */ | 708 */ |
| 709 int Length() const; | 709 int Length() const; |
| 710 | 710 |
| 711 /** | 711 /** |
| 712 * Returns the number of bytes in the UTF-8 encoded | 712 * Returns the number of bytes in the UTF-8 encoded |
| 713 * representation of this string. | 713 * representation of this string. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 743 /** | 743 /** |
| 744 * Returns true if the string is both external and ascii | 744 * Returns true if the string is both external and ascii |
| 745 */ | 745 */ |
| 746 bool IsExternalAscii() const; | 746 bool IsExternalAscii() const; |
| 747 /** | 747 /** |
| 748 * An ExternalStringResource is a wrapper around a two-byte string | 748 * An ExternalStringResource is a wrapper around a two-byte string |
| 749 * buffer that resides outside V8's heap. Implement an | 749 * buffer that resides outside V8's heap. Implement an |
| 750 * ExternalStringResource to manage the life cycle of the underlying | 750 * ExternalStringResource to manage the life cycle of the underlying |
| 751 * buffer. Note that the string data must be immutable. | 751 * buffer. Note that the string data must be immutable. |
| 752 */ | 752 */ |
| 753 class EXPORT ExternalStringResource { // NOLINT | 753 class V8EXPORT ExternalStringResource { // NOLINT |
| 754 public: | 754 public: |
| 755 /** | 755 /** |
| 756 * Override the destructor to manage the life cycle of the underlying | 756 * Override the destructor to manage the life cycle of the underlying |
| 757 * buffer. | 757 * buffer. |
| 758 */ | 758 */ |
| 759 virtual ~ExternalStringResource() {} | 759 virtual ~ExternalStringResource() {} |
| 760 /** The string data from the underlying buffer.*/ | 760 /** The string data from the underlying buffer.*/ |
| 761 virtual const uint16_t* data() const = 0; | 761 virtual const uint16_t* data() const = 0; |
| 762 /** The length of the string. That is, the number of two-byte characters.*/ | 762 /** The length of the string. That is, the number of two-byte characters.*/ |
| 763 virtual size_t length() const = 0; | 763 virtual size_t length() const = 0; |
| 764 protected: | 764 protected: |
| 765 ExternalStringResource() {} | 765 ExternalStringResource() {} |
| 766 private: | 766 private: |
| 767 // Disallow copying and assigning. | 767 // Disallow copying and assigning. |
| 768 ExternalStringResource(const ExternalStringResource&); | 768 ExternalStringResource(const ExternalStringResource&); |
| 769 void operator=(const ExternalStringResource&); | 769 void operator=(const ExternalStringResource&); |
| 770 }; | 770 }; |
| 771 | 771 |
| 772 /** | 772 /** |
| 773 * An ExternalAsciiStringResource is a wrapper around an ascii | 773 * An ExternalAsciiStringResource is a wrapper around an ascii |
| 774 * string buffer that resides outside V8's heap. Implement an | 774 * string buffer that resides outside V8's heap. Implement an |
| 775 * ExternalAsciiStringResource to manage the life cycle of the | 775 * ExternalAsciiStringResource to manage the life cycle of the |
| 776 * underlying buffer. Note that the string data must be immutable | 776 * underlying buffer. Note that the string data must be immutable |
| 777 * and that the data must be strict 7-bit ASCII, not Latin1 or | 777 * and that the data must be strict 7-bit ASCII, not Latin1 or |
| 778 * UTF-8, which would require special treatment internally in the | 778 * UTF-8, which would require special treatment internally in the |
| 779 * engine and, in the case of UTF-8, do not allow efficient indexing. | 779 * engine and, in the case of UTF-8, do not allow efficient indexing. |
| 780 * Use String::New or convert to 16 bit data for non-ASCII. | 780 * Use String::New or convert to 16 bit data for non-ASCII. |
| 781 */ | 781 */ |
| 782 | 782 |
| 783 class EXPORT ExternalAsciiStringResource { // NOLINT | 783 class V8EXPORT ExternalAsciiStringResource { // NOLINT |
| 784 public: | 784 public: |
| 785 /** | 785 /** |
| 786 * Override the destructor to manage the life cycle of the underlying | 786 * Override the destructor to manage the life cycle of the underlying |
| 787 * buffer. | 787 * buffer. |
| 788 */ | 788 */ |
| 789 virtual ~ExternalAsciiStringResource() {} | 789 virtual ~ExternalAsciiStringResource() {} |
| 790 /** The string data from the underlying buffer.*/ | 790 /** The string data from the underlying buffer.*/ |
| 791 virtual const char* data() const = 0; | 791 virtual const char* data() const = 0; |
| 792 /** The number of ascii characters in the string.*/ | 792 /** The number of ascii characters in the string.*/ |
| 793 virtual size_t length() const = 0; | 793 virtual size_t length() const = 0; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 /** Creates an undetectable string from the supplied ascii or utf-8 data.*/ | 873 /** Creates an undetectable string from the supplied ascii or utf-8 data.*/ |
| 874 static Local<String> NewUndetectable(const char* data, int length = -1); | 874 static Local<String> NewUndetectable(const char* data, int length = -1); |
| 875 | 875 |
| 876 /** Creates an undetectable string from the supplied utf-16 data.*/ | 876 /** Creates an undetectable string from the supplied utf-16 data.*/ |
| 877 static Local<String> NewUndetectable(const uint16_t* data, int length = -1); | 877 static Local<String> NewUndetectable(const uint16_t* data, int length = -1); |
| 878 | 878 |
| 879 /** | 879 /** |
| 880 * Converts an object to a utf8-encoded character array. Useful if | 880 * Converts an object to a utf8-encoded character array. Useful if |
| 881 * you want to print the object. | 881 * you want to print the object. |
| 882 */ | 882 */ |
| 883 class EXPORT Utf8Value { | 883 class V8EXPORT Utf8Value { |
| 884 public: | 884 public: |
| 885 explicit Utf8Value(Handle<v8::Value> obj); | 885 explicit Utf8Value(Handle<v8::Value> obj); |
| 886 ~Utf8Value(); | 886 ~Utf8Value(); |
| 887 char* operator*() const { return str_; } | 887 char* operator*() const { return str_; } |
| 888 int length() { return length_; } | 888 int length() { return length_; } |
| 889 private: | 889 private: |
| 890 char* str_; | 890 char* str_; |
| 891 int length_; | 891 int length_; |
| 892 | 892 |
| 893 // Disallow copying and assigning. | 893 // Disallow copying and assigning. |
| 894 Utf8Value(const Utf8Value&); | 894 Utf8Value(const Utf8Value&); |
| 895 void operator=(const Utf8Value&); | 895 void operator=(const Utf8Value&); |
| 896 }; | 896 }; |
| 897 | 897 |
| 898 /** | 898 /** |
| 899 * Converts an object to an ascii string. | 899 * Converts an object to an ascii string. |
| 900 * Useful if you want to print the object. | 900 * Useful if you want to print the object. |
| 901 */ | 901 */ |
| 902 class EXPORT AsciiValue { | 902 class V8EXPORT AsciiValue { |
| 903 public: | 903 public: |
| 904 explicit AsciiValue(Handle<v8::Value> obj); | 904 explicit AsciiValue(Handle<v8::Value> obj); |
| 905 ~AsciiValue(); | 905 ~AsciiValue(); |
| 906 char* operator*() const { return str_; } | 906 char* operator*() const { return str_; } |
| 907 int length() { return length_; } | 907 int length() { return length_; } |
| 908 private: | 908 private: |
| 909 char* str_; | 909 char* str_; |
| 910 int length_; | 910 int length_; |
| 911 | 911 |
| 912 // Disallow copying and assigning. | 912 // Disallow copying and assigning. |
| 913 AsciiValue(const AsciiValue&); | 913 AsciiValue(const AsciiValue&); |
| 914 void operator=(const AsciiValue&); | 914 void operator=(const AsciiValue&); |
| 915 }; | 915 }; |
| 916 | 916 |
| 917 /** | 917 /** |
| 918 * Converts an object to a two-byte string. | 918 * Converts an object to a two-byte string. |
| 919 */ | 919 */ |
| 920 class EXPORT Value { | 920 class V8EXPORT Value { |
| 921 public: | 921 public: |
| 922 explicit Value(Handle<v8::Value> obj); | 922 explicit Value(Handle<v8::Value> obj); |
| 923 ~Value(); | 923 ~Value(); |
| 924 uint16_t* operator*() const { return str_; } | 924 uint16_t* operator*() const { return str_; } |
| 925 int length() { return length_; } | 925 int length() { return length_; } |
| 926 private: | 926 private: |
| 927 uint16_t* str_; | 927 uint16_t* str_; |
| 928 int length_; | 928 int length_; |
| 929 | 929 |
| 930 // Disallow copying and assigning. | 930 // Disallow copying and assigning. |
| 931 Value(const Value&); | 931 Value(const Value&); |
| 932 void operator=(const Value&); | 932 void operator=(const Value&); |
| 933 }; | 933 }; |
| 934 }; | 934 }; |
| 935 | 935 |
| 936 | 936 |
| 937 /** | 937 /** |
| 938 * A JavaScript number value (ECMA-262, 4.3.20) | 938 * A JavaScript number value (ECMA-262, 4.3.20) |
| 939 */ | 939 */ |
| 940 class EXPORT Number : public Primitive { | 940 class V8EXPORT Number : public Primitive { |
| 941 public: | 941 public: |
| 942 double Value() const; | 942 double Value() const; |
| 943 static Local<Number> New(double value); | 943 static Local<Number> New(double value); |
| 944 static Number* Cast(v8::Value* obj); | 944 static Number* Cast(v8::Value* obj); |
| 945 private: | 945 private: |
| 946 Number(); | 946 Number(); |
| 947 }; | 947 }; |
| 948 | 948 |
| 949 | 949 |
| 950 /** | 950 /** |
| 951 * A JavaScript value representing a signed integer. | 951 * A JavaScript value representing a signed integer. |
| 952 */ | 952 */ |
| 953 class EXPORT Integer : public Number { | 953 class V8EXPORT Integer : public Number { |
| 954 public: | 954 public: |
| 955 static Local<Integer> New(int32_t value); | 955 static Local<Integer> New(int32_t value); |
| 956 int64_t Value() const; | 956 int64_t Value() const; |
| 957 static Integer* Cast(v8::Value* obj); | 957 static Integer* Cast(v8::Value* obj); |
| 958 private: | 958 private: |
| 959 Integer(); | 959 Integer(); |
| 960 }; | 960 }; |
| 961 | 961 |
| 962 | 962 |
| 963 /** | 963 /** |
| 964 * A JavaScript value representing a 32-bit signed integer. | 964 * A JavaScript value representing a 32-bit signed integer. |
| 965 */ | 965 */ |
| 966 class EXPORT Int32 : public Integer { | 966 class V8EXPORT Int32 : public Integer { |
| 967 public: | 967 public: |
| 968 int32_t Value() const; | 968 int32_t Value() const; |
| 969 private: | 969 private: |
| 970 Int32(); | 970 Int32(); |
| 971 }; | 971 }; |
| 972 | 972 |
| 973 | 973 |
| 974 /** | 974 /** |
| 975 * A JavaScript value representing a 32-bit unsigned integer. | 975 * A JavaScript value representing a 32-bit unsigned integer. |
| 976 */ | 976 */ |
| 977 class EXPORT Uint32 : public Integer { | 977 class V8EXPORT Uint32 : public Integer { |
| 978 public: | 978 public: |
| 979 uint32_t Value() const; | 979 uint32_t Value() const; |
| 980 private: | 980 private: |
| 981 Uint32(); | 981 Uint32(); |
| 982 }; | 982 }; |
| 983 | 983 |
| 984 | 984 |
| 985 /** | 985 /** |
| 986 * An instance of the built-in Date constructor (ECMA-262, 15.9). | 986 * An instance of the built-in Date constructor (ECMA-262, 15.9). |
| 987 */ | 987 */ |
| 988 class EXPORT Date : public Value { | 988 class V8EXPORT Date : public Value { |
| 989 public: | 989 public: |
| 990 static Local<Value> New(double time); | 990 static Local<Value> New(double time); |
| 991 | 991 |
| 992 /** | 992 /** |
| 993 * A specialization of Value::NumberValue that is more efficient | 993 * A specialization of Value::NumberValue that is more efficient |
| 994 * because we know the structure of this object. | 994 * because we know the structure of this object. |
| 995 */ | 995 */ |
| 996 double NumberValue() const; | 996 double NumberValue() const; |
| 997 | 997 |
| 998 static Date* Cast(v8::Value* obj); | 998 static Date* Cast(v8::Value* obj); |
| 999 }; | 999 }; |
| 1000 | 1000 |
| 1001 | 1001 |
| 1002 enum PropertyAttribute { | 1002 enum PropertyAttribute { |
| 1003 None = 0, | 1003 None = 0, |
| 1004 ReadOnly = 1 << 0, | 1004 ReadOnly = 1 << 0, |
| 1005 DontEnum = 1 << 1, | 1005 DontEnum = 1 << 1, |
| 1006 DontDelete = 1 << 2 | 1006 DontDelete = 1 << 2 |
| 1007 }; | 1007 }; |
| 1008 | 1008 |
| 1009 /** | 1009 /** |
| 1010 * A JavaScript object (ECMA-262, 4.3.3) | 1010 * A JavaScript object (ECMA-262, 4.3.3) |
| 1011 */ | 1011 */ |
| 1012 class EXPORT Object : public Value { | 1012 class V8EXPORT Object : public Value { |
| 1013 public: | 1013 public: |
| 1014 bool Set(Handle<Value> key, | 1014 bool Set(Handle<Value> key, |
| 1015 Handle<Value> value, | 1015 Handle<Value> value, |
| 1016 PropertyAttribute attribs = None); | 1016 PropertyAttribute attribs = None); |
| 1017 Local<Value> Get(Handle<Value> key); | 1017 Local<Value> Get(Handle<Value> key); |
| 1018 | 1018 |
| 1019 // TODO(1245389): Replace the type-specific versions of these | 1019 // TODO(1245389): Replace the type-specific versions of these |
| 1020 // functions with generic ones that accept a Handle<Value> key. | 1020 // functions with generic ones that accept a Handle<Value> key. |
| 1021 bool Has(Handle<String> key); | 1021 bool Has(Handle<String> key); |
| 1022 bool Delete(Handle<String> key); | 1022 bool Delete(Handle<String> key); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 static Local<Object> New(); | 1079 static Local<Object> New(); |
| 1080 static Object* Cast(Value* obj); | 1080 static Object* Cast(Value* obj); |
| 1081 private: | 1081 private: |
| 1082 Object(); | 1082 Object(); |
| 1083 }; | 1083 }; |
| 1084 | 1084 |
| 1085 | 1085 |
| 1086 /** | 1086 /** |
| 1087 * An instance of the built-in array constructor (ECMA-262, 15.4.2). | 1087 * An instance of the built-in array constructor (ECMA-262, 15.4.2). |
| 1088 */ | 1088 */ |
| 1089 class EXPORT Array : public Object { | 1089 class V8EXPORT Array : public Object { |
| 1090 public: | 1090 public: |
| 1091 uint32_t Length() const; | 1091 uint32_t Length() const; |
| 1092 | 1092 |
| 1093 static Local<Array> New(int length = 0); | 1093 static Local<Array> New(int length = 0); |
| 1094 static Array* Cast(Value* obj); | 1094 static Array* Cast(Value* obj); |
| 1095 private: | 1095 private: |
| 1096 Array(); | 1096 Array(); |
| 1097 }; | 1097 }; |
| 1098 | 1098 |
| 1099 | 1099 |
| 1100 /** | 1100 /** |
| 1101 * A JavaScript function object (ECMA-262, 15.3). | 1101 * A JavaScript function object (ECMA-262, 15.3). |
| 1102 */ | 1102 */ |
| 1103 class EXPORT Function : public Object { | 1103 class V8EXPORT Function : public Object { |
| 1104 public: | 1104 public: |
| 1105 Local<Object> NewInstance() const; | 1105 Local<Object> NewInstance() const; |
| 1106 Local<Object> NewInstance(int argc, Handle<Value> argv[]) const; | 1106 Local<Object> NewInstance(int argc, Handle<Value> argv[]) const; |
| 1107 Local<Value> Call(Handle<Object> recv, int argc, Handle<Value> argv[]); | 1107 Local<Value> Call(Handle<Object> recv, int argc, Handle<Value> argv[]); |
| 1108 void SetName(Handle<String> name); | 1108 void SetName(Handle<String> name); |
| 1109 Handle<Value> GetName() const; | 1109 Handle<Value> GetName() const; |
| 1110 static Function* Cast(Value* obj); | 1110 static Function* Cast(Value* obj); |
| 1111 private: | 1111 private: |
| 1112 Function(); | 1112 Function(); |
| 1113 }; | 1113 }; |
| 1114 | 1114 |
| 1115 | 1115 |
| 1116 /** | 1116 /** |
| 1117 * A JavaScript value that wraps a c++ void*. This type of value is | 1117 * A JavaScript value that wraps a c++ void*. This type of value is |
| 1118 * mainly used to associate c++ data structures with JavaScript | 1118 * mainly used to associate c++ data structures with JavaScript |
| 1119 * objects. | 1119 * objects. |
| 1120 */ | 1120 */ |
| 1121 class EXPORT External : public Value { | 1121 class V8EXPORT External : public Value { |
| 1122 public: | 1122 public: |
| 1123 static Local<External> New(void* value); | 1123 static Local<External> New(void* value); |
| 1124 static External* Cast(Value* obj); | 1124 static External* Cast(Value* obj); |
| 1125 void* Value() const; | 1125 void* Value() const; |
| 1126 private: | 1126 private: |
| 1127 External(); | 1127 External(); |
| 1128 }; | 1128 }; |
| 1129 | 1129 |
| 1130 | 1130 |
| 1131 // --- T e m p l a t e s --- | 1131 // --- T e m p l a t e s --- |
| 1132 | 1132 |
| 1133 | 1133 |
| 1134 /** | 1134 /** |
| 1135 * The superclass of object and function templates. | 1135 * The superclass of object and function templates. |
| 1136 */ | 1136 */ |
| 1137 class EXPORT Template : public Data { | 1137 class V8EXPORT Template : public Data { |
| 1138 public: | 1138 public: |
| 1139 /** Adds a property to each instance created by this template.*/ | 1139 /** Adds a property to each instance created by this template.*/ |
| 1140 void Set(Handle<String> name, Handle<Data> value, | 1140 void Set(Handle<String> name, Handle<Data> value, |
| 1141 PropertyAttribute attributes = None); | 1141 PropertyAttribute attributes = None); |
| 1142 inline void Set(const char* name, Handle<Data> value); | 1142 inline void Set(const char* name, Handle<Data> value); |
| 1143 private: | 1143 private: |
| 1144 Template(); | 1144 Template(); |
| 1145 | 1145 |
| 1146 friend class ObjectTemplate; | 1146 friend class ObjectTemplate; |
| 1147 friend class FunctionTemplate; | 1147 friend class FunctionTemplate; |
| 1148 }; | 1148 }; |
| 1149 | 1149 |
| 1150 | 1150 |
| 1151 /** | 1151 /** |
| 1152 * The argument information given to function call callbacks. This | 1152 * The argument information given to function call callbacks. This |
| 1153 * class provides access to information about the context of the call, | 1153 * class provides access to information about the context of the call, |
| 1154 * including the receiver, the number and values of arguments, and | 1154 * including the receiver, the number and values of arguments, and |
| 1155 * the holder of the function. | 1155 * the holder of the function. |
| 1156 */ | 1156 */ |
| 1157 class EXPORT Arguments { | 1157 class V8EXPORT Arguments { |
| 1158 public: | 1158 public: |
| 1159 inline int Length() const; | 1159 inline int Length() const; |
| 1160 inline Local<Value> operator[](int i) const; | 1160 inline Local<Value> operator[](int i) const; |
| 1161 inline Local<Function> Callee() const; | 1161 inline Local<Function> Callee() const; |
| 1162 inline Local<Object> This() const; | 1162 inline Local<Object> This() const; |
| 1163 inline Local<Object> Holder() const; | 1163 inline Local<Object> Holder() const; |
| 1164 inline bool IsConstructCall() const; | 1164 inline bool IsConstructCall() const; |
| 1165 inline Local<Value> Data() const; | 1165 inline Local<Value> Data() const; |
| 1166 private: | 1166 private: |
| 1167 Arguments(); | 1167 Arguments(); |
| 1168 friend class ImplementationUtilities; | 1168 friend class ImplementationUtilities; |
| 1169 inline Arguments(Local<Value> data, | 1169 inline Arguments(Local<Value> data, |
| 1170 Local<Object> holder, | 1170 Local<Object> holder, |
| 1171 Local<Function> callee, | 1171 Local<Function> callee, |
| 1172 bool is_construct_call, | 1172 bool is_construct_call, |
| 1173 void** values, int length); | 1173 void** values, int length); |
| 1174 Local<Value> data_; | 1174 Local<Value> data_; |
| 1175 Local<Object> holder_; | 1175 Local<Object> holder_; |
| 1176 Local<Function> callee_; | 1176 Local<Function> callee_; |
| 1177 bool is_construct_call_; | 1177 bool is_construct_call_; |
| 1178 void** values_; | 1178 void** values_; |
| 1179 int length_; | 1179 int length_; |
| 1180 }; | 1180 }; |
| 1181 | 1181 |
| 1182 | 1182 |
| 1183 /** | 1183 /** |
| 1184 * The information passed to an accessor callback about the context | 1184 * The information passed to an accessor callback about the context |
| 1185 * of the property access. | 1185 * of the property access. |
| 1186 */ | 1186 */ |
| 1187 class EXPORT AccessorInfo { | 1187 class V8EXPORT AccessorInfo { |
| 1188 public: | 1188 public: |
| 1189 inline AccessorInfo(Local<Object> self, | 1189 inline AccessorInfo(Local<Object> self, |
| 1190 Local<Value> data, | 1190 Local<Value> data, |
| 1191 Local<Object> holder) | 1191 Local<Object> holder) |
| 1192 : self_(self), data_(data), holder_(holder) { } | 1192 : self_(self), data_(data), holder_(holder) { } |
| 1193 inline Local<Value> Data() const; | 1193 inline Local<Value> Data() const; |
| 1194 inline Local<Object> This() const; | 1194 inline Local<Object> This() const; |
| 1195 inline Local<Object> Holder() const; | 1195 inline Local<Object> Holder() const; |
| 1196 private: | 1196 private: |
| 1197 Local<Object> self_; | 1197 Local<Object> self_; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 * | 1431 * |
| 1432 * The Child function and Child instance will have the following | 1432 * The Child function and Child instance will have the following |
| 1433 * properties: | 1433 * properties: |
| 1434 * | 1434 * |
| 1435 * \code | 1435 * \code |
| 1436 * child_func.prototype.__proto__ == function.prototype; | 1436 * child_func.prototype.__proto__ == function.prototype; |
| 1437 * child_instance.instance_accessor calls 'InstanceAccessorCallback' | 1437 * child_instance.instance_accessor calls 'InstanceAccessorCallback' |
| 1438 * child_instance.instance_property == 3; | 1438 * child_instance.instance_property == 3; |
| 1439 * \endcode | 1439 * \endcode |
| 1440 */ | 1440 */ |
| 1441 class EXPORT FunctionTemplate : public Template { | 1441 class V8EXPORT FunctionTemplate : public Template { |
| 1442 public: | 1442 public: |
| 1443 /** Creates a function template.*/ | 1443 /** Creates a function template.*/ |
| 1444 static Local<FunctionTemplate> New( | 1444 static Local<FunctionTemplate> New( |
| 1445 InvocationCallback callback = 0, | 1445 InvocationCallback callback = 0, |
| 1446 Handle<Value> data = Handle<Value>(), | 1446 Handle<Value> data = Handle<Value>(), |
| 1447 Handle<Signature> signature = Handle<Signature>()); | 1447 Handle<Signature> signature = Handle<Signature>()); |
| 1448 /** Returns the unique function instance in the current execution context.*/ | 1448 /** Returns the unique function instance in the current execution context.*/ |
| 1449 Local<Function> GetFunction(); | 1449 Local<Function> GetFunction(); |
| 1450 | 1450 |
| 1451 /** | 1451 /** |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1523 friend class ObjectTemplate; | 1523 friend class ObjectTemplate; |
| 1524 }; | 1524 }; |
| 1525 | 1525 |
| 1526 | 1526 |
| 1527 /** | 1527 /** |
| 1528 * An ObjectTemplate is used to create objects at runtime. | 1528 * An ObjectTemplate is used to create objects at runtime. |
| 1529 * | 1529 * |
| 1530 * Properties added to an ObjectTemplate are added to each object | 1530 * Properties added to an ObjectTemplate are added to each object |
| 1531 * created from the ObjectTemplate. | 1531 * created from the ObjectTemplate. |
| 1532 */ | 1532 */ |
| 1533 class EXPORT ObjectTemplate : public Template { | 1533 class V8EXPORT ObjectTemplate : public Template { |
| 1534 public: | 1534 public: |
| 1535 /** Creates an ObjectTemplate. */ | 1535 /** Creates an ObjectTemplate. */ |
| 1536 static Local<ObjectTemplate> New(); | 1536 static Local<ObjectTemplate> New(); |
| 1537 | 1537 |
| 1538 /** Creates a new instance of this template.*/ | 1538 /** Creates a new instance of this template.*/ |
| 1539 Local<Object> NewInstance(); | 1539 Local<Object> NewInstance(); |
| 1540 | 1540 |
| 1541 /** | 1541 /** |
| 1542 * Sets an accessor on the object template. | 1542 * Sets an accessor on the object template. |
| 1543 * | 1543 * |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1665 ObjectTemplate(); | 1665 ObjectTemplate(); |
| 1666 static Local<ObjectTemplate> New(Handle<FunctionTemplate> constructor); | 1666 static Local<ObjectTemplate> New(Handle<FunctionTemplate> constructor); |
| 1667 friend class FunctionTemplate; | 1667 friend class FunctionTemplate; |
| 1668 }; | 1668 }; |
| 1669 | 1669 |
| 1670 | 1670 |
| 1671 /** | 1671 /** |
| 1672 * A Signature specifies which receivers and arguments a function can | 1672 * A Signature specifies which receivers and arguments a function can |
| 1673 * legally be called with. | 1673 * legally be called with. |
| 1674 */ | 1674 */ |
| 1675 class EXPORT Signature : public Data { | 1675 class V8EXPORT Signature : public Data { |
| 1676 public: | 1676 public: |
| 1677 static Local<Signature> New(Handle<FunctionTemplate> receiver = | 1677 static Local<Signature> New(Handle<FunctionTemplate> receiver = |
| 1678 Handle<FunctionTemplate>(), | 1678 Handle<FunctionTemplate>(), |
| 1679 int argc = 0, | 1679 int argc = 0, |
| 1680 Handle<FunctionTemplate> argv[] = 0); | 1680 Handle<FunctionTemplate> argv[] = 0); |
| 1681 private: | 1681 private: |
| 1682 Signature(); | 1682 Signature(); |
| 1683 }; | 1683 }; |
| 1684 | 1684 |
| 1685 | 1685 |
| 1686 /** | 1686 /** |
| 1687 * A utility for determining the type of objects based on the template | 1687 * A utility for determining the type of objects based on the template |
| 1688 * they were constructed from. | 1688 * they were constructed from. |
| 1689 */ | 1689 */ |
| 1690 class EXPORT TypeSwitch : public Data { | 1690 class V8EXPORT TypeSwitch : public Data { |
| 1691 public: | 1691 public: |
| 1692 static Local<TypeSwitch> New(Handle<FunctionTemplate> type); | 1692 static Local<TypeSwitch> New(Handle<FunctionTemplate> type); |
| 1693 static Local<TypeSwitch> New(int argc, Handle<FunctionTemplate> types[]); | 1693 static Local<TypeSwitch> New(int argc, Handle<FunctionTemplate> types[]); |
| 1694 int match(Handle<Value> value); | 1694 int match(Handle<Value> value); |
| 1695 private: | 1695 private: |
| 1696 TypeSwitch(); | 1696 TypeSwitch(); |
| 1697 }; | 1697 }; |
| 1698 | 1698 |
| 1699 | 1699 |
| 1700 // --- E x t e n s i o n s --- | 1700 // --- E x t e n s i o n s --- |
| 1701 | 1701 |
| 1702 | 1702 |
| 1703 /** | 1703 /** |
| 1704 * Ignore | 1704 * Ignore |
| 1705 */ | 1705 */ |
| 1706 class EXPORT Extension { // NOLINT | 1706 class V8EXPORT Extension { // NOLINT |
| 1707 public: | 1707 public: |
| 1708 Extension(const char* name, | 1708 Extension(const char* name, |
| 1709 const char* source = 0, | 1709 const char* source = 0, |
| 1710 int dep_count = 0, | 1710 int dep_count = 0, |
| 1711 const char** deps = 0); | 1711 const char** deps = 0); |
| 1712 virtual ~Extension() { } | 1712 virtual ~Extension() { } |
| 1713 virtual v8::Handle<v8::FunctionTemplate> | 1713 virtual v8::Handle<v8::FunctionTemplate> |
| 1714 GetNativeFunction(v8::Handle<v8::String> name) { | 1714 GetNativeFunction(v8::Handle<v8::String> name) { |
| 1715 return v8::Handle<v8::FunctionTemplate>(); | 1715 return v8::Handle<v8::FunctionTemplate>(); |
| 1716 } | 1716 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1728 int dep_count_; | 1728 int dep_count_; |
| 1729 const char** deps_; | 1729 const char** deps_; |
| 1730 bool auto_enable_; | 1730 bool auto_enable_; |
| 1731 | 1731 |
| 1732 // Disallow copying and assigning. | 1732 // Disallow copying and assigning. |
| 1733 Extension(const Extension&); | 1733 Extension(const Extension&); |
| 1734 void operator=(const Extension&); | 1734 void operator=(const Extension&); |
| 1735 }; | 1735 }; |
| 1736 | 1736 |
| 1737 | 1737 |
| 1738 void EXPORT RegisterExtension(Extension* extension); | 1738 void V8EXPORT RegisterExtension(Extension* extension); |
| 1739 | 1739 |
| 1740 | 1740 |
| 1741 /** | 1741 /** |
| 1742 * Ignore | 1742 * Ignore |
| 1743 */ | 1743 */ |
| 1744 class EXPORT DeclareExtension { | 1744 class V8EXPORT DeclareExtension { |
| 1745 public: | 1745 public: |
| 1746 inline DeclareExtension(Extension* extension) { | 1746 inline DeclareExtension(Extension* extension) { |
| 1747 RegisterExtension(extension); | 1747 RegisterExtension(extension); |
| 1748 } | 1748 } |
| 1749 }; | 1749 }; |
| 1750 | 1750 |
| 1751 | 1751 |
| 1752 // --- S t a t i c s --- | 1752 // --- S t a t i c s --- |
| 1753 | 1753 |
| 1754 | 1754 |
| 1755 Handle<Primitive> EXPORT Undefined(); | 1755 Handle<Primitive> V8EXPORT Undefined(); |
| 1756 Handle<Primitive> EXPORT Null(); | 1756 Handle<Primitive> V8EXPORT Null(); |
| 1757 Handle<Boolean> EXPORT True(); | 1757 Handle<Boolean> V8EXPORT True(); |
| 1758 Handle<Boolean> EXPORT False(); | 1758 Handle<Boolean> V8EXPORT False(); |
| 1759 | 1759 |
| 1760 | 1760 |
| 1761 /** | 1761 /** |
| 1762 * A set of constraints that specifies the limits of the runtime's | 1762 * A set of constraints that specifies the limits of the runtime's |
| 1763 * memory use. | 1763 * memory use. |
| 1764 */ | 1764 */ |
| 1765 class EXPORT ResourceConstraints { | 1765 class V8EXPORT ResourceConstraints { |
| 1766 public: | 1766 public: |
| 1767 ResourceConstraints(); | 1767 ResourceConstraints(); |
| 1768 int max_young_space_size() const { return max_young_space_size_; } | 1768 int max_young_space_size() const { return max_young_space_size_; } |
| 1769 void set_max_young_space_size(int value) { max_young_space_size_ = value; } | 1769 void set_max_young_space_size(int value) { max_young_space_size_ = value; } |
| 1770 int max_old_space_size() const { return max_old_space_size_; } | 1770 int max_old_space_size() const { return max_old_space_size_; } |
| 1771 void set_max_old_space_size(int value) { max_old_space_size_ = value; } | 1771 void set_max_old_space_size(int value) { max_old_space_size_ = value; } |
| 1772 uint32_t* stack_limit() const { return stack_limit_; } | 1772 uint32_t* stack_limit() const { return stack_limit_; } |
| 1773 void set_stack_limit(uint32_t* value) { stack_limit_ = value; } | 1773 void set_stack_limit(uint32_t* value) { stack_limit_ = value; } |
| 1774 private: | 1774 private: |
| 1775 int max_young_space_size_; | 1775 int max_young_space_size_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1789 | 1789 |
| 1790 typedef void (*MessageCallback)(Handle<Message> message, Handle<Value> data); | 1790 typedef void (*MessageCallback)(Handle<Message> message, Handle<Value> data); |
| 1791 | 1791 |
| 1792 | 1792 |
| 1793 /** | 1793 /** |
| 1794 * Schedules an exception to be thrown when returning to JavaScript. When an | 1794 * Schedules an exception to be thrown when returning to JavaScript. When an |
| 1795 * exception has been scheduled it is illegal to invoke any JavaScript | 1795 * exception has been scheduled it is illegal to invoke any JavaScript |
| 1796 * operation; the caller must return immediately and only after the exception | 1796 * operation; the caller must return immediately and only after the exception |
| 1797 * has been handled does it become legal to invoke JavaScript operations. | 1797 * has been handled does it become legal to invoke JavaScript operations. |
| 1798 */ | 1798 */ |
| 1799 Handle<Value> EXPORT ThrowException(Handle<Value> exception); | 1799 Handle<Value> V8EXPORT ThrowException(Handle<Value> exception); |
| 1800 | 1800 |
| 1801 /** | 1801 /** |
| 1802 * Create new error objects by calling the corresponding error object | 1802 * Create new error objects by calling the corresponding error object |
| 1803 * constructor with the message. | 1803 * constructor with the message. |
| 1804 */ | 1804 */ |
| 1805 class EXPORT Exception { | 1805 class V8EXPORT Exception { |
| 1806 public: | 1806 public: |
| 1807 static Local<Value> RangeError(Handle<String> message); | 1807 static Local<Value> RangeError(Handle<String> message); |
| 1808 static Local<Value> ReferenceError(Handle<String> message); | 1808 static Local<Value> ReferenceError(Handle<String> message); |
| 1809 static Local<Value> SyntaxError(Handle<String> message); | 1809 static Local<Value> SyntaxError(Handle<String> message); |
| 1810 static Local<Value> TypeError(Handle<String> message); | 1810 static Local<Value> TypeError(Handle<String> message); |
| 1811 static Local<Value> Error(Handle<String> message); | 1811 static Local<Value> Error(Handle<String> message); |
| 1812 }; | 1812 }; |
| 1813 | 1813 |
| 1814 | 1814 |
| 1815 // --- C o u n t e r s C a l l b a c k s --- | 1815 // --- C o u n t e r s C a l l b a c k s --- |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1845 /** | 1845 /** |
| 1846 * Applications must provide a callback function which is called to generate | 1846 * Applications must provide a callback function which is called to generate |
| 1847 * a context if a context was not deserialized from the snapshot. | 1847 * a context if a context was not deserialized from the snapshot. |
| 1848 */ | 1848 */ |
| 1849 typedef Persistent<Context> (*ContextGenerator)(); | 1849 typedef Persistent<Context> (*ContextGenerator)(); |
| 1850 | 1850 |
| 1851 | 1851 |
| 1852 /** | 1852 /** |
| 1853 * Container class for static utility functions. | 1853 * Container class for static utility functions. |
| 1854 */ | 1854 */ |
| 1855 class EXPORT V8 { | 1855 class V8EXPORT V8 { |
| 1856 public: | 1856 public: |
| 1857 /** Set the callback to invoke in case of fatal errors. */ | 1857 /** Set the callback to invoke in case of fatal errors. */ |
| 1858 static void SetFatalErrorHandler(FatalErrorCallback that); | 1858 static void SetFatalErrorHandler(FatalErrorCallback that); |
| 1859 | 1859 |
| 1860 /** | 1860 /** |
| 1861 * Ignore out-of-memory exceptions. | 1861 * Ignore out-of-memory exceptions. |
| 1862 * | 1862 * |
| 1863 * V8 running out of memory is treated as a fatal error by default. | 1863 * V8 running out of memory is treated as a fatal error by default. |
| 1864 * This means that the fatal error handler is called and that V8 is | 1864 * This means that the fatal error handler is called and that V8 is |
| 1865 * terminated. | 1865 * terminated. |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2010 template <class T> friend class Handle; | 2010 template <class T> friend class Handle; |
| 2011 template <class T> friend class Local; | 2011 template <class T> friend class Local; |
| 2012 template <class T> friend class Persistent; | 2012 template <class T> friend class Persistent; |
| 2013 friend class Context; | 2013 friend class Context; |
| 2014 }; | 2014 }; |
| 2015 | 2015 |
| 2016 | 2016 |
| 2017 /** | 2017 /** |
| 2018 * An external exception handler. | 2018 * An external exception handler. |
| 2019 */ | 2019 */ |
| 2020 class EXPORT TryCatch { | 2020 class V8EXPORT TryCatch { |
| 2021 public: | 2021 public: |
| 2022 | 2022 |
| 2023 /** | 2023 /** |
| 2024 * Creates a new try/catch block and registers it with v8. | 2024 * Creates a new try/catch block and registers it with v8. |
| 2025 */ | 2025 */ |
| 2026 TryCatch(); | 2026 TryCatch(); |
| 2027 | 2027 |
| 2028 /** | 2028 /** |
| 2029 * Unregisters and deletes this try/catch block. | 2029 * Unregisters and deletes this try/catch block. |
| 2030 */ | 2030 */ |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2089 void* js_handler_; | 2089 void* js_handler_; |
| 2090 }; | 2090 }; |
| 2091 | 2091 |
| 2092 | 2092 |
| 2093 // --- C o n t e x t --- | 2093 // --- C o n t e x t --- |
| 2094 | 2094 |
| 2095 | 2095 |
| 2096 /** | 2096 /** |
| 2097 * Ignore | 2097 * Ignore |
| 2098 */ | 2098 */ |
| 2099 class EXPORT ExtensionConfiguration { | 2099 class V8EXPORT ExtensionConfiguration { |
| 2100 public: | 2100 public: |
| 2101 ExtensionConfiguration(int name_count, const char* names[]) | 2101 ExtensionConfiguration(int name_count, const char* names[]) |
| 2102 : name_count_(name_count), names_(names) { } | 2102 : name_count_(name_count), names_(names) { } |
| 2103 private: | 2103 private: |
| 2104 friend class ImplementationUtilities; | 2104 friend class ImplementationUtilities; |
| 2105 int name_count_; | 2105 int name_count_; |
| 2106 const char** names_; | 2106 const char** names_; |
| 2107 }; | 2107 }; |
| 2108 | 2108 |
| 2109 | 2109 |
| 2110 /** | 2110 /** |
| 2111 * A sandboxed execution context with its own set of built-in objects | 2111 * A sandboxed execution context with its own set of built-in objects |
| 2112 * and functions. | 2112 * and functions. |
| 2113 */ | 2113 */ |
| 2114 class EXPORT Context { | 2114 class V8EXPORT Context { |
| 2115 public: | 2115 public: |
| 2116 /** Returns the global object of the context. */ | 2116 /** Returns the global object of the context. */ |
| 2117 Local<Object> Global(); | 2117 Local<Object> Global(); |
| 2118 | 2118 |
| 2119 /** | 2119 /** |
| 2120 * Detaches the global object from its context before | 2120 * Detaches the global object from its context before |
| 2121 * the global object can be reused to create a new context. | 2121 * the global object can be reused to create a new context. |
| 2122 */ | 2122 */ |
| 2123 void DetachGlobal(); | 2123 void DetachGlobal(); |
| 2124 | 2124 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2163 /** Returns true if the context has experienced an out of memory situation. */ | 2163 /** Returns true if the context has experienced an out of memory situation. */ |
| 2164 bool HasOutOfMemoryException(); | 2164 bool HasOutOfMemoryException(); |
| 2165 | 2165 |
| 2166 /** Returns true if V8 has a current context. */ | 2166 /** Returns true if V8 has a current context. */ |
| 2167 static bool InContext(); | 2167 static bool InContext(); |
| 2168 | 2168 |
| 2169 /** | 2169 /** |
| 2170 * Stack-allocated class which sets the execution context for all | 2170 * Stack-allocated class which sets the execution context for all |
| 2171 * operations executed within a local scope. | 2171 * operations executed within a local scope. |
| 2172 */ | 2172 */ |
| 2173 class EXPORT Scope { | 2173 class V8EXPORT Scope { |
| 2174 public: | 2174 public: |
| 2175 inline Scope(Handle<Context> context) : context_(context) { | 2175 inline Scope(Handle<Context> context) : context_(context) { |
| 2176 context_->Enter(); | 2176 context_->Enter(); |
| 2177 } | 2177 } |
| 2178 inline ~Scope() { context_->Exit(); } | 2178 inline ~Scope() { context_->Exit(); } |
| 2179 private: | 2179 private: |
| 2180 Handle<Context> context_; | 2180 Handle<Context> context_; |
| 2181 }; | 2181 }; |
| 2182 | 2182 |
| 2183 private: | 2183 private: |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2249 * v8::Unlocker unlocker; | 2249 * v8::Unlocker unlocker; |
| 2250 * // V8 not locked. | 2250 * // V8 not locked. |
| 2251 * } | 2251 * } |
| 2252 * // V8 locked again (2 levels). | 2252 * // V8 locked again (2 levels). |
| 2253 * } | 2253 * } |
| 2254 * // V8 still locked (1 level). | 2254 * // V8 still locked (1 level). |
| 2255 * } | 2255 * } |
| 2256 * // V8 Now no longer locked. | 2256 * // V8 Now no longer locked. |
| 2257 * \endcode | 2257 * \endcode |
| 2258 */ | 2258 */ |
| 2259 class EXPORT Unlocker { | 2259 class V8EXPORT Unlocker { |
| 2260 public: | 2260 public: |
| 2261 Unlocker(); | 2261 Unlocker(); |
| 2262 ~Unlocker(); | 2262 ~Unlocker(); |
| 2263 }; | 2263 }; |
| 2264 | 2264 |
| 2265 | 2265 |
| 2266 class EXPORT Locker { | 2266 class V8EXPORT Locker { |
| 2267 public: | 2267 public: |
| 2268 Locker(); | 2268 Locker(); |
| 2269 ~Locker(); | 2269 ~Locker(); |
| 2270 | 2270 |
| 2271 /** | 2271 /** |
| 2272 * Start preemption. | 2272 * Start preemption. |
| 2273 * | 2273 * |
| 2274 * When preemption is started, a timer is fired every n milli seconds | 2274 * When preemption is started, a timer is fired every n milli seconds |
| 2275 * that will switch between multiple threads that are in contention | 2275 * that will switch between multiple threads that are in contention |
| 2276 * for the V8 lock. | 2276 * for the V8 lock. |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2467 | 2467 |
| 2468 | 2468 |
| 2469 /** | 2469 /** |
| 2470 * \example process.cc | 2470 * \example process.cc |
| 2471 */ | 2471 */ |
| 2472 | 2472 |
| 2473 | 2473 |
| 2474 } // namespace v8 | 2474 } // namespace v8 |
| 2475 | 2475 |
| 2476 | 2476 |
| 2477 #undef EXPORT | 2477 #undef V8EXPORT |
| 2478 #undef EXPORT_INLINE | 2478 #undef V8EXPORT_INLINE |
| 2479 #undef TYPE_CHECK | 2479 #undef TYPE_CHECK |
| 2480 | 2480 |
| 2481 | 2481 |
| 2482 #endif // V8_H_ | 2482 #endif // V8_H_ |
| OLD | NEW |