Struct chakracore::value::External
[−]
[src]
pub struct External(_);
A JavaScript external object.
Methods
impl External
[src]
fn new<T>(_guard: &ContextGuard, external: Box<T>) -> Self
Creates a new object with external data.
The object takes ownership of the resource. It is undetermined when, and even if, the destructor is called. It relies on the engine's finalize callback.
As long as the object is referenced on the stack or in any script
context, the external
data will be kept alive (i.e it is not tied to
the handle).
unsafe fn from_ptr<T>(_guard: &ContextGuard, external: *mut T) -> Self
Creates a new object with external data.
This is unsafe because the object does not take ownership of the resource. Therefore the data may become a dangling pointer. The caller is responsible for keeping the reference alive.
unsafe fn value<T>(&self) -> &mut T
Returns the external object's data.
fn is_same(value: &Value) -> bool
Returns true if the value is an External
.
impl External
[src]
unsafe fn from_raw(value: JsRef) -> External
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 = 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).
Trait Implementations
impl Clone for External
[src]
fn clone(&self) -> External
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 External
[src]
fn drop(&mut self)
Decrements the reference counter if the object is recyclable.