quickjs_runtime::jsutils::jsproxies

Type Alias JsProxy

source
pub type JsProxy = Proxy;

Aliased Type§

struct JsProxy { /* private fields */ }

Implementations

source§

impl Proxy

source

pub fn new() -> Self

source

pub fn name(self, name: &str) -> Self

set the name of the proxy class this will indicate how to construct the class from script

source

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();
source

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”

source

pub fn constructor<C>(self, constructor: C) -> Self

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

source

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

source

pub fn method<M>(self, name: &str, method: M) -> Self

add a method to the Proxy class, this method will be available as a member of instances of the Proxy class

source

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

source

pub fn static_method<M>(self, name: &str, method: M) -> Self

add a static method to the Proxy class, this method will be available as a member of the Proxy class itself

source

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

source

pub fn static_getter_setter<G, S>( self, name: &str, getter: G, setter: S, ) -> Self

add a static getter and setter to the Proxy class

source

pub fn static_catch_all_getter_setter<G, S>(self, getter: G, setter: S) -> Self

add a static getter and setter to the Proxy class

source

pub fn getter_setter<G, S>(self, name: &str, getter: G, setter: S) -> Self

add a getter and setter to the Proxy class, these will be available as a member of an instance of this Proxy class

source

pub fn getter<G>(self, name: &str, getter: G) -> Self

add a getter and setter to the Proxy class, these will be available as a member of an instance of this Proxy class

source

pub fn catch_all_getter_setter<G, S>(self, getter: G, setter: S) -> Self

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

source

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

source

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

source

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

Trait Implementations

source§

impl Default for Proxy

source§

fn default() -> Self

Returns the “default value” for a type. Read more