Skip to content

Commit 815e1b6

Browse files
authored
Merge pull request RustPython#3355 from moreal/use-pymodule-attribute-wasm-window
Remove usage of `py_module!` from `_window`
2 parents b394c0a + 5a16ab8 commit 815e1b6

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

wasm/lib/src/vm_class.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ pub(crate) struct StoredVirtualMachine {
2323
held_objects: RefCell<Vec<PyObjectRef>>,
2424
}
2525

26+
#[pymodule]
27+
mod _window {}
28+
29+
fn init_window_module(vm: &VirtualMachine) -> PyObjectRef {
30+
let module = _window::make_module(vm);
31+
32+
extend_module!(vm, module, {
33+
"window" => js_module::PyJsValue::new(wasm_builtins::window()).into_ref(vm),
34+
});
35+
36+
module
37+
}
38+
2639
impl StoredVirtualMachine {
2740
fn new(id: String, inject_browser_module: bool) -> StoredVirtualMachine {
2841
let mut scope = None;
@@ -31,11 +44,6 @@ impl StoredVirtualMachine {
3144

3245
js_module::setup_js_module(vm);
3346
if inject_browser_module {
34-
fn init_window_module(vm: &VirtualMachine) -> PyObjectRef {
35-
py_module!(vm, "_window", {
36-
"window" => js_module::PyJsValue::new(wasm_builtins::window()).into_ref(vm),
37-
})
38-
}
3947
vm.add_native_module("_window".to_owned(), Box::new(init_window_module));
4048
setup_browser_module(vm);
4149
}

0 commit comments

Comments
 (0)