Struct js::jsapi::Value
[−]
[src]
#[repr(C)]pub struct Value { pub data: jsval_layout, }
JS::Value is the interface for a single JavaScript Engine value. A few general notes on JS::Value:
JS::Value has setX() and isX() members for X in
{ Int32, Double, String, Symbol, Boolean, Undefined, Null, Object, Magic }
JS::Value also contains toX() for each of the non-singleton types.
Magic is a singleton type whose payload contains either a JSWhyMagic "reason" for the magic value or a uint32_t value. By providing JSWhyMagic values when creating and checking for magic values, it is possible to assert, at runtime, that only magic values with the expected reason flow through a particular value. For example, if cx->exception has a magic value, the reason must be JS_GENERATOR_CLOSING.
The JS::Value operations are preferred. The JSVAL_* operations remain for compatibility; they may be removed at some point. These operations mostly provide similar functionality. But there are a few key differences. One is that JS::Value gives null a separate type. Also, to help prevent mistakenly boxing a nullable JSObject* as an object, Value::setObject takes a JSObject&. (Conversely, Value::toObject returns a JSObject&.) A convenience member Value::setObjectOrNull is provided.
JSVAL_VOID is the same as the singleton value of the Undefined type.
Note that JS::Value is 8 bytes on 32 and 64-bit architectures. Thus, on 32-bit user code should avoid copying jsval/JS::Value as much as possible, preferring to pass by const Value&.
Fields
data: jsval_layout
Trait Implementations
impl Debug for Value
[src]
impl Copy for Value
[src]
impl Clone for Value
[src]
fn clone(&self) -> Self
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more