pub struct ClassBuilder<'context> { /* private fields */ }
Expand description
Class builder which allows adding methods and static methods to the class.
Implementations§
Source§impl<'context> ClassBuilder<'context>
impl<'context> ClassBuilder<'context>
Sourcepub fn method<N>(
&mut self,
name: N,
length: usize,
function: NativeFunction,
) -> &mut Self
pub fn method<N>( &mut self, name: N, length: usize, function: NativeFunction, ) -> &mut Self
Add a method to the class.
It is added to prototype
.
Sourcepub fn static_method<N>(
&mut self,
name: N,
length: usize,
function: NativeFunction,
) -> &mut Self
pub fn static_method<N>( &mut self, name: N, length: usize, function: NativeFunction, ) -> &mut Self
Add a static method to the class.
It is added to class 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 a data property to the class, with the specified attribute.
It is added to 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 a static data property to the class, with the specified attribute.
It is added to class 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 an accessor property to the class, with the specified attribute.
It is added to 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 a static accessor property to the class, with the specified attribute.
It is added to class 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 a property descriptor to the class, with the specified attribute.
It is added to 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 a static property descriptor to the class, with the specified attribute.
It is added to class object itself.