Skip to content

Commit

Permalink
Use f64 instead of u64 for places where bindgen is expecting bigint
Browse files Browse the repository at this point in the history
  • Loading branch information
shanemadden committed Sep 12, 2024
1 parent 55e6a94 commit f02a66c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/game/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern "C" {

#[cfg(feature = "mmo")]
#[wasm_bindgen(js_namespace = ["Game"], js_class = "cpu", static_method_of = Cpu, getter, js_name = unlockedTime)]
fn unlocked_time() -> Option<u64>;
fn unlocked_time() -> Option<f64>;

#[wasm_bindgen(js_namespace = ["Game"], js_class = "cpu", static_method_of = Cpu, js_name = getHeapStatistics)]
fn get_heap_statistics() -> HeapStatistics;
Expand Down Expand Up @@ -90,10 +90,11 @@ pub fn unlocked() -> bool {
Cpu::unlocked()
}

// note: f64 due to https://github.com/rustwasm/wasm-bindgen/issues/4113
/// If your account has been unlocked for a limited time, contains the time
/// it's unlocked until in milliseconds since epoch.
#[cfg(feature = "mmo")]
pub fn unlocked_time() -> Option<u64> {
pub fn unlocked_time() -> Option<f64> {
Cpu::unlocked_time()
}

Expand Down
5 changes: 3 additions & 2 deletions src/game/market.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ extern "C" {
/// Tick of order creation, `None` for intershard orders.
#[wasm_bindgen(method, getter)]
pub fn created(this: &Order) -> Option<u32>;
// todo should be u64 but seems to panic at the moment, follow up
// note: f64 due to https://github.com/rustwasm/wasm-bindgen/issues/4113
/// Timestamp of order creation in milliseconds since epoch.
#[wasm_bindgen(method, getter = createdTimestamp)]
pub fn created_timestamp(this: &Order) -> f64;
Expand Down Expand Up @@ -307,9 +307,10 @@ extern "C" {
/// Tick of order creation, `None` for intershard orders
#[wasm_bindgen(method, getter)]
pub fn created(this: &MyOrder) -> Option<u32>;
// note: f64 due to https://github.com/rustwasm/wasm-bindgen/issues/4113
/// Timestamp of order creation in milliseconds since epoch
#[wasm_bindgen(method, getter = createdTimestamp)]
pub fn created_timestamp(this: &MyOrder) -> u64;
pub fn created_timestamp(this: &MyOrder) -> f64;
#[wasm_bindgen(method, getter)]
pub fn active(this: &MyOrder) -> bool;
#[wasm_bindgen(method, getter = type)]
Expand Down

0 comments on commit f02a66c

Please sign in to comment.