v8  10.1.124 (node 18.2.0)
V8 is Google's open source JavaScript engine
ValueSerializer::Delegate Class Referenceabstract

#include <v8-value-serializer.h>

Public Member Functions

virtual ~Delegate ()=default
 
virtual void ThrowDataCloneError (Local< String > message)=0
 
virtual Maybe< bool > WriteHostObject (Isolate *isolate, Local< Object > object)
 
virtual Maybe< uint32_t > GetSharedArrayBufferId (Isolate *isolate, Local< SharedArrayBuffer > shared_array_buffer)
 
virtual Maybe< uint32_t > GetWasmModuleTransferId (Isolate *isolate, Local< WasmModuleObject > module)
 
virtual bool SupportsSharedValues () const
 
virtual Maybe< uint32_t > GetSharedValueId (Isolate *isolate, Local< Value > shared_value)
 
virtual void * ReallocateBufferMemory (void *old_buffer, size_t size, size_t *actual_size)
 
virtual void FreeBufferMemory (void *buffer)
 

Detailed Description

Definition at line 37 of file v8-value-serializer.h.

Constructor & Destructor Documentation

◆ ~Delegate()

virtual ~Delegate ( )
virtualdefault

Member Function Documentation

◆ FreeBufferMemory()

virtual void FreeBufferMemory ( void *  buffer)
virtual

Frees a buffer allocated with |ReallocateBufferMemory|.

The default implementation uses the stdlib's free() function.

◆ GetSharedArrayBufferId()

virtual Maybe<uint32_t> GetSharedArrayBufferId ( Isolate isolate,
Local< SharedArrayBuffer shared_array_buffer 
)
virtual

Called when the ValueSerializer is going to serialize a SharedArrayBuffer object. The embedder must return an ID for the object, using the same ID if this SharedArrayBuffer has already been serialized in this buffer. When deserializing, this ID will be passed to ValueDeserializer::GetSharedArrayBufferFromId as |clone_id|.

If the object cannot be serialized, an exception should be thrown and Nothing<uint32_t>() returned.

◆ GetSharedValueId()

virtual Maybe<uint32_t> GetSharedValueId ( Isolate isolate,
Local< Value shared_value 
)
virtual

Called when the ValueSerializer serializes a value that is shared across Isolates. The embedder must return an ID for the object. This function must be idempotent for the same object. When deserializing, the ID will be passed to ValueDeserializer::Delegate::GetSharedValueFromId as |shared_value_id|.

◆ GetWasmModuleTransferId()

virtual Maybe<uint32_t> GetWasmModuleTransferId ( Isolate isolate,
Local< WasmModuleObject module 
)
virtual

◆ ReallocateBufferMemory()

virtual void* ReallocateBufferMemory ( void *  old_buffer,
size_t  size,
size_t *  actual_size 
)
virtual

Allocates memory for the buffer of at least the size provided. The actual size (which may be greater or equal) is written to |actual_size|. If no buffer has been allocated yet, nullptr will be provided.

If the memory cannot be allocated, nullptr should be returned. |actual_size| will be ignored. It is assumed that |old_buffer| is still valid in this case and has not been modified.

The default implementation uses the stdlib's realloc() function.

◆ SupportsSharedValues()

virtual bool SupportsSharedValues ( ) const
virtual

Returns whether shared values are supported. GetSharedValueId is only called if SupportsSharedValues() returns true.

◆ ThrowDataCloneError()

virtual void ThrowDataCloneError ( Local< String message)
pure virtual

Handles the case where a DataCloneError would be thrown in the structured clone spec. Other V8 embedders may throw some other appropriate exception type.

◆ WriteHostObject()

virtual Maybe<bool> WriteHostObject ( Isolate isolate,
Local< Object object 
)
virtual

The embedder overrides this method to write some kind of host object, if possible. If not, a suitable exception should be thrown and Nothing<bool>() returned.


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