File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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]
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments