pub struct ConstructorBuilder<'context> { /* private fields */ }Expand description
Builder for creating constructors objects, like Array.
Implementations§
Source§impl<'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 Self
pub fn property<K, V>( &mut self, key: K, value: V, attribute: Attribute, ) -> &mut Self
Add new data property to the constructor’s prototype.
Sourcepub fn static_property<K, V>(
&mut self,
key: K,
value: V,
attribute: Attribute,
) -> &mut Self
pub fn static_property<K, V>( &mut self, key: K, value: V, attribute: Attribute, ) -> &mut Self
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 Self
pub fn property_descriptor<K, P>(&mut self, key: K, property: P) -> &mut Self
Add new property to the constructor’s prototype.
Sourcepub fn static_property_descriptor<K, P>(
&mut self,
key: K,
property: P,
) -> &mut Self
pub fn static_property_descriptor<K, P>( &mut self, key: K, property: P, ) -> &mut Self
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 Self
pub fn name<N>(&mut self, name: N) -> &mut Self
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