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 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1657 * it as string if successful. | 1657 * it as string if successful. |
1658 * | 1658 * |
1659 * \param json_object The JSON-serializable object to stringify. | 1659 * \param json_object The JSON-serializable object to stringify. |
1660 * \return The corresponding string if successfully stringified. | 1660 * \return The corresponding string if successfully stringified. |
1661 */ | 1661 */ |
1662 static V8_WARN_UNUSED_RESULT MaybeLocal<String> Stringify( | 1662 static V8_WARN_UNUSED_RESULT MaybeLocal<String> Stringify( |
1663 Local<Context> context, Local<Object> json_object, | 1663 Local<Context> context, Local<Object> json_object, |
1664 Local<String> gap = Local<String>()); | 1664 Local<String> gap = Local<String>()); |
1665 }; | 1665 }; |
1666 | 1666 |
| 1667 /** |
| 1668 * Value serialization compatible with the HTML structured clone algorithm. |
| 1669 * The format is backward-compatible (i.e. safe to store to disk). |
| 1670 * |
| 1671 * WARNING: This API is under development, and changes (including incompatible |
| 1672 * changes to the API or wire format) may occur without notice until this |
| 1673 * warning is removed. |
| 1674 */ |
| 1675 class V8_EXPORT ValueSerializer { |
| 1676 public: |
| 1677 explicit ValueSerializer(Isolate* isolate); |
| 1678 ~ValueSerializer(); |
| 1679 |
| 1680 /* |
| 1681 * Writes out a header, which includes the format version. |
| 1682 */ |
| 1683 void WriteHeader(); |
| 1684 |
| 1685 /* |
| 1686 * Serializes a JavaScript value into the buffer. |
| 1687 */ |
| 1688 V8_WARN_UNUSED_RESULT Maybe<bool> WriteValue(Local<Context> context, |
| 1689 Local<Value> value); |
| 1690 |
| 1691 /* |
| 1692 * Returns the stored data. This serializer should not be used once the buffer |
| 1693 * is released. The contents are undefined if a previous write has failed. |
| 1694 */ |
| 1695 std::vector<uint8_t> ReleaseBuffer(); |
| 1696 |
| 1697 private: |
| 1698 ValueSerializer(const ValueSerializer&) = delete; |
| 1699 void operator=(const ValueSerializer&) = delete; |
| 1700 |
| 1701 struct PrivateData; |
| 1702 PrivateData* private_; |
| 1703 }; |
| 1704 |
| 1705 /** |
| 1706 * Deserializes values from data written with ValueSerializer, or a compatible |
| 1707 * implementation. |
| 1708 * |
| 1709 * WARNING: This API is under development, and changes (including incompatible |
| 1710 * changes to the API or wire format) may occur without notice until this |
| 1711 * warning is removed. |
| 1712 */ |
| 1713 class V8_EXPORT ValueDeserializer { |
| 1714 public: |
| 1715 ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size); |
| 1716 ~ValueDeserializer(); |
| 1717 |
| 1718 /* |
| 1719 * Reads and validates a header (including the format version). |
| 1720 * May, for example, reject an invalid or unsupported wire format. |
| 1721 */ |
| 1722 V8_WARN_UNUSED_RESULT Maybe<bool> ReadHeader(); |
| 1723 |
| 1724 /* |
| 1725 * Deserializes a JavaScript value from the buffer. |
| 1726 */ |
| 1727 V8_WARN_UNUSED_RESULT MaybeLocal<Value> ReadValue(Local<Context> context); |
| 1728 |
| 1729 /* |
| 1730 * Must be called before ReadHeader to enable support for reading the legacy |
| 1731 * wire format (i.e., which predates this being shipped). |
| 1732 * |
| 1733 * Don't use this unless you need to read data written by previous versions of |
| 1734 * blink::ScriptValueSerializer. |
| 1735 */ |
| 1736 void SetSupportsLegacyWireFormat(bool supports_legacy_wire_format); |
| 1737 |
| 1738 /* |
| 1739 * Reads the underlying wire format version. Likely mostly to be useful to |
| 1740 * legacy code reading old wire format versions. Must be called after |
| 1741 * ReadHeader. |
| 1742 */ |
| 1743 uint32_t GetWireFormatVersion() const; |
| 1744 |
| 1745 private: |
| 1746 ValueDeserializer(const ValueDeserializer&) = delete; |
| 1747 void operator=(const ValueDeserializer&) = delete; |
| 1748 |
| 1749 struct PrivateData; |
| 1750 PrivateData* private_; |
| 1751 }; |
1667 | 1752 |
1668 /** | 1753 /** |
1669 * A map whose keys are referenced weakly. It is similar to JavaScript WeakMap | 1754 * A map whose keys are referenced weakly. It is similar to JavaScript WeakMap |
1670 * but can be created without entering a v8::Context and hence shouldn't | 1755 * but can be created without entering a v8::Context and hence shouldn't |
1671 * escape to JavaScript. | 1756 * escape to JavaScript. |
1672 */ | 1757 */ |
1673 class V8_EXPORT NativeWeakMap : public Data { | 1758 class V8_EXPORT NativeWeakMap : public Data { |
1674 public: | 1759 public: |
1675 static Local<NativeWeakMap> New(Isolate* isolate); | 1760 static Local<NativeWeakMap> New(Isolate* isolate); |
1676 void Set(Local<Value> key, Local<Value> value); | 1761 void Set(Local<Value> key, Local<Value> value); |
(...skipping 7329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9006 */ | 9091 */ |
9007 | 9092 |
9008 | 9093 |
9009 } // namespace v8 | 9094 } // namespace v8 |
9010 | 9095 |
9011 | 9096 |
9012 #undef TYPE_CHECK | 9097 #undef TYPE_CHECK |
9013 | 9098 |
9014 | 9099 |
9015 #endif // INCLUDE_V8_H_ | 9100 #endif // INCLUDE_V8_H_ |
OLD | NEW |