diff --git a/Kernel/Bus/PCI/Access.cpp b/Kernel/Bus/PCI/Access.cpp index 322471a9292..5a0318f42f1 100644 --- a/Kernel/Bus/PCI/Access.cpp +++ b/Kernel/Bus/PCI/Access.cpp @@ -183,7 +183,7 @@ ErrorOr Access::fast_enumerate(Function& 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 device_identifiers; + Vector> device_identifiers; { SpinlockLocker locker(m_access_lock); VERIFY(!m_device_identifiers.is_empty()); @@ -198,10 +198,11 @@ ErrorOr Access::fast_enumerate(Function& 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 4ee85407716..795e02bfaa5 100644 --- a/Kernel/Bus/PCI/Access.h +++ b/Kernel/Bus/PCI/Access.h @@ -62,6 +62,6 @@ private: mutable Spinlock m_scan_lock {}; HashMap> m_host_controllers; - NonnullRefPtrVector m_device_identifiers; + Vector> m_device_identifiers; }; } diff --git a/Kernel/Memory/MemoryManager.cpp b/Kernel/Memory/MemoryManager.cpp index 8dd49c1b99e..ad5b14365d5 100644 --- a/Kernel/Memory/MemoryManager.cpp +++ b/Kernel/Memory/MemoryManager.cpp @@ -785,18 +785,18 @@ ErrorOr> MemoryManager::allocate_dma_buffer_page(S return allocate_dma_buffer_page(name, access, dma_buffer_page); } -ErrorOr> MemoryManager::allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access, NonnullRefPtrVector& dma_buffer_pages) +ErrorOr> MemoryManager::allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access, Vector>& 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> MemoryManager::allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access) { VERIFY(!(size % PAGE_SIZE)); - NonnullRefPtrVector dma_buffer_pages; + Vector> dma_buffer_pages; return allocate_dma_buffer_pages(size, name, access, dma_buffer_pages); } @@ -1010,12 +1010,12 @@ ErrorOr> MemoryManager::allocate_physical_page(Shoul }); } -ErrorOr> MemoryManager::allocate_contiguous_physical_pages(size_t size) +ErrorOr>> MemoryManager::allocate_contiguous_physical_pages(size_t size) { VERIFY(!(size % PAGE_SIZE)); size_t page_count = ceil_div(size, static_cast(PAGE_SIZE)); - auto physical_pages = TRY(m_global_data.with([&](auto& global_data) -> ErrorOr> { + auto physical_pages = TRY(m_global_data.with([&](auto& global_data) -> ErrorOr>> { // 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> 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 10537c8064e..8ec09e9786c 100644 --- a/Kernel/Memory/MemoryManager.h +++ b/Kernel/Memory/MemoryManager.h @@ -166,13 +166,13 @@ public: NonnullRefPtr allocate_committed_physical_page(Badge, ShouldZeroFill = ShouldZeroFill::Yes); ErrorOr> allocate_physical_page(ShouldZeroFill = ShouldZeroFill::Yes, bool* did_purge = nullptr); - ErrorOr> allocate_contiguous_physical_pages(size_t size); + ErrorOr>> allocate_contiguous_physical_pages(size_t size); void deallocate_physical_page(PhysicalAddress); ErrorOr> allocate_contiguous_kernel_region(size_t, StringView name, Region::Access access, Region::Cacheable = Region::Cacheable::Yes); ErrorOr> allocate_dma_buffer_page(StringView name, Memory::Region::Access access, RefPtr& dma_buffer_page); ErrorOr> allocate_dma_buffer_page(StringView name, Memory::Region::Access access); - ErrorOr> allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access, NonnullRefPtrVector& dma_buffer_pages); + ErrorOr> allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access, Vector>& dma_buffer_pages); ErrorOr> allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access); ErrorOr> allocate_kernel_region(size_t, StringView name, Region::Access access, AllocationStrategy strategy = AllocationStrategy::Reserve, Region::Cacheable = Region::Cacheable::Yes); ErrorOr> 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 6437f96d908..26590ff3f1e 100644 --- a/Kernel/Memory/PhysicalRegion.cpp +++ b/Kernel/Memory/PhysicalRegion.cpp @@ -75,7 +75,7 @@ OwnPtr PhysicalRegion::try_take_pages_from_beginning(size_t page return try_create(taken_lower, taken_upper); } -NonnullRefPtrVector PhysicalRegion::take_contiguous_free_pages(size_t count) +Vector> 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 PhysicalRegion::take_contiguous_free_pages(siz if (!page_base.has_value()) return {}; - NonnullRefPtrVector physical_pages; + Vector> 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 31ffdba97b8..0a124b97409 100644 --- a/Kernel/Memory/PhysicalRegion.h +++ b/Kernel/Memory/PhysicalRegion.h @@ -34,7 +34,7 @@ public: OwnPtr try_take_pages_from_beginning(size_t); RefPtr take_free_page(); - NonnullRefPtrVector take_contiguous_free_pages(size_t count); + Vector> 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 042ea248adf..416ada19465 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(command_table.command_fis), 0, 64); auto& fis = *(volatile FIS::HostToDevice::Register*)command_table.command_fis; @@ -497,7 +497,7 @@ Optional AHCIPort::prepare_and_set_scatter_li VERIFY(m_lock.is_locked()); VERIFY(request.block_count() > 0); - NonnullRefPtrVector allocated_dma_regions; + Vector> 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(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 21df462b6a4..ec63bc1cfab 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 m_dma_buffers; - NonnullRefPtrVector m_command_table_pages; + Vector> m_dma_buffers; + Vector> m_command_table_pages; RefPtr m_command_list_page; OwnPtr m_command_list_region; RefPtr m_fis_receive_page; diff --git a/Kernel/Storage/NVMe/NVMeController.cpp b/Kernel/Storage/NVMe/NVMeController.cpp index e5752380af5..7f9335dfe00 100644 --- a/Kernel/Storage/NVMe/NVMeController.cpp +++ b/Kernel/Storage/NVMe/NVMeController.cpp @@ -256,9 +256,9 @@ UNMAP_AFTER_INIT ErrorOr NVMeController::create_admin_queue(Optional i { auto qdepth = get_admin_q_dept(); OwnPtr cq_dma_region; - NonnullRefPtrVector cq_dma_pages; + Vector> cq_dma_pages; OwnPtr sq_dma_region; - NonnullRefPtrVector sq_dma_pages; + Vector> 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 NVMeController::create_admin_queue(Optional i } auto doorbell_regs = TRY(Memory::map_typed_writable(PhysicalAddress(m_bar + REG_SQ0TDBL_START))); - m_controller_regs->acq = reinterpret_cast(AK::convert_between_host_and_little_endian(cq_dma_pages.first().paddr().as_ptr())); - m_controller_regs->asq = reinterpret_cast(AK::convert_between_host_and_little_endian(sq_dma_pages.first().paddr().as_ptr())); + m_controller_regs->acq = reinterpret_cast(AK::convert_between_host_and_little_endian(cq_dma_pages.first()->paddr().as_ptr())); + m_controller_regs->asq = reinterpret_cast(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 NVMeController::create_admin_queue(Optional i UNMAP_AFTER_INIT ErrorOr NVMeController::create_io_queue(u8 qid, Optional irq) { OwnPtr cq_dma_region; - NonnullRefPtrVector cq_dma_pages; + Vector> cq_dma_pages; OwnPtr sq_dma_region; - NonnullRefPtrVector sq_dma_pages; + Vector> 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 NVMeController::create_io_queue(u8 qid, Optional< { NVMeSubmission sub {}; sub.op = OP_ADMIN_CREATE_COMPLETION_QUEUE; - sub.create_cq.prp1 = reinterpret_cast(AK::convert_between_host_and_little_endian(cq_dma_pages.first().paddr().as_ptr())); + sub.create_cq.prp1 = reinterpret_cast(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 NVMeController::create_io_queue(u8 qid, Optional< { NVMeSubmission sub {}; sub.op = OP_ADMIN_CREATE_SUBMISSION_QUEUE; - sub.create_sq.prp1 = reinterpret_cast(AK::convert_between_host_and_little_endian(sq_dma_pages.first().paddr().as_ptr())); + sub.create_sq.prp1 = reinterpret_cast(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 438c8335ef1..7b4aeaf46ba 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 rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u8 irq, u32 q_depth, OwnPtr cq_dma_region, NonnullRefPtrVector cq_dma_page, OwnPtr sq_dma_region, NonnullRefPtrVector sq_dma_page, Memory::TypedMapping db_regs) +UNMAP_AFTER_INIT NVMeInterruptQueue::NVMeInterruptQueue(NonnullOwnPtr rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u8 irq, u32 q_depth, OwnPtr cq_dma_region, Vector> cq_dma_page, OwnPtr sq_dma_region, Vector> sq_dma_page, Memory::TypedMapping 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 e92168b535c..f8b3632af24 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 rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u8 irq, u32 q_depth, OwnPtr cq_dma_region, NonnullRefPtrVector cq_dma_page, OwnPtr sq_dma_region, NonnullRefPtrVector sq_dma_page, Memory::TypedMapping db_regs); + NVMeInterruptQueue(NonnullOwnPtr rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u8 irq, u32 q_depth, OwnPtr cq_dma_region, Vector> cq_dma_page, OwnPtr sq_dma_region, Vector> sq_dma_page, Memory::TypedMapping 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 7dce2ca8c0a..e8ab70e18a6 100644 --- a/Kernel/Storage/NVMe/NVMePollQueue.cpp +++ b/Kernel/Storage/NVMe/NVMePollQueue.cpp @@ -10,7 +10,7 @@ #include namespace Kernel { -UNMAP_AFTER_INIT NVMePollQueue::NVMePollQueue(NonnullOwnPtr rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr cq_dma_region, NonnullRefPtrVector cq_dma_page, OwnPtr sq_dma_region, NonnullRefPtrVector sq_dma_page, Memory::TypedMapping db_regs) +UNMAP_AFTER_INIT NVMePollQueue::NVMePollQueue(NonnullOwnPtr rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr cq_dma_region, Vector> cq_dma_page, OwnPtr sq_dma_region, Vector> sq_dma_page, Memory::TypedMapping 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 f1e24402c97..4080d6c76f2 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 rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr cq_dma_region, NonnullRefPtrVector cq_dma_page, OwnPtr sq_dma_region, NonnullRefPtrVector sq_dma_page, Memory::TypedMapping db_regs); + NVMePollQueue(NonnullOwnPtr rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr cq_dma_region, Vector> cq_dma_page, OwnPtr sq_dma_region, Vector> sq_dma_page, Memory::TypedMapping 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 2b60aac22aa..04408f4dc72 100644 --- a/Kernel/Storage/NVMe/NVMeQueue.cpp +++ b/Kernel/Storage/NVMe/NVMeQueue.cpp @@ -12,7 +12,7 @@ #include namespace Kernel { -ErrorOr> NVMeQueue::try_create(u16 qid, Optional irq, u32 q_depth, OwnPtr cq_dma_region, NonnullRefPtrVector cq_dma_page, OwnPtr sq_dma_region, NonnullRefPtrVector sq_dma_page, Memory::TypedMapping db_regs) +ErrorOr> NVMeQueue::try_create(u16 qid, Optional irq, u32 q_depth, OwnPtr cq_dma_region, Vector> cq_dma_page, OwnPtr sq_dma_region, Vector> sq_dma_page, Memory::TypedMapping 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 rw_dma_page; @@ -25,7 +25,7 @@ ErrorOr> NVMeQueue::try_create(u16 qid, Optional rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr cq_dma_region, NonnullRefPtrVector cq_dma_page, OwnPtr sq_dma_region, NonnullRefPtrVector sq_dma_page, Memory::TypedMapping db_regs) +UNMAP_AFTER_INIT NVMeQueue::NVMeQueue(NonnullOwnPtr rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr cq_dma_region, Vector> cq_dma_page, OwnPtr sq_dma_region, Vector> sq_dma_page, Memory::TypedMapping 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 8b930ac618a..d3f0b8dc6bb 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 { public: - static ErrorOr> try_create(u16 qid, Optional irq, u32 q_depth, OwnPtr cq_dma_region, NonnullRefPtrVector cq_dma_page, OwnPtr sq_dma_region, NonnullRefPtrVector sq_dma_page, Memory::TypedMapping db_regs); + static ErrorOr> try_create(u16 qid, Optional irq, u32 q_depth, OwnPtr cq_dma_region, Vector> cq_dma_page, OwnPtr sq_dma_region, Vector> sq_dma_page, Memory::TypedMapping 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 rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr cq_dma_region, NonnullRefPtrVector cq_dma_page, OwnPtr sq_dma_region, NonnullRefPtrVector sq_dma_page, Memory::TypedMapping db_regs); + NVMeQueue(NonnullOwnPtr rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr cq_dma_region, Vector> cq_dma_page, OwnPtr sq_dma_region, Vector> sq_dma_page, Memory::TypedMapping db_regs); private: bool cqe_available(); @@ -71,10 +71,10 @@ private: u32 m_qdepth {}; Spinlock m_sq_lock {}; OwnPtr m_cq_dma_region; - NonnullRefPtrVector m_cq_dma_page; + Vector> m_cq_dma_page; Span m_sqe_array; OwnPtr m_sq_dma_region; - NonnullRefPtrVector m_sq_dma_page; + Vector> m_sq_dma_page; Span m_cqe_array; Memory::TypedMapping m_db_regs; NonnullRefPtr 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 661b8711a18..aa3952fcd03 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 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 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_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 sequence_type; for (auto& type : types) { - if (type.name() == "sequence") { - sequence_type = verify_cast(type); + if (type->name() == "sequence") { + sequence_type = verify_cast(*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 record_type; for (auto& type : types) { - if (type.name() == "record") { - record_type = verify_cast(type); + if (type->name() == "record") { + record_type = verify_cast(*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 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 types; + Vector> types; // 4. Let optionalityValues be an optionality list. Vector 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(\"{}\", {}, NonnullRefPtrVector {{", type.name(), type.is_nullable()); + builder.appendff("make_ref_counted(\"{}\", {}, Vector> {{", 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(\"{}\", {}, NonnullRefPtrVector {{", type.name(), type.is_nullable()); + builder.appendff("make_ref_counted(\"{}\", {}, Vector> {{", 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 { "sv); + types_builder.append("Vector> { "sv); StringBuilder optionality_builder; optionality_builder.append("Vector { "sv); diff --git a/Tests/LibSQL/TestSqlStatementParser.cpp b/Tests/LibSQL/TestSqlStatementParser.cpp index e42819a295e..335df91a01c 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(*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(*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 665219db9f9..91e51154605 100644 --- a/Userland/Applets/ResourceGraph/main.cpp +++ b/Userland/Applets/ResourceGraph/main.cpp @@ -257,7 +257,7 @@ ErrorOr serenity_main(Main::Arguments arguments) return 1; } - NonnullRefPtrVector applet_windows; + Vector> applet_windows; auto create_applet = [&](GraphType graph_type, StringView spec) -> ErrorOr { auto parts = spec.split_view(','); diff --git a/Userland/Applications/Assistant/Providers.cpp b/Userland/Applications/Assistant/Providers.cpp index 89b740857e2..1a0c034bca4 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)> on_complete) +void AppProvider::query(DeprecatedString const& query, Function>)> on_complete) { if (query.starts_with('=') || query.starts_with('$')) return; - NonnullRefPtrVector results; + Vector> results; Desktop::AppFile::for_each([&](NonnullRefPtr app_file) { auto query_and_arguments = query.split_limit(' ', 2); @@ -83,7 +83,7 @@ void AppProvider::query(DeprecatedString const& query, Function)> on_complete) +void CalculatorProvider::query(DeprecatedString const& query, Function>)> on_complete) { if (!query.starts_with('=')) return; @@ -108,7 +108,7 @@ void CalculatorProvider::query(DeprecatedString const& query, Function results; + Vector> 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)> on_complete) +void FileProvider::query(DeprecatedString const& query, Function>)> on_complete) { build_filesystem_cache(); if (m_fuzzy_match_work) m_fuzzy_match_work->cancel(); - m_fuzzy_match_work = Threading::BackgroundAction>>::construct( - [this, query](auto& task) -> Optional> { - NonnullRefPtrVector results; + m_fuzzy_match_work = Threading::BackgroundAction>>>::construct( + [this, query](auto& task) -> Optional>> { + Vector> 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)> on_complete) +void TerminalProvider::query(DeprecatedString const& query, Function>)> on_complete) { if (!query.starts_with('$')) return; auto command = query.substring(1).trim_whitespace(); - NonnullRefPtrVector results; + Vector> results; results.append(adopt_ref(*new TerminalResult(move(command)))); on_complete(move(results)); } -void URLProvider::query(DeprecatedString const& query, Function)> on_complete) +void URLProvider::query(DeprecatedString const& query, Function>)> on_complete) { if (query.is_empty() || query.starts_with('=') || query.starts_with('$')) return; @@ -232,7 +232,7 @@ void URLProvider::query(DeprecatedString const& query, Function results; + Vector> 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 cef555dceb2..3d1daba6c23 100644 --- a/Userland/Applications/Assistant/Providers.h +++ b/Userland/Applications/Assistant/Providers.h @@ -134,28 +134,28 @@ class Provider : public RefCounted { public: virtual ~Provider() = default; - virtual void query(DeprecatedString const&, Function)> on_complete) = 0; + virtual void query(DeprecatedString const&, Function>)> on_complete) = 0; }; class AppProvider final : public Provider { public: - void query(DeprecatedString const& query, Function)> on_complete) override; + void query(DeprecatedString const& query, Function>)> on_complete) override; }; class CalculatorProvider final : public Provider { public: - void query(DeprecatedString const& query, Function)> on_complete) override; + void query(DeprecatedString const& query, Function>)> on_complete) override; }; class FileProvider final : public Provider { public: FileProvider(); - void query(DeprecatedString const& query, Function)> on_complete) override; + void query(DeprecatedString const& query, Function>)> on_complete) override; void build_filesystem_cache(); private: - RefPtr>>> m_fuzzy_match_work; + RefPtr>>>> m_fuzzy_match_work; bool m_building_cache { false }; Vector m_full_path_cache; Queue m_work_queue; @@ -163,12 +163,12 @@ private: class TerminalProvider final : public Provider { public: - void query(DeprecatedString const& query, Function)> on_complete) override; + void query(DeprecatedString const& query, Function>)> on_complete) override; }; class URLProvider final : public Provider { public: - void query(DeprecatedString const& query, Function)> on_complete) override; + void query(DeprecatedString const& query, Function>)> on_complete) override; }; } diff --git a/Userland/Applications/Assistant/main.cpp b/Userland/Applications/Assistant/main.cpp index 83a928c9c5e..04129cfbcb2 100644 --- a/Userland/Applications/Assistant/main.cpp +++ b/Userland/Applications/Assistant/main.cpp @@ -36,7 +36,7 @@ namespace Assistant { struct AppState { Optional selected_index; - NonnullRefPtrVector results; + Vector> results; size_t visible_result_count { 0 }; Threading::Mutex lock; @@ -84,7 +84,7 @@ public: { } - Function)> on_new_results; + Function>)> 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>(results); + result_array[i] = make>>(results); } on_result_cache_updated(); }); @@ -142,7 +142,7 @@ private: Array, ProviderCount> m_providers; Threading::Mutex m_mutex; - HashMap>, ProviderCount>> m_result_cache; + HashMap>>, ProviderCount>> m_result_cache; }; } @@ -211,7 +211,7 @@ ErrorOr 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 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(); - 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 6e9514b95b0..716d88d64e5 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 461e615ebf8..99bd845cccd 100644 --- a/Userland/Applications/Browser/BookmarksBarWidget.h +++ b/Userland/Applications/Browser/BookmarksBarWidget.h @@ -66,7 +66,7 @@ private: RefPtr m_context_menu_default_action; DeprecatedString m_context_menu_url; - NonnullRefPtrVector m_bookmarks; + Vector> m_bookmarks; int m_last_visible_index { -1 }; }; diff --git a/Userland/Applications/Browser/WindowActions.cpp b/Userland/Applications/Browser/WindowActions.cpp index ce2b9478cb8..95a3d0e6f5a 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 25a3a0f0ee4..79416996753 100644 --- a/Userland/Applications/Browser/WindowActions.h +++ b/Userland/Applications/Browser/WindowActions.h @@ -38,7 +38,7 @@ private: RefPtr m_create_new_window_action; RefPtr m_next_tab_action; RefPtr m_previous_tab_action; - NonnullRefPtrVector m_tab_actions; + Vector> m_tab_actions; RefPtr m_about_action; RefPtr m_show_bookmarks_bar_action; RefPtr m_vertical_tabs_action; diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp index 3d7f684dc07..8c1713ba55b 100644 --- a/Userland/Applications/FileManager/DirectoryView.cpp +++ b/Userland/Applications/FileManager/DirectoryView.cpp @@ -52,21 +52,21 @@ NonnullRefPtr LauncherHandler::create_launch_action(Function DirectoryView::get_default_launch_handler(NonnullRefPtrVector const& handlers) +RefPtr DirectoryView::get_default_launch_handler(Vector> 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 DirectoryView::get_default_launch_handler(NonnullRefPtrV return {}; } -NonnullRefPtrVector DirectoryView::get_launch_handlers(URL const& url) +Vector> DirectoryView::get_launch_handlers(URL const& url) { - NonnullRefPtrVector handlers; + Vector> handlers; for (auto& h : Desktop::Launcher::get_handlers_with_details_for_url(url)) { handlers.append(adopt_ref(*new LauncherHandler(h))); } return handlers; } -NonnullRefPtrVector DirectoryView::get_launch_handlers(DeprecatedString const& path) +Vector> 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 8f1a0070ec7..b7e4ef9e4ca 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 get_default_launch_handler(NonnullRefPtrVector const& handlers); - static NonnullRefPtrVector get_launch_handlers(URL const& url); - static NonnullRefPtrVector get_launch_handlers(DeprecatedString const& path); + static RefPtr get_default_launch_handler(Vector> const& handlers); + static Vector> get_launch_handlers(URL const& url); + static Vector> get_launch_handlers(DeprecatedString const& path); void refresh(); diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index de36bdec3a2..341c2103c22 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -66,7 +66,7 @@ static void do_create_archive(Vector const& selected_file_path static void do_set_wallpaper(DeprecatedString const& file_path, GUI::Window* window); static void do_unzip_archive(Vector const& selected_file_paths, GUI::Window* window); static void show_properties(DeprecatedString const& container_dir_path, DeprecatedString const& path, Vector const& selected, GUI::Window* window); -static bool add_launch_handler_actions_to_menu(RefPtr& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr& default_action, NonnullRefPtrVector& current_file_launch_handlers); +static bool add_launch_handler_actions_to_menu(RefPtr& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr& default_action, Vector>& current_file_launch_handlers); ErrorOr 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& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr& default_action, NonnullRefPtrVector& current_file_launch_handlers) +bool add_launch_handler_actions_to_menu(RefPtr& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr& default_action, Vector>& 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& 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 run_in_desktop_mode() TRY(desktop_context_menu->try_add_action(properties_action)); RefPtr file_context_menu; - NonnullRefPtrVector current_file_handlers; + Vector> current_file_handlers; RefPtr 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 run_in_windowed_mode(DeprecatedString const& initial_location, Depr TRY(tree_view_directory_context_menu->try_add_action(properties_action)); RefPtr file_context_menu; - NonnullRefPtrVector current_file_handlers; + Vector> current_file_handlers; RefPtr 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 f9aff7609c8..6c5457e58d4 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 ed41e8d4fb8..cfd5a177543 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 folder_stack; + Vector> 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 91a4cb6259c..66e721710e7 100644 --- a/Userland/Applications/Mail/AccountHolder.h +++ b/Userland/Applications/Mail/AccountHolder.h @@ -34,7 +34,7 @@ public: m_mailboxes.append(move(mailbox)); } - NonnullRefPtrVector const& mailboxes() const { return m_mailboxes; } + Vector> const& mailboxes() const { return m_mailboxes; } DeprecatedString const& name() const { return m_name; } private: @@ -44,7 +44,7 @@ private: } DeprecatedString m_name; - NonnullRefPtrVector m_mailboxes; + Vector> m_mailboxes; }; class MailboxNode final : public BaseNode { @@ -66,7 +66,7 @@ public: void set_parent(NonnullRefPtr parent) { m_parent = parent; } bool has_children() const { return !m_children.is_empty(); } - NonnullRefPtrVector const& children() const { return m_children; } + Vector> const& children() const { return m_children; } void add_child(NonnullRefPtr child) { m_children.append(child); } private: @@ -81,7 +81,7 @@ private: IMAP::ListItem m_mailbox; DeprecatedString m_display_name; - NonnullRefPtrVector m_children; + Vector> m_children; RefPtr m_parent; }; @@ -96,7 +96,7 @@ public: void add_account_with_name_and_mailboxes(DeprecatedString, Vector const&); - NonnullRefPtrVector const& accounts() const { return m_accounts; } + Vector> 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 m_accounts; + Vector> m_accounts; RefPtr m_mailbox_tree_model; }; diff --git a/Userland/Applications/Mail/MailboxTreeModel.cpp b/Userland/Applications/Mail/MailboxTreeModel.cpp index 44b16b6ea2d..583021941e6 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 2884aae6810..5d3f632e581 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 parent_siblings = (parent->parent ? parent->parent->children : m_outline->children); + Vector> 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(i), index.column(), parent.ptr()); } diff --git a/Userland/Applications/Piano/TrackControlsWidget.h b/Userland/Applications/Piano/TrackControlsWidget.h index 6076e8c2310..0ac0cea172f 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 m_parameter_widgets; + Vector> m_parameter_widgets; }; diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp index b9483834842..ab53535f736 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().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(), layer.display_bitmap(), layer.rect(), (float)layer.opacity_percent() / 100.0f); + auto target = dest_rect.to_type().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(), layer->display_bitmap(), layer->rect(), (float)layer->opacity_percent() / 100.0f); } } @@ -126,17 +126,17 @@ ErrorOr Image::serialize_as_json(JsonObjectSerializer& 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 Image::export_qoi_to_file(NonnullOwnPtr stream) const void Image::add_layer(NonnullRefPtr 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 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 Image::merge_layers(LayerMergeMode layer_merge_mode) if (m_layers.size() < 2) return {}; - NonnullRefPtrVector new_layers; + Vector> 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 Image::merge_layers(LayerMergeMode layer_merge_mode) painter.blit(bottom_layer->location() - merged_layer->location(), bottom_layer->display_bitmap(), bottom_layer->rect(), static_cast(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(layer.opacity_percent()) / 100.0f); + painter.blit(layer->location() - merged_layer->location(), layer->display_bitmap(), layer->rect(), static_cast(layer->opacity_percent()) / 100.0f); } TRY(new_layers.try_append(merged_layer)); @@ -421,7 +421,7 @@ ErrorOr Image::merge_active_layer(NonnullRefPtr const& layer, Layer Optional> 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 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 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 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 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 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 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 Image::nonempty_content_bounding_rect() const Optional 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 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 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 a15e3baf4f5..86644f0bca9 100644 --- a/Userland/Applications/PixelPaint/Image.h +++ b/Userland/Applications/PixelPaint/Image.h @@ -126,7 +126,7 @@ private: ErrorOr merge_active_layer(NonnullRefPtr const&, LayerMergeDirection); Gfx::IntSize m_size; - NonnullRefPtrVector m_layers; + Vector> m_layers; HashTable m_clients; diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index dc774d68db6..598e112418b 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 ImageEditor::save_project_to_file(NonnullOwnPtr 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 2ea71b84ba7..8951b5f4e06 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 const& guides() const { return m_guides; } + Vector> const& guides() const { return m_guides; } bool guide_visibility() { return m_show_guides; } void set_guide_visibility(bool show_guides); Function on_set_guide_visibility; @@ -168,7 +168,7 @@ private: DeprecatedString m_path; DeprecatedString m_title; - NonnullRefPtrVector m_guides; + Vector> 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 ac1b5f1073a..fcc45b42aae 100644 --- a/Userland/Applications/PixelPaint/Tools/GuideTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/GuideTool.cpp @@ -24,15 +24,15 @@ RefPtr 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 e8488104d9f..25484f39515 100644 --- a/Userland/Applications/PixelPaint/Tools/TextTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/TextTool.cpp @@ -30,9 +30,9 @@ void TextToolEditor::handle_keyevent(Badge, GUI::KeyEvent& event) TextEditor::keydown_event(event); } -NonnullRefPtrVector TextToolEditor::actions() +Vector> TextToolEditor::actions() { - static NonnullRefPtrVector actions = { cut_action(), copy_action(), paste_action(), undo_action(), redo_action(), select_all_action() }; + static Vector> 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 62b512a1040..60d0cb9badf 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, GUI::KeyEvent&); - NonnullRefPtrVector actions(); + Vector> actions(); protected: TextToolEditor(); diff --git a/Userland/Applications/Presenter/Slide.cpp b/Userland/Applications/Presenter/Slide.cpp index fcbed854192..8e07961a198 100644 --- a/Userland/Applications/Presenter/Slide.cpp +++ b/Userland/Applications/Presenter/Slide.cpp @@ -9,7 +9,7 @@ #include "Presentation.h" #include -Slide::Slide(NonnullRefPtrVector slide_objects, DeprecatedString title) +Slide::Slide(Vector> slide_objects, DeprecatedString title) : m_slide_objects(move(slide_objects)) , m_title(move(title)) { @@ -25,7 +25,7 @@ ErrorOr 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 slide_objects; + Vector> 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 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 8e7482b47bf..013917d3156 100644 --- a/Userland/Applications/Presenter/Slide.h +++ b/Userland/Applications/Presenter/Slide.h @@ -24,8 +24,8 @@ public: ErrorOr render(Presentation const&) const; private: - Slide(NonnullRefPtrVector slide_objects, DeprecatedString title); + Slide(Vector> slide_objects, DeprecatedString title); - NonnullRefPtrVector m_slide_objects; + Vector> m_slide_objects; DeprecatedString m_title; }; diff --git a/Userland/Applications/Spreadsheet/ConditionalFormatting.h b/Userland/Applications/Spreadsheet/ConditionalFormatting.h index bcd11d85958..d6e324d91dc 100644 --- a/Userland/Applications/Spreadsheet/ConditionalFormatting.h +++ b/Userland/Applications/Spreadsheet/ConditionalFormatting.h @@ -52,7 +52,7 @@ private: ConditionsView(); Vector* m_formats { nullptr }; - NonnullRefPtrVector m_widgets; + Vector> m_widgets; }; } diff --git a/Userland/Applications/Spreadsheet/ExportDialog.cpp b/Userland/Applications/Spreadsheet/ExportDialog.cpp index b4cfc87641d..708126ed073 100644 --- a/Userland/Applications/Spreadsheet/ExportDialog.cpp +++ b/Userland/Applications/Spreadsheet/ExportDialog.cpp @@ -202,7 +202,7 @@ ErrorOr ExportDialog::make_and_run_for(StringView mime, Core::File& file, auto export_worksheet = [&]() -> ErrorOr { 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 c2ae658235c..168cc6c914b 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(window, NonnullRefPtrVector {}, false).release_value_but_fixme_should_propagate_errors(); + auto widget = window->set_main_widget(window, Vector> {}, 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 2da65ae87d0..55a00335bce 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, DeprecatedString> ImportDialog::make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook& workbook) +ErrorOr>, 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, DeprecatedString> { + auto import_xsv = [&]() -> ErrorOr>, 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, DeprecatedString> ImportDialog::make_and_run if (result == GUI::Dialog::ExecResult::OK) { auto& reader = page.reader(); - NonnullRefPtrVector sheets; + Vector> sheets; if (reader.has_value()) { reader->parse(); @@ -209,7 +209,7 @@ ErrorOr, DeprecatedString> ImportDialog::make_and_run return DeprecatedString { "CSV Import was cancelled" }; }; - auto import_worksheet = [&]() -> ErrorOr, DeprecatedString> { + auto import_worksheet = [&]() -> ErrorOr>, 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, DeprecatedString> ImportDialog::make_and_run if (!json_value.is_array()) return DeprecatedString::formatted("Did not find a spreadsheet in {}", filename); - NonnullRefPtrVector sheets; + Vector> 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 dba25312c63..6b883e47aef 100644 --- a/Userland/Applications/Spreadsheet/ImportDialog.h +++ b/Userland/Applications/Spreadsheet/ImportDialog.h @@ -55,7 +55,7 @@ private: }; struct ImportDialog { - static ErrorOr, DeprecatedString> make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook&); + static ErrorOr>, 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 4e175e31457..7d6d006a35d 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 d0a802e1f2a..a34c855148e 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&& sheets, bool should_add_sheet_if_empty) +SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, Vector>&& sheets, bool should_add_sheet_if_empty) : m_workbook(make(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 new_sheets; + Vector> 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 new_sheets) +void SpreadsheetWidget::setup_tabs(Vector> new_sheets) { for (auto& sheet : new_sheets) { - auto& new_view = m_tab_widget->add_tab(sheet.name(), sheet); + auto& new_view = m_tab_widget->add_tab(sheet->name(), sheet); new_view.model()->on_cell_data_change = [&](auto& cell, auto& previous_data) { undo_stack().push(make(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 new_sheets; + Vector> 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) { VERIFY(m_workbook == &sheet->workbook()); - NonnullRefPtrVector new_sheets; + Vector> 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 d2ad4951718..d6f10c417e6 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&& sheets = {}, bool should_add_sheet_if_empty = true); + explicit SpreadsheetWidget(GUI::Window& window, Vector>&& sheets = {}, bool should_add_sheet_if_empty = true); - void setup_tabs(NonnullRefPtrVector new_sheets); + void setup_tabs(Vector> 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 e7add532cc5..8c85abd3324 100644 --- a/Userland/Applications/Spreadsheet/Workbook.cpp +++ b/Userland/Applications/Spreadsheet/Workbook.cpp @@ -18,7 +18,7 @@ namespace Spreadsheet { -Workbook::Workbook(NonnullRefPtrVector&& sheets, GUI::Window& parent_window) +Workbook::Workbook(Vector>&& sheets, GUI::Window& parent_window) : m_sheets(move(sheets)) , m_vm(JS::VM::create()) , m_interpreter(JS::Interpreter::create(m_vm)) diff --git a/Userland/Applications/Spreadsheet/Workbook.h b/Userland/Applications/Spreadsheet/Workbook.h index 84d394053de..b4d31e6be6e 100644 --- a/Userland/Applications/Spreadsheet/Workbook.h +++ b/Userland/Applications/Spreadsheet/Workbook.h @@ -14,7 +14,7 @@ namespace Spreadsheet { class Workbook { public: - Workbook(NonnullRefPtrVector&& sheets, GUI::Window& parent_window); + Workbook(Vector>&& sheets, GUI::Window& parent_window); ErrorOr open_file(String const& filename, Core::File&); ErrorOr write_to_file(String const& filename, Core::File&); @@ -28,8 +28,8 @@ public: bool has_sheets() const { return !m_sheets.is_empty(); } - NonnullRefPtrVector const& sheets() const { return m_sheets; } - NonnullRefPtrVector sheets() { return m_sheets; } + Vector> const& sheets() const { return m_sheets; } + Vector> sheets() { return m_sheets; } Sheet& add_sheet(StringView name) { @@ -43,7 +43,7 @@ public: JS::VM const& vm() const { return *m_vm; } private: - NonnullRefPtrVector m_sheets; + Vector> m_sheets; NonnullRefPtr m_vm; NonnullOwnPtr m_interpreter; JS::VM::InterpreterExecutionScope m_interpreter_scope; diff --git a/Userland/Applications/Spreadsheet/main.cpp b/Userland/Applications/Spreadsheet/main.cpp index d20d001b1e8..d7599cc235f 100644 --- a/Userland/Applications/Spreadsheet/main.cpp +++ b/Userland/Applications/Spreadsheet/main.cpp @@ -51,7 +51,7 @@ ErrorOr 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(*window, NonnullRefPtrVector {}, filename.is_empty())); + auto spreadsheet_widget = TRY(window->set_main_widget(*window, Vector> {}, 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 5f34a89cb45..c84da311f05 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 c9100de39fd..3c659538e2d 100644 --- a/Userland/Applications/SystemMonitor/ProcessModel.h +++ b/Userland/Applications/SystemMonitor/ProcessModel.h @@ -207,7 +207,7 @@ private: struct Process { pid_t pid; - NonnullRefPtrVector threads; + Vector> 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(i); break; } diff --git a/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.cpp b/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.cpp index 0f8ed977c95..f52b269e321 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 b800760aec0..a7509c4c7ef 100644 --- a/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.h +++ b/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.h @@ -45,7 +45,7 @@ public: private: explicit ProjectTemplatesModel(); - NonnullRefPtrVector m_templates; + Vector> m_templates; Vector m_mapping; RefPtr m_file_watcher; diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index c44145824ff..e30c23ed73b 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> 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 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> 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 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()); + editor_wrapper->editor().set_editing_engine(make()); } else { for (auto& editor_wrapper : m_all_editor_wrappers) - editor_wrapper.editor().set_editing_engine(make()); + editor_wrapper->editor().set_editing_engine(make()); } }); vim_emulation_setting_action->set_checked(false); @@ -1506,17 +1506,17 @@ ErrorOr 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 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> 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 e2f403a8f9f..d54b3754726 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 m_all_editor_wrappers; + Vector> m_all_editor_wrappers; RefPtr m_current_editor_wrapper; - NonnullRefPtrVector m_all_editor_tab_widgets; + Vector> m_all_editor_tab_widgets; RefPtr m_current_editor_tab_widget; HashMap> m_open_files; @@ -217,7 +217,7 @@ private: RefPtr m_current_editor_in_execution; RefPtr m_recent_projects_submenu { nullptr }; - NonnullRefPtrVector m_new_file_actions; + Vector> m_new_file_actions; RefPtr m_new_plain_file_action; RefPtr m_new_directory_action; diff --git a/Userland/Games/Hearts/Game.cpp b/Userland/Games/Hearts/Game.cpp index dcaafcbf428..f84646d62b9 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 deck = Cards::create_standard_deck(Cards::Shuffle::Yes).release_value_but_fixme_should_propagate_errors(); + Vector> 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 cards, Gfx::IntPoint end, Function did_finish_callback, int initial_delay_ms, int steps) +void Game::start_animation(Vector> cards, Gfx::IntPoint end, Function did_finish_callback, int initial_delay_ms, int steps) { stop_animation(); @@ -229,7 +229,7 @@ void Game::start_animation(NonnullRefPtrVector 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>(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 cards; + Vector> 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 first_player_cards; + Vector> first_player_cards; for (auto& card : m_cards_highlighted) first_player_cards.append(*card); clear_highlighted_cards(); VERIFY(first_player_cards.size() == 3); - NonnullRefPtrVector passed_cards[4]; + Vector> 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 506d50917a0..0f057669817 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 cards, Gfx::IntPoint end, Function did_finish_callback, int initial_delay_ms, int steps = 30); + void start_animation(Vector> cards, Gfx::IntPoint end, Function 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> m_cards_highlighted; Player m_players[4]; - NonnullRefPtrVector m_trick; + Vector> m_trick; Player* m_leading_player { nullptr }; u8 m_trick_number { 0 }; RefPtr m_delay_timer; diff --git a/Userland/Games/Hearts/Player.cpp b/Userland/Games/Hearts/Player.cpp index 5feb78f7e76..7a72f1063b9 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 Player::pick_cards_to_pass(PassingDirection) +Vector> Player::pick_cards_to_pass(PassingDirection) { auto sorted_hand = hand_sorted_by_fn(compare_card_value); - NonnullRefPtrVector cards; + Vector> 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 const& cards) +void Player::remove_cards(Vector> 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 9c6746728f1..2a7b576d00d 100644 --- a/Userland/Games/Hearts/Player.h +++ b/Userland/Games/Hearts/Player.h @@ -33,7 +33,7 @@ public: { } - NonnullRefPtrVector pick_cards_to_pass(PassingDirection); + Vector> pick_cards_to_pass(PassingDirection); size_t pick_lead_card(Function, Function); Optional pick_low_points_high_value_card(Optional suit = {}); Optional pick_lower_value_card(Card& other_card); @@ -45,7 +45,7 @@ public: Vector hand_sorted_by_fn(bool (*)(CardWithIndex&, CardWithIndex&)) const; void sort_hand() { quick_sort(hand, hearts_card_less); } - void remove_cards(NonnullRefPtrVector const& cards); + void remove_cards(Vector> const& cards); Vector> hand; Vector> cards_taken; diff --git a/Userland/Games/Snake/Game.cpp b/Userland/Games/Snake/Game.cpp index f7fc81900b7..782b371983a 100644 --- a/Userland/Games/Snake/Game.cpp +++ b/Userland/Games/Snake/Game.cpp @@ -53,7 +53,7 @@ ErrorOr> Game::try_create() "/res/emoji/U+1FAB1.png"sv, }; - NonnullRefPtrVector food_bitmaps; + Vector> food_bitmaps; TRY(food_bitmaps.try_ensure_capacity(food_bitmaps_files.size())); for (auto file : food_bitmaps_files) { @@ -69,7 +69,7 @@ ErrorOr> Game::try_create() return adopt_nonnull_ref_or_enomem(new (nothrow) Game(move(food_bitmaps))); } -Game::Game(NonnullRefPtrVector food_bitmaps) +Game::Game(Vector> 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 5244fadc7c2..0e4b91c065b 100644 --- a/Userland/Games/Snake/Game.h +++ b/Userland/Games/Snake/Game.h @@ -30,7 +30,7 @@ public: Function on_score_update; private: - explicit Game(NonnullRefPtrVector food_bitmaps); + explicit Game(Vector> 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 m_food_bitmaps; + Vector> 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 3b74ae30206..e85631c4d95 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 moved_cards; + Vector> 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 cards_drawn; + Vector> 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 moved_card; + Vector> 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 moved_cards) +void Game::remember_move_for_undo(CardStack& from, CardStack& to, Vector> 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 cards; + Vector> 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 cards_popped; + Vector> 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 8e73da4969c..a0a885289fa 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 cards; + Vector> 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 moved_cards); + void remember_move_for_undo(CardStack& from, CardStack& to, Vector> 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 m_new_deck; + Vector> 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 0c624db7bdc..d474186e436 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 cards; + Vector> 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 cdf6d9bd61a..9223e9eff95 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 m_new_deck; + Vector> 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 b6fc71826ba..79a95a0ff2a 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> create_standard_deck(Shuffle shuffle) +ErrorOr>> create_standard_deck(Shuffle shuffle) { return create_deck(1, 1, 1, 1, shuffle); } -ErrorOr> 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>> 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 deck; + Vector> 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 { diff --git a/Userland/Libraries/LibCards/Card.h b/Userland/Libraries/LibCards/Card.h index 2c828a91deb..7bf0570ec89 100644 --- a/Userland/Libraries/LibCards/Card.h +++ b/Userland/Libraries/LibCards/Card.h @@ -131,8 +131,8 @@ enum class Shuffle { No, Yes, }; -ErrorOr> create_standard_deck(Shuffle); -ErrorOr> create_deck(unsigned full_club_suit_count, unsigned full_diamond_suit_count, unsigned full_heart_suit_count, unsigned full_spade_suit_count, Shuffle); +ErrorOr>> create_standard_deck(Shuffle); +ErrorOr>> 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 9bc6961ea31..cae16a8d7b6 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 CardGame::pick_up_cards_from_stack(Cards::CardStack& stack, Gfx::IntPoint click_location, CardStack::MovementRule movement_rule) @@ -70,10 +70,10 @@ RefPtr 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 eeebfef031b..226e441e8f9 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& stacks() { return m_stacks; } - NonnullRefPtrVector const& stacks() const { return m_stacks; } + Vector>& stacks() { return m_stacks; } + Vector> const& stacks() const { return m_stacks; } CardStack& stack_at_location(int location) { return m_stacks[location]; } template @@ -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& moving_cards() { return m_moving_cards; } - NonnullRefPtrVector const& moving_cards() const { return m_moving_cards; } + Vector>& moving_cards() { return m_moving_cards; } + Vector> const& moving_cards() const { return m_moving_cards; } Gfx::IntRect moving_cards_bounds() const; RefPtr moving_cards_source_stack() const { return m_moving_cards_source_stack; } ErrorOr 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 m_stacks; + Vector> m_stacks; - NonnullRefPtrVector m_moving_cards; + Vector> m_moving_cards; RefPtr m_moving_cards_source_stack; RefPtr m_previewed_card_stack; }; diff --git a/Userland/Libraries/LibCards/CardStack.cpp b/Userland/Libraries/LibCards/CardStack.cpp index 75e6a4b58a5..2aac1ad152b 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 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 CardStack::add_all_grabbed_cards(Gfx::IntPoint click_location, NonnullRefPtrVector& grabbed, MovementRule movement_rule) +ErrorOr CardStack::add_all_grabbed_cards(Gfx::IntPoint click_location, Vector>& grabbed, MovementRule movement_rule) { VERIFY(grabbed.is_empty()); @@ -137,8 +137,8 @@ ErrorOr CardStack::add_all_grabbed_cards(Gfx::IntPoint click_location, Non RefPtr 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 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 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 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 1cdcf23e445..6fa274a050b 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 const& stack() const { return m_stack; } + Vector> 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 add_all_grabbed_cards(Gfx::IntPoint click_location, NonnullRefPtrVector& grabbed, MovementRule movement_rule = MovementRule::Alternating); + ErrorOr add_all_grabbed_cards(Gfx::IntPoint click_location, Vector>& 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 m_covered_stack; - NonnullRefPtrVector m_stack; + Vector> m_stack; Vector 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 e298a3515e0..7d7c44d9648 100644 --- a/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp +++ b/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp @@ -199,9 +199,9 @@ Vector CppComprehensionEngine::scope_of_reference_to_symbol(ASTNode Vector 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(decl); + if (decl->is_variable_or_parameter_declaration()) { + auto& var_or_param = verify_cast(*decl); if (var_or_param.full_name() == identifier.name() && var_or_param.type()->is_named_type()) { VERIFY(verify_cast(*var_or_param.type()).name()); if (verify_cast(*var_or_param.type()).name()) @@ -326,7 +326,7 @@ Vector CppComprehensionEngine::properties_of_typ Vector 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::get_child_symbols Vector 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 CppComprehensionEngine::ge Optional 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::get hint.current_index = argument_index; for (auto& arg : func_decl.parameters()) { Vector 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 ccb93c4eb04..07012841e83 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 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 f33c4d22390..90bbeb857cf 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& children() { return m_children; } - NonnullRefPtrVector const& children() const { return m_children; } + Vector>& children() { return m_children; } + Vector> const& children() const { return m_children; } template 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> m_properties; - NonnullRefPtrVector m_children; + Vector> m_children; Function m_event_filter; }; diff --git a/Userland/Libraries/LibCpp/AST.cpp b/Userland/Libraries/LibCpp/AST.cpp index 74c16851455..610f7ada759 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 FunctionDeclaration::declarations() const +Vector> FunctionDeclaration::declarations() const { - NonnullRefPtrVector declarations; + Vector> 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 FunctionDefinition::declarations() const +Vector> FunctionDefinition::declarations() const { - NonnullRefPtrVector declarations; + Vector> 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 StructOrClassDeclaration::declarations() const +Vector> StructOrClassDeclaration::declarations() const { - NonnullRefPtrVector declarations; + Vector> 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 Statement::declarations() const +Vector> Statement::declarations() const { if (is_declaration()) { - NonnullRefPtrVector vec; + Vector> vec; auto const& decl = static_cast(*this); vec.empend(const_cast(decl)); return vec; @@ -469,9 +469,9 @@ NonnullRefPtrVector Statement::declarations() const return {}; } -NonnullRefPtrVector ForStatement::declarations() const +Vector> ForStatement::declarations() const { - NonnullRefPtrVector declarations; + Vector> declarations; if (m_init) declarations.extend(m_init->declarations()); if (m_body) @@ -479,11 +479,11 @@ NonnullRefPtrVector ForStatement::declarations() const return declarations; } -NonnullRefPtrVector BlockStatement::declarations() const +Vector> BlockStatement::declarations() const { - NonnullRefPtrVector declarations; + Vector> 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 IfStatement::declarations() const +Vector> IfStatement::declarations() const { - NonnullRefPtrVector declarations; + Vector> 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 0e8be683d3c..1679b6af762 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 declarations() const { return {}; } + virtual Vector> 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 declarations() const override { return m_declarations; } + virtual Vector> declarations() const override { return m_declarations; } TranslationUnit(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) : ASTNode(parent, start, end, filename) { } - void set_declarations(NonnullRefPtrVector&& declarations) { m_declarations = move(declarations); } + void set_declarations(Vector>&& declarations) { m_declarations = move(declarations); } private: - NonnullRefPtrVector m_declarations; + Vector> 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 declarations() const override; + virtual Vector> declarations() const override; protected: Statement(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) @@ -167,20 +167,20 @@ public: { } - virtual NonnullRefPtrVector declarations() const override; + virtual Vector> declarations() const override; Vector const& qualifiers() const { return m_qualifiers; } void set_qualifiers(Vector const& qualifiers) { m_qualifiers = qualifiers; } Type const* return_type() const { return m_return_type.ptr(); } void set_return_type(RefPtr const& return_type) { m_return_type = return_type; } - NonnullRefPtrVector const& parameters() const { return m_parameters; } - void set_parameters(NonnullRefPtrVector const& parameters) { m_parameters = parameters; } + Vector> const& parameters() const { return m_parameters; } + void set_parameters(Vector> const& parameters) { m_parameters = parameters; } FunctionDefinition const* definition() const { return m_definition.ptr(); } void set_definition(RefPtr&& definition) { m_definition = move(definition); } private: Vector m_qualifiers; RefPtr m_return_type; - NonnullRefPtrVector m_parameters; + Vector> m_parameters; RefPtr m_definition; }; @@ -325,11 +325,11 @@ public: } void set_return_type(Type& type) { m_return_type = type; } - void set_parameters(NonnullRefPtrVector parameters) { m_parameters = move(parameters); } + void set_parameters(Vector> parameters) { m_parameters = move(parameters); } private: RefPtr m_return_type; - NonnullRefPtrVector m_parameters; + Vector> m_parameters; }; class FunctionDefinition : public ASTNode { @@ -343,12 +343,12 @@ public: { } - virtual NonnullRefPtrVector declarations() const override; - NonnullRefPtrVector const& statements() { return m_statements; } + virtual Vector> declarations() const override; + Vector> const& statements() { return m_statements; } void add_statement(NonnullRefPtr&& statement) { m_statements.append(move(statement)); } private: - NonnullRefPtrVector m_statements; + Vector> m_statements; }; class InvalidStatement : public Statement { @@ -444,13 +444,13 @@ public: Identifier const* name() const { return m_name.ptr(); } void set_name(RefPtr&& name) { m_name = move(name); } - NonnullRefPtrVector const& scope() const { return m_scope; } - void set_scope(NonnullRefPtrVector scope) { m_scope = move(scope); } + Vector> const& scope() const { return m_scope; } + void set_scope(Vector> scope) { m_scope = move(scope); } void add_to_scope(NonnullRefPtr&& part) { m_scope.append(move(part)); } private: RefPtr m_name; - NonnullRefPtrVector m_scope; + Vector> m_scope; mutable Optional m_full_name; }; @@ -469,7 +469,7 @@ public: void add_template_argument(NonnullRefPtr&& type) { m_template_arguments.append(move(type)); } private: - NonnullRefPtrVector m_template_arguments; + Vector> m_template_arguments; mutable Optional m_full_name; }; @@ -609,11 +609,11 @@ public: void set_callee(RefPtr&& callee) { m_callee = move(callee); } void add_argument(NonnullRefPtr&& arg) { m_arguments.append(move(arg)); } - NonnullRefPtrVector const& arguments() const { return m_arguments; } + Vector> const& arguments() const { return m_arguments; } private: RefPtr m_callee; - NonnullRefPtrVector m_arguments; + Vector> 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 declarations() const override; + virtual Vector> declarations() const override; enum class Type { Struct, @@ -702,16 +702,16 @@ public: { } - NonnullRefPtrVector const& members() const { return m_members; } - void set_members(NonnullRefPtrVector&& members) { m_members = move(members); } + Vector> const& members() const { return m_members; } + void set_members(Vector>&& members) { m_members = move(members); } - NonnullRefPtrVector const& baseclasses() const { return m_baseclasses; } - void set_baseclasses(NonnullRefPtrVector&& baseclasses) { m_baseclasses = move(baseclasses); } + Vector> const& baseclasses() const { return m_baseclasses; } + void set_baseclasses(Vector>&& baseclasses) { m_baseclasses = move(baseclasses); } private: StructOrClassDeclaration::Type m_type; - NonnullRefPtrVector m_members; - NonnullRefPtrVector m_baseclasses; + Vector> m_members; + Vector> 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 declarations() const override; + virtual Vector> declarations() const override; void set_init(RefPtr&& init) { m_init = move(init); } void set_test(RefPtr&& 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 declarations() const override; + virtual Vector> declarations() const override; void add_statement(NonnullRefPtr&& statement) { m_statements.append(move(statement)); } private: - NonnullRefPtrVector m_statements; + Vector> 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 declarations() const override; + virtual Vector> declarations() const override; void set_predicate(RefPtr&& predicate) { m_predicate = move(predicate); } void set_then_statement(RefPtr&& then) { m_then = move(then); } @@ -858,11 +858,11 @@ public: { } - virtual NonnullRefPtrVector declarations() const override { return m_declarations; } + virtual Vector> declarations() const override { return m_declarations; } void add_declaration(NonnullRefPtr&& declaration) { m_declarations.append(move(declaration)); } private: - NonnullRefPtrVector m_declarations; + Vector> m_declarations; }; class CppCastExpression : public Expression { @@ -936,7 +936,7 @@ public: void add_expression(NonnullRefPtr&& exp) { m_expressions.append(move(exp)); } private: - NonnullRefPtrVector m_expressions; + Vector> m_expressions; }; class DummyAstNode : public ASTNode { diff --git a/Userland/Libraries/LibCpp/Parser.cpp b/Userland/Libraries/LibCpp/Parser.cpp index a091b64085a..5cf2eb9ca93 100644 --- a/Userland/Libraries/LibCpp/Parser.cpp +++ b/Userland/Libraries/LibCpp/Parser.cpp @@ -37,9 +37,9 @@ NonnullRefPtr Parser::parse() return unit; } -NonnullRefPtrVector Parser::parse_declarations_in_translation_unit(ASTNode const& parent) +Vector> Parser::parse_declarations_in_translation_unit(ASTNode const& parent) { - NonnullRefPtrVector declarations; + Vector> 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 Parser::parse_template_arguments(ASTNode const& parent) +Vector> Parser::parse_template_arguments(ASTNode const& parent) { LOG_SCOPE(); consume(Token::Type::Less); - NonnullRefPtrVector template_arguments; + Vector> template_arguments; while (!eof() && peek().type() != Token::Type::Greater) { template_arguments.append(parse_type(parent)); } @@ -350,7 +350,7 @@ NonnullRefPtr Parser::parse_expression(ASTNode const& parent) return expression; } - NonnullRefPtrVector secondary_expressions; + Vector> secondary_expressions; while (match_secondary_expression()) { // FIXME: Handle operator precedence @@ -359,7 +359,7 @@ NonnullRefPtr Parser::parse_expression(ASTNode const& parent) } for (size_t i = 0; secondary_expressions.size() != 0 && i < secondary_expressions.size() - 1; ++i) { - const_cast(secondary_expressions[i]).set_parent(secondary_expressions[i + 1]); + const_cast(*secondary_expressions[i]).set_parent(secondary_expressions[i + 1]); } return expression; @@ -748,10 +748,10 @@ bool Parser::match_function_declaration() return false; } -Optional> Parser::parse_parameter_list(ASTNode const& parent) +Optional>> Parser::parse_parameter_list(ASTNode const& parent) { LOG_SCOPE(); - NonnullRefPtrVector parameters; + Vector> parameters; while (peek().type() != Token::Type::RightParen && !eof()) { if (match_ellipsis()) { auto param = create_ast_node(parent, position(), {}, RefPtr {}); @@ -981,7 +981,7 @@ Optional 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 Parser::parse_class_declaration(AS auto has_final = match_keyword("final"); - NonnullRefPtrVector baseclasses; + Vector> baseclasses; // FIXME: Don't ignore this. if (peek(has_final ? 1 : 0).type() == Token::Type::Colon) { @@ -1569,11 +1569,11 @@ NonnullRefPtr Parser::parse_braced_init_list(ASTNode const init_list->set_end(position()); return init_list; } -NonnullRefPtrVector Parser::parse_class_members(StructOrClassDeclaration& parent) +Vector> Parser::parse_class_members(StructOrClassDeclaration& parent) { auto class_name = parent.full_name(); - NonnullRefPtrVector members; + Vector> 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 349d2eb0b13..6ced38a2946 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> parse_parameter_list(ASTNode const& parent); + Optional>> parse_parameter_list(ASTNode const& parent); Optional consume_whitespace(); void consume_preprocessor(); @@ -110,15 +110,15 @@ private: NonnullRefPtr parse_comment(ASTNode const& parent); NonnullRefPtr parse_if_statement(ASTNode const& parent); NonnullRefPtr parse_namespace_declaration(ASTNode const& parent, bool is_nested_namespace = false); - NonnullRefPtrVector parse_declarations_in_translation_unit(ASTNode const& parent); + Vector> parse_declarations_in_translation_unit(ASTNode const& parent); RefPtr parse_single_declaration_in_translation_unit(ASTNode const& parent); - NonnullRefPtrVector parse_template_arguments(ASTNode const& parent); + Vector> parse_template_arguments(ASTNode const& parent); NonnullRefPtr parse_name(ASTNode const& parent); NonnullRefPtr parse_cpp_cast_expression(ASTNode const& parent); NonnullRefPtr parse_sizeof_expression(ASTNode const& parent); NonnullRefPtr parse_braced_init_list(ASTNode const& parent); NonnullRefPtr parse_c_style_cast_expression(ASTNode const& parent); - NonnullRefPtrVector parse_class_members(StructOrClassDeclaration& parent); + Vector> parse_class_members(StructOrClassDeclaration& parent); NonnullRefPtr parse_constructor(ASTNode const& parent); NonnullRefPtr parse_destructor(ASTNode const& parent); NonnullRefPtr parse_using_namespace_declaration(ASTNode const& parent); @@ -138,7 +138,7 @@ private: struct State { size_t token_index { 0 }; - NonnullRefPtrVector state_nodes; + Vector> state_nodes; }; void error(StringView message = {}); @@ -192,7 +192,7 @@ private: Vector m_saved_states; RefPtr m_root_node; Vector m_errors; - NonnullRefPtrVector m_nodes; + Vector> m_nodes; }; } diff --git a/Userland/Libraries/LibDSP/Track.cpp b/Userland/Libraries/LibDSP/Track.cpp index 66179d72468..2e2d784efec 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 Track::synth() { - return static_ptr_cast(m_processor_chain.ptr_at(0)); + return static_ptr_cast(m_processor_chain[0]); } NonnullRefPtr Track::delay() { - return static_ptr_cast(m_processor_chain.ptr_at(1)); + return static_ptr_cast(m_processor_chain[1]); } bool AudioTrack::check_processor_chain_valid() const @@ -81,11 +81,11 @@ void Track::current_signal(FixedArray& 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 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 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 63c6d73716d..1ec19505d79 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 resize_internal_buffers_to(size_t buffer_size); - NonnullRefPtrVector const& processor_chain() const { return m_processor_chain; } + Vector> const& processor_chain() const { return m_processor_chain; } NonnullRefPtr transport() const { return m_transport; } NonnullRefPtr 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 m_processor_chain; + Vector> m_processor_chain; NonnullRefPtr m_transport; NonnullRefPtr m_track_mastering; NonnullRefPtr m_keyboard; @@ -90,7 +90,7 @@ protected: void compute_current_clips_signal() override; private: - NonnullRefPtrVector m_clips; + Vector> m_clips; }; class AudioTrack final : public Track { @@ -103,13 +103,13 @@ public: } bool check_processor_chain_valid() const override; - NonnullRefPtrVector const& clips() const { return m_clips; } + Vector> const& clips() const { return m_clips; } protected: void compute_current_clips_signal() override; private: - NonnullRefPtrVector m_clips; + Vector> m_clips; }; } diff --git a/Userland/Libraries/LibDesktop/Launcher.cpp b/Userland/Libraries/LibDesktop/Launcher.cpp index c3139156e03..de182ddfea7 100644 --- a/Userland/Libraries/LibDesktop/Launcher.cpp +++ b/Userland/Libraries/LibDesktop/Launcher.cpp @@ -102,10 +102,10 @@ Vector 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
+auto Launcher::get_handlers_with_details_for_url(const URL& url) -> Vector> { auto details = connection().get_handlers_with_details_for_url(url.to_deprecated_string()); - NonnullRefPtrVector
handlers_with_details; + Vector> 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 f49c0f96c77..82da4d402cb 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 get_handlers_for_url(const URL&); - static NonnullRefPtrVector
get_handlers_with_details_for_url(const URL&); + static Vector> get_handlers_with_details_for_url(const URL&); }; } diff --git a/Userland/Libraries/LibELF/DynamicLinker.cpp b/Userland/Libraries/LibELF/DynamicLinker.cpp index 38a7c4bfbcd..d0d6e5bd2aa 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 collect_loaders_for_library(DeprecatedString const& path) +static Vector> collect_loaders_for_library(DeprecatedString const& path) { VERIFY(path.starts_with('/')); HashTable seen_names; - NonnullRefPtrVector loaders; + Vector> loaders; for_each_unfinished_dependency_of(path, seen_names, [&](auto& loader) { loaders.append(loader); }); @@ -386,37 +386,37 @@ static Result 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(VirtualMemoryRangeFlags::SyscallCode) | static_cast(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(VirtualMemoryRangeFlags::Immutable); if (syscall(SC_annotate_mapping, segment.address().get(), flags)) { VERIFY_NOT_REACHED(); @@ -428,7 +428,7 @@ static Result 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 dded956b395..7b5cb82f01c 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 properties, NonnullRefPtrVector sub_objects) + Object(DeprecatedString name, Vector> properties, Vector> 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(child)) { - auto const& property = static_cast(child); + auto const& property = static_cast(*child); if (property.key() != "layout" && is(property.value().ptr())) callback(property.key(), static_ptr_cast(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(child)) { - TRY(callback(static_cast(child))); + TRY(callback(static_cast(*child))); } } @@ -218,7 +218,7 @@ public: { for (auto const& child : m_properties) { if (is(child)) { - auto const& property = static_cast(child); + auto const& property = static_cast(*child); if (property.key() == "layout") { VERIFY(is(property.value().ptr())); return static_cast(*property.value()); @@ -232,7 +232,7 @@ public: { for (auto const& child : m_properties) { if (is(child)) { - auto const& property = static_cast(child); + auto const& property = static_cast(*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(child) && i != m_sub_objects.size() - 1) builder.append('\n'); @@ -274,9 +274,9 @@ public: private: // Properties and comments - NonnullRefPtrVector m_properties; + Vector> m_properties; // Sub objects and comments - NonnullRefPtrVector m_sub_objects; + Vector> m_sub_objects; DeprecatedString m_name {}; }; @@ -304,18 +304,18 @@ public: bool has_main_class() const { return m_main_class != nullptr; } - NonnullRefPtrVector leading_comments() const { return m_leading_comments; } + Vector> leading_comments() const { return m_leading_comments; } Object const& main_class() const { VERIFY(!m_main_class.is_null()); return *m_main_class.ptr(); } - NonnullRefPtrVector trailing_comments() const { return m_trailing_comments; } + Vector> 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 m_leading_comments; + Vector> m_leading_comments; RefPtr m_main_class; - NonnullRefPtrVector m_trailing_comments; + Vector> m_trailing_comments; }; } diff --git a/Userland/Libraries/LibGUI/GML/Parser.cpp b/Userland/Libraries/LibGUI/GML/Parser.cpp index 18f93109f4c..ef71d155ac9 100644 --- a/Userland/Libraries/LibGUI/GML/Parser.cpp +++ b/Userland/Libraries/LibGUI/GML/Parser.cpp @@ -46,7 +46,7 @@ static ErrorOr> parse_gml_object(Queue& tokens) tokens.dequeue(); - NonnullRefPtrVector pending_comments; + Vector> 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 80269219d40..03d87fd753d 100644 --- a/Userland/Libraries/LibGUI/Menubar.h +++ b/Userland/Libraries/LibGUI/Menubar.h @@ -32,7 +32,7 @@ public: private: Menubar() = default; - NonnullRefPtrVector m_menus; + Vector> m_menus; }; } diff --git a/Userland/Libraries/LibGUI/Statusbar.cpp b/Userland/Libraries/LibGUI/Statusbar.cpp index 3da3ef54235..2ea42af74d5 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 c570920965a..0720c7a396d 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 m_segments; + Vector> m_segments; RefPtr m_corner; }; diff --git a/Userland/Libraries/LibGUI/TextEditor.h b/Userland/Libraries/LibGUI/TextEditor.h index 0eb80b20522..2406b9e1d2e 100644 --- a/Userland/Libraries/LibGUI/TextEditor.h +++ b/Userland/Libraries/LibGUI/TextEditor.h @@ -414,7 +414,7 @@ private: RefPtr m_select_all_action; RefPtr m_insert_emoji_action; Core::ElapsedTimer m_triple_click_timer; - NonnullRefPtrVector m_custom_context_menu_actions; + Vector> 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 362df134728..a03e20e7857 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(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(row), 0, parent_node); } diff --git a/Userland/Libraries/LibGUI/TreeViewModel.h b/Userland/Libraries/LibGUI/TreeViewModel.h index 6021fbf519f..b063e939a18 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 const& child_nodes() const { return m_child_nodes; } - NonnullRefPtrVector& child_nodes() { return m_child_nodes; } + Vector> const& child_nodes() const { return m_child_nodes; } + Vector>& child_nodes() { return m_child_nodes; } private: DeprecatedString m_text; Optional m_icon; WeakPtr m_parent_node; - NonnullRefPtrVector m_child_nodes; + Vector> m_child_nodes; }; - NonnullRefPtrVector const& nodes() const { return m_nodes; } - NonnullRefPtrVector& nodes() { return m_nodes; } + Vector> const& nodes() const { return m_nodes; } + Vector>& nodes() { return m_nodes; } template NonnullRefPtr add_node(DeprecatedString text, Optional icon, Args&&... args) @@ -86,7 +86,7 @@ public: private: TreeViewModel() = default; - NonnullRefPtrVector m_nodes; + Vector> m_nodes; }; } diff --git a/Userland/Libraries/LibGUI/Widget.cpp b/Userland/Libraries/LibGUI/Widget.cpp index f08a80f0245..b8a52878708 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(children()[i])) continue; - auto& child = verify_cast(children()[i]); + auto& child = verify_cast(*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::child_widgets() const Vector widgets; widgets.ensure_capacity(children().size()); for (auto& child : const_cast(this)->children()) { - if (is(child)) - widgets.append(static_cast(child)); + if (is(*child)) + widgets.append(static_cast(*child)); } return widgets; } diff --git a/Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp b/Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp index 81b593a78b6..d612ddf6ce2 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 f8ce753025a..11de34141d6 100644 --- a/Userland/Libraries/LibGUI/Wizards/WizardDialog.h +++ b/Userland/Libraries/LibGUI/Wizards/WizardDialog.h @@ -49,6 +49,6 @@ private: RefPtr