summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-08-25 22:18:32 +0430
committerAndreas Kling <kling@serenityos.org>2020-08-26 08:45:01 +0200
commit394e4c04cd5dfdca56f67e6384288a209bdbf6dc (patch)
tree92332e13de789afa219e69a77fedb5806c513018 /Applications
parent521e730df107db3565880b79c6d6a7e66132787e (diff)
downloadserenity-394e4c04cd5dfdca56f67e6384288a209bdbf6dc.zip
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.
Diffstat (limited to 'Applications')
-rw-r--r--Applications/Spreadsheet/Spreadsheet.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/Applications/Spreadsheet/Spreadsheet.cpp b/Applications/Spreadsheet/Spreadsheet.cpp
index e40cb983ca..e90bfc9610 100644
--- a/Applications/Spreadsheet/Spreadsheet.cpp
+++ b/Applications/Spreadsheet/Spreadsheet.cpp
@@ -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);