Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
js_engine.hpp File Reference
#include <atomic>
#include <string>
#include <string_view>
#include <functional>
#include <optional>
#include <memory>
#include <vector>
#include <cstddef>
#include <cstdint>
#include <stdexcept>
#include <unordered_set>
#include <choc/containers/choc_Value.h>
#include <choc/text/choc_JSON.h>

Go to the source code of this file.

Classes

struct  pulp::view::HostObjectProperty
struct  pulp::view::HostObjectMethod
struct  pulp::view::HostObjectDescriptor
struct  pulp::view::JsEngineCreationStats
class  pulp::view::JsEngine
struct  pulp::view::ScriptBytecodeCacheStats
 Process-wide reuse of compiled script bytecode (QuickJS backend). More...

Namespaces

namespace  pulp
namespace  pulp::view
 Hover-cursor tracking for platform window hosts.
namespace  pulp::view::detail

Typedefs

using pulp::view::ModuleResolver = std::function<std::optional<std::string>(std::string_view path)>
using pulp::view::ModuleCompletionHandler = std::function<void(const std::string& error, const choc::value::Value& result)>
using pulp::view::LogCallback = std::function<void(std::string_view level, std::string_view message)>
using pulp::view::NativeFunction = std::function<choc::value::Value(const choc::value::Value* args, size_t num_args)>
using pulp::view::NativePromiseFunction = NativeFunction

Enumerations

enum class  pulp::view::JsEngineType { pulp::view::quickjs , pulp::view::jsc , pulp::view::v8 }

Functions

constexpr std::string_view pulp::view::engine_type_name (JsEngineType type)
std::unique_ptr< JsEngine > pulp::view::create_js_engine (JsEngineType type)
std::unique_ptr< JsEngine > pulp::view::create_default_js_engine ()
bool pulp::view::is_engine_available (JsEngineType type)
JsEngineCreationStats pulp::view::js_engine_creation_stats ()
void pulp::view::reset_js_engine_creation_stats_for_tests ()
ScriptBytecodeCacheStats pulp::view::script_bytecode_cache_stats ()
void pulp::view::clear_script_bytecode_cache ()
 Drop every stored script (tests; a host that wants the memory back).
std::size_t pulp::view::precompile_scripts (const std::vector< std::string > &sources, const std::atomic< bool > *cancel=nullptr)
 Compile whole scripts into the bytecode cache without running them, on the calling thread, in a private QuickJS runtime.
bool pulp::view::script_bytecode_cached (const std::string &source)
 True when byte-identical source has stored bytecode (tests, diagnostics).
std::vector< std::uint8_t > pulp::view::build_embedded_script_bytecode (const std::string &source)
 Build-time script bytecode (QuickJS backend).
bool pulp::view::register_embedded_script_bytecode (const std::uint8_t *blob, std::size_t size)
 Returns false (and registers nothing) for a malformed blob, or one whose engine fingerprint differs from this process's engine.
std::string pulp::view::script_bytecode_engine_fingerprint ()
 The engine's bytecode fingerprint: the QuickJS version plus a digest of the bytecode this engine emits for a fixed probe script, so any change to the bytecode format or opcode/atom numbering changes it.
void pulp::view::detail::set_precompile_claim_hook_for_tests (std::function< void(const std::string &)> hook)
 Tests only: called by precompile_scripts() on its own thread after it has claimed source and before it compiles it, so a test can hold a compile in flight deterministically.
std::function< void(const std::string &)> pulp::view::detail::precompile_claim_hook_for_tests ()
void pulp::view::detail::clear_embedded_script_bytecode_for_tests ()
 Tests only: forget every registered embedded bytecode blob.

Variables

constexpr std::size_t pulp::view::kDefaultJsMemoryLimitBytes = std::size_t{512} * 1024 * 1024