diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-06-05 11:42:12 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-06-05 11:42:12 +0200 |
| commit | f1a2985897850321e0a9acb1b74bb41e016deb5c (patch) | |
| tree | bc0585a7bb629549bc3f7914027d62bb21bde30c /web | |
| parent | 52c74a1c33ce12b93ec5830f5a6348d9578c7c6e (diff) | |
| download | nissy-core-f1a2985897850321e0a9acb1b74bb41e016deb5c.tar.gz nissy-core-f1a2985897850321e0a9acb1b74bb41e016deb5c.zip | |
Added debug mode to web build and fixed a couple of bugs
Diffstat (limited to 'web')
| -rw-r--r-- | web/adapter.cpp | 6 | ||||
| -rw-r--r-- | web/http/nissyapp.mjs | 8 | ||||
| -rw-r--r-- | web/http/worker.mjs | 3 |
3 files changed, 10 insertions, 7 deletions
diff --git a/web/adapter.cpp b/web/adapter.cpp index 3df3a54..9cb2e2d 100644 --- a/web/adapter.cpp +++ b/web/adapter.cpp | |||
| @@ -151,13 +151,14 @@ int poll_status(void *arg) | |||
| 151 | if (arg == nullptr) | 151 | if (arg == nullptr) |
| 152 | return nissy::status::RUN.value; | 152 | return nissy::status::RUN.value; |
| 153 | 153 | ||
| 154 | std::function<int(void)> poll((int (*)(void))arg); | 154 | std::function<int(void)> poll((int (*)(void))*(int *)arg); |
| 155 | return poll(); | 155 | return poll(); |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | // The parameter js_poll_status is of type int here, but actually it is a | 158 | // The parameter js_poll_status is of type int here, but actually it is a |
| 159 | // pointer to a JS function. The type will have to be changed to a 64-bit | 159 | // pointer to a JS function. The type will have to be changed to a 64-bit |
| 160 | // integer when we move to WASM64. | 160 | // integer when we move to WASM64. |
| 161 | int js_poll_status_global = 0; | ||
| 161 | nissy::solver::solve_result solve(std::string name, | 162 | nissy::solver::solve_result solve(std::string name, |
| 162 | nissy::cube cube, nissy::nissflag nissflag, unsigned minmoves, | 163 | nissy::cube cube, nissy::nissflag nissflag, unsigned minmoves, |
| 163 | unsigned maxmoves, unsigned maxsols, unsigned optimal, unsigned threads, | 164 | unsigned maxmoves, unsigned maxsols, unsigned optimal, unsigned threads, |
| @@ -179,9 +180,10 @@ nissy::solver::solve_result solve(std::string name, | |||
| 179 | 180 | ||
| 180 | // TODO: when running multiple solvers at the same time, we could use | 181 | // TODO: when running multiple solvers at the same time, we could use |
| 181 | // poll_status_id as intended (i.e. an id of some sort) | 182 | // poll_status_id as intended (i.e. an id of some sort) |
| 183 | js_poll_status_global = js_poll_status; | ||
| 182 | return loaded_solvers.at(name).solve(cube, nissflag, minmoves, | 184 | return loaded_solvers.at(name).solve(cube, nissflag, minmoves, |
| 183 | maxmoves, maxsols, optimal, threads, | 185 | maxmoves, maxsols, optimal, threads, |
| 184 | poll_status, &js_poll_status); | 186 | poll_status, &js_poll_status_global); |
| 185 | } | 187 | } |
| 186 | 188 | ||
| 187 | EMSCRIPTEN_BINDINGS(Nissy) | 189 | EMSCRIPTEN_BINDINGS(Nissy) |
diff --git a/web/http/nissyapp.mjs b/web/http/nissyapp.mjs index cdfd4d5..b056b5f 100644 --- a/web/http/nissyapp.mjs +++ b/web/http/nissyapp.mjs | |||
| @@ -267,10 +267,10 @@ function startSolve(solver, scramble) { | |||
| 267 | arg: { | 267 | arg: { |
| 268 | solver: solver, | 268 | solver: solver, |
| 269 | scramble: scramble, | 269 | scramble: scramble, |
| 270 | minmoves: minSlider.value, | 270 | minmoves: Number(minSlider.value), |
| 271 | maxmoves: maxSlider.value, | 271 | maxmoves: Number(maxSlider.value), |
| 272 | maxsolutions: maxSolsInput.value, | 272 | maxsolutions: Number(maxSolsInput.value), |
| 273 | optimal: optimalInput.value, | 273 | optimal: Number(optimalInput.value), |
| 274 | threads: window.navigator.hardwareConcurrency, | 274 | threads: window.navigator.hardwareConcurrency, |
| 275 | } | 275 | } |
| 276 | }); | 276 | }); |
diff --git a/web/http/worker.mjs b/web/http/worker.mjs index 0c1acb9..b988bdd 100644 --- a/web/http/worker.mjs +++ b/web/http/worker.mjs | |||
| @@ -3,7 +3,8 @@ import Nissy from "./nissy_web_module.mjs" | |||
| 3 | const nissy = await Nissy(); | 3 | const nissy = await Nissy(); |
| 4 | 4 | ||
| 5 | const log = (cstr) => postMessage({ | 5 | const log = (cstr) => postMessage({ |
| 6 | command: "log", id: -1, | 6 | command: "log", |
| 7 | id: -1, | ||
| 7 | object: nissy.UTF8ToString(cstr) | 8 | object: nissy.UTF8ToString(cstr) |
| 8 | }); | 9 | }); |
| 9 | nissy.setLogger(nissy.addFunction(log, "vp")); | 10 | nissy.setLogger(nissy.addFunction(log, "vp")); |
