Struct chakracore::value::function::Function
[−]
[src]
pub struct Function(_);
A JavaScript function object.
Methods
impl Function
[src]
fn new(_guard: &ContextGuard, callback: Box<FunctionCallback>) -> Self
Creates an anonymous function
fn with_name(
guard: &ContextGuard,
name: &str,
callback: Box<FunctionCallback>
) -> Self
guard: &ContextGuard,
name: &str,
callback: Box<FunctionCallback>
) -> Self
Creates a named function
fn instance_of(&self, _guard: &ContextGuard, object: &Object) -> bool
Returns whether the object is an instance of this Function
or not.
fn call(&self, guard: &ContextGuard, arguments: &[&Value]) -> Result<Value>
Calls a function and returns the result. The context (i.e this
) will
be the global object associated with the ContextGuard
.
fn call_with_this(
&self,
_guard: &ContextGuard,
this: &Value,
arguments: &[&Value]
) -> Result<Value>
&self,
_guard: &ContextGuard,
this: &Value,
arguments: &[&Value]
) -> Result<Value>
Calls a function, with a context, and returns the result.
fn construct(
&self,
_guard: &ContextGuard,
this: &Value,
args: &[&Value]
) -> Result<Value>
&self,
_guard: &ContextGuard,
this: &Value,
args: &[&Value]
) -> Result<Value>
Calls a function as a constructor and returns the result.
fn is_same(value: &Value) -> bool
Returns true if the value is a Function
.
impl Function
[src]
unsafe fn from_raw(value: JsRef) -> Function
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 Function
[src]
fn clone(&self) -> Function
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 Function
[src]
fn drop(&mut self)
Decrements the reference counter if the object is recyclable.