1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use crate::plumbing::nativepointer::NativePointer;
use std::fmt;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = Interceptor, js_name = attach)]
pub fn attach(target: NativePointer, callbacks: js_sys::Object);
#[wasm_bindgen(js_name = InvocationArg)]
#[derive(Debug)]
pub type InvocationArgs;
#[wasm_bindgen(js_name = InvocationContext)]
#[derive(Debug)]
pub type InvocationContext;
#[wasm_bindgen(method, getter, js_name = returnAddress)]
pub fn return_address(this: &InvocationContext) -> NativePointer;
#[wasm_bindgen(method, getter, js_name = context)]
pub fn context(this: &InvocationContext) -> crate::plumbing::cpu::CpuContext;
#[wasm_bindgen(method, getter, js_name = threadId)]
pub fn thread_id(this: &InvocationContext) -> u32;
#[wasm_bindgen(method, getter, js_name = depth)]
pub fn depth(this: &InvocationContext) -> u32;
#[wasm_bindgen(method, structural, indexing_getter)]
pub fn get(this: &InvocationContext, prop: &str) -> JsValue;
#[wasm_bindgen(method, structural, indexing_setter)]
pub fn set(this: &InvocationContext, prop: &str, val: JsValue);
#[wasm_bindgen(js_name = InvocationReturnValue, extends = NativePointer)]
#[derive(Debug)]
pub type InvocationReturnValue;
#[wasm_bindgen(constructor)]
fn new(s: &str) -> InvocationReturnValue;
#[wasm_bindgen(method, js_name = replace)]
pub fn replace(this: &InvocationReturnValue, value: NativePointer);
}
impl InvocationArgs {
pub fn get(&self, index: u32) -> NativePointer {
let a: &js_sys::Array = &self.unchecked_ref();
a.get(index).unchecked_into()
}
}
impl fmt::Display for InvocationReturnValue {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let p: &NativePointer = self.as_ref();
write!(f, "{}", p.to_string())
}
}