Skip to main content

HostHooks

Struct HostHooks 

Source
pub struct HostHooks {
Show 27 fields pub get: fn(&mut Interp, &ObjRef, HostRef, &str) -> Option<Value>, pub set: fn(&mut Interp, &ObjRef, HostRef, &str, Value) -> Option<Value>, pub delete: fn(&mut Interp, HostRef, &str) -> Option<bool>, pub keys: fn(&Interp, HostRef) -> HostKeys, pub iterate: fn(&Interp, HostRef, bool) -> Option<Vec<Value>>, pub resolves_on_read: fn(HostRef) -> bool, pub proto: fn(&Interp, HostRef) -> Option<Option<ObjRef>>, pub set_proto: fn(&mut Interp, HostRef, &ObjRef) -> bool, pub probe: fn(&Interp, HostRef, &str, bool) -> HostProbe, pub own: fn(&Interp, HostRef, &str) -> HostOwn, pub define: HostDefineFn, pub describe: fn(&Interp, HostRef) -> Option<String>, pub class_name: fn(HostRef) -> (&'static str, &'static str), pub construct_element: HostConstructElementFn, pub gc_cleanup: fn(&Interp), pub after_call: fn(&mut Interp), pub new_interp_state: fn(&dyn Any) -> Rc<dyn Any>, pub init_runtime: fn(&mut JsRuntime), pub teardown_runtime: fn(u64, &dyn Any, &mut Vec<Value>), pub current_base_url: fn(&Rc<RefCell<Scope>>) -> Option<String>, pub has_ready_async_io: fn(&dyn Any) -> bool, pub has_pending_async_io: fn(&dyn Any) -> bool, pub pump_async_io: fn(&mut Interp) -> bool, pub after_eval: fn(&mut Interp), pub after_pump: fn(&mut Interp), pub special_get: fn(&mut Interp, &ObjRef, &str) -> Option<Value>, pub special_set: fn(&mut Interp, &ObjRef, &str, &Value) -> bool,
}
Expand description

ホスト物に対する操作の表。

Fields§

§get: fn(&mut Interp, &ObjRef, HostRef, &str) -> Option<Value>

obj[key] の取得。None は「ホスト物としては処理しない」(核が普通の props・原型の連鎖で解決する)。

§set: fn(&mut Interp, &ObjRef, HostRef, &str, Value) -> Option<Value>

obj[key] = val。処理したら None、処理しなければ値を返す(核が普通の props へ書く)。

§delete: fn(&mut Interp, HostRef, &str) -> Option<bool>

delete obj[key]。処理したら Some(結果)、処理しなければ None(核が普通に消す)。

§keys: fn(&Interp, HostRef) -> HostKeys

自身の列挙可能なプロパティ。

§iterate: fn(&Interp, HostRef, bool) -> Option<Vec<Value>>

for (x of obj)(第 3 引数 true)・for (k in obj)(false)の列。ホスト物として扱わなければ None。

§resolves_on_read: fn(HostRef) -> bool

"key" in obj が「読めるか」で決まる種類か(自身のプロパティを実体に持たず、読み取り時に解決する種類)。

§proto: fn(&Interp, HostRef) -> Option<Option<ObjRef>>

原型(__proto__・instanceof の連鎖の起点)。実体の proto が無いときだけ使う。 None は「この種類は原型を実体の外に持たない」(核が組み込みの原型へ進む)、Some(None) は「原型が無い」。

§set_proto: fn(&mut Interp, HostRef, &ObjRef) -> bool

__proto__ への代入。処理したら true。

§probe: fn(&Interp, HostRef, &str, bool) -> HostProbe

インラインキャッシュ用の問い合わせ。第 3 引数は代入のとき true。

§own: fn(&Interp, HostRef, &str) -> HostOwn

自身のプロパティの状態。

§define: HostDefineFn

Object.defineProperty の自身のプロパティ(get, set, value の順)。処理したら true。

§describe: fn(&Interp, HostRef) -> Option<String>

診断用の短い説明(<div#player.x>)。無ければ None。

§class_name: fn(HostRef) -> (&'static str, &'static str)

種類名(診断用の短い名, 呼べない物としての名)。

§construct_element: HostConstructElementFn

カスタム要素(HTMLElement 等)の new 構築。対象外なら None。

§gc_cleanup: fn(&Interp)

循環 GC 前のホスト資源掃除(孤立 DOM ノードの解放など)。

§after_call: fn(&mut Interp)

関数呼び出し後の後処理(カスタム要素の反応キュー消化など)。

§new_interp_state: fn(&dyn Any) -> Rc<dyn Any>

JsRuntime::host_state から Interp::host_state を作る。

§init_runtime: fn(&mut JsRuntime)

JsRuntime::new の初期化末尾(prelude の仕掛け等)。

§teardown_runtime: fn(u64, &dyn Any, &mut Vec<Value>)

Drop for JsRuntime の片付け(ホスト資源から循環根を回収し、外部資源を解放する)。

§current_base_url: fn(&Rc<RefCell<Scope>>) -> Option<String>

現在の文書 URL(location.href 等)。無ければ None(JsRuntime::base_url を使う)。

§has_ready_async_io: fn(&dyn Any) -> bool

到着済みの非同期 I/O 結果があるか(JsRuntime::host_state を受ける)。

§has_pending_async_io: fn(&dyn Any) -> bool

未完了の非同期 I/O があるか(Interp::host_state を受ける)。

§pump_async_io: fn(&mut Interp) -> bool

到着済みの非同期 I/O 結果を配送する。1 件以上処理したら true。

§after_eval: fn(&mut Interp)

JsRuntime::eval 末尾の後処理(Observer 発火など)。

§after_pump: fn(&mut Interp)

JsRuntime::pump_timers 末尾の後処理(MutationObserver 発火など)。

§special_get: fn(&mut Interp, &ObjRef, &str) -> Option<Value>

非 HostRef のホスト特殊実体(RadioNodeList.value / select.selectedIndex 等)の取得。対象外なら None。

§special_set: fn(&mut Interp, &ObjRef, &str, &Value) -> bool

非 HostRef のホスト特殊実体への代入。処理したら true。

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.