summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-03-06 14:17:01 +0100
committerAndreas Kling <kling@serenityos.org>2023-03-06 23:46:35 +0100
commit8a48246ed1a93983668a25f5b9b0af0e745e3f04 (patch)
treedd98425d119f79e0160bf19951f96a4a30276cbb
parent104be6c8ace8d56f66a89b570cdd615e74d22aa8 (diff)
downloadserenity-8a48246ed1a93983668a25f5b9b0af0e745e3f04.zip
Everywhere: Stop using NonnullRefPtrVector
This class had slightly confusing semantics and the added weirdness doesn't seem worth it just so we can say "." instead of "->" when iterating over a vector of NNRPs. This patch replaces NonnullRefPtrVector<T> with Vector<NNRP<T>>.
-rw-r--r--Kernel/Bus/PCI/Access.cpp11
-rw-r--r--Kernel/Bus/PCI/Access.h2
-rw-r--r--Kernel/Memory/MemoryManager.cpp12
-rw-r--r--Kernel/Memory/MemoryManager.h4
-rw-r--r--Kernel/Memory/PhysicalRegion.cpp4
-rw-r--r--Kernel/Memory/PhysicalRegion.h2
-rw-r--r--Kernel/Storage/ATA/AHCI/Port.cpp16
-rw-r--r--Kernel/Storage/ATA/AHCI/Port.h4
-rw-r--r--Kernel/Storage/NVMe/NVMeController.cpp16
-rw-r--r--Kernel/Storage/NVMe/NVMeInterruptQueue.cpp2
-rw-r--r--Kernel/Storage/NVMe/NVMeInterruptQueue.h2
-rw-r--r--Kernel/Storage/NVMe/NVMePollQueue.cpp2
-rw-r--r--Kernel/Storage/NVMe/NVMePollQueue.h2
-rw-r--r--Kernel/Storage/NVMe/NVMeQueue.cpp4
-rw-r--r--Kernel/Storage/NVMe/NVMeQueue.h8
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp34
-rw-r--r--Tests/LibSQL/TestSqlStatementParser.cpp40
-rw-r--r--Userland/Applets/ResourceGraph/main.cpp2
-rw-r--r--Userland/Applications/Assistant/Providers.cpp24
-rw-r--r--Userland/Applications/Assistant/Providers.h14
-rw-r--r--Userland/Applications/Assistant/main.cpp18
-rw-r--r--Userland/Applications/Browser/BookmarksBarWidget.cpp12
-rw-r--r--Userland/Applications/Browser/BookmarksBarWidget.h2
-rw-r--r--Userland/Applications/Browser/WindowActions.cpp4
-rw-r--r--Userland/Applications/Browser/WindowActions.h2
-rw-r--r--Userland/Applications/FileManager/DirectoryView.cpp14
-rw-r--r--Userland/Applications/FileManager/DirectoryView.h6
-rw-r--r--Userland/Applications/FileManager/main.cpp12
-rw-r--r--Userland/Applications/GamesSettings/CardSettingsWidget.cpp2
-rw-r--r--Userland/Applications/Mail/AccountHolder.cpp6
-rw-r--r--Userland/Applications/Mail/AccountHolder.h12
-rw-r--r--Userland/Applications/Mail/MailboxTreeModel.cpp4
-rw-r--r--Userland/Applications/PDFViewer/OutlineModel.cpp4
-rw-r--r--Userland/Applications/Piano/TrackControlsWidget.h2
-rw-r--r--Userland/Applications/PixelPaint/Image.cpp80
-rw-r--r--Userland/Applications/PixelPaint/Image.h2
-rw-r--r--Userland/Applications/PixelPaint/ImageEditor.cpp14
-rw-r--r--Userland/Applications/PixelPaint/ImageEditor.h4
-rw-r--r--Userland/Applications/PixelPaint/Tools/GuideTool.cpp8
-rw-r--r--Userland/Applications/PixelPaint/Tools/TextTool.cpp8
-rw-r--r--Userland/Applications/PixelPaint/Tools/TextTool.h2
-rw-r--r--Userland/Applications/Presenter/Slide.cpp6
-rw-r--r--Userland/Applications/Presenter/Slide.h4
-rw-r--r--Userland/Applications/Spreadsheet/ConditionalFormatting.h2
-rw-r--r--Userland/Applications/Spreadsheet/ExportDialog.cpp2
-rw-r--r--Userland/Applications/Spreadsheet/HelpWindow.cpp2
-rw-r--r--Userland/Applications/Spreadsheet/ImportDialog.cpp10
-rw-r--r--Userland/Applications/Spreadsheet/ImportDialog.h2
-rw-r--r--Userland/Applications/Spreadsheet/JSIntegration.cpp8
-rw-r--r--Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp12
-rw-r--r--Userland/Applications/Spreadsheet/SpreadsheetWidget.h4
-rw-r--r--Userland/Applications/Spreadsheet/Workbook.cpp2
-rw-r--r--Userland/Applications/Spreadsheet/Workbook.h8
-rw-r--r--Userland/Applications/Spreadsheet/main.cpp2
-rw-r--r--Userland/Applications/SystemMonitor/ProcessModel.cpp2
-rw-r--r--Userland/Applications/SystemMonitor/ProcessModel.h4
-rw-r--r--Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.cpp2
-rw-r--r--Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.h2
-rw-r--r--Userland/DevTools/HackStudio/HackStudioWidget.cpp42
-rw-r--r--Userland/DevTools/HackStudio/HackStudioWidget.h6
-rw-r--r--Userland/Games/Hearts/Game.cpp30
-rw-r--r--Userland/Games/Hearts/Game.h4
-rw-r--r--Userland/Games/Hearts/Player.cpp8
-rw-r--r--Userland/Games/Hearts/Player.h4
-rw-r--r--Userland/Games/Snake/Game.cpp6
-rw-r--r--Userland/Games/Snake/Game.h4
-rw-r--r--Userland/Games/Solitaire/Game.cpp48
-rw-r--r--Userland/Games/Solitaire/Game.h6
-rw-r--r--Userland/Games/Spider/Game.cpp42
-rw-r--r--Userland/Games/Spider/Game.h2
-rw-r--r--Userland/Libraries/LibCards/Card.cpp6
-rw-r--r--Userland/Libraries/LibCards/Card.h4
-rw-r--r--Userland/Libraries/LibCards/CardGame.cpp12
-rw-r--r--Userland/Libraries/LibCards/CardGame.h12
-rw-r--r--Userland/Libraries/LibCards/CardStack.cpp40
-rw-r--r--Userland/Libraries/LibCards/CardStack.h6
-rw-r--r--Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp22
-rw-r--r--Userland/Libraries/LibCore/Object.cpp6
-rw-r--r--Userland/Libraries/LibCore/Object.h8
-rw-r--r--Userland/Libraries/LibCpp/AST.cpp68
-rw-r--r--Userland/Libraries/LibCpp/AST.h68
-rw-r--r--Userland/Libraries/LibCpp/Parser.cpp24
-rw-r--r--Userland/Libraries/LibCpp/Parser.h12
-rw-r--r--Userland/Libraries/LibDSP/Track.cpp30
-rw-r--r--Userland/Libraries/LibDSP/Track.h10
-rw-r--r--Userland/Libraries/LibDesktop/Launcher.cpp4
-rw-r--r--Userland/Libraries/LibDesktop/Launcher.h2
-rw-r--r--Userland/Libraries/LibELF/DynamicLinker.cpp24
-rw-r--r--Userland/Libraries/LibGUI/GML/AST.h30
-rw-r--r--Userland/Libraries/LibGUI/GML/Parser.cpp2
-rw-r--r--Userland/Libraries/LibGUI/Menubar.h2
-rw-r--r--Userland/Libraries/LibGUI/Statusbar.cpp50
-rw-r--r--Userland/Libraries/LibGUI/Statusbar.h2
-rw-r--r--Userland/Libraries/LibGUI/TextEditor.h2
-rw-r--r--Userland/Libraries/LibGUI/TreeViewModel.cpp4
-rw-r--r--Userland/Libraries/LibGUI/TreeViewModel.h12
-rw-r--r--Userland/Libraries/LibGUI/Widget.cpp10
-rw-r--r--Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp4
-rw-r--r--Userland/Libraries/LibGUI/Wizards/WizardDialog.h2
-rw-r--r--Userland/Libraries/LibGfx/AntiAliasingPainter.cpp40
-rw-r--r--Userland/Libraries/LibGfx/Painter.cpp26
-rw-r--r--Userland/Libraries/LibGfx/Path.cpp82
-rw-r--r--Userland/Libraries/LibGfx/Path.h8
-rw-r--r--Userland/Libraries/LibIDL/IDLParser.cpp4
-rw-r--r--Userland/Libraries/LibIDL/Types.cpp6
-rw-r--r--Userland/Libraries/LibIDL/Types.h32
-rw-r--r--Userland/Libraries/LibIPC/Connection.cpp2
-rw-r--r--Userland/Libraries/LibIPC/Message.h3
-rw-r--r--Userland/Libraries/LibJS/AST.cpp130
-rw-r--r--Userland/Libraries/LibJS/AST.h62
-rw-r--r--Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp42
-rw-r--r--Userland/Libraries/LibJS/Parser.cpp62
-rw-r--r--Userland/Libraries/LibJS/SourceTextModule.cpp20
-rw-r--r--Userland/Libraries/LibManual/PageNode.cpp2
-rw-r--r--Userland/Libraries/LibManual/SectionNode.h2
-rw-r--r--Userland/Libraries/LibPDF/Document.cpp8
-rw-r--r--Userland/Libraries/LibPDF/Document.h8
-rw-r--r--Userland/Libraries/LibPDF/Renderer.cpp2
-rw-r--r--Userland/Libraries/LibSQL/AST/AST.h62
-rw-r--r--Userland/Libraries/LibSQL/AST/CreateTable.cpp12
-rw-r--r--Userland/Libraries/LibSQL/AST/Describe.cpp4
-rw-r--r--Userland/Libraries/LibSQL/AST/Expression.cpp2
-rw-r--r--Userland/Libraries/LibSQL/AST/Insert.cpp8
-rw-r--r--Userland/Libraries/LibSQL/AST/Parser.cpp26
-rw-r--r--Userland/Libraries/LibSQL/AST/Select.cpp26
-rw-r--r--Userland/Libraries/LibSQL/Database.cpp2
-rw-r--r--Userland/Libraries/LibSQL/Meta.cpp4
-rw-r--r--Userland/Libraries/LibSQL/Meta.h12
-rw-r--r--Userland/Libraries/LibTest/TestSuite.cpp24
-rw-r--r--Userland/Libraries/LibTest/TestSuite.h6
-rw-r--r--Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp4
-rw-r--r--Userland/Libraries/LibWeb/CSS/CSSStyleRule.h8
-rw-r--r--Userland/Libraries/LibWeb/CSS/MediaList.cpp14
-rw-r--r--Userland/Libraries/LibWeb/CSS/MediaList.h6
-rw-r--r--Userland/Libraries/LibWeb/CSS/MediaQuery.cpp2
-rw-r--r--Userland/Libraries/LibWeb/CSS/MediaQuery.h2
-rw-r--r--Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp8
-rw-r--r--Userland/Libraries/LibWeb/CSS/MediaQueryList.h6
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp16
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.h12
-rw-r--r--Userland/Libraries/LibWeb/CSS/Selector.cpp4
-rw-r--r--Userland/Libraries/LibWeb/CSS/Selector.h4
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleComputer.cpp14
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleComputer.h2
-rw-r--r--Userland/Libraries/LibWeb/HTML/Path2D.cpp4
-rw-r--r--Userland/Libraries/LibWeb/HTML/Window.h4
-rw-r--r--Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.cpp12
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/WebIDL/OverloadResolution.cpp4
-rw-r--r--Userland/Services/AudioServer/ConnectionFromClient.cpp2
-rw-r--r--Userland/Services/SystemServer/main.cpp6
-rw-r--r--Userland/Services/WindowServer/Screen.cpp36
-rw-r--r--Userland/Services/WindowServer/Screen.h14
-rw-r--r--Userland/Shell/AST.cpp128
-rw-r--r--Userland/Shell/AST.h36
-rw-r--r--Userland/Shell/Builtin.cpp8
-rw-r--r--Userland/Shell/Execution.h2
-rw-r--r--Userland/Shell/Formatter.cpp10
-rw-r--r--Userland/Shell/ImmediateFunctions.cpp158
-rw-r--r--Userland/Shell/NodeVisitor.cpp10
-rw-r--r--Userland/Shell/Parser.cpp18
-rw-r--r--Userland/Shell/Parser.h4
-rw-r--r--Userland/Shell/PosixParser.cpp14
-rw-r--r--Userland/Shell/PosixParser.h2
-rw-r--r--Userland/Shell/Shell.cpp40
-rw-r--r--Userland/Shell/Shell.h12
-rw-r--r--Userland/Shell/SyntaxHighlighter.cpp2
-rw-r--r--Userland/Utilities/test-pthread.cpp24
168 files changed, 1280 insertions, 1280 deletions
diff --git a/Kernel/Bus/PCI/Access.cpp b/Kernel/Bus/PCI/Access.cpp
index 322471a929..5a0318f42f 100644
--- a/Kernel/Bus/PCI/Access.cpp
+++ b/Kernel/Bus/PCI/Access.cpp
@@ -183,7 +183,7 @@ ErrorOr<void> Access::fast_enumerate(Function<void(DeviceIdentifier const&)>& ca
{
// Note: We hold the m_access_lock for a brief moment just to ensure we get
// a complete Vector in case someone wants to mutate it.
- NonnullRefPtrVector<DeviceIdentifier> device_identifiers;
+ Vector<NonnullRefPtr<DeviceIdentifier>> device_identifiers;
{
SpinlockLocker locker(m_access_lock);
VERIFY(!m_device_identifiers.is_empty());
@@ -198,10 +198,11 @@ ErrorOr<void> Access::fast_enumerate(Function<void(DeviceIdentifier const&)>& ca
DeviceIdentifier const& Access::get_device_identifier(Address address) const
{
for (auto& device_identifier : m_device_identifiers) {
- if (device_identifier.address().domain() == address.domain()
- && device_identifier.address().bus() == address.bus()
- && device_identifier.address().device() == address.device()
- && device_identifier.address().function() == address.function()) {
+ auto device_address = device_identifier->address();
+ if (device_address.domain() == address.domain()
+ && device_address.bus() == address.bus()
+ && device_address.device() == address.device()
+ && device_address.function() == address.function()) {
return device_identifier;
}
}
diff --git a/Kernel/Bus/PCI/Access.h b/Kernel/Bus/PCI/Access.h
index 4ee8540771..795e02bfaa 100644
--- a/Kernel/Bus/PCI/Access.h
+++ b/Kernel/Bus/PCI/Access.h
@@ -62,6 +62,6 @@ private:
mutable Spinlock<LockRank::None> m_scan_lock {};
HashMap<u32, NonnullOwnPtr<PCI::HostController>> m_host_controllers;
- NonnullRefPtrVector<DeviceIdentifier> m_device_identifiers;
+ Vector<NonnullRefPtr<DeviceIdentifier>> m_device_identifiers;
};
}
diff --git a/Kernel/Memory/MemoryManager.cpp b/Kernel/Memory/MemoryManager.cpp
index 8dd49c1b99..ad5b14365d 100644
--- a/Kernel/Memory/MemoryManager.cpp
+++ b/Kernel/Memory/MemoryManager.cpp
@@ -785,18 +785,18 @@ ErrorOr<NonnullOwnPtr<Memory::Region>> MemoryManager::allocate_dma_buffer_page(S
return allocate_dma_buffer_page(name, access, dma_buffer_page);
}
-ErrorOr<NonnullOwnPtr<Memory::Region>> MemoryManager::allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access, NonnullRefPtrVector<Memory::PhysicalPage>& dma_buffer_pages)
+ErrorOr<NonnullOwnPtr<Memory::Region>> MemoryManager::allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access, Vector<NonnullRefPtr<Memory::PhysicalPage>>& dma_buffer_pages)
{
VERIFY(!(size % PAGE_SIZE));
dma_buffer_pages = TRY(allocate_contiguous_physical_pages(size));
// Do not enable Cache for this region as physical memory transfers are performed (Most architectures have this behaviour by default)
- return allocate_kernel_region(dma_buffer_pages.first().paddr(), size, name, access, Region::Cacheable::No);
+ return allocate_kernel_region(dma_buffer_pages.first()->paddr(), size, name, access, Region::Cacheable::No);
}
ErrorOr<NonnullOwnPtr<Memory::Region>> MemoryManager::allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access)
{
VERIFY(!(size % PAGE_SIZE));
- NonnullRefPtrVector<Memory::PhysicalPage> dma_buffer_pages;
+ Vector<NonnullRefPtr<Memory::PhysicalPage>> dma_buffer_pages;
return allocate_dma_buffer_pages(size, name, access, dma_buffer_pages);
}
@@ -1010,12 +1010,12 @@ ErrorOr<NonnullRefPtr<PhysicalPage>> MemoryManager::allocate_physical_page(Shoul
});
}
-ErrorOr<NonnullRefPtrVector<PhysicalPage>> MemoryManager::allocate_contiguous_physical_pages(size_t size)
+ErrorOr<Vector<NonnullRefPtr<PhysicalPage>>> MemoryManager::allocate_contiguous_physical_pages(size_t size)
{
VERIFY(!(size % PAGE_SIZE));
size_t page_count = ceil_div(size, static_cast<size_t>(PAGE_SIZE));
- auto physical_pages = TRY(m_global_data.with([&](auto& global_data) -> ErrorOr<NonnullRefPtrVector<PhysicalPage>> {
+ auto physical_pages = TRY(m_global_data.with([&](auto& global_data) -> ErrorOr<Vector<NonnullRefPtr<PhysicalPage>>> {
// We need to make sure we don't touch pages that we have committed to
if (global_data.system_memory_info.physical_pages_uncommitted < page_count)
return ENOMEM;
@@ -1033,7 +1033,7 @@ ErrorOr<NonnullRefPtrVector<PhysicalPage>> MemoryManager::allocate_contiguous_ph
}));
{
- auto cleanup_region = TRY(MM.allocate_kernel_region(physical_pages[0].paddr(), PAGE_SIZE * page_count, {}, Region::Access::Read | Region::Access::Write));
+ auto cleanup_region = TRY(MM.allocate_kernel_region(physical_pages[0]->paddr(), PAGE_SIZE * page_count, {}, Region::Access::Read | Region::Access::Write));
memset(cleanup_region->vaddr().as_ptr(), 0, PAGE_SIZE * page_count);
}
return physical_pages;
diff --git a/Kernel/Memory/MemoryManager.h b/Kernel/Memory/MemoryManager.h
index 10537c8064..8ec09e9786 100644
--- a/Kernel/Memory/MemoryManager.h
+++ b/Kernel/Memory/MemoryManager.h
@@ -166,13 +166,13 @@ public:
NonnullRefPtr<PhysicalPage> allocate_committed_physical_page(Badge<CommittedPhysicalPageSet>, ShouldZeroFill = ShouldZeroFill::Yes);
ErrorOr<NonnullRefPtr<PhysicalPage>> allocate_physical_page(ShouldZeroFill = ShouldZeroFill::Yes, bool* did_purge = nullptr);
- ErrorOr<NonnullRefPtrVector<PhysicalPage>> allocate_contiguous_physical_pages(size_t size);
+ ErrorOr<Vector<NonnullRefPtr<PhysicalPage>>> allocate_contiguous_physical_pages(size_t size);
void deallocate_physical_page(PhysicalAddress);
ErrorOr<NonnullOwnPtr<Region>> allocate_contiguous_kernel_region(size_t, StringView name, Region::Access access, Region::Cacheable = Region::Cacheable::Yes);
ErrorOr<NonnullOwnPtr<Memory::Region>> allocate_dma_buffer_page(StringView name, Memory::Region::Access access, RefPtr<Memory::PhysicalPage>& dma_buffer_page);
ErrorOr<NonnullOwnPtr<Memory::Region>> allocate_dma_buffer_page(StringView name, Memory::Region::Access access);
- ErrorOr<NonnullOwnPtr<Memory::Region>> allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access, NonnullRefPtrVector<Memory::PhysicalPage>& dma_buffer_pages);
+ ErrorOr<NonnullOwnPtr<Memory::Region>> allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access, Vector<NonnullRefPtr<Memory::PhysicalPage>>& dma_buffer_pages);
ErrorOr<NonnullOwnPtr<Memory::Region>> allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access);
ErrorOr<NonnullOwnPtr<Region>> allocate_kernel_region(size_t, StringView name, Region::Access access, AllocationStrategy strategy = AllocationStrategy::Reserve, Region::Cacheable = Region::Cacheable::Yes);
ErrorOr<NonnullOwnPtr<Region>> allocate_kernel_region(PhysicalAddress, size_t, StringView name, Region::Access access, Region::Cacheable = Region::Cacheable::Yes);
diff --git a/Kernel/Memory/PhysicalRegion.cpp b/Kernel/Memory/PhysicalRegion.cpp
index 6437f96d90..26590ff3f1 100644
--- a/Kernel/Memory/PhysicalRegion.cpp
+++ b/Kernel/Memory/PhysicalRegion.cpp
@@ -75,7 +75,7 @@ OwnPtr<PhysicalRegion> PhysicalRegion::try_take_pages_from_beginning(size_t page
return try_create(taken_lower, taken_upper);
}
-NonnullRefPtrVector<PhysicalPage> PhysicalRegion::take_contiguous_free_pages(size_t count)
+Vector<NonnullRefPtr<PhysicalPage>> PhysicalRegion::take_contiguous_free_pages(size_t count)
{
auto rounded_page_count = next_power_of_two(count);
auto order = count_trailing_zeroes(rounded_page_count);
@@ -95,7 +95,7 @@ NonnullRefPtrVector<PhysicalPage> PhysicalRegion::take_contiguous_free_pages(siz
if (!page_base.has_value())
return {};
- NonnullRefPtrVector<PhysicalPage> physical_pages;
+ Vector<NonnullRefPtr<PhysicalPage>> physical_pages;
physical_pages.ensure_capacity(count);
for (size_t i = 0; i < count; ++i)
diff --git a/Kernel/Memory/PhysicalRegion.h b/Kernel/Memory/PhysicalRegion.h
index 31ffdba97b..0a124b9740 100644
--- a/Kernel/Memory/PhysicalRegion.h
+++ b/Kernel/Memory/PhysicalRegion.h
@@ -34,7 +34,7 @@ public:
OwnPtr<PhysicalRegion> try_take_pages_from_beginning(size_t);
RefPtr<PhysicalPage> take_free_page();
- NonnullRefPtrVector<PhysicalPage> take_contiguous_free_pages(size_t count);
+ Vector<NonnullRefPtr<PhysicalPage>> take_contiguous_free_pages(size_t count);
void return_page(PhysicalAddress);
private:
diff --git a/Kernel/Storage/ATA/AHCI/Port.cpp b/Kernel/Storage/ATA/AHCI/Port.cpp
index 042ea248ad..416ada1946 100644
--- a/Kernel/Storage/ATA/AHCI/Port.cpp
+++ b/Kernel/Storage/ATA/AHCI/Port.cpp
@@ -210,7 +210,7 @@ void AHCIPort::eject()
auto unused_command_header = try_to_find_unused_command_header();
VERIFY(unused_command_header.has_value());
auto* command_list_entries = (volatile AHCI::CommandHeader*)m_command_list_region->vaddr().as_ptr();
- command_list_entries[unused_command_header.value()].ctba = m_command_table_pages[unused_command_header.value()].paddr().get();
+ command_list_entries[unused_command_header.value()].ctba = m_command_table_pages[unused_command_header.value()]->paddr().get();
command_list_entries[unused_command_header.value()].ctbau = 0;
command_list_entries[unused_command_header.value()].prdbc = 0;
command_list_entries[unused_command_header.value()].prdtl = 0;
@@ -221,7 +221,7 @@ void AHCIPort::eject()
// handshake error bit in PxSERR register if CFL is incorrect.
command_list_entries[unused_command_header.value()].attributes = (size_t)FIS::DwordCount::RegisterHostToDevice | AHCI::CommandHeaderAttributes::P | AHCI::CommandHeaderAttributes::C | AHCI::CommandHeaderAttributes::A;
- auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()].paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)).value(), "AHCI Command Table"sv, Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No).release_value();
+ auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()]->paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)).value(), "AHCI Command Table"sv, Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No).release_value();
auto& command_table = *(volatile AHCI::CommandTable*)command_table_region->vaddr().as_ptr();
memset(const_cast<u8*>(command_table.command_fis), 0, 64);
auto& fis = *(volatile FIS::HostToDevice::Register*)command_table.command_fis;
@@ -497,7 +497,7 @@ Optional<AsyncDeviceRequest::RequestResult> AHCIPort::prepare_and_set_scatter_li
VERIFY(m_lock.is_locked());
VERIFY(request.block_count() > 0);
- NonnullRefPtrVector<Memory::PhysicalPage> allocated_dma_regions;
+ Vector<NonnullRefPtr<Memory::PhysicalPage>> allocated_dma_regions;
for (size_t index = 0; index < calculate_descriptors_count(request.block_count()); index++) {
allocated_dma_regions.append(m_dma_buffers.at(index));
}
@@ -578,7 +578,7 @@ bool AHCIPort::access_device(AsyncBlockDeviceRequest::RequestType direction, u64
auto unused_command_header = try_to_find_unused_command_header();
VERIFY(unused_command_header.has_value());
auto* command_list_entries = (volatile AHCI::CommandHeader*)m_command_list_region->vaddr().as_ptr();
- command_list_entries[unused_command_header.value()].ctba = m_command_table_pages[unused_command_header.value()].paddr().get();
+ command_list_entries[unused_command_header.value()].ctba = m_command_table_pages[unused_command_header.value()]->paddr().get();
command_list_entries[unused_command_header.value()].ctbau = 0;
command_list_entries[unused_command_header.value()].prdbc = 0;
command_list_entries[unused_command_header.value()].prdtl = m_current_scatter_list->scatters_count();
@@ -591,7 +591,7 @@ bool AHCIPort::access_device(AsyncBlockDeviceRequest::RequestType direction, u64
dbgln_if(AHCI_DEBUG, "AHCI Port {}: CLE: ctba={:#08x}, ctbau={:#08x}, prdbc={:#08x}, prdtl={:#04x}, attributes={:#04x}", representative_port_index(), (u32)command_list_entries[unused_command_header.value()].ctba, (u32)command_list_entries[unused_command_header.value()].ctbau, (u32)command_list_entries[unused_command_header.value()].prdbc, (u16)command_list_entries[unused_command_header.value()].prdtl, (u16)command_list_entries[unused_command_header.value()].attributes);
- auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()].paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)).value(), "AHCI Command Table"sv, Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No).release_value();
+ auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()]->paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)).value(), "AHCI Command Table"sv, Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No).release_value();
auto& command_table = *(volatile AHCI::CommandTable*)command_table_region->vaddr().as_ptr();
dbgln_if(AHCI_DEBUG, "AHCI Port {}: Allocated command table at {}", representative_port_index(), command_table_region->vaddr());
@@ -652,7 +652,7 @@ bool AHCIPort::access_device(AsyncBlockDeviceRequest::RequestType direction, u64
mark_command_header_ready_to_process(unused_command_header.value());
full_memory_barrier();
- dbgln_if(AHCI_DEBUG, "AHCI Port {}: Do a {}, lba {}, block count {} @ {}, ended", representative_port_index(), direction == AsyncBlockDeviceRequest::RequestType::Write ? "write" : "read", lba, block_count, m_dma_buffers[0].paddr());
+ dbgln_if(AHCI_DEBUG, "AHCI Port {}: Do a {}, lba {}, block count {} @ {}, ended", representative_port_index(), direction == AsyncBlockDeviceRequest::RequestType::Write ? "write" : "read", lba, block_count, m_dma_buffers[0]->paddr());
return true;
}
@@ -670,7 +670,7 @@ bool AHCIPort::identify_device()
auto unused_command_header = try_to_find_unused_command_header();
VERIFY(unused_command_header.has_value());
auto* command_list_entries = (volatile AHCI::CommandHeader*)m_command_list_region->vaddr().as_ptr();
- command_list_entries[unused_command_header.value()].ctba = m_command_table_pages[unused_command_header.value()].paddr().get();
+ command_list_entries[unused_command_header.value()].ctba = m_command_table_pages[unused_command_header.value()]->paddr().get();
command_list_entries[unused_command_header.value()].ctbau = 0;
command_list_entries[unused_command_header.value()].prdbc = 512;
command_list_entries[unused_command_header.value()].prdtl = 1;
@@ -679,7 +679,7 @@ bool AHCIPort::identify_device()
// QEMU doesn't care if we don't set the correct CFL field in this register, real hardware will set an handshake error bit in PxSERR register.
command_list_entries[unused_command_header.value()].attributes = (size_t)FIS::DwordCount::RegisterHostToDevice | AHCI::CommandHeaderAttributes::P;
- auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()].paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)).value(), "AHCI Command Table"sv, Memory::Region::Access::ReadWrite).release_value();
+ auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()]->paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)).value(), "AHCI Command Table"sv, Memory::Region::Access::ReadWrite).release_value();
auto& command_table = *(volatile AHCI::CommandTable*)command_table_region->vaddr().as_ptr();
memset(const_cast<u8*>(command_table.command_fis), 0, 64);
command_table.descriptors[0].base_high = 0;
diff --git a/Kernel/Storage/ATA/AHCI/Port.h b/Kernel/Storage/ATA/AHCI/Port.h
index 21df462b6a..ec63bc1cfa 100644
--- a/Kernel/Storage/ATA/AHCI/Port.h
+++ b/Kernel/Storage/ATA/AHCI/Port.h
@@ -112,8 +112,8 @@ private:
mutable bool m_wait_for_completion { false };
- NonnullRefPtrVector<Memory::PhysicalPage> m_dma_buffers;
- NonnullRefPtrVector<Memory::PhysicalPage> m_command_table_pages;
+ Vector<NonnullRefPtr<Memory::PhysicalPage>> m_dma_buffers;
+ Vector<NonnullRefPtr<Memory::PhysicalPage>> m_command_table_pages;
RefPtr<Memory::PhysicalPage> m_command_list_page;
OwnPtr<Memory::Region> m_command_list_region;
RefPtr<Memory::PhysicalPage> m_fis_receive_page;
diff --git a/Kernel/Storage/NVMe/NVMeController.cpp b/Kernel/Storage/NVMe/NVMeController.cpp
index e5752380af..7f9335dfe0 100644
--- a/Kernel/Storage/NVMe/NVMeController.cpp
+++ b/Kernel/Storage/NVMe/NVMeController.cpp
@@ -256,9 +256,9 @@ UNMAP_AFTER_INIT ErrorOr<void> NVMeController::create_admin_queue(Optional<u8> i
{
auto qdepth = get_admin_q_dept();
OwnPtr<Memory::Region> cq_dma_region;
- NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_pages;
+ Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_pages;
OwnPtr<Memory::Region> sq_dma_region;
- NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_pages;
+ Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_pages;
auto cq_size = round_up_to_power_of_two(CQ_SIZE(qdepth), 4096);
auto sq_size = round_up_to_power_of_two(SQ_SIZE(qdepth), 4096);
if (!reset_controller()) {
@@ -280,8 +280,8 @@ UNMAP_AFTER_INIT ErrorOr<void> NVMeController::create_admin_queue(Optional<u8> i
}
auto doorbell_regs = TRY(Memory::map_typed_writable<DoorbellRegister volatile>(PhysicalAddress(m_bar + REG_SQ0TDBL_START)));
- m_controller_regs->acq = reinterpret_cast<u64>(AK::convert_between_host_and_little_endian(cq_dma_pages.first().paddr().as_ptr()));
- m_controller_regs->asq = reinterpret_cast<u64>(AK::convert_between_host_and_little_endian(sq_dma_pages.first().paddr().as_ptr()));
+ m_controller_regs->acq = reinterpret_cast<u64>(AK::convert_between_host_and_little_endian(cq_dma_pages.first()->paddr().as_ptr()));
+ m_controller_regs->asq = reinterpret_cast<u64>(AK::convert_between_host_and_little_endian(sq_dma_pages.first()->paddr().as_ptr()));
if (!start_controller()) {
dmesgln_pci(*this, "Failed to restart the NVMe controller");
@@ -297,9 +297,9 @@ UNMAP_AFTER_INIT ErrorOr<void> NVMeController::create_admin_queue(Optional<u8> i
UNMAP_AFTER_INIT ErrorOr<void> NVMeController::create_io_queue(u8 qid, Optional<u8> irq)
{
OwnPtr<Memory::Region> cq_dma_region;
- NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_pages;
+ Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_pages;
OwnPtr<Memory::Region> sq_dma_region;
- NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_pages;
+ Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_pages;
auto cq_size = round_up_to_power_of_two(CQ_SIZE(IO_QUEUE_SIZE), 4096);
auto sq_size = round_up_to_power_of_two(SQ_SIZE(IO_QUEUE_SIZE), 4096);
@@ -320,7 +320,7 @@ UNMAP_AFTER_INIT ErrorOr<void> NVMeController::create_io_queue(u8 qid, Optional<
{
NVMeSubmission sub {};
sub.op = OP_ADMIN_CREATE_COMPLETION_QUEUE;
- sub.create_cq.prp1 = reinterpret_cast<u64>(AK::convert_between_host_and_little_endian(cq_dma_pages.first().paddr().as_ptr()));
+ sub.create_cq.prp1 = reinterpret_cast<u64>(AK::convert_between_host_and_little_endian(cq_dma_pages.first()->paddr().as_ptr()));
sub.create_cq.cqid = qid;
// The queue size is 0 based
sub.create_cq.qsize = AK::convert_between_host_and_little_endian(IO_QUEUE_SIZE - 1);
@@ -335,7 +335,7 @@ UNMAP_AFTER_INIT ErrorOr<void> NVMeController::create_io_queue(u8 qid, Optional<
{
NVMeSubmission sub {};
sub.op = OP_ADMIN_CREATE_SUBMISSION_QUEUE;
- sub.create_sq.prp1 = reinterpret_cast<u64>(AK::convert_between_host_and_little_endian(sq_dma_pages.first().paddr().as_ptr()));
+ sub.create_sq.prp1 = reinterpret_cast<u64>(AK::convert_between_host_and_little_endian(sq_dma_pages.first()->paddr().as_ptr()));
sub.create_sq.sqid = qid;
// The queue size is 0 based
sub.create_sq.qsize = AK::convert_between_host_and_little_endian(IO_QUEUE_SIZE - 1);
diff --git a/Kernel/Storage/NVMe/NVMeInterruptQueue.cpp b/Kernel/Storage/NVMe/NVMeInterruptQueue.cpp
index 438c8335ef..7b4aeaf46b 100644
--- a/Kernel/Storage/NVMe/NVMeInterruptQueue.cpp
+++ b/Kernel/Storage/NVMe/NVMeInterruptQueue.cpp
@@ -11,7 +11,7 @@
namespace Kernel {
-UNMAP_AFTER_INIT NVMeInterruptQueue::NVMeInterruptQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u8 irq, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs)
+UNMAP_AFTER_INIT NVMeInterruptQueue::NVMeInterruptQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u8 irq, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs)
: NVMeQueue(move(rw_dma_region), rw_dma_page, qid, q_depth, move(cq_dma_region), cq_dma_page, move(sq_dma_region), sq_dma_page, move(db_regs))
, IRQHandler(irq)
{
diff --git a/Kernel/Storage/NVMe/NVMeInterruptQueue.h b/Kernel/Storage/NVMe/NVMeInterruptQueue.h
index e92168b535..f8b3632af2 100644
--- a/Kernel/Storage/NVMe/NVMeInterruptQueue.h
+++ b/Kernel/Storage/NVMe/NVMeInterruptQueue.h
@@ -13,7 +13,7 @@ namespace Kernel {
class NVMeInterruptQueue : public NVMeQueue
, public IRQHandler {
public:
- NVMeInterruptQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u8 irq, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs);
+ NVMeInterruptQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u8 irq, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs);
void submit_sqe(NVMeSubmission& submission) override;
virtual ~NVMeInterruptQueue() override {};
diff --git a/Kernel/Storage/NVMe/NVMePollQueue.cpp b/Kernel/Storage/NVMe/NVMePollQueue.cpp
index 7dce2ca8c0..e8ab70e18a 100644
--- a/Kernel/Storage/NVMe/NVMePollQueue.cpp
+++ b/Kernel/Storage/NVMe/NVMePollQueue.cpp
@@ -10,7 +10,7 @@
#include <Kernel/Storage/NVMe/NVMePollQueue.h>
namespace Kernel {
-UNMAP_AFTER_INIT NVMePollQueue::NVMePollQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs)
+UNMAP_AFTER_INIT NVMePollQueue::NVMePollQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs)
: NVMeQueue(move(rw_dma_region), rw_dma_page, qid, q_depth, move(cq_dma_region), cq_dma_page, move(sq_dma_region), sq_dma_page, move(db_regs))
{
}
diff --git a/Kernel/Storage/NVMe/NVMePollQueue.h b/Kernel/Storage/NVMe/NVMePollQueue.h
index f1e24402c9..4080d6c76f 100644
--- a/Kernel/Storage/NVMe/NVMePollQueue.h
+++ b/Kernel/Storage/NVMe/NVMePollQueue.h
@@ -12,7 +12,7 @@ namespace Kernel {
class NVMePollQueue : public NVMeQueue {
public:
- NVMePollQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs);
+ NVMePollQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs);
void submit_sqe(NVMeSubmission& submission) override;
virtual ~NVMePollQueue() override {};
diff --git a/Kernel/Storage/NVMe/NVMeQueue.cpp b/Kernel/Storage/NVMe/NVMeQueue.cpp
index 2b60aac22a..04408f4dc7 100644
--- a/Kernel/Storage/NVMe/NVMeQueue.cpp
+++ b/Kernel/Storage/NVMe/NVMeQueue.cpp
@@ -12,7 +12,7 @@
#include <Kernel/Storage/NVMe/NVMeQueue.h>
namespace Kernel {
-ErrorOr<NonnullLockRefPtr<NVMeQueue>> NVMeQueue::try_create(u16 qid, Optional<u8> irq, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs)
+ErrorOr<NonnullLockRefPtr<NVMeQueue>> NVMeQueue::try_create(u16 qid, Optional<u8> irq, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs)
{
// Note: Allocate DMA region for RW operation. For now the requests don't exceed more than 4096 bytes (Storage device takes care of it)
RefPtr<Memory::PhysicalPage> rw_dma_page;
@@ -25,7 +25,7 @@ ErrorOr<NonnullLockRefPtr<NVMeQueue>> NVMeQueue::try_create(u16 qid, Optional<u8
return queue;
}
-UNMAP_AFTER_INIT NVMeQueue::NVMeQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs)
+UNMAP_AFTER_INIT NVMeQueue::NVMeQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs)
: m_current_request(nullptr)
, m_rw_dma_region(move(rw_dma_region))
, m_qid(qid)
diff --git a/Kernel/Storage/NVMe/NVMeQueue.h b/Kernel/Storage/NVMe/NVMeQueue.h
index 8b930ac618..d3f0b8dc6b 100644
--- a/Kernel/Storage/NVMe/NVMeQueue.h
+++ b/Kernel/Storage/NVMe/NVMeQueue.h
@@ -30,7 +30,7 @@ struct DoorbellRegister {
class AsyncBlockDeviceRequest;
class NVMeQueue : public AtomicRefCounted<NVMeQueue> {
public:
- static ErrorOr<NonnullLockRefPtr<NVMeQueue>> try_create(u16 qid, Optional<u8> irq, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs);
+ static ErrorOr<NonnullLockRefPtr<NVMeQueue>> try_create(u16 qid, Optional<u8> irq, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs);
bool is_admin_queue() { return m_admin_queue; };
u16 submit_sync_sqe(NVMeSubmission&);
void read(AsyncBlockDeviceRequest& request, u16 nsid, u64 index, u32 count);
@@ -44,7 +44,7 @@ protected:
{
m_db_regs->sq_tail = m_sq_tail;
}
- NVMeQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs);
+ NVMeQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs);
private:
bool cqe_available();
@@ -71,10 +71,10 @@ private:
u32 m_qdepth {};
Spinlock<LockRank::Interrupts> m_sq_lock {};
OwnPtr<Memory::Region> m_cq_dma_region;
- NonnullRefPtrVector<Memory::PhysicalPage> m_cq_dma_page;
+ Vector<NonnullRefPtr<Memory::PhysicalPage>> m_cq_dma_page;
Span<NVMeSubmission> m_sqe_array;
OwnPtr<Memory::Region> m_sq_dma_region;
- NonnullRefPtrVector<Memory::PhysicalPage> m_sq_dma_page;
+ Vector<NonnullRefPtr<Memory::PhysicalPage>> m_sq_dma_page;
Span<NVMeCompletion> m_cqe_array;
Memory::TypedMapping<DoorbellRegister volatile> m_db_regs;
NonnullRefPtr<Memory::PhysicalPage const> m_rw_dma_page;
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp
index 661b8711a1..aa3952fcd0 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp
@@ -850,7 +850,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
VERIFY(parameterized_type.parameters().size() == 2);
// A record only allows the key to be a string.
- VERIFY(parameterized_type.parameters()[0].is_string());
+ VERIFY(parameterized_type.parameters()[0]->is_string());
// An ECMAScript value O is converted to an IDL record<K, V> value as follows:
// 1. If Type(O) is not Object, throw a TypeError.
@@ -924,7 +924,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
RefPtr<Type const> dictionary_type;
for (auto& dictionary : interface.dictionaries) {
for (auto& type : types) {
- if (type.name() == dictionary.key) {
+ if (type->name() == dictionary.key) {
dictionary_type = type;
break;
}
@@ -998,7 +998,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
bool includes_object = false;
for (auto& type : types) {
- if (type.name() == "object") {
+ if (type->name() == "object") {
includes_object = true;
break;
}
@@ -1032,7 +1032,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
continue;
auto union_platform_object_type_generator = union_generator.fork();
- union_platform_object_type_generator.set("platform_object_type", type.name());
+ union_platform_object_type_generator.set("platform_object_type", type->name());
union_platform_object_type_generator.append(R"~~~(
if (is<@platform_object_type@>(@js_name@@js_suffix@_object))
@@ -1055,7 +1055,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
// 6. If Type(V) is Object and V has an [[ArrayBufferData]] internal slot, then
// 1. If types includes ArrayBuffer, then return the result of converting V to ArrayBuffer.
for (auto& type : types) {
- if (type.name() == "BufferSource") {
+ if (type->name() == "BufferSource") {
union_generator.append(R"~~~(
if (is<JS::ArrayBuffer>(@js_name@@js_suffix@_object))
return JS::make_handle(@js_name@@js_suffix@_object);
@@ -1085,8 +1085,8 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
// 1. If types includes a sequence type, then:
RefPtr<IDL::ParameterizedType const> sequence_type;
for (auto& type : types) {
- if (type.name() == "sequence") {
- sequence_type = verify_cast<IDL::ParameterizedType>(type);
+ if (type->name() == "sequence") {
+ sequence_type = verify_cast<IDL::ParameterizedType>(*type);
break;
}
}
@@ -1125,8 +1125,8 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
// 4. If types includes a record type, then return the result of converting V to that record type.
RefPtr<IDL::ParameterizedType const> record_type;
for (auto& type : types) {
- if (type.name() == "record") {
- record_type = verify_cast<IDL::ParameterizedType>(type);
+ if (type->name() == "record") {
+ record_type = verify_cast<IDL::ParameterizedType>(*type);
break;
}
}
@@ -1158,7 +1158,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
// 1. If types includes boolean, then return the result of converting V to boolean.
bool includes_boolean = false;
for (auto& type : types) {
- if (type.name() == "boolean") {
+ if (type->name() == "boolean") {
includes_boolean = true;
break;
}
@@ -1173,7 +1173,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
RefPtr<IDL::Type const> numeric_type;
for (auto& type : types) {
- if (type.is_numeric()) {
+ if (type->is_numeric()) {
numeric_type = type;
break;
}
@@ -1200,7 +1200,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
// 1. If types includes bigint, then return the result of converting V to bigint
bool includes_bigint = false;
for (auto& type : types) {
- if (type.name() == "bigint") {
+ if (type->name() == "bigint") {
includes_bigint = true;
break;
}
@@ -1215,7 +1215,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
bool includes_string = false;
for (auto& type : types) {
- if (type.is_string()) {
+ if (type->is_string()) {
includes_string = true;
break;
}
@@ -1831,7 +1831,7 @@ static EffectiveOverloadSet compute_the_effective_overload_set(auto const& overl
int argument_count = (int)arguments.size();
// 3. Let types be a type list.
- NonnullRefPtrVector<Type const> types;
+ Vector<NonnullRefPtr<Type const>> types;
// 4. Let optionalityValues be an optionality list.
Vector<Optionality> optionality_values;
@@ -1948,7 +1948,7 @@ static DeprecatedString generate_constructor_for_idl_type(Type const& type)
case Type::Kind::Parameterized: {
auto const& parameterized_type = type.as_parameterized();
StringBuilder builder;
- builder.appendff("make_ref_counted<IDL::ParameterizedTypeType>(\"{}\", {}, NonnullRefPtrVector<IDL::Type const> {{", type.name(), type.is_nullable());
+ builder.appendff("make_ref_counted<IDL::ParameterizedTypeType>(\"{}\", {}, Vector<NonnullRefPtr<IDL::Type const>> {{", type.name(), type.is_nullable());
append_type_list(builder, parameterized_type.parameters());
builder.append("})"sv);
return builder.to_deprecated_string();
@@ -1956,7 +1956,7 @@ static DeprecatedString generate_constructor_for_idl_type(Type const& type)
case Type::Kind::Union: {
auto const& union_type = type.as_union();
StringBuilder builder;
- builder.appendff("make_ref_counted<IDL::UnionType>(\"{}\", {}, NonnullRefPtrVector<IDL::Type const> {{", type.name(), type.is_nullable());
+ builder.appendff("make_ref_counted<IDL::UnionType>(\"{}\", {}, Vector<NonnullRefPtr<IDL::Type const>> {{", type.name(), type.is_nullable());
append_type_list(builder, union_type.member_types());
builder.append("})"sv);
return builder.to_deprecated_string();
@@ -2015,7 +2015,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@function.name:snakecase@)
continue;
StringBuilder types_builder;
- types_builder.append("NonnullRefPtrVector<IDL::Type const> { "sv);
+ types_builder.append("Vector<NonnullRefPtr<IDL::Type const>> { "sv);
StringBuilder optionality_builder;
optionality_builder.append("Vector<IDL::Optionality> { "sv);
diff --git a/Tests/LibSQL/TestSqlStatementParser.cpp b/Tests/LibSQL/TestSqlStatementParser.cpp
index e42819a295..335df91a01 100644
--- a/Tests/LibSQL/TestSqlStatementParser.cpp
+++ b/Tests/LibSQL/TestSqlStatementParser.cpp
@@ -93,16 +93,16 @@ TEST_CASE(create_table)
for (size_t i = 0; i < columns.size(); ++i) {
const auto& column = columns[i];
const auto& expected_column = expected_columns[i];
- EXPECT_EQ(column.name(), expected_column.name);
+ EXPECT_EQ(column->name(), expected_column.name);
- const auto& type_name = column.type_name();
+ const auto& type_name = column->type_name();
EXPECT_EQ(type_name->name(), expected_column.type);
const auto& signed_numbers = type_name->signed_numbers();
EXPECT_EQ(signed_numbers.size(), expected_column.signed_numbers.size());
for (size_t j = 0; j < signed_numbers.size(); ++j) {
- double signed_number = signed_numbers[j].value();
+ double signed_number = signed_numbers[j]->value();
double expected_signed_number = expected_column.signed_numbers[j];
EXPECT_EQ(signed_number, expected_signed_number);
}
@@ -227,7 +227,7 @@ TEST_CASE(alter_table_add_column)
EXPECT_EQ(signed_numbers.size(), expected_column.signed_numbers.size());
for (size_t j = 0; j < signed_numbers.size(); ++j) {
- double signed_number = signed_numbers[j].value();
+ double signed_number = signed_numbers[j]->value();
double expected_signed_number = expected_column.signed_numbers[j];
EXPECT_EQ(signed_number, expected_signed_number);
}
@@ -337,7 +337,7 @@ TEST_CASE(insert)
for (size_t i = 0; i < chained_expressions.size(); ++i) {
const auto& chained_expression = chained_expressions[i];
- const auto& expressions = chained_expression.expressions();
+ const auto& expressions = chained_expression->expressions();
EXPECT_EQ(expressions.size(), expected_chain_sizes[i]);
for (const auto& expression : expressions)
@@ -586,17 +586,17 @@ TEST_CASE(select)
for (size_t i = 0; i < result_column_list.size(); ++i) {
const auto& result_column = result_column_list[i];
const auto& expected_column = expected_columns[i];
- EXPECT_EQ(result_column.type(), expected_column.type);
+ EXPECT_EQ(result_column->type(), expected_column.type);
- switch (result_column.type()) {
+ switch (result_column->type()) {
case SQL::AST::ResultType::All:
EXPECT(expected_column.table_name_or_column_alias.is_null());
break;
case SQL::AST::ResultType::Table:
- EXPECT_EQ(result_column.table_name(), expected_column.table_name_or_column_alias);
+ EXPECT_EQ(result_column->table_name(), expected_column.table_name_or_column_alias);
break;
case SQL::AST::ResultType::Expression:
- EXPECT_EQ(result_column.column_alias(), expected_column.table_name_or_column_alias);
+ EXPECT_EQ(result_column->column_alias(), expected_column.table_name_or_column_alias);
break;
}
}
@@ -606,9 +606,9 @@ TEST_CASE(select)
for (size_t i = 0; i < table_or_subquery_list.size(); ++i) {
const auto& result_from = table_or_subquery_list[i];
const auto& expected_from = expected_from_list[i];
- EXPECT_EQ(result_from.schema_name(), expected_from.schema_name);
- EXPECT_EQ(result_from.table_name(), expected_from.table_name);
- EXPECT_EQ(result_from.table_alias(), expected_from.table_alias);
+ EXPECT_EQ(result_from->schema_name(), expected_from.schema_name);
+ EXPECT_EQ(result_from->table_name(), expected_from.table_name);
+ EXPECT_EQ(result_from->table_alias(), expected_from.table_alias);
}
const auto& where_clause = select.where_clause();
@@ -635,10 +635,10 @@ TEST_CASE(select)
for (size_t i = 0; i < ordering_term_list.size(); ++i) {
const auto& result_order = ordering_term_list[i];
const auto& expected_order = expected_ordering[i];
- EXPECT(!is<SQL::AST::ErrorExpression>(*result_order.expression()));
- EXPECT_EQ(result_order.collation_name(), expected_order.collation_name);
- EXPECT_EQ(result_order.order(), expected_order.order);
- EXPECT_EQ(result_order.nulls(), expected_order.nulls);
+ EXPECT(!is<SQL::AST::ErrorExpression>(*result_order->expression()));
+ EXPECT_EQ(result_order->collation_name(), expected_order.collation_name);
+ EXPECT_EQ(result_order->order(), expected_order.order);
+ EXPECT_EQ(result_order->nulls(), expected_order.nulls);
}
const auto& limit_clause = select.limit_clause();
@@ -731,11 +731,11 @@ TEST_CASE(common_table_expression)
for (size_t i = 0; i < common_table_expressions.size(); ++i) {
const auto& common_table_expression = common_table_expressions[i];
const auto& expected_common_table_expression = expected_selected_tables.selected_tables[i];
- EXPECT_EQ(common_table_expression.table_name(), expected_common_table_expression.table_name);
- EXPECT_EQ(common_table_expression.column_names().size(), expected_common_table_expression.column_names.size());
+ EXPECT_EQ(common_table_expression->table_name(), expected_common_table_expression.table_name);
+ EXPECT_EQ(common_table_expression->column_names().size(), expected_common_table_expression.column_names.size());
- for (size_t j = 0; j < common_table_expression.column_names().size(); ++j)
- EXPECT_EQ(common_table_expression.column_names()[j], expected_common_table_expression.column_names[j]);
+ for (size_t j = 0; j < common_table_expression->column_names().size(); ++j)
+ EXPECT_EQ(common_table_expression->column_names()[j], expected_common_table_expression.column_names[j]);
}
};
diff --git a/Userland/Applets/ResourceGraph/main.cpp b/Userland/Applets/ResourceGraph/main.cpp
index 665219db9f..91e5115460 100644
--- a/Userland/Applets/ResourceGraph/main.cpp
+++ b/Userland/Applets/ResourceGraph/main.cpp
@@ -257,7 +257,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 1;
}
- NonnullRefPtrVector<GUI::Window> applet_windows;
+ Vector<NonnullRefPtr<GUI::Window>> applet_windows;
auto create_applet = [&](GraphType graph_type, StringView spec) -> ErrorOr<void> {
auto parts = spec.split_view(',');
diff --git a/Userland/Applications/Assistant/Providers.cpp b/Userland/Applications/Assistant/Providers.cpp
index 89b740857e..1a0c034bca 100644
--- a/Userland/Applications/Assistant/Providers.cpp
+++ b/Userland/Applications/Assistant/Providers.cpp
@@ -61,12 +61,12 @@ void URLResult::activate() const
Desktop::Launcher::open(URL::create_with_url_or_path(title()));
}
-void AppProvider::query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete)
+void AppProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
{
if (query.starts_with('=') || query.starts_with('$'))
return;
- NonnullRefPtrVector<Result> results;
+ Vector<NonnullRefPtr<Result>> results;
Desktop::AppFile::for_each([&](NonnullRefPtr<Desktop::AppFile> app_file) {
auto query_and_arguments = query.split_limit(' ', 2);
@@ -83,7 +83,7 @@ void AppProvider::query(DeprecatedString const& query, Function<void(NonnullRefP
on_complete(move(results));
}
-void CalculatorProvider::query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete)
+void CalculatorProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
{
if (!query.starts_with('='))
return;
@@ -108,7 +108,7 @@ void CalculatorProvider::query(DeprecatedString const& query, Function<void(Nonn
calculation = result.to_string_without_side_effects().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
}
- NonnullRefPtrVector<Result> results;
+ Vector<NonnullRefPtr<Result>> results;
results.append(adopt_ref(*new CalculatorResult(calculation)));
on_complete(move(results));
}
@@ -123,16 +123,16 @@ FileProvider::FileProvider()
build_filesystem_cache();
}
-void FileProvider::query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete)
+void FileProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
{
build_filesystem_cache();
if (m_fuzzy_match_work)
m_fuzzy_match_work->cancel();
- m_fuzzy_match_work = Threading::BackgroundAction<Optional<NonnullRefPtrVector<Result>>>::construct(
- [this, query](auto& task) -> Optional<NonnullRefPtrVector<Result>> {
- NonnullRefPtrVector<Result> results;
+ m_fuzzy_match_work = Threading::BackgroundAction<Optional<Vector<NonnullRefPtr<Result>>>>::construct(
+ [this, query](auto& task) -> Optional<Vector<NonnullRefPtr<Result>>> {
+ Vector<NonnullRefPtr<Result>> results;
for (auto& path : m_full_path_cache) {
if (task.is_cancelled())
@@ -203,19 +203,19 @@ void FileProvider::build_filesystem_cache()
});
}
-void TerminalProvider::query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete)
+void TerminalProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
{
if (!query.starts_with('$'))
return;
auto command = query.substring(1).trim_whitespace();
- NonnullRefPtrVector<Result> results;
+ Vector<NonnullRefPtr<Result>> results;
results.append(adopt_ref(*new TerminalResult(move(command))));
on_complete(move(results));
}
-void URLProvider::query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete)
+void URLProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
{
if (query.is_empty() || query.starts_with('=') || query.starts_with('$'))
return;
@@ -232,7 +232,7 @@ void URLProvider::query(DeprecatedString const& query, Function<void(NonnullRefP
if (!url.is_valid())
return;
- NonnullRefPtrVector<Result> results;
+ Vector<NonnullRefPtr<Result>> results;
results.append(adopt_ref(*new URLResult(url)));
on_complete(results);
}
diff --git a/Userland/Applications/Assistant/Providers.h b/Userland/Applications/Assistant/Providers.h
index cef555dceb..3d1daba6c2 100644
--- a/Userland/Applications/Assistant/Providers.h
+++ b/Userland/Applications/Assistant/Providers.h
@@ -134,28 +134,28 @@ class Provider : public RefCounted<Provider> {
public:
virtual ~Provider() = default;
- virtual void query(DeprecatedString const&, Function<void(NonnullRefPtrVector<Result>)> on_complete) = 0;
+ virtual void query(DeprecatedString const&, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) = 0;
};
class AppProvider final : public Provider {
public:
- void query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) override;
+ void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
};
class CalculatorProvider final : public Provider {
public:
- void query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) override;
+ void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
};
class FileProvider final : public Provider {
public:
FileProvider();
- void query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) override;
+ void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
void build_filesystem_cache();
private:
- RefPtr<Threading::BackgroundAction<Optional<NonnullRefPtrVector<Result>>>> m_fuzzy_match_work;
+ RefPtr<Threading::BackgroundAction<Optional<Vector<NonnullRefPtr<Result>>>>> m_fuzzy_match_work;
bool m_building_cache { false };
Vector<DeprecatedString> m_full_path_cache;
Queue<DeprecatedString> m_work_queue;
@@ -163,12 +163,12 @@ private:
class TerminalProvider final : public Provider {
public:
- void query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) override;
+ void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
};
class URLProvider final : public Provider {
public:
- void query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) override;
+ void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
};
}
diff --git a/Userland/Applications/Assistant/main.cpp b/Userland/Applications/Assistant/main.cpp
index 83a928c9c5..04129cfbcb 100644
--- a/Userland/Applications/Assistant/main.cpp
+++ b/Userland/Applications/Assistant/main.cpp
@@ -36,7 +36,7 @@ namespace Assistant {
struct AppState {
Optional<size_t> selected_index;
- NonnullRefPtrVector<Result const> results;
+ Vector<NonnullRefPtr<Result const>> results;
size_t visible_result_count { 0 };
Threading::Mutex lock;
@@ -84,7 +84,7 @@ public:
{
}
- Function<void(NonnullRefPtrVector<Result const>)> on_new_results;
+ Function<void(Vector<NonnullRefPtr<Result const>>)> on_new_results;
void search(DeprecatedString const& query)
{
@@ -98,7 +98,7 @@ public:
auto& result_array = m_result_cache.ensure(query);
if (result_array.at(i) != nullptr)
return;
- result_array[i] = make<NonnullRefPtrVector<Result>>(results);
+ result_array[i] = make<Vector<NonnullRefPtr<Result>>>(results);
}
on_result_cache_updated();
});
@@ -142,7 +142,7 @@ private:
Array<NonnullRefPtr<Provider>, ProviderCount> m_providers;
Threading::Mutex m_mutex;
- HashMap<DeprecatedString, Array<OwnPtr<NonnullRefPtrVector<Result>>, ProviderCount>> m_result_cache;
+ HashMap<DeprecatedString, Array<OwnPtr<Vector<NonnullRefPtr<Result>>>, ProviderCount>> m_result_cache;
};
}
@@ -211,7 +211,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (!app_state.selected_index.has_value())
return;
lockfile.release();
- app_state.results[app_state.selected_index.value()].activate();
+ app_state.results[app_state.selected_index.value()]->activate();
GUI::Application::the()->quit();
};
text_box.on_up_pressed = [&]() {
@@ -254,11 +254,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
for (size_t i = 0; i < app_state.visible_result_count; ++i) {
auto& result = app_state.results[i];
auto& match = results_container.add<Assistant::ResultRow>();
- match.set_icon(result.bitmap());
- match.set_text(String::from_deprecated_string(result.title()).release_value_but_fixme_should_propagate_errors());
- match.set_tooltip(move(result.tooltip()));
+ match.set_icon(result->bitmap());
+ match.set_text(String::from_deprecated_string(result->title()).release_value_but_fixme_should_propagate_errors());
+ match.set_tooltip(move(result->tooltip()));
match.on_click = [&result](auto) {
- result.activate();
+ result->activate();
GUI::Application::the()->quit();
};
}
diff --git a/Userland/Applications/Browser/BookmarksBarWidget.cpp b/Userland/Applications/Browser/BookmarksBarWidget.cpp
index 6e9514b95b..716d88d64e 100644
--- a/Userland/Applications/Browser/BookmarksBarWidget.cpp
+++ b/Userland/Applications/Browser/BookmarksBarWidget.cpp
@@ -243,13 +243,13 @@ void BookmarksBarWidget::update_content_size()
for (size_t i = 0; i < m_bookmarks.size(); ++i) {
auto& bookmark = m_bookmarks.at(i);
- if (x_position + bookmark.width() + m_additional->width() > width()) {
+ if (x_position + bookmark->width() + m_additional->width() > width()) {
m_last_visible_index = i;
break;
}
- bookmark.set_x(x_position);
- bookmark.set_visible(true);
- x_position += bookmark.width();
+ bookmark->set_x(x_position);
+ bookmark->set_visible(true);
+ x_position += bookmark->width();
}
if (m_last_visible_index < 0) {
@@ -261,8 +261,8 @@ void BookmarksBarWidget::update_content_size()
m_additional->set_menu(m_additional_menu);
for (size_t i = m_last_visible_index; i < m_bookmarks.size(); ++i) {
auto& bookmark = m_bookmarks.at(i);
- bookmark.set_visible(false);
- m_additional_menu->add_action(GUI::Action::create(bookmark.text().to_deprecated_string(), g_icon_bag.filetype_html, [&](auto&) { bookmark.on_click(0); }));
+ bookmark->set_visible(false);
+ m_additional_menu->add_action(GUI::Action::create(bookmark->text().to_deprecated_string(), g_icon_bag.filetype_html, [&](auto&) { bookmark->on_click(0); }));
}
}
}
diff --git a/Userland/Applications/Browser/BookmarksBarWidget.h b/Userland/Applications/Browser/BookmarksBarWidget.h
index 461e615ebf..99bd845ccc 100644
--- a/Userland/Applications/Browser/BookmarksBarWidget.h
+++ b/Userland/Applications/Browser/BookmarksBarWidget.h
@@ -66,7 +66,7 @@ private:
RefPtr<GUI::Action> m_context_menu_default_action;
DeprecatedString m_context_menu_url;
- NonnullRefPtrVector<GUI::Button> m_bookmarks;
+ Vector<NonnullRefPtr<GUI::Button>> m_bookmarks;
int m_last_visible_index { -1 };
};
diff --git a/Userland/Applications/Browser/WindowActions.cpp b/Userland/Applications/Browser/WindowActions.cpp
index ce2b9478cb..95a3d0e6f5 100644
--- a/Userland/Applications/Browser/WindowActions.cpp
+++ b/Userland/Applications/Browser/WindowActions.cpp
@@ -65,7 +65,7 @@ WindowActions::WindowActions(GUI::Window& window)
on_tabs[i]();
},
&window));
- m_tab_actions.last().set_status_tip(DeprecatedString::formatted("Switch to tab {}", i + 1));
+ m_tab_actions.last()->set_status_tip(DeprecatedString::formatted("Switch to tab {}", i + 1));
}
m_tab_actions.append(GUI::Action::create(
"Last tab", { Mod_Ctrl, Key_9 }, [this](auto&) {
@@ -73,7 +73,7 @@ WindowActions::WindowActions(GUI::Window& window)
on_tabs[8]();
},
&window));
- m_tab_actions.last().set_status_tip("Switch to last tab");
+ m_tab_actions.last()->set_status_tip("Switch to last tab");
m_about_action = GUI::CommonActions::make_about_action("Browser", GUI::Icon::default_icon("app-browser"sv), &window);
diff --git a/Userland/Applications/Browser/WindowActions.h b/Userland/Applications/Browser/WindowActions.h
index 25a3a0f0ee..7941699675 100644
--- a/Userland/Applications/Browser/WindowActions.h
+++ b/Userland/Applications/Browser/WindowActions.h
@@ -38,7 +38,7 @@ private:
RefPtr<GUI::Action> m_create_new_window_action;
RefPtr<GUI::Action> m_next_tab_action;
RefPtr<GUI::Action> m_previous_tab_action;
- NonnullRefPtrVector<GUI::Action> m_tab_actions;
+ Vector<NonnullRefPtr<GUI::Action>> m_tab_actions;
RefPtr<GUI::Action> m_about_action;
RefPtr<GUI::Action> m_show_bookmarks_bar_action;
RefPtr<GUI::Action> m_vertical_tabs_action;
diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp
index 3d7f684dc0..8c1713ba55 100644
--- a/Userland/Applications/FileManager/DirectoryView.cpp
+++ b/Userland/Applications/FileManager/DirectoryView.cpp
@@ -52,21 +52,21 @@ NonnullRefPtr<GUI::Action> LauncherHandler::create_launch_action(Function<void(L
});
}
-RefPtr<LauncherHandler> DirectoryView::get_default_launch_handler(NonnullRefPtrVector<LauncherHandler> const& handlers)
+RefPtr<LauncherHandler> DirectoryView::get_default_launch_handler(Vector<NonnullRefPtr<LauncherHandler>> const& handlers)
{
// If this is an application, pick it first
for (size_t i = 0; i < handlers.size(); i++) {
- if (handlers[i].details().launcher_type == Desktop::Launcher::LauncherType::Application)
+ if (handlers[i]->details().launcher_type == Desktop::Launcher::LauncherType::Application)
return handlers[i];
}
// If there's a handler preferred by the user, pick this first
for (size_t i = 0; i < handlers.size(); i++) {
- if (handlers[i].details().launcher_type == Desktop::Launcher::LauncherType::UserPreferred)
+ if (handlers[i]->details().launcher_type == Desktop::Launcher::LauncherType::UserPreferred)
return handlers[i];
}
// Otherwise, use the user's default, if available
for (size_t i = 0; i < handlers.size(); i++) {
- if (handlers[i].details().launcher_type == Desktop::Launcher::LauncherType::UserDefault)
+ if (handlers[i]->details().launcher_type == Desktop::Launcher::LauncherType::UserDefault)
return handlers[i];
}
// If still no match, use the first one we find
@@ -77,16 +77,16 @@ RefPtr<LauncherHandler> DirectoryView::get_default_launch_handler(NonnullRefPtrV
return {};
}
-NonnullRefPtrVector<LauncherHandler> DirectoryView::get_launch_handlers(URL const& url)
+Vector<NonnullRefPtr<LauncherHandler>> DirectoryView::get_launch_handlers(URL const& url)
{
- NonnullRefPtrVector<LauncherHandler> handlers;
+ Vector<NonnullRefPtr<LauncherHandler>> handlers;
for (auto& h : Desktop::Launcher::get_handlers_with_details_for_url(url)) {
handlers.append(adopt_ref(*new LauncherHandler(h)));
}
return handlers;
}
-NonnullRefPtrVector<LauncherHandler> DirectoryView::get_launch_handlers(DeprecatedString const& path)
+Vector<NonnullRefPtr<LauncherHandler>> DirectoryView::get_launch_handlers(DeprecatedString const& path)
{
return get_launch_handlers(URL::create_with_file_scheme(path));
}
diff --git a/Userland/Applications/FileManager/DirectoryView.h b/Userland/Applications/FileManager/DirectoryView.h
index 8f1a0070ec..b7e4ef9e4c 100644
--- a/Userland/Applications/FileManager/DirectoryView.h
+++ b/Userland/Applications/FileManager/DirectoryView.h
@@ -58,9 +58,9 @@ public:
void open_next_directory();
int path_history_size() const { return m_path_history.size(); }
int path_history_position() const { return m_path_history_position; }
- static RefPtr<LauncherHandler> get_default_launch_handler(NonnullRefPtrVector<LauncherHandler> const& handlers);
- static NonnullRefPtrVector<LauncherHandler> get_launch_handlers(URL const& url);
- static NonnullRefPtrVector<LauncherHandler> get_launch_handlers(DeprecatedString const& path);
+ static RefPtr<LauncherHandler> get_default_launch_handler(Vector<NonnullRefPtr<LauncherHandler>> const& handlers);
+ static Vector<NonnullRefPtr<LauncherHandler>> get_launch_handlers(URL const& url);
+ static Vector<NonnullRefPtr<LauncherHandler>> get_launch_handlers(DeprecatedString const& path);
void refresh();
diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp
index de36bdec3a..341c2103c2 100644
--- a/Userland/Applications/FileManager/main.cpp
+++ b/Userland/Applications/FileManager/main.cpp
@@ -66,7 +66,7 @@ static void do_create_archive(Vector<DeprecatedString> const& selected_file_path
static void do_set_wallpaper(DeprecatedString const& file_path, GUI::Window* window);
static void do_unzip_archive(Vector<DeprecatedString> const& selected_file_paths, GUI::Window* window);
static void show_properties(DeprecatedString const& container_dir_path, DeprecatedString const& path, Vector<DeprecatedString> const& selected, GUI::Window* window);
-static bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr<GUI::Action>& default_action, NonnullRefPtrVector<LauncherHandler>& current_file_launch_handlers);
+static bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr<GUI::Action>& default_action, Vector<NonnullRefPtr<LauncherHandler>>& current_file_launch_handlers);
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
@@ -310,7 +310,7 @@ void show_properties(DeprecatedString const& container_dir_path, DeprecatedStrin
properties->show();
}
-bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr<GUI::Action>& default_action, NonnullRefPtrVector<LauncherHandler>& current_file_launch_handlers)
+bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr<GUI::Action>& default_action, Vector<NonnullRefPtr<LauncherHandler>>& current_file_launch_handlers)
{
current_file_launch_handlers = directory_view.get_launch_handlers(full_path);
@@ -337,9 +337,9 @@ bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView c
added_open_menu_items = true;
auto& file_open_with_menu = menu->add_submenu("Open with");
for (auto& handler : current_file_launch_handlers) {
- if (&handler == default_file_handler.ptr())
+ if (handler == default_file_handler)
continue;
- file_open_with_menu.add_action(handler.create_launch_action([&, full_path = move(full_path)](auto& launcher_handler) {
+ file_open_with_menu.add_action(handler->create_launch_action([&, full_path = move(full_path)](auto& launcher_handler) {
directory_view.launch(URL::create_with_file_scheme(full_path), launcher_handler);
}));
}
@@ -502,7 +502,7 @@ ErrorOr<int> run_in_desktop_mode()
TRY(desktop_context_menu->try_add_action(properties_action));
RefPtr<GUI::Menu> file_context_menu;
- NonnullRefPtrVector<LauncherHandler> current_file_handlers;
+ Vector<NonnullRefPtr<LauncherHandler>> current_file_handlers;
RefPtr<GUI::Action> file_context_menu_action_default_action;
directory_view->on_context_menu_request = [&](GUI::ModelIndex const& index, GUI::ContextMenuEvent const& event) {
@@ -1168,7 +1168,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
TRY(tree_view_directory_context_menu->try_add_action(properties_action));
RefPtr<GUI::Menu> file_context_menu;
- NonnullRefPtrVector<LauncherHandler> current_file_handlers;
+ Vector<NonnullRefPtr<LauncherHandler>> current_file_handlers;
RefPtr<GUI::Action> file_context_menu_action_default_action;
directory_view->on_context_menu_request = [&](GUI::ModelIndex const& index, GUI::ContextMenuEvent const& event) {
diff --git a/Userland/Applications/GamesSettings/CardSettingsWidget.cpp b/Userland/Applications/GamesSettings/CardSettingsWidget.cpp
index f9aff7609c..6c5457e58d 100644
--- a/Userland/Applications/GamesSettings/CardSettingsWidget.cpp
+++ b/Userland/Applications/GamesSettings/CardSettingsWidget.cpp
@@ -63,7 +63,7 @@ private:
auto background_color = this->background_color();
for (auto& stack : stacks())
- stack.paint(painter, background_color);
+ stack->paint(painter, background_color);
}
};
diff --git a/Userland/Applications/Mail/AccountHolder.cpp b/Userland/Applications/Mail/AccountHolder.cpp
index ed41e8d4fb..cfd5a17754 100644
--- a/Userland/Applications/Mail/AccountHolder.cpp
+++ b/Userland/Applications/Mail/AccountHolder.cpp
@@ -17,7 +17,7 @@ void AccountHolder::add_account_with_name_and_mailboxes(DeprecatedString name, V
auto account = AccountNode::create(move(name));
// This holds all of the ancestors of the current leaf folder.
- NonnullRefPtrVector<MailboxNode> folder_stack;
+ Vector<NonnullRefPtr<MailboxNode>> folder_stack;
for (auto& mailbox : mailboxes) {
// mailbox.name is converted to StringView to get access to split by string.
@@ -44,7 +44,7 @@ void AccountHolder::add_account_with_name_and_mailboxes(DeprecatedString name, V
// Only keep the ancestors of the current leaf folder.
folder_stack.shrink(subfolders.size() - 1);
- parent_folder.add_child(mailbox_node);
+ parent_folder->add_child(mailbox_node);
VERIFY(!mailbox_node->has_parent());
mailbox_node->set_parent(parent_folder);
@@ -54,7 +54,7 @@ void AccountHolder::add_account_with_name_and_mailboxes(DeprecatedString name, V
} else {
// FIXME: This assumes that the server has the "CHILDREN" capability.
if (mailbox.flags & (unsigned)IMAP::MailboxFlag::HasChildren) {
- if (!folder_stack.is_empty() && folder_stack.first().select_name() != mailbox.name) {
+ if (!folder_stack.is_empty() && folder_stack.first()->select_name() != mailbox.name) {
// This is a new root folder, clear the stack as there are no ancestors of the current leaf folder at this point.
folder_stack.clear();
}
diff --git a/Userland/Applications/Mail/AccountHolder.h b/Userland/Applications/Mail/AccountHolder.h
index 91a4cb6259..66e721710e 100644
--- a/Userland/Applications/Mail/AccountHolder.h
+++ b/Userland/Applications/Mail/AccountHolder.h
@@ -34,7 +34,7 @@ public:
m_mailboxes.append(move(mailbox));
}
- NonnullRefPtrVector<MailboxNode> const& mailboxes() const { return m_mailboxes; }
+ Vector<NonnullRefPtr<MailboxNode>> const& mailboxes() const { return m_mailboxes; }
DeprecatedString const& name() const { return m_name; }
private:
@@ -44,7 +44,7 @@ private:
}
DeprecatedString m_name;
- NonnullRefPtrVector<MailboxNode> m_mailboxes;
+ Vector<NonnullRefPtr<MailboxNode>> m_mailboxes;
};
class MailboxNode final : public BaseNode {
@@ -66,7 +66,7 @@ public:
void set_parent(NonnullRefPtr<MailboxNode> parent) { m_parent = parent; }
bool has_children() const { return !m_children.is_empty(); }
- NonnullRefPtrVector<MailboxNode> const& children() const { return m_children; }
+ Vector<NonnullRefPtr<MailboxNode>> const& children() const { return m_children; }
void add_child(NonnullRefPtr<MailboxNode> child) { m_children.append(child); }
private:
@@ -81,7 +81,7 @@ private:
IMAP::ListItem m_mailbox;
DeprecatedString m_display_name;
- NonnullRefPtrVector<MailboxNode> m_children;
+ Vector<NonnullRefPtr<MailboxNode>> m_children;
RefPtr<MailboxNode> m_parent;
};
@@ -96,7 +96,7 @@ public:
void add_account_with_name_and_mailboxes(DeprecatedString, Vector<IMAP::ListItem> const&);
- NonnullRefPtrVector<AccountNode> const& accounts() const { return m_accounts; }
+ Vector<NonnullRefPtr<AccountNode>> const& accounts() const { return m_accounts; }
MailboxTreeModel& mailbox_tree_model() { return *m_mailbox_tree_model; }
private:
@@ -104,6 +104,6 @@ private:
void rebuild_tree();
- NonnullRefPtrVector<AccountNode> m_accounts;
+ Vector<NonnullRefPtr<AccountNode>> m_accounts;
RefPtr<MailboxTreeModel> m_mailbox_tree_model;
};
diff --git a/Userland/Applications/Mail/MailboxTreeModel.cpp b/Userland/Applications/Mail/MailboxTreeModel.cpp
index 44b16b6ea2..583021941e 100644
--- a/Userland/Applications/Mail/MailboxTreeModel.cpp
+++ b/Userland/Applications/Mail/MailboxTreeModel.cpp
@@ -48,14 +48,14 @@ GUI::ModelIndex MailboxTreeModel::parent_index(GUI::ModelIndex const& index) con
if (!mailbox_node.has_parent()) {
for (size_t row = 0; row < mailbox_node.associated_account().mailboxes().size(); ++row) {
- if (&mailbox_node.associated_account().mailboxes()[row] == &mailbox_node) {
+ if (mailbox_node.associated_account().mailboxes()[row] == &mailbox_node) {
return create_index(row, index.column(), &mailbox_node.associated_account());
}
}
} else {
VERIFY(mailbox_node.parent()->has_children());
for (size_t row = 0; row < mailbox_node.parent()->children().size(); ++row) {
- if (&mailbox_node.parent()->children()[row] == &mailbox_node) {
+ if (mailbox_node.parent()->children()[row] == &mailbox_node) {
return create_index(row, index.column(), mailbox_node.parent());
}
}
diff --git a/Userland/Applications/PDFViewer/OutlineModel.cpp b/Userland/Applications/PDFViewer/OutlineModel.cpp
index 2884aae681..5d3f632e58 100644
--- a/Userland/Applications/PDFViewer/OutlineModel.cpp
+++ b/Userland/Applications/PDFViewer/OutlineModel.cpp
@@ -118,9 +118,9 @@ GUI::ModelIndex OutlineModel::parent_index(const GUI::ModelIndex& index) const
if (!parent)
return {};
- NonnullRefPtrVector<PDF::OutlineItem> parent_siblings = (parent->parent ? parent->parent->children : m_outline->children);
+ Vector<NonnullRefPtr<PDF::OutlineItem>> parent_siblings = (parent->parent ? parent->parent->children : m_outline->children);
for (size_t i = 0; i < parent_siblings.size(); i++) {
- auto* parent_sibling = &parent_siblings[i];
+ auto* parent_sibling = parent_siblings[i].ptr();
if (parent_sibling == parent.ptr())
return create_index(static_cast<int>(i), index.column(), parent.ptr());
}
diff --git a/Userland/Applications/Piano/TrackControlsWidget.h b/Userland/Applications/Piano/TrackControlsWidget.h
index 6076e8c231..0ac0cea172 100644
--- a/Userland/Applications/Piano/TrackControlsWidget.h
+++ b/Userland/Applications/Piano/TrackControlsWidget.h
@@ -30,5 +30,5 @@ private:
TrackManager& m_track_manager;
MainWidget& m_main_widget;
- NonnullRefPtrVector<ProcessorParameterWidget> m_parameter_widgets;
+ Vector<NonnullRefPtr<ProcessorParameterWidget>> m_parameter_widgets;
};
diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp
index b948383484..ab53535f73 100644
--- a/Userland/Applications/PixelPaint/Image.cpp
+++ b/Userland/Applications/PixelPaint/Image.cpp
@@ -42,11 +42,11 @@ void Image::paint_into(GUI::Painter& painter, Gfx::IntRect const& dest_rect, flo
Gfx::PainterStateSaver saver(painter);
painter.add_clip_rect(dest_rect);
for (auto const& layer : m_layers) {
- if (!layer.is_visible())
+ if (!layer->is_visible())
continue;
- auto target = dest_rect.to_type<float>().translated(layer.location().x() * scale, layer.location().y() * scale);
- target.set_size(layer.size().width() * scale, layer.size().height() * scale);
- painter.draw_scaled_bitmap(target.to_type<int>(), layer.display_bitmap(), layer.rect(), (float)layer.opacity_percent() / 100.0f);
+ auto target = dest_rect.to_type<float>().translated(layer->location().x() * scale, layer->location().y() * scale);
+ target.set_size(layer->size().width() * scale, layer->size().height() * scale);
+ painter.draw_scaled_bitmap(target.to_type<int>(), layer->display_bitmap(), layer->rect(), (float)layer->opacity_percent() / 100.0f);
}
}
@@ -126,17 +126,17 @@ ErrorOr<void> Image::serialize_as_json(JsonObjectSerializer<StringBuilder>& json
auto json_layers = TRY(json.add_array("layers"sv));
for (auto const& layer : m_layers) {
auto json_layer = TRY(json_layers.add_object());
- TRY(json_layer.add("width"sv, layer.size().width()));
- TRY(json_layer.add("height"sv, layer.size().height()));
- TRY(json_layer.add("name"sv, layer.name()));
- TRY(json_layer.add("locationx"sv, layer.location().x()));
- TRY(json_layer.add("locationy"sv, layer.location().y()));
- TRY(json_layer.add("opacity_percent"sv, layer.opacity_percent()));
- TRY(json_layer.add("visible"sv, layer.is_visible()));
- TRY(json_layer.add("selected"sv, layer.is_selected()));
- TRY(json_layer.add("bitmap"sv, TRY(encode_base64(TRY(Gfx::PNGWriter::encode(layer.content_bitmap()))))));
- if (layer.is_masked())
- TRY(json_layer.add("mask"sv, TRY(encode_base64(TRY(Gfx::PNGWriter::encode(*layer.mask_bitmap()))))));
+ TRY(json_layer.add("width"sv, layer->size().width()));
+ TRY(json_layer.add("height"sv, layer->size().height()));
+ TRY(json_layer.add("name"sv, layer->name()));
+ TRY(json_layer.add("locationx"sv, layer->location().x()));
+ TRY(json_layer.add("locationy"sv, layer->location().y()));
+ TRY(json_layer.add("opacity_percent"sv, layer->opacity_percent()));
+ TRY(json_layer.add("visible"sv, layer->is_visible()));
+ TRY(json_layer.add("selected"sv, layer->is_selected()));
+ TRY(json_layer.add("bitmap"sv, TRY(encode_base64(TRY(Gfx::PNGWriter::encode(layer->content_bitmap()))))));
+ if (layer->is_masked())
+ TRY(json_layer.add("mask"sv, TRY(encode_base64(TRY(Gfx::PNGWriter::encode(*layer->mask_bitmap()))))));
TRY(json_layer.finish());
}
@@ -204,7 +204,7 @@ ErrorOr<void> Image::export_qoi_to_file(NonnullOwnPtr<Stream> stream) const
void Image::add_layer(NonnullRefPtr<Layer> layer)
{
for (auto& existing_layer : m_layers) {
- VERIFY(&existing_layer != layer.ptr());
+ VERIFY(existing_layer != layer);
}
m_layers.append(move(layer));
@@ -256,7 +256,7 @@ ErrorOr<void> Image::restore_snapshot(Image const& snapshot)
size_t Image::index_of(Layer const& layer) const
{
for (size_t i = 0; i < m_layers.size(); ++i) {
- if (&m_layers.at(i) == &layer)
+ if (m_layers[i] == &layer)
return i;
}
VERIFY_NOT_REACHED();
@@ -350,18 +350,18 @@ ErrorOr<void> Image::merge_layers(LayerMergeMode layer_merge_mode)
if (m_layers.size() < 2)
return {};
- NonnullRefPtrVector<Layer> new_layers;
+ Vector<NonnullRefPtr<Layer>> new_layers;
Gfx::IntRect merged_layer_bounding_rect = {};
size_t bottom_layer_index = 0;
for (auto const& layer : m_layers) {
- if (!layer.is_visible()) {
+ if (!layer->is_visible()) {
if (layer_merge_mode == LayerMergeMode::VisibleOnly)
TRY(new_layers.try_append(layer));
if (merged_layer_bounding_rect.is_empty())
bottom_layer_index++;
continue;
}
- merged_layer_bounding_rect = merged_layer_bounding_rect.united(layer.relative_rect());
+ merged_layer_bounding_rect = merged_layer_bounding_rect.united(layer->relative_rect());
}
if (merged_layer_bounding_rect.is_empty())
@@ -379,9 +379,9 @@ ErrorOr<void> Image::merge_layers(LayerMergeMode layer_merge_mode)
painter.blit(bottom_layer->location() - merged_layer->location(), bottom_layer->display_bitmap(), bottom_layer->rect(), static_cast<float>(bottom_layer->opacity_percent()) / 100.0f);
for (size_t index = bottom_layer_index + 1; index < m_layers.size(); index++) {
auto& layer = m_layers.at(index);
- if (!layer.is_visible())
+ if (!layer->is_visible())
continue;
- painter.blit(layer.location() - merged_layer->location(), layer.display_bitmap(), layer.rect(), static_cast<float>(layer.opacity_percent()) / 100.0f);
+ painter.blit(layer->location() - merged_layer->location(), layer->display_bitmap(), layer->rect(), static_cast<float>(layer->opacity_percent()) / 100.0f);
}
TRY(new_layers.try_append(merged_layer));
@@ -421,7 +421,7 @@ ErrorOr<void> Image::merge_active_layer(NonnullRefPtr<Layer> const& layer, Layer
Optional<NonnullRefPtr<Layer>> maybe_adjacent_layer;
while (layer_to_merge_index >= 0 && layer_to_merge_index < layer_count) {
- auto& layer = m_layers.at(layer_to_merge_index);
+ auto const& layer = *m_layers[layer_to_merge_index];
if (layer.is_visible()) {
maybe_adjacent_layer = layer;
break;
@@ -541,7 +541,7 @@ ErrorOr<void> Image::flip(Gfx::Orientation orientation)
auto& layer = m_layers[i];
auto new_layer = TRY(Layer::create_snapshot(*this, layer));
- if (layer.is_selected())
+ if (layer->is_selected())
selected_layer_index = i;
TRY(new_layer->flip(orientation, Layer::NotifyClients::No));
@@ -551,9 +551,9 @@ ErrorOr<void> Image::flip(Gfx::Orientation orientation)
m_layers = move(flipped_layers);
for (auto& layer : m_layers)
- layer.did_modify_bitmap({}, Layer::NotifyClients::No);
+ layer->did_modify_bitmap({}, Layer::NotifyClients::No);
- select_layer(&m_layers[selected_layer_index]);
+ select_layer(m_layers[selected_layer_index]);
did_change();
@@ -572,7 +572,7 @@ ErrorOr<void> Image::rotate(Gfx::RotationDirection direction)
auto& layer = m_layers[i];
auto new_layer = TRY(Layer::create_snapshot(*this, layer));
- if (layer.is_selected())
+ if (layer->is_selected())
selected_layer_index = i;
TRY(new_layer->rotate(direction, Layer::NotifyClients::No));
@@ -582,9 +582,9 @@ ErrorOr<void> Image::rotate(Gfx::RotationDirection direction)
m_layers = move(rotated_layers);
for (auto& layer : m_layers)
- layer.did_modify_bitmap({}, Layer::NotifyClients::Yes);
+ layer->did_modify_bitmap({}, Layer::NotifyClients::Yes);
- select_layer(&m_layers[selected_layer_index]);
+ select_layer(m_layers[selected_layer_index]);
m_size = { m_size.height(), m_size.width() };
did_change_rect();
@@ -604,7 +604,7 @@ ErrorOr<void> Image::crop(Gfx::IntRect const& cropped_rect)
auto& layer = m_layers[i];
auto new_layer = TRY(Layer::create_snapshot(*this, layer));
- if (layer.is_selected())
+ if (layer->is_selected())
selected_layer_index = i;
auto layer_location = new_layer->location();
@@ -621,9 +621,9 @@ ErrorOr<void> Image::crop(Gfx::IntRect const& cropped_rect)
m_layers = move(cropped_layers);
for (auto& layer : m_layers)
- layer.did_modify_bitmap({}, Layer::NotifyClients::Yes);
+ layer->did_modify_bitmap({}, Layer::NotifyClients::Yes);
- select_layer(&m_layers[selected_layer_index]);
+ select_layer(m_layers[selected_layer_index]);
m_size = { cropped_rect.width(), cropped_rect.height() };
did_change_rect(cropped_rect);
@@ -638,10 +638,10 @@ Optional<Gfx::IntRect> Image::nonempty_content_bounding_rect() const
Optional<Gfx::IntRect> bounding_rect;
for (auto const& layer : m_layers) {
- auto layer_content_rect_in_layer_coordinates = layer.nonempty_content_bounding_rect();
+ auto layer_content_rect_in_layer_coordinates = layer->nonempty_content_bounding_rect();
if (!layer_content_rect_in_layer_coordinates.has_value())
continue;
- auto layer_content_rect_in_image_coordinates = layer_content_rect_in_layer_coordinates->translated(layer.location());
+ auto layer_content_rect_in_image_coordinates = layer_content_rect_in_layer_coordinates->translated(layer->location());
if (!bounding_rect.has_value())
bounding_rect = layer_content_rect_in_image_coordinates;
else
@@ -674,7 +674,7 @@ ErrorOr<void> Image::resize(Gfx::IntSize new_size, Gfx::Painter::ScalingMode sca
auto& layer = m_layers[i];
auto new_layer = TRY(Layer::create_snapshot(*this, layer));
- if (layer.is_selected())
+ if (layer->is_selected())
selected_layer_index = i;
Gfx::IntPoint new_location(scale_x * new_layer->location().x(), scale_y * new_layer->location().y());
@@ -685,9 +685,9 @@ ErrorOr<void> Image::resize(Gfx::IntSize new_size, Gfx::Painter::ScalingMode sca
m_layers = move(resized_layers);
for (auto& layer : m_layers)
- layer.did_modify_bitmap({}, Layer::NotifyClients::Yes);
+ layer->did_modify_bitmap({}, Layer::NotifyClients::Yes);
- select_layer(&m_layers[selected_layer_index]);
+ select_layer(m_layers[selected_layer_index]);
m_size = { new_size.width(), new_size.height() };
did_change_rect();
@@ -699,11 +699,11 @@ Color Image::color_at(Gfx::IntPoint point) const
{
Color color;
for (auto const& layer : m_layers) {
- if (!layer.is_visible() || !layer.rect().contains(point))
+ if (!layer->is_visible() || !layer->rect().contains(point))
continue;
- auto layer_color = layer.display_bitmap().get_pixel(point);
- float layer_opacity = layer.opacity_percent() / 100.0f;
+ auto layer_color = layer->display_bitmap().get_pixel(point);
+ float layer_opacity = layer->opacity_percent() / 100.0f;
layer_color.set_alpha((u8)(layer_color.alpha() * layer_opacity));
color = color.blend(layer_color);
}
diff --git a/Userland/Applications/PixelPaint/Image.h b/Userland/Applications/PixelPaint/Image.h
index a15e3baf4f..86644f0bca 100644
--- a/Userland/Applications/PixelPaint/Image.h
+++ b/Userland/Applications/PixelPaint/Image.h
@@ -126,7 +126,7 @@ private:
ErrorOr<void> merge_active_layer(NonnullRefPtr<Layer> const&, LayerMergeDirection);
Gfx::IntSize m_size;
- NonnullRefPtrVector<Layer> m_layers;
+ Vector<NonnullRefPtr<Layer>> m_layers;
HashTable<ImageClient*> m_clients;
diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp
index dc774d68db..598e112418 100644
--- a/Userland/Applications/PixelPaint/ImageEditor.cpp
+++ b/Userland/Applications/PixelPaint/ImageEditor.cpp
@@ -187,11 +187,11 @@ void ImageEditor::paint_event(GUI::PaintEvent& event)
if (m_show_guides) {
for (auto& guide : m_guides) {
- if (guide.orientation() == Guide::Orientation::Horizontal) {
- int y_coordinate = (int)content_to_frame_position({ 0.0f, guide.offset() }).y();
+ if (guide->orientation() == Guide::Orientation::Horizontal) {
+ int y_coordinate = (int)content_to_frame_position({ 0.0f, guide->offset() }).y();
painter.draw_line({ 0, y_coordinate }, { rect().width(), y_coordinate }, Color::Cyan, 1, Gfx::Painter::LineStyle::Dashed, Color::LightGray);
- } else if (guide.orientation() == Guide::Orientation::Vertical) {
- int x_coordinate = (int)content_to_frame_position({ guide.offset(), 0.0f }).x();
+ } else if (guide->orientation() == Guide::Orientation::Vertical) {
+ int x_coordinate = (int)content_to_frame_position({ guide->offset(), 0.0f }).x();
painter.draw_line({ x_coordinate, 0 }, { x_coordinate, rect().height() }, Color::Cyan, 1, Gfx::Painter::LineStyle::Dashed, Color::LightGray);
}
}
@@ -768,10 +768,10 @@ ErrorOr<void> ImageEditor::save_project_to_file(NonnullOwnPtr<Core::File> file)
auto json_guides = TRY(json.add_array("guides"sv));
for (auto const& guide : m_guides) {
auto json_guide = TRY(json_guides.add_object());
- TRY(json_guide.add("offset"sv, (double)guide.offset()));
- if (guide.orientation() == Guide::Orientation::Vertical)
+ TRY(json_guide.add("offset"sv, (double)guide->offset()));
+ if (guide->orientation() == Guide::Orientation::Vertical)
TRY(json_guide.add("orientation"sv, "vertical"));
- else if (guide.orientation() == Guide::Orientation::Horizontal)
+ else if (guide->orientation() == Guide::Orientation::Horizontal)
TRY(json_guide.add("orientation"sv, "horizontal"));
TRY(json_guide.finish());
}
diff --git a/Userland/Applications/PixelPaint/ImageEditor.h b/Userland/Applications/PixelPaint/ImageEditor.h
index 2ea71b84ba..8951b5f4e0 100644
--- a/Userland/Applications/PixelPaint/ImageEditor.h
+++ b/Userland/Applications/PixelPaint/ImageEditor.h
@@ -94,7 +94,7 @@ public:
void save_project_as();
void save_project();
- NonnullRefPtrVector<Guide> const& guides() const { return m_guides; }
+ Vector<NonnullRefPtr<Guide>> const& guides() const { return m_guides; }
bool guide_visibility() { return m_show_guides; }
void set_guide_visibility(bool show_guides);
Function<void(bool)> on_set_guide_visibility;
@@ -168,7 +168,7 @@ private:
DeprecatedString m_path;
DeprecatedString m_title;
- NonnullRefPtrVector<Guide> m_guides;
+ Vector<NonnullRefPtr<Guide>> m_guides;
bool m_show_guides { true };
bool m_show_rulers { true };
bool m_show_pixel_grid { true };
diff --git a/Userland/Applications/PixelPaint/Tools/GuideTool.cpp b/Userland/Applications/PixelPaint/Tools/GuideTool.cpp
index ac1b5f1073..fcc45b42aa 100644
--- a/Userland/Applications/PixelPaint/Tools/GuideTool.cpp
+++ b/Userland/Applications/PixelPaint/Tools/GuideTool.cpp
@@ -24,15 +24,15 @@ RefPtr<Guide> GuideTool::closest_guide(Gfx::IntPoint point)
for (auto& guide : guides) {
int relevant_position = 0;
- if (guide.orientation() == Guide::Orientation::Horizontal)
+ if (guide->orientation() == Guide::Orientation::Horizontal)
relevant_position = point.y();
- else if (guide.orientation() == Guide::Orientation::Vertical)
+ else if (guide->orientation() == Guide::Orientation::Vertical)
relevant_position = point.x();
- auto distance = abs(relevant_position - (int)guide.offset());
+ auto distance = abs(relevant_position - (int)guide->offset());
if (distance < closest_guide_distance) {
- closest_guide = &guide;
+ closest_guide = guide;
closest_guide_distance = distance;
}
}
diff --git a/Userland/Applications/PixelPaint/Tools/TextTool.cpp b/Userland/Applications/PixelPaint/Tools/TextTool.cpp
index e8488104d9..25484f3951 100644
--- a/Userland/Applications/PixelPaint/Tools/TextTool.cpp
+++ b/Userland/Applications/PixelPaint/Tools/TextTool.cpp
@@ -30,9 +30,9 @@ void TextToolEditor::handle_keyevent(Badge<TextTool>, GUI::KeyEvent& event)
TextEditor::keydown_event(event);
}
-NonnullRefPtrVector<GUI::Action> TextToolEditor::actions()
+Vector<NonnullRefPtr<GUI::Action>> TextToolEditor::actions()
{
- static NonnullRefPtrVector<GUI::Action> actions = { cut_action(), copy_action(), paste_action(), undo_action(), redo_action(), select_all_action() };
+ static Vector<NonnullRefPtr<GUI::Action>> actions = { cut_action(), copy_action(), paste_action(), undo_action(), redo_action(), select_all_action() };
return actions;
}
@@ -290,9 +290,9 @@ bool TextTool::on_keydown(GUI::KeyEvent& event)
// Pass key events that would normally be handled by menu shortcuts to our TextEditor subclass.
for (auto& action : m_text_editor->actions()) {
- auto const& shortcut = action.shortcut();
+ auto const& shortcut = action->shortcut();
if (event.key() == shortcut.key() && event.modifiers() == shortcut.modifiers()) {
- action.activate(m_text_editor);
+ action->activate(m_text_editor);
return true;
}
}
diff --git a/Userland/Applications/PixelPaint/Tools/TextTool.h b/Userland/Applications/PixelPaint/Tools/TextTool.h
index 62b512a104..60d0cb9bad 100644
--- a/Userland/Applications/PixelPaint/Tools/TextTool.h
+++ b/Userland/Applications/PixelPaint/Tools/TextTool.h
@@ -22,7 +22,7 @@ class TextToolEditor : public GUI::TextEditor {
public:
virtual ~TextToolEditor() override = default;
virtual void handle_keyevent(Badge<TextTool>, GUI::KeyEvent&);
- NonnullRefPtrVector<GUI::Action> actions();
+ Vector<NonnullRefPtr<GUI::Action>> actions();
protected:
TextToolEditor();
diff --git a/Userland/Applications/Presenter/Slide.cpp b/Userland/Applications/Presenter/Slide.cpp
index fcbed85419..8e07961a19 100644
--- a/Userland/Applications/Presenter/Slide.cpp
+++ b/Userland/Applications/Presenter/Slide.cpp
@@ -9,7 +9,7 @@
#include "Presentation.h"
#include <AK/JsonObject.h>
-Slide::Slide(NonnullRefPtrVector<SlideObject> slide_objects, DeprecatedString title)
+Slide::Slide(Vector<NonnullRefPtr<SlideObject>> slide_objects, DeprecatedString title)
: m_slide_objects(move(slide_objects))
, m_title(move(title))
{
@@ -25,7 +25,7 @@ ErrorOr<Slide> Slide::parse_slide(JsonObject const& slide_json)
return Error::from_string_view("Slide objects must be an array"sv);
auto const& json_slide_objects = maybe_slide_objects.value();
- NonnullRefPtrVector<SlideObject> slide_objects;
+ Vector<NonnullRefPtr<SlideObject>> slide_objects;
for (auto const& maybe_slide_object_json : json_slide_objects.values()) {
if (!maybe_slide_object_json.is_object())
return Error::from_string_view("Slides must be objects"sv);
@@ -43,6 +43,6 @@ ErrorOr<HTMLElement> Slide::render(Presentation const& presentation) const
HTMLElement wrapper;
wrapper.tag_name = "div"sv;
for (auto const& object : m_slide_objects)
- TRY(wrapper.children.try_append(TRY(object.render(presentation))));
+ TRY(wrapper.children.try_append(TRY(object->render(presentation))));
return wrapper;
}
diff --git a/Userland/Applications/Presenter/Slide.h b/Userland/Applications/Presenter/Slide.h
index 8e7482b47b..013917d315 100644
--- a/Userland/Applications/Presenter/Slide.h
+++ b/Userland/Applications/Presenter/Slide.h
@@ -24,8 +24,8 @@ public:
ErrorOr<HTMLElement> render(Presentation const&) const;
private:
- Slide(NonnullRefPtrVector<SlideObject> slide_objects, DeprecatedString title);
+ Slide(Vector<NonnullRefPtr<SlideObject>> slide_objects, DeprecatedString title);
- NonnullRefPtrVector<SlideObject> m_slide_objects;
+ Vector<NonnullRefPtr<SlideObject>> m_slide_objects;
DeprecatedString m_title;
};
diff --git a/Userland/Applications/Spreadsheet/ConditionalFormatting.h b/Userland/Applications/Spreadsheet/ConditionalFormatting.h
index bcd11d8595..d6e324d91d 100644
--- a/Userland/Applications/Spreadsheet/ConditionalFormatting.h
+++ b/Userland/Applications/Spreadsheet/ConditionalFormatting.h
@@ -52,7 +52,7 @@ private:
ConditionsView();
Vector<ConditionalFormat>* m_formats { nullptr };
- NonnullRefPtrVector<GUI::Widget> m_widgets;
+ Vector<NonnullRefPtr<GUI::Widget>> m_widgets;
};
}
diff --git a/Userland/Applications/Spreadsheet/ExportDialog.cpp b/Userland/Applications/Spreadsheet/ExportDialog.cpp
index b4cfc87641..708126ed07 100644
--- a/Userland/Applications/Spreadsheet/ExportDialog.cpp
+++ b/Userland/Applications/Spreadsheet/ExportDialog.cpp
@@ -202,7 +202,7 @@ ErrorOr<void> ExportDialog::make_and_run_for(StringView mime, Core::File& file,
auto export_worksheet = [&]() -> ErrorOr<void> {
JsonArray array;
for (auto& sheet : workbook.sheets())
- array.append(sheet.to_json());
+ array.append(sheet->to_json());
auto file_content = array.to_deprecated_string();
return file.write_entire_buffer(file_content.bytes());
diff --git a/Userland/Applications/Spreadsheet/HelpWindow.cpp b/Userland/Applications/Spreadsheet/HelpWindow.cpp
index c2ae658235..168cc6c914 100644
--- a/Userland/Applications/Spreadsheet/HelpWindow.cpp
+++ b/Userland/Applications/Spreadsheet/HelpWindow.cpp
@@ -112,7 +112,7 @@ HelpWindow::HelpWindow(GUI::Window* parent)
window->set_title(DeprecatedString::formatted("Spreadsheet Help - Example {} for {}", name, entry));
window->on_close = [window = window.ptr()] { window->remove_from_parent(); };
- auto widget = window->set_main_widget<SpreadsheetWidget>(window, NonnullRefPtrVector<Sheet> {}, false).release_value_but_fixme_should_propagate_errors();
+ auto widget = window->set_main_widget<SpreadsheetWidget>(window, Vector<NonnullRefPtr<Sheet>> {}, false).release_value_but_fixme_should_propagate_errors();
auto sheet = Sheet::from_json(value, widget->workbook());
if (!sheet) {
GUI::MessageBox::show_error(this, DeprecatedString::formatted("Corrupted example '{}' in '{}'", name, url.path()));
diff --git a/Userland/Applications/Spreadsheet/ImportDialog.cpp b/Userland/Applications/Spreadsheet/ImportDialog.cpp
index 2da65ae87d..55a00335bc 100644
--- a/Userland/Applications/Spreadsheet/ImportDialog.cpp
+++ b/Userland/Applications/Spreadsheet/ImportDialog.cpp
@@ -174,13 +174,13 @@ void CSVImportDialogPage::update_preview()
m_data_preview_table_view->update();
}
-ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> ImportDialog::make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook& workbook)
+ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> ImportDialog::make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook& workbook)
{
auto wizard = GUI::WizardDialog::construct(&parent);
wizard->set_title("File Import Wizard");
wizard->set_icon(GUI::Icon::default_icon("app-spreadsheet"sv).bitmap_for_size(16));
- auto import_xsv = [&]() -> ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> {
+ auto import_xsv = [&]() -> ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> {
auto contents_or_error = file.read_until_eof();
if (contents_or_error.is_error())
return DeprecatedString::formatted("{}", contents_or_error.release_error());
@@ -191,7 +191,7 @@ ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> ImportDialog::make_and_run
if (result == GUI::Dialog::ExecResult::OK) {
auto& reader = page.reader();
- NonnullRefPtrVector<Sheet> sheets;
+ Vector<NonnullRefPtr<Sheet>> sheets;
if (reader.has_value()) {
reader->parse();
@@ -209,7 +209,7 @@ ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> ImportDialog::make_and_run
return DeprecatedString { "CSV Import was cancelled" };
};
- auto import_worksheet = [&]() -> ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> {
+ auto import_worksheet = [&]() -> ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> {
auto contents_or_error = file.read_until_eof();
if (contents_or_error.is_error())
return DeprecatedString::formatted("{}", contents_or_error.release_error());
@@ -221,7 +221,7 @@ ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> ImportDialog::make_and_run
if (!json_value.is_array())
return DeprecatedString::formatted("Did not find a spreadsheet in {}", filename);
- NonnullRefPtrVector<Sheet> sheets;
+ Vector<NonnullRefPtr<Sheet>> sheets;
auto& json_array = json_value.as_array();
json_array.for_each([&](auto& sheet_json) {
diff --git a/Userland/Applications/Spreadsheet/ImportDialog.h b/Userland/Applications/Spreadsheet/ImportDialog.h
index dba25312c6..6b883e47ae 100644
--- a/Userland/Applications/Spreadsheet/ImportDialog.h
+++ b/Userland/Applications/Spreadsheet/ImportDialog.h
@@ -55,7 +55,7 @@ private:
};
struct ImportDialog {
- static ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook&);
+ static ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook&);
};
}
diff --git a/Userland/Applications/Spreadsheet/JSIntegration.cpp b/Userland/Applications/Spreadsheet/JSIntegration.cpp
index 4e175e3145..7d6d006a35 100644
--- a/Userland/Applications/Spreadsheet/JSIntegration.cpp
+++ b/Userland/Applications/Spreadsheet/JSIntegration.cpp
@@ -390,7 +390,7 @@ void WorkbookObject::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);
for (auto& sheet : m_workbook.sheets())
- visitor.visit(&sheet.global_object());
+ visitor.visit(&sheet->global_object());
}
JS_DEFINE_NATIVE_FUNCTION(WorkbookObject::sheet)
@@ -411,13 +411,13 @@ JS_DEFINE_NATIVE_FUNCTION(WorkbookObject::sheet)
if (name_value.is_string()) {
auto name = TRY(name_value.as_string().deprecated_string());
for (auto& sheet : workbook.sheets()) {
- if (sheet.name() == name)
- return JS::Value(&sheet.global_object());
+ if (sheet->name() == name)
+ return JS::Value(&sheet->global_object());
}
} else {
auto index = TRY(name_value.to_length(vm));
if (index < workbook.sheets().size())
- return JS::Value(&workbook.sheets()[index].global_object());
+ return JS::Value(&workbook.sheets()[index]->global_object());
}
return JS::js_undefined();
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
index d0a802e1f2..a34c855148 100644
--- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
+++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
@@ -27,7 +27,7 @@
namespace Spreadsheet {
-SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVector<Sheet>&& sheets, bool should_add_sheet_if_empty)
+SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, Vector<NonnullRefPtr<Sheet>>&& sheets, bool should_add_sheet_if_empty)
: m_workbook(make<Workbook>(move(sheets), parent_window))
{
set_fill_with_background_color(true);
@@ -111,7 +111,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
m_tab_context_menu->add_action(GUI::Action::create("Add new sheet...", Gfx::Bitmap::load_from_file("/res/icons/16x16/new-tab.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
DeprecatedString name;
if (GUI::InputBox::show(window(), name, "Name for new sheet"sv, "Create sheet"sv) == GUI::Dialog::ExecResult::OK) {
- NonnullRefPtrVector<Sheet> new_sheets;
+ Vector<NonnullRefPtr<Sheet>> new_sheets;
new_sheets.append(m_workbook->add_sheet(name));
setup_tabs(move(new_sheets));
}
@@ -330,10 +330,10 @@ void SpreadsheetWidget::clipboard_content_did_change(DeprecatedString const& mim
m_paste_action->set_enabled(!sheet->selected_cells().is_empty() && mime_type.starts_with("text/"sv));
}
-void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
+void SpreadsheetWidget::setup_tabs(Vector<NonnullRefPtr<Sheet>> new_sheets)
{
for (auto& sheet : new_sheets) {
- auto& new_view = m_tab_widget->add_tab<SpreadsheetView>(sheet.name(), sheet);
+ auto& new_view = m_tab_widget->add_tab<SpreadsheetView>(sheet->name(), sheet);
new_view.model()->on_cell_data_change = [&](auto& cell, auto& previous_data) {
undo_stack().push(make<CellsUndoCommand>(cell, previous_data));
window()->set_modified(true);
@@ -570,7 +570,7 @@ void SpreadsheetWidget::add_sheet()
name.append("Sheet"sv);
name.appendff(" {}", m_workbook->sheets().size() + 1);
- NonnullRefPtrVector<Sheet> new_sheets;
+ Vector<NonnullRefPtr<Sheet>> new_sheets;
new_sheets.append(m_workbook->add_sheet(name.string_view()));
setup_tabs(move(new_sheets));
}
@@ -579,7 +579,7 @@ void SpreadsheetWidget::add_sheet(NonnullRefPtr<Sheet>&& sheet)
{
VERIFY(m_workbook == &sheet->workbook());
- NonnullRefPtrVector<Sheet> new_sheets;
+ Vector<NonnullRefPtr<Sheet>> new_sheets;
new_sheets.append(move(sheet));
m_workbook->sheets().extend(new_sheets);
setup_tabs(new_sheets);
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.h b/Userland/Applications/Spreadsheet/SpreadsheetWidget.h
index d2ad495171..d6f10c417e 100644
--- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.h
+++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.h
@@ -60,9 +60,9 @@ private:
// ^GUI::Clipboard::ClipboardClient
virtual void clipboard_content_did_change(DeprecatedString const& mime_type) override;
- explicit SpreadsheetWidget(GUI::Window& window, NonnullRefPtrVector<Sheet>&& sheets = {}, bool should_add_sheet_if_empty = true);
+ explicit SpreadsheetWidget(GUI::Window& window, Vector<NonnullRefPtr<Sheet>>&& sheets = {}, bool should_add_sheet_if_empty = true);
- void setup_tabs(NonnullRefPtrVector<Sheet> new_sheets);
+ void setup_tabs(Vector<NonnullRefPtr<Sheet>> new_sheets);
void try_generate_tip_for_input_expression(StringView source, size_t offset);
diff --git a/Userland/Applications/Spreadsheet/Workbook.cpp b/Userland/Applications/Spreadsheet/Workbook.cpp
index e7add532cc..8c85abd332 100644
--- a/Userland/Applications/Spreadsheet/Workbook.cpp
+++ b/Userland/Applications/Spreadsheet/Workbook.cpp
@@ -18,7 +18,7 @@
namespace Spreadsheet {
-Workbook::Workbook(NonnullRefPtrVector<Sheet>&& sheets, GUI::Window& parent_window)
+Workbook::Workbook(Vector<NonnullRefPtr<Sheet>>&& sheets, GUI::Window& parent_window)
: m_sheets(move(sheets))
, m_vm(JS::VM::create())
, m_interpreter(JS::Interpreter::create<JS::GlobalObject>(m_vm))
diff --git a/Userland/Applications/Spreadsheet/Workbook.h b/Userland/Applications/Spreadsheet/Workbook.h
index 84d394053d..b4d31e6be6 100644
--- a/Userland/Applications/Spreadsheet/Workbook.h
+++ b/Userland/Applications/Spreadsheet/Workbook.h
@@ -14,7 +14,7 @@ namespace Spreadsheet {
class Workbook {
public:
- Workbook(NonnullRefPtrVector<Sheet>&& sheets, GUI::Window& parent_window);
+ Workbook(Vector<NonnullRefPtr<Sheet>>&& sheets, GUI::Window& parent_window);
ErrorOr<void, DeprecatedString> open_file(String const& filename, Core::File&);
ErrorOr<void> write_to_file(String const& filename, Core::File&);
@@ -28,8 +28,8 @@ public:
bool has_sheets() const { return !m_sheets.is_empty(); }
- NonnullRefPtrVector<Sheet> const& sheets() const { return m_sheets; }
- NonnullRefPtrVector<Sheet> sheets() { return m_sheets; }
+ Vector<NonnullRefPtr<Sheet>> const& sheets() const { return m_sheets; }
+ Vector<NonnullRefPtr<Sheet>> sheets() { return m_sheets; }
Sheet& add_sheet(StringView name)
{
@@ -43,7 +43,7 @@ public:
JS::VM const& vm() const { return *m_vm; }
private:
- NonnullRefPtrVector<Sheet> m_sheets;
+ Vector<NonnullRefPtr<Sheet>> m_sheets;
NonnullRefPtr<JS::VM> m_vm;
NonnullOwnPtr<JS::Interpreter> m_interpreter;
JS::VM::InterpreterExecutionScope m_interpreter_scope;
diff --git a/Userland/Applications/Spreadsheet/main.cpp b/Userland/Applications/Spreadsheet/main.cpp
index d20d001b1e..d7599cc235 100644
--- a/Userland/Applications/Spreadsheet/main.cpp
+++ b/Userland/Applications/Spreadsheet/main.cpp
@@ -51,7 +51,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->resize(640, 480);
window->set_icon(app_icon.bitmap_for_size(16));
- auto spreadsheet_widget = TRY(window->set_main_widget<Spreadsheet::SpreadsheetWidget>(*window, NonnullRefPtrVector<Spreadsheet::Sheet> {}, filename.is_empty()));
+ auto spreadsheet_widget = TRY(window->set_main_widget<Spreadsheet::SpreadsheetWidget>(*window, Vector<NonnullRefPtr<Spreadsheet::Sheet>> {}, filename.is_empty()));
spreadsheet_widget->initialize_menubar(*window);
spreadsheet_widget->update_window_title();
diff --git a/Userland/Applications/SystemMonitor/ProcessModel.cpp b/Userland/Applications/SystemMonitor/ProcessModel.cpp
index 5f34a89cb4..c84da311f0 100644
--- a/Userland/Applications/SystemMonitor/ProcessModel.cpp
+++ b/Userland/Applications/SystemMonitor/ProcessModel.cpp
@@ -497,7 +497,7 @@ void ProcessModel::update()
thread_data->previous_state = move(thread_data->current_state);
thread_data->current_state = move(state);
if (auto maybe_thread_index = (*process_state)->threads.find_first_index(thread_data); maybe_thread_index.has_value()) {
- (*process_state)->threads.ptr_at(maybe_thread_index.value()) = thread_data;
+ (*process_state)->threads[maybe_thread_index.value()] = thread_data;
} else {
(*process_state)->threads.append(thread_data);
}
diff --git a/Userland/Applications/SystemMonitor/ProcessModel.h b/Userland/Applications/SystemMonitor/ProcessModel.h
index c9100de39f..3c659538e2 100644
--- a/Userland/Applications/SystemMonitor/ProcessModel.h
+++ b/Userland/Applications/SystemMonitor/ProcessModel.h
@@ -207,7 +207,7 @@ private:
struct Process {
pid_t pid;
- NonnullRefPtrVector<Thread> threads;
+ Vector<NonnullRefPtr<Thread>> threads;
bool operator==(Process const& other) const
{
@@ -224,7 +224,7 @@ private:
{
auto main_thread_index = -1;
for (size_t i = 0; i < threads.size(); ++i) {
- if (threads[i].is_main_thread()) {
+ if (threads[i]->is_main_thread()) {
main_thread_index = static_cast<int>(i);
break;
}
diff --git a/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.cpp b/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.cpp
index 0f8ed977c9..f52b269e32 100644
--- a/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.cpp
+++ b/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.cpp
@@ -132,7 +132,7 @@ void ProjectTemplatesModel::rescan_templates()
// Enumerate the loaded projects into a sorted mapping, by priority value descending.
m_mapping.clear();
for (auto& project_template : m_templates)
- m_mapping.append(&project_template);
+ m_mapping.append(project_template);
quick_sort(m_mapping, [](auto a, auto b) {
return a->priority() > b->priority();
});
diff --git a/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.h b/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.h
index b800760aec..a7509c4c7e 100644
--- a/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.h
+++ b/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.h
@@ -45,7 +45,7 @@ public:
private:
explicit ProjectTemplatesModel();
- NonnullRefPtrVector<ProjectTemplate> m_templates;
+ Vector<NonnullRefPtr<ProjectTemplate>> m_templates;
Vector<ProjectTemplate*> m_mapping;
RefPtr<Core::FileWatcher> m_file_watcher;
diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp
index c44145824f..e30c23ed73 100644
--- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp
+++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp
@@ -265,7 +265,7 @@ void HackStudioWidget::open_project(DeprecatedString const& root_path)
debugger.set_source_root(m_project->root_path());
}
for (auto& editor_wrapper : m_all_editor_wrappers)
- editor_wrapper.set_project_root(m_project->root_path());
+ editor_wrapper->set_project_root(m_project->root_path());
m_locations_history.clear();
m_locations_history_end_index = 0;
@@ -398,19 +398,19 @@ void HackStudioWidget::close_file_in_all_editors(DeprecatedString const& filenam
[&filename](DeprecatedString const& element) { return element == filename; });
for (auto& editor_wrapper : m_all_editor_wrappers) {
- Editor& editor = editor_wrapper.editor();
+ Editor& editor = editor_wrapper->editor();
DeprecatedString editor_file_path = editor.code_document().file_path();
DeprecatedString relative_editor_file_path = LexicalPath::relative_path(editor_file_path, project().root_path());
if (relative_editor_file_path == filename) {
if (m_open_files_vector.is_empty()) {
editor.set_document(CodeDocument::create());
- editor_wrapper.set_filename("");
+ editor_wrapper->set_filename("");
} else {
auto& first_path = m_open_files_vector[0];
auto& document = m_open_files.get(first_path).value()->code_document();
editor.set_document(document);
- editor_wrapper.set_filename(first_path);
+ editor_wrapper->set_filename(first_path);
}
}
}
@@ -713,7 +713,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_new_project_action(
// If the user wishes to save the changes, this occurs in warn_unsaved_changes. If they do not,
// we need to mark the documents as clean so open_project works properly without asking again.
for (auto& editor_wrapper : m_all_editor_wrappers)
- editor_wrapper.editor().document().set_unmodified();
+ editor_wrapper->editor().document().set_unmodified();
auto dialog = NewProjectDialog::construct(window());
dialog->set_icon(window()->icon());
auto result = dialog->exec();
@@ -754,7 +754,7 @@ void HackStudioWidget::add_new_editor_tab_widget(GUI::Widget& parent)
if (m_all_editor_tab_widgets.size() > 1) {
for (auto& widget : m_all_editor_tab_widgets)
- widget.set_close_button_enabled(true);
+ widget->set_close_button_enabled(true);
}
tab_widget->on_change = [&](auto& widget) {
@@ -914,8 +914,8 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_save_as_action()
current_editor_wrapper().set_filename(relative_file_path);
} else {
for (auto& editor_wrapper : m_all_editor_wrappers) {
- if (editor_wrapper.filename() == old_filename)
- editor_wrapper.set_filename(relative_file_path);
+ if (editor_wrapper->filename() == old_filename)
+ editor_wrapper->set_filename(relative_file_path);
}
}
current_editor_wrapper().save();
@@ -1031,7 +1031,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_debug_action()
m_run_action->set_enabled(false);
for (auto& editor_wrapper : m_all_editor_wrappers) {
- editor_wrapper.set_debug_mode(true);
+ editor_wrapper->set_debug_mode(true);
}
});
}
@@ -1083,7 +1083,7 @@ void HackStudioWidget::initialize_debugger()
m_debugger_thread.clear();
for (auto& editor_wrapper : m_all_editor_wrappers) {
- editor_wrapper.set_debug_mode(false);
+ editor_wrapper->set_debug_mode(false);
}
HackStudioWidget::hide_action_tabs();
@@ -1454,10 +1454,10 @@ ErrorOr<void> HackStudioWidget::create_edit_menu(GUI::Window& window)
auto vim_emulation_setting_action = GUI::Action::create_checkable("&Vim Emulation", { Mod_Ctrl | Mod_Shift | Mod_Alt, Key_V }, [this](auto& action) {
if (action.is_checked()) {
for (auto& editor_wrapper : m_all_editor_wrappers)
- editor_wrapper.editor().set_editing_engine(make<GUI::VimEditingEngine>());
+ editor_wrapper->editor().set_editing_engine(make<GUI::VimEditingEngine>());
} else {
for (auto& editor_wrapper : m_all_editor_wrappers)
- editor_wrapper.editor().set_editing_engine(make<GUI::RegularEditingEngine>());
+ editor_wrapper->editor().set_editing_engine(make<GUI::RegularEditingEngine>());
}
});
vim_emulation_setting_action->set_checked(false);
@@ -1506,17 +1506,17 @@ ErrorOr<void> HackStudioWidget::create_view_menu(GUI::Window& window)
m_no_wrapping_action = GUI::Action::create_checkable("&No Wrapping", [&](auto&) {
m_wrapping_mode = GUI::TextEditor::WrappingMode::NoWrap;
for (auto& wrapper : m_all_editor_wrappers)
- wrapper.editor().set_wrapping_mode(GUI::TextEditor::WrappingMode::NoWrap);
+ wrapper->editor().set_wrapping_mode(GUI::TextEditor::WrappingMode::NoWrap);
});
m_wrap_anywhere_action = GUI::Action::create_checkable("Wrap &Anywhere", [&](auto&) {
m_wrapping_mode = GUI::TextEditor::WrappingMode::WrapAnywhere;
for (auto& wrapper : m_all_editor_wrappers)
- wrapper.editor().set_wrapping_mode(GUI::TextEditor::WrappingMode::WrapAnywhere);
+ wrapper->editor().set_wrapping_mode(GUI::TextEditor::WrappingMode::WrapAnywhere);
});
m_wrap_at_words_action = GUI::Action::create_checkable("Wrap at &Words", [&](auto&) {
m_wrapping_mode = GUI::TextEditor::WrappingMode::WrapAtWords;
for (auto& wrapper : m_all_editor_wrappers)
- wrapper.editor().set_wrapping_mode(GUI::TextEditor::WrappingMode::WrapAtWords);
+ wrapper->editor().set_wrapping_mode(GUI::TextEditor::WrappingMode::WrapAtWords);
});
m_wrapping_mode_actions.add_action(*m_no_wrapping_action);
@@ -1668,8 +1668,8 @@ HackStudioWidget::ContinueDecision HackStudioWidget::warn_unsaved_changes(Deprec
if (result == GUI::MessageBox::ExecResult::Yes) {
for (auto& editor_wrapper : m_all_editor_wrappers) {
- if (editor_wrapper.editor().document().is_modified()) {
- editor_wrapper.save();
+ if (editor_wrapper->editor().document().is_modified()) {
+ editor_wrapper->save();
}
}
}
@@ -1680,7 +1680,7 @@ HackStudioWidget::ContinueDecision HackStudioWidget::warn_unsaved_changes(Deprec
bool HackStudioWidget::any_document_is_dirty() const
{
return any_of(m_all_editor_wrappers, [](auto& editor_wrapper) {
- return editor_wrapper.editor().document().is_modified();
+ return editor_wrapper->editor().document().is_modified();
});
}
@@ -1858,7 +1858,7 @@ void HackStudioWidget::change_editor_font(RefPtr<Gfx::Font const> font)
{
m_editor_font = move(font);
for (auto& editor_wrapper : m_all_editor_wrappers) {
- editor_wrapper.editor().set_font(*m_editor_font);
+ editor_wrapper->editor().set_font(*m_editor_font);
}
Config::write_string("HackStudio"sv, "EditorFont"sv, "Family"sv, m_editor_font->family());
@@ -1893,7 +1893,7 @@ void HackStudioWidget::debug_process(pid_t pid)
m_run_action->set_enabled(false);
for (auto& editor_wrapper : m_all_editor_wrappers) {
- editor_wrapper.set_debug_mode(true);
+ editor_wrapper->set_debug_mode(true);
}
}
@@ -1909,7 +1909,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_toggle_syntax_highl
auto icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-cplusplus.png"sv));
auto action = GUI::Action::create_checkable("&Semantic Highlighting", icon, [this](auto& action) {
for (auto& editor_wrapper : m_all_editor_wrappers)
- editor_wrapper.editor().set_semantic_syntax_highlighting(action.is_checked());
+ editor_wrapper->editor().set_semantic_syntax_highlighting(action.is_checked());
});
return action;
diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.h b/Userland/DevTools/HackStudio/HackStudioWidget.h
index e2f403a8f9..d54b375472 100644
--- a/Userland/DevTools/HackStudio/HackStudioWidget.h
+++ b/Userland/DevTools/HackStudio/HackStudioWidget.h
@@ -177,9 +177,9 @@ private:
ProjectLocation current_project_location() const;
void update_history_actions();
- NonnullRefPtrVector<EditorWrapper> m_all_editor_wrappers;
+ Vector<NonnullRefPtr<EditorWrapper>> m_all_editor_wrappers;
RefPtr<EditorWrapper> m_current_editor_wrapper;
- NonnullRefPtrVector<GUI::TabWidget> m_all_editor_tab_widgets;
+ Vector<NonnullRefPtr<GUI::TabWidget>> m_all_editor_tab_widgets;
RefPtr<GUI::TabWidget> m_current_editor_tab_widget;
HashMap<DeprecatedString, NonnullRefPtr<ProjectFile>> m_open_files;
@@ -217,7 +217,7 @@ private:
RefPtr<EditorWrapper> m_current_editor_in_execution;
RefPtr<GUI::Menu> m_recent_projects_submenu { nullptr };
- NonnullRefPtrVector<GUI::Action> m_new_file_actions;
+ Vector<NonnullRefPtr<GUI::Action>> m_new_file_actions;
RefPtr<GUI::Action> m_new_plain_file_action;
RefPtr<GUI::Action> m_new_directory_action;
diff --git a/Userland/Games/Hearts/Game.cpp b/Userland/Games/Hearts/Game.cpp
index dcaafcbf42..f84646d62b 100644
--- a/Userland/Games/Hearts/Game.cpp
+++ b/Userland/Games/Hearts/Game.cpp
@@ -197,7 +197,7 @@ void Game::setup(DeprecatedString player_name, int hand_number)
m_passing_button->set_focus(false);
}
- NonnullRefPtrVector<Card> deck = Cards::create_standard_deck(Cards::Shuffle::Yes).release_value_but_fixme_should_propagate_errors();
+ Vector<NonnullRefPtr<Card>> deck = Cards::create_standard_deck(Cards::Shuffle::Yes).release_value_but_fixme_should_propagate_errors();
for (auto& player : m_players) {
player.hand.ensure_capacity(Card::card_count);
@@ -220,7 +220,7 @@ void Game::setup(DeprecatedString player_name, int hand_number)
continue_game_after_delay();
}
-void Game::start_animation(NonnullRefPtrVector<Card> cards, Gfx::IntPoint end, Function<void()> did_finish_callback, int initial_delay_ms, int steps)
+void Game::start_animation(Vector<NonnullRefPtr<Card>> cards, Gfx::IntPoint end, Function<void()> did_finish_callback, int initial_delay_ms, int steps)
{
stop_animation();
@@ -229,7 +229,7 @@ void Game::start_animation(NonnullRefPtrVector<Card> cards, Gfx::IntPoint end, F
m_animation_steps = steps;
m_animation_cards.clear_with_capacity();
for (auto& card : cards)
- m_animation_cards.empend(card, card.position());
+ m_animation_cards.empend(card, card->position());
m_animation_did_finish = make<Function<void()>>(move(did_finish_callback));
m_animation_delay_timer = Core::Timer::create_single_shot(initial_delay_ms, [&] {
m_animation_playing = true;
@@ -338,17 +338,17 @@ size_t Game::pick_card(Player& player)
return player.pick_lead_card(move(valid_card), move(prefer_card));
}
}
- auto* high_card = &m_trick[0];
+ auto* high_card = m_trick[0].ptr();
for (auto& card : m_trick)
- if (high_card->suit() == card.suit() && hearts_card_value(card) > hearts_card_value(*high_card))
- high_card = &card;
+ if (high_card->suit() == card->suit() && hearts_card_value(card) > hearts_card_value(*high_card))
+ high_card = card;
if (high_card->suit() == Cards::Suit::Spades && hearts_card_value(*high_card) > CardValue::Queen)
RETURN_CARD_IF_VALID(player.pick_specific_card(Cards::Suit::Spades, CardValue::Queen));
auto card_has_points = [](Card& card) { return hearts_card_points(card) > 0; };
auto trick_has_points = m_trick.first_matching(card_has_points).has_value();
bool is_trailing_player = m_trick.size() == 3;
if (!trick_has_points && is_trailing_player) {
- RETURN_CARD_IF_VALID(player.pick_low_points_high_value_card(m_trick[0].suit()));
+ RETURN_CARD_IF_VALID(player.pick_low_points_high_value_card(m_trick[0]->suit()));
if (is_first_trick)
return player.pick_low_points_high_value_card().value();
else {
@@ -523,11 +523,11 @@ void Game::advance_game()
return;
}
- auto leading_card_suit = m_trick[0].suit();
+ auto leading_card_suit = m_trick[0]->suit();
size_t taker_index = 0;
auto taker_value = hearts_card_value(m_trick[0]);
for (size_t i = 1; i < 4; i++) {
- if (m_trick[i].suit() != leading_card_suit)
+ if (m_trick[i]->suit() != leading_card_suit)
continue;
if (hearts_card_value(m_trick[i]) <= taker_value)
continue;
@@ -608,7 +608,7 @@ void Game::play_card(Player& player, size_t card_index)
VERIFY(m_leading_player);
size_t leading_player_index = player_index(*m_leading_player);
- NonnullRefPtrVector<Card> cards;
+ Vector<NonnullRefPtr<Card>> cards;
cards.append(*card);
start_animation(
cards,
@@ -661,7 +661,7 @@ bool Game::is_valid_play(Player& player, Card& card, DeprecatedString* explanati
}
// Player must follow suit unless they don't have any matching cards.
- auto leading_card_suit = m_trick[0].suit();
+ auto leading_card_suit = m_trick[0]->suit();
if (leading_card_suit == card.suit())
return true;
auto has_matching_card = player.has_card_of_suit(leading_card_suit);
@@ -818,13 +818,13 @@ void Game::select_cards_for_passing()
void Game::pass_cards()
{
- NonnullRefPtrVector<Card> first_player_cards;
+ Vector<NonnullRefPtr<Card>> first_player_cards;
for (auto& card : m_cards_highlighted)
first_player_cards.append(*card);
clear_highlighted_cards();
VERIFY(first_player_cards.size() == 3);
- NonnullRefPtrVector<Card> passed_cards[4];
+ Vector<NonnullRefPtr<Card>> passed_cards[4];
passed_cards[0] = first_player_cards;
passed_cards[1] = m_players[1].pick_cards_to_pass(passing_direction());
passed_cards[2] = m_players[2].pick_cards_to_pass(passing_direction());
@@ -852,7 +852,7 @@ void Game::pass_cards()
for (auto& card : passed_cards[i]) {
m_players[destination_player_index].hand.append(card);
if constexpr (!HEARTS_DEBUG)
- card.set_upside_down(destination_player_index != 0);
+ card->set_upside_down(destination_player_index != 0);
if (destination_player_index == 0)
highlight_card(card);
}
@@ -911,7 +911,7 @@ void Game::paint_event(GUI::PaintEvent& event)
}
for (size_t i = 0; i < m_trick.size(); i++)
- m_trick[i].paint(painter);
+ m_trick[i]->paint(painter);
}
void Game::dump_state() const
diff --git a/Userland/Games/Hearts/Game.h b/Userland/Games/Hearts/Game.h
index 506d50917a..0f05766981 100644
--- a/Userland/Games/Hearts/Game.h
+++ b/Userland/Games/Hearts/Game.h
@@ -64,7 +64,7 @@ private:
void pass_cards();
PassingDirection passing_direction() const;
- void start_animation(NonnullRefPtrVector<Card> cards, Gfx::IntPoint end, Function<void()> did_finish_callback, int initial_delay_ms, int steps = 30);
+ void start_animation(Vector<NonnullRefPtr<Card>> cards, Gfx::IntPoint end, Function<void()> did_finish_callback, int initial_delay_ms, int steps = 30);
void stop_animation();
virtual void paint_event(GUI::PaintEvent&) override;
@@ -92,7 +92,7 @@ private:
HashTable<NonnullRefPtr<Card>> m_cards_highlighted;
Player m_players[4];
- NonnullRefPtrVector<Card> m_trick;
+ Vector<NonnullRefPtr<Card>> m_trick;
Player* m_leading_player { nullptr };
u8 m_trick_number { 0 };
RefPtr<Core::Timer> m_delay_timer;
diff --git a/Userland/Games/Hearts/Player.cpp b/Userland/Games/Hearts/Player.cpp
index 5feb78f7e7..7a72f1063b 100644
--- a/Userland/Games/Hearts/Player.cpp
+++ b/Userland/Games/Hearts/Player.cpp
@@ -25,10 +25,10 @@ static bool compare_card_points_and_value(CardWithIndex& cwi1, CardWithIndex& cw
return false;
}
-NonnullRefPtrVector<Card> Player::pick_cards_to_pass(PassingDirection)
+Vector<NonnullRefPtr<Card>> Player::pick_cards_to_pass(PassingDirection)
{
auto sorted_hand = hand_sorted_by_fn(compare_card_value);
- NonnullRefPtrVector<Card> cards;
+ Vector<NonnullRefPtr<Card>> cards;
cards.append(*sorted_hand[0].card);
cards.append(*sorted_hand[1].card);
cards.append(*sorted_hand[2].card);
@@ -158,11 +158,11 @@ bool Player::has_card_of_suit(Cards::Suit suit)
return matching_card.has_value();
}
-void Player::remove_cards(NonnullRefPtrVector<Card> const& cards)
+void Player::remove_cards(Vector<NonnullRefPtr<Card>> const& cards)
{
for (auto& card : cards) {
hand.remove_first_matching([&card](auto& other_card) {
- return other_card.ptr() == &card;
+ return other_card == card;
});
}
}
diff --git a/Userland/Games/Hearts/Player.h b/Userland/Games/Hearts/Player.h
index 9c6746728f..2a7b576d00 100644
--- a/Userland/Games/Hearts/Player.h
+++ b/Userland/Games/Hearts/Player.h
@@ -33,7 +33,7 @@ public:
{
}
- NonnullRefPtrVector<Card> pick_cards_to_pass(PassingDirection);
+ Vector<NonnullRefPtr<Card>> pick_cards_to_pass(PassingDirection);
size_t pick_lead_card(Function<bool(Card&)>, Function<bool(Card&)>);
Optional<size_t> pick_low_points_high_value_card(Optional<Cards::Suit> suit = {});
Optional<size_t> pick_lower_value_card(Card& other_card);
@@ -45,7 +45,7 @@ public:
Vector<CardWithIndex> hand_sorted_by_fn(bool (*)(CardWithIndex&, CardWithIndex&)) const;
void sort_hand() { quick_sort(hand, hearts_card_less); }
- void remove_cards(NonnullRefPtrVector<Card> const& cards);
+ void remove_cards(Vector<NonnullRefPtr<Card>> const& cards);
Vector<RefPtr<Card>> hand;
Vector<RefPtr<Card>> cards_taken;
diff --git a/Userland/Games/Snake/Game.cpp b/Userland/Games/Snake/Game.cpp
index f7fc81900b..782b371983 100644
--- a/Userland/Games/Snake/Game.cpp
+++ b/Userland/Games/Snake/Game.cpp
@@ -53,7 +53,7 @@ ErrorOr<NonnullRefPtr<Game>> Game::try_create()
"/res/emoji/U+1FAB1.png"sv,
};
- NonnullRefPtrVector<Gfx::Bitmap> food_bitmaps;
+ Vector<NonnullRefPtr<Gfx::Bitmap>> food_bitmaps;
TRY(food_bitmaps.try_ensure_capacity(food_bitmaps_files.size()));
for (auto file : food_bitmaps_files) {
@@ -69,7 +69,7 @@ ErrorOr<NonnullRefPtr<Game>> Game::try_create()
return adopt_nonnull_ref_or_enomem(new (nothrow) Game(move(food_bitmaps)));
}
-Game::Game(NonnullRefPtrVector<Gfx::Bitmap> food_bitmaps)
+Game::Game(Vector<NonnullRefPtr<Gfx::Bitmap>> food_bitmaps)
: m_food_bitmaps(move(food_bitmaps))
{
set_font(Gfx::FontDatabase::default_fixed_width_font().bold_variant());
@@ -263,7 +263,7 @@ void Game::paint_event(GUI::PaintEvent& event)
painter.fill_rect(bottom_side, m_snake_base_color.darkened(0.55));
}
- painter.draw_scaled_bitmap(cell_rect(m_fruit), m_food_bitmaps[m_fruit_type], m_food_bitmaps[m_fruit_type].rect());
+ painter.draw_scaled_bitmap(cell_rect(m_fruit), m_food_bitmaps[m_fruit_type], m_food_bitmaps[m_fruit_type]->rect());
}
void Game::game_over()
diff --git a/Userland/Games/Snake/Game.h b/Userland/Games/Snake/Game.h
index 5244fadc7c..0e4b91c065 100644
--- a/Userland/Games/Snake/Game.h
+++ b/Userland/Games/Snake/Game.h
@@ -30,7 +30,7 @@ public:
Function<bool(u32)> on_score_update;
private:
- explicit Game(NonnullRefPtrVector<Gfx::Bitmap> food_bitmaps);
+ explicit Game(Vector<NonnullRefPtr<Gfx::Bitmap>> food_bitmaps);
virtual void paint_event(GUI::PaintEvent&) override;
virtual void keydown_event(GUI::KeyEvent&) override;
@@ -76,7 +76,7 @@ private:
unsigned m_score { 0 };
bool m_is_new_high_score { false };
- NonnullRefPtrVector<Gfx::Bitmap> m_food_bitmaps;
+ Vector<NonnullRefPtr<Gfx::Bitmap>> m_food_bitmaps;
Gfx::Color m_snake_base_color { Color::Yellow };
};
diff --git a/Userland/Games/Solitaire/Game.cpp b/Userland/Games/Solitaire/Game.cpp
index 3b74ae3020..e85631c4d9 100644
--- a/Userland/Games/Solitaire/Game.cpp
+++ b/Userland/Games/Solitaire/Game.cpp
@@ -172,7 +172,7 @@ void Game::setup(Mode mode)
on_game_end(GameOverReason::NewGame, m_score);
for (auto& stack : stacks())
- stack.clear();
+ stack->clear();
m_new_deck.clear();
m_new_game_animation_pile = 0;
@@ -256,14 +256,14 @@ void Game::mousedown_event(GUI::MouseEvent& event)
auto click_location = event.position();
for (auto& to_check : stacks()) {
- if (to_check.type() == CardStack::Type::Waste)
+ if (to_check->type() == CardStack::Type::Waste)
continue;
- if (to_check.bounding_box().contains(click_location)) {
- if (to_check.type() == CardStack::Type::Stock) {
+ if (to_check->bounding_box().contains(click_location)) {
+ if (to_check->type() == CardStack::Type::Stock) {
draw_cards();
- } else if (!to_check.is_empty()) {
- auto& top_card = to_check.peek();
+ } else if (!to_check->is_empty()) {
+ auto& top_card = to_check->peek();
if (top_card.is_upside_down()) {
if (top_card.rect().contains(click_location)) {
@@ -356,8 +356,8 @@ void Game::mousemove_event(GUI::MouseEvent& event)
for (auto& to_intersect : moving_cards()) {
mark_intersecting_stacks_dirty(to_intersect);
- to_intersect.rect().translate_by(dx, dy);
- update(to_intersect.rect());
+ to_intersect->rect().translate_by(dx, dy);
+ update(to_intersect->rect());
}
m_mouse_down_location = click_location;
@@ -380,11 +380,11 @@ void Game::doubleclick_event(GUI::MouseEvent& event)
auto click_location = event.position();
for (auto& to_check : stacks()) {
- if (to_check.type() != CardStack::Type::Normal && to_check.type() != CardStack::Type::Play)
+ if (to_check->type() != CardStack::Type::Normal && to_check->type() != CardStack::Type::Play)
continue;
- if (to_check.bounding_box().contains(click_location) && !to_check.is_empty()) {
- auto& top_card = to_check.peek();
+ if (to_check->bounding_box().contains(click_location) && !to_check->is_empty()) {
+ auto& top_card = to_check->peek();
if (!top_card.is_upside_down() && top_card.rect().contains(click_location))
attempt_to_move_card_to_foundations(to_check);
@@ -418,7 +418,7 @@ void Game::draw_cards()
update(waste.bounding_box());
update(play.bounding_box());
- NonnullRefPtrVector<Card> moved_cards;
+ Vector<NonnullRefPtr<Card>> moved_cards;
while (!play.is_empty()) {
auto card = play.pop();
stock.push(card).release_value_but_fixme_should_propagate_errors();
@@ -458,7 +458,7 @@ void Game::draw_cards()
update(stock.bounding_box());
- NonnullRefPtrVector<Card> cards_drawn;
+ Vector<NonnullRefPtr<Card>> cards_drawn;
for (size_t i = 0; (i < cards_to_draw) && !stock.is_empty(); ++i) {
auto card = stock.pop();
cards_drawn.prepend(card);
@@ -509,7 +509,7 @@ bool Game::attempt_to_move_card_to_foundations(CardStack& from)
mark_intersecting_stacks_dirty(card);
foundation.push(card).release_value_but_fixme_should_propagate_errors();
- NonnullRefPtrVector<Card> moved_card;
+ Vector<NonnullRefPtr<Card>> moved_card;
moved_card.append(card);
remember_move_for_undo(from, foundation, moved_card);
@@ -538,7 +538,7 @@ void Game::auto_move_eligible_cards_to_foundations()
while (true) {
bool card_was_moved = false;
for (auto& to_check : stacks()) {
- if (to_check.type() != CardStack::Type::Normal && to_check.type() != CardStack::Type::Play)
+ if (to_check->type() != CardStack::Type::Normal && to_check->type() != CardStack::Type::Play)
continue;
if (attempt_to_move_card_to_foundations(to_check))
@@ -567,17 +567,17 @@ void Game::paint_event(GUI::PaintEvent& event)
if (is_moving_cards()) {
for (auto& card : moving_cards())
- card.clear(painter, background_color);
+ card->clear(painter, background_color);
}
for (auto& stack : stacks()) {
- stack.paint(painter, background_color);
+ stack->paint(painter, background_color);
}
if (is_moving_cards()) {
for (auto& card : moving_cards()) {
- card.paint(painter);
- card.save_old_position();
+ card->paint(painter);
+ card->save_old_position();
}
}
@@ -585,14 +585,14 @@ void Game::paint_event(GUI::PaintEvent& event)
if (is_moving_cards()) {
check_for_game_over();
for (auto& card : moving_cards())
- card.set_moving(false);
+ card->set_moving(false);
}
clear_moving_cards();
}
}
-void Game::remember_move_for_undo(CardStack& from, CardStack& to, NonnullRefPtrVector<Card> moved_cards)
+void Game::remember_move_for_undo(CardStack& from, CardStack& to, Vector<NonnullRefPtr<Card>> moved_cards)
{
m_last_move.type = LastMove::Type::MoveCards;
m_last_move.from = &from;
@@ -604,7 +604,7 @@ void Game::remember_move_for_undo(CardStack& from, CardStack& to, NonnullRefPtrV
void Game::remember_flip_for_undo(Card& card)
{
- NonnullRefPtrVector<Card> cards;
+ Vector<NonnullRefPtr<Card>> cards;
cards.append(card);
m_last_move.type = LastMove::Type::FlipCard;
m_last_move.cards = cards;
@@ -618,7 +618,7 @@ void Game::perform_undo()
return;
if (m_last_move.type == LastMove::Type::FlipCard) {
- m_last_move.cards.at(0).set_upside_down(true);
+ m_last_move.cards[0]->set_upside_down(true);
if (on_undo_availability_change)
on_undo_availability_change(false);
invalidate_layout();
@@ -641,7 +641,7 @@ void Game::perform_undo()
if (m_last_move.from->type() == CardStack::Type::Stock) {
auto& waste = stack_at_location(Waste);
auto& play = stack_at_location(Play);
- NonnullRefPtrVector<Card> cards_popped;
+ Vector<NonnullRefPtr<Card>> cards_popped;
for (size_t i = 0; i < m_last_move.cards.size(); i++) {
if (!waste.is_empty()) {
auto card = waste.pop();
diff --git a/Userland/Games/Solitaire/Game.h b/Userland/Games/Solitaire/Game.h
index 8e73da4969..a0a885289f 100644
--- a/Userland/Games/Solitaire/Game.h
+++ b/Userland/Games/Solitaire/Game.h
@@ -130,7 +130,7 @@ private:
Type type { Type::Invalid };
CardStack* from { nullptr };
- NonnullRefPtrVector<Card> cards;
+ Vector<NonnullRefPtr<Card>> cards;
CardStack* to { nullptr };
};
@@ -173,7 +173,7 @@ private:
void score_move(CardStack& from, CardStack& to, bool inverse = false);
void score_flip(bool inverse = false);
- void remember_move_for_undo(CardStack& from, CardStack& to, NonnullRefPtrVector<Card> moved_cards);
+ void remember_move_for_undo(CardStack& from, CardStack& to, Vector<NonnullRefPtr<Card>> moved_cards);
void remember_flip_for_undo(Card& card);
void update_score(int to_add);
void draw_cards();
@@ -200,7 +200,7 @@ private:
Mode m_mode { Mode::SingleCardDraw };
LastMove m_last_move;
- NonnullRefPtrVector<Card> m_new_deck;
+ Vector<NonnullRefPtr<Card>> m_new_deck;
Gfx::IntPoint m_mouse_down_location;
bool m_mouse_down { false };
diff --git a/Userland/Games/Spider/Game.cpp b/Userland/Games/Spider/Game.cpp
index 0c624db7bd..d474186e43 100644
--- a/Userland/Games/Spider/Game.cpp
+++ b/Userland/Games/Spider/Game.cpp
@@ -50,7 +50,7 @@ void Game::setup(Mode mode)
on_game_end(GameOverReason::NewGame, m_score);
for (auto& stack : stacks())
- stack.clear();
+ stack->clear();
m_new_game_animation_pile = 0;
@@ -91,7 +91,7 @@ void Game::perform_undo()
if (!m_last_move.was_visible)
m_last_move.from->peek().set_upside_down(true);
- NonnullRefPtrVector<Card> cards;
+ Vector<NonnullRefPtr<Card>> cards;
for (size_t i = 0; i < m_last_move.card_count; i++)
cards.append(m_last_move.to->pop());
for (ssize_t i = m_last_move.card_count - 1; i >= 0; i--)
@@ -146,18 +146,18 @@ void Game::detect_full_stacks()
Color color;
for (size_t i = current_pile.stack().size(); i > 0; i--) {
auto& card = current_pile.stack().at(i - 1);
- if (card.is_upside_down())
+ if (card->is_upside_down())
break;
if (!started) {
- if (card.rank() != Cards::Rank::Ace)
+ if (card->rank() != Cards::Rank::Ace)
break;
started = true;
- color = card.color();
- } else if (to_underlying(card.rank()) != last_value + 1 || card.color() != color) {
+ color = card->color();
+ } else if (to_underlying(card->rank()) != last_value + 1 || card->color() != color) {
break;
- } else if (card.rank() == Cards::Rank::King) {
+ } else if (card->rank() == Cards::Rank::King) {
// we have a full set
auto original_current_rect = current_pile.bounding_box();
@@ -177,7 +177,7 @@ void Game::detect_full_stacks()
on_undo_availability_change(false);
}
- last_value = to_underlying(card.rank());
+ last_value = to_underlying(card->rank());
}
}
@@ -212,24 +212,24 @@ void Game::paint_event(GUI::PaintEvent& event)
if (is_moving_cards()) {
for (auto& card : moving_cards())
- card.clear(painter, background_color);
+ card->clear(painter, background_color);
}
for (auto& stack : stacks()) {
- stack.paint(painter, background_color);
+ stack->paint(painter, background_color);
}
if (is_moving_cards()) {
for (auto& card : moving_cards()) {
- card.paint(painter);
- card.save_old_position();
+ card->paint(painter);
+ card->save_old_position();
}
}
if (!m_mouse_down) {
if (is_moving_cards()) {
for (auto& card : moving_cards())
- card.set_moving(false);
+ card->set_moving(false);
}
clear_moving_cards();
}
@@ -255,15 +255,15 @@ void Game::mousedown_event(GUI::MouseEvent& event)
auto click_location = event.position();
for (auto& to_check : stacks()) {
- if (to_check.type() == CardStack::Type::Waste)
+ if (to_check->type() == CardStack::Type::Waste)
continue;
- if (to_check.bounding_box().contains(click_location)) {
- if (to_check.type() == CardStack::Type::Stock) {
+ if (to_check->bounding_box().contains(click_location)) {
+ if (to_check->type() == CardStack::Type::Stock) {
start_timer_if_necessary();
draw_cards();
- } else if (!to_check.is_empty()) {
- auto& top_card = to_check.peek();
+ } else if (!to_check->is_empty()) {
+ auto& top_card = to_check->peek();
if (top_card.is_upside_down()) {
if (top_card.rect().contains(click_location)) {
@@ -312,7 +312,7 @@ void Game::mouseup_event(GUI::MouseEvent& event)
if (stack == moving_cards_source_stack())
continue;
- if (stack.is_allowed_to_push(moving_cards().at(0), moving_cards().size(), Cards::CardStack::MovementRule::Any) && !stack.is_empty()) {
+ if (stack->is_allowed_to_push(moving_cards().at(0), moving_cards().size(), Cards::CardStack::MovementRule::Any) && !stack->is_empty()) {
move_focused_cards(stack);
rebound = false;
@@ -361,8 +361,8 @@ void Game::mousemove_event(GUI::MouseEvent& event)
for (auto& to_intersect : moving_cards()) {
mark_intersecting_stacks_dirty(to_intersect);
- to_intersect.rect().translate_by(dx, dy);
- update(to_intersect.rect());
+ to_intersect->rect().translate_by(dx, dy);
+ update(to_intersect->rect());
}
m_mouse_down_location = click_location;
diff --git a/Userland/Games/Spider/Game.h b/Userland/Games/Spider/Game.h
index cdf6d9bd61..9223e9eff9 100644
--- a/Userland/Games/Spider/Game.h
+++ b/Userland/Games/Spider/Game.h
@@ -104,7 +104,7 @@ private:
Mode m_mode { Mode::SingleSuit };
LastMove m_last_move;
- NonnullRefPtrVector<Card> m_new_deck;
+ Vector<NonnullRefPtr<Card>> m_new_deck;
Gfx::IntPoint m_mouse_down_location;
bool m_mouse_down { false };
diff --git a/Userland/Libraries/LibCards/Card.cpp b/Userland/Libraries/LibCards/Card.cpp
index b6fc71826b..79a95a0ff2 100644
--- a/Userland/Libraries/LibCards/Card.cpp
+++ b/Userland/Libraries/LibCards/Card.cpp
@@ -55,14 +55,14 @@ void Card::clear_and_paint(GUI::Painter& painter, Color background_color, bool h
save_old_position();
}
-ErrorOr<NonnullRefPtrVector<Card>> create_standard_deck(Shuffle shuffle)
+ErrorOr<Vector<NonnullRefPtr<Card>>> create_standard_deck(Shuffle shuffle)
{
return create_deck(1, 1, 1, 1, shuffle);
}
-ErrorOr<NonnullRefPtrVector<Card>> create_deck(unsigned full_club_suit_count, unsigned full_diamond_suit_count, unsigned full_heart_suit_count, unsigned full_spade_suit_count, Shuffle shuffle)
+ErrorOr<Vector<NonnullRefPtr<Card>>> create_deck(unsigned full_club_suit_count, unsigned full_diamond_suit_count, unsigned full_heart_suit_count, unsigned full_spade_suit_count, Shuffle shuffle)
{
- NonnullRefPtrVector<Card> deck;
+ Vector<NonnullRefPtr<Card>> deck;
TRY(deck.try_ensure_capacity(Card::card_count * (full_club_suit_count + full_diamond_suit_count + full_heart_suit_count + full_spade_suit_count)));
auto add_cards_for_suit = [&deck](Cards::Suit suit, unsigned number_of_suits) -> ErrorOr<void> {
diff --git a/Userland/Libraries/LibCards/Card.h b/Userland/Libraries/LibCards/Card.h
index 2c828a91de..7bf0570ec8 100644
--- a/Userland/Libraries/LibCards/Card.h
+++ b/Userland/Libraries/LibCards/Card.h
@@ -131,8 +131,8 @@ enum class Shuffle {
No,
Yes,
};
-ErrorOr<NonnullRefPtrVector<Card>> create_standard_deck(Shuffle);
-ErrorOr<NonnullRefPtrVector<Card>> create_deck(unsigned full_club_suit_count, unsigned full_diamond_suit_count, unsigned full_heart_suit_count, unsigned full_spade_suit_count, Shuffle);
+ErrorOr<Vector<NonnullRefPtr<Card>>> create_standard_deck(Shuffle);
+ErrorOr<Vector<NonnullRefPtr<Card>>> create_deck(unsigned full_club_suit_count, unsigned full_diamond_suit_count, unsigned full_heart_suit_count, unsigned full_spade_suit_count, Shuffle);
}
diff --git a/Userland/Libraries/LibCards/CardGame.cpp b/Userland/Libraries/LibCards/CardGame.cpp
index 9bc6961ea3..cae16a8d7b 100644
--- a/Userland/Libraries/LibCards/CardGame.cpp
+++ b/Userland/Libraries/LibCards/CardGame.cpp
@@ -36,8 +36,8 @@ CardGame::CardGame()
void CardGame::mark_intersecting_stacks_dirty(Cards::Card const& intersecting_card)
{
for (auto& stack : stacks()) {
- if (intersecting_card.rect().intersects(stack.bounding_box()))
- update(stack.bounding_box());
+ if (intersecting_card.rect().intersects(stack->bounding_box()))
+ update(stack->bounding_box());
}
update(intersecting_card.rect());
@@ -49,7 +49,7 @@ Gfx::IntRect CardGame::moving_cards_bounds() const
return {};
// Note: This assumes that the cards are arranged in a line.
- return m_moving_cards.first().rect().united(m_moving_cards.last().rect());
+ return m_moving_cards.first()->rect().united(m_moving_cards.last()->rect());
}
ErrorOr<void> CardGame::pick_up_cards_from_stack(Cards::CardStack& stack, Gfx::IntPoint click_location, CardStack::MovementRule movement_rule)
@@ -70,10 +70,10 @@ RefPtr<CardStack> CardGame::find_stack_to_drop_on(CardStack::MovementRule moveme
if (stack == moving_cards_source_stack())
continue;
- if (stack.bounding_box().intersects(bounds_to_check)
- && stack.is_allowed_to_push(moving_cards().at(0), moving_cards().size(), movement_rule)) {
+ if (stack->bounding_box().intersects(bounds_to_check)
+ && stack->is_allowed_to_push(moving_cards().at(0), moving_cards().size(), movement_rule)) {
- auto distance = bounds_to_check.center().distance_from(stack.bounding_box().center());
+ auto distance = bounds_to_check.center().distance_from(stack->bounding_box().center());
if (distance < closest_distance) {
closest_stack = stack;
closest_distance = distance;
diff --git a/Userland/Libraries/LibCards/CardGame.h b/Userland/Libraries/LibCards/CardGame.h
index eeebfef031..226e441e8f 100644
--- a/Userland/Libraries/LibCards/CardGame.h
+++ b/Userland/Libraries/LibCards/CardGame.h
@@ -25,8 +25,8 @@ public:
Gfx::Color background_color() const;
void set_background_color(Gfx::Color);
- NonnullRefPtrVector<CardStack>& stacks() { return m_stacks; }
- NonnullRefPtrVector<CardStack> const& stacks() const { return m_stacks; }
+ Vector<NonnullRefPtr<CardStack>>& stacks() { return m_stacks; }
+ Vector<NonnullRefPtr<CardStack>> const& stacks() const { return m_stacks; }
CardStack& stack_at_location(int location) { return m_stacks[location]; }
template<class... Args>
@@ -38,8 +38,8 @@ public:
void mark_intersecting_stacks_dirty(Card const& intersecting_card);
bool is_moving_cards() const { return !m_moving_cards.is_empty(); }
- NonnullRefPtrVector<Card>& moving_cards() { return m_moving_cards; }
- NonnullRefPtrVector<Card> const& moving_cards() const { return m_moving_cards; }
+ Vector<NonnullRefPtr<Card>>& moving_cards() { return m_moving_cards; }
+ Vector<NonnullRefPtr<Card>> const& moving_cards() const { return m_moving_cards; }
Gfx::IntRect moving_cards_bounds() const;
RefPtr<CardStack> moving_cards_source_stack() const { return m_moving_cards_source_stack; }
ErrorOr<void> pick_up_cards_from_stack(CardStack&, Gfx::IntPoint click_location, CardStack::MovementRule);
@@ -59,9 +59,9 @@ protected:
private:
virtual void config_string_did_change(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value) override;
- NonnullRefPtrVector<CardStack> m_stacks;
+ Vector<NonnullRefPtr<CardStack>> m_stacks;
- NonnullRefPtrVector<Card> m_moving_cards;
+ Vector<NonnullRefPtr<Card>> m_moving_cards;
RefPtr<CardStack> m_moving_cards_source_stack;
RefPtr<CardStack> m_previewed_card_stack;
};
diff --git a/Userland/Libraries/LibCards/CardStack.cpp b/Userland/Libraries/LibCards/CardStack.cpp
index 75e6a4b58a..2aac1ad152 100644
--- a/Userland/Libraries/LibCards/CardStack.cpp
+++ b/Userland/Libraries/LibCards/CardStack.cpp
@@ -37,7 +37,7 @@ void CardStack::paint(GUI::Painter& painter, Gfx::Color background_color)
auto draw_background_if_empty = [&]() {
size_t number_of_moving_cards = 0;
for (auto const& card : m_stack)
- number_of_moving_cards += card.is_moving() ? 1 : 0;
+ number_of_moving_cards += card->is_moving() ? 1 : 0;
if (m_covered_stack && !m_covered_stack->is_empty())
return false;
@@ -96,15 +96,15 @@ void CardStack::paint(GUI::Painter& painter, Gfx::Color background_color)
RefPtr<Card> previewed_card;
for (size_t i = 0; i < m_stack.size(); ++i) {
- if (auto& card = m_stack[i]; !card.is_moving()) {
- if (card.is_previewed()) {
+ if (auto& card = m_stack[i]; !card->is_moving()) {
+ if (card->is_previewed()) {
VERIFY(!previewed_card);
previewed_card = card;
continue;
}
auto highlighted = m_highlighted && (i == m_stack.size() - 1);
- card.clear_and_paint(painter, Gfx::Color::Transparent, highlighted);
+ card->clear_and_paint(painter, Gfx::Color::Transparent, highlighted);
}
}
@@ -118,10 +118,10 @@ void CardStack::rebound_cards()
size_t card_index = 0;
for (auto& card : m_stack)
- card.set_position(m_stack_positions.at(card_index++));
+ card->set_position(m_stack_positions.at(card_index++));
}
-ErrorOr<void> CardStack::add_all_grabbed_cards(Gfx::IntPoint click_location, NonnullRefPtrVector<Card>& grabbed, MovementRule movement_rule)
+ErrorOr<void> CardStack::add_all_grabbed_cards(Gfx::IntPoint click_location, Vector<NonnullRefPtr<Card>>& grabbed, MovementRule movement_rule)
{
VERIFY(grabbed.is_empty());
@@ -137,8 +137,8 @@ ErrorOr<void> CardStack::add_all_grabbed_cards(Gfx::IntPoint click_location, Non
RefPtr<Card> last_intersect;
for (auto& card : m_stack) {
- if (card.rect().contains(click_location)) {
- if (card.is_upside_down())
+ if (card->rect().contains(click_location)) {
+ if (card->is_upside_down())
continue;
last_intersect = card;
@@ -148,12 +148,12 @@ ErrorOr<void> CardStack::add_all_grabbed_cards(Gfx::IntPoint click_location, Non
last_intersect->set_moving(true);
}
- if (card.is_upside_down()) {
+ if (card->is_upside_down()) {
grabbed.clear();
return {};
}
- card.set_moving(true);
+ card->set_moving(true);
TRY(grabbed.try_append(card));
}
}
@@ -173,28 +173,28 @@ ErrorOr<void> CardStack::add_all_grabbed_cards(Gfx::IntPoint click_location, Non
bool color_match;
switch (movement_rule) {
case MovementRule::Alternating:
- color_match = card.color() != last_color;
+ color_match = card->color() != last_color;
break;
case MovementRule::Same:
- color_match = card.color() == last_color;
+ color_match = card->color() == last_color;
break;
case MovementRule::Any:
color_match = true;
break;
}
- if (!color_match || to_underlying(card.rank()) != last_value - 1) {
+ if (!color_match || to_underlying(card->rank()) != last_value - 1) {
valid_stack = false;
break;
}
}
- last_value = to_underlying(card.rank());
- last_color = card.color();
+ last_value = to_underlying(card->rank());
+ last_color = card->color();
}
if (!valid_stack) {
for (auto& card : grabbed) {
- card.set_moving(false);
+ card->set_moving(false);
}
grabbed.clear();
}
@@ -257,9 +257,9 @@ bool CardStack::preview_card(Gfx::IntPoint click_location)
RefPtr<Card> last_intersect;
for (auto& card : m_stack) {
- if (!card.rect().contains(click_location))
+ if (!card->rect().contains(click_location))
continue;
- if (card.is_upside_down())
+ if (card->is_upside_down())
continue;
last_intersect = card;
@@ -275,7 +275,7 @@ bool CardStack::preview_card(Gfx::IntPoint click_location)
void CardStack::clear_card_preview()
{
for (auto& card : m_stack)
- card.set_previewed(false);
+ card->set_previewed(false);
}
bool CardStack::make_top_card_visible()
@@ -350,7 +350,7 @@ void CardStack::calculate_bounding_box()
size_t card_position = 0;
for (auto& card : m_stack) {
if (card_position % m_rules.step == 0 && card_position != 0) {
- if (card.is_upside_down()) {
+ if (card->is_upside_down()) {
width += m_rules.shift_x;
height += m_rules.shift_y_upside_down;
} else {
diff --git a/Userland/Libraries/LibCards/CardStack.h b/Userland/Libraries/LibCards/CardStack.h
index 1cdcf23e44..6fa274a050 100644
--- a/Userland/Libraries/LibCards/CardStack.h
+++ b/Userland/Libraries/LibCards/CardStack.h
@@ -35,7 +35,7 @@ public:
bool is_empty() const { return m_stack.is_empty(); }
Type type() const { return m_type; }
- NonnullRefPtrVector<Card> const& stack() const { return m_stack; }
+ Vector<NonnullRefPtr<Card>> const& stack() const { return m_stack; }
size_t count() const { return m_stack.size(); }
Card const& peek() const { return m_stack.last(); }
Card& peek() { return m_stack.last(); }
@@ -49,7 +49,7 @@ public:
void rebound_cards();
bool is_allowed_to_push(Card const&, size_t stack_size = 1, MovementRule movement_rule = MovementRule::Alternating) const;
- ErrorOr<void> add_all_grabbed_cards(Gfx::IntPoint click_location, NonnullRefPtrVector<Card>& grabbed, MovementRule movement_rule = MovementRule::Alternating);
+ ErrorOr<void> add_all_grabbed_cards(Gfx::IntPoint click_location, Vector<NonnullRefPtr<Card>>& grabbed, MovementRule movement_rule = MovementRule::Alternating);
bool preview_card(Gfx::IntPoint click_location);
void clear_card_preview();
@@ -91,7 +91,7 @@ private:
// eg, in Solitaire the Play stack is positioned over the Waste stack.
RefPtr<CardStack> m_covered_stack;
- NonnullRefPtrVector<Card> m_stack;
+ Vector<NonnullRefPtr<Card>> m_stack;
Vector<Gfx::IntPoint> m_stack_positions;
Gfx::IntPoint m_position;
Gfx::IntRect m_bounding_box;
diff --git a/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp b/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp
index e298a3515e..7d7c44d964 100644
--- a/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp
+++ b/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp
@@ -199,9 +199,9 @@ Vector<StringView> CppComprehensionEngine::scope_of_reference_to_symbol(ASTNode
Vector<StringView> scope_parts;
for (auto& scope_part : name->scope()) {
// If the target node is part of a scope reference, we want to end the scope chain before it.
- if (&scope_part == &node)
+ if (scope_part == &node)
break;
- scope_parts.append(scope_part.name());
+ scope_parts.append(scope_part->name());
}
return scope_parts;
}
@@ -263,8 +263,8 @@ DeprecatedString CppComprehensionEngine::type_of_variable(Identifier const& iden
ASTNode const* current = &identifier;
while (current) {
for (auto& decl : current->declarations()) {
- if (decl.is_variable_or_parameter_declaration()) {
- auto& var_or_param = verify_cast<VariableOrParameterDeclaration>(decl);
+ if (decl->is_variable_or_parameter_declaration()) {
+ auto& var_or_param = verify_cast<VariableOrParameterDeclaration>(*decl);
if (var_or_param.full_name() == identifier.name() && var_or_param.type()->is_named_type()) {
VERIFY(verify_cast<NamedType>(*var_or_param.type()).name());
if (verify_cast<NamedType>(*var_or_param.type()).name())
@@ -326,7 +326,7 @@ Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::properties_of_typ
Vector<StringView> scope(type_symbol.scope);
scope.append(type_symbol.name);
// FIXME: We don't have to create the Symbol here, it should already exist in the 'm_symbol' table of some DocumentData we already parsed.
- properties.append(Symbol::create(member.full_name(), scope, member, Symbol::IsLocal::No));
+ properties.append(Symbol::create(member->full_name(), scope, member, Symbol::IsLocal::No));
}
return properties;
}
@@ -346,16 +346,16 @@ Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::get_child_symbols
Vector<Symbol> symbols;
for (auto& decl : node.declarations()) {
- symbols.append(Symbol::create(decl.full_name(), scope, decl, is_local));
+ symbols.append(Symbol::create(decl->full_name(), scope, decl, is_local));
- bool should_recurse = decl.is_namespace() || decl.is_struct_or_class() || decl.is_function();
- bool are_child_symbols_local = decl.is_function();
+ bool should_recurse = decl->is_namespace() || decl->is_struct_or_class() || decl->is_function();
+ bool are_child_symbols_local = decl->is_function();
if (!should_recurse)
continue;
auto new_scope = scope;
- new_scope.append(decl.full_name());
+ new_scope.append(decl->full_name());
symbols.extend(get_child_symbols(decl, new_scope, are_child_symbols_local ? Symbol::IsLocal::Yes : is_local));
}
@@ -864,7 +864,7 @@ Optional<CodeComprehensionEngine::FunctionParamsHint> CppComprehensionEngine::ge
Optional<size_t> invoked_arg_index;
for (size_t arg_index = 0; arg_index < call_node->arguments().size(); ++arg_index) {
- if (&call_node->arguments()[arg_index] == node.ptr()) {
+ if (call_node->arguments()[arg_index] == node.ptr()) {
invoked_arg_index = arg_index;
break;
}
@@ -920,7 +920,7 @@ Optional<CppComprehensionEngine::FunctionParamsHint> CppComprehensionEngine::get
hint.current_index = argument_index;
for (auto& arg : func_decl.parameters()) {
Vector<StringView> tokens_text;
- for (auto token : document_of_declaration->parser().tokens_in_range(arg.start(), arg.end())) {
+ for (auto token : document_of_declaration->parser().tokens_in_range(arg->start(), arg->end())) {
tokens_text.append(token.text());
}
hint.params.append(DeprecatedString::join(' ', tokens_text));
diff --git a/Userland/Libraries/LibCore/Object.cpp b/Userland/Libraries/LibCore/Object.cpp
index ccb93c4eb0..07012841e8 100644
--- a/Userland/Libraries/LibCore/Object.cpp
+++ b/Userland/Libraries/LibCore/Object.cpp
@@ -48,7 +48,7 @@ Object::~Object()
// NOTE: We also unparent the children, so that they won't try to unparent
// themselves in their own destructors.
for (auto& child : children)
- child.m_parent = nullptr;
+ child->m_parent = nullptr;
all_objects().remove(*this);
stop_timer();
@@ -103,7 +103,7 @@ void Object::insert_child_before(Object& new_child, Object& before_child)
void Object::remove_child(Object& object)
{
for (size_t i = 0; i < m_children.size(); ++i) {
- if (m_children.ptr_at(i).ptr() == &object) {
+ if (m_children[i] == &object) {
// NOTE: We protect the child so it survives the handling of ChildRemoved.
NonnullRefPtr<Object> protector = object;
object.m_parent = nullptr;
@@ -119,7 +119,7 @@ void Object::remove_child(Object& object)
void Object::remove_all_children()
{
while (!m_children.is_empty())
- m_children.first().remove_from_parent();
+ m_children.first()->remove_from_parent();
}
void Object::timer_event(Core::TimerEvent&)
diff --git a/Userland/Libraries/LibCore/Object.h b/Userland/Libraries/LibCore/Object.h
index f33c4d2239..90bbeb857c 100644
--- a/Userland/Libraries/LibCore/Object.h
+++ b/Userland/Libraries/LibCore/Object.h
@@ -112,14 +112,14 @@ public:
DeprecatedString const& name() const { return m_name; }
void set_name(DeprecatedString name) { m_name = move(name); }
- NonnullRefPtrVector<Object>& children() { return m_children; }
- NonnullRefPtrVector<Object> const& children() const { return m_children; }
+ Vector<NonnullRefPtr<Object>>& children() { return m_children; }
+ Vector<NonnullRefPtr<Object>> const& children() const { return m_children; }
template<typename Callback>
void for_each_child(Callback callback)
{
for (auto& child : m_children) {
- if (callback(child) == IterationDecision::Break)
+ if (callback(*child) == IterationDecision::Break)
return;
}
}
@@ -219,7 +219,7 @@ private:
int m_timer_id { 0 };
unsigned m_inspector_count { 0 };
HashMap<DeprecatedString, NonnullOwnPtr<Property>> m_properties;
- NonnullRefPtrVector<Object> m_children;
+ Vector<NonnullRefPtr<Object>> m_children;
Function<bool(Core::Event&)> m_event_filter;
};
diff --git a/Userland/Libraries/LibCpp/AST.cpp b/Userland/Libraries/LibCpp/AST.cpp
index 74c1685145..610f7ada75 100644
--- a/Userland/Libraries/LibCpp/AST.cpp
+++ b/Userland/Libraries/LibCpp/AST.cpp
@@ -24,7 +24,7 @@ void TranslationUnit::dump(FILE* output, size_t indent) const
{
ASTNode::dump(output, indent);
for (auto const& child : m_declarations) {
- child.dump(output, indent + 1);
+ child->dump(output, indent + 1);
}
}
@@ -46,7 +46,7 @@ void FunctionDeclaration::dump(FILE* output, size_t indent) const
print_indent(output, indent + 1);
outln(output, "(");
for (auto const& arg : m_parameters) {
- arg.dump(output, indent + 1);
+ arg->dump(output, indent + 1);
}
print_indent(output, indent + 1);
outln(output, ")");
@@ -55,9 +55,9 @@ void FunctionDeclaration::dump(FILE* output, size_t indent) const
}
}
-NonnullRefPtrVector<Declaration const> FunctionDeclaration::declarations() const
+Vector<NonnullRefPtr<Declaration const>> FunctionDeclaration::declarations() const
{
- NonnullRefPtrVector<Declaration const> declarations;
+ Vector<NonnullRefPtr<Declaration const>> declarations;
for (auto& arg : m_parameters) {
declarations.append(arg);
}
@@ -124,11 +124,11 @@ DeprecatedString FunctionType::to_deprecated_string() const
first = false;
else
builder.append(", "sv);
- if (parameter.type())
- builder.append(parameter.type()->to_deprecated_string());
- if (parameter.name() && !parameter.full_name().is_empty()) {
+ if (parameter->type())
+ builder.append(parameter->type()->to_deprecated_string());
+ if (parameter->name() && !parameter->full_name().is_empty()) {
builder.append(' ');
- builder.append(parameter.full_name());
+ builder.append(parameter->full_name());
}
}
builder.append(')');
@@ -156,17 +156,17 @@ void FunctionDefinition::dump(FILE* output, size_t indent) const
print_indent(output, indent);
outln(output, "{{");
for (auto const& statement : m_statements) {
- statement.dump(output, indent + 1);
+ statement->dump(output, indent + 1);
}
print_indent(output, indent);
outln(output, "}}");
}
-NonnullRefPtrVector<Declaration const> FunctionDefinition::declarations() const
+Vector<NonnullRefPtr<Declaration const>> FunctionDefinition::declarations() const
{
- NonnullRefPtrVector<Declaration const> declarations;
+ Vector<NonnullRefPtr<Declaration const>> declarations;
for (auto& statement : m_statements) {
- declarations.extend(statement.declarations());
+ declarations.extend(statement->declarations());
}
return declarations;
}
@@ -297,7 +297,7 @@ void FunctionCall::dump(FILE* output, size_t indent) const
ASTNode::dump(output, indent);
m_callee->dump(output, indent + 1);
for (auto const& arg : m_arguments) {
- arg.dump(output, indent + 1);
+ arg->dump(output, indent + 1);
}
}
@@ -338,7 +338,7 @@ void StructOrClassDeclaration::dump(FILE* output, size_t indent) const
outln(output, ":");
for (size_t i = 0; i < m_baseclasses.size(); ++i) {
auto& baseclass = m_baseclasses[i];
- baseclass.dump(output, indent + 1);
+ baseclass->dump(output, indent + 1);
if (i < m_baseclasses.size() - 1) {
print_indent(output, indent + 1);
outln(output, ",");
@@ -347,12 +347,12 @@ void StructOrClassDeclaration::dump(FILE* output, size_t indent) const
}
outln(output, "");
for (auto& member : m_members) {
- member.dump(output, indent + 1);
+ member->dump(output, indent + 1);
}
}
-NonnullRefPtrVector<Declaration const> StructOrClassDeclaration::declarations() const
+Vector<NonnullRefPtr<Declaration const>> StructOrClassDeclaration::declarations() const
{
- NonnullRefPtrVector<Declaration const> declarations;
+ Vector<NonnullRefPtr<Declaration const>> declarations;
for (auto& member : m_members)
declarations.append(member);
return declarations;
@@ -425,7 +425,7 @@ void FunctionType::dump(FILE* output, size_t indent) const
print_indent(output, indent + 1);
outln("(");
for (auto& parameter : m_parameters)
- parameter.dump(output, indent + 2);
+ parameter->dump(output, indent + 2);
print_indent(output, indent + 1);
outln(")");
}
@@ -441,7 +441,7 @@ void BlockStatement::dump(FILE* output, size_t indent) const
{
ASTNode::dump(output, indent);
for (auto& statement : m_statements) {
- statement.dump(output, indent + 1);
+ statement->dump(output, indent + 1);
}
}
@@ -458,10 +458,10 @@ void ForStatement::dump(FILE* output, size_t indent) const
m_body->dump(output, indent + 1);
}
-NonnullRefPtrVector<Declaration const> Statement::declarations() const
+Vector<NonnullRefPtr<Declaration const>> Statement::declarations() const
{
if (is_declaration()) {
- NonnullRefPtrVector<Declaration const> vec;
+ Vector<NonnullRefPtr<Declaration const>> vec;
auto const& decl = static_cast<Declaration const&>(*this);
vec.empend(const_cast<Declaration&>(decl));
return vec;
@@ -469,9 +469,9 @@ NonnullRefPtrVector<Declaration const> Statement::declarations() const
return {};
}
-NonnullRefPtrVector<Declaration const> ForStatement::declarations() const
+Vector<NonnullRefPtr<Declaration const>> ForStatement::declarations() const
{
- NonnullRefPtrVector<Declaration const> declarations;
+ Vector<NonnullRefPtr<Declaration const>> declarations;
if (m_init)
declarations.extend(m_init->declarations());
if (m_body)
@@ -479,11 +479,11 @@ NonnullRefPtrVector<Declaration const> ForStatement::declarations() const
return declarations;
}
-NonnullRefPtrVector<Declaration const> BlockStatement::declarations() const
+Vector<NonnullRefPtr<Declaration const>> BlockStatement::declarations() const
{
- NonnullRefPtrVector<Declaration const> declarations;
+ Vector<NonnullRefPtr<Declaration const>> declarations;
for (auto& statement : m_statements) {
- declarations.extend(statement.declarations());
+ declarations.extend(statement->declarations());
}
return declarations;
}
@@ -508,9 +508,9 @@ void IfStatement::dump(FILE* output, size_t indent) const
}
}
-NonnullRefPtrVector<Declaration const> IfStatement::declarations() const
+Vector<NonnullRefPtr<Declaration const>> IfStatement::declarations() const
{
- NonnullRefPtrVector<Declaration const> declarations;
+ Vector<NonnullRefPtr<Declaration const>> declarations;
if (m_predicate)
declarations.extend(m_predicate->declarations());
if (m_then)
@@ -526,7 +526,7 @@ void NamespaceDeclaration::dump(FILE* output, size_t indent) const
print_indent(output, indent + 1);
outln(output, "{}", full_name());
for (auto& decl : m_declarations)
- decl.dump(output, indent + 1);
+ decl->dump(output, indent + 1);
}
void NullPointerLiteral::dump(FILE* output, size_t indent) const
@@ -549,7 +549,7 @@ StringView Name::full_name() const
StringBuilder builder;
if (!m_scope.is_empty()) {
for (auto& scope : m_scope) {
- builder.appendff("{}::", scope.name());
+ builder.appendff("{}::", scope->name());
}
}
m_full_name = DeprecatedString::formatted("{}{}", builder.to_deprecated_string(), m_name.is_null() ? ""sv : m_name->name());
@@ -565,7 +565,7 @@ StringView TemplatizedName::full_name() const
name.append(Name::full_name());
name.append('<');
for (auto& type : m_template_arguments) {
- name.append(type.to_deprecated_string());
+ name.append(type->to_deprecated_string());
}
name.append('>');
m_full_name = name.to_deprecated_string();
@@ -601,7 +601,7 @@ void BracedInitList::dump(FILE* output, size_t indent) const
{
ASTNode::dump(output, indent);
for (auto& exp : m_expressions) {
- exp.dump(output, indent + 1);
+ exp->dump(output, indent + 1);
}
}
@@ -621,7 +621,7 @@ void Constructor::dump(FILE* output, size_t indent) const
print_indent(output, indent + 1);
outln(output, "(");
for (auto const& arg : parameters()) {
- arg.dump(output, indent + 1);
+ arg->dump(output, indent + 1);
}
print_indent(output, indent + 1);
outln(output, ")");
@@ -637,7 +637,7 @@ void Destructor::dump(FILE* output, size_t indent) const
print_indent(output, indent + 1);
outln(output, "(");
for (auto const& arg : parameters()) {
- arg.dump(output, indent + 1);
+ arg->dump(output, indent + 1);
}
print_indent(output, indent + 1);
outln(output, ")");
diff --git a/Userland/Libraries/LibCpp/AST.h b/Userland/Libraries/LibCpp/AST.h
index 0e8be683d3..1679b6af76 100644
--- a/Userland/Libraries/LibCpp/AST.h
+++ b/Userland/Libraries/LibCpp/AST.h
@@ -54,7 +54,7 @@ public:
void set_end(Position const& end) { m_end = end; }
void set_parent(ASTNode const& parent) { m_parent = &parent; }
- virtual NonnullRefPtrVector<Declaration const> declarations() const { return {}; }
+ virtual Vector<NonnullRefPtr<Declaration const>> declarations() const { return {}; }
virtual bool is_identifier() const { return false; }
virtual bool is_member_expression() const { return false; }
@@ -87,17 +87,17 @@ public:
virtual ~TranslationUnit() override = default;
virtual StringView class_name() const override { return "TranslationUnit"sv; }
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
- virtual NonnullRefPtrVector<Declaration const> declarations() const override { return m_declarations; }
+ virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override { return m_declarations; }
TranslationUnit(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
: ASTNode(parent, start, end, filename)
{
}
- void set_declarations(NonnullRefPtrVector<Declaration const>&& declarations) { m_declarations = move(declarations); }
+ void set_declarations(Vector<NonnullRefPtr<Declaration const>>&& declarations) { m_declarations = move(declarations); }
private:
- NonnullRefPtrVector<Declaration const> m_declarations;
+ Vector<NonnullRefPtr<Declaration const>> m_declarations;
};
class Statement : public ASTNode {
@@ -105,7 +105,7 @@ public:
virtual ~Statement() override = default;
virtual StringView class_name() const override { return "Statement"sv; }
- virtual NonnullRefPtrVector<Declaration const> declarations() const override;
+ virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override;
protected:
Statement(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
@@ -167,20 +167,20 @@ public:
{
}
- virtual NonnullRefPtrVector<Declaration const> declarations() const override;
+ virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override;
Vector<StringView> const& qualifiers() const { return m_qualifiers; }
void set_qualifiers(Vector<StringView> const& qualifiers) { m_qualifiers = qualifiers; }
Type const* return_type() const { return m_return_type.ptr(); }
void set_return_type(RefPtr<Type const> const& return_type) { m_return_type = return_type; }
- NonnullRefPtrVector<Parameter const> const& parameters() const { return m_parameters; }
- void set_parameters(NonnullRefPtrVector<Parameter const> const& parameters) { m_parameters = parameters; }
+ Vector<NonnullRefPtr<Parameter const>> const& parameters() const { return m_parameters; }
+ void set_parameters(Vector<NonnullRefPtr<Parameter const>> const& parameters) { m_parameters = parameters; }
FunctionDefinition const* definition() const { return m_definition.ptr(); }
void set_definition(RefPtr<FunctionDefinition const>&& definition) { m_definition = move(definition); }
private:
Vector<StringView> m_qualifiers;
RefPtr<Type const> m_return_type;
- NonnullRefPtrVector<Parameter const> m_parameters;
+ Vector<NonnullRefPtr<Parameter const>> m_parameters;
RefPtr<FunctionDefinition const> m_definition;
};
@@ -325,11 +325,11 @@ public:
}
void set_return_type(Type& type) { m_return_type = type; }
- void set_parameters(NonnullRefPtrVector<Parameter const> parameters) { m_parameters = move(parameters); }
+ void set_parameters(Vector<NonnullRefPtr<Parameter const>> parameters) { m_parameters = move(parameters); }
private:
RefPtr<Type const> m_return_type;
- NonnullRefPtrVector<Parameter const> m_parameters;
+ Vector<NonnullRefPtr<Parameter const>> m_parameters;
};
class FunctionDefinition : public ASTNode {
@@ -343,12 +343,12 @@ public:
{
}
- virtual NonnullRefPtrVector<Declaration const> declarations() const override;
- NonnullRefPtrVector<Statement const> const& statements() { return m_statements; }
+ virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override;
+ Vector<NonnullRefPtr<Statement const>> const& statements() { return m_statements; }
void add_statement(NonnullRefPtr<Statement const>&& statement) { m_statements.append(move(statement)); }
private:
- NonnullRefPtrVector<Statement const> m_statements;
+ Vector<NonnullRefPtr<Statement const>> m_statements;
};
class InvalidStatement : public Statement {
@@ -444,13 +444,13 @@ public:
Identifier const* name() const { return m_name.ptr(); }
void set_name(RefPtr<Identifier const>&& name) { m_name = move(name); }
- NonnullRefPtrVector<Identifier const> const& scope() const { return m_scope; }
- void set_scope(NonnullRefPtrVector<Identifier const> scope) { m_scope = move(scope); }
+ Vector<NonnullRefPtr<Identifier const>> const& scope() const { return m_scope; }
+ void set_scope(Vector<NonnullRefPtr<Identifier const>> scope) { m_scope = move(scope); }
void add_to_scope(NonnullRefPtr<Identifier const>&& part) { m_scope.append(move(part)); }
private:
RefPtr<Identifier const> m_name;
- NonnullRefPtrVector<Identifier const> m_scope;
+ Vector<NonnullRefPtr<Identifier const>> m_scope;
mutable Optional<DeprecatedString> m_full_name;
};
@@ -469,7 +469,7 @@ public:
void add_template_argument(NonnullRefPtr<Type const>&& type) { m_template_arguments.append(move(type)); }
private:
- NonnullRefPtrVector<Type const> m_template_arguments;
+ Vector<NonnullRefPtr<Type const>> m_template_arguments;
mutable Optional<DeprecatedString> m_full_name;
};
@@ -609,11 +609,11 @@ public:
void set_callee(RefPtr<Expression const>&& callee) { m_callee = move(callee); }
void add_argument(NonnullRefPtr<Expression const>&& arg) { m_arguments.append(move(arg)); }
- NonnullRefPtrVector<Expression const> const& arguments() const { return m_arguments; }
+ Vector<NonnullRefPtr<Expression const>> const& arguments() const { return m_arguments; }
private:
RefPtr<Expression const> m_callee;
- NonnullRefPtrVector<Expression const> m_arguments;
+ Vector<NonnullRefPtr<Expression const>> m_arguments;
};
class StringLiteral final : public Expression {
@@ -689,7 +689,7 @@ public:
virtual bool is_struct_or_class() const override { return true; }
virtual bool is_struct() const override { return m_type == Type::Struct; }
virtual bool is_class() const override { return m_type == Type::Class; }
- virtual NonnullRefPtrVector<Declaration const> declarations() const override;
+ virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override;
enum class Type {
Struct,
@@ -702,16 +702,16 @@ public:
{
}
- NonnullRefPtrVector<Declaration const> const& members() const { return m_members; }
- void set_members(NonnullRefPtrVector<Declaration const>&& members) { m_members = move(members); }
+ Vector<NonnullRefPtr<Declaration const>> const& members() const { return m_members; }
+ void set_members(Vector<NonnullRefPtr<Declaration const>>&& members) { m_members = move(members); }
- NonnullRefPtrVector<Name const> const& baseclasses() const { return m_baseclasses; }
- void set_baseclasses(NonnullRefPtrVector<Name const>&& baseclasses) { m_baseclasses = move(baseclasses); }
+ Vector<NonnullRefPtr<Name const>> const& baseclasses() const { return m_baseclasses; }
+ void set_baseclasses(Vector<NonnullRefPtr<Name const>>&& baseclasses) { m_baseclasses = move(baseclasses); }
private:
StructOrClassDeclaration::Type m_type;
- NonnullRefPtrVector<Declaration const> m_members;
- NonnullRefPtrVector<Name const> m_baseclasses;
+ Vector<NonnullRefPtr<Declaration const>> m_members;
+ Vector<NonnullRefPtr<Name const>> m_baseclasses;
};
enum class UnaryOp {
@@ -776,7 +776,7 @@ public:
virtual StringView class_name() const override { return "ForStatement"sv; }
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
- virtual NonnullRefPtrVector<Declaration const> declarations() const override;
+ virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override;
void set_init(RefPtr<VariableDeclaration const>&& init) { m_init = move(init); }
void set_test(RefPtr<Expression const>&& test) { m_test = move(test); }
@@ -802,12 +802,12 @@ public:
virtual StringView class_name() const override { return "BlockStatement"sv; }
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
- virtual NonnullRefPtrVector<Declaration const> declarations() const override;
+ virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override;
void add_statement(NonnullRefPtr<Statement const>&& statement) { m_statements.append(move(statement)); }
private:
- NonnullRefPtrVector<Statement const> m_statements;
+ Vector<NonnullRefPtr<Statement const>> m_statements;
};
class Comment final : public Statement {
@@ -831,7 +831,7 @@ public:
virtual ~IfStatement() override = default;
virtual StringView class_name() const override { return "IfStatement"sv; }
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
- virtual NonnullRefPtrVector<Declaration const> declarations() const override;
+ virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override;
void set_predicate(RefPtr<Expression const>&& predicate) { m_predicate = move(predicate); }
void set_then_statement(RefPtr<Statement const>&& then) { m_then = move(then); }
@@ -858,11 +858,11 @@ public:
{
}
- virtual NonnullRefPtrVector<Declaration const> declarations() const override { return m_declarations; }
+ virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override { return m_declarations; }
void add_declaration(NonnullRefPtr<Declaration const>&& declaration) { m_declarations.append(move(declaration)); }
private:
- NonnullRefPtrVector<Declaration const> m_declarations;
+ Vector<NonnullRefPtr<Declaration const>> m_declarations;
};
class CppCastExpression : public Expression {
@@ -936,7 +936,7 @@ public:
void add_expression(NonnullRefPtr<Expression const>&& exp) { m_expressions.append(move(exp)); }
private:
- NonnullRefPtrVector<Expression const> m_expressions;
+ Vector<NonnullRefPtr<Expression const>> m_expressions;
};
class DummyAstNode : public ASTNode {
diff --git a/Userland/Libraries/LibCpp/Parser.cpp b/Userland/Libraries/LibCpp/Parser.cpp
index a091b64085..5cf2eb9ca9 100644
--- a/Userland/Libraries/LibCpp/Parser.cpp
+++ b/Userland/Libraries/LibCpp/Parser.cpp
@@ -37,9 +37,9 @@ NonnullRefPtr<TranslationUnit> Parser::parse()
return unit;
}
-NonnullRefPtrVector<Declaration const> Parser::parse_declarations_in_translation_unit(ASTNode const& parent)
+Vector<NonnullRefPtr<Declaration const>> Parser::parse_declarations_in_translation_unit(ASTNode const& parent)
{
- NonnullRefPtrVector<Declaration const> declarations;
+ Vector<NonnullRefPtr<Declaration const>> declarations;
while (!eof()) {
auto declaration = parse_single_declaration_in_translation_unit(parent);
if (declaration) {
@@ -259,13 +259,13 @@ bool Parser::match_template_arguments()
return peek().type() == Token::Type::Greater;
}
-NonnullRefPtrVector<Type const> Parser::parse_template_arguments(ASTNode const& parent)
+Vector<NonnullRefPtr<Type const>> Parser::parse_template_arguments(ASTNode const& parent)
{
LOG_SCOPE();
consume(Token::Type::Less);
- NonnullRefPtrVector<Type const> template_arguments;
+ Vector<NonnullRefPtr<Type const>> template_arguments;
while (!eof() && peek().type() != Token::Type::Greater) {
template_arguments.append(parse_type(parent));
}
@@ -350,7 +350,7 @@ NonnullRefPtr<Expression const> Parser::parse_expression(ASTNode const& parent)
return expression;
}
- NonnullRefPtrVector<Expression const> secondary_expressions;
+ Vector<NonnullRefPtr<Expression const>> secondary_expressions;
while (match_secondary_expression()) {
// FIXME: Handle operator precedence
@@ -359,7 +359,7 @@ NonnullRefPtr<Expression const> Parser::parse_expression(ASTNode const& parent)
}
for (size_t i = 0; secondary_expressions.size() != 0 && i < secondary_expressions.size() - 1; ++i) {
- const_cast<Expression&>(secondary_expressions[i]).set_parent(secondary_expressions[i + 1]);
+ const_cast<Expression&>(*secondary_expressions[i]).set_parent(secondary_expressions[i + 1]);
}
return expression;
@@ -748,10 +748,10 @@ bool Parser::match_function_declaration()
return false;
}
-Optional<NonnullRefPtrVector<Parameter const>> Parser::parse_parameter_list(ASTNode const& parent)
+Optional<Vector<NonnullRefPtr<Parameter const>>> Parser::parse_parameter_list(ASTNode const& parent)
{
LOG_SCOPE();
- NonnullRefPtrVector<Parameter const> parameters;
+ Vector<NonnullRefPtr<Parameter const>> parameters;
while (peek().type() != Token::Type::RightParen && !eof()) {
if (match_ellipsis()) {
auto param = create_ast_node<Parameter>(parent, position(), {}, RefPtr<Name> {});
@@ -981,7 +981,7 @@ Optional<size_t> Parser::index_of_node_at(Position pos) const
for (size_t node_index = 0; node_index < m_nodes.size(); ++node_index) {
auto& node = m_nodes[node_index];
- if (node.start() > pos || node.end() < pos)
+ if (node->start() > pos || node->end() < pos)
continue;
if (!match_node_index.has_value() || (node_span(node) <= node_span(m_nodes[match_node_index.value()])))
@@ -1155,7 +1155,7 @@ NonnullRefPtr<StructOrClassDeclaration const> Parser::parse_class_declaration(AS
auto has_final = match_keyword("final");
- NonnullRefPtrVector<Name const> baseclasses;
+ Vector<NonnullRefPtr<Name const>> baseclasses;
// FIXME: Don't ignore this.
if (peek(has_final ? 1 : 0).type() == Token::Type::Colon) {
@@ -1569,11 +1569,11 @@ NonnullRefPtr<BracedInitList const> Parser::parse_braced_init_list(ASTNode const
init_list->set_end(position());
return init_list;
}
-NonnullRefPtrVector<Declaration const> Parser::parse_class_members(StructOrClassDeclaration& parent)
+Vector<NonnullRefPtr<Declaration const>> Parser::parse_class_members(StructOrClassDeclaration& parent)
{
auto class_name = parent.full_name();
- NonnullRefPtrVector<Declaration const> members;
+ Vector<NonnullRefPtr<Declaration const>> members;
while (!eof() && peek().type() != Token::Type::RightCurly) {
if (match_access_specifier())
consume_access_specifier(); // FIXME: Do not ignore access specifiers
diff --git a/Userland/Libraries/LibCpp/Parser.h b/Userland/Libraries/LibCpp/Parser.h
index 349d2eb0b1..6ced38a294 100644
--- a/Userland/Libraries/LibCpp/Parser.h
+++ b/Userland/Libraries/LibCpp/Parser.h
@@ -83,7 +83,7 @@ private:
bool match_destructor(StringView class_name);
bool match_using_namespace_declaration();
- Optional<NonnullRefPtrVector<Parameter const>> parse_parameter_list(ASTNode const& parent);
+ Optional<Vector<NonnullRefPtr<Parameter const>>> parse_parameter_list(ASTNode const& parent);
Optional<Token> consume_whitespace();
void consume_preprocessor();
@@ -110,15 +110,15 @@ private:
NonnullRefPtr<Comment const> parse_comment(ASTNode const& parent);
NonnullRefPtr<IfStatement const> parse_if_statement(ASTNode const& parent);
NonnullRefPtr<NamespaceDeclaration const> parse_namespace_declaration(ASTNode const& parent, bool is_nested_namespace = false);
- NonnullRefPtrVector<Declaration const> parse_declarations_in_translation_unit(ASTNode const& parent);
+ Vector<NonnullRefPtr<Declaration const>> parse_declarations_in_translation_unit(ASTNode const& parent);
RefPtr<Declaration const> parse_single_declaration_in_translation_unit(ASTNode const& parent);
- NonnullRefPtrVector<Type const> parse_template_arguments(ASTNode const& parent);
+ Vector<NonnullRefPtr<Type const>> parse_template_arguments(ASTNode const& parent);
NonnullRefPtr<Name const> parse_name(ASTNode const& parent);
NonnullRefPtr<CppCastExpression const> parse_cpp_cast_expression(ASTNode const& parent);
NonnullRefPtr<SizeofExpression const> parse_sizeof_expression(ASTNode const& parent);
NonnullRefPtr<BracedInitList const> parse_braced_init_list(ASTNode const& parent);
NonnullRefPtr<CStyleCastExpression const> parse_c_style_cast_expression(ASTNode const& parent);
- NonnullRefPtrVector<Declaration const> parse_class_members(StructOrClassDeclaration& parent);
+ Vector<NonnullRefPtr<Declaration const>> parse_class_members(StructOrClassDeclaration& parent);
NonnullRefPtr<Constructor const> parse_constructor(ASTNode const& parent);
NonnullRefPtr<Destructor const> parse_destructor(ASTNode const& parent);
NonnullRefPtr<UsingNamespaceDeclaration const> parse_using_namespace_declaration(ASTNode const& parent);
@@ -138,7 +138,7 @@ private:
struct State {
size_t token_index { 0 };
- NonnullRefPtrVector<ASTNode> state_nodes;
+ Vector<NonnullRefPtr<ASTNode>> state_nodes;
};
void error(StringView message = {});
@@ -192,7 +192,7 @@ private:
Vector<State> m_saved_states;
RefPtr<TranslationUnit> m_root_node;
Vector<DeprecatedString> m_errors;
- NonnullRefPtrVector<ASTNode> m_nodes;
+ Vector<NonnullRefPtr<ASTNode>> m_nodes;
};
}
diff --git a/Userland/Libraries/LibDSP/Track.cpp b/Userland/Libraries/LibDSP/Track.cpp
index 66179d7246..2e2d784efe 100644
--- a/Userland/Libraries/LibDSP/Track.cpp
+++ b/Userland/Libraries/LibDSP/Track.cpp
@@ -33,22 +33,22 @@ bool Track::check_processor_chain_valid_with_initial_type(SignalType initial_typ
for (auto& processor : m_processor_chain) {
// The first processor must have the given initial signal type as input.
if (previous_processor == nullptr) {
- if (processor.input_type() != initial_type)
+ if (processor->input_type() != initial_type)
return false;
- } else if (previous_processor->output_type() != processor.input_type())
+ } else if (previous_processor->output_type() != processor->input_type())
return false;
- previous_processor = &processor;
+ previous_processor = processor.ptr();
}
return true;
}
NonnullRefPtr<Synthesizers::Classic> Track::synth()
{
- return static_ptr_cast<Synthesizers::Classic>(m_processor_chain.ptr_at(0));
+ return static_ptr_cast<Synthesizers::Classic>(m_processor_chain[0]);
}
NonnullRefPtr<Effects::Delay> Track::delay()
{
- return static_ptr_cast<Effects::Delay>(m_processor_chain.ptr_at(1));
+ return static_ptr_cast<Effects::Delay>(m_processor_chain[1]);
}
bool AudioTrack::check_processor_chain_valid() const
@@ -81,11 +81,11 @@ void Track::current_signal(FixedArray<Sample>& output_signal)
for (auto& processor : m_processor_chain) {
// Depending on what the processor needs to have as output, we need to place either a pre-allocated note hash map or a pre-allocated sample buffer in the target signal.
- if (processor.output_type() == SignalType::Note)
+ if (processor->output_type() == SignalType::Note)
target_signal = &m_secondary_note_buffer;
else
target_signal = &m_secondary_sample_buffer;
- processor.process(*source_signal, *target_signal);
+ processor->process(*source_signal, *target_signal);
swap(source_signal, target_signal);
}
VERIFY(source_signal->type() == SignalType::Sample);
@@ -109,9 +109,9 @@ void NoteTrack::compute_current_clips_signal()
for (auto& clip : m_clips) {
// A clip is playing if its start time or end time fall in the current time range.
// Or, if they both enclose the current time range.
- if ((clip.start() <= start_time && clip.end() >= end_time)
- || (clip.start() >= start_time && clip.start() < end_time)
- || (clip.end() > start_time && clip.end() <= end_time)) {
+ if ((clip->start() <= start_time && clip->end() >= end_time)
+ || (clip->start() >= start_time && clip->start() < end_time)
+ || (clip->end() > start_time && clip->end() <= end_time)) {
VERIFY(playing_clips_index < playing_clips.size());
playing_clips[playing_clips_index++] = clip;
}
@@ -149,8 +149,8 @@ void AudioTrack::compute_current_clips_signal()
Optional<RollNote> NoteTrack::note_at(u32 time, u8 pitch) const
{
for (auto& clip : m_clips) {
- if (time >= clip.start() && time <= clip.end())
- return clip.note_at(time, pitch);
+ if (time >= clip->start() && time <= clip->end())
+ return clip->note_at(time, pitch);
}
return {};
@@ -159,15 +159,15 @@ Optional<RollNote> NoteTrack::note_at(u32 time, u8 pitch) const
void NoteTrack::set_note(RollNote note)
{
for (auto& clip : m_clips) {
- if (clip.start() <= note.on_sample && clip.end() >= note.on_sample)
- clip.set_note(note);
+ if (clip->start() <= note.on_sample && clip->end() >= note.on_sample)
+ clip->set_note(note);
}
}
void NoteTrack::remove_note(RollNote note)
{
for (auto& clip : m_clips)
- clip.remove_note(note);
+ clip->remove_note(note);
}
void NoteTrack::add_clip(u32 start_time, u32 end_time)
diff --git a/Userland/Libraries/LibDSP/Track.h b/Userland/Libraries/LibDSP/Track.h
index 63c6d73716..1ec19505d7 100644
--- a/Userland/Libraries/LibDSP/Track.h
+++ b/Userland/Libraries/LibDSP/Track.h
@@ -33,7 +33,7 @@ public:
// We are informed of an audio buffer size change. This happens off-audio-thread so we can allocate.
ErrorOr<void> resize_internal_buffers_to(size_t buffer_size);
- NonnullRefPtrVector<Processor> const& processor_chain() const { return m_processor_chain; }
+ Vector<NonnullRefPtr<Processor>> const& processor_chain() const { return m_processor_chain; }
NonnullRefPtr<Transport const> transport() const { return m_transport; }
NonnullRefPtr<DSP::Effects::Mastering> track_mastering() { return m_track_mastering; }
@@ -53,7 +53,7 @@ protected:
// Subclasses override to provide the base signal to the processing chain
virtual void compute_current_clips_signal() = 0;
- NonnullRefPtrVector<Processor> m_processor_chain;
+ Vector<NonnullRefPtr<Processor>> m_processor_chain;
NonnullRefPtr<Transport> m_transport;
NonnullRefPtr<Effects::Mastering> m_track_mastering;
NonnullRefPtr<Keyboard> m_keyboard;
@@ -90,7 +90,7 @@ protected:
void compute_current_clips_signal() override;
private:
- NonnullRefPtrVector<NoteClip> m_clips;
+ Vector<NonnullRefPtr<NoteClip>> m_clips;
};
class AudioTrack final : public Track {
@@ -103,13 +103,13 @@ public:
}
bool check_processor_chain_valid() const override;
- NonnullRefPtrVector<AudioClip> const& clips() const { return m_clips; }
+ Vector<NonnullRefPtr<AudioClip>> const& clips() const { return m_clips; }
protected:
void compute_current_clips_signal() override;
private:
- NonnullRefPtrVector<AudioClip> m_clips;
+ Vector<NonnullRefPtr<AudioClip>> m_clips;
};
}
diff --git a/Userland/Libraries/LibDesktop/Launcher.cpp b/Userland/Libraries/LibDesktop/Launcher.cpp
index c3139156e0..de182ddfea 100644
--- a/Userland/Libraries/LibDesktop/Launcher.cpp
+++ b/Userland/Libraries/LibDesktop/Launcher.cpp
@@ -102,10 +102,10 @@ Vector<DeprecatedString> Launcher::get_handlers_for_url(const URL& url)
return connection().get_handlers_for_url(url.to_deprecated_string());
}
-auto Launcher::get_handlers_with_details_for_url(const URL& url) -> NonnullRefPtrVector<Details>
+auto Launcher::get_handlers_with_details_for_url(const URL& url) -> Vector<NonnullRefPtr<Details>>
{
auto details = connection().get_handlers_with_details_for_url(url.to_deprecated_string());
- NonnullRefPtrVector<Details> handlers_with_details;
+ Vector<NonnullRefPtr<Details>> handlers_with_details;
for (auto& value : details) {
handlers_with_details.append(Details::from_details_str(value));
}
diff --git a/Userland/Libraries/LibDesktop/Launcher.h b/Userland/Libraries/LibDesktop/Launcher.h
index f49c0f96c7..82da4d402c 100644
--- a/Userland/Libraries/LibDesktop/Launcher.h
+++ b/Userland/Libraries/LibDesktop/Launcher.h
@@ -39,7 +39,7 @@ public:
static bool open(const URL&, DeprecatedString const& handler_name = {});
static bool open(const URL&, Details const& details);
static Vector<DeprecatedString> get_handlers_for_url(const URL&);
- static NonnullRefPtrVector<Details> get_handlers_with_details_for_url(const URL&);
+ static Vector<NonnullRefPtr<Details>> get_handlers_with_details_for_url(const URL&);
};
}
diff --git a/Userland/Libraries/LibELF/DynamicLinker.cpp b/Userland/Libraries/LibELF/DynamicLinker.cpp
index 38a7c4bfbc..d0d6e5bd2a 100644
--- a/Userland/Libraries/LibELF/DynamicLinker.cpp
+++ b/Userland/Libraries/LibELF/DynamicLinker.cpp
@@ -348,12 +348,12 @@ static void for_each_unfinished_dependency_of(DeprecatedString const& path, Hash
callback(*s_loaders.get(path).value());
}
-static NonnullRefPtrVector<DynamicLoader> collect_loaders_for_library(DeprecatedString const& path)
+static Vector<NonnullRefPtr<DynamicLoader>> collect_loaders_for_library(DeprecatedString const& path)
{
VERIFY(path.starts_with('/'));
HashTable<DeprecatedString> seen_names;
- NonnullRefPtrVector<DynamicLoader> loaders;
+ Vector<NonnullRefPtr<DynamicLoader>> loaders;
for_each_unfinished_dependency_of(path, seen_names, [&](auto& loader) {
loaders.append(loader);
});
@@ -386,37 +386,37 @@ static Result<void, DlErrorMessage> link_main_library(DeprecatedString const& pa
auto loaders = collect_loaders_for_library(path);
for (auto& loader : loaders) {
- auto dynamic_object = loader.map();
+ auto dynamic_object = loader->map();
if (dynamic_object)
s_global_objects.set(dynamic_object->filepath(), *dynamic_object);
}
for (auto& loader : loaders) {
- bool success = loader.link(flags);
+ bool success = loader->link(flags);
if (!success) {
- return DlErrorMessage { DeprecatedString::formatted("Failed to link library {}", loader.filepath()) };
+ return DlErrorMessage { DeprecatedString::formatted("Failed to link library {}", loader->filepath()) };
}
}
for (auto& loader : loaders) {
- auto result = loader.load_stage_3(flags);
+ auto result = loader->load_stage_3(flags);
VERIFY(!result.is_error());
auto& object = result.value();
- if (loader.filepath().ends_with("/libc.so"sv)) {
+ if (loader->filepath().ends_with("/libc.so"sv)) {
initialize_libc(*object);
}
- if (loader.filepath().ends_with("/libsystem.so"sv)) {
- VERIFY(!loader.text_segments().is_empty());
- for (auto const& segment : loader.text_segments()) {
+ if (loader->filepath().ends_with("/libsystem.so"sv)) {
+ VERIFY(!loader->text_segments().is_empty());
+ for (auto const& segment : loader->text_segments()) {
auto flags = static_cast<int>(VirtualMemoryRangeFlags::SyscallCode) | static_cast<int>(VirtualMemoryRangeFlags::Immutable);
if (syscall(SC_annotate_mapping, segment.address().get(), flags)) {
VERIFY_NOT_REACHED();
}
}
} else {
- for (auto const& segment : loader.text_segments()) {
+ for (auto const& segment : loader->text_segments()) {
auto flags = static_cast<int>(VirtualMemoryRangeFlags::Immutable);
if (syscall(SC_annotate_mapping, segment.address().get(), flags)) {
VERIFY_NOT_REACHED();
@@ -428,7 +428,7 @@ static Result<void, DlErrorMessage> link_main_library(DeprecatedString const& pa
drop_loader_promise("prot_exec"sv);
for (auto& loader : loaders) {
- loader.load_stage_4();
+ loader->load_stage_4();
}
return {};
diff --git a/Userland/Libraries/LibGUI/GML/AST.h b/Userland/Libraries/LibGUI/GML/AST.h
index dded956b39..7b5cb82f01 100644
--- a/Userland/Libraries/LibGUI/GML/AST.h
+++ b/Userland/Libraries/LibGUI/GML/AST.h
@@ -152,7 +152,7 @@ public:
class Object : public ValueNode {
public:
Object() = default;
- Object(DeprecatedString name, NonnullRefPtrVector<Node const> properties, NonnullRefPtrVector<Node const> sub_objects)
+ Object(DeprecatedString name, Vector<NonnullRefPtr<Node const>> properties, Vector<NonnullRefPtr<Node const>> sub_objects)
: m_properties(move(properties))
, m_sub_objects(move(sub_objects))
, m_name(move(name))
@@ -182,7 +182,7 @@ public:
{
for (auto const& child : m_properties) {
if (is<KeyValuePair>(child)) {
- auto const& property = static_cast<KeyValuePair const&>(child);
+ auto const& property = static_cast<KeyValuePair const&>(*child);
if (property.key() != "layout" && is<JsonValueNode>(property.value().ptr()))
callback(property.key(), static_ptr_cast<JsonValueNode>(property.value()));
}
@@ -207,7 +207,7 @@ public:
for (auto const& child : m_sub_objects) {
// doesn't capture layout as intended, as that's behind a kv-pair
if (is<Object>(child)) {
- TRY(callback(static_cast<Object const&>(child)));
+ TRY(callback(static_cast<Object const&>(*child)));
}
}
@@ -218,7 +218,7 @@ public:
{
for (auto const& child : m_properties) {
if (is<KeyValuePair>(child)) {
- auto const& property = static_cast<KeyValuePair const&>(child);
+ auto const& property = static_cast<KeyValuePair const&>(*child);
if (property.key() == "layout") {
VERIFY(is<Object>(property.value().ptr()));
return static_cast<Object const&>(*property.value());
@@ -232,7 +232,7 @@ public:
{
for (auto const& child : m_properties) {
if (is<KeyValuePair>(child)) {
- auto const& property = static_cast<KeyValuePair const&>(child);
+ auto const& property = static_cast<KeyValuePair const&>(*child);
if (property.key() == property_name)
return property.value();
}
@@ -251,7 +251,7 @@ public:
builder.append('\n');
for (auto const& property : m_properties)
- property.format(builder, indentation + 1, false);
+ property->format(builder, indentation + 1, false);
if (!m_properties.is_empty() && !m_sub_objects.is_empty())
builder.append('\n');
@@ -259,7 +259,7 @@ public:
// This loop is necessary as we need to know what the last child is.
for (size_t i = 0; i < m_sub_objects.size(); ++i) {
auto const& child = m_sub_objects[i];
- child.format(builder, indentation + 1, false);
+ child->format(builder, indentation + 1, false);
if (is<Object>(child) && i != m_sub_objects.size() - 1)
builder.append('\n');
@@ -274,9 +274,9 @@ public:
private:
// Properties and comments
- NonnullRefPtrVector<Node const> m_properties;
+ Vector<NonnullRefPtr<Node const>> m_properties;
// Sub objects and comments
- NonnullRefPtrVector<Node const> m_sub_objects;
+ Vector<NonnullRefPtr<Node const>> m_sub_objects;
DeprecatedString m_name {};
};
@@ -304,18 +304,18 @@ public:
bool has_main_class() const { return m_main_class != nullptr; }
- NonnullRefPtrVector<Comment const> leading_comments() const { return m_leading_comments; }
+ Vector<NonnullRefPtr<Comment const>> leading_comments() const { return m_leading_comments; }
Object const& main_class() const
{
VERIFY(!m_main_class.is_null());
return *m_main_class.ptr();
}
- NonnullRefPtrVector<Comment const> trailing_comments() const { return m_trailing_comments; }
+ Vector<NonnullRefPtr<Comment const>> trailing_comments() const { return m_trailing_comments; }
virtual void format(StringBuilder& builder, size_t indentation, [[maybe_unused]] bool is_inline) const override
{
for (auto const& comment : m_leading_comments)
- comment.format(builder, indentation, false);
+ comment->format(builder, indentation, false);
if (!m_leading_comments.is_empty())
builder.append('\n');
@@ -324,13 +324,13 @@ public:
builder.append('\n');
for (auto const& comment : m_trailing_comments)
- comment.format(builder, indentation, false);
+ comment->format(builder, indentation, false);
}
private:
- NonnullRefPtrVector<Comment const> m_leading_comments;
+ Vector<NonnullRefPtr<Comment const>> m_leading_comments;
RefPtr<Object const> m_main_class;
- NonnullRefPtrVector<Comment const> m_trailing_comments;
+ Vector<NonnullRefPtr<Comment const>> m_trailing_comments;
};
}
diff --git a/Userland/Libraries/LibGUI/GML/Parser.cpp b/Userland/Libraries/LibGUI/GML/Parser.cpp
index 18f93109f4..ef71d155ac 100644
--- a/Userland/Libraries/LibGUI/GML/Parser.cpp
+++ b/Userland/Libraries/LibGUI/GML/Parser.cpp
@@ -46,7 +46,7 @@ static ErrorOr<NonnullRefPtr<Object>> parse_gml_object(Queue<Token>& tokens)
tokens.dequeue();
- NonnullRefPtrVector<Comment> pending_comments;
+ Vector<NonnullRefPtr<Comment>> pending_comments;
for (;;) {
if (peek() == Token::Type::RightCurly) {
// End of object
diff --git a/Userland/Libraries/LibGUI/Menubar.h b/Userland/Libraries/LibGUI/Menubar.h
index 80269219d4..03d87fd753 100644
--- a/Userland/Libraries/LibGUI/Menubar.h
+++ b/Userland/Libraries/LibGUI/Menubar.h
@@ -32,7 +32,7 @@ public:
private:
Menubar() = default;
- NonnullRefPtrVector<Menu> m_menus;
+ Vector<NonnullRefPtr<Menu>> m_menus;
};
}
diff --git a/Userland/Libraries/LibGUI/Statusbar.cpp b/Userland/Libraries/LibGUI/Statusbar.cpp
index 3da3ef5423..2ea42af74d 100644
--- a/Userland/Libraries/LibGUI/Statusbar.cpp
+++ b/Userland/Libraries/LibGUI/Statusbar.cpp
@@ -63,46 +63,46 @@ void Statusbar::set_segment_count(size_t count)
void Statusbar::update_segment(size_t index)
{
auto& segment = m_segments.at(index);
- if (segment.mode() == Segment::Mode::Auto) {
- if (segment.restored_text().is_empty())
- segment.set_visible(false);
+ if (segment->mode() == Segment::Mode::Auto) {
+ if (segment->restored_text().is_empty())
+ segment->set_visible(false);
else {
constexpr auto horizontal_padding { 10 };
- auto width = font().width(segment.restored_text()) + horizontal_padding;
- segment.set_restored_width(width);
- segment.set_fixed_width(width);
+ auto width = font().width(segment->restored_text()) + horizontal_padding;
+ segment->set_restored_width(width);
+ segment->set_fixed_width(width);
}
- } else if (segment.mode() == Segment::Mode::Fixed) {
- if (segment.max_width().is_int()) {
- segment.set_restored_width(segment.max_width().as_int());
- segment.set_fixed_width(segment.max_width());
+ } else if (segment->mode() == Segment::Mode::Fixed) {
+ if (segment->max_width().is_int()) {
+ segment->set_restored_width(segment->max_width().as_int());
+ segment->set_fixed_width(segment->max_width());
}
}
- if (segment.override_text().is_null()) {
+ if (segment->override_text().is_null()) {
for (size_t i = 1; i < m_segments.size(); i++) {
if (!text(i).is_empty())
- m_segments[i].set_visible(true);
+ m_segments[i]->set_visible(true);
}
- segment.set_text(String::from_utf8(segment.restored_text()).release_value_but_fixme_should_propagate_errors());
- segment.set_frame_shape(Gfx::FrameShape::Panel);
- if (segment.mode() != Segment::Mode::Proportional)
- segment.set_fixed_width(segment.restored_width());
+ segment->set_text(String::from_utf8(segment->restored_text()).release_value_but_fixme_should_propagate_errors());
+ segment->set_frame_shape(Gfx::FrameShape::Panel);
+ if (segment->mode() != Segment::Mode::Proportional)
+ segment->set_fixed_width(segment->restored_width());
} else {
for (size_t i = 1; i < m_segments.size(); i++) {
- if (!m_segments[i].is_clickable())
- m_segments[i].set_visible(false);
+ if (!m_segments[i]->is_clickable())
+ m_segments[i]->set_visible(false);
}
- segment.set_text(String::from_utf8(segment.override_text()).release_value_but_fixme_should_propagate_errors());
- segment.set_frame_shape(Gfx::FrameShape::NoFrame);
- if (segment.mode() != Segment::Mode::Proportional)
- segment.set_fixed_width(SpecialDimension::Grow);
+ segment->set_text(String::from_utf8(segment->override_text()).release_value_but_fixme_should_propagate_errors());
+ segment->set_frame_shape(Gfx::FrameShape::NoFrame);
+ if (segment->mode() != Segment::Mode::Proportional)
+ segment->set_fixed_width(SpecialDimension::Grow);
}
}
DeprecatedString Statusbar::text(size_t index) const
{
- return m_segments.at(index).text().to_deprecated_string();
+ return m_segments[index]->text().to_deprecated_string();
}
void Statusbar::set_text(DeprecatedString text)
@@ -112,13 +112,13 @@ void Statusbar::set_text(DeprecatedString text)
void Statusbar::set_text(size_t index, DeprecatedString text)
{
- m_segments.at(index).m_restored_text = move(text);
+ m_segments[index]->m_restored_text = move(text);
update_segment(index);
}
void Statusbar::set_override_text(DeprecatedString override_text)
{
- m_segments.at(0).m_override_text = move(override_text);
+ m_segments[0]->m_override_text = move(override_text);
update_segment(0);
}
diff --git a/Userland/Libraries/LibGUI/Statusbar.h b/Userland/Libraries/LibGUI/Statusbar.h
index c570920965..0720c7a396 100644
--- a/Userland/Libraries/LibGUI/Statusbar.h
+++ b/Userland/Libraries/LibGUI/Statusbar.h
@@ -78,7 +78,7 @@ private:
virtual void child_event(Core::ChildEvent&) override;
- NonnullRefPtrVector<Segment> m_segments;
+ Vector<NonnullRefPtr<Segment>> m_segments;
RefPtr<ResizeCorner> m_corner;
};
diff --git a/Userland/Libraries/LibGUI/TextEditor.h b/Userland/Libraries/LibGUI/TextEditor.h
index 0eb80b2052..2406b9e1d2 100644
--- a/Userland/Libraries/LibGUI/TextEditor.h
+++ b/Userland/Libraries/LibGUI/TextEditor.h
@@ -414,7 +414,7 @@ private:
RefPtr<Action> m_select_all_action;
RefPtr<Action> m_insert_emoji_action;
Core::ElapsedTimer m_triple_click_timer;
- NonnullRefPtrVector<Action> m_custom_context_menu_actions;
+ Vector<NonnullRefPtr<Action>> m_custom_context_menu_actions;
size_t m_reflow_deferred { 0 };
bool m_reflow_requested { false };
diff --git a/Userland/Libraries/LibGUI/TreeViewModel.cpp b/Userland/Libraries/LibGUI/TreeViewModel.cpp
index 362df13472..a03e20e785 100644
--- a/Userland/Libraries/LibGUI/TreeViewModel.cpp
+++ b/Userland/Libraries/LibGUI/TreeViewModel.cpp
@@ -32,12 +32,12 @@ ModelIndex TreeViewModel::parent_index(ModelIndex const& index) const
return {};
if (parent_node->parent_node() == nullptr) {
for (size_t row = 0; row < m_nodes.size(); row++)
- if (m_nodes.ptr_at(row).ptr() == parent_node)
+ if (m_nodes[row] == parent_node)
return create_index(static_cast<int>(row), 0, parent_node);
VERIFY_NOT_REACHED();
}
for (size_t row = 0; row < parent_node->parent_node()->child_nodes().size(); row++) {
- auto const* child_node_at_row = parent_node->parent_node()->child_nodes().ptr_at(row).ptr();
+ auto const* child_node_at_row = parent_node->parent_node()->child_nodes()[row].ptr();
if (child_node_at_row == parent_node)
return create_index(static_cast<int>(row), 0, parent_node);
}
diff --git a/Userland/Libraries/LibGUI/TreeViewModel.h b/Userland/Libraries/LibGUI/TreeViewModel.h
index 6021fbf519..b063e939a1 100644
--- a/Userland/Libraries/LibGUI/TreeViewModel.h
+++ b/Userland/Libraries/LibGUI/TreeViewModel.h
@@ -59,18 +59,18 @@ public:
Node const* parent_node() const { return m_parent_node; }
Node* parent_node() { return m_parent_node; }
- NonnullRefPtrVector<Node> const& child_nodes() const { return m_child_nodes; }
- NonnullRefPtrVector<Node>& child_nodes() { return m_child_nodes; }
+ Vector<NonnullRefPtr<Node>> const& child_nodes() const { return m_child_nodes; }
+ Vector<NonnullRefPtr<Node>>& child_nodes() { return m_child_nodes; }
private:
DeprecatedString m_text;
Optional<Icon> m_icon;
WeakPtr<Node> m_parent_node;
- NonnullRefPtrVector<Node> m_child_nodes;
+ Vector<NonnullRefPtr<Node>> m_child_nodes;
};
- NonnullRefPtrVector<Node> const& nodes() const { return m_nodes; }
- NonnullRefPtrVector<Node>& nodes() { return m_nodes; }
+ Vector<NonnullRefPtr<Node>> const& nodes() const { return m_nodes; }
+ Vector<NonnullRefPtr<Node>>& nodes() { return m_nodes; }
template<typename NodeType = Node, typename... Args>
NonnullRefPtr<NodeType> add_node(DeprecatedString text, Optional<Icon> icon, Args&&... args)
@@ -86,7 +86,7 @@ public:
private:
TreeViewModel() = default;
- NonnullRefPtrVector<Node> m_nodes;
+ Vector<NonnullRefPtr<Node>> m_nodes;
};
}
diff --git a/Userland/Libraries/LibGUI/Widget.cpp b/Userland/Libraries/LibGUI/Widget.cpp
index f08a80f024..b8a5287870 100644
--- a/Userland/Libraries/LibGUI/Widget.cpp
+++ b/Userland/Libraries/LibGUI/Widget.cpp
@@ -702,7 +702,7 @@ Widget* Widget::child_at(Gfx::IntPoint point) const
for (int i = children().size() - 1; i >= 0; --i) {
if (!is<Widget>(children()[i]))
continue;
- auto& child = verify_cast<Widget>(children()[i]);
+ auto& child = verify_cast<Widget>(*children()[i]);
if (!child.is_visible())
continue;
if (child.relative_non_grabbable_rect().contains(point))
@@ -976,7 +976,7 @@ bool Widget::is_frontmost() const
auto* parent = parent_widget();
if (!parent)
return true;
- return &parent->children().last() == this;
+ return parent->children().last() == this;
}
bool Widget::is_backmost() const
@@ -984,7 +984,7 @@ bool Widget::is_backmost() const
auto* parent = parent_widget();
if (!parent)
return true;
- return &parent->children().first() == this;
+ return parent->children().first() == this;
}
Action* Widget::action_for_shortcut(Shortcut const& shortcut)
@@ -1036,8 +1036,8 @@ Vector<Widget&> Widget::child_widgets() const
Vector<Widget&> widgets;
widgets.ensure_capacity(children().size());
for (auto& child : const_cast<Widget*>(this)->children()) {
- if (is<Widget>(child))
- widgets.append(static_cast<Widget&>(child));
+ if (is<Widget>(*child))
+ widgets.append(static_cast<Widget&>(*child));
}
return widgets;
}
diff --git a/Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp b/Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp
index 81b593a78b..d612ddf6ce 100644
--- a/Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp
+++ b/Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp
@@ -76,7 +76,7 @@ WizardDialog::WizardDialog(Window* parent_window)
void WizardDialog::push_page(AbstractWizardPage& page)
{
if (!m_page_stack.is_empty())
- m_page_stack.last().page_leave();
+ m_page_stack.last()->page_leave();
m_page_stack.append(page);
m_page_container_widget->remove_all_children();
@@ -111,7 +111,7 @@ void WizardDialog::pop_page()
m_page_container_widget->add_child(m_page_stack.last());
update_navigation();
- m_page_stack.last().page_enter();
+ m_page_stack.last()->page_enter();
}
void WizardDialog::update_navigation()
diff --git a/Userland/Libraries/LibGUI/Wizards/WizardDialog.h b/Userland/Libraries/LibGUI/Wizards/WizardDialog.h
index f8ce753025..11de34141d 100644
--- a/Userland/Libraries/LibGUI/Wizards/WizardDialog.h
+++ b/Userland/Libraries/LibGUI/Wizards/WizardDialog.h
@@ -49,6 +49,6 @@ private:
RefPtr<Button> m_next_button;
RefPtr<Button> m_cancel_button;
- NonnullRefPtrVector<AbstractWizardPage> m_page_stack;
+ Vector<NonnullRefPtr<AbstractWizardPage>> m_page_stack;
};
}
diff --git a/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp b/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp
index a4b922f50d..05d3104c9a 100644
--- a/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp
+++ b/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp
@@ -232,52 +232,52 @@ void AntiAliasingPainter::stroke_path(Path const& path, Color color, float thick
Optional<FloatLine> first_line;
for (auto& segment : path.segments()) {
- switch (segment.type()) {
+ switch (segment->type()) {
case Segment::Type::Invalid:
VERIFY_NOT_REACHED();
case Segment::Type::MoveTo:
- cursor = segment.point();
+ cursor = segment->point();
break;
case Segment::Type::LineTo:
- draw_line(cursor, segment.point(), color, thickness);
+ draw_line(cursor, segment->point(), color, thickness);
if (thickness > 1) {
if (!first_line.has_value())
- first_line = FloatLine(cursor, segment.point());
+ first_line = FloatLine(cursor, segment->point());
if (previous_was_line)
- stroke_segment_intersection(cursor, segment.point(), last_line, color, thickness);
+ stroke_segment_intersection(cursor, segment->point(), last_line, color, thickness);
last_line.set_a(cursor);
- last_line.set_b(segment.point());
+ last_line.set_b(segment->point());
}
- cursor = segment.point();
+ cursor = segment->point();
break;
case Segment::Type::QuadraticBezierCurveTo: {
- auto through = static_cast<QuadraticBezierCurveSegment const&>(segment).through();
- draw_quadratic_bezier_curve(through, cursor, segment.point(), color, thickness);
- cursor = segment.point();
+ auto through = static_cast<QuadraticBezierCurveSegment const&>(*segment).through();
+ draw_quadratic_bezier_curve(through, cursor, segment->point(), color, thickness);
+ cursor = segment->point();
break;
}
case Segment::Type::CubicBezierCurveTo: {
- auto& curve = static_cast<CubicBezierCurveSegment const&>(segment);
+ auto& curve = static_cast<CubicBezierCurveSegment const&>(*segment);
auto through_0 = curve.through_0();
auto through_1 = curve.through_1();
- draw_cubic_bezier_curve(through_0, through_1, cursor, segment.point(), color, thickness);
- cursor = segment.point();
+ draw_cubic_bezier_curve(through_0, through_1, cursor, segment->point(), color, thickness);
+ cursor = segment->point();
break;
}
case Segment::Type::EllipticalArcTo:
- auto& arc = static_cast<EllipticalArcSegment const&>(segment);
- draw_elliptical_arc(cursor, segment.point(), arc.center(), arc.radii(), arc.x_axis_rotation(), arc.theta_1(), arc.theta_delta(), color, thickness);
- cursor = segment.point();
+ auto& arc = static_cast<EllipticalArcSegment const&>(*segment);
+ draw_elliptical_arc(cursor, segment->point(), arc.center(), arc.radii(), arc.x_axis_rotation(), arc.theta_1(), arc.theta_delta(), color, thickness);
+ cursor = segment->point();
break;
}
- previous_was_line = segment.type() == Segment::Type::LineTo;
+ previous_was_line = segment->type() == Segment::Type::LineTo;
}
// Check if the figure was started and closed as line at the same position.
- if (thickness > 1 && previous_was_line && path.segments().size() >= 2 && path.segments().first().point() == cursor
- && (path.segments().first().type() == Segment::Type::LineTo
- || (path.segments().first().type() == Segment::Type::MoveTo && path.segments()[1].type() == Segment::Type::LineTo))) {
+ if (thickness > 1 && previous_was_line && path.segments().size() >= 2 && path.segments().first()->point() == cursor
+ && (path.segments().first()->type() == Segment::Type::LineTo
+ || (path.segments().first()->type() == Segment::Type::MoveTo && path.segments()[1]->type() == Segment::Type::LineTo))) {
stroke_segment_intersection(first_line.value().a(), first_line.value().b(), last_line, color, thickness);
}
}
diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp
index 24463739c5..c9c63ddef5 100644
--- a/Userland/Libraries/LibGfx/Painter.cpp
+++ b/Userland/Libraries/LibGfx/Painter.cpp
@@ -2356,35 +2356,35 @@ void Painter::stroke_path(Path const& path, Color color, int thickness)
FloatPoint cursor;
for (auto& segment : path.segments()) {
- switch (segment.type()) {
+ switch (segment->type()) {
case Segment::Type::Invalid:
VERIFY_NOT_REACHED();
break;
case Segment::Type::MoveTo:
- cursor = segment.point();
+ cursor = segment->point();
break;
case Segment::Type::LineTo:
- draw_line(cursor.to_type<int>(), segment.point().to_type<int>(), color, thickness);
- cursor = segment.point();
+ draw_line(cursor.to_type<int>(), segment->point().to_type<int>(), color, thickness);
+ cursor = segment->point();
break;
case Segment::Type::QuadraticBezierCurveTo: {
- auto through = static_cast<QuadraticBezierCurveSegment const&>(segment).through();
- draw_quadratic_bezier_curve(through.to_type<int>(), cursor.to_type<int>(), segment.point().to_type<int>(), color, thickness);
- cursor = segment.point();
+ auto through = static_cast<QuadraticBezierCurveSegment const&>(*segment).through();
+ draw_quadratic_bezier_curve(through.to_type<int>(), cursor.to_type<int>(), segment->point().to_type<int>(), color, thickness);
+ cursor = segment->point();
break;
}
case Segment::Type::CubicBezierCurveTo: {
- auto& curve = static_cast<CubicBezierCurveSegment const&>(segment);
+ auto& curve = static_cast<CubicBezierCurveSegment const&>(*segment);
auto through_0 = curve.through_0();
auto through_1 = curve.through_1();
- draw_cubic_bezier_curve(through_0.to_type<int>(), through_1.to_type<int>(), cursor.to_type<int>(), segment.point().to_type<int>(), color, thickness);
- cursor = segment.point();
+ draw_cubic_bezier_curve(through_0.to_type<int>(), through_1.to_type<int>(), cursor.to_type<int>(), segment->point().to_type<int>(), color, thickness);
+ cursor = segment->point();
break;
}
case Segment::Type::EllipticalArcTo:
- auto& arc = static_cast<EllipticalArcSegment const&>(segment);
- draw_elliptical_arc(cursor.to_type<int>(), segment.point().to_type<int>(), arc.center().to_type<int>(), arc.radii(), arc.x_axis_rotation(), arc.theta_1(), arc.theta_delta(), color, thickness);
- cursor = segment.point();
+ auto& arc = static_cast<EllipticalArcSegment const&>(*segment);
+ draw_elliptical_arc(cursor.to_type<int>(), segment->point().to_type<int>(), arc.center().to_type<int>(), arc.radii(), arc.x_axis_rotation(), arc.theta_1(), arc.theta_delta(), color, thickness);
+ cursor = segment->point();
break;
}
}
diff --git a/Userland/Libraries/LibGfx/Path.cpp b/Userland/Libraries/LibGfx/Path.cpp
index 7fff0ca234..79e47e6fd3 100644
--- a/Userland/Libraries/LibGfx/Path.cpp
+++ b/Userland/Libraries/LibGfx/Path.cpp
@@ -27,7 +27,7 @@ void Path::elliptical_arc_to(FloatPoint point, FloatSize radii, double x_axis_ro
// Find the last point
FloatPoint last_point { 0, 0 };
if (!m_segments.is_empty())
- last_point = m_segments.last().point();
+ last_point = m_segments.last()->point();
// Step 1 of out-of-range radii correction
if (rx == 0.0 || ry == 0.0) {
@@ -120,14 +120,14 @@ void Path::close()
if (m_segments.size() <= 1)
return;
- auto last_point = m_segments.last().point();
+ auto last_point = m_segments.last()->point();
for (ssize_t i = m_segments.size() - 1; i >= 0; --i) {
auto& segment = m_segments[i];
- if (segment.type() == Segment::Type::MoveTo) {
- if (last_point == segment.point())
+ if (segment->type() == Segment::Type::MoveTo) {
+ if (last_point == segment->point())
return;
- append_segment<LineSegment>(segment.point());
+ append_segment<LineSegment>(segment->point());
invalidate_split_lines();
return;
}
@@ -145,7 +145,7 @@ void Path::close_all_subpaths()
bool is_first_point_in_subpath { false };
for (auto& segment : m_segments) {
- switch (segment.type()) {
+ switch (segment->type()) {
case Segment::Type::MoveTo: {
if (cursor.has_value() && !is_first_point_in_subpath) {
// This is a move from a subpath to another
@@ -157,7 +157,7 @@ void Path::close_all_subpaths()
append_segment<LineSegment>(start_of_subpath.value());
}
is_first_point_in_subpath = true;
- cursor = segment.point();
+ cursor = segment->point();
break;
}
case Segment::Type::LineTo:
@@ -168,7 +168,7 @@ void Path::close_all_subpaths()
start_of_subpath = cursor;
is_first_point_in_subpath = false;
}
- cursor = segment.point();
+ cursor = segment->point();
break;
case Segment::Type::Invalid:
VERIFY_NOT_REACHED();
@@ -182,7 +182,7 @@ DeprecatedString Path::to_deprecated_string() const
StringBuilder builder;
builder.append("Path { "sv);
for (auto& segment : m_segments) {
- switch (segment.type()) {
+ switch (segment->type()) {
case Segment::Type::MoveTo:
builder.append("MoveTo"sv);
break;
@@ -202,21 +202,21 @@ DeprecatedString Path::to_deprecated_string() const
builder.append("Invalid"sv);
break;
}
- builder.appendff("({}", segment.point());
+ builder.appendff("({}", segment->point());
- switch (segment.type()) {
+ switch (segment->type()) {
case Segment::Type::QuadraticBezierCurveTo:
builder.append(", "sv);
- builder.append(static_cast<QuadraticBezierCurveSegment const&>(segment).through().to_deprecated_string());
+ builder.append(static_cast<QuadraticBezierCurveSegment const&>(*segment).through().to_deprecated_string());
break;
case Segment::Type::CubicBezierCurveTo:
builder.append(", "sv);
- builder.append(static_cast<CubicBezierCurveSegment const&>(segment).through_0().to_deprecated_string());
+ builder.append(static_cast<CubicBezierCurveSegment const&>(*segment).through_0().to_deprecated_string());
builder.append(", "sv);
- builder.append(static_cast<CubicBezierCurveSegment const&>(segment).through_1().to_deprecated_string());
+ builder.append(static_cast<CubicBezierCurveSegment const&>(*segment).through_1().to_deprecated_string());
break;
case Segment::Type::EllipticalArcTo: {
- auto& arc = static_cast<EllipticalArcSegment const&>(segment);
+ auto& arc = static_cast<EllipticalArcSegment const&>(*segment);
builder.appendff(", {}, {}, {}, {}, {}",
arc.radii().to_deprecated_string().characters(),
arc.center().to_deprecated_string().characters(),
@@ -273,47 +273,47 @@ void Path::segmentize_path()
bool first = true;
for (auto& segment : m_segments) {
- switch (segment.type()) {
+ switch (segment->type()) {
case Segment::Type::MoveTo:
if (first) {
- min_x = segment.point().x();
- min_y = segment.point().y();
- max_x = segment.point().x();
- max_y = segment.point().y();
+ min_x = segment->point().x();
+ min_y = segment->point().y();
+ max_x = segment->point().x();
+ max_y = segment->point().y();
} else {
- add_point_to_bbox(segment.point());
+ add_point_to_bbox(segment->point());
}
- cursor = segment.point();
+ cursor = segment->point();
break;
case Segment::Type::LineTo: {
- add_line(cursor, segment.point());
- cursor = segment.point();
+ add_line(cursor, segment->point());
+ cursor = segment->point();
break;
}
case Segment::Type::QuadraticBezierCurveTo: {
- auto control = static_cast<QuadraticBezierCurveSegment const&>(segment).through();
- Painter::for_each_line_segment_on_bezier_curve(control, cursor, segment.point(), [&](FloatPoint p0, FloatPoint p1) {
+ auto control = static_cast<QuadraticBezierCurveSegment const&>(*segment).through();
+ Painter::for_each_line_segment_on_bezier_curve(control, cursor, segment->point(), [&](FloatPoint p0, FloatPoint p1) {
add_line(p0, p1);
});
- cursor = segment.point();
+ cursor = segment->point();
break;
}
case Segment::Type::CubicBezierCurveTo: {
- auto& curve = static_cast<CubicBezierCurveSegment const&>(segment);
+ auto& curve = static_cast<CubicBezierCurveSegment const&>(*segment);
auto control_0 = curve.through_0();
auto control_1 = curve.through_1();
- Painter::for_each_line_segment_on_cubic_bezier_curve(control_0, control_1, cursor, segment.point(), [&](FloatPoint p0, FloatPoint p1) {
+ Painter::for_each_line_segment_on_cubic_bezier_curve(control_0, control_1, cursor, segment->point(), [&](FloatPoint p0, FloatPoint p1) {
add_line(p0, p1);
});
- cursor = segment.point();
+ cursor = segment->point();
break;
}
case Segment::Type::EllipticalArcTo: {
- auto& arc = static_cast<EllipticalArcSegment const&>(segment);
+ auto& arc = static_cast<EllipticalArcSegment const&>(*segment);
Painter::for_each_line_segment_on_elliptical_arc(cursor, arc.point(), arc.center(), arc.radii(), arc.x_axis_rotation(), arc.theta_1(), arc.theta_delta(), [&](FloatPoint p0, FloatPoint p1) {
add_line(p0, p1);
});
- cursor = segment.point();
+ cursor = segment->point();
break;
}
case Segment::Type::Invalid:
@@ -337,28 +337,28 @@ Path Path::copy_transformed(Gfx::AffineTransform const& transform) const
Path result;
for (auto const& segment : m_segments) {
- switch (segment.type()) {
+ switch (segment->type()) {
case Segment::Type::MoveTo:
- result.move_to(transform.map(segment.point()));
+ result.move_to(transform.map(segment->point()));
break;
case Segment::Type::LineTo: {
- result.line_to(transform.map(segment.point()));
+ result.line_to(transform.map(segment->point()));
break;
}
case Segment::Type::QuadraticBezierCurveTo: {
- auto const& quadratic_segment = static_cast<QuadraticBezierCurveSegment const&>(segment);
- result.quadratic_bezier_curve_to(transform.map(quadratic_segment.through()), transform.map(segment.point()));
+ auto const& quadratic_segment = static_cast<QuadraticBezierCurveSegment const&>(*segment);
+ result.quadratic_bezier_curve_to(transform.map(quadratic_segment.through()), transform.map(segment->point()));
break;
}
case Segment::Type::CubicBezierCurveTo: {
- auto const& cubic_segment = static_cast<CubicBezierCurveSegment const&>(segment);
- result.cubic_bezier_curve_to(transform.map(cubic_segment.through_0()), transform.map(cubic_segment.through_1()), transform.map(segment.point()));
+ auto const& cubic_segment = static_cast<CubicBezierCurveSegment const&>(*segment);
+ result.cubic_bezier_curve_to(transform.map(cubic_segment.through_0()), transform.map(cubic_segment.through_1()), transform.map(segment->point()));
break;
}
case Segment::Type::EllipticalArcTo: {
- auto const& arc_segment = static_cast<EllipticalArcSegment const&>(segment);
+ auto const& arc_segment = static_cast<EllipticalArcSegment const&>(*segment);
result.elliptical_arc_to(
- transform.map(segment.point()),
+ transform.map(segment->point()),
transform.map(arc_segment.center()),
transform.map(arc_segment.radii()),
arc_segment.x_axis_rotation(),
diff --git a/Userland/Libraries/LibGfx/Path.h b/Userland/Libraries/LibGfx/Path.h
index c51276e75d..f6a92c4ce2 100644
--- a/Userland/Libraries/LibGfx/Path.h
+++ b/Userland/Libraries/LibGfx/Path.h
@@ -160,7 +160,7 @@ public:
{
float previous_y = 0;
if (!m_segments.is_empty())
- previous_y = m_segments.last().point().y();
+ previous_y = m_segments.last()->point().y();
line_to({ x, previous_y });
}
@@ -168,7 +168,7 @@ public:
{
float previous_x = 0;
if (!m_segments.is_empty())
- previous_x = m_segments.last().point().x();
+ previous_x = m_segments.last()->point().x();
line_to({ previous_x, y });
}
@@ -218,7 +218,7 @@ public:
float x;
};
- NonnullRefPtrVector<Segment const> const& segments() const { return m_segments; }
+ Vector<NonnullRefPtr<Segment const>> const& segments() const { return m_segments; }
auto& split_lines() const
{
if (!m_split_lines.has_value()) {
@@ -269,7 +269,7 @@ private:
m_segments.append(adopt_ref(*new T(forward<Args>(args)...)));
}
- NonnullRefPtrVector<Segment const> m_segments {};
+ Vector<NonnullRefPtr<Segment const>> m_segments {};
Optional<Vector<SplitLineSegment>> m_split_lines {};
Optional<Gfx::FloatRect> m_bounding_box;
diff --git a/Userland/Libraries/LibIDL/IDLParser.cpp b/Userland/Libraries/LibIDL/IDLParser.cpp
index 87adc465bc..d998264c8d 100644
--- a/Userland/Libraries/LibIDL/IDLParser.cpp
+++ b/Userland/Libraries/LibIDL/IDLParser.cpp
@@ -166,7 +166,7 @@ Optional<Interface&> Parser::resolve_import(auto path)
NonnullRefPtr<Type const> Parser::parse_type()
{
if (lexer.consume_specific('(')) {
- NonnullRefPtrVector<Type const> union_member_types;
+ Vector<NonnullRefPtr<Type const>> union_member_types;
union_member_types.append(parse_type());
consume_whitespace();
assert_string("or"sv);
@@ -203,7 +203,7 @@ NonnullRefPtr<Type const> Parser::parse_type()
name = "long long"sv;
}
- NonnullRefPtrVector<Type const> parameters;
+ Vector<NonnullRefPtr<Type const>> parameters;
bool is_parameterized_type = false;
if (lexer.consume_specific('<')) {
is_parameterized_type = true;
diff --git a/Userland/Libraries/LibIDL/Types.cpp b/Userland/Libraries/LibIDL/Types.cpp
index 4e49f71d9d..73faf3e1a6 100644
--- a/Userland/Libraries/LibIDL/Types.cpp
+++ b/Userland/Libraries/LibIDL/Types.cpp
@@ -61,7 +61,7 @@ bool Type::includes_undefined() const
// - the type is a union type and one of its member types includes undefined.
if (is_union()) {
for (auto& type : as_union().member_types()) {
- if (type.includes_undefined())
+ if (type->includes_undefined())
return true;
}
}
@@ -87,7 +87,7 @@ bool Type::is_distinguishable_from(IDL::Type const& other) const
for (auto& this_member_type : this_union.member_types()) {
for (auto& other_member_type : other_union.member_types()) {
- if (!this_member_type.is_distinguishable_from(other_member_type))
+ if (!this_member_type->is_distinguishable_from(other_member_type))
return false;
}
}
@@ -196,7 +196,7 @@ int EffectiveOverloadSet::distinguishing_argument_index()
for (auto first_item_index = 0u; first_item_index < m_items.size(); ++first_item_index) {
for (auto second_item_index = first_item_index + 1; second_item_index < m_items.size(); ++second_item_index) {
- if (!m_items[first_item_index].types[argument_index].is_distinguishable_from(m_items[second_item_index].types[argument_index])) {
+ if (!m_items[first_item_index].types[argument_index]->is_distinguishable_from(m_items[second_item_index].types[argument_index])) {
found_indistinguishable = true;
break;
}
diff --git a/Userland/Libraries/LibIDL/Types.h b/Userland/Libraries/LibIDL/Types.h
index f507de1fe3..cfa57f62d1 100644
--- a/Userland/Libraries/LibIDL/Types.h
+++ b/Userland/Libraries/LibIDL/Types.h
@@ -222,7 +222,7 @@ class Interface;
class ParameterizedType : public Type {
public:
- ParameterizedType(DeprecatedString name, bool nullable, NonnullRefPtrVector<Type const> parameters)
+ ParameterizedType(DeprecatedString name, bool nullable, Vector<NonnullRefPtr<Type const>> parameters)
: Type(Kind::Parameterized, move(name), nullable)
, m_parameters(move(parameters))
{
@@ -232,11 +232,11 @@ public:
void generate_sequence_from_iterable(SourceGenerator& generator, DeprecatedString const& cpp_name, DeprecatedString const& iterable_cpp_name, DeprecatedString const& iterator_method_cpp_name, IDL::Interface const&, size_t recursion_depth) const;
- NonnullRefPtrVector<Type const> const& parameters() const { return m_parameters; }
- NonnullRefPtrVector<Type const>& parameters() { return m_parameters; }
+ Vector<NonnullRefPtr<Type const>> const& parameters() const { return m_parameters; }
+ Vector<NonnullRefPtr<Type const>>& parameters() { return m_parameters; }
private:
- NonnullRefPtrVector<Type const> m_parameters;
+ Vector<NonnullRefPtr<Type const>> m_parameters;
};
static inline size_t get_shortest_function_length(Vector<Function&> const& overload_set)
@@ -318,7 +318,7 @@ public:
class UnionType : public Type {
public:
- UnionType(DeprecatedString name, bool nullable, NonnullRefPtrVector<Type const> member_types)
+ UnionType(DeprecatedString name, bool nullable, Vector<NonnullRefPtr<Type const>> member_types)
: Type(Kind::Union, move(name), nullable)
, m_member_types(move(member_types))
{
@@ -326,16 +326,16 @@ public:
virtual ~UnionType() override = default;
- NonnullRefPtrVector<Type const> const& member_types() const { return m_member_types; }
- NonnullRefPtrVector<Type const>& member_types() { return m_member_types; }
+ Vector<NonnullRefPtr<Type const>> const& member_types() const { return m_member_types; }
+ Vector<NonnullRefPtr<Type const>>& member_types() { return m_member_types; }
// https://webidl.spec.whatwg.org/#dfn-flattened-union-member-types
- NonnullRefPtrVector<Type const> flattened_member_types() const
+ Vector<NonnullRefPtr<Type const>> flattened_member_types() const
{
// 1. Let T be the union type.
// 2. Initialize S to ∅.
- NonnullRefPtrVector<Type const> types;
+ Vector<NonnullRefPtr<Type const>> types;
// 3. For each member type U of T:
for (auto& type : m_member_types) {
@@ -344,8 +344,8 @@ public:
// 2. If U is a nullable type, then set U to be the inner type of U. (NOTE: Not necessary as nullable is stored with Type and not as a separate struct)
// 3. If U is a union type, then add to S the flattened member types of U.
- if (type.is_union()) {
- auto& union_member_type = type.as_union();
+ if (type->is_union()) {
+ auto& union_member_type = type->as_union();
types.extend(union_member_type.flattened_member_types());
} else {
// 4. Otherwise, U is not a union type. Add U to S.
@@ -368,7 +368,7 @@ public:
// 3. For each member type U of T:
for (auto& type : m_member_types) {
// 1. If U is a nullable type, then:
- if (type.is_nullable()) {
+ if (type->is_nullable()) {
// 1. Set n to n + 1.
++num_nullable_member_types;
@@ -376,8 +376,8 @@ public:
}
// 2. If U is a union type, then:
- if (type.is_union()) {
- auto& union_member_type = type.as_union();
+ if (type->is_union()) {
+ auto& union_member_type = type->as_union();
// 1. Let m be the number of nullable member types of U.
// 2. Set n to n + m.
@@ -390,7 +390,7 @@ public:
}
private:
- NonnullRefPtrVector<Type const> m_member_types;
+ Vector<NonnullRefPtr<Type const>> m_member_types;
};
// https://webidl.spec.whatwg.org/#dfn-optionality-value
@@ -405,7 +405,7 @@ class EffectiveOverloadSet {
public:
struct Item {
int callable_id;
- NonnullRefPtrVector<Type const> types;
+ Vector<NonnullRefPtr<Type const>> types;
Vector<Optionality> optionality_values;
};
diff --git a/Userland/Libraries/LibIPC/Connection.cpp b/Userland/Libraries/LibIPC/Connection.cpp
index df9c9c9123..84622a7c68 100644
--- a/Userland/Libraries/LibIPC/Connection.cpp
+++ b/Userland/Libraries/LibIPC/Connection.cpp
@@ -64,7 +64,7 @@ ErrorOr<void> ConnectionBase::post_message(MessageBuffer buffer)
TRY(buffer.data.try_prepend(reinterpret_cast<u8 const*>(&message_size), sizeof(message_size)));
for (auto& fd : buffer.fds) {
- if (auto result = fd_passing_socket().send_fd(fd.value()); result.is_error()) {
+ if (auto result = fd_passing_socket().send_fd(fd->value()); result.is_error()) {
shutdown_with_error(result.error());
return result;
}
diff --git a/Userland/Libraries/LibIPC/Message.h b/Userland/Libraries/LibIPC/Message.h
index a5f202ec0e..68e652b00a 100644
--- a/Userland/Libraries/LibIPC/Message.h
+++ b/Userland/Libraries/LibIPC/Message.h
@@ -8,7 +8,6 @@
#pragma once
#include <AK/Error.h>
-#include <AK/NonnullRefPtrVector.h>
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <unistd.h>
@@ -36,7 +35,7 @@ private:
struct MessageBuffer {
Vector<u8, 1024> data;
- NonnullRefPtrVector<AutoCloseFileDescriptor, 1> fds;
+ Vector<NonnullRefPtr<AutoCloseFileDescriptor>, 1> fds;
};
enum class ErrorCode : u32 {
diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp
index 2c662597b8..641f0f8eaa 100644
--- a/Userland/Libraries/LibJS/AST.cpp
+++ b/Userland/Libraries/LibJS/AST.cpp
@@ -107,7 +107,7 @@ Completion ScopeNode::evaluate_statements(Interpreter& interpreter) const
{
auto completion = normal_completion({});
for (auto const& node : children()) {
- completion = node.execute(interpreter).update_empty(completion.value());
+ completion = node->execute(interpreter).update_empty(completion.value());
if (completion.is_abrupt())
break;
}
@@ -958,12 +958,12 @@ struct ForInOfHeadState {
VERIFY(expression_lhs);
if (is<VariableDeclaration>(*expression_lhs)) {
auto& declaration = static_cast<VariableDeclaration const&>(*expression_lhs);
- VERIFY(declaration.declarations().first().target().has<NonnullRefPtr<Identifier const>>());
- lhs_reference = TRY(declaration.declarations().first().target().get<NonnullRefPtr<Identifier const>>()->to_reference(interpreter));
+ VERIFY(declaration.declarations().first()->target().has<NonnullRefPtr<Identifier const>>());
+ lhs_reference = TRY(declaration.declarations().first()->target().get<NonnullRefPtr<Identifier const>>()->to_reference(interpreter));
} else if (is<UsingDeclaration>(*expression_lhs)) {
auto& declaration = static_cast<UsingDeclaration const&>(*expression_lhs);
- VERIFY(declaration.declarations().first().target().has<NonnullRefPtr<Identifier const>>());
- lhs_reference = TRY(declaration.declarations().first().target().get<NonnullRefPtr<Identifier const>>()->to_reference(interpreter));
+ VERIFY(declaration.declarations().first()->target().has<NonnullRefPtr<Identifier const>>());
+ lhs_reference = TRY(declaration.declarations().first()->target().get<NonnullRefPtr<Identifier const>>()->to_reference(interpreter));
} else {
VERIFY(is<Identifier>(*expression_lhs) || is<MemberExpression>(*expression_lhs) || is<CallExpression>(*expression_lhs));
auto& expression = static_cast<Expression const&>(*expression_lhs);
@@ -1032,7 +1032,7 @@ struct ForInOfHeadState {
}
VERIFY(expression_lhs && is<VariableDeclaration>(*expression_lhs));
auto& for_declaration = static_cast<VariableDeclaration const&>(*expression_lhs);
- auto& binding_pattern = for_declaration.declarations().first().target().get<NonnullRefPtr<BindingPattern const>>();
+ auto& binding_pattern = for_declaration.declarations().first()->target().get<NonnullRefPtr<BindingPattern const>>();
VERIFY(lhs_kind == VarBinding || iteration_environment);
// At this point iteration_environment is undefined if lhs_kind == VarBinding which means this does both
@@ -1063,16 +1063,16 @@ static ThrowCompletionOr<ForInOfHeadState> for_in_of_head_execute(Interpreter& i
if (is<VariableDeclaration>(ast_ptr->ptr())) {
auto& variable_declaration = static_cast<VariableDeclaration const&>(*(*ast_ptr));
VERIFY(variable_declaration.declarations().size() == 1);
- state.destructuring = variable_declaration.declarations().first().target().has<NonnullRefPtr<BindingPattern const>>();
+ state.destructuring = variable_declaration.declarations().first()->target().has<NonnullRefPtr<BindingPattern const>>();
if (variable_declaration.declaration_kind() == DeclarationKind::Var) {
state.lhs_kind = ForInOfHeadState::VarBinding;
auto& variable = variable_declaration.declarations().first();
// B.3.5 Initializers in ForIn Statement Heads, https://tc39.es/ecma262/#sec-initializers-in-forin-statement-heads
- if (variable.init()) {
- VERIFY(variable.target().has<NonnullRefPtr<Identifier const>>());
- auto& binding_id = variable.target().get<NonnullRefPtr<Identifier const>>()->string();
+ if (variable->init()) {
+ VERIFY(variable->target().has<NonnullRefPtr<Identifier const>>());
+ auto& binding_id = variable->target().get<NonnullRefPtr<Identifier const>>()->string();
auto reference = TRY(interpreter.vm().resolve_binding(binding_id));
- auto result = TRY(interpreter.vm().named_evaluation_if_anonymous_function(*variable.init(), binding_id));
+ auto result = TRY(interpreter.vm().named_evaluation_if_anonymous_function(*variable->init(), binding_id));
TRY(reference.put_value(vm, result));
}
} else {
@@ -1950,7 +1950,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::class_definition_e
auto class_private_environment = new_private_environment(vm, outer_private_environment);
for (auto const& element : m_elements) {
- auto opt_private_name = element.private_bound_identifier();
+ auto opt_private_name = element->private_bound_identifier();
if (opt_private_name.has_value())
class_private_environment->add_private_name({}, opt_private_name.release_value());
}
@@ -2026,10 +2026,10 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::class_definition_e
for (auto const& element : m_elements) {
// Note: All ClassElementEvaluation start with evaluating the name (or we fake it).
- auto element_value = TRY(element.class_element_evaluation(interpreter, element.is_static() ? *class_constructor : *prototype));
+ auto element_value = TRY(element->class_element_evaluation(interpreter, element->is_static() ? *class_constructor : *prototype));
if (element_value.has<PrivateElement>()) {
- auto& container = element.is_static() ? static_private_methods : instance_private_methods;
+ auto& container = element->is_static() ? static_private_methods : instance_private_methods;
auto& private_element = element_value.get<PrivateElement>();
@@ -2051,11 +2051,11 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::class_definition_e
if (!added_to_existing)
container.append(move(element_value.get<PrivateElement>()));
} else if (auto* class_field_definition_ptr = element_value.get_pointer<ClassFieldDefinition>()) {
- if (element.is_static())
+ if (element->is_static())
static_elements.append(move(*class_field_definition_ptr));
else
instance_fields.append(move(*class_field_definition_ptr));
- } else if (element.class_element_kind() == ClassElement::ElementKind::StaticInitializer) {
+ } else if (element->class_element_kind() == ClassElement::ElementKind::StaticInitializer) {
// We use Completion to hold the ClassStaticBlockDefinition Record.
VERIFY(element_value.has<Completion>() && element_value.get<Completion>().value().has_value());
auto& element_object = element_value.get<Completion>().value()->as_object();
@@ -2108,28 +2108,28 @@ void ScopeNode::dump(int indent) const
print_indent(indent + 1);
outln("(Lexical declarations)");
for (auto& declaration : m_lexical_declarations)
- declaration.dump(indent + 2);
+ declaration->dump(indent + 2);
}
if (!m_var_declarations.is_empty()) {
print_indent(indent + 1);
outln("(Variable declarations)");
for (auto& declaration : m_var_declarations)
- declaration.dump(indent + 2);
+ declaration->dump(indent + 2);
}
if (!m_functions_hoistable_with_annexB_extension.is_empty()) {
print_indent(indent + 1);
outln("(Hoisted functions via annexB extension)");
for (auto& declaration : m_functions_hoistable_with_annexB_extension)
- declaration.dump(indent + 2);
+ declaration->dump(indent + 2);
}
if (!m_children.is_empty()) {
print_indent(indent + 1);
outln("(Children)");
for (auto& child : children())
- child.dump(indent + 2);
+ child->dump(indent + 2);
}
}
@@ -2322,7 +2322,7 @@ void ClassExpression::dump(int indent) const
print_indent(indent);
outln("(Elements)");
for (auto& method : m_elements)
- method.dump(indent + 1);
+ method->dump(indent + 1);
}
void ClassMethod::dump(int indent) const
@@ -3033,8 +3033,8 @@ Completion VariableDeclaration::execute(Interpreter& interpreter) const
auto& vm = interpreter.vm();
for (auto& declarator : m_declarations) {
- if (auto* init = declarator.init()) {
- TRY(declarator.target().visit(
+ if (auto* init = declarator->init()) {
+ TRY(declarator->target().visit(
[&](NonnullRefPtr<Identifier const> const& id) -> ThrowCompletionOr<void> {
auto reference = TRY(id->to_reference(interpreter));
auto initializer_result = TRY(interpreter.vm().named_evaluation_if_anonymous_function(*init, id->string()));
@@ -3053,8 +3053,8 @@ Completion VariableDeclaration::execute(Interpreter& interpreter) const
return vm.binding_initialization(pattern, initializer_result, environment);
}));
} else if (m_declaration_kind != DeclarationKind::Var) {
- VERIFY(declarator.target().has<NonnullRefPtr<Identifier const>>());
- auto& identifier = declarator.target().get<NonnullRefPtr<Identifier const>>();
+ VERIFY(declarator->target().has<NonnullRefPtr<Identifier const>>());
+ auto& identifier = declarator->target().get<NonnullRefPtr<Identifier const>>();
auto reference = TRY(identifier->to_reference(interpreter));
TRY(reference.initialize_referenced_binding(vm, js_undefined()));
}
@@ -3073,7 +3073,7 @@ Completion VariableDeclarator::execute(Interpreter& interpreter) const
ThrowCompletionOr<void> VariableDeclaration::for_each_bound_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const
{
for (auto const& entry : declarations()) {
- TRY(entry.target().visit(
+ TRY(entry->target().visit(
[&](NonnullRefPtr<Identifier const> const& id) {
return callback(id->string());
},
@@ -3107,7 +3107,7 @@ void VariableDeclaration::dump(int indent) const
outln("{}", declaration_kind_string);
for (auto& declarator : m_declarations)
- declarator.dump(indent + 1);
+ declarator->dump(indent + 1);
}
// 6.2.1.2 Runtime Semantics: Evaluation, https://tc39.es/proposal-explicit-resource-management/#sec-let-and-const-declarations-runtime-semantics-evaluation
@@ -3118,14 +3118,14 @@ Completion UsingDeclaration::execute(Interpreter& interpreter) const
auto& vm = interpreter.vm();
for (auto& declarator : m_declarations) {
- VERIFY(declarator.target().has<NonnullRefPtr<Identifier const>>());
- VERIFY(declarator.init());
+ VERIFY(declarator->target().has<NonnullRefPtr<Identifier const>>());
+ VERIFY(declarator->init());
- auto& id = declarator.target().get<NonnullRefPtr<Identifier const>>();
+ auto& id = declarator->target().get<NonnullRefPtr<Identifier const>>();
// 2. ReturnIfAbrupt(next).
auto reference = TRY(id->to_reference(interpreter));
- auto initializer_result = TRY(interpreter.vm().named_evaluation_if_anonymous_function(*declarator.init(), id->string()));
+ auto initializer_result = TRY(interpreter.vm().named_evaluation_if_anonymous_function(*declarator->init(), id->string()));
VERIFY(!initializer_result.is_empty());
TRY(reference.initialize_referenced_binding(vm, initializer_result, Environment::InitializeBindingHint::SyncDispose));
}
@@ -3137,8 +3137,8 @@ Completion UsingDeclaration::execute(Interpreter& interpreter) const
ThrowCompletionOr<void> UsingDeclaration::for_each_bound_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const
{
for (auto const& entry : m_declarations) {
- VERIFY(entry.target().has<NonnullRefPtr<Identifier const>>());
- TRY(callback(entry.target().get<NonnullRefPtr<Identifier const>>()->string()));
+ VERIFY(entry->target().has<NonnullRefPtr<Identifier const>>());
+ TRY(callback(entry->target().get<NonnullRefPtr<Identifier const>>()->string()));
}
return {};
@@ -3149,7 +3149,7 @@ void UsingDeclaration::dump(int indent) const
ASTNode::dump(indent);
print_indent(indent + 1);
for (auto& declarator : m_declarations)
- declarator.dump(indent + 1);
+ declarator->dump(indent + 1);
}
void VariableDeclarator::dump(int indent) const
@@ -3178,7 +3178,7 @@ void ObjectExpression::dump(int indent) const
{
ASTNode::dump(indent);
for (auto& property : m_properties) {
- property.dump(indent + 1);
+ property->dump(indent + 1);
}
}
@@ -3208,10 +3208,10 @@ Completion ObjectExpression::execute(Interpreter& interpreter) const
// 2. Perform ? PropertyDefinitionEvaluation of PropertyDefinitionList with argument obj.
for (auto& property : m_properties) {
- auto key = TRY(property.key().execute(interpreter)).release_value();
+ auto key = TRY(property->key().execute(interpreter)).release_value();
// PropertyDefinition : ... AssignmentExpression
- if (property.type() == ObjectProperty::Type::Spread) {
+ if (property->type() == ObjectProperty::Type::Spread) {
// 4. Perform ? CopyDataProperties(object, fromValue, excludedNames).
TRY(object->copy_data_properties(vm, key, {}));
@@ -3219,10 +3219,10 @@ Completion ObjectExpression::execute(Interpreter& interpreter) const
continue;
}
- auto value = TRY(property.value().execute(interpreter)).release_value();
+ auto value = TRY(property->value().execute(interpreter)).release_value();
// 8. If isProtoSetter is true, then
- if (property.type() == ObjectProperty::Type::ProtoSetter) {
+ if (property->type() == ObjectProperty::Type::ProtoSetter) {
// a. If Type(propValue) is either Object or Null, then
if (value.is_object() || value.is_null()) {
// i. Perform ! object.[[SetPrototypeOf]](propValue).
@@ -3234,21 +3234,21 @@ Completion ObjectExpression::execute(Interpreter& interpreter) const
auto property_key = TRY(PropertyKey::from_value(vm, key));
- if (property.is_method()) {
+ if (property->is_method()) {
VERIFY(value.is_function());
static_cast<ECMAScriptFunctionObject&>(value.as_function()).set_home_object(object);
auto name = MUST(get_function_property_name(property_key));
- if (property.type() == ObjectProperty::Type::Getter) {
+ if (property->type() == ObjectProperty::Type::Getter) {
name = DeprecatedString::formatted("get {}", name);
- } else if (property.type() == ObjectProperty::Type::Setter) {
+ } else if (property->type() == ObjectProperty::Type::Setter) {
name = DeprecatedString::formatted("set {}", name);
}
update_function_name(value, name);
}
- switch (property.type()) {
+ switch (property->type()) {
case ObjectProperty::Type::Getter:
VERIFY(value.is_function());
object->define_direct_accessor(property_key, &value.as_function(), nullptr, Attribute::Configurable | Attribute::Enumerable);
@@ -3741,7 +3741,7 @@ void TemplateLiteral::dump(int indent) const
{
ASTNode::dump(indent);
for (auto& expression : m_expressions)
- expression.dump(indent + 1);
+ expression->dump(indent + 1);
}
// 13.2.8.5 Runtime Semantics: Evaluation, https://tc39.es/ecma262/#sec-template-literals-runtime-semantics-evaluation
@@ -3757,7 +3757,7 @@ Completion TemplateLiteral::execute(Interpreter& interpreter) const
// 2. Let subRef be the result of evaluating Expression.
// 3. Let sub be ? GetValue(subRef).
- auto sub = TRY(expression.execute(interpreter)).release_value();
+ auto sub = TRY(expression->execute(interpreter)).release_value();
// 4. Let middle be ? ToString(sub).
auto string = TRY(sub.to_deprecated_string(vm));
@@ -3835,7 +3835,7 @@ Completion TaggedTemplateLiteral::execute(Interpreter& interpreter) const
// tag`foo${bar}baz${qux}` -> "foo", bar, "baz", qux, "" -> tag(["foo", "baz", ""], bar, qux)
// So we want all the odd expressions
for (size_t i = 1; i < expressions.size(); i += 2)
- arguments.append(TRY(expressions[i].execute(interpreter)).release_value());
+ arguments.append(TRY(expressions[i]->execute(interpreter)).release_value());
// 5. Return ? EvaluateCall(tagFunc, tagRef, TemplateLiteral, tailCall).
return call(vm, tag, tag_this_value, move(arguments));
@@ -3887,7 +3887,7 @@ ThrowCompletionOr<Value> TaggedTemplateLiteral::get_template_object(Interpreter&
auto cooked_string_index = i * 2;
// a. Let prop be ! ToString(𝔽(index)).
// b. Let cookedValue be cookedStrings[index].
- auto cooked_value = TRY(expressions[cooked_string_index].execute(interpreter)).release_value();
+ auto cooked_value = TRY(expressions[cooked_string_index]->execute(interpreter)).release_value();
// NOTE: If the string contains invalid escapes we get a null expression here,
// which we then convert to the expected `undefined` TV. See
@@ -3900,7 +3900,7 @@ ThrowCompletionOr<Value> TaggedTemplateLiteral::get_template_object(Interpreter&
// d. Let rawValue be the String value rawStrings[index].
// e. Perform ! DefinePropertyOrThrow(rawObj, prop, PropertyDescriptor { [[Value]]: rawValue, [[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: false }).
- raw_obj->indexed_properties().append(TRY(raw_strings[i].execute(interpreter)).release_value());
+ raw_obj->indexed_properties().append(TRY(raw_strings[i]->execute(interpreter)).release_value());
// f. Set index to index + 1.
}
@@ -4108,11 +4108,11 @@ Completion SwitchStatement::execute_impl(Interpreter& interpreter) const
// 14.12.3 CaseClauseIsSelected ( C, input ), https://tc39.es/ecma262/#sec-runtime-semantics-caseclauseisselected
auto case_clause_is_selected = [&](auto const& case_clause, auto input) -> ThrowCompletionOr<bool> {
// 1. Assert: C is an instance of the production CaseClause : case Expression : StatementList[opt] .
- VERIFY(case_clause.test());
+ VERIFY(case_clause->test());
// 2. Let exprRef be the result of evaluating the Expression of C.
// 3. Let clauseSelector be ? GetValue(exprRef).
- auto clause_selector = TRY(case_clause.test()->execute(interpreter)).release_value();
+ auto clause_selector = TRY(case_clause->test()->execute(interpreter)).release_value();
// 4. Return IsStrictlyEqual(input, clauseSelector).
return is_strictly_equal(input, clause_selector);
@@ -4126,11 +4126,11 @@ Completion SwitchStatement::execute_impl(Interpreter& interpreter) const
return js_undefined();
}
- NonnullRefPtrVector<SwitchCase const> case_clauses_1;
- NonnullRefPtrVector<SwitchCase const> case_clauses_2;
+ Vector<NonnullRefPtr<SwitchCase const>> case_clauses_1;
+ Vector<NonnullRefPtr<SwitchCase const>> case_clauses_2;
RefPtr<SwitchCase const> default_clause;
for (auto const& switch_case : m_cases) {
- if (!switch_case.test())
+ if (!switch_case->test())
default_clause = switch_case;
else if (!default_clause)
case_clauses_1.append(switch_case);
@@ -4163,7 +4163,7 @@ Completion SwitchStatement::execute_impl(Interpreter& interpreter) const
// b. If found is true, then
if (found) {
// i. Let R be the result of evaluating C.
- auto result = case_clause.evaluate_statements(interpreter);
+ auto result = case_clause->evaluate_statements(interpreter);
// ii. If R.[[Value]] is not empty, set V to R.[[Value]].
if (result.value().has_value())
@@ -4203,7 +4203,7 @@ Completion SwitchStatement::execute_impl(Interpreter& interpreter) const
// b. If found is true, then
if (found) {
// i. Let R be the result of evaluating C.
- auto result = case_clause.evaluate_statements(interpreter);
+ auto result = case_clause->evaluate_statements(interpreter);
// ii. If R.[[Value]] is not empty, set V to R.[[Value]].
if (result.value().has_value())
@@ -4237,7 +4237,7 @@ Completion SwitchStatement::execute_impl(Interpreter& interpreter) const
// ii. If foundInB is true, then
if (found_in_b) {
// 1. Let R be the result of evaluating CaseClause C.
- auto result = case_clause.evaluate_statements(interpreter);
+ auto result = case_clause->evaluate_statements(interpreter);
// 2. If R.[[Value]] is not empty, set V to R.[[Value]].
if (result.value().has_value())
@@ -4269,7 +4269,7 @@ Completion SwitchStatement::execute_impl(Interpreter& interpreter) const
// 15. For each CaseClause C of B, do
for (auto const& case_clause : case_clauses_2) {
// a. Let R be the result of evaluating CaseClause C.
- result = case_clause.evaluate_statements(interpreter);
+ result = case_clause->evaluate_statements(interpreter);
// b. If R.[[Value]] is not empty, set V to R.[[Value]].
if (result.value().has_value())
@@ -4375,7 +4375,7 @@ void SwitchStatement::dump(int indent) const
ASTNode::dump(indent);
m_discriminant->dump(indent + 1);
for (auto& switch_case : m_cases) {
- switch_case.dump(indent + 1);
+ switch_case->dump(indent + 1);
}
}
@@ -4434,7 +4434,7 @@ void SequenceExpression::dump(int indent) const
{
ASTNode::dump(indent);
for (auto& expression : m_expressions)
- expression.dump(indent + 1);
+ expression->dump(indent + 1);
}
// 13.16.1 Runtime Semantics: Evaluation, https://tc39.es/ecma262/#sec-comma-operator-runtime-semantics-evaluation
@@ -4449,7 +4449,7 @@ Completion SequenceExpression::execute(Interpreter& interpreter) const
// 4. Return ? GetValue(rref).
Value last_value;
for (auto const& expression : m_expressions)
- last_value = TRY(expression.execute(interpreter)).release_value();
+ last_value = TRY(expression->execute(interpreter)).release_value();
return { move(last_value) };
}
@@ -4484,7 +4484,7 @@ ThrowCompletionOr<void> ScopeNode::for_each_lexically_scoped_declaration(ThrowCo
ThrowCompletionOr<void> ScopeNode::for_each_lexically_declared_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const
{
for (auto const& declaration : m_lexical_declarations) {
- TRY(declaration.for_each_bound_name([&](auto const& name) {
+ TRY(declaration->for_each_bound_name([&](auto const& name) {
return callback(name);
}));
}
@@ -4494,7 +4494,7 @@ ThrowCompletionOr<void> ScopeNode::for_each_lexically_declared_name(ThrowComplet
ThrowCompletionOr<void> ScopeNode::for_each_var_declared_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const
{
for (auto& declaration : m_var_declarations) {
- TRY(declaration.for_each_bound_name([&](auto const& name) {
+ TRY(declaration->for_each_bound_name([&](auto const& name) {
return callback(name);
}));
}
@@ -4506,7 +4506,7 @@ ThrowCompletionOr<void> ScopeNode::for_each_var_function_declaration_in_reverse_
for (ssize_t i = m_var_declarations.size() - 1; i >= 0; i--) {
auto& declaration = m_var_declarations[i];
if (is<FunctionDeclaration>(declaration))
- TRY(callback(static_cast<FunctionDeclaration const&>(declaration)));
+ TRY(callback(static_cast<FunctionDeclaration const&>(*declaration)));
}
return {};
}
@@ -4516,7 +4516,7 @@ ThrowCompletionOr<void> ScopeNode::for_each_var_scoped_variable_declaration(Thro
for (auto& declaration : m_var_declarations) {
if (!is<FunctionDeclaration>(declaration)) {
VERIFY(is<VariableDeclaration>(declaration));
- TRY(callback(static_cast<VariableDeclaration const&>(declaration)));
+ TRY(callback(static_cast<VariableDeclaration const&>(*declaration)));
}
}
return {};
@@ -4526,7 +4526,7 @@ ThrowCompletionOr<void> ScopeNode::for_each_function_hoistable_with_annexB_exten
{
for (auto& function : m_functions_hoistable_with_annexB_extension) {
// We need const_cast here since it might have to set a property on function declaration.
- TRY(callback(const_cast<FunctionDeclaration&>(function)));
+ TRY(callback(const_cast<FunctionDeclaration&>(*function)));
}
return {};
}
diff --git a/Userland/Libraries/LibJS/AST.h b/Userland/Libraries/LibJS/AST.h
index e73999e84a..79510f15ea 100644
--- a/Userland/Libraries/LibJS/AST.h
+++ b/Userland/Libraries/LibJS/AST.h
@@ -272,7 +272,7 @@ public:
{
auto child = create_ast_node<T>(range, forward<Args>(args)...);
m_children.append(move(child));
- return static_cast<T&>(m_children.last());
+ return static_cast<T&>(*m_children.last());
}
void append(NonnullRefPtr<Statement const> child)
{
@@ -287,7 +287,7 @@ public:
m_functions_hoistable_with_annexB_extension.shrink_to_fit();
}
- NonnullRefPtrVector<Statement const> const& children() const { return m_children; }
+ Vector<NonnullRefPtr<Statement const>> const& children() const { return m_children; }
virtual void dump(int indent) const override;
virtual Bytecode::CodeGenerationErrorOr<void> generate_bytecode(Bytecode::Generator&) const override;
@@ -324,11 +324,11 @@ protected:
private:
virtual bool is_scope_node() const final { return true; }
- NonnullRefPtrVector<Statement const> m_children;
- NonnullRefPtrVector<Declaration const> m_lexical_declarations;
- NonnullRefPtrVector<Declaration const> m_var_declarations;
+ Vector<NonnullRefPtr<Statement const>> m_children;
+ Vector<NonnullRefPtr<Declaration const>> m_lexical_declarations;
+ Vector<NonnullRefPtr<Declaration const>> m_var_declarations;
- NonnullRefPtrVector<FunctionDeclaration const> m_functions_hoistable_with_annexB_extension;
+ Vector<NonnullRefPtr<FunctionDeclaration const>> m_functions_hoistable_with_annexB_extension;
};
// ImportEntry Record, https://tc39.es/ecma262/#table-importentry-record-fields
@@ -526,11 +526,11 @@ public:
append(export_statement);
}
- NonnullRefPtrVector<ImportStatement const> const& imports() const { return m_imports; }
- NonnullRefPtrVector<ExportStatement const> const& exports() const { return m_exports; }
+ Vector<NonnullRefPtr<ImportStatement const>> const& imports() const { return m_imports; }
+ Vector<NonnullRefPtr<ExportStatement const>> const& exports() const { return m_exports; }
- NonnullRefPtrVector<ImportStatement const>& imports() { return m_imports; }
- NonnullRefPtrVector<ExportStatement const>& exports() { return m_exports; }
+ Vector<NonnullRefPtr<ImportStatement const>>& imports() { return m_imports; }
+ Vector<NonnullRefPtr<ExportStatement const>>& exports() { return m_exports; }
bool has_top_level_await() const { return m_has_top_level_await; }
void set_has_top_level_await() { m_has_top_level_await = true; }
@@ -543,8 +543,8 @@ private:
bool m_is_strict_mode { false };
Type m_type { Type::Script };
- NonnullRefPtrVector<ImportStatement const> m_imports;
- NonnullRefPtrVector<ExportStatement const> m_exports;
+ Vector<NonnullRefPtr<ImportStatement const>> m_imports;
+ Vector<NonnullRefPtr<ExportStatement const>> m_exports;
bool m_has_top_level_await { false };
};
@@ -1101,7 +1101,7 @@ private:
class SequenceExpression final : public Expression {
public:
- SequenceExpression(SourceRange source_range, NonnullRefPtrVector<Expression const> expressions)
+ SequenceExpression(SourceRange source_range, Vector<NonnullRefPtr<Expression const>> expressions)
: Expression(source_range)
, m_expressions(move(expressions))
{
@@ -1113,7 +1113,7 @@ public:
virtual Bytecode::CodeGenerationErrorOr<void> generate_bytecode(Bytecode::Generator&) const override;
private:
- NonnullRefPtrVector<Expression const> m_expressions;
+ Vector<NonnullRefPtr<Expression const>> m_expressions;
};
class Literal : public Expression {
@@ -1395,7 +1395,7 @@ public:
class ClassExpression final : public Expression {
public:
- ClassExpression(SourceRange source_range, DeprecatedString name, DeprecatedString source_text, RefPtr<FunctionExpression const> constructor, RefPtr<Expression const> super_class, NonnullRefPtrVector<ClassElement const> elements)
+ ClassExpression(SourceRange source_range, DeprecatedString name, DeprecatedString source_text, RefPtr<FunctionExpression const> constructor, RefPtr<Expression const> super_class, Vector<NonnullRefPtr<ClassElement const>> elements)
: Expression(source_range)
, m_name(move(name))
, m_source_text(move(source_text))
@@ -1424,7 +1424,7 @@ private:
DeprecatedString m_source_text;
RefPtr<FunctionExpression const> m_constructor;
RefPtr<Expression const> m_super_class;
- NonnullRefPtrVector<ClassElement const> m_elements;
+ Vector<NonnullRefPtr<ClassElement const>> m_elements;
};
class ClassDeclaration final : public Declaration {
@@ -1691,7 +1691,7 @@ private:
class VariableDeclaration final : public Declaration {
public:
- VariableDeclaration(SourceRange source_range, DeclarationKind declaration_kind, NonnullRefPtrVector<VariableDeclarator const> declarations)
+ VariableDeclaration(SourceRange source_range, DeclarationKind declaration_kind, Vector<NonnullRefPtr<VariableDeclarator const>> declarations)
: Declaration(source_range)
, m_declaration_kind(declaration_kind)
, m_declarations(move(declarations))
@@ -1704,7 +1704,7 @@ public:
virtual void dump(int indent) const override;
virtual Bytecode::CodeGenerationErrorOr<void> generate_bytecode(Bytecode::Generator&) const override;
- NonnullRefPtrVector<VariableDeclarator const> const& declarations() const { return m_declarations; }
+ Vector<NonnullRefPtr<VariableDeclarator const>> const& declarations() const { return m_declarations; }
virtual ThrowCompletionOr<void> for_each_bound_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const override;
@@ -1716,12 +1716,12 @@ private:
virtual bool is_variable_declaration() const override { return true; }
DeclarationKind m_declaration_kind;
- NonnullRefPtrVector<VariableDeclarator const> m_declarations;
+ Vector<NonnullRefPtr<VariableDeclarator const>> m_declarations;
};
class UsingDeclaration final : public Declaration {
public:
- UsingDeclaration(SourceRange source_range, NonnullRefPtrVector<VariableDeclarator const> declarations)
+ UsingDeclaration(SourceRange source_range, Vector<NonnullRefPtr<VariableDeclarator const>> declarations)
: Declaration(move(source_range))
, m_declarations(move(declarations))
{
@@ -1736,10 +1736,10 @@ public:
virtual bool is_lexical_declaration() const override { return true; }
- NonnullRefPtrVector<VariableDeclarator const> const& declarations() const { return m_declarations; }
+ Vector<NonnullRefPtr<VariableDeclarator const>> const& declarations() const { return m_declarations; }
private:
- NonnullRefPtrVector<VariableDeclarator const> m_declarations;
+ Vector<NonnullRefPtr<VariableDeclarator const>> m_declarations;
};
class ObjectProperty final : public ASTNode {
@@ -1783,7 +1783,7 @@ private:
class ObjectExpression final : public Expression {
public:
- explicit ObjectExpression(SourceRange source_range, NonnullRefPtrVector<ObjectProperty> properties = {})
+ explicit ObjectExpression(SourceRange source_range, Vector<NonnullRefPtr<ObjectProperty>> properties = {})
: Expression(source_range)
, m_properties(move(properties))
{
@@ -1796,7 +1796,7 @@ public:
private:
virtual bool is_object_expression() const override { return true; }
- NonnullRefPtrVector<ObjectProperty> m_properties;
+ Vector<NonnullRefPtr<ObjectProperty>> m_properties;
};
class ArrayExpression final : public Expression {
@@ -1821,13 +1821,13 @@ private:
class TemplateLiteral final : public Expression {
public:
- TemplateLiteral(SourceRange source_range, NonnullRefPtrVector<Expression const> expressions)
+ TemplateLiteral(SourceRange source_range, Vector<NonnullRefPtr<Expression const>> expressions)
: Expression(source_range)
, m_expressions(move(expressions))
{
}
- TemplateLiteral(SourceRange source_range, NonnullRefPtrVector<Expression const> expressions, NonnullRefPtrVector<Expression const> raw_strings)
+ TemplateLiteral(SourceRange source_range, Vector<NonnullRefPtr<Expression const>> expressions, Vector<NonnullRefPtr<Expression const>> raw_strings)
: Expression(source_range)
, m_expressions(move(expressions))
, m_raw_strings(move(raw_strings))
@@ -1838,12 +1838,12 @@ public:
virtual void dump(int indent) const override;
virtual Bytecode::CodeGenerationErrorOr<void> generate_bytecode(Bytecode::Generator&) const override;
- NonnullRefPtrVector<Expression const> const& expressions() const { return m_expressions; }
- NonnullRefPtrVector<Expression const> const& raw_strings() const { return m_raw_strings; }
+ Vector<NonnullRefPtr<Expression const>> const& expressions() const { return m_expressions; }
+ Vector<NonnullRefPtr<Expression const>> const& raw_strings() const { return m_raw_strings; }
private:
- NonnullRefPtrVector<Expression const> const m_expressions;
- NonnullRefPtrVector<Expression const> const m_raw_strings;
+ Vector<NonnullRefPtr<Expression const>> const m_expressions;
+ Vector<NonnullRefPtr<Expression const>> const m_raw_strings;
};
class TaggedTemplateLiteral final : public Expression {
@@ -2110,7 +2110,7 @@ public:
private:
NonnullRefPtr<Expression const> m_discriminant;
- NonnullRefPtrVector<SwitchCase const> m_cases;
+ Vector<NonnullRefPtr<SwitchCase const>> m_cases;
};
class BreakStatement final : public Statement {
diff --git a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp
index 44df9c5cb0..2c942e4b1d 100644
--- a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp
+++ b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp
@@ -291,7 +291,7 @@ Bytecode::CodeGenerationErrorOr<void> ScopeNode::generate_bytecode(Bytecode::Gen
return maybe_error.release_value();
for (auto& child : children()) {
- TRY(child.generate_bytecode(generator));
+ TRY(child->generate_bytecode(generator));
if (generator.is_current_block_terminated())
break;
}
@@ -1085,7 +1085,7 @@ Bytecode::CodeGenerationErrorOr<void> ObjectExpression::generate_bytecode(Byteco
for (auto& property : m_properties) {
Bytecode::Op::PropertyKind property_kind;
- switch (property.type()) {
+ switch (property->type()) {
case ObjectProperty::Type::KeyValue:
property_kind = Bytecode::Op::PropertyKind::KeyValue;
break;
@@ -1103,21 +1103,21 @@ Bytecode::CodeGenerationErrorOr<void> ObjectExpression::generate_bytecode(Byteco
break;
}
- if (is<StringLiteral>(property.key())) {
- auto& string_literal = static_cast<StringLiteral const&>(property.key());
+ if (is<StringLiteral>(property->key())) {
+ auto& string_literal = static_cast<StringLiteral const&>(property->key());
Bytecode::IdentifierTableIndex key_name = generator.intern_identifier(string_literal.value());
if (property_kind != Bytecode::Op::PropertyKind::Spread)
- TRY(property.value().generate_bytecode(generator));
+ TRY(property->value().generate_bytecode(generator));
generator.emit<Bytecode::Op::PutById>(object_reg, key_name, property_kind);
} else {
- TRY(property.key().generate_bytecode(generator));
+ TRY(property->key().generate_bytecode(generator));
auto property_reg = generator.allocate_register();
generator.emit<Bytecode::Op::Store>(property_reg);
if (property_kind != Bytecode::Op::PropertyKind::Spread)
- TRY(property.value().generate_bytecode(generator));
+ TRY(property->value().generate_bytecode(generator));
generator.emit<Bytecode::Op::PutByValue>(object_reg, property_reg, property_kind);
}
@@ -1504,8 +1504,8 @@ static Bytecode::CodeGenerationErrorOr<void> assign_accumulator_to_variable_decl
Bytecode::CodeGenerationErrorOr<void> VariableDeclaration::generate_bytecode(Bytecode::Generator& generator) const
{
for (auto& declarator : m_declarations) {
- if (declarator.init())
- TRY(declarator.init()->generate_bytecode(generator));
+ if (declarator->init())
+ TRY(declarator->init()->generate_bytecode(generator));
else
generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
TRY(assign_accumulator_to_variable_declarator(generator, declarator, *this));
@@ -2026,7 +2026,7 @@ Bytecode::CodeGenerationErrorOr<void> ConditionalExpression::generate_bytecode(B
Bytecode::CodeGenerationErrorOr<void> SequenceExpression::generate_bytecode(Bytecode::Generator& generator) const
{
for (auto& expression : m_expressions)
- TRY(expression.generate_bytecode(generator));
+ TRY(expression->generate_bytecode(generator));
return {};
}
@@ -2036,7 +2036,7 @@ Bytecode::CodeGenerationErrorOr<void> TemplateLiteral::generate_bytecode(Bytecod
auto string_reg = generator.allocate_register();
for (size_t i = 0; i < m_expressions.size(); i++) {
- TRY(m_expressions[i].generate_bytecode(generator));
+ TRY(m_expressions[i]->generate_bytecode(generator));
if (i == 0) {
generator.emit<Bytecode::Op::Store>(string_reg);
} else {
@@ -2069,7 +2069,7 @@ Bytecode::CodeGenerationErrorOr<void> TaggedTemplateLiteral::generate_bytecode(B
if (i % 2 != 0)
continue;
- TRY(expressions[i].generate_bytecode(generator));
+ TRY(expressions[i]->generate_bytecode(generator));
auto string_reg = string_regs[reg_index++];
generator.emit<Bytecode::Op::Store>(string_reg);
}
@@ -2089,7 +2089,7 @@ Bytecode::CodeGenerationErrorOr<void> TaggedTemplateLiteral::generate_bytecode(B
for (size_t i = 1; i < expressions.size(); i += 2) {
auto string_reg = argument_regs[1 + i / 2];
- TRY(expressions[i].generate_bytecode(generator));
+ TRY(expressions[i]->generate_bytecode(generator));
generator.emit<Bytecode::Op::Store>(string_reg);
}
@@ -2099,7 +2099,7 @@ Bytecode::CodeGenerationErrorOr<void> TaggedTemplateLiteral::generate_bytecode(B
reg_index = 0;
for (auto& raw_string : m_template_literal->raw_strings()) {
- TRY(raw_string.generate_bytecode(generator));
+ TRY(raw_string->generate_bytecode(generator));
auto raw_string_reg = string_regs[reg_index++];
generator.emit<Bytecode::Op::Store>(raw_string_reg);
raw_string_regs.append(raw_string_reg);
@@ -2292,9 +2292,9 @@ Bytecode::CodeGenerationErrorOr<void> SwitchStatement::generate_labelled_evaluat
for (auto& switch_case : m_cases) {
auto& case_block = generator.make_block();
- if (switch_case.test()) {
+ if (switch_case->test()) {
generator.switch_to_basic_block(*next_test_block);
- TRY(switch_case.test()->generate_bytecode(generator));
+ TRY(switch_case->test()->generate_bytecode(generator));
generator.emit<Bytecode::Op::StrictlyEquals>(discriminant_reg);
next_test_block = &generator.make_block();
generator.emit<Bytecode::Op::JumpConditional>().set_targets(Bytecode::Label { case_block }, Bytecode::Label { *next_test_block });
@@ -2318,8 +2318,8 @@ Bytecode::CodeGenerationErrorOr<void> SwitchStatement::generate_labelled_evaluat
generator.switch_to_basic_block(*current_block);
generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
- for (auto& statement : switch_case.children()) {
- TRY(statement.generate_bytecode(generator));
+ for (auto& statement : switch_case->children()) {
+ TRY(statement->generate_bytecode(generator));
if (generator.is_current_block_terminated())
break;
}
@@ -2464,7 +2464,7 @@ static Bytecode::CodeGenerationErrorOr<ForInOfHeadEvaluationResult> for_in_of_he
// ForInOfStatement : for ( ForDeclaration of AssignmentExpression ) Statement
auto& variable_declaration = static_cast<VariableDeclaration const&>(**ast_ptr);
- result.is_destructuring = variable_declaration.declarations().first().target().has<NonnullRefPtr<BindingPattern const>>();
+ result.is_destructuring = variable_declaration.declarations().first()->target().has<NonnullRefPtr<BindingPattern const>>();
result.lhs_kind = variable_declaration.is_lexical_declaration() ? LHSKind::LexicalBinding : LHSKind::VarBinding;
// 1. Let oldEnv be the running execution context's LexicalEnvironment.
@@ -2660,7 +2660,7 @@ static Bytecode::CodeGenerationErrorOr<void> for_in_of_body_evaluation(Bytecode:
if (!destructuring) {
// 1. Assert: lhs binds a single name.
// 2. Let lhsName be the sole element of BoundNames of lhs.
- auto lhs_name = variable_declaration.declarations().first().target().get<NonnullRefPtr<Identifier const>>()->string();
+ auto lhs_name = variable_declaration.declarations().first()->target().get<NonnullRefPtr<Identifier const>>()->string();
// 3. Let lhsRef be ! ResolveBinding(lhsName).
// NOTE: We're skipping all the completion stuff that the spec does, as the unwinding mechanism will take case of doing that.
auto identifier = generator.intern_identifier(lhs_name);
@@ -2692,7 +2692,7 @@ static Bytecode::CodeGenerationErrorOr<void> for_in_of_body_evaluation(Bytecode:
if (head_result.lhs_kind == LHSKind::VarBinding || head_result.lhs_kind == LHSKind::LexicalBinding) {
auto& declaration = static_cast<VariableDeclaration const&>(*lhs.get<NonnullRefPtr<ASTNode const>>());
VERIFY(declaration.declarations().size() == 1);
- auto& binding_pattern = declaration.declarations().first().target().get<NonnullRefPtr<BindingPattern const>>();
+ auto& binding_pattern = declaration.declarations().first()->target().get<NonnullRefPtr<BindingPattern const>>();
auto value_register = generator.allocate_register();
generator.emit<Bytecode::Op::Store>(value_register);
diff --git a/Userland/Libraries/LibJS/Parser.cpp b/Userland/Libraries/LibJS/Parser.cpp
index 1261498211..6ca40d55ac 100644
--- a/Userland/Libraries/LibJS/Parser.cpp
+++ b/Userland/Libraries/LibJS/Parser.cpp
@@ -231,13 +231,13 @@ public:
for (size_t i = 0; i < m_functions_to_hoist.size(); i++) {
auto const& function_declaration = m_functions_to_hoist[i];
- if (m_lexical_names.contains(function_declaration.name()) || m_forbidden_var_names.contains(function_declaration.name()))
+ if (m_lexical_names.contains(function_declaration->name()) || m_forbidden_var_names.contains(function_declaration->name()))
continue;
if (is_top_level()) {
- m_node->add_hoisted_function(move(m_functions_to_hoist.ptr_at(i)));
+ m_node->add_hoisted_function(move(m_functions_to_hoist[i]));
} else {
- if (!m_parent_scope->m_lexical_names.contains(function_declaration.name()) && !m_parent_scope->m_function_names.contains(function_declaration.name()))
- m_parent_scope->m_functions_to_hoist.append(move(m_functions_to_hoist.ptr_at(i)));
+ if (!m_parent_scope->m_lexical_names.contains(function_declaration->name()) && !m_parent_scope->m_function_names.contains(function_declaration->name()))
+ m_parent_scope->m_functions_to_hoist.append(move(m_functions_to_hoist[i]));
}
}
@@ -284,7 +284,7 @@ private:
HashTable<DeprecatedFlyString> m_forbidden_lexical_names;
HashTable<DeprecatedFlyString> m_forbidden_var_names;
- NonnullRefPtrVector<FunctionDeclaration const> m_functions_to_hoist;
+ Vector<NonnullRefPtr<FunctionDeclaration const>> m_functions_to_hoist;
Optional<Vector<FunctionParameter>> m_function_parameters;
@@ -565,9 +565,9 @@ void Parser::parse_module(Program& program)
program.set_has_top_level_await();
for (auto& export_statement : program.exports()) {
- if (export_statement.has_statement())
+ if (export_statement->has_statement())
continue;
- for (auto& entry : export_statement.entries()) {
+ for (auto& entry : export_statement->entries()) {
if (entry.is_module_request() || entry.kind == ExportEntry::Kind::EmptyNamedExport)
return;
@@ -586,14 +586,14 @@ void Parser::parse_module(Program& program)
found = true;
}));
for (auto& import : program.imports()) {
- if (import.has_bound_name(exported_name)) {
+ if (import->has_bound_name(exported_name)) {
found = true;
break;
}
}
if (!found)
- syntax_error(DeprecatedString::formatted("'{}' in export is not declared", exported_name), export_statement.source_range().start);
+ syntax_error(DeprecatedString::formatted("'{}' in export is not declared", exported_name), export_statement->source_range().start);
}
}
}
@@ -1065,7 +1065,7 @@ NonnullRefPtr<ClassExpression const> Parser::parse_class_expression(bool expect_
consume(TokenType::Class);
- NonnullRefPtrVector<ClassElement const> elements;
+ Vector<NonnullRefPtr<ClassElement const>> elements;
RefPtr<Expression const> super_class;
RefPtr<FunctionExpression const> constructor;
HashTable<DeprecatedFlyString> found_private_names;
@@ -1188,18 +1188,18 @@ NonnullRefPtr<ClassExpression const> Parser::parse_class_expression(bool expect_
// and the getter and setter are either both static or both non-static.
for (auto& element : elements) {
- auto private_name = element.private_bound_identifier();
+ auto private_name = element->private_bound_identifier();
if (!private_name.has_value() || private_name.value() != name)
continue;
- if (element.class_element_kind() != ClassElement::ElementKind::Method
- || element.is_static() != is_static) {
+ if (element->class_element_kind() != ClassElement::ElementKind::Method
+ || element->is_static() != is_static) {
syntax_error(DeprecatedString::formatted("Duplicate private field or method named '{}'", name));
break;
}
- VERIFY(is<ClassMethod>(element));
- auto& class_method_element = static_cast<ClassMethod const&>(element);
+ VERIFY(is<ClassMethod>(*element));
+ auto& class_method_element = static_cast<ClassMethod const&>(*element);
if (class_method_element.kind() == ClassMethod::Kind::Method || class_method_element.kind() == method_kind) {
syntax_error(DeprecatedString::formatted("Duplicate private field or method named '{}'", name));
@@ -1690,7 +1690,7 @@ NonnullRefPtr<ObjectExpression const> Parser::parse_object_expression()
auto rule_start = push_start();
consume(TokenType::CurlyOpen);
- NonnullRefPtrVector<ObjectProperty> properties;
+ Vector<NonnullRefPtr<ObjectProperty>> properties;
ObjectProperty::Type property_type;
Optional<SourceRange> invalid_object_literal_property_range;
@@ -1908,8 +1908,8 @@ NonnullRefPtr<TemplateLiteral const> Parser::parse_template_literal(bool is_tagg
auto rule_start = push_start();
consume(TokenType::TemplateLiteralStart);
- NonnullRefPtrVector<Expression const> expressions;
- NonnullRefPtrVector<Expression const> raw_strings;
+ Vector<NonnullRefPtr<Expression const>> expressions;
+ Vector<NonnullRefPtr<Expression const>> raw_strings;
auto append_empty_string = [this, &rule_start, &expressions, &raw_strings, is_tagged]() {
auto string_literal = create_ast_node<StringLiteral>({ m_source_code, rule_start.position(), position() }, "");
@@ -2044,7 +2044,7 @@ NonnullRefPtr<Expression const> Parser::parse_expression(int min_precedence, Ass
}
if (match(TokenType::Comma) && min_precedence <= 1) {
- NonnullRefPtrVector<Expression const> expressions;
+ Vector<NonnullRefPtr<Expression const>> expressions;
expressions.append(expression);
while (match(TokenType::Comma)) {
consume();
@@ -3024,7 +3024,7 @@ NonnullRefPtr<VariableDeclaration const> Parser::parse_variable_declaration(IsFo
}
consume();
- NonnullRefPtrVector<VariableDeclarator const> declarations;
+ Vector<NonnullRefPtr<VariableDeclarator const>> declarations;
for (;;) {
Variant<NonnullRefPtr<Identifier const>, NonnullRefPtr<BindingPattern const>, Empty> target {};
if (auto pattern = parse_binding_pattern(declaration_kind != DeclarationKind::Var ? AllowDuplicates::No : AllowDuplicates::Yes, AllowMemberExpressions::No)) {
@@ -3096,7 +3096,7 @@ NonnullRefPtr<UsingDeclaration const> Parser::parse_using_declaration(IsForLoopV
VERIFY(m_state.current_token.original_value() == "using"sv);
consume(TokenType::Identifier);
VERIFY(!m_state.current_token.trivia_contains_line_terminator());
- NonnullRefPtrVector<VariableDeclarator const> declarations;
+ Vector<NonnullRefPtr<VariableDeclarator const>> declarations;
for (;;) {
auto lexical_binding = parse_lexical_binding();
@@ -3385,7 +3385,7 @@ NonnullRefPtr<SwitchStatement const> Parser::parse_switch_statement()
consume(TokenType::CurlyOpen);
- NonnullRefPtrVector<SwitchCase> cases;
+ Vector<NonnullRefPtr<SwitchCase>> cases;
auto switch_statement = create_ast_node<SwitchStatement>({ m_source_code, rule_start.position(), position() }, move(determinant));
@@ -3431,7 +3431,7 @@ NonnullRefPtr<SwitchCase const> Parser::parse_switch_case()
consume(TokenType::Colon);
- NonnullRefPtrVector<Statement> consequent;
+ Vector<NonnullRefPtr<Statement>> consequent;
TemporaryChange break_change(m_state.in_break_context, true);
auto switch_case = create_ast_node<SwitchCase>({ m_source_code, rule_start.position(), position() }, move(test));
parse_statement_list(switch_case);
@@ -3609,7 +3609,7 @@ NonnullRefPtr<Statement const> Parser::parse_for_statement()
if (match_of(m_state.current_token)) {
if (declaration->declarations().size() != 1)
syntax_error("Must have exactly one declaration in for using of");
- else if (declaration->declarations().first().init())
+ else if (declaration->declarations().first()->init())
syntax_error("Using declaration cannot have initializer");
return parse_for_in_of_statement(move(declaration), is_await_loop);
@@ -3643,7 +3643,7 @@ NonnullRefPtr<Statement const> Parser::parse_for_statement()
}
if (declaration->declaration_kind() == DeclarationKind::Const) {
for (auto const& variable : declaration->declarations()) {
- if (!variable.init())
+ if (!variable->init())
syntax_error("Missing initializer in 'const' variable declaration");
}
}
@@ -3699,8 +3699,8 @@ NonnullRefPtr<Statement const> Parser::parse_for_in_of_statement(NonnullRefPtr<A
if (!declaration.declarations().is_empty()) {
// AnnexB extension B.3.5 Initializers in ForIn Statement Heads, https://tc39.es/ecma262/#sec-initializers-in-forin-statement-heads
auto& variable = declaration.declarations().first();
- if (variable.init()) {
- if (m_state.strict_mode || declaration.declaration_kind() != DeclarationKind::Var || !variable.target().has<NonnullRefPtr<Identifier const>>())
+ if (variable->init()) {
+ if (m_state.strict_mode || declaration.declaration_kind() != DeclarationKind::Var || !variable->target().has<NonnullRefPtr<Identifier const>>())
syntax_error("Variable initializer not allowed in for..in/of");
else
has_annexB_for_in_init_extension = true;
@@ -4441,7 +4441,7 @@ NonnullRefPtr<ImportStatement const> Parser::parse_import_statement(Program& pro
for (auto& entry : entries_with_location) {
for (auto& import_statement : program.imports()) {
- if (import_statement.has_bound_name(entry.entry.local_name))
+ if (import_statement->has_bound_name(entry.entry.local_name))
syntax_error(DeprecatedString::formatted("Identifier '{}' already declared", entry.entry.local_name), entry.position);
}
@@ -4660,7 +4660,7 @@ NonnullRefPtr<ExportStatement const> Parser::parse_export_statement(Program& pro
auto& variables = static_cast<VariableDeclaration const&>(*declaration);
VERIFY(variables.is_lexical_declaration());
for (auto& decl : variables.declarations()) {
- decl.target().visit(
+ decl->target().visit(
[&](NonnullRefPtr<Identifier const> const& identifier) {
entries_with_location.append({ ExportEntry::named_export(identifier->string(), identifier->string()), identifier->source_range().start });
},
@@ -4678,7 +4678,7 @@ NonnullRefPtr<ExportStatement const> Parser::parse_export_statement(Program& pro
auto variable_declaration = parse_variable_declaration();
m_state.current_scope_pusher->add_declaration(variable_declaration);
for (auto& decl : variable_declaration->declarations()) {
- decl.target().visit(
+ decl->target().visit(
[&](NonnullRefPtr<Identifier const> const& identifier) {
entries_with_location.append({ ExportEntry::named_export(identifier->string(), identifier->string()), identifier->source_range().start });
},
@@ -4742,7 +4742,7 @@ NonnullRefPtr<ExportStatement const> Parser::parse_export_statement(Program& pro
for (auto& entry : entries_with_location) {
for (auto& export_statement : program.exports()) {
- if (export_statement.has_export(entry.entry.export_name))
+ if (export_statement->has_export(entry.entry.export_name))
syntax_error(DeprecatedString::formatted("Duplicate export with name: '{}'", entry.entry.export_name), entry.position);
}
diff --git a/Userland/Libraries/LibJS/SourceTextModule.cpp b/Userland/Libraries/LibJS/SourceTextModule.cpp
index 43b0306285..73cb952d44 100644
--- a/Userland/Libraries/LibJS/SourceTextModule.cpp
+++ b/Userland/Libraries/LibJS/SourceTextModule.cpp
@@ -55,13 +55,13 @@ static Vector<ModuleRequest> module_requests(Program& program, Vector<Deprecated
Vector<RequestedModuleAndSourceIndex> requested_modules_with_indices;
for (auto& import_statement : program.imports())
- requested_modules_with_indices.empend(import_statement.start_offset(), &import_statement.module_request());
+ requested_modules_with_indices.empend(import_statement->start_offset(), &import_statement->module_request());
for (auto& export_statement : program.exports()) {
- for (auto& export_entry : export_statement.entries()) {
+ for (auto& export_entry : export_statement->entries()) {
if (!export_entry.is_module_request())
continue;
- requested_modules_with_indices.empend(export_statement.start_offset(), &export_statement.module_request());
+ requested_modules_with_indices.empend(export_statement->start_offset(), &export_statement->module_request());
}
}
@@ -141,7 +141,7 @@ Result<NonnullGCPtr<SourceTextModule>, Vector<ParserError>> SourceTextModule::pa
// 4. Let importEntries be ImportEntries of body.
Vector<ImportEntry> import_entries;
for (auto const& import_statement : body->imports())
- import_entries.extend(import_statement.entries());
+ import_entries.extend(import_statement->entries());
// 5. Let importedBoundNames be ImportedLocalNames(importEntries).
// Note: Since we have to potentially extract the import entry we just use importEntries
@@ -163,12 +163,12 @@ Result<NonnullGCPtr<SourceTextModule>, Vector<ParserError>> SourceTextModule::pa
// 10. For each ExportEntry Record ee of exportEntries, do
for (auto const& export_statement : body->exports()) {
- if (export_statement.is_default_export()) {
+ if (export_statement->is_default_export()) {
VERIFY(!default_export);
- VERIFY(export_statement.entries().size() == 1);
- VERIFY(export_statement.has_statement());
+ VERIFY(export_statement->entries().size() == 1);
+ VERIFY(export_statement->has_statement());
- auto const& entry = export_statement.entries()[0];
+ auto const& entry = export_statement->entries()[0];
VERIFY(entry.kind == ExportEntry::Kind::NamedExport);
VERIFY(!entry.is_module_request());
VERIFY(import_entries.find_if(
@@ -179,12 +179,12 @@ Result<NonnullGCPtr<SourceTextModule>, Vector<ParserError>> SourceTextModule::pa
default_export = export_statement;
}
- for (auto const& export_entry : export_statement.entries()) {
+ for (auto const& export_entry : export_statement->entries()) {
// Special case, export {} from "module" should add "module" to
// required_modules but not any import or export so skip here.
if (export_entry.kind == ExportEntry::Kind::EmptyNamedExport) {
- VERIFY(export_statement.entries().size() == 1);
+ VERIFY(export_statement->entries().size() == 1);
break;
}
diff --git a/Userland/Libraries/LibManual/PageNode.cpp b/Userland/Libraries/LibManual/PageNode.cpp
index d2b6605cc0..7dcc918c08 100644
--- a/Userland/Libraries/LibManual/PageNode.cpp
+++ b/Userland/Libraries/LibManual/PageNode.cpp
@@ -18,7 +18,7 @@ Node const* PageNode::parent() const
ErrorOr<Span<NonnullRefPtr<Node const>>> PageNode::children() const
{
- static NonnullRefPtrVector<Node const> empty_vector;
+ static Vector<NonnullRefPtr<Node const>> empty_vector;
return empty_vector.span();
}
diff --git a/Userland/Libraries/LibManual/SectionNode.h b/Userland/Libraries/LibManual/SectionNode.h
index 4f405dae31..a349d7821e 100644
--- a/Userland/Libraries/LibManual/SectionNode.h
+++ b/Userland/Libraries/LibManual/SectionNode.h
@@ -48,7 +48,7 @@ protected:
private:
ErrorOr<void> reify_if_needed() const;
- mutable NonnullRefPtrVector<Node const> m_children;
+ mutable Vector<NonnullRefPtr<Node const>> m_children;
mutable bool m_reified { false };
bool m_open { false };
};
diff --git a/Userland/Libraries/LibPDF/Document.cpp b/Userland/Libraries/LibPDF/Document.cpp
index 02112b2ed0..99d70127ca 100644
--- a/Userland/Libraries/LibPDF/Document.cpp
+++ b/Userland/Libraries/LibPDF/Document.cpp
@@ -17,7 +17,7 @@ DeprecatedString OutlineItem::to_deprecated_string(int indent) const
StringBuilder child_builder;
child_builder.append('[');
for (auto& child : children)
- child_builder.appendff("{}\n", child.to_deprecated_string(indent + 1));
+ child_builder.appendff("{}\n", child->to_deprecated_string(indent + 1));
child_builder.appendff("{}]", indent_str);
StringBuilder builder;
@@ -335,7 +335,7 @@ PDFErrorOr<NonnullRefPtr<OutlineItem>> Document::build_outline_item(NonnullRefPt
auto first_ref = outline_item_dict->get_value(CommonNames::First);
auto children = TRY(build_outline_item_chain(first_ref, page_number_by_index_ref));
for (auto& child : children) {
- child.parent = outline_item;
+ child->parent = outline_item;
}
outline_item->children = move(children);
}
@@ -390,7 +390,7 @@ PDFErrorOr<NonnullRefPtr<OutlineItem>> Document::build_outline_item(NonnullRefPt
return outline_item;
}
-PDFErrorOr<NonnullRefPtrVector<OutlineItem>> Document::build_outline_item_chain(Value const& first_ref, HashMap<u32, u32> const& page_number_by_index_ref)
+PDFErrorOr<Vector<NonnullRefPtr<OutlineItem>>> Document::build_outline_item_chain(Value const& first_ref, HashMap<u32, u32> const& page_number_by_index_ref)
{
// We used to receive a last_ref parameter, which was what the parent of this chain
// thought was this chain's last child. There are documents out there in the wild
@@ -399,7 +399,7 @@ PDFErrorOr<NonnullRefPtrVector<OutlineItem>> Document::build_outline_item_chain(
// (we already ignore the /Parent attribute too, which can also be out of sync).
VERIFY(first_ref.has<Reference>());
- NonnullRefPtrVector<OutlineItem> children;
+ Vector<NonnullRefPtr<OutlineItem>> children;
auto first_value = TRY(get_or_load_value(first_ref.as_ref_index())).get<NonnullRefPtr<Object>>();
auto first_dict = first_value->cast<DictObject>();
diff --git a/Userland/Libraries/LibPDF/Document.h b/Userland/Libraries/LibPDF/Document.h
index bbb7bc164f..7805a20017 100644
--- a/Userland/Libraries/LibPDF/Document.h
+++ b/Userland/Libraries/LibPDF/Document.h
@@ -56,7 +56,7 @@ struct Destination {
struct OutlineItem final : public RefCounted<OutlineItem> {
RefPtr<OutlineItem> parent;
- NonnullRefPtrVector<OutlineItem> children;
+ Vector<NonnullRefPtr<OutlineItem>> children;
DeprecatedString title;
i32 count { 0 };
Destination dest;
@@ -70,7 +70,7 @@ struct OutlineItem final : public RefCounted<OutlineItem> {
};
struct OutlineDict final : public RefCounted<OutlineDict> {
- NonnullRefPtrVector<OutlineItem> children;
+ Vector<NonnullRefPtr<OutlineItem>> children;
u32 count { 0 };
OutlineDict() = default;
@@ -138,7 +138,7 @@ private:
PDFErrorOr<void> build_outline();
PDFErrorOr<NonnullRefPtr<OutlineItem>> build_outline_item(NonnullRefPtr<DictObject> const& outline_item_dict, HashMap<u32, u32> const&);
- PDFErrorOr<NonnullRefPtrVector<OutlineItem>> build_outline_item_chain(Value const& first_ref, HashMap<u32, u32> const&);
+ PDFErrorOr<Vector<NonnullRefPtr<OutlineItem>>> build_outline_item_chain(Value const& first_ref, HashMap<u32, u32> const&);
PDFErrorOr<Destination> create_destination_from_parameters(NonnullRefPtr<ArrayObject>, HashMap<u32, u32> const&);
PDFErrorOr<Destination> create_destination_from_dictionary_entry(NonnullRefPtr<Object> const& entry, HashMap<u32, u32> const& page_number_by_index_ref);
@@ -258,7 +258,7 @@ struct Formatter<PDF::OutlineDict> : Formatter<FormatString> {
StringBuilder child_builder;
child_builder.append('[');
for (auto& child : dict.children)
- child_builder.appendff("{}\n", child.to_deprecated_string(2));
+ child_builder.appendff("{}\n", child->to_deprecated_string(2));
child_builder.append(" ]"sv);
return Formatter<FormatString>::format(builder,
diff --git a/Userland/Libraries/LibPDF/Renderer.cpp b/Userland/Libraries/LibPDF/Renderer.cpp
index bf5505dfb9..eb1f0681d2 100644
--- a/Userland/Libraries/LibPDF/Renderer.cpp
+++ b/Userland/Libraries/LibPDF/Renderer.cpp
@@ -238,7 +238,7 @@ RENDERER_HANDLER(path_cubic_bezier_curve_no_first_control)
{
VERIFY(args.size() == 4);
VERIFY(!m_current_path.segments().is_empty());
- auto current_point = m_current_path.segments().rbegin()->point();
+ auto current_point = (*m_current_path.segments().rbegin())->point();
m_current_path.cubic_bezier_curve_to(
current_point,
map(args[0].to_float(), args[1].to_float()),
diff --git a/Userland/Libraries/LibSQL/AST/AST.h b/Userland/Libraries/LibSQL/AST/AST.h
index c1e2501f6c..7668ed342d 100644
--- a/Userland/Libraries/LibSQL/AST/AST.h
+++ b/Userland/Libraries/LibSQL/AST/AST.h
@@ -55,7 +55,7 @@ private:
class TypeName : public ASTNode {
public:
- TypeName(DeprecatedString name, NonnullRefPtrVector<SignedNumber> signed_numbers)
+ TypeName(DeprecatedString name, Vector<NonnullRefPtr<SignedNumber>> signed_numbers)
: m_name(move(name))
, m_signed_numbers(move(signed_numbers))
{
@@ -63,11 +63,11 @@ public:
}
DeprecatedString const& name() const { return m_name; }
- NonnullRefPtrVector<SignedNumber> const& signed_numbers() const { return m_signed_numbers; }
+ Vector<NonnullRefPtr<SignedNumber>> const& signed_numbers() const { return m_signed_numbers; }
private:
DeprecatedString m_name;
- NonnullRefPtrVector<SignedNumber> m_signed_numbers;
+ Vector<NonnullRefPtr<SignedNumber>> m_signed_numbers;
};
class ColumnDefinition : public ASTNode {
@@ -107,7 +107,7 @@ private:
class CommonTableExpressionList : public ASTNode {
public:
- CommonTableExpressionList(bool recursive, NonnullRefPtrVector<CommonTableExpression> common_table_expressions)
+ CommonTableExpressionList(bool recursive, Vector<NonnullRefPtr<CommonTableExpression>> common_table_expressions)
: m_recursive(recursive)
, m_common_table_expressions(move(common_table_expressions))
{
@@ -115,11 +115,11 @@ public:
}
bool recursive() const { return m_recursive; }
- NonnullRefPtrVector<CommonTableExpression> const& common_table_expressions() const { return m_common_table_expressions; }
+ Vector<NonnullRefPtr<CommonTableExpression>> const& common_table_expressions() const { return m_common_table_expressions; }
private:
bool m_recursive;
- NonnullRefPtrVector<CommonTableExpression> m_common_table_expressions;
+ Vector<NonnullRefPtr<CommonTableExpression>> m_common_table_expressions;
};
class QualifiedTableName : public ASTNode {
@@ -205,18 +205,18 @@ private:
class GroupByClause : public ASTNode {
public:
- GroupByClause(NonnullRefPtrVector<Expression> group_by_list, RefPtr<Expression> having_clause)
+ GroupByClause(Vector<NonnullRefPtr<Expression>> group_by_list, RefPtr<Expression> having_clause)
: m_group_by_list(move(group_by_list))
, m_having_clause(move(having_clause))
{
VERIFY(!m_group_by_list.is_empty());
}
- NonnullRefPtrVector<Expression> const& group_by_list() const { return m_group_by_list; }
+ Vector<NonnullRefPtr<Expression>> const& group_by_list() const { return m_group_by_list; }
RefPtr<Expression> const& having_clause() const { return m_having_clause; }
private:
- NonnullRefPtrVector<Expression> m_group_by_list;
+ Vector<NonnullRefPtr<Expression>> m_group_by_list;
RefPtr<Expression> m_having_clause;
};
@@ -232,7 +232,7 @@ public:
{
}
- explicit TableOrSubquery(NonnullRefPtrVector<TableOrSubquery> subqueries)
+ explicit TableOrSubquery(Vector<NonnullRefPtr<TableOrSubquery>> subqueries)
: m_is_subquery(!subqueries.is_empty())
, m_subqueries(move(subqueries))
{
@@ -244,7 +244,7 @@ public:
DeprecatedString const& table_alias() const { return m_table_alias; }
bool is_subquery() const { return m_is_subquery; }
- NonnullRefPtrVector<TableOrSubquery> const& subqueries() const { return m_subqueries; }
+ Vector<NonnullRefPtr<TableOrSubquery>> const& subqueries() const { return m_subqueries; }
private:
bool m_is_table { false };
@@ -253,7 +253,7 @@ private:
DeprecatedString m_table_alias {};
bool m_is_subquery { false };
- NonnullRefPtrVector<TableOrSubquery> m_subqueries {};
+ Vector<NonnullRefPtr<TableOrSubquery>> m_subqueries {};
};
class OrderingTerm : public ASTNode {
@@ -573,16 +573,16 @@ private:
class ChainedExpression : public Expression {
public:
- explicit ChainedExpression(NonnullRefPtrVector<Expression> expressions)
+ explicit ChainedExpression(Vector<NonnullRefPtr<Expression>> expressions)
: m_expressions(move(expressions))
{
}
- NonnullRefPtrVector<Expression> const& expressions() const { return m_expressions; }
+ Vector<NonnullRefPtr<Expression>> const& expressions() const { return m_expressions; }
virtual ResultOr<Value> evaluate(ExecutionContext&) const override;
private:
- NonnullRefPtrVector<Expression> m_expressions;
+ Vector<NonnullRefPtr<Expression>> m_expressions;
};
class CastExpression : public NestedExpression {
@@ -800,7 +800,7 @@ public:
{
}
- CreateTable(DeprecatedString schema_name, DeprecatedString table_name, NonnullRefPtrVector<ColumnDefinition> columns, bool is_temporary, bool is_error_if_table_exists)
+ CreateTable(DeprecatedString schema_name, DeprecatedString table_name, Vector<NonnullRefPtr<ColumnDefinition>> columns, bool is_temporary, bool is_error_if_table_exists)
: m_schema_name(move(schema_name))
, m_table_name(move(table_name))
, m_columns(move(columns))
@@ -816,7 +816,7 @@ public:
RefPtr<Select> const& select_statement() const { return m_select_statement; }
bool has_columns() const { return !m_columns.is_empty(); }
- NonnullRefPtrVector<ColumnDefinition> const& columns() const { return m_columns; }
+ Vector<NonnullRefPtr<ColumnDefinition>> const& columns() const { return m_columns; }
bool is_temporary() const { return m_is_temporary; }
bool is_error_if_table_exists() const { return m_is_error_if_table_exists; }
@@ -827,7 +827,7 @@ private:
DeprecatedString m_schema_name;
DeprecatedString m_table_name;
RefPtr<Select> m_select_statement;
- NonnullRefPtrVector<ColumnDefinition> m_columns;
+ Vector<NonnullRefPtr<ColumnDefinition>> m_columns;
bool m_is_temporary;
bool m_is_error_if_table_exists;
};
@@ -937,7 +937,7 @@ enum class ConflictResolution {
class Insert : public Statement {
public:
- Insert(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString alias, Vector<DeprecatedString> column_names, NonnullRefPtrVector<ChainedExpression> chained_expressions)
+ Insert(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, DeprecatedString schema_name, DeprecatedString table_name, DeprecatedString alias, Vector<DeprecatedString> column_names, Vector<NonnullRefPtr<ChainedExpression>> chained_expressions)
: m_common_table_expression_list(move(common_table_expression_list))
, m_conflict_resolution(conflict_resolution)
, m_schema_name(move(schema_name))
@@ -979,7 +979,7 @@ public:
bool default_values() const { return !has_expressions() && !has_selection(); };
bool has_expressions() const { return !m_chained_expressions.is_empty(); }
- NonnullRefPtrVector<ChainedExpression> const& chained_expressions() const { return m_chained_expressions; }
+ Vector<NonnullRefPtr<ChainedExpression>> const& chained_expressions() const { return m_chained_expressions; }
bool has_selection() const { return !m_select_statement.is_null(); }
RefPtr<Select> const& select_statement() const { return m_select_statement; }
@@ -993,7 +993,7 @@ private:
DeprecatedString m_table_name;
DeprecatedString m_alias;
Vector<DeprecatedString> m_column_names;
- NonnullRefPtrVector<ChainedExpression> m_chained_expressions;
+ Vector<NonnullRefPtr<ChainedExpression>> m_chained_expressions;
RefPtr<Select> m_select_statement;
};
@@ -1004,7 +1004,7 @@ public:
NonnullRefPtr<Expression> expression;
};
- Update(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, NonnullRefPtr<QualifiedTableName> qualified_table_name, Vector<UpdateColumns> update_columns, NonnullRefPtrVector<TableOrSubquery> table_or_subquery_list, RefPtr<Expression> where_clause, RefPtr<ReturningClause> returning_clause)
+ Update(RefPtr<CommonTableExpressionList> common_table_expression_list, ConflictResolution conflict_resolution, NonnullRefPtr<QualifiedTableName> qualified_table_name, Vector<UpdateColumns> update_columns, Vector<NonnullRefPtr<TableOrSubquery>> table_or_subquery_list, RefPtr<Expression> where_clause, RefPtr<ReturningClause> returning_clause)
: m_common_table_expression_list(move(common_table_expression_list))
, m_conflict_resolution(conflict_resolution)
, m_qualified_table_name(move(qualified_table_name))
@@ -1019,7 +1019,7 @@ public:
ConflictResolution conflict_resolution() const { return m_conflict_resolution; }
NonnullRefPtr<QualifiedTableName> const& qualified_table_name() const { return m_qualified_table_name; }
Vector<UpdateColumns> const& update_columns() const { return m_update_columns; }
- NonnullRefPtrVector<TableOrSubquery> const& table_or_subquery_list() const { return m_table_or_subquery_list; }
+ Vector<NonnullRefPtr<TableOrSubquery>> const& table_or_subquery_list() const { return m_table_or_subquery_list; }
RefPtr<Expression> const& where_clause() const { return m_where_clause; }
RefPtr<ReturningClause> const& returning_clause() const { return m_returning_clause; }
@@ -1030,7 +1030,7 @@ private:
ConflictResolution m_conflict_resolution;
NonnullRefPtr<QualifiedTableName> m_qualified_table_name;
Vector<UpdateColumns> m_update_columns;
- NonnullRefPtrVector<TableOrSubquery> m_table_or_subquery_list;
+ Vector<NonnullRefPtr<TableOrSubquery>> m_table_or_subquery_list;
RefPtr<Expression> m_where_clause;
RefPtr<ReturningClause> m_returning_clause;
};
@@ -1061,7 +1061,7 @@ private:
class Select : public Statement {
public:
- Select(RefPtr<CommonTableExpressionList> common_table_expression_list, bool select_all, NonnullRefPtrVector<ResultColumn> result_column_list, NonnullRefPtrVector<TableOrSubquery> table_or_subquery_list, RefPtr<Expression> where_clause, RefPtr<GroupByClause> group_by_clause, NonnullRefPtrVector<OrderingTerm> ordering_term_list, RefPtr<LimitClause> limit_clause)
+ Select(RefPtr<CommonTableExpressionList> common_table_expression_list, bool select_all, Vector<NonnullRefPtr<ResultColumn>> result_column_list, Vector<NonnullRefPtr<TableOrSubquery>> table_or_subquery_list, RefPtr<Expression> where_clause, RefPtr<GroupByClause> group_by_clause, Vector<NonnullRefPtr<OrderingTerm>> ordering_term_list, RefPtr<LimitClause> limit_clause)
: m_common_table_expression_list(move(common_table_expression_list))
, m_select_all(move(select_all))
, m_result_column_list(move(result_column_list))
@@ -1075,22 +1075,22 @@ public:
RefPtr<CommonTableExpressionList> const& common_table_expression_list() const { return m_common_table_expression_list; }
bool select_all() const { return m_select_all; }
- NonnullRefPtrVector<ResultColumn> const& result_column_list() const { return m_result_column_list; }
- NonnullRefPtrVector<TableOrSubquery> const& table_or_subquery_list() const { return m_table_or_subquery_list; }
+ Vector<NonnullRefPtr<ResultColumn>> const& result_column_list() const { return m_result_column_list; }
+ Vector<NonnullRefPtr<TableOrSubquery>> const& table_or_subquery_list() const { return m_table_or_subquery_list; }
RefPtr<Expression> const& where_clause() const { return m_where_clause; }
RefPtr<GroupByClause> const& group_by_clause() const { return m_group_by_clause; }
- NonnullRefPtrVector<OrderingTerm> const& ordering_term_list() const { return m_ordering_term_list; }
+ Vector<NonnullRefPtr<OrderingTerm>> const& ordering_term_list() const { return m_ordering_term_list; }
RefPtr<LimitClause> const& limit_clause() const { return m_limit_clause; }
ResultOr<ResultSet> execute(ExecutionContext&) const override;
private:
RefPtr<CommonTableExpressionList> m_common_table_expression_list;
bool m_select_all;
- NonnullRefPtrVector<ResultColumn> m_result_column_list;
- NonnullRefPtrVector<TableOrSubquery> m_table_or_subquery_list;
+ Vector<NonnullRefPtr<ResultColumn>> m_result_column_list;
+ Vector<NonnullRefPtr<TableOrSubquery>> m_table_or_subquery_list;
RefPtr<Expression> m_where_clause;
RefPtr<GroupByClause> m_group_by_clause;
- NonnullRefPtrVector<OrderingTerm> m_ordering_term_list;
+ Vector<NonnullRefPtr<OrderingTerm>> m_ordering_term_list;
RefPtr<LimitClause> m_limit_clause;
};
diff --git a/Userland/Libraries/LibSQL/AST/CreateTable.cpp b/Userland/Libraries/LibSQL/AST/CreateTable.cpp
index a40409ee53..384574463d 100644
--- a/Userland/Libraries/LibSQL/AST/CreateTable.cpp
+++ b/Userland/Libraries/LibSQL/AST/CreateTable.cpp
@@ -17,18 +17,18 @@ ResultOr<ResultSet> CreateTable::execute(ExecutionContext& context) const
for (auto const& column : m_columns) {
SQLType type;
- if (column.type_name()->name().is_one_of("VARCHAR"sv, "TEXT"sv))
+ if (column->type_name()->name().is_one_of("VARCHAR"sv, "TEXT"sv))
type = SQLType::Text;
- else if (column.type_name()->name().is_one_of("INT"sv, "INTEGER"sv))
+ else if (column->type_name()->name().is_one_of("INT"sv, "INTEGER"sv))
type = SQLType::Integer;
- else if (column.type_name()->name().is_one_of("FLOAT"sv, "NUMBER"sv))
+ else if (column->type_name()->name().is_one_of("FLOAT"sv, "NUMBER"sv))
type = SQLType::Float;
- else if (column.type_name()->name().is_one_of("BOOL"sv, "BOOLEAN"sv))
+ else if (column->type_name()->name().is_one_of("BOOL"sv, "BOOLEAN"sv))
type = SQLType::Boolean;
else
- return Result { SQLCommand::Create, SQLErrorCode::InvalidType, column.type_name()->name() };
+ return Result { SQLCommand::Create, SQLErrorCode::InvalidType, column->type_name()->name() };
- table_def->append_column(column.name(), type);
+ table_def->append_column(column->name(), type);
}
if (auto result = context.database->add_table(*table_def); result.is_error()) {
diff --git a/Userland/Libraries/LibSQL/AST/Describe.cpp b/Userland/Libraries/LibSQL/AST/Describe.cpp
index 8cc6dfcba8..ecdf1b90ca 100644
--- a/Userland/Libraries/LibSQL/AST/Describe.cpp
+++ b/Userland/Libraries/LibSQL/AST/Describe.cpp
@@ -26,8 +26,8 @@ ResultOr<ResultSet> DescribeTable::execute(ExecutionContext& context) const
for (auto& column : table_def->columns()) {
Tuple tuple(descriptor);
- tuple[0] = column.name();
- tuple[1] = SQLType_name(column.type());
+ tuple[0] = column->name();
+ tuple[1] = SQLType_name(column->type());
result.insert_row(tuple, Tuple {});
}
diff --git a/Userland/Libraries/LibSQL/AST/Expression.cpp b/Userland/Libraries/LibSQL/AST/Expression.cpp
index e4457e4868..9bdb71b86c 100644
--- a/Userland/Libraries/LibSQL/AST/Expression.cpp
+++ b/Userland/Libraries/LibSQL/AST/Expression.cpp
@@ -52,7 +52,7 @@ ResultOr<Value> ChainedExpression::evaluate(ExecutionContext& context) const
TRY(values.try_ensure_capacity(expressions().size()));
for (auto& expression : expressions())
- values.unchecked_append(TRY(expression.evaluate(context)));
+ values.unchecked_append(TRY(expression->evaluate(context)));
return Value::create_tuple(move(values));
}
diff --git a/Userland/Libraries/LibSQL/AST/Insert.cpp b/Userland/Libraries/LibSQL/AST/Insert.cpp
index 76be3de763..43f7e5022f 100644
--- a/Userland/Libraries/LibSQL/AST/Insert.cpp
+++ b/Userland/Libraries/LibSQL/AST/Insert.cpp
@@ -27,11 +27,11 @@ ResultOr<ResultSet> Insert::execute(ExecutionContext& context) const
for (auto& row_expr : m_chained_expressions) {
for (auto& column_def : table_def->columns()) {
- if (!m_column_names.contains_slow(column_def.name()))
- row[column_def.name()] = column_def.default_value();
+ if (!m_column_names.contains_slow(column_def->name()))
+ row[column_def->name()] = column_def->default_value();
}
- auto row_value = TRY(row_expr.evaluate(context));
+ auto row_value = TRY(row_expr->evaluate(context));
VERIFY(row_value.type() == SQLType::Tuple);
auto values = row_value.to_vector().release_value();
@@ -46,7 +46,7 @@ ResultOr<ResultSet> Insert::execute(ExecutionContext& context) const
auto element_type = tuple_descriptor[element_index].type;
if (!values[ix].is_type_compatible_with(element_type))
- return Result { SQLCommand::Insert, SQLErrorCode::InvalidValueType, table_def->columns()[element_index].name() };
+ return Result { SQLCommand::Insert, SQLErrorCode::InvalidValueType, table_def->columns()[element_index]->name() };
row[element_index] = move(values[ix]);
}
diff --git a/Userland/Libraries/LibSQL/AST/Parser.cpp b/Userland/Libraries/LibSQL/AST/Parser.cpp
index 7d91cc85e2..26d88ec205 100644
--- a/Userland/Libraries/LibSQL/AST/Parser.cpp
+++ b/Userland/Libraries/LibSQL/AST/Parser.cpp
@@ -121,7 +121,7 @@ NonnullRefPtr<CreateTable> Parser::parse_create_table_statement()
return create_ast_node<CreateTable>(move(schema_name), move(table_name), move(select_statement), is_temporary, is_error_if_table_exists);
}
- NonnullRefPtrVector<ColumnDefinition> column_definitions;
+ Vector<NonnullRefPtr<ColumnDefinition>> column_definitions;
parse_comma_separated_list(true, [&]() { column_definitions.append(parse_column_definition()); });
// FIXME: Parse "table-constraint".
@@ -213,7 +213,7 @@ NonnullRefPtr<Insert> Parser::parse_insert_statement(RefPtr<CommonTableExpressio
if (match(TokenType::ParenOpen))
parse_comma_separated_list(true, [&]() { column_names.append(consume(TokenType::Identifier).value()); });
- NonnullRefPtrVector<ChainedExpression> chained_expressions;
+ Vector<NonnullRefPtr<ChainedExpression>> chained_expressions;
RefPtr<Select> select_statement;
if (consume_if(TokenType::Values)) {
@@ -271,7 +271,7 @@ NonnullRefPtr<Update> Parser::parse_update_statement(RefPtr<CommonTableExpressio
update_columns.append({ move(column_names), parse_expression() });
});
- NonnullRefPtrVector<TableOrSubquery> table_or_subquery_list;
+ Vector<NonnullRefPtr<TableOrSubquery>> table_or_subquery_list;
if (consume_if(TokenType::From)) {
// FIXME: Parse join-clause.
parse_comma_separated_list(false, [&]() { table_or_subquery_list.append(parse_table_or_subquery()); });
@@ -314,10 +314,10 @@ NonnullRefPtr<Select> Parser::parse_select_statement(RefPtr<CommonTableExpressio
bool select_all = !consume_if(TokenType::Distinct);
consume_if(TokenType::All); // ALL is the default, so ignore it if specified.
- NonnullRefPtrVector<ResultColumn> result_column_list;
+ Vector<NonnullRefPtr<ResultColumn>> result_column_list;
parse_comma_separated_list(false, [&]() { result_column_list.append(parse_result_column()); });
- NonnullRefPtrVector<TableOrSubquery> table_or_subquery_list;
+ Vector<NonnullRefPtr<TableOrSubquery>> table_or_subquery_list;
if (consume_if(TokenType::From)) {
// FIXME: Parse join-clause.
parse_comma_separated_list(false, [&]() { table_or_subquery_list.append(parse_table_or_subquery()); });
@@ -331,7 +331,7 @@ NonnullRefPtr<Select> Parser::parse_select_statement(RefPtr<CommonTableExpressio
if (consume_if(TokenType::Group)) {
consume(TokenType::By);
- NonnullRefPtrVector<Expression> group_by_list;
+ Vector<NonnullRefPtr<Expression>> group_by_list;
parse_comma_separated_list(false, [&]() { group_by_list.append(parse_expression()); });
if (!group_by_list.is_empty()) {
@@ -346,7 +346,7 @@ NonnullRefPtr<Select> Parser::parse_select_statement(RefPtr<CommonTableExpressio
// FIXME: Parse 'WINDOW window-name AS window-defn'.
// FIXME: Parse 'compound-operator'.
- NonnullRefPtrVector<OrderingTerm> ordering_term_list;
+ Vector<NonnullRefPtr<OrderingTerm>> ordering_term_list;
if (consume_if(TokenType::Order)) {
consume(TokenType::By);
parse_comma_separated_list(false, [&]() { ordering_term_list.append(parse_ordering_term()); });
@@ -377,7 +377,7 @@ RefPtr<CommonTableExpressionList> Parser::parse_common_table_expression_list()
consume(TokenType::With);
bool recursive = consume_if(TokenType::Recursive);
- NonnullRefPtrVector<CommonTableExpression> common_table_expression;
+ Vector<NonnullRefPtr<CommonTableExpression>> common_table_expression;
parse_comma_separated_list(false, [&]() { common_table_expression.append(parse_common_table_expression()); });
if (common_table_expression.is_empty()) {
@@ -670,7 +670,7 @@ RefPtr<Expression> Parser::parse_chained_expression()
if (match(TokenType::Select))
return parse_exists_expression(false, TokenType::Select);
- NonnullRefPtrVector<Expression> expressions;
+ Vector<NonnullRefPtr<Expression>> expressions;
parse_comma_separated_list(false, [&]() { expressions.append(parse_expression()); });
consume(TokenType::ParenClose);
@@ -854,7 +854,7 @@ RefPtr<Expression> Parser::parse_in_expression(NonnullRefPtr<Expression> express
// FIXME: Consolidate this with parse_chained_expression(). That method consumes the opening paren as
// well, and also requires at least one expression (whereas this allows for an empty chain).
- NonnullRefPtrVector<Expression> expressions;
+ Vector<NonnullRefPtr<Expression>> expressions;
if (!match(TokenType::ParenClose))
parse_comma_separated_list(false, [&]() { expressions.append(parse_expression()); });
@@ -884,7 +884,7 @@ NonnullRefPtr<ColumnDefinition> Parser::parse_column_definition()
auto type_name = match(TokenType::Identifier)
? parse_type_name()
// https://www.sqlite.org/datatype3.html: If no type is specified then the column has affinity BLOB.
- : create_ast_node<TypeName>("BLOB", NonnullRefPtrVector<SignedNumber> {});
+ : create_ast_node<TypeName>("BLOB", Vector<NonnullRefPtr<SignedNumber>> {});
// FIXME: Parse "column-constraint".
@@ -895,7 +895,7 @@ NonnullRefPtr<TypeName> Parser::parse_type_name()
{
// https: //sqlite.org/syntax/type-name.html
auto name = consume(TokenType::Identifier).value();
- NonnullRefPtrVector<SignedNumber> signed_numbers;
+ Vector<NonnullRefPtr<SignedNumber>> signed_numbers;
if (consume_if(TokenType::ParenOpen)) {
signed_numbers.append(parse_signed_number());
@@ -1038,7 +1038,7 @@ NonnullRefPtr<TableOrSubquery> Parser::parse_table_or_subquery()
// FIXME: Parse join-clause.
- NonnullRefPtrVector<TableOrSubquery> subqueries;
+ Vector<NonnullRefPtr<TableOrSubquery>> subqueries;
parse_comma_separated_list(true, [&]() { subqueries.append(parse_table_or_subquery()); });
return create_ast_node<TableOrSubquery>(move(subqueries));
diff --git a/Userland/Libraries/LibSQL/AST/Select.cpp b/Userland/Libraries/LibSQL/AST/Select.cpp
index 677509ee7a..96806ff837 100644
--- a/Userland/Libraries/LibSQL/AST/Select.cpp
+++ b/Userland/Libraries/LibSQL/AST/Select.cpp
@@ -39,41 +39,41 @@ static DeprecatedString result_column_name(ResultColumn const& column, size_t co
ResultOr<ResultSet> Select::execute(ExecutionContext& context) const
{
- NonnullRefPtrVector<ResultColumn const> columns;
+ Vector<NonnullRefPtr<ResultColumn const>> columns;
Vector<DeprecatedString> column_names;
auto const& result_column_list = this->result_column_list();
VERIFY(!result_column_list.is_empty());
for (auto& table_descriptor : table_or_subquery_list()) {
- if (!table_descriptor.is_table())
+ if (!table_descriptor->is_table())
return Result { SQLCommand::Select, SQLErrorCode::NotYetImplemented, "Sub-selects are not yet implemented"sv };
- auto table_def = TRY(context.database->get_table(table_descriptor.schema_name(), table_descriptor.table_name()));
+ auto table_def = TRY(context.database->get_table(table_descriptor->schema_name(), table_descriptor->table_name()));
- if (result_column_list.size() == 1 && result_column_list[0].type() == ResultType::All) {
+ if (result_column_list.size() == 1 && result_column_list[0]->type() == ResultType::All) {
TRY(columns.try_ensure_capacity(columns.size() + table_def->columns().size()));
TRY(column_names.try_ensure_capacity(column_names.size() + table_def->columns().size()));
for (auto& col : table_def->columns()) {
columns.unchecked_append(
create_ast_node<ResultColumn>(
- create_ast_node<ColumnNameExpression>(table_def->parent()->name(), table_def->name(), col.name()),
+ create_ast_node<ColumnNameExpression>(table_def->parent()->name(), table_def->name(), col->name()),
""));
- column_names.unchecked_append(col.name());
+ column_names.unchecked_append(col->name());
}
}
}
- if (result_column_list.size() != 1 || result_column_list[0].type() != ResultType::All) {
+ if (result_column_list.size() != 1 || result_column_list[0]->type() != ResultType::All) {
TRY(columns.try_ensure_capacity(result_column_list.size()));
TRY(column_names.try_ensure_capacity(result_column_list.size()));
for (size_t i = 0; i < result_column_list.size(); ++i) {
auto const& col = result_column_list[i];
- if (col.type() == ResultType::All) {
+ if (col->type() == ResultType::All) {
// FIXME can have '*' for example in conjunction with computed columns
return Result { SQLCommand::Select, SQLErrorCode::SyntaxError, "*"sv };
}
@@ -93,10 +93,10 @@ ResultOr<ResultSet> Select::execute(ExecutionContext& context) const
rows.append(tuple);
for (auto& table_descriptor : table_or_subquery_list()) {
- if (!table_descriptor.is_table())
+ if (!table_descriptor->is_table())
return Result { SQLCommand::Select, SQLErrorCode::NotYetImplemented, "Sub-selects are not yet implemented"sv };
- auto table_def = TRY(context.database->get_table(table_descriptor.schema_name(), table_descriptor.table_name()));
+ auto table_def = TRY(context.database->get_table(table_descriptor->schema_name(), table_descriptor->table_name()));
if (table_def->num_columns() == 0)
continue;
@@ -118,7 +118,7 @@ ResultOr<ResultSet> Select::execute(ExecutionContext& context) const
bool has_ordering { false };
auto sort_descriptor = adopt_ref(*new TupleDescriptor);
for (auto& term : m_ordering_term_list) {
- sort_descriptor->append(TupleElementDescriptor { .order = term.order() });
+ sort_descriptor->append(TupleElementDescriptor { .order = term->order() });
has_ordering = true;
}
Tuple sort_key(sort_descriptor);
@@ -135,14 +135,14 @@ ResultOr<ResultSet> Select::execute(ExecutionContext& context) const
tuple.clear();
for (auto& col : columns) {
- auto value = TRY(col.expression()->evaluate(context));
+ auto value = TRY(col->expression()->evaluate(context));
tuple.append(value);
}
if (has_ordering) {
sort_key.clear();
for (auto& term : m_ordering_term_list) {
- auto value = TRY(term.expression()->evaluate(context));
+ auto value = TRY(term->expression()->evaluate(context));
sort_key.append(value);
}
}
diff --git a/Userland/Libraries/LibSQL/Database.cpp b/Userland/Libraries/LibSQL/Database.cpp
index a7dabf3ab2..edb067fefd 100644
--- a/Userland/Libraries/LibSQL/Database.cpp
+++ b/Userland/Libraries/LibSQL/Database.cpp
@@ -127,7 +127,7 @@ ResultOr<void> Database::add_table(TableDef& table)
return Result { SQLCommand::Unknown, SQLErrorCode::TableExists, table.name() };
for (auto& column : table.columns()) {
- if (!m_table_columns->insert(column.key()))
+ if (!m_table_columns->insert(column->key()))
VERIFY_NOT_REACHED();
}
diff --git a/Userland/Libraries/LibSQL/Meta.cpp b/Userland/Libraries/LibSQL/Meta.cpp
index 35bf4a808b..c186e62305 100644
--- a/Userland/Libraries/LibSQL/Meta.cpp
+++ b/Userland/Libraries/LibSQL/Meta.cpp
@@ -118,7 +118,7 @@ NonnullRefPtr<TupleDescriptor> IndexDef::to_tuple_descriptor() const
{
NonnullRefPtr<TupleDescriptor> ret = adopt_ref(*new TupleDescriptor);
for (auto& part : m_key_definition) {
- ret->append({ "", "", part.name(), part.type(), part.sort_order() });
+ ret->append({ "", "", part->name(), part->type(), part->sort_order() });
}
return ret;
}
@@ -161,7 +161,7 @@ NonnullRefPtr<TupleDescriptor> TableDef::to_tuple_descriptor() const
{
NonnullRefPtr<TupleDescriptor> ret = adopt_ref(*new TupleDescriptor);
for (auto& part : m_columns) {
- ret->append({ parent()->name(), name(), part.name(), part.type(), Order::Ascending });
+ ret->append({ parent()->name(), name(), part->name(), part->type(), Order::Ascending });
}
return ret;
}
diff --git a/Userland/Libraries/LibSQL/Meta.h b/Userland/Libraries/LibSQL/Meta.h
index 5c922f7490..a29b3a4aa6 100644
--- a/Userland/Libraries/LibSQL/Meta.h
+++ b/Userland/Libraries/LibSQL/Meta.h
@@ -110,7 +110,7 @@ class IndexDef : public Relation {
public:
~IndexDef() override = default;
- NonnullRefPtrVector<KeyPartDef> const& key_definition() const { return m_key_definition; }
+ Vector<NonnullRefPtr<KeyPartDef>> const& key_definition() const { return m_key_definition; }
bool unique() const { return m_unique; }
[[nodiscard]] size_t size() const { return m_key_definition.size(); }
void append_column(DeprecatedString, SQLType, Order = Order::Ascending);
@@ -123,7 +123,7 @@ private:
IndexDef(TableDef*, DeprecatedString, bool unique = true, u32 pointer = 0);
explicit IndexDef(DeprecatedString, bool unique = true, u32 pointer = 0);
- NonnullRefPtrVector<KeyPartDef> m_key_definition;
+ Vector<NonnullRefPtr<KeyPartDef>> m_key_definition;
bool m_unique { false };
friend TableDef;
@@ -138,8 +138,8 @@ public:
void append_column(Key const&);
size_t num_columns() { return m_columns.size(); }
size_t num_indexes() { return m_indexes.size(); }
- NonnullRefPtrVector<ColumnDef> const& columns() const { return m_columns; }
- NonnullRefPtrVector<IndexDef> const& indexes() const { return m_indexes; }
+ Vector<NonnullRefPtr<ColumnDef>> const& columns() const { return m_columns; }
+ Vector<NonnullRefPtr<IndexDef>> const& indexes() const { return m_indexes; }
[[nodiscard]] NonnullRefPtr<TupleDescriptor> to_tuple_descriptor() const;
static NonnullRefPtr<IndexDef> index_def();
@@ -149,8 +149,8 @@ public:
private:
explicit TableDef(SchemaDef*, DeprecatedString);
- NonnullRefPtrVector<ColumnDef> m_columns;
- NonnullRefPtrVector<IndexDef> m_indexes;
+ Vector<NonnullRefPtr<ColumnDef>> m_columns;
+ Vector<NonnullRefPtr<IndexDef>> m_indexes;
};
}
diff --git a/Userland/Libraries/LibTest/TestSuite.cpp b/Userland/Libraries/LibTest/TestSuite.cpp
index d576f1d519..79e73d3c21 100644
--- a/Userland/Libraries/LibTest/TestSuite.cpp
+++ b/Userland/Libraries/LibTest/TestSuite.cpp
@@ -81,7 +81,7 @@ int TestSuite::main(DeprecatedString const& suite_name, Span<StringView> argumen
if (do_list_cases) {
outln("Available cases for {}:", suite_name);
for (auto const& test : matching_tests) {
- outln(" {}", test.name());
+ outln(" {}", test->name());
}
return 0;
}
@@ -91,18 +91,18 @@ int TestSuite::main(DeprecatedString const& suite_name, Span<StringView> argumen
return run(matching_tests);
}
-NonnullRefPtrVector<TestCase> TestSuite::find_cases(DeprecatedString const& search, bool find_tests, bool find_benchmarks)
+Vector<NonnullRefPtr<TestCase>> TestSuite::find_cases(DeprecatedString const& search, bool find_tests, bool find_benchmarks)
{
- NonnullRefPtrVector<TestCase> matches;
+ Vector<NonnullRefPtr<TestCase>> matches;
for (auto& t : m_cases) {
- if (!search.is_empty() && !t.name().matches(search, CaseSensitivity::CaseInsensitive)) {
+ if (!search.is_empty() && !t->name().matches(search, CaseSensitivity::CaseInsensitive)) {
continue;
}
- if (!find_tests && !t.is_benchmark()) {
+ if (!find_tests && !t->is_benchmark()) {
continue;
}
- if (!find_benchmarks && t.is_benchmark()) {
+ if (!find_benchmarks && t->is_benchmark()) {
continue;
}
@@ -111,7 +111,7 @@ NonnullRefPtrVector<TestCase> TestSuite::find_cases(DeprecatedString const& sear
return matches;
}
-int TestSuite::run(NonnullRefPtrVector<TestCase> const& tests)
+int TestSuite::run(Vector<NonnullRefPtr<TestCase>> const& tests)
{
size_t test_count = 0;
size_t test_failed_count = 0;
@@ -119,18 +119,18 @@ int TestSuite::run(NonnullRefPtrVector<TestCase> const& tests)
TestElapsedTimer global_timer;
for (auto const& t : tests) {
- auto const test_type = t.is_benchmark() ? "benchmark" : "test";
+ auto const test_type = t->is_benchmark() ? "benchmark" : "test";
- warnln("Running {} '{}'.", test_type, t.name());
+ warnln("Running {} '{}'.", test_type, t->name());
m_current_test_case_passed = true;
TestElapsedTimer timer;
- t.func()();
+ t->func()();
auto const time = timer.elapsed_milliseconds();
- dbgln("{} {} '{}' in {}ms", m_current_test_case_passed ? "Completed" : "Failed", test_type, t.name(), time);
+ dbgln("{} {} '{}' in {}ms", m_current_test_case_passed ? "Completed" : "Failed", test_type, t->name(), time);
- if (t.is_benchmark()) {
+ if (t->is_benchmark()) {
m_benchtime += time;
benchmark_count++;
} else {
diff --git a/Userland/Libraries/LibTest/TestSuite.h b/Userland/Libraries/LibTest/TestSuite.h
index 2b286f336b..2ae320ce59 100644
--- a/Userland/Libraries/LibTest/TestSuite.h
+++ b/Userland/Libraries/LibTest/TestSuite.h
@@ -32,9 +32,9 @@ public:
s_global = nullptr;
}
- int run(NonnullRefPtrVector<TestCase> const&);
+ int run(Vector<NonnullRefPtr<TestCase>> const&);
int main(DeprecatedString const& suite_name, Span<StringView> arguments);
- NonnullRefPtrVector<TestCase> find_cases(DeprecatedString const& search, bool find_tests, bool find_benchmarks);
+ Vector<NonnullRefPtr<TestCase>> find_cases(DeprecatedString const& search, bool find_tests, bool find_benchmarks);
void add_case(NonnullRefPtr<TestCase> const& test_case)
{
m_cases.append(test_case);
@@ -46,7 +46,7 @@ public:
private:
static TestSuite* s_global;
- NonnullRefPtrVector<TestCase> m_cases;
+ Vector<NonnullRefPtr<TestCase>> m_cases;
u64 m_testtime = 0;
u64 m_benchtime = 0;
DeprecatedString m_suite_name;
diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp
index a36e637a79..c886048f6c 100644
--- a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp
+++ b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp
@@ -12,12 +12,12 @@
namespace Web::CSS {
-WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSStyleRule>> CSSStyleRule::create(JS::Realm& realm, NonnullRefPtrVector<Web::CSS::Selector>&& selectors, CSSStyleDeclaration& declaration)
+WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSStyleRule>> CSSStyleRule::create(JS::Realm& realm, Vector<NonnullRefPtr<Web::CSS::Selector>>&& selectors, CSSStyleDeclaration& declaration)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<CSSStyleRule>(realm, realm, move(selectors), declaration));
}
-CSSStyleRule::CSSStyleRule(JS::Realm& realm, NonnullRefPtrVector<Selector>&& selectors, CSSStyleDeclaration& declaration)
+CSSStyleRule::CSSStyleRule(JS::Realm& realm, Vector<NonnullRefPtr<Selector>>&& selectors, CSSStyleDeclaration& declaration)
: CSSRule(realm)
, m_selectors(move(selectors))
, m_declaration(declaration)
diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h
index 1a9b15466a..a5ebb302e0 100644
--- a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h
+++ b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h
@@ -19,11 +19,11 @@ class CSSStyleRule final : public CSSRule {
WEB_PLATFORM_OBJECT(CSSStyleRule, CSSRule);
public:
- static WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSStyleRule>> create(JS::Realm&, NonnullRefPtrVector<Selector>&&, CSSStyleDeclaration&);
+ static WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSStyleRule>> create(JS::Realm&, Vector<NonnullRefPtr<Selector>>&&, CSSStyleDeclaration&);
virtual ~CSSStyleRule() override = default;
- NonnullRefPtrVector<Selector> const& selectors() const { return m_selectors; }
+ Vector<NonnullRefPtr<Selector>> const& selectors() const { return m_selectors; }
CSSStyleDeclaration const& declaration() const { return m_declaration; }
virtual Type type() const override { return Type::Style; };
@@ -34,13 +34,13 @@ public:
CSSStyleDeclaration* style();
private:
- CSSStyleRule(JS::Realm&, NonnullRefPtrVector<Selector>&&, CSSStyleDeclaration&);
+ CSSStyleRule(JS::Realm&, Vector<NonnullRefPtr<Selector>>&&, CSSStyleDeclaration&);
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
virtual DeprecatedString serialized() const override;
- NonnullRefPtrVector<Selector> m_selectors;
+ Vector<NonnullRefPtr<Selector>> m_selectors;
CSSStyleDeclaration& m_declaration;
};
diff --git a/Userland/Libraries/LibWeb/CSS/MediaList.cpp b/Userland/Libraries/LibWeb/CSS/MediaList.cpp
index fc97206bc5..c3abe4c2f0 100644
--- a/Userland/Libraries/LibWeb/CSS/MediaList.cpp
+++ b/Userland/Libraries/LibWeb/CSS/MediaList.cpp
@@ -13,12 +13,12 @@
namespace Web::CSS {
-WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaList>> MediaList::create(JS::Realm& realm, NonnullRefPtrVector<MediaQuery>&& media)
+WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaList>> MediaList::create(JS::Realm& realm, Vector<NonnullRefPtr<MediaQuery>>&& media)
{
return MUST_OR_THROW_OOM(realm.heap().allocate<MediaList>(realm, realm, move(media)));
}
-MediaList::MediaList(JS::Realm& realm, NonnullRefPtrVector<MediaQuery>&& media)
+MediaList::MediaList(JS::Realm& realm, Vector<NonnullRefPtr<MediaQuery>>&& media)
: Bindings::LegacyPlatformObject(realm)
, m_media(move(media))
{
@@ -58,7 +58,7 @@ DeprecatedString MediaList::item(u32 index) const
if (!is_supported_property_index(index))
return {};
- return m_media[index].to_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
+ return m_media[index]->to_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
}
// https://www.w3.org/TR/cssom-1/#dom-medialist-appendmedium
@@ -74,7 +74,7 @@ void MediaList::append_medium(DeprecatedString medium)
// 3. If comparing m with any of the media queries in the collection of media queries returns true, then return.
auto serialized = m->to_string().release_value_but_fixme_should_propagate_errors();
for (auto& existing_medium : m_media) {
- if (existing_medium.to_string().release_value_but_fixme_should_propagate_errors() == serialized)
+ if (existing_medium->to_string().release_value_but_fixme_should_propagate_errors() == serialized)
return;
}
@@ -97,7 +97,7 @@ void MediaList::delete_medium(DeprecatedString medium)
bool MediaList::evaluate(HTML::Window const& window)
{
for (auto& media : m_media)
- media.evaluate(window);
+ media->evaluate(window);
return matches();
}
@@ -109,7 +109,7 @@ bool MediaList::matches() const
}
for (auto& media : m_media) {
- if (media.matches())
+ if (media->matches())
return true;
}
return false;
@@ -119,7 +119,7 @@ WebIDL::ExceptionOr<JS::Value> MediaList::item_value(size_t index) const
{
if (index >= m_media.size())
return JS::js_undefined();
- return JS::PrimitiveString::create(vm(), m_media[index].to_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string());
+ return JS::PrimitiveString::create(vm(), m_media[index]->to_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string());
}
}
diff --git a/Userland/Libraries/LibWeb/CSS/MediaList.h b/Userland/Libraries/LibWeb/CSS/MediaList.h
index 182e9ace2b..52b0bb6252 100644
--- a/Userland/Libraries/LibWeb/CSS/MediaList.h
+++ b/Userland/Libraries/LibWeb/CSS/MediaList.h
@@ -21,7 +21,7 @@ class MediaList final : public Bindings::LegacyPlatformObject {
WEB_PLATFORM_OBJECT(MediaList, Bindings::LegacyPlatformObject);
public:
- static WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaList>> create(JS::Realm&, NonnullRefPtrVector<MediaQuery>&& media);
+ static WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaList>> create(JS::Realm&, Vector<NonnullRefPtr<MediaQuery>>&& media);
~MediaList() = default;
DeprecatedString media_text() const;
@@ -38,7 +38,7 @@ public:
bool matches() const;
private:
- MediaList(JS::Realm&, NonnullRefPtrVector<MediaQuery>&&);
+ MediaList(JS::Realm&, Vector<NonnullRefPtr<MediaQuery>>&&);
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
@@ -55,7 +55,7 @@ private:
virtual bool named_property_setter_has_identifier() const override { return false; }
virtual bool named_property_deleter_has_identifier() const override { return false; }
- NonnullRefPtrVector<MediaQuery> m_media;
+ Vector<NonnullRefPtr<MediaQuery>> m_media;
};
}
diff --git a/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp b/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp
index b7e328122c..1ddd7bcdb9 100644
--- a/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp
+++ b/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp
@@ -379,7 +379,7 @@ bool MediaQuery::evaluate(HTML::Window const& window)
}
// https://www.w3.org/TR/cssom-1/#serialize-a-media-query-list
-ErrorOr<String> serialize_a_media_query_list(NonnullRefPtrVector<MediaQuery> const& media_queries)
+ErrorOr<String> serialize_a_media_query_list(Vector<NonnullRefPtr<MediaQuery>> const& media_queries)
{
// 1. If the media query list is empty, then return the empty string.
if (media_queries.is_empty())
diff --git a/Userland/Libraries/LibWeb/CSS/MediaQuery.h b/Userland/Libraries/LibWeb/CSS/MediaQuery.h
index 050c95cb8b..88115a1547 100644
--- a/Userland/Libraries/LibWeb/CSS/MediaQuery.h
+++ b/Userland/Libraries/LibWeb/CSS/MediaQuery.h
@@ -254,7 +254,7 @@ private:
bool m_matches { false };
};
-ErrorOr<String> serialize_a_media_query_list(NonnullRefPtrVector<MediaQuery> const&);
+ErrorOr<String> serialize_a_media_query_list(Vector<NonnullRefPtr<MediaQuery>> const&);
bool is_media_feature_name(StringView name);
diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp b/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp
index 9e6b1d9dbd..eaa1c51281 100644
--- a/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp
+++ b/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp
@@ -15,12 +15,12 @@
namespace Web::CSS {
-WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaQueryList>> MediaQueryList::create(DOM::Document& document, NonnullRefPtrVector<MediaQuery>&& media)
+WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaQueryList>> MediaQueryList::create(DOM::Document& document, Vector<NonnullRefPtr<MediaQuery>>&& media)
{
return MUST_OR_THROW_OOM(document.heap().allocate<MediaQueryList>(document.realm(), document, move(media)));
}
-MediaQueryList::MediaQueryList(DOM::Document& document, NonnullRefPtrVector<MediaQuery>&& media)
+MediaQueryList::MediaQueryList(DOM::Document& document, Vector<NonnullRefPtr<MediaQuery>>&& media)
: DOM::EventTarget(document.realm())
, m_document(document)
, m_media(move(media))
@@ -52,7 +52,7 @@ DeprecatedString MediaQueryList::media() const
bool MediaQueryList::matches() const
{
for (auto& media : m_media) {
- if (media.matches())
+ if (media->matches())
return true;
}
return false;
@@ -62,7 +62,7 @@ bool MediaQueryList::evaluate()
{
bool now_matches = false;
for (auto& media : m_media) {
- now_matches = now_matches || media.evaluate(m_document->window());
+ now_matches = now_matches || media->evaluate(m_document->window());
}
return now_matches;
diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryList.h b/Userland/Libraries/LibWeb/CSS/MediaQueryList.h
index d53b607309..276c84c14f 100644
--- a/Userland/Libraries/LibWeb/CSS/MediaQueryList.h
+++ b/Userland/Libraries/LibWeb/CSS/MediaQueryList.h
@@ -17,7 +17,7 @@ class MediaQueryList final : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(MediaQueryList, DOM::EventTarget);
public:
- static WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaQueryList>> create(DOM::Document&, NonnullRefPtrVector<MediaQuery>&&);
+ static WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaQueryList>> create(DOM::Document&, Vector<NonnullRefPtr<MediaQuery>>&&);
virtual ~MediaQueryList() override = default;
@@ -32,13 +32,13 @@ public:
WebIDL::CallbackType* onchange();
private:
- MediaQueryList(DOM::Document&, NonnullRefPtrVector<MediaQuery>&&);
+ MediaQueryList(DOM::Document&, Vector<NonnullRefPtr<MediaQuery>>&&);
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
JS::NonnullGCPtr<DOM::Document> m_document;
- NonnullRefPtrVector<MediaQuery> m_media;
+ Vector<NonnullRefPtr<MediaQuery>> m_media;
};
}
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index c2fefa1638..c8d4ac46e7 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -156,7 +156,7 @@ Parser::ParseErrorOr<SelectorList> Parser::parse_a_selector_list(TokenStream<T>&
{
auto comma_separated_lists = parse_a_comma_separated_list_of_component_values(tokens);
- NonnullRefPtrVector<Selector> selectors;
+ Vector<NonnullRefPtr<Selector>> selectors;
for (auto& selector_parts : comma_separated_lists) {
auto stream = TokenStream(selector_parts);
auto selector = parse_complex_selector(stream, mode);
@@ -662,19 +662,19 @@ Parser::ParseErrorOr<Optional<Selector::SimpleSelector>> Parser::parse_simple_se
return ParseError::SyntaxError;
}
-NonnullRefPtrVector<MediaQuery> Parser::parse_as_media_query_list()
+Vector<NonnullRefPtr<MediaQuery>> Parser::parse_as_media_query_list()
{
return parse_a_media_query_list(m_token_stream);
}
template<typename T>
-NonnullRefPtrVector<MediaQuery> Parser::parse_a_media_query_list(TokenStream<T>& tokens)
+Vector<NonnullRefPtr<MediaQuery>> Parser::parse_a_media_query_list(TokenStream<T>& tokens)
{
// https://www.w3.org/TR/mediaqueries-4/#mq-list
auto comma_separated_lists = parse_a_comma_separated_list_of_component_values(tokens);
- AK::NonnullRefPtrVector<MediaQuery> media_queries;
+ AK::Vector<NonnullRefPtr<MediaQuery>> media_queries;
for (auto& media_query_parts : comma_separated_lists) {
auto stream = TokenStream(media_query_parts);
media_queries.append(parse_media_query(stream));
@@ -1443,12 +1443,12 @@ Optional<GeneralEnclosed> Parser::parse_general_enclosed(TokenStream<ComponentVa
// 5.4.1. Consume a list of rules
// https://www.w3.org/TR/css-syntax-3/#consume-list-of-rules
template<typename T>
-NonnullRefPtrVector<Rule> Parser::consume_a_list_of_rules(TokenStream<T>& tokens, TopLevel top_level)
+Vector<NonnullRefPtr<Rule>> Parser::consume_a_list_of_rules(TokenStream<T>& tokens, TopLevel top_level)
{
// To consume a list of rules, given a top-level flag:
// Create an initially empty list of rules.
- NonnullRefPtrVector<Rule> rules;
+ Vector<NonnullRefPtr<Rule>> rules;
// Repeatedly consume the next input token:
for (;;) {
@@ -2075,7 +2075,7 @@ RefPtr<Rule> Parser::parse_a_rule(TokenStream<T>& tokens)
// 5.3.4. Parse a list of rules
// https://www.w3.org/TR/css-syntax-3/#parse-list-of-rules
template<typename T>
-NonnullRefPtrVector<Rule> Parser::parse_a_list_of_rules(TokenStream<T>& tokens)
+Vector<NonnullRefPtr<Rule>> Parser::parse_a_list_of_rules(TokenStream<T>& tokens)
{
// To parse a list of rules from input:
@@ -7443,7 +7443,7 @@ RefPtr<CSS::MediaQuery> parse_media_query(CSS::Parser::ParsingContext const& con
return parser.parse_as_media_query();
}
-NonnullRefPtrVector<CSS::MediaQuery> parse_media_query_list(CSS::Parser::ParsingContext const& context, StringView string)
+Vector<NonnullRefPtr<CSS::MediaQuery>> parse_media_query_list(CSS::Parser::ParsingContext const& context, StringView string)
{
CSS::Parser::Parser parser(context, string);
return parser.parse_as_media_query_list();
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
index eabad979e6..561c490504 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
@@ -78,7 +78,7 @@ public:
Optional<SelectorList> parse_as_selector(SelectorParsingMode = SelectorParsingMode::Standard);
Optional<SelectorList> parse_as_relative_selector(SelectorParsingMode = SelectorParsingMode::Standard);
- NonnullRefPtrVector<MediaQuery> parse_as_media_query_list();
+ Vector<NonnullRefPtr<MediaQuery>> parse_as_media_query_list();
RefPtr<MediaQuery> parse_as_media_query();
RefPtr<Supports> parse_as_supports();
@@ -99,14 +99,14 @@ private:
// "Parse a stylesheet" is intended to be the normal parser entry point, for parsing stylesheets.
struct ParsedStyleSheet {
Optional<AK::URL> location;
- NonnullRefPtrVector<Rule> rules;
+ Vector<NonnullRefPtr<Rule>> rules;
};
template<typename T>
ParsedStyleSheet parse_a_stylesheet(TokenStream<T>&, Optional<AK::URL> location);
// "Parse a list of rules" is intended for the content of at-rules such as @media. It differs from "Parse a stylesheet" in the handling of <CDO-token> and <CDC-token>.
template<typename T>
- NonnullRefPtrVector<Rule> parse_a_list_of_rules(TokenStream<T>&);
+ Vector<NonnullRefPtr<Rule>> parse_a_list_of_rules(TokenStream<T>&);
// "Parse a rule" is intended for use by the CSSStyleSheet#insertRule method, and similar functions which might exist, which parse text into a single rule.
template<typename T>
@@ -142,7 +142,7 @@ private:
ParseErrorOr<SelectorList> parse_a_selector_list(TokenStream<T>&, SelectorType, SelectorParsingMode = SelectorParsingMode::Standard);
template<typename T>
- NonnullRefPtrVector<MediaQuery> parse_a_media_query_list(TokenStream<T>&);
+ Vector<NonnullRefPtr<MediaQuery>> parse_a_media_query_list(TokenStream<T>&);
template<typename T>
RefPtr<Supports> parse_a_supports(TokenStream<T>&);
@@ -153,7 +153,7 @@ private:
Yes
};
template<typename T>
- [[nodiscard]] NonnullRefPtrVector<Rule> consume_a_list_of_rules(TokenStream<T>&, TopLevel);
+ [[nodiscard]] Vector<NonnullRefPtr<Rule>> consume_a_list_of_rules(TokenStream<T>&, TopLevel);
template<typename T>
[[nodiscard]] NonnullRefPtr<Rule> consume_an_at_rule(TokenStream<T>&);
template<typename T>
@@ -377,7 +377,7 @@ RefPtr<CSS::StyleValue> parse_css_value(CSS::Parser::ParsingContext const&, Stri
Optional<CSS::SelectorList> parse_selector(CSS::Parser::ParsingContext const&, StringView);
CSS::CSSRule* parse_css_rule(CSS::Parser::ParsingContext const&, StringView);
RefPtr<CSS::MediaQuery> parse_media_query(CSS::Parser::ParsingContext const&, StringView);
-NonnullRefPtrVector<CSS::MediaQuery> parse_media_query_list(CSS::Parser::ParsingContext const&, StringView);
+Vector<NonnullRefPtr<CSS::MediaQuery>> parse_media_query_list(CSS::Parser::ParsingContext const&, StringView);
RefPtr<CSS::Supports> parse_css_supports(CSS::Parser::ParsingContext const&, StringView);
}
diff --git a/Userland/Libraries/LibWeb/CSS/Selector.cpp b/Userland/Libraries/LibWeb/CSS/Selector.cpp
index a43e1b4ccf..d0f21139b5 100644
--- a/Userland/Libraries/LibWeb/CSS/Selector.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Selector.cpp
@@ -45,7 +45,7 @@ u32 Selector::specificity() const
auto count_specificity_of_most_complex_selector = [&](auto& selector_list) {
u32 max_selector_list_argument_specificity = 0;
for (auto const& complex_selector : selector_list) {
- max_selector_list_argument_specificity = max(max_selector_list_argument_specificity, complex_selector.specificity());
+ max_selector_list_argument_specificity = max(max_selector_list_argument_specificity, complex_selector->specificity());
}
u32 child_ids = (max_selector_list_argument_specificity & ids_mask) >> ids_shift;
@@ -337,7 +337,7 @@ ErrorOr<String> Selector::serialize() const
}
// https://www.w3.org/TR/cssom/#serialize-a-group-of-selectors
-ErrorOr<String> serialize_a_group_of_selectors(NonnullRefPtrVector<Selector> const& selectors)
+ErrorOr<String> serialize_a_group_of_selectors(Vector<NonnullRefPtr<Selector>> const& selectors)
{
// To serialize a group of selectors serialize each selector in the group of selectors and then serialize a comma-separated list of these serializations.
return String::join(", "sv, selectors);
diff --git a/Userland/Libraries/LibWeb/CSS/Selector.h b/Userland/Libraries/LibWeb/CSS/Selector.h
index fb9e0976d2..94bc0051fd 100644
--- a/Userland/Libraries/LibWeb/CSS/Selector.h
+++ b/Userland/Libraries/LibWeb/CSS/Selector.h
@@ -15,7 +15,7 @@
namespace Web::CSS {
-using SelectorList = NonnullRefPtrVector<class Selector>;
+using SelectorList = Vector<NonnullRefPtr<class Selector>>;
// This is a <complex-selector> in the spec. https://www.w3.org/TR/selectors-4/#complex
class Selector : public RefCounted<Selector> {
@@ -294,7 +294,7 @@ constexpr StringView pseudo_class_name(Selector::SimpleSelector::PseudoClass::Ty
VERIFY_NOT_REACHED();
}
-ErrorOr<String> serialize_a_group_of_selectors(NonnullRefPtrVector<Selector> const& selectors);
+ErrorOr<String> serialize_a_group_of_selectors(Vector<NonnullRefPtr<Selector>> const& selectors);
}
diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
index f76ef83c44..e3664e337d 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
@@ -184,8 +184,8 @@ Vector<MatchingRule> StyleComputer::collect_matching_rules(DOM::Element const& e
sheet.for_each_effective_style_rule([&](auto const& rule) {
size_t selector_index = 0;
for (auto& selector : rule.selectors()) {
- if (SelectorEngine::matches(selector, element, pseudo_element)) {
- matching_rules.append({ &rule, style_sheet_index, rule_index, selector_index, selector.specificity() });
+ if (SelectorEngine::matches(*selector, element, pseudo_element)) {
+ matching_rules.append({ &rule, style_sheet_index, rule_index, selector_index, selector->specificity() });
break;
}
++selector_index;
@@ -203,9 +203,9 @@ static void sort_matching_rules(Vector<MatchingRule>& matching_rules)
quick_sort(matching_rules, [&](MatchingRule& a, MatchingRule& b) {
auto const& a_selector = a.rule->selectors()[a.selector_index];
auto const& b_selector = b.rule->selectors()[b.selector_index];
- auto a_specificity = a_selector.specificity();
- auto b_specificity = b_selector.specificity();
- if (a_selector.specificity() == b_selector.specificity()) {
+ auto a_specificity = a_selector->specificity();
+ auto b_specificity = b_selector->specificity();
+ if (a_selector->specificity() == b_selector->specificity()) {
if (a.style_sheet_index == b.style_sheet_index)
return a.rule_index < b.rule_index;
return a.style_sheet_index < b.style_sheet_index;
@@ -1406,7 +1406,7 @@ PropertyDependencyNode::PropertyDependencyNode(String name)
void PropertyDependencyNode::add_child(NonnullRefPtr<PropertyDependencyNode> new_child)
{
for (auto const& child : m_children) {
- if (child.m_name == new_child->m_name)
+ if (child->m_name == new_child->m_name)
return;
}
@@ -1422,7 +1422,7 @@ bool PropertyDependencyNode::has_cycles()
TemporaryChange change { m_marked, true };
for (auto& child : m_children) {
- if (child.has_cycles())
+ if (child->has_cycles())
return true;
}
return false;
diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.h b/Userland/Libraries/LibWeb/CSS/StyleComputer.h
index dce9551cf3..5c02fb7338 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleComputer.h
+++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.h
@@ -43,7 +43,7 @@ private:
explicit PropertyDependencyNode(String name);
String m_name;
- NonnullRefPtrVector<PropertyDependencyNode> m_children;
+ Vector<NonnullRefPtr<PropertyDependencyNode>> m_children;
bool m_marked { false };
};
diff --git a/Userland/Libraries/LibWeb/HTML/Path2D.cpp b/Userland/Libraries/LibWeb/HTML/Path2D.cpp
index aa0708c939..b99a262c62 100644
--- a/Userland/Libraries/LibWeb/HTML/Path2D.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Path2D.cpp
@@ -42,7 +42,7 @@ Path2D::Path2D(JS::Realm& realm, Optional<Variant<JS::Handle<Path2D>, Deprecated
if (!svg_path.segments().is_empty()) {
// 5. Let (x, y) be the last point in svgPath.
- auto xy = svg_path.segments().last().point();
+ auto xy = svg_path.segments().last()->point();
// 6. Add all the subpaths, if any, from svgPath to output.
this->path() = move(svg_path);
@@ -85,7 +85,7 @@ WebIDL::ExceptionOr<void> Path2D::add_path(JS::NonnullGCPtr<Path2D> path, Geomet
auto copy = path->path().copy_transformed(Gfx::AffineTransform { static_cast<float>(matrix->m11()), static_cast<float>(matrix->m12()), static_cast<float>(matrix->m21()), static_cast<float>(matrix->m22()), static_cast<float>(matrix->m41()), static_cast<float>(matrix->m42()) });
// 6. Let (x, y) be the last point in the last subpath of c.
- auto xy = copy.segments().last().point();
+ auto xy = copy.segments().last()->point();
// 7. Add all the subpaths in c to a.
// FIXME: Is this correct?
diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h
index a78a6a009f..5238414e36 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.h
+++ b/Userland/Libraries/LibWeb/HTML/Window.h
@@ -183,9 +183,9 @@ private:
AnimationFrameCallbackDriver m_animation_frame_callback_driver;
// https://w3c.github.io/requestidlecallback/#dfn-list-of-idle-request-callbacks
- NonnullRefPtrVector<IdleCallback> m_idle_request_callbacks;
+ Vector<NonnullRefPtr<IdleCallback>> m_idle_request_callbacks;
// https://w3c.github.io/requestidlecallback/#dfn-list-of-runnable-idle-callbacks
- NonnullRefPtrVector<IdleCallback> m_runnable_idle_callbacks;
+ Vector<NonnullRefPtr<IdleCallback>> m_runnable_idle_callbacks;
// https://w3c.github.io/requestidlecallback/#dfn-idle-callback-identifier
u32 m_idle_callback_identifier = 0;
diff --git a/Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.cpp b/Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.cpp
index 384ef38ac3..2333aec577 100644
--- a/Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.cpp
+++ b/Userland/Libraries/LibWeb/Painting/SVGGeometryPaintable.cpp
@@ -64,27 +64,27 @@ void SVGGeometryPaintable::paint(PaintContext& context, PaintPhase phase) const
};
for (auto& segment : path.segments()) {
- switch (segment.type()) {
+ switch (segment->type()) {
case Gfx::Segment::Type::Invalid:
break;
case Gfx::Segment::Type::MoveTo:
- new_path.move_to(transform_point(segment.point()));
+ new_path.move_to(transform_point(segment->point()));
break;
case Gfx::Segment::Type::LineTo:
- new_path.line_to(transform_point(segment.point()));
+ new_path.line_to(transform_point(segment->point()));
break;
case Gfx::Segment::Type::QuadraticBezierCurveTo: {
- auto& quadratic_bezier_segment = static_cast<Gfx::QuadraticBezierCurveSegment const&>(segment);
+ auto& quadratic_bezier_segment = static_cast<Gfx::QuadraticBezierCurveSegment const&>(*segment);
new_path.quadratic_bezier_curve_to(transform_point(quadratic_bezier_segment.through()), transform_point(quadratic_bezier_segment.point()));
break;
}
case Gfx::Segment::Type::CubicBezierCurveTo: {
- auto& cubic_bezier_segment = static_cast<Gfx::CubicBezierCurveSegment const&>(segment);
+ auto& cubic_bezier_segment = static_cast<Gfx::CubicBezierCurveSegment const&>(*segment);
new_path.cubic_bezier_curve_to(transform_point(cubic_bezier_segment.through_0()), transform_point(cubic_bezier_segment.through_1()), transform_point(cubic_bezier_segment.point()));
break;
}
case Gfx::Segment::Type::EllipticalArcTo: {
- auto& elliptical_arc_segment = static_cast<Gfx::EllipticalArcSegment const&>(segment);
+ auto& elliptical_arc_segment = static_cast<Gfx::EllipticalArcSegment const&>(*segment);
new_path.elliptical_arc_to(transform_point(elliptical_arc_segment.point()), elliptical_arc_segment.radii().scaled_by(scaling, scaling), elliptical_arc_segment.x_axis_rotation(), elliptical_arc_segment.large_arc(), elliptical_arc_segment.sweep());
break;
}
diff --git a/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp
index d516f8486d..a9c66f9e37 100644
--- a/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp
+++ b/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp
@@ -115,7 +115,7 @@ Gfx::Path path_from_path_instructions(ReadonlySpan<PathInstruction> instructions
for (auto& instruction : instructions) {
// If the first path element uses relative coordinates, we treat them as absolute by making them relative to (0, 0).
- auto last_point = path.segments().is_empty() ? Gfx::FloatPoint { 0, 0 } : path.segments().last().point();
+ auto last_point = path.segments().is_empty() ? Gfx::FloatPoint { 0, 0 } : path.segments().last()->point();
auto& absolute = instruction.absolute;
auto& data = instruction.data;
diff --git a/Userland/Libraries/LibWeb/WebIDL/OverloadResolution.cpp b/Userland/Libraries/LibWeb/WebIDL/OverloadResolution.cpp
index d827d846de..9538796d7d 100644
--- a/Userland/Libraries/LibWeb/WebIDL/OverloadResolution.cpp
+++ b/Userland/Libraries/LibWeb/WebIDL/OverloadResolution.cpp
@@ -139,7 +139,7 @@ JS::ThrowCompletionOr<ResolvedOverload> resolve_overload(JS::VM& vm, IDL::Effect
if (type.is_union()) {
auto flattened_members = type.as_union().flattened_member_types();
for (auto const& member : flattened_members) {
- if (member.is_nullable())
+ if (member->is_nullable())
return true;
// FIXME: - a dictionary type
// FIXME: - an annotated type whose inner type is one of the above types
@@ -351,7 +351,7 @@ JS::ThrowCompletionOr<ResolvedOverload> resolve_overload(JS::VM& vm, IDL::Effect
}
// 18. Otherwise: if there is an entry in S that has any at position i of its type list, then remove from S all other entries.
- else if (overloads.has_overload_with_matching_argument_at_index(i, [](auto const& type, auto) { return type.is_any(); })) {
+ else if (overloads.has_overload_with_matching_argument_at_index(i, [](auto const& type, auto) { return type->is_any(); })) {
overloads.remove_all_other_entries();
}
diff --git a/Userland/Services/AudioServer/ConnectionFromClient.cpp b/Userland/Services/AudioServer/ConnectionFromClient.cpp
index ea938f31ce..9afaa8bf9d 100644
--- a/Userland/Services/AudioServer/ConnectionFromClient.cpp
+++ b/Userland/Services/AudioServer/ConnectionFromClient.cpp
@@ -15,7 +15,7 @@ static HashMap<int, RefPtr<ConnectionFromClient>> s_connections;
void ConnectionFromClient::for_each(Function<void(ConnectionFromClient&)> callback)
{
- NonnullRefPtrVector<ConnectionFromClient> connections;
+ Vector<NonnullRefPtr<ConnectionFromClient>> connections;
for (auto& it : s_connections)
connections.append(*it.value);
for (auto& connection : connections)
diff --git a/Userland/Services/SystemServer/main.cpp b/Userland/Services/SystemServer/main.cpp
index 8c185bc7b0..fd6a66ae3d 100644
--- a/Userland/Services/SystemServer/main.cpp
+++ b/Userland/Services/SystemServer/main.cpp
@@ -31,7 +31,7 @@
#include <unistd.h>
DeprecatedString g_system_mode = "graphical";
-NonnullRefPtrVector<Service> g_services;
+Vector<NonnullRefPtr<Service>> g_services;
// NOTE: This handler ensures that the destructor of g_services is called.
static void sigterm_handler(int)
@@ -549,8 +549,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
// After we've set them all up, activate them!
dbgln("Activating {} services...", g_services.size());
for (auto& service : g_services) {
- if (auto result = service.activate(); result.is_error())
- dbgln("{}: {}", service.name(), result.release_error());
+ if (auto result = service->activate(); result.is_error())
+ dbgln("{}: {}", service->name(), result.release_error());
}
return event_loop.exec();
diff --git a/Userland/Services/WindowServer/Screen.cpp b/Userland/Services/WindowServer/Screen.cpp
index 6b7f0ed292..4b95c9fa3d 100644
--- a/Userland/Services/WindowServer/Screen.cpp
+++ b/Userland/Services/WindowServer/Screen.cpp
@@ -23,7 +23,7 @@
namespace WindowServer {
-NonnullRefPtrVector<Screen, default_screen_count> Screen::s_screens;
+Vector<NonnullRefPtr<Screen>, default_screen_count> Screen::s_screens;
Screen* Screen::s_main_screen { nullptr };
Gfx::IntRect Screen::s_bounding_screens_rect {};
ScreenLayout Screen::s_layout;
@@ -89,9 +89,9 @@ bool Screen::apply_layout(ScreenLayout&& screen_layout, DeprecatedString& error_
auto& screen = s_layout.screens[it.key];
auto& new_screen = screen_layout.screens[it.value];
if (screen.resolution != new_screen.resolution)
- screens_with_resolution_change.set(&s_screens[it.key], it.value);
+ screens_with_resolution_change.set(s_screens[it.key], it.value);
if (screen.scale_factor != new_screen.scale_factor)
- screens_with_scale_change.set(&s_screens[it.key], it.value);
+ screens_with_scale_change.set(s_screens[it.key], it.value);
}
auto screens_backup = move(s_screens);
@@ -105,18 +105,18 @@ bool Screen::apply_layout(ScreenLayout&& screen_layout, DeprecatedString& error_
AK::ArmedScopeGuard rollback([&] {
for (auto& screen : s_screens)
- screen.close_device();
+ screen->close_device();
s_screens = move(screens_backup);
s_layout = move(layout_backup);
for (size_t i = 0; i < s_screens.size(); i++) {
auto& old_screen = s_screens[i];
// Restore the original screen index in case it changed
- old_screen.set_index(i);
+ old_screen->set_index(i);
if (i == s_layout.main_screen_index)
- old_screen.make_main_screen();
- bool changed_scale = screens_with_scale_change.contains(&old_screen);
- if (screens_with_resolution_change.contains(&old_screen)) {
- if (old_screen.open_device()) {
+ old_screen->make_main_screen();
+ bool changed_scale = screens_with_scale_change.contains(old_screen);
+ if (screens_with_resolution_change.contains(old_screen)) {
+ if (old_screen->open_device()) {
// The resolution was changed, so we also implicitly applied the new scale factor
changed_scale = false;
} else {
@@ -125,9 +125,9 @@ bool Screen::apply_layout(ScreenLayout&& screen_layout, DeprecatedString& error_
}
}
- old_screen.update_virtual_and_physical_rects();
+ old_screen->update_virtual_and_physical_rects();
if (changed_scale)
- old_screen.scale_factor_changed();
+ old_screen->scale_factor_changed();
}
update_bounding_rect();
});
@@ -137,7 +137,7 @@ bool Screen::apply_layout(ScreenLayout&& screen_layout, DeprecatedString& error_
bool need_to_open_device;
if (auto it = new_to_current_indices_map.find(index); it != new_to_current_indices_map.end()) {
// Re-use the existing screen instance
- screen = &screens_backup[it->value];
+ screen = screens_backup[it->value];
s_screens.append(*screen);
screen->set_index(index);
@@ -179,7 +179,7 @@ bool Screen::apply_layout(ScreenLayout&& screen_layout, DeprecatedString& error_
float closest_distance = 0;
Optional<Gfx::IntPoint> closest_point;
for (auto& screen : s_screens) {
- auto closest_point_on_screen_rect = screen.rect().closest_to(cursor_location);
+ auto closest_point_on_screen_rect = screen->rect().closest_to(cursor_location);
auto distance = closest_point_on_screen_rect.distance_from(cursor_location);
if (!closest_point.has_value() || distance < closest_distance) {
closest_distance = distance;
@@ -279,10 +279,10 @@ Screen& Screen::closest_to_rect(Gfx::IntRect const& rect)
Screen* best_screen = nullptr;
int best_area = 0;
for (auto& screen : s_screens) {
- auto r = screen.rect().intersected(rect);
+ auto r = screen->rect().intersected(rect);
int area = r.width() * r.height();
if (!best_screen || area > best_area) {
- best_screen = &screen;
+ best_screen = screen;
best_area = area;
}
}
@@ -296,7 +296,7 @@ Screen& Screen::closest_to_rect(Gfx::IntRect const& rect)
Screen& Screen::closest_to_location(Gfx::IntPoint point)
{
for (auto& screen : s_screens) {
- if (screen.rect().contains(point))
+ if (screen->rect().contains(point))
return screen;
}
// TODO: guess based on how close the point is to the next screen rectangle
@@ -306,9 +306,9 @@ Screen& Screen::closest_to_location(Gfx::IntPoint point)
void Screen::update_bounding_rect()
{
if (!s_screens.is_empty()) {
- s_bounding_screens_rect = s_screens[0].rect();
+ s_bounding_screens_rect = s_screens[0]->rect();
for (size_t i = 1; i < s_screens.size(); i++)
- s_bounding_screens_rect = s_bounding_screens_rect.united(s_screens[i].rect());
+ s_bounding_screens_rect = s_bounding_screens_rect.united(s_screens[i]->rect());
} else {
s_bounding_screens_rect = {};
}
diff --git a/Userland/Services/WindowServer/Screen.h b/Userland/Services/WindowServer/Screen.h
index 64cce345bf..3d8b7bc50d 100644
--- a/Userland/Services/WindowServer/Screen.h
+++ b/Userland/Services/WindowServer/Screen.h
@@ -98,22 +98,22 @@ public:
{
if (index >= s_screens.size())
return nullptr;
- return &s_screens[index];
+ return s_screens[index];
}
static Vector<Gfx::IntRect, 4> rects()
{
Vector<Gfx::IntRect, 4> rects;
for (auto& screen : s_screens)
- rects.append(screen.rect());
+ rects.append(screen->rect());
return rects;
}
static Screen* find_by_location(Gfx::IntPoint point)
{
for (auto& screen : s_screens) {
- if (screen.rect().contains(point))
- return &screen;
+ if (screen->rect().contains(point))
+ return screen;
}
return nullptr;
}
@@ -127,7 +127,7 @@ public:
static IterationDecision for_each(F f)
{
for (auto& screen : s_screens) {
- IterationDecision decision = f(screen);
+ IterationDecision decision = f(*screen);
if (decision != IterationDecision::Continue)
return decision;
}
@@ -187,7 +187,7 @@ private:
static void update_indices()
{
for (size_t i = 0; i < s_screens.size(); i++)
- s_screens[i].m_index = i;
+ s_screens[i]->m_index = i;
}
static void update_bounding_rect();
static void update_scale_factors_in_use();
@@ -199,7 +199,7 @@ private:
ScreenLayout::Screen& screen_layout_info() { return s_layout.screens[m_index]; }
ScreenLayout::Screen const& screen_layout_info() const { return s_layout.screens[m_index]; }
- static NonnullRefPtrVector<Screen, default_screen_count> s_screens;
+ static Vector<NonnullRefPtr<Screen>, default_screen_count> s_screens;
static Screen* s_main_screen;
static Gfx::IntRect s_bounding_screens_rect;
static ScreenLayout s_layout;
diff --git a/Userland/Shell/AST.cpp b/Userland/Shell/AST.cpp
index 04bc99aa4d..ca53f40cfd 100644
--- a/Userland/Shell/AST.cpp
+++ b/Userland/Shell/AST.cpp
@@ -48,7 +48,7 @@ ErrorOr<void> AK::Formatter<Shell::AST::Command>::format(FormatBuilder& builder,
for (auto& redir : value.redirections) {
TRY(builder.put_padding(' ', 1));
- if (redir.is_path_redirection()) {
+ if (redir->is_path_redirection()) {
auto path_redir = (Shell::AST::PathRedirection const*)&redir;
TRY(builder.put_i64(path_redir->fd));
switch (path_redir->direction) {
@@ -66,12 +66,12 @@ ErrorOr<void> AK::Formatter<Shell::AST::Command>::format(FormatBuilder& builder,
break;
}
TRY(builder.put_literal(path_redir->path));
- } else if (redir.is_fd_redirection()) {
+ } else if (redir->is_fd_redirection()) {
auto* fdredir = (Shell::AST::FdRedirection const*)&redir;
TRY(builder.put_i64(fdredir->new_fd));
TRY(builder.put_literal(">"sv));
TRY(builder.put_i64(fdredir->old_fd));
- } else if (redir.is_close_redirection()) {
+ } else if (redir->is_close_redirection()) {
auto close_redir = (Shell::AST::CloseRedirection const*)&redir;
TRY(builder.put_i64(close_redir->fd));
TRY(builder.put_literal(">&-"sv));
@@ -156,18 +156,18 @@ static inline Vector<Command> join_commands(Vector<Command> left, Vector<Command
return commands;
}
-static ErrorOr<String> resolve_slices(RefPtr<Shell> shell, String&& input_value, NonnullRefPtrVector<Slice> slices)
+static ErrorOr<String> resolve_slices(RefPtr<Shell> shell, String&& input_value, Vector<NonnullRefPtr<Slice>> slices)
{
if (slices.is_empty())
return move(input_value);
for (auto& slice : slices) {
- auto value = TRY(slice.run(shell));
+ auto value = TRY(slice->run(shell));
if (shell && shell->has_any_error())
break;
if (!value) {
- shell->raise_error(Shell::ShellError::InvalidSliceContentsError, "Invalid slice contents", slice.position());
+ shell->raise_error(Shell::ShellError::InvalidSliceContentsError, "Invalid slice contents", slice->position());
return move(input_value);
}
@@ -179,7 +179,7 @@ static ErrorOr<String> resolve_slices(RefPtr<Shell> shell, String&& input_value,
for (auto& value : index_values) {
auto maybe_index = value.bytes_as_string_view().to_int();
if (!maybe_index.has_value()) {
- shell->raise_error(Shell::ShellError::InvalidSliceContentsError, DeprecatedString::formatted("Invalid value in slice index {}: {} (expected a number)", i, value), slice.position());
+ shell->raise_error(Shell::ShellError::InvalidSliceContentsError, DeprecatedString::formatted("Invalid value in slice index {}: {} (expected a number)", i, value), slice->position());
return move(input_value);
}
++i;
@@ -190,7 +190,7 @@ static ErrorOr<String> resolve_slices(RefPtr<Shell> shell, String&& input_value,
index += input_value.bytes_as_string_view().length();
if (index < 0 || (size_t)index >= input_value.bytes_as_string_view().length()) {
- shell->raise_error(Shell::ShellError::InvalidSliceContentsError, DeprecatedString::formatted("Slice index {} (evaluated as {}) out of value bounds [0-{})", index, original_index, input_value.bytes_as_string_view().length()), slice.position());
+ shell->raise_error(Shell::ShellError::InvalidSliceContentsError, DeprecatedString::formatted("Slice index {} (evaluated as {}) out of value bounds [0-{})", index, original_index, input_value.bytes_as_string_view().length()), slice->position());
return move(input_value);
}
indices.unchecked_append(index);
@@ -206,18 +206,18 @@ static ErrorOr<String> resolve_slices(RefPtr<Shell> shell, String&& input_value,
return move(input_value);
}
-static ErrorOr<Vector<String>> resolve_slices(RefPtr<Shell> shell, Vector<String>&& values, NonnullRefPtrVector<Slice> slices)
+static ErrorOr<Vector<String>> resolve_slices(RefPtr<Shell> shell, Vector<String>&& values, Vector<NonnullRefPtr<Slice>> slices)
{
if (slices.is_empty())
return move(values);
for (auto& slice : slices) {
- auto value = TRY(slice.run(shell));
+ auto value = TRY(slice->run(shell));
if (shell && shell->has_any_error())
break;
if (!value) {
- shell->raise_error(Shell::ShellError::InvalidSliceContentsError, "Invalid slice contents", slice.position());
+ shell->raise_error(Shell::ShellError::InvalidSliceContentsError, "Invalid slice contents", slice->position());
return move(values);
}
@@ -229,7 +229,7 @@ static ErrorOr<Vector<String>> resolve_slices(RefPtr<Shell> shell, Vector<String
for (auto& value : index_values) {
auto maybe_index = value.bytes_as_string_view().to_int();
if (!maybe_index.has_value()) {
- shell->raise_error(Shell::ShellError::InvalidSliceContentsError, DeprecatedString::formatted("Invalid value in slice index {}: {} (expected a number)", i, value), slice.position());
+ shell->raise_error(Shell::ShellError::InvalidSliceContentsError, DeprecatedString::formatted("Invalid value in slice index {}: {} (expected a number)", i, value), slice->position());
return move(values);
}
++i;
@@ -240,7 +240,7 @@ static ErrorOr<Vector<String>> resolve_slices(RefPtr<Shell> shell, Vector<String
index += values.size();
if (index < 0 || (size_t)index >= values.size()) {
- shell->raise_error(Shell::ShellError::InvalidSliceContentsError, DeprecatedString::formatted("Slice index {} (evaluated as {}) out of value bounds [0-{})", index, original_index, values.size()), slice.position());
+ shell->raise_error(Shell::ShellError::InvalidSliceContentsError, DeprecatedString::formatted("Slice index {} (evaluated as {}) out of value bounds [0-{})", index, original_index, values.size()), slice->position());
return move(values);
}
indices.unchecked_append(index);
@@ -505,7 +505,7 @@ ErrorOr<RefPtr<Value>> ListConcatenate::run(RefPtr<Shell> shell)
result = make_ref_counted<CommandSequenceValue>(move(joined_commands));
}
} else {
- NonnullRefPtrVector<Value> values;
+ Vector<NonnullRefPtr<Value>> values;
if (result->is_list_without_resolution()) {
values.extend(static_cast<ListValue*>(result.ptr())->values());
@@ -695,17 +695,17 @@ ErrorOr<void> BraceExpansion::dump(int level) const
{
TRY(Node::dump(level));
for (auto& entry : m_entries)
- TRY(entry.dump(level + 1));
+ TRY(entry->dump(level + 1));
return {};
}
ErrorOr<RefPtr<Value>> BraceExpansion::run(RefPtr<Shell> shell)
{
- NonnullRefPtrVector<Value> values;
+ Vector<NonnullRefPtr<Value>> values;
for (auto& entry : m_entries) {
if (shell && shell->has_any_error())
break;
- auto value = TRY(entry.run(shell));
+ auto value = TRY(entry->run(shell));
if (value)
values.append(value.release_nonnull());
}
@@ -716,10 +716,10 @@ ErrorOr<RefPtr<Value>> BraceExpansion::run(RefPtr<Shell> shell)
HitTestResult BraceExpansion::hit_test_position(size_t offset) const
{
for (auto& entry : m_entries) {
- auto result = entry.hit_test_position(offset);
+ auto result = entry->hit_test_position(offset);
if (result.matching_node) {
if (!result.closest_command_node)
- result.closest_command_node = &entry;
+ result.closest_command_node = entry;
return result;
}
}
@@ -730,20 +730,20 @@ HitTestResult BraceExpansion::hit_test_position(size_t offset) const
ErrorOr<void> BraceExpansion::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightMetadata metadata)
{
for (auto& entry : m_entries) {
- TRY(entry.highlight_in_editor(editor, shell, metadata));
+ TRY(entry->highlight_in_editor(editor, shell, metadata));
metadata.is_first_in_list = false;
}
return {};
}
-BraceExpansion::BraceExpansion(Position position, NonnullRefPtrVector<Node> entries)
+BraceExpansion::BraceExpansion(Position position, Vector<NonnullRefPtr<Node>> entries)
: Node(move(position))
, m_entries(move(entries))
{
for (auto& entry : m_entries) {
- if (entry.is_syntax_error()) {
- set_is_syntax_error(entry.syntax_error_node());
+ if (entry->is_syntax_error()) {
+ set_is_syntax_error(entry->syntax_error_node());
break;
}
}
@@ -838,7 +838,7 @@ ErrorOr<RefPtr<Value>> CastToList::run(RefPtr<Shell> shell)
return inner_value;
auto values = TRY(inner_value->resolve_as_list(shell));
- NonnullRefPtrVector<Value> cast_values;
+ Vector<NonnullRefPtr<Value>> cast_values;
for (auto& value : values)
cast_values.append(make_ref_counted<StringValue>(value));
@@ -1663,7 +1663,7 @@ ErrorOr<RefPtr<Value>> HistoryEvent::run(RefPtr<Shell> shell)
shell->raise_error(Shell::ShellError::EvaluatedSyntaxError, "History word index out of bounds", m_selector.word_selector_range.start.position);
return make_ref_counted<AST::ListValue>({});
}
- return nodes[index].run(shell);
+ return nodes[index]->run(shell);
}
ErrorOr<void> HistoryEvent::highlight_in_editor(Line::Editor& editor, Shell&, HighlightMetadata metadata)
@@ -1832,9 +1832,9 @@ ErrorOr<void> Execute::for_each_entry(RefPtr<Shell> shell, Function<ErrorOr<Iter
auto jobs = shell->run_commands(commands);
ScopeGuard kill_jobs_if_around { [&] {
for (auto& job : jobs) {
- if (job.is_running_in_background() && !job.exited() && !job.signaled()) {
- job.set_should_announce_signal(false); // We're explicitly killing it here.
- shell->kill_job(&job, SIGTERM);
+ if (job->is_running_in_background() && !job->exited() && !job->signaled()) {
+ job->set_should_announce_signal(false); // We're explicitly killing it here.
+ shell->kill_job(job, SIGTERM);
}
}
} };
@@ -1873,7 +1873,7 @@ ErrorOr<void> Execute::for_each_entry(RefPtr<Shell> shell, Function<ErrorOr<Iter
auto jobs = shell->run_commands(commands);
if (!jobs.is_empty())
- TRY(callback(make_ref_counted<JobValue>(&jobs.last())));
+ TRY(callback(make_ref_counted<JobValue>(jobs.last())));
return {};
}
@@ -1886,13 +1886,13 @@ ErrorOr<RefPtr<Value>> Execute::run(RefPtr<Shell> shell)
if (m_command->would_execute())
return m_command->run(shell);
- NonnullRefPtrVector<Value> values;
+ Vector<NonnullRefPtr<Value>> values;
TRY(for_each_entry(shell, [&](auto value) {
values.append(*value);
return IterationDecision::Continue;
}));
- if (values.size() == 1 && values.first().is_job())
+ if (values.size() == 1 && values.first()->is_job())
return values.first();
return make_ref_counted<ListValue>(move(values));
@@ -2065,7 +2065,7 @@ ErrorOr<void> ImmediateExpression::dump(int level) const
print_indented(level + 2, "{}", m_function.name);
print_indented(level + 1, "(arguments)");
for (auto& argument : arguments())
- TRY(argument.dump(level + 2));
+ TRY(argument->dump(level + 2));
return {};
}
@@ -2093,7 +2093,7 @@ ErrorOr<void> ImmediateExpression::highlight_in_editor(Line::Editor& editor, She
// Arguments
for (auto& argument : m_arguments) {
metadata.is_first_in_list = false;
- TRY(argument.highlight_in_editor(editor, shell, metadata));
+ TRY(argument->highlight_in_editor(editor, shell, metadata));
}
// Closing brace
@@ -2123,14 +2123,14 @@ HitTestResult ImmediateExpression::hit_test_position(size_t offset) const
return { this, this, this };
for (auto& argument : m_arguments) {
- if (auto result = argument.hit_test_position(offset); result.matching_node)
+ if (auto result = argument->hit_test_position(offset); result.matching_node)
return result;
}
return {};
}
-ImmediateExpression::ImmediateExpression(Position position, NameWithPosition function, NonnullRefPtrVector<AST::Node> arguments, Optional<Position> closing_brace_position)
+ImmediateExpression::ImmediateExpression(Position position, NameWithPosition function, Vector<NonnullRefPtr<AST::Node>> arguments, Optional<Position> closing_brace_position)
: Node(move(position))
, m_arguments(move(arguments))
, m_function(move(function))
@@ -2140,8 +2140,8 @@ ImmediateExpression::ImmediateExpression(Position position, NameWithPosition fun
return;
for (auto& argument : m_arguments) {
- if (argument.is_syntax_error()) {
- set_is_syntax_error(argument.syntax_error_node());
+ if (argument->is_syntax_error()) {
+ set_is_syntax_error(argument->syntax_error_node());
return;
}
}
@@ -2244,9 +2244,9 @@ ErrorOr<void> MatchExpr::dump(int level) const
}
print_indented(level + 2, "{}", builder.string_view());
TRY(entry.options.visit(
- [&](NonnullRefPtrVector<Node> const& options) -> ErrorOr<void> {
+ [&](Vector<NonnullRefPtr<Node>> const& options) -> ErrorOr<void> {
for (auto& option : options)
- TRY(option.dump(level + 3));
+ TRY(option->dump(level + 3));
return {};
},
[&](Vector<Regex<ECMA262>> const& options) -> ErrorOr<void> {
@@ -2307,17 +2307,17 @@ ErrorOr<RefPtr<Value>> MatchExpr::run(RefPtr<Shell> shell)
return ErrorOr<Regex<ECMA262>>(move(option));
} else {
Vector<String> pattern;
- if (option.is_glob()) {
- pattern.append(static_cast<const Glob*>(&option)->text());
- } else if (option.is_bareword()) {
- pattern.append(static_cast<const BarewordLiteral*>(&option)->text());
+ if (option->is_glob()) {
+ pattern.append(static_cast<Glob const*>(option.ptr())->text());
+ } else if (option->is_bareword()) {
+ pattern.append(static_cast<BarewordLiteral const*>(option.ptr())->text());
} else {
- auto list_or_error = option.run(shell);
+ auto list_or_error = option->run(shell);
if (list_or_error.is_error() || (shell && shell->has_any_error()))
return ErrorOr<Vector<String>>(move(pattern));
auto list = list_or_error.release_value();
- auto result = option.for_each_entry(shell, [&](auto&& value) -> ErrorOr<IterationDecision> {
+ auto result = option->for_each_entry(shell, [&](auto&& value) -> ErrorOr<IterationDecision> {
pattern.extend(TRY(value->resolve_as_list(nullptr))); // Note: 'nullptr' incurs special behavior,
// asking the node for a 'raw' value.
return IterationDecision::Continue;
@@ -2379,9 +2379,9 @@ ErrorOr<void> MatchExpr::highlight_in_editor(Line::Editor& editor, Shell& shell,
for (auto& entry : m_entries) {
metadata.is_first_in_list = false;
TRY(entry.options.visit(
- [&](NonnullRefPtrVector<Node>& node_options) -> ErrorOr<void> {
+ [&](Vector<NonnullRefPtr<Node>>& node_options) -> ErrorOr<void> {
for (auto& option : node_options)
- TRY(option.highlight_in_editor(editor, shell, metadata));
+ TRY(option->highlight_in_editor(editor, shell, metadata));
return {};
},
[](auto&) -> ErrorOr<void> { return {}; }));
@@ -2526,9 +2526,9 @@ ErrorOr<RefPtr<Value>> Pipe::run(RefPtr<Shell> shell)
auto& redirections = command.redirections;
for (ssize_t i = redirections.size() - 1; i >= 0; --i) {
auto& redirection = redirections[i];
- if (!redirection.is_fd_redirection())
+ if (!redirection->is_fd_redirection())
continue;
- auto& fd_redirection = static_cast<FdRedirection&>(redirection);
+ auto& fd_redirection = static_cast<FdRedirection&>(*redirection);
if (fd_redirection.old_fd == -1) {
insert_index = i;
break;
@@ -2663,8 +2663,8 @@ ErrorOr<void> Range::dump(int level) const
ErrorOr<RefPtr<Value>> Range::run(RefPtr<Shell> shell)
{
- auto interpolate = [position = position()](RefPtr<Value> start, RefPtr<Value> end, RefPtr<Shell> shell) -> NonnullRefPtrVector<Value> {
- NonnullRefPtrVector<Value> values;
+ auto interpolate = [position = position()](RefPtr<Value> start, RefPtr<Value> end, RefPtr<Shell> shell) -> Vector<NonnullRefPtr<Value>> {
+ Vector<NonnullRefPtr<Value>> values;
if (start->is_string() && end->is_string()) {
auto start_str = start->resolve_as_list(shell).release_value_but_fixme_should_propagate_errors()[0];
@@ -2839,7 +2839,7 @@ ErrorOr<void> Sequence::dump(int level) const
{
TRY(Node::dump(level));
for (auto& entry : m_entries)
- TRY(entry.dump(level + 1));
+ TRY(entry->dump(level + 1));
return {};
}
@@ -2851,7 +2851,7 @@ ErrorOr<RefPtr<Value>> Sequence::run(RefPtr<Shell> shell)
if (shell && shell->has_any_error())
break;
if (!last_command_in_sequence) {
- auto commands = TRY(entry.to_lazy_evaluated_commands(shell));
+ auto commands = TRY(entry->to_lazy_evaluated_commands(shell));
all_commands.extend(move(commands));
last_command_in_sequence = &all_commands.last();
continue;
@@ -2860,7 +2860,7 @@ ErrorOr<RefPtr<Value>> Sequence::run(RefPtr<Shell> shell)
if (last_command_in_sequence->should_wait) {
last_command_in_sequence->next_chain.append(NodeWithAction { entry, NodeWithAction::Sequence });
} else {
- all_commands.extend(TRY(entry.to_lazy_evaluated_commands(shell)));
+ all_commands.extend(TRY(entry->to_lazy_evaluated_commands(shell)));
last_command_in_sequence = &all_commands.last();
}
}
@@ -2871,14 +2871,14 @@ ErrorOr<RefPtr<Value>> Sequence::run(RefPtr<Shell> shell)
ErrorOr<void> Sequence::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightMetadata metadata)
{
for (auto& entry : m_entries)
- TRY(entry.highlight_in_editor(editor, shell, metadata));
+ TRY(entry->highlight_in_editor(editor, shell, metadata));
return {};
}
HitTestResult Sequence::hit_test_position(size_t offset) const
{
for (auto& entry : m_entries) {
- auto result = entry.hit_test_position(offset);
+ auto result = entry->hit_test_position(offset);
if (result.matching_node) {
if (!result.closest_command_node)
result.closest_command_node = entry;
@@ -2892,20 +2892,20 @@ HitTestResult Sequence::hit_test_position(size_t offset) const
RefPtr<Node const> Sequence::leftmost_trivial_literal() const
{
for (auto& entry : m_entries) {
- if (auto node = entry.leftmost_trivial_literal())
+ if (auto node = entry->leftmost_trivial_literal())
return node;
}
return nullptr;
}
-Sequence::Sequence(Position position, NonnullRefPtrVector<Node> entries, Vector<Position> separator_positions)
+Sequence::Sequence(Position position, Vector<NonnullRefPtr<Node>> entries, Vector<Position> separator_positions)
: Node(move(position))
, m_entries(move(entries))
, m_separator_positions(separator_positions)
{
for (auto& entry : m_entries) {
- if (entry.is_syntax_error()) {
- set_is_syntax_error(entry.syntax_error_node());
+ if (entry->is_syntax_error()) {
+ set_is_syntax_error(entry->syntax_error_node());
break;
}
}
@@ -3669,7 +3669,7 @@ ErrorOr<NonnullRefPtr<Value>> Value::with_slices(NonnullRefPtr<Slice> slice) con
return value;
}
-ErrorOr<NonnullRefPtr<Value>> Value::with_slices(NonnullRefPtrVector<Slice> slices) const&
+ErrorOr<NonnullRefPtr<Value>> Value::with_slices(Vector<NonnullRefPtr<Slice>> slices) const&
{
auto value = TRY(clone());
value->m_slices.extend(move(slices));
@@ -3684,16 +3684,16 @@ ErrorOr<Vector<String>> ListValue::resolve_as_list(RefPtr<Shell> shell)
{
Vector<String> values;
for (auto& value : m_contained_values)
- values.extend(TRY(value.resolve_as_list(shell)));
+ values.extend(TRY(value->resolve_as_list(shell)));
return resolve_slices(shell, move(values), m_slices);
}
ErrorOr<NonnullRefPtr<Value>> ListValue::resolve_without_cast(RefPtr<Shell> shell)
{
- NonnullRefPtrVector<Value> values;
+ Vector<NonnullRefPtr<Value>> values;
for (auto& value : m_contained_values)
- values.append(TRY(value.resolve_without_cast(shell)));
+ values.append(TRY(value->resolve_without_cast(shell)));
NonnullRefPtr<Value> value = make_ref_counted<ListValue>(move(values));
if (!m_slices.is_empty())
diff --git a/Userland/Shell/AST.h b/Userland/Shell/AST.h
index 0ae1d236b8..f70302ebb7 100644
--- a/Userland/Shell/AST.h
+++ b/Userland/Shell/AST.h
@@ -208,7 +208,7 @@ struct NodeWithAction {
struct Command {
Vector<String> argv;
- NonnullRefPtrVector<Redirection> redirections;
+ Vector<NonnullRefPtr<Redirection>> redirections;
bool should_wait { true };
bool is_pipe_source { false };
bool should_notify_if_in_background { true };
@@ -233,7 +233,7 @@ public:
virtual ErrorOr<NonnullRefPtr<Value>> resolve_without_cast(RefPtr<Shell>) { return *this; }
virtual ErrorOr<NonnullRefPtr<Value>> clone() const = 0;
virtual ErrorOr<NonnullRefPtr<Value>> with_slices(NonnullRefPtr<Slice> slice) const&;
- virtual ErrorOr<NonnullRefPtr<Value>> with_slices(NonnullRefPtrVector<Slice> slices) const&;
+ virtual ErrorOr<NonnullRefPtr<Value>> with_slices(Vector<NonnullRefPtr<Slice>> slices) const&;
virtual ~Value();
virtual bool is_command() const { return false; }
virtual bool is_glob() const { return false; }
@@ -243,12 +243,12 @@ public:
virtual bool is_list_without_resolution() const { return false; }
protected:
- Value& set_slices(NonnullRefPtrVector<Slice> slices)
+ Value& set_slices(Vector<NonnullRefPtr<Slice>> slices)
{
m_slices = move(slices);
return *this;
}
- NonnullRefPtrVector<Slice> m_slices;
+ Vector<NonnullRefPtr<Slice>> m_slices;
};
class CommandValue final : public Value {
@@ -316,16 +316,16 @@ public:
virtual bool is_list() const override { return true; }
virtual bool is_list_without_resolution() const override { return true; }
ListValue(Vector<String> values);
- ListValue(NonnullRefPtrVector<Value> values)
+ ListValue(Vector<NonnullRefPtr<Value>> values)
: m_contained_values(move(values))
{
}
- NonnullRefPtrVector<Value> const& values() const { return m_contained_values; }
- NonnullRefPtrVector<Value>& values() { return m_contained_values; }
+ Vector<NonnullRefPtr<Value>> const& values() const { return m_contained_values; }
+ Vector<NonnullRefPtr<Value>>& values() { return m_contained_values; }
private:
- NonnullRefPtrVector<Value> m_contained_values;
+ Vector<NonnullRefPtr<Value>> m_contained_values;
};
class StringValue final : public Value {
@@ -629,11 +629,11 @@ private:
class BraceExpansion final : public Node {
public:
- BraceExpansion(Position, NonnullRefPtrVector<Node>);
+ BraceExpansion(Position, Vector<NonnullRefPtr<Node>>);
virtual ~BraceExpansion() = default;
virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); }
- NonnullRefPtrVector<Node> const& entries() const { return m_entries; }
+ Vector<NonnullRefPtr<Node>> const& entries() const { return m_entries; }
private:
NODE(BraceExpansion);
@@ -642,7 +642,7 @@ private:
virtual ErrorOr<void> highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override;
virtual HitTestResult hit_test_position(size_t) const override;
- NonnullRefPtrVector<Node> m_entries;
+ Vector<NonnullRefPtr<Node>> m_entries;
};
class CastToCommand final : public Node {
@@ -1019,11 +1019,11 @@ private:
class ImmediateExpression final : public Node {
public:
- ImmediateExpression(Position, NameWithPosition function, NonnullRefPtrVector<AST::Node> arguments, Optional<Position> closing_brace_position);
+ ImmediateExpression(Position, NameWithPosition function, Vector<NonnullRefPtr<AST::Node>> arguments, Optional<Position> closing_brace_position);
virtual ~ImmediateExpression();
virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); }
- NonnullRefPtrVector<Node> const& arguments() const { return m_arguments; }
+ Vector<NonnullRefPtr<Node>> const& arguments() const { return m_arguments; }
auto const& function() const { return m_function; }
String const& function_name() const { return m_function.name; }
Position const& function_position() const { return m_function.position; }
@@ -1037,7 +1037,7 @@ private:
ErrorOr<Vector<Line::CompletionSuggestion>> complete_for_editor(Shell&, size_t, HitTestResult const&) const override;
virtual HitTestResult hit_test_position(size_t) const override;
- NonnullRefPtrVector<AST::Node> m_arguments;
+ Vector<NonnullRefPtr<AST::Node>> m_arguments;
NameWithPosition m_function;
Optional<Position> m_closing_brace_position;
};
@@ -1066,7 +1066,7 @@ private:
};
struct MatchEntry {
- Variant<NonnullRefPtrVector<Node>, Vector<Regex<ECMA262>>> options;
+ Variant<Vector<NonnullRefPtr<Node>>, Vector<Regex<ECMA262>>> options;
Optional<Vector<String>> match_names;
Optional<Position> match_as_position;
Vector<Position> pipe_positions;
@@ -1188,11 +1188,11 @@ private:
class Sequence final : public Node {
public:
- Sequence(Position, NonnullRefPtrVector<Node>, Vector<Position> separator_positions);
+ Sequence(Position, Vector<NonnullRefPtr<Node>>, Vector<Position> separator_positions);
virtual ~Sequence();
virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); }
- NonnullRefPtrVector<Node> const& entries() const { return m_entries; }
+ Vector<NonnullRefPtr<Node>> const& entries() const { return m_entries; }
Vector<Position> const& separator_positions() const { return m_separator_positions; }
@@ -1206,7 +1206,7 @@ private:
virtual bool should_override_execution_in_current_process() const override { return true; }
virtual RefPtr<Node const> leftmost_trivial_literal() const override;
- NonnullRefPtrVector<Node> m_entries;
+ Vector<NonnullRefPtr<Node>> m_entries;
Vector<Position> m_separator_positions;
};
diff --git a/Userland/Shell/Builtin.cpp b/Userland/Shell/Builtin.cpp
index ea5ab7db1c..d9cc2a60ce 100644
--- a/Userland/Shell/Builtin.cpp
+++ b/Userland/Shell/Builtin.cpp
@@ -1014,7 +1014,7 @@ ErrorOr<int> Shell::builtin_time(Main::Arguments arguments)
auto timer = Core::ElapsedTimer::start_new();
for (auto& job : run_commands(commands)) {
block_on_job(job);
- exit_code = job.exit_code();
+ exit_code = job->exit_code();
}
iteration_times.add(static_cast<float>(timer.elapsed()));
}
@@ -1190,7 +1190,7 @@ ErrorOr<int> Shell::builtin_not(Main::Arguments arguments)
for (auto& job : run_commands(commands)) {
found_a_job = true;
block_on_job(job);
- exit_code = job.exit_code();
+ exit_code = job->exit_code();
}
// In case it was a function.
if (!found_a_job)
@@ -1242,7 +1242,7 @@ ErrorOr<int> Shell::builtin_kill(Main::Arguments arguments)
return exit_code;
}
-ErrorOr<bool> Shell::run_builtin(const AST::Command& command, NonnullRefPtrVector<AST::Rewiring> const& rewirings, int& retval)
+ErrorOr<bool> Shell::run_builtin(const AST::Command& command, Vector<NonnullRefPtr<AST::Rewiring>> const& rewirings, int& retval)
{
if (command.argv.is_empty())
return false;
@@ -1266,7 +1266,7 @@ ErrorOr<bool> Shell::run_builtin(const AST::Command& command, NonnullRefPtrVecto
SavedFileDescriptors fds { rewirings };
for (auto& rewiring : rewirings) {
- int rc = dup2(rewiring.old_fd, rewiring.new_fd);
+ int rc = dup2(rewiring->old_fd, rewiring->new_fd);
if (rc < 0) {
perror("dup2(run)");
return false;
diff --git a/Userland/Shell/Execution.h b/Userland/Shell/Execution.h
index 681d908405..5123105cfc 100644
--- a/Userland/Shell/Execution.h
+++ b/Userland/Shell/Execution.h
@@ -29,7 +29,7 @@ private:
class SavedFileDescriptors {
public:
- SavedFileDescriptors(NonnullRefPtrVector<AST::Rewiring> const&);
+ SavedFileDescriptors(Vector<NonnullRefPtr<AST::Rewiring>> const&);
~SavedFileDescriptors();
private:
diff --git a/Userland/Shell/Formatter.cpp b/Userland/Shell/Formatter.cpp
index 3c1ac9aad3..fca5c53ea9 100644
--- a/Userland/Shell/Formatter.cpp
+++ b/Userland/Shell/Formatter.cpp
@@ -204,7 +204,7 @@ void Formatter::visit(const AST::BraceExpansion* node)
if (!first)
current_builder().append(',');
first = false;
- entry.visit(*this);
+ entry->visit(*this);
}
}
@@ -529,7 +529,7 @@ void Formatter::visit(const AST::ImmediateExpression* node)
for (auto& node : node->arguments()) {
current_builder().append(' ');
- node.visit(*this);
+ node->visit(*this);
}
if (node->has_closing_brace())
@@ -585,12 +585,12 @@ void Formatter::visit(const AST::MatchExpr* node)
first_entry = false;
auto first = true;
entry.options.visit(
- [&](NonnullRefPtrVector<AST::Node> const& patterns) {
+ [&](Vector<NonnullRefPtr<AST::Node>> const& patterns) {
for (auto& option : patterns) {
if (!first)
current_builder().append(" | "sv);
first = false;
- option.visit(*this);
+ option->visit(*this);
}
},
[&](Vector<Regex<ECMA262>> const& patterns) {
@@ -721,7 +721,7 @@ void Formatter::visit(const AST::Sequence* node)
else
insert_separator();
- entry.visit(*this);
+ entry->visit(*this);
}
visited(node);
diff --git a/Userland/Shell/ImmediateFunctions.cpp b/Userland/Shell/ImmediateFunctions.cpp
index 5930d2212e..6baf1c6247 100644
--- a/Userland/Shell/ImmediateFunctions.cpp
+++ b/Userland/Shell/ImmediateFunctions.cpp
@@ -10,7 +10,7 @@
namespace Shell {
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_length_impl(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments, bool across)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_length_impl(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments, bool across)
{
auto name = across ? "length_across" : "length";
if (arguments.size() < 1 || arguments.size() > 2) {
@@ -32,12 +32,12 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_length_impl(AST::ImmediateExpression
// length list <expr>
auto& mode_arg = arguments.first();
- if (!mode_arg.is_bareword()) {
- raise_error(ShellError::EvaluatedSyntaxError, DeprecatedString::formatted("Expected a bareword (either 'string' or 'list') in the two-argument form of the `{}' immediate", name), mode_arg.position());
+ if (!mode_arg->is_bareword()) {
+ raise_error(ShellError::EvaluatedSyntaxError, DeprecatedString::formatted("Expected a bareword (either 'string' or 'list') in the two-argument form of the `{}' immediate", name), mode_arg->position());
return nullptr;
}
- auto const& mode_name = static_cast<const AST::BarewordLiteral&>(mode_arg).text();
+ auto const& mode_name = static_cast<const AST::BarewordLiteral&>(*mode_arg).text();
if (mode_name == "list") {
mode = List;
} else if (mode_name == "string") {
@@ -45,13 +45,13 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_length_impl(AST::ImmediateExpression
} else if (mode_name == "infer") {
mode = Infer;
} else {
- raise_error(ShellError::EvaluatedSyntaxError, DeprecatedString::formatted("Expected either 'string' or 'list' (and not {}) in the two-argument form of the `{}' immediate", mode_name, name), mode_arg.position());
+ raise_error(ShellError::EvaluatedSyntaxError, DeprecatedString::formatted("Expected either 'string' or 'list' (and not {}) in the two-argument form of the `{}' immediate", mode_name, name), mode_arg->position());
return nullptr;
}
- expr_node = &arguments[1];
+ expr_node = arguments[1];
} else {
- expr_node = &arguments[0];
+ expr_node = arguments[0];
}
if (mode == Infer) {
@@ -81,7 +81,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_length_impl(AST::ImmediateExpression
resulting_nodes.unchecked_append(AST::make_ref_counted<AST::ImmediateExpression>(
expr_node->position(),
AST::NameWithPosition { TRY("length"_string), invoking_node.function_position() },
- NonnullRefPtrVector<AST::Node> { Vector<NonnullRefPtr<AST::Node>> {
+ Vector<NonnullRefPtr<AST::Node>> { Vector<NonnullRefPtr<AST::Node>> {
static_cast<NonnullRefPtr<AST::Node>>(AST::make_ref_counted<AST::BarewordLiteral>(expr_node->position(), TRY(String::from_utf8(mode_name)))),
AST::make_ref_counted<AST::SyntheticNode>(expr_node->position(), NonnullRefPtr<AST::Value>(entry)),
} },
@@ -189,39 +189,39 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_length_impl(AST::ImmediateExpression
}
}
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_length(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_length(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
return immediate_length_impl(invoking_node, arguments, false);
}
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_length_across(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_length_across(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
return immediate_length_impl(invoking_node, arguments, true);
}
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_regex_replace(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_regex_replace(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
if (arguments.size() != 3) {
raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 3 arguments to regex_replace", invoking_node.position());
return nullptr;
}
- auto pattern = TRY(const_cast<AST::Node&>(arguments[0]).run(this));
- auto replacement = TRY(const_cast<AST::Node&>(arguments[1]).run(this));
- auto value = TRY(TRY(const_cast<AST::Node&>(arguments[2]).run(this))->resolve_without_cast(this));
+ auto pattern = TRY(const_cast<AST::Node&>(*arguments[0]).run(this));
+ auto replacement = TRY(const_cast<AST::Node&>(*arguments[1]).run(this));
+ auto value = TRY(TRY(const_cast<AST::Node&>(*arguments[2]).run(this))->resolve_without_cast(this));
if (!pattern->is_string()) {
- raise_error(ShellError::EvaluatedSyntaxError, "Expected the regex_replace pattern to be a string", arguments[0].position());
+ raise_error(ShellError::EvaluatedSyntaxError, "Expected the regex_replace pattern to be a string", arguments[0]->position());
return nullptr;
}
if (!replacement->is_string()) {
- raise_error(ShellError::EvaluatedSyntaxError, "Expected the regex_replace replacement string to be a string", arguments[1].position());
+ raise_error(ShellError::EvaluatedSyntaxError, "Expected the regex_replace replacement string to be a string", arguments[1]->position());
return nullptr;
}
if (!value->is_string()) {
- raise_error(ShellError::EvaluatedSyntaxError, "Expected the regex_replace target value to be a string", arguments[2].position());
+ raise_error(ShellError::EvaluatedSyntaxError, "Expected the regex_replace target value to be a string", arguments[2]->position());
return nullptr;
}
@@ -234,18 +234,18 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_regex_replace(AST::ImmediateExpressi
return AST::make_ref_counted<AST::StringLiteral>(invoking_node.position(), TRY(String::from_utf8(result)), AST::StringLiteral::EnclosureType::None);
}
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_remove_suffix(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_remove_suffix(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
if (arguments.size() != 2) {
raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 2 arguments to remove_suffix", invoking_node.position());
return nullptr;
}
- auto suffix = TRY(const_cast<AST::Node&>(arguments[0]).run(this));
- auto value = TRY(TRY(const_cast<AST::Node&>(arguments[1]).run(this))->resolve_without_cast(this));
+ auto suffix = TRY(const_cast<AST::Node&>(*arguments[0]).run(this));
+ auto value = TRY(TRY(const_cast<AST::Node&>(*arguments[1]).run(this))->resolve_without_cast(this));
if (!suffix->is_string()) {
- raise_error(ShellError::EvaluatedSyntaxError, "Expected the remove_suffix suffix string to be a string", arguments[0].position());
+ raise_error(ShellError::EvaluatedSyntaxError, "Expected the remove_suffix suffix string to be a string", arguments[0]->position());
return nullptr;
}
@@ -266,18 +266,18 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_remove_suffix(AST::ImmediateExpressi
return AST::make_ref_counted<AST::ListConcatenate>(invoking_node.position(), move(nodes));
}
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_remove_prefix(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_remove_prefix(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
if (arguments.size() != 2) {
raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 2 arguments to remove_prefix", invoking_node.position());
return nullptr;
}
- auto prefix = TRY(const_cast<AST::Node&>(arguments[0]).run(this));
- auto value = TRY(TRY(const_cast<AST::Node&>(arguments[1]).run(this))->resolve_without_cast(this));
+ auto prefix = TRY(const_cast<AST::Node&>(*arguments[0]).run(this));
+ auto value = TRY(TRY(const_cast<AST::Node&>(*arguments[1]).run(this))->resolve_without_cast(this));
if (!prefix->is_string()) {
- raise_error(ShellError::EvaluatedSyntaxError, "Expected the remove_prefix prefix string to be a string", arguments[0].position());
+ raise_error(ShellError::EvaluatedSyntaxError, "Expected the remove_prefix prefix string to be a string", arguments[0]->position());
return nullptr;
}
@@ -297,18 +297,18 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_remove_prefix(AST::ImmediateExpressi
return AST::make_ref_counted<AST::ListConcatenate>(invoking_node.position(), move(nodes));
}
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_split(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_split(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
if (arguments.size() != 2) {
raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 2 arguments to split", invoking_node.position());
return nullptr;
}
- auto delimiter = TRY(const_cast<AST::Node&>(arguments[0]).run(this));
- auto value = TRY(TRY(const_cast<AST::Node&>(arguments[1]).run(this))->resolve_without_cast(this));
+ auto delimiter = TRY(const_cast<AST::Node&>(*arguments[0]).run(this));
+ auto value = TRY(TRY(const_cast<AST::Node&>(*arguments[1]).run(this))->resolve_without_cast(this));
if (!delimiter->is_string()) {
- raise_error(ShellError::EvaluatedSyntaxError, "Expected the split delimiter string to be a string", arguments[0].position());
+ raise_error(ShellError::EvaluatedSyntaxError, "Expected the split delimiter string to be a string", arguments[0]->position());
return nullptr;
}
@@ -321,13 +321,13 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_split(AST::ImmediateExpression& invo
for (auto& entry : values) {
// ImmediateExpression(split <delimiter> <entry>)
resulting_nodes.unchecked_append(AST::make_ref_counted<AST::ImmediateExpression>(
- arguments[1].position(),
+ arguments[1]->position(),
invoking_node.function(),
- NonnullRefPtrVector<AST::Node> { Vector<NonnullRefPtr<AST::Node>> {
+ Vector<NonnullRefPtr<AST::Node>> { Vector<NonnullRefPtr<AST::Node>> {
arguments[0],
- AST::make_ref_counted<AST::SyntheticNode>(arguments[1].position(), NonnullRefPtr<AST::Value>(entry)),
+ AST::make_ref_counted<AST::SyntheticNode>(arguments[1]->position(), NonnullRefPtr<AST::Value>(entry)),
} },
- arguments[1].position()));
+ arguments[1]->position()));
}
return AST::make_ref_counted<AST::ListConcatenate>(invoking_node.position(), move(resulting_nodes));
@@ -341,7 +341,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_split(AST::ImmediateExpression& invo
auto list = TRY(value->resolve_as_list(this));
if (!value->is_list()) {
if (list.is_empty())
- return AST::make_ref_counted<AST::ListConcatenate>(invoking_node.position(), NonnullRefPtrVector<AST::Node> {});
+ return AST::make_ref_counted<AST::ListConcatenate>(invoking_node.position(), Vector<NonnullRefPtr<AST::Node>> {});
auto& value = list.first();
Vector<String> split_strings;
@@ -364,22 +364,22 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_split(AST::ImmediateExpression& invo
return transform(AST::make_ref_counted<AST::ListValue>(list)->values());
}
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_concat_lists(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_concat_lists(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
- NonnullRefPtrVector<AST::Node> result;
+ Vector<NonnullRefPtr<AST::Node>> result;
for (auto& argument : arguments) {
- if (auto* list = dynamic_cast<const AST::ListConcatenate*>(&argument)) {
+ if (auto* list = dynamic_cast<AST::ListConcatenate const*>(argument.ptr())) {
result.extend(list->list());
} else {
- auto list_of_values = TRY(TRY(const_cast<AST::Node&>(argument).run(this))->resolve_without_cast(this));
+ auto list_of_values = TRY(TRY(const_cast<AST::Node&>(*argument).run(this))->resolve_without_cast(this));
if (auto* list = dynamic_cast<AST::ListValue*>(list_of_values.ptr())) {
for (auto& entry : static_cast<Vector<NonnullRefPtr<AST::Value>>&>(list->values()))
- result.append(AST::make_ref_counted<AST::SyntheticNode>(argument.position(), entry));
+ result.append(AST::make_ref_counted<AST::SyntheticNode>(argument->position(), entry));
} else {
auto values = TRY(list_of_values->resolve_as_list(this));
for (auto& entry : values)
- result.append(AST::make_ref_counted<AST::StringLiteral>(argument.position(), entry, AST::StringLiteral::EnclosureType::None));
+ result.append(AST::make_ref_counted<AST::StringLiteral>(argument->position(), entry, AST::StringLiteral::EnclosureType::None));
}
}
}
@@ -387,7 +387,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_concat_lists(AST::ImmediateExpressio
return AST::make_ref_counted<AST::ListConcatenate>(invoking_node.position(), move(result));
}
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_filter_glob(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_filter_glob(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
// filter_glob string list
if (arguments.size() != 2) {
@@ -395,33 +395,33 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_filter_glob(AST::ImmediateExpression
return nullptr;
}
- auto glob_list = TRY(TRY(const_cast<AST::Node&>(arguments[0]).run(*this))->resolve_as_list(*this));
+ auto glob_list = TRY(TRY(const_cast<AST::Node&>(*arguments[0]).run(*this))->resolve_as_list(*this));
if (glob_list.size() != 1) {
- raise_error(ShellError::EvaluatedSyntaxError, "Expected the <glob> argument to filter_glob to be a single string", arguments[0].position());
+ raise_error(ShellError::EvaluatedSyntaxError, "Expected the <glob> argument to filter_glob to be a single string", arguments[0]->position());
return nullptr;
}
auto& glob = glob_list.first();
auto& list_node = arguments[1];
- NonnullRefPtrVector<AST::Node> result;
+ Vector<NonnullRefPtr<AST::Node>> result;
- TRY(const_cast<AST::Node&>(list_node).for_each_entry(*this, [&](NonnullRefPtr<AST::Value> entry) -> ErrorOr<IterationDecision> {
+ TRY(const_cast<AST::Node&>(*list_node).for_each_entry(*this, [&](NonnullRefPtr<AST::Value> entry) -> ErrorOr<IterationDecision> {
auto value = TRY(entry->resolve_as_list(*this));
if (value.size() == 0)
return IterationDecision::Continue;
if (value.size() == 1) {
if (!value.first().bytes_as_string_view().matches(glob))
return IterationDecision::Continue;
- result.append(AST::make_ref_counted<AST::StringLiteral>(arguments[1].position(), value.first(), AST::StringLiteral::EnclosureType::None));
+ result.append(AST::make_ref_counted<AST::StringLiteral>(arguments[1]->position(), value.first(), AST::StringLiteral::EnclosureType::None));
return IterationDecision::Continue;
}
for (auto& entry : value) {
if (entry.bytes_as_string_view().matches(glob)) {
- NonnullRefPtrVector<AST::Node> nodes;
+ Vector<NonnullRefPtr<AST::Node>> nodes;
for (auto& string : value)
- nodes.append(AST::make_ref_counted<AST::StringLiteral>(arguments[1].position(), string, AST::StringLiteral::EnclosureType::None));
- result.append(AST::make_ref_counted<AST::ListConcatenate>(arguments[1].position(), move(nodes)));
+ nodes.append(AST::make_ref_counted<AST::StringLiteral>(arguments[1]->position(), string, AST::StringLiteral::EnclosureType::None));
+ result.append(AST::make_ref_counted<AST::ListConcatenate>(arguments[1]->position(), move(nodes)));
return IterationDecision::Continue;
}
}
@@ -431,22 +431,22 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_filter_glob(AST::ImmediateExpression
return AST::make_ref_counted<AST::ListConcatenate>(invoking_node.position(), move(result));
}
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_join(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_join(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
if (arguments.size() != 2) {
raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 2 arguments to join", invoking_node.position());
return nullptr;
}
- auto delimiter = TRY(const_cast<AST::Node&>(arguments[0]).run(this));
+ auto delimiter = TRY(const_cast<AST::Node&>(*arguments[0]).run(this));
if (!delimiter->is_string()) {
- raise_error(ShellError::EvaluatedSyntaxError, "Expected the join delimiter string to be a string", arguments[0].position());
+ raise_error(ShellError::EvaluatedSyntaxError, "Expected the join delimiter string to be a string", arguments[0]->position());
return nullptr;
}
- auto value = TRY(TRY(const_cast<AST::Node&>(arguments[1]).run(this))->resolve_without_cast(this));
+ auto value = TRY(TRY(const_cast<AST::Node&>(*arguments[1]).run(this))->resolve_without_cast(this));
if (!value->is_list()) {
- raise_error(ShellError::EvaluatedSyntaxError, "Expected the joined list to be a list", arguments[1].position());
+ raise_error(ShellError::EvaluatedSyntaxError, "Expected the joined list to be a list", arguments[1]->position());
return nullptr;
}
@@ -457,49 +457,49 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_join(AST::ImmediateExpression& invok
return AST::make_ref_counted<AST::StringLiteral>(invoking_node.position(), TRY(builder.to_string()), AST::StringLiteral::EnclosureType::None);
}
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_value_or_default(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_value_or_default(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
if (arguments.size() != 2) {
raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 2 arguments to value_or_default", invoking_node.position());
return nullptr;
}
- auto name = TRY(TRY(const_cast<AST::Node&>(arguments.first()).run(*this))->resolve_as_string(*this));
+ auto name = TRY(TRY(const_cast<AST::Node&>(*arguments.first()).run(*this))->resolve_as_string(*this));
if (!TRY(local_variable_or(name, ""sv)).is_empty())
return make_ref_counted<AST::SimpleVariable>(invoking_node.position(), name);
return arguments.last();
}
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_assign_default(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_assign_default(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
if (arguments.size() != 2) {
raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 2 arguments to assign_default", invoking_node.position());
return nullptr;
}
- auto name = TRY(TRY(const_cast<AST::Node&>(arguments.first()).run(*this))->resolve_as_string(*this));
+ auto name = TRY(TRY(const_cast<AST::Node&>(*arguments.first()).run(*this))->resolve_as_string(*this));
if (!TRY(local_variable_or(name, ""sv)).is_empty())
return make_ref_counted<AST::SimpleVariable>(invoking_node.position(), name);
- auto value = TRY(TRY(const_cast<AST::Node&>(arguments.last()).run(*this))->resolve_without_cast(*this));
+ auto value = TRY(TRY(const_cast<AST::Node&>(*arguments.last()).run(*this))->resolve_without_cast(*this));
set_local_variable(name.to_deprecated_string(), value);
return make_ref_counted<AST::SyntheticNode>(invoking_node.position(), value);
}
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_error_if_empty(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_error_if_empty(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
if (arguments.size() != 2) {
raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 2 arguments to error_if_empty", invoking_node.position());
return nullptr;
}
- auto name = TRY(TRY(const_cast<AST::Node&>(arguments.first()).run(*this))->resolve_as_string(*this));
+ auto name = TRY(TRY(const_cast<AST::Node&>(*arguments.first()).run(*this))->resolve_as_string(*this));
if (!TRY(local_variable_or(name, ""sv)).is_empty())
return make_ref_counted<AST::SimpleVariable>(invoking_node.position(), name);
- auto error_value = TRY(TRY(const_cast<AST::Node&>(arguments.last()).run(*this))->resolve_as_string(*this));
+ auto error_value = TRY(TRY(const_cast<AST::Node&>(*arguments.last()).run(*this))->resolve_as_string(*this));
if (error_value.is_empty())
error_value = TRY(String::formatted("Expected {} to be non-empty", name));
@@ -507,63 +507,63 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_error_if_empty(AST::ImmediateExpress
return nullptr;
}
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_null_or_alternative(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_null_or_alternative(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
if (arguments.size() != 2) {
raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 2 arguments to null_or_alternative", invoking_node.position());
return nullptr;
}
- auto value = TRY(TRY(const_cast<AST::Node&>(arguments.first()).run(*this))->resolve_without_cast(*this));
+ auto value = TRY(TRY(const_cast<AST::Node&>(*arguments.first()).run(*this))->resolve_without_cast(*this));
if ((value->is_string() && TRY(value->resolve_as_string(*this)).is_empty()) || (value->is_list() && TRY(value->resolve_as_list(*this)).is_empty()))
return make_ref_counted<AST::SyntheticNode>(invoking_node.position(), value);
return arguments.last();
}
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_defined_value_or_default(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_defined_value_or_default(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
if (arguments.size() != 2) {
raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 2 arguments to defined_value_or_default", invoking_node.position());
return nullptr;
}
- auto name = TRY(TRY(const_cast<AST::Node&>(arguments.first()).run(*this))->resolve_as_string(*this));
+ auto name = TRY(TRY(const_cast<AST::Node&>(*arguments.first()).run(*this))->resolve_as_string(*this));
if (!find_frame_containing_local_variable(name))
return arguments.last();
return make_ref_counted<AST::SimpleVariable>(invoking_node.position(), name);
}
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_assign_defined_default(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_assign_defined_default(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
if (arguments.size() != 2) {
raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 2 arguments to assign_defined_default", invoking_node.position());
return nullptr;
}
- auto name = TRY(TRY(const_cast<AST::Node&>(arguments.first()).run(*this))->resolve_as_string(*this));
+ auto name = TRY(TRY(const_cast<AST::Node&>(*arguments.first()).run(*this))->resolve_as_string(*this));
if (find_frame_containing_local_variable(name))
return make_ref_counted<AST::SimpleVariable>(invoking_node.position(), name);
- auto value = TRY(TRY(const_cast<AST::Node&>(arguments.last()).run(*this))->resolve_without_cast(*this));
+ auto value = TRY(TRY(const_cast<AST::Node&>(*arguments.last()).run(*this))->resolve_without_cast(*this));
set_local_variable(name.to_deprecated_string(), value);
return make_ref_counted<AST::SyntheticNode>(invoking_node.position(), value);
}
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_error_if_unset(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_error_if_unset(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
if (arguments.size() != 2) {
raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 2 arguments to error_if_unset", invoking_node.position());
return nullptr;
}
- auto name = TRY(TRY(const_cast<AST::Node&>(arguments.first()).run(*this))->resolve_as_string(*this));
+ auto name = TRY(TRY(const_cast<AST::Node&>(*arguments.first()).run(*this))->resolve_as_string(*this));
if (find_frame_containing_local_variable(name))
return make_ref_counted<AST::SimpleVariable>(invoking_node.position(), name);
- auto error_value = TRY(TRY(const_cast<AST::Node&>(arguments.last()).run(*this))->resolve_as_string(*this));
+ auto error_value = TRY(TRY(const_cast<AST::Node&>(*arguments.last()).run(*this))->resolve_as_string(*this));
if (error_value.is_empty())
error_value = TRY(String::formatted("Expected {} to be set", name));
@@ -571,39 +571,39 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_error_if_unset(AST::ImmediateExpress
return nullptr;
}
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_null_if_unset_or_alternative(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_null_if_unset_or_alternative(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
if (arguments.size() != 2) {
raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 2 arguments to null_if_unset_or_alternative", invoking_node.position());
return nullptr;
}
- auto name = TRY(TRY(const_cast<AST::Node&>(arguments.first()).run(*this))->resolve_as_string(*this));
+ auto name = TRY(TRY(const_cast<AST::Node&>(*arguments.first()).run(*this))->resolve_as_string(*this));
if (!find_frame_containing_local_variable(name))
return arguments.last();
return make_ref_counted<AST::SimpleVariable>(invoking_node.position(), name);
}
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_reexpand(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_reexpand(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
if (arguments.size() != 1) {
raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 1 argument to reexpand", invoking_node.position());
return nullptr;
}
- auto value = TRY(TRY(const_cast<AST::Node&>(arguments.first()).run(*this))->resolve_as_string(*this));
+ auto value = TRY(TRY(const_cast<AST::Node&>(*arguments.first()).run(*this))->resolve_as_string(*this));
return parse(value, m_is_interactive, false);
}
-ErrorOr<RefPtr<AST::Node>> Shell::immediate_length_of_variable(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::immediate_length_of_variable(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
if (arguments.size() != 1) {
raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 1 argument to length_of_variable", invoking_node.position());
return nullptr;
}
- auto name = TRY(TRY(const_cast<AST::Node&>(arguments.first()).run(*this))->resolve_as_string(*this));
+ auto name = TRY(TRY(const_cast<AST::Node&>(*arguments.first()).run(*this))->resolve_as_string(*this));
auto variable = make_ref_counted<AST::SimpleVariable>(invoking_node.position(), name);
return immediate_length_impl(
@@ -612,7 +612,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_length_of_variable(AST::ImmediateExp
false);
}
-ErrorOr<RefPtr<AST::Node>> Shell::run_immediate_function(StringView str, AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
+ErrorOr<RefPtr<AST::Node>> Shell::run_immediate_function(StringView str, AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)
{
#define __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(name) \
if (str == #name) \
diff --git a/Userland/Shell/NodeVisitor.cpp b/Userland/Shell/NodeVisitor.cpp
index 834c78a3f0..f2dd63b1e5 100644
--- a/Userland/Shell/NodeVisitor.cpp
+++ b/Userland/Shell/NodeVisitor.cpp
@@ -38,7 +38,7 @@ void NodeVisitor::visit(const AST::BarewordLiteral*)
void NodeVisitor::visit(const AST::BraceExpansion* node)
{
for (auto& entry : node->entries())
- entry.visit(*this);
+ entry->visit(*this);
}
void NodeVisitor::visit(const AST::CastToCommand* node)
@@ -128,7 +128,7 @@ void NodeVisitor::visit(const AST::IfCond* node)
void NodeVisitor::visit(const AST::ImmediateExpression* node)
{
for (auto& node : node->arguments())
- node.visit(*this);
+ node->visit(*this);
}
void NodeVisitor::visit(const AST::Join* node)
@@ -141,9 +141,9 @@ void NodeVisitor::visit(const AST::MatchExpr* node)
{
node->matched_expr()->visit(*this);
for (auto& entry : node->entries()) {
- if (auto* ptr = entry.options.get_pointer<NonnullRefPtrVector<Node>>()) {
+ if (auto* ptr = entry.options.get_pointer<Vector<NonnullRefPtr<Node>>>()) {
for (auto& option : *ptr)
- option.visit(*this);
+ option->visit(*this);
}
if (entry.body)
entry.body->visit(*this);
@@ -181,7 +181,7 @@ void NodeVisitor::visit(const AST::ReadWriteRedirection* node)
void NodeVisitor::visit(const AST::Sequence* node)
{
for (auto& entry : node->entries())
- entry.visit(*this);
+ entry->visit(*this);
}
void NodeVisitor::visit(const AST::Subshell* node)
diff --git a/Userland/Shell/Parser.cpp b/Userland/Shell/Parser.cpp
index 02ce44ec13..9c328e9a5d 100644
--- a/Userland/Shell/Parser.cpp
+++ b/Userland/Shell/Parser.cpp
@@ -149,9 +149,9 @@ RefPtr<AST::Node> Parser::parse_as_single_expression()
return parser.parse_expression();
}
-NonnullRefPtrVector<AST::Node> Parser::parse_as_multiple_expressions()
+Vector<NonnullRefPtr<AST::Node>> Parser::parse_as_multiple_expressions()
{
- NonnullRefPtrVector<AST::Node> nodes;
+ Vector<NonnullRefPtr<AST::Node>> nodes;
for (;;) {
consume_while(is_whitespace);
auto node = parse_expression();
@@ -168,7 +168,7 @@ RefPtr<AST::Node> Parser::parse_toplevel()
auto rule_start = push_start();
SequenceParseResult result;
- NonnullRefPtrVector<AST::Node> sequence;
+ Vector<NonnullRefPtr<AST::Node>> sequence;
Vector<AST::Position> positions;
do {
result = parse_sequence();
@@ -188,7 +188,7 @@ RefPtr<AST::Node> Parser::parse_toplevel()
Parser::SequenceParseResult Parser::parse_sequence()
{
- NonnullRefPtrVector<AST::Node> left;
+ Vector<NonnullRefPtr<AST::Node>> left;
auto read_terminators = [&](bool consider_tabs_and_spaces) {
if (m_heredoc_initiations.is_empty()) {
discard_terminators:;
@@ -927,7 +927,7 @@ AST::MatchEntry Parser::parse_match_entry()
{
auto rule_start = push_start();
- NonnullRefPtrVector<AST::Node> patterns;
+ Vector<NonnullRefPtr<AST::Node>> patterns;
Vector<Regex<ECMA262>> regexps;
Vector<AST::Position> pipe_positions;
Optional<Vector<String>> match_names;
@@ -942,14 +942,14 @@ AST::MatchEntry Parser::parse_match_entry()
auto regex_pattern = parse_regex_pattern();
if (regex_pattern.has_value()) {
if (auto error = regex_pattern.value().parser_result.error; error != regex::Error::NoError)
- return { NonnullRefPtrVector<AST::Node> {}, {}, {}, {}, create<AST::SyntaxError>(String::from_utf8(regex::get_error_string(error)).release_value_but_fixme_should_propagate_errors(), false) };
+ return { Vector<NonnullRefPtr<AST::Node>> {}, {}, {}, {}, create<AST::SyntaxError>(String::from_utf8(regex::get_error_string(error)).release_value_but_fixme_should_propagate_errors(), false) };
pattern_kind = Regex;
regexps.append(regex_pattern.release_value());
} else {
auto glob_pattern = parse_match_pattern();
if (!glob_pattern)
- return { NonnullRefPtrVector<AST::Node> {}, {}, {}, {}, create<AST::SyntaxError>("Expected a pattern in 'match' body"_string.release_value_but_fixme_should_propagate_errors(), true) };
+ return { Vector<NonnullRefPtr<AST::Node>> {}, {}, {}, {}, create<AST::SyntaxError>("Expected a pattern in 'match' body"_string.release_value_but_fixme_should_propagate_errors(), true) };
pattern_kind = Glob;
patterns.append(glob_pattern.release_nonnull());
@@ -1633,7 +1633,7 @@ RefPtr<AST::Node> Parser::parse_immediate_expression()
consume_while(is_whitespace);
- NonnullRefPtrVector<AST::Node> arguments;
+ Vector<NonnullRefPtr<AST::Node>> arguments;
do {
auto expr = parse_expression();
if (!expr)
@@ -2021,7 +2021,7 @@ RefPtr<AST::Node> Parser::parse_brace_expansion_spec()
m_extra_chars_not_allowed_in_barewords.append(',');
auto rule_start = push_start();
- NonnullRefPtrVector<AST::Node> subexpressions;
+ Vector<NonnullRefPtr<AST::Node>> subexpressions;
if (next_is(","sv)) {
// Note that we don't consume the ',' here.
diff --git a/Userland/Shell/Parser.h b/Userland/Shell/Parser.h
index 802489d9b0..3ca87658cb 100644
--- a/Userland/Shell/Parser.h
+++ b/Userland/Shell/Parser.h
@@ -27,7 +27,7 @@ public:
/// Parse the given string *as* an expression
/// that is to forcefully enclose it in double-quotes.
RefPtr<AST::Node> parse_as_single_expression();
- NonnullRefPtrVector<AST::Node> parse_as_multiple_expressions();
+ Vector<NonnullRefPtr<AST::Node>> parse_as_multiple_expressions();
struct SavedOffset {
size_t offset;
@@ -47,7 +47,7 @@ private:
};
struct SequenceParseResult {
- NonnullRefPtrVector<AST::Node> entries;
+ Vector<NonnullRefPtr<AST::Node>> entries;
Vector<AST::Position, 1> separator_positions;
ShouldReadMoreSequences decision;
};
diff --git a/Userland/Shell/PosixParser.cpp b/Userland/Shell/PosixParser.cpp
index d7358104e7..4703174408 100644
--- a/Userland/Shell/PosixParser.cpp
+++ b/Userland/Shell/PosixParser.cpp
@@ -663,7 +663,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_complete_command()
ErrorOr<RefPtr<AST::Node>> Parser::parse_list()
{
- NonnullRefPtrVector<AST::Node> nodes;
+ Vector<NonnullRefPtr<AST::Node>> nodes;
Vector<AST::Position> positions;
auto start_position = peek().position.value_or(empty_position());
@@ -1120,7 +1120,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_case_clause()
ErrorOr<Parser::CaseItemsResult> Parser::parse_case_list()
{
// Just a list of words split by '|', delimited by ')'
- NonnullRefPtrVector<AST::Node> nodes;
+ Vector<NonnullRefPtr<AST::Node>> nodes;
Vector<AST::Position> pipes;
for (;;) {
@@ -1291,7 +1291,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_compound_list()
ErrorOr<RefPtr<AST::Node>> Parser::parse_term()
{
- NonnullRefPtrVector<AST::Node> nodes;
+ Vector<NonnullRefPtr<AST::Node>> nodes;
Vector<AST::Position> positions;
auto start_position = peek().position.value_or(empty_position());
@@ -1381,7 +1381,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_for_clause()
RefPtr<AST::Node> Parser::parse_word_list()
{
- NonnullRefPtrVector<AST::Node> nodes;
+ Vector<NonnullRefPtr<AST::Node>> nodes;
auto start_position = peek().position.value_or(empty_position());
@@ -1568,7 +1568,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_word()
}
if (!node) {
- NonnullRefPtrVector<AST::Node> arguments;
+ Vector<NonnullRefPtr<AST::Node>> arguments;
arguments.append(make_ref_counted<AST::BarewordLiteral>(
token.position.value_or(empty_position()),
x.parameter));
@@ -1787,7 +1787,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_simple_command()
auto start_position = peek().position.value_or(empty_position());
Vector<String> definitions;
- NonnullRefPtrVector<AST::Node> nodes;
+ Vector<NonnullRefPtr<AST::Node>> nodes;
for (;;) {
if (auto io_redirect = TRY(parse_io_redirect()))
@@ -1858,7 +1858,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_simple_command()
// "substitute_aliases"sv,
// empty_position(),
// },
- // NonnullRefPtrVector<AST::Node> { *new_word },
+ // Vector<NonnullRefPtr<AST::Node>> { *new_word },
// Optional<AST::Position> {});
// }
diff --git a/Userland/Shell/PosixParser.h b/Userland/Shell/PosixParser.h
index 06a79426d9..a45a0cbc4a 100644
--- a/Userland/Shell/PosixParser.h
+++ b/Userland/Shell/PosixParser.h
@@ -63,7 +63,7 @@ private:
struct CaseItemsResult {
Vector<AST::Position> pipe_positions;
- NonnullRefPtrVector<AST::Node> nodes;
+ Vector<NonnullRefPtr<AST::Node>> nodes;
};
ErrorOr<RefPtr<AST::Node>> parse_complete_command();
diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp
index b77e30b5c5..03d1bfb08a 100644
--- a/Userland/Shell/Shell.cpp
+++ b/Userland/Shell/Shell.cpp
@@ -634,9 +634,9 @@ ErrorOr<RefPtr<Job>> Shell::run_command(const AST::Command& command)
}
// Resolve redirections.
- NonnullRefPtrVector<AST::Rewiring> rewirings;
+ Vector<NonnullRefPtr<AST::Rewiring>> rewirings;
auto resolve_redirection = [&](auto& redirection) -> ErrorOr<void> {
- auto rewiring = TRY(redirection.apply());
+ auto rewiring = TRY(redirection->apply());
if (rewiring->fd_action != AST::Rewiring::Close::ImmediatelyCloseNew)
rewirings.append(*rewiring);
@@ -675,18 +675,18 @@ ErrorOr<RefPtr<Job>> Shell::run_command(const AST::Command& command)
auto apply_rewirings = [&]() -> ErrorOr<void> {
for (auto& rewiring : rewirings) {
- dbgln_if(SH_DEBUG, "in {}<{}>, dup2({}, {})", command.argv.is_empty() ? "(<Empty>)"sv : command.argv[0], getpid(), rewiring.old_fd, rewiring.new_fd);
- int rc = dup2(rewiring.old_fd, rewiring.new_fd);
+ dbgln_if(SH_DEBUG, "in {}<{}>, dup2({}, {})", command.argv.is_empty() ? "(<Empty>)"sv : command.argv[0], getpid(), rewiring->old_fd, rewiring->new_fd);
+ int rc = dup2(rewiring->old_fd, rewiring->new_fd);
if (rc < 0)
return Error::from_syscall("dup2"sv, rc);
- // {new,old}_fd is closed via the `fds` collector, but rewiring.other_pipe_end->{new,old}_fd
+ // {new,old}_fd is closed via the `fds` collector, but rewiring->other_pipe_end->{new,old}_fd
// isn't yet in that collector when the first child spawns.
- if (rewiring.other_pipe_end) {
- if (rewiring.fd_action == AST::Rewiring::Close::RefreshNew) {
- if (rewiring.other_pipe_end && close(rewiring.other_pipe_end->new_fd) < 0)
+ if (rewiring->other_pipe_end) {
+ if (rewiring->fd_action == AST::Rewiring::Close::RefreshNew) {
+ if (rewiring->other_pipe_end && close(rewiring->other_pipe_end->new_fd) < 0)
perror("close other pipe end");
- } else if (rewiring.fd_action == AST::Rewiring::Close::RefreshOld) {
- if (rewiring.other_pipe_end && close(rewiring.other_pipe_end->old_fd) < 0)
+ } else if (rewiring->fd_action == AST::Rewiring::Close::RefreshOld) {
+ if (rewiring->other_pipe_end && close(rewiring->other_pipe_end->old_fd) < 0)
perror("close other pipe end");
}
}
@@ -714,7 +714,7 @@ ErrorOr<RefPtr<Job>> Shell::run_command(const AST::Command& command)
SavedFileDescriptors fds { rewirings };
for (auto& rewiring : rewirings)
- TRY(Core::System::dup2(rewiring.old_fd, rewiring.new_fd));
+ TRY(Core::System::dup2(rewiring->old_fd, rewiring->new_fd));
if (int local_return_code = 0; invoke_function(command, local_return_code)) {
last_return_code = local_return_code;
@@ -1001,7 +1001,7 @@ void Shell::run_tail(RefPtr<Job> job)
}
}
-NonnullRefPtrVector<Job> Shell::run_commands(Vector<AST::Command>& commands)
+Vector<NonnullRefPtr<Job>> Shell::run_commands(Vector<AST::Command>& commands)
{
if (m_error != ShellError::None) {
possibly_print_error();
@@ -1010,7 +1010,7 @@ NonnullRefPtrVector<Job> Shell::run_commands(Vector<AST::Command>& commands)
return {};
}
- NonnullRefPtrVector<Job> spawned_jobs;
+ Vector<NonnullRefPtr<Job>> spawned_jobs;
for (auto& command : commands) {
if constexpr (SH_DEBUG) {
@@ -1018,13 +1018,13 @@ NonnullRefPtrVector<Job> Shell::run_commands(Vector<AST::Command>& commands)
for (auto& arg : command.argv)
dbgln("argv: {}", arg);
for (auto& redir : command.redirections) {
- if (redir.is_path_redirection()) {
+ if (redir->is_path_redirection()) {
auto path_redir = (const AST::PathRedirection*)&redir;
dbgln("redir path '{}' <-({})-> {}", path_redir->path, (int)path_redir->direction, path_redir->fd);
- } else if (redir.is_fd_redirection()) {
+ } else if (redir->is_fd_redirection()) {
auto* fdredir = (const AST::FdRedirection*)&redir;
dbgln("redir fd {} -> {}", fdredir->old_fd, fdredir->new_fd);
- } else if (redir.is_close_redirection()) {
+ } else if (redir->is_close_redirection()) {
auto close_redir = (const AST::CloseRedirection*)&redir;
dbgln("close fd {}", close_redir->fd);
} else {
@@ -2551,7 +2551,7 @@ RefPtr<AST::Node> Shell::parse(StringView input, bool interactive, bool as_comma
auto nodes = parser.parse_as_multiple_expressions();
return make_ref_counted<AST::ListConcatenate>(
- nodes.is_empty() ? AST::Position { 0, 0, { 0, 0 }, { 0, 0 } } : nodes.first().position(),
+ nodes.is_empty() ? AST::Position { 0, 0, { 0, 0 }, { 0, 0 } } : nodes.first()->position(),
move(nodes));
}
@@ -2572,10 +2572,10 @@ void FileDescriptionCollector::add(int fd)
m_fds.append(fd);
}
-SavedFileDescriptors::SavedFileDescriptors(NonnullRefPtrVector<AST::Rewiring> const& intended_rewirings)
+SavedFileDescriptors::SavedFileDescriptors(Vector<NonnullRefPtr<AST::Rewiring>> const& intended_rewirings)
{
for (auto& rewiring : intended_rewirings) {
- int new_fd = dup(rewiring.new_fd);
+ int new_fd = dup(rewiring->new_fd);
if (new_fd < 0) {
if (errno != EBADF)
perror("dup");
@@ -2589,7 +2589,7 @@ SavedFileDescriptors::SavedFileDescriptors(NonnullRefPtrVector<AST::Rewiring> co
auto rc = fcntl(new_fd, F_SETFD, flags | FD_CLOEXEC);
VERIFY(rc == 0);
- m_saves.append({ rewiring.new_fd, new_fd });
+ m_saves.append({ rewiring->new_fd, new_fd });
m_collector.add(new_fd);
}
}
diff --git a/Userland/Shell/Shell.h b/Userland/Shell/Shell.h
index 9d01900823..bb4b05bf0e 100644
--- a/Userland/Shell/Shell.h
+++ b/Userland/Shell/Shell.h
@@ -152,11 +152,11 @@ public:
Optional<RunnablePath> runnable_path_for(StringView);
Optional<DeprecatedString> help_path_for(Vector<RunnablePath> visited, RunnablePath const& runnable_path);
ErrorOr<RefPtr<Job>> run_command(const AST::Command&);
- NonnullRefPtrVector<Job> run_commands(Vector<AST::Command>&);
+ Vector<NonnullRefPtr<Job>> run_commands(Vector<AST::Command>&);
bool run_file(DeprecatedString const&, bool explicitly_invoked = true);
- ErrorOr<bool> run_builtin(const AST::Command&, NonnullRefPtrVector<AST::Rewiring> const&, int& retval);
+ ErrorOr<bool> run_builtin(const AST::Command&, Vector<NonnullRefPtr<AST::Rewiring>> const&, int& retval);
bool has_builtin(StringView) const;
- ErrorOr<RefPtr<AST::Node>> run_immediate_function(StringView name, AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const&);
+ ErrorOr<RefPtr<AST::Node>> run_immediate_function(StringView name, AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const&);
static bool has_immediate_function(StringView);
void block_on_job(RefPtr<Job>);
void block_on_pipeline(RefPtr<AST::Pipeline>);
@@ -423,13 +423,13 @@ private:
virtual void custom_event(Core::CustomEvent&) override;
#define __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(name) \
- ErrorOr<RefPtr<AST::Node>> immediate_##name(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const&);
+ ErrorOr<RefPtr<AST::Node>> immediate_##name(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const&);
ENUMERATE_SHELL_IMMEDIATE_FUNCTIONS();
#undef __ENUMERATE_SHELL_IMMEDIATE_FUNCTION
- ErrorOr<RefPtr<AST::Node>> immediate_length_impl(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const&, bool across);
+ ErrorOr<RefPtr<AST::Node>> immediate_length_impl(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const&, bool across);
#define __ENUMERATE_SHELL_BUILTIN(builtin) \
ErrorOr<int> builtin_##builtin(Main::Arguments);
@@ -460,7 +460,7 @@ private:
HashMap<DeprecatedString, ShellFunction> m_functions;
NonnullOwnPtrVector<LocalFrame> m_local_frames;
Promise::List m_active_promises;
- NonnullRefPtrVector<AST::Redirection> m_global_redirections;
+ Vector<NonnullRefPtr<AST::Redirection>> m_global_redirections;
HashMap<DeprecatedString, DeprecatedString> m_aliases;
bool m_is_interactive { true };
diff --git a/Userland/Shell/SyntaxHighlighter.cpp b/Userland/Shell/SyntaxHighlighter.cpp
index 4ebe9bb127..2172f740d0 100644
--- a/Userland/Shell/SyntaxHighlighter.cpp
+++ b/Userland/Shell/SyntaxHighlighter.cpp
@@ -421,7 +421,7 @@ private:
{
for (auto& entry : node->entries()) {
ScopedValueRollback first_in_command { m_is_first_in_command };
- entry.visit(*this);
+ entry->visit(*this);
}
for (auto& position : node->separator_positions()) {
diff --git a/Userland/Utilities/test-pthread.cpp b/Userland/Utilities/test-pthread.cpp
index 52404086d7..5958acbb1c 100644
--- a/Userland/Utilities/test-pthread.cpp
+++ b/Userland/Utilities/test-pthread.cpp
@@ -20,7 +20,7 @@ static ErrorOr<void> test_once()
static Vector<int> v;
v.clear();
pthread_once_t once = PTHREAD_ONCE_INIT;
- NonnullRefPtrVector<Threading::Thread, threads_count> threads;
+ Vector<NonnullRefPtr<Threading::Thread>, threads_count> threads;
for (size_t i = 0; i < threads_count; i++) {
threads.unchecked_append(TRY(Threading::Thread::try_create([&] {
@@ -29,12 +29,12 @@ static ErrorOr<void> test_once()
sleep(1);
});
})));
- threads.last().start();
+ threads.last()->start();
}
// clang-format off
// It wants to put [[maybe_unused]] on its own line, for some reason.
for (auto& thread : threads)
- [[maybe_unused]] auto res = thread.join();
+ [[maybe_unused]] auto res = thread->join();
// clang-format on
VERIFY(v.size() == 1);
@@ -48,7 +48,7 @@ static ErrorOr<void> test_mutex()
constexpr size_t num_times = 100;
Vector<int> v;
- NonnullRefPtrVector<Threading::Thread, threads_count> threads;
+ Vector<NonnullRefPtr<Threading::Thread>, threads_count> threads;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
for (size_t i = 0; i < threads_count; i++) {
@@ -62,12 +62,12 @@ static ErrorOr<void> test_mutex()
}
return 0;
})));
- threads.last().start();
+ threads.last()->start();
}
// clang-format off
// It wants to put [[maybe_unused]] on its own line, for some reason.
for (auto& thread : threads)
- [[maybe_unused]] auto res = thread.join();
+ [[maybe_unused]] auto res = thread->join();
// clang-format on
VERIFY(v.size() == threads_count * num_times);
@@ -83,7 +83,7 @@ static ErrorOr<void> test_semaphore_as_lock()
constexpr size_t num_times = 100;
Vector<int> v;
- NonnullRefPtrVector<Threading::Thread, threads_count> threads;
+ Vector<NonnullRefPtr<Threading::Thread>, threads_count> threads;
sem_t semaphore;
sem_init(&semaphore, 0, 1);
@@ -98,12 +98,12 @@ static ErrorOr<void> test_semaphore_as_lock()
}
return 0;
})));
- threads.last().start();
+ threads.last()->start();
}
// clang-format off
// It wants to put [[maybe_unused]] on its own line, for some reason.
for (auto& thread : threads)
- [[maybe_unused]] auto res = thread.join();
+ [[maybe_unused]] auto res = thread->join();
// clang-format on
VERIFY(v.size() == threads_count * num_times);
@@ -148,7 +148,7 @@ static ErrorOr<void> test_semaphore_nonbinary()
constexpr size_t threads_count = 10;
constexpr size_t num_times = 100;
- NonnullRefPtrVector<Threading::Thread, threads_count> threads;
+ Vector<NonnullRefPtr<Threading::Thread>, threads_count> threads;
sem_t semaphore;
sem_init(&semaphore, 0, num);
@@ -169,12 +169,12 @@ static ErrorOr<void> test_semaphore_nonbinary()
}
return 0;
})));
- threads.last().start();
+ threads.last()->start();
}
// clang-format off
// It wants to put [[maybe_unused]] on its own line, for some reason.
for (auto& thread : threads)
- [[maybe_unused]] auto res = thread.join();
+ [[maybe_unused]] auto res = thread->join();
// clang-format on
VERIFY(value.load() == 0);