V8 Project
v8::ScriptCompiler::ExternalSourceStream Class Referenceabstract

For streaming incomplete script data to V8. More...

#include <v8.h>

+ Collaboration diagram for v8::ScriptCompiler::ExternalSourceStream:

Public Member Functions

virtual ~ExternalSourceStream ()
 
virtual size_t GetMoreData (const uint8_t **src)=0
 V8 calls this to request the next chunk of data from the embedder. More...
 

Detailed Description

For streaming incomplete script data to V8.

The embedder should implement a subclass of this class.

Definition at line 1096 of file v8.h.

Constructor & Destructor Documentation

◆ ~ExternalSourceStream()

virtual v8::ScriptCompiler::ExternalSourceStream::~ExternalSourceStream ( )
inlinevirtual

Definition at line 1098 of file v8.h.

1098 {}

Member Function Documentation

◆ GetMoreData()

virtual size_t v8::ScriptCompiler::ExternalSourceStream::GetMoreData ( const uint8_t **  src)
pure virtual

V8 calls this to request the next chunk of data from the embedder.

This function will be called on a background thread, so it's OK to block and wait for the data, if the embedder doesn't have data yet. Returns the length of the data returned. When the data ends, GetMoreData should return 0. Caller takes ownership of the data.

When streaming UTF-8 data, V8 handles multi-byte characters split between two data chunks, but doesn't handle multi-byte characters split between more than two data chunks. The embedder can avoid this problem by always returning at least 2 bytes of data.

If the embedder wants to cancel the streaming, they should make the next GetMoreData call return 0. V8 will interpret it as end of data (and most probably, parsing will fail). The streaming task will return as soon as V8 has parsed the data it received so far.

Referenced by v8::internal::ExternalStreamingStream::FillBuffer().

+ Here is the caller graph for this function:

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