Struct chakracore::value::Object
[−]
[src]
pub struct Object(_);
A JavaScript object.
Methods
impl Object
[src]
fn new(_guard: &ContextGuard) -> Self
Creates a new empty object.
fn set(&self, _guard: &ContextGuard, key: &Property, value: &Value)
Sets an object's property's value.
fn set_index(&self, guard: &ContextGuard, index: u32, value: &Value)
Sets an object's index value.
fn get(&self, _guard: &ContextGuard, key: &Property) -> Value
Returns an object's property's value.
fn get_index(&self, guard: &ContextGuard, index: u32) -> Value
Returns an object's index value.
fn delete(&self, _guard: &ContextGuard, key: &Property) -> bool
Deletes an object's property.
fn delete_index(&self, guard: &ContextGuard, index: u32)
Deletes an object's index.
fn has(&self, _guard: &ContextGuard, key: &Property) -> bool
Determines whether an object has a property.
fn has_index(&self, guard: &ContextGuard, index: u32) -> bool
Determines whether an object has a value at the specified index.
fn define_property(
&self,
_guard: &ContextGuard,
key: &Property,
desc: &Object
) -> bool
&self,
_guard: &ContextGuard,
key: &Property,
desc: &Object
) -> bool
Defines or modifies a property directly on an object.
This is equivalent to Object.defineProperty()
.
fn set_prototype(&self, _guard: &ContextGuard, prototype: &Value) -> Result<()>
Sets the object's prototype. This will result in an error if it's called on the context's global object.
fn get_prototype(&self, _guard: &ContextGuard) -> Value
Returns the object's prototype.
fn get_own_property_names(&self, _guard: &ContextGuard) -> Array
Returns the object's property names
fn prevent_extension(&self)
Makes an object non-extensible.
fn is_extensible(&self) -> bool
Returns whether the object is extensible or not.
unsafe fn set_collect_callback(&self, callback: Box<Fn(&Value)>)
Sets a callback that is executed before the object is collected.
This is highly unsafe to use. There is no bookkeeping whether any other
caller replaces the current callback or not. It is also used internally
by Function
to cleanup user data (if it's replaced, memory will leak).
fn is_same(value: &Value) -> bool
Returns true if the value is an Object
.
impl Object
[src]
unsafe fn from_raw(value: JsRef) -> Object
Creates an instance from a raw pointer.
This is used for managing the lifetime of JSRT objects. They are
tracked using reference counting; incrementing with from_raw
,
and decrementing with drop
.
This is required to support items stored on the heap, since the JSRT runtime only observes the stack.
If used in conjunction with a Property
or any Value
, it is
assumed a Context
is active.
fn as_raw(&self) -> JsRef
Returns the underlying raw pointer.
Methods from Deref<Target = Value>
fn is_undefined(&self) -> bool
Returns true if this value is undefined
.
fn is_null(&self) -> bool
Returns true if this value is null
.
fn is_number(&self) -> bool
Returns true if this value is a Number
.
fn into_number(self) -> Option<Number>
Represent the value as a Number
. Does not affect the underlying value.
fn is_string(&self) -> bool
Returns true if this value is a String
.
fn into_string(self) -> Option<String>
Represent the value as a String
. Does not affect the underlying value.
fn is_boolean(&self) -> bool
Returns true if this value is a Boolean
.
fn into_boolean(self) -> Option<Boolean>
Represent the value as a Boolean
. Does not affect the underlying value.
fn is_object(&self) -> bool
Returns true if this value is an Object
.
fn into_object(self) -> Option<Object>
Represent the value as an Object
. Does not affect the underlying value.
fn is_external(&self) -> bool
Returns true if this value is an External
.
fn into_external(self) -> Option<External>
Represent the value as an External
. Does not affect the underlying value.
fn is_function(&self) -> bool
Returns true if this value is a Function
.
fn into_function(self) -> Option<Function>
Represent the value as a Function
. Does not affect the underlying value.
fn is_array(&self) -> bool
Returns true if this value is an Array
.
fn into_array(self) -> Option<Array>
Represent the value as an Array
. Does not affect the underlying value.
fn is_array_buffer(&self) -> bool
Returns true if this value is an ArrayBuffer
.
fn into_array_buffer(self) -> Option<ArrayBuffer>
Represent the value as an ArrayBuffer
. Does not affect the underlying value.
fn is_promise(&self) -> bool
Returns true if this value is a Promise
.
fn into_promise(self) -> Option<Promise>
Represent the value as a Promise
. Does not affect the underlying value.
fn to_string(&self, _guard: &ContextGuard) -> String
Converts the value to a native string, containing the value's string representation.
fn to_integer(&self, _guard: &ContextGuard) -> i32
Converts the value to a native integer, containing the value's integer representation.
fn to_double(&self, _guard: &ContextGuard) -> f64
Converts the value to a native double, containing the value's floating point representation.
fn to_bool(&self, _guard: &ContextGuard) -> bool
Converts the value to a native boolean, containing the value's bool representation.
fn to_json(&self, guard: &ContextGuard) -> Result<String>
Converts the value to a native string, containing the value's JSON representation.
fn boolean_representation(&self, _guard: &ContextGuard) -> Boolean
Creates a new boolean with this value represented as Boolean
.
fn number_representation(&self, _guard: &ContextGuard) -> Number
Creates a new number with this value represented as Number
.
fn object_representation(&self, _guard: &ContextGuard) -> Object
Creates a new object with this value represented as Object
.
fn string_representation(&self, _guard: &ContextGuard) -> String
Creates a new string with this value represented as String
.
fn get_type(&self) -> JsValueType
Returns the type of the value. This method should be used with
consideration. It does not keep track of custom types, such as
External
. It only returns the runtime's definition of a type.
fn equals(&self, _guard: &ContextGuard, that: &Value) -> bool
Compare two values for equality (==
).
fn strict_equals(&self, _guard: &ContextGuard, that: &Value) -> bool
Compare two values for strict equality (===
).
Trait Implementations
impl From<Function> for Object
[src]
impl From<Promise> for Object
[src]
impl Clone for Object
[src]
fn clone(&self) -> Object
Duplicates a reference counted type.
The underlying pointer will be copied, and its reference count will be incremented, returned wrapped as the type.
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Drop for Object
[src]
fn drop(&mut self)
Decrements the reference counter if the object is recyclable.
impl Deref for Object
[src]
type Target = Value
The resulting type after dereferencing
fn deref(&self) -> &Self::Target
The method called to dereference a value
impl From<Array> for Object
[src]
impl From<ArrayBuffer> for Object
[src]
fn from(child: ArrayBuffer) -> Object
Performs the conversion.