[−]Struct qjs::ContextRef
A borrowed reference to a Context
.
Methods
impl ContextRef
[src]
pub fn new_array_buffer<T: AsMut<[u8]>>(&self, buf: &mut T) -> ArrayBuffer
[src]
Creates a new ArrayBuffer
of the given bytes.
pub fn new_shared_array_buffer<T: Into<Vec<u8>>>(
&self,
buf: T
) -> SharedArrayBuffer
[src]
&self,
buf: T
) -> SharedArrayBuffer
Creates a new SharedArrayBuffer
of the given bytes.
pub fn new_array_buffer_copy(&self, buf: &mut [u8]) -> ArrayBuffer
[src]
Creates a new ArrayBuffer
which copy the given bytes.
impl ContextRef
[src]
pub fn new_atom<T: NewAtom>(&self, v: T) -> Local<JSAtom>
[src]
Create or find an Atom
in the context.
pub fn bind_atom(&self, atom: JSAtom) -> Local<JSAtom>
[src]
pub fn new_atom_string<T: Into<Vec<u8>>>(&self, s: T) -> Local<Value>
[src]
Create or find an Atom
base on string.
pub fn free_atom(&self, atom: JSAtom)
[src]
Free an Atom
reference.
pub fn clone_atom(&self, atom: JSAtom) -> Local<JSAtom>
[src]
Clone an Atom
in the context.
pub fn atom_to_value(&self, atom: JSAtom) -> Local<Value>
[src]
Convert an Atom
to a Javascript Value
.
pub fn atom_to_string(&self, atom: JSAtom) -> Local<Value>
[src]
Convert an Atom
to a Javascript String
.
pub fn atom_to_cstring(&self, atom: JSAtom) -> CString
[src]
Convert an Atom
to a CString
.
impl ContextRef
[src]
pub fn new_c_function<T: NewValue>(
&self,
func: CFunction<T>,
name: Option<&str>,
length: usize
) -> Result<Local<Value>, Error>
[src]
&self,
func: CFunction<T>,
name: Option<&str>,
length: usize
) -> Result<Local<Value>, Error>
Create a new C function.
pub fn new_c_function_magic(
&self,
func: UnsafeCFunctionMagic,
name: Option<&str>,
length: usize,
cproto: CFunc,
magic: i32
) -> Result<Local<Value>, Error>
[src]
&self,
func: UnsafeCFunctionMagic,
name: Option<&str>,
length: usize,
cproto: CFunc,
magic: i32
) -> Result<Local<Value>, Error>
Create a new C function with magic.
pub fn new_c_function2(
&self,
func: UnsafeCFunction,
name: Option<&str>,
length: usize,
cproto: CFunc,
magic: i32
) -> Result<Local<Value>, Error>
[src]
&self,
func: UnsafeCFunction,
name: Option<&str>,
length: usize,
cproto: CFunc,
magic: i32
) -> Result<Local<Value>, Error>
Create a new C function with prototype and magic.
pub fn new_c_function_data<T: Args>(
&self,
func: UnsafeCFunctionData,
length: usize,
magic: i32,
data: T
) -> Result<Local<Value>, Error>
[src]
&self,
func: UnsafeCFunctionData,
length: usize,
magic: i32,
data: T
) -> Result<Local<Value>, Error>
Create a new C function with magic and data.
impl ContextRef
[src]
pub fn set_class_proto<T: Into<JSValue>>(&self, class_id: ClassId, obj: T)
[src]
Define a prototype for a given class in a given JSContext.
pub fn get_class_proto(&self, class_id: ClassId) -> Local<Value>
[src]
Get the prototype for a given class in a given JSContext.
impl ContextRef
[src]
pub fn runtime(&self) -> &RuntimeRef
[src]
pub fn userdata<T>(&self) -> Option<NonNull<T>>
[src]
pub fn set_userdata<T>(&self, userdata: Option<NonNull<T>>) -> &Self
[src]
pub fn set_max_stack_size(&self, stack_size: usize) -> &Self
[src]
Set the maximum system stack size.
pub fn global_object(&self) -> Local<Value>
[src]
impl ContextRef
[src]
pub fn is_error(&self, val: &Value) -> bool
[src]
pub fn throw<T: NewValue>(&self, exc: T) -> Local<Value>
[src]
pub fn get_exception(&self) -> Option<Local<Value>>
[src]
pub fn enable_is_error_property(&self, enable: bool)
[src]
pub fn reset_uncatchable_error(&self)
[src]
pub fn new_error(&self) -> Local<Value>
[src]
pub fn throw_error<T: ToString>(
&self,
msg: T,
stack: Option<String>
) -> Local<Value>
[src]
&self,
msg: T,
stack: Option<String>
) -> Local<Value>
pub fn throw_out_of_memory(&self) -> Local<Value>
[src]
pub fn throw_custom_error<T: ToString>(
&self,
name: &str,
msg: T,
stack: Option<String>
) -> Local<Value>
[src]
&self,
name: &str,
msg: T,
stack: Option<String>
) -> Local<Value>
pub fn throw_syntax_error<T: Into<Vec<u8>>>(&self, msg: T) -> Local<Value>
[src]
pub fn throw_type_error<T: Into<Vec<u8>>>(&self, msg: T) -> Local<Value>
[src]
pub fn throw_reference_error<T: Into<Vec<u8>>>(&self, msg: T) -> Local<Value>
[src]
pub fn throw_range_error<T: Into<Vec<u8>>>(&self, msg: T) -> Local<Value>
[src]
pub fn throw_internal_error<T: Into<Vec<u8>>>(&self, msg: T) -> Local<Value>
[src]
pub fn check_error(&self, ret: i32) -> Result<i32, Error>
[src]
pub fn check_null<T>(&self, ptr: *mut T) -> Result<NonNull<T>, Error>
[src]
pub fn check_bool(&self, ret: i32) -> Result<bool, Error>
[src]
impl ContextRef
[src]
pub fn eval<T: Source, V: ExtractValue>(
&self,
source: T,
flags: T::Flags
) -> Result<Option<V>, Error>
[src]
&self,
source: T,
flags: T::Flags
) -> Result<Option<V>, Error>
Evaluate a script or module source.
pub fn eval_script<T: Into<Vec<u8>>>(
&self,
input: T,
filename: &str,
flags: Eval
) -> Result<Local<Value>, Error>
[src]
&self,
input: T,
filename: &str,
flags: Eval
) -> Result<Local<Value>, Error>
Evaluate a script or module source.
pub fn eval_file<P: AsRef<Path>>(
&self,
path: P,
flags: Eval
) -> Result<Local<Value>, Error>
[src]
&self,
path: P,
flags: Eval
) -> Result<Local<Value>, Error>
Evaluate a script or module source in file.
pub fn eval_binary(
&self,
buf: &[u8],
flags: EvalBinary
) -> Result<Local<Value>, Error>
[src]
&self,
buf: &[u8],
flags: EvalBinary
) -> Result<Local<Value>, Error>
Evaluate a script or module source in bytecode.
pub fn parse_json<T: Into<Vec<u8>>>(
&self,
input: T,
filename: &str
) -> Result<Local<Value>, Error>
[src]
&self,
input: T,
filename: &str
) -> Result<Local<Value>, Error>
Parse JSON expression.
impl ContextRef
[src]
pub fn is_function(&self, val: &Value) -> bool
[src]
pub fn is_constructor(&self, val: &Value) -> bool
[src]
pub fn call<T: Args>(
&self,
func: &Value,
this: Option<&Value>,
args: T
) -> Result<Local<Value>, Error>
[src]
&self,
func: &Value,
this: Option<&Value>,
args: T
) -> Result<Local<Value>, Error>
pub fn invoke<N: NewAtom, T: Args>(
&self,
this: &Value,
atom: N,
args: T
) -> Result<Local<Value>, Error>
[src]
&self,
this: &Value,
atom: N,
args: T
) -> Result<Local<Value>, Error>
pub fn call_constructor<T: Args>(
&self,
func: &Value,
args: T
) -> Result<Local<Value>, Error>
[src]
&self,
func: &Value,
args: T
) -> Result<Local<Value>, Error>
pub fn call_constructor2<T: Args>(
&self,
func: &Value,
new_target: Option<&Value>,
args: T
) -> Result<Local<Value>, Error>
[src]
&self,
func: &Value,
new_target: Option<&Value>,
args: T
) -> Result<Local<Value>, Error>
impl ContextRef
[src]
impl ContextRef
[src]
impl ContextRef
[src]
pub fn new_c_module<T: Into<Vec<u8>>>(
&self,
name: T,
init: ModuleInitFunc
) -> Result<NonNull<JSModuleDef>, Error>
[src]
&self,
name: T,
init: ModuleInitFunc
) -> Result<NonNull<JSModuleDef>, Error>
Create a new C module.
pub fn detect_module<T: Into<Vec<u8>>>(&self, input: T) -> bool
[src]
return true if input
contains the source of a module (heuristic).
Heuristic: skip comments and expect 'import' keyword not followed by '(' or '.'
impl ContextRef
[src]
pub fn write_object(
&self,
obj: &Value,
flags: WriteObj
) -> Result<Vec<u8>, Error>
[src]
&self,
obj: &Value,
flags: WriteObj
) -> Result<Vec<u8>, Error>
Write the script or module to bytecode
pub fn read_object(
&self,
buf: &[u8],
flags: ReadObj
) -> Result<Local<Value>, Error>
[src]
&self,
buf: &[u8],
flags: ReadObj
) -> Result<Local<Value>, Error>
Read the script or module from bytecode
pub fn eval_function<T: Into<JSValue>>(
&self,
func: T,
this: &Value
) -> Result<Local<Value>, Error>
[src]
&self,
func: T,
this: &Value
) -> Result<Local<Value>, Error>
Evaluate a script or module source in bytecode.
impl ContextRef
[src]
pub fn get_own_property_names(
&self,
value: &Value,
flags: Names
) -> Result<Option<Vec<Atom>>, Error>
[src]
&self,
value: &Value,
flags: Names
) -> Result<Option<Vec<Atom>>, Error>
Returns an array of all properties (including non-enumerable properties except for those which use Symbol) found directly in a given object.
pub fn get_own_property_descriptor<T: NewAtom>(
&self,
value: &Value,
prop: T
) -> Result<Option<Descriptor>, Error>
[src]
&self,
value: &Value,
prop: T
) -> Result<Option<Descriptor>, Error>
Returns a property descriptor for an own property (that is, one directly present on an object and not in the object's prototype chain) of a given object.
pub fn get_property<T: GetProperty>(
&self,
this: &Value,
prop: T
) -> Option<Local<Value>>
[src]
&self,
this: &Value,
prop: T
) -> Option<Local<Value>>
Get a property value on an object.
pub fn set_property<T: SetProperty, V: NewValue>(
&self,
this: &Value,
prop: T,
val: V
) -> Result<bool, Error>
[src]
&self,
this: &Value,
prop: T,
val: V
) -> Result<bool, Error>
Set a property value on an object.
pub fn has_property<T: HasProperty>(
&self,
this: &Value,
prop: T
) -> Result<bool, Error>
[src]
&self,
this: &Value,
prop: T
) -> Result<bool, Error>
Check if a property on an object.
pub fn delete_property<T: DeleteProperty>(
&self,
this: &Value,
prop: T
) -> Result<bool, Error>
[src]
&self,
this: &Value,
prop: T
) -> Result<bool, Error>
Delete a property on an object.
It returns a bool
indicating whether or not the property was successfully deleted.
pub fn define_property<T: DefineProperty>(
&self,
this: &Value,
prop: T,
val: Option<Value>,
getter: Option<&Value>,
setter: Option<&Value>,
flags: Prop
) -> Result<bool, Error>
[src]
&self,
this: &Value,
prop: T,
val: Option<Value>,
getter: Option<&Value>,
setter: Option<&Value>,
flags: Prop
) -> Result<bool, Error>
Defines a new property directly on an object, or modifies an existing property on an object.
pub fn define_property_value<T: DefinePropertyValue, V: NewValue>(
&self,
this: &Value,
prop: T,
val: V,
flags: Prop
) -> Result<bool, Error>
[src]
&self,
this: &Value,
prop: T,
val: V,
flags: Prop
) -> Result<bool, Error>
Defines a new property with value directly on an object, or modifies an existing property on an object.
pub fn define_property_get_set<T: DefinePropertyGetSet>(
&self,
this: &Value,
prop: T,
getter: Option<&Value>,
setter: Option<&Value>,
flags: Prop
) -> Result<bool, Error>
[src]
&self,
this: &Value,
prop: T,
getter: Option<&Value>,
setter: Option<&Value>,
flags: Prop
) -> Result<bool, Error>
Defines a new property with getter and setter directly on an object, or modifies an existing property on an object.
pub fn is_extensible(&self, obj: &Value) -> Result<bool, Error>
[src]
Check if an object is extensible (whether it can have new properties added to it).
pub fn prevent_extensions(&self, obj: &Value) -> Result<bool, Error>
[src]
Prevents new properties from ever being added to an object (i.e. prevents future extensions to the object).
impl ContextRef
[src]
pub fn init_module_std(&self) -> Result<NonNull<ModuleDef>, Error>
[src]
pub fn init_module_os(&self) -> Result<NonNull<ModuleDef>, Error>
[src]
pub fn std_add_helpers<I: IntoIterator<Item = S>, S: Into<Vec<u8>>>(
&self,
args: I
) -> Result<(), Error>
[src]
&self,
args: I
) -> Result<(), Error>
pub fn std_loop(&self)
[src]
pub fn std_dump_error(&self)
[src]
pub fn std_eval_binary(&self, buf: &[u8], flags: EvalBinary)
[src]
impl ContextRef
[src]
pub fn new_userdata<T>(&self, v: T) -> Local<Value>
[src]
pub fn get_userdata_unchecked<T>(&self, obj: &Value) -> NonNull<T>
[src]
impl ContextRef
[src]
pub fn get_opaque<T>(&self, obj: &Value, class_id: ClassId) -> *mut T
[src]
impl ContextRef
[src]
pub fn clone_value(&self, v: &Value) -> Local<Value>
[src]
pub fn free_value<T: Into<Value>>(&self, v: T)
[src]
pub fn nan(&self) -> Local<Value>
[src]
pub fn null(&self) -> Local<Value>
[src]
pub fn undefined(&self) -> Local<Value>
[src]
pub fn false_value(&self) -> Local<Value>
[src]
pub fn true_value(&self) -> Local<Value>
[src]
pub fn exception(&self) -> Local<Value>
[src]
pub fn uninitialized(&self) -> Local<Value>
[src]
pub fn new_value<T: NewValue>(&self, s: T) -> Value
[src]
pub fn new_object_proto_class(&self, proto: &Value, class_id: ClassId) -> Value
[src]
pub fn new_object_class(&self, class_id: ClassId) -> Value
[src]
pub fn new_object_proto(&self, proto: &Value) -> Value
[src]
pub fn new_object(&self) -> Value
[src]
pub fn new_array(&self) -> Value
[src]
pub fn new_catch_offset(&self, off: i32) -> Value
[src]
pub fn new_bigint64(&self, n: i64) -> Value
[src]
pub fn new_biguint64(&self, n: u64) -> Value
[src]
pub fn to_bool(&self, val: &Value) -> Option<bool>
[src]
pub fn to_int32(&self, val: &Value) -> Option<i32>
[src]
pub fn to_int64(&self, val: &Value) -> Option<i64>
[src]
pub fn to_index(&self, val: &Value) -> Option<u64>
[src]
pub fn to_float64(&self, val: &Value) -> Option<f64>
[src]
pub fn to_bigint64(&self, val: &Value) -> Option<i64>
[src]
pub fn to_str(&self, val: &Value) -> Value
[src]
pub fn to_property_key(&self, val: &Value) -> Value
[src]
pub fn to_cstring(&self, val: &Value) -> Option<CString>
[src]
Convert Javascript String to C UTF-8 encoded strings.
pub fn is_instance_of(&self, val: &Value, obj: &Value) -> Result<bool, Error>
[src]
Trait Implementations
impl Send for ContextRef
impl AsMut<ContextRef> for Context
fn as_mut(&mut self) -> &mut ContextRef
impl PartialEq<ContextRef> for Context
[src]
fn eq(&self, other: &ContextRef) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialEq<ContextRef> for ContextRef
[src]
fn eq(&self, other: &ContextRef) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialEq<Context> for ContextRef
[src]
fn eq(&self, other: &Context) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl AsRef<ContextRef> for Context
fn as_ref(&self) -> &ContextRef
impl Debug for ContextRef
[src]
impl Borrow<ContextRef> for Context
fn borrow(&self) -> &ContextRef
impl BorrowMut<ContextRef> for Context
fn borrow_mut(&mut self) -> &mut ContextRef
impl ForeignTypeRef for ContextRef
type CType = JSContext
The raw C type.
unsafe fn from_ptr<'a>(ptr: *mut Self::CType) -> &'a Self
[src]
Constructs a shared instance of this type from its raw type.
unsafe fn from_ptr_mut<'a>(ptr: *mut Self::CType) -> &'a mut Self
[src]
Constructs a mutable reference of this type from its raw type.
fn as_ptr(&self) -> *mut Self::CType
[src]
Returns a raw pointer to the wrapped value.
Auto Trait Implementations
impl Unpin for ContextRef
impl !Sync for ContextRef
impl UnwindSafe for ContextRef
impl !RefUnwindSafe for ContextRef
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,