From 90b1354688e988ba1311a5645f631d353fa7ff80 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 21 Jun 2019 18:37:47 +0200 Subject: [PATCH] AK: Rename RetainPtr => RefPtr and Retained => NonnullRefPtr. --- AK/AKString.h | 8 +-- AK/ByteBuffer.h | 28 ++++---- AK/RetainPtr.h | 64 +++++++++---------- AK/Retained.h | 42 ++++++------ AK/StringImpl.cpp | 10 +-- AK/StringImpl.h | 10 +-- AK/WeakPtr.h | 4 +- AK/Weakable.h | 2 +- Applications/FileManager/DirectoryView.h | 2 +- Applications/FileManager/main.cpp | 4 +- Applications/FontEditor/FontEditor.cpp | 2 +- Applications/FontEditor/FontEditor.h | 4 +- Applications/FontEditor/GlyphEditorWidget.h | 2 +- Applications/FontEditor/GlyphMapWidget.h | 2 +- Applications/FontEditor/main.cpp | 2 +- Applications/IRCClient/IRCAppWindow.h | 12 ++-- Applications/IRCClient/IRCChannel.cpp | 2 +- Applications/IRCClient/IRCChannel.h | 6 +- .../IRCClient/IRCChannelMemberListModel.h | 2 +- Applications/IRCClient/IRCClient.h | 10 +-- Applications/IRCClient/IRCLogBuffer.cpp | 2 +- Applications/IRCClient/IRCLogBuffer.h | 4 +- Applications/IRCClient/IRCLogBufferModel.cpp | 2 +- Applications/IRCClient/IRCLogBufferModel.h | 6 +- Applications/IRCClient/IRCQuery.cpp | 2 +- Applications/IRCClient/IRCQuery.h | 4 +- Applications/IRCClient/IRCWindow.h | 2 +- Applications/IRCClient/IRCWindowListModel.h | 2 +- Applications/PaintBrush/PaintableWidget.h | 2 +- Applications/ProcessManager/ProcessModel.h | 10 +-- Applications/Taskbar/WindowList.h | 2 +- Applications/Terminal/Terminal.cpp | 2 +- Applications/Terminal/Terminal.h | 6 +- Applications/Terminal/main.cpp | 4 +- Demos/Fire/Fire.cpp | 2 +- Demos/PaintTest/main.cpp | 4 +- DevTools/VisualBuilder/VBForm.h | 2 +- DevTools/VisualBuilder/VBWidget.h | 4 +- .../VisualBuilder/VBWidgetPropertyModel.h | 2 +- Games/Minesweeper/Field.h | 16 ++--- Games/Snake/SnakeGame.h | 2 +- Kernel/Devices/DiskPartition.cpp | 4 +- Kernel/Devices/DiskPartition.h | 6 +- Kernel/Devices/FileBackedDiskDevice.cpp | 2 +- Kernel/Devices/FileBackedDiskDevice.h | 2 +- Kernel/Devices/IDEDiskDevice.cpp | 2 +- Kernel/Devices/IDEDiskDevice.h | 4 +- Kernel/Devices/MBRPartitionTable.cpp | 4 +- Kernel/Devices/MBRPartitionTable.h | 6 +- Kernel/File.cpp | 2 +- Kernel/File.h | 2 +- Kernel/FileSystem/Custody.cpp | 4 +- Kernel/FileSystem/Custody.h | 8 +-- Kernel/FileSystem/DevPtsFS.cpp | 4 +- Kernel/FileSystem/DevPtsFS.h | 4 +- Kernel/FileSystem/DiskBackedFileSystem.cpp | 2 +- Kernel/FileSystem/DiskBackedFileSystem.h | 4 +- Kernel/FileSystem/Ext2FileSystem.cpp | 10 +-- Kernel/FileSystem/Ext2FileSystem.h | 12 ++-- Kernel/FileSystem/FIFO.cpp | 6 +- Kernel/FileSystem/FIFO.h | 6 +- Kernel/FileSystem/FileDescription.cpp | 10 +-- Kernel/FileSystem/FileDescription.h | 16 ++--- Kernel/FileSystem/FileSystem.cpp | 2 +- Kernel/FileSystem/FileSystem.h | 6 +- Kernel/FileSystem/Inode.cpp | 2 +- Kernel/FileSystem/Inode.h | 2 +- Kernel/FileSystem/InodeFile.cpp | 2 +- Kernel/FileSystem/InodeFile.h | 6 +- Kernel/FileSystem/ProcFS.cpp | 10 +-- Kernel/FileSystem/ProcFS.h | 14 ++-- Kernel/FileSystem/SyntheticFileSystem.cpp | 18 +++--- Kernel/FileSystem/SyntheticFileSystem.h | 20 +++--- Kernel/FileSystem/VirtualFileSystem.cpp | 36 +++++------ Kernel/FileSystem/VirtualFileSystem.h | 26 ++++---- Kernel/Net/IPv4Socket.cpp | 2 +- Kernel/Net/IPv4Socket.h | 4 +- Kernel/Net/LocalSocket.cpp | 2 +- Kernel/Net/LocalSocket.h | 4 +- Kernel/Net/NetworkTask.cpp | 2 +- Kernel/Net/Socket.cpp | 4 +- Kernel/Net/Socket.h | 10 +-- Kernel/Net/TCPSocket.cpp | 4 +- Kernel/Net/TCPSocket.h | 4 +- Kernel/Net/UDPSocket.cpp | 4 +- Kernel/Net/UDPSocket.h | 4 +- Kernel/Process.cpp | 14 ++-- Kernel/Process.h | 22 +++---- Kernel/ProcessTracer.h | 2 +- Kernel/SharedMemory.cpp | 8 +-- Kernel/SharedMemory.h | 4 +- Kernel/TTY/MasterPTY.h | 2 +- Kernel/TTY/PTYMultiplexer.cpp | 2 +- Kernel/TTY/PTYMultiplexer.h | 2 +- Kernel/TTY/SlavePTY.h | 2 +- Kernel/Thread.h | 6 +- Kernel/VM/MemoryManager.cpp | 14 ++-- Kernel/VM/MemoryManager.h | 14 ++-- Kernel/VM/PageDirectory.h | 8 +-- Kernel/VM/PhysicalPage.cpp | 2 +- Kernel/VM/PhysicalPage.h | 2 +- Kernel/VM/PhysicalRegion.cpp | 4 +- Kernel/VM/PhysicalRegion.h | 4 +- Kernel/VM/Region.cpp | 6 +- Kernel/VM/Region.h | 10 +-- Kernel/VM/VMObject.cpp | 10 +-- Kernel/VM/VMObject.h | 18 +++--- Kernel/init.cpp | 4 +- LibC/SharedBuffer.cpp | 4 +- LibC/SharedBuffer.h | 4 +- LibCore/CConfigFile.cpp | 4 +- LibCore/CConfigFile.h | 4 +- LibCore/CHttpResponse.h | 2 +- LibCore/CNetworkJob.cpp | 2 +- LibCore/CNetworkJob.h | 4 +- LibGUI/GAbstractView.cpp | 2 +- LibGUI/GAbstractView.h | 4 +- LibGUI/GAction.cpp | 4 +- LibGUI/GAction.h | 16 ++--- LibGUI/GButton.cpp | 2 +- LibGUI/GButton.h | 4 +- LibGUI/GDirectoryModel.cpp | 6 +- LibGUI/GDirectoryModel.h | 4 +- LibGUI/GFilePicker.h | 2 +- LibGUI/GFileSystemModel.h | 2 +- LibGUI/GFontDatabase.cpp | 2 +- LibGUI/GFontDatabase.h | 2 +- LibGUI/GIcon.cpp | 6 +- LibGUI/GIcon.h | 14 ++-- LibGUI/GLabel.cpp | 2 +- LibGUI/GLabel.h | 4 +- LibGUI/GMenu.cpp | 2 +- LibGUI/GMenu.h | 2 +- LibGUI/GMenuItem.cpp | 2 +- LibGUI/GMenuItem.h | 4 +- LibGUI/GMessageBox.cpp | 2 +- LibGUI/GMessageBox.h | 2 +- LibGUI/GRadioButton.cpp | 8 +-- LibGUI/GResizeCorner.h | 2 +- LibGUI/GSortingProxyModel.cpp | 2 +- LibGUI/GSortingProxyModel.h | 6 +- LibGUI/GTableView.h | 2 +- LibGUI/GTextEditor.h | 12 ++-- LibGUI/GToolBar.cpp | 2 +- LibGUI/GToolBar.h | 4 +- LibGUI/GTreeView.h | 4 +- LibGUI/GWidget.cpp | 2 +- LibGUI/GWidget.h | 4 +- LibGUI/GWindow.cpp | 2 +- LibGUI/GWindow.h | 6 +- LibHTML/CSS/StyleDeclaration.h | 2 +- LibHTML/DOM/Document.cpp | 2 +- LibHTML/DOM/Document.h | 2 +- LibHTML/DOM/Element.cpp | 2 +- LibHTML/DOM/Element.h | 2 +- LibHTML/DOM/Node.cpp | 4 +- LibHTML/DOM/Node.h | 6 +- LibHTML/DOM/ParentNode.cpp | 2 +- LibHTML/DOM/ParentNode.h | 2 +- LibHTML/DOM/Text.cpp | 2 +- LibHTML/DOM/Text.h | 2 +- LibHTML/Frame.h | 2 +- LibHTML/Layout/LayoutNode.cpp | 2 +- LibHTML/Layout/LayoutNode.h | 2 +- LibHTML/Parser/Parser.cpp | 6 +- LibHTML/Parser/Parser.h | 2 +- Servers/WindowServer/WSButton.cpp | 2 +- Servers/WindowServer/WSButton.h | 4 +- Servers/WindowServer/WSClientConnection.cpp | 2 +- Servers/WindowServer/WSClientConnection.h | 2 +- Servers/WindowServer/WSClipboard.cpp | 2 +- Servers/WindowServer/WSClipboard.h | 4 +- Servers/WindowServer/WSCompositor.cpp | 6 +- Servers/WindowServer/WSCompositor.h | 8 +-- Servers/WindowServer/WSCursor.cpp | 8 +-- Servers/WindowServer/WSCursor.h | 10 +-- Servers/WindowServer/WSWindow.h | 14 ++-- Servers/WindowServer/WSWindowManager.cpp | 4 +- Servers/WindowServer/WSWindowManager.h | 24 +++---- SharedGraphics/CharacterBitmap.cpp | 2 +- SharedGraphics/CharacterBitmap.h | 2 +- SharedGraphics/Font.cpp | 6 +- SharedGraphics/Font.h | 6 +- SharedGraphics/GraphicsBitmap.cpp | 12 ++-- SharedGraphics/GraphicsBitmap.h | 14 ++-- SharedGraphics/PNGLoader.cpp | 8 +-- SharedGraphics/PNGLoader.h | 2 +- SharedGraphics/Painter.h | 2 +- 188 files changed, 562 insertions(+), 562 deletions(-) diff --git a/AK/AKString.h b/AK/AKString.h index 7784c9252f..453a67dd35 100644 --- a/AK/AKString.h +++ b/AK/AKString.h @@ -12,7 +12,7 @@ namespace AK { // String is a convenience wrapper around StringImpl, suitable for passing // around as a value type. It's basically the same as passing around a -// RetainPtr, with a bit of syntactic sugar. +// RefPtr, with a bit of syntactic sugar. // // Note that StringImpl is an immutable object that cannot shrink or grow. // Its allocation size is snugly tailored to the specific string it contains. @@ -74,12 +74,12 @@ public: { } - String(RetainPtr&& impl) + String(RefPtr&& impl) : m_impl(move(impl)) { } - String(Retained&& impl) + String(NonnullRefPtr&& impl) : m_impl(move(impl)) { } @@ -186,7 +186,7 @@ public: private: bool match_helper(const StringView& mask) const; - RetainPtr m_impl; + RefPtr m_impl; }; inline bool StringView::operator==(const String& string) const diff --git a/AK/ByteBuffer.h b/AK/ByteBuffer.h index ffd39b834a..6b2f2d394c 100644 --- a/AK/ByteBuffer.h +++ b/AK/ByteBuffer.h @@ -10,12 +10,12 @@ namespace AK { class ByteBufferImpl : public RefCounted { public: - static Retained create_uninitialized(int size); - static Retained create_zeroed(int); - static Retained copy(const void*, int); - static Retained wrap(void*, int); - static Retained wrap(const void*, int); - static Retained adopt(void*, int); + static NonnullRefPtr create_uninitialized(int size); + static NonnullRefPtr create_zeroed(int); + static NonnullRefPtr copy(const void*, int); + static NonnullRefPtr wrap(void*, int); + static NonnullRefPtr wrap(const void*, int); + static NonnullRefPtr adopt(void*, int); ~ByteBufferImpl() { clear(); } @@ -180,12 +180,12 @@ public: } private: - explicit ByteBuffer(RetainPtr&& impl) + explicit ByteBuffer(RefPtr&& impl) : m_impl(move(impl)) { } - RetainPtr m_impl; + RefPtr m_impl; }; inline ByteBufferImpl::ByteBufferImpl(int size) @@ -227,34 +227,34 @@ inline void ByteBufferImpl::grow(int size) kfree(old_data); } -inline Retained ByteBufferImpl::create_uninitialized(int size) +inline NonnullRefPtr ByteBufferImpl::create_uninitialized(int size) { return ::adopt(*new ByteBufferImpl(size)); } -inline Retained ByteBufferImpl::create_zeroed(int size) +inline NonnullRefPtr ByteBufferImpl::create_zeroed(int size) { auto buffer = ::adopt(*new ByteBufferImpl(size)); memset(buffer->pointer(), 0, size); return buffer; } -inline Retained ByteBufferImpl::copy(const void* data, int size) +inline NonnullRefPtr ByteBufferImpl::copy(const void* data, int size) { return ::adopt(*new ByteBufferImpl(data, size, Copy)); } -inline Retained ByteBufferImpl::wrap(void* data, int size) +inline NonnullRefPtr ByteBufferImpl::wrap(void* data, int size) { return ::adopt(*new ByteBufferImpl(data, size, Wrap)); } -inline Retained ByteBufferImpl::wrap(const void* data, int size) +inline NonnullRefPtr ByteBufferImpl::wrap(const void* data, int size) { return ::adopt(*new ByteBufferImpl(const_cast(data), size, Wrap)); } -inline Retained ByteBufferImpl::adopt(void* data, int size) +inline NonnullRefPtr ByteBufferImpl::adopt(void* data, int size) { return ::adopt(*new ByteBufferImpl(data, size, Adopt)); } diff --git a/AK/RetainPtr.h b/AK/RetainPtr.h index b11870d8fa..f19ffb35a8 100644 --- a/AK/RetainPtr.h +++ b/AK/RetainPtr.h @@ -6,65 +6,65 @@ namespace AK { template -class RetainPtr { +class RefPtr { public: enum AdoptTag { Adopt }; - RetainPtr() {} - RetainPtr(const T* ptr) + RefPtr() {} + RefPtr(const T* ptr) : m_ptr(const_cast(ptr)) { ref_if_not_null(m_ptr); } - RetainPtr(T* ptr) + RefPtr(T* ptr) : m_ptr(ptr) { ref_if_not_null(m_ptr); } - RetainPtr(T& object) + RefPtr(T& object) : m_ptr(&object) { m_ptr->ref(); } - RetainPtr(const T& object) + RefPtr(const T& object) : m_ptr(const_cast(&object)) { m_ptr->ref(); } - RetainPtr(AdoptTag, T& object) + RefPtr(AdoptTag, T& object) : m_ptr(&object) { } - RetainPtr(RetainPtr& other) + RefPtr(RefPtr& other) : m_ptr(other.copy_ref().leak_ref()) { } - RetainPtr(RetainPtr&& other) + RefPtr(RefPtr&& other) : m_ptr(other.leak_ref()) { } template - RetainPtr(Retained&& other) + RefPtr(NonnullRefPtr&& other) : m_ptr(static_cast(&other.leak_ref())) { } template - RetainPtr(RetainPtr&& other) + RefPtr(RefPtr&& other) : m_ptr(static_cast(other.leak_ref())) { } - RetainPtr(const RetainPtr& other) - : m_ptr(const_cast(other).copy_ref().leak_ref()) + RefPtr(const RefPtr& other) + : m_ptr(const_cast(other).copy_ref().leak_ref()) { } template - RetainPtr(const RetainPtr& other) - : m_ptr(const_cast&>(other).copy_ref().leak_ref()) + RefPtr(const RefPtr& other) + : m_ptr(const_cast&>(other).copy_ref().leak_ref()) { } - ~RetainPtr() + ~RefPtr() { clear(); #ifdef SANITIZE_PTRS @@ -74,9 +74,9 @@ public: m_ptr = (T*)(0xe0e0e0e0); #endif } - RetainPtr(std::nullptr_t) {} + RefPtr(std::nullptr_t) {} - RetainPtr& operator=(RetainPtr&& other) + RefPtr& operator=(RefPtr&& other) { if (this != &other) { deref_if_not_null(m_ptr); @@ -86,7 +86,7 @@ public: } template - RetainPtr& operator=(RetainPtr&& other) + RefPtr& operator=(RefPtr&& other) { if (this != static_cast(&other)) { deref_if_not_null(m_ptr); @@ -96,7 +96,7 @@ public: } template - RetainPtr& operator=(Retained&& other) + RefPtr& operator=(NonnullRefPtr&& other) { deref_if_not_null(m_ptr); m_ptr = &other.leak_ref(); @@ -104,7 +104,7 @@ public: } template - RetainPtr& operator=(const Retained& other) + RefPtr& operator=(const NonnullRefPtr& other) { if (m_ptr != other.ptr()) deref_if_not_null(m_ptr); @@ -115,7 +115,7 @@ public: } template - RetainPtr& operator=(const RetainPtr& other) + RefPtr& operator=(const RefPtr& other) { if (m_ptr != other.ptr()) deref_if_not_null(m_ptr); @@ -124,7 +124,7 @@ public: return *this; } - RetainPtr& operator=(const T* ptr) + RefPtr& operator=(const T* ptr) { if (m_ptr != ptr) deref_if_not_null(m_ptr); @@ -133,7 +133,7 @@ public: return *this; } - RetainPtr& operator=(const T& object) + RefPtr& operator=(const T& object) { if (m_ptr != &object) deref_if_not_null(m_ptr); @@ -142,15 +142,15 @@ public: return *this; } - RetainPtr& operator=(std::nullptr_t) + RefPtr& operator=(std::nullptr_t) { clear(); return *this; } - RetainPtr copy_ref() const + RefPtr copy_ref() const { - return RetainPtr(m_ptr); + return RefPtr(m_ptr); } void clear() @@ -185,11 +185,11 @@ public: bool operator==(std::nullptr_t) const { return !m_ptr; } bool operator!=(std::nullptr_t) const { return m_ptr; } - bool operator==(const RetainPtr& other) const { return m_ptr == other.m_ptr; } - bool operator!=(const RetainPtr& other) const { return m_ptr != other.m_ptr; } + bool operator==(const RefPtr& other) const { return m_ptr == other.m_ptr; } + bool operator!=(const RefPtr& other) const { return m_ptr != other.m_ptr; } - bool operator==(RetainPtr& other) { return m_ptr == other.m_ptr; } - bool operator!=(RetainPtr& other) { return m_ptr != other.m_ptr; } + bool operator==(RefPtr& other) { return m_ptr == other.m_ptr; } + bool operator!=(RefPtr& other) { return m_ptr != other.m_ptr; } bool operator==(const T* other) const { return m_ptr == other; } bool operator!=(const T* other) const { return m_ptr != other; } @@ -205,4 +205,4 @@ private: } -using AK::RetainPtr; +using AK::RefPtr; diff --git a/AK/Retained.h b/AK/Retained.h index ba86036a27..ca8f22b1ef 100644 --- a/AK/Retained.h +++ b/AK/Retained.h @@ -32,58 +32,58 @@ inline void deref_if_not_null(T* ptr) } template -class CONSUMABLE(unconsumed) Retained { +class CONSUMABLE(unconsumed) NonnullRefPtr { public: enum AdoptTag { Adopt }; RETURN_TYPESTATE(unconsumed) - Retained(const T& object) + NonnullRefPtr(const T& object) : m_ptr(const_cast(&object)) { m_ptr->ref(); } template RETURN_TYPESTATE(unconsumed) - Retained(const U& object) + NonnullRefPtr(const U& object) : m_ptr(&const_cast(static_cast(object))) { m_ptr->ref(); } RETURN_TYPESTATE(unconsumed) - Retained(AdoptTag, T& object) + NonnullRefPtr(AdoptTag, T& object) : m_ptr(&object) { } RETURN_TYPESTATE(unconsumed) - Retained(Retained& other) + NonnullRefPtr(NonnullRefPtr& other) : m_ptr(&other.copy_ref().leak_ref()) { } RETURN_TYPESTATE(unconsumed) - Retained(Retained&& other) + NonnullRefPtr(NonnullRefPtr&& other) : m_ptr(&other.leak_ref()) { } template RETURN_TYPESTATE(unconsumed) - Retained(Retained&& other) + NonnullRefPtr(NonnullRefPtr&& other) : m_ptr(static_cast(&other.leak_ref())) { } RETURN_TYPESTATE(unconsumed) - Retained(const Retained& other) - : m_ptr(&const_cast(other).copy_ref().leak_ref()) + NonnullRefPtr(const NonnullRefPtr& other) + : m_ptr(&const_cast(other).copy_ref().leak_ref()) { } template RETURN_TYPESTATE(unconsumed) - Retained(const Retained& other) - : m_ptr(&const_cast&>(other).copy_ref().leak_ref()) + NonnullRefPtr(const NonnullRefPtr& other) + : m_ptr(&const_cast&>(other).copy_ref().leak_ref()) { } - ~Retained() + ~NonnullRefPtr() { deref_if_not_null(m_ptr); m_ptr = nullptr; @@ -96,7 +96,7 @@ public: } CALLABLE_WHEN(unconsumed) - Retained& operator=(Retained&& other) + NonnullRefPtr& operator=(NonnullRefPtr&& other) { if (this != &other) { deref_if_not_null(m_ptr); @@ -107,7 +107,7 @@ public: template CALLABLE_WHEN(unconsumed) - Retained& operator=(Retained&& other) + NonnullRefPtr& operator=(NonnullRefPtr&& other) { if (this != static_cast(&other)) { deref_if_not_null(m_ptr); @@ -117,7 +117,7 @@ public: } CALLABLE_WHEN(unconsumed) - Retained& operator=(T& object) + NonnullRefPtr& operator=(T& object) { if (m_ptr != &object) deref_if_not_null(m_ptr); @@ -127,9 +127,9 @@ public: } CALLABLE_WHEN(unconsumed) - Retained copy_ref() const + NonnullRefPtr copy_ref() const { - return Retained(*m_ptr); + return NonnullRefPtr(*m_ptr); } CALLABLE_WHEN(unconsumed) @@ -208,18 +208,18 @@ public: } private: - Retained() {} + NonnullRefPtr() {} T* m_ptr { nullptr }; }; template -inline Retained adopt(T& object) +inline NonnullRefPtr adopt(T& object) { - return Retained(Retained::Adopt, object); + return NonnullRefPtr(NonnullRefPtr::Adopt, object); } } using AK::adopt; -using AK::Retained; +using AK::NonnullRefPtr; diff --git a/AK/StringImpl.cpp b/AK/StringImpl.cpp index cf15329fdb..6ccb481075 100644 --- a/AK/StringImpl.cpp +++ b/AK/StringImpl.cpp @@ -60,7 +60,7 @@ static inline int allocation_size_for_stringimpl(int length) return sizeof(StringImpl) + (sizeof(char) * length) + sizeof(char); } -Retained StringImpl::create_uninitialized(int length, char*& buffer) +NonnullRefPtr StringImpl::create_uninitialized(int length, char*& buffer) { ASSERT(length); void* slot = kmalloc(allocation_size_for_stringimpl(length)); @@ -71,7 +71,7 @@ Retained StringImpl::create_uninitialized(int length, char*& buffer) return new_stringimpl; } -RetainPtr StringImpl::create(const char* cstring, int length, ShouldChomp should_chomp) +RefPtr StringImpl::create(const char* cstring, int length, ShouldChomp should_chomp) { if (!cstring) return nullptr; @@ -99,7 +99,7 @@ RetainPtr StringImpl::create(const char* cstring, int length, Should return new_stringimpl; } -RetainPtr StringImpl::create(const char* cstring, ShouldChomp shouldChomp) +RefPtr StringImpl::create(const char* cstring, ShouldChomp shouldChomp) { if (!cstring) return nullptr; @@ -131,7 +131,7 @@ static inline char to_ascii_uppercase(char c) return c; } -Retained StringImpl::to_lowercase() const +NonnullRefPtr StringImpl::to_lowercase() const { for (int i = 0; i < m_length; ++i) { if (!is_ascii_lowercase(characters()[i])) @@ -147,7 +147,7 @@ slow_path: return lowercased; } -Retained StringImpl::to_uppercase() const +NonnullRefPtr StringImpl::to_uppercase() const { for (int i = 0; i < m_length; ++i) { if (!is_ascii_uppercase(characters()[i])) diff --git a/AK/StringImpl.h b/AK/StringImpl.h index 5eb0a27962..01e70f3135 100644 --- a/AK/StringImpl.h +++ b/AK/StringImpl.h @@ -14,11 +14,11 @@ enum ShouldChomp { class StringImpl : public RefCounted { public: - static Retained create_uninitialized(int length, char*& buffer); - static RetainPtr create(const char* cstring, ShouldChomp = NoChomp); - static RetainPtr create(const char* cstring, int length, ShouldChomp = NoChomp); - Retained to_lowercase() const; - Retained to_uppercase() const; + static NonnullRefPtr create_uninitialized(int length, char*& buffer); + static RefPtr create(const char* cstring, ShouldChomp = NoChomp); + static RefPtr create(const char* cstring, int length, ShouldChomp = NoChomp); + NonnullRefPtr to_lowercase() const; + NonnullRefPtr to_uppercase() const; void operator delete(void* ptr) { diff --git a/AK/WeakPtr.h b/AK/WeakPtr.h index 30d118e178..7715589ea7 100644 --- a/AK/WeakPtr.h +++ b/AK/WeakPtr.h @@ -50,12 +50,12 @@ public: bool operator==(const OwnPtr& other) const { return ptr() == other.ptr(); } private: - WeakPtr(RetainPtr>&& link) + WeakPtr(RefPtr>&& link) : m_link(move(link)) { } - RetainPtr> m_link; + RefPtr> m_link; }; template diff --git a/AK/Weakable.h b/AK/Weakable.h index ba9a428ffb..3985e974a1 100644 --- a/AK/Weakable.h +++ b/AK/Weakable.h @@ -45,7 +45,7 @@ protected: } private: - RetainPtr> m_link; + RefPtr> m_link; }; } diff --git a/Applications/FileManager/DirectoryView.h b/Applications/FileManager/DirectoryView.h index c7e2f08bc5..3c082ff36e 100644 --- a/Applications/FileManager/DirectoryView.h +++ b/Applications/FileManager/DirectoryView.h @@ -44,7 +44,7 @@ private: ViewMode m_view_mode { Invalid }; - Retained m_model; + NonnullRefPtr m_model; int m_path_history_position { 0 }; Vector m_path_history; void add_path_to_history(const StringView& path); diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp index 4f8f1cbc01..4817444b17 100644 --- a/Applications/FileManager/main.cpp +++ b/Applications/FileManager/main.cpp @@ -103,8 +103,8 @@ int main(int argc, char** argv) } }); - RetainPtr view_as_table_action; - RetainPtr view_as_icons_action; + RefPtr view_as_table_action; + RefPtr view_as_icons_action; view_as_table_action = GAction::create("Table view", { Mod_Ctrl, KeyCode::Key_L }, GraphicsBitmap::load_from_file("/res/icons/16x16/table-view.png"), [&](const GAction&) { directory_view->set_view_mode(DirectoryView::ViewMode::List); diff --git a/Applications/FontEditor/FontEditor.cpp b/Applications/FontEditor/FontEditor.cpp index 247e17d276..28dc2e6366 100644 --- a/Applications/FontEditor/FontEditor.cpp +++ b/Applications/FontEditor/FontEditor.cpp @@ -10,7 +10,7 @@ #include #include -FontEditorWidget::FontEditorWidget(const String& path, RetainPtr&& edited_font, GWidget* parent) +FontEditorWidget::FontEditorWidget(const String& path, RefPtr&& edited_font, GWidget* parent) : GWidget(parent) , m_edited_font(move(edited_font)) { diff --git a/Applications/FontEditor/FontEditor.h b/Applications/FontEditor/FontEditor.h index 9132c5029a..e6777c4b46 100644 --- a/Applications/FontEditor/FontEditor.h +++ b/Applications/FontEditor/FontEditor.h @@ -9,11 +9,11 @@ class GTextBox; class FontEditorWidget final : public GWidget { public: - FontEditorWidget(const String& path, RetainPtr&&, GWidget* parent = nullptr); + FontEditorWidget(const String& path, RefPtr&&, GWidget* parent = nullptr); virtual ~FontEditorWidget() override; private: - RetainPtr m_edited_font; + RefPtr m_edited_font; GlyphMapWidget* m_glyph_map_widget { nullptr }; GlyphEditorWidget* m_glyph_editor_widget { nullptr }; diff --git a/Applications/FontEditor/GlyphEditorWidget.h b/Applications/FontEditor/GlyphEditorWidget.h index 3784c054b5..9fd05a322e 100644 --- a/Applications/FontEditor/GlyphEditorWidget.h +++ b/Applications/FontEditor/GlyphEditorWidget.h @@ -24,7 +24,7 @@ private: void draw_at_mouse(const GMouseEvent&); - RetainPtr m_font; + RefPtr m_font; byte m_glyph { 0 }; int m_scale { 10 }; }; diff --git a/Applications/FontEditor/GlyphMapWidget.h b/Applications/FontEditor/GlyphMapWidget.h index e5746aff0b..521c0f7c2f 100644 --- a/Applications/FontEditor/GlyphMapWidget.h +++ b/Applications/FontEditor/GlyphMapWidget.h @@ -30,7 +30,7 @@ private: Rect get_outer_rect(byte glyph) const; - RetainPtr m_font; + RefPtr m_font; int m_rows { 8 }; int m_horizontal_spacing { 2 }; int m_vertical_spacing { 2 }; diff --git a/Applications/FontEditor/main.cpp b/Applications/FontEditor/main.cpp index 9f80a5962f..d2bc0967ce 100644 --- a/Applications/FontEditor/main.cpp +++ b/Applications/FontEditor/main.cpp @@ -7,7 +7,7 @@ int main(int argc, char** argv) { GApplication app(argc, argv); - RetainPtr edited_font; + RefPtr edited_font; String path; if (argc == 2) { diff --git a/Applications/IRCClient/IRCAppWindow.h b/Applications/IRCClient/IRCAppWindow.h index 96e0867a67..1d376f164a 100644 --- a/Applications/IRCClient/IRCAppWindow.h +++ b/Applications/IRCClient/IRCAppWindow.h @@ -24,10 +24,10 @@ private: IRCClient m_client; GStackWidget* m_container { nullptr }; GTableView* m_window_list { nullptr }; - RetainPtr m_join_action; - RetainPtr m_part_action; - RetainPtr m_whois_action; - RetainPtr m_open_query_action; - RetainPtr m_close_query_action; - RetainPtr m_change_nick_action; + RefPtr m_join_action; + RefPtr m_part_action; + RefPtr m_whois_action; + RefPtr m_open_query_action; + RefPtr m_close_query_action; + RefPtr m_change_nick_action; }; diff --git a/Applications/IRCClient/IRCChannel.cpp b/Applications/IRCClient/IRCChannel.cpp index 8e18b558b3..75bf4c7d76 100644 --- a/Applications/IRCClient/IRCChannel.cpp +++ b/Applications/IRCClient/IRCChannel.cpp @@ -18,7 +18,7 @@ IRCChannel::~IRCChannel() { } -Retained IRCChannel::create(IRCClient& client, const String& name) +NonnullRefPtr IRCChannel::create(IRCClient& client, const String& name) { return adopt(*new IRCChannel(client, name)); } diff --git a/Applications/IRCClient/IRCChannel.h b/Applications/IRCClient/IRCChannel.h index fe219c2534..816bd108c5 100644 --- a/Applications/IRCClient/IRCChannel.h +++ b/Applications/IRCClient/IRCChannel.h @@ -13,7 +13,7 @@ class IRCWindow; class IRCChannel : public RefCounted { public: - static Retained create(IRCClient&, const String&); + static NonnullRefPtr create(IRCClient&, const String&); ~IRCChannel(); bool is_open() const { return m_open; } @@ -64,7 +64,7 @@ private: Vector m_members; bool m_open { false }; - Retained m_log; - Retained m_member_model; + NonnullRefPtr m_log; + NonnullRefPtr m_member_model; IRCWindow* m_window { nullptr }; }; diff --git a/Applications/IRCClient/IRCChannelMemberListModel.h b/Applications/IRCClient/IRCChannelMemberListModel.h index df0e762264..deca6347e6 100644 --- a/Applications/IRCClient/IRCChannelMemberListModel.h +++ b/Applications/IRCClient/IRCChannelMemberListModel.h @@ -10,7 +10,7 @@ public: enum Column { Name }; - static Retained create(IRCChannel& channel) { return adopt(*new IRCChannelMemberListModel(channel)); } + static NonnullRefPtr create(IRCChannel& channel) { return adopt(*new IRCChannelMemberListModel(channel)); } virtual ~IRCChannelMemberListModel() override; virtual int row_count(const GModelIndex&) const override; diff --git a/Applications/IRCClient/IRCClient.h b/Applications/IRCClient/IRCClient.h index ac02b9e9fc..d591f4b527 100644 --- a/Applications/IRCClient/IRCClient.h +++ b/Applications/IRCClient/IRCClient.h @@ -120,14 +120,14 @@ private: String m_nickname; OwnPtr m_notifier; - HashMap> m_channels; - HashMap> m_queries; + HashMap> m_channels; + HashMap> m_queries; Vector m_windows; IRCWindow* m_server_subwindow { nullptr }; - Retained m_client_window_list_model; - Retained m_log; - Retained m_config; + NonnullRefPtr m_client_window_list_model; + NonnullRefPtr m_log; + NonnullRefPtr m_config; }; diff --git a/Applications/IRCClient/IRCLogBuffer.cpp b/Applications/IRCClient/IRCLogBuffer.cpp index bfa8736306..fb5934b071 100644 --- a/Applications/IRCClient/IRCLogBuffer.cpp +++ b/Applications/IRCClient/IRCLogBuffer.cpp @@ -3,7 +3,7 @@ #include #include -Retained IRCLogBuffer::create() +NonnullRefPtr IRCLogBuffer::create() { return adopt(*new IRCLogBuffer); } diff --git a/Applications/IRCClient/IRCLogBuffer.h b/Applications/IRCClient/IRCLogBuffer.h index 0720b5b32d..c442afbf98 100644 --- a/Applications/IRCClient/IRCLogBuffer.h +++ b/Applications/IRCClient/IRCLogBuffer.h @@ -10,7 +10,7 @@ class IRCLogBufferModel; class IRCLogBuffer : public RefCounted { public: - static Retained create(); + static NonnullRefPtr create(); ~IRCLogBuffer(); struct Message { @@ -32,6 +32,6 @@ public: private: IRCLogBuffer(); - Retained m_model; + NonnullRefPtr m_model; CircularQueue m_messages; }; diff --git a/Applications/IRCClient/IRCLogBufferModel.cpp b/Applications/IRCClient/IRCLogBufferModel.cpp index 6c3874b476..8805b10918 100644 --- a/Applications/IRCClient/IRCLogBufferModel.cpp +++ b/Applications/IRCClient/IRCLogBufferModel.cpp @@ -4,7 +4,7 @@ #include #include -IRCLogBufferModel::IRCLogBufferModel(Retained&& log_buffer) +IRCLogBufferModel::IRCLogBufferModel(NonnullRefPtr&& log_buffer) : m_log_buffer(move(log_buffer)) { } diff --git a/Applications/IRCClient/IRCLogBufferModel.h b/Applications/IRCClient/IRCLogBufferModel.h index 5be8237d07..d0685f4637 100644 --- a/Applications/IRCClient/IRCLogBufferModel.h +++ b/Applications/IRCClient/IRCLogBufferModel.h @@ -13,7 +13,7 @@ public: __Count, }; - static Retained create(Retained&& log_buffer) { return adopt(*new IRCLogBufferModel(move(log_buffer))); } + static NonnullRefPtr create(NonnullRefPtr&& log_buffer) { return adopt(*new IRCLogBufferModel(move(log_buffer))); } virtual ~IRCLogBufferModel() override; virtual int row_count(const GModelIndex&) const override; @@ -24,7 +24,7 @@ public: virtual void update() override; private: - explicit IRCLogBufferModel(Retained&&); + explicit IRCLogBufferModel(NonnullRefPtr&&); - Retained m_log_buffer; + NonnullRefPtr m_log_buffer; }; diff --git a/Applications/IRCClient/IRCQuery.cpp b/Applications/IRCClient/IRCQuery.cpp index a592c01012..3d6f4d2778 100644 --- a/Applications/IRCClient/IRCQuery.cpp +++ b/Applications/IRCClient/IRCQuery.cpp @@ -16,7 +16,7 @@ IRCQuery::~IRCQuery() { } -Retained IRCQuery::create(IRCClient& client, const String& name) +NonnullRefPtr IRCQuery::create(IRCClient& client, const String& name) { return adopt(*new IRCQuery(client, name)); } diff --git a/Applications/IRCClient/IRCQuery.h b/Applications/IRCClient/IRCQuery.h index e7e52a1a8e..d94ef37007 100644 --- a/Applications/IRCClient/IRCQuery.h +++ b/Applications/IRCClient/IRCQuery.h @@ -12,7 +12,7 @@ class IRCWindow; class IRCQuery : public RefCounted { public: - static Retained create(IRCClient&, const String& name); + static NonnullRefPtr create(IRCClient&, const String& name); ~IRCQuery(); String name() const { return m_name; } @@ -35,5 +35,5 @@ private: String m_name; IRCWindow* m_window { nullptr }; - Retained m_log; + NonnullRefPtr m_log; }; diff --git a/Applications/IRCClient/IRCWindow.h b/Applications/IRCClient/IRCWindow.h index 2fce542fe5..8ea9fca189 100644 --- a/Applications/IRCClient/IRCWindow.h +++ b/Applications/IRCClient/IRCWindow.h @@ -49,6 +49,6 @@ private: String m_name; GTableView* m_table_view { nullptr }; GTextEditor* m_text_editor { nullptr }; - RetainPtr m_log_buffer; + RefPtr m_log_buffer; int m_unread_count { 0 }; }; diff --git a/Applications/IRCClient/IRCWindowListModel.h b/Applications/IRCClient/IRCWindowListModel.h index 47e4621c96..2828722840 100644 --- a/Applications/IRCClient/IRCWindowListModel.h +++ b/Applications/IRCClient/IRCWindowListModel.h @@ -12,7 +12,7 @@ public: Name, }; - static Retained create(IRCClient& client) { return adopt(*new IRCWindowListModel(client)); } + static NonnullRefPtr create(IRCClient& client) { return adopt(*new IRCWindowListModel(client)); } virtual ~IRCWindowListModel() override; virtual int row_count(const GModelIndex&) const override; diff --git a/Applications/PaintBrush/PaintableWidget.h b/Applications/PaintBrush/PaintableWidget.h index bd6cd4455b..81df54c9ec 100644 --- a/Applications/PaintBrush/PaintableWidget.h +++ b/Applications/PaintBrush/PaintableWidget.h @@ -32,7 +32,7 @@ private: virtual void mouseup_event(GMouseEvent&) override; virtual void mousemove_event(GMouseEvent&) override; - RetainPtr m_bitmap; + RefPtr m_bitmap; Color m_primary_color { Color::Black }; Color m_secondary_color { Color::White }; diff --git a/Applications/ProcessManager/ProcessModel.h b/Applications/ProcessManager/ProcessModel.h index cebe524d26..6f74609dc4 100644 --- a/Applications/ProcessManager/ProcessModel.h +++ b/Applications/ProcessManager/ProcessModel.h @@ -25,7 +25,7 @@ public: __Count }; - static Retained create(GraphWidget& graph) { return adopt(*new ProcessModel(graph)); } + static NonnullRefPtr create(GraphWidget& graph) { return adopt(*new ProcessModel(graph)); } virtual ~ProcessModel() override; virtual int row_count(const GModelIndex&) const override; @@ -61,9 +61,9 @@ private: HashMap m_usernames; HashMap> m_processes; Vector m_pids; - RetainPtr m_generic_process_icon; - RetainPtr m_high_priority_icon; - RetainPtr m_low_priority_icon; - RetainPtr m_normal_priority_icon; + RefPtr m_generic_process_icon; + RefPtr m_high_priority_icon; + RefPtr m_low_priority_icon; + RefPtr m_normal_priority_icon; CFile m_proc_all; }; diff --git a/Applications/Taskbar/WindowList.h b/Applications/Taskbar/WindowList.h index 12cefb52ab..406ec52e87 100644 --- a/Applications/Taskbar/WindowList.h +++ b/Applications/Taskbar/WindowList.h @@ -55,7 +55,7 @@ private: Rect m_rect; GButton* m_button { nullptr }; String m_icon_path; - RetainPtr m_icon; + RefPtr m_icon; bool m_active { false }; bool m_minimized { false }; }; diff --git a/Applications/Terminal/Terminal.cpp b/Applications/Terminal/Terminal.cpp index 94720d8f62..3ba514fe73 100644 --- a/Applications/Terminal/Terminal.cpp +++ b/Applications/Terminal/Terminal.cpp @@ -19,7 +19,7 @@ byte Terminal::Attribute::default_foreground_color = 7; byte Terminal::Attribute::default_background_color = 0; -Terminal::Terminal(int ptm_fd, RetainPtr config) +Terminal::Terminal(int ptm_fd, RefPtr config) : m_ptm_fd(ptm_fd) , m_notifier(ptm_fd, CNotifier::Read) , m_config(config) diff --git a/Applications/Terminal/Terminal.h b/Applications/Terminal/Terminal.h index d631416bf6..388570589b 100644 --- a/Applications/Terminal/Terminal.h +++ b/Applications/Terminal/Terminal.h @@ -14,7 +14,7 @@ class Font; class Terminal final : public GFrame { public: - explicit Terminal(int ptm_fd, RetainPtr config); + explicit Terminal(int ptm_fd, RefPtr config); virtual ~Terminal() override; void create_window(); @@ -30,7 +30,7 @@ public: bool should_beep() { return m_should_beep; } void set_should_beep(bool sb) { m_should_beep = sb; }; - RetainPtr config() const { return m_config; } + RefPtr config() const { return m_config; } private: typedef Vector ParamVector; @@ -205,7 +205,7 @@ private: CTimer m_cursor_blink_timer; CTimer m_visual_beep_timer; - RetainPtr m_config; + RefPtr m_config; byte m_last_char { 0 }; }; diff --git a/Applications/Terminal/main.cpp b/Applications/Terminal/main.cpp index e78eb11332..eb94315263 100644 --- a/Applications/Terminal/main.cpp +++ b/Applications/Terminal/main.cpp @@ -81,7 +81,7 @@ static void make_shell(int ptm_fd) } } -GWindow* create_settings_window(Terminal& terminal, RetainPtr config) +GWindow* create_settings_window(Terminal& terminal, RefPtr config) { auto* window = new GWindow; window->set_title("Terminal Settings"); @@ -149,7 +149,7 @@ int main(int argc, char** argv) window->set_double_buffering_enabled(false); window->set_should_exit_event_loop_on_close(true); - RetainPtr config = CConfigFile::get_for_app("Terminal"); + RefPtr config = CConfigFile::get_for_app("Terminal"); Terminal terminal(ptm_fd, config); window->set_has_alpha_channel(true); window->set_main_widget(&terminal); diff --git a/Demos/Fire/Fire.cpp b/Demos/Fire/Fire.cpp index 0407b9ffc3..f04f4c8d4b 100644 --- a/Demos/Fire/Fire.cpp +++ b/Demos/Fire/Fire.cpp @@ -69,7 +69,7 @@ public: void set_stat_label(GLabel* l) { stats = l; }; private: - RetainPtr bitmap; + RefPtr bitmap; GLabel* stats; virtual void paint_event(GPaintEvent&) override; diff --git a/Demos/PaintTest/main.cpp b/Demos/PaintTest/main.cpp index 4a2f9fd860..4914258943 100644 --- a/Demos/PaintTest/main.cpp +++ b/Demos/PaintTest/main.cpp @@ -12,7 +12,7 @@ public: } virtual ~TestWidget() override {} - void set_bitmap(RetainPtr&& bitmap) + void set_bitmap(RefPtr&& bitmap) { m_bitmap = move(bitmap); update(); @@ -31,7 +31,7 @@ private: painter.blit_tiled({ 160, 160, 160, 160 }, *m_bitmap, m_bitmap->rect()); } - RetainPtr m_bitmap; + RefPtr m_bitmap; }; int main(int argc, char** argv) diff --git a/DevTools/VisualBuilder/VBForm.h b/DevTools/VisualBuilder/VBForm.h index 37ced0a651..8e610052a3 100644 --- a/DevTools/VisualBuilder/VBForm.h +++ b/DevTools/VisualBuilder/VBForm.h @@ -52,7 +52,7 @@ private: String m_name; int m_grid_size { 5 }; bool m_should_snap_to_grid { true }; - Vector> m_widgets; + Vector> m_widgets; HashMap m_gwidget_map; HashTable m_selected_widgets; Point m_transform_event_origin; diff --git a/DevTools/VisualBuilder/VBWidget.h b/DevTools/VisualBuilder/VBWidget.h index e71e82efa8..2b6e43dc09 100644 --- a/DevTools/VisualBuilder/VBWidget.h +++ b/DevTools/VisualBuilder/VBWidget.h @@ -44,7 +44,7 @@ class VBWidget : public RefCounted friend class VBWidgetPropertyModel; public: - static Retained create(VBWidgetType type, VBForm& form) { return adopt(*new VBWidget(type, form)); } + static NonnullRefPtr create(VBWidgetType type, VBForm& form) { return adopt(*new VBWidget(type, form)); } ~VBWidget(); bool is_selected() const; @@ -80,6 +80,6 @@ private: VBForm& m_form; GWidget* m_gwidget { nullptr }; Vector> m_properties; - Retained m_property_model; + NonnullRefPtr m_property_model; Rect m_transform_origin_rect; }; diff --git a/DevTools/VisualBuilder/VBWidgetPropertyModel.h b/DevTools/VisualBuilder/VBWidgetPropertyModel.h index b84bffc697..0653e818ae 100644 --- a/DevTools/VisualBuilder/VBWidgetPropertyModel.h +++ b/DevTools/VisualBuilder/VBWidgetPropertyModel.h @@ -13,7 +13,7 @@ public: __Count }; - static Retained create(VBWidget& widget) { return adopt(*new VBWidgetPropertyModel(widget)); } + static NonnullRefPtr create(VBWidget& widget) { return adopt(*new VBWidgetPropertyModel(widget)); } virtual ~VBWidgetPropertyModel() override; virtual int row_count(const GModelIndex&) const override; diff --git a/Games/Minesweeper/Field.h b/Games/Minesweeper/Field.h index 1725ceefda..cd557a2d97 100644 --- a/Games/Minesweeper/Field.h +++ b/Games/Minesweeper/Field.h @@ -83,14 +83,14 @@ private: int m_mine_count { 10 }; int m_unswept_empties { 0 }; Vector> m_squares; - RetainPtr m_mine_bitmap; - RetainPtr m_flag_bitmap; - RetainPtr m_badflag_bitmap; - RetainPtr m_consider_bitmap; - RetainPtr m_default_face_bitmap; - RetainPtr m_good_face_bitmap; - RetainPtr m_bad_face_bitmap; - RetainPtr m_number_bitmap[8]; + RefPtr m_mine_bitmap; + RefPtr m_flag_bitmap; + RefPtr m_badflag_bitmap; + RefPtr m_consider_bitmap; + RefPtr m_default_face_bitmap; + RefPtr m_good_face_bitmap; + RefPtr m_bad_face_bitmap; + RefPtr m_number_bitmap[8]; GButton& m_face_button; GLabel& m_flag_label; GLabel& m_time_label; diff --git a/Games/Snake/SnakeGame.h b/Games/Snake/SnakeGame.h index 704e80c0d3..19cb36e722 100644 --- a/Games/Snake/SnakeGame.h +++ b/Games/Snake/SnakeGame.h @@ -59,5 +59,5 @@ private: unsigned m_high_score { 0 }; String m_high_score_text; - Vector> m_fruit_bitmaps; + Vector> m_fruit_bitmaps; }; diff --git a/Kernel/Devices/DiskPartition.cpp b/Kernel/Devices/DiskPartition.cpp index 34ebf00ea5..7fc60c733d 100644 --- a/Kernel/Devices/DiskPartition.cpp +++ b/Kernel/Devices/DiskPartition.cpp @@ -2,12 +2,12 @@ // #define OFFD_DEBUG -Retained DiskPartition::create(Retained&& device, unsigned block_offset) +NonnullRefPtr DiskPartition::create(NonnullRefPtr&& device, unsigned block_offset) { return adopt(*new DiskPartition(move(device), block_offset)); } -DiskPartition::DiskPartition(Retained&& device, unsigned block_offset) +DiskPartition::DiskPartition(NonnullRefPtr&& device, unsigned block_offset) : m_device(move(device)) , m_block_offset(block_offset) { diff --git a/Kernel/Devices/DiskPartition.h b/Kernel/Devices/DiskPartition.h index c4e1b39ee9..7db12eefc2 100644 --- a/Kernel/Devices/DiskPartition.h +++ b/Kernel/Devices/DiskPartition.h @@ -5,7 +5,7 @@ class DiskPartition final : public DiskDevice { public: - static Retained create(Retained&& device, unsigned block_offset); + static NonnullRefPtr create(NonnullRefPtr&& device, unsigned block_offset); virtual ~DiskPartition(); virtual unsigned block_size() const override; @@ -17,8 +17,8 @@ public: private: virtual const char* class_name() const override; - DiskPartition(Retained&&, unsigned); + DiskPartition(NonnullRefPtr&&, unsigned); - Retained m_device; + NonnullRefPtr m_device; unsigned m_block_offset; }; diff --git a/Kernel/Devices/FileBackedDiskDevice.cpp b/Kernel/Devices/FileBackedDiskDevice.cpp index b56aaff6d6..8b05e6e697 100644 --- a/Kernel/Devices/FileBackedDiskDevice.cpp +++ b/Kernel/Devices/FileBackedDiskDevice.cpp @@ -7,7 +7,7 @@ //#define FBBD_DEBUG #define IGNORE_FILE_LENGTH // Useful for e.g /dev/hda2 -RetainPtr FileBackedDiskDevice::create(String&& image_path, unsigned block_size) +RefPtr FileBackedDiskDevice::create(String&& image_path, unsigned block_size) { return adopt(*new FileBackedDiskDevice(move(image_path), block_size)); } diff --git a/Kernel/Devices/FileBackedDiskDevice.h b/Kernel/Devices/FileBackedDiskDevice.h index 667f3af427..580f3b531d 100644 --- a/Kernel/Devices/FileBackedDiskDevice.h +++ b/Kernel/Devices/FileBackedDiskDevice.h @@ -8,7 +8,7 @@ class FileBackedDiskDevice final : public DiskDevice { public: - static RetainPtr create(String&& image_path, unsigned block_size); + static RefPtr create(String&& image_path, unsigned block_size); virtual ~FileBackedDiskDevice() override; bool is_valid() const { return m_file; } diff --git a/Kernel/Devices/IDEDiskDevice.cpp b/Kernel/Devices/IDEDiskDevice.cpp index 4c50915e61..5778805981 100644 --- a/Kernel/Devices/IDEDiskDevice.cpp +++ b/Kernel/Devices/IDEDiskDevice.cpp @@ -78,7 +78,7 @@ #define ATA_REG_ALTSTATUS 0x0C #define ATA_REG_DEVADDRESS 0x0D -Retained IDEDiskDevice::create() +NonnullRefPtr IDEDiskDevice::create() { return adopt(*new IDEDiskDevice); } diff --git a/Kernel/Devices/IDEDiskDevice.h b/Kernel/Devices/IDEDiskDevice.h index 7f5cfbd99e..da5f491516 100644 --- a/Kernel/Devices/IDEDiskDevice.h +++ b/Kernel/Devices/IDEDiskDevice.h @@ -18,7 +18,7 @@ class IDEDiskDevice final : public IRQHandler , public DiskDevice { AK_MAKE_ETERNAL public: - static Retained create(); + static NonnullRefPtr create(); virtual ~IDEDiskDevice() override; // ^DiskDevice @@ -55,7 +55,7 @@ private: PCI::Address m_pci_address; PhysicalRegionDescriptor m_prdt; - RetainPtr m_dma_buffer_page; + RefPtr m_dma_buffer_page; word m_bus_master_base { 0 }; Lockable m_dma_enabled; }; diff --git a/Kernel/Devices/MBRPartitionTable.cpp b/Kernel/Devices/MBRPartitionTable.cpp index b194855b3e..2d4f733c93 100644 --- a/Kernel/Devices/MBRPartitionTable.cpp +++ b/Kernel/Devices/MBRPartitionTable.cpp @@ -3,7 +3,7 @@ #define MBR_DEBUG -MBRPartitionTable::MBRPartitionTable(Retained&& device) +MBRPartitionTable::MBRPartitionTable(NonnullRefPtr&& device) : m_device(move(device)) { } @@ -37,7 +37,7 @@ bool MBRPartitionTable::initialize() return true; } -RetainPtr MBRPartitionTable::partition(unsigned index) +RefPtr MBRPartitionTable::partition(unsigned index) { ASSERT(index >= 1 && index <= 4); diff --git a/Kernel/Devices/MBRPartitionTable.h b/Kernel/Devices/MBRPartitionTable.h index a3ad937b2c..d5ca9b138f 100644 --- a/Kernel/Devices/MBRPartitionTable.h +++ b/Kernel/Devices/MBRPartitionTable.h @@ -31,14 +31,14 @@ class MBRPartitionTable { AK_MAKE_ETERNAL public: - MBRPartitionTable(Retained&& device); + MBRPartitionTable(NonnullRefPtr&& device); ~MBRPartitionTable(); bool initialize(); - RetainPtr partition(unsigned index); + RefPtr partition(unsigned index); private: - Retained m_device; + NonnullRefPtr m_device; ByteBuffer read_header() const; const MBRPartitionHeader& header() const; diff --git a/Kernel/File.cpp b/Kernel/File.cpp index b366c523b1..693b21ee74 100644 --- a/Kernel/File.cpp +++ b/Kernel/File.cpp @@ -9,7 +9,7 @@ File::~File() { } -KResultOr> File::open(int options) +KResultOr> File::open(int options) { UNUSED_PARAM(options); return FileDescription::create(this); diff --git a/Kernel/File.h b/Kernel/File.h index ec81adbdf4..cc42cb2a44 100644 --- a/Kernel/File.h +++ b/Kernel/File.h @@ -43,7 +43,7 @@ class File : public RefCounted { public: virtual ~File(); - virtual KResultOr> open(int options); + virtual KResultOr> open(int options); virtual void close(); virtual bool can_read(FileDescription&) const = 0; diff --git a/Kernel/FileSystem/Custody.cpp b/Kernel/FileSystem/Custody.cpp index 769d4c0de8..6e64359bfa 100644 --- a/Kernel/FileSystem/Custody.cpp +++ b/Kernel/FileSystem/Custody.cpp @@ -26,9 +26,9 @@ Custody* Custody::get_if_cached(Custody* parent, const String& name) return nullptr; } -Retained Custody::get_or_create(Custody* parent, const String& name, Inode& inode) +NonnullRefPtr Custody::get_or_create(Custody* parent, const String& name, Inode& inode) { - if (RetainPtr cached_custody = get_if_cached(parent, name)) { + if (RefPtr cached_custody = get_if_cached(parent, name)) { if (&cached_custody->inode() != &inode) { dbgprintf("WTF! cached custody for name '%s' has inode=%s, new inode=%s\n", name.characters(), diff --git a/Kernel/FileSystem/Custody.h b/Kernel/FileSystem/Custody.h index 03c6fabdff..cc2ca004f1 100644 --- a/Kernel/FileSystem/Custody.h +++ b/Kernel/FileSystem/Custody.h @@ -13,8 +13,8 @@ class VFS; class Custody : public RefCounted { public: static Custody* get_if_cached(Custody* parent, const String& name); - static Retained get_or_create(Custody* parent, const String& name, Inode&); - static Retained create(Custody* parent, const String& name, Inode& inode) + static NonnullRefPtr get_or_create(Custody* parent, const String& name, Inode&); + static NonnullRefPtr create(Custody* parent, const String& name, Inode& inode) { return adopt(*new Custody(parent, name, inode)); } @@ -38,9 +38,9 @@ public: private: Custody(Custody* parent, const String& name, Inode&); - RetainPtr m_parent; + RefPtr m_parent; String m_name; - Retained m_inode; + NonnullRefPtr m_inode; bool m_deleted { false }; bool m_mounted_on { false }; }; diff --git a/Kernel/FileSystem/DevPtsFS.cpp b/Kernel/FileSystem/DevPtsFS.cpp index be3a0d6968..d376192511 100644 --- a/Kernel/FileSystem/DevPtsFS.cpp +++ b/Kernel/FileSystem/DevPtsFS.cpp @@ -11,7 +11,7 @@ DevPtsFS& DevPtsFS::the() return *s_the; } -Retained DevPtsFS::create() +NonnullRefPtr DevPtsFS::create() { return adopt(*new DevPtsFS); } @@ -36,7 +36,7 @@ const char* DevPtsFS::class_name() const return "DevPtsFS"; } -Retained DevPtsFS::create_slave_pty_device_file(unsigned index) +NonnullRefPtr DevPtsFS::create_slave_pty_device_file(unsigned index) { auto file = adopt(*new SynthFSInode(*this, generate_inode_index())); diff --git a/Kernel/FileSystem/DevPtsFS.h b/Kernel/FileSystem/DevPtsFS.h index fc638bd580..b285814cf5 100644 --- a/Kernel/FileSystem/DevPtsFS.h +++ b/Kernel/FileSystem/DevPtsFS.h @@ -11,7 +11,7 @@ public: [[gnu::pure]] static DevPtsFS& the(); virtual ~DevPtsFS() override; - static Retained create(); + static NonnullRefPtr create(); virtual bool initialize() override; virtual const char* class_name() const override; @@ -22,7 +22,7 @@ public: private: DevPtsFS(); - Retained create_slave_pty_device_file(unsigned index); + NonnullRefPtr create_slave_pty_device_file(unsigned index); HashTable m_slave_ptys; }; diff --git a/Kernel/FileSystem/DiskBackedFileSystem.cpp b/Kernel/FileSystem/DiskBackedFileSystem.cpp index 413e4931ed..afb4a8cc5f 100644 --- a/Kernel/FileSystem/DiskBackedFileSystem.cpp +++ b/Kernel/FileSystem/DiskBackedFileSystem.cpp @@ -45,7 +45,7 @@ Lockable>& block_cache() return *s_cache; } -DiskBackedFS::DiskBackedFS(Retained&& device) +DiskBackedFS::DiskBackedFS(NonnullRefPtr&& device) : m_device(move(device)) { } diff --git a/Kernel/FileSystem/DiskBackedFileSystem.h b/Kernel/FileSystem/DiskBackedFileSystem.h index b115eb6d12..8f75435e71 100644 --- a/Kernel/FileSystem/DiskBackedFileSystem.h +++ b/Kernel/FileSystem/DiskBackedFileSystem.h @@ -15,7 +15,7 @@ public: virtual void flush_writes() override; protected: - explicit DiskBackedFS(Retained&&); + explicit DiskBackedFS(NonnullRefPtr&&); void set_block_size(unsigned); @@ -27,7 +27,7 @@ protected: private: int m_block_size { 0 }; - Retained m_device; + NonnullRefPtr m_device; HashMap m_write_cache; }; diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index c9ea7b06bc..ce7cefcc48 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -31,12 +31,12 @@ static byte to_ext2_file_type(mode_t mode) return EXT2_FT_UNKNOWN; } -Retained Ext2FS::create(Retained&& device) +NonnullRefPtr Ext2FS::create(NonnullRefPtr&& device) { return adopt(*new Ext2FS(move(device))); } -Ext2FS::Ext2FS(Retained&& device) +Ext2FS::Ext2FS(NonnullRefPtr&& device) : DiskBackedFS(move(device)) { } @@ -448,7 +448,7 @@ void Ext2FSInode::flush_metadata() set_metadata_dirty(false); } -RetainPtr Ext2FS::get_inode(InodeIdentifier inode) const +RefPtr Ext2FS::get_inode(InodeIdentifier inode) const { LOCKER(m_lock); ASSERT(inode.fsid() == fsid()); @@ -1085,7 +1085,7 @@ bool Ext2FS::set_block_allocation_state(BlockIndex block_index, bool new_state) return true; } -RetainPtr Ext2FS::create_directory(InodeIdentifier parent_id, const String& name, mode_t mode, int& error) +RefPtr Ext2FS::create_directory(InodeIdentifier parent_id, const String& name, mode_t mode, int& error) { LOCKER(m_lock); ASSERT(parent_id.fsid() == fsid()); @@ -1125,7 +1125,7 @@ RetainPtr Ext2FS::create_directory(InodeIdentifier parent_id, const Strin return inode; } -RetainPtr Ext2FS::create_inode(InodeIdentifier parent_id, const String& name, mode_t mode, off_t size, dev_t dev, int& error) +RefPtr Ext2FS::create_inode(InodeIdentifier parent_id, const String& name, mode_t mode, off_t size, dev_t dev, int& error) { LOCKER(m_lock); ASSERT(parent_id.fsid() == fsid()); diff --git a/Kernel/FileSystem/Ext2FileSystem.h b/Kernel/FileSystem/Ext2FileSystem.h index 7ef3d10240..64349ee1a2 100644 --- a/Kernel/FileSystem/Ext2FileSystem.h +++ b/Kernel/FileSystem/Ext2FileSystem.h @@ -60,7 +60,7 @@ class Ext2FS final : public DiskBackedFS { friend class Ext2FSInode; public: - static Retained create(Retained&&); + static NonnullRefPtr create(NonnullRefPtr&&); virtual ~Ext2FS() override; virtual bool initialize() override; @@ -73,7 +73,7 @@ private: typedef unsigned BlockIndex; typedef unsigned GroupIndex; typedef unsigned InodeIndex; - explicit Ext2FS(Retained&&); + explicit Ext2FS(NonnullRefPtr&&); const ext2_super_block& super_block() const; const ext2_group_desc& group_descriptor(unsigned groupIndex) const; @@ -92,9 +92,9 @@ private: virtual const char* class_name() const override; virtual InodeIdentifier root_inode() const override; - virtual RetainPtr create_inode(InodeIdentifier parentInode, const String& name, mode_t, off_t size, dev_t, int& error) override; - virtual RetainPtr create_directory(InodeIdentifier parentInode, const String& name, mode_t, int& error) override; - virtual RetainPtr get_inode(InodeIdentifier) const override; + virtual RefPtr create_inode(InodeIdentifier parentInode, const String& name, mode_t, off_t size, dev_t, int& error) override; + virtual RefPtr create_directory(InodeIdentifier parentInode, const String& name, mode_t, int& error) override; + virtual RefPtr get_inode(InodeIdentifier) const override; InodeIndex allocate_inode(GroupIndex preferred_group, off_t expected_size); Vector allocate_blocks(GroupIndex, int count); @@ -126,7 +126,7 @@ private: mutable ByteBuffer m_cached_super_block; mutable ByteBuffer m_cached_group_descriptor_table; - mutable HashMap> m_inode_cache; + mutable HashMap> m_inode_cache; }; inline Ext2FS& Ext2FSInode::fs() diff --git a/Kernel/FileSystem/FIFO.cpp b/Kernel/FileSystem/FIFO.cpp index 6e1f081848..c2d0184377 100644 --- a/Kernel/FileSystem/FIFO.cpp +++ b/Kernel/FileSystem/FIFO.cpp @@ -16,7 +16,7 @@ Lockable>& all_fifos() return *s_table; } -RetainPtr FIFO::from_fifo_id(dword id) +RefPtr FIFO::from_fifo_id(dword id) { auto* ptr = reinterpret_cast(id); LOCKER(all_fifos().lock()); @@ -25,12 +25,12 @@ RetainPtr FIFO::from_fifo_id(dword id) return ptr; } -Retained FIFO::create(uid_t uid) +NonnullRefPtr FIFO::create(uid_t uid) { return adopt(*new FIFO(uid)); } -Retained FIFO::open_direction(FIFO::Direction direction) +NonnullRefPtr FIFO::open_direction(FIFO::Direction direction) { auto description = FileDescription::create(this); attach(direction); diff --git a/Kernel/FileSystem/FIFO.h b/Kernel/FileSystem/FIFO.h index baad9bd8a1..73a3915ba0 100644 --- a/Kernel/FileSystem/FIFO.h +++ b/Kernel/FileSystem/FIFO.h @@ -14,14 +14,14 @@ public: Writer }; - static RetainPtr from_fifo_id(dword); + static RefPtr from_fifo_id(dword); - static Retained create(uid_t); + static NonnullRefPtr create(uid_t); virtual ~FIFO() override; uid_t uid() const { return m_uid; } - Retained open_direction(Direction); + NonnullRefPtr open_direction(Direction); void attach(Direction); void detach(Direction); diff --git a/Kernel/FileSystem/FileDescription.cpp b/Kernel/FileSystem/FileDescription.cpp index a75ec14259..d6c75a8fb6 100644 --- a/Kernel/FileSystem/FileDescription.cpp +++ b/Kernel/FileSystem/FileDescription.cpp @@ -15,19 +15,19 @@ #include #include -Retained FileDescription::create(RetainPtr&& custody) +NonnullRefPtr FileDescription::create(RefPtr&& custody) { auto description = adopt(*new FileDescription(InodeFile::create(custody->inode()))); description->m_custody = move(custody); return description; } -Retained FileDescription::create(RetainPtr&& file, SocketRole role) +NonnullRefPtr FileDescription::create(RefPtr&& file, SocketRole role) { return adopt(*new FileDescription(move(file), role)); } -FileDescription::FileDescription(RetainPtr&& file, SocketRole role) +FileDescription::FileDescription(RefPtr&& file, SocketRole role) : m_file(move(file)) { if (m_file->is_inode()) @@ -58,9 +58,9 @@ void FileDescription::set_socket_role(SocketRole role) socket()->attach(*this); } -Retained FileDescription::clone() +NonnullRefPtr FileDescription::clone() { - RetainPtr description; + RefPtr description; if (is_fifo()) { description = fifo()->open_direction(m_fifo_direction); } else { diff --git a/Kernel/FileSystem/FileDescription.h b/Kernel/FileSystem/FileDescription.h index 2cffc5169a..b856eff045 100644 --- a/Kernel/FileSystem/FileDescription.h +++ b/Kernel/FileSystem/FileDescription.h @@ -21,11 +21,11 @@ class SharedMemory; class FileDescription : public RefCounted { public: - static Retained create(RetainPtr&&); - static Retained create(RetainPtr&&, SocketRole = SocketRole::None); + static NonnullRefPtr create(RefPtr&&); + static NonnullRefPtr create(RefPtr&&, SocketRole = SocketRole::None); ~FileDescription(); - Retained clone(); + NonnullRefPtr clone(); int close(); @@ -92,7 +92,7 @@ public: ByteBuffer& generator_cache() { return m_generator_cache; } - void set_original_inode(Badge, Retained&& inode) { m_inode = move(inode); } + void set_original_inode(Badge, NonnullRefPtr&& inode) { m_inode = move(inode); } SocketRole socket_role() const { return m_socket_role; } void set_socket_role(SocketRole); @@ -105,12 +105,12 @@ public: private: friend class VFS; - FileDescription(RetainPtr&&, SocketRole = SocketRole::None); + FileDescription(RefPtr&&, SocketRole = SocketRole::None); FileDescription(FIFO&, FIFO::Direction); - RetainPtr m_custody; - RetainPtr m_inode; - RetainPtr m_file; + RefPtr m_custody; + RefPtr m_inode; + RefPtr m_file; off_t m_current_offset { 0 }; diff --git a/Kernel/FileSystem/FileSystem.cpp b/Kernel/FileSystem/FileSystem.cpp index 95a4f47093..885087fbef 100644 --- a/Kernel/FileSystem/FileSystem.cpp +++ b/Kernel/FileSystem/FileSystem.cpp @@ -58,7 +58,7 @@ void FS::sync() { Inode::sync(); - Vector, 32> fses; + Vector, 32> fses; { InterruptDisabler disabler; for (auto& it : all_fses()) diff --git a/Kernel/FileSystem/FileSystem.h b/Kernel/FileSystem/FileSystem.h index 3e9fcc6314..c9ad4b5dcb 100644 --- a/Kernel/FileSystem/FileSystem.h +++ b/Kernel/FileSystem/FileSystem.h @@ -54,10 +54,10 @@ public: byte file_type { 0 }; }; - virtual RetainPtr create_inode(InodeIdentifier parentInode, const String& name, mode_t, off_t size, dev_t, int& error) = 0; - virtual RetainPtr create_directory(InodeIdentifier parentInode, const String& name, mode_t, int& error) = 0; + virtual RefPtr create_inode(InodeIdentifier parentInode, const String& name, mode_t, off_t size, dev_t, int& error) = 0; + virtual RefPtr create_directory(InodeIdentifier parentInode, const String& name, mode_t, int& error) = 0; - virtual RetainPtr get_inode(InodeIdentifier) const = 0; + virtual RefPtr get_inode(InodeIdentifier) const = 0; virtual void flush_writes() {} diff --git a/Kernel/FileSystem/Inode.cpp b/Kernel/FileSystem/Inode.cpp index ef4fbe8207..57cd4af8e1 100644 --- a/Kernel/FileSystem/Inode.cpp +++ b/Kernel/FileSystem/Inode.cpp @@ -13,7 +13,7 @@ HashTable& all_inodes() void Inode::sync() { - Vector, 32> inodes; + Vector, 32> inodes; { InterruptDisabler disabler; for (auto* inode : all_inodes()) { diff --git a/Kernel/FileSystem/Inode.h b/Kernel/FileSystem/Inode.h index c7d3baf274..f3b769710f 100644 --- a/Kernel/FileSystem/Inode.h +++ b/Kernel/FileSystem/Inode.h @@ -85,6 +85,6 @@ private: FS& m_fs; unsigned m_index { 0 }; WeakPtr m_vmo; - RetainPtr m_socket; + RefPtr m_socket; bool m_metadata_dirty { false }; }; diff --git a/Kernel/FileSystem/InodeFile.cpp b/Kernel/FileSystem/InodeFile.cpp index 5dee202e68..7617636486 100644 --- a/Kernel/FileSystem/InodeFile.cpp +++ b/Kernel/FileSystem/InodeFile.cpp @@ -4,7 +4,7 @@ #include #include -InodeFile::InodeFile(Retained&& inode) +InodeFile::InodeFile(NonnullRefPtr&& inode) : m_inode(move(inode)) { } diff --git a/Kernel/FileSystem/InodeFile.h b/Kernel/FileSystem/InodeFile.h index 73f1f2444f..f4bbe7b48d 100644 --- a/Kernel/FileSystem/InodeFile.h +++ b/Kernel/FileSystem/InodeFile.h @@ -6,7 +6,7 @@ class Inode; class InodeFile final : public File { public: - static Retained create(Retained&& inode) + static NonnullRefPtr create(NonnullRefPtr&& inode) { return adopt(*new InodeFile(move(inode))); } @@ -33,6 +33,6 @@ public: virtual bool is_inode() const override { return true; } private: - explicit InodeFile(Retained&&); - Retained m_inode; + explicit InodeFile(NonnullRefPtr&&); + NonnullRefPtr m_inode; }; diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index 95ad22096b..06f6cb3f1d 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -174,7 +174,7 @@ ProcFS& ProcFS::the() return *s_the; } -Retained ProcFS::create() +NonnullRefPtr ProcFS::create() { return adopt(*new ProcFS); } @@ -614,7 +614,7 @@ ByteBuffer procfs$inodes(InodeIdentifier) extern HashTable& all_inodes(); StringBuilder builder; for (auto it : all_inodes()) { - RetainPtr inode = *it; + RefPtr inode = *it; builder.appendf("Inode{K%x} %02u:%08u (%u)\n", inode.ptr(), inode->fsid(), inode->index(), inode->ref_count()); } return builder.to_byte_buffer(); @@ -747,13 +747,13 @@ const char* ProcFS::class_name() const return "ProcFS"; } -RetainPtr ProcFS::create_inode(InodeIdentifier, const String&, mode_t, off_t, dev_t, int&) +RefPtr ProcFS::create_inode(InodeIdentifier, const String&, mode_t, off_t, dev_t, int&) { kprintf("FIXME: Implement ProcFS::create_inode()?\n"); return {}; } -RetainPtr ProcFS::create_directory(InodeIdentifier, const String&, mode_t, int& error) +RefPtr ProcFS::create_directory(InodeIdentifier, const String&, mode_t, int& error) { error = -EROFS; return nullptr; @@ -764,7 +764,7 @@ InodeIdentifier ProcFS::root_inode() const return { fsid(), FI_Root }; } -RetainPtr ProcFS::get_inode(InodeIdentifier inode_id) const +RefPtr ProcFS::get_inode(InodeIdentifier inode_id) const { #ifdef PROCFS_DEBUG dbgprintf("ProcFS::get_inode(%u)\n", inode_id.index()); diff --git a/Kernel/FileSystem/ProcFS.h b/Kernel/FileSystem/ProcFS.h index 5b3e82969c..2976253556 100644 --- a/Kernel/FileSystem/ProcFS.h +++ b/Kernel/FileSystem/ProcFS.h @@ -16,16 +16,16 @@ public: [[gnu::pure]] static ProcFS& the(); virtual ~ProcFS() override; - static Retained create(); + static NonnullRefPtr create(); virtual bool initialize() override; virtual const char* class_name() const override; virtual InodeIdentifier root_inode() const override; - virtual RetainPtr get_inode(InodeIdentifier) const override; + virtual RefPtr get_inode(InodeIdentifier) const override; - virtual RetainPtr create_inode(InodeIdentifier parent_id, const String& name, mode_t, off_t size, dev_t, int& error) override; - virtual RetainPtr create_directory(InodeIdentifier parent_id, const String& name, mode_t, int& error) override; + virtual RefPtr create_inode(InodeIdentifier parent_id, const String& name, mode_t, off_t size, dev_t, int& error) override; + virtual RefPtr create_directory(InodeIdentifier parent_id, const String& name, mode_t, int& error) override; void add_sys_file(String&&, Function&& read_callback, Function&& write_callback); void add_sys_bool(String&&, Lockable&, Function&& notify_callback = nullptr); @@ -36,7 +36,7 @@ private: struct ProcFSDirectoryEntry { ProcFSDirectoryEntry() {} - ProcFSDirectoryEntry(const char* a_name, unsigned a_proc_file_type, Function&& a_read_callback = nullptr, Function&& a_write_callback = nullptr, RetainPtr&& a_inode = nullptr) + ProcFSDirectoryEntry(const char* a_name, unsigned a_proc_file_type, Function&& a_read_callback = nullptr, Function&& a_write_callback = nullptr, RefPtr&& a_inode = nullptr) : name(a_name) , proc_file_type(a_proc_file_type) , read_callback(move(a_read_callback)) @@ -49,7 +49,7 @@ private: unsigned proc_file_type { 0 }; Function read_callback; Function write_callback; - RetainPtr inode; + RefPtr inode; InodeIdentifier identifier(unsigned fsid) const; }; @@ -60,7 +60,7 @@ private: mutable Lock m_inodes_lock; mutable HashMap m_inodes; - RetainPtr m_root_inode; + RefPtr m_root_inode; Lockable m_kmalloc_stack_helper; }; diff --git a/Kernel/FileSystem/SyntheticFileSystem.cpp b/Kernel/FileSystem/SyntheticFileSystem.cpp index 62ea9c55fd..d884fd0e3d 100644 --- a/Kernel/FileSystem/SyntheticFileSystem.cpp +++ b/Kernel/FileSystem/SyntheticFileSystem.cpp @@ -5,7 +5,7 @@ //#define SYNTHFS_DEBUG -Retained SynthFS::create() +NonnullRefPtr SynthFS::create() { return adopt(*new SynthFS); } @@ -33,7 +33,7 @@ bool SynthFS::initialize() return true; } -Retained SynthFS::create_directory(String&& name) +NonnullRefPtr SynthFS::create_directory(String&& name) { auto file = adopt(*new SynthFSInode(*this, generate_inode_index())); file->m_name = move(name); @@ -45,7 +45,7 @@ Retained SynthFS::create_directory(String&& name) return file; } -Retained SynthFS::create_text_file(String&& name, ByteBuffer&& contents, mode_t mode) +NonnullRefPtr SynthFS::create_text_file(String&& name, ByteBuffer&& contents, mode_t mode) { auto file = adopt(*new SynthFSInode(*this, generate_inode_index())); file->m_data = contents; @@ -58,7 +58,7 @@ Retained SynthFS::create_text_file(String&& name, ByteBuffer&& con return file; } -Retained SynthFS::create_generated_file(String&& name, Function&& generator, mode_t mode) +NonnullRefPtr SynthFS::create_generated_file(String&& name, Function&& generator, mode_t mode) { auto file = adopt(*new SynthFSInode(*this, generate_inode_index())); file->m_generator = move(generator); @@ -71,7 +71,7 @@ Retained SynthFS::create_generated_file(String&& name, Function SynthFS::create_generated_file(String&& name, Function&& read_callback, Function&& write_callback, mode_t mode) +NonnullRefPtr SynthFS::create_generated_file(String&& name, Function&& read_callback, Function&& write_callback, mode_t mode) { auto file = adopt(*new SynthFSInode(*this, generate_inode_index())); file->m_generator = move(read_callback); @@ -85,7 +85,7 @@ Retained SynthFS::create_generated_file(String&& name, Function&& file, InodeIndex parent) +InodeIdentifier SynthFS::add_file(RefPtr&& file, InodeIndex parent) { LOCKER(m_lock); ASSERT(file); @@ -138,7 +138,7 @@ InodeIdentifier SynthFS::root_inode() const return { fsid(), 1 }; } -RetainPtr SynthFS::create_inode(InodeIdentifier parentInode, const String& name, mode_t mode, off_t size, dev_t, int& error) +RefPtr SynthFS::create_inode(InodeIdentifier parentInode, const String& name, mode_t mode, off_t size, dev_t, int& error) { (void)parentInode; (void)name; @@ -149,7 +149,7 @@ RetainPtr SynthFS::create_inode(InodeIdentifier parentInode, const String return {}; } -RetainPtr SynthFS::create_directory(InodeIdentifier, const String&, mode_t, int& error) +RefPtr SynthFS::create_directory(InodeIdentifier, const String&, mode_t, int& error) { error = -EROFS; return nullptr; @@ -161,7 +161,7 @@ auto SynthFS::generate_inode_index() -> InodeIndex return m_next_inode_index++; } -RetainPtr SynthFS::get_inode(InodeIdentifier inode) const +RefPtr SynthFS::get_inode(InodeIdentifier inode) const { LOCKER(m_lock); auto it = m_inodes.find(inode.index()); diff --git a/Kernel/FileSystem/SyntheticFileSystem.h b/Kernel/FileSystem/SyntheticFileSystem.h index 5a46f85a87..15e5dc9a21 100644 --- a/Kernel/FileSystem/SyntheticFileSystem.h +++ b/Kernel/FileSystem/SyntheticFileSystem.h @@ -10,14 +10,14 @@ class SynthFSInode; class SynthFS : public FS { public: virtual ~SynthFS() override; - static Retained create(); + static NonnullRefPtr create(); virtual bool initialize() override; virtual const char* class_name() const override; virtual InodeIdentifier root_inode() const override; - virtual RetainPtr create_inode(InodeIdentifier parentInode, const String& name, mode_t, off_t size, dev_t, int& error) override; - virtual RetainPtr create_directory(InodeIdentifier parentInode, const String& name, mode_t, int& error) override; - virtual RetainPtr get_inode(InodeIdentifier) const override; + virtual RefPtr create_inode(InodeIdentifier parentInode, const String& name, mode_t, off_t size, dev_t, int& error) override; + virtual RefPtr create_directory(InodeIdentifier parentInode, const String& name, mode_t, int& error) override; + virtual RefPtr get_inode(InodeIdentifier) const override; protected: typedef unsigned InodeIndex; @@ -27,17 +27,17 @@ protected: SynthFS(); - Retained create_directory(String&& name); - Retained create_text_file(String&& name, ByteBuffer&&, mode_t = 0010644); - Retained create_generated_file(String&& name, Function&&, mode_t = 0100644); - Retained create_generated_file(String&& name, Function&&, Function&&, mode_t = 0100644); + NonnullRefPtr create_directory(String&& name); + NonnullRefPtr create_text_file(String&& name, ByteBuffer&&, mode_t = 0010644); + NonnullRefPtr create_generated_file(String&& name, Function&&, mode_t = 0100644); + NonnullRefPtr create_generated_file(String&& name, Function&&, Function&&, mode_t = 0100644); - InodeIdentifier add_file(RetainPtr&&, InodeIndex parent = RootInodeIndex); + InodeIdentifier add_file(RefPtr&&, InodeIndex parent = RootInodeIndex); bool remove_file(InodeIndex); private: InodeIndex m_next_inode_index { 2 }; - HashMap> m_inodes; + HashMap> m_inodes; }; struct SynthFSInodeCustomData { diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp index 296821094e..9d0b126813 100644 --- a/Kernel/FileSystem/VirtualFileSystem.cpp +++ b/Kernel/FileSystem/VirtualFileSystem.cpp @@ -36,7 +36,7 @@ InodeIdentifier VFS::root_inode_id() const return m_root_inode->identifier(); } -bool VFS::mount(Retained&& file_system, StringView path) +bool VFS::mount(NonnullRefPtr&& file_system, StringView path) { auto result = resolve_path(path, root_custody()); if (result.is_error()) { @@ -53,7 +53,7 @@ bool VFS::mount(Retained&& file_system, StringView path) return true; } -bool VFS::mount_root(Retained&& file_system) +bool VFS::mount_root(NonnullRefPtr&& file_system) { if (m_root_inode) { kprintf("VFS: mount_root can't mount another root\n"); @@ -149,9 +149,9 @@ KResult VFS::stat(StringView path, int options, Custody& base, struct stat& stat return custody_or_error.value()->inode().metadata().stat(statbuf); } -KResultOr> VFS::open(StringView path, int options, mode_t mode, Custody& base) +KResultOr> VFS::open(StringView path, int options, mode_t mode, Custody& base) { - RetainPtr parent_custody; + RefPtr parent_custody; auto custody_or_error = resolve_path(path, base, &parent_custody, options); if (options & O_CREAT) { if (!parent_custody) @@ -208,7 +208,7 @@ KResult VFS::mknod(StringView path, mode_t mode, dev_t dev, Custody& base) if (!is_regular_file(mode) && !is_block_device(mode) && !is_character_device(mode) && !is_fifo(mode) && !is_socket(mode)) return KResult(-EINVAL); - RetainPtr parent_custody; + RefPtr parent_custody; auto existing_file_or_error = resolve_path(path, base, &parent_custody); if (!existing_file_or_error.is_error()) return KResult(-EEXIST); @@ -230,7 +230,7 @@ KResult VFS::mknod(StringView path, mode_t mode, dev_t dev, Custody& base) return KSuccess; } -KResultOr> VFS::create(StringView path, int options, mode_t mode, Custody& parent_custody) +KResultOr> VFS::create(StringView path, int options, mode_t mode, Custody& parent_custody) { (void)options; @@ -255,7 +255,7 @@ KResultOr> VFS::create(StringView path, int options, m KResult VFS::mkdir(StringView path, mode_t mode, Custody& base) { - RetainPtr parent_custody; + RefPtr parent_custody; auto result = resolve_path(path, base, &parent_custody); if (!result.is_error()) return KResult(-EEXIST); @@ -300,7 +300,7 @@ KResult VFS::access(StringView path, int mode, Custody& base) return KSuccess; } -KResultOr> VFS::open_directory(StringView path, Custody& base) +KResultOr> VFS::open_directory(StringView path, Custody& base) { auto inode_or_error = resolve_path(path, base); if (inode_or_error.is_error()) @@ -339,14 +339,14 @@ KResult VFS::chmod(StringView path, mode_t mode, Custody& base) KResult VFS::rename(StringView old_path, StringView new_path, Custody& base) { - RetainPtr old_parent_custody; + RefPtr old_parent_custody; auto old_custody_or_error = resolve_path(old_path, base, &old_parent_custody); if (old_custody_or_error.is_error()) return old_custody_or_error.error(); auto& old_custody = *old_custody_or_error.value(); auto& old_inode = old_custody.inode(); - RetainPtr new_parent_custody; + RefPtr new_parent_custody; auto new_custody_or_error = resolve_path(new_path, base, &new_parent_custody); if (new_custody_or_error.is_error()) { if (new_custody_or_error.error() != -ENOENT) @@ -445,7 +445,7 @@ KResult VFS::link(StringView old_path, StringView new_path, Custody& base) auto& old_custody = *old_custody_or_error.value(); auto& old_inode = old_custody.inode(); - RetainPtr parent_custody; + RefPtr parent_custody; auto new_custody_or_error = resolve_path(new_path, base, &parent_custody); if (!new_custody_or_error.is_error()) return KResult(-EEXIST); @@ -469,7 +469,7 @@ KResult VFS::link(StringView old_path, StringView new_path, Custody& base) KResult VFS::unlink(StringView path, Custody& base) { - RetainPtr parent_custody; + RefPtr parent_custody; auto custody_or_error = resolve_path(path, base, &parent_custody); if (custody_or_error.is_error()) return custody_or_error.error(); @@ -498,7 +498,7 @@ KResult VFS::unlink(StringView path, Custody& base) KResult VFS::symlink(StringView target, StringView linkpath, Custody& base) { - RetainPtr parent_custody; + RefPtr parent_custody; auto existing_custody_or_error = resolve_path(linkpath, base, &parent_custody); if (!existing_custody_or_error.is_error()) return KResult(-EEXIST); @@ -524,7 +524,7 @@ KResult VFS::symlink(StringView target, StringView linkpath, Custody& base) KResult VFS::rmdir(StringView path, Custody& base) { - RetainPtr parent_custody; + RefPtr parent_custody; auto custody_or_error = resolve_path(path, base, &parent_custody); if (custody_or_error.is_error()) return KResult(custody_or_error.error()); @@ -559,14 +559,14 @@ KResult VFS::rmdir(StringView path, Custody& base) return parent_inode.remove_child(FileSystemPath(path).basename()); } -RetainPtr VFS::get_inode(InodeIdentifier inode_id) +RefPtr VFS::get_inode(InodeIdentifier inode_id) { if (!inode_id.is_valid()) return nullptr; return inode_id.fs()->get_inode(inode_id); } -VFS::Mount::Mount(RetainPtr&& host_custody, Retained&& guest_fs) +VFS::Mount::Mount(RefPtr&& host_custody, NonnullRefPtr&& guest_fs) : m_guest(guest_fs->root_inode()) , m_guest_fs(move(guest_fs)) , m_host_custody(move(host_custody)) @@ -624,7 +624,7 @@ Custody& VFS::root_custody() return *m_root_custody; } -KResultOr> VFS::resolve_path(StringView path, Custody& base, RetainPtr* parent_custody, int options) +KResultOr> VFS::resolve_path(StringView path, Custody& base, RefPtr* parent_custody, int options) { if (path.is_empty()) return KResult(-EINVAL); @@ -632,7 +632,7 @@ KResultOr> VFS::resolve_path(StringView path, Custody& base, R auto parts = path.split_view('/'); InodeIdentifier crumb_id; - Vector, 32> custody_chain; + Vector, 32> custody_chain; if (path[0] == '/') { custody_chain.append(root_custody()); diff --git a/Kernel/FileSystem/VirtualFileSystem.h b/Kernel/FileSystem/VirtualFileSystem.h index c1f2e20860..595e75cb86 100644 --- a/Kernel/FileSystem/VirtualFileSystem.h +++ b/Kernel/FileSystem/VirtualFileSystem.h @@ -35,7 +35,7 @@ class VFS { public: class Mount { public: - Mount(RetainPtr&&, Retained&&); + Mount(RefPtr&&, NonnullRefPtr&&); InodeIdentifier host() const; InodeIdentifier guest() const { return m_guest; } @@ -47,8 +47,8 @@ public: private: InodeIdentifier m_host; InodeIdentifier m_guest; - Retained m_guest_fs; - RetainPtr m_host_custody; + NonnullRefPtr m_guest_fs; + RefPtr m_host_custody; }; [[gnu::pure]] static VFS& the(); @@ -56,12 +56,12 @@ public: VFS(); ~VFS(); - bool mount_root(Retained&&); - bool mount(Retained&&, StringView path); + bool mount_root(NonnullRefPtr&&); + bool mount(NonnullRefPtr&&, StringView path); - KResultOr> open(RetainPtr&&, int options); - KResultOr> open(StringView path, int options, mode_t mode, Custody& base); - KResultOr> create(StringView path, int options, mode_t mode, Custody& parent_custody); + KResultOr> open(RefPtr&&, int options); + KResultOr> open(StringView path, int options, mode_t mode, Custody& base); + KResultOr> create(StringView path, int options, mode_t mode, Custody& parent_custody); KResult mkdir(StringView path, mode_t mode, Custody& base); KResult link(StringView old_path, StringView new_path, Custody& base); KResult unlink(StringView path, Custody& base); @@ -76,7 +76,7 @@ public: KResult utime(StringView path, Custody& base, time_t atime, time_t mtime); KResult rename(StringView oldpath, StringView newpath, Custody& base); KResult mknod(StringView path, mode_t, dev_t, Custody& base); - KResultOr> open_directory(StringView path, Custody& base); + KResultOr> open_directory(StringView path, Custody& base); void register_device(Badge, Device&); void unregister_device(Badge, Device&); @@ -91,12 +91,12 @@ public: Device* get_device(unsigned major, unsigned minor); Custody& root_custody(); - KResultOr> resolve_path(StringView path, Custody& base, RetainPtr* parent = nullptr, int options = 0); + KResultOr> resolve_path(StringView path, Custody& base, RefPtr* parent = nullptr, int options = 0); private: friend class FileDescription; - RetainPtr get_inode(InodeIdentifier); + RefPtr get_inode(InodeIdentifier); bool is_vfs_root(InodeIdentifier) const; @@ -105,9 +105,9 @@ private: Mount* find_mount_for_host(InodeIdentifier); Mount* find_mount_for_guest(InodeIdentifier); - RetainPtr m_root_inode; + RefPtr m_root_inode; Vector> m_mounts; HashMap m_devices; - RetainPtr m_root_custody; + RefPtr m_root_custody; }; diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index 0b205b191a..95ea2a4d19 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -23,7 +23,7 @@ Lockable>& IPv4Socket::all_sockets() return *s_table; } -Retained IPv4Socket::create(int type, int protocol) +NonnullRefPtr IPv4Socket::create(int type, int protocol) { if (type == SOCK_STREAM) return TCPSocket::create(protocol); diff --git a/Kernel/Net/IPv4Socket.h b/Kernel/Net/IPv4Socket.h index dea6b5c171..e983bf8bc3 100644 --- a/Kernel/Net/IPv4Socket.h +++ b/Kernel/Net/IPv4Socket.h @@ -15,7 +15,7 @@ class TCPSocket; class IPv4Socket : public Socket { public: - static Retained create(int type, int protocol); + static NonnullRefPtr create(int type, int protocol); virtual ~IPv4Socket() override; static Lockable>& all_sockets(); @@ -88,7 +88,7 @@ class IPv4SocketHandle : public SocketHandle { public: IPv4SocketHandle() {} - IPv4SocketHandle(RetainPtr&& socket) + IPv4SocketHandle(RefPtr&& socket) : SocketHandle(move(socket)) { } diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp index 95fcc6b940..57e13a4a3a 100644 --- a/Kernel/Net/LocalSocket.cpp +++ b/Kernel/Net/LocalSocket.cpp @@ -7,7 +7,7 @@ //#define DEBUG_LOCAL_SOCKET -Retained LocalSocket::create(int type) +NonnullRefPtr LocalSocket::create(int type) { return adopt(*new LocalSocket(type)); } diff --git a/Kernel/Net/LocalSocket.h b/Kernel/Net/LocalSocket.h index f1ac23719b..4d348e8435 100644 --- a/Kernel/Net/LocalSocket.h +++ b/Kernel/Net/LocalSocket.h @@ -7,7 +7,7 @@ class FileDescription; class LocalSocket final : public Socket { public: - static Retained create(int type); + static NonnullRefPtr create(int type); virtual ~LocalSocket() override; virtual KResult bind(const sockaddr*, socklen_t) override; @@ -28,7 +28,7 @@ private: virtual bool is_local() const override { return true; } bool has_attached_peer(const FileDescription&) const; - RetainPtr m_file; + RefPtr m_file; bool m_bound { false }; int m_accepted_fds_open { 0 }; diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp index 6113d241dd..0a12ffd5b7 100644 --- a/Kernel/Net/NetworkTask.cpp +++ b/Kernel/Net/NetworkTask.cpp @@ -209,7 +209,7 @@ void handle_icmp(const EthernetFrameHeader& eth, int frame_size) { LOCKER(IPv4Socket::all_sockets().lock()); - for (RetainPtr socket : IPv4Socket::all_sockets().resource()) { + for (RefPtr socket : IPv4Socket::all_sockets().resource()) { LOCKER(socket->lock()); if (socket->protocol() != (unsigned)IPv4Protocol::ICMP) continue; diff --git a/Kernel/Net/Socket.cpp b/Kernel/Net/Socket.cpp index 6164cbe783..d15bd5d09b 100644 --- a/Kernel/Net/Socket.cpp +++ b/Kernel/Net/Socket.cpp @@ -6,7 +6,7 @@ #include #include -KResultOr> Socket::create(int domain, int type, int protocol) +KResultOr> Socket::create(int domain, int type, int protocol) { (void)protocol; switch (domain) { @@ -41,7 +41,7 @@ KResult Socket::listen(int backlog) return KSuccess; } -RetainPtr Socket::accept() +RefPtr Socket::accept() { LOCKER(m_lock); if (m_pending.is_empty()) diff --git a/Kernel/Net/Socket.h b/Kernel/Net/Socket.h index ff129f8e54..af9e257a37 100644 --- a/Kernel/Net/Socket.h +++ b/Kernel/Net/Socket.h @@ -25,7 +25,7 @@ class FileDescription; class Socket : public File { public: - static KResultOr> create(int domain, int type, int protocol); + static KResultOr> create(int domain, int type, int protocol); virtual ~Socket() override; int domain() const { return m_domain; } @@ -33,7 +33,7 @@ public: int protocol() const { return m_protocol; } bool can_accept() const { return !m_pending.is_empty(); } - RetainPtr accept(); + RefPtr accept(); bool is_connected() const { return m_connected; } KResult listen(int backlog); @@ -89,14 +89,14 @@ private: timeval m_receive_deadline { 0, 0 }; timeval m_send_deadline { 0, 0 }; - Vector> m_pending; + Vector> m_pending; }; class SocketHandle { public: SocketHandle() {} - SocketHandle(RetainPtr&& socket) + SocketHandle(RefPtr&& socket) : m_socket(move(socket)) { if (m_socket) @@ -126,5 +126,5 @@ public: const Socket& socket() const { return *m_socket; } private: - RetainPtr m_socket; + RefPtr m_socket; }; diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp index c38f3c3cd6..595958dd02 100644 --- a/Kernel/Net/TCPSocket.cpp +++ b/Kernel/Net/TCPSocket.cpp @@ -15,7 +15,7 @@ Lockable>& TCPSocket::sockets_by_port() TCPSocketHandle TCPSocket::from_port(word port) { - RetainPtr socket; + RefPtr socket; { LOCKER(sockets_by_port().lock()); auto it = sockets_by_port().resource().find(port); @@ -38,7 +38,7 @@ TCPSocket::~TCPSocket() sockets_by_port().resource().remove(local_port()); } -Retained TCPSocket::create(int protocol) +NonnullRefPtr TCPSocket::create(int protocol) { return adopt(*new TCPSocket(protocol)); } diff --git a/Kernel/Net/TCPSocket.h b/Kernel/Net/TCPSocket.h index a54d04417d..905089abba 100644 --- a/Kernel/Net/TCPSocket.h +++ b/Kernel/Net/TCPSocket.h @@ -4,7 +4,7 @@ class TCPSocket final : public IPv4Socket { public: - static Retained create(int protocol); + static NonnullRefPtr create(int protocol); virtual ~TCPSocket() override; enum class State { @@ -49,7 +49,7 @@ class TCPSocketHandle : public SocketHandle { public: TCPSocketHandle() {} - TCPSocketHandle(RetainPtr&& socket) + TCPSocketHandle(RefPtr&& socket) : SocketHandle(move(socket)) { } diff --git a/Kernel/Net/UDPSocket.cpp b/Kernel/Net/UDPSocket.cpp index 6ae66cfb09..0d1b815d37 100644 --- a/Kernel/Net/UDPSocket.cpp +++ b/Kernel/Net/UDPSocket.cpp @@ -15,7 +15,7 @@ Lockable>& UDPSocket::sockets_by_port() UDPSocketHandle UDPSocket::from_port(word port) { - RetainPtr socket; + RefPtr socket; { LOCKER(sockets_by_port().lock()); auto it = sockets_by_port().resource().find(port); @@ -38,7 +38,7 @@ UDPSocket::~UDPSocket() sockets_by_port().resource().remove(local_port()); } -Retained UDPSocket::create(int protocol) +NonnullRefPtr UDPSocket::create(int protocol) { return adopt(*new UDPSocket(protocol)); } diff --git a/Kernel/Net/UDPSocket.h b/Kernel/Net/UDPSocket.h index 80ef09b7bf..3cd147d7e5 100644 --- a/Kernel/Net/UDPSocket.h +++ b/Kernel/Net/UDPSocket.h @@ -6,7 +6,7 @@ class UDPSocketHandle; class UDPSocket final : public IPv4Socket { public: - static Retained create(int protocol); + static NonnullRefPtr create(int protocol); virtual ~UDPSocket() override; static UDPSocketHandle from_port(word); @@ -27,7 +27,7 @@ class UDPSocketHandle : public SocketHandle { public: UDPSocketHandle() {} - UDPSocketHandle(RetainPtr&& socket) + UDPSocketHandle(RefPtr&& socket) : SocketHandle(move(socket)) { } diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index d671d177df..52ff29dcca 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -105,7 +105,7 @@ Region* Process::allocate_region(VirtualAddress vaddr, size_t size, const String return m_regions.last().ptr(); } -Region* Process::allocate_file_backed_region(VirtualAddress vaddr, size_t size, RetainPtr&& inode, const String& name, int prot) +Region* Process::allocate_file_backed_region(VirtualAddress vaddr, size_t size, RefPtr&& inode, const String& name, int prot) { auto range = allocate_range(vaddr, size); if (!range.is_valid()) @@ -115,7 +115,7 @@ Region* Process::allocate_file_backed_region(VirtualAddress vaddr, size_t size, return m_regions.last().ptr(); } -Region* Process::allocate_region_with_vmo(VirtualAddress vaddr, size_t size, Retained&& vmo, size_t offset_in_vmo, const String& name, int prot) +Region* Process::allocate_region_with_vmo(VirtualAddress vaddr, size_t size, NonnullRefPtr&& vmo, size_t offset_in_vmo, const String& name, int prot) { auto range = allocate_range(vaddr, size); if (!range.is_valid()) @@ -334,7 +334,7 @@ int Process::do_exec(String path, Vector arguments, Vector envir auto vmo = VMObject::create_file_backed(description->inode()); vmo->set_name(description->absolute_path()); - RetainPtr region = allocate_region_with_vmo(VirtualAddress(), metadata.size, vmo.copy_ref(), 0, vmo->name(), PROT_READ); + RefPtr region = allocate_region_with_vmo(VirtualAddress(), metadata.size, vmo.copy_ref(), 0, vmo->name(), PROT_READ); ASSERT(region); if (this != ¤t->process()) { @@ -516,7 +516,7 @@ Process* Process::create_user_process(const String& path, uid_t uid, gid_t gid, if (arguments.is_empty()) { arguments.append(parts.last()); } - RetainPtr cwd; + RefPtr cwd; { InterruptDisabler disabler; if (auto* parent = Process::from_pid(parent_pid)) @@ -562,7 +562,7 @@ Process* Process::create_kernel_process(String&& name, void (*e)()) return process; } -Process::Process(String&& name, uid_t uid, gid_t gid, pid_t ppid, RingLevel ring, RetainPtr&& cwd, RetainPtr&& executable, TTY* tty, Process* fork_parent) +Process::Process(String&& name, uid_t uid, gid_t gid, pid_t ppid, RingLevel ring, RefPtr&& cwd, RefPtr&& executable, TTY* tty, Process* fork_parent) : m_name(move(name)) , m_pid(next_pid++) // FIXME: RACE: This variable looks racy! , m_uid(uid) @@ -2445,7 +2445,7 @@ struct SharedBuffer { Region* m_pid2_region { nullptr }; bool m_pid1_writable { false }; bool m_pid2_writable { false }; - Retained m_vmo; + NonnullRefPtr m_vmo; }; static int s_next_shared_buffer_id; @@ -2734,7 +2734,7 @@ void Process::FileDescriptionAndFlags::clear() flags = 0; } -void Process::FileDescriptionAndFlags::set(Retained&& d, dword f) +void Process::FileDescriptionAndFlags::set(NonnullRefPtr&& d, dword f) { description = move(d); flags = f; diff --git a/Kernel/Process.h b/Kernel/Process.h index 46f5b895a1..c8c7583603 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -211,7 +211,7 @@ public: void set_tty(TTY* tty) { m_tty = tty; } size_t region_count() const { return m_regions.size(); } - const Vector>& regions() const { return m_regions; } + const Vector>& regions() const { return m_regions; } void dump_regions(); ProcessTracer* tracer() { return m_tracer.ptr(); } @@ -248,8 +248,8 @@ public: bool is_superuser() const { return m_euid == 0; } - Region* allocate_region_with_vmo(VirtualAddress, size_t, Retained&&, size_t offset_in_vmo, const String& name, int prot); - Region* allocate_file_backed_region(VirtualAddress, size_t, RetainPtr&&, const String& name, int prot); + Region* allocate_region_with_vmo(VirtualAddress, size_t, NonnullRefPtr&&, size_t offset_in_vmo, const String& name, int prot); + Region* allocate_file_backed_region(VirtualAddress, size_t, RefPtr&&, const String& name, int prot); Region* allocate_region(VirtualAddress, size_t, const String& name, int prot = PROT_READ | PROT_WRITE, bool commit = true); bool deallocate_region(Region& region); @@ -273,7 +273,7 @@ private: friend class Scheduler; friend class Region; - Process(String&& name, uid_t, gid_t, pid_t ppid, RingLevel, RetainPtr&& cwd = nullptr, RetainPtr&& executable = nullptr, TTY* = nullptr, Process* fork_parent = nullptr); + Process(String&& name, uid_t, gid_t, pid_t ppid, RingLevel, RefPtr&& cwd = nullptr, RefPtr&& executable = nullptr, TTY* = nullptr, Process* fork_parent = nullptr); Range allocate_range(VirtualAddress, size_t); @@ -287,7 +287,7 @@ private: Thread* m_main_thread { nullptr }; - RetainPtr m_page_directory; + RefPtr m_page_directory; Process* m_prev { nullptr }; Process* m_next { nullptr }; @@ -307,8 +307,8 @@ private: struct FileDescriptionAndFlags { operator bool() const { return !!description; } void clear(); - void set(Retained&& d, dword f = 0); - RetainPtr description; + void set(NonnullRefPtr&& d, dword f = 0); + RefPtr description; dword flags { 0 }; }; Vector m_fds; @@ -319,14 +319,14 @@ private: byte m_termination_status { 0 }; byte m_termination_signal { 0 }; - RetainPtr m_executable; - RetainPtr m_cwd; + RefPtr m_executable; + RefPtr m_cwd; TTY* m_tty { nullptr }; Region* region_from_range(VirtualAddress, size_t); - Vector> m_regions; + Vector> m_regions; VirtualAddress m_return_to_ring3_from_signal_trampoline; VirtualAddress m_return_to_ring0_from_signal_trampoline; @@ -345,7 +345,7 @@ private: unsigned m_syscall_count { 0 }; - RetainPtr m_tracer; + RefPtr m_tracer; OwnPtr m_elf_loader; Lock m_big_lock { "Process" }; diff --git a/Kernel/ProcessTracer.h b/Kernel/ProcessTracer.h index 0b71b0ba0a..8733c0a813 100644 --- a/Kernel/ProcessTracer.h +++ b/Kernel/ProcessTracer.h @@ -6,7 +6,7 @@ class ProcessTracer : public File { public: - static Retained create(pid_t pid) { return adopt(*new ProcessTracer(pid)); } + static NonnullRefPtr create(pid_t pid) { return adopt(*new ProcessTracer(pid)); } virtual ~ProcessTracer() override; bool is_dead() const { return m_dead; } diff --git a/Kernel/SharedMemory.cpp b/Kernel/SharedMemory.cpp index 6100aee70c..fec48ce082 100644 --- a/Kernel/SharedMemory.cpp +++ b/Kernel/SharedMemory.cpp @@ -4,15 +4,15 @@ #include #include -Lockable>>& shared_memories() +Lockable>>& shared_memories() { - static Lockable>>* map; + static Lockable>>* map; if (!map) - map = new Lockable>>; + map = new Lockable>>; return *map; } -KResultOr> SharedMemory::open(const String& name, int flags, mode_t mode) +KResultOr> SharedMemory::open(const String& name, int flags, mode_t mode) { UNUSED_PARAM(flags); LOCKER(shared_memories().lock()); diff --git a/Kernel/SharedMemory.h b/Kernel/SharedMemory.h index f7ec96f495..7ab7d7497a 100644 --- a/Kernel/SharedMemory.h +++ b/Kernel/SharedMemory.h @@ -11,7 +11,7 @@ class VMObject; class SharedMemory : public File { public: - static KResultOr> open(const String& name, int flags, mode_t); + static KResultOr> open(const String& name, int flags, mode_t); static KResult unlink(const String& name); virtual ~SharedMemory() override; @@ -39,5 +39,5 @@ private: uid_t m_uid { 0 }; gid_t m_gid { 0 }; mode_t m_mode { 0 }; - RetainPtr m_vmo; + RefPtr m_vmo; }; diff --git a/Kernel/TTY/MasterPTY.h b/Kernel/TTY/MasterPTY.h index accb6902bc..d4965cd76a 100644 --- a/Kernel/TTY/MasterPTY.h +++ b/Kernel/TTY/MasterPTY.h @@ -29,7 +29,7 @@ private: virtual int ioctl(FileDescription&, unsigned request, unsigned arg) override; virtual const char* class_name() const override { return "MasterPTY"; } - RetainPtr m_slave; + RefPtr m_slave; unsigned m_index; bool m_closed { false }; DoubleBuffer m_buffer; diff --git a/Kernel/TTY/PTYMultiplexer.cpp b/Kernel/TTY/PTYMultiplexer.cpp index 3b8b596502..6a9b645e0c 100644 --- a/Kernel/TTY/PTYMultiplexer.cpp +++ b/Kernel/TTY/PTYMultiplexer.cpp @@ -28,7 +28,7 @@ PTYMultiplexer::~PTYMultiplexer() { } -KResultOr> PTYMultiplexer::open(int options) +KResultOr> PTYMultiplexer::open(int options) { UNUSED_PARAM(options); LOCKER(m_lock); diff --git a/Kernel/TTY/PTYMultiplexer.h b/Kernel/TTY/PTYMultiplexer.h index b25a5674fc..5a5e8f51b5 100644 --- a/Kernel/TTY/PTYMultiplexer.h +++ b/Kernel/TTY/PTYMultiplexer.h @@ -15,7 +15,7 @@ public: static PTYMultiplexer& the(); // ^CharacterDevice - virtual KResultOr> open(int options) override; + virtual KResultOr> open(int options) override; virtual ssize_t read(FileDescription&, byte*, ssize_t) override { return 0; } virtual ssize_t write(FileDescription&, const byte*, ssize_t) override { return 0; } virtual bool can_read(FileDescription&) const override { return true; } diff --git a/Kernel/TTY/SlavePTY.h b/Kernel/TTY/SlavePTY.h index 83387d8731..71c79371fc 100644 --- a/Kernel/TTY/SlavePTY.h +++ b/Kernel/TTY/SlavePTY.h @@ -30,7 +30,7 @@ private: friend class MasterPTY; SlavePTY(MasterPTY&, unsigned index); - RetainPtr m_master; + RefPtr m_master; unsigned m_index; InodeIdentifier m_devpts_inode_id; String m_tty_name; diff --git a/Kernel/Thread.h b/Kernel/Thread.h index 91cd852e5e..bc00eb630f 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -176,10 +176,10 @@ private: dword m_pending_signals { 0 }; dword m_signal_mask { 0 }; dword m_kernel_stack_base { 0 }; - RetainPtr m_kernel_stack_region; - RetainPtr m_kernel_stack_for_signal_handler_region; + RefPtr m_kernel_stack_region; + RefPtr m_kernel_stack_for_signal_handler_region; pid_t m_waitee_pid { -1 }; - RetainPtr m_blocked_description; + RefPtr m_blocked_description; timeval m_select_timeout; SignalActionData m_signal_action_data[32]; Region* m_signal_stack_user_region { nullptr }; diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp index bcc97d1b35..dd0f0f9ef0 100644 --- a/Kernel/VM/MemoryManager.cpp +++ b/Kernel/VM/MemoryManager.cpp @@ -81,7 +81,7 @@ void MemoryManager::initialize_paging() #endif m_quickmap_addr = VirtualAddress((1 * MB) - PAGE_SIZE); - RetainPtr region = nullptr; + RefPtr region = nullptr; bool region_is_super = false; for (auto* mmap = (multiboot_memory_map_t*)multiboot_info_ptr->mmap_addr; (unsigned long)mmap < multiboot_info_ptr->mmap_addr + multiboot_info_ptr->mmap_length; mmap = (multiboot_memory_map_t*)((unsigned long)mmap + mmap->size + sizeof(mmap->size))) { @@ -151,7 +151,7 @@ void MemoryManager::initialize_paging() #endif } -RetainPtr MemoryManager::allocate_page_table(PageDirectory& page_directory, unsigned index) +RefPtr MemoryManager::allocate_page_table(PageDirectory& page_directory, unsigned index) { ASSERT(!page_directory.m_physical_pages.contains(index)); auto physical_page = allocate_supervisor_physical_page(); @@ -444,7 +444,7 @@ PageFaultResponse MemoryManager::handle_page_fault(const PageFault& fault) return PageFaultResponse::ShouldCrash; } -RetainPtr MemoryManager::allocate_kernel_region(size_t size, String&& name) +RefPtr MemoryManager::allocate_kernel_region(size_t size, String&& name) { InterruptDisabler disabler; @@ -478,11 +478,11 @@ void MemoryManager::deallocate_user_physical_page(PhysicalPage&& page) ASSERT_NOT_REACHED(); } -RetainPtr MemoryManager::allocate_user_physical_page(ShouldZeroFill should_zero_fill) +RefPtr MemoryManager::allocate_user_physical_page(ShouldZeroFill should_zero_fill) { InterruptDisabler disabler; - RetainPtr page = nullptr; + RefPtr page = nullptr; for (auto& region : m_user_physical_regions) { page = region->take_free_page(false); @@ -535,11 +535,11 @@ void MemoryManager::deallocate_supervisor_physical_page(PhysicalPage&& page) ASSERT_NOT_REACHED(); } -RetainPtr MemoryManager::allocate_supervisor_physical_page() +RefPtr MemoryManager::allocate_supervisor_physical_page() { InterruptDisabler disabler; - RetainPtr page = nullptr; + RefPtr page = nullptr; for (auto& region : m_super_physical_regions) { page = region->take_free_page(true); diff --git a/Kernel/VM/MemoryManager.h b/Kernel/VM/MemoryManager.h index efa291e41c..605f35dd95 100644 --- a/Kernel/VM/MemoryManager.h +++ b/Kernel/VM/MemoryManager.h @@ -61,8 +61,8 @@ public: Yes }; - RetainPtr allocate_user_physical_page(ShouldZeroFill); - RetainPtr allocate_supervisor_physical_page(); + RefPtr allocate_user_physical_page(ShouldZeroFill); + RefPtr allocate_supervisor_physical_page(); void deallocate_user_physical_page(PhysicalPage&&); void deallocate_supervisor_physical_page(PhysicalPage&&); @@ -70,7 +70,7 @@ public: void map_for_kernel(VirtualAddress, PhysicalAddress); - RetainPtr allocate_kernel_region(size_t, String&& name); + RefPtr allocate_kernel_region(size_t, String&& name); void map_region_at_address(PageDirectory&, Region&, VirtualAddress, bool user_accessible); unsigned user_physical_pages() const { return m_user_physical_pages; } @@ -93,7 +93,7 @@ private: void flush_entire_tlb(); void flush_tlb(VirtualAddress); - RetainPtr allocate_page_table(PageDirectory&, unsigned index); + RefPtr allocate_page_table(PageDirectory&, unsigned index); void map_protected(VirtualAddress, size_t length); @@ -214,7 +214,7 @@ private: PageTableEntry ensure_pte(PageDirectory&, VirtualAddress); - RetainPtr m_kernel_page_directory; + RefPtr m_kernel_page_directory; dword* m_page_table_zero { nullptr }; dword* m_page_table_one { nullptr }; @@ -225,8 +225,8 @@ private: unsigned m_super_physical_pages { 0 }; unsigned m_super_physical_pages_used { 0 }; - Vector> m_user_physical_regions {}; - Vector> m_super_physical_regions {}; + Vector> m_user_physical_regions {}; + Vector> m_super_physical_regions {}; HashTable m_vmos; HashTable m_user_regions; diff --git a/Kernel/VM/PageDirectory.h b/Kernel/VM/PageDirectory.h index cf0876e438..fcf8ea83dc 100644 --- a/Kernel/VM/PageDirectory.h +++ b/Kernel/VM/PageDirectory.h @@ -10,8 +10,8 @@ class PageDirectory : public RefCounted { friend class MemoryManager; public: - static Retained create_for_userspace(const RangeAllocator* parent_range_allocator = nullptr) { return adopt(*new PageDirectory(parent_range_allocator)); } - static Retained create_at_fixed_address(PhysicalAddress paddr) { return adopt(*new PageDirectory(paddr)); } + static NonnullRefPtr create_for_userspace(const RangeAllocator* parent_range_allocator = nullptr) { return adopt(*new PageDirectory(parent_range_allocator)); } + static NonnullRefPtr create_at_fixed_address(PhysicalAddress paddr) { return adopt(*new PageDirectory(paddr)); } ~PageDirectory(); dword cr3() const { return m_directory_page->paddr().get(); } @@ -26,6 +26,6 @@ private: explicit PageDirectory(PhysicalAddress); RangeAllocator m_range_allocator; - RetainPtr m_directory_page; - HashMap> m_physical_pages; + RefPtr m_directory_page; + HashMap> m_physical_pages; }; diff --git a/Kernel/VM/PhysicalPage.cpp b/Kernel/VM/PhysicalPage.cpp index adc64e870b..49436a22af 100644 --- a/Kernel/VM/PhysicalPage.cpp +++ b/Kernel/VM/PhysicalPage.cpp @@ -2,7 +2,7 @@ #include #include -Retained PhysicalPage::create(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist) +NonnullRefPtr PhysicalPage::create(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist) { void* slot = kmalloc(sizeof(PhysicalPage)); new (slot) PhysicalPage(paddr, supervisor, may_return_to_freelist); diff --git a/Kernel/VM/PhysicalPage.h b/Kernel/VM/PhysicalPage.h index e4422d14a0..a36200f266 100644 --- a/Kernel/VM/PhysicalPage.h +++ b/Kernel/VM/PhysicalPage.h @@ -28,7 +28,7 @@ public: } } - static Retained create(PhysicalAddress, bool supervisor, bool may_return_to_freelist = true); + static NonnullRefPtr create(PhysicalAddress, bool supervisor, bool may_return_to_freelist = true); word ref_count() const { return m_retain_count; } diff --git a/Kernel/VM/PhysicalRegion.cpp b/Kernel/VM/PhysicalRegion.cpp index fd7021d977..436f17d144 100644 --- a/Kernel/VM/PhysicalRegion.cpp +++ b/Kernel/VM/PhysicalRegion.cpp @@ -6,7 +6,7 @@ #include #include -Retained PhysicalRegion::create(PhysicalAddress lower, PhysicalAddress upper) +NonnullRefPtr PhysicalRegion::create(PhysicalAddress lower, PhysicalAddress upper) { return adopt(*new PhysicalRegion(lower, upper)); } @@ -36,7 +36,7 @@ unsigned PhysicalRegion::finalize_capacity() return size(); } -RetainPtr PhysicalRegion::take_free_page(bool supervisor) +RefPtr PhysicalRegion::take_free_page(bool supervisor) { ASSERT(m_pages); diff --git a/Kernel/VM/PhysicalRegion.h b/Kernel/VM/PhysicalRegion.h index 7cecc4b365..425a5900a7 100644 --- a/Kernel/VM/PhysicalRegion.h +++ b/Kernel/VM/PhysicalRegion.h @@ -10,7 +10,7 @@ class PhysicalRegion : public RefCounted { AK_MAKE_ETERNAL public: - static Retained create(PhysicalAddress lower, PhysicalAddress upper); + static NonnullRefPtr create(PhysicalAddress lower, PhysicalAddress upper); ~PhysicalRegion() {} void expand(PhysicalAddress lower, PhysicalAddress upper); @@ -23,7 +23,7 @@ public: unsigned free() const { return m_pages - m_used; } bool contains(PhysicalPage& page) const { return page.paddr() >= m_lower && page.paddr() <= m_upper; } - RetainPtr take_free_page(bool supervisor); + RefPtr take_free_page(bool supervisor); void return_page_at(PhysicalAddress addr); void return_page(PhysicalPage&& page) { return_page_at(page.paddr()); } diff --git a/Kernel/VM/Region.cpp b/Kernel/VM/Region.cpp index 234fc4710b..e191ce2e25 100644 --- a/Kernel/VM/Region.cpp +++ b/Kernel/VM/Region.cpp @@ -15,7 +15,7 @@ Region::Region(const Range& range, const String& name, byte access, bool cow) MM.register_region(*this); } -Region::Region(const Range& range, RetainPtr&& inode, const String& name, byte access) +Region::Region(const Range& range, RefPtr&& inode, const String& name, byte access) : m_range(range) , m_vmo(VMObject::create_file_backed(move(inode))) , m_name(name) @@ -25,7 +25,7 @@ Region::Region(const Range& range, RetainPtr&& inode, const String& name, MM.register_region(*this); } -Region::Region(const Range& range, Retained&& vmo, size_t offset_in_vmo, const String& name, byte access, bool cow) +Region::Region(const Range& range, NonnullRefPtr&& vmo, size_t offset_in_vmo, const String& name, byte access, bool cow) : m_range(range) , m_offset_in_vmo(offset_in_vmo) , m_vmo(move(vmo)) @@ -66,7 +66,7 @@ bool Region::page_in() return true; } -Retained Region::clone() +NonnullRefPtr Region::clone() { ASSERT(current); if (m_shared || (is_readable() && !is_writable())) { diff --git a/Kernel/VM/Region.h b/Kernel/VM/Region.h index 1e0d374b17..9079280d2f 100644 --- a/Kernel/VM/Region.h +++ b/Kernel/VM/Region.h @@ -19,8 +19,8 @@ public: }; Region(const Range&, const String&, byte access, bool cow = false); - Region(const Range&, Retained&&, size_t offset_in_vmo, const String&, byte access, bool cow = false); - Region(const Range&, RetainPtr&&, const String&, byte access); + Region(const Range&, NonnullRefPtr&&, size_t offset_in_vmo, const String&, byte access, bool cow = false); + Region(const Range&, RefPtr&&, const String&, byte access); ~Region(); VirtualAddress vaddr() const { return m_range.base(); } @@ -38,7 +38,7 @@ public: bool is_shared() const { return m_shared; } void set_shared(bool shared) { m_shared = shared; } - Retained clone(); + NonnullRefPtr clone(); bool contains(VirtualAddress vaddr) const { @@ -97,10 +97,10 @@ public: } private: - RetainPtr m_page_directory; + RefPtr m_page_directory; Range m_range; size_t m_offset_in_vmo { 0 }; - Retained m_vmo; + NonnullRefPtr m_vmo; String m_name; byte m_access { 0 }; bool m_shared { false }; diff --git a/Kernel/VM/VMObject.cpp b/Kernel/VM/VMObject.cpp index 34a8a2cf55..9bcd6875eb 100644 --- a/Kernel/VM/VMObject.cpp +++ b/Kernel/VM/VMObject.cpp @@ -3,7 +3,7 @@ #include #include -Retained VMObject::create_file_backed(RetainPtr&& inode) +NonnullRefPtr VMObject::create_file_backed(RefPtr&& inode) { InterruptDisabler disabler; if (inode->vmo()) @@ -13,13 +13,13 @@ Retained VMObject::create_file_backed(RetainPtr&& inode) return vmo; } -Retained VMObject::create_anonymous(size_t size) +NonnullRefPtr VMObject::create_anonymous(size_t size) { size = ceil_div(size, PAGE_SIZE) * PAGE_SIZE; return adopt(*new VMObject(size)); } -Retained VMObject::create_for_physical_range(PhysicalAddress paddr, size_t size) +NonnullRefPtr VMObject::create_for_physical_range(PhysicalAddress paddr, size_t size) { size = ceil_div(size, PAGE_SIZE) * PAGE_SIZE; auto vmo = adopt(*new VMObject(paddr, size)); @@ -27,7 +27,7 @@ Retained VMObject::create_for_physical_range(PhysicalAddress paddr, si return vmo; } -Retained VMObject::clone() +NonnullRefPtr VMObject::clone() { return adopt(*new VMObject(*this)); } @@ -59,7 +59,7 @@ VMObject::VMObject(PhysicalAddress paddr, size_t size) ASSERT(m_physical_pages.size() == page_count()); } -VMObject::VMObject(RetainPtr&& inode) +VMObject::VMObject(RefPtr&& inode) : m_inode(move(inode)) { ASSERT(m_inode); diff --git a/Kernel/VM/VMObject.h b/Kernel/VM/VMObject.h index 5713d54395..ca6403f58e 100644 --- a/Kernel/VM/VMObject.h +++ b/Kernel/VM/VMObject.h @@ -18,10 +18,10 @@ class VMObject : public RefCounted friend class MemoryManager; public: - static Retained create_file_backed(RetainPtr&&); - static Retained create_anonymous(size_t); - static Retained create_for_physical_range(PhysicalAddress, size_t); - Retained clone(); + static NonnullRefPtr create_file_backed(RefPtr&&); + static NonnullRefPtr create_anonymous(size_t); + static NonnullRefPtr create_for_physical_range(PhysicalAddress, size_t); + NonnullRefPtr clone(); ~VMObject(); bool is_anonymous() const { return !m_inode; } @@ -34,8 +34,8 @@ public: void set_name(const String& name) { m_name = name; } size_t page_count() const { return m_size / PAGE_SIZE; } - const Vector>& physical_pages() const { return m_physical_pages; } - Vector>& physical_pages() { return m_physical_pages; } + const Vector>& physical_pages() const { return m_physical_pages; } + Vector>& physical_pages() { return m_physical_pages; } void inode_contents_changed(Badge, off_t, ssize_t, const byte*); void inode_size_changed(Badge, size_t old_size, size_t new_size); @@ -43,7 +43,7 @@ public: size_t size() const { return m_size; } private: - VMObject(RetainPtr&&); + VMObject(RefPtr&&); explicit VMObject(VMObject&); explicit VMObject(size_t); VMObject(PhysicalAddress, size_t); @@ -55,7 +55,7 @@ private: bool m_allow_cpu_caching { true }; off_t m_inode_offset { 0 }; size_t m_size { 0 }; - RetainPtr m_inode; - Vector> m_physical_pages; + RefPtr m_inode; + Vector> m_physical_pages; Lock m_paging_lock { "VMObject" }; }; diff --git a/Kernel/init.cpp b/Kernel/init.cpp index cde76f94e2..d1b9e381f8 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -86,7 +86,7 @@ VFS* vfs; auto dev_hd0 = IDEDiskDevice::create(); - Retained root_dev = dev_hd0.copy_ref(); + NonnullRefPtr root_dev = dev_hd0.copy_ref(); root = root.substring(strlen("/dev/hda"), root.length() - strlen("/dev/hda")); @@ -199,7 +199,7 @@ extern "C" [[noreturn]] void init() auto e1000 = E1000NetworkAdapter::autodetect(); - Retained new_procfs = ProcFS::create(); + NonnullRefPtr new_procfs = ProcFS::create(); new_procfs->initialize(); auto devptsfs = DevPtsFS::create(); diff --git a/LibC/SharedBuffer.cpp b/LibC/SharedBuffer.cpp index 58537a0094..cc61d6a25f 100644 --- a/LibC/SharedBuffer.cpp +++ b/LibC/SharedBuffer.cpp @@ -3,7 +3,7 @@ #include #include -RetainPtr SharedBuffer::create(pid_t peer, int size) +RefPtr SharedBuffer::create(pid_t peer, int size) { void* data; int shared_buffer_id = create_shared_buffer(peer, size, &data); @@ -14,7 +14,7 @@ RetainPtr SharedBuffer::create(pid_t peer, int size) return adopt(*new SharedBuffer(shared_buffer_id, size, data)); } -RetainPtr SharedBuffer::create_from_shared_buffer_id(int shared_buffer_id) +RefPtr SharedBuffer::create_from_shared_buffer_id(int shared_buffer_id) { void* data = get_shared_buffer(shared_buffer_id); if (data == (void*)-1) { diff --git a/LibC/SharedBuffer.h b/LibC/SharedBuffer.h index 09c5b83f3a..588ba1821b 100644 --- a/LibC/SharedBuffer.h +++ b/LibC/SharedBuffer.h @@ -5,8 +5,8 @@ class SharedBuffer : public RefCounted { public: - static RetainPtr create(pid_t peer, int); - static RetainPtr create_from_shared_buffer_id(int); + static RefPtr create(pid_t peer, int); + static RefPtr create_from_shared_buffer_id(int); ~SharedBuffer(); int shared_buffer_id() const { return m_shared_buffer_id; } diff --git a/LibCore/CConfigFile.cpp b/LibCore/CConfigFile.cpp index d39d4505a0..39151d24c9 100644 --- a/LibCore/CConfigFile.cpp +++ b/LibCore/CConfigFile.cpp @@ -6,7 +6,7 @@ #include #include -Retained CConfigFile::get_for_app(const String& app_name) +NonnullRefPtr CConfigFile::get_for_app(const String& app_name) { String home_path = get_current_user_home_path(); if (home_path == "/") @@ -15,7 +15,7 @@ Retained CConfigFile::get_for_app(const String& app_name) return adopt(*new CConfigFile(path)); } -Retained CConfigFile::get_for_system(const String& app_name) +NonnullRefPtr CConfigFile::get_for_system(const String& app_name) { auto path = String::format("/etc/%s.ini", app_name.characters()); return adopt(*new CConfigFile(path)); diff --git a/LibCore/CConfigFile.h b/LibCore/CConfigFile.h index f771702776..4e5e4fa5e0 100644 --- a/LibCore/CConfigFile.h +++ b/LibCore/CConfigFile.h @@ -9,8 +9,8 @@ class CConfigFile : public RefCounted { public: - static Retained get_for_app(const String& app_name); - static Retained get_for_system(const String& app_name); + static NonnullRefPtr get_for_app(const String& app_name); + static NonnullRefPtr get_for_system(const String& app_name); ~CConfigFile(); bool has_group(const String&) const; diff --git a/LibCore/CHttpResponse.h b/LibCore/CHttpResponse.h index 851f77d3a0..3feaa6bfd2 100644 --- a/LibCore/CHttpResponse.h +++ b/LibCore/CHttpResponse.h @@ -7,7 +7,7 @@ class CHttpResponse : public CNetworkResponse { public: virtual ~CHttpResponse() override; - static Retained create(int code, HashMap&& headers, ByteBuffer&& payload) + static NonnullRefPtr create(int code, HashMap&& headers, ByteBuffer&& payload) { return adopt(*new CHttpResponse(code, move(headers), move(payload))); } diff --git a/LibCore/CNetworkJob.cpp b/LibCore/CNetworkJob.cpp index 8ff758a3a4..f6905ed11d 100644 --- a/LibCore/CNetworkJob.cpp +++ b/LibCore/CNetworkJob.cpp @@ -10,7 +10,7 @@ CNetworkJob::~CNetworkJob() { } -void CNetworkJob::did_finish(Retained&& response) +void CNetworkJob::did_finish(NonnullRefPtr&& response) { m_response = move(response); printf("%s{%p} job did_finish!\n", class_name(), this); diff --git a/LibCore/CNetworkJob.h b/LibCore/CNetworkJob.h index eaae27c464..faf2e370ed 100644 --- a/LibCore/CNetworkJob.h +++ b/LibCore/CNetworkJob.h @@ -28,10 +28,10 @@ public: protected: CNetworkJob(); - void did_finish(Retained&&); + void did_finish(NonnullRefPtr&&); void did_fail(Error); private: - RetainPtr m_response; + RefPtr m_response; Error m_error { Error::None }; }; diff --git a/LibGUI/GAbstractView.cpp b/LibGUI/GAbstractView.cpp index 36b10818ad..2f7c410592 100644 --- a/LibGUI/GAbstractView.cpp +++ b/LibGUI/GAbstractView.cpp @@ -15,7 +15,7 @@ GAbstractView::~GAbstractView() delete m_edit_widget; } -void GAbstractView::set_model(RetainPtr&& model) +void GAbstractView::set_model(RefPtr&& model) { if (model == m_model) return; diff --git a/LibGUI/GAbstractView.h b/LibGUI/GAbstractView.h index 7709c0cae8..1a517c0c16 100644 --- a/LibGUI/GAbstractView.h +++ b/LibGUI/GAbstractView.h @@ -13,7 +13,7 @@ public: explicit GAbstractView(GWidget* parent); virtual ~GAbstractView() override; - void set_model(RetainPtr&&); + void set_model(RefPtr&&); GModel* model() { return m_model.ptr(); } const GModel* model() const { return m_model.ptr(); } @@ -48,6 +48,6 @@ protected: Rect m_edit_widget_content_rect; private: - RetainPtr m_model; + RefPtr m_model; bool m_activates_on_selection { false }; }; diff --git a/LibGUI/GAction.cpp b/LibGUI/GAction.cpp index 3e701d485a..8d9d023f87 100644 --- a/LibGUI/GAction.cpp +++ b/LibGUI/GAction.cpp @@ -16,7 +16,7 @@ GAction::GAction(const StringView& text, Function on_activation_ { } -GAction::GAction(const StringView& text, RetainPtr&& icon, Function on_activation_callback, GWidget* widget) +GAction::GAction(const StringView& text, RefPtr&& icon, Function on_activation_callback, GWidget* widget) : on_activation(move(on_activation_callback)) , m_text(text) , m_icon(move(icon)) @@ -29,7 +29,7 @@ GAction::GAction(const StringView& text, const GShortcut& shortcut, Function&& icon, Function on_activation_callback, GWidget* widget) +GAction::GAction(const StringView& text, const GShortcut& shortcut, RefPtr&& icon, Function on_activation_callback, GWidget* widget) : on_activation(move(on_activation_callback)) , m_text(text) , m_icon(move(icon)) diff --git a/LibGUI/GAction.h b/LibGUI/GAction.h index 7f6f8d8d9f..590ea57578 100644 --- a/LibGUI/GAction.h +++ b/LibGUI/GAction.h @@ -23,23 +23,23 @@ public: ApplicationGlobal, WidgetLocal, }; - static Retained create(const StringView& text, Function callback, GWidget* widget = nullptr) + static NonnullRefPtr create(const StringView& text, Function callback, GWidget* widget = nullptr) { return adopt(*new GAction(text, move(callback), widget)); } - static Retained create(const StringView& text, const StringView& custom_data, Function callback, GWidget* widget = nullptr) + static NonnullRefPtr create(const StringView& text, const StringView& custom_data, Function callback, GWidget* widget = nullptr) { return adopt(*new GAction(text, custom_data, move(callback), widget)); } - static Retained create(const StringView& text, RetainPtr&& icon, Function callback, GWidget* widget = nullptr) + static NonnullRefPtr create(const StringView& text, RefPtr&& icon, Function callback, GWidget* widget = nullptr) { return adopt(*new GAction(text, move(icon), move(callback), widget)); } - static Retained create(const StringView& text, const GShortcut& shortcut, Function callback, GWidget* widget = nullptr) + static NonnullRefPtr create(const StringView& text, const GShortcut& shortcut, Function callback, GWidget* widget = nullptr) { return adopt(*new GAction(text, shortcut, move(callback), widget)); } - static Retained create(const StringView& text, const GShortcut& shortcut, RetainPtr&& icon, Function callback, GWidget* widget = nullptr) + static NonnullRefPtr create(const StringView& text, const GShortcut& shortcut, RefPtr&& icon, Function callback, GWidget* widget = nullptr) { return adopt(*new GAction(text, shortcut, move(icon), move(callback), widget)); } @@ -78,8 +78,8 @@ public: private: GAction(const StringView& text, Function = nullptr, GWidget* = nullptr); GAction(const StringView& text, const GShortcut&, Function = nullptr, GWidget* = nullptr); - GAction(const StringView& text, const GShortcut&, RetainPtr&& icon, Function = nullptr, GWidget* = nullptr); - GAction(const StringView& text, RetainPtr&& icon, Function = nullptr, GWidget* = nullptr); + GAction(const StringView& text, const GShortcut&, RefPtr&& icon, Function = nullptr, GWidget* = nullptr); + GAction(const StringView& text, RefPtr&& icon, Function = nullptr, GWidget* = nullptr); GAction(const StringView& text, const StringView& custom_data = StringView(), Function = nullptr, GWidget* = nullptr); template @@ -89,7 +89,7 @@ private: String m_text; String m_custom_data; - RetainPtr m_icon; + RefPtr m_icon; GShortcut m_shortcut; bool m_enabled { true }; bool m_checkable { false }; diff --git a/LibGUI/GButton.cpp b/LibGUI/GButton.cpp index c9c4e119f2..364ab4677c 100644 --- a/LibGUI/GButton.cpp +++ b/LibGUI/GButton.cpp @@ -81,7 +81,7 @@ void GButton::set_action(GAction& action) set_checked(action.is_checked()); } -void GButton::set_icon(RetainPtr&& icon) +void GButton::set_icon(RefPtr&& icon) { if (m_icon == icon) return; diff --git a/LibGUI/GButton.h b/LibGUI/GButton.h index 2e12b8f3e1..ecb93aa024 100644 --- a/LibGUI/GButton.h +++ b/LibGUI/GButton.h @@ -15,7 +15,7 @@ public: explicit GButton(GWidget* parent); virtual ~GButton() override; - void set_icon(RetainPtr&&); + void set_icon(RefPtr&&); const GraphicsBitmap* icon() const { return m_icon.ptr(); } GraphicsBitmap* icon() { return m_icon.ptr(); } @@ -39,7 +39,7 @@ protected: virtual void paint_event(GPaintEvent&) override; private: - RetainPtr m_icon; + RefPtr m_icon; ButtonStyle m_button_style { ButtonStyle::Normal }; TextAlignment m_text_alignment { TextAlignment::Center }; WeakPtr m_action; diff --git a/LibGUI/GDirectoryModel.cpp b/LibGUI/GDirectoryModel.cpp index ee5ddcd39b..b4cc311632 100644 --- a/LibGUI/GDirectoryModel.cpp +++ b/LibGUI/GDirectoryModel.cpp @@ -11,11 +11,11 @@ #include #include -static CLockable>>& thumbnail_cache() +static CLockable>>& thumbnail_cache() { - static CLockable>>* s_map; + static CLockable>>* s_map; if (!s_map) - s_map = new CLockable>>(); + s_map = new CLockable>>(); return *s_map; } diff --git a/LibGUI/GDirectoryModel.h b/LibGUI/GDirectoryModel.h index 41ad4c4a18..05ad88cd28 100644 --- a/LibGUI/GDirectoryModel.h +++ b/LibGUI/GDirectoryModel.h @@ -8,7 +8,7 @@ class GDirectoryModel final : public GModel { friend int thumbnail_thread(void*); public: - static Retained create() { return adopt(*new GDirectoryModel); } + static NonnullRefPtr create() { return adopt(*new GDirectoryModel); } virtual ~GDirectoryModel() override; enum Column { @@ -42,7 +42,7 @@ public: uid_t uid { 0 }; uid_t gid { 0 }; ino_t inode { 0 }; - mutable RetainPtr thumbnail; + mutable RefPtr thumbnail; bool is_directory() const { return S_ISDIR(mode); } bool is_executable() const { return mode & S_IXUSR; } String full_path(const GDirectoryModel& model) const { return String::format("%s/%s", model.path().characters(), name.characters()); } diff --git a/LibGUI/GFilePicker.h b/LibGUI/GFilePicker.h index 12af7e3941..b091edb2e7 100644 --- a/LibGUI/GFilePicker.h +++ b/LibGUI/GFilePicker.h @@ -19,7 +19,7 @@ private: void clear_preview(); GTableView* m_view { nullptr }; - Retained m_model; + NonnullRefPtr m_model; FileSystemPath m_selected_file; GLabel* m_preview_image_label { nullptr }; diff --git a/LibGUI/GFileSystemModel.h b/LibGUI/GFileSystemModel.h index 5e7c7545e7..80b2f17ddd 100644 --- a/LibGUI/GFileSystemModel.h +++ b/LibGUI/GFileSystemModel.h @@ -12,7 +12,7 @@ public: FilesAndDirectories }; - static Retained create(const StringView& root_path = "/", Mode mode = Mode::FilesAndDirectories) + static NonnullRefPtr create(const StringView& root_path = "/", Mode mode = Mode::FilesAndDirectories) { return adopt(*new GFileSystemModel(root_path, mode)); } diff --git a/LibGUI/GFontDatabase.cpp b/LibGUI/GFontDatabase.cpp index b676c71016..6bd3887707 100644 --- a/LibGUI/GFontDatabase.cpp +++ b/LibGUI/GFontDatabase.cpp @@ -53,7 +53,7 @@ void GFontDatabase::for_each_fixed_width_font(Function } } -RetainPtr GFontDatabase::get_by_name(const StringView& name) +RefPtr GFontDatabase::get_by_name(const StringView& name) { auto it = m_name_to_metadata.find(name); if (it == m_name_to_metadata.end()) diff --git a/LibGUI/GFontDatabase.h b/LibGUI/GFontDatabase.h index 7b22bc4d10..46d4f26ace 100644 --- a/LibGUI/GFontDatabase.h +++ b/LibGUI/GFontDatabase.h @@ -16,7 +16,7 @@ class GFontDatabase { public: static GFontDatabase& the(); - RetainPtr get_by_name(const StringView&); + RefPtr get_by_name(const StringView&); void for_each_font(Function); void for_each_fixed_width_font(Function); diff --git a/LibGUI/GIcon.cpp b/LibGUI/GIcon.cpp index 17c34e8356..fa63b9d986 100644 --- a/LibGUI/GIcon.cpp +++ b/LibGUI/GIcon.cpp @@ -15,7 +15,7 @@ GIcon::GIcon(const GIcon& other) { } -GIcon::GIcon(RetainPtr&& bitmap) +GIcon::GIcon(RefPtr&& bitmap) : GIcon() { if (bitmap) { @@ -25,7 +25,7 @@ GIcon::GIcon(RetainPtr&& bitmap) } } -GIcon::GIcon(RetainPtr&& bitmap1, RetainPtr&& bitmap2) +GIcon::GIcon(RefPtr&& bitmap1, RefPtr&& bitmap2) : GIcon(move(bitmap1)) { if (bitmap2) { @@ -53,7 +53,7 @@ const GraphicsBitmap* GIconImpl::bitmap_for_size(int size) const return best_fit; } -void GIconImpl::set_bitmap_for_size(int size, RetainPtr&& bitmap) +void GIconImpl::set_bitmap_for_size(int size, RefPtr&& bitmap) { if (!bitmap) { m_bitmaps.remove(size); diff --git a/LibGUI/GIcon.h b/LibGUI/GIcon.h index a509f9db18..b8222ae7f3 100644 --- a/LibGUI/GIcon.h +++ b/LibGUI/GIcon.h @@ -5,22 +5,22 @@ class GIconImpl : public RefCounted { public: - static Retained create() { return adopt(*new GIconImpl); } + static NonnullRefPtr create() { return adopt(*new GIconImpl); } ~GIconImpl() {} const GraphicsBitmap* bitmap_for_size(int) const; - void set_bitmap_for_size(int, RetainPtr&&); + void set_bitmap_for_size(int, RefPtr&&); private: GIconImpl() {} - HashMap> m_bitmaps; + HashMap> m_bitmaps; }; class GIcon { public: GIcon(); - explicit GIcon(RetainPtr&&); - explicit GIcon(RetainPtr&&, RetainPtr&&); + explicit GIcon(RefPtr&&); + explicit GIcon(RefPtr&&, RefPtr&&); explicit GIcon(const GIconImpl&); GIcon(const GIcon&); ~GIcon() {} @@ -34,10 +34,10 @@ public: } const GraphicsBitmap* bitmap_for_size(int size) const { return m_impl->bitmap_for_size(size); } - void set_bitmap_for_size(int size, RetainPtr&& bitmap) { m_impl->set_bitmap_for_size(size, move(bitmap)); } + void set_bitmap_for_size(int size, RefPtr&& bitmap) { m_impl->set_bitmap_for_size(size, move(bitmap)); } const GIconImpl& impl() const { return *m_impl; } private: - Retained m_impl; + NonnullRefPtr m_impl; }; diff --git a/LibGUI/GLabel.cpp b/LibGUI/GLabel.cpp index abab0ac09a..cc1ac3e4a3 100644 --- a/LibGUI/GLabel.cpp +++ b/LibGUI/GLabel.cpp @@ -17,7 +17,7 @@ GLabel::~GLabel() { } -void GLabel::set_icon(RetainPtr&& icon) +void GLabel::set_icon(RefPtr&& icon) { m_icon = move(icon); } diff --git a/LibGUI/GLabel.h b/LibGUI/GLabel.h index 406595756b..dffd0b70bd 100644 --- a/LibGUI/GLabel.h +++ b/LibGUI/GLabel.h @@ -14,7 +14,7 @@ public: String text() const { return m_text; } void set_text(const StringView&); - void set_icon(RetainPtr&&); + void set_icon(RefPtr&&); const GraphicsBitmap* icon() const { return m_icon.ptr(); } GraphicsBitmap* icon() { return m_icon.ptr(); } @@ -32,7 +32,7 @@ private: virtual void paint_event(GPaintEvent&) override; String m_text; - RetainPtr m_icon; + RefPtr m_icon; TextAlignment m_text_alignment { TextAlignment::Center }; bool m_should_stretch_icon { false }; }; diff --git a/LibGUI/GMenu.cpp b/LibGUI/GMenu.cpp index cb5902adba..048ac38e67 100644 --- a/LibGUI/GMenu.cpp +++ b/LibGUI/GMenu.cpp @@ -31,7 +31,7 @@ GMenu::~GMenu() unrealize_menu(); } -void GMenu::add_action(Retained action) +void GMenu::add_action(NonnullRefPtr action) { m_items.append(make(m_menu_id, move(action))); #ifdef GMENU_DEBUG diff --git a/LibGUI/GMenu.h b/LibGUI/GMenu.h index 61b11c0692..37680f6d6b 100644 --- a/LibGUI/GMenu.h +++ b/LibGUI/GMenu.h @@ -18,7 +18,7 @@ public: GAction* action_at(int); - void add_action(Retained); + void add_action(NonnullRefPtr); void add_separator(); void popup(const Point& screen_position); diff --git a/LibGUI/GMenuItem.cpp b/LibGUI/GMenuItem.cpp index cfd38e778d..c07333c514 100644 --- a/LibGUI/GMenuItem.cpp +++ b/LibGUI/GMenuItem.cpp @@ -9,7 +9,7 @@ GMenuItem::GMenuItem(unsigned menu_id, Type type) { } -GMenuItem::GMenuItem(unsigned menu_id, Retained&& action) +GMenuItem::GMenuItem(unsigned menu_id, NonnullRefPtr&& action) : m_type(Action) , m_menu_id(menu_id) , m_action(move(action)) diff --git a/LibGUI/GMenuItem.h b/LibGUI/GMenuItem.h index 61ec355179..092b2c9fe0 100644 --- a/LibGUI/GMenuItem.h +++ b/LibGUI/GMenuItem.h @@ -15,7 +15,7 @@ public: }; GMenuItem(unsigned menu_id, Type); - GMenuItem(unsigned menu_id, Retained&&); + GMenuItem(unsigned menu_id, NonnullRefPtr&&); ~GMenuItem(); Type type() const { return m_type; } @@ -45,5 +45,5 @@ private: bool m_enabled { true }; bool m_checkable { false }; bool m_checked { false }; - RetainPtr m_action; + RefPtr m_action; }; diff --git a/LibGUI/GMessageBox.cpp b/LibGUI/GMessageBox.cpp index c628997069..33fa96b3a5 100644 --- a/LibGUI/GMessageBox.cpp +++ b/LibGUI/GMessageBox.cpp @@ -23,7 +23,7 @@ GMessageBox::~GMessageBox() { } -RetainPtr GMessageBox::icon() const +RefPtr GMessageBox::icon() const { switch (m_type) { case Type::Information: diff --git a/LibGUI/GMessageBox.h b/LibGUI/GMessageBox.h index e05e0d2e06..3b7a0f9e19 100644 --- a/LibGUI/GMessageBox.h +++ b/LibGUI/GMessageBox.h @@ -20,7 +20,7 @@ public: private: void build(); - RetainPtr icon() const; + RefPtr icon() const; String m_text; Type m_type { Type::None }; diff --git a/LibGUI/GRadioButton.cpp b/LibGUI/GRadioButton.cpp index 59cab6d904..377b3000ae 100644 --- a/LibGUI/GRadioButton.cpp +++ b/LibGUI/GRadioButton.cpp @@ -2,10 +2,10 @@ #include #include -static RetainPtr s_unfilled_circle_bitmap; -static RetainPtr s_filled_circle_bitmap; -static RetainPtr s_changing_filled_circle_bitmap; -static RetainPtr s_changing_unfilled_circle_bitmap; +static RefPtr s_unfilled_circle_bitmap; +static RefPtr s_filled_circle_bitmap; +static RefPtr s_changing_filled_circle_bitmap; +static RefPtr s_changing_unfilled_circle_bitmap; GRadioButton::GRadioButton(const StringView& text, GWidget* parent) : GAbstractButton(text, parent) diff --git a/LibGUI/GResizeCorner.h b/LibGUI/GResizeCorner.h index 2d6ae0c670..ac73703879 100644 --- a/LibGUI/GResizeCorner.h +++ b/LibGUI/GResizeCorner.h @@ -14,5 +14,5 @@ protected: virtual void leave_event(CEvent&) override; private: - RetainPtr m_bitmap; + RefPtr m_bitmap; }; diff --git a/LibGUI/GSortingProxyModel.cpp b/LibGUI/GSortingProxyModel.cpp index 7897503ffd..5bf379695b 100644 --- a/LibGUI/GSortingProxyModel.cpp +++ b/LibGUI/GSortingProxyModel.cpp @@ -3,7 +3,7 @@ #include #include -GSortingProxyModel::GSortingProxyModel(Retained&& target) +GSortingProxyModel::GSortingProxyModel(NonnullRefPtr&& target) : m_target(move(target)) , m_key_column(-1) { diff --git a/LibGUI/GSortingProxyModel.h b/LibGUI/GSortingProxyModel.h index 334878bcc5..d9f64a1ac1 100644 --- a/LibGUI/GSortingProxyModel.h +++ b/LibGUI/GSortingProxyModel.h @@ -4,7 +4,7 @@ class GSortingProxyModel final : public GModel { public: - static Retained create(Retained&& model) { return adopt(*new GSortingProxyModel(move(model))); } + static NonnullRefPtr create(NonnullRefPtr&& model) { return adopt(*new GSortingProxyModel(move(model))); } virtual ~GSortingProxyModel() override; virtual int row_count(const GModelIndex& = GModelIndex()) const override; @@ -22,14 +22,14 @@ public: GModelIndex map_to_target(const GModelIndex&) const; private: - explicit GSortingProxyModel(Retained&&); + explicit GSortingProxyModel(NonnullRefPtr&&); GModel& target() { return *m_target; } const GModel& target() const { return *m_target; } void resort(); - Retained m_target; + NonnullRefPtr m_target; Vector m_row_mappings; int m_key_column { -1 }; GSortOrder m_sort_order { GSortOrder::Ascending }; diff --git a/LibGUI/GTableView.h b/LibGUI/GTableView.h index 9db2e68eaa..3f63f94aab 100644 --- a/LibGUI/GTableView.h +++ b/LibGUI/GTableView.h @@ -60,7 +60,7 @@ private: int width { 0 }; bool has_initialized_width { false }; bool visibility { true }; - RetainPtr visibility_action; + RefPtr visibility_action; }; ColumnData& column_data(int column) const; diff --git a/LibGUI/GTextEditor.h b/LibGUI/GTextEditor.h index 124f82b8ca..fc7b387cac 100644 --- a/LibGUI/GTextEditor.h +++ b/LibGUI/GTextEditor.h @@ -221,11 +221,11 @@ private: int m_horizontal_content_padding { 2 }; GTextRange m_selection; OwnPtr m_context_menu; - RetainPtr m_undo_action; - RetainPtr m_redo_action; - RetainPtr m_cut_action; - RetainPtr m_copy_action; - RetainPtr m_paste_action; - RetainPtr m_delete_action; + RefPtr m_undo_action; + RefPtr m_redo_action; + RefPtr m_cut_action; + RefPtr m_copy_action; + RefPtr m_paste_action; + RefPtr m_delete_action; CElapsedTimer m_triple_click_timer; }; diff --git a/LibGUI/GToolBar.cpp b/LibGUI/GToolBar.cpp index 5aa6f469c2..72e95e2620 100644 --- a/LibGUI/GToolBar.cpp +++ b/LibGUI/GToolBar.cpp @@ -18,7 +18,7 @@ GToolBar::~GToolBar() { } -void GToolBar::add_action(Retained&& action) +void GToolBar::add_action(NonnullRefPtr&& action) { GAction* raw_action_ptr = action.ptr(); auto item = make(); diff --git a/LibGUI/GToolBar.h b/LibGUI/GToolBar.h index ec0c654bb0..375734e586 100644 --- a/LibGUI/GToolBar.h +++ b/LibGUI/GToolBar.h @@ -9,7 +9,7 @@ public: explicit GToolBar(GWidget* parent); virtual ~GToolBar() override; - void add_action(Retained&&); + void add_action(NonnullRefPtr&&); void add_separator(); bool has_frame() const { return m_has_frame; } @@ -27,7 +27,7 @@ private: Action }; Type type { Invalid }; - RetainPtr action; + RefPtr action; }; Vector> m_items; bool m_has_frame { true }; diff --git a/LibGUI/GTreeView.h b/LibGUI/GTreeView.h index 3cd62d8782..6fe0df6e69 100644 --- a/LibGUI/GTreeView.h +++ b/LibGUI/GTreeView.h @@ -37,6 +37,6 @@ private: mutable HashMap> m_view_metadata; - RetainPtr m_expand_bitmap; - RetainPtr m_collapse_bitmap; + RefPtr m_expand_bitmap; + RefPtr m_collapse_bitmap; }; diff --git a/LibGUI/GWidget.cpp b/LibGUI/GWidget.cpp index d0ac2161b0..814cda4c86 100644 --- a/LibGUI/GWidget.cpp +++ b/LibGUI/GWidget.cpp @@ -371,7 +371,7 @@ void GWidget::set_focus(bool focus) } } -void GWidget::set_font(RetainPtr&& font) +void GWidget::set_font(RefPtr&& font) { if (!font) m_font = Font::default_font(); diff --git a/LibGUI/GWidget.h b/LibGUI/GWidget.h index 36d2d025f5..ff23613c22 100644 --- a/LibGUI/GWidget.h +++ b/LibGUI/GWidget.h @@ -161,7 +161,7 @@ public: bool fill_with_background_color() const { return m_fill_with_background_color; } const Font& font() const { return *m_font; } - void set_font(RetainPtr&&); + void set_font(RefPtr&&); void set_global_cursor_tracking(bool); bool global_cursor_tracking() const; @@ -221,7 +221,7 @@ private: Rect m_relative_rect; Color m_background_color; Color m_foreground_color; - RetainPtr m_font; + RefPtr m_font; String m_tooltip; SizePolicy m_horizontal_size_policy { SizePolicy::Fill }; diff --git a/LibGUI/GWindow.cpp b/LibGUI/GWindow.cpp index 1f2e0b1682..b404480f87 100644 --- a/LibGUI/GWindow.cpp +++ b/LibGUI/GWindow.cpp @@ -593,7 +593,7 @@ void GWindow::flip(const Vector& dirty_rects) painter.blit(dirty_rect.location(), *m_front_bitmap, dirty_rect); } -Retained GWindow::create_backing_bitmap(const Size& size) +NonnullRefPtr GWindow::create_backing_bitmap(const Size& size) { ASSERT(GEventLoop::server_pid()); ASSERT(!size.is_empty()); diff --git a/LibGUI/GWindow.h b/LibGUI/GWindow.h index f83fded8a5..48cee884a2 100644 --- a/LibGUI/GWindow.h +++ b/LibGUI/GWindow.h @@ -135,12 +135,12 @@ private: void collect_keyboard_activation_targets(); - Retained create_backing_bitmap(const Size&); + NonnullRefPtr create_backing_bitmap(const Size&); void set_current_backing_bitmap(GraphicsBitmap&, bool flush_immediately = false); void flip(const Vector& dirty_rects); - RetainPtr m_front_bitmap; - RetainPtr m_back_bitmap; + RefPtr m_front_bitmap; + RefPtr m_back_bitmap; int m_window_id { 0 }; float m_opacity_when_windowless { 1.0f }; GWidget* m_main_widget { nullptr }; diff --git a/LibHTML/CSS/StyleDeclaration.h b/LibHTML/CSS/StyleDeclaration.h index 558e084925..b93769e193 100644 --- a/LibHTML/CSS/StyleDeclaration.h +++ b/LibHTML/CSS/StyleDeclaration.h @@ -13,5 +13,5 @@ public: public: String m_property_name; - RetainPtr m_value; + RefPtr m_value; }; diff --git a/LibHTML/DOM/Document.cpp b/LibHTML/DOM/Document.cpp index e1ca034b16..f642ad55c4 100644 --- a/LibHTML/DOM/Document.cpp +++ b/LibHTML/DOM/Document.cpp @@ -36,7 +36,7 @@ void Document::build_layout_tree() create_layout_tree_for_node(*this); } -RetainPtr Document::create_layout_node() +RefPtr Document::create_layout_node() { return adopt(*new LayoutDocument(*this)); } diff --git a/LibHTML/DOM/Document.h b/LibHTML/DOM/Document.h index 2b2f697f51..86846cfeb8 100644 --- a/LibHTML/DOM/Document.h +++ b/LibHTML/DOM/Document.h @@ -10,7 +10,7 @@ public: Document(); virtual ~Document() override; - virtual RetainPtr create_layout_node() override; + virtual RefPtr create_layout_node() override; void build_layout_tree(); diff --git a/LibHTML/DOM/Element.cpp b/LibHTML/DOM/Element.cpp index d6128cc9f2..e291fc3dd0 100644 --- a/LibHTML/DOM/Element.cpp +++ b/LibHTML/DOM/Element.cpp @@ -50,7 +50,7 @@ void Element::set_attributes(Vector&& attributes) m_attributes = move(attributes); } -RetainPtr Element::create_layout_node() +RefPtr Element::create_layout_node() { if (m_tag_name == "html") return adopt(*new LayoutBlock(*this)); diff --git a/LibHTML/DOM/Element.h b/LibHTML/DOM/Element.h index 416e59e424..1331d20c7e 100644 --- a/LibHTML/DOM/Element.h +++ b/LibHTML/DOM/Element.h @@ -40,7 +40,7 @@ public: callback(attribute.name(), attribute.value()); } - virtual RetainPtr create_layout_node() override; + virtual RefPtr create_layout_node() override; private: Attribute* find_attribute(const String& name); diff --git a/LibHTML/DOM/Node.cpp b/LibHTML/DOM/Node.cpp index c528dc2543..cdf160797e 100644 --- a/LibHTML/DOM/Node.cpp +++ b/LibHTML/DOM/Node.cpp @@ -23,12 +23,12 @@ void Node::deref() delete this; } -RetainPtr Node::create_layout_node() +RefPtr Node::create_layout_node() { return nullptr; } -void Node::set_layout_node(Retained layout_node) +void Node::set_layout_node(NonnullRefPtr layout_node) { m_layout_node = move(layout_node); } diff --git a/LibHTML/DOM/Node.h b/LibHTML/DOM/Node.h index a021225f9e..50fede6403 100644 --- a/LibHTML/DOM/Node.h +++ b/LibHTML/DOM/Node.h @@ -41,12 +41,12 @@ public: void set_next_sibling(Node* node) { m_next_sibling = node; } void set_previous_sibling(Node* node) { m_previous_sibling = node; } - virtual RetainPtr create_layout_node(); + virtual RefPtr create_layout_node(); const LayoutNode* layout_node() const { return m_layout_node; } LayoutNode* layout_node() { return m_layout_node; } - void set_layout_node(Retained); + void set_layout_node(NonnullRefPtr); protected: explicit Node(NodeType); @@ -56,5 +56,5 @@ protected: ParentNode* m_parent_node { nullptr }; Node* m_next_sibling { nullptr }; Node* m_previous_sibling { nullptr }; - RetainPtr m_layout_node; + RefPtr m_layout_node; }; diff --git a/LibHTML/DOM/ParentNode.cpp b/LibHTML/DOM/ParentNode.cpp index 7eb2a950c8..278e7a4c07 100644 --- a/LibHTML/DOM/ParentNode.cpp +++ b/LibHTML/DOM/ParentNode.cpp @@ -1,6 +1,6 @@ #include -void ParentNode::append_child(Retained node) +void ParentNode::append_child(NonnullRefPtr node) { if (m_last_child) m_last_child->set_next_sibling(node.ptr()); diff --git a/LibHTML/DOM/ParentNode.h b/LibHTML/DOM/ParentNode.h index 9bdc1e3668..8bcd59adda 100644 --- a/LibHTML/DOM/ParentNode.h +++ b/LibHTML/DOM/ParentNode.h @@ -4,7 +4,7 @@ class ParentNode : public Node { public: - void append_child(Retained); + void append_child(NonnullRefPtr); Node* first_child() { return m_first_child; } Node* last_child() { return m_last_child; } diff --git a/LibHTML/DOM/Text.cpp b/LibHTML/DOM/Text.cpp index 1f13e37092..8bb807270c 100644 --- a/LibHTML/DOM/Text.cpp +++ b/LibHTML/DOM/Text.cpp @@ -11,7 +11,7 @@ Text::~Text() { } -RetainPtr Text::create_layout_node() +RefPtr Text::create_layout_node() { return adopt(*new LayoutText(*this)); } diff --git a/LibHTML/DOM/Text.h b/LibHTML/DOM/Text.h index 37742b8063..e7ce724026 100644 --- a/LibHTML/DOM/Text.h +++ b/LibHTML/DOM/Text.h @@ -10,7 +10,7 @@ public: const String& data() const { return m_data; } - virtual RetainPtr create_layout_node() override; + virtual RefPtr create_layout_node() override; private: String m_data; diff --git a/LibHTML/Frame.h b/LibHTML/Frame.h index 3007a02fbf..9fd4467dc0 100644 --- a/LibHTML/Frame.h +++ b/LibHTML/Frame.h @@ -16,6 +16,6 @@ public: void layout(); private: - RetainPtr m_document; + RefPtr m_document; Size m_size; }; diff --git a/LibHTML/Layout/LayoutNode.cpp b/LibHTML/Layout/LayoutNode.cpp index e6d858868a..6e36a971ee 100644 --- a/LibHTML/Layout/LayoutNode.cpp +++ b/LibHTML/Layout/LayoutNode.cpp @@ -22,7 +22,7 @@ void LayoutNode::deref() delete this; } -void LayoutNode::append_child(Retained node) +void LayoutNode::append_child(NonnullRefPtr node) { if (m_last_child) m_last_child->set_next_sibling(node.ptr()); diff --git a/LibHTML/Layout/LayoutNode.h b/LibHTML/Layout/LayoutNode.h index 3aa31e8f2a..75c21a176d 100644 --- a/LibHTML/Layout/LayoutNode.h +++ b/LibHTML/Layout/LayoutNode.h @@ -38,7 +38,7 @@ public: bool has_children() const { return m_first_child; } - void append_child(Retained); + void append_child(NonnullRefPtr); void set_next_sibling(LayoutNode* node) { m_next_sibling = node; } void set_previous_sibling(LayoutNode* node) { m_previous_sibling = node; } diff --git a/LibHTML/Parser/Parser.cpp b/LibHTML/Parser/Parser.cpp index db16fe28b5..63f1ffb45b 100644 --- a/LibHTML/Parser/Parser.cpp +++ b/LibHTML/Parser/Parser.cpp @@ -4,7 +4,7 @@ #include #include -static Retained create_element(const String& tag_name) +static NonnullRefPtr create_element(const String& tag_name) { return adopt(*new Element(tag_name)); } @@ -32,9 +32,9 @@ static bool is_self_closing_tag(const String& tag_name) || tag_name == "wbr"; } -Retained parse(const String& html) +NonnullRefPtr parse(const String& html) { - Vector> node_stack; + Vector> node_stack; auto doc = adopt(*new Document); node_stack.append(doc); diff --git a/LibHTML/Parser/Parser.h b/LibHTML/Parser/Parser.h index 453f9833fa..577ebf5f69 100644 --- a/LibHTML/Parser/Parser.h +++ b/LibHTML/Parser/Parser.h @@ -3,5 +3,5 @@ #include #include -Retained parse(const String& html); +NonnullRefPtr parse(const String& html); diff --git a/Servers/WindowServer/WSButton.cpp b/Servers/WindowServer/WSButton.cpp index f4dfb9f5da..10b635fb68 100644 --- a/Servers/WindowServer/WSButton.cpp +++ b/Servers/WindowServer/WSButton.cpp @@ -5,7 +5,7 @@ #include #include -WSButton::WSButton(WSWindowFrame& frame, Retained&& bitmap, Function&& on_click_handler) +WSButton::WSButton(WSWindowFrame& frame, NonnullRefPtr&& bitmap, Function&& on_click_handler) : on_click(move(on_click_handler)) , m_frame(frame) , m_bitmap(move(bitmap)) diff --git a/Servers/WindowServer/WSButton.h b/Servers/WindowServer/WSButton.h index 780e55aaa3..b2f0147ce1 100644 --- a/Servers/WindowServer/WSButton.h +++ b/Servers/WindowServer/WSButton.h @@ -12,7 +12,7 @@ class WSWindowFrame; class WSButton : public Weakable { public: - WSButton(WSWindowFrame&, Retained&&, Function&& on_click_handler); + WSButton(WSWindowFrame&, NonnullRefPtr&&, Function&& on_click_handler); ~WSButton(); Rect relative_rect() const { return m_relative_rect; } @@ -34,7 +34,7 @@ public: private: WSWindowFrame& m_frame; Rect m_relative_rect; - Retained m_bitmap; + NonnullRefPtr m_bitmap; bool m_pressed { false }; bool m_visible { true }; bool m_hovered { false }; diff --git a/Servers/WindowServer/WSClientConnection.cpp b/Servers/WindowServer/WSClientConnection.cpp index dd3efeedd3..7b326a14e4 100644 --- a/Servers/WindowServer/WSClientConnection.cpp +++ b/Servers/WindowServer/WSClientConnection.cpp @@ -483,7 +483,7 @@ void WSClientConnection::handle_request(const WSAPIGetClipboardContentsRequest&) // FIXME: Optimize case where an app is copy/pasting within itself. // We can just reuse the SharedBuffer then, since it will have the same peer PID. // It would be even nicer if a SharedBuffer could have an arbitrary number of clients.. - RetainPtr shared_buffer = SharedBuffer::create(m_pid, WSClipboard::the().size()); + RefPtr shared_buffer = SharedBuffer::create(m_pid, WSClipboard::the().size()); ASSERT(shared_buffer); memcpy(shared_buffer->data(), WSClipboard::the().data(), WSClipboard::the().size()); shared_buffer->seal(); diff --git a/Servers/WindowServer/WSClientConnection.h b/Servers/WindowServer/WSClientConnection.h index 1313295799..7032a5e186 100644 --- a/Servers/WindowServer/WSClientConnection.h +++ b/Servers/WindowServer/WSClientConnection.h @@ -98,7 +98,7 @@ private: int m_next_menu_id { 20000 }; int m_next_window_id { 1982 }; - RetainPtr m_last_sent_clipboard_content; + RefPtr m_last_sent_clipboard_content; }; template diff --git a/Servers/WindowServer/WSClipboard.cpp b/Servers/WindowServer/WSClipboard.cpp index 6b4dc8e9d4..113a3dd692 100644 --- a/Servers/WindowServer/WSClipboard.cpp +++ b/Servers/WindowServer/WSClipboard.cpp @@ -36,7 +36,7 @@ void WSClipboard::clear() m_contents_size = 0; } -void WSClipboard::set_data(Retained&& data, int contents_size) +void WSClipboard::set_data(NonnullRefPtr&& data, int contents_size) { dbgprintf("WSClipboard::set_data <- %p (%u bytes)\n", data->data(), contents_size); m_shared_buffer = move(data); diff --git a/Servers/WindowServer/WSClipboard.h b/Servers/WindowServer/WSClipboard.h index 7b12598c3b..1f53137ba5 100644 --- a/Servers/WindowServer/WSClipboard.h +++ b/Servers/WindowServer/WSClipboard.h @@ -17,11 +17,11 @@ public: int size() const; void clear(); - void set_data(Retained&&, int contents_size); + void set_data(NonnullRefPtr&&, int contents_size); private: WSClipboard(); - RetainPtr m_shared_buffer; + RefPtr m_shared_buffer; int m_contents_size { 0 }; }; diff --git a/Servers/WindowServer/WSCompositor.cpp b/Servers/WindowServer/WSCompositor.cpp index e21beaf3ff..647a44f5b4 100644 --- a/Servers/WindowServer/WSCompositor.cpp +++ b/Servers/WindowServer/WSCompositor.cpp @@ -117,7 +117,7 @@ void WSCompositor::compose() return IterationDecision::Continue; PainterStateSaver saver(*m_back_painter); m_back_painter->add_clip_rect(window.frame().rect()); - RetainPtr backing_store = window.backing_store(); + RefPtr backing_store = window.backing_store(); for (auto& dirty_rect : dirty_rects.rects()) { if (wm.any_opaque_window_above_this_one_contains_rect(window, dirty_rect)) continue; @@ -226,7 +226,7 @@ bool WSCompositor::set_wallpaper(const String& path, Function&& call { struct Context { String path; - RetainPtr bitmap; + RefPtr bitmap; Function callback; }; auto context = make(); @@ -254,7 +254,7 @@ bool WSCompositor::set_wallpaper(const String& path, Function&& call return true; } -void WSCompositor::finish_setting_wallpaper(const String& path, Retained&& bitmap) +void WSCompositor::finish_setting_wallpaper(const String& path, NonnullRefPtr&& bitmap) { m_wallpaper_path = path; m_wallpaper = move(bitmap); diff --git a/Servers/WindowServer/WSCompositor.h b/Servers/WindowServer/WSCompositor.h index 8f9c15f6da..6002bfd4ca 100644 --- a/Servers/WindowServer/WSCompositor.h +++ b/Servers/WindowServer/WSCompositor.h @@ -43,7 +43,7 @@ private: void draw_cursor(); void draw_geometry_label(); void draw_menubar(); - void finish_setting_wallpaper(const String& path, Retained&&); + void finish_setting_wallpaper(const String& path, NonnullRefPtr&&); unsigned m_compose_count { 0 }; unsigned m_flush_count { 0 }; @@ -52,8 +52,8 @@ private: bool m_flash_flush { false }; bool m_buffers_are_flipped { false }; - RetainPtr m_front_bitmap; - RetainPtr m_back_bitmap; + RefPtr m_front_bitmap; + RefPtr m_back_bitmap; OwnPtr m_back_painter; OwnPtr m_front_painter; @@ -64,5 +64,5 @@ private: String m_wallpaper_path; WallpaperMode m_wallpaper_mode { WallpaperMode::Unchecked }; - RetainPtr m_wallpaper; + RefPtr m_wallpaper; }; diff --git a/Servers/WindowServer/WSCursor.cpp b/Servers/WindowServer/WSCursor.cpp index 1923908513..54f8bc8271 100644 --- a/Servers/WindowServer/WSCursor.cpp +++ b/Servers/WindowServer/WSCursor.cpp @@ -1,7 +1,7 @@ #include #include -WSCursor::WSCursor(Retained&& bitmap, const Point& hotspot) +WSCursor::WSCursor(NonnullRefPtr&& bitmap, const Point& hotspot) : m_bitmap(move(bitmap)) , m_hotspot(hotspot) { @@ -11,17 +11,17 @@ WSCursor::~WSCursor() { } -Retained WSCursor::create(Retained&& bitmap) +NonnullRefPtr WSCursor::create(NonnullRefPtr&& bitmap) { return adopt(*new WSCursor(move(bitmap), bitmap->rect().center())); } -Retained WSCursor::create(Retained&& bitmap, const Point& hotspot) +NonnullRefPtr WSCursor::create(NonnullRefPtr&& bitmap, const Point& hotspot) { return adopt(*new WSCursor(move(bitmap), hotspot)); } -RetainPtr WSCursor::create(WSStandardCursor standard_cursor) +RefPtr WSCursor::create(WSStandardCursor standard_cursor) { switch (standard_cursor) { case WSStandardCursor::None: diff --git a/Servers/WindowServer/WSCursor.h b/Servers/WindowServer/WSCursor.h index e8437c808a..76640da4a7 100644 --- a/Servers/WindowServer/WSCursor.h +++ b/Servers/WindowServer/WSCursor.h @@ -14,9 +14,9 @@ enum class WSStandardCursor { class WSCursor : public RefCounted { public: - static Retained create(Retained&&, const Point& hotspot); - static Retained create(Retained&&); - static RetainPtr create(WSStandardCursor); + static NonnullRefPtr create(NonnullRefPtr&&, const Point& hotspot); + static NonnullRefPtr create(NonnullRefPtr&&); + static RefPtr create(WSStandardCursor); ~WSCursor(); Point hotspot() const { return m_hotspot; } @@ -26,8 +26,8 @@ public: Size size() const { return m_bitmap->size(); } private: - WSCursor(Retained&&, const Point&); + WSCursor(NonnullRefPtr&&, const Point&); - RetainPtr m_bitmap; + RefPtr m_bitmap; Point m_hotspot; }; diff --git a/Servers/WindowServer/WSWindow.h b/Servers/WindowServer/WSWindow.h index 46fbee3132..8f55adb23c 100644 --- a/Servers/WindowServer/WSWindow.h +++ b/Servers/WindowServer/WSWindow.h @@ -102,7 +102,7 @@ public: virtual void event(CEvent&) override; GraphicsBitmap* backing_store() { return m_backing_store.ptr(); } - void set_backing_store(RetainPtr&& backing_store) + void set_backing_store(RefPtr&& backing_store) { m_last_backing_store = move(m_backing_store); m_backing_store = move(backing_store); @@ -129,7 +129,7 @@ public: const GraphicsBitmap& icon() const { return *m_icon; } String icon_path() const { return m_icon_path; } - void set_icon(const String& path, Retained&& icon) + void set_icon(const String& path, NonnullRefPtr&& icon) { m_icon_path = path; m_icon = move(icon); @@ -137,7 +137,7 @@ public: void set_default_icon(); const WSCursor* override_cursor() const { return m_override_cursor.ptr(); } - void set_override_cursor(RetainPtr&& cursor) { m_override_cursor = move(cursor); } + void set_override_cursor(RefPtr&& cursor) { m_override_cursor = move(cursor); } void request_update(const Rect&); DisjointRectSet take_pending_paint_rects() { return move(m_pending_paint_rects); } @@ -166,15 +166,15 @@ private: bool m_maximized { false }; bool m_fullscreen { false }; bool m_show_titlebar { true }; - RetainPtr m_backing_store; - RetainPtr m_last_backing_store; + RefPtr m_backing_store; + RefPtr m_last_backing_store; int m_window_id { -1 }; float m_opacity { 1 }; Size m_size_increment; Size m_base_size; - Retained m_icon; + NonnullRefPtr m_icon; String m_icon_path; - RetainPtr m_override_cursor; + RefPtr m_override_cursor; WSWindowFrame m_frame; Color m_background_color { Color::LightGray }; unsigned m_wm_event_mask { 0 }; diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp index 541379ecfa..9129f4c226 100644 --- a/Servers/WindowServer/WSWindowManager.cpp +++ b/Servers/WindowServer/WSWindowManager.cpp @@ -109,7 +109,7 @@ WSWindowManager::~WSWindowManager() { } -Retained WSWindowManager::get_cursor(const String& name, const Point& hotspot) +NonnullRefPtr WSWindowManager::get_cursor(const String& name, const Point& hotspot) { auto path = m_wm_config->read_entry("Cursor", name, "/res/cursors/arrow.png"); auto gb = GraphicsBitmap::load_from_file(path); @@ -118,7 +118,7 @@ Retained WSWindowManager::get_cursor(const String& name, const Point& return WSCursor::create(*GraphicsBitmap::load_from_file("/res/cursors/arrow.png")); } -Retained WSWindowManager::get_cursor(const String& name) +NonnullRefPtr WSWindowManager::get_cursor(const String& name) { auto path = m_wm_config->read_entry("Cursor", name, "/res/cursors/arrow.png"); auto gb = GraphicsBitmap::load_from_file(path); diff --git a/Servers/WindowServer/WSWindowManager.h b/Servers/WindowServer/WSWindowManager.h index d73fffb971..2dad80a4df 100644 --- a/Servers/WindowServer/WSWindowManager.h +++ b/Servers/WindowServer/WSWindowManager.h @@ -52,7 +52,7 @@ public: WSWindowManager(); virtual ~WSWindowManager() override; - RetainPtr wm_config() const { return m_wm_config; } + RefPtr wm_config() const { return m_wm_config; } void reload_config(bool); void add_window(WSWindow&); @@ -142,8 +142,8 @@ public: } private: - Retained get_cursor(const String& name); - Retained get_cursor(const String& name, const Point& hotspot); + NonnullRefPtr get_cursor(const String& name); + NonnullRefPtr get_cursor(const String& name, const Point& hotspot); void process_mouse_event(WSMouseEvent&, WSWindow*& hovered_window); void process_event_for_doubleclick(WSWindow& window, WSMouseEvent& event); @@ -175,14 +175,14 @@ private: void tell_wm_listener_about_window_rect(WSWindow& listener, WSWindow&); void pick_new_active_window(); - RetainPtr m_arrow_cursor; - RetainPtr m_resize_horizontally_cursor; - RetainPtr m_resize_vertically_cursor; - RetainPtr m_resize_diagonally_tlbr_cursor; - RetainPtr m_resize_diagonally_bltr_cursor; - RetainPtr m_i_beam_cursor; - RetainPtr m_disallowed_cursor; - RetainPtr m_move_cursor; + RefPtr m_arrow_cursor; + RefPtr m_resize_horizontally_cursor; + RefPtr m_resize_vertically_cursor; + RefPtr m_resize_diagonally_tlbr_cursor; + RefPtr m_resize_diagonally_bltr_cursor; + RefPtr m_i_beam_cursor; + RefPtr m_disallowed_cursor; + RefPtr m_move_cursor; Color m_background_color; Color m_active_window_border_color; @@ -245,7 +245,7 @@ private: WeakPtr m_cursor_tracking_button; WeakPtr m_hovered_button; - RetainPtr m_wm_config; + RefPtr m_wm_config; }; template diff --git a/SharedGraphics/CharacterBitmap.cpp b/SharedGraphics/CharacterBitmap.cpp index ecfc550d19..3a3805f3ac 100644 --- a/SharedGraphics/CharacterBitmap.cpp +++ b/SharedGraphics/CharacterBitmap.cpp @@ -10,7 +10,7 @@ CharacterBitmap::~CharacterBitmap() { } -Retained CharacterBitmap::create_from_ascii(const char* asciiData, unsigned width, unsigned height) +NonnullRefPtr CharacterBitmap::create_from_ascii(const char* asciiData, unsigned width, unsigned height) { return adopt(*new CharacterBitmap(asciiData, width, height)); } diff --git a/SharedGraphics/CharacterBitmap.h b/SharedGraphics/CharacterBitmap.h index bc8edac764..d7b90f97d7 100644 --- a/SharedGraphics/CharacterBitmap.h +++ b/SharedGraphics/CharacterBitmap.h @@ -6,7 +6,7 @@ class CharacterBitmap : public RefCounted { public: - static Retained create_from_ascii(const char* asciiData, unsigned width, unsigned height); + static NonnullRefPtr create_from_ascii(const char* asciiData, unsigned width, unsigned height); ~CharacterBitmap(); bool bit_at(unsigned x, unsigned y) const { return m_bits[y * width() + x] == '#'; } diff --git a/SharedGraphics/Font.cpp b/SharedGraphics/Font.cpp index 47baaa7163..9f58f55d5c 100644 --- a/SharedGraphics/Font.cpp +++ b/SharedGraphics/Font.cpp @@ -53,7 +53,7 @@ Font& Font::default_bold_font() return *s_default_bold_font; } -RetainPtr Font::clone() const +RefPtr Font::clone() const { size_t bytes_per_glyph = sizeof(dword) * glyph_height(); // FIXME: This is leaked! @@ -93,7 +93,7 @@ Font::~Font() { } -RetainPtr Font::load_from_memory(const byte* data) +RefPtr Font::load_from_memory(const byte* data) { auto& header = *reinterpret_cast(data); if (memcmp(header.magic, "!Fnt", 4)) { @@ -114,7 +114,7 @@ RetainPtr Font::load_from_memory(const byte* data) return adopt(*new Font(String(header.name), rows, widths, !header.is_variable_width, header.glyph_width, header.glyph_height)); } -RetainPtr Font::load_from_file(const StringView& path) +RefPtr Font::load_from_file(const StringView& path) { MappedFile mapped_file(path); if (!mapped_file.is_valid()) diff --git a/SharedGraphics/Font.h b/SharedGraphics/Font.h index f491ca1a6e..c182b38931 100644 --- a/SharedGraphics/Font.h +++ b/SharedGraphics/Font.h @@ -47,9 +47,9 @@ public: static Font& default_fixed_width_font(); - RetainPtr clone() const; + RefPtr clone() const; - static RetainPtr load_from_file(const StringView& path); + static RefPtr load_from_file(const StringView& path); bool write_to_file(const StringView& path); ~Font(); @@ -78,7 +78,7 @@ public: private: Font(const StringView& name, unsigned* rows, byte* widths, bool is_fixed_width, byte glyph_width, byte glyph_height); - static RetainPtr load_from_memory(const byte*); + static RefPtr load_from_memory(const byte*); String m_name; diff --git a/SharedGraphics/GraphicsBitmap.cpp b/SharedGraphics/GraphicsBitmap.cpp index 5d9b85b382..7b87555ee0 100644 --- a/SharedGraphics/GraphicsBitmap.cpp +++ b/SharedGraphics/GraphicsBitmap.cpp @@ -7,7 +7,7 @@ #include #include -Retained GraphicsBitmap::create(Format format, const Size& size) +NonnullRefPtr GraphicsBitmap::create(Format format, const Size& size) { return adopt(*new GraphicsBitmap(format, size)); } @@ -24,17 +24,17 @@ GraphicsBitmap::GraphicsBitmap(Format format, const Size& size) m_needs_munmap = true; } -Retained GraphicsBitmap::create_wrapper(Format format, const Size& size, RGBA32* data) +NonnullRefPtr GraphicsBitmap::create_wrapper(Format format, const Size& size, RGBA32* data) { return adopt(*new GraphicsBitmap(format, size, data)); } -RetainPtr GraphicsBitmap::load_from_file(const StringView& path) +RefPtr GraphicsBitmap::load_from_file(const StringView& path) { return load_png(path); } -RetainPtr GraphicsBitmap::load_from_file(Format format, const StringView& path, const Size& size) +RefPtr GraphicsBitmap::load_from_file(Format format, const StringView& path, const Size& size) { MappedFile mapped_file(path); if (!mapped_file.is_valid()) @@ -61,12 +61,12 @@ GraphicsBitmap::GraphicsBitmap(Format format, const Size& size, MappedFile&& map ASSERT(format != Format::Indexed8); } -Retained GraphicsBitmap::create_with_shared_buffer(Format format, Retained&& shared_buffer, const Size& size) +NonnullRefPtr GraphicsBitmap::create_with_shared_buffer(Format format, NonnullRefPtr&& shared_buffer, const Size& size) { return adopt(*new GraphicsBitmap(format, move(shared_buffer), size)); } -GraphicsBitmap::GraphicsBitmap(Format format, Retained&& shared_buffer, const Size& size) +GraphicsBitmap::GraphicsBitmap(Format format, NonnullRefPtr&& shared_buffer, const Size& size) : m_size(size) , m_data((RGBA32*)shared_buffer->data()) , m_pitch(round_up_to_power_of_two(size.width() * sizeof(RGBA32), 16)) diff --git a/SharedGraphics/GraphicsBitmap.h b/SharedGraphics/GraphicsBitmap.h index c011bb715e..bf859bdbca 100644 --- a/SharedGraphics/GraphicsBitmap.h +++ b/SharedGraphics/GraphicsBitmap.h @@ -19,11 +19,11 @@ public: Indexed8 }; - static Retained create(Format, const Size&); - static Retained create_wrapper(Format, const Size&, RGBA32*); - static RetainPtr load_from_file(const StringView& path); - static RetainPtr load_from_file(Format, const StringView& path, const Size&); - static Retained create_with_shared_buffer(Format, Retained&&, const Size&); + static NonnullRefPtr create(Format, const Size&); + static NonnullRefPtr create_wrapper(Format, const Size&, RGBA32*); + static RefPtr load_from_file(const StringView& path); + static RefPtr load_from_file(Format, const StringView& path, const Size&); + static NonnullRefPtr create_with_shared_buffer(Format, NonnullRefPtr&&, const Size&); ~GraphicsBitmap(); RGBA32* scanline(int y); @@ -81,7 +81,7 @@ private: GraphicsBitmap(Format, const Size&); GraphicsBitmap(Format, const Size&, RGBA32*); GraphicsBitmap(Format, const Size&, MappedFile&&); - GraphicsBitmap(Format, Retained&&, const Size&); + GraphicsBitmap(Format, NonnullRefPtr&&, const Size&); Size m_size; RGBA32* m_data { nullptr }; @@ -90,7 +90,7 @@ private: Format m_format { Format::Invalid }; bool m_needs_munmap { false }; MappedFile m_mapped_file; - RetainPtr m_shared_buffer; + RefPtr m_shared_buffer; }; inline RGBA32* GraphicsBitmap::scanline(int y) diff --git a/SharedGraphics/PNGLoader.cpp b/SharedGraphics/PNGLoader.cpp index 5f67149906..2560966b39 100644 --- a/SharedGraphics/PNGLoader.cpp +++ b/SharedGraphics/PNGLoader.cpp @@ -42,7 +42,7 @@ struct PNGLoadingContext { bool has_seen_zlib_header { false }; bool has_alpha() const { return color_type & 4; } Vector scanlines; - RetainPtr bitmap; + RefPtr bitmap; byte* decompression_buffer { nullptr }; int decompression_buffer_size { 0 }; Vector compressed_data; @@ -98,10 +98,10 @@ private: int m_size_remaining; }; -static RetainPtr load_png_impl(const byte*, int); +static RefPtr load_png_impl(const byte*, int); static bool process_chunk(Streamer&, PNGLoadingContext& context); -RetainPtr load_png(const StringView& path) +RefPtr load_png(const StringView& path) { MappedFile mapped_file(path); if (!mapped_file.is_valid()) @@ -302,7 +302,7 @@ template } } -static RetainPtr load_png_impl(const byte* data, int data_size) +static RefPtr load_png_impl(const byte* data, int data_size) { #ifdef PNG_STOPWATCH_DEBUG Stopwatch sw("load_png_impl: total"); diff --git a/SharedGraphics/PNGLoader.h b/SharedGraphics/PNGLoader.h index 7365977ce7..3fa06bd927 100644 --- a/SharedGraphics/PNGLoader.h +++ b/SharedGraphics/PNGLoader.h @@ -2,4 +2,4 @@ #include -RetainPtr load_png(const StringView& path); +RefPtr load_png(const StringView& path); diff --git a/SharedGraphics/Painter.h b/SharedGraphics/Painter.h index ac92a2fe34..94dd2c4eea 100644 --- a/SharedGraphics/Painter.h +++ b/SharedGraphics/Painter.h @@ -80,7 +80,7 @@ protected: const State& state() const { return m_state_stack.last(); } Rect m_clip_origin; - Retained m_target; + NonnullRefPtr m_target; Vector m_state_stack; };