Skip to content

Commit

Permalink
Use f64 instead of u64 for places where bindgen is expecting `Big…
Browse files Browse the repository at this point in the history
…Int` (#541)
  • Loading branch information
shanemadden authored Sep 13, 2024
1 parent 55e6a94 commit e7bd612
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Unreleased

### Breaking:

- Change return type of `Structure::destroy` from `i8` to `Result<(), ErrorCode>`.
- Change return type of `Structure::destroy` from `i8` to `Result<(), ErrorCode>`
- Change inner u8 of `RoomCoordinate` to private
- Use `f64` instead of `u64` to work around bindgen expecting `BigInt` return values

0.22.0 (2024-08-27)
===================
Expand Down
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 e7bd612

Please sign in to comment.