pub type JsProxy = Proxy;
Aliased Type§
struct JsProxy { /* private fields */ }
Implementations
source§impl Proxy
impl Proxy
pub fn new() -> Self
sourcepub fn name(self, name: &str) -> Self
pub fn name(self, name: &str) -> Self
set the name of the proxy class this will indicate how to construct the class from script
sourcepub fn namespace(self, namespace: &[&str]) -> Self
pub fn namespace(self, namespace: &[&str]) -> Self
set the namespace of the proxy class
§Example
use quickjs_runtime::reflection::Proxy;
Proxy::new().namespace(&["com", "hirofa"]).name("SomeClass");
means from script you can access the class by
let instance = new com.hirofa.SomeClass();
sourcepub fn get_class_name(&self) -> String
pub fn get_class_name(&self) -> String
get the canonical classname of a Proxy
§example
use quickjs_runtime::reflection::Proxy;
Proxy::new().namespace(&["com", "hirofa"]).name("SomeClass");
will result in a class_name of “com.hirofa.SomeClass”
sourcepub fn constructor<C>(self, constructor: C) -> Selfwhere
C: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, usize, &[QuickJsValueAdapter]) -> Result<(), JsError> + 'static,
pub fn constructor<C>(self, constructor: C) -> Selfwhere
C: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, usize, &[QuickJsValueAdapter]) -> Result<(), JsError> + 'static,
add a constructor for the Proxy class this will enable a script to create a new instance of a Proxy class if omitted the Proxy class will not be constructable from script
sourcepub fn finalizer<C>(self, finalizer: C) -> Self
pub fn finalizer<C>(self, finalizer: C) -> Self
add a finalizer for the Proxy class this will be called when an instance of the Proxy class is dropped or garbage collected
sourcepub fn method<M>(self, name: &str, method: M) -> Selfwhere
M: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, &usize, &[QuickJsValueAdapter]) -> Result<QuickJsValueAdapter, JsError> + 'static,
pub fn method<M>(self, name: &str, method: M) -> Selfwhere
M: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, &usize, &[QuickJsValueAdapter]) -> Result<QuickJsValueAdapter, JsError> + 'static,
add a method to the Proxy class, this method will be available as a member of instances of the Proxy class
sourcepub fn native_method(self, name: &str, method: ProxyNativeMethod) -> Self
pub fn native_method(self, name: &str, method: ProxyNativeMethod) -> Self
add a method to the Proxy class, this method will be available as a member of instances of the Proxy class
sourcepub fn static_method<M>(self, name: &str, method: M) -> Selfwhere
M: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, &[QuickJsValueAdapter]) -> Result<QuickJsValueAdapter, JsError> + 'static,
pub fn static_method<M>(self, name: &str, method: M) -> Selfwhere
M: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, &[QuickJsValueAdapter]) -> Result<QuickJsValueAdapter, JsError> + 'static,
add a static method to the Proxy class, this method will be available as a member of the Proxy class itself
sourcepub fn static_native_method(
self,
name: &str,
method: ProxyStaticNativeMethod,
) -> Self
pub fn static_native_method( self, name: &str, method: ProxyStaticNativeMethod, ) -> Self
add a static method to the Proxy class, this method will be available as a member of the Proxy class itself
sourcepub fn static_getter_setter<G, S>(
self,
name: &str,
getter: G,
setter: S,
) -> Selfwhere
G: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter) -> Result<QuickJsValueAdapter, JsError> + 'static,
S: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, QuickJsValueAdapter) -> Result<(), JsError> + 'static,
pub fn static_getter_setter<G, S>(
self,
name: &str,
getter: G,
setter: S,
) -> Selfwhere
G: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter) -> Result<QuickJsValueAdapter, JsError> + 'static,
S: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, QuickJsValueAdapter) -> Result<(), JsError> + 'static,
add a static getter and setter to the Proxy class
sourcepub fn static_catch_all_getter_setter<G, S>(self, getter: G, setter: S) -> Selfwhere
G: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, &str) -> Result<QuickJsValueAdapter, JsError> + 'static,
S: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, &str, QuickJsValueAdapter) -> Result<(), JsError> + 'static,
pub fn static_catch_all_getter_setter<G, S>(self, getter: G, setter: S) -> Selfwhere
G: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, &str) -> Result<QuickJsValueAdapter, JsError> + 'static,
S: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, &str, QuickJsValueAdapter) -> Result<(), JsError> + 'static,
add a static getter and setter to the Proxy class
sourcepub fn getter_setter<G, S>(self, name: &str, getter: G, setter: S) -> Selfwhere
G: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, &usize) -> Result<QuickJsValueAdapter, JsError> + 'static,
S: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, &usize, QuickJsValueAdapter) -> Result<(), JsError> + 'static,
pub fn getter_setter<G, S>(self, name: &str, getter: G, setter: S) -> Selfwhere
G: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, &usize) -> Result<QuickJsValueAdapter, JsError> + 'static,
S: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, &usize, QuickJsValueAdapter) -> Result<(), JsError> + 'static,
add a getter and setter to the Proxy class, these will be available as a member of an instance of this Proxy class
sourcepub fn getter<G>(self, name: &str, getter: G) -> Selfwhere
G: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, &usize) -> Result<QuickJsValueAdapter, JsError> + 'static,
pub fn getter<G>(self, name: &str, getter: G) -> Selfwhere
G: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, &usize) -> Result<QuickJsValueAdapter, JsError> + 'static,
add a getter and setter to the Proxy class, these will be available as a member of an instance of this Proxy class
sourcepub fn catch_all_getter_setter<G, S>(self, getter: G, setter: S) -> Selfwhere
G: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, &usize, &str) -> Result<QuickJsValueAdapter, JsError> + 'static,
S: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, &usize, &str, QuickJsValueAdapter) -> Result<(), JsError> + 'static,
pub fn catch_all_getter_setter<G, S>(self, getter: G, setter: S) -> Selfwhere
G: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, &usize, &str) -> Result<QuickJsValueAdapter, JsError> + 'static,
S: Fn(&QuickJsRuntimeAdapter, &QuickJsRealmAdapter, &usize, &str, QuickJsValueAdapter) -> Result<(), JsError> + 'static,
add a catchall getter and setter to the Proxy class, these will be used for properties which are not specifically defined as getter, setter or method in this Proxy
sourcepub fn event_target(self) -> Self
pub fn event_target(self) -> Self
indicate the Proxy class should implement the EventTarget interface, this will result in the addEventListener, removeEventListener and dispatchEvent methods to be available on instances of the Proxy class
sourcepub fn static_event_target(self) -> Self
pub fn static_event_target(self) -> Self
indicate the Proxy class should implement the EventTarget interface, this will result in the addEventListener, removeEventListener and dispatchEvent methods to be available
sourcepub fn install(
self,
q_ctx: &QuickJsRealmAdapter,
add_variable_to_global: bool,
) -> Result<QuickJsValueAdapter, JsError>
pub fn install( self, q_ctx: &QuickJsRealmAdapter, add_variable_to_global: bool, ) -> Result<QuickJsValueAdapter, JsError>
install the Proxy class in a QuickJsContext, this is always needed as a final step to actually make the Proxy class work