Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
v8::ValueSerializer Class Reference

#include <v8-value-serializer.h>

Classes

class  Delegate
 

Public Types

enum class  SharedImmutableArrayBufferMode { kDisabled , kEnabled }
 

Public Member Functions

 ValueSerializer (Isolate *isolate, SharedImmutableArrayBufferMode share_immutable_array_buffer=SharedImmutableArrayBufferMode::kDisabled)
 
 ValueSerializer (Isolate *isolate, Delegate *delegate, SharedImmutableArrayBufferMode share_immutable_array_buffer=SharedImmutableArrayBufferMode::kDisabled)
 
 ~ValueSerializer ()
 
void WriteHeader ()
 
Maybe< bool > WriteValue (Local< Context > context, Local< Value > value)
 
std::pair< uint8_t *, size_t > Release ()
 
void TransferArrayBuffer (uint32_t transfer_id, Local< ArrayBuffer > array_buffer)
 
void SetTreatArrayBufferViewsAsHostObjects (bool mode)
 
std::vector< std::shared_ptr< v8::BackingStore > > ReleaseSharedImmutableBackingStores ()
 
void WriteUint32 (uint32_t value)
 
void WriteUint64 (uint64_t value)
 
void WriteDouble (double value)
 
void WriteRawBytes (const void *source, size_t length)
 
 ValueSerializer (const ValueSerializer &)=delete
 
void operator= (const ValueSerializer &)=delete
 

Detailed Description

Value serialization compatible with the HTML structured clone algorithm. The format is backward-compatible (i.e. safe to store to disk).

Member Enumeration Documentation

◆ SharedImmutableArrayBufferMode

Enumerator
kDisabled 
kEnabled 

Constructor & Destructor Documentation

◆ ValueSerializer() [1/3]

v8::ValueSerializer::ValueSerializer ( Isolate isolate,
SharedImmutableArrayBufferMode  share_immutable_array_buffer = SharedImmutableArrayBufferMode::kDisabled 
)
explicit

◆ ValueSerializer() [2/3]

v8::ValueSerializer::ValueSerializer ( Isolate isolate,
Delegate delegate,
SharedImmutableArrayBufferMode  share_immutable_array_buffer = SharedImmutableArrayBufferMode::kDisabled 
)

◆ ~ValueSerializer()

v8::ValueSerializer::~ValueSerializer ( )

◆ ValueSerializer() [3/3]

v8::ValueSerializer::ValueSerializer ( const ValueSerializer )
delete

Member Function Documentation

◆ operator=()

void v8::ValueSerializer::operator= ( const ValueSerializer )
delete

◆ Release()

std::pair< uint8_t *, size_t > v8::ValueSerializer::Release ( )

Returns the stored data (allocated using the delegate's ReallocateBufferMemory) and its size. This serializer should not be used once the buffer is released. The contents are undefined if a previous write has failed. Ownership of the buffer is transferred to the caller.

◆ ReleaseSharedImmutableBackingStores()

std::vector< std::shared_ptr< v8::BackingStore > > v8::ValueSerializer::ReleaseSharedImmutableBackingStores ( )

Returns the backing stores of all immutable JSArrayBuffers that were serialized without copying.

When SharedImmutableArrayBufferMode::kEnabled is passed to the constructor, the embedder MUST call this method after serialization and transmit these backing stores to the receiver, where they must be passed to ValueDeserializer::SetSharedImmutableBackingStores.

◆ SetTreatArrayBufferViewsAsHostObjects()

void v8::ValueSerializer::SetTreatArrayBufferViewsAsHostObjects ( bool  mode)

Indicate whether to treat ArrayBufferView objects as host objects, i.e. pass them to Delegate::WriteHostObject. This should not be called when no Delegate was passed.

The default is not to treat ArrayBufferViews as host objects.

◆ TransferArrayBuffer()

void v8::ValueSerializer::TransferArrayBuffer ( uint32_t  transfer_id,
Local< ArrayBuffer array_buffer 
)

Marks an ArrayBuffer as havings its contents transferred out of band. Pass the corresponding ArrayBuffer in the deserializing context to ValueDeserializer::TransferArrayBuffer.

◆ WriteDouble()

void v8::ValueSerializer::WriteDouble ( double  value)

◆ WriteHeader()

void v8::ValueSerializer::WriteHeader ( )

Writes out a header, which includes the format version.

◆ WriteRawBytes()

void v8::ValueSerializer::WriteRawBytes ( const void *  source,
size_t  length 
)

◆ WriteUint32()

void v8::ValueSerializer::WriteUint32 ( uint32_t  value)

Write raw data in various common formats to the buffer. Note that integer types are written in base-128 varint format, not with a binary copy. For use during an override of Delegate::WriteHostObject.

◆ WriteUint64()

void v8::ValueSerializer::WriteUint64 ( uint64_t  value)

◆ WriteValue()

Maybe< bool > v8::ValueSerializer::WriteValue ( Local< Context context,
Local< Value value 
)

Serializes a JavaScript value into the buffer.


The documentation for this class was generated from the following file: