fix: implement generate_random_number for wasm binding

This commit is contained in:
Owen Delahoy
2025-05-22 20:11:26 +09:00
parent 268b30deee
commit c31f2b10b7

View File

@@ -288,8 +288,9 @@ impl limbo_core::IO for PlatformIO {
}
fn generate_random_number(&self) -> i64 {
let random_f64 = Math_random();
(random_f64 * i64::MAX as f64) as i64
let mut buf = [0u8; 8];
getrandom::getrandom(&mut buf).unwrap();
i64::from_ne_bytes(buf)
}
fn get_memory_io(&self) -> Arc<limbo_core::MemoryIO> {
@@ -297,11 +298,6 @@ impl limbo_core::IO for PlatformIO {
}
}
#[wasm_bindgen]
extern "C" {
fn Math_random() -> f64;
}
#[wasm_bindgen]
extern "C" {
type Date;