1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:27:35 +00:00

LibJS: Add side-effect-free version of Value::to_string()

There are now two API's on Value:

- Value::to_string(Interpreter&) -- may throw.
- Value::to_string_without_side_effects() -- will never throw.

These are some pretty big sweeping changes, so it's possible that I did
some part the wrong way. We'll work it out as we go. :^)

Fixes #2123.
This commit is contained in:
Andreas Kling 2020-05-15 13:39:24 +02:00
parent d8aa2a6997
commit c6ddbd1f3e
25 changed files with 285 additions and 112 deletions

View file

@ -161,8 +161,12 @@ JS::Value CanvasRenderingContext2DWrapper::fill_style_getter(JS::Interpreter& in
void CanvasRenderingContext2DWrapper::fill_style_setter(JS::Interpreter& interpreter, JS::Value value)
{
if (auto* impl = impl_from(interpreter))
impl->set_fill_style(value.to_string());
if (auto* impl = impl_from(interpreter)) {
auto string = value.to_string(interpreter);
if (interpreter.exception())
return;
impl->set_fill_style(string);
}
}
JS::Value CanvasRenderingContext2DWrapper::stroke_style_getter(JS::Interpreter& interpreter)
@ -175,8 +179,12 @@ JS::Value CanvasRenderingContext2DWrapper::stroke_style_getter(JS::Interpreter&
void CanvasRenderingContext2DWrapper::stroke_style_setter(JS::Interpreter& interpreter, JS::Value value)
{
if (auto* impl = impl_from(interpreter))
impl->set_stroke_style(value.to_string());
if (auto* impl = impl_from(interpreter)){
auto string = value.to_string(interpreter);
if (interpreter.exception())
return;
impl->set_stroke_style(string);
}
}
JS::Value CanvasRenderingContext2DWrapper::line_width_getter(JS::Interpreter& interpreter)