| 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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 private: | 448 private: |
| 449 friend class internal::GlobalHandles; | 449 friend class internal::GlobalHandles; |
| 450 WeakCallbackData(Isolate* isolate, Local<T> handle, P* parameter) | 450 WeakCallbackData(Isolate* isolate, Local<T> handle, P* parameter) |
| 451 : isolate_(isolate), handle_(handle), parameter_(parameter) { } | 451 : isolate_(isolate), handle_(handle), parameter_(parameter) { } |
| 452 Isolate* isolate_; | 452 Isolate* isolate_; |
| 453 Local<T> handle_; | 453 Local<T> handle_; |
| 454 P* parameter_; | 454 P* parameter_; |
| 455 }; | 455 }; |
| 456 | 456 |
| 457 | 457 |
| 458 // TODO(dcarney): Remove this class. | |
| 459 template<typename T, | |
| 460 typename P, | |
| 461 typename M = NonCopyablePersistentTraits<T> > | |
| 462 class WeakReferenceCallbacks { | |
| 463 public: | |
| 464 typedef void (*Revivable)(Isolate* isolate, | |
| 465 Persistent<T, M>* object, | |
| 466 P* parameter); | |
| 467 }; | |
| 468 | |
| 469 | |
| 470 /** | 458 /** |
| 471 * An object reference that is independent of any handle scope. Where | 459 * An object reference that is independent of any handle scope. Where |
| 472 * a Local handle only lives as long as the HandleScope in which it was | 460 * a Local handle only lives as long as the HandleScope in which it was |
| 473 * allocated, a PersistentBase handle remains valid until it is explicitly | 461 * allocated, a PersistentBase handle remains valid until it is explicitly |
| 474 * disposed. | 462 * disposed. |
| 475 * | 463 * |
| 476 * A persistent handle contains a reference to a storage cell within | 464 * A persistent handle contains a reference to a storage cell within |
| 477 * the v8 engine which holds an object value and which is updated by | 465 * the v8 engine which holds an object value and which is updated by |
| 478 * the garbage collector whenever the object is moved. A new storage | 466 * the garbage collector whenever the object is moved. A new storage |
| 479 * cell can be created using the constructor or PersistentBase::Reset and | 467 * cell can be created using the constructor or PersistentBase::Reset and |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 } | 682 } |
| 695 /** | 683 /** |
| 696 * The destructor will dispose the Persistent based on the | 684 * The destructor will dispose the Persistent based on the |
| 697 * kResetInDestructor flags in the traits class. Since not calling dispose | 685 * kResetInDestructor flags in the traits class. Since not calling dispose |
| 698 * can result in a memory leak, it is recommended to always set this flag. | 686 * can result in a memory leak, it is recommended to always set this flag. |
| 699 */ | 687 */ |
| 700 V8_INLINE ~Persistent() { | 688 V8_INLINE ~Persistent() { |
| 701 if (M::kResetInDestructor) this->Reset(); | 689 if (M::kResetInDestructor) this->Reset(); |
| 702 } | 690 } |
| 703 | 691 |
| 704 V8_DEPRECATED("Use Reset instead", | |
| 705 V8_INLINE void Dispose()) { this->Reset(); } | |
| 706 | |
| 707 // TODO(dcarney): this is pretty useless, fix or remove | 692 // TODO(dcarney): this is pretty useless, fix or remove |
| 708 template <class S> | 693 template <class S> |
| 709 V8_INLINE static Persistent<T>& Cast(Persistent<S>& that) { // NOLINT | 694 V8_INLINE static Persistent<T>& Cast(Persistent<S>& that) { // NOLINT |
| 710 #ifdef V8_ENABLE_CHECKS | 695 #ifdef V8_ENABLE_CHECKS |
| 711 // If we're going to perform the type check then we have to check | 696 // If we're going to perform the type check then we have to check |
| 712 // that the handle isn't empty before doing the checked cast. | 697 // that the handle isn't empty before doing the checked cast. |
| 713 if (!that.IsEmpty()) T::Cast(*that); | 698 if (!that.IsEmpty()) T::Cast(*that); |
| 714 #endif | 699 #endif |
| 715 return reinterpret_cast<Persistent<T>&>(that); | 700 return reinterpret_cast<Persistent<T>&>(that); |
| 716 } | 701 } |
| 717 | 702 |
| 718 // TODO(dcarney): this is pretty useless, fix or remove | 703 // TODO(dcarney): this is pretty useless, fix or remove |
| 719 template <class S> V8_INLINE Persistent<S>& As() { // NOLINT | 704 template <class S> V8_INLINE Persistent<S>& As() { // NOLINT |
| 720 return Persistent<S>::Cast(*this); | 705 return Persistent<S>::Cast(*this); |
| 721 } | 706 } |
| 722 | 707 |
| 723 template<typename S, typename P> | |
| 724 V8_DEPRECATED( | |
| 725 "Use SetWeak instead", | |
| 726 V8_INLINE void MakeWeak( | |
| 727 P* parameter, | |
| 728 typename WeakReferenceCallbacks<S, P>::Revivable callback)); | |
| 729 | |
| 730 template<typename P> | |
| 731 V8_DEPRECATED( | |
| 732 "Use SetWeak instead", | |
| 733 V8_INLINE void MakeWeak( | |
| 734 P* parameter, | |
| 735 typename WeakReferenceCallbacks<T, P>::Revivable callback)); | |
| 736 | |
| 737 // This will be removed. | 708 // This will be removed. |
| 738 V8_INLINE T* ClearAndLeak(); | 709 V8_INLINE T* ClearAndLeak(); |
| 739 | 710 |
| 740 V8_DEPRECATED("This will be removed", | |
| 741 V8_INLINE void Clear()) { this->val_ = 0; } | |
| 742 | |
| 743 // TODO(dcarney): remove | 711 // TODO(dcarney): remove |
| 744 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR | 712 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR |
| 745 | 713 |
| 746 private: | 714 private: |
| 747 #endif | 715 #endif |
| 748 template <class S> V8_INLINE Persistent(S* that) : PersistentBase<T>(that) { } | 716 template <class S> V8_INLINE Persistent(S* that) : PersistentBase<T>(that) { } |
| 749 | 717 |
| 750 V8_INLINE T* operator*() const { return this->val_; } | 718 V8_INLINE T* operator*() const { return this->val_; } |
| 751 | 719 |
| 752 private: | 720 private: |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 * garbage collector will no longer track the object stored in the | 813 * garbage collector will no longer track the object stored in the |
| 846 * handle and may deallocate it. The behavior of accessing a handle | 814 * handle and may deallocate it. The behavior of accessing a handle |
| 847 * for which the handle scope has been deleted is undefined. | 815 * for which the handle scope has been deleted is undefined. |
| 848 */ | 816 */ |
| 849 class V8_EXPORT HandleScope { | 817 class V8_EXPORT HandleScope { |
| 850 public: | 818 public: |
| 851 HandleScope(Isolate* isolate); | 819 HandleScope(Isolate* isolate); |
| 852 | 820 |
| 853 ~HandleScope(); | 821 ~HandleScope(); |
| 854 | 822 |
| 855 template <class T> | |
| 856 V8_DEPRECATED("Use EscapableHandleScope::Escape instead", | |
| 857 Local<T> Close(Handle<T> value)); | |
| 858 | |
| 859 /** | 823 /** |
| 860 * Counts the number of allocated handles. | 824 * Counts the number of allocated handles. |
| 861 */ | 825 */ |
| 862 static int NumberOfHandles(); | 826 static int NumberOfHandles(); |
| 863 | 827 |
| 864 private: | 828 private: |
| 865 /** | 829 /** |
| 866 * Creates a new handle with the given value. | 830 * Creates a new handle with the given value. |
| 867 */ | 831 */ |
| 868 static internal::Object** CreateHandle(internal::Isolate* isolate, | 832 static internal::Object** CreateHandle(internal::Isolate* isolate, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 887 public: | 851 public: |
| 888 internal::Object** next; | 852 internal::Object** next; |
| 889 internal::Object** limit; | 853 internal::Object** limit; |
| 890 int level; | 854 int level; |
| 891 V8_INLINE void Initialize() { | 855 V8_INLINE void Initialize() { |
| 892 next = limit = NULL; | 856 next = limit = NULL; |
| 893 level = 0; | 857 level = 0; |
| 894 } | 858 } |
| 895 }; | 859 }; |
| 896 | 860 |
| 897 void Leave(); | |
| 898 | |
| 899 internal::Isolate* isolate_; | 861 internal::Isolate* isolate_; |
| 900 internal::Object** prev_next_; | 862 internal::Object** prev_next_; |
| 901 internal::Object** prev_limit_; | 863 internal::Object** prev_limit_; |
| 902 | 864 |
| 903 // TODO(dcarney): remove this field | |
| 904 // Allow for the active closing of HandleScopes which allows to pass a handle | |
| 905 // from the HandleScope being closed to the next top most HandleScope. | |
| 906 bool is_closed_; | |
| 907 internal::Object** RawClose(internal::Object** value); | |
| 908 | |
| 909 friend class ImplementationUtilities; | 865 friend class ImplementationUtilities; |
| 910 friend class EscapableHandleScope; | 866 friend class EscapableHandleScope; |
| 911 template<class F> friend class Handle; | 867 template<class F> friend class Handle; |
| 912 template<class F> friend class Local; | 868 template<class F> friend class Local; |
| 913 friend class Object; | 869 friend class Object; |
| 914 friend class Context; | 870 friend class Context; |
| 915 }; | 871 }; |
| 916 | 872 |
| 917 | 873 |
| 918 /** | 874 /** |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 /** | 1094 /** |
| 1139 * Runs the script returning the resulting value. If the script is | 1095 * Runs the script returning the resulting value. If the script is |
| 1140 * context independent (created using ::New) it will be run in the | 1096 * context independent (created using ::New) it will be run in the |
| 1141 * currently entered context. If it is context specific (created | 1097 * currently entered context. If it is context specific (created |
| 1142 * using ::Compile) it will be run in the context in which it was | 1098 * using ::Compile) it will be run in the context in which it was |
| 1143 * compiled. | 1099 * compiled. |
| 1144 */ | 1100 */ |
| 1145 Local<Value> Run(); | 1101 Local<Value> Run(); |
| 1146 | 1102 |
| 1147 /** | 1103 /** |
| 1148 * Returns the script id value. | |
| 1149 */ | |
| 1150 V8_DEPRECATED("Use GetId instead", Local<Value> Id()); | |
| 1151 | |
| 1152 /** | |
| 1153 * Returns the script id. | 1104 * Returns the script id. |
| 1154 */ | 1105 */ |
| 1155 int GetId(); | 1106 int GetId(); |
| 1156 | 1107 |
| 1157 /** | 1108 /** |
| 1158 * Associate an additional data object with the script. This is mainly used | 1109 * Associate an additional data object with the script. This is mainly used |
| 1159 * with the debugger as this data object is only available through the | 1110 * with the debugger as this data object is only available through the |
| 1160 * debugger API. | 1111 * debugger API. |
| 1161 */ | 1112 */ |
| 1162 void SetData(Handle<String> data); | 1113 void SetData(Handle<String> data); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 int GetEndColumn() const; | 1184 int GetEndColumn() const; |
| 1234 | 1185 |
| 1235 /** | 1186 /** |
| 1236 * Passes on the value set by the embedder when it fed the script from which | 1187 * Passes on the value set by the embedder when it fed the script from which |
| 1237 * this Message was generated to V8. | 1188 * this Message was generated to V8. |
| 1238 */ | 1189 */ |
| 1239 bool IsSharedCrossOrigin() const; | 1190 bool IsSharedCrossOrigin() const; |
| 1240 | 1191 |
| 1241 // TODO(1245381): Print to a string instead of on a FILE. | 1192 // TODO(1245381): Print to a string instead of on a FILE. |
| 1242 static void PrintCurrentStackTrace(Isolate* isolate, FILE* out); | 1193 static void PrintCurrentStackTrace(Isolate* isolate, FILE* out); |
| 1243 V8_DEPRECATED("Will be removed", | |
| 1244 static void PrintCurrentStackTrace(FILE* out)); | |
| 1245 | 1194 |
| 1246 static const int kNoLineNumberInfo = 0; | 1195 static const int kNoLineNumberInfo = 0; |
| 1247 static const int kNoColumnInfo = 0; | 1196 static const int kNoColumnInfo = 0; |
| 1248 static const int kNoScriptIdInfo = 0; | 1197 static const int kNoScriptIdInfo = 0; |
| 1249 }; | 1198 }; |
| 1250 | 1199 |
| 1251 | 1200 |
| 1252 /** | 1201 /** |
| 1253 * Representation of a JavaScript stack trace. The information collected is a | 1202 * Representation of a JavaScript stack trace. The information collected is a |
| 1254 * snapshot of the execution stack and the information remains valid after | 1203 * snapshot of the execution stack and the information remains valid after |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 * Grab a snapshot of the current JavaScript execution stack. | 1241 * Grab a snapshot of the current JavaScript execution stack. |
| 1293 * | 1242 * |
| 1294 * \param frame_limit The maximum number of stack frames we want to capture. | 1243 * \param frame_limit The maximum number of stack frames we want to capture. |
| 1295 * \param options Enumerates the set of things we will capture for each | 1244 * \param options Enumerates the set of things we will capture for each |
| 1296 * StackFrame. | 1245 * StackFrame. |
| 1297 */ | 1246 */ |
| 1298 static Local<StackTrace> CurrentStackTrace( | 1247 static Local<StackTrace> CurrentStackTrace( |
| 1299 Isolate* isolate, | 1248 Isolate* isolate, |
| 1300 int frame_limit, | 1249 int frame_limit, |
| 1301 StackTraceOptions options = kOverview); | 1250 StackTraceOptions options = kOverview); |
| 1302 V8_DEPRECATED("Will be removed", | |
| 1303 static Local<StackTrace> CurrentStackTrace( | |
| 1304 int frame_limit, StackTraceOptions options = kOverview)); | |
| 1305 }; | 1251 }; |
| 1306 | 1252 |
| 1307 | 1253 |
| 1308 /** | 1254 /** |
| 1309 * A single JavaScript stack frame. | 1255 * A single JavaScript stack frame. |
| 1310 */ | 1256 */ |
| 1311 class V8_EXPORT StackFrame { | 1257 class V8_EXPORT StackFrame { |
| 1312 public: | 1258 public: |
| 1313 /** | 1259 /** |
| 1314 * Returns the number, 1-based, of the line for the associate function call. | 1260 * Returns the number, 1-based, of the line for the associate function call. |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1626 | 1572 |
| 1627 | 1573 |
| 1628 /** | 1574 /** |
| 1629 * A primitive boolean value (ECMA-262, 4.3.14). Either the true | 1575 * A primitive boolean value (ECMA-262, 4.3.14). Either the true |
| 1630 * or false value. | 1576 * or false value. |
| 1631 */ | 1577 */ |
| 1632 class V8_EXPORT Boolean : public Primitive { | 1578 class V8_EXPORT Boolean : public Primitive { |
| 1633 public: | 1579 public: |
| 1634 bool Value() const; | 1580 bool Value() const; |
| 1635 V8_INLINE static Handle<Boolean> New(Isolate* isolate, bool value); | 1581 V8_INLINE static Handle<Boolean> New(Isolate* isolate, bool value); |
| 1636 V8_DEPRECATED("Will be removed", | |
| 1637 V8_INLINE static Handle<Boolean> New(bool value)); | |
| 1638 }; | 1582 }; |
| 1639 | 1583 |
| 1640 | 1584 |
| 1641 /** | 1585 /** |
| 1642 * A JavaScript string value (ECMA-262, 4.3.17). | 1586 * A JavaScript string value (ECMA-262, 4.3.17). |
| 1643 */ | 1587 */ |
| 1644 class V8_EXPORT String : public Primitive { | 1588 class V8_EXPORT String : public Primitive { |
| 1645 public: | 1589 public: |
| 1646 enum Encoding { | 1590 enum Encoding { |
| 1647 UNKNOWN_ENCODING = 0x1, | 1591 UNKNOWN_ENCODING = 0x1, |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1833 V8_INLINE ExternalStringResource* GetExternalStringResource() const; | 1777 V8_INLINE ExternalStringResource* GetExternalStringResource() const; |
| 1834 | 1778 |
| 1835 /** | 1779 /** |
| 1836 * Get the ExternalAsciiStringResource for an external ASCII string. | 1780 * Get the ExternalAsciiStringResource for an external ASCII string. |
| 1837 * Returns NULL if IsExternalAscii() doesn't return true. | 1781 * Returns NULL if IsExternalAscii() doesn't return true. |
| 1838 */ | 1782 */ |
| 1839 const ExternalAsciiStringResource* GetExternalAsciiStringResource() const; | 1783 const ExternalAsciiStringResource* GetExternalAsciiStringResource() const; |
| 1840 | 1784 |
| 1841 V8_INLINE static String* Cast(v8::Value* obj); | 1785 V8_INLINE static String* Cast(v8::Value* obj); |
| 1842 | 1786 |
| 1843 /** | |
| 1844 * Allocates a new string from either UTF-8 encoded or ASCII data. | |
| 1845 * The second parameter 'length' gives the buffer length. If omitted, | |
| 1846 * the function calls 'strlen' to determine the buffer length. | |
| 1847 */ | |
| 1848 V8_DEPRECATED( | |
| 1849 "Use NewFromUtf8 instead", | |
| 1850 V8_INLINE static Local<String> New(const char* data, int length = -1)); | |
| 1851 | |
| 1852 /** Allocates a new string from 16-bit character codes.*/ | |
| 1853 V8_DEPRECATED( | |
| 1854 "Use NewFromTwoByte instead", | |
| 1855 V8_INLINE static Local<String> New( | |
| 1856 const uint16_t* data, int length = -1)); | |
| 1857 | |
| 1858 /** | |
| 1859 * Creates an internalized string (historically called a "symbol", | |
| 1860 * not to be confused with ES6 symbols). Returns one if it exists already. | |
| 1861 */ | |
| 1862 V8_DEPRECATED( | |
| 1863 "Use NewFromUtf8 instead", | |
| 1864 V8_INLINE static Local<String> NewSymbol( | |
| 1865 const char* data, int length = -1)); | |
| 1866 | |
| 1867 enum NewStringType { | 1787 enum NewStringType { |
| 1868 kNormalString, kInternalizedString, kUndetectableString | 1788 kNormalString, kInternalizedString, kUndetectableString |
| 1869 }; | 1789 }; |
| 1870 | 1790 |
| 1871 /** Allocates a new string from UTF-8 data.*/ | 1791 /** Allocates a new string from UTF-8 data.*/ |
| 1872 static Local<String> NewFromUtf8(Isolate* isolate, | 1792 static Local<String> NewFromUtf8(Isolate* isolate, |
| 1873 const char* data, | 1793 const char* data, |
| 1874 NewStringType type = kNormalString, | 1794 NewStringType type = kNormalString, |
| 1875 int length = -1); | 1795 int length = -1); |
| 1876 | 1796 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1897 /** | 1817 /** |
| 1898 * Creates a new external string using the data defined in the given | 1818 * Creates a new external string using the data defined in the given |
| 1899 * resource. When the external string is no longer live on V8's heap the | 1819 * resource. When the external string is no longer live on V8's heap the |
| 1900 * resource will be disposed by calling its Dispose method. The caller of | 1820 * resource will be disposed by calling its Dispose method. The caller of |
| 1901 * this function should not otherwise delete or modify the resource. Neither | 1821 * this function should not otherwise delete or modify the resource. Neither |
| 1902 * should the underlying buffer be deallocated or modified except through the | 1822 * should the underlying buffer be deallocated or modified except through the |
| 1903 * destructor of the external string resource. | 1823 * destructor of the external string resource. |
| 1904 */ | 1824 */ |
| 1905 static Local<String> NewExternal(Isolate* isolate, | 1825 static Local<String> NewExternal(Isolate* isolate, |
| 1906 ExternalStringResource* resource); | 1826 ExternalStringResource* resource); |
| 1907 V8_DEPRECATED("Will be removed", static Local<String> NewExternal( | |
| 1908 ExternalStringResource* resource)); | |
| 1909 | 1827 |
| 1910 /** | 1828 /** |
| 1911 * Associate an external string resource with this string by transforming it | 1829 * Associate an external string resource with this string by transforming it |
| 1912 * in place so that existing references to this string in the JavaScript heap | 1830 * in place so that existing references to this string in the JavaScript heap |
| 1913 * will use the external string resource. The external string resource's | 1831 * will use the external string resource. The external string resource's |
| 1914 * character contents need to be equivalent to this string. | 1832 * character contents need to be equivalent to this string. |
| 1915 * Returns true if the string has been changed to be an external string. | 1833 * Returns true if the string has been changed to be an external string. |
| 1916 * The string is not modified if the operation fails. See NewExternal for | 1834 * The string is not modified if the operation fails. See NewExternal for |
| 1917 * information on the lifetime of the resource. | 1835 * information on the lifetime of the resource. |
| 1918 */ | 1836 */ |
| 1919 bool MakeExternal(ExternalStringResource* resource); | 1837 bool MakeExternal(ExternalStringResource* resource); |
| 1920 | 1838 |
| 1921 /** | 1839 /** |
| 1922 * Creates a new external string using the ASCII data defined in the given | 1840 * Creates a new external string using the ASCII data defined in the given |
| 1923 * resource. When the external string is no longer live on V8's heap the | 1841 * resource. When the external string is no longer live on V8's heap the |
| 1924 * resource will be disposed by calling its Dispose method. The caller of | 1842 * resource will be disposed by calling its Dispose method. The caller of |
| 1925 * this function should not otherwise delete or modify the resource. Neither | 1843 * this function should not otherwise delete or modify the resource. Neither |
| 1926 * should the underlying buffer be deallocated or modified except through the | 1844 * should the underlying buffer be deallocated or modified except through the |
| 1927 * destructor of the external string resource. | 1845 * destructor of the external string resource. |
| 1928 */ | 1846 */ |
| 1929 static Local<String> NewExternal(Isolate* isolate, | 1847 static Local<String> NewExternal(Isolate* isolate, |
| 1930 ExternalAsciiStringResource* resource); | 1848 ExternalAsciiStringResource* resource); |
| 1931 V8_DEPRECATED("Will be removed", static Local<String> NewExternal( | |
| 1932 ExternalAsciiStringResource* resource)); | |
| 1933 | 1849 |
| 1934 /** | 1850 /** |
| 1935 * Associate an external string resource with this string by transforming it | 1851 * Associate an external string resource with this string by transforming it |
| 1936 * in place so that existing references to this string in the JavaScript heap | 1852 * in place so that existing references to this string in the JavaScript heap |
| 1937 * will use the external string resource. The external string resource's | 1853 * will use the external string resource. The external string resource's |
| 1938 * character contents need to be equivalent to this string. | 1854 * character contents need to be equivalent to this string. |
| 1939 * Returns true if the string has been changed to be an external string. | 1855 * Returns true if the string has been changed to be an external string. |
| 1940 * The string is not modified if the operation fails. See NewExternal for | 1856 * The string is not modified if the operation fails. See NewExternal for |
| 1941 * information on the lifetime of the resource. | 1857 * information on the lifetime of the resource. |
| 1942 */ | 1858 */ |
| 1943 bool MakeExternal(ExternalAsciiStringResource* resource); | 1859 bool MakeExternal(ExternalAsciiStringResource* resource); |
| 1944 | 1860 |
| 1945 /** | 1861 /** |
| 1946 * Returns true if this string can be made external. | 1862 * Returns true if this string can be made external. |
| 1947 */ | 1863 */ |
| 1948 bool CanMakeExternal(); | 1864 bool CanMakeExternal(); |
| 1949 | 1865 |
| 1950 /** Creates an undetectable string from the supplied ASCII or UTF-8 data.*/ | |
| 1951 V8_DEPRECATED( | |
| 1952 "Use NewFromUtf8 instead", | |
| 1953 V8_INLINE static Local<String> NewUndetectable(const char* data, | |
| 1954 int length = -1)); | |
| 1955 | |
| 1956 /** Creates an undetectable string from the supplied 16-bit character codes.*/ | |
| 1957 V8_DEPRECATED( | |
| 1958 "Use NewFromTwoByte instead", | |
| 1959 V8_INLINE static Local<String> NewUndetectable(const uint16_t* data, | |
| 1960 int length = -1)); | |
| 1961 | |
| 1962 /** | 1866 /** |
| 1963 * Converts an object to a UTF-8-encoded character array. Useful if | 1867 * Converts an object to a UTF-8-encoded character array. Useful if |
| 1964 * you want to print the object. If conversion to a string fails | 1868 * you want to print the object. If conversion to a string fails |
| 1965 * (e.g. due to an exception in the toString() method of the object) | 1869 * (e.g. due to an exception in the toString() method of the object) |
| 1966 * then the length() method returns 0 and the * operator returns | 1870 * then the length() method returns 0 and the * operator returns |
| 1967 * NULL. | 1871 * NULL. |
| 1968 */ | 1872 */ |
| 1969 class V8_EXPORT Utf8Value { | 1873 class V8_EXPORT Utf8Value { |
| 1970 public: | 1874 public: |
| 1971 explicit Utf8Value(Handle<v8::Value> obj); | 1875 explicit Utf8Value(Handle<v8::Value> obj); |
| 1972 ~Utf8Value(); | 1876 ~Utf8Value(); |
| 1973 char* operator*() { return str_; } | 1877 char* operator*() { return str_; } |
| 1974 const char* operator*() const { return str_; } | 1878 const char* operator*() const { return str_; } |
| 1975 int length() const { return length_; } | 1879 int length() const { return length_; } |
| 1976 private: | 1880 private: |
| 1977 char* str_; | 1881 char* str_; |
| 1978 int length_; | 1882 int length_; |
| 1979 | 1883 |
| 1980 // Disallow copying and assigning. | 1884 // Disallow copying and assigning. |
| 1981 Utf8Value(const Utf8Value&); | 1885 Utf8Value(const Utf8Value&); |
| 1982 void operator=(const Utf8Value&); | 1886 void operator=(const Utf8Value&); |
| 1983 }; | 1887 }; |
| 1984 | 1888 |
| 1985 /** | 1889 /** |
| 1986 * Converts an object to an ASCII string. | |
| 1987 * Useful if you want to print the object. | |
| 1988 * If conversion to a string fails (eg. due to an exception in the toString() | |
| 1989 * method of the object) then the length() method returns 0 and the * operator | |
| 1990 * returns NULL. | |
| 1991 */ | |
| 1992 class V8_EXPORT AsciiValue { | |
| 1993 public: | |
| 1994 V8_DEPRECATED("Use Utf8Value instead", | |
| 1995 explicit AsciiValue(Handle<v8::Value> obj)); | |
| 1996 ~AsciiValue(); | |
| 1997 char* operator*() { return str_; } | |
| 1998 const char* operator*() const { return str_; } | |
| 1999 int length() const { return length_; } | |
| 2000 private: | |
| 2001 char* str_; | |
| 2002 int length_; | |
| 2003 | |
| 2004 // Disallow copying and assigning. | |
| 2005 AsciiValue(const AsciiValue&); | |
| 2006 void operator=(const AsciiValue&); | |
| 2007 }; | |
| 2008 | |
| 2009 /** | |
| 2010 * Converts an object to a two-byte string. | 1890 * Converts an object to a two-byte string. |
| 2011 * If conversion to a string fails (eg. due to an exception in the toString() | 1891 * If conversion to a string fails (eg. due to an exception in the toString() |
| 2012 * method of the object) then the length() method returns 0 and the * operator | 1892 * method of the object) then the length() method returns 0 and the * operator |
| 2013 * returns NULL. | 1893 * returns NULL. |
| 2014 */ | 1894 */ |
| 2015 class V8_EXPORT Value { | 1895 class V8_EXPORT Value { |
| 2016 public: | 1896 public: |
| 2017 explicit Value(Handle<v8::Value> obj); | 1897 explicit Value(Handle<v8::Value> obj); |
| 2018 ~Value(); | 1898 ~Value(); |
| 2019 uint16_t* operator*() { return str_; } | 1899 uint16_t* operator*() { return str_; } |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2480 * Clones an element at index |index|. Returns an empty | 2360 * Clones an element at index |index|. Returns an empty |
| 2481 * handle if cloning fails (for any reason). | 2361 * handle if cloning fails (for any reason). |
| 2482 */ | 2362 */ |
| 2483 Local<Object> CloneElementAt(uint32_t index); | 2363 Local<Object> CloneElementAt(uint32_t index); |
| 2484 | 2364 |
| 2485 /** | 2365 /** |
| 2486 * Creates a JavaScript array with the given length. If the length | 2366 * Creates a JavaScript array with the given length. If the length |
| 2487 * is negative the returned array will have length 0. | 2367 * is negative the returned array will have length 0. |
| 2488 */ | 2368 */ |
| 2489 static Local<Array> New(Isolate* isolate, int length = 0); | 2369 static Local<Array> New(Isolate* isolate, int length = 0); |
| 2490 V8_DEPRECATED("Will be removed", static Local<Array> New(int length = 0)); | |
| 2491 | 2370 |
| 2492 V8_INLINE static Array* Cast(Value* obj); | 2371 V8_INLINE static Array* Cast(Value* obj); |
| 2493 private: | 2372 private: |
| 2494 Array(); | 2373 Array(); |
| 2495 static void CheckCast(Value* obj); | 2374 static void CheckCast(Value* obj); |
| 2496 }; | 2375 }; |
| 2497 | 2376 |
| 2498 | 2377 |
| 2499 template<typename T> | 2378 template<typename T> |
| 2500 class ReturnValue { | 2379 class ReturnValue { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2649 * kLineOffsetNotFound if no information available. | 2528 * kLineOffsetNotFound if no information available. |
| 2650 */ | 2529 */ |
| 2651 int GetScriptColumnNumber() const; | 2530 int GetScriptColumnNumber() const; |
| 2652 | 2531 |
| 2653 /** | 2532 /** |
| 2654 * Tells whether this function is builtin. | 2533 * Tells whether this function is builtin. |
| 2655 */ | 2534 */ |
| 2656 bool IsBuiltin() const; | 2535 bool IsBuiltin() const; |
| 2657 | 2536 |
| 2658 /** | 2537 /** |
| 2659 * Returns scriptId object. | |
| 2660 */ | |
| 2661 V8_DEPRECATED("Use ScriptId instead", Handle<Value> GetScriptId() const); | |
| 2662 | |
| 2663 /** | |
| 2664 * Returns scriptId. | 2538 * Returns scriptId. |
| 2665 */ | 2539 */ |
| 2666 int ScriptId() const; | 2540 int ScriptId() const; |
| 2667 | 2541 |
| 2668 ScriptOrigin GetScriptOrigin() const; | 2542 ScriptOrigin GetScriptOrigin() const; |
| 2669 V8_INLINE static Function* Cast(Value* obj); | 2543 V8_INLINE static Function* Cast(Value* obj); |
| 2670 static const int kLineOffsetNotFound; | 2544 static const int kLineOffsetNotFound; |
| 2671 | 2545 |
| 2672 private: | 2546 private: |
| 2673 Function(); | 2547 Function(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2744 */ | 2618 */ |
| 2745 size_t ByteLength() const; | 2619 size_t ByteLength() const; |
| 2746 | 2620 |
| 2747 /** | 2621 /** |
| 2748 * Create a new ArrayBuffer. Allocate |byte_length| bytes. | 2622 * Create a new ArrayBuffer. Allocate |byte_length| bytes. |
| 2749 * Allocated memory will be owned by a created ArrayBuffer and | 2623 * Allocated memory will be owned by a created ArrayBuffer and |
| 2750 * will be deallocated when it is garbage-collected, | 2624 * will be deallocated when it is garbage-collected, |
| 2751 * unless the object is externalized. | 2625 * unless the object is externalized. |
| 2752 */ | 2626 */ |
| 2753 static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length); | 2627 static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length); |
| 2754 V8_DEPRECATED("Will be removed", | |
| 2755 static Local<ArrayBuffer> New(size_t byte_length)); | |
| 2756 | 2628 |
| 2757 /** | 2629 /** |
| 2758 * Create a new ArrayBuffer over an existing memory block. | 2630 * Create a new ArrayBuffer over an existing memory block. |
| 2759 * The created array buffer is immediately in externalized state. | 2631 * The created array buffer is immediately in externalized state. |
| 2760 * The memory block will not be reclaimed when a created ArrayBuffer | 2632 * The memory block will not be reclaimed when a created ArrayBuffer |
| 2761 * is garbage-collected. | 2633 * is garbage-collected. |
| 2762 */ | 2634 */ |
| 2763 static Local<ArrayBuffer> New(Isolate* isolate, void* data, | 2635 static Local<ArrayBuffer> New(Isolate* isolate, void* data, |
| 2764 size_t byte_length); | 2636 size_t byte_length); |
| 2765 V8_DEPRECATED("Will be removed", | |
| 2766 static Local<ArrayBuffer> New(void* data, size_t byte_length)); | |
| 2767 | 2637 |
| 2768 /** | 2638 /** |
| 2769 * Returns true if ArrayBuffer is extrenalized, that is, does not | 2639 * Returns true if ArrayBuffer is extrenalized, that is, does not |
| 2770 * own its memory block. | 2640 * own its memory block. |
| 2771 */ | 2641 */ |
| 2772 bool IsExternal() const; | 2642 bool IsExternal() const; |
| 2773 | 2643 |
| 2774 /** | 2644 /** |
| 2775 * Neuters this ArrayBuffer and all its views (typed arrays). | 2645 * Neuters this ArrayBuffer and all its views (typed arrays). |
| 2776 * Neutering sets the byte length of the buffer and all typed arrays to zero, | 2646 * Neutering sets the byte length of the buffer and all typed arrays to zero, |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3017 static void CheckCast(Value* obj); | 2887 static void CheckCast(Value* obj); |
| 3018 }; | 2888 }; |
| 3019 | 2889 |
| 3020 | 2890 |
| 3021 /** | 2891 /** |
| 3022 * An instance of the built-in Date constructor (ECMA-262, 15.9). | 2892 * An instance of the built-in Date constructor (ECMA-262, 15.9). |
| 3023 */ | 2893 */ |
| 3024 class V8_EXPORT Date : public Object { | 2894 class V8_EXPORT Date : public Object { |
| 3025 public: | 2895 public: |
| 3026 static Local<Value> New(Isolate* isolate, double time); | 2896 static Local<Value> New(Isolate* isolate, double time); |
| 3027 V8_DEPRECATED("Will be removed", static Local<Value> New(double time)); | |
| 3028 | |
| 3029 V8_DEPRECATED( | |
| 3030 "Use ValueOf instead", | |
| 3031 double NumberValue() const) { return ValueOf(); } | |
| 3032 | 2897 |
| 3033 /** | 2898 /** |
| 3034 * A specialization of Value::NumberValue that is more efficient | 2899 * A specialization of Value::NumberValue that is more efficient |
| 3035 * because we know the structure of this object. | 2900 * because we know the structure of this object. |
| 3036 */ | 2901 */ |
| 3037 double ValueOf() const; | 2902 double ValueOf() const; |
| 3038 | 2903 |
| 3039 V8_INLINE static Date* Cast(v8::Value* obj); | 2904 V8_INLINE static Date* Cast(v8::Value* obj); |
| 3040 | 2905 |
| 3041 /** | 2906 /** |
| 3042 * Notification that the embedder has changed the time zone, | 2907 * Notification that the embedder has changed the time zone, |
| 3043 * daylight savings time, or other date / time configuration | 2908 * daylight savings time, or other date / time configuration |
| 3044 * parameters. V8 keeps a cache of various values used for | 2909 * parameters. V8 keeps a cache of various values used for |
| 3045 * date / time computation. This notification will reset | 2910 * date / time computation. This notification will reset |
| 3046 * those cached values for the current context so that date / | 2911 * those cached values for the current context so that date / |
| 3047 * time configuration changes would be reflected in the Date | 2912 * time configuration changes would be reflected in the Date |
| 3048 * object. | 2913 * object. |
| 3049 * | 2914 * |
| 3050 * This API should not be called more than needed as it will | 2915 * This API should not be called more than needed as it will |
| 3051 * negatively impact the performance of date operations. | 2916 * negatively impact the performance of date operations. |
| 3052 */ | 2917 */ |
| 3053 static void DateTimeConfigurationChangeNotification(Isolate* isolate); | 2918 static void DateTimeConfigurationChangeNotification(Isolate* isolate); |
| 3054 V8_DEPRECATED("Will be removed", | |
| 3055 static void DateTimeConfigurationChangeNotification()); | |
| 3056 | 2919 |
| 3057 private: | 2920 private: |
| 3058 static void CheckCast(v8::Value* obj); | 2921 static void CheckCast(v8::Value* obj); |
| 3059 }; | 2922 }; |
| 3060 | 2923 |
| 3061 | 2924 |
| 3062 /** | 2925 /** |
| 3063 * A Number object (ECMA-262, 4.3.21). | 2926 * A Number object (ECMA-262, 4.3.21). |
| 3064 */ | 2927 */ |
| 3065 class V8_EXPORT NumberObject : public Object { | 2928 class V8_EXPORT NumberObject : public Object { |
| 3066 public: | 2929 public: |
| 3067 static Local<Value> New(Isolate* isolate, double value); | 2930 static Local<Value> New(Isolate* isolate, double value); |
| 3068 V8_DEPRECATED("Will be removed", static Local<Value> New(double value)); | |
| 3069 | 2931 |
| 3070 V8_DEPRECATED( | |
| 3071 "Use ValueOf instead", | |
| 3072 double NumberValue() const) { return ValueOf(); } | |
| 3073 | |
| 3074 /** | |
| 3075 * Returns the Number held by the object. | |
| 3076 */ | |
| 3077 double ValueOf() const; | 2932 double ValueOf() const; |
| 3078 | 2933 |
| 3079 V8_INLINE static NumberObject* Cast(v8::Value* obj); | 2934 V8_INLINE static NumberObject* Cast(v8::Value* obj); |
| 3080 | 2935 |
| 3081 private: | 2936 private: |
| 3082 static void CheckCast(v8::Value* obj); | 2937 static void CheckCast(v8::Value* obj); |
| 3083 }; | 2938 }; |
| 3084 | 2939 |
| 3085 | 2940 |
| 3086 /** | 2941 /** |
| 3087 * A Boolean object (ECMA-262, 4.3.15). | 2942 * A Boolean object (ECMA-262, 4.3.15). |
| 3088 */ | 2943 */ |
| 3089 class V8_EXPORT BooleanObject : public Object { | 2944 class V8_EXPORT BooleanObject : public Object { |
| 3090 public: | 2945 public: |
| 3091 static Local<Value> New(bool value); | 2946 static Local<Value> New(bool value); |
| 3092 | 2947 |
| 3093 V8_DEPRECATED( | |
| 3094 "Use ValueOf instead", | |
| 3095 bool BooleanValue() const) { return ValueOf(); } | |
| 3096 | |
| 3097 /** | |
| 3098 * Returns the Boolean held by the object. | |
| 3099 */ | |
| 3100 bool ValueOf() const; | 2948 bool ValueOf() const; |
| 3101 | 2949 |
| 3102 V8_INLINE static BooleanObject* Cast(v8::Value* obj); | 2950 V8_INLINE static BooleanObject* Cast(v8::Value* obj); |
| 3103 | 2951 |
| 3104 private: | 2952 private: |
| 3105 static void CheckCast(v8::Value* obj); | 2953 static void CheckCast(v8::Value* obj); |
| 3106 }; | 2954 }; |
| 3107 | 2955 |
| 3108 | 2956 |
| 3109 /** | 2957 /** |
| 3110 * A String object (ECMA-262, 4.3.18). | 2958 * A String object (ECMA-262, 4.3.18). |
| 3111 */ | 2959 */ |
| 3112 class V8_EXPORT StringObject : public Object { | 2960 class V8_EXPORT StringObject : public Object { |
| 3113 public: | 2961 public: |
| 3114 static Local<Value> New(Handle<String> value); | 2962 static Local<Value> New(Handle<String> value); |
| 3115 | 2963 |
| 3116 V8_DEPRECATED( | |
| 3117 "Use ValueOf instead", | |
| 3118 Local<String> StringValue() const) { return ValueOf(); } | |
| 3119 | |
| 3120 /** | |
| 3121 * Returns the String held by the object. | |
| 3122 */ | |
| 3123 Local<String> ValueOf() const; | 2964 Local<String> ValueOf() const; |
| 3124 | 2965 |
| 3125 V8_INLINE static StringObject* Cast(v8::Value* obj); | 2966 V8_INLINE static StringObject* Cast(v8::Value* obj); |
| 3126 | 2967 |
| 3127 private: | 2968 private: |
| 3128 static void CheckCast(v8::Value* obj); | 2969 static void CheckCast(v8::Value* obj); |
| 3129 }; | 2970 }; |
| 3130 | 2971 |
| 3131 | 2972 |
| 3132 /** | 2973 /** |
| 3133 * A Symbol object (ECMA-262 edition 6). | 2974 * A Symbol object (ECMA-262 edition 6). |
| 3134 * | 2975 * |
| 3135 * This is an experimental feature. Use at your own risk. | 2976 * This is an experimental feature. Use at your own risk. |
| 3136 */ | 2977 */ |
| 3137 class V8_EXPORT SymbolObject : public Object { | 2978 class V8_EXPORT SymbolObject : public Object { |
| 3138 public: | 2979 public: |
| 3139 static Local<Value> New(Isolate* isolate, Handle<Symbol> value); | 2980 static Local<Value> New(Isolate* isolate, Handle<Symbol> value); |
| 3140 | 2981 |
| 3141 V8_DEPRECATED( | |
| 3142 "Use ValueOf instead", | |
| 3143 Local<Symbol> SymbolValue() const) { return ValueOf(); } | |
| 3144 | |
| 3145 /** | |
| 3146 * Returns the Symbol held by the object. | |
| 3147 */ | |
| 3148 Local<Symbol> ValueOf() const; | 2982 Local<Symbol> ValueOf() const; |
| 3149 | 2983 |
| 3150 V8_INLINE static SymbolObject* Cast(v8::Value* obj); | 2984 V8_INLINE static SymbolObject* Cast(v8::Value* obj); |
| 3151 | 2985 |
| 3152 private: | 2986 private: |
| 3153 static void CheckCast(v8::Value* obj); | 2987 static void CheckCast(v8::Value* obj); |
| 3154 }; | 2988 }; |
| 3155 | 2989 |
| 3156 | 2990 |
| 3157 /** | 2991 /** |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3200 }; | 3034 }; |
| 3201 | 3035 |
| 3202 | 3036 |
| 3203 /** | 3037 /** |
| 3204 * A JavaScript value that wraps a C++ void*. This type of value is mainly used | 3038 * A JavaScript value that wraps a C++ void*. This type of value is mainly used |
| 3205 * to associate C++ data structures with JavaScript objects. | 3039 * to associate C++ data structures with JavaScript objects. |
| 3206 */ | 3040 */ |
| 3207 class V8_EXPORT External : public Value { | 3041 class V8_EXPORT External : public Value { |
| 3208 public: | 3042 public: |
| 3209 static Local<External> New(Isolate* isolate, void* value); | 3043 static Local<External> New(Isolate* isolate, void* value); |
| 3210 V8_DEPRECATED("Will be removed", static Local<External> New(void *value)); | |
| 3211 V8_INLINE static External* Cast(Value* obj); | 3044 V8_INLINE static External* Cast(Value* obj); |
| 3212 void* Value() const; | 3045 void* Value() const; |
| 3213 private: | 3046 private: |
| 3214 static void CheckCast(v8::Value* obj); | 3047 static void CheckCast(v8::Value* obj); |
| 3215 }; | 3048 }; |
| 3216 | 3049 |
| 3217 | 3050 |
| 3218 // --- Templates --- | 3051 // --- Templates --- |
| 3219 | 3052 |
| 3220 | 3053 |
| 3221 /** | 3054 /** |
| 3222 * The superclass of object and function templates. | 3055 * The superclass of object and function templates. |
| 3223 */ | 3056 */ |
| 3224 class V8_EXPORT Template : public Data { | 3057 class V8_EXPORT Template : public Data { |
| 3225 public: | 3058 public: |
| 3226 /** Adds a property to each instance created by this template.*/ | 3059 /** Adds a property to each instance created by this template.*/ |
| 3227 void Set(Handle<String> name, Handle<Data> value, | 3060 void Set(Handle<String> name, Handle<Data> value, |
| 3228 PropertyAttribute attributes = None); | 3061 PropertyAttribute attributes = None); |
| 3229 V8_INLINE void Set(Isolate* isolate, const char* name, Handle<Data> value); | 3062 V8_INLINE void Set(Isolate* isolate, const char* name, Handle<Data> value); |
| 3230 V8_DEPRECATED("Will be removed", | |
| 3231 V8_INLINE void Set(const char* name, Handle<Data> value)); | |
| 3232 | 3063 |
| 3233 void SetAccessorProperty( | 3064 void SetAccessorProperty( |
| 3234 Local<String> name, | 3065 Local<String> name, |
| 3235 Local<FunctionTemplate> getter = Local<FunctionTemplate>(), | 3066 Local<FunctionTemplate> getter = Local<FunctionTemplate>(), |
| 3236 Local<FunctionTemplate> setter = Local<FunctionTemplate>(), | 3067 Local<FunctionTemplate> setter = Local<FunctionTemplate>(), |
| 3237 PropertyAttribute attribute = None, | 3068 PropertyAttribute attribute = None, |
| 3238 AccessControl settings = DEFAULT); | 3069 AccessControl settings = DEFAULT); |
| 3239 | 3070 |
| 3240 /** | 3071 /** |
| 3241 * Whenever the property with the given name is accessed on objects | 3072 * Whenever the property with the given name is accessed on objects |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3757 * A Signature specifies which receivers and arguments are valid | 3588 * A Signature specifies which receivers and arguments are valid |
| 3758 * parameters to a function. | 3589 * parameters to a function. |
| 3759 */ | 3590 */ |
| 3760 class V8_EXPORT Signature : public Data { | 3591 class V8_EXPORT Signature : public Data { |
| 3761 public: | 3592 public: |
| 3762 static Local<Signature> New(Isolate* isolate, | 3593 static Local<Signature> New(Isolate* isolate, |
| 3763 Handle<FunctionTemplate> receiver = | 3594 Handle<FunctionTemplate> receiver = |
| 3764 Handle<FunctionTemplate>(), | 3595 Handle<FunctionTemplate>(), |
| 3765 int argc = 0, | 3596 int argc = 0, |
| 3766 Handle<FunctionTemplate> argv[] = 0); | 3597 Handle<FunctionTemplate> argv[] = 0); |
| 3767 V8_DEPRECATED("Will be removed", | |
| 3768 static Local<Signature> New(Handle<FunctionTemplate> receiver = | |
| 3769 Handle<FunctionTemplate>(), | |
| 3770 int argc = 0, | |
| 3771 Handle<FunctionTemplate> argv[] = | |
| 3772 0)); | |
| 3773 | 3598 |
| 3774 private: | 3599 private: |
| 3775 Signature(); | 3600 Signature(); |
| 3776 }; | 3601 }; |
| 3777 | 3602 |
| 3778 | 3603 |
| 3779 /** | 3604 /** |
| 3780 * An AccessorSignature specifies which receivers are valid parameters | 3605 * An AccessorSignature specifies which receivers are valid parameters |
| 3781 * to an accessor callback. | 3606 * to an accessor callback. |
| 3782 */ | 3607 */ |
| 3783 class V8_EXPORT AccessorSignature : public Data { | 3608 class V8_EXPORT AccessorSignature : public Data { |
| 3784 public: | 3609 public: |
| 3785 static Local<AccessorSignature> New(Isolate* isolate, | 3610 static Local<AccessorSignature> New(Isolate* isolate, |
| 3786 Handle<FunctionTemplate> receiver = | 3611 Handle<FunctionTemplate> receiver = |
| 3787 Handle<FunctionTemplate>()); | 3612 Handle<FunctionTemplate>()); |
| 3788 V8_DEPRECATED("Will be removed", static Local<AccessorSignature> New( | |
| 3789 Handle<FunctionTemplate> receiver = | |
| 3790 Handle<FunctionTemplate>())); | |
| 3791 | 3613 |
| 3792 private: | 3614 private: |
| 3793 AccessorSignature(); | 3615 AccessorSignature(); |
| 3794 }; | 3616 }; |
| 3795 | 3617 |
| 3796 | 3618 |
| 3797 class V8_EXPORT DeclaredAccessorDescriptor : public Data { | 3619 class V8_EXPORT DeclaredAccessorDescriptor : public Data { |
| 3798 private: | 3620 private: |
| 3799 DeclaredAccessorDescriptor(); | 3621 DeclaredAccessorDescriptor(); |
| 3800 }; | 3622 }; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3887 // Note that the strings passed into this constructor must live as long | 3709 // Note that the strings passed into this constructor must live as long |
| 3888 // as the Extension itself. | 3710 // as the Extension itself. |
| 3889 Extension(const char* name, | 3711 Extension(const char* name, |
| 3890 const char* source = 0, | 3712 const char* source = 0, |
| 3891 int dep_count = 0, | 3713 int dep_count = 0, |
| 3892 const char** deps = 0, | 3714 const char** deps = 0, |
| 3893 int source_length = -1); | 3715 int source_length = -1); |
| 3894 virtual ~Extension() { } | 3716 virtual ~Extension() { } |
| 3895 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( | 3717 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( |
| 3896 v8::Isolate* isolate, v8::Handle<v8::String> name) { | 3718 v8::Isolate* isolate, v8::Handle<v8::String> name) { |
| 3897 #if defined(V8_DEPRECATION_WARNINGS) | |
| 3898 return v8::Handle<v8::FunctionTemplate>(); | |
| 3899 #else | |
| 3900 return GetNativeFunction(name); | |
| 3901 #endif | |
| 3902 } | |
| 3903 | |
| 3904 V8_DEPRECATED("Will be removed", | |
| 3905 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( | |
| 3906 v8::Handle<v8::String> name)) { | |
| 3907 return v8::Handle<v8::FunctionTemplate>(); | 3719 return v8::Handle<v8::FunctionTemplate>(); |
| 3908 } | 3720 } |
| 3909 | 3721 |
| 3910 const char* name() const { return name_; } | 3722 const char* name() const { return name_; } |
| 3911 size_t source_length() const { return source_length_; } | 3723 size_t source_length() const { return source_length_; } |
| 3912 const String::ExternalAsciiStringResource* source() const { | 3724 const String::ExternalAsciiStringResource* source() const { |
| 3913 return &source_; } | 3725 return &source_; } |
| 3914 int dependency_count() { return dep_count_; } | 3726 int dependency_count() { return dep_count_; } |
| 3915 const char** dependencies() { return deps_; } | 3727 const char** dependencies() { return deps_; } |
| 3916 void set_auto_enable(bool value) { auto_enable_ = value; } | 3728 void set_auto_enable(bool value) { auto_enable_ = value; } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3944 }; | 3756 }; |
| 3945 | 3757 |
| 3946 | 3758 |
| 3947 // --- Statics --- | 3759 // --- Statics --- |
| 3948 | 3760 |
| 3949 V8_INLINE Handle<Primitive> Undefined(Isolate* isolate); | 3761 V8_INLINE Handle<Primitive> Undefined(Isolate* isolate); |
| 3950 V8_INLINE Handle<Primitive> Null(Isolate* isolate); | 3762 V8_INLINE Handle<Primitive> Null(Isolate* isolate); |
| 3951 V8_INLINE Handle<Boolean> True(Isolate* isolate); | 3763 V8_INLINE Handle<Boolean> True(Isolate* isolate); |
| 3952 V8_INLINE Handle<Boolean> False(Isolate* isolate); | 3764 V8_INLINE Handle<Boolean> False(Isolate* isolate); |
| 3953 | 3765 |
| 3954 V8_DEPRECATED("Will be removed", Handle<Primitive> V8_EXPORT Undefined()); | |
| 3955 V8_DEPRECATED("Will be removed", Handle<Primitive> V8_EXPORT Null()); | |
| 3956 V8_DEPRECATED("Will be removed", Handle<Boolean> V8_EXPORT True()); | |
| 3957 V8_DEPRECATED("Will be removed", Handle<Boolean> V8_EXPORT False()); | |
| 3958 | |
| 3959 | 3766 |
| 3960 /** | 3767 /** |
| 3961 * A set of constraints that specifies the limits of the runtime's memory use. | 3768 * A set of constraints that specifies the limits of the runtime's memory use. |
| 3962 * You must set the heap size before initializing the VM - the size cannot be | 3769 * You must set the heap size before initializing the VM - the size cannot be |
| 3963 * adjusted after the VM is initialized. | 3770 * adjusted after the VM is initialized. |
| 3964 * | 3771 * |
| 3965 * If you are using threads then you should hold the V8::Locker lock while | 3772 * If you are using threads then you should hold the V8::Locker lock while |
| 3966 * setting the stack limit and you must set a non-default stack limit separately | 3773 * setting the stack limit and you must set a non-default stack limit separately |
| 3967 * for each thread. | 3774 * for each thread. |
| 3968 */ | 3775 */ |
| 3969 class V8_EXPORT ResourceConstraints { | 3776 class V8_EXPORT ResourceConstraints { |
| 3970 public: | 3777 public: |
| 3971 ResourceConstraints(); | 3778 ResourceConstraints(); |
| 3972 | 3779 |
| 3973 /** | 3780 /** |
| 3974 * Configures the constraints with reasonable default values based on the | 3781 * Configures the constraints with reasonable default values based on the |
| 3975 * capabilities of the current device the VM is running on. | 3782 * capabilities of the current device the VM is running on. |
| 3976 * | 3783 * |
| 3977 * \param physical_memory The total amount of physical memory on the current | 3784 * \param physical_memory The total amount of physical memory on the current |
| 3978 * device, in bytes. | 3785 * device, in bytes. |
| 3979 * \param number_of_processors The number of CPUs available on the current | 3786 * \param number_of_processors The number of CPUs available on the current |
| 3980 * device. | 3787 * device. |
| 3981 */ | 3788 */ |
| 3982 void ConfigureDefaults(uint64_t physical_memory, | 3789 void ConfigureDefaults(uint64_t physical_memory, |
| 3983 uint32_t number_of_processors); | 3790 uint32_t number_of_processors); |
| 3984 V8_DEPRECATED("Will be removed", | |
| 3985 void ConfigureDefaults(uint64_t physical_memory)); | |
| 3986 | 3791 |
| 3987 int max_young_space_size() const { return max_young_space_size_; } | 3792 int max_young_space_size() const { return max_young_space_size_; } |
| 3988 void set_max_young_space_size(int value) { max_young_space_size_ = value; } | 3793 void set_max_young_space_size(int value) { max_young_space_size_ = value; } |
| 3989 int max_old_space_size() const { return max_old_space_size_; } | 3794 int max_old_space_size() const { return max_old_space_size_; } |
| 3990 void set_max_old_space_size(int value) { max_old_space_size_ = value; } | 3795 void set_max_old_space_size(int value) { max_old_space_size_ = value; } |
| 3991 int max_executable_size() const { return max_executable_size_; } | 3796 int max_executable_size() const { return max_executable_size_; } |
| 3992 void set_max_executable_size(int value) { max_executable_size_ = value; } | 3797 void set_max_executable_size(int value) { max_executable_size_ = value; } |
| 3993 uint32_t* stack_limit() const { return stack_limit_; } | 3798 uint32_t* stack_limit() const { return stack_limit_; } |
| 3994 // Sets an address beyond which the VM's stack may not grow. | 3799 // Sets an address beyond which the VM's stack may not grow. |
| 3995 void set_stack_limit(uint32_t* value) { stack_limit_ = value; } | 3800 void set_stack_limit(uint32_t* value) { stack_limit_ = value; } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 4017 | 3822 |
| 4018 // --- Exceptions --- | 3823 // --- Exceptions --- |
| 4019 | 3824 |
| 4020 | 3825 |
| 4021 typedef void (*FatalErrorCallback)(const char* location, const char* message); | 3826 typedef void (*FatalErrorCallback)(const char* location, const char* message); |
| 4022 | 3827 |
| 4023 | 3828 |
| 4024 typedef void (*MessageCallback)(Handle<Message> message, Handle<Value> error); | 3829 typedef void (*MessageCallback)(Handle<Message> message, Handle<Value> error); |
| 4025 | 3830 |
| 4026 | 3831 |
| 4027 V8_DEPRECATED( | |
| 4028 "Use Isolate::ThrowException instead", | |
| 4029 Handle<Value> V8_EXPORT ThrowException(Handle<Value> exception)); | |
| 4030 | |
| 4031 /** | 3832 /** |
| 4032 * Create new error objects by calling the corresponding error object | 3833 * Create new error objects by calling the corresponding error object |
| 4033 * constructor with the message. | 3834 * constructor with the message. |
| 4034 */ | 3835 */ |
| 4035 class V8_EXPORT Exception { | 3836 class V8_EXPORT Exception { |
| 4036 public: | 3837 public: |
| 4037 static Local<Value> RangeError(Handle<String> message); | 3838 static Local<Value> RangeError(Handle<String> message); |
| 4038 static Local<Value> ReferenceError(Handle<String> message); | 3839 static Local<Value> ReferenceError(Handle<String> message); |
| 4039 static Local<Value> SyntaxError(Handle<String> message); | 3840 static Local<Value> SyntaxError(Handle<String> message); |
| 4040 static Local<Value> TypeError(Handle<String> message); | 3841 static Local<Value> TypeError(Handle<String> message); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4213 * Requires: this == Isolate::GetCurrent(). | 4014 * Requires: this == Isolate::GetCurrent(). |
| 4214 */ | 4015 */ |
| 4215 void Exit(); | 4016 void Exit(); |
| 4216 | 4017 |
| 4217 /** | 4018 /** |
| 4218 * Disposes the isolate. The isolate must not be entered by any | 4019 * Disposes the isolate. The isolate must not be entered by any |
| 4219 * thread to be disposable. | 4020 * thread to be disposable. |
| 4220 */ | 4021 */ |
| 4221 void Dispose(); | 4022 void Dispose(); |
| 4222 | 4023 |
| 4223 V8_DEPRECATED("Use SetData(0, data) instead.", | |
| 4224 V8_INLINE void SetData(void* data)); | |
| 4225 V8_DEPRECATED("Use GetData(0) instead.", V8_INLINE void* GetData()); | |
| 4226 | |
| 4227 /** | 4024 /** |
| 4228 * Associate embedder-specific data with the isolate. |slot| has to be | 4025 * Associate embedder-specific data with the isolate. |slot| has to be |
| 4229 * between 0 and GetNumberOfDataSlots() - 1. | 4026 * between 0 and GetNumberOfDataSlots() - 1. |
| 4230 */ | 4027 */ |
| 4231 V8_INLINE void SetData(uint32_t slot, void* data); | 4028 V8_INLINE void SetData(uint32_t slot, void* data); |
| 4232 | 4029 |
| 4233 /** | 4030 /** |
| 4234 * Retrieve embedder-specific data from the isolate. | 4031 * Retrieve embedder-specific data from the isolate. |
| 4235 * Returns NULL if SetData has never been called for the given |slot|. | 4032 * Returns NULL if SetData has never been called for the given |slot|. |
| 4236 */ | 4033 */ |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4834 * are not guaranteed to live past each call. The \p event_handler must | 4631 * are not guaranteed to live past each call. The \p event_handler must |
| 4835 * copy strings and other parameters it needs to keep around. | 4632 * copy strings and other parameters it needs to keep around. |
| 4836 * \note the set of events declared in JitCodeEvent::EventType is expected to | 4633 * \note the set of events declared in JitCodeEvent::EventType is expected to |
| 4837 * grow over time, and the JitCodeEvent structure is expected to accrue | 4634 * grow over time, and the JitCodeEvent structure is expected to accrue |
| 4838 * new members. The \p event_handler function must ignore event codes | 4635 * new members. The \p event_handler function must ignore event codes |
| 4839 * it does not recognize to maintain future compatibility. | 4636 * it does not recognize to maintain future compatibility. |
| 4840 */ | 4637 */ |
| 4841 static void SetJitCodeEventHandler(JitCodeEventOptions options, | 4638 static void SetJitCodeEventHandler(JitCodeEventOptions options, |
| 4842 JitCodeEventHandler event_handler); | 4639 JitCodeEventHandler event_handler); |
| 4843 | 4640 |
| 4844 V8_DEPRECATED( | |
| 4845 "Use Isolate::AdjustAmountOfExternalAllocatedMemory instead", | |
| 4846 static int64_t AdjustAmountOfExternalAllocatedMemory( | |
| 4847 int64_t change_in_bytes)); | |
| 4848 | |
| 4849 /** | 4641 /** |
| 4850 * Forcefully terminate the current thread of JavaScript execution | 4642 * Forcefully terminate the current thread of JavaScript execution |
| 4851 * in the given isolate. If no isolate is provided, the default | 4643 * in the given isolate. If no isolate is provided, the default |
| 4852 * isolate is used. | 4644 * isolate is used. |
| 4853 * | 4645 * |
| 4854 * This method can be used by any thread even if that thread has not | 4646 * This method can be used by any thread even if that thread has not |
| 4855 * acquired the V8 lock with a Locker object. | 4647 * acquired the V8 lock with a Locker object. |
| 4856 * | 4648 * |
| 4857 * \param isolate The isolate in which to terminate the current JS execution. | 4649 * \param isolate The isolate in which to terminate the current JS execution. |
| 4858 */ | 4650 */ |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4968 */ | 4760 */ |
| 4969 static void ShutdownPlatform(); | 4761 static void ShutdownPlatform(); |
| 4970 | 4762 |
| 4971 private: | 4763 private: |
| 4972 V8(); | 4764 V8(); |
| 4973 | 4765 |
| 4974 static internal::Object** GlobalizeReference(internal::Isolate* isolate, | 4766 static internal::Object** GlobalizeReference(internal::Isolate* isolate, |
| 4975 internal::Object** handle); | 4767 internal::Object** handle); |
| 4976 static internal::Object** CopyPersistent(internal::Object** handle); | 4768 static internal::Object** CopyPersistent(internal::Object** handle); |
| 4977 static void DisposeGlobal(internal::Object** global_handle); | 4769 static void DisposeGlobal(internal::Object** global_handle); |
| 4978 typedef WeakReferenceCallbacks<Value, void>::Revivable RevivableCallback; | |
| 4979 typedef WeakCallbackData<Value, void>::Callback WeakCallback; | 4770 typedef WeakCallbackData<Value, void>::Callback WeakCallback; |
| 4980 static void MakeWeak(internal::Object** global_handle, | 4771 static void MakeWeak(internal::Object** global_handle, |
| 4981 void* data, | 4772 void* data, |
| 4982 WeakCallback weak_callback, | 4773 WeakCallback weak_callback); |
| 4983 RevivableCallback weak_reference_callback); | |
| 4984 static void ClearWeak(internal::Object** global_handle); | 4774 static void ClearWeak(internal::Object** global_handle); |
| 4985 static void Eternalize(Isolate* isolate, | 4775 static void Eternalize(Isolate* isolate, |
| 4986 Value* handle, | 4776 Value* handle, |
| 4987 int* index); | 4777 int* index); |
| 4988 static Local<Value> GetEternal(Isolate* isolate, int index); | 4778 static Local<Value> GetEternal(Isolate* isolate, int index); |
| 4989 | 4779 |
| 4990 template <class T> friend class Handle; | 4780 template <class T> friend class Handle; |
| 4991 template <class T> friend class Local; | 4781 template <class T> friend class Local; |
| 4992 template <class T> friend class Eternal; | 4782 template <class T> friend class Eternal; |
| 4993 template <class T> friend class PersistentBase; | 4783 template <class T> friend class PersistentBase; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5186 * created by a previous call to Context::New with the same global | 4976 * created by a previous call to Context::New with the same global |
| 5187 * template. The state of the global object will be completely reset | 4977 * template. The state of the global object will be completely reset |
| 5188 * and only object identify will remain. | 4978 * and only object identify will remain. |
| 5189 */ | 4979 */ |
| 5190 static Local<Context> New( | 4980 static Local<Context> New( |
| 5191 Isolate* isolate, | 4981 Isolate* isolate, |
| 5192 ExtensionConfiguration* extensions = NULL, | 4982 ExtensionConfiguration* extensions = NULL, |
| 5193 Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(), | 4983 Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(), |
| 5194 Handle<Value> global_object = Handle<Value>()); | 4984 Handle<Value> global_object = Handle<Value>()); |
| 5195 | 4985 |
| 5196 V8_DEPRECATED("Use Isolate::GetEnteredContext instead", | |
| 5197 static Local<Context> GetEntered()); | |
| 5198 | |
| 5199 V8_DEPRECATED("Use Isolate::GetCurrentContext instead", | |
| 5200 static Local<Context> GetCurrent()); | |
| 5201 | |
| 5202 V8_DEPRECATED("Use Isolate::GetCallingContext instead", | |
| 5203 static Local<Context> GetCalling()); | |
| 5204 | |
| 5205 /** | 4986 /** |
| 5206 * Sets the security token for the context. To access an object in | 4987 * Sets the security token for the context. To access an object in |
| 5207 * another context, the security tokens must match. | 4988 * another context, the security tokens must match. |
| 5208 */ | 4989 */ |
| 5209 void SetSecurityToken(Handle<Value> token); | 4990 void SetSecurityToken(Handle<Value> token); |
| 5210 | 4991 |
| 5211 /** Restores the security token to the default value. */ | 4992 /** Restores the security token to the default value. */ |
| 5212 void UseDefaultSecurityToken(); | 4993 void UseDefaultSecurityToken(); |
| 5213 | 4994 |
| 5214 /** Returns the security token of this context.*/ | 4995 /** Returns the security token of this context.*/ |
| 5215 Handle<Value> GetSecurityToken(); | 4996 Handle<Value> GetSecurityToken(); |
| 5216 | 4997 |
| 5217 /** | 4998 /** |
| 5218 * Enter this context. After entering a context, all code compiled | 4999 * Enter this context. After entering a context, all code compiled |
| 5219 * and run is compiled and run in this context. If another context | 5000 * and run is compiled and run in this context. If another context |
| 5220 * is already entered, this old context is saved so it can be | 5001 * is already entered, this old context is saved so it can be |
| 5221 * restored when the new context is exited. | 5002 * restored when the new context is exited. |
| 5222 */ | 5003 */ |
| 5223 void Enter(); | 5004 void Enter(); |
| 5224 | 5005 |
| 5225 /** | 5006 /** |
| 5226 * Exit this context. Exiting the current context restores the | 5007 * Exit this context. Exiting the current context restores the |
| 5227 * context that was in place when entering the current context. | 5008 * context that was in place when entering the current context. |
| 5228 */ | 5009 */ |
| 5229 void Exit(); | 5010 void Exit(); |
| 5230 | 5011 |
| 5231 /** Returns true if the context has experienced an out of memory situation. */ | 5012 /** Returns true if the context has experienced an out of memory situation. */ |
| 5232 bool HasOutOfMemoryException(); | 5013 bool HasOutOfMemoryException(); |
| 5233 | 5014 |
| 5234 V8_DEPRECATED("Use Isolate::InContext instead", | |
| 5235 static bool InContext()); | |
| 5236 | |
| 5237 /** Returns an isolate associated with a current context. */ | 5015 /** Returns an isolate associated with a current context. */ |
| 5238 v8::Isolate* GetIsolate(); | 5016 v8::Isolate* GetIsolate(); |
| 5239 | 5017 |
| 5240 /** | 5018 /** |
| 5241 * Gets the embedder data with the given index, which must have been set by a | 5019 * Gets the embedder data with the given index, which must have been set by a |
| 5242 * previous call to SetEmbedderData with the same index. Note that index 0 | 5020 * previous call to SetEmbedderData with the same index. Note that index 0 |
| 5243 * currently has a special meaning for Chrome's debugger. | 5021 * currently has a special meaning for Chrome's debugger. |
| 5244 */ | 5022 */ |
| 5245 V8_INLINE Local<Value> GetEmbedderData(int index); | 5023 V8_INLINE Local<Value> GetEmbedderData(int index); |
| 5246 | 5024 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5296 | 5074 |
| 5297 /** | 5075 /** |
| 5298 * Stack-allocated class which sets the execution context for all | 5076 * Stack-allocated class which sets the execution context for all |
| 5299 * operations executed within a local scope. | 5077 * operations executed within a local scope. |
| 5300 */ | 5078 */ |
| 5301 class Scope { | 5079 class Scope { |
| 5302 public: | 5080 public: |
| 5303 explicit V8_INLINE Scope(Handle<Context> context) : context_(context) { | 5081 explicit V8_INLINE Scope(Handle<Context> context) : context_(context) { |
| 5304 context_->Enter(); | 5082 context_->Enter(); |
| 5305 } | 5083 } |
| 5306 V8_DEPRECATED( | |
| 5307 "Use Handle version instead", | |
| 5308 V8_INLINE Scope(Isolate* isolate, Persistent<Context>& context)) // NOLI
NT | |
| 5309 : context_(Handle<Context>::New(isolate, context)) { | |
| 5310 context_->Enter(); | |
| 5311 } | |
| 5312 V8_INLINE ~Scope() { context_->Exit(); } | 5084 V8_INLINE ~Scope() { context_->Exit(); } |
| 5313 | 5085 |
| 5314 private: | 5086 private: |
| 5315 Handle<Context> context_; | 5087 Handle<Context> context_; |
| 5316 }; | 5088 }; |
| 5317 | 5089 |
| 5318 private: | 5090 private: |
| 5319 friend class Value; | 5091 friend class Value; |
| 5320 friend class Script; | 5092 friend class Script; |
| 5321 friend class Object; | 5093 friend class Object; |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5887 | 5659 |
| 5888 template <class T> | 5660 template <class T> |
| 5889 template <typename S, typename P> | 5661 template <typename S, typename P> |
| 5890 void PersistentBase<T>::SetWeak( | 5662 void PersistentBase<T>::SetWeak( |
| 5891 P* parameter, | 5663 P* parameter, |
| 5892 typename WeakCallbackData<S, P>::Callback callback) { | 5664 typename WeakCallbackData<S, P>::Callback callback) { |
| 5893 TYPE_CHECK(S, T); | 5665 TYPE_CHECK(S, T); |
| 5894 typedef typename WeakCallbackData<Value, void>::Callback Callback; | 5666 typedef typename WeakCallbackData<Value, void>::Callback Callback; |
| 5895 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), | 5667 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), |
| 5896 parameter, | 5668 parameter, |
| 5897 reinterpret_cast<Callback>(callback), | 5669 reinterpret_cast<Callback>(callback)); |
| 5898 NULL); | |
| 5899 } | 5670 } |
| 5900 | 5671 |
| 5901 | 5672 |
| 5902 template <class T> | 5673 template <class T> |
| 5903 template <typename P> | 5674 template <typename P> |
| 5904 void PersistentBase<T>::SetWeak( | 5675 void PersistentBase<T>::SetWeak( |
| 5905 P* parameter, | 5676 P* parameter, |
| 5906 typename WeakCallbackData<T, P>::Callback callback) { | 5677 typename WeakCallbackData<T, P>::Callback callback) { |
| 5907 SetWeak<T, P>(parameter, callback); | 5678 SetWeak<T, P>(parameter, callback); |
| 5908 } | 5679 } |
| 5909 | 5680 |
| 5910 | 5681 |
| 5911 template <class T, class M> | |
| 5912 template <typename S, typename P> | |
| 5913 void Persistent<T, M>::MakeWeak( | |
| 5914 P* parameters, | |
| 5915 typename WeakReferenceCallbacks<S, P>::Revivable callback) { | |
| 5916 TYPE_CHECK(S, T); | |
| 5917 typedef typename WeakReferenceCallbacks<Value, void>::Revivable Revivable; | |
| 5918 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), | |
| 5919 parameters, | |
| 5920 NULL, | |
| 5921 reinterpret_cast<Revivable>(callback)); | |
| 5922 } | |
| 5923 | |
| 5924 | |
| 5925 template <class T, class M> | |
| 5926 template <typename P> | |
| 5927 void Persistent<T, M>::MakeWeak( | |
| 5928 P* parameters, | |
| 5929 typename WeakReferenceCallbacks<T, P>::Revivable callback) { | |
| 5930 MakeWeak<T, P>(parameters, callback); | |
| 5931 } | |
| 5932 | |
| 5933 | |
| 5934 template <class T> | 5682 template <class T> |
| 5935 void PersistentBase<T>::ClearWeak() { | 5683 void PersistentBase<T>::ClearWeak() { |
| 5936 V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)); | 5684 V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)); |
| 5937 } | 5685 } |
| 5938 | 5686 |
| 5939 | 5687 |
| 5940 template <class T> | 5688 template <class T> |
| 5941 void PersistentBase<T>::MarkIndependent() { | 5689 void PersistentBase<T>::MarkIndependent() { |
| 5942 typedef internal::Internals I; | 5690 typedef internal::Internals I; |
| 5943 if (this->IsEmpty()) return; | 5691 if (this->IsEmpty()) return; |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6148 return is_construct_call_; | 5896 return is_construct_call_; |
| 6149 } | 5897 } |
| 6150 | 5898 |
| 6151 | 5899 |
| 6152 template<typename T> | 5900 template<typename T> |
| 6153 int FunctionCallbackInfo<T>::Length() const { | 5901 int FunctionCallbackInfo<T>::Length() const { |
| 6154 return length_; | 5902 return length_; |
| 6155 } | 5903 } |
| 6156 | 5904 |
| 6157 | 5905 |
| 6158 template <class T> | |
| 6159 Local<T> HandleScope::Close(Handle<T> value) { | |
| 6160 internal::Object** before = reinterpret_cast<internal::Object**>(*value); | |
| 6161 internal::Object** after = RawClose(before); | |
| 6162 return Local<T>(reinterpret_cast<T*>(after)); | |
| 6163 } | |
| 6164 | |
| 6165 Handle<Value> ScriptOrigin::ResourceName() const { | 5906 Handle<Value> ScriptOrigin::ResourceName() const { |
| 6166 return resource_name_; | 5907 return resource_name_; |
| 6167 } | 5908 } |
| 6168 | 5909 |
| 6169 | 5910 |
| 6170 Handle<Integer> ScriptOrigin::ResourceLineOffset() const { | 5911 Handle<Integer> ScriptOrigin::ResourceLineOffset() const { |
| 6171 return resource_line_offset_; | 5912 return resource_line_offset_; |
| 6172 } | 5913 } |
| 6173 | 5914 |
| 6174 | 5915 |
| 6175 Handle<Integer> ScriptOrigin::ResourceColumnOffset() const { | 5916 Handle<Integer> ScriptOrigin::ResourceColumnOffset() const { |
| 6176 return resource_column_offset_; | 5917 return resource_column_offset_; |
| 6177 } | 5918 } |
| 6178 | 5919 |
| 6179 Handle<Boolean> ScriptOrigin::ResourceIsSharedCrossOrigin() const { | 5920 Handle<Boolean> ScriptOrigin::ResourceIsSharedCrossOrigin() const { |
| 6180 return resource_is_shared_cross_origin_; | 5921 return resource_is_shared_cross_origin_; |
| 6181 } | 5922 } |
| 6182 | 5923 |
| 6183 | 5924 |
| 6184 Handle<Boolean> Boolean::New(Isolate* isolate, bool value) { | 5925 Handle<Boolean> Boolean::New(Isolate* isolate, bool value) { |
| 6185 return value ? True(isolate) : False(isolate); | 5926 return value ? True(isolate) : False(isolate); |
| 6186 } | 5927 } |
| 6187 | 5928 |
| 6188 | 5929 |
| 6189 Handle<Boolean> Boolean::New(bool value) { | |
| 6190 return Boolean::New(Isolate::GetCurrent(), value); | |
| 6191 } | |
| 6192 | |
| 6193 | |
| 6194 void Template::Set(Isolate* isolate, const char* name, v8::Handle<Data> value) { | 5930 void Template::Set(Isolate* isolate, const char* name, v8::Handle<Data> value) { |
| 6195 Set(v8::String::NewFromUtf8(isolate, name), value); | 5931 Set(v8::String::NewFromUtf8(isolate, name), value); |
| 6196 } | 5932 } |
| 6197 | 5933 |
| 6198 | 5934 |
| 6199 void Template::Set(const char* name, v8::Handle<Data> value) { | |
| 6200 Set(Isolate::GetCurrent(), name, value); | |
| 6201 } | |
| 6202 | |
| 6203 | |
| 6204 Local<Value> Object::GetInternalField(int index) { | 5935 Local<Value> Object::GetInternalField(int index) { |
| 6205 #ifndef V8_ENABLE_CHECKS | 5936 #ifndef V8_ENABLE_CHECKS |
| 6206 typedef internal::Object O; | 5937 typedef internal::Object O; |
| 6207 typedef internal::HeapObject HO; | 5938 typedef internal::HeapObject HO; |
| 6208 typedef internal::Internals I; | 5939 typedef internal::Internals I; |
| 6209 O* obj = *reinterpret_cast<O**>(this); | 5940 O* obj = *reinterpret_cast<O**>(this); |
| 6210 // Fast path: If the object is a plain JSObject, which is the common case, we | 5941 // Fast path: If the object is a plain JSObject, which is the common case, we |
| 6211 // know where to find the internal fields and can return the value directly. | 5942 // know where to find the internal fields and can return the value directly. |
| 6212 if (I::GetInstanceType(obj) == I::kJSObjectType) { | 5943 if (I::GetInstanceType(obj) == I::kJSObjectType) { |
| 6213 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); | 5944 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6246 | 5977 |
| 6247 Local<String> String::Empty(Isolate* isolate) { | 5978 Local<String> String::Empty(Isolate* isolate) { |
| 6248 typedef internal::Object* S; | 5979 typedef internal::Object* S; |
| 6249 typedef internal::Internals I; | 5980 typedef internal::Internals I; |
| 6250 I::CheckInitialized(isolate); | 5981 I::CheckInitialized(isolate); |
| 6251 S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex); | 5982 S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex); |
| 6252 return Local<String>(reinterpret_cast<String*>(slot)); | 5983 return Local<String>(reinterpret_cast<String*>(slot)); |
| 6253 } | 5984 } |
| 6254 | 5985 |
| 6255 | 5986 |
| 6256 Local<String> String::New(const char* data, int length) { | |
| 6257 return NewFromUtf8(Isolate::GetCurrent(), data, kNormalString, length); | |
| 6258 } | |
| 6259 | |
| 6260 | |
| 6261 Local<String> String::New(const uint16_t* data, int length) { | |
| 6262 return NewFromTwoByte(Isolate::GetCurrent(), data, kNormalString, length); | |
| 6263 } | |
| 6264 | |
| 6265 | |
| 6266 Local<String> String::NewSymbol(const char* data, int length) { | |
| 6267 return NewFromUtf8(Isolate::GetCurrent(), data, kInternalizedString, length); | |
| 6268 } | |
| 6269 | |
| 6270 | |
| 6271 Local<String> String::NewUndetectable(const char* data, int length) { | |
| 6272 return NewFromUtf8(Isolate::GetCurrent(), data, kUndetectableString, length); | |
| 6273 } | |
| 6274 | |
| 6275 | |
| 6276 Local<String> String::NewUndetectable(const uint16_t* data, int length) { | |
| 6277 return NewFromTwoByte( | |
| 6278 Isolate::GetCurrent(), data, kUndetectableString, length); | |
| 6279 } | |
| 6280 | |
| 6281 | |
| 6282 String::ExternalStringResource* String::GetExternalStringResource() const { | 5987 String::ExternalStringResource* String::GetExternalStringResource() const { |
| 6283 typedef internal::Object O; | 5988 typedef internal::Object O; |
| 6284 typedef internal::Internals I; | 5989 typedef internal::Internals I; |
| 6285 O* obj = *reinterpret_cast<O**>(const_cast<String*>(this)); | 5990 O* obj = *reinterpret_cast<O**>(const_cast<String*>(this)); |
| 6286 String::ExternalStringResource* result; | 5991 String::ExternalStringResource* result; |
| 6287 if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) { | 5992 if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) { |
| 6288 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); | 5993 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); |
| 6289 result = reinterpret_cast<String::ExternalStringResource*>(value); | 5994 result = reinterpret_cast<String::ExternalStringResource*>(value); |
| 6290 } else { | 5995 } else { |
| 6291 result = NULL; | 5996 result = NULL; |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6642 | 6347 |
| 6643 Handle<Boolean> False(Isolate* isolate) { | 6348 Handle<Boolean> False(Isolate* isolate) { |
| 6644 typedef internal::Object* S; | 6349 typedef internal::Object* S; |
| 6645 typedef internal::Internals I; | 6350 typedef internal::Internals I; |
| 6646 I::CheckInitialized(isolate); | 6351 I::CheckInitialized(isolate); |
| 6647 S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex); | 6352 S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex); |
| 6648 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); | 6353 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); |
| 6649 } | 6354 } |
| 6650 | 6355 |
| 6651 | 6356 |
| 6652 void Isolate::SetData(void* data) { | |
| 6653 typedef internal::Internals I; | |
| 6654 I::SetEmbedderData(this, 0, data); | |
| 6655 } | |
| 6656 | |
| 6657 | |
| 6658 void* Isolate::GetData() { | |
| 6659 typedef internal::Internals I; | |
| 6660 return I::GetEmbedderData(this, 0); | |
| 6661 } | |
| 6662 | |
| 6663 | |
| 6664 void Isolate::SetData(uint32_t slot, void* data) { | 6357 void Isolate::SetData(uint32_t slot, void* data) { |
| 6665 typedef internal::Internals I; | 6358 typedef internal::Internals I; |
| 6666 I::SetEmbedderData(this, slot, data); | 6359 I::SetEmbedderData(this, slot, data); |
| 6667 } | 6360 } |
| 6668 | 6361 |
| 6669 | 6362 |
| 6670 void* Isolate::GetData(uint32_t slot) { | 6363 void* Isolate::GetData(uint32_t slot) { |
| 6671 typedef internal::Internals I; | 6364 typedef internal::Internals I; |
| 6672 return I::GetEmbedderData(this, slot); | 6365 return I::GetEmbedderData(this, slot); |
| 6673 } | 6366 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6743 */ | 6436 */ |
| 6744 | 6437 |
| 6745 | 6438 |
| 6746 } // namespace v8 | 6439 } // namespace v8 |
| 6747 | 6440 |
| 6748 | 6441 |
| 6749 #undef TYPE_CHECK | 6442 #undef TYPE_CHECK |
| 6750 | 6443 |
| 6751 | 6444 |
| 6752 #endif // V8_H_ | 6445 #endif // V8_H_ |
| OLD | NEW |