Skip to content

Latest commit

 

History

History
366 lines (217 loc) · 11.3 KB

globals.md

File metadata and controls

366 lines (217 loc) · 11.3 KB

quickjs-emscriptenGlobals

quickjs-emscripten

Index

Classes

Interfaces

Type aliases

Functions

Type aliases

ExecutePendingJobsResult

Ƭ ExecutePendingJobsResult: SuccessOrFail‹number, QuickJSHandle

Defined in quickjs.ts:212

Used as an optional for the results of executing pendingJobs. On success, value contains the number of async jobs executed by the runtime. { value: number } | { error: QuickJSHandle }.


InterruptHandler

Ƭ InterruptHandler: function

Defined in quickjs.ts:63

Callback called regularly while the VM executes code. Determines if a VM's execution should be interrupted.

returns true to interrupt JS execution inside the VM.

returns false or undefined to continue JS execution inside the VM.

Type declaration:

▸ (vm: QuickJSVm): boolean | undefined

Parameters:

Name Type
vm QuickJSVm

JSCFunctionPointer

Ƭ JSCFunctionPointer: Pointer‹"JSCFunction"›

Defined in ffi.ts:49

Used internally for C-to-Javascript function calls.


JSContextPointer

Ƭ JSContextPointer: Pointer‹"JSContext"›

Defined in ffi.ts:22

JSContext*.


JSRuntimePointer

Ƭ JSRuntimePointer: Pointer‹"JSRuntime"›

Defined in ffi.ts:17

JSRuntime*.


JSValue

Ƭ JSValue: LifetimeJSValuePointer, JSValuePointer, QuickJSVm

Defined in quickjs.ts:949

A owned QuickJSHandle that should be disposed or returned.

The QuickJS interpreter passes Javascript values between functions as JSValue structs that references some internal data. Because passing structs cross the Empscripten FFI interfaces is bothersome, we use pointers to these structs instead.

A JSValue reference is "owned" in its scope. before exiting the scope, it should be freed, by calling JS_FreeValue(ctx, js_value)) or returned from the scope. We extend that contract - a JSValuePointer (JSValue*) must also be freed.

You can do so from Javascript by calling the .dispose() method.


JSValueConst

Ƭ JSValueConst: LifetimeJSValueConstPointer, JSValuePointer, QuickJSVm

Defined in quickjs.ts:932

A QuickJSHandle to a borrowed value that does not need to be disposed.

In QuickJS, a JSValueConst is a "borrowed" reference that isn't owned by the current scope. That means that the current scope should not JS_FreeValue it, or retain a reference to it after the scope exits, because it may be freed by its owner.

quickjs-emscripten takes care of disposing JSValueConst references.


JSValueConstPointer

Ƭ JSValueConstPointer: Pointer‹"JSValueConst"›

Defined in ffi.ts:34

`JSValueConst* See JSValueConst and StaticJSValue.


JSValueConstPointerPointer

Ƭ JSValueConstPointerPointer: Pointer‹"JSValueConst[]"›

Defined in ffi.ts:44

Used internally for Javascript-to-C function calls.


JSValuePointer

Ƭ JSValuePointer: Pointer‹"JSValue"›

Defined in ffi.ts:28

JSValue*. See JSValue.


JSValuePointerPointer

Ƭ JSValuePointerPointer: Pointer‹"JSValue[]"›

Defined in ffi.ts:39

Used internally for Javascript-to-C function calls.


Pointer

Ƭ Pointer: number & object

Defined in ffi.ts:12

C pointer to export type CType. Pointer types are used internally for FFI, but are not intended for external use.

unstable This export type is considered private and may change.


QTS_C_To_HostCallbackFuncPointer

Ƭ QTS_C_To_HostCallbackFuncPointer: Pointer‹"C_To_HostCallbackFunc"›

Defined in ffi.ts:54

Used internally for C-to-Javascript function calls.


QTS_C_To_HostInterruptFuncPointer

Ƭ QTS_C_To_HostInterruptFuncPointer: Pointer‹"C_To_HostInterruptFunc"›

Defined in ffi.ts:59

Used internally for C-to-Javascript interrupt handlers.


QuickJSHandle

Ƭ QuickJSHandle: StaticJSValue | JSValue | JSValueConst

Defined in quickjs.ts:958

Wraps a C pointer to a QuickJS JSValue, which represents a Javascript value inside a QuickJS virtual machine.

Values must not be shared between QuickJSVm instances. You must dispose of any handles you create by calling the .dispose() method.


QuickJSPropertyKey

Ƭ QuickJSPropertyKey: number | string | QuickJSHandle

Defined in quickjs.ts:65


StaticJSValue

Ƭ StaticJSValue: LifetimeJSValueConstPointer, JSValueConstPointer, QuickJSVm

Defined in quickjs.ts:920

A QuickJSHandle to a constant that will never change, and does not need to be disposed.


SuccessOrFail

Ƭ SuccessOrFail: object | object

Defined in vm-interface.ts:5

Used as an optional. { value: S } | { error: E }.


VmCallResult

Ƭ VmCallResult: SuccessOrFail‹VmHandle, VmHandle›

Defined in vm-interface.ts:18

Used as an optional for results of a Vm call. { value: VmHandle } | { error: VmHandle }.


VmFunctionImplementation

Ƭ VmFunctionImplementation: function

Defined in vm-interface.ts:32

A VmFunctionImplementation takes handles as arguments. It should return a handle, or be void.

To indicate an exception, a VMs can throw either a handle (transferred directly) or any other Javascript value (only the poperties name and message will be transferred). Or, the VmFunctionImplementation may return a VmCallResult's { error: handle } error variant.

VmFunctionImplementation should not free its arguments or its return value. It should not retain a reference to its return value or thrown error.

Type declaration:

▸ (this: VmHandle, ...args: VmHandle[]): VmHandle | VmCallResult‹VmHandle› | void

Parameters:

Name Type
this VmHandle
...args VmHandle[]

Functions

getQuickJS

getQuickJS(): Promise‹QuickJS

Defined in quickjs.ts:1164

This is the top-level entrypoint for the quickjs-emscripten library. Get the root QuickJS API.

Returns: Promise‹QuickJS


getQuickJSSync

getQuickJSSync(): QuickJS

Defined in quickjs.ts:1177

Provides synchronous access to the QuickJS API once getQuickJS has resolved at least once.

throws If called before getQuickJS resolves.

Returns: QuickJS


shouldInterruptAfterDeadline

shouldInterruptAfterDeadline(deadline: Date | number): InterruptHandler

Defined in quickjs.ts:1150

Returns an interrupt handler that interrupts Javascript execution after a deadline time.

Parameters:

Name Type Description
deadline Date | number Interrupt execution if it's still running after this time. Number values are compared against Date.now()

Returns: InterruptHandler