Runtime Management
js_create
buf- Pre-allocated memory bufferlen- Size of the buffer in bytes
NULL on failure
js_create_dynamic
NULL on failure
js_destroy
js- Runtime instance
js_setstackbase
js- Runtime instancebase- Pointer to stack base (typically a local variable address)
js_setstacklimit
js- Runtime instancelimit- Maximum stack size in bytes
Evaluation Functions
js_eval_bytecode
js- Runtime instancecode- JavaScript source codelen- Length of code string
js_eval_bytecode_eval
js- Runtime instancecode- JavaScript source codelen- Length of code string
js_eval_bytecode_module
js- Runtime instancecode- JavaScript source codelen- Length of code string
js_eval_bytecode_repl
js- Runtime instancecode- JavaScript source codelen- Length of code string
Value Creation
js_mknum
value- Numeric value
js_mkstr
js- Runtime instancedata- String datalen- String length
js_mkundef
js_mknull
js_mkobj
js- Runtime instance
js_mkarr
js- Runtime instance
js_mkfun
fn- C function pointer with signature(ant_t *js, jsval_t *args, int nargs)
js_mkbigint
js- Runtime instancedigits- String of decimal digitslen- Length of digits stringnegative- Whether the value is negative
js_mksym
js- Runtime instancedesc- Symbol description
Value Inspection
vtype
val- JavaScript value
js_getnum
val- JavaScript number value
js_getstr
js- Runtime instanceval- JavaScript string valuelen- Output parameter for string length
js_str
js- Runtime instanceval- JavaScript value
js_truthy
js- Runtime instanceval- JavaScript value
true if truthy, false otherwise
Object Operations
js_glob
js- Runtime instance
js_set
js- Runtime instanceobj- Object valuekey- Property name (C string)val- Property value
js_get
js- Runtime instanceobj- Object valuekey- Property name (C string)
js_del
js- Runtime instanceobj- Object valuekey- Property name
true if deleted, false otherwise
js_set_proto
js- Runtime instanceobj- Object valueproto- Prototype object
js_get_proto
js- Runtime instanceobj- Object value
Array Operations
js_arr_len
js- Runtime instancearr- Array value
js_arr_get
js- Runtime instancearr- Array valueidx- Array index
js_arr_push
js- Runtime instancearr- Array valueval- Value to push
Property Iteration
js_prop_iter_begin
js- Runtime instanceobj- Object value
js_prop_iter_next
iter- Iterator handlekey- Output parameter for property namekey_len- Output parameter for name lengthvalue- Output parameter for property value
true if more properties exist, false when done
js_prop_iter_end
iter- Iterator handle
Context Functions
js_getthis
this value.
Parameters:
js- Runtime instance
this value
js_setthis
this value.
Parameters:
js- Runtime instanceval- Newthisvalue
js_getcurrentfunc
js- Runtime instance
Root Management
js_root
js- Runtime instanceval- Value to root
js_unroot
js- Runtime instancehandle- Root handle
js_deref
js- Runtime instancehandle- Root handle
Utility Functions
js_chkargs
args- Argument arraynargs- Number of argumentstypes- Type specification string (e.g., “dd” for two numbers, “ds” for number and string)
true if arguments match, false otherwise
Type codes:
d- Numbers- Stringb- Booleano- Objectf- Function
js_set_filename
js- Runtime instancefilename- Filename string