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: HostDefineFnObject.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。