mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
Previously, the LibWeb bindings generator would output multiple per interface files like Prototype/Constructor/Namespace/GlobalMixin depending on the contents of that IDL file. This complicates the build system as it means that it does not know what files will be generated without knowledge of the contents of that IDL file. Instead, for each IDL file only generate a single Bindings/<IDLFile>.h and Bindings/<IDLFile>.cpp.
86 lines
2.4 KiB
C++
86 lines
2.4 KiB
C++
/*
|
||
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
||
*
|
||
* SPDX-License-Identifier: BSD-2-Clause
|
||
*/
|
||
|
||
#include <LibWeb/Bindings/DOMException.h>
|
||
#include <LibWeb/Bindings/Intrinsics.h>
|
||
#include <LibWeb/HTML/StructuredSerialize.h>
|
||
#include <LibWeb/WebIDL/DOMException.h>
|
||
|
||
namespace Web::WebIDL {
|
||
|
||
GC_DEFINE_ALLOCATOR(DOMException);
|
||
|
||
GC::Ref<DOMException> DOMException::create(JS::Realm& realm, FlyString name, Utf16String const& message)
|
||
{
|
||
return realm.create<DOMException>(realm, move(name), message);
|
||
}
|
||
|
||
GC::Ref<DOMException> DOMException::create(JS::Realm& realm)
|
||
{
|
||
return realm.create<DOMException>(realm);
|
||
}
|
||
|
||
GC::Ref<DOMException> DOMException::construct_impl(JS::Realm& realm, Utf16String const& message, FlyString name)
|
||
{
|
||
return realm.create<DOMException>(realm, move(name), message);
|
||
}
|
||
|
||
DOMException::DOMException(JS::Realm& realm, FlyString name, Utf16String const& message)
|
||
: PlatformObject(realm)
|
||
, ErrorData(realm.vm())
|
||
, m_name(move(name))
|
||
, m_message(message)
|
||
{
|
||
}
|
||
|
||
DOMException::DOMException(JS::Realm& realm)
|
||
: PlatformObject(realm)
|
||
, ErrorData(realm.vm())
|
||
{
|
||
}
|
||
|
||
DOMException::~DOMException() = default;
|
||
|
||
void DOMException::initialize(JS::Realm& realm)
|
||
{
|
||
WEB_SET_PROTOTYPE_FOR_INTERFACE(DOMException);
|
||
Base::initialize(realm);
|
||
}
|
||
|
||
void DOMException::visit_edges(Visitor& visitor)
|
||
{
|
||
Base::visit_edges(visitor);
|
||
ErrorData::visit_edges(visitor);
|
||
}
|
||
|
||
WebIDL::ExceptionOr<void> DOMException::serialization_steps(HTML::TransferDataEncoder& serialized, bool, HTML::SerializationMemory&)
|
||
{
|
||
// 1. Set serialized.[[Name]] to value’s name.
|
||
serialized.encode(m_name.to_string());
|
||
|
||
// 2. Set serialized.[[Message]] to value’s message.
|
||
serialized.encode(m_message.to_utf16_string());
|
||
|
||
// FIXME: 3. User agents should attach a serialized representation of any interesting accompanying data which are not yet specified, notably the stack property, to serialized.
|
||
|
||
return {};
|
||
}
|
||
|
||
WebIDL::ExceptionOr<void> DOMException::deserialization_steps(HTML::TransferDataDecoder& serialized, HTML::DeserializationMemory&)
|
||
{
|
||
// 1. Set value’s name to serialized.[[Name]].
|
||
m_name = serialized.decode<String>();
|
||
|
||
// 2. Set value’s message to serialized.[[Message]].
|
||
m_message = serialized.decode<Utf16String>();
|
||
|
||
// FIXME: 3. If any other data is attached to serialized, then deserialize and attach it to value.
|
||
|
||
return {};
|
||
}
|
||
|
||
}
|