Skip to content

niso_js.h: the JS binding

Generated from bindings/js/niso_js.h when the site was built at 7aa23e2.

From bindings/js/niso_js.h, a header of its own outside niso_runtime.h.

Functions: niso_js_new, niso_js_free, niso_js_eval, niso_js_eval_string, niso_js_run, niso_js_run_until, niso_js_detached, niso_js_start_worker, niso_js_gc, niso_js_errors, niso_js_held

Running JS against a niso DOM. The DOM must outlive the niso_js.

typedef struct niso_js niso_js;
niso_js* niso_js_new(niso_dom* dom);
void niso_js_free(niso_js* js);

Runs a classic script. Returns 0, or nonzero after reporting an uncaught exception.

int niso_js_eval(niso_js* js, const char* src, size_t len, const char* name);

Like niso_js_eval, and on success stores the completion value as a string in *result, valid until the next niso_js_eval_string or niso_js_free.

int niso_js_eval_string(niso_js* js, const char* src, size_t len, const char* name, niso_str* result);

Runs microtasks, then the DOM’s tasks due within max_ms (niso_dom_run), skipping the clock ahead to each unless a connection is open. After every task the DOM runs, here or in the host’s calls, the binding runs microtasks and settles the fetches that finished and the media session’s actions, and the DOM collects between them.

void niso_js_run(niso_js* js, double max_ms);

niso_js_run up to until on the niso_dom_now clock, which may have passed: a host that runs a page in steps keeps each step to one deadline.

void niso_js_run_until(niso_js* js, double until);

Runs f(arg) with no niso_js current. The callbacks a DOM drops go to the niso_js current on the thread, so a host that frees a DOM after its niso_js while another page’s runs (a page freed from that page’s callback) frees it here.

void niso_js_detached(void (*f)(void*), void* arg);

In a worker’s DOM: runs the worker’s script, then lets its messages flow.

void niso_js_start_worker(niso_js* js);

Forces a full JS GC, runs the finalizers it queues, then collects the DOM.

void niso_js_gc(niso_js* js);

Uncaught exceptions reported so far.

size_t niso_js_errors(niso_js* js);

Handles currently held by wrappers.

size_t niso_js_held(niso_js* js);