Struct boa::object::ConstructorBuilder
source · [−]pub struct ConstructorBuilder<'context> { /* private fields */ }
Expand description
Builder for creating constructors objects, like Array
.
Implementations
sourceimpl<'context> ConstructorBuilder<'context>
impl<'context> ConstructorBuilder<'context>
sourcepub fn new(context: &'context mut Context, constructor: NativeFunction) -> Self
pub fn new(context: &'context mut Context, constructor: NativeFunction) -> Self
Create a new ConstructorBuilder
.
sourcepub fn method<B>(
&mut self,
function: NativeFunction,
binding: B,
length: usize
) -> &mut Selfwhere
B: Into<FunctionBinding>,
pub fn method<B>(
&mut self,
function: NativeFunction,
binding: B,
length: usize
) -> &mut Selfwhere
B: Into<FunctionBinding>,
Add new method to the constructors prototype.
sourcepub fn static_method<B>(
&mut self,
function: NativeFunction,
binding: B,
length: usize
) -> &mut Selfwhere
B: Into<FunctionBinding>,
pub fn static_method<B>(
&mut self,
function: NativeFunction,
binding: B,
length: usize
) -> &mut Selfwhere
B: Into<FunctionBinding>,
Add new static method to the constructors object itself.
sourcepub fn property<K, V>(
&mut self,
key: K,
value: V,
attribute: Attribute
) -> &mut Selfwhere
K: Into<PropertyKey>,
V: Into<JsValue>,
pub fn property<K, V>(
&mut self,
key: K,
value: V,
attribute: Attribute
) -> &mut Selfwhere
K: Into<PropertyKey>,
V: Into<JsValue>,
Add new data property to the constructor’s prototype.
sourcepub fn static_property<K, V>(
&mut self,
key: K,
value: V,
attribute: Attribute
) -> &mut Selfwhere
K: Into<PropertyKey>,
V: Into<JsValue>,
pub fn static_property<K, V>(
&mut self,
key: K,
value: V,
attribute: Attribute
) -> &mut Selfwhere
K: Into<PropertyKey>,
V: Into<JsValue>,
Add new static data property to the constructor object itself.
sourcepub fn accessor<K>(
&mut self,
key: K,
get: Option<JsObject>,
set: Option<JsObject>,
attribute: Attribute
) -> &mut Selfwhere
K: Into<PropertyKey>,
pub fn accessor<K>(
&mut self,
key: K,
get: Option<JsObject>,
set: Option<JsObject>,
attribute: Attribute
) -> &mut Selfwhere
K: Into<PropertyKey>,
Add new accessor property to the constructor’s prototype.
sourcepub fn static_accessor<K>(
&mut self,
key: K,
get: Option<JsObject>,
set: Option<JsObject>,
attribute: Attribute
) -> &mut Selfwhere
K: Into<PropertyKey>,
pub fn static_accessor<K>(
&mut self,
key: K,
get: Option<JsObject>,
set: Option<JsObject>,
attribute: Attribute
) -> &mut Selfwhere
K: Into<PropertyKey>,
Add new static accessor property to the constructor object itself.
sourcepub fn property_descriptor<K, P>(&mut self, key: K, property: P) -> &mut Selfwhere
K: Into<PropertyKey>,
P: Into<PropertyDescriptor>,
pub fn property_descriptor<K, P>(&mut self, key: K, property: P) -> &mut Selfwhere
K: Into<PropertyKey>,
P: Into<PropertyDescriptor>,
Add new property to the constructor’s prototype.
sourcepub fn static_property_descriptor<K, P>(
&mut self,
key: K,
property: P
) -> &mut Selfwhere
K: Into<PropertyKey>,
P: Into<PropertyDescriptor>,
pub fn static_property_descriptor<K, P>(
&mut self,
key: K,
property: P
) -> &mut Selfwhere
K: Into<PropertyKey>,
P: Into<PropertyDescriptor>,
Add new static property to the constructor object itself.
sourcepub fn length(&mut self, length: usize) -> &mut Self
pub fn length(&mut self, length: usize) -> &mut Self
Specify how many arguments the constructor function takes.
Default is 0
.
sourcepub fn name<N>(&mut self, name: N) -> &mut Selfwhere
N: AsRef<str>,
pub fn name<N>(&mut self, name: N) -> &mut Selfwhere
N: AsRef<str>,
Specify the name of the constructor function.
Default is "[object]"
sourcepub fn callable(&mut self, callable: bool) -> &mut Self
pub fn callable(&mut self, callable: bool) -> &mut Self
Specify whether the constructor function can be called.
Default is true
sourcepub fn constructable(&mut self, constructable: bool) -> &mut Self
pub fn constructable(&mut self, constructable: bool) -> &mut Self
Specify whether the constructor function can be called with new
keyword.
Default is true