summaryrefslogtreecommitdiff
path: root/Userland/Applications/Spreadsheet
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-12-06 22:17:27 +0000
committerLinus Groh <mail@linusgroh.de>2022-12-07 16:43:06 +0000
commit525f22d018cb5f9c4c6ea0e2b5544fdcab8da483 (patch)
tree2488bac4fab4acec0d258c9bac2338bc95ee6398 /Userland/Applications/Spreadsheet
parent5db38d7ba1a8caa5138dd65cc06be0c0e5a568e4 (diff)
downloadserenity-525f22d018cb5f9c4c6ea0e2b5544fdcab8da483.zip
LibJS: Replace standalone js_string() with PrimitiveString::create()
Note that js_rope_string() has been folded into this, the old name was misleading - it would not always create a rope string, only if both sides are not empty strings. Use a three-argument create() overload instead.
Diffstat (limited to 'Userland/Applications/Spreadsheet')
-rw-r--r--Userland/Applications/Spreadsheet/Cell.cpp3
-rw-r--r--Userland/Applications/Spreadsheet/CellType/String.cpp3
-rw-r--r--Userland/Applications/Spreadsheet/JSIntegration.cpp12
-rw-r--r--Userland/Applications/Spreadsheet/Spreadsheet.cpp2
4 files changed, 11 insertions, 9 deletions
diff --git a/Userland/Applications/Spreadsheet/Cell.cpp b/Userland/Applications/Spreadsheet/Cell.cpp
index dea260bb97..9b534328ba 100644
--- a/Userland/Applications/Spreadsheet/Cell.cpp
+++ b/Userland/Applications/Spreadsheet/Cell.cpp
@@ -153,7 +153,8 @@ JS::Value Cell::js_data()
if (m_kind == Formula)
return m_evaluated_data;
- return JS::js_string(m_sheet->interpreter().heap(), m_data);
+ auto& vm = m_sheet->interpreter().vm();
+ return JS::PrimitiveString::create(vm, m_data);
}
DeprecatedString Cell::source() const
diff --git a/Userland/Applications/Spreadsheet/CellType/String.cpp b/Userland/Applications/Spreadsheet/CellType/String.cpp
index 79ebe52cd6..d011ca0a15 100644
--- a/Userland/Applications/Spreadsheet/CellType/String.cpp
+++ b/Userland/Applications/Spreadsheet/CellType/String.cpp
@@ -27,8 +27,9 @@ JS::ThrowCompletionOr<DeprecatedString> StringCell::display(Cell& cell, CellType
JS::ThrowCompletionOr<JS::Value> StringCell::js_value(Cell& cell, CellTypeMetadata const& metadata) const
{
+ auto& vm = cell.sheet().interpreter().vm();
auto string = TRY(display(cell, metadata));
- return JS::js_string(cell.sheet().interpreter().heap(), string);
+ return JS::PrimitiveString::create(vm, string);
}
DeprecatedString StringCell::metadata_hint(MetadataName metadata) const
diff --git a/Userland/Applications/Spreadsheet/JSIntegration.cpp b/Userland/Applications/Spreadsheet/JSIntegration.cpp
index 68f9a087f3..87bbd64cc1 100644
--- a/Userland/Applications/Spreadsheet/JSIntegration.cpp
+++ b/Userland/Applications/Spreadsheet/JSIntegration.cpp
@@ -178,7 +178,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_name)
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "SheetGlobalObject");
auto sheet_object = static_cast<SheetGlobalObject*>(this_object);
- return JS::js_string(vm, sheet_object->m_sheet.name());
+ return JS::PrimitiveString::create(vm, sheet_object->m_sheet.name());
}
JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_real_cell_contents)
@@ -205,9 +205,9 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_real_cell_contents)
return JS::js_undefined();
if (cell->kind() == Spreadsheet::Cell::Kind::Formula)
- return JS::js_string(vm, DeprecatedString::formatted("={}", cell->data()));
+ return JS::PrimitiveString::create(vm, DeprecatedString::formatted("={}", cell->data()));
- return JS::js_string(vm, cell->data());
+ return JS::PrimitiveString::create(vm, cell->data());
}
JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::set_real_cell_contents)
@@ -260,7 +260,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::parse_cell_name)
return JS::js_undefined();
auto object = JS::Object::create(realm, realm.intrinsics().object_prototype());
- object->define_direct_property("column", JS::js_string(vm, sheet_object->m_sheet.column(position.value().column)), JS::default_attributes);
+ object->define_direct_property("column", JS::PrimitiveString::create(vm, sheet_object->m_sheet.column(position.value().column)), JS::default_attributes);
object->define_direct_property("row", JS::Value((unsigned)position.value().row), JS::default_attributes);
return object;
@@ -286,7 +286,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::current_cell_position)
auto position = current_cell->position();
auto object = JS::Object::create(realm, realm.intrinsics().object_prototype());
- object->define_direct_property("column", JS::js_string(vm, sheet_object->m_sheet.column(position.column)), JS::default_attributes);
+ object->define_direct_property("column", JS::PrimitiveString::create(vm, sheet_object->m_sheet.column(position.column)), JS::default_attributes);
object->define_direct_property("row", JS::Value((unsigned)position.row), JS::default_attributes);
return object;
@@ -342,7 +342,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::column_arithmetic)
if (!new_column.has_value())
return vm.throw_completion<JS::TypeError>(DeprecatedString::formatted("'{}' is not a valid column", column_name_str));
- return JS::js_string(vm, new_column.release_value());
+ return JS::PrimitiveString::create(vm, new_column.release_value());
}
JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_column_bound)
diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp
index 8dd11ea9fc..1c3d0ae067 100644
--- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp
+++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp
@@ -426,7 +426,7 @@ RefPtr<Sheet> Sheet::from_json(JsonObject const& object, Workbook& workbook)
break;
case Cell::Formula: {
auto& vm = sheet->interpreter().vm();
- auto value_or_error = JS::call(vm, parse_function, json, JS::js_string(vm, obj.get("value"sv).as_string()));
+ auto value_or_error = JS::call(vm, parse_function, json, JS::PrimitiveString::create(vm, obj.get("value"sv).as_string()));
if (value_or_error.is_error()) {
warnln("Failed to load previous value for cell {}, leaving as undefined", position.to_cell_identifier(sheet));
value_or_error = JS::js_undefined();