Skip to content

Commit

Permalink
fix: allow frontend function to send booleans & numbers to backend (#198
Browse files Browse the repository at this point in the history
)

* fix: allow frontend function to send booleans to backend

* fix: allow frontend function to send numbers to backend
  • Loading branch information
BossSloth authored Dec 31, 2024
1 parent 558a779 commit aa4f054
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core/ffi/javascript.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ PyObject* JavaScript::EvaluateFromSocket(std::string script)
std::string type = response.json["type"];

if (type == "string") return PyUnicode_FromString(response.json["value"].get<std::string>().c_str());
else if (type == "bool") return PyBool_FromLong(response.json["value"]);
else if (type == "int") return PyLong_FromLong(response.json["value"]);
else if (type == "boolean") return PyBool_FromLong(response.json["value"]);
else if (type == "number") return PyLong_FromLong(response.json["value"]);
else
return PyUnicode_FromString("Js function returned unaccepted type. accepted types [string, bool, int]");
return PyUnicode_FromString(fmt::format("Js function returned unaccepted type '{}'. Accepted types [string, boolean, number]", type).c_str());

}
catch (nlohmann::detail::exception& ex)
Expand Down

0 comments on commit aa4f054

Please sign in to comment.