From ed5840afecdc3099992dd7497e119eca2a223daf Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 12 Oct 2020 01:31:17 +0100 Subject: [PATCH] js tests seem to work Signed-off-by: Ian Jackson --- src/api.rs | 1 + templates/script.ts | 2 +- wasm/wasm.rs | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/api.rs b/src/api.rs index 1a8bebdc..aadf34d8 100644 --- a/src/api.rs +++ b/src/api.rs @@ -199,6 +199,7 @@ struct ApiPieceWrest { #[throws(OE)] fn api_wrest(form : Json>) -> impl response::Responder<'static> { + // xxx wresting does not seem to work, maybe client isn't doing it? api_piece_op(form) } impl ApiPieceOp for ApiPieceWrest { diff --git a/templates/script.ts b/templates/script.ts index 9d3ac39f..ec7e0124 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -741,7 +741,7 @@ function drag_mousemove(e: MouseEvent) { console.log('CHECK RAISE ', dragraise, dragraise*dragraise, ddr2); piece_set_zlevel(piece,p, (oldtop_piece) => { let oldtop_p = pieces[oldtop_piece]!; - let z = "42" as any; // xxx Bigfloats.add(oldtop_p.z, 1); + let z = wasm_bindgen.increment(oldtop_p.z); p.z = z; api_piece(api, "setz", piece,p, { z: z }); }); diff --git a/wasm/wasm.rs b/wasm/wasm.rs index 650cbf6d..8c25c5a1 100644 --- a/wasm/wasm.rs +++ b/wasm/wasm.rs @@ -41,6 +41,13 @@ pub fn check(packed: &JsValue) { ZCoord::check_str(&get_packed_str(packed)?).e()?; } +#[throws(JsValue)] +#[wasm_bindgen] +pub fn increment(packed: &JsValue) -> JsValue { + let mut m = Mutable::from_str(&get_packed_str(packed)?).e()?; + m.increment().e()?.to_string().into() +} + #[wasm_bindgen] pub struct ZCoordIterator (zcoord::BoxedIterator); -- 2.30.2