Skip to main content

box_value

Function box_value 

Source
pub fn box_value(value: Value) -> JsValue
Expand description

Box value so that JS_VALUE_GET_PTR on the answer can be --’d from C.

The box owns one strong reference to the engine value, so the engine keeps the payload alive exactly as long as the C side holds a JSValue, and not one moment longer: the reference implementation’s determinism comes from precisely this.

The tag is chosen by what the value is, because C’s JS_IsString reads the tag: strings answer JS_TAG_STRING, everything else JS_TAG_OBJECT. Both are negative, so both carry a reference count.