| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** \mainpage V8 API Reference Guide | 5 /** \mainpage V8 API Reference Guide |
| 6 * | 6 * |
| 7 * V8 is Google's open source JavaScript engine. | 7 * V8 is Google's open source JavaScript engine. |
| 8 * | 8 * |
| 9 * This set of documents provides reference material generated from the | 9 * This set of documents provides reference material generated from the |
| 10 * V8 header file, include/v8.h. | 10 * V8 header file, include/v8.h. |
| (...skipping 1755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1766 | 1766 |
| 1767 | 1767 |
| 1768 /** | 1768 /** |
| 1769 * A JavaScript string value (ECMA-262, 4.3.17). | 1769 * A JavaScript string value (ECMA-262, 4.3.17). |
| 1770 */ | 1770 */ |
| 1771 class V8_EXPORT String : public Name { | 1771 class V8_EXPORT String : public Name { |
| 1772 public: | 1772 public: |
| 1773 enum Encoding { | 1773 enum Encoding { |
| 1774 UNKNOWN_ENCODING = 0x1, | 1774 UNKNOWN_ENCODING = 0x1, |
| 1775 TWO_BYTE_ENCODING = 0x0, | 1775 TWO_BYTE_ENCODING = 0x0, |
| 1776 ASCII_ENCODING = 0x4, // TODO(yangguo): deprecate this. | |
| 1777 ONE_BYTE_ENCODING = 0x4 | 1776 ONE_BYTE_ENCODING = 0x4 |
| 1778 }; | 1777 }; |
| 1779 /** | 1778 /** |
| 1780 * Returns the number of characters in this string. | 1779 * Returns the number of characters in this string. |
| 1781 */ | 1780 */ |
| 1782 int Length() const; | 1781 int Length() const; |
| 1783 | 1782 |
| 1784 /** | 1783 /** |
| 1785 * Returns the number of bytes in the UTF-8 encoded | 1784 * Returns the number of bytes in the UTF-8 encoded |
| 1786 * representation of this string. | 1785 * representation of this string. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1822 * \param options Various options that might affect performance of this or | 1821 * \param options Various options that might affect performance of this or |
| 1823 * subsequent operations. | 1822 * subsequent operations. |
| 1824 * \return The number of characters copied to the buffer excluding the null | 1823 * \return The number of characters copied to the buffer excluding the null |
| 1825 * terminator. For WriteUtf8: The number of bytes copied to the buffer | 1824 * terminator. For WriteUtf8: The number of bytes copied to the buffer |
| 1826 * including the null terminator (if written). | 1825 * including the null terminator (if written). |
| 1827 */ | 1826 */ |
| 1828 enum WriteOptions { | 1827 enum WriteOptions { |
| 1829 NO_OPTIONS = 0, | 1828 NO_OPTIONS = 0, |
| 1830 HINT_MANY_WRITES_EXPECTED = 1, | 1829 HINT_MANY_WRITES_EXPECTED = 1, |
| 1831 NO_NULL_TERMINATION = 2, | 1830 NO_NULL_TERMINATION = 2, |
| 1832 PRESERVE_ASCII_NULL = 4, // TODO(yangguo): deprecate this. | |
| 1833 PRESERVE_ONE_BYTE_NULL = 4, | 1831 PRESERVE_ONE_BYTE_NULL = 4, |
| 1834 // Used by WriteUtf8 to replace orphan surrogate code units with the | 1832 // Used by WriteUtf8 to replace orphan surrogate code units with the |
| 1835 // unicode replacement character. Needs to be set to guarantee valid UTF-8 | 1833 // unicode replacement character. Needs to be set to guarantee valid UTF-8 |
| 1836 // output. | 1834 // output. |
| 1837 REPLACE_INVALID_UTF8 = 8 | 1835 REPLACE_INVALID_UTF8 = 8 |
| 1838 }; | 1836 }; |
| 1839 | 1837 |
| 1840 // 16-bit character codes. | 1838 // 16-bit character codes. |
| 1841 int Write(uint16_t* buffer, | 1839 int Write(uint16_t* buffer, |
| 1842 int start = 0, | 1840 int start = 0, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1861 /** | 1859 /** |
| 1862 * Returns true if the string is external | 1860 * Returns true if the string is external |
| 1863 */ | 1861 */ |
| 1864 bool IsExternal() const; | 1862 bool IsExternal() const; |
| 1865 | 1863 |
| 1866 /** | 1864 /** |
| 1867 * Returns true if the string is both external and one-byte. | 1865 * Returns true if the string is both external and one-byte. |
| 1868 */ | 1866 */ |
| 1869 bool IsExternalOneByte() const; | 1867 bool IsExternalOneByte() const; |
| 1870 | 1868 |
| 1871 // TODO(yangguo): deprecate this. | |
| 1872 bool IsExternalAscii() const { return IsExternalOneByte(); } | |
| 1873 | |
| 1874 class V8_EXPORT ExternalStringResourceBase { // NOLINT | 1869 class V8_EXPORT ExternalStringResourceBase { // NOLINT |
| 1875 public: | 1870 public: |
| 1876 virtual ~ExternalStringResourceBase() {} | 1871 virtual ~ExternalStringResourceBase() {} |
| 1877 | 1872 |
| 1878 protected: | 1873 protected: |
| 1879 ExternalStringResourceBase() {} | 1874 ExternalStringResourceBase() {} |
| 1880 | 1875 |
| 1881 /** | 1876 /** |
| 1882 * Internally V8 will call this Dispose method when the external string | 1877 * Internally V8 will call this Dispose method when the external string |
| 1883 * resource is no longer needed. The default implementation will use the | 1878 * resource is no longer needed. The default implementation will use the |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1942 */ | 1937 */ |
| 1943 virtual ~ExternalOneByteStringResource() {} | 1938 virtual ~ExternalOneByteStringResource() {} |
| 1944 /** The string data from the underlying buffer.*/ | 1939 /** The string data from the underlying buffer.*/ |
| 1945 virtual const char* data() const = 0; | 1940 virtual const char* data() const = 0; |
| 1946 /** The number of Latin-1 characters in the string.*/ | 1941 /** The number of Latin-1 characters in the string.*/ |
| 1947 virtual size_t length() const = 0; | 1942 virtual size_t length() const = 0; |
| 1948 protected: | 1943 protected: |
| 1949 ExternalOneByteStringResource() {} | 1944 ExternalOneByteStringResource() {} |
| 1950 }; | 1945 }; |
| 1951 | 1946 |
| 1952 typedef ExternalOneByteStringResource ExternalAsciiStringResource; | |
| 1953 | |
| 1954 /** | 1947 /** |
| 1955 * If the string is an external string, return the ExternalStringResourceBase | 1948 * If the string is an external string, return the ExternalStringResourceBase |
| 1956 * regardless of the encoding, otherwise return NULL. The encoding of the | 1949 * regardless of the encoding, otherwise return NULL. The encoding of the |
| 1957 * string is returned in encoding_out. | 1950 * string is returned in encoding_out. |
| 1958 */ | 1951 */ |
| 1959 V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase( | 1952 V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase( |
| 1960 Encoding* encoding_out) const; | 1953 Encoding* encoding_out) const; |
| 1961 | 1954 |
| 1962 /** | 1955 /** |
| 1963 * Get the ExternalStringResource for an external string. Returns | 1956 * Get the ExternalStringResource for an external string. Returns |
| 1964 * NULL if IsExternal() doesn't return true. | 1957 * NULL if IsExternal() doesn't return true. |
| 1965 */ | 1958 */ |
| 1966 V8_INLINE ExternalStringResource* GetExternalStringResource() const; | 1959 V8_INLINE ExternalStringResource* GetExternalStringResource() const; |
| 1967 | 1960 |
| 1968 /** | 1961 /** |
| 1969 * Get the ExternalOneByteStringResource for an external one-byte string. | 1962 * Get the ExternalOneByteStringResource for an external one-byte string. |
| 1970 * Returns NULL if IsExternalOneByte() doesn't return true. | 1963 * Returns NULL if IsExternalOneByte() doesn't return true. |
| 1971 */ | 1964 */ |
| 1972 const ExternalOneByteStringResource* GetExternalOneByteStringResource() const; | 1965 const ExternalOneByteStringResource* GetExternalOneByteStringResource() const; |
| 1973 | 1966 |
| 1974 // TODO(yangguo): deprecate this. | |
| 1975 const ExternalAsciiStringResource* GetExternalAsciiStringResource() const { | |
| 1976 return GetExternalOneByteStringResource(); | |
| 1977 } | |
| 1978 | |
| 1979 V8_INLINE static String* Cast(v8::Value* obj); | 1967 V8_INLINE static String* Cast(v8::Value* obj); |
| 1980 | 1968 |
| 1981 enum NewStringType { | 1969 enum NewStringType { |
| 1982 kNormalString, kInternalizedString, kUndetectableString | 1970 kNormalString, kInternalizedString, kUndetectableString |
| 1983 }; | 1971 }; |
| 1984 | 1972 |
| 1985 /** Allocates a new string from UTF-8 data.*/ | 1973 /** Allocates a new string from UTF-8 data.*/ |
| 1986 static Local<String> NewFromUtf8(Isolate* isolate, | 1974 static Local<String> NewFromUtf8(Isolate* isolate, |
| 1987 const char* data, | 1975 const char* data, |
| 1988 NewStringType type = kNormalString, | 1976 NewStringType type = kNormalString, |
| (...skipping 5067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7056 */ | 7044 */ |
| 7057 | 7045 |
| 7058 | 7046 |
| 7059 } // namespace v8 | 7047 } // namespace v8 |
| 7060 | 7048 |
| 7061 | 7049 |
| 7062 #undef TYPE_CHECK | 7050 #undef TYPE_CHECK |
| 7063 | 7051 |
| 7064 | 7052 |
| 7065 #endif // V8_H_ | 7053 #endif // V8_H_ |
| OLD | NEW |