mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:07:44 +00:00
LibJS: Add a helper for calling JS::Function's with arguments
The fact that a `MarkedValueList` had to be created was just annoying, so here's an alternative. This patchset also removes some (now) unneeded MarkedValueList.h includes.
This commit is contained in:
parent
521e730df1
commit
394e4c04cd
15 changed files with 72 additions and 113 deletions
|
@ -35,6 +35,7 @@
|
|||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
|
||||
namespace Spreadsheet {
|
||||
|
||||
|
@ -348,9 +349,7 @@ RefPtr<Sheet> Sheet::from_json(const JsonObject& object)
|
|||
break;
|
||||
case Cell::Formula: {
|
||||
auto& interpreter = sheet->interpreter();
|
||||
JS::MarkedValueList args { interpreter.heap() };
|
||||
args.append(JS::js_string(interpreter, obj.get("value").as_string()));
|
||||
auto value = interpreter.call(parse_function, json, move(args));
|
||||
auto value = interpreter.call(parse_function, json, JS::js_string(interpreter, obj.get("value").as_string()));
|
||||
cell = make<Cell>(obj.get("source").to_string(), move(value), sheet->make_weak_ptr());
|
||||
break;
|
||||
}
|
||||
|
@ -387,9 +386,7 @@ JsonObject Sheet::to_json() const
|
|||
if (it.value->kind == Cell::Formula) {
|
||||
data.set("source", it.value->data);
|
||||
auto json = m_interpreter->global_object().get("JSON");
|
||||
JS::MarkedValueList args(m_interpreter->heap());
|
||||
args.append(it.value->evaluated_data);
|
||||
auto stringified = m_interpreter->call(json.as_object().get("stringify").as_function(), json, move(args));
|
||||
auto stringified = m_interpreter->call(json.as_object().get("stringify").as_function(), json, it.value->evaluated_data);
|
||||
data.set("value", stringified.to_string_without_side_effects());
|
||||
} else {
|
||||
data.set("value", it.value->data);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue