aboutsummaryrefslogtreecommitdiff
path: root/web/adapter.cpp
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-05-25 12:38:39 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-05-25 12:38:39 +0200
commit87852933851674cacbc8b2295d046831db27ab81 (patch)
treee67a8b8d3ff9d41c927887483f62882da6258fb6 /web/adapter.cpp
parent2852d47c0e7b0da72259ddcec693270d52110578 (diff)
downloadnissy-core-87852933851674cacbc8b2295d046831db27ab81.tar.gz
nissy-core-87852933851674cacbc8b2295d046831db27ab81.zip
Cleanup
Diffstat (limited to 'web/adapter.cpp')
-rw-r--r--web/adapter.cpp38
1 files changed, 0 insertions, 38 deletions
diff --git a/web/adapter.cpp b/web/adapter.cpp
index c3134e9..71a34ab 100644
--- a/web/adapter.cpp
+++ b/web/adapter.cpp
@@ -114,8 +114,6 @@ int poll_status(void *arg)
114 return callFunctionInt(*(int *)arg); 114 return callFunctionInt(*(int *)arg);
115} 115}
116 116
117#if 1
118
119nissy::solver::solve_result solve(std::string name, 117nissy::solver::solve_result solve(std::string name,
120 nissy::cube cube, nissy::nissflag nissflag, unsigned minmoves, 118 nissy::cube cube, nissy::nissflag nissflag, unsigned minmoves,
121 unsigned maxmoves, unsigned maxsols, unsigned optimal, unsigned threads, 119 unsigned maxmoves, unsigned maxsols, unsigned optimal, unsigned threads,
@@ -137,35 +135,6 @@ nissy::solver::solve_result solve(std::string name,
137 maxmoves, maxsols, optimal, threads, NULL, &poll_status_id); 135 maxmoves, maxsols, optimal, threads, NULL, &poll_status_id);
138} 136}
139 137
140#else
141
142std::string solve(std::string name,
143 nissy::cube cube, nissy::nissflag nissflag, unsigned minmoves,
144 unsigned maxmoves, unsigned maxsols, unsigned optimal, unsigned threads,
145 int poll_status_id)
146{
147 // Here we use a dirty trick to make this function always return the
148 // same kind of JavaScript object. If we did not do this, the returned
149 // object would be a Promise on the first run of the solver for each
150 // session (because when loading the table some async JS code is
151 // called), and a regular object otherwise.
152 // TODO figure out if there is a better way to do this.
153 fake_async();
154
155 if (!solver_valid(name))
156 return "";
157/*
158 return nissy::solver::solve_result
159 {.err = nissy::error::INVALID_SOLVER};
160*/
161
162 return loaded_solvers.at(name).solve(cube, nissflag, minmoves,
163 maxmoves, maxsols, optimal, threads, NULL, &poll_status_id)
164 .solutions[0];
165}
166
167#endif
168
169EMSCRIPTEN_BINDINGS(Nissy) 138EMSCRIPTEN_BINDINGS(Nissy)
170{ 139{
171 emscripten::class_<nissy::nissflag>("NissFlag") 140 emscripten::class_<nissy::nissflag>("NissFlag")
@@ -208,13 +177,6 @@ EMSCRIPTEN_BINDINGS(Nissy)
208 .function("toString", &nissy::cube::to_string) 177 .function("toString", &nissy::cube::to_string)
209 ; 178 ;
210 179
211/*
212 emscripten::register_vector<std::string>("StringVector");
213 emscripten::value_array<nissy::solver::solve_result>("SolveResult")
214 .element(&nissy::solver::solve_result::err)
215 .element(&nissy::solver::solve_result::solutions)
216 ;
217*/
218 emscripten::class_<nissy::solver::solve_result>("SolveResult") 180 emscripten::class_<nissy::solver::solve_result>("SolveResult")
219 .property("err", &nissy::solver::solve_result::err) 181 .property("err", &nissy::solver::solve_result::err)
220 .property("solutions", &nissy::solver::solve_result::solutions) 182 .property("solutions", &nissy::solver::solve_result::solutions)

Generated with cgit - Back to sebastiano.tronto.net