mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:47:44 +00:00
LibJS: Convert Heap::allocate{,_without_realm}() to NonnullGCPtr
This commit is contained in:
parent
2a66fc6cae
commit
22089436ed
161 changed files with 367 additions and 370 deletions
|
@ -14,12 +14,12 @@ namespace Web::Fetch::Fetching {
|
|||
|
||||
JS::NonnullGCPtr<PendingResponse> PendingResponse::create(JS::VM& vm, JS::NonnullGCPtr<Infrastructure::Request> request)
|
||||
{
|
||||
return { *vm.heap().allocate_without_realm<PendingResponse>(request) };
|
||||
return vm.heap().allocate_without_realm<PendingResponse>(request);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<PendingResponse> PendingResponse::create(JS::VM& vm, JS::NonnullGCPtr<Infrastructure::Request> request, JS::NonnullGCPtr<Infrastructure::Response> response)
|
||||
{
|
||||
return { *vm.heap().allocate_without_realm<PendingResponse>(request, response) };
|
||||
return vm.heap().allocate_without_realm<PendingResponse>(request, response);
|
||||
}
|
||||
|
||||
PendingResponse::PendingResponse(JS::NonnullGCPtr<Infrastructure::Request> request, JS::GCPtr<Infrastructure::Response> response)
|
||||
|
|
|
@ -16,7 +16,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Headers>> Headers::construct_impl(JS::Realm
|
|||
auto& vm = realm.vm();
|
||||
|
||||
// The new Headers(init) constructor steps are:
|
||||
auto* headers = realm.heap().allocate<Headers>(realm, realm, Infrastructure::HeaderList::create(vm));
|
||||
auto headers = realm.heap().allocate<Headers>(realm, realm, Infrastructure::HeaderList::create(vm));
|
||||
|
||||
// 1. Set this’s guard to "none".
|
||||
headers->m_guard = Guard::None;
|
||||
|
@ -25,7 +25,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Headers>> Headers::construct_impl(JS::Realm
|
|||
if (init.has_value())
|
||||
TRY(headers->fill(*init));
|
||||
|
||||
return JS::NonnullGCPtr(*headers);
|
||||
return headers;
|
||||
}
|
||||
|
||||
Headers::Headers(JS::Realm& realm, JS::NonnullGCPtr<Infrastructure::HeaderList> header_list)
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Web::Fetch {
|
|||
|
||||
JS::NonnullGCPtr<HeadersIterator> HeadersIterator::create(Headers const& headers, JS::Object::PropertyKind iteration_kind)
|
||||
{
|
||||
return *headers.heap().allocate<HeadersIterator>(headers.realm(), headers, iteration_kind);
|
||||
return headers.heap().allocate<HeadersIterator>(headers.realm(), headers, iteration_kind);
|
||||
}
|
||||
|
||||
HeadersIterator::HeadersIterator(Headers const& headers, JS::Object::PropertyKind iteration_kind)
|
||||
|
|
|
@ -14,7 +14,7 @@ ConnectionTimingInfo::ConnectionTimingInfo() = default;
|
|||
|
||||
JS::NonnullGCPtr<ConnectionTimingInfo> ConnectionTimingInfo::create(JS::VM& vm)
|
||||
{
|
||||
return { *vm.heap().allocate_without_realm<ConnectionTimingInfo>() };
|
||||
return vm.heap().allocate_without_realm<ConnectionTimingInfo>();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::Fetch::Infrastructure {
|
|||
|
||||
JS::NonnullGCPtr<FetchAlgorithms> FetchAlgorithms::create(JS::VM& vm, Input input)
|
||||
{
|
||||
return { *vm.heap().allocate_without_realm<FetchAlgorithms>(move(input)) };
|
||||
return vm.heap().allocate_without_realm<FetchAlgorithms>(move(input));
|
||||
}
|
||||
|
||||
FetchAlgorithms::FetchAlgorithms(Input input)
|
||||
|
|
|
@ -15,7 +15,7 @@ FetchController::FetchController() = default;
|
|||
|
||||
JS::NonnullGCPtr<FetchController> FetchController::create(JS::VM& vm)
|
||||
{
|
||||
return { *vm.heap().allocate_without_realm<FetchController>() };
|
||||
return vm.heap().allocate_without_realm<FetchController>();
|
||||
}
|
||||
|
||||
void FetchController::visit_edges(JS::Cell::Visitor& visitor)
|
||||
|
|
|
@ -23,7 +23,7 @@ JS::NonnullGCPtr<FetchParams> FetchParams::create(JS::VM& vm, JS::NonnullGCPtr<R
|
|||
{
|
||||
auto algorithms = Infrastructure::FetchAlgorithms::create(vm, {});
|
||||
auto controller = Infrastructure::FetchController::create(vm);
|
||||
return { *vm.heap().allocate_without_realm<FetchParams>(request, algorithms, controller, timing_info) };
|
||||
return vm.heap().allocate_without_realm<FetchParams>(request, algorithms, controller, timing_info);
|
||||
}
|
||||
|
||||
void FetchParams::visit_edges(JS::Cell::Visitor& visitor)
|
||||
|
|
|
@ -14,7 +14,7 @@ FetchTimingInfo::FetchTimingInfo() = default;
|
|||
|
||||
JS::NonnullGCPtr<FetchTimingInfo> FetchTimingInfo::create(JS::VM& vm)
|
||||
{
|
||||
return { *vm.heap().allocate_without_realm<FetchTimingInfo>() };
|
||||
return vm.heap().allocate_without_realm<FetchTimingInfo>();
|
||||
}
|
||||
|
||||
void FetchTimingInfo::visit_edges(JS::Cell::Visitor& visitor)
|
||||
|
|
|
@ -34,7 +34,7 @@ WebIDL::ExceptionOr<Body> Body::clone() const
|
|||
|
||||
// FIXME: 1. Let « out1, out2 » be the result of teeing body’s stream.
|
||||
// FIXME: 2. Set body’s stream to out1.
|
||||
auto* out2 = vm.heap().allocate<Streams::ReadableStream>(realm, realm);
|
||||
auto out2 = vm.heap().allocate<Streams::ReadableStream>(realm, realm);
|
||||
|
||||
// 3. Return a body whose stream is out2 and other members are copied from body.
|
||||
return Body { JS::make_handle(out2), m_source, m_length };
|
||||
|
|
|
@ -48,7 +48,7 @@ ErrorOr<Header> Header::from_string_pair(StringView name, StringView value)
|
|||
|
||||
JS::NonnullGCPtr<HeaderList> HeaderList::create(JS::VM& vm)
|
||||
{
|
||||
return { *vm.heap().allocate_without_realm<HeaderList>() };
|
||||
return vm.heap().allocate_without_realm<HeaderList>();
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#header-list-contains
|
||||
|
|
|
@ -28,7 +28,7 @@ void Request::visit_edges(JS::Cell::Visitor& visitor)
|
|||
|
||||
JS::NonnullGCPtr<Request> Request::create(JS::VM& vm)
|
||||
{
|
||||
return { *vm.heap().allocate_without_realm<Request>(HeaderList::create(vm)) };
|
||||
return vm.heap().allocate_without_realm<Request>(HeaderList::create(vm));
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-request-url
|
||||
|
|
|
@ -29,7 +29,7 @@ void Response::visit_edges(JS::Cell::Visitor& visitor)
|
|||
|
||||
JS::NonnullGCPtr<Response> Response::create(JS::VM& vm)
|
||||
{
|
||||
return { *vm.heap().allocate_without_realm<Response>(HeaderList::create(vm)) };
|
||||
return vm.heap().allocate_without_realm<Response>(HeaderList::create(vm));
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#ref-for-concept-network-error%E2%91%A3
|
||||
|
@ -193,7 +193,7 @@ ErrorOr<JS::NonnullGCPtr<BasicFilteredResponse>> BasicFilteredResponse::create(J
|
|||
TRY(header_list->append(header));
|
||||
}
|
||||
|
||||
return { *vm.heap().allocate_without_realm<BasicFilteredResponse>(internal_response, header_list) };
|
||||
return vm.heap().allocate_without_realm<BasicFilteredResponse>(internal_response, header_list);
|
||||
}
|
||||
|
||||
BasicFilteredResponse::BasicFilteredResponse(JS::NonnullGCPtr<Response> internal_response, JS::NonnullGCPtr<HeaderList> header_list)
|
||||
|
@ -223,7 +223,7 @@ ErrorOr<JS::NonnullGCPtr<CORSFilteredResponse>> CORSFilteredResponse::create(JS:
|
|||
TRY(header_list->append(header));
|
||||
}
|
||||
|
||||
return { *vm.heap().allocate_without_realm<CORSFilteredResponse>(internal_response, header_list) };
|
||||
return vm.heap().allocate_without_realm<CORSFilteredResponse>(internal_response, header_list);
|
||||
}
|
||||
|
||||
CORSFilteredResponse::CORSFilteredResponse(JS::NonnullGCPtr<Response> internal_response, JS::NonnullGCPtr<HeaderList> header_list)
|
||||
|
@ -242,7 +242,7 @@ JS::NonnullGCPtr<OpaqueFilteredResponse> OpaqueFilteredResponse::create(JS::VM&
|
|||
{
|
||||
// An opaque filtered response is a filtered response whose type is "opaque", URL list is the empty list,
|
||||
// status is 0, status message is the empty byte sequence, header list is empty, and body is null.
|
||||
return { *vm.heap().allocate_without_realm<OpaqueFilteredResponse>(internal_response, HeaderList::create(vm)) };
|
||||
return vm.heap().allocate_without_realm<OpaqueFilteredResponse>(internal_response, HeaderList::create(vm));
|
||||
}
|
||||
|
||||
OpaqueFilteredResponse::OpaqueFilteredResponse(JS::NonnullGCPtr<Response> internal_response, JS::NonnullGCPtr<HeaderList> header_list)
|
||||
|
@ -261,7 +261,7 @@ JS::NonnullGCPtr<OpaqueRedirectFilteredResponse> OpaqueRedirectFilteredResponse:
|
|||
{
|
||||
// An opaque-redirect filtered response is a filtered response whose type is "opaqueredirect",
|
||||
// status is 0, status message is the empty byte sequence, header list is empty, and body is null.
|
||||
return { *vm.heap().allocate_without_realm<OpaqueRedirectFilteredResponse>(internal_response, HeaderList::create(vm)) };
|
||||
return vm.heap().allocate_without_realm<OpaqueRedirectFilteredResponse>(internal_response, HeaderList::create(vm));
|
||||
}
|
||||
|
||||
OpaqueRedirectFilteredResponse::OpaqueRedirectFilteredResponse(JS::NonnullGCPtr<Response> internal_response, JS::NonnullGCPtr<HeaderList> header_list)
|
||||
|
|
|
@ -77,7 +77,7 @@ JS::NonnullGCPtr<Request> Request::create(JS::Realm& realm, JS::NonnullGCPtr<Inf
|
|||
{
|
||||
// 1. Let requestObject be a new Request object with realm.
|
||||
// 2. Set requestObject’s request to request.
|
||||
auto* request_object = realm.heap().allocate<Request>(realm, realm, request);
|
||||
auto request_object = realm.heap().allocate<Request>(realm, realm, request);
|
||||
|
||||
// 3. Set requestObject’s headers to a new Headers object with realm, whose headers list is request’s headers list and guard is guard.
|
||||
request_object->m_headers = realm.heap().allocate<Headers>(realm, realm, request->header_list());
|
||||
|
@ -87,7 +87,7 @@ JS::NonnullGCPtr<Request> Request::create(JS::Realm& realm, JS::NonnullGCPtr<Inf
|
|||
request_object->m_signal = realm.heap().allocate<DOM::AbortSignal>(realm, realm);
|
||||
|
||||
// 5. Return requestObject.
|
||||
return JS::NonnullGCPtr { *request_object };
|
||||
return request_object;
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#dom-request
|
||||
|
@ -96,7 +96,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::construct_impl(JS::Realm
|
|||
auto& vm = realm.vm();
|
||||
|
||||
// Referred to as 'this' in the spec.
|
||||
auto request_object = JS::NonnullGCPtr { *realm.heap().allocate<Request>(realm, realm, Infrastructure::Request::create(vm)) };
|
||||
auto request_object = realm.heap().allocate<Request>(realm, realm, Infrastructure::Request::create(vm));
|
||||
|
||||
// 1. Let request be null.
|
||||
JS::GCPtr<Infrastructure::Request> input_request;
|
||||
|
|
|
@ -69,14 +69,14 @@ JS::NonnullGCPtr<Response> Response::create(JS::Realm& realm, JS::NonnullGCPtr<I
|
|||
{
|
||||
// 1. Let responseObject be a new Response object with realm.
|
||||
// 2. Set responseObject’s response to response.
|
||||
auto* response_object = realm.heap().allocate<Response>(realm, realm, response);
|
||||
auto response_object = realm.heap().allocate<Response>(realm, realm, response);
|
||||
|
||||
// 3. Set responseObject’s headers to a new Headers object with realm, whose headers list is response’s headers list and guard is guard.
|
||||
response_object->m_headers = realm.heap().allocate<Headers>(realm, realm, response->header_list());
|
||||
response_object->m_headers->set_guard(guard);
|
||||
|
||||
// 4. Return responseObject.
|
||||
return JS::NonnullGCPtr { *response_object };
|
||||
return response_object;
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#initialize-a-response
|
||||
|
@ -126,7 +126,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> Response::construct_impl(JS::Rea
|
|||
auto& vm = realm.vm();
|
||||
|
||||
// Referred to as 'this' in the spec.
|
||||
auto response_object = JS::NonnullGCPtr { *realm.heap().allocate<Response>(realm, realm, Infrastructure::Response::create(vm)) };
|
||||
auto response_object = realm.heap().allocate<Response>(realm, realm, Infrastructure::Response::create(vm));
|
||||
|
||||
// 1. Set this’s response to a new response.
|
||||
// NOTE: This is done at the beginning as the 'this' value Response object
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue