Everywhere: Stop using NonnullRefPtrVector

This class had slightly confusing semantics and the added weirdness
doesn't seem worth it just so we can say "." instead of "->" when
iterating over a vector of NNRPs.

This patch replaces NonnullRefPtrVector<T> with Vector<NNRP<T>>.
This commit is contained in:
Andreas Kling 2023-03-06 14:17:01 +01:00
parent 104be6c8ac
commit 8a48246ed1
168 changed files with 1280 additions and 1280 deletions

View file

@ -183,7 +183,7 @@ ErrorOr<void> Access::fast_enumerate(Function<void(DeviceIdentifier const&)>& ca
{
// Note: We hold the m_access_lock for a brief moment just to ensure we get
// a complete Vector in case someone wants to mutate it.
NonnullRefPtrVector<DeviceIdentifier> device_identifiers;
Vector<NonnullRefPtr<DeviceIdentifier>> device_identifiers;
{
SpinlockLocker locker(m_access_lock);
VERIFY(!m_device_identifiers.is_empty());
@ -198,10 +198,11 @@ ErrorOr<void> Access::fast_enumerate(Function<void(DeviceIdentifier const&)>& ca
DeviceIdentifier const& Access::get_device_identifier(Address address) const
{
for (auto& device_identifier : m_device_identifiers) {
if (device_identifier.address().domain() == address.domain()
&& device_identifier.address().bus() == address.bus()
&& device_identifier.address().device() == address.device()
&& device_identifier.address().function() == address.function()) {
auto device_address = device_identifier->address();
if (device_address.domain() == address.domain()
&& device_address.bus() == address.bus()
&& device_address.device() == address.device()
&& device_address.function() == address.function()) {
return device_identifier;
}
}

View file

@ -62,6 +62,6 @@ private:
mutable Spinlock<LockRank::None> m_scan_lock {};
HashMap<u32, NonnullOwnPtr<PCI::HostController>> m_host_controllers;
NonnullRefPtrVector<DeviceIdentifier> m_device_identifiers;
Vector<NonnullRefPtr<DeviceIdentifier>> m_device_identifiers;
};
}

View file

@ -785,18 +785,18 @@ ErrorOr<NonnullOwnPtr<Memory::Region>> MemoryManager::allocate_dma_buffer_page(S
return allocate_dma_buffer_page(name, access, dma_buffer_page);
}
ErrorOr<NonnullOwnPtr<Memory::Region>> MemoryManager::allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access, NonnullRefPtrVector<Memory::PhysicalPage>& dma_buffer_pages)
ErrorOr<NonnullOwnPtr<Memory::Region>> MemoryManager::allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access, Vector<NonnullRefPtr<Memory::PhysicalPage>>& dma_buffer_pages)
{
VERIFY(!(size % PAGE_SIZE));
dma_buffer_pages = TRY(allocate_contiguous_physical_pages(size));
// Do not enable Cache for this region as physical memory transfers are performed (Most architectures have this behaviour by default)
return allocate_kernel_region(dma_buffer_pages.first().paddr(), size, name, access, Region::Cacheable::No);
return allocate_kernel_region(dma_buffer_pages.first()->paddr(), size, name, access, Region::Cacheable::No);
}
ErrorOr<NonnullOwnPtr<Memory::Region>> MemoryManager::allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access)
{
VERIFY(!(size % PAGE_SIZE));
NonnullRefPtrVector<Memory::PhysicalPage> dma_buffer_pages;
Vector<NonnullRefPtr<Memory::PhysicalPage>> dma_buffer_pages;
return allocate_dma_buffer_pages(size, name, access, dma_buffer_pages);
}
@ -1010,12 +1010,12 @@ ErrorOr<NonnullRefPtr<PhysicalPage>> MemoryManager::allocate_physical_page(Shoul
});
}
ErrorOr<NonnullRefPtrVector<PhysicalPage>> MemoryManager::allocate_contiguous_physical_pages(size_t size)
ErrorOr<Vector<NonnullRefPtr<PhysicalPage>>> MemoryManager::allocate_contiguous_physical_pages(size_t size)
{
VERIFY(!(size % PAGE_SIZE));
size_t page_count = ceil_div(size, static_cast<size_t>(PAGE_SIZE));
auto physical_pages = TRY(m_global_data.with([&](auto& global_data) -> ErrorOr<NonnullRefPtrVector<PhysicalPage>> {
auto physical_pages = TRY(m_global_data.with([&](auto& global_data) -> ErrorOr<Vector<NonnullRefPtr<PhysicalPage>>> {
// We need to make sure we don't touch pages that we have committed to
if (global_data.system_memory_info.physical_pages_uncommitted < page_count)
return ENOMEM;
@ -1033,7 +1033,7 @@ ErrorOr<NonnullRefPtrVector<PhysicalPage>> MemoryManager::allocate_contiguous_ph
}));
{
auto cleanup_region = TRY(MM.allocate_kernel_region(physical_pages[0].paddr(), PAGE_SIZE * page_count, {}, Region::Access::Read | Region::Access::Write));
auto cleanup_region = TRY(MM.allocate_kernel_region(physical_pages[0]->paddr(), PAGE_SIZE * page_count, {}, Region::Access::Read | Region::Access::Write));
memset(cleanup_region->vaddr().as_ptr(), 0, PAGE_SIZE * page_count);
}
return physical_pages;

View file

@ -166,13 +166,13 @@ public:
NonnullRefPtr<PhysicalPage> allocate_committed_physical_page(Badge<CommittedPhysicalPageSet>, ShouldZeroFill = ShouldZeroFill::Yes);
ErrorOr<NonnullRefPtr<PhysicalPage>> allocate_physical_page(ShouldZeroFill = ShouldZeroFill::Yes, bool* did_purge = nullptr);
ErrorOr<NonnullRefPtrVector<PhysicalPage>> allocate_contiguous_physical_pages(size_t size);
ErrorOr<Vector<NonnullRefPtr<PhysicalPage>>> allocate_contiguous_physical_pages(size_t size);
void deallocate_physical_page(PhysicalAddress);
ErrorOr<NonnullOwnPtr<Region>> allocate_contiguous_kernel_region(size_t, StringView name, Region::Access access, Region::Cacheable = Region::Cacheable::Yes);
ErrorOr<NonnullOwnPtr<Memory::Region>> allocate_dma_buffer_page(StringView name, Memory::Region::Access access, RefPtr<Memory::PhysicalPage>& dma_buffer_page);
ErrorOr<NonnullOwnPtr<Memory::Region>> allocate_dma_buffer_page(StringView name, Memory::Region::Access access);
ErrorOr<NonnullOwnPtr<Memory::Region>> allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access, NonnullRefPtrVector<Memory::PhysicalPage>& dma_buffer_pages);
ErrorOr<NonnullOwnPtr<Memory::Region>> allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access, Vector<NonnullRefPtr<Memory::PhysicalPage>>& dma_buffer_pages);
ErrorOr<NonnullOwnPtr<Memory::Region>> allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access);
ErrorOr<NonnullOwnPtr<Region>> allocate_kernel_region(size_t, StringView name, Region::Access access, AllocationStrategy strategy = AllocationStrategy::Reserve, Region::Cacheable = Region::Cacheable::Yes);
ErrorOr<NonnullOwnPtr<Region>> allocate_kernel_region(PhysicalAddress, size_t, StringView name, Region::Access access, Region::Cacheable = Region::Cacheable::Yes);

View file

@ -75,7 +75,7 @@ OwnPtr<PhysicalRegion> PhysicalRegion::try_take_pages_from_beginning(size_t page
return try_create(taken_lower, taken_upper);
}
NonnullRefPtrVector<PhysicalPage> PhysicalRegion::take_contiguous_free_pages(size_t count)
Vector<NonnullRefPtr<PhysicalPage>> PhysicalRegion::take_contiguous_free_pages(size_t count)
{
auto rounded_page_count = next_power_of_two(count);
auto order = count_trailing_zeroes(rounded_page_count);
@ -95,7 +95,7 @@ NonnullRefPtrVector<PhysicalPage> PhysicalRegion::take_contiguous_free_pages(siz
if (!page_base.has_value())
return {};
NonnullRefPtrVector<PhysicalPage> physical_pages;
Vector<NonnullRefPtr<PhysicalPage>> physical_pages;
physical_pages.ensure_capacity(count);
for (size_t i = 0; i < count; ++i)

View file

@ -34,7 +34,7 @@ public:
OwnPtr<PhysicalRegion> try_take_pages_from_beginning(size_t);
RefPtr<PhysicalPage> take_free_page();
NonnullRefPtrVector<PhysicalPage> take_contiguous_free_pages(size_t count);
Vector<NonnullRefPtr<PhysicalPage>> take_contiguous_free_pages(size_t count);
void return_page(PhysicalAddress);
private:

View file

@ -210,7 +210,7 @@ void AHCIPort::eject()
auto unused_command_header = try_to_find_unused_command_header();
VERIFY(unused_command_header.has_value());
auto* command_list_entries = (volatile AHCI::CommandHeader*)m_command_list_region->vaddr().as_ptr();
command_list_entries[unused_command_header.value()].ctba = m_command_table_pages[unused_command_header.value()].paddr().get();
command_list_entries[unused_command_header.value()].ctba = m_command_table_pages[unused_command_header.value()]->paddr().get();
command_list_entries[unused_command_header.value()].ctbau = 0;
command_list_entries[unused_command_header.value()].prdbc = 0;
command_list_entries[unused_command_header.value()].prdtl = 0;
@ -221,7 +221,7 @@ void AHCIPort::eject()
// handshake error bit in PxSERR register if CFL is incorrect.
command_list_entries[unused_command_header.value()].attributes = (size_t)FIS::DwordCount::RegisterHostToDevice | AHCI::CommandHeaderAttributes::P | AHCI::CommandHeaderAttributes::C | AHCI::CommandHeaderAttributes::A;
auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()].paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)).value(), "AHCI Command Table"sv, Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No).release_value();
auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()]->paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)).value(), "AHCI Command Table"sv, Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No).release_value();
auto& command_table = *(volatile AHCI::CommandTable*)command_table_region->vaddr().as_ptr();
memset(const_cast<u8*>(command_table.command_fis), 0, 64);
auto& fis = *(volatile FIS::HostToDevice::Register*)command_table.command_fis;
@ -497,7 +497,7 @@ Optional<AsyncDeviceRequest::RequestResult> AHCIPort::prepare_and_set_scatter_li
VERIFY(m_lock.is_locked());
VERIFY(request.block_count() > 0);
NonnullRefPtrVector<Memory::PhysicalPage> allocated_dma_regions;
Vector<NonnullRefPtr<Memory::PhysicalPage>> allocated_dma_regions;
for (size_t index = 0; index < calculate_descriptors_count(request.block_count()); index++) {
allocated_dma_regions.append(m_dma_buffers.at(index));
}
@ -578,7 +578,7 @@ bool AHCIPort::access_device(AsyncBlockDeviceRequest::RequestType direction, u64
auto unused_command_header = try_to_find_unused_command_header();
VERIFY(unused_command_header.has_value());
auto* command_list_entries = (volatile AHCI::CommandHeader*)m_command_list_region->vaddr().as_ptr();
command_list_entries[unused_command_header.value()].ctba = m_command_table_pages[unused_command_header.value()].paddr().get();
command_list_entries[unused_command_header.value()].ctba = m_command_table_pages[unused_command_header.value()]->paddr().get();
command_list_entries[unused_command_header.value()].ctbau = 0;
command_list_entries[unused_command_header.value()].prdbc = 0;
command_list_entries[unused_command_header.value()].prdtl = m_current_scatter_list->scatters_count();
@ -591,7 +591,7 @@ bool AHCIPort::access_device(AsyncBlockDeviceRequest::RequestType direction, u64
dbgln_if(AHCI_DEBUG, "AHCI Port {}: CLE: ctba={:#08x}, ctbau={:#08x}, prdbc={:#08x}, prdtl={:#04x}, attributes={:#04x}", representative_port_index(), (u32)command_list_entries[unused_command_header.value()].ctba, (u32)command_list_entries[unused_command_header.value()].ctbau, (u32)command_list_entries[unused_command_header.value()].prdbc, (u16)command_list_entries[unused_command_header.value()].prdtl, (u16)command_list_entries[unused_command_header.value()].attributes);
auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()].paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)).value(), "AHCI Command Table"sv, Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No).release_value();
auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()]->paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)).value(), "AHCI Command Table"sv, Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No).release_value();
auto& command_table = *(volatile AHCI::CommandTable*)command_table_region->vaddr().as_ptr();
dbgln_if(AHCI_DEBUG, "AHCI Port {}: Allocated command table at {}", representative_port_index(), command_table_region->vaddr());
@ -652,7 +652,7 @@ bool AHCIPort::access_device(AsyncBlockDeviceRequest::RequestType direction, u64
mark_command_header_ready_to_process(unused_command_header.value());
full_memory_barrier();
dbgln_if(AHCI_DEBUG, "AHCI Port {}: Do a {}, lba {}, block count {} @ {}, ended", representative_port_index(), direction == AsyncBlockDeviceRequest::RequestType::Write ? "write" : "read", lba, block_count, m_dma_buffers[0].paddr());
dbgln_if(AHCI_DEBUG, "AHCI Port {}: Do a {}, lba {}, block count {} @ {}, ended", representative_port_index(), direction == AsyncBlockDeviceRequest::RequestType::Write ? "write" : "read", lba, block_count, m_dma_buffers[0]->paddr());
return true;
}
@ -670,7 +670,7 @@ bool AHCIPort::identify_device()
auto unused_command_header = try_to_find_unused_command_header();
VERIFY(unused_command_header.has_value());
auto* command_list_entries = (volatile AHCI::CommandHeader*)m_command_list_region->vaddr().as_ptr();
command_list_entries[unused_command_header.value()].ctba = m_command_table_pages[unused_command_header.value()].paddr().get();
command_list_entries[unused_command_header.value()].ctba = m_command_table_pages[unused_command_header.value()]->paddr().get();
command_list_entries[unused_command_header.value()].ctbau = 0;
command_list_entries[unused_command_header.value()].prdbc = 512;
command_list_entries[unused_command_header.value()].prdtl = 1;
@ -679,7 +679,7 @@ bool AHCIPort::identify_device()
// QEMU doesn't care if we don't set the correct CFL field in this register, real hardware will set an handshake error bit in PxSERR register.
command_list_entries[unused_command_header.value()].attributes = (size_t)FIS::DwordCount::RegisterHostToDevice | AHCI::CommandHeaderAttributes::P;
auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()].paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)).value(), "AHCI Command Table"sv, Memory::Region::Access::ReadWrite).release_value();
auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()]->paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)).value(), "AHCI Command Table"sv, Memory::Region::Access::ReadWrite).release_value();
auto& command_table = *(volatile AHCI::CommandTable*)command_table_region->vaddr().as_ptr();
memset(const_cast<u8*>(command_table.command_fis), 0, 64);
command_table.descriptors[0].base_high = 0;

View file

@ -112,8 +112,8 @@ private:
mutable bool m_wait_for_completion { false };
NonnullRefPtrVector<Memory::PhysicalPage> m_dma_buffers;
NonnullRefPtrVector<Memory::PhysicalPage> m_command_table_pages;
Vector<NonnullRefPtr<Memory::PhysicalPage>> m_dma_buffers;
Vector<NonnullRefPtr<Memory::PhysicalPage>> m_command_table_pages;
RefPtr<Memory::PhysicalPage> m_command_list_page;
OwnPtr<Memory::Region> m_command_list_region;
RefPtr<Memory::PhysicalPage> m_fis_receive_page;

View file

@ -256,9 +256,9 @@ UNMAP_AFTER_INIT ErrorOr<void> NVMeController::create_admin_queue(Optional<u8> i
{
auto qdepth = get_admin_q_dept();
OwnPtr<Memory::Region> cq_dma_region;
NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_pages;
Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_pages;
OwnPtr<Memory::Region> sq_dma_region;
NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_pages;
Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_pages;
auto cq_size = round_up_to_power_of_two(CQ_SIZE(qdepth), 4096);
auto sq_size = round_up_to_power_of_two(SQ_SIZE(qdepth), 4096);
if (!reset_controller()) {
@ -280,8 +280,8 @@ UNMAP_AFTER_INIT ErrorOr<void> NVMeController::create_admin_queue(Optional<u8> i
}
auto doorbell_regs = TRY(Memory::map_typed_writable<DoorbellRegister volatile>(PhysicalAddress(m_bar + REG_SQ0TDBL_START)));
m_controller_regs->acq = reinterpret_cast<u64>(AK::convert_between_host_and_little_endian(cq_dma_pages.first().paddr().as_ptr()));
m_controller_regs->asq = reinterpret_cast<u64>(AK::convert_between_host_and_little_endian(sq_dma_pages.first().paddr().as_ptr()));
m_controller_regs->acq = reinterpret_cast<u64>(AK::convert_between_host_and_little_endian(cq_dma_pages.first()->paddr().as_ptr()));
m_controller_regs->asq = reinterpret_cast<u64>(AK::convert_between_host_and_little_endian(sq_dma_pages.first()->paddr().as_ptr()));
if (!start_controller()) {
dmesgln_pci(*this, "Failed to restart the NVMe controller");
@ -297,9 +297,9 @@ UNMAP_AFTER_INIT ErrorOr<void> NVMeController::create_admin_queue(Optional<u8> i
UNMAP_AFTER_INIT ErrorOr<void> NVMeController::create_io_queue(u8 qid, Optional<u8> irq)
{
OwnPtr<Memory::Region> cq_dma_region;
NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_pages;
Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_pages;
OwnPtr<Memory::Region> sq_dma_region;
NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_pages;
Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_pages;
auto cq_size = round_up_to_power_of_two(CQ_SIZE(IO_QUEUE_SIZE), 4096);
auto sq_size = round_up_to_power_of_two(SQ_SIZE(IO_QUEUE_SIZE), 4096);
@ -320,7 +320,7 @@ UNMAP_AFTER_INIT ErrorOr<void> NVMeController::create_io_queue(u8 qid, Optional<
{
NVMeSubmission sub {};
sub.op = OP_ADMIN_CREATE_COMPLETION_QUEUE;
sub.create_cq.prp1 = reinterpret_cast<u64>(AK::convert_between_host_and_little_endian(cq_dma_pages.first().paddr().as_ptr()));
sub.create_cq.prp1 = reinterpret_cast<u64>(AK::convert_between_host_and_little_endian(cq_dma_pages.first()->paddr().as_ptr()));
sub.create_cq.cqid = qid;
// The queue size is 0 based
sub.create_cq.qsize = AK::convert_between_host_and_little_endian(IO_QUEUE_SIZE - 1);
@ -335,7 +335,7 @@ UNMAP_AFTER_INIT ErrorOr<void> NVMeController::create_io_queue(u8 qid, Optional<
{
NVMeSubmission sub {};
sub.op = OP_ADMIN_CREATE_SUBMISSION_QUEUE;
sub.create_sq.prp1 = reinterpret_cast<u64>(AK::convert_between_host_and_little_endian(sq_dma_pages.first().paddr().as_ptr()));
sub.create_sq.prp1 = reinterpret_cast<u64>(AK::convert_between_host_and_little_endian(sq_dma_pages.first()->paddr().as_ptr()));
sub.create_sq.sqid = qid;
// The queue size is 0 based
sub.create_sq.qsize = AK::convert_between_host_and_little_endian(IO_QUEUE_SIZE - 1);

View file

@ -11,7 +11,7 @@
namespace Kernel {
UNMAP_AFTER_INIT NVMeInterruptQueue::NVMeInterruptQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u8 irq, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs)
UNMAP_AFTER_INIT NVMeInterruptQueue::NVMeInterruptQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u8 irq, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs)
: NVMeQueue(move(rw_dma_region), rw_dma_page, qid, q_depth, move(cq_dma_region), cq_dma_page, move(sq_dma_region), sq_dma_page, move(db_regs))
, IRQHandler(irq)
{

View file

@ -13,7 +13,7 @@ namespace Kernel {
class NVMeInterruptQueue : public NVMeQueue
, public IRQHandler {
public:
NVMeInterruptQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u8 irq, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs);
NVMeInterruptQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u8 irq, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs);
void submit_sqe(NVMeSubmission& submission) override;
virtual ~NVMeInterruptQueue() override {};

View file

@ -10,7 +10,7 @@
#include <Kernel/Storage/NVMe/NVMePollQueue.h>
namespace Kernel {
UNMAP_AFTER_INIT NVMePollQueue::NVMePollQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs)
UNMAP_AFTER_INIT NVMePollQueue::NVMePollQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs)
: NVMeQueue(move(rw_dma_region), rw_dma_page, qid, q_depth, move(cq_dma_region), cq_dma_page, move(sq_dma_region), sq_dma_page, move(db_regs))
{
}

View file

@ -12,7 +12,7 @@ namespace Kernel {
class NVMePollQueue : public NVMeQueue {
public:
NVMePollQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs);
NVMePollQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs);
void submit_sqe(NVMeSubmission& submission) override;
virtual ~NVMePollQueue() override {};

View file

@ -12,7 +12,7 @@
#include <Kernel/Storage/NVMe/NVMeQueue.h>
namespace Kernel {
ErrorOr<NonnullLockRefPtr<NVMeQueue>> NVMeQueue::try_create(u16 qid, Optional<u8> irq, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs)
ErrorOr<NonnullLockRefPtr<NVMeQueue>> NVMeQueue::try_create(u16 qid, Optional<u8> irq, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs)
{
// Note: Allocate DMA region for RW operation. For now the requests don't exceed more than 4096 bytes (Storage device takes care of it)
RefPtr<Memory::PhysicalPage> rw_dma_page;
@ -25,7 +25,7 @@ ErrorOr<NonnullLockRefPtr<NVMeQueue>> NVMeQueue::try_create(u16 qid, Optional<u8
return queue;
}
UNMAP_AFTER_INIT NVMeQueue::NVMeQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs)
UNMAP_AFTER_INIT NVMeQueue::NVMeQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs)
: m_current_request(nullptr)
, m_rw_dma_region(move(rw_dma_region))
, m_qid(qid)

View file

@ -30,7 +30,7 @@ struct DoorbellRegister {
class AsyncBlockDeviceRequest;
class NVMeQueue : public AtomicRefCounted<NVMeQueue> {
public:
static ErrorOr<NonnullLockRefPtr<NVMeQueue>> try_create(u16 qid, Optional<u8> irq, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs);
static ErrorOr<NonnullLockRefPtr<NVMeQueue>> try_create(u16 qid, Optional<u8> irq, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs);
bool is_admin_queue() { return m_admin_queue; };
u16 submit_sync_sqe(NVMeSubmission&);
void read(AsyncBlockDeviceRequest& request, u16 nsid, u64 index, u32 count);
@ -44,7 +44,7 @@ protected:
{
m_db_regs->sq_tail = m_sq_tail;
}
NVMeQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs);
NVMeQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, Vector<NonnullRefPtr<Memory::PhysicalPage>> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs);
private:
bool cqe_available();
@ -71,10 +71,10 @@ private:
u32 m_qdepth {};
Spinlock<LockRank::Interrupts> m_sq_lock {};
OwnPtr<Memory::Region> m_cq_dma_region;
NonnullRefPtrVector<Memory::PhysicalPage> m_cq_dma_page;
Vector<NonnullRefPtr<Memory::PhysicalPage>> m_cq_dma_page;
Span<NVMeSubmission> m_sqe_array;
OwnPtr<Memory::Region> m_sq_dma_region;
NonnullRefPtrVector<Memory::PhysicalPage> m_sq_dma_page;
Vector<NonnullRefPtr<Memory::PhysicalPage>> m_sq_dma_page;
Span<NVMeCompletion> m_cqe_array;
Memory::TypedMapping<DoorbellRegister volatile> m_db_regs;
NonnullRefPtr<Memory::PhysicalPage const> m_rw_dma_page;

View file

@ -850,7 +850,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
VERIFY(parameterized_type.parameters().size() == 2);
// A record only allows the key to be a string.
VERIFY(parameterized_type.parameters()[0].is_string());
VERIFY(parameterized_type.parameters()[0]->is_string());
// An ECMAScript value O is converted to an IDL record<K, V> value as follows:
// 1. If Type(O) is not Object, throw a TypeError.
@ -924,7 +924,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
RefPtr<Type const> dictionary_type;
for (auto& dictionary : interface.dictionaries) {
for (auto& type : types) {
if (type.name() == dictionary.key) {
if (type->name() == dictionary.key) {
dictionary_type = type;
break;
}
@ -998,7 +998,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
bool includes_object = false;
for (auto& type : types) {
if (type.name() == "object") {
if (type->name() == "object") {
includes_object = true;
break;
}
@ -1032,7 +1032,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
continue;
auto union_platform_object_type_generator = union_generator.fork();
union_platform_object_type_generator.set("platform_object_type", type.name());
union_platform_object_type_generator.set("platform_object_type", type->name());
union_platform_object_type_generator.append(R"~~~(
if (is<@platform_object_type@>(@js_name@@js_suffix@_object))
@ -1055,7 +1055,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
// 6. If Type(V) is Object and V has an [[ArrayBufferData]] internal slot, then
// 1. If types includes ArrayBuffer, then return the result of converting V to ArrayBuffer.
for (auto& type : types) {
if (type.name() == "BufferSource") {
if (type->name() == "BufferSource") {
union_generator.append(R"~~~(
if (is<JS::ArrayBuffer>(@js_name@@js_suffix@_object))
return JS::make_handle(@js_name@@js_suffix@_object);
@ -1085,8 +1085,8 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
// 1. If types includes a sequence type, then:
RefPtr<IDL::ParameterizedType const> sequence_type;
for (auto& type : types) {
if (type.name() == "sequence") {
sequence_type = verify_cast<IDL::ParameterizedType>(type);
if (type->name() == "sequence") {
sequence_type = verify_cast<IDL::ParameterizedType>(*type);
break;
}
}
@ -1125,8 +1125,8 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
// 4. If types includes a record type, then return the result of converting V to that record type.
RefPtr<IDL::ParameterizedType const> record_type;
for (auto& type : types) {
if (type.name() == "record") {
record_type = verify_cast<IDL::ParameterizedType>(type);
if (type->name() == "record") {
record_type = verify_cast<IDL::ParameterizedType>(*type);
break;
}
}
@ -1158,7 +1158,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
// 1. If types includes boolean, then return the result of converting V to boolean.
bool includes_boolean = false;
for (auto& type : types) {
if (type.name() == "boolean") {
if (type->name() == "boolean") {
includes_boolean = true;
break;
}
@ -1173,7 +1173,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
RefPtr<IDL::Type const> numeric_type;
for (auto& type : types) {
if (type.is_numeric()) {
if (type->is_numeric()) {
numeric_type = type;
break;
}
@ -1200,7 +1200,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
// 1. If types includes bigint, then return the result of converting V to bigint
bool includes_bigint = false;
for (auto& type : types) {
if (type.name() == "bigint") {
if (type->name() == "bigint") {
includes_bigint = true;
break;
}
@ -1215,7 +1215,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
bool includes_string = false;
for (auto& type : types) {
if (type.is_string()) {
if (type->is_string()) {
includes_string = true;
break;
}
@ -1831,7 +1831,7 @@ static EffectiveOverloadSet compute_the_effective_overload_set(auto const& overl
int argument_count = (int)arguments.size();
// 3. Let types be a type list.
NonnullRefPtrVector<Type const> types;
Vector<NonnullRefPtr<Type const>> types;
// 4. Let optionalityValues be an optionality list.
Vector<Optionality> optionality_values;
@ -1948,7 +1948,7 @@ static DeprecatedString generate_constructor_for_idl_type(Type const& type)
case Type::Kind::Parameterized: {
auto const& parameterized_type = type.as_parameterized();
StringBuilder builder;
builder.appendff("make_ref_counted<IDL::ParameterizedTypeType>(\"{}\", {}, NonnullRefPtrVector<IDL::Type const> {{", type.name(), type.is_nullable());
builder.appendff("make_ref_counted<IDL::ParameterizedTypeType>(\"{}\", {}, Vector<NonnullRefPtr<IDL::Type const>> {{", type.name(), type.is_nullable());
append_type_list(builder, parameterized_type.parameters());
builder.append("})"sv);
return builder.to_deprecated_string();
@ -1956,7 +1956,7 @@ static DeprecatedString generate_constructor_for_idl_type(Type const& type)
case Type::Kind::Union: {
auto const& union_type = type.as_union();
StringBuilder builder;
builder.appendff("make_ref_counted<IDL::UnionType>(\"{}\", {}, NonnullRefPtrVector<IDL::Type const> {{", type.name(), type.is_nullable());
builder.appendff("make_ref_counted<IDL::UnionType>(\"{}\", {}, Vector<NonnullRefPtr<IDL::Type const>> {{", type.name(), type.is_nullable());
append_type_list(builder, union_type.member_types());
builder.append("})"sv);
return builder.to_deprecated_string();
@ -2015,7 +2015,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@function.name:snakecase@)
continue;
StringBuilder types_builder;
types_builder.append("NonnullRefPtrVector<IDL::Type const> { "sv);
types_builder.append("Vector<NonnullRefPtr<IDL::Type const>> { "sv);
StringBuilder optionality_builder;
optionality_builder.append("Vector<IDL::Optionality> { "sv);

View file

@ -93,16 +93,16 @@ TEST_CASE(create_table)
for (size_t i = 0; i < columns.size(); ++i) {
const auto& column = columns[i];
const auto& expected_column = expected_columns[i];
EXPECT_EQ(column.name(), expected_column.name);
EXPECT_EQ(column->name(), expected_column.name);
const auto& type_name = column.type_name();
const auto& type_name = column->type_name();
EXPECT_EQ(type_name->name(), expected_column.type);
const auto& signed_numbers = type_name->signed_numbers();
EXPECT_EQ(signed_numbers.size(), expected_column.signed_numbers.size());
for (size_t j = 0; j < signed_numbers.size(); ++j) {
double signed_number = signed_numbers[j].value();
double signed_number = signed_numbers[j]->value();
double expected_signed_number = expected_column.signed_numbers[j];
EXPECT_EQ(signed_number, expected_signed_number);
}
@ -227,7 +227,7 @@ TEST_CASE(alter_table_add_column)
EXPECT_EQ(signed_numbers.size(), expected_column.signed_numbers.size());
for (size_t j = 0; j < signed_numbers.size(); ++j) {
double signed_number = signed_numbers[j].value();
double signed_number = signed_numbers[j]->value();
double expected_signed_number = expected_column.signed_numbers[j];
EXPECT_EQ(signed_number, expected_signed_number);
}
@ -337,7 +337,7 @@ TEST_CASE(insert)
for (size_t i = 0; i < chained_expressions.size(); ++i) {
const auto& chained_expression = chained_expressions[i];
const auto& expressions = chained_expression.expressions();
const auto& expressions = chained_expression->expressions();
EXPECT_EQ(expressions.size(), expected_chain_sizes[i]);
for (const auto& expression : expressions)
@ -586,17 +586,17 @@ TEST_CASE(select)
for (size_t i = 0; i < result_column_list.size(); ++i) {
const auto& result_column = result_column_list[i];
const auto& expected_column = expected_columns[i];
EXPECT_EQ(result_column.type(), expected_column.type);
EXPECT_EQ(result_column->type(), expected_column.type);
switch (result_column.type()) {
switch (result_column->type()) {
case SQL::AST::ResultType::All:
EXPECT(expected_column.table_name_or_column_alias.is_null());
break;
case SQL::AST::ResultType::Table:
EXPECT_EQ(result_column.table_name(), expected_column.table_name_or_column_alias);
EXPECT_EQ(result_column->table_name(), expected_column.table_name_or_column_alias);
break;
case SQL::AST::ResultType::Expression:
EXPECT_EQ(result_column.column_alias(), expected_column.table_name_or_column_alias);
EXPECT_EQ(result_column->column_alias(), expected_column.table_name_or_column_alias);
break;
}
}
@ -606,9 +606,9 @@ TEST_CASE(select)
for (size_t i = 0; i < table_or_subquery_list.size(); ++i) {
const auto& result_from = table_or_subquery_list[i];
const auto& expected_from = expected_from_list[i];
EXPECT_EQ(result_from.schema_name(), expected_from.schema_name);
EXPECT_EQ(result_from.table_name(), expected_from.table_name);
EXPECT_EQ(result_from.table_alias(), expected_from.table_alias);
EXPECT_EQ(result_from->schema_name(), expected_from.schema_name);
EXPECT_EQ(result_from->table_name(), expected_from.table_name);
EXPECT_EQ(result_from->table_alias(), expected_from.table_alias);
}
const auto& where_clause = select.where_clause();
@ -635,10 +635,10 @@ TEST_CASE(select)
for (size_t i = 0; i < ordering_term_list.size(); ++i) {
const auto& result_order = ordering_term_list[i];
const auto& expected_order = expected_ordering[i];
EXPECT(!is<SQL::AST::ErrorExpression>(*result_order.expression()));
EXPECT_EQ(result_order.collation_name(), expected_order.collation_name);
EXPECT_EQ(result_order.order(), expected_order.order);
EXPECT_EQ(result_order.nulls(), expected_order.nulls);
EXPECT(!is<SQL::AST::ErrorExpression>(*result_order->expression()));
EXPECT_EQ(result_order->collation_name(), expected_order.collation_name);
EXPECT_EQ(result_order->order(), expected_order.order);
EXPECT_EQ(result_order->nulls(), expected_order.nulls);
}
const auto& limit_clause = select.limit_clause();
@ -731,11 +731,11 @@ TEST_CASE(common_table_expression)
for (size_t i = 0; i < common_table_expressions.size(); ++i) {
const auto& common_table_expression = common_table_expressions[i];
const auto& expected_common_table_expression = expected_selected_tables.selected_tables[i];
EXPECT_EQ(common_table_expression.table_name(), expected_common_table_expression.table_name);
EXPECT_EQ(common_table_expression.column_names().size(), expected_common_table_expression.column_names.size());
EXPECT_EQ(common_table_expression->table_name(), expected_common_table_expression.table_name);
EXPECT_EQ(common_table_expression->column_names().size(), expected_common_table_expression.column_names.size());
for (size_t j = 0; j < common_table_expression.column_names().size(); ++j)
EXPECT_EQ(common_table_expression.column_names()[j], expected_common_table_expression.column_names[j]);
for (size_t j = 0; j < common_table_expression->column_names().size(); ++j)
EXPECT_EQ(common_table_expression->column_names()[j], expected_common_table_expression.column_names[j]);
}
};

View file

@ -257,7 +257,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 1;
}
NonnullRefPtrVector<GUI::Window> applet_windows;
Vector<NonnullRefPtr<GUI::Window>> applet_windows;
auto create_applet = [&](GraphType graph_type, StringView spec) -> ErrorOr<void> {
auto parts = spec.split_view(',');

View file

@ -61,12 +61,12 @@ void URLResult::activate() const
Desktop::Launcher::open(URL::create_with_url_or_path(title()));
}
void AppProvider::query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete)
void AppProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
{
if (query.starts_with('=') || query.starts_with('$'))
return;
NonnullRefPtrVector<Result> results;
Vector<NonnullRefPtr<Result>> results;
Desktop::AppFile::for_each([&](NonnullRefPtr<Desktop::AppFile> app_file) {
auto query_and_arguments = query.split_limit(' ', 2);
@ -83,7 +83,7 @@ void AppProvider::query(DeprecatedString const& query, Function<void(NonnullRefP
on_complete(move(results));
}
void CalculatorProvider::query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete)
void CalculatorProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
{
if (!query.starts_with('='))
return;
@ -108,7 +108,7 @@ void CalculatorProvider::query(DeprecatedString const& query, Function<void(Nonn
calculation = result.to_string_without_side_effects().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
}
NonnullRefPtrVector<Result> results;
Vector<NonnullRefPtr<Result>> results;
results.append(adopt_ref(*new CalculatorResult(calculation)));
on_complete(move(results));
}
@ -123,16 +123,16 @@ FileProvider::FileProvider()
build_filesystem_cache();
}
void FileProvider::query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete)
void FileProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
{
build_filesystem_cache();
if (m_fuzzy_match_work)
m_fuzzy_match_work->cancel();
m_fuzzy_match_work = Threading::BackgroundAction<Optional<NonnullRefPtrVector<Result>>>::construct(
[this, query](auto& task) -> Optional<NonnullRefPtrVector<Result>> {
NonnullRefPtrVector<Result> results;
m_fuzzy_match_work = Threading::BackgroundAction<Optional<Vector<NonnullRefPtr<Result>>>>::construct(
[this, query](auto& task) -> Optional<Vector<NonnullRefPtr<Result>>> {
Vector<NonnullRefPtr<Result>> results;
for (auto& path : m_full_path_cache) {
if (task.is_cancelled())
@ -203,19 +203,19 @@ void FileProvider::build_filesystem_cache()
});
}
void TerminalProvider::query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete)
void TerminalProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
{
if (!query.starts_with('$'))
return;
auto command = query.substring(1).trim_whitespace();
NonnullRefPtrVector<Result> results;
Vector<NonnullRefPtr<Result>> results;
results.append(adopt_ref(*new TerminalResult(move(command))));
on_complete(move(results));
}
void URLProvider::query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete)
void URLProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
{
if (query.is_empty() || query.starts_with('=') || query.starts_with('$'))
return;
@ -232,7 +232,7 @@ void URLProvider::query(DeprecatedString const& query, Function<void(NonnullRefP
if (!url.is_valid())
return;
NonnullRefPtrVector<Result> results;
Vector<NonnullRefPtr<Result>> results;
results.append(adopt_ref(*new URLResult(url)));
on_complete(results);
}

View file

@ -134,28 +134,28 @@ class Provider : public RefCounted<Provider> {
public:
virtual ~Provider() = default;
virtual void query(DeprecatedString const&, Function<void(NonnullRefPtrVector<Result>)> on_complete) = 0;
virtual void query(DeprecatedString const&, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) = 0;
};
class AppProvider final : public Provider {
public:
void query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) override;
void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
};
class CalculatorProvider final : public Provider {
public:
void query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) override;
void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
};
class FileProvider final : public Provider {
public:
FileProvider();
void query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) override;
void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
void build_filesystem_cache();
private:
RefPtr<Threading::BackgroundAction<Optional<NonnullRefPtrVector<Result>>>> m_fuzzy_match_work;
RefPtr<Threading::BackgroundAction<Optional<Vector<NonnullRefPtr<Result>>>>> m_fuzzy_match_work;
bool m_building_cache { false };
Vector<DeprecatedString> m_full_path_cache;
Queue<DeprecatedString> m_work_queue;
@ -163,12 +163,12 @@ private:
class TerminalProvider final : public Provider {
public:
void query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) override;
void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
};
class URLProvider final : public Provider {
public:
void query(DeprecatedString const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) override;
void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
};
}

View file

@ -36,7 +36,7 @@ namespace Assistant {
struct AppState {
Optional<size_t> selected_index;
NonnullRefPtrVector<Result const> results;
Vector<NonnullRefPtr<Result const>> results;
size_t visible_result_count { 0 };
Threading::Mutex lock;
@ -84,7 +84,7 @@ public:
{
}
Function<void(NonnullRefPtrVector<Result const>)> on_new_results;
Function<void(Vector<NonnullRefPtr<Result const>>)> on_new_results;
void search(DeprecatedString const& query)
{
@ -98,7 +98,7 @@ public:
auto& result_array = m_result_cache.ensure(query);
if (result_array.at(i) != nullptr)
return;
result_array[i] = make<NonnullRefPtrVector<Result>>(results);
result_array[i] = make<Vector<NonnullRefPtr<Result>>>(results);
}
on_result_cache_updated();
});
@ -142,7 +142,7 @@ private:
Array<NonnullRefPtr<Provider>, ProviderCount> m_providers;
Threading::Mutex m_mutex;
HashMap<DeprecatedString, Array<OwnPtr<NonnullRefPtrVector<Result>>, ProviderCount>> m_result_cache;
HashMap<DeprecatedString, Array<OwnPtr<Vector<NonnullRefPtr<Result>>>, ProviderCount>> m_result_cache;
};
}
@ -211,7 +211,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (!app_state.selected_index.has_value())
return;
lockfile.release();
app_state.results[app_state.selected_index.value()].activate();
app_state.results[app_state.selected_index.value()]->activate();
GUI::Application::the()->quit();
};
text_box.on_up_pressed = [&]() {
@ -254,11 +254,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
for (size_t i = 0; i < app_state.visible_result_count; ++i) {
auto& result = app_state.results[i];
auto& match = results_container.add<Assistant::ResultRow>();
match.set_icon(result.bitmap());
match.set_text(String::from_deprecated_string(result.title()).release_value_but_fixme_should_propagate_errors());
match.set_tooltip(move(result.tooltip()));
match.set_icon(result->bitmap());
match.set_text(String::from_deprecated_string(result->title()).release_value_but_fixme_should_propagate_errors());
match.set_tooltip(move(result->tooltip()));
match.on_click = [&result](auto) {
result.activate();
result->activate();
GUI::Application::the()->quit();
};
}

View file

@ -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); }));
}
}
}

View file

@ -66,7 +66,7 @@ private:
RefPtr<GUI::Action> m_context_menu_default_action;
DeprecatedString m_context_menu_url;
NonnullRefPtrVector<GUI::Button> m_bookmarks;
Vector<NonnullRefPtr<GUI::Button>> m_bookmarks;
int m_last_visible_index { -1 };
};

View file

@ -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);

View file

@ -38,7 +38,7 @@ private:
RefPtr<GUI::Action> m_create_new_window_action;
RefPtr<GUI::Action> m_next_tab_action;
RefPtr<GUI::Action> m_previous_tab_action;
NonnullRefPtrVector<GUI::Action> m_tab_actions;
Vector<NonnullRefPtr<GUI::Action>> m_tab_actions;
RefPtr<GUI::Action> m_about_action;
RefPtr<GUI::Action> m_show_bookmarks_bar_action;
RefPtr<GUI::Action> m_vertical_tabs_action;

View file

@ -52,21 +52,21 @@ NonnullRefPtr<GUI::Action> LauncherHandler::create_launch_action(Function<void(L
});
}
RefPtr<LauncherHandler> DirectoryView::get_default_launch_handler(NonnullRefPtrVector<LauncherHandler> const& handlers)
RefPtr<LauncherHandler> DirectoryView::get_default_launch_handler(Vector<NonnullRefPtr<LauncherHandler>> const& handlers)
{
// If this is an application, pick it first
for (size_t i = 0; i < handlers.size(); i++) {
if (handlers[i].details().launcher_type == Desktop::Launcher::LauncherType::Application)
if (handlers[i]->details().launcher_type == Desktop::Launcher::LauncherType::Application)
return handlers[i];
}
// If there's a handler preferred by the user, pick this first
for (size_t i = 0; i < handlers.size(); i++) {
if (handlers[i].details().launcher_type == Desktop::Launcher::LauncherType::UserPreferred)
if (handlers[i]->details().launcher_type == Desktop::Launcher::LauncherType::UserPreferred)
return handlers[i];
}
// Otherwise, use the user's default, if available
for (size_t i = 0; i < handlers.size(); i++) {
if (handlers[i].details().launcher_type == Desktop::Launcher::LauncherType::UserDefault)
if (handlers[i]->details().launcher_type == Desktop::Launcher::LauncherType::UserDefault)
return handlers[i];
}
// If still no match, use the first one we find
@ -77,16 +77,16 @@ RefPtr<LauncherHandler> DirectoryView::get_default_launch_handler(NonnullRefPtrV
return {};
}
NonnullRefPtrVector<LauncherHandler> DirectoryView::get_launch_handlers(URL const& url)
Vector<NonnullRefPtr<LauncherHandler>> DirectoryView::get_launch_handlers(URL const& url)
{
NonnullRefPtrVector<LauncherHandler> handlers;
Vector<NonnullRefPtr<LauncherHandler>> handlers;
for (auto& h : Desktop::Launcher::get_handlers_with_details_for_url(url)) {
handlers.append(adopt_ref(*new LauncherHandler(h)));
}
return handlers;
}
NonnullRefPtrVector<LauncherHandler> DirectoryView::get_launch_handlers(DeprecatedString const& path)
Vector<NonnullRefPtr<LauncherHandler>> DirectoryView::get_launch_handlers(DeprecatedString const& path)
{
return get_launch_handlers(URL::create_with_file_scheme(path));
}

View file

@ -58,9 +58,9 @@ public:
void open_next_directory();
int path_history_size() const { return m_path_history.size(); }
int path_history_position() const { return m_path_history_position; }
static RefPtr<LauncherHandler> get_default_launch_handler(NonnullRefPtrVector<LauncherHandler> const& handlers);
static NonnullRefPtrVector<LauncherHandler> get_launch_handlers(URL const& url);
static NonnullRefPtrVector<LauncherHandler> get_launch_handlers(DeprecatedString const& path);
static RefPtr<LauncherHandler> get_default_launch_handler(Vector<NonnullRefPtr<LauncherHandler>> const& handlers);
static Vector<NonnullRefPtr<LauncherHandler>> get_launch_handlers(URL const& url);
static Vector<NonnullRefPtr<LauncherHandler>> get_launch_handlers(DeprecatedString const& path);
void refresh();

View file

@ -66,7 +66,7 @@ static void do_create_archive(Vector<DeprecatedString> const& selected_file_path
static void do_set_wallpaper(DeprecatedString const& file_path, GUI::Window* window);
static void do_unzip_archive(Vector<DeprecatedString> const& selected_file_paths, GUI::Window* window);
static void show_properties(DeprecatedString const& container_dir_path, DeprecatedString const& path, Vector<DeprecatedString> const& selected, GUI::Window* window);
static bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr<GUI::Action>& default_action, NonnullRefPtrVector<LauncherHandler>& current_file_launch_handlers);
static bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr<GUI::Action>& default_action, Vector<NonnullRefPtr<LauncherHandler>>& current_file_launch_handlers);
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
@ -310,7 +310,7 @@ void show_properties(DeprecatedString const& container_dir_path, DeprecatedStrin
properties->show();
}
bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr<GUI::Action>& default_action, NonnullRefPtrVector<LauncherHandler>& current_file_launch_handlers)
bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr<GUI::Action>& default_action, Vector<NonnullRefPtr<LauncherHandler>>& current_file_launch_handlers)
{
current_file_launch_handlers = directory_view.get_launch_handlers(full_path);
@ -337,9 +337,9 @@ bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView c
added_open_menu_items = true;
auto& file_open_with_menu = menu->add_submenu("Open with");
for (auto& handler : current_file_launch_handlers) {
if (&handler == default_file_handler.ptr())
if (handler == default_file_handler)
continue;
file_open_with_menu.add_action(handler.create_launch_action([&, full_path = move(full_path)](auto& launcher_handler) {
file_open_with_menu.add_action(handler->create_launch_action([&, full_path = move(full_path)](auto& launcher_handler) {
directory_view.launch(URL::create_with_file_scheme(full_path), launcher_handler);
}));
}
@ -502,7 +502,7 @@ ErrorOr<int> run_in_desktop_mode()
TRY(desktop_context_menu->try_add_action(properties_action));
RefPtr<GUI::Menu> file_context_menu;
NonnullRefPtrVector<LauncherHandler> current_file_handlers;
Vector<NonnullRefPtr<LauncherHandler>> current_file_handlers;
RefPtr<GUI::Action> file_context_menu_action_default_action;
directory_view->on_context_menu_request = [&](GUI::ModelIndex const& index, GUI::ContextMenuEvent const& event) {
@ -1168,7 +1168,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
TRY(tree_view_directory_context_menu->try_add_action(properties_action));
RefPtr<GUI::Menu> file_context_menu;
NonnullRefPtrVector<LauncherHandler> current_file_handlers;
Vector<NonnullRefPtr<LauncherHandler>> current_file_handlers;
RefPtr<GUI::Action> file_context_menu_action_default_action;
directory_view->on_context_menu_request = [&](GUI::ModelIndex const& index, GUI::ContextMenuEvent const& event) {

View file

@ -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);
}
};

View file

@ -17,7 +17,7 @@ void AccountHolder::add_account_with_name_and_mailboxes(DeprecatedString name, V
auto account = AccountNode::create(move(name));
// This holds all of the ancestors of the current leaf folder.
NonnullRefPtrVector<MailboxNode> folder_stack;
Vector<NonnullRefPtr<MailboxNode>> folder_stack;
for (auto& mailbox : mailboxes) {
// mailbox.name is converted to StringView to get access to split by string.
@ -44,7 +44,7 @@ void AccountHolder::add_account_with_name_and_mailboxes(DeprecatedString name, V
// Only keep the ancestors of the current leaf folder.
folder_stack.shrink(subfolders.size() - 1);
parent_folder.add_child(mailbox_node);
parent_folder->add_child(mailbox_node);
VERIFY(!mailbox_node->has_parent());
mailbox_node->set_parent(parent_folder);
@ -54,7 +54,7 @@ void AccountHolder::add_account_with_name_and_mailboxes(DeprecatedString name, V
} else {
// FIXME: This assumes that the server has the "CHILDREN" capability.
if (mailbox.flags & (unsigned)IMAP::MailboxFlag::HasChildren) {
if (!folder_stack.is_empty() && folder_stack.first().select_name() != mailbox.name) {
if (!folder_stack.is_empty() && folder_stack.first()->select_name() != mailbox.name) {
// This is a new root folder, clear the stack as there are no ancestors of the current leaf folder at this point.
folder_stack.clear();
}

View file

@ -34,7 +34,7 @@ public:
m_mailboxes.append(move(mailbox));
}
NonnullRefPtrVector<MailboxNode> const& mailboxes() const { return m_mailboxes; }
Vector<NonnullRefPtr<MailboxNode>> const& mailboxes() const { return m_mailboxes; }
DeprecatedString const& name() const { return m_name; }
private:
@ -44,7 +44,7 @@ private:
}
DeprecatedString m_name;
NonnullRefPtrVector<MailboxNode> m_mailboxes;
Vector<NonnullRefPtr<MailboxNode>> m_mailboxes;
};
class MailboxNode final : public BaseNode {
@ -66,7 +66,7 @@ public:
void set_parent(NonnullRefPtr<MailboxNode> parent) { m_parent = parent; }
bool has_children() const { return !m_children.is_empty(); }
NonnullRefPtrVector<MailboxNode> const& children() const { return m_children; }
Vector<NonnullRefPtr<MailboxNode>> const& children() const { return m_children; }
void add_child(NonnullRefPtr<MailboxNode> child) { m_children.append(child); }
private:
@ -81,7 +81,7 @@ private:
IMAP::ListItem m_mailbox;
DeprecatedString m_display_name;
NonnullRefPtrVector<MailboxNode> m_children;
Vector<NonnullRefPtr<MailboxNode>> m_children;
RefPtr<MailboxNode> m_parent;
};
@ -96,7 +96,7 @@ public:
void add_account_with_name_and_mailboxes(DeprecatedString, Vector<IMAP::ListItem> const&);
NonnullRefPtrVector<AccountNode> const& accounts() const { return m_accounts; }
Vector<NonnullRefPtr<AccountNode>> const& accounts() const { return m_accounts; }
MailboxTreeModel& mailbox_tree_model() { return *m_mailbox_tree_model; }
private:
@ -104,6 +104,6 @@ private:
void rebuild_tree();
NonnullRefPtrVector<AccountNode> m_accounts;
Vector<NonnullRefPtr<AccountNode>> m_accounts;
RefPtr<MailboxTreeModel> m_mailbox_tree_model;
};

View file

@ -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());
}
}

View file

@ -118,9 +118,9 @@ GUI::ModelIndex OutlineModel::parent_index(const GUI::ModelIndex& index) const
if (!parent)
return {};
NonnullRefPtrVector<PDF::OutlineItem> parent_siblings = (parent->parent ? parent->parent->children : m_outline->children);
Vector<NonnullRefPtr<PDF::OutlineItem>> parent_siblings = (parent->parent ? parent->parent->children : m_outline->children);
for (size_t i = 0; i < parent_siblings.size(); i++) {
auto* parent_sibling = &parent_siblings[i];
auto* parent_sibling = parent_siblings[i].ptr();
if (parent_sibling == parent.ptr())
return create_index(static_cast<int>(i), index.column(), parent.ptr());
}

View file

@ -30,5 +30,5 @@ private:
TrackManager& m_track_manager;
MainWidget& m_main_widget;
NonnullRefPtrVector<ProcessorParameterWidget> m_parameter_widgets;
Vector<NonnullRefPtr<ProcessorParameterWidget>> m_parameter_widgets;
};

View file

@ -42,11 +42,11 @@ void Image::paint_into(GUI::Painter& painter, Gfx::IntRect const& dest_rect, flo
Gfx::PainterStateSaver saver(painter);
painter.add_clip_rect(dest_rect);
for (auto const& layer : m_layers) {
if (!layer.is_visible())
if (!layer->is_visible())
continue;
auto target = dest_rect.to_type<float>().translated(layer.location().x() * scale, layer.location().y() * scale);
target.set_size(layer.size().width() * scale, layer.size().height() * scale);
painter.draw_scaled_bitmap(target.to_type<int>(), layer.display_bitmap(), layer.rect(), (float)layer.opacity_percent() / 100.0f);
auto target = dest_rect.to_type<float>().translated(layer->location().x() * scale, layer->location().y() * scale);
target.set_size(layer->size().width() * scale, layer->size().height() * scale);
painter.draw_scaled_bitmap(target.to_type<int>(), layer->display_bitmap(), layer->rect(), (float)layer->opacity_percent() / 100.0f);
}
}
@ -126,17 +126,17 @@ ErrorOr<void> Image::serialize_as_json(JsonObjectSerializer<StringBuilder>& json
auto json_layers = TRY(json.add_array("layers"sv));
for (auto const& layer : m_layers) {
auto json_layer = TRY(json_layers.add_object());
TRY(json_layer.add("width"sv, layer.size().width()));
TRY(json_layer.add("height"sv, layer.size().height()));
TRY(json_layer.add("name"sv, layer.name()));
TRY(json_layer.add("locationx"sv, layer.location().x()));
TRY(json_layer.add("locationy"sv, layer.location().y()));
TRY(json_layer.add("opacity_percent"sv, layer.opacity_percent()));
TRY(json_layer.add("visible"sv, layer.is_visible()));
TRY(json_layer.add("selected"sv, layer.is_selected()));
TRY(json_layer.add("bitmap"sv, TRY(encode_base64(TRY(Gfx::PNGWriter::encode(layer.content_bitmap()))))));
if (layer.is_masked())
TRY(json_layer.add("mask"sv, TRY(encode_base64(TRY(Gfx::PNGWriter::encode(*layer.mask_bitmap()))))));
TRY(json_layer.add("width"sv, layer->size().width()));
TRY(json_layer.add("height"sv, layer->size().height()));
TRY(json_layer.add("name"sv, layer->name()));
TRY(json_layer.add("locationx"sv, layer->location().x()));
TRY(json_layer.add("locationy"sv, layer->location().y()));
TRY(json_layer.add("opacity_percent"sv, layer->opacity_percent()));
TRY(json_layer.add("visible"sv, layer->is_visible()));
TRY(json_layer.add("selected"sv, layer->is_selected()));
TRY(json_layer.add("bitmap"sv, TRY(encode_base64(TRY(Gfx::PNGWriter::encode(layer->content_bitmap()))))));
if (layer->is_masked())
TRY(json_layer.add("mask"sv, TRY(encode_base64(TRY(Gfx::PNGWriter::encode(*layer->mask_bitmap()))))));
TRY(json_layer.finish());
}
@ -204,7 +204,7 @@ ErrorOr<void> Image::export_qoi_to_file(NonnullOwnPtr<Stream> stream) const
void Image::add_layer(NonnullRefPtr<Layer> layer)
{
for (auto& existing_layer : m_layers) {
VERIFY(&existing_layer != layer.ptr());
VERIFY(existing_layer != layer);
}
m_layers.append(move(layer));
@ -256,7 +256,7 @@ ErrorOr<void> Image::restore_snapshot(Image const& snapshot)
size_t Image::index_of(Layer const& layer) const
{
for (size_t i = 0; i < m_layers.size(); ++i) {
if (&m_layers.at(i) == &layer)
if (m_layers[i] == &layer)
return i;
}
VERIFY_NOT_REACHED();
@ -350,18 +350,18 @@ ErrorOr<void> Image::merge_layers(LayerMergeMode layer_merge_mode)
if (m_layers.size() < 2)
return {};
NonnullRefPtrVector<Layer> new_layers;
Vector<NonnullRefPtr<Layer>> new_layers;
Gfx::IntRect merged_layer_bounding_rect = {};
size_t bottom_layer_index = 0;
for (auto const& layer : m_layers) {
if (!layer.is_visible()) {
if (!layer->is_visible()) {
if (layer_merge_mode == LayerMergeMode::VisibleOnly)
TRY(new_layers.try_append(layer));
if (merged_layer_bounding_rect.is_empty())
bottom_layer_index++;
continue;
}
merged_layer_bounding_rect = merged_layer_bounding_rect.united(layer.relative_rect());
merged_layer_bounding_rect = merged_layer_bounding_rect.united(layer->relative_rect());
}
if (merged_layer_bounding_rect.is_empty())
@ -379,9 +379,9 @@ ErrorOr<void> Image::merge_layers(LayerMergeMode layer_merge_mode)
painter.blit(bottom_layer->location() - merged_layer->location(), bottom_layer->display_bitmap(), bottom_layer->rect(), static_cast<float>(bottom_layer->opacity_percent()) / 100.0f);
for (size_t index = bottom_layer_index + 1; index < m_layers.size(); index++) {
auto& layer = m_layers.at(index);
if (!layer.is_visible())
if (!layer->is_visible())
continue;
painter.blit(layer.location() - merged_layer->location(), layer.display_bitmap(), layer.rect(), static_cast<float>(layer.opacity_percent()) / 100.0f);
painter.blit(layer->location() - merged_layer->location(), layer->display_bitmap(), layer->rect(), static_cast<float>(layer->opacity_percent()) / 100.0f);
}
TRY(new_layers.try_append(merged_layer));
@ -421,7 +421,7 @@ ErrorOr<void> Image::merge_active_layer(NonnullRefPtr<Layer> const& layer, Layer
Optional<NonnullRefPtr<Layer>> maybe_adjacent_layer;
while (layer_to_merge_index >= 0 && layer_to_merge_index < layer_count) {
auto& layer = m_layers.at(layer_to_merge_index);
auto const& layer = *m_layers[layer_to_merge_index];
if (layer.is_visible()) {
maybe_adjacent_layer = layer;
break;
@ -541,7 +541,7 @@ ErrorOr<void> Image::flip(Gfx::Orientation orientation)
auto& layer = m_layers[i];
auto new_layer = TRY(Layer::create_snapshot(*this, layer));
if (layer.is_selected())
if (layer->is_selected())
selected_layer_index = i;
TRY(new_layer->flip(orientation, Layer::NotifyClients::No));
@ -551,9 +551,9 @@ ErrorOr<void> Image::flip(Gfx::Orientation orientation)
m_layers = move(flipped_layers);
for (auto& layer : m_layers)
layer.did_modify_bitmap({}, Layer::NotifyClients::No);
layer->did_modify_bitmap({}, Layer::NotifyClients::No);
select_layer(&m_layers[selected_layer_index]);
select_layer(m_layers[selected_layer_index]);
did_change();
@ -572,7 +572,7 @@ ErrorOr<void> Image::rotate(Gfx::RotationDirection direction)
auto& layer = m_layers[i];
auto new_layer = TRY(Layer::create_snapshot(*this, layer));
if (layer.is_selected())
if (layer->is_selected())
selected_layer_index = i;
TRY(new_layer->rotate(direction, Layer::NotifyClients::No));
@ -582,9 +582,9 @@ ErrorOr<void> Image::rotate(Gfx::RotationDirection direction)
m_layers = move(rotated_layers);
for (auto& layer : m_layers)
layer.did_modify_bitmap({}, Layer::NotifyClients::Yes);
layer->did_modify_bitmap({}, Layer::NotifyClients::Yes);
select_layer(&m_layers[selected_layer_index]);
select_layer(m_layers[selected_layer_index]);
m_size = { m_size.height(), m_size.width() };
did_change_rect();
@ -604,7 +604,7 @@ ErrorOr<void> Image::crop(Gfx::IntRect const& cropped_rect)
auto& layer = m_layers[i];
auto new_layer = TRY(Layer::create_snapshot(*this, layer));
if (layer.is_selected())
if (layer->is_selected())
selected_layer_index = i;
auto layer_location = new_layer->location();
@ -621,9 +621,9 @@ ErrorOr<void> Image::crop(Gfx::IntRect const& cropped_rect)
m_layers = move(cropped_layers);
for (auto& layer : m_layers)
layer.did_modify_bitmap({}, Layer::NotifyClients::Yes);
layer->did_modify_bitmap({}, Layer::NotifyClients::Yes);
select_layer(&m_layers[selected_layer_index]);
select_layer(m_layers[selected_layer_index]);
m_size = { cropped_rect.width(), cropped_rect.height() };
did_change_rect(cropped_rect);
@ -638,10 +638,10 @@ Optional<Gfx::IntRect> Image::nonempty_content_bounding_rect() const
Optional<Gfx::IntRect> bounding_rect;
for (auto const& layer : m_layers) {
auto layer_content_rect_in_layer_coordinates = layer.nonempty_content_bounding_rect();
auto layer_content_rect_in_layer_coordinates = layer->nonempty_content_bounding_rect();
if (!layer_content_rect_in_layer_coordinates.has_value())
continue;
auto layer_content_rect_in_image_coordinates = layer_content_rect_in_layer_coordinates->translated(layer.location());
auto layer_content_rect_in_image_coordinates = layer_content_rect_in_layer_coordinates->translated(layer->location());
if (!bounding_rect.has_value())
bounding_rect = layer_content_rect_in_image_coordinates;
else
@ -674,7 +674,7 @@ ErrorOr<void> Image::resize(Gfx::IntSize new_size, Gfx::Painter::ScalingMode sca
auto& layer = m_layers[i];
auto new_layer = TRY(Layer::create_snapshot(*this, layer));
if (layer.is_selected())
if (layer->is_selected())
selected_layer_index = i;
Gfx::IntPoint new_location(scale_x * new_layer->location().x(), scale_y * new_layer->location().y());
@ -685,9 +685,9 @@ ErrorOr<void> Image::resize(Gfx::IntSize new_size, Gfx::Painter::ScalingMode sca
m_layers = move(resized_layers);
for (auto& layer : m_layers)
layer.did_modify_bitmap({}, Layer::NotifyClients::Yes);
layer->did_modify_bitmap({}, Layer::NotifyClients::Yes);
select_layer(&m_layers[selected_layer_index]);
select_layer(m_layers[selected_layer_index]);
m_size = { new_size.width(), new_size.height() };
did_change_rect();
@ -699,11 +699,11 @@ Color Image::color_at(Gfx::IntPoint point) const
{
Color color;
for (auto const& layer : m_layers) {
if (!layer.is_visible() || !layer.rect().contains(point))
if (!layer->is_visible() || !layer->rect().contains(point))
continue;
auto layer_color = layer.display_bitmap().get_pixel(point);
float layer_opacity = layer.opacity_percent() / 100.0f;
auto layer_color = layer->display_bitmap().get_pixel(point);
float layer_opacity = layer->opacity_percent() / 100.0f;
layer_color.set_alpha((u8)(layer_color.alpha() * layer_opacity));
color = color.blend(layer_color);
}

View file

@ -126,7 +126,7 @@ private:
ErrorOr<void> merge_active_layer(NonnullRefPtr<Layer> const&, LayerMergeDirection);
Gfx::IntSize m_size;
NonnullRefPtrVector<Layer> m_layers;
Vector<NonnullRefPtr<Layer>> m_layers;
HashTable<ImageClient*> m_clients;

View file

@ -187,11 +187,11 @@ void ImageEditor::paint_event(GUI::PaintEvent& event)
if (m_show_guides) {
for (auto& guide : m_guides) {
if (guide.orientation() == Guide::Orientation::Horizontal) {
int y_coordinate = (int)content_to_frame_position({ 0.0f, guide.offset() }).y();
if (guide->orientation() == Guide::Orientation::Horizontal) {
int y_coordinate = (int)content_to_frame_position({ 0.0f, guide->offset() }).y();
painter.draw_line({ 0, y_coordinate }, { rect().width(), y_coordinate }, Color::Cyan, 1, Gfx::Painter::LineStyle::Dashed, Color::LightGray);
} else if (guide.orientation() == Guide::Orientation::Vertical) {
int x_coordinate = (int)content_to_frame_position({ guide.offset(), 0.0f }).x();
} else if (guide->orientation() == Guide::Orientation::Vertical) {
int x_coordinate = (int)content_to_frame_position({ guide->offset(), 0.0f }).x();
painter.draw_line({ x_coordinate, 0 }, { x_coordinate, rect().height() }, Color::Cyan, 1, Gfx::Painter::LineStyle::Dashed, Color::LightGray);
}
}
@ -768,10 +768,10 @@ ErrorOr<void> ImageEditor::save_project_to_file(NonnullOwnPtr<Core::File> file)
auto json_guides = TRY(json.add_array("guides"sv));
for (auto const& guide : m_guides) {
auto json_guide = TRY(json_guides.add_object());
TRY(json_guide.add("offset"sv, (double)guide.offset()));
if (guide.orientation() == Guide::Orientation::Vertical)
TRY(json_guide.add("offset"sv, (double)guide->offset()));
if (guide->orientation() == Guide::Orientation::Vertical)
TRY(json_guide.add("orientation"sv, "vertical"));
else if (guide.orientation() == Guide::Orientation::Horizontal)
else if (guide->orientation() == Guide::Orientation::Horizontal)
TRY(json_guide.add("orientation"sv, "horizontal"));
TRY(json_guide.finish());
}

View file

@ -94,7 +94,7 @@ public:
void save_project_as();
void save_project();
NonnullRefPtrVector<Guide> const& guides() const { return m_guides; }
Vector<NonnullRefPtr<Guide>> const& guides() const { return m_guides; }
bool guide_visibility() { return m_show_guides; }
void set_guide_visibility(bool show_guides);
Function<void(bool)> on_set_guide_visibility;
@ -168,7 +168,7 @@ private:
DeprecatedString m_path;
DeprecatedString m_title;
NonnullRefPtrVector<Guide> m_guides;
Vector<NonnullRefPtr<Guide>> m_guides;
bool m_show_guides { true };
bool m_show_rulers { true };
bool m_show_pixel_grid { true };

View file

@ -24,15 +24,15 @@ RefPtr<Guide> GuideTool::closest_guide(Gfx::IntPoint point)
for (auto& guide : guides) {
int relevant_position = 0;
if (guide.orientation() == Guide::Orientation::Horizontal)
if (guide->orientation() == Guide::Orientation::Horizontal)
relevant_position = point.y();
else if (guide.orientation() == Guide::Orientation::Vertical)
else if (guide->orientation() == Guide::Orientation::Vertical)
relevant_position = point.x();
auto distance = abs(relevant_position - (int)guide.offset());
auto distance = abs(relevant_position - (int)guide->offset());
if (distance < closest_guide_distance) {
closest_guide = &guide;
closest_guide = guide;
closest_guide_distance = distance;
}
}

View file

@ -30,9 +30,9 @@ void TextToolEditor::handle_keyevent(Badge<TextTool>, GUI::KeyEvent& event)
TextEditor::keydown_event(event);
}
NonnullRefPtrVector<GUI::Action> TextToolEditor::actions()
Vector<NonnullRefPtr<GUI::Action>> TextToolEditor::actions()
{
static NonnullRefPtrVector<GUI::Action> actions = { cut_action(), copy_action(), paste_action(), undo_action(), redo_action(), select_all_action() };
static Vector<NonnullRefPtr<GUI::Action>> actions = { cut_action(), copy_action(), paste_action(), undo_action(), redo_action(), select_all_action() };
return actions;
}
@ -290,9 +290,9 @@ bool TextTool::on_keydown(GUI::KeyEvent& event)
// Pass key events that would normally be handled by menu shortcuts to our TextEditor subclass.
for (auto& action : m_text_editor->actions()) {
auto const& shortcut = action.shortcut();
auto const& shortcut = action->shortcut();
if (event.key() == shortcut.key() && event.modifiers() == shortcut.modifiers()) {
action.activate(m_text_editor);
action->activate(m_text_editor);
return true;
}
}

View file

@ -22,7 +22,7 @@ class TextToolEditor : public GUI::TextEditor {
public:
virtual ~TextToolEditor() override = default;
virtual void handle_keyevent(Badge<TextTool>, GUI::KeyEvent&);
NonnullRefPtrVector<GUI::Action> actions();
Vector<NonnullRefPtr<GUI::Action>> actions();
protected:
TextToolEditor();

View file

@ -9,7 +9,7 @@
#include "Presentation.h"
#include <AK/JsonObject.h>
Slide::Slide(NonnullRefPtrVector<SlideObject> slide_objects, DeprecatedString title)
Slide::Slide(Vector<NonnullRefPtr<SlideObject>> slide_objects, DeprecatedString title)
: m_slide_objects(move(slide_objects))
, m_title(move(title))
{
@ -25,7 +25,7 @@ ErrorOr<Slide> Slide::parse_slide(JsonObject const& slide_json)
return Error::from_string_view("Slide objects must be an array"sv);
auto const& json_slide_objects = maybe_slide_objects.value();
NonnullRefPtrVector<SlideObject> slide_objects;
Vector<NonnullRefPtr<SlideObject>> slide_objects;
for (auto const& maybe_slide_object_json : json_slide_objects.values()) {
if (!maybe_slide_object_json.is_object())
return Error::from_string_view("Slides must be objects"sv);
@ -43,6 +43,6 @@ ErrorOr<HTMLElement> Slide::render(Presentation const& presentation) const
HTMLElement wrapper;
wrapper.tag_name = "div"sv;
for (auto const& object : m_slide_objects)
TRY(wrapper.children.try_append(TRY(object.render(presentation))));
TRY(wrapper.children.try_append(TRY(object->render(presentation))));
return wrapper;
}

View file

@ -24,8 +24,8 @@ public:
ErrorOr<HTMLElement> render(Presentation const&) const;
private:
Slide(NonnullRefPtrVector<SlideObject> slide_objects, DeprecatedString title);
Slide(Vector<NonnullRefPtr<SlideObject>> slide_objects, DeprecatedString title);
NonnullRefPtrVector<SlideObject> m_slide_objects;
Vector<NonnullRefPtr<SlideObject>> m_slide_objects;
DeprecatedString m_title;
};

View file

@ -52,7 +52,7 @@ private:
ConditionsView();
Vector<ConditionalFormat>* m_formats { nullptr };
NonnullRefPtrVector<GUI::Widget> m_widgets;
Vector<NonnullRefPtr<GUI::Widget>> m_widgets;
};
}

View file

@ -202,7 +202,7 @@ ErrorOr<void> ExportDialog::make_and_run_for(StringView mime, Core::File& file,
auto export_worksheet = [&]() -> ErrorOr<void> {
JsonArray array;
for (auto& sheet : workbook.sheets())
array.append(sheet.to_json());
array.append(sheet->to_json());
auto file_content = array.to_deprecated_string();
return file.write_entire_buffer(file_content.bytes());

View file

@ -112,7 +112,7 @@ HelpWindow::HelpWindow(GUI::Window* parent)
window->set_title(DeprecatedString::formatted("Spreadsheet Help - Example {} for {}", name, entry));
window->on_close = [window = window.ptr()] { window->remove_from_parent(); };
auto widget = window->set_main_widget<SpreadsheetWidget>(window, NonnullRefPtrVector<Sheet> {}, false).release_value_but_fixme_should_propagate_errors();
auto widget = window->set_main_widget<SpreadsheetWidget>(window, Vector<NonnullRefPtr<Sheet>> {}, false).release_value_but_fixme_should_propagate_errors();
auto sheet = Sheet::from_json(value, widget->workbook());
if (!sheet) {
GUI::MessageBox::show_error(this, DeprecatedString::formatted("Corrupted example '{}' in '{}'", name, url.path()));

View file

@ -174,13 +174,13 @@ void CSVImportDialogPage::update_preview()
m_data_preview_table_view->update();
}
ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> ImportDialog::make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook& workbook)
ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> ImportDialog::make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook& workbook)
{
auto wizard = GUI::WizardDialog::construct(&parent);
wizard->set_title("File Import Wizard");
wizard->set_icon(GUI::Icon::default_icon("app-spreadsheet"sv).bitmap_for_size(16));
auto import_xsv = [&]() -> ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> {
auto import_xsv = [&]() -> ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> {
auto contents_or_error = file.read_until_eof();
if (contents_or_error.is_error())
return DeprecatedString::formatted("{}", contents_or_error.release_error());
@ -191,7 +191,7 @@ ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> ImportDialog::make_and_run
if (result == GUI::Dialog::ExecResult::OK) {
auto& reader = page.reader();
NonnullRefPtrVector<Sheet> sheets;
Vector<NonnullRefPtr<Sheet>> sheets;
if (reader.has_value()) {
reader->parse();
@ -209,7 +209,7 @@ ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> ImportDialog::make_and_run
return DeprecatedString { "CSV Import was cancelled" };
};
auto import_worksheet = [&]() -> ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> {
auto import_worksheet = [&]() -> ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> {
auto contents_or_error = file.read_until_eof();
if (contents_or_error.is_error())
return DeprecatedString::formatted("{}", contents_or_error.release_error());
@ -221,7 +221,7 @@ ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> ImportDialog::make_and_run
if (!json_value.is_array())
return DeprecatedString::formatted("Did not find a spreadsheet in {}", filename);
NonnullRefPtrVector<Sheet> sheets;
Vector<NonnullRefPtr<Sheet>> sheets;
auto& json_array = json_value.as_array();
json_array.for_each([&](auto& sheet_json) {

View file

@ -55,7 +55,7 @@ private:
};
struct ImportDialog {
static ErrorOr<NonnullRefPtrVector<Sheet>, DeprecatedString> make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook&);
static ErrorOr<Vector<NonnullRefPtr<Sheet>>, DeprecatedString> make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook&);
};
}

View file

@ -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();

View file

@ -27,7 +27,7 @@
namespace Spreadsheet {
SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVector<Sheet>&& sheets, bool should_add_sheet_if_empty)
SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, Vector<NonnullRefPtr<Sheet>>&& sheets, bool should_add_sheet_if_empty)
: m_workbook(make<Workbook>(move(sheets), parent_window))
{
set_fill_with_background_color(true);
@ -111,7 +111,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
m_tab_context_menu->add_action(GUI::Action::create("Add new sheet...", Gfx::Bitmap::load_from_file("/res/icons/16x16/new-tab.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
DeprecatedString name;
if (GUI::InputBox::show(window(), name, "Name for new sheet"sv, "Create sheet"sv) == GUI::Dialog::ExecResult::OK) {
NonnullRefPtrVector<Sheet> new_sheets;
Vector<NonnullRefPtr<Sheet>> new_sheets;
new_sheets.append(m_workbook->add_sheet(name));
setup_tabs(move(new_sheets));
}
@ -330,10 +330,10 @@ void SpreadsheetWidget::clipboard_content_did_change(DeprecatedString const& mim
m_paste_action->set_enabled(!sheet->selected_cells().is_empty() && mime_type.starts_with("text/"sv));
}
void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
void SpreadsheetWidget::setup_tabs(Vector<NonnullRefPtr<Sheet>> new_sheets)
{
for (auto& sheet : new_sheets) {
auto& new_view = m_tab_widget->add_tab<SpreadsheetView>(sheet.name(), sheet);
auto& new_view = m_tab_widget->add_tab<SpreadsheetView>(sheet->name(), sheet);
new_view.model()->on_cell_data_change = [&](auto& cell, auto& previous_data) {
undo_stack().push(make<CellsUndoCommand>(cell, previous_data));
window()->set_modified(true);
@ -570,7 +570,7 @@ void SpreadsheetWidget::add_sheet()
name.append("Sheet"sv);
name.appendff(" {}", m_workbook->sheets().size() + 1);
NonnullRefPtrVector<Sheet> new_sheets;
Vector<NonnullRefPtr<Sheet>> new_sheets;
new_sheets.append(m_workbook->add_sheet(name.string_view()));
setup_tabs(move(new_sheets));
}
@ -579,7 +579,7 @@ void SpreadsheetWidget::add_sheet(NonnullRefPtr<Sheet>&& sheet)
{
VERIFY(m_workbook == &sheet->workbook());
NonnullRefPtrVector<Sheet> new_sheets;
Vector<NonnullRefPtr<Sheet>> new_sheets;
new_sheets.append(move(sheet));
m_workbook->sheets().extend(new_sheets);
setup_tabs(new_sheets);

View file

@ -60,9 +60,9 @@ private:
// ^GUI::Clipboard::ClipboardClient
virtual void clipboard_content_did_change(DeprecatedString const& mime_type) override;
explicit SpreadsheetWidget(GUI::Window& window, NonnullRefPtrVector<Sheet>&& sheets = {}, bool should_add_sheet_if_empty = true);
explicit SpreadsheetWidget(GUI::Window& window, Vector<NonnullRefPtr<Sheet>>&& sheets = {}, bool should_add_sheet_if_empty = true);
void setup_tabs(NonnullRefPtrVector<Sheet> new_sheets);
void setup_tabs(Vector<NonnullRefPtr<Sheet>> new_sheets);
void try_generate_tip_for_input_expression(StringView source, size_t offset);

View file

@ -18,7 +18,7 @@
namespace Spreadsheet {
Workbook::Workbook(NonnullRefPtrVector<Sheet>&& sheets, GUI::Window& parent_window)
Workbook::Workbook(Vector<NonnullRefPtr<Sheet>>&& sheets, GUI::Window& parent_window)
: m_sheets(move(sheets))
, m_vm(JS::VM::create())
, m_interpreter(JS::Interpreter::create<JS::GlobalObject>(m_vm))

View file

@ -14,7 +14,7 @@ namespace Spreadsheet {
class Workbook {
public:
Workbook(NonnullRefPtrVector<Sheet>&& sheets, GUI::Window& parent_window);
Workbook(Vector<NonnullRefPtr<Sheet>>&& sheets, GUI::Window& parent_window);
ErrorOr<void, DeprecatedString> open_file(String const& filename, Core::File&);
ErrorOr<void> write_to_file(String const& filename, Core::File&);
@ -28,8 +28,8 @@ public:
bool has_sheets() const { return !m_sheets.is_empty(); }
NonnullRefPtrVector<Sheet> const& sheets() const { return m_sheets; }
NonnullRefPtrVector<Sheet> sheets() { return m_sheets; }
Vector<NonnullRefPtr<Sheet>> const& sheets() const { return m_sheets; }
Vector<NonnullRefPtr<Sheet>> sheets() { return m_sheets; }
Sheet& add_sheet(StringView name)
{
@ -43,7 +43,7 @@ public:
JS::VM const& vm() const { return *m_vm; }
private:
NonnullRefPtrVector<Sheet> m_sheets;
Vector<NonnullRefPtr<Sheet>> m_sheets;
NonnullRefPtr<JS::VM> m_vm;
NonnullOwnPtr<JS::Interpreter> m_interpreter;
JS::VM::InterpreterExecutionScope m_interpreter_scope;

View file

@ -51,7 +51,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->resize(640, 480);
window->set_icon(app_icon.bitmap_for_size(16));
auto spreadsheet_widget = TRY(window->set_main_widget<Spreadsheet::SpreadsheetWidget>(*window, NonnullRefPtrVector<Spreadsheet::Sheet> {}, filename.is_empty()));
auto spreadsheet_widget = TRY(window->set_main_widget<Spreadsheet::SpreadsheetWidget>(*window, Vector<NonnullRefPtr<Spreadsheet::Sheet>> {}, filename.is_empty()));
spreadsheet_widget->initialize_menubar(*window);
spreadsheet_widget->update_window_title();

View file

@ -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);
}

View file

@ -207,7 +207,7 @@ private:
struct Process {
pid_t pid;
NonnullRefPtrVector<Thread> threads;
Vector<NonnullRefPtr<Thread>> threads;
bool operator==(Process const& other) const
{
@ -224,7 +224,7 @@ private:
{
auto main_thread_index = -1;
for (size_t i = 0; i < threads.size(); ++i) {
if (threads[i].is_main_thread()) {
if (threads[i]->is_main_thread()) {
main_thread_index = static_cast<int>(i);
break;
}

View file

@ -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();
});

View file

@ -45,7 +45,7 @@ public:
private:
explicit ProjectTemplatesModel();
NonnullRefPtrVector<ProjectTemplate> m_templates;
Vector<NonnullRefPtr<ProjectTemplate>> m_templates;
Vector<ProjectTemplate*> m_mapping;
RefPtr<Core::FileWatcher> m_file_watcher;

View file

@ -265,7 +265,7 @@ void HackStudioWidget::open_project(DeprecatedString const& root_path)
debugger.set_source_root(m_project->root_path());
}
for (auto& editor_wrapper : m_all_editor_wrappers)
editor_wrapper.set_project_root(m_project->root_path());
editor_wrapper->set_project_root(m_project->root_path());
m_locations_history.clear();
m_locations_history_end_index = 0;
@ -398,19 +398,19 @@ void HackStudioWidget::close_file_in_all_editors(DeprecatedString const& filenam
[&filename](DeprecatedString const& element) { return element == filename; });
for (auto& editor_wrapper : m_all_editor_wrappers) {
Editor& editor = editor_wrapper.editor();
Editor& editor = editor_wrapper->editor();
DeprecatedString editor_file_path = editor.code_document().file_path();
DeprecatedString relative_editor_file_path = LexicalPath::relative_path(editor_file_path, project().root_path());
if (relative_editor_file_path == filename) {
if (m_open_files_vector.is_empty()) {
editor.set_document(CodeDocument::create());
editor_wrapper.set_filename("");
editor_wrapper->set_filename("");
} else {
auto& first_path = m_open_files_vector[0];
auto& document = m_open_files.get(first_path).value()->code_document();
editor.set_document(document);
editor_wrapper.set_filename(first_path);
editor_wrapper->set_filename(first_path);
}
}
}
@ -713,7 +713,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_new_project_action(
// If the user wishes to save the changes, this occurs in warn_unsaved_changes. If they do not,
// we need to mark the documents as clean so open_project works properly without asking again.
for (auto& editor_wrapper : m_all_editor_wrappers)
editor_wrapper.editor().document().set_unmodified();
editor_wrapper->editor().document().set_unmodified();
auto dialog = NewProjectDialog::construct(window());
dialog->set_icon(window()->icon());
auto result = dialog->exec();
@ -754,7 +754,7 @@ void HackStudioWidget::add_new_editor_tab_widget(GUI::Widget& parent)
if (m_all_editor_tab_widgets.size() > 1) {
for (auto& widget : m_all_editor_tab_widgets)
widget.set_close_button_enabled(true);
widget->set_close_button_enabled(true);
}
tab_widget->on_change = [&](auto& widget) {
@ -914,8 +914,8 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_save_as_action()
current_editor_wrapper().set_filename(relative_file_path);
} else {
for (auto& editor_wrapper : m_all_editor_wrappers) {
if (editor_wrapper.filename() == old_filename)
editor_wrapper.set_filename(relative_file_path);
if (editor_wrapper->filename() == old_filename)
editor_wrapper->set_filename(relative_file_path);
}
}
current_editor_wrapper().save();
@ -1031,7 +1031,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_debug_action()
m_run_action->set_enabled(false);
for (auto& editor_wrapper : m_all_editor_wrappers) {
editor_wrapper.set_debug_mode(true);
editor_wrapper->set_debug_mode(true);
}
});
}
@ -1083,7 +1083,7 @@ void HackStudioWidget::initialize_debugger()
m_debugger_thread.clear();
for (auto& editor_wrapper : m_all_editor_wrappers) {
editor_wrapper.set_debug_mode(false);
editor_wrapper->set_debug_mode(false);
}
HackStudioWidget::hide_action_tabs();
@ -1454,10 +1454,10 @@ ErrorOr<void> HackStudioWidget::create_edit_menu(GUI::Window& window)
auto vim_emulation_setting_action = GUI::Action::create_checkable("&Vim Emulation", { Mod_Ctrl | Mod_Shift | Mod_Alt, Key_V }, [this](auto& action) {
if (action.is_checked()) {
for (auto& editor_wrapper : m_all_editor_wrappers)
editor_wrapper.editor().set_editing_engine(make<GUI::VimEditingEngine>());
editor_wrapper->editor().set_editing_engine(make<GUI::VimEditingEngine>());
} else {
for (auto& editor_wrapper : m_all_editor_wrappers)
editor_wrapper.editor().set_editing_engine(make<GUI::RegularEditingEngine>());
editor_wrapper->editor().set_editing_engine(make<GUI::RegularEditingEngine>());
}
});
vim_emulation_setting_action->set_checked(false);
@ -1506,17 +1506,17 @@ ErrorOr<void> HackStudioWidget::create_view_menu(GUI::Window& window)
m_no_wrapping_action = GUI::Action::create_checkable("&No Wrapping", [&](auto&) {
m_wrapping_mode = GUI::TextEditor::WrappingMode::NoWrap;
for (auto& wrapper : m_all_editor_wrappers)
wrapper.editor().set_wrapping_mode(GUI::TextEditor::WrappingMode::NoWrap);
wrapper->editor().set_wrapping_mode(GUI::TextEditor::WrappingMode::NoWrap);
});
m_wrap_anywhere_action = GUI::Action::create_checkable("Wrap &Anywhere", [&](auto&) {
m_wrapping_mode = GUI::TextEditor::WrappingMode::WrapAnywhere;
for (auto& wrapper : m_all_editor_wrappers)
wrapper.editor().set_wrapping_mode(GUI::TextEditor::WrappingMode::WrapAnywhere);
wrapper->editor().set_wrapping_mode(GUI::TextEditor::WrappingMode::WrapAnywhere);
});
m_wrap_at_words_action = GUI::Action::create_checkable("Wrap at &Words", [&](auto&) {
m_wrapping_mode = GUI::TextEditor::WrappingMode::WrapAtWords;
for (auto& wrapper : m_all_editor_wrappers)
wrapper.editor().set_wrapping_mode(GUI::TextEditor::WrappingMode::WrapAtWords);
wrapper->editor().set_wrapping_mode(GUI::TextEditor::WrappingMode::WrapAtWords);
});
m_wrapping_mode_actions.add_action(*m_no_wrapping_action);
@ -1668,8 +1668,8 @@ HackStudioWidget::ContinueDecision HackStudioWidget::warn_unsaved_changes(Deprec
if (result == GUI::MessageBox::ExecResult::Yes) {
for (auto& editor_wrapper : m_all_editor_wrappers) {
if (editor_wrapper.editor().document().is_modified()) {
editor_wrapper.save();
if (editor_wrapper->editor().document().is_modified()) {
editor_wrapper->save();
}
}
}
@ -1680,7 +1680,7 @@ HackStudioWidget::ContinueDecision HackStudioWidget::warn_unsaved_changes(Deprec
bool HackStudioWidget::any_document_is_dirty() const
{
return any_of(m_all_editor_wrappers, [](auto& editor_wrapper) {
return editor_wrapper.editor().document().is_modified();
return editor_wrapper->editor().document().is_modified();
});
}
@ -1858,7 +1858,7 @@ void HackStudioWidget::change_editor_font(RefPtr<Gfx::Font const> font)
{
m_editor_font = move(font);
for (auto& editor_wrapper : m_all_editor_wrappers) {
editor_wrapper.editor().set_font(*m_editor_font);
editor_wrapper->editor().set_font(*m_editor_font);
}
Config::write_string("HackStudio"sv, "EditorFont"sv, "Family"sv, m_editor_font->family());
@ -1893,7 +1893,7 @@ void HackStudioWidget::debug_process(pid_t pid)
m_run_action->set_enabled(false);
for (auto& editor_wrapper : m_all_editor_wrappers) {
editor_wrapper.set_debug_mode(true);
editor_wrapper->set_debug_mode(true);
}
}
@ -1909,7 +1909,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_toggle_syntax_highl
auto icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-cplusplus.png"sv));
auto action = GUI::Action::create_checkable("&Semantic Highlighting", icon, [this](auto& action) {
for (auto& editor_wrapper : m_all_editor_wrappers)
editor_wrapper.editor().set_semantic_syntax_highlighting(action.is_checked());
editor_wrapper->editor().set_semantic_syntax_highlighting(action.is_checked());
});
return action;

View file

@ -177,9 +177,9 @@ private:
ProjectLocation current_project_location() const;
void update_history_actions();
NonnullRefPtrVector<EditorWrapper> m_all_editor_wrappers;
Vector<NonnullRefPtr<EditorWrapper>> m_all_editor_wrappers;
RefPtr<EditorWrapper> m_current_editor_wrapper;
NonnullRefPtrVector<GUI::TabWidget> m_all_editor_tab_widgets;
Vector<NonnullRefPtr<GUI::TabWidget>> m_all_editor_tab_widgets;
RefPtr<GUI::TabWidget> m_current_editor_tab_widget;
HashMap<DeprecatedString, NonnullRefPtr<ProjectFile>> m_open_files;
@ -217,7 +217,7 @@ private:
RefPtr<EditorWrapper> m_current_editor_in_execution;
RefPtr<GUI::Menu> m_recent_projects_submenu { nullptr };
NonnullRefPtrVector<GUI::Action> m_new_file_actions;
Vector<NonnullRefPtr<GUI::Action>> m_new_file_actions;
RefPtr<GUI::Action> m_new_plain_file_action;
RefPtr<GUI::Action> m_new_directory_action;

View file

@ -197,7 +197,7 @@ void Game::setup(DeprecatedString player_name, int hand_number)
m_passing_button->set_focus(false);
}
NonnullRefPtrVector<Card> deck = Cards::create_standard_deck(Cards::Shuffle::Yes).release_value_but_fixme_should_propagate_errors();
Vector<NonnullRefPtr<Card>> deck = Cards::create_standard_deck(Cards::Shuffle::Yes).release_value_but_fixme_should_propagate_errors();
for (auto& player : m_players) {
player.hand.ensure_capacity(Card::card_count);
@ -220,7 +220,7 @@ void Game::setup(DeprecatedString player_name, int hand_number)
continue_game_after_delay();
}
void Game::start_animation(NonnullRefPtrVector<Card> cards, Gfx::IntPoint end, Function<void()> did_finish_callback, int initial_delay_ms, int steps)
void Game::start_animation(Vector<NonnullRefPtr<Card>> cards, Gfx::IntPoint end, Function<void()> did_finish_callback, int initial_delay_ms, int steps)
{
stop_animation();
@ -229,7 +229,7 @@ void Game::start_animation(NonnullRefPtrVector<Card> cards, Gfx::IntPoint end, F
m_animation_steps = steps;
m_animation_cards.clear_with_capacity();
for (auto& card : cards)
m_animation_cards.empend(card, card.position());
m_animation_cards.empend(card, card->position());
m_animation_did_finish = make<Function<void()>>(move(did_finish_callback));
m_animation_delay_timer = Core::Timer::create_single_shot(initial_delay_ms, [&] {
m_animation_playing = true;
@ -338,17 +338,17 @@ size_t Game::pick_card(Player& player)
return player.pick_lead_card(move(valid_card), move(prefer_card));
}
}
auto* high_card = &m_trick[0];
auto* high_card = m_trick[0].ptr();
for (auto& card : m_trick)
if (high_card->suit() == card.suit() && hearts_card_value(card) > hearts_card_value(*high_card))
high_card = &card;
if (high_card->suit() == card->suit() && hearts_card_value(card) > hearts_card_value(*high_card))
high_card = card;
if (high_card->suit() == Cards::Suit::Spades && hearts_card_value(*high_card) > CardValue::Queen)
RETURN_CARD_IF_VALID(player.pick_specific_card(Cards::Suit::Spades, CardValue::Queen));
auto card_has_points = [](Card& card) { return hearts_card_points(card) > 0; };
auto trick_has_points = m_trick.first_matching(card_has_points).has_value();
bool is_trailing_player = m_trick.size() == 3;
if (!trick_has_points && is_trailing_player) {
RETURN_CARD_IF_VALID(player.pick_low_points_high_value_card(m_trick[0].suit()));
RETURN_CARD_IF_VALID(player.pick_low_points_high_value_card(m_trick[0]->suit()));
if (is_first_trick)
return player.pick_low_points_high_value_card().value();
else {
@ -523,11 +523,11 @@ void Game::advance_game()
return;
}
auto leading_card_suit = m_trick[0].suit();
auto leading_card_suit = m_trick[0]->suit();
size_t taker_index = 0;
auto taker_value = hearts_card_value(m_trick[0]);
for (size_t i = 1; i < 4; i++) {
if (m_trick[i].suit() != leading_card_suit)
if (m_trick[i]->suit() != leading_card_suit)
continue;
if (hearts_card_value(m_trick[i]) <= taker_value)
continue;
@ -608,7 +608,7 @@ void Game::play_card(Player& player, size_t card_index)
VERIFY(m_leading_player);
size_t leading_player_index = player_index(*m_leading_player);
NonnullRefPtrVector<Card> cards;
Vector<NonnullRefPtr<Card>> cards;
cards.append(*card);
start_animation(
cards,
@ -661,7 +661,7 @@ bool Game::is_valid_play(Player& player, Card& card, DeprecatedString* explanati
}
// Player must follow suit unless they don't have any matching cards.
auto leading_card_suit = m_trick[0].suit();
auto leading_card_suit = m_trick[0]->suit();
if (leading_card_suit == card.suit())
return true;
auto has_matching_card = player.has_card_of_suit(leading_card_suit);
@ -818,13 +818,13 @@ void Game::select_cards_for_passing()
void Game::pass_cards()
{
NonnullRefPtrVector<Card> first_player_cards;
Vector<NonnullRefPtr<Card>> first_player_cards;
for (auto& card : m_cards_highlighted)
first_player_cards.append(*card);
clear_highlighted_cards();
VERIFY(first_player_cards.size() == 3);
NonnullRefPtrVector<Card> passed_cards[4];
Vector<NonnullRefPtr<Card>> passed_cards[4];
passed_cards[0] = first_player_cards;
passed_cards[1] = m_players[1].pick_cards_to_pass(passing_direction());
passed_cards[2] = m_players[2].pick_cards_to_pass(passing_direction());
@ -852,7 +852,7 @@ void Game::pass_cards()
for (auto& card : passed_cards[i]) {
m_players[destination_player_index].hand.append(card);
if constexpr (!HEARTS_DEBUG)
card.set_upside_down(destination_player_index != 0);
card->set_upside_down(destination_player_index != 0);
if (destination_player_index == 0)
highlight_card(card);
}
@ -911,7 +911,7 @@ void Game::paint_event(GUI::PaintEvent& event)
}
for (size_t i = 0; i < m_trick.size(); i++)
m_trick[i].paint(painter);
m_trick[i]->paint(painter);
}
void Game::dump_state() const

View file

@ -64,7 +64,7 @@ private:
void pass_cards();
PassingDirection passing_direction() const;
void start_animation(NonnullRefPtrVector<Card> cards, Gfx::IntPoint end, Function<void()> did_finish_callback, int initial_delay_ms, int steps = 30);
void start_animation(Vector<NonnullRefPtr<Card>> cards, Gfx::IntPoint end, Function<void()> did_finish_callback, int initial_delay_ms, int steps = 30);
void stop_animation();
virtual void paint_event(GUI::PaintEvent&) override;
@ -92,7 +92,7 @@ private:
HashTable<NonnullRefPtr<Card>> m_cards_highlighted;
Player m_players[4];
NonnullRefPtrVector<Card> m_trick;
Vector<NonnullRefPtr<Card>> m_trick;
Player* m_leading_player { nullptr };
u8 m_trick_number { 0 };
RefPtr<Core::Timer> m_delay_timer;

View file

@ -25,10 +25,10 @@ static bool compare_card_points_and_value(CardWithIndex& cwi1, CardWithIndex& cw
return false;
}
NonnullRefPtrVector<Card> Player::pick_cards_to_pass(PassingDirection)
Vector<NonnullRefPtr<Card>> Player::pick_cards_to_pass(PassingDirection)
{
auto sorted_hand = hand_sorted_by_fn(compare_card_value);
NonnullRefPtrVector<Card> cards;
Vector<NonnullRefPtr<Card>> cards;
cards.append(*sorted_hand[0].card);
cards.append(*sorted_hand[1].card);
cards.append(*sorted_hand[2].card);
@ -158,11 +158,11 @@ bool Player::has_card_of_suit(Cards::Suit suit)
return matching_card.has_value();
}
void Player::remove_cards(NonnullRefPtrVector<Card> const& cards)
void Player::remove_cards(Vector<NonnullRefPtr<Card>> const& cards)
{
for (auto& card : cards) {
hand.remove_first_matching([&card](auto& other_card) {
return other_card.ptr() == &card;
return other_card == card;
});
}
}

View file

@ -33,7 +33,7 @@ public:
{
}
NonnullRefPtrVector<Card> pick_cards_to_pass(PassingDirection);
Vector<NonnullRefPtr<Card>> pick_cards_to_pass(PassingDirection);
size_t pick_lead_card(Function<bool(Card&)>, Function<bool(Card&)>);
Optional<size_t> pick_low_points_high_value_card(Optional<Cards::Suit> suit = {});
Optional<size_t> pick_lower_value_card(Card& other_card);
@ -45,7 +45,7 @@ public:
Vector<CardWithIndex> hand_sorted_by_fn(bool (*)(CardWithIndex&, CardWithIndex&)) const;
void sort_hand() { quick_sort(hand, hearts_card_less); }
void remove_cards(NonnullRefPtrVector<Card> const& cards);
void remove_cards(Vector<NonnullRefPtr<Card>> const& cards);
Vector<RefPtr<Card>> hand;
Vector<RefPtr<Card>> cards_taken;

View file

@ -53,7 +53,7 @@ ErrorOr<NonnullRefPtr<Game>> Game::try_create()
"/res/emoji/U+1FAB1.png"sv,
};
NonnullRefPtrVector<Gfx::Bitmap> food_bitmaps;
Vector<NonnullRefPtr<Gfx::Bitmap>> food_bitmaps;
TRY(food_bitmaps.try_ensure_capacity(food_bitmaps_files.size()));
for (auto file : food_bitmaps_files) {
@ -69,7 +69,7 @@ ErrorOr<NonnullRefPtr<Game>> Game::try_create()
return adopt_nonnull_ref_or_enomem(new (nothrow) Game(move(food_bitmaps)));
}
Game::Game(NonnullRefPtrVector<Gfx::Bitmap> food_bitmaps)
Game::Game(Vector<NonnullRefPtr<Gfx::Bitmap>> food_bitmaps)
: m_food_bitmaps(move(food_bitmaps))
{
set_font(Gfx::FontDatabase::default_fixed_width_font().bold_variant());
@ -263,7 +263,7 @@ void Game::paint_event(GUI::PaintEvent& event)
painter.fill_rect(bottom_side, m_snake_base_color.darkened(0.55));
}
painter.draw_scaled_bitmap(cell_rect(m_fruit), m_food_bitmaps[m_fruit_type], m_food_bitmaps[m_fruit_type].rect());
painter.draw_scaled_bitmap(cell_rect(m_fruit), m_food_bitmaps[m_fruit_type], m_food_bitmaps[m_fruit_type]->rect());
}
void Game::game_over()

View file

@ -30,7 +30,7 @@ public:
Function<bool(u32)> on_score_update;
private:
explicit Game(NonnullRefPtrVector<Gfx::Bitmap> food_bitmaps);
explicit Game(Vector<NonnullRefPtr<Gfx::Bitmap>> food_bitmaps);
virtual void paint_event(GUI::PaintEvent&) override;
virtual void keydown_event(GUI::KeyEvent&) override;
@ -76,7 +76,7 @@ private:
unsigned m_score { 0 };
bool m_is_new_high_score { false };
NonnullRefPtrVector<Gfx::Bitmap> m_food_bitmaps;
Vector<NonnullRefPtr<Gfx::Bitmap>> m_food_bitmaps;
Gfx::Color m_snake_base_color { Color::Yellow };
};

View file

@ -172,7 +172,7 @@ void Game::setup(Mode mode)
on_game_end(GameOverReason::NewGame, m_score);
for (auto& stack : stacks())
stack.clear();
stack->clear();
m_new_deck.clear();
m_new_game_animation_pile = 0;
@ -256,14 +256,14 @@ void Game::mousedown_event(GUI::MouseEvent& event)
auto click_location = event.position();
for (auto& to_check : stacks()) {
if (to_check.type() == CardStack::Type::Waste)
if (to_check->type() == CardStack::Type::Waste)
continue;
if (to_check.bounding_box().contains(click_location)) {
if (to_check.type() == CardStack::Type::Stock) {
if (to_check->bounding_box().contains(click_location)) {
if (to_check->type() == CardStack::Type::Stock) {
draw_cards();
} else if (!to_check.is_empty()) {
auto& top_card = to_check.peek();
} else if (!to_check->is_empty()) {
auto& top_card = to_check->peek();
if (top_card.is_upside_down()) {
if (top_card.rect().contains(click_location)) {
@ -356,8 +356,8 @@ void Game::mousemove_event(GUI::MouseEvent& event)
for (auto& to_intersect : moving_cards()) {
mark_intersecting_stacks_dirty(to_intersect);
to_intersect.rect().translate_by(dx, dy);
update(to_intersect.rect());
to_intersect->rect().translate_by(dx, dy);
update(to_intersect->rect());
}
m_mouse_down_location = click_location;
@ -380,11 +380,11 @@ void Game::doubleclick_event(GUI::MouseEvent& event)
auto click_location = event.position();
for (auto& to_check : stacks()) {
if (to_check.type() != CardStack::Type::Normal && to_check.type() != CardStack::Type::Play)
if (to_check->type() != CardStack::Type::Normal && to_check->type() != CardStack::Type::Play)
continue;
if (to_check.bounding_box().contains(click_location) && !to_check.is_empty()) {
auto& top_card = to_check.peek();
if (to_check->bounding_box().contains(click_location) && !to_check->is_empty()) {
auto& top_card = to_check->peek();
if (!top_card.is_upside_down() && top_card.rect().contains(click_location))
attempt_to_move_card_to_foundations(to_check);
@ -418,7 +418,7 @@ void Game::draw_cards()
update(waste.bounding_box());
update(play.bounding_box());
NonnullRefPtrVector<Card> moved_cards;
Vector<NonnullRefPtr<Card>> moved_cards;
while (!play.is_empty()) {
auto card = play.pop();
stock.push(card).release_value_but_fixme_should_propagate_errors();
@ -458,7 +458,7 @@ void Game::draw_cards()
update(stock.bounding_box());
NonnullRefPtrVector<Card> cards_drawn;
Vector<NonnullRefPtr<Card>> cards_drawn;
for (size_t i = 0; (i < cards_to_draw) && !stock.is_empty(); ++i) {
auto card = stock.pop();
cards_drawn.prepend(card);
@ -509,7 +509,7 @@ bool Game::attempt_to_move_card_to_foundations(CardStack& from)
mark_intersecting_stacks_dirty(card);
foundation.push(card).release_value_but_fixme_should_propagate_errors();
NonnullRefPtrVector<Card> moved_card;
Vector<NonnullRefPtr<Card>> moved_card;
moved_card.append(card);
remember_move_for_undo(from, foundation, moved_card);
@ -538,7 +538,7 @@ void Game::auto_move_eligible_cards_to_foundations()
while (true) {
bool card_was_moved = false;
for (auto& to_check : stacks()) {
if (to_check.type() != CardStack::Type::Normal && to_check.type() != CardStack::Type::Play)
if (to_check->type() != CardStack::Type::Normal && to_check->type() != CardStack::Type::Play)
continue;
if (attempt_to_move_card_to_foundations(to_check))
@ -567,17 +567,17 @@ void Game::paint_event(GUI::PaintEvent& event)
if (is_moving_cards()) {
for (auto& card : moving_cards())
card.clear(painter, background_color);
card->clear(painter, background_color);
}
for (auto& stack : stacks()) {
stack.paint(painter, background_color);
stack->paint(painter, background_color);
}
if (is_moving_cards()) {
for (auto& card : moving_cards()) {
card.paint(painter);
card.save_old_position();
card->paint(painter);
card->save_old_position();
}
}
@ -585,14 +585,14 @@ void Game::paint_event(GUI::PaintEvent& event)
if (is_moving_cards()) {
check_for_game_over();
for (auto& card : moving_cards())
card.set_moving(false);
card->set_moving(false);
}
clear_moving_cards();
}
}
void Game::remember_move_for_undo(CardStack& from, CardStack& to, NonnullRefPtrVector<Card> moved_cards)
void Game::remember_move_for_undo(CardStack& from, CardStack& to, Vector<NonnullRefPtr<Card>> moved_cards)
{
m_last_move.type = LastMove::Type::MoveCards;
m_last_move.from = &from;
@ -604,7 +604,7 @@ void Game::remember_move_for_undo(CardStack& from, CardStack& to, NonnullRefPtrV
void Game::remember_flip_for_undo(Card& card)
{
NonnullRefPtrVector<Card> cards;
Vector<NonnullRefPtr<Card>> cards;
cards.append(card);
m_last_move.type = LastMove::Type::FlipCard;
m_last_move.cards = cards;
@ -618,7 +618,7 @@ void Game::perform_undo()
return;
if (m_last_move.type == LastMove::Type::FlipCard) {
m_last_move.cards.at(0).set_upside_down(true);
m_last_move.cards[0]->set_upside_down(true);
if (on_undo_availability_change)
on_undo_availability_change(false);
invalidate_layout();
@ -641,7 +641,7 @@ void Game::perform_undo()
if (m_last_move.from->type() == CardStack::Type::Stock) {
auto& waste = stack_at_location(Waste);
auto& play = stack_at_location(Play);
NonnullRefPtrVector<Card> cards_popped;
Vector<NonnullRefPtr<Card>> cards_popped;
for (size_t i = 0; i < m_last_move.cards.size(); i++) {
if (!waste.is_empty()) {
auto card = waste.pop();

View file

@ -130,7 +130,7 @@ private:
Type type { Type::Invalid };
CardStack* from { nullptr };
NonnullRefPtrVector<Card> cards;
Vector<NonnullRefPtr<Card>> cards;
CardStack* to { nullptr };
};
@ -173,7 +173,7 @@ private:
void score_move(CardStack& from, CardStack& to, bool inverse = false);
void score_flip(bool inverse = false);
void remember_move_for_undo(CardStack& from, CardStack& to, NonnullRefPtrVector<Card> moved_cards);
void remember_move_for_undo(CardStack& from, CardStack& to, Vector<NonnullRefPtr<Card>> moved_cards);
void remember_flip_for_undo(Card& card);
void update_score(int to_add);
void draw_cards();
@ -200,7 +200,7 @@ private:
Mode m_mode { Mode::SingleCardDraw };
LastMove m_last_move;
NonnullRefPtrVector<Card> m_new_deck;
Vector<NonnullRefPtr<Card>> m_new_deck;
Gfx::IntPoint m_mouse_down_location;
bool m_mouse_down { false };

View file

@ -50,7 +50,7 @@ void Game::setup(Mode mode)
on_game_end(GameOverReason::NewGame, m_score);
for (auto& stack : stacks())
stack.clear();
stack->clear();
m_new_game_animation_pile = 0;
@ -91,7 +91,7 @@ void Game::perform_undo()
if (!m_last_move.was_visible)
m_last_move.from->peek().set_upside_down(true);
NonnullRefPtrVector<Card> cards;
Vector<NonnullRefPtr<Card>> cards;
for (size_t i = 0; i < m_last_move.card_count; i++)
cards.append(m_last_move.to->pop());
for (ssize_t i = m_last_move.card_count - 1; i >= 0; i--)
@ -146,18 +146,18 @@ void Game::detect_full_stacks()
Color color;
for (size_t i = current_pile.stack().size(); i > 0; i--) {
auto& card = current_pile.stack().at(i - 1);
if (card.is_upside_down())
if (card->is_upside_down())
break;
if (!started) {
if (card.rank() != Cards::Rank::Ace)
if (card->rank() != Cards::Rank::Ace)
break;
started = true;
color = card.color();
} else if (to_underlying(card.rank()) != last_value + 1 || card.color() != color) {
color = card->color();
} else if (to_underlying(card->rank()) != last_value + 1 || card->color() != color) {
break;
} else if (card.rank() == Cards::Rank::King) {
} else if (card->rank() == Cards::Rank::King) {
// we have a full set
auto original_current_rect = current_pile.bounding_box();
@ -177,7 +177,7 @@ void Game::detect_full_stacks()
on_undo_availability_change(false);
}
last_value = to_underlying(card.rank());
last_value = to_underlying(card->rank());
}
}
@ -212,24 +212,24 @@ void Game::paint_event(GUI::PaintEvent& event)
if (is_moving_cards()) {
for (auto& card : moving_cards())
card.clear(painter, background_color);
card->clear(painter, background_color);
}
for (auto& stack : stacks()) {
stack.paint(painter, background_color);
stack->paint(painter, background_color);
}
if (is_moving_cards()) {
for (auto& card : moving_cards()) {
card.paint(painter);
card.save_old_position();
card->paint(painter);
card->save_old_position();
}
}
if (!m_mouse_down) {
if (is_moving_cards()) {
for (auto& card : moving_cards())
card.set_moving(false);
card->set_moving(false);
}
clear_moving_cards();
}
@ -255,15 +255,15 @@ void Game::mousedown_event(GUI::MouseEvent& event)
auto click_location = event.position();
for (auto& to_check : stacks()) {
if (to_check.type() == CardStack::Type::Waste)
if (to_check->type() == CardStack::Type::Waste)
continue;
if (to_check.bounding_box().contains(click_location)) {
if (to_check.type() == CardStack::Type::Stock) {
if (to_check->bounding_box().contains(click_location)) {
if (to_check->type() == CardStack::Type::Stock) {
start_timer_if_necessary();
draw_cards();
} else if (!to_check.is_empty()) {
auto& top_card = to_check.peek();
} else if (!to_check->is_empty()) {
auto& top_card = to_check->peek();
if (top_card.is_upside_down()) {
if (top_card.rect().contains(click_location)) {
@ -312,7 +312,7 @@ void Game::mouseup_event(GUI::MouseEvent& event)
if (stack == moving_cards_source_stack())
continue;
if (stack.is_allowed_to_push(moving_cards().at(0), moving_cards().size(), Cards::CardStack::MovementRule::Any) && !stack.is_empty()) {
if (stack->is_allowed_to_push(moving_cards().at(0), moving_cards().size(), Cards::CardStack::MovementRule::Any) && !stack->is_empty()) {
move_focused_cards(stack);
rebound = false;
@ -361,8 +361,8 @@ void Game::mousemove_event(GUI::MouseEvent& event)
for (auto& to_intersect : moving_cards()) {
mark_intersecting_stacks_dirty(to_intersect);
to_intersect.rect().translate_by(dx, dy);
update(to_intersect.rect());
to_intersect->rect().translate_by(dx, dy);
update(to_intersect->rect());
}
m_mouse_down_location = click_location;

View file

@ -104,7 +104,7 @@ private:
Mode m_mode { Mode::SingleSuit };
LastMove m_last_move;
NonnullRefPtrVector<Card> m_new_deck;
Vector<NonnullRefPtr<Card>> m_new_deck;
Gfx::IntPoint m_mouse_down_location;
bool m_mouse_down { false };

View file

@ -55,14 +55,14 @@ void Card::clear_and_paint(GUI::Painter& painter, Color background_color, bool h
save_old_position();
}
ErrorOr<NonnullRefPtrVector<Card>> create_standard_deck(Shuffle shuffle)
ErrorOr<Vector<NonnullRefPtr<Card>>> create_standard_deck(Shuffle shuffle)
{
return create_deck(1, 1, 1, 1, shuffle);
}
ErrorOr<NonnullRefPtrVector<Card>> create_deck(unsigned full_club_suit_count, unsigned full_diamond_suit_count, unsigned full_heart_suit_count, unsigned full_spade_suit_count, Shuffle shuffle)
ErrorOr<Vector<NonnullRefPtr<Card>>> create_deck(unsigned full_club_suit_count, unsigned full_diamond_suit_count, unsigned full_heart_suit_count, unsigned full_spade_suit_count, Shuffle shuffle)
{
NonnullRefPtrVector<Card> deck;
Vector<NonnullRefPtr<Card>> deck;
TRY(deck.try_ensure_capacity(Card::card_count * (full_club_suit_count + full_diamond_suit_count + full_heart_suit_count + full_spade_suit_count)));
auto add_cards_for_suit = [&deck](Cards::Suit suit, unsigned number_of_suits) -> ErrorOr<void> {

View file

@ -131,8 +131,8 @@ enum class Shuffle {
No,
Yes,
};
ErrorOr<NonnullRefPtrVector<Card>> create_standard_deck(Shuffle);
ErrorOr<NonnullRefPtrVector<Card>> create_deck(unsigned full_club_suit_count, unsigned full_diamond_suit_count, unsigned full_heart_suit_count, unsigned full_spade_suit_count, Shuffle);
ErrorOr<Vector<NonnullRefPtr<Card>>> create_standard_deck(Shuffle);
ErrorOr<Vector<NonnullRefPtr<Card>>> create_deck(unsigned full_club_suit_count, unsigned full_diamond_suit_count, unsigned full_heart_suit_count, unsigned full_spade_suit_count, Shuffle);
}

View file

@ -36,8 +36,8 @@ CardGame::CardGame()
void CardGame::mark_intersecting_stacks_dirty(Cards::Card const& intersecting_card)
{
for (auto& stack : stacks()) {
if (intersecting_card.rect().intersects(stack.bounding_box()))
update(stack.bounding_box());
if (intersecting_card.rect().intersects(stack->bounding_box()))
update(stack->bounding_box());
}
update(intersecting_card.rect());
@ -49,7 +49,7 @@ Gfx::IntRect CardGame::moving_cards_bounds() const
return {};
// Note: This assumes that the cards are arranged in a line.
return m_moving_cards.first().rect().united(m_moving_cards.last().rect());
return m_moving_cards.first()->rect().united(m_moving_cards.last()->rect());
}
ErrorOr<void> CardGame::pick_up_cards_from_stack(Cards::CardStack& stack, Gfx::IntPoint click_location, CardStack::MovementRule movement_rule)
@ -70,10 +70,10 @@ RefPtr<CardStack> CardGame::find_stack_to_drop_on(CardStack::MovementRule moveme
if (stack == moving_cards_source_stack())
continue;
if (stack.bounding_box().intersects(bounds_to_check)
&& stack.is_allowed_to_push(moving_cards().at(0), moving_cards().size(), movement_rule)) {
if (stack->bounding_box().intersects(bounds_to_check)
&& stack->is_allowed_to_push(moving_cards().at(0), moving_cards().size(), movement_rule)) {
auto distance = bounds_to_check.center().distance_from(stack.bounding_box().center());
auto distance = bounds_to_check.center().distance_from(stack->bounding_box().center());
if (distance < closest_distance) {
closest_stack = stack;
closest_distance = distance;

View file

@ -25,8 +25,8 @@ public:
Gfx::Color background_color() const;
void set_background_color(Gfx::Color);
NonnullRefPtrVector<CardStack>& stacks() { return m_stacks; }
NonnullRefPtrVector<CardStack> const& stacks() const { return m_stacks; }
Vector<NonnullRefPtr<CardStack>>& stacks() { return m_stacks; }
Vector<NonnullRefPtr<CardStack>> const& stacks() const { return m_stacks; }
CardStack& stack_at_location(int location) { return m_stacks[location]; }
template<class... Args>
@ -38,8 +38,8 @@ public:
void mark_intersecting_stacks_dirty(Card const& intersecting_card);
bool is_moving_cards() const { return !m_moving_cards.is_empty(); }
NonnullRefPtrVector<Card>& moving_cards() { return m_moving_cards; }
NonnullRefPtrVector<Card> const& moving_cards() const { return m_moving_cards; }
Vector<NonnullRefPtr<Card>>& moving_cards() { return m_moving_cards; }
Vector<NonnullRefPtr<Card>> const& moving_cards() const { return m_moving_cards; }
Gfx::IntRect moving_cards_bounds() const;
RefPtr<CardStack> moving_cards_source_stack() const { return m_moving_cards_source_stack; }
ErrorOr<void> pick_up_cards_from_stack(CardStack&, Gfx::IntPoint click_location, CardStack::MovementRule);
@ -59,9 +59,9 @@ protected:
private:
virtual void config_string_did_change(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value) override;
NonnullRefPtrVector<CardStack> m_stacks;
Vector<NonnullRefPtr<CardStack>> m_stacks;
NonnullRefPtrVector<Card> m_moving_cards;
Vector<NonnullRefPtr<Card>> m_moving_cards;
RefPtr<CardStack> m_moving_cards_source_stack;
RefPtr<CardStack> m_previewed_card_stack;
};

View file

@ -37,7 +37,7 @@ void CardStack::paint(GUI::Painter& painter, Gfx::Color background_color)
auto draw_background_if_empty = [&]() {
size_t number_of_moving_cards = 0;
for (auto const& card : m_stack)
number_of_moving_cards += card.is_moving() ? 1 : 0;
number_of_moving_cards += card->is_moving() ? 1 : 0;
if (m_covered_stack && !m_covered_stack->is_empty())
return false;
@ -96,15 +96,15 @@ void CardStack::paint(GUI::Painter& painter, Gfx::Color background_color)
RefPtr<Card> previewed_card;
for (size_t i = 0; i < m_stack.size(); ++i) {
if (auto& card = m_stack[i]; !card.is_moving()) {
if (card.is_previewed()) {
if (auto& card = m_stack[i]; !card->is_moving()) {
if (card->is_previewed()) {
VERIFY(!previewed_card);
previewed_card = card;
continue;
}
auto highlighted = m_highlighted && (i == m_stack.size() - 1);
card.clear_and_paint(painter, Gfx::Color::Transparent, highlighted);
card->clear_and_paint(painter, Gfx::Color::Transparent, highlighted);
}
}
@ -118,10 +118,10 @@ void CardStack::rebound_cards()
size_t card_index = 0;
for (auto& card : m_stack)
card.set_position(m_stack_positions.at(card_index++));
card->set_position(m_stack_positions.at(card_index++));
}
ErrorOr<void> CardStack::add_all_grabbed_cards(Gfx::IntPoint click_location, NonnullRefPtrVector<Card>& grabbed, MovementRule movement_rule)
ErrorOr<void> CardStack::add_all_grabbed_cards(Gfx::IntPoint click_location, Vector<NonnullRefPtr<Card>>& grabbed, MovementRule movement_rule)
{
VERIFY(grabbed.is_empty());
@ -137,8 +137,8 @@ ErrorOr<void> CardStack::add_all_grabbed_cards(Gfx::IntPoint click_location, Non
RefPtr<Card> last_intersect;
for (auto& card : m_stack) {
if (card.rect().contains(click_location)) {
if (card.is_upside_down())
if (card->rect().contains(click_location)) {
if (card->is_upside_down())
continue;
last_intersect = card;
@ -148,12 +148,12 @@ ErrorOr<void> CardStack::add_all_grabbed_cards(Gfx::IntPoint click_location, Non
last_intersect->set_moving(true);
}
if (card.is_upside_down()) {
if (card->is_upside_down()) {
grabbed.clear();
return {};
}
card.set_moving(true);
card->set_moving(true);
TRY(grabbed.try_append(card));
}
}
@ -173,28 +173,28 @@ ErrorOr<void> CardStack::add_all_grabbed_cards(Gfx::IntPoint click_location, Non
bool color_match;
switch (movement_rule) {
case MovementRule::Alternating:
color_match = card.color() != last_color;
color_match = card->color() != last_color;
break;
case MovementRule::Same:
color_match = card.color() == last_color;
color_match = card->color() == last_color;
break;
case MovementRule::Any:
color_match = true;
break;
}
if (!color_match || to_underlying(card.rank()) != last_value - 1) {
if (!color_match || to_underlying(card->rank()) != last_value - 1) {
valid_stack = false;
break;
}
}
last_value = to_underlying(card.rank());
last_color = card.color();
last_value = to_underlying(card->rank());
last_color = card->color();
}
if (!valid_stack) {
for (auto& card : grabbed) {
card.set_moving(false);
card->set_moving(false);
}
grabbed.clear();
}
@ -257,9 +257,9 @@ bool CardStack::preview_card(Gfx::IntPoint click_location)
RefPtr<Card> last_intersect;
for (auto& card : m_stack) {
if (!card.rect().contains(click_location))
if (!card->rect().contains(click_location))
continue;
if (card.is_upside_down())
if (card->is_upside_down())
continue;
last_intersect = card;
@ -275,7 +275,7 @@ bool CardStack::preview_card(Gfx::IntPoint click_location)
void CardStack::clear_card_preview()
{
for (auto& card : m_stack)
card.set_previewed(false);
card->set_previewed(false);
}
bool CardStack::make_top_card_visible()
@ -350,7 +350,7 @@ void CardStack::calculate_bounding_box()
size_t card_position = 0;
for (auto& card : m_stack) {
if (card_position % m_rules.step == 0 && card_position != 0) {
if (card.is_upside_down()) {
if (card->is_upside_down()) {
width += m_rules.shift_x;
height += m_rules.shift_y_upside_down;
} else {

View file

@ -35,7 +35,7 @@ public:
bool is_empty() const { return m_stack.is_empty(); }
Type type() const { return m_type; }
NonnullRefPtrVector<Card> const& stack() const { return m_stack; }
Vector<NonnullRefPtr<Card>> const& stack() const { return m_stack; }
size_t count() const { return m_stack.size(); }
Card const& peek() const { return m_stack.last(); }
Card& peek() { return m_stack.last(); }
@ -49,7 +49,7 @@ public:
void rebound_cards();
bool is_allowed_to_push(Card const&, size_t stack_size = 1, MovementRule movement_rule = MovementRule::Alternating) const;
ErrorOr<void> add_all_grabbed_cards(Gfx::IntPoint click_location, NonnullRefPtrVector<Card>& grabbed, MovementRule movement_rule = MovementRule::Alternating);
ErrorOr<void> add_all_grabbed_cards(Gfx::IntPoint click_location, Vector<NonnullRefPtr<Card>>& grabbed, MovementRule movement_rule = MovementRule::Alternating);
bool preview_card(Gfx::IntPoint click_location);
void clear_card_preview();
@ -91,7 +91,7 @@ private:
// eg, in Solitaire the Play stack is positioned over the Waste stack.
RefPtr<CardStack> m_covered_stack;
NonnullRefPtrVector<Card> m_stack;
Vector<NonnullRefPtr<Card>> m_stack;
Vector<Gfx::IntPoint> m_stack_positions;
Gfx::IntPoint m_position;
Gfx::IntRect m_bounding_box;

View file

@ -199,9 +199,9 @@ Vector<StringView> CppComprehensionEngine::scope_of_reference_to_symbol(ASTNode
Vector<StringView> scope_parts;
for (auto& scope_part : name->scope()) {
// If the target node is part of a scope reference, we want to end the scope chain before it.
if (&scope_part == &node)
if (scope_part == &node)
break;
scope_parts.append(scope_part.name());
scope_parts.append(scope_part->name());
}
return scope_parts;
}
@ -263,8 +263,8 @@ DeprecatedString CppComprehensionEngine::type_of_variable(Identifier const& iden
ASTNode const* current = &identifier;
while (current) {
for (auto& decl : current->declarations()) {
if (decl.is_variable_or_parameter_declaration()) {
auto& var_or_param = verify_cast<VariableOrParameterDeclaration>(decl);
if (decl->is_variable_or_parameter_declaration()) {
auto& var_or_param = verify_cast<VariableOrParameterDeclaration>(*decl);
if (var_or_param.full_name() == identifier.name() && var_or_param.type()->is_named_type()) {
VERIFY(verify_cast<NamedType>(*var_or_param.type()).name());
if (verify_cast<NamedType>(*var_or_param.type()).name())
@ -326,7 +326,7 @@ Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::properties_of_typ
Vector<StringView> scope(type_symbol.scope);
scope.append(type_symbol.name);
// FIXME: We don't have to create the Symbol here, it should already exist in the 'm_symbol' table of some DocumentData we already parsed.
properties.append(Symbol::create(member.full_name(), scope, member, Symbol::IsLocal::No));
properties.append(Symbol::create(member->full_name(), scope, member, Symbol::IsLocal::No));
}
return properties;
}
@ -346,16 +346,16 @@ Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::get_child_symbols
Vector<Symbol> symbols;
for (auto& decl : node.declarations()) {
symbols.append(Symbol::create(decl.full_name(), scope, decl, is_local));
symbols.append(Symbol::create(decl->full_name(), scope, decl, is_local));
bool should_recurse = decl.is_namespace() || decl.is_struct_or_class() || decl.is_function();
bool are_child_symbols_local = decl.is_function();
bool should_recurse = decl->is_namespace() || decl->is_struct_or_class() || decl->is_function();
bool are_child_symbols_local = decl->is_function();
if (!should_recurse)
continue;
auto new_scope = scope;
new_scope.append(decl.full_name());
new_scope.append(decl->full_name());
symbols.extend(get_child_symbols(decl, new_scope, are_child_symbols_local ? Symbol::IsLocal::Yes : is_local));
}
@ -864,7 +864,7 @@ Optional<CodeComprehensionEngine::FunctionParamsHint> CppComprehensionEngine::ge
Optional<size_t> invoked_arg_index;
for (size_t arg_index = 0; arg_index < call_node->arguments().size(); ++arg_index) {
if (&call_node->arguments()[arg_index] == node.ptr()) {
if (call_node->arguments()[arg_index] == node.ptr()) {
invoked_arg_index = arg_index;
break;
}
@ -920,7 +920,7 @@ Optional<CppComprehensionEngine::FunctionParamsHint> CppComprehensionEngine::get
hint.current_index = argument_index;
for (auto& arg : func_decl.parameters()) {
Vector<StringView> tokens_text;
for (auto token : document_of_declaration->parser().tokens_in_range(arg.start(), arg.end())) {
for (auto token : document_of_declaration->parser().tokens_in_range(arg->start(), arg->end())) {
tokens_text.append(token.text());
}
hint.params.append(DeprecatedString::join(' ', tokens_text));

View file

@ -48,7 +48,7 @@ Object::~Object()
// NOTE: We also unparent the children, so that they won't try to unparent
// themselves in their own destructors.
for (auto& child : children)
child.m_parent = nullptr;
child->m_parent = nullptr;
all_objects().remove(*this);
stop_timer();
@ -103,7 +103,7 @@ void Object::insert_child_before(Object& new_child, Object& before_child)
void Object::remove_child(Object& object)
{
for (size_t i = 0; i < m_children.size(); ++i) {
if (m_children.ptr_at(i).ptr() == &object) {
if (m_children[i] == &object) {
// NOTE: We protect the child so it survives the handling of ChildRemoved.
NonnullRefPtr<Object> protector = object;
object.m_parent = nullptr;
@ -119,7 +119,7 @@ void Object::remove_child(Object& object)
void Object::remove_all_children()
{
while (!m_children.is_empty())
m_children.first().remove_from_parent();
m_children.first()->remove_from_parent();
}
void Object::timer_event(Core::TimerEvent&)

View file

@ -112,14 +112,14 @@ public:
DeprecatedString const& name() const { return m_name; }
void set_name(DeprecatedString name) { m_name = move(name); }
NonnullRefPtrVector<Object>& children() { return m_children; }
NonnullRefPtrVector<Object> const& children() const { return m_children; }
Vector<NonnullRefPtr<Object>>& children() { return m_children; }
Vector<NonnullRefPtr<Object>> const& children() const { return m_children; }
template<typename Callback>
void for_each_child(Callback callback)
{
for (auto& child : m_children) {
if (callback(child) == IterationDecision::Break)
if (callback(*child) == IterationDecision::Break)
return;
}
}
@ -219,7 +219,7 @@ private:
int m_timer_id { 0 };
unsigned m_inspector_count { 0 };
HashMap<DeprecatedString, NonnullOwnPtr<Property>> m_properties;
NonnullRefPtrVector<Object> m_children;
Vector<NonnullRefPtr<Object>> m_children;
Function<bool(Core::Event&)> m_event_filter;
};

View file

@ -24,7 +24,7 @@ void TranslationUnit::dump(FILE* output, size_t indent) const
{
ASTNode::dump(output, indent);
for (auto const& child : m_declarations) {
child.dump(output, indent + 1);
child->dump(output, indent + 1);
}
}
@ -46,7 +46,7 @@ void FunctionDeclaration::dump(FILE* output, size_t indent) const
print_indent(output, indent + 1);
outln(output, "(");
for (auto const& arg : m_parameters) {
arg.dump(output, indent + 1);
arg->dump(output, indent + 1);
}
print_indent(output, indent + 1);
outln(output, ")");
@ -55,9 +55,9 @@ void FunctionDeclaration::dump(FILE* output, size_t indent) const
}
}
NonnullRefPtrVector<Declaration const> FunctionDeclaration::declarations() const
Vector<NonnullRefPtr<Declaration const>> FunctionDeclaration::declarations() const
{
NonnullRefPtrVector<Declaration const> declarations;
Vector<NonnullRefPtr<Declaration const>> declarations;
for (auto& arg : m_parameters) {
declarations.append(arg);
}
@ -124,11 +124,11 @@ DeprecatedString FunctionType::to_deprecated_string() const
first = false;
else
builder.append(", "sv);
if (parameter.type())
builder.append(parameter.type()->to_deprecated_string());
if (parameter.name() && !parameter.full_name().is_empty()) {
if (parameter->type())
builder.append(parameter->type()->to_deprecated_string());
if (parameter->name() && !parameter->full_name().is_empty()) {
builder.append(' ');
builder.append(parameter.full_name());
builder.append(parameter->full_name());
}
}
builder.append(')');
@ -156,17 +156,17 @@ void FunctionDefinition::dump(FILE* output, size_t indent) const
print_indent(output, indent);
outln(output, "{{");
for (auto const& statement : m_statements) {
statement.dump(output, indent + 1);
statement->dump(output, indent + 1);
}
print_indent(output, indent);
outln(output, "}}");
}
NonnullRefPtrVector<Declaration const> FunctionDefinition::declarations() const
Vector<NonnullRefPtr<Declaration const>> FunctionDefinition::declarations() const
{
NonnullRefPtrVector<Declaration const> declarations;
Vector<NonnullRefPtr<Declaration const>> declarations;
for (auto& statement : m_statements) {
declarations.extend(statement.declarations());
declarations.extend(statement->declarations());
}
return declarations;
}
@ -297,7 +297,7 @@ void FunctionCall::dump(FILE* output, size_t indent) const
ASTNode::dump(output, indent);
m_callee->dump(output, indent + 1);
for (auto const& arg : m_arguments) {
arg.dump(output, indent + 1);
arg->dump(output, indent + 1);
}
}
@ -338,7 +338,7 @@ void StructOrClassDeclaration::dump(FILE* output, size_t indent) const
outln(output, ":");
for (size_t i = 0; i < m_baseclasses.size(); ++i) {
auto& baseclass = m_baseclasses[i];
baseclass.dump(output, indent + 1);
baseclass->dump(output, indent + 1);
if (i < m_baseclasses.size() - 1) {
print_indent(output, indent + 1);
outln(output, ",");
@ -347,12 +347,12 @@ void StructOrClassDeclaration::dump(FILE* output, size_t indent) const
}
outln(output, "");
for (auto& member : m_members) {
member.dump(output, indent + 1);
member->dump(output, indent + 1);
}
}
NonnullRefPtrVector<Declaration const> StructOrClassDeclaration::declarations() const
Vector<NonnullRefPtr<Declaration const>> StructOrClassDeclaration::declarations() const
{
NonnullRefPtrVector<Declaration const> declarations;
Vector<NonnullRefPtr<Declaration const>> declarations;
for (auto& member : m_members)
declarations.append(member);
return declarations;
@ -425,7 +425,7 @@ void FunctionType::dump(FILE* output, size_t indent) const
print_indent(output, indent + 1);
outln("(");
for (auto& parameter : m_parameters)
parameter.dump(output, indent + 2);
parameter->dump(output, indent + 2);
print_indent(output, indent + 1);
outln(")");
}
@ -441,7 +441,7 @@ void BlockStatement::dump(FILE* output, size_t indent) const
{
ASTNode::dump(output, indent);
for (auto& statement : m_statements) {
statement.dump(output, indent + 1);
statement->dump(output, indent + 1);
}
}
@ -458,10 +458,10 @@ void ForStatement::dump(FILE* output, size_t indent) const
m_body->dump(output, indent + 1);
}
NonnullRefPtrVector<Declaration const> Statement::declarations() const
Vector<NonnullRefPtr<Declaration const>> Statement::declarations() const
{
if (is_declaration()) {
NonnullRefPtrVector<Declaration const> vec;
Vector<NonnullRefPtr<Declaration const>> vec;
auto const& decl = static_cast<Declaration const&>(*this);
vec.empend(const_cast<Declaration&>(decl));
return vec;
@ -469,9 +469,9 @@ NonnullRefPtrVector<Declaration const> Statement::declarations() const
return {};
}
NonnullRefPtrVector<Declaration const> ForStatement::declarations() const
Vector<NonnullRefPtr<Declaration const>> ForStatement::declarations() const
{
NonnullRefPtrVector<Declaration const> declarations;
Vector<NonnullRefPtr<Declaration const>> declarations;
if (m_init)
declarations.extend(m_init->declarations());
if (m_body)
@ -479,11 +479,11 @@ NonnullRefPtrVector<Declaration const> ForStatement::declarations() const
return declarations;
}
NonnullRefPtrVector<Declaration const> BlockStatement::declarations() const
Vector<NonnullRefPtr<Declaration const>> BlockStatement::declarations() const
{
NonnullRefPtrVector<Declaration const> declarations;
Vector<NonnullRefPtr<Declaration const>> declarations;
for (auto& statement : m_statements) {
declarations.extend(statement.declarations());
declarations.extend(statement->declarations());
}
return declarations;
}
@ -508,9 +508,9 @@ void IfStatement::dump(FILE* output, size_t indent) const
}
}
NonnullRefPtrVector<Declaration const> IfStatement::declarations() const
Vector<NonnullRefPtr<Declaration const>> IfStatement::declarations() const
{
NonnullRefPtrVector<Declaration const> declarations;
Vector<NonnullRefPtr<Declaration const>> declarations;
if (m_predicate)
declarations.extend(m_predicate->declarations());
if (m_then)
@ -526,7 +526,7 @@ void NamespaceDeclaration::dump(FILE* output, size_t indent) const
print_indent(output, indent + 1);
outln(output, "{}", full_name());
for (auto& decl : m_declarations)
decl.dump(output, indent + 1);
decl->dump(output, indent + 1);
}
void NullPointerLiteral::dump(FILE* output, size_t indent) const
@ -549,7 +549,7 @@ StringView Name::full_name() const
StringBuilder builder;
if (!m_scope.is_empty()) {
for (auto& scope : m_scope) {
builder.appendff("{}::", scope.name());
builder.appendff("{}::", scope->name());
}
}
m_full_name = DeprecatedString::formatted("{}{}", builder.to_deprecated_string(), m_name.is_null() ? ""sv : m_name->name());
@ -565,7 +565,7 @@ StringView TemplatizedName::full_name() const
name.append(Name::full_name());
name.append('<');
for (auto& type : m_template_arguments) {
name.append(type.to_deprecated_string());
name.append(type->to_deprecated_string());
}
name.append('>');
m_full_name = name.to_deprecated_string();
@ -601,7 +601,7 @@ void BracedInitList::dump(FILE* output, size_t indent) const
{
ASTNode::dump(output, indent);
for (auto& exp : m_expressions) {
exp.dump(output, indent + 1);
exp->dump(output, indent + 1);
}
}
@ -621,7 +621,7 @@ void Constructor::dump(FILE* output, size_t indent) const
print_indent(output, indent + 1);
outln(output, "(");
for (auto const& arg : parameters()) {
arg.dump(output, indent + 1);
arg->dump(output, indent + 1);
}
print_indent(output, indent + 1);
outln(output, ")");
@ -637,7 +637,7 @@ void Destructor::dump(FILE* output, size_t indent) const
print_indent(output, indent + 1);
outln(output, "(");
for (auto const& arg : parameters()) {
arg.dump(output, indent + 1);
arg->dump(output, indent + 1);
}
print_indent(output, indent + 1);
outln(output, ")");

View file

@ -54,7 +54,7 @@ public:
void set_end(Position const& end) { m_end = end; }
void set_parent(ASTNode const& parent) { m_parent = &parent; }
virtual NonnullRefPtrVector<Declaration const> declarations() const { return {}; }
virtual Vector<NonnullRefPtr<Declaration const>> declarations() const { return {}; }
virtual bool is_identifier() const { return false; }
virtual bool is_member_expression() const { return false; }
@ -87,17 +87,17 @@ public:
virtual ~TranslationUnit() override = default;
virtual StringView class_name() const override { return "TranslationUnit"sv; }
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
virtual NonnullRefPtrVector<Declaration const> declarations() const override { return m_declarations; }
virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override { return m_declarations; }
TranslationUnit(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
: ASTNode(parent, start, end, filename)
{
}
void set_declarations(NonnullRefPtrVector<Declaration const>&& declarations) { m_declarations = move(declarations); }
void set_declarations(Vector<NonnullRefPtr<Declaration const>>&& declarations) { m_declarations = move(declarations); }
private:
NonnullRefPtrVector<Declaration const> m_declarations;
Vector<NonnullRefPtr<Declaration const>> m_declarations;
};
class Statement : public ASTNode {
@ -105,7 +105,7 @@ public:
virtual ~Statement() override = default;
virtual StringView class_name() const override { return "Statement"sv; }
virtual NonnullRefPtrVector<Declaration const> declarations() const override;
virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override;
protected:
Statement(ASTNode const* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
@ -167,20 +167,20 @@ public:
{
}
virtual NonnullRefPtrVector<Declaration const> declarations() const override;
virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override;
Vector<StringView> const& qualifiers() const { return m_qualifiers; }
void set_qualifiers(Vector<StringView> const& qualifiers) { m_qualifiers = qualifiers; }
Type const* return_type() const { return m_return_type.ptr(); }
void set_return_type(RefPtr<Type const> const& return_type) { m_return_type = return_type; }
NonnullRefPtrVector<Parameter const> const& parameters() const { return m_parameters; }
void set_parameters(NonnullRefPtrVector<Parameter const> const& parameters) { m_parameters = parameters; }
Vector<NonnullRefPtr<Parameter const>> const& parameters() const { return m_parameters; }
void set_parameters(Vector<NonnullRefPtr<Parameter const>> const& parameters) { m_parameters = parameters; }
FunctionDefinition const* definition() const { return m_definition.ptr(); }
void set_definition(RefPtr<FunctionDefinition const>&& definition) { m_definition = move(definition); }
private:
Vector<StringView> m_qualifiers;
RefPtr<Type const> m_return_type;
NonnullRefPtrVector<Parameter const> m_parameters;
Vector<NonnullRefPtr<Parameter const>> m_parameters;
RefPtr<FunctionDefinition const> m_definition;
};
@ -325,11 +325,11 @@ public:
}
void set_return_type(Type& type) { m_return_type = type; }
void set_parameters(NonnullRefPtrVector<Parameter const> parameters) { m_parameters = move(parameters); }
void set_parameters(Vector<NonnullRefPtr<Parameter const>> parameters) { m_parameters = move(parameters); }
private:
RefPtr<Type const> m_return_type;
NonnullRefPtrVector<Parameter const> m_parameters;
Vector<NonnullRefPtr<Parameter const>> m_parameters;
};
class FunctionDefinition : public ASTNode {
@ -343,12 +343,12 @@ public:
{
}
virtual NonnullRefPtrVector<Declaration const> declarations() const override;
NonnullRefPtrVector<Statement const> const& statements() { return m_statements; }
virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override;
Vector<NonnullRefPtr<Statement const>> const& statements() { return m_statements; }
void add_statement(NonnullRefPtr<Statement const>&& statement) { m_statements.append(move(statement)); }
private:
NonnullRefPtrVector<Statement const> m_statements;
Vector<NonnullRefPtr<Statement const>> m_statements;
};
class InvalidStatement : public Statement {
@ -444,13 +444,13 @@ public:
Identifier const* name() const { return m_name.ptr(); }
void set_name(RefPtr<Identifier const>&& name) { m_name = move(name); }
NonnullRefPtrVector<Identifier const> const& scope() const { return m_scope; }
void set_scope(NonnullRefPtrVector<Identifier const> scope) { m_scope = move(scope); }
Vector<NonnullRefPtr<Identifier const>> const& scope() const { return m_scope; }
void set_scope(Vector<NonnullRefPtr<Identifier const>> scope) { m_scope = move(scope); }
void add_to_scope(NonnullRefPtr<Identifier const>&& part) { m_scope.append(move(part)); }
private:
RefPtr<Identifier const> m_name;
NonnullRefPtrVector<Identifier const> m_scope;
Vector<NonnullRefPtr<Identifier const>> m_scope;
mutable Optional<DeprecatedString> m_full_name;
};
@ -469,7 +469,7 @@ public:
void add_template_argument(NonnullRefPtr<Type const>&& type) { m_template_arguments.append(move(type)); }
private:
NonnullRefPtrVector<Type const> m_template_arguments;
Vector<NonnullRefPtr<Type const>> m_template_arguments;
mutable Optional<DeprecatedString> m_full_name;
};
@ -609,11 +609,11 @@ public:
void set_callee(RefPtr<Expression const>&& callee) { m_callee = move(callee); }
void add_argument(NonnullRefPtr<Expression const>&& arg) { m_arguments.append(move(arg)); }
NonnullRefPtrVector<Expression const> const& arguments() const { return m_arguments; }
Vector<NonnullRefPtr<Expression const>> const& arguments() const { return m_arguments; }
private:
RefPtr<Expression const> m_callee;
NonnullRefPtrVector<Expression const> m_arguments;
Vector<NonnullRefPtr<Expression const>> m_arguments;
};
class StringLiteral final : public Expression {
@ -689,7 +689,7 @@ public:
virtual bool is_struct_or_class() const override { return true; }
virtual bool is_struct() const override { return m_type == Type::Struct; }
virtual bool is_class() const override { return m_type == Type::Class; }
virtual NonnullRefPtrVector<Declaration const> declarations() const override;
virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override;
enum class Type {
Struct,
@ -702,16 +702,16 @@ public:
{
}
NonnullRefPtrVector<Declaration const> const& members() const { return m_members; }
void set_members(NonnullRefPtrVector<Declaration const>&& members) { m_members = move(members); }
Vector<NonnullRefPtr<Declaration const>> const& members() const { return m_members; }
void set_members(Vector<NonnullRefPtr<Declaration const>>&& members) { m_members = move(members); }
NonnullRefPtrVector<Name const> const& baseclasses() const { return m_baseclasses; }
void set_baseclasses(NonnullRefPtrVector<Name const>&& baseclasses) { m_baseclasses = move(baseclasses); }
Vector<NonnullRefPtr<Name const>> const& baseclasses() const { return m_baseclasses; }
void set_baseclasses(Vector<NonnullRefPtr<Name const>>&& baseclasses) { m_baseclasses = move(baseclasses); }
private:
StructOrClassDeclaration::Type m_type;
NonnullRefPtrVector<Declaration const> m_members;
NonnullRefPtrVector<Name const> m_baseclasses;
Vector<NonnullRefPtr<Declaration const>> m_members;
Vector<NonnullRefPtr<Name const>> m_baseclasses;
};
enum class UnaryOp {
@ -776,7 +776,7 @@ public:
virtual StringView class_name() const override { return "ForStatement"sv; }
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
virtual NonnullRefPtrVector<Declaration const> declarations() const override;
virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override;
void set_init(RefPtr<VariableDeclaration const>&& init) { m_init = move(init); }
void set_test(RefPtr<Expression const>&& test) { m_test = move(test); }
@ -802,12 +802,12 @@ public:
virtual StringView class_name() const override { return "BlockStatement"sv; }
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
virtual NonnullRefPtrVector<Declaration const> declarations() const override;
virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override;
void add_statement(NonnullRefPtr<Statement const>&& statement) { m_statements.append(move(statement)); }
private:
NonnullRefPtrVector<Statement const> m_statements;
Vector<NonnullRefPtr<Statement const>> m_statements;
};
class Comment final : public Statement {
@ -831,7 +831,7 @@ public:
virtual ~IfStatement() override = default;
virtual StringView class_name() const override { return "IfStatement"sv; }
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
virtual NonnullRefPtrVector<Declaration const> declarations() const override;
virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override;
void set_predicate(RefPtr<Expression const>&& predicate) { m_predicate = move(predicate); }
void set_then_statement(RefPtr<Statement const>&& then) { m_then = move(then); }
@ -858,11 +858,11 @@ public:
{
}
virtual NonnullRefPtrVector<Declaration const> declarations() const override { return m_declarations; }
virtual Vector<NonnullRefPtr<Declaration const>> declarations() const override { return m_declarations; }
void add_declaration(NonnullRefPtr<Declaration const>&& declaration) { m_declarations.append(move(declaration)); }
private:
NonnullRefPtrVector<Declaration const> m_declarations;
Vector<NonnullRefPtr<Declaration const>> m_declarations;
};
class CppCastExpression : public Expression {
@ -936,7 +936,7 @@ public:
void add_expression(NonnullRefPtr<Expression const>&& exp) { m_expressions.append(move(exp)); }
private:
NonnullRefPtrVector<Expression const> m_expressions;
Vector<NonnullRefPtr<Expression const>> m_expressions;
};
class DummyAstNode : public ASTNode {

View file

@ -37,9 +37,9 @@ NonnullRefPtr<TranslationUnit> Parser::parse()
return unit;
}
NonnullRefPtrVector<Declaration const> Parser::parse_declarations_in_translation_unit(ASTNode const& parent)
Vector<NonnullRefPtr<Declaration const>> Parser::parse_declarations_in_translation_unit(ASTNode const& parent)
{
NonnullRefPtrVector<Declaration const> declarations;
Vector<NonnullRefPtr<Declaration const>> declarations;
while (!eof()) {
auto declaration = parse_single_declaration_in_translation_unit(parent);
if (declaration) {
@ -259,13 +259,13 @@ bool Parser::match_template_arguments()
return peek().type() == Token::Type::Greater;
}
NonnullRefPtrVector<Type const> Parser::parse_template_arguments(ASTNode const& parent)
Vector<NonnullRefPtr<Type const>> Parser::parse_template_arguments(ASTNode const& parent)
{
LOG_SCOPE();
consume(Token::Type::Less);
NonnullRefPtrVector<Type const> template_arguments;
Vector<NonnullRefPtr<Type const>> template_arguments;
while (!eof() && peek().type() != Token::Type::Greater) {
template_arguments.append(parse_type(parent));
}
@ -350,7 +350,7 @@ NonnullRefPtr<Expression const> Parser::parse_expression(ASTNode const& parent)
return expression;
}
NonnullRefPtrVector<Expression const> secondary_expressions;
Vector<NonnullRefPtr<Expression const>> secondary_expressions;
while (match_secondary_expression()) {
// FIXME: Handle operator precedence
@ -359,7 +359,7 @@ NonnullRefPtr<Expression const> Parser::parse_expression(ASTNode const& parent)
}
for (size_t i = 0; secondary_expressions.size() != 0 && i < secondary_expressions.size() - 1; ++i) {
const_cast<Expression&>(secondary_expressions[i]).set_parent(secondary_expressions[i + 1]);
const_cast<Expression&>(*secondary_expressions[i]).set_parent(secondary_expressions[i + 1]);
}
return expression;
@ -748,10 +748,10 @@ bool Parser::match_function_declaration()
return false;
}
Optional<NonnullRefPtrVector<Parameter const>> Parser::parse_parameter_list(ASTNode const& parent)
Optional<Vector<NonnullRefPtr<Parameter const>>> Parser::parse_parameter_list(ASTNode const& parent)
{
LOG_SCOPE();
NonnullRefPtrVector<Parameter const> parameters;
Vector<NonnullRefPtr<Parameter const>> parameters;
while (peek().type() != Token::Type::RightParen && !eof()) {
if (match_ellipsis()) {
auto param = create_ast_node<Parameter>(parent, position(), {}, RefPtr<Name> {});
@ -981,7 +981,7 @@ Optional<size_t> Parser::index_of_node_at(Position pos) const
for (size_t node_index = 0; node_index < m_nodes.size(); ++node_index) {
auto& node = m_nodes[node_index];
if (node.start() > pos || node.end() < pos)
if (node->start() > pos || node->end() < pos)
continue;
if (!match_node_index.has_value() || (node_span(node) <= node_span(m_nodes[match_node_index.value()])))
@ -1155,7 +1155,7 @@ NonnullRefPtr<StructOrClassDeclaration const> Parser::parse_class_declaration(AS
auto has_final = match_keyword("final");
NonnullRefPtrVector<Name const> baseclasses;
Vector<NonnullRefPtr<Name const>> baseclasses;
// FIXME: Don't ignore this.
if (peek(has_final ? 1 : 0).type() == Token::Type::Colon) {
@ -1569,11 +1569,11 @@ NonnullRefPtr<BracedInitList const> Parser::parse_braced_init_list(ASTNode const
init_list->set_end(position());
return init_list;
}
NonnullRefPtrVector<Declaration const> Parser::parse_class_members(StructOrClassDeclaration& parent)
Vector<NonnullRefPtr<Declaration const>> Parser::parse_class_members(StructOrClassDeclaration& parent)
{
auto class_name = parent.full_name();
NonnullRefPtrVector<Declaration const> members;
Vector<NonnullRefPtr<Declaration const>> members;
while (!eof() && peek().type() != Token::Type::RightCurly) {
if (match_access_specifier())
consume_access_specifier(); // FIXME: Do not ignore access specifiers

View file

@ -83,7 +83,7 @@ private:
bool match_destructor(StringView class_name);
bool match_using_namespace_declaration();
Optional<NonnullRefPtrVector<Parameter const>> parse_parameter_list(ASTNode const& parent);
Optional<Vector<NonnullRefPtr<Parameter const>>> parse_parameter_list(ASTNode const& parent);
Optional<Token> consume_whitespace();
void consume_preprocessor();
@ -110,15 +110,15 @@ private:
NonnullRefPtr<Comment const> parse_comment(ASTNode const& parent);
NonnullRefPtr<IfStatement const> parse_if_statement(ASTNode const& parent);
NonnullRefPtr<NamespaceDeclaration const> parse_namespace_declaration(ASTNode const& parent, bool is_nested_namespace = false);
NonnullRefPtrVector<Declaration const> parse_declarations_in_translation_unit(ASTNode const& parent);
Vector<NonnullRefPtr<Declaration const>> parse_declarations_in_translation_unit(ASTNode const& parent);
RefPtr<Declaration const> parse_single_declaration_in_translation_unit(ASTNode const& parent);
NonnullRefPtrVector<Type const> parse_template_arguments(ASTNode const& parent);
Vector<NonnullRefPtr<Type const>> parse_template_arguments(ASTNode const& parent);
NonnullRefPtr<Name const> parse_name(ASTNode const& parent);
NonnullRefPtr<CppCastExpression const> parse_cpp_cast_expression(ASTNode const& parent);
NonnullRefPtr<SizeofExpression const> parse_sizeof_expression(ASTNode const& parent);
NonnullRefPtr<BracedInitList const> parse_braced_init_list(ASTNode const& parent);
NonnullRefPtr<CStyleCastExpression const> parse_c_style_cast_expression(ASTNode const& parent);
NonnullRefPtrVector<Declaration const> parse_class_members(StructOrClassDeclaration& parent);
Vector<NonnullRefPtr<Declaration const>> parse_class_members(StructOrClassDeclaration& parent);
NonnullRefPtr<Constructor const> parse_constructor(ASTNode const& parent);
NonnullRefPtr<Destructor const> parse_destructor(ASTNode const& parent);
NonnullRefPtr<UsingNamespaceDeclaration const> parse_using_namespace_declaration(ASTNode const& parent);
@ -138,7 +138,7 @@ private:
struct State {
size_t token_index { 0 };
NonnullRefPtrVector<ASTNode> state_nodes;
Vector<NonnullRefPtr<ASTNode>> state_nodes;
};
void error(StringView message = {});
@ -192,7 +192,7 @@ private:
Vector<State> m_saved_states;
RefPtr<TranslationUnit> m_root_node;
Vector<DeprecatedString> m_errors;
NonnullRefPtrVector<ASTNode> m_nodes;
Vector<NonnullRefPtr<ASTNode>> m_nodes;
};
}

View file

@ -33,22 +33,22 @@ bool Track::check_processor_chain_valid_with_initial_type(SignalType initial_typ
for (auto& processor : m_processor_chain) {
// The first processor must have the given initial signal type as input.
if (previous_processor == nullptr) {
if (processor.input_type() != initial_type)
if (processor->input_type() != initial_type)
return false;
} else if (previous_processor->output_type() != processor.input_type())
} else if (previous_processor->output_type() != processor->input_type())
return false;
previous_processor = &processor;
previous_processor = processor.ptr();
}
return true;
}
NonnullRefPtr<Synthesizers::Classic> Track::synth()
{
return static_ptr_cast<Synthesizers::Classic>(m_processor_chain.ptr_at(0));
return static_ptr_cast<Synthesizers::Classic>(m_processor_chain[0]);
}
NonnullRefPtr<Effects::Delay> Track::delay()
{
return static_ptr_cast<Effects::Delay>(m_processor_chain.ptr_at(1));
return static_ptr_cast<Effects::Delay>(m_processor_chain[1]);
}
bool AudioTrack::check_processor_chain_valid() const
@ -81,11 +81,11 @@ void Track::current_signal(FixedArray<Sample>& output_signal)
for (auto& processor : m_processor_chain) {
// Depending on what the processor needs to have as output, we need to place either a pre-allocated note hash map or a pre-allocated sample buffer in the target signal.
if (processor.output_type() == SignalType::Note)
if (processor->output_type() == SignalType::Note)
target_signal = &m_secondary_note_buffer;
else
target_signal = &m_secondary_sample_buffer;
processor.process(*source_signal, *target_signal);
processor->process(*source_signal, *target_signal);
swap(source_signal, target_signal);
}
VERIFY(source_signal->type() == SignalType::Sample);
@ -109,9 +109,9 @@ void NoteTrack::compute_current_clips_signal()
for (auto& clip : m_clips) {
// A clip is playing if its start time or end time fall in the current time range.
// Or, if they both enclose the current time range.
if ((clip.start() <= start_time && clip.end() >= end_time)
|| (clip.start() >= start_time && clip.start() < end_time)
|| (clip.end() > start_time && clip.end() <= end_time)) {
if ((clip->start() <= start_time && clip->end() >= end_time)
|| (clip->start() >= start_time && clip->start() < end_time)
|| (clip->end() > start_time && clip->end() <= end_time)) {
VERIFY(playing_clips_index < playing_clips.size());
playing_clips[playing_clips_index++] = clip;
}
@ -149,8 +149,8 @@ void AudioTrack::compute_current_clips_signal()
Optional<RollNote> NoteTrack::note_at(u32 time, u8 pitch) const
{
for (auto& clip : m_clips) {
if (time >= clip.start() && time <= clip.end())
return clip.note_at(time, pitch);
if (time >= clip->start() && time <= clip->end())
return clip->note_at(time, pitch);
}
return {};
@ -159,15 +159,15 @@ Optional<RollNote> NoteTrack::note_at(u32 time, u8 pitch) const
void NoteTrack::set_note(RollNote note)
{
for (auto& clip : m_clips) {
if (clip.start() <= note.on_sample && clip.end() >= note.on_sample)
clip.set_note(note);
if (clip->start() <= note.on_sample && clip->end() >= note.on_sample)
clip->set_note(note);
}
}
void NoteTrack::remove_note(RollNote note)
{
for (auto& clip : m_clips)
clip.remove_note(note);
clip->remove_note(note);
}
void NoteTrack::add_clip(u32 start_time, u32 end_time)

View file

@ -33,7 +33,7 @@ public:
// We are informed of an audio buffer size change. This happens off-audio-thread so we can allocate.
ErrorOr<void> resize_internal_buffers_to(size_t buffer_size);
NonnullRefPtrVector<Processor> const& processor_chain() const { return m_processor_chain; }
Vector<NonnullRefPtr<Processor>> const& processor_chain() const { return m_processor_chain; }
NonnullRefPtr<Transport const> transport() const { return m_transport; }
NonnullRefPtr<DSP::Effects::Mastering> track_mastering() { return m_track_mastering; }
@ -53,7 +53,7 @@ protected:
// Subclasses override to provide the base signal to the processing chain
virtual void compute_current_clips_signal() = 0;
NonnullRefPtrVector<Processor> m_processor_chain;
Vector<NonnullRefPtr<Processor>> m_processor_chain;
NonnullRefPtr<Transport> m_transport;
NonnullRefPtr<Effects::Mastering> m_track_mastering;
NonnullRefPtr<Keyboard> m_keyboard;
@ -90,7 +90,7 @@ protected:
void compute_current_clips_signal() override;
private:
NonnullRefPtrVector<NoteClip> m_clips;
Vector<NonnullRefPtr<NoteClip>> m_clips;
};
class AudioTrack final : public Track {
@ -103,13 +103,13 @@ public:
}
bool check_processor_chain_valid() const override;
NonnullRefPtrVector<AudioClip> const& clips() const { return m_clips; }
Vector<NonnullRefPtr<AudioClip>> const& clips() const { return m_clips; }
protected:
void compute_current_clips_signal() override;
private:
NonnullRefPtrVector<AudioClip> m_clips;
Vector<NonnullRefPtr<AudioClip>> m_clips;
};
}

View file

@ -102,10 +102,10 @@ Vector<DeprecatedString> Launcher::get_handlers_for_url(const URL& url)
return connection().get_handlers_for_url(url.to_deprecated_string());
}
auto Launcher::get_handlers_with_details_for_url(const URL& url) -> NonnullRefPtrVector<Details>
auto Launcher::get_handlers_with_details_for_url(const URL& url) -> Vector<NonnullRefPtr<Details>>
{
auto details = connection().get_handlers_with_details_for_url(url.to_deprecated_string());
NonnullRefPtrVector<Details> handlers_with_details;
Vector<NonnullRefPtr<Details>> handlers_with_details;
for (auto& value : details) {
handlers_with_details.append(Details::from_details_str(value));
}

View file

@ -39,7 +39,7 @@ public:
static bool open(const URL&, DeprecatedString const& handler_name = {});
static bool open(const URL&, Details const& details);
static Vector<DeprecatedString> get_handlers_for_url(const URL&);
static NonnullRefPtrVector<Details> get_handlers_with_details_for_url(const URL&);
static Vector<NonnullRefPtr<Details>> get_handlers_with_details_for_url(const URL&);
};
}

View file

@ -348,12 +348,12 @@ static void for_each_unfinished_dependency_of(DeprecatedString const& path, Hash
callback(*s_loaders.get(path).value());
}
static NonnullRefPtrVector<DynamicLoader> collect_loaders_for_library(DeprecatedString const& path)
static Vector<NonnullRefPtr<DynamicLoader>> collect_loaders_for_library(DeprecatedString const& path)
{
VERIFY(path.starts_with('/'));
HashTable<DeprecatedString> seen_names;
NonnullRefPtrVector<DynamicLoader> loaders;
Vector<NonnullRefPtr<DynamicLoader>> loaders;
for_each_unfinished_dependency_of(path, seen_names, [&](auto& loader) {
loaders.append(loader);
});
@ -386,37 +386,37 @@ static Result<void, DlErrorMessage> link_main_library(DeprecatedString const& pa
auto loaders = collect_loaders_for_library(path);
for (auto& loader : loaders) {
auto dynamic_object = loader.map();
auto dynamic_object = loader->map();
if (dynamic_object)
s_global_objects.set(dynamic_object->filepath(), *dynamic_object);
}
for (auto& loader : loaders) {
bool success = loader.link(flags);
bool success = loader->link(flags);
if (!success) {
return DlErrorMessage { DeprecatedString::formatted("Failed to link library {}", loader.filepath()) };
return DlErrorMessage { DeprecatedString::formatted("Failed to link library {}", loader->filepath()) };
}
}
for (auto& loader : loaders) {
auto result = loader.load_stage_3(flags);
auto result = loader->load_stage_3(flags);
VERIFY(!result.is_error());
auto& object = result.value();
if (loader.filepath().ends_with("/libc.so"sv)) {
if (loader->filepath().ends_with("/libc.so"sv)) {
initialize_libc(*object);
}
if (loader.filepath().ends_with("/libsystem.so"sv)) {
VERIFY(!loader.text_segments().is_empty());
for (auto const& segment : loader.text_segments()) {
if (loader->filepath().ends_with("/libsystem.so"sv)) {
VERIFY(!loader->text_segments().is_empty());
for (auto const& segment : loader->text_segments()) {
auto flags = static_cast<int>(VirtualMemoryRangeFlags::SyscallCode) | static_cast<int>(VirtualMemoryRangeFlags::Immutable);
if (syscall(SC_annotate_mapping, segment.address().get(), flags)) {
VERIFY_NOT_REACHED();
}
}
} else {
for (auto const& segment : loader.text_segments()) {
for (auto const& segment : loader->text_segments()) {
auto flags = static_cast<int>(VirtualMemoryRangeFlags::Immutable);
if (syscall(SC_annotate_mapping, segment.address().get(), flags)) {
VERIFY_NOT_REACHED();
@ -428,7 +428,7 @@ static Result<void, DlErrorMessage> link_main_library(DeprecatedString const& pa
drop_loader_promise("prot_exec"sv);
for (auto& loader : loaders) {
loader.load_stage_4();
loader->load_stage_4();
}
return {};

View file

@ -152,7 +152,7 @@ public:
class Object : public ValueNode {
public:
Object() = default;
Object(DeprecatedString name, NonnullRefPtrVector<Node const> properties, NonnullRefPtrVector<Node const> sub_objects)
Object(DeprecatedString name, Vector<NonnullRefPtr<Node const>> properties, Vector<NonnullRefPtr<Node const>> sub_objects)
: m_properties(move(properties))
, m_sub_objects(move(sub_objects))
, m_name(move(name))
@ -182,7 +182,7 @@ public:
{
for (auto const& child : m_properties) {
if (is<KeyValuePair>(child)) {
auto const& property = static_cast<KeyValuePair const&>(child);
auto const& property = static_cast<KeyValuePair const&>(*child);
if (property.key() != "layout" && is<JsonValueNode>(property.value().ptr()))
callback(property.key(), static_ptr_cast<JsonValueNode>(property.value()));
}
@ -207,7 +207,7 @@ public:
for (auto const& child : m_sub_objects) {
// doesn't capture layout as intended, as that's behind a kv-pair
if (is<Object>(child)) {
TRY(callback(static_cast<Object const&>(child)));
TRY(callback(static_cast<Object const&>(*child)));
}
}
@ -218,7 +218,7 @@ public:
{
for (auto const& child : m_properties) {
if (is<KeyValuePair>(child)) {
auto const& property = static_cast<KeyValuePair const&>(child);
auto const& property = static_cast<KeyValuePair const&>(*child);
if (property.key() == "layout") {
VERIFY(is<Object>(property.value().ptr()));
return static_cast<Object const&>(*property.value());
@ -232,7 +232,7 @@ public:
{
for (auto const& child : m_properties) {
if (is<KeyValuePair>(child)) {
auto const& property = static_cast<KeyValuePair const&>(child);
auto const& property = static_cast<KeyValuePair const&>(*child);
if (property.key() == property_name)
return property.value();
}
@ -251,7 +251,7 @@ public:
builder.append('\n');
for (auto const& property : m_properties)
property.format(builder, indentation + 1, false);
property->format(builder, indentation + 1, false);
if (!m_properties.is_empty() && !m_sub_objects.is_empty())
builder.append('\n');
@ -259,7 +259,7 @@ public:
// This loop is necessary as we need to know what the last child is.
for (size_t i = 0; i < m_sub_objects.size(); ++i) {
auto const& child = m_sub_objects[i];
child.format(builder, indentation + 1, false);
child->format(builder, indentation + 1, false);
if (is<Object>(child) && i != m_sub_objects.size() - 1)
builder.append('\n');
@ -274,9 +274,9 @@ public:
private:
// Properties and comments
NonnullRefPtrVector<Node const> m_properties;
Vector<NonnullRefPtr<Node const>> m_properties;
// Sub objects and comments
NonnullRefPtrVector<Node const> m_sub_objects;
Vector<NonnullRefPtr<Node const>> m_sub_objects;
DeprecatedString m_name {};
};
@ -304,18 +304,18 @@ public:
bool has_main_class() const { return m_main_class != nullptr; }
NonnullRefPtrVector<Comment const> leading_comments() const { return m_leading_comments; }
Vector<NonnullRefPtr<Comment const>> leading_comments() const { return m_leading_comments; }
Object const& main_class() const
{
VERIFY(!m_main_class.is_null());
return *m_main_class.ptr();
}
NonnullRefPtrVector<Comment const> trailing_comments() const { return m_trailing_comments; }
Vector<NonnullRefPtr<Comment const>> trailing_comments() const { return m_trailing_comments; }
virtual void format(StringBuilder& builder, size_t indentation, [[maybe_unused]] bool is_inline) const override
{
for (auto const& comment : m_leading_comments)
comment.format(builder, indentation, false);
comment->format(builder, indentation, false);
if (!m_leading_comments.is_empty())
builder.append('\n');
@ -324,13 +324,13 @@ public:
builder.append('\n');
for (auto const& comment : m_trailing_comments)
comment.format(builder, indentation, false);
comment->format(builder, indentation, false);
}
private:
NonnullRefPtrVector<Comment const> m_leading_comments;
Vector<NonnullRefPtr<Comment const>> m_leading_comments;
RefPtr<Object const> m_main_class;
NonnullRefPtrVector<Comment const> m_trailing_comments;
Vector<NonnullRefPtr<Comment const>> m_trailing_comments;
};
}

View file

@ -46,7 +46,7 @@ static ErrorOr<NonnullRefPtr<Object>> parse_gml_object(Queue<Token>& tokens)
tokens.dequeue();
NonnullRefPtrVector<Comment> pending_comments;
Vector<NonnullRefPtr<Comment>> pending_comments;
for (;;) {
if (peek() == Token::Type::RightCurly) {
// End of object

View file

@ -32,7 +32,7 @@ public:
private:
Menubar() = default;
NonnullRefPtrVector<Menu> m_menus;
Vector<NonnullRefPtr<Menu>> m_menus;
};
}

View file

@ -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);
}

View file

@ -78,7 +78,7 @@ private:
virtual void child_event(Core::ChildEvent&) override;
NonnullRefPtrVector<Segment> m_segments;
Vector<NonnullRefPtr<Segment>> m_segments;
RefPtr<ResizeCorner> m_corner;
};

View file

@ -414,7 +414,7 @@ private:
RefPtr<Action> m_select_all_action;
RefPtr<Action> m_insert_emoji_action;
Core::ElapsedTimer m_triple_click_timer;
NonnullRefPtrVector<Action> m_custom_context_menu_actions;
Vector<NonnullRefPtr<Action>> m_custom_context_menu_actions;
size_t m_reflow_deferred { 0 };
bool m_reflow_requested { false };

View file

@ -32,12 +32,12 @@ ModelIndex TreeViewModel::parent_index(ModelIndex const& index) const
return {};
if (parent_node->parent_node() == nullptr) {
for (size_t row = 0; row < m_nodes.size(); row++)
if (m_nodes.ptr_at(row).ptr() == parent_node)
if (m_nodes[row] == parent_node)
return create_index(static_cast<int>(row), 0, parent_node);
VERIFY_NOT_REACHED();
}
for (size_t row = 0; row < parent_node->parent_node()->child_nodes().size(); row++) {
auto const* child_node_at_row = parent_node->parent_node()->child_nodes().ptr_at(row).ptr();
auto const* child_node_at_row = parent_node->parent_node()->child_nodes()[row].ptr();
if (child_node_at_row == parent_node)
return create_index(static_cast<int>(row), 0, parent_node);
}

View file

@ -59,18 +59,18 @@ public:
Node const* parent_node() const { return m_parent_node; }
Node* parent_node() { return m_parent_node; }
NonnullRefPtrVector<Node> const& child_nodes() const { return m_child_nodes; }
NonnullRefPtrVector<Node>& child_nodes() { return m_child_nodes; }
Vector<NonnullRefPtr<Node>> const& child_nodes() const { return m_child_nodes; }
Vector<NonnullRefPtr<Node>>& child_nodes() { return m_child_nodes; }
private:
DeprecatedString m_text;
Optional<Icon> m_icon;
WeakPtr<Node> m_parent_node;
NonnullRefPtrVector<Node> m_child_nodes;
Vector<NonnullRefPtr<Node>> m_child_nodes;
};
NonnullRefPtrVector<Node> const& nodes() const { return m_nodes; }
NonnullRefPtrVector<Node>& nodes() { return m_nodes; }
Vector<NonnullRefPtr<Node>> const& nodes() const { return m_nodes; }
Vector<NonnullRefPtr<Node>>& nodes() { return m_nodes; }
template<typename NodeType = Node, typename... Args>
NonnullRefPtr<NodeType> add_node(DeprecatedString text, Optional<Icon> icon, Args&&... args)
@ -86,7 +86,7 @@ public:
private:
TreeViewModel() = default;
NonnullRefPtrVector<Node> m_nodes;
Vector<NonnullRefPtr<Node>> m_nodes;
};
}

View file

@ -702,7 +702,7 @@ Widget* Widget::child_at(Gfx::IntPoint point) const
for (int i = children().size() - 1; i >= 0; --i) {
if (!is<Widget>(children()[i]))
continue;
auto& child = verify_cast<Widget>(children()[i]);
auto& child = verify_cast<Widget>(*children()[i]);
if (!child.is_visible())
continue;
if (child.relative_non_grabbable_rect().contains(point))
@ -976,7 +976,7 @@ bool Widget::is_frontmost() const
auto* parent = parent_widget();
if (!parent)
return true;
return &parent->children().last() == this;
return parent->children().last() == this;
}
bool Widget::is_backmost() const
@ -984,7 +984,7 @@ bool Widget::is_backmost() const
auto* parent = parent_widget();
if (!parent)
return true;
return &parent->children().first() == this;
return parent->children().first() == this;
}
Action* Widget::action_for_shortcut(Shortcut const& shortcut)
@ -1036,8 +1036,8 @@ Vector<Widget&> Widget::child_widgets() const
Vector<Widget&> widgets;
widgets.ensure_capacity(children().size());
for (auto& child : const_cast<Widget*>(this)->children()) {
if (is<Widget>(child))
widgets.append(static_cast<Widget&>(child));
if (is<Widget>(*child))
widgets.append(static_cast<Widget&>(*child));
}
return widgets;
}

View file

@ -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()

View file

@ -49,6 +49,6 @@ private:
RefPtr<Button> m_next_button;
RefPtr<Button> m_cancel_button;
NonnullRefPtrVector<AbstractWizardPage> m_page_stack;
Vector<NonnullRefPtr<AbstractWizardPage>> m_page_stack;
};
}

View file

@ -232,52 +232,52 @@ void AntiAliasingPainter::stroke_path(Path const& path, Color color, float thick
Optional<FloatLine> first_line;
for (auto& segment : path.segments()) {
switch (segment.type()) {
switch (segment->type()) {
case Segment::Type::Invalid:
VERIFY_NOT_REACHED();
case Segment::Type::MoveTo:
cursor = segment.point();
cursor = segment->point();
break;
case Segment::Type::LineTo:
draw_line(cursor, segment.point(), color, thickness);
draw_line(cursor, segment->point(), color, thickness);
if (thickness > 1) {
if (!first_line.has_value())
first_line = FloatLine(cursor, segment.point());
first_line = FloatLine(cursor, segment->point());
if (previous_was_line)
stroke_segment_intersection(cursor, segment.point(), last_line, color, thickness);
stroke_segment_intersection(cursor, segment->point(), last_line, color, thickness);
last_line.set_a(cursor);
last_line.set_b(segment.point());
last_line.set_b(segment->point());
}
cursor = segment.point();
cursor = segment->point();
break;
case Segment::Type::QuadraticBezierCurveTo: {
auto through = static_cast<QuadraticBezierCurveSegment const&>(segment).through();
draw_quadratic_bezier_curve(through, cursor, segment.point(), color, thickness);
cursor = segment.point();
auto through = static_cast<QuadraticBezierCurveSegment const&>(*segment).through();
draw_quadratic_bezier_curve(through, cursor, segment->point(), color, thickness);
cursor = segment->point();
break;
}
case Segment::Type::CubicBezierCurveTo: {
auto& curve = static_cast<CubicBezierCurveSegment const&>(segment);
auto& curve = static_cast<CubicBezierCurveSegment const&>(*segment);
auto through_0 = curve.through_0();
auto through_1 = curve.through_1();
draw_cubic_bezier_curve(through_0, through_1, cursor, segment.point(), color, thickness);
cursor = segment.point();
draw_cubic_bezier_curve(through_0, through_1, cursor, segment->point(), color, thickness);
cursor = segment->point();
break;
}
case Segment::Type::EllipticalArcTo:
auto& arc = static_cast<EllipticalArcSegment const&>(segment);
draw_elliptical_arc(cursor, segment.point(), arc.center(), arc.radii(), arc.x_axis_rotation(), arc.theta_1(), arc.theta_delta(), color, thickness);
cursor = segment.point();
auto& arc = static_cast<EllipticalArcSegment const&>(*segment);
draw_elliptical_arc(cursor, segment->point(), arc.center(), arc.radii(), arc.x_axis_rotation(), arc.theta_1(), arc.theta_delta(), color, thickness);
cursor = segment->point();
break;
}
previous_was_line = segment.type() == Segment::Type::LineTo;
previous_was_line = segment->type() == Segment::Type::LineTo;
}
// Check if the figure was started and closed as line at the same position.
if (thickness > 1 && previous_was_line && path.segments().size() >= 2 && path.segments().first().point() == cursor
&& (path.segments().first().type() == Segment::Type::LineTo
|| (path.segments().first().type() == Segment::Type::MoveTo && path.segments()[1].type() == Segment::Type::LineTo))) {
if (thickness > 1 && previous_was_line && path.segments().size() >= 2 && path.segments().first()->point() == cursor
&& (path.segments().first()->type() == Segment::Type::LineTo
|| (path.segments().first()->type() == Segment::Type::MoveTo && path.segments()[1]->type() == Segment::Type::LineTo))) {
stroke_segment_intersection(first_line.value().a(), first_line.value().b(), last_line, color, thickness);
}
}

Some files were not shown because too many files have changed in this diff Show more