mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 11:07:46 +00:00
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.
This commit is contained in:
parent
5db38d7ba1
commit
525f22d018
144 changed files with 656 additions and 672 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue