Skip to content

Commit f1dac50

Browse files
bdemannyouknowone
authored andcommitted
address pr notes
1 parent 4f80d70 commit f1dac50

2 files changed

Lines changed: 18 additions & 25 deletions

File tree

‎vm/src/stdlib/time.rs‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,17 @@ mod decl {
102102
Ok(duration_since_system_now(vm)?.as_secs_f64())
103103
}
104104

105-
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
105+
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind"))]
106106
fn _time(_vm: &VirtualMachine) -> PyResult<f64> {
107-
#[cfg(feature = "wasmbind")]
108-
{
109-
use wasm_bindgen::prelude::*;
110-
#[wasm_bindgen]
111-
extern "C" {
112-
type Date;
113-
#[wasm_bindgen(static_method_of = Date)]
114-
fn now() -> f64;
115-
}
116-
// Date.now returns unix time in milliseconds, we want it in seconds
117-
return Ok(Date::now() / 1000.0);
107+
use wasm_bindgen::prelude::*;
108+
#[wasm_bindgen]
109+
extern "C" {
110+
type Date;
111+
#[wasm_bindgen(static_method_of = Date)]
112+
fn now() -> f64;
118113
}
119-
panic!("Date not available")
114+
// Date.now returns unix time in milliseconds, we want it in seconds
115+
return Ok(Date::now() / 1000.0);
120116
}
121117

122118
#[pyfunction]

‎vm/src/vm/vm_object.rs‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,17 @@ impl VirtualMachine {
1919
self.flush_std();
2020
panic!("{msg}")
2121
}
22-
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
22+
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind"))]
2323
{
24-
#[cfg(feature = "wasmbind")]
25-
{
26-
use wasm_bindgen::prelude::*;
27-
#[wasm_bindgen]
28-
extern "C" {
29-
#[wasm_bindgen(js_namespace = console)]
30-
fn error(s: &str);
31-
}
32-
let mut s = String::new();
33-
self.write_exception(&mut s, &exc).unwrap();
34-
error(&s);
24+
use wasm_bindgen::prelude::*;
25+
#[wasm_bindgen]
26+
extern "C" {
27+
#[wasm_bindgen(js_namespace = console)]
28+
fn error(s: &str);
3529
}
30+
let mut s = String::new();
31+
self.write_exception(&mut s, &exc).unwrap();
32+
error(&s);
3633
panic!("{}; exception backtrace above", msg)
3734
}
3835
}

0 commit comments

Comments
 (0)