From b91c49364df1683c7fe1191eb02b8d9c331874f6 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 23 Apr 2021 16:46:57 +0200 Subject: [PATCH] AK: Rename adopt() to adopt_ref() This makes it more symmetrical with adopt_own() (which is used to create a NonnullOwnPtr from the result of a naked new.) --- AK/ByteBuffer.h | 6 +- AK/MappedFile.cpp | 2 +- AK/NonnullRefPtr.h | 4 +- AK/StringImpl.cpp | 2 +- AK/TestSuite.h | 28 ++-- AK/Tests/TestIntrusiveList.cpp | 8 +- AK/Tests/TestNonnullRefPtr.cpp | 10 +- AK/Tests/TestRefPtr.cpp | 18 +-- AK/Tests/TestWeakPtr.cpp | 4 +- AK/WeakPtr.h | 2 +- AK/Weakable.h | 2 +- Documentation/SmartPointers.md | 4 +- Kernel/Devices/Device.h | 2 +- Kernel/Devices/HID/I8042Controller.cpp | 2 +- Kernel/Devices/HID/PS2KeyboardDevice.cpp | 2 +- Kernel/Devices/HID/PS2MouseDevice.cpp | 2 +- Kernel/Devices/HID/VMWareMouseDevice.cpp | 2 +- Kernel/FileSystem/AnonymousFile.h | 2 +- Kernel/FileSystem/Custody.h | 2 +- Kernel/FileSystem/DevFS.cpp | 10 +- Kernel/FileSystem/DevPtsFS.cpp | 6 +- Kernel/FileSystem/Ext2FileSystem.cpp | 4 +- Kernel/FileSystem/FIFO.cpp | 2 +- Kernel/FileSystem/FileDescription.cpp | 4 +- Kernel/FileSystem/InodeFile.h | 2 +- Kernel/FileSystem/InodeWatcher.cpp | 2 +- Kernel/FileSystem/Plan9FileSystem.cpp | 6 +- Kernel/FileSystem/ProcFS.cpp | 8 +- Kernel/FileSystem/ProcFS.h | 2 +- Kernel/FileSystem/TmpFS.cpp | 4 +- Kernel/Interrupts/InterruptManagement.cpp | 6 +- Kernel/KBuffer.h | 4 +- Kernel/Net/E1000NetworkAdapter.cpp | 2 +- Kernel/Net/IPv4Socket.cpp | 2 +- Kernel/Net/LocalSocket.cpp | 2 +- Kernel/Net/NE2000NetworkAdapter.cpp | 2 +- Kernel/Net/RTL8139NetworkAdapter.cpp | 2 +- Kernel/Net/TCPSocket.cpp | 2 +- Kernel/Net/UDPSocket.cpp | 2 +- Kernel/Process.cpp | 4 +- Kernel/ProcessGroup.cpp | 2 +- Kernel/Storage/AHCIController.cpp | 2 +- Kernel/Storage/AHCIPort.cpp | 4 +- Kernel/Storage/AHCIPortHandler.cpp | 2 +- Kernel/Storage/BMIDEChannel.cpp | 4 +- Kernel/Storage/IDEChannel.cpp | 4 +- Kernel/Storage/IDEController.cpp | 2 +- Kernel/Storage/PATADiskDevice.cpp | 2 +- Kernel/Storage/Partition/DiskPartition.cpp | 2 +- Kernel/Storage/RamdiskController.cpp | 2 +- Kernel/Storage/RamdiskDevice.cpp | 2 +- Kernel/Storage/SATADiskDevice.cpp | 2 +- Kernel/Syscalls/fork.cpp | 2 +- Kernel/Syscalls/futex.cpp | 2 +- Kernel/TTY/MasterPTY.cpp | 2 +- Kernel/TTY/PTYMultiplexer.cpp | 2 +- Kernel/Thread.cpp | 2 +- Kernel/Time/APICTimer.cpp | 2 +- Kernel/Time/HPETComparator.cpp | 2 +- Kernel/Time/PIT.cpp | 2 +- Kernel/Time/RTC.cpp | 2 +- Kernel/TimerQueue.cpp | 4 +- Kernel/VM/AnonymousVMObject.cpp | 12 +- Kernel/VM/ContiguousVMObject.cpp | 2 +- Kernel/VM/PageDirectory.h | 4 +- Kernel/VM/PhysicalPage.cpp | 2 +- Kernel/VM/PhysicalRegion.cpp | 2 +- Kernel/VM/PrivateInodeVMObject.cpp | 4 +- Kernel/VM/SharedInodeVMObject.cpp | 4 +- Kernel/VirtIO/VirtIO.cpp | 4 +- .../ClipboardHistoryModel.cpp | 2 +- .../Applications/Browser/ConsoleWidget.cpp | 2 +- .../Applications/Calendar/AddEventDialog.h | 2 +- .../FileManager/DirectoryView.cpp | 2 +- .../Applications/FontEditor/FontEditor.cpp | 2 +- Userland/Applications/FontEditor/UndoGlyph.h | 2 +- Userland/Applications/Help/ManualModel.h | 2 +- .../Applications/IRCClient/IRCChannel.cpp | 2 +- .../IRCClient/IRCChannelMemberListModel.h | 2 +- .../Applications/IRCClient/IRCLogBuffer.cpp | 6 +- Userland/Applications/IRCClient/IRCQuery.cpp | 2 +- .../IRCClient/IRCWindowListModel.h | 2 +- .../CharacterMapFileListModel.h | 2 +- Userland/Applications/PixelPaint/Image.cpp | 2 +- Userland/Applications/PixelPaint/Layer.cpp | 4 +- .../SoundPlayerWidgetAdvancedView.cpp | 2 +- Userland/Applications/SpaceAnalyzer/main.cpp | 2 +- .../Applications/Spreadsheet/HelpWindow.cpp | 2 +- .../Applications/Spreadsheet/HelpWindow.h | 2 +- .../Applications/Spreadsheet/Spreadsheet.cpp | 4 +- .../Spreadsheet/SpreadsheetModel.h | 2 +- .../SystemMonitor/DevicesModel.cpp | 2 +- .../Applications/SystemMonitor/ProcessModel.h | 2 +- .../SystemMonitor/ProcessStateWidget.cpp | 2 +- Userland/Applications/ThemeEditor/main.cpp | 2 +- Userland/Demos/WidgetGallery/GalleryModels.h | 4 +- .../DevTools/HackStudio/ClassViewWidget.cpp | 2 +- Userland/DevTools/HackStudio/CodeDocument.cpp | 4 +- .../HackStudio/Debugger/BacktraceModel.cpp | 2 +- .../HackStudio/Debugger/DisassemblyModel.h | 2 +- .../HackStudio/Debugger/RegistersModel.h | 4 +- .../HackStudio/Debugger/VariablesModel.cpp | 2 +- .../Dialogs/ProjectTemplatesModel.h | 2 +- .../DevTools/HackStudio/FindInFilesWidget.cpp | 2 +- .../DevTools/HackStudio/Git/GitFilesModel.cpp | 2 +- Userland/DevTools/HackStudio/Git/GitRepo.cpp | 4 +- .../HackStudio/LanguageServers/FileDB.cpp | 4 +- Userland/DevTools/HackStudio/Locator.cpp | 2 +- Userland/DevTools/HackStudio/ProjectFile.h | 2 +- .../DevTools/HackStudio/ProjectTemplate.cpp | 2 +- .../DevTools/HackStudio/WidgetTreeModel.h | 2 +- .../Inspector/RemoteObjectGraphModel.h | 2 +- .../Inspector/RemoteObjectPropertyModel.h | 2 +- Userland/DevTools/Profiler/DisassemblyModel.h | 2 +- .../DevTools/Profiler/IndividualSampleModel.h | 2 +- Userland/DevTools/Profiler/Profile.h | 2 +- Userland/DevTools/Profiler/ProfileModel.h | 2 +- Userland/DevTools/Profiler/SamplesModel.h | 2 +- Userland/Libraries/LibAudio/Buffer.h | 4 +- Userland/Libraries/LibAudio/Loader.h | 4 +- .../Libraries/LibCore/AnonymousBuffer.cpp | 2 +- Userland/Libraries/LibCore/ConfigFile.cpp | 8 +- Userland/Libraries/LibCore/EventLoop.cpp | 2 +- Userland/Libraries/LibCore/FileWatcher.cpp | 2 +- Userland/Libraries/LibCore/Object.h | 2 +- Userland/Libraries/LibCore/Timer.h | 4 +- Userland/Libraries/LibCpp/Parser.h | 6 +- Userland/Libraries/LibDesktop/AppFile.cpp | 2 +- Userland/Libraries/LibDesktop/Launcher.cpp | 2 +- Userland/Libraries/LibELF/DynamicLoader.cpp | 2 +- Userland/Libraries/LibELF/DynamicObject.cpp | 2 +- Userland/Libraries/LibGUI/Action.cpp | 16 +- .../Libraries/LibGUI/AutocompleteProvider.cpp | 2 +- Userland/Libraries/LibGUI/DisplayLink.cpp | 2 +- Userland/Libraries/LibGUI/FileSystemModel.h | 2 +- .../Libraries/LibGUI/FilteringProxyModel.h | 2 +- Userland/Libraries/LibGUI/FontPicker.cpp | 2 +- Userland/Libraries/LibGUI/Icon.h | 2 +- Userland/Libraries/LibGUI/ItemListModel.h | 4 +- Userland/Libraries/LibGUI/JsonArrayModel.h | 2 +- .../LibGUI/RunningProcessesModel.cpp | 2 +- Userland/Libraries/LibGUI/SortingProxyModel.h | 2 +- Userland/Libraries/LibGUI/TextDocument.cpp | 2 +- Userland/Libraries/LibGemini/Document.cpp | 2 +- Userland/Libraries/LibGemini/GeminiResponse.h | 2 +- Userland/Libraries/LibGfx/Bitmap.cpp | 8 +- Userland/Libraries/LibGfx/BitmapFont.cpp | 6 +- Userland/Libraries/LibGfx/CharacterBitmap.cpp | 2 +- Userland/Libraries/LibGfx/FontDatabase.cpp | 2 +- Userland/Libraries/LibGfx/ImageDecoder.h | 4 +- Userland/Libraries/LibGfx/Palette.cpp | 4 +- Userland/Libraries/LibGfx/Path.h | 2 +- Userland/Libraries/LibGfx/Typeface.cpp | 2 +- Userland/Libraries/LibHTTP/HttpResponse.h | 2 +- Userland/Libraries/LibJS/AST.h | 2 +- Userland/Libraries/LibJS/Heap/Handle.h | 2 +- Userland/Libraries/LibJS/Parser.cpp | 2 +- Userland/Libraries/LibJS/Runtime/VM.cpp | 2 +- Userland/Libraries/LibPCIDB/Database.cpp | 2 +- Userland/Libraries/LibProtocol/Download.h | 2 +- Userland/Libraries/LibSQL/AST.h | 2 +- Userland/Libraries/LibTTF/Font.cpp | 2 +- .../Libraries/LibThread/BackgroundAction.h | 2 +- Userland/Libraries/LibWeb/CSS/CSSImportRule.h | 2 +- .../LibWeb/CSS/CSSStyleDeclaration.h | 4 +- Userland/Libraries/LibWeb/CSS/CSSStyleRule.h | 2 +- Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h | 2 +- Userland/Libraries/LibWeb/CSS/Screen.h | 2 +- .../Libraries/LibWeb/CSS/StyleProperties.cpp | 2 +- .../Libraries/LibWeb/CSS/StyleProperties.h | 2 +- .../Libraries/LibWeb/CSS/StyleSheetList.h | 2 +- Userland/Libraries/LibWeb/CSS/StyleValue.h | 14 +- .../CodeGenerators/WrapperGenerator.cpp | 4 +- Userland/Libraries/LibWeb/DOM/DOMException.h | 4 +- .../LibWeb/DOM/DOMImplementation.cpp | 4 +- .../Libraries/LibWeb/DOM/DOMImplementation.h | 2 +- Userland/Libraries/LibWeb/DOM/Document.cpp | 14 +- Userland/Libraries/LibWeb/DOM/Document.h | 2 +- Userland/Libraries/LibWeb/DOM/Element.cpp | 22 +-- .../Libraries/LibWeb/DOM/ElementFactory.cpp | 146 +++++++++--------- Userland/Libraries/LibWeb/DOM/Event.h | 2 +- .../Libraries/LibWeb/DOM/HTMLCollection.h | 2 +- Userland/Libraries/LibWeb/DOM/Node.cpp | 10 +- Userland/Libraries/LibWeb/DOM/Range.cpp | 8 +- Userland/Libraries/LibWeb/DOM/ShadowRoot.cpp | 2 +- Userland/Libraries/LibWeb/DOM/Text.cpp | 2 +- Userland/Libraries/LibWeb/DOM/Timer.cpp | 4 +- Userland/Libraries/LibWeb/DOM/Window.cpp | 2 +- Userland/Libraries/LibWeb/DOMTreeModel.h | 2 +- .../LibWeb/HTML/CanvasRenderingContext2D.h | 2 +- .../LibWeb/HTML/GlobalEventHandlers.cpp | 4 +- .../Libraries/LibWeb/HTML/HTMLBRElement.cpp | 2 +- .../LibWeb/HTML/HTMLCanvasElement.cpp | 2 +- .../LibWeb/HTML/HTMLIFrameElement.cpp | 2 +- .../LibWeb/HTML/HTMLImageElement.cpp | 2 +- .../LibWeb/HTML/HTMLInputElement.cpp | 12 +- .../LibWeb/HTML/HTMLLabelElement.cpp | 2 +- .../LibWeb/HTML/HTMLObjectElement.cpp | 2 +- .../LibWeb/HTML/HTMLTemplateElement.cpp | 2 +- Userland/Libraries/LibWeb/HTML/ImageData.cpp | 2 +- .../LibWeb/HTML/Parser/HTMLDocumentParser.cpp | 16 +- .../Libraries/LibWeb/HTML/SubmitEvent.cpp | 2 +- .../Libraries/LibWeb/Layout/ListItemBox.cpp | 2 +- Userland/Libraries/LibWeb/Layout/Node.cpp | 2 +- .../Libraries/LibWeb/Layout/TreeBuilder.cpp | 4 +- Userland/Libraries/LibWeb/LayoutTreeModel.h | 2 +- .../Libraries/LibWeb/Loader/FrameLoader.cpp | 2 +- Userland/Libraries/LibWeb/Loader/Resource.cpp | 4 +- Userland/Libraries/LibWeb/Page/Frame.h | 4 +- .../Libraries/LibWeb/SVG/SVGPathElement.cpp | 2 +- .../Libraries/LibWeb/SVG/SVGSVGElement.cpp | 2 +- .../Libraries/LibWeb/StylePropertiesModel.h | 2 +- .../Libraries/LibWeb/UIEvents/MouseEvent.h | 2 +- Userland/Libraries/LibWeb/XHR/ProgressEvent.h | 2 +- .../Libraries/LibWeb/XHR/XMLHttpRequest.h | 2 +- Userland/Libraries/LibWebSocket/WebSocket.cpp | 2 +- Userland/Services/AudioServer/Mixer.cpp | 2 +- Userland/Services/EchoServer/Client.h | 2 +- Userland/Services/TelnetServer/Client.h | 2 +- Userland/Services/WindowServer/Cursor.cpp | 4 +- Userland/Services/WindowServer/Menubar.h | 2 +- Userland/Shell/AST.cpp | 8 +- Userland/Shell/AST.h | 12 +- Userland/Shell/Builtin.cpp | 2 +- Userland/Shell/Job.h | 2 +- Userland/Shell/Parser.cpp | 2 +- Userland/Shell/Shell.cpp | 14 +- Userland/Shell/main.cpp | 2 +- 228 files changed, 461 insertions(+), 461 deletions(-) diff --git a/AK/ByteBuffer.h b/AK/ByteBuffer.h index bd85e08c483..38e1e377f99 100644 --- a/AK/ByteBuffer.h +++ b/AK/ByteBuffer.h @@ -292,12 +292,12 @@ inline void ByteBufferImpl::zero_fill() inline NonnullRefPtr ByteBufferImpl::create_uninitialized(size_t size) { - return ::adopt(*new ByteBufferImpl(size)); + return ::adopt_ref(*new ByteBufferImpl(size)); } inline NonnullRefPtr ByteBufferImpl::create_zeroed(size_t size) { - auto buffer = ::adopt(*new ByteBufferImpl(size)); + auto buffer = ::adopt_ref(*new ByteBufferImpl(size)); if (size != 0) __builtin_memset(buffer->data(), 0, size); return buffer; @@ -305,7 +305,7 @@ inline NonnullRefPtr ByteBufferImpl::create_zeroed(size_t size) inline NonnullRefPtr ByteBufferImpl::copy(const void* data, size_t size) { - return ::adopt(*new ByteBufferImpl(data, size)); + return ::adopt_ref(*new ByteBufferImpl(data, size)); } } diff --git a/AK/MappedFile.cpp b/AK/MappedFile.cpp index 284f9814617..9c3199d0fe9 100644 --- a/AK/MappedFile.cpp +++ b/AK/MappedFile.cpp @@ -37,7 +37,7 @@ Result, OSError> MappedFile::map(const String& path) if (ptr == MAP_FAILED) return OSError(errno); - return adopt(*new MappedFile(ptr, size)); + return adopt_ref(*new MappedFile(ptr, size)); } MappedFile::MappedFile(void* ptr, size_t size) diff --git a/AK/NonnullRefPtr.h b/AK/NonnullRefPtr.h index b64ea0e3c67..b4ea20b4514 100644 --- a/AK/NonnullRefPtr.h +++ b/AK/NonnullRefPtr.h @@ -314,7 +314,7 @@ private: }; template -inline NonnullRefPtr adopt(T& object) +inline NonnullRefPtr adopt_ref(T& object) { return NonnullRefPtr(NonnullRefPtr::Adopt, object); } @@ -335,5 +335,5 @@ inline void swap(NonnullRefPtr& a, NonnullRefPtr& b) } -using AK::adopt; +using AK::adopt_ref; using AK::NonnullRefPtr; diff --git a/AK/StringImpl.cpp b/AK/StringImpl.cpp index f29c5c3579b..ea7c4f52550 100644 --- a/AK/StringImpl.cpp +++ b/AK/StringImpl.cpp @@ -71,7 +71,7 @@ NonnullRefPtr StringImpl::create_uninitialized(size_t length, char*& VERIFY(length); void* slot = kmalloc(allocation_size_for_stringimpl(length)); VERIFY(slot); - auto new_stringimpl = adopt(*new (slot) StringImpl(ConstructWithInlineBuffer, length)); + auto new_stringimpl = adopt_ref(*new (slot) StringImpl(ConstructWithInlineBuffer, length)); buffer = const_cast(new_stringimpl->characters()); buffer[length] = '\0'; return new_stringimpl; diff --git a/AK/TestSuite.h b/AK/TestSuite.h index b8f252a1421..45799bd1021 100644 --- a/AK/TestSuite.h +++ b/AK/TestSuite.h @@ -239,25 +239,25 @@ using AK::TestSuite; #define __TESTCASE_FUNC(x) __test_##x #define __TESTCASE_TYPE(x) __TestCase_##x -#define TEST_CASE(x) \ - static void __TESTCASE_FUNC(x)(); \ - struct __TESTCASE_TYPE(x) { \ - __TESTCASE_TYPE(x) \ - () { TestSuite::the().add_case(adopt(*new TestCase(#x, __TESTCASE_FUNC(x), false))); } \ - }; \ - static struct __TESTCASE_TYPE(x) __TESTCASE_TYPE(x); \ +#define TEST_CASE(x) \ + static void __TESTCASE_FUNC(x)(); \ + struct __TESTCASE_TYPE(x) { \ + __TESTCASE_TYPE(x) \ + () { TestSuite::the().add_case(adopt_ref(*new TestCase(#x, __TESTCASE_FUNC(x), false))); } \ + }; \ + static struct __TESTCASE_TYPE(x) __TESTCASE_TYPE(x); \ static void __TESTCASE_FUNC(x)() #define __BENCHMARK_FUNC(x) __benchmark_##x #define __BENCHMARK_TYPE(x) __BenchmarkCase_##x -#define BENCHMARK_CASE(x) \ - static void __BENCHMARK_FUNC(x)(); \ - struct __BENCHMARK_TYPE(x) { \ - __BENCHMARK_TYPE(x) \ - () { TestSuite::the().add_case(adopt(*new TestCase(#x, __BENCHMARK_FUNC(x), true))); } \ - }; \ - static struct __BENCHMARK_TYPE(x) __BENCHMARK_TYPE(x); \ +#define BENCHMARK_CASE(x) \ + static void __BENCHMARK_FUNC(x)(); \ + struct __BENCHMARK_TYPE(x) { \ + __BENCHMARK_TYPE(x) \ + () { TestSuite::the().add_case(adopt_ref(*new TestCase(#x, __BENCHMARK_FUNC(x), true))); } \ + }; \ + static struct __BENCHMARK_TYPE(x) __BENCHMARK_TYPE(x); \ static void __BENCHMARK_FUNC(x)() #define TEST_MAIN(x) \ diff --git a/AK/Tests/TestIntrusiveList.cpp b/AK/Tests/TestIntrusiveList.cpp index ee9af5a276c..3e3012bc20f 100644 --- a/AK/Tests/TestIntrusiveList.cpp +++ b/AK/Tests/TestIntrusiveList.cpp @@ -60,7 +60,7 @@ using IntrusiveRefPtrList = IntrusiveListref_count()); IntrusiveRefPtrList ref_list; @@ -73,7 +73,7 @@ TEST_CASE(intrusive_ref_ptr_no_ref_leaks) TEST_CASE(intrusive_ref_ptr_clear) { - auto item = adopt(*new IntrusiveRefPtrItem()); + auto item = adopt_ref(*new IntrusiveRefPtrItem()); EXPECT_EQ(1u, item->ref_count()); IntrusiveRefPtrList ref_list; @@ -86,7 +86,7 @@ TEST_CASE(intrusive_ref_ptr_clear) TEST_CASE(intrusive_ref_ptr_destructor) { - auto item = adopt(*new IntrusiveRefPtrItem()); + auto item = adopt_ref(*new IntrusiveRefPtrItem()); EXPECT_EQ(1u, item->ref_count()); { @@ -107,7 +107,7 @@ using IntrusiveNonnullRefPtrList = IntrusiveListref_count()); IntrusiveNonnullRefPtrList nonnull_ref_list; diff --git a/AK/Tests/TestNonnullRefPtr.cpp b/AK/Tests/TestNonnullRefPtr.cpp index 99421223eff..19d43fc2e20 100644 --- a/AK/Tests/TestNonnullRefPtr.cpp +++ b/AK/Tests/TestNonnullRefPtr.cpp @@ -15,7 +15,7 @@ struct Object : public RefCounted { TEST_CASE(basics) { - auto object = adopt(*new Object); + auto object = adopt_ref(*new Object); EXPECT(object.ptr() != nullptr); EXPECT_EQ(object->ref_count(), 1u); object->ref(); @@ -33,7 +33,7 @@ TEST_CASE(basics) TEST_CASE(assign_reference) { - auto object = adopt(*new Object); + auto object = adopt_ref(*new Object); EXPECT_EQ(object->ref_count(), 1u); object = *object; EXPECT_EQ(object->ref_count(), 1u); @@ -45,8 +45,8 @@ TEST_CASE(assign_owner_of_self) RefPtr parent; }; - auto parent = adopt(*new Object); - auto child = adopt(*new Object); + auto parent = adopt_ref(*new Object); + auto child = adopt_ref(*new Object); child->parent = move(parent); child = *child->parent; @@ -55,7 +55,7 @@ TEST_CASE(assign_owner_of_self) TEST_CASE(swap_with_self) { - auto object = adopt(*new Object); + auto object = adopt_ref(*new Object); swap(object, object); EXPECT_EQ(object->ref_count(), 1u); } diff --git a/AK/Tests/TestRefPtr.cpp b/AK/Tests/TestRefPtr.cpp index 4d7d0c28b0f..f8461183f86 100644 --- a/AK/Tests/TestRefPtr.cpp +++ b/AK/Tests/TestRefPtr.cpp @@ -27,7 +27,7 @@ size_t SelfAwareObject::num_destroyed = 0; TEST_CASE(basics) { - RefPtr object = adopt(*new Object); + RefPtr object = adopt_ref(*new Object); EXPECT(object.ptr() != nullptr); EXPECT_EQ(object->ref_count(), 1u); object->ref(); @@ -45,7 +45,7 @@ TEST_CASE(basics) TEST_CASE(assign_reference) { - RefPtr object = adopt(*new Object); + RefPtr object = adopt_ref(*new Object); EXPECT_EQ(object->ref_count(), 1u); object = *object; EXPECT_EQ(object->ref_count(), 1u); @@ -53,7 +53,7 @@ TEST_CASE(assign_reference) TEST_CASE(assign_ptr) { - RefPtr object = adopt(*new Object); + RefPtr object = adopt_ref(*new Object); EXPECT_EQ(object->ref_count(), 1u); object = object.ptr(); EXPECT_EQ(object->ref_count(), 1u); @@ -61,7 +61,7 @@ TEST_CASE(assign_ptr) TEST_CASE(copy_move_ref) { - RefPtr object = adopt(*new Object2); + RefPtr object = adopt_ref(*new Object2); EXPECT_EQ(object->ref_count(), 1u); { auto object2 = object; @@ -84,8 +84,8 @@ TEST_CASE(copy_move_ref) TEST_CASE(swap) { - RefPtr object_a = adopt(*new Object); - RefPtr object_b = adopt(*new Object); + RefPtr object_a = adopt_ref(*new Object); + RefPtr object_b = adopt_ref(*new Object); auto* ptr_a = object_a.ptr(); auto* ptr_b = object_b.ptr(); swap(object_a, object_b); @@ -97,7 +97,7 @@ TEST_CASE(swap) TEST_CASE(assign_moved_self) { - RefPtr object = adopt(*new Object); + RefPtr object = adopt_ref(*new Object); EXPECT_EQ(object->ref_count(), 1u); #ifdef __clang__ # pragma clang diagnostic push @@ -112,7 +112,7 @@ TEST_CASE(assign_moved_self) TEST_CASE(assign_copy_self) { - RefPtr object = adopt(*new Object); + RefPtr object = adopt_ref(*new Object); EXPECT_EQ(object->ref_count(), 1u); #ifdef __clang__ @@ -129,7 +129,7 @@ TEST_CASE(assign_copy_self) TEST_CASE(self_observers) { - RefPtr object = adopt(*new SelfAwareObject); + RefPtr object = adopt_ref(*new SelfAwareObject); EXPECT_EQ(object->ref_count(), 1u); EXPECT_EQ(object->m_has_one_ref_left, false); EXPECT_EQ(SelfAwareObject::num_destroyed, 0u); diff --git a/AK/Tests/TestWeakPtr.cpp b/AK/Tests/TestWeakPtr.cpp index a993355bf69..63651204b1b 100644 --- a/AK/Tests/TestWeakPtr.cpp +++ b/AK/Tests/TestWeakPtr.cpp @@ -34,7 +34,7 @@ TEST_CASE(basic_weak) WeakPtr weak2; { - auto simple = adopt(*new SimpleWeakable); + auto simple = adopt_ref(*new SimpleWeakable); weak1 = simple; weak2 = simple; EXPECT_EQ(weak1.is_null(), false); @@ -54,7 +54,7 @@ TEST_CASE(weakptr_move) WeakPtr weak2; { - auto simple = adopt(*new SimpleWeakable); + auto simple = adopt_ref(*new SimpleWeakable); weak1 = simple; weak2 = move(weak1); EXPECT_EQ(weak1.is_null(), true); diff --git a/AK/WeakPtr.h b/AK/WeakPtr.h index b164fb864a2..b89dc480f29 100644 --- a/AK/WeakPtr.h +++ b/AK/WeakPtr.h @@ -198,7 +198,7 @@ inline WeakPtr Weakable::make_weak_ptr() const // There is a small chance that we create a new WeakLink and throw // it away because another thread beat us to it. But the window is // pretty small and the overhead isn't terrible. - m_link.assign_if_null(adopt(*new WeakLink(const_cast(static_cast(*this))))); + m_link.assign_if_null(adopt_ref(*new WeakLink(const_cast(static_cast(*this))))); } WeakPtr weak_ptr(m_link); diff --git a/AK/Weakable.h b/AK/Weakable.h index 4b23f44f80b..4ad2a516af8 100644 --- a/AK/Weakable.h +++ b/AK/Weakable.h @@ -43,7 +43,7 @@ public: if (!(m_consumers.fetch_add(1u << 1, AK::MemoryOrder::memory_order_acquire) & 1u)) { T* ptr = (T*)m_ptr.load(AK::MemoryOrder::memory_order_acquire); if (ptr && ptr->try_ref()) - ref = adopt(*ptr); + ref = adopt_ref(*ptr); } m_consumers.fetch_sub(1u << 1, AK::MemoryOrder::memory_order_release); } diff --git a/Documentation/SmartPointers.md b/Documentation/SmartPointers.md index 339a3e335b9..a6d456e02b0 100644 --- a/Documentation/SmartPointers.md +++ b/Documentation/SmartPointers.md @@ -42,14 +42,14 @@ Objects can only be held by `RefPtr` if they meet certain criteria. Specifically To make a class `T` reference-counted, you can simply make it inherit from `RefCounted`. This will add all the necessary pieces to `T`. -**Note:** When constructing an object that derives from `RefCounted`, the reference count starts out at 1 (since 0 would mean that the object has no owners and should be deleted.) The object must therefore be "adopted" by someone who takes responsibility of that 1. This is done through the global `adopt()` function: +**Note:** When constructing an object that derives from `RefCounted`, the reference count starts out at 1 (since 0 would mean that the object has no owners and should be deleted.) The object must therefore be "adopted" by someone who takes responsibility of that 1. This is done through the global `adopt_ref()` function: ```cpp class Bar : public RefCounted { ... }; -RefPtr our_object = adopt(*new Bar); +RefPtr our_object = adopt_ref(*new Bar); RefPtr another_owner = our_object; ``` diff --git a/Kernel/Devices/Device.h b/Kernel/Devices/Device.h index 98e3cfe1fa0..1bc751d8202 100644 --- a/Kernel/Devices/Device.h +++ b/Kernel/Devices/Device.h @@ -51,7 +51,7 @@ public: template NonnullRefPtr make_request(Args&&... args) { - auto request = adopt(*new AsyncRequestType(*this, forward(args)...)); + auto request = adopt_ref(*new AsyncRequestType(*this, forward(args)...)); ScopedSpinLock lock(m_requests_lock); bool was_empty = m_requests.is_empty(); m_requests.append(request); diff --git a/Kernel/Devices/HID/I8042Controller.cpp b/Kernel/Devices/HID/I8042Controller.cpp index 9479373f815..c48df8690a6 100644 --- a/Kernel/Devices/HID/I8042Controller.cpp +++ b/Kernel/Devices/HID/I8042Controller.cpp @@ -14,7 +14,7 @@ namespace Kernel { UNMAP_AFTER_INIT NonnullRefPtr I8042Controller::initialize() { - return adopt(*new I8042Controller()); + return adopt_ref(*new I8042Controller()); } RefPtr I8042Controller::mouse() const diff --git a/Kernel/Devices/HID/PS2KeyboardDevice.cpp b/Kernel/Devices/HID/PS2KeyboardDevice.cpp index b61ad693827..9dfe2a772d4 100644 --- a/Kernel/Devices/HID/PS2KeyboardDevice.cpp +++ b/Kernel/Devices/HID/PS2KeyboardDevice.cpp @@ -85,7 +85,7 @@ void PS2KeyboardDevice::handle_irq(const RegisterState&) UNMAP_AFTER_INIT RefPtr PS2KeyboardDevice::try_to_initialize(const I8042Controller& ps2_controller) { - auto device = adopt(*new PS2KeyboardDevice(ps2_controller)); + auto device = adopt_ref(*new PS2KeyboardDevice(ps2_controller)); if (device->initialize()) return device; return nullptr; diff --git a/Kernel/Devices/HID/PS2MouseDevice.cpp b/Kernel/Devices/HID/PS2MouseDevice.cpp index ef1086d6cbd..f4947ea2094 100644 --- a/Kernel/Devices/HID/PS2MouseDevice.cpp +++ b/Kernel/Devices/HID/PS2MouseDevice.cpp @@ -176,7 +176,7 @@ void PS2MouseDevice::set_sample_rate(u8 rate) UNMAP_AFTER_INIT RefPtr PS2MouseDevice::try_to_initialize(const I8042Controller& ps2_controller) { - auto device = adopt(*new PS2MouseDevice(ps2_controller)); + auto device = adopt_ref(*new PS2MouseDevice(ps2_controller)); if (device->initialize()) return device; return nullptr; diff --git a/Kernel/Devices/HID/VMWareMouseDevice.cpp b/Kernel/Devices/HID/VMWareMouseDevice.cpp index 32f498e4927..2c54a285cb8 100644 --- a/Kernel/Devices/HID/VMWareMouseDevice.cpp +++ b/Kernel/Devices/HID/VMWareMouseDevice.cpp @@ -15,7 +15,7 @@ UNMAP_AFTER_INIT RefPtr VMWareMouseDevice::try_to_initialize( return {}; if (!VMWareBackdoor::the()->vmmouse_is_absolute()) return {}; - auto device = adopt(*new VMWareMouseDevice(ps2_controller)); + auto device = adopt_ref(*new VMWareMouseDevice(ps2_controller)); if (device->initialize()) return device; return {}; diff --git a/Kernel/FileSystem/AnonymousFile.h b/Kernel/FileSystem/AnonymousFile.h index ca3c162bfd4..470d5cdf4a6 100644 --- a/Kernel/FileSystem/AnonymousFile.h +++ b/Kernel/FileSystem/AnonymousFile.h @@ -14,7 +14,7 @@ class AnonymousFile final : public File { public: static NonnullRefPtr create(NonnullRefPtr vmobject) { - return adopt(*new AnonymousFile(move(vmobject))); + return adopt_ref(*new AnonymousFile(move(vmobject))); } virtual ~AnonymousFile() override; diff --git a/Kernel/FileSystem/Custody.h b/Kernel/FileSystem/Custody.h index 9c747f767e0..3c18ff692c7 100644 --- a/Kernel/FileSystem/Custody.h +++ b/Kernel/FileSystem/Custody.h @@ -21,7 +21,7 @@ class Custody : public RefCounted { public: static NonnullRefPtr create(Custody* parent, const StringView& name, Inode& inode, int mount_flags) { - return adopt(*new Custody(parent, name, inode, mount_flags)); + return adopt_ref(*new Custody(parent, name, inode, mount_flags)); } ~Custody(); diff --git a/Kernel/FileSystem/DevFS.cpp b/Kernel/FileSystem/DevFS.cpp index feaf586d9cb..e1503698e8c 100644 --- a/Kernel/FileSystem/DevFS.cpp +++ b/Kernel/FileSystem/DevFS.cpp @@ -14,11 +14,11 @@ namespace Kernel { NonnullRefPtr DevFS::create() { - return adopt(*new DevFS); + return adopt_ref(*new DevFS); } DevFS::DevFS() - : m_root_inode(adopt(*new DevFSRootDirectoryInode(*this))) + : m_root_inode(adopt_ref(*new DevFSRootDirectoryInode(*this))) { LOCKER(m_lock); Device::for_each([&](Device& device) { @@ -32,7 +32,7 @@ DevFS::DevFS() void DevFS::notify_new_device(Device& device) { LOCKER(m_lock); - auto new_device_inode = adopt(*new DevFSDeviceInode(*this, device)); + auto new_device_inode = adopt_ref(*new DevFSDeviceInode(*this, device)); m_nodes.append(new_device_inode); m_root_inode->m_devices.append(new_device_inode); } @@ -274,7 +274,7 @@ KResultOr> DevFSRootDirectoryInode::create_child(const Stri } if (name != "pts") return EROFS; - auto new_directory_inode = adopt(*new DevFSPtsDirectoryInode(m_parent_fs)); + auto new_directory_inode = adopt_ref(*new DevFSPtsDirectoryInode(m_parent_fs)); m_subfolders.append(new_directory_inode); m_parent_fs.m_nodes.append(new_directory_inode); return KResult(KSuccess); @@ -284,7 +284,7 @@ KResultOr> DevFSRootDirectoryInode::create_child(const Stri if (link.name() == name) return EEXIST; } - auto new_link_inode = adopt(*new DevFSLinkInode(m_parent_fs, name)); + auto new_link_inode = adopt_ref(*new DevFSLinkInode(m_parent_fs, name)); m_links.append(new_link_inode); m_parent_fs.m_nodes.append(new_link_inode); return new_link_inode; diff --git a/Kernel/FileSystem/DevPtsFS.cpp b/Kernel/FileSystem/DevPtsFS.cpp index 5f2df3ab8ba..1546b3cd3ab 100644 --- a/Kernel/FileSystem/DevPtsFS.cpp +++ b/Kernel/FileSystem/DevPtsFS.cpp @@ -15,7 +15,7 @@ namespace Kernel { NonnullRefPtr DevPtsFS::create() { - return adopt(*new DevPtsFS); + return adopt_ref(*new DevPtsFS); } DevPtsFS::DevPtsFS() @@ -30,7 +30,7 @@ static AK::Singleton> s_ptys; bool DevPtsFS::initialize() { - m_root_inode = adopt(*new DevPtsFSInode(*this, 1, nullptr)); + m_root_inode = adopt_ref(*new DevPtsFSInode(*this, 1, nullptr)); m_root_inode->m_metadata.inode = { fsid(), 1 }; m_root_inode->m_metadata.mode = 0040555; m_root_inode->m_metadata.uid = 0; @@ -66,7 +66,7 @@ RefPtr DevPtsFS::get_inode(InodeIdentifier inode_id) const auto* device = Device::get_device(201, pty_index); VERIFY(device); - auto inode = adopt(*new DevPtsFSInode(const_cast(*this), inode_id.index(), static_cast(device))); + auto inode = adopt_ref(*new DevPtsFSInode(const_cast(*this), inode_id.index(), static_cast(device))); inode->m_metadata.inode = inode_id; inode->m_metadata.size = 0; inode->m_metadata.uid = device->uid(); diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index 745c746a37c..1c1eaf53583 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -55,7 +55,7 @@ static unsigned divide_rounded_up(unsigned a, unsigned b) NonnullRefPtr Ext2FS::create(FileDescription& file_description) { - return adopt(*new Ext2FS(file_description)); + return adopt_ref(*new Ext2FS(file_description)); } Ext2FS::Ext2FS(FileDescription& file_description) @@ -797,7 +797,7 @@ RefPtr Ext2FS::get_inode(InodeIdentifier inode) const if (!find_block_containing_inode(inode.index(), block_index, offset)) return {}; - auto new_inode = adopt(*new Ext2FSInode(const_cast(*this), inode.index())); + auto new_inode = adopt_ref(*new Ext2FSInode(const_cast(*this), inode.index())); auto buffer = UserOrKernelBuffer::for_kernel_buffer(reinterpret_cast(&new_inode->m_raw_inode)); if (auto result = read_block(block_index, &buffer, sizeof(ext2_inode), offset); result.is_error()) { // FIXME: Propagate the actual error. diff --git a/Kernel/FileSystem/FIFO.cpp b/Kernel/FileSystem/FIFO.cpp index 0b5e1154942..a190c07f872 100644 --- a/Kernel/FileSystem/FIFO.cpp +++ b/Kernel/FileSystem/FIFO.cpp @@ -27,7 +27,7 @@ static int s_next_fifo_id = 1; NonnullRefPtr FIFO::create(uid_t uid) { - return adopt(*new FIFO(uid)); + return adopt_ref(*new FIFO(uid)); } KResultOr> FIFO::open_direction(FIFO::Direction direction) diff --git a/Kernel/FileSystem/FileDescription.cpp b/Kernel/FileSystem/FileDescription.cpp index bfc3db6fd33..70a6be8ead3 100644 --- a/Kernel/FileSystem/FileDescription.cpp +++ b/Kernel/FileSystem/FileDescription.cpp @@ -25,7 +25,7 @@ namespace Kernel { KResultOr> FileDescription::create(Custody& custody) { - auto description = adopt(*new FileDescription(InodeFile::create(custody.inode()))); + auto description = adopt_ref(*new FileDescription(InodeFile::create(custody.inode()))); description->m_custody = custody; auto result = description->attach(); if (result.is_error()) { @@ -37,7 +37,7 @@ KResultOr> FileDescription::create(Custody& custo KResultOr> FileDescription::create(File& file) { - auto description = adopt(*new FileDescription(file)); + auto description = adopt_ref(*new FileDescription(file)); auto result = description->attach(); if (result.is_error()) { dbgln_if(FILEDESCRIPTION_DEBUG, "Failed to create file description for file: {}", result); diff --git a/Kernel/FileSystem/InodeFile.h b/Kernel/FileSystem/InodeFile.h index c3937243b94..ddf4d22bb18 100644 --- a/Kernel/FileSystem/InodeFile.h +++ b/Kernel/FileSystem/InodeFile.h @@ -16,7 +16,7 @@ class InodeFile final : public File { public: static NonnullRefPtr create(NonnullRefPtr&& inode) { - return adopt(*new InodeFile(move(inode))); + return adopt_ref(*new InodeFile(move(inode))); } virtual ~InodeFile() override; diff --git a/Kernel/FileSystem/InodeWatcher.cpp b/Kernel/FileSystem/InodeWatcher.cpp index 8e2d7de3af6..20baf7d4486 100644 --- a/Kernel/FileSystem/InodeWatcher.cpp +++ b/Kernel/FileSystem/InodeWatcher.cpp @@ -12,7 +12,7 @@ namespace Kernel { NonnullRefPtr InodeWatcher::create(Inode& inode) { - return adopt(*new InodeWatcher(inode)); + return adopt_ref(*new InodeWatcher(inode)); } InodeWatcher::InodeWatcher(Inode& inode) diff --git a/Kernel/FileSystem/Plan9FileSystem.cpp b/Kernel/FileSystem/Plan9FileSystem.cpp index 519024c505a..d28915515f4 100644 --- a/Kernel/FileSystem/Plan9FileSystem.cpp +++ b/Kernel/FileSystem/Plan9FileSystem.cpp @@ -11,7 +11,7 @@ namespace Kernel { NonnullRefPtr Plan9FS::create(FileDescription& file_description) { - return adopt(*new Plan9FS(file_description)); + return adopt_ref(*new Plan9FS(file_description)); } Plan9FS::Plan9FS(FileDescription& file_description) @@ -597,7 +597,7 @@ KResult Plan9FS::post_message_and_wait_for_a_reply(Message& message) { auto request_type = message.type(); auto tag = message.tag(); - auto completion = adopt(*new ReceiveCompletion(tag)); + auto completion = adopt_ref(*new ReceiveCompletion(tag)); auto result = post_message(message, completion); if (result.is_error()) return result; @@ -680,7 +680,7 @@ Plan9FSInode::Plan9FSInode(Plan9FS& fs, u32 fid) NonnullRefPtr Plan9FSInode::create(Plan9FS& fs, u32 fid) { - return adopt(*new Plan9FSInode(fs, fid)); + return adopt_ref(*new Plan9FSInode(fs, fid)); } Plan9FSInode::~Plan9FSInode() diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index 8b96f459fe0..63a505ad94d 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -237,7 +237,7 @@ struct ProcFSInodeData : public FileDescriptionData { NonnullRefPtr ProcFS::create() { - return adopt(*new ProcFS); + return adopt_ref(*new ProcFS); } ProcFS::~ProcFS() @@ -1018,10 +1018,10 @@ RefPtr ProcFS::get_inode(InodeIdentifier inode_id) const // and if that fails we cannot return this instance anymore and just // create a new one. if (it->value->try_ref()) - return adopt(*it->value); + return adopt_ref(*it->value); // We couldn't ref it, so just create a new one and replace the entry } - auto inode = adopt(*new ProcFSInode(const_cast(*this), inode_id.index())); + auto inode = adopt_ref(*new ProcFSInode(const_cast(*this), inode_id.index())); auto result = m_inodes.set(inode_id.index().value(), inode.ptr()); VERIFY(result == ((it == m_inodes.end()) ? AK::HashSetResult::InsertedNewEntry : AK::HashSetResult::ReplacedExistingEntry)); return inode; @@ -1677,7 +1677,7 @@ KResult ProcFSInode::chmod(mode_t) ProcFS::ProcFS() { - m_root_inode = adopt(*new ProcFSInode(*this, 1)); + m_root_inode = adopt_ref(*new ProcFSInode(*this, 1)); m_entries.resize(FI_MaxStaticFileIndex); m_entries[FI_Root_df] = { "df", FI_Root_df, false, procfs$df }; m_entries[FI_Root_all] = { "all", FI_Root_all, false, procfs$all }; diff --git a/Kernel/FileSystem/ProcFS.h b/Kernel/FileSystem/ProcFS.h index b0b9e4b6fab..1b8b1b833b7 100644 --- a/Kernel/FileSystem/ProcFS.h +++ b/Kernel/FileSystem/ProcFS.h @@ -132,7 +132,7 @@ private: ProcFSProxyInode(ProcFS&, FileDescription&); static NonnullRefPtr create(ProcFS& fs, FileDescription& fd) { - return adopt(*new ProcFSProxyInode(fs, fd)); + return adopt_ref(*new ProcFSProxyInode(fs, fd)); } NonnullRefPtr m_fd; diff --git a/Kernel/FileSystem/TmpFS.cpp b/Kernel/FileSystem/TmpFS.cpp index 7a56b234eb6..bc0d8741401 100644 --- a/Kernel/FileSystem/TmpFS.cpp +++ b/Kernel/FileSystem/TmpFS.cpp @@ -13,7 +13,7 @@ namespace Kernel { NonnullRefPtr TmpFS::create() { - return adopt(*new TmpFS); + return adopt_ref(*new TmpFS); } TmpFS::TmpFS() @@ -86,7 +86,7 @@ TmpFSInode::~TmpFSInode() NonnullRefPtr TmpFSInode::create(TmpFS& fs, InodeMetadata metadata, InodeIdentifier parent) { - auto inode = adopt(*new TmpFSInode(fs, metadata, parent)); + auto inode = adopt_ref(*new TmpFSInode(fs, metadata, parent)); fs.register_inode(inode); return inode; } diff --git a/Kernel/Interrupts/InterruptManagement.cpp b/Kernel/Interrupts/InterruptManagement.cpp index 6bcb03a997f..2a3a94d4dcf 100644 --- a/Kernel/Interrupts/InterruptManagement.cpp +++ b/Kernel/Interrupts/InterruptManagement.cpp @@ -125,7 +125,7 @@ UNMAP_AFTER_INIT void InterruptManagement::switch_to_pic_mode() dmesgln("Interrupts: Switch to Legacy PIC mode"); InterruptDisabler disabler; m_smp_enabled = false; - m_interrupt_controllers[0] = adopt(*new PIC()); + m_interrupt_controllers[0] = adopt_ref(*new PIC()); SpuriousInterruptHandler::initialize(7); SpuriousInterruptHandler::initialize(15); for (auto& irq_controller : m_interrupt_controllers) { @@ -183,7 +183,7 @@ UNMAP_AFTER_INIT void InterruptManagement::locate_apic_data() int irq_controller_count = 0; if (madt->flags & PCAT_COMPAT_FLAG) { - m_interrupt_controllers[0] = adopt(*new PIC()); + m_interrupt_controllers[0] = adopt_ref(*new PIC()); irq_controller_count++; } size_t entry_index = 0; @@ -195,7 +195,7 @@ UNMAP_AFTER_INIT void InterruptManagement::locate_apic_data() auto* ioapic_entry = (const ACPI::Structures::MADTEntries::IOAPIC*)madt_entry; dbgln("IOAPIC found @ MADT entry {}, MMIO Registers @ {}", entry_index, PhysicalAddress(ioapic_entry->ioapic_address)); m_interrupt_controllers.resize(1 + irq_controller_count); - m_interrupt_controllers[irq_controller_count] = adopt(*new IOAPIC(PhysicalAddress(ioapic_entry->ioapic_address), ioapic_entry->gsi_base)); + m_interrupt_controllers[irq_controller_count] = adopt_ref(*new IOAPIC(PhysicalAddress(ioapic_entry->ioapic_address), ioapic_entry->gsi_base)); irq_controller_count++; } if (madt_entry->type == (u8)ACPI::Structures::MADTEntryType::InterruptSourceOverride) { diff --git a/Kernel/KBuffer.h b/Kernel/KBuffer.h index 7d02e9792d5..fc76fee6aac 100644 --- a/Kernel/KBuffer.h +++ b/Kernel/KBuffer.h @@ -32,7 +32,7 @@ public: auto region = MM.allocate_kernel_region(page_round_up(size), name, access, strategy); if (!region) return nullptr; - return adopt(*new KBufferImpl(region.release_nonnull(), size, strategy)); + return adopt_ref(*new KBufferImpl(region.release_nonnull(), size, strategy)); } static RefPtr try_create_with_bytes(ReadonlyBytes bytes, Region::Access access, const char* name = "KBuffer", AllocationStrategy strategy = AllocationStrategy::Reserve) @@ -41,7 +41,7 @@ public: if (!region) return nullptr; memcpy(region->vaddr().as_ptr(), bytes.data(), bytes.size()); - return adopt(*new KBufferImpl(region.release_nonnull(), bytes.size(), strategy)); + return adopt_ref(*new KBufferImpl(region.release_nonnull(), bytes.size(), strategy)); } static RefPtr create_with_size(size_t size, Region::Access access, const char* name, AllocationStrategy strategy = AllocationStrategy::Reserve) diff --git a/Kernel/Net/E1000NetworkAdapter.cpp b/Kernel/Net/E1000NetworkAdapter.cpp index 99119f5d9b2..241c6436d25 100644 --- a/Kernel/Net/E1000NetworkAdapter.cpp +++ b/Kernel/Net/E1000NetworkAdapter.cpp @@ -165,7 +165,7 @@ UNMAP_AFTER_INIT void E1000NetworkAdapter::detect() if (!is_valid_device_id(id.device_id)) return; u8 irq = PCI::get_interrupt_line(address); - [[maybe_unused]] auto& unused = adopt(*new E1000NetworkAdapter(address, irq)).leak_ref(); + [[maybe_unused]] auto& unused = adopt_ref(*new E1000NetworkAdapter(address, irq)).leak_ref(); }); } diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index e49c6c1a283..3063ec1e3e6 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -41,7 +41,7 @@ KResultOr> IPv4Socket::create(int type, int protocol) if (type == SOCK_DGRAM) return UDPSocket::create(protocol); if (type == SOCK_RAW) - return adopt(*new IPv4Socket(type, protocol)); + return adopt_ref(*new IPv4Socket(type, protocol)); return EINVAL; } diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp index 4d4ac372b6a..6a73450b929 100644 --- a/Kernel/Net/LocalSocket.cpp +++ b/Kernel/Net/LocalSocket.cpp @@ -33,7 +33,7 @@ void LocalSocket::for_each(Function callback) KResultOr> LocalSocket::create(int type) { - return adopt(*new LocalSocket(type)); + return adopt_ref(*new LocalSocket(type)); } LocalSocket::LocalSocket(int type) diff --git a/Kernel/Net/NE2000NetworkAdapter.cpp b/Kernel/Net/NE2000NetworkAdapter.cpp index 0954f0da698..384a5987f8b 100644 --- a/Kernel/Net/NE2000NetworkAdapter.cpp +++ b/Kernel/Net/NE2000NetworkAdapter.cpp @@ -158,7 +158,7 @@ UNMAP_AFTER_INIT void NE2000NetworkAdapter::detect() if (!ne2k_ids.span().contains_slow(id)) return; u8 irq = PCI::get_interrupt_line(address); - [[maybe_unused]] auto& unused = adopt(*new NE2000NetworkAdapter(address, irq)).leak_ref(); + [[maybe_unused]] auto& unused = adopt_ref(*new NE2000NetworkAdapter(address, irq)).leak_ref(); }); } diff --git a/Kernel/Net/RTL8139NetworkAdapter.cpp b/Kernel/Net/RTL8139NetworkAdapter.cpp index 0228447ac15..2a193cec8df 100644 --- a/Kernel/Net/RTL8139NetworkAdapter.cpp +++ b/Kernel/Net/RTL8139NetworkAdapter.cpp @@ -114,7 +114,7 @@ UNMAP_AFTER_INIT void RTL8139NetworkAdapter::detect() if (id != rtl8139_id) return; u8 irq = PCI::get_interrupt_line(address); - [[maybe_unused]] auto& unused = adopt(*new RTL8139NetworkAdapter(address, irq)).leak_ref(); + [[maybe_unused]] auto& unused = adopt_ref(*new RTL8139NetworkAdapter(address, irq)).leak_ref(); }); } diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp index 94f4a30def9..d7608cd5f57 100644 --- a/Kernel/Net/TCPSocket.cpp +++ b/Kernel/Net/TCPSocket.cpp @@ -139,7 +139,7 @@ TCPSocket::~TCPSocket() NonnullRefPtr TCPSocket::create(int protocol) { - return adopt(*new TCPSocket(protocol)); + return adopt_ref(*new TCPSocket(protocol)); } KResultOr TCPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, [[maybe_unused]] int flags) diff --git a/Kernel/Net/UDPSocket.cpp b/Kernel/Net/UDPSocket.cpp index 06ea0b6b80f..309823d626b 100644 --- a/Kernel/Net/UDPSocket.cpp +++ b/Kernel/Net/UDPSocket.cpp @@ -56,7 +56,7 @@ UDPSocket::~UDPSocket() NonnullRefPtr UDPSocket::create(int protocol) { - return adopt(*new UDPSocket(protocol)); + return adopt_ref(*new UDPSocket(protocol)); } KResultOr UDPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, [[maybe_unused]] int flags) diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index e451ff89695..259f931d111 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -143,7 +143,7 @@ RefPtr Process::create_user_process(RefPtr& first_thread, const if (!cwd) cwd = VFS::the().root_custody(); - auto process = adopt(*new Process(first_thread, parts.take_last(), uid, gid, parent_pid, false, move(cwd), nullptr, tty)); + auto process = adopt_ref(*new Process(first_thread, parts.take_last(), uid, gid, parent_pid, false, move(cwd), nullptr, tty)); if (!first_thread) return {}; process->m_fds.resize(m_max_open_file_descriptors); @@ -171,7 +171,7 @@ RefPtr Process::create_user_process(RefPtr& first_thread, const RefPtr Process::create_kernel_process(RefPtr& first_thread, String&& name, void (*entry)(void*), void* entry_data, u32 affinity) { - auto process = adopt(*new Process(first_thread, move(name), (uid_t)0, (gid_t)0, ProcessID(0), true)); + auto process = adopt_ref(*new Process(first_thread, move(name), (uid_t)0, (gid_t)0, ProcessID(0), true)); if (!first_thread) return {}; first_thread->tss().eip = (FlatPtr)entry; diff --git a/Kernel/ProcessGroup.cpp b/Kernel/ProcessGroup.cpp index 9039ab42513..938b41152fa 100644 --- a/Kernel/ProcessGroup.cpp +++ b/Kernel/ProcessGroup.cpp @@ -19,7 +19,7 @@ ProcessGroup::~ProcessGroup() NonnullRefPtr ProcessGroup::create(ProcessGroupID pgid) { - auto process_group = adopt(*new ProcessGroup(pgid)); + auto process_group = adopt_ref(*new ProcessGroup(pgid)); { ScopedSpinLock lock(g_process_groups_lock); g_process_groups->prepend(process_group); diff --git a/Kernel/Storage/AHCIController.cpp b/Kernel/Storage/AHCIController.cpp index 084963f6501..50413ca6c46 100644 --- a/Kernel/Storage/AHCIController.cpp +++ b/Kernel/Storage/AHCIController.cpp @@ -17,7 +17,7 @@ namespace Kernel { NonnullRefPtr AHCIController::initialize(PCI::Address address) { - return adopt(*new AHCIController(address)); + return adopt_ref(*new AHCIController(address)); } bool AHCIController::reset() diff --git a/Kernel/Storage/AHCIPort.cpp b/Kernel/Storage/AHCIPort.cpp index e4080aad269..30e31a64c04 100644 --- a/Kernel/Storage/AHCIPort.cpp +++ b/Kernel/Storage/AHCIPort.cpp @@ -18,7 +18,7 @@ namespace Kernel { NonnullRefPtr AHCIPort::ScatterList::create(AsyncBlockDeviceRequest& request, NonnullRefPtrVector allocated_pages, size_t device_block_size) { - return adopt(*new ScatterList(request, allocated_pages, device_block_size)); + return adopt_ref(*new ScatterList(request, allocated_pages, device_block_size)); } AHCIPort::ScatterList::ScatterList(AsyncBlockDeviceRequest& request, NonnullRefPtrVector allocated_pages, size_t device_block_size) @@ -29,7 +29,7 @@ AHCIPort::ScatterList::ScatterList(AsyncBlockDeviceRequest& request, NonnullRefP NonnullRefPtr AHCIPort::create(const AHCIPortHandler& handler, volatile AHCI::PortRegisters& registers, u32 port_index) { - return adopt(*new AHCIPort(handler, registers, port_index)); + return adopt_ref(*new AHCIPort(handler, registers, port_index)); } AHCIPort::AHCIPort(const AHCIPortHandler& handler, volatile AHCI::PortRegisters& registers, u32 port_index) diff --git a/Kernel/Storage/AHCIPortHandler.cpp b/Kernel/Storage/AHCIPortHandler.cpp index f3dc941cd9f..51ceb329e43 100644 --- a/Kernel/Storage/AHCIPortHandler.cpp +++ b/Kernel/Storage/AHCIPortHandler.cpp @@ -11,7 +11,7 @@ namespace Kernel { NonnullRefPtr AHCIPortHandler::create(AHCIController& controller, u8 irq, AHCI::MaskedBitField taken_ports) { - return adopt(*new AHCIPortHandler(controller, irq, taken_ports)); + return adopt_ref(*new AHCIPortHandler(controller, irq, taken_ports)); } AHCIPortHandler::AHCIPortHandler(AHCIController& controller, u8 irq, AHCI::MaskedBitField taken_ports) diff --git a/Kernel/Storage/BMIDEChannel.cpp b/Kernel/Storage/BMIDEChannel.cpp index 04fd190d680..62c3654700c 100644 --- a/Kernel/Storage/BMIDEChannel.cpp +++ b/Kernel/Storage/BMIDEChannel.cpp @@ -13,12 +13,12 @@ namespace Kernel { UNMAP_AFTER_INIT NonnullRefPtr BMIDEChannel::create(const IDEController& ide_controller, IDEChannel::IOAddressGroup io_group, IDEChannel::ChannelType type) { - return adopt(*new BMIDEChannel(ide_controller, io_group, type)); + return adopt_ref(*new BMIDEChannel(ide_controller, io_group, type)); } UNMAP_AFTER_INIT NonnullRefPtr BMIDEChannel::create(const IDEController& ide_controller, u8 irq, IDEChannel::IOAddressGroup io_group, IDEChannel::ChannelType type) { - return adopt(*new BMIDEChannel(ide_controller, irq, io_group, type)); + return adopt_ref(*new BMIDEChannel(ide_controller, irq, io_group, type)); } UNMAP_AFTER_INIT BMIDEChannel::BMIDEChannel(const IDEController& controller, IDEChannel::IOAddressGroup io_group, IDEChannel::ChannelType type) diff --git a/Kernel/Storage/IDEChannel.cpp b/Kernel/Storage/IDEChannel.cpp index ad9eb13ee1b..7c592007b54 100644 --- a/Kernel/Storage/IDEChannel.cpp +++ b/Kernel/Storage/IDEChannel.cpp @@ -26,12 +26,12 @@ namespace Kernel { UNMAP_AFTER_INIT NonnullRefPtr IDEChannel::create(const IDEController& controller, IOAddressGroup io_group, ChannelType type) { - return adopt(*new IDEChannel(controller, io_group, type)); + return adopt_ref(*new IDEChannel(controller, io_group, type)); } UNMAP_AFTER_INIT NonnullRefPtr IDEChannel::create(const IDEController& controller, u8 irq, IOAddressGroup io_group, ChannelType type) { - return adopt(*new IDEChannel(controller, irq, io_group, type)); + return adopt_ref(*new IDEChannel(controller, irq, io_group, type)); } RefPtr IDEChannel::master_device() const diff --git a/Kernel/Storage/IDEController.cpp b/Kernel/Storage/IDEController.cpp index 6111607dd7d..274efc4b887 100644 --- a/Kernel/Storage/IDEController.cpp +++ b/Kernel/Storage/IDEController.cpp @@ -16,7 +16,7 @@ namespace Kernel { UNMAP_AFTER_INIT NonnullRefPtr IDEController::initialize(PCI::Address address, bool force_pio) { - return adopt(*new IDEController(address, force_pio)); + return adopt_ref(*new IDEController(address, force_pio)); } bool IDEController::reset() diff --git a/Kernel/Storage/PATADiskDevice.cpp b/Kernel/Storage/PATADiskDevice.cpp index 896367091f3..294c1cf30f8 100644 --- a/Kernel/Storage/PATADiskDevice.cpp +++ b/Kernel/Storage/PATADiskDevice.cpp @@ -15,7 +15,7 @@ namespace Kernel { UNMAP_AFTER_INIT NonnullRefPtr PATADiskDevice::create(const IDEController& controller, IDEChannel& channel, DriveType type, InterfaceType interface_type, u16 capabilities, u64 max_addressable_block) { - return adopt(*new PATADiskDevice(controller, channel, type, interface_type, capabilities, max_addressable_block)); + return adopt_ref(*new PATADiskDevice(controller, channel, type, interface_type, capabilities, max_addressable_block)); } UNMAP_AFTER_INIT PATADiskDevice::PATADiskDevice(const IDEController& controller, IDEChannel& channel, DriveType type, InterfaceType interface_type, u16 capabilities, u64 max_addressable_block) diff --git a/Kernel/Storage/Partition/DiskPartition.cpp b/Kernel/Storage/Partition/DiskPartition.cpp index 4e908a2c3cf..9d4dfbc1f4c 100644 --- a/Kernel/Storage/Partition/DiskPartition.cpp +++ b/Kernel/Storage/Partition/DiskPartition.cpp @@ -12,7 +12,7 @@ namespace Kernel { NonnullRefPtr DiskPartition::create(BlockDevice& device, unsigned minor_number, DiskPartitionMetadata metadata) { - return adopt(*new DiskPartition(device, minor_number, metadata)); + return adopt_ref(*new DiskPartition(device, minor_number, metadata)); } DiskPartition::DiskPartition(BlockDevice& device, unsigned minor_number, DiskPartitionMetadata metadata) diff --git a/Kernel/Storage/RamdiskController.cpp b/Kernel/Storage/RamdiskController.cpp index ff3de9c09e5..2c0e04c0352 100644 --- a/Kernel/Storage/RamdiskController.cpp +++ b/Kernel/Storage/RamdiskController.cpp @@ -13,7 +13,7 @@ namespace Kernel { NonnullRefPtr RamdiskController::initialize() { - return adopt(*new RamdiskController()); + return adopt_ref(*new RamdiskController()); } bool RamdiskController::reset() diff --git a/Kernel/Storage/RamdiskDevice.cpp b/Kernel/Storage/RamdiskDevice.cpp index 0e7d90a1fa6..87fd37144e0 100644 --- a/Kernel/Storage/RamdiskDevice.cpp +++ b/Kernel/Storage/RamdiskDevice.cpp @@ -14,7 +14,7 @@ namespace Kernel { NonnullRefPtr RamdiskDevice::create(const RamdiskController& controller, NonnullOwnPtr&& region, int major, int minor) { - return adopt(*new RamdiskDevice(controller, move(region), major, minor)); + return adopt_ref(*new RamdiskDevice(controller, move(region), major, minor)); } RamdiskDevice::RamdiskDevice(const RamdiskController& controller, NonnullOwnPtr&& region, int major, int minor) diff --git a/Kernel/Storage/SATADiskDevice.cpp b/Kernel/Storage/SATADiskDevice.cpp index 35ba3ef61cf..4d0677dc616 100644 --- a/Kernel/Storage/SATADiskDevice.cpp +++ b/Kernel/Storage/SATADiskDevice.cpp @@ -15,7 +15,7 @@ namespace Kernel { NonnullRefPtr SATADiskDevice::create(const AHCIController& controller, const AHCIPort& port, size_t sector_size, u64 max_addressable_block) { - return adopt(*new SATADiskDevice(controller, port, sector_size, max_addressable_block)); + return adopt_ref(*new SATADiskDevice(controller, port, sector_size, max_addressable_block)); } SATADiskDevice::SATADiskDevice(const AHCIController& controller, const AHCIPort& port, size_t sector_size, u64 max_addressable_block) diff --git a/Kernel/Syscalls/fork.cpp b/Kernel/Syscalls/fork.cpp index 37d6b5796de..0caf62df5cd 100644 --- a/Kernel/Syscalls/fork.cpp +++ b/Kernel/Syscalls/fork.cpp @@ -16,7 +16,7 @@ KResultOr Process::sys$fork(RegisterState& regs) { REQUIRE_PROMISE(proc); RefPtr child_first_thread; - auto child = adopt(*new Process(child_first_thread, m_name, uid(), gid(), pid(), m_is_kernel_process, m_cwd, m_executable, m_tty, this)); + auto child = adopt_ref(*new Process(child_first_thread, m_name, uid(), gid(), pid(), m_is_kernel_process, m_cwd, m_executable, m_tty, this)); if (!child_first_thread) return ENOMEM; child->m_root_directory = m_root_directory; diff --git a/Kernel/Syscalls/futex.cpp b/Kernel/Syscalls/futex.cpp index 193e63999c3..89a801d0731 100644 --- a/Kernel/Syscalls/futex.cpp +++ b/Kernel/Syscalls/futex.cpp @@ -167,7 +167,7 @@ KResultOr Process::sys$futex(Userspace use if (it != queues->end()) return it->value; if (create_if_not_found) { - auto futex_queue = adopt(*new FutexQueue(user_address_or_offset, vmobject)); + auto futex_queue = adopt_ref(*new FutexQueue(user_address_or_offset, vmobject)); auto result = queues->set(user_address_or_offset, futex_queue); VERIFY(result == AK::HashSetResult::InsertedNewEntry); return futex_queue; diff --git a/Kernel/TTY/MasterPTY.cpp b/Kernel/TTY/MasterPTY.cpp index bc83242d7ee..42a80baf585 100644 --- a/Kernel/TTY/MasterPTY.cpp +++ b/Kernel/TTY/MasterPTY.cpp @@ -17,7 +17,7 @@ namespace Kernel { MasterPTY::MasterPTY(unsigned index) : CharacterDevice(200, index) - , m_slave(adopt(*new SlavePTY(*this, index))) + , m_slave(adopt_ref(*new SlavePTY(*this, index))) , m_index(index) { m_pts_name = String::formatted("/dev/pts/{}", m_index); diff --git a/Kernel/TTY/PTYMultiplexer.cpp b/Kernel/TTY/PTYMultiplexer.cpp index eb5cc0bb9b4..1df690cc5c3 100644 --- a/Kernel/TTY/PTYMultiplexer.cpp +++ b/Kernel/TTY/PTYMultiplexer.cpp @@ -40,7 +40,7 @@ KResultOr> PTYMultiplexer::open(int options) if (m_freelist.is_empty()) return EBUSY; auto master_index = m_freelist.take_last(); - auto master = adopt(*new MasterPTY(master_index)); + auto master = adopt_ref(*new MasterPTY(master_index)); dbgln_if(PTMX_DEBUG, "PTYMultiplexer::open: Vending master {}", master->index()); auto description = FileDescription::create(move(master)); if (!description.is_error()) { diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index fd70f82b24c..de51daedf61 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -41,7 +41,7 @@ KResultOr> Thread::try_create(NonnullRefPtr proce if (!kernel_stack_region) return ENOMEM; kernel_stack_region->set_stack(true); - return adopt(*new Thread(move(process), kernel_stack_region.release_nonnull())); + return adopt_ref(*new Thread(move(process), kernel_stack_region.release_nonnull())); } Thread::Thread(NonnullRefPtr process, NonnullOwnPtr kernel_stack_region) diff --git a/Kernel/Time/APICTimer.cpp b/Kernel/Time/APICTimer.cpp index b89391bd4db..a2543aa0ca0 100644 --- a/Kernel/Time/APICTimer.cpp +++ b/Kernel/Time/APICTimer.cpp @@ -19,7 +19,7 @@ namespace Kernel { UNMAP_AFTER_INIT APICTimer* APICTimer::initialize(u8 interrupt_number, HardwareTimerBase& calibration_source) { - auto timer = adopt(*new APICTimer(interrupt_number, nullptr)); + auto timer = adopt_ref(*new APICTimer(interrupt_number, nullptr)); timer->register_interrupt_handler(); if (!timer->calibrate(calibration_source)) { return nullptr; diff --git a/Kernel/Time/HPETComparator.cpp b/Kernel/Time/HPETComparator.cpp index 7d48821fdfe..7ba16bef367 100644 --- a/Kernel/Time/HPETComparator.cpp +++ b/Kernel/Time/HPETComparator.cpp @@ -13,7 +13,7 @@ namespace Kernel { UNMAP_AFTER_INIT NonnullRefPtr HPETComparator::create(u8 number, u8 irq, bool periodic_capable) { - auto timer = adopt(*new HPETComparator(number, irq, periodic_capable)); + auto timer = adopt_ref(*new HPETComparator(number, irq, periodic_capable)); timer->register_interrupt_handler(); return timer; } diff --git a/Kernel/Time/PIT.cpp b/Kernel/Time/PIT.cpp index 69f9636414b..8e2f9169981 100644 --- a/Kernel/Time/PIT.cpp +++ b/Kernel/Time/PIT.cpp @@ -17,7 +17,7 @@ namespace Kernel { UNMAP_AFTER_INIT NonnullRefPtr PIT::initialize(Function callback) { - return adopt(*new PIT(move(callback))); + return adopt_ref(*new PIT(move(callback))); } inline static void reset_countdown(u16 timer_reload) diff --git a/Kernel/Time/RTC.cpp b/Kernel/Time/RTC.cpp index 3d6958884ca..31c1f09e020 100644 --- a/Kernel/Time/RTC.cpp +++ b/Kernel/Time/RTC.cpp @@ -16,7 +16,7 @@ namespace Kernel { NonnullRefPtr RealTimeClock::create(Function callback) { - return adopt(*new RealTimeClock(move(callback))); + return adopt_ref(*new RealTimeClock(move(callback))); } RealTimeClock::RealTimeClock(Function callback) : HardwareTimer(IRQ_TIMER, move(callback)) diff --git a/Kernel/TimerQueue.cpp b/Kernel/TimerQueue.cpp index 85ae642eb7b..b7dd9efc450 100644 --- a/Kernel/TimerQueue.cpp +++ b/Kernel/TimerQueue.cpp @@ -67,7 +67,7 @@ RefPtr TimerQueue::add_timer_without_id(clockid_t clock_id, const Time& d // *must* be a RefPtr. Otherwise calling cancel_timer() could // inadvertently cancel another timer that has been created between // returning from the timer handler and a call to cancel_timer(). - auto timer = adopt(*new Timer(clock_id, deadline, move(callback))); + auto timer = adopt_ref(*new Timer(clock_id, deadline, move(callback))); ScopedSpinLock lock(g_timerqueue_lock); timer->m_id = 0; // Don't generate a timer id @@ -119,7 +119,7 @@ TimerId TimerQueue::add_timer(clockid_t clock_id, const Time& deadline, Function { auto expires = TimeManagement::the().current_time(clock_id).value(); expires = expires + deadline; - return add_timer(adopt(*new Timer(clock_id, expires, move(callback)))); + return add_timer(adopt_ref(*new Timer(clock_id, expires, move(callback)))); } bool TimerQueue::cancel_timer(TimerId id) diff --git a/Kernel/VM/AnonymousVMObject.cpp b/Kernel/VM/AnonymousVMObject.cpp index 2863e47cb54..7d9b577832d 100644 --- a/Kernel/VM/AnonymousVMObject.cpp +++ b/Kernel/VM/AnonymousVMObject.cpp @@ -41,13 +41,13 @@ RefPtr AnonymousVMObject::clone() // one would keep the one it still has. This ensures that the original // one and this one, as well as the clone have sufficient resources // to cow all pages as needed - m_shared_committed_cow_pages = adopt(*new CommittedCowPages(need_cow_pages)); + m_shared_committed_cow_pages = adopt_ref(*new CommittedCowPages(need_cow_pages)); // Both original and clone become COW. So create a COW map for ourselves // or reset all pages to be copied again if we were previously cloned ensure_or_reset_cow_map(); - return adopt(*new AnonymousVMObject(*this)); + return adopt_ref(*new AnonymousVMObject(*this)); } RefPtr AnonymousVMObject::create_with_size(size_t size, AllocationStrategy commit) @@ -57,17 +57,17 @@ RefPtr AnonymousVMObject::create_with_size(size_t size, Alloc if (!MM.commit_user_physical_pages(ceil_div(size, static_cast(PAGE_SIZE)))) return {}; } - return adopt(*new AnonymousVMObject(size, commit)); + return adopt_ref(*new AnonymousVMObject(size, commit)); } NonnullRefPtr AnonymousVMObject::create_with_physical_pages(NonnullRefPtrVector physical_pages) { - return adopt(*new AnonymousVMObject(physical_pages)); + return adopt_ref(*new AnonymousVMObject(physical_pages)); } NonnullRefPtr AnonymousVMObject::create_with_physical_page(PhysicalPage& page) { - return adopt(*new AnonymousVMObject(page)); + return adopt_ref(*new AnonymousVMObject(page)); } RefPtr AnonymousVMObject::create_for_physical_range(PhysicalAddress paddr, size_t size) @@ -76,7 +76,7 @@ RefPtr AnonymousVMObject::create_for_physical_range(PhysicalA dbgln("Shenanigans! create_for_physical_range({}, {}) would wrap around", paddr, size); return nullptr; } - return adopt(*new AnonymousVMObject(paddr, size)); + return adopt_ref(*new AnonymousVMObject(paddr, size)); } AnonymousVMObject::AnonymousVMObject(size_t size, AllocationStrategy strategy) diff --git a/Kernel/VM/ContiguousVMObject.cpp b/Kernel/VM/ContiguousVMObject.cpp index 243314c87eb..2550cec8297 100644 --- a/Kernel/VM/ContiguousVMObject.cpp +++ b/Kernel/VM/ContiguousVMObject.cpp @@ -12,7 +12,7 @@ namespace Kernel { NonnullRefPtr ContiguousVMObject::create_with_size(size_t size, size_t physical_alignment) { - return adopt(*new ContiguousVMObject(size, physical_alignment)); + return adopt_ref(*new ContiguousVMObject(size, physical_alignment)); } ContiguousVMObject::ContiguousVMObject(size_t size, size_t physical_alignment) diff --git a/Kernel/VM/PageDirectory.h b/Kernel/VM/PageDirectory.h index d965d883ecb..6f1a5bfbe54 100644 --- a/Kernel/VM/PageDirectory.h +++ b/Kernel/VM/PageDirectory.h @@ -22,12 +22,12 @@ class PageDirectory : public RefCounted { public: static RefPtr create_for_userspace(const RangeAllocator* parent_range_allocator = nullptr) { - auto page_directory = adopt(*new PageDirectory(parent_range_allocator)); + auto page_directory = adopt_ref(*new PageDirectory(parent_range_allocator)); if (!page_directory->is_valid()) return {}; return page_directory; } - static NonnullRefPtr create_kernel_page_directory() { return adopt(*new PageDirectory); } + static NonnullRefPtr create_kernel_page_directory() { return adopt_ref(*new PageDirectory); } static RefPtr find_by_cr3(u32); ~PageDirectory(); diff --git a/Kernel/VM/PhysicalPage.cpp b/Kernel/VM/PhysicalPage.cpp index ed17fbc025a..082c636d1d2 100644 --- a/Kernel/VM/PhysicalPage.cpp +++ b/Kernel/VM/PhysicalPage.cpp @@ -12,7 +12,7 @@ namespace Kernel { NonnullRefPtr PhysicalPage::create(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist) { - return adopt(*new PhysicalPage(paddr, supervisor, may_return_to_freelist)); + return adopt_ref(*new PhysicalPage(paddr, supervisor, may_return_to_freelist)); } PhysicalPage::PhysicalPage(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist) diff --git a/Kernel/VM/PhysicalRegion.cpp b/Kernel/VM/PhysicalRegion.cpp index c9ffa7f498c..420442bf417 100644 --- a/Kernel/VM/PhysicalRegion.cpp +++ b/Kernel/VM/PhysicalRegion.cpp @@ -17,7 +17,7 @@ namespace Kernel { NonnullRefPtr PhysicalRegion::create(PhysicalAddress lower, PhysicalAddress upper) { - return adopt(*new PhysicalRegion(lower, upper)); + return adopt_ref(*new PhysicalRegion(lower, upper)); } PhysicalRegion::PhysicalRegion(PhysicalAddress lower, PhysicalAddress upper) diff --git a/Kernel/VM/PrivateInodeVMObject.cpp b/Kernel/VM/PrivateInodeVMObject.cpp index 9e92035ca98..18aa0fb21fe 100644 --- a/Kernel/VM/PrivateInodeVMObject.cpp +++ b/Kernel/VM/PrivateInodeVMObject.cpp @@ -11,12 +11,12 @@ namespace Kernel { NonnullRefPtr PrivateInodeVMObject::create_with_inode(Inode& inode) { - return adopt(*new PrivateInodeVMObject(inode, inode.size())); + return adopt_ref(*new PrivateInodeVMObject(inode, inode.size())); } RefPtr PrivateInodeVMObject::clone() { - return adopt(*new PrivateInodeVMObject(*this)); + return adopt_ref(*new PrivateInodeVMObject(*this)); } PrivateInodeVMObject::PrivateInodeVMObject(Inode& inode, size_t size) diff --git a/Kernel/VM/SharedInodeVMObject.cpp b/Kernel/VM/SharedInodeVMObject.cpp index 2114bbbdeb4..91e7873fb79 100644 --- a/Kernel/VM/SharedInodeVMObject.cpp +++ b/Kernel/VM/SharedInodeVMObject.cpp @@ -14,14 +14,14 @@ NonnullRefPtr SharedInodeVMObject::create_with_inode(Inode& size_t size = inode.size(); if (auto shared_vmobject = inode.shared_vmobject()) return shared_vmobject.release_nonnull(); - auto vmobject = adopt(*new SharedInodeVMObject(inode, size)); + auto vmobject = adopt_ref(*new SharedInodeVMObject(inode, size)); vmobject->inode().set_shared_vmobject(*vmobject); return vmobject; } RefPtr SharedInodeVMObject::clone() { - return adopt(*new SharedInodeVMObject(*this)); + return adopt_ref(*new SharedInodeVMObject(*this)); } SharedInodeVMObject::SharedInodeVMObject(Inode& inode, size_t size) diff --git a/Kernel/VirtIO/VirtIO.cpp b/Kernel/VirtIO/VirtIO.cpp index 4ef665f7f40..73e1f99d366 100644 --- a/Kernel/VirtIO/VirtIO.cpp +++ b/Kernel/VirtIO/VirtIO.cpp @@ -22,11 +22,11 @@ void VirtIO::detect() return; switch (id.device_id) { case VIRTIO_CONSOLE_PCI_DEVICE_ID: { - [[maybe_unused]] auto& unused = adopt(*new VirtIOConsole(address)).leak_ref(); + [[maybe_unused]] auto& unused = adopt_ref(*new VirtIOConsole(address)).leak_ref(); break; } case VIRTIO_ENTROPY_PCI_DEVICE_ID: { - [[maybe_unused]] auto& unused = adopt(*new VirtIORNG(address)).leak_ref(); + [[maybe_unused]] auto& unused = adopt_ref(*new VirtIORNG(address)).leak_ref(); break; } default: diff --git a/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp b/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp index a6936b6924a..c667c1c3347 100644 --- a/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp +++ b/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp @@ -10,7 +10,7 @@ NonnullRefPtr ClipboardHistoryModel::create() { - return adopt(*new ClipboardHistoryModel()); + return adopt_ref(*new ClipboardHistoryModel()); } ClipboardHistoryModel::~ClipboardHistoryModel() diff --git a/Userland/Applications/Browser/ConsoleWidget.cpp b/Userland/Applications/Browser/ConsoleWidget.cpp index 69b32ca3097..1b69c858f5c 100644 --- a/Userland/Applications/Browser/ConsoleWidget.cpp +++ b/Userland/Applications/Browser/ConsoleWidget.cpp @@ -30,7 +30,7 @@ ConsoleWidget::ConsoleWidget() set_fill_with_background_color(true); auto base_document = Web::DOM::Document::create(); - base_document->append_child(adopt(*new Web::DOM::DocumentType(base_document))); + base_document->append_child(adopt_ref(*new Web::DOM::DocumentType(base_document))); auto html_element = base_document->create_element("html"); base_document->append_child(html_element); auto head_element = base_document->create_element("head"); diff --git a/Userland/Applications/Calendar/AddEventDialog.h b/Userland/Applications/Calendar/AddEventDialog.h index 5998a402ab1..c400476764b 100644 --- a/Userland/Applications/Calendar/AddEventDialog.h +++ b/Userland/Applications/Calendar/AddEventDialog.h @@ -32,7 +32,7 @@ private: __Count, }; - static NonnullRefPtr create() { return adopt(*new MonthListModel); } + static NonnullRefPtr create() { return adopt_ref(*new MonthListModel); } virtual ~MonthListModel() override; virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp index 1336abbb1af..6e66ee9b4e4 100644 --- a/Userland/Applications/FileManager/DirectoryView.cpp +++ b/Userland/Applications/FileManager/DirectoryView.cpp @@ -118,7 +118,7 @@ NonnullRefPtrVector DirectoryView::get_launch_handlers(const UR { NonnullRefPtrVector handlers; for (auto& h : Desktop::Launcher::get_handlers_with_details_for_url(url)) { - handlers.append(adopt(*new LauncherHandler(h))); + handlers.append(adopt_ref(*new LauncherHandler(h))); } return handlers; } diff --git a/Userland/Applications/FontEditor/FontEditor.cpp b/Userland/Applications/FontEditor/FontEditor.cpp index 9ef1d6aed60..e6cc7bbaf81 100644 --- a/Userland/Applications/FontEditor/FontEditor.cpp +++ b/Userland/Applications/FontEditor/FontEditor.cpp @@ -481,7 +481,7 @@ void FontEditorWidget::initialize(const String& path, RefPtr&& }); m_undo_stack = make(); - m_undo_glyph = adopt(*new UndoGlyph(m_glyph_map_widget->selected_glyph(), *m_edited_font)); + m_undo_glyph = adopt_ref(*new UndoGlyph(m_glyph_map_widget->selected_glyph(), *m_edited_font)); did_change_undo_stack(); if (on_initialize) diff --git a/Userland/Applications/FontEditor/UndoGlyph.h b/Userland/Applications/FontEditor/UndoGlyph.h index c09e51d2546..bfda5dc1175 100644 --- a/Userland/Applications/FontEditor/UndoGlyph.h +++ b/Userland/Applications/FontEditor/UndoGlyph.h @@ -19,7 +19,7 @@ public: } RefPtr save_state() const { - auto state = adopt(*new UndoGlyph(m_code_point, *m_font)); + auto state = adopt_ref(*new UndoGlyph(m_code_point, *m_font)); auto glyph = font().glyph(m_code_point).glyph_bitmap(); for (int x = 0; x < glyph.width(); x++) for (int y = 0; y < glyph.height(); y++) diff --git a/Userland/Applications/Help/ManualModel.h b/Userland/Applications/Help/ManualModel.h index 936739751bd..39bd85360b1 100644 --- a/Userland/Applications/Help/ManualModel.h +++ b/Userland/Applications/Help/ManualModel.h @@ -16,7 +16,7 @@ class ManualModel final : public GUI::Model { public: static NonnullRefPtr create() { - return adopt(*new ManualModel); + return adopt_ref(*new ManualModel); } virtual ~ManualModel() override {}; diff --git a/Userland/Applications/IRCClient/IRCChannel.cpp b/Userland/Applications/IRCClient/IRCChannel.cpp index a4ebc7ca423..750acc43a05 100644 --- a/Userland/Applications/IRCClient/IRCChannel.cpp +++ b/Userland/Applications/IRCClient/IRCChannel.cpp @@ -25,7 +25,7 @@ IRCChannel::~IRCChannel() NonnullRefPtr IRCChannel::create(IRCClient& client, const String& name) { - return adopt(*new IRCChannel(client, name)); + return adopt_ref(*new IRCChannel(client, name)); } void IRCChannel::add_member(const String& name, char prefix) diff --git a/Userland/Applications/IRCClient/IRCChannelMemberListModel.h b/Userland/Applications/IRCClient/IRCChannelMemberListModel.h index 8e38ad32be5..5d3145be627 100644 --- a/Userland/Applications/IRCClient/IRCChannelMemberListModel.h +++ b/Userland/Applications/IRCClient/IRCChannelMemberListModel.h @@ -16,7 +16,7 @@ public: enum Column { Name }; - static NonnullRefPtr create(IRCChannel& channel) { return adopt(*new IRCChannelMemberListModel(channel)); } + static NonnullRefPtr create(IRCChannel& channel) { return adopt_ref(*new IRCChannelMemberListModel(channel)); } virtual ~IRCChannelMemberListModel() override; virtual int row_count(const GUI::ModelIndex&) const override; diff --git a/Userland/Applications/IRCClient/IRCLogBuffer.cpp b/Userland/Applications/IRCClient/IRCLogBuffer.cpp index d883db957eb..c6a8511e657 100644 --- a/Userland/Applications/IRCClient/IRCLogBuffer.cpp +++ b/Userland/Applications/IRCClient/IRCLogBuffer.cpp @@ -15,19 +15,19 @@ NonnullRefPtr IRCLogBuffer::create() { - return adopt(*new IRCLogBuffer); + return adopt_ref(*new IRCLogBuffer); } IRCLogBuffer::IRCLogBuffer() { m_document = Web::DOM::Document::create(); - m_document->append_child(adopt(*new Web::DOM::DocumentType(document()))); + m_document->append_child(adopt_ref(*new Web::DOM::DocumentType(document()))); auto html_element = m_document->create_element("html"); m_document->append_child(html_element); auto head_element = m_document->create_element("head"); html_element->append_child(head_element); auto style_element = m_document->create_element("style"); - style_element->append_child(adopt(*new Web::DOM::Text(document(), "div { font-family: Csilla; font-weight: lighter; }"))); + style_element->append_child(adopt_ref(*new Web::DOM::Text(document(), "div { font-family: Csilla; font-weight: lighter; }"))); head_element->append_child(style_element); auto body_element = m_document->create_element("body"); html_element->append_child(body_element); diff --git a/Userland/Applications/IRCClient/IRCQuery.cpp b/Userland/Applications/IRCClient/IRCQuery.cpp index 644377da4c6..bc939f371a7 100644 --- a/Userland/Applications/IRCClient/IRCQuery.cpp +++ b/Userland/Applications/IRCClient/IRCQuery.cpp @@ -23,7 +23,7 @@ IRCQuery::~IRCQuery() NonnullRefPtr IRCQuery::create(IRCClient& client, const String& name) { - return adopt(*new IRCQuery(client, name)); + return adopt_ref(*new IRCQuery(client, name)); } void IRCQuery::add_message(char prefix, const String& name, const String& text, Color color) diff --git a/Userland/Applications/IRCClient/IRCWindowListModel.h b/Userland/Applications/IRCClient/IRCWindowListModel.h index a0e33ed81a7..fce8f8e3c6f 100644 --- a/Userland/Applications/IRCClient/IRCWindowListModel.h +++ b/Userland/Applications/IRCClient/IRCWindowListModel.h @@ -18,7 +18,7 @@ public: Name, }; - static NonnullRefPtr create(IRCClient& client) { return adopt(*new IRCWindowListModel(client)); } + static NonnullRefPtr create(IRCClient& client) { return adopt_ref(*new IRCWindowListModel(client)); } virtual ~IRCWindowListModel() override; virtual int row_count(const GUI::ModelIndex&) const override; diff --git a/Userland/Applications/KeyboardSettings/CharacterMapFileListModel.h b/Userland/Applications/KeyboardSettings/CharacterMapFileListModel.h index 0ccc31166a1..d0585e1c46d 100644 --- a/Userland/Applications/KeyboardSettings/CharacterMapFileListModel.h +++ b/Userland/Applications/KeyboardSettings/CharacterMapFileListModel.h @@ -13,7 +13,7 @@ class CharacterMapFileListModel final : public GUI::Model { public: static NonnullRefPtr create(Vector& file_names) { - return adopt(*new CharacterMapFileListModel(file_names)); + return adopt_ref(*new CharacterMapFileListModel(file_names)); } virtual ~CharacterMapFileListModel() override { } diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp index db88941bfb7..62db2fac821 100644 --- a/Userland/Applications/PixelPaint/Image.cpp +++ b/Userland/Applications/PixelPaint/Image.cpp @@ -27,7 +27,7 @@ RefPtr Image::create_with_size(const Gfx::IntSize& size) if (size.width() > 16384 || size.height() > 16384) return nullptr; - return adopt(*new Image(size)); + return adopt_ref(*new Image(size)); } Image::Image(const Gfx::IntSize& size) diff --git a/Userland/Applications/PixelPaint/Layer.cpp b/Userland/Applications/PixelPaint/Layer.cpp index f81382e32d7..92ce3422b97 100644 --- a/Userland/Applications/PixelPaint/Layer.cpp +++ b/Userland/Applications/PixelPaint/Layer.cpp @@ -18,7 +18,7 @@ RefPtr Layer::create_with_size(Image& image, const Gfx::IntSize& size, co if (size.width() > 16384 || size.height() > 16384) return nullptr; - return adopt(*new Layer(image, size, name)); + return adopt_ref(*new Layer(image, size, name)); } RefPtr Layer::create_with_bitmap(Image& image, const Gfx::Bitmap& bitmap, const String& name) @@ -29,7 +29,7 @@ RefPtr Layer::create_with_bitmap(Image& image, const Gfx::Bitmap& bitmap, if (bitmap.size().width() > 16384 || bitmap.size().height() > 16384) return nullptr; - return adopt(*new Layer(image, bitmap, name)); + return adopt_ref(*new Layer(image, bitmap, name)); } RefPtr Layer::create_snapshot(Image& image, const Layer& layer) diff --git a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp index 356dea2e786..07c358700e1 100644 --- a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp +++ b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp @@ -35,7 +35,7 @@ SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window set_layout(); m_splitter = add(); m_player_view = m_splitter->add(); - m_playlist_model = adopt(*new PlaylistModel()); + m_playlist_model = adopt_ref(*new PlaylistModel()); m_player_view->set_layout(); diff --git a/Userland/Applications/SpaceAnalyzer/main.cpp b/Userland/Applications/SpaceAnalyzer/main.cpp index 440db2a39e7..c28f0da7fef 100644 --- a/Userland/Applications/SpaceAnalyzer/main.cpp +++ b/Userland/Applications/SpaceAnalyzer/main.cpp @@ -253,7 +253,7 @@ int main(int argc, char* argv[]) { auto app = GUI::Application::construct(argc, argv); - RefPtr tree = adopt(*new Tree("")); + RefPtr tree = adopt_ref(*new Tree("")); // Configure application window. auto app_icon = GUI::Icon::default_icon("app-space-analyzer"); diff --git a/Userland/Applications/Spreadsheet/HelpWindow.cpp b/Userland/Applications/Spreadsheet/HelpWindow.cpp index a1f49fd739c..0ee42e3709d 100644 --- a/Userland/Applications/Spreadsheet/HelpWindow.cpp +++ b/Userland/Applications/Spreadsheet/HelpWindow.cpp @@ -21,7 +21,7 @@ namespace Spreadsheet { class HelpListModel final : public GUI::Model { public: - static NonnullRefPtr create() { return adopt(*new HelpListModel); } + static NonnullRefPtr create() { return adopt_ref(*new HelpListModel); } virtual ~HelpListModel() override { } diff --git a/Userland/Applications/Spreadsheet/HelpWindow.h b/Userland/Applications/Spreadsheet/HelpWindow.h index 29029d5c05a..d5756c81c0c 100644 --- a/Userland/Applications/Spreadsheet/HelpWindow.h +++ b/Userland/Applications/Spreadsheet/HelpWindow.h @@ -23,7 +23,7 @@ public: if (s_the) return *s_the; - return *(s_the = adopt(*new HelpWindow(window))); + return *(s_the = adopt_ref(*new HelpWindow(window))); } virtual ~HelpWindow() override; diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp index 1f5e3439039..30db02f98b5 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp +++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp @@ -359,7 +359,7 @@ void Sheet::copy_cells(Vector from, Vector to, Optional Sheet::from_json(const JsonObject& object, Workbook& workbook) { - auto sheet = adopt(*new Sheet(workbook)); + auto sheet = adopt_ref(*new Sheet(workbook)); auto rows = object.get("rows").to_u32(default_row_count); auto columns = object.get("columns"); auto name = object.get("name").as_string_or("Sheet"); @@ -617,7 +617,7 @@ RefPtr Sheet::from_xsv(const Reader::XSV& xsv, Workbook& workbook) auto cols = xsv.headers(); auto rows = xsv.size(); - auto sheet = adopt(*new Sheet(workbook)); + auto sheet = adopt_ref(*new Sheet(workbook)); if (xsv.has_explicit_headers()) { sheet->m_columns = cols; } else { diff --git a/Userland/Applications/Spreadsheet/SpreadsheetModel.h b/Userland/Applications/Spreadsheet/SpreadsheetModel.h index 6626c011f26..0eb77e36007 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetModel.h +++ b/Userland/Applications/Spreadsheet/SpreadsheetModel.h @@ -13,7 +13,7 @@ namespace Spreadsheet { class SheetModel final : public GUI::Model { public: - static NonnullRefPtr create(Sheet& sheet) { return adopt(*new SheetModel(sheet)); } + static NonnullRefPtr create(Sheet& sheet) { return adopt_ref(*new SheetModel(sheet)); } virtual ~SheetModel() override; virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return m_sheet->row_count(); } diff --git a/Userland/Applications/SystemMonitor/DevicesModel.cpp b/Userland/Applications/SystemMonitor/DevicesModel.cpp index 22abd5c9e1e..08b578aa984 100644 --- a/Userland/Applications/SystemMonitor/DevicesModel.cpp +++ b/Userland/Applications/SystemMonitor/DevicesModel.cpp @@ -14,7 +14,7 @@ NonnullRefPtr DevicesModel::create() { - return adopt(*new DevicesModel); + return adopt_ref(*new DevicesModel); } DevicesModel::DevicesModel() diff --git a/Userland/Applications/SystemMonitor/ProcessModel.h b/Userland/Applications/SystemMonitor/ProcessModel.h index e928f360b3b..3ca2f8e2485 100644 --- a/Userland/Applications/SystemMonitor/ProcessModel.h +++ b/Userland/Applications/SystemMonitor/ProcessModel.h @@ -53,7 +53,7 @@ public: static ProcessModel& the(); - static NonnullRefPtr create() { return adopt(*new ProcessModel); } + static NonnullRefPtr create() { return adopt_ref(*new ProcessModel); } virtual ~ProcessModel() override; virtual int row_count(const GUI::ModelIndex&) const override; diff --git a/Userland/Applications/SystemMonitor/ProcessStateWidget.cpp b/Userland/Applications/SystemMonitor/ProcessStateWidget.cpp index 91bdbdeb3f8..c7a0b6b8f38 100644 --- a/Userland/Applications/SystemMonitor/ProcessStateWidget.cpp +++ b/Userland/Applications/SystemMonitor/ProcessStateWidget.cpp @@ -88,7 +88,7 @@ ProcessStateWidget::ProcessStateWidget(pid_t pid) m_table_view = add(); m_table_view->column_header().set_visible(false); m_table_view->column_header().set_section_size(0, 90); - m_table_view->set_model(adopt(*new ProcessStateModel(ProcessModel::the(), pid))); + m_table_view->set_model(adopt_ref(*new ProcessStateModel(ProcessModel::the(), pid))); } ProcessStateWidget::~ProcessStateWidget() diff --git a/Userland/Applications/ThemeEditor/main.cpp b/Userland/Applications/ThemeEditor/main.cpp index 6e612afaf78..be2e37154f3 100644 --- a/Userland/Applications/ThemeEditor/main.cpp +++ b/Userland/Applications/ThemeEditor/main.cpp @@ -95,7 +95,7 @@ int main(int argc, char** argv) #undef __ENUMERATE_COLOR_ROLE combo_box.set_only_allow_values_from_model(true); - combo_box.set_model(adopt(*new ColorRoleModel(color_roles))); + combo_box.set_model(adopt_ref(*new ColorRoleModel(color_roles))); combo_box.on_change = [&](auto&, auto& index) { auto role = static_cast(index.model())->color_role(index); color_input.set_color(preview_palette.color(role)); diff --git a/Userland/Demos/WidgetGallery/GalleryModels.h b/Userland/Demos/WidgetGallery/GalleryModels.h index 9a29d320e94..a42153ee023 100644 --- a/Userland/Demos/WidgetGallery/GalleryModels.h +++ b/Userland/Demos/WidgetGallery/GalleryModels.h @@ -13,7 +13,7 @@ class MouseCursorModel final : public GUI::Model { public: - static NonnullRefPtr create() { return adopt(*new MouseCursorModel); } + static NonnullRefPtr create() { return adopt_ref(*new MouseCursorModel); } virtual ~MouseCursorModel() override { } enum Column { @@ -86,7 +86,7 @@ private: class FileIconsModel final : public GUI::Model { public: - static NonnullRefPtr create() { return adopt(*new FileIconsModel); } + static NonnullRefPtr create() { return adopt_ref(*new FileIconsModel); } virtual ~FileIconsModel() override { } enum Column { diff --git a/Userland/DevTools/HackStudio/ClassViewWidget.cpp b/Userland/DevTools/HackStudio/ClassViewWidget.cpp index 820da3cb080..4f05ac67f6e 100644 --- a/Userland/DevTools/HackStudio/ClassViewWidget.cpp +++ b/Userland/DevTools/HackStudio/ClassViewWidget.cpp @@ -33,7 +33,7 @@ ClassViewWidget::ClassViewWidget() RefPtr ClassViewModel::create() { - return adopt(*new ClassViewModel()); + return adopt_ref(*new ClassViewModel()); } int ClassViewModel::row_count(const GUI::ModelIndex& index) const diff --git a/Userland/DevTools/HackStudio/CodeDocument.cpp b/Userland/DevTools/HackStudio/CodeDocument.cpp index 43078fe2056..bc08806b595 100644 --- a/Userland/DevTools/HackStudio/CodeDocument.cpp +++ b/Userland/DevTools/HackStudio/CodeDocument.cpp @@ -10,12 +10,12 @@ namespace HackStudio { NonnullRefPtr CodeDocument::create(const String& file_path, Client* client) { - return adopt(*new CodeDocument(file_path, client)); + return adopt_ref(*new CodeDocument(file_path, client)); } NonnullRefPtr CodeDocument::create(Client* client) { - return adopt(*new CodeDocument(client)); + return adopt_ref(*new CodeDocument(client)); } CodeDocument::CodeDocument(const String& file_path, Client* client) diff --git a/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp b/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp index 03b103929d5..4cc245ee922 100644 --- a/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp +++ b/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp @@ -12,7 +12,7 @@ namespace HackStudio { NonnullRefPtr BacktraceModel::create(const Debug::DebugSession& debug_session, const PtraceRegisters& regs) { - return adopt(*new BacktraceModel(create_backtrace(debug_session, regs))); + return adopt_ref(*new BacktraceModel(create_backtrace(debug_session, regs))); } GUI::Variant BacktraceModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const diff --git a/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h b/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h index 870ccd853e6..ba856bcb6c3 100644 --- a/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h +++ b/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h @@ -30,7 +30,7 @@ class DisassemblyModel final : public GUI::Model { public: static NonnullRefPtr create(const Debug::DebugSession& debug_session, const PtraceRegisters& regs) { - return adopt(*new DisassemblyModel(debug_session, regs)); + return adopt_ref(*new DisassemblyModel(debug_session, regs)); } enum Column { diff --git a/Userland/DevTools/HackStudio/Debugger/RegistersModel.h b/Userland/DevTools/HackStudio/Debugger/RegistersModel.h index e540391234f..cc984f86f24 100644 --- a/Userland/DevTools/HackStudio/Debugger/RegistersModel.h +++ b/Userland/DevTools/HackStudio/Debugger/RegistersModel.h @@ -22,12 +22,12 @@ class RegistersModel final : public GUI::Model { public: static RefPtr create(const PtraceRegisters& regs) { - return adopt(*new RegistersModel(regs)); + return adopt_ref(*new RegistersModel(regs)); } static RefPtr create(const PtraceRegisters& current_regs, const PtraceRegisters& previous_regs) { - return adopt(*new RegistersModel(current_regs, previous_regs)); + return adopt_ref(*new RegistersModel(current_regs, previous_regs)); } enum Column { diff --git a/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp b/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp index c5a8d171885..40749baed95 100644 --- a/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp +++ b/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp @@ -169,7 +169,7 @@ RefPtr VariablesModel::create(const PtraceRegisters& regs) if (!lib) return nullptr; auto variables = lib->debug_info->get_variables_in_current_scope(regs); - return adopt(*new VariablesModel(move(variables), regs)); + return adopt_ref(*new VariablesModel(move(variables), regs)); } } diff --git a/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.h b/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.h index c52f2db1b16..4674a738cfa 100644 --- a/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.h +++ b/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.h @@ -19,7 +19,7 @@ class ProjectTemplatesModel final : public GUI::Model { public: static NonnullRefPtr create() { - return adopt(*new ProjectTemplatesModel()); + return adopt_ref(*new ProjectTemplatesModel()); } enum Column { diff --git a/Userland/DevTools/HackStudio/FindInFilesWidget.cpp b/Userland/DevTools/HackStudio/FindInFilesWidget.cpp index a82a9c0c3d6..7bc50f0da84 100644 --- a/Userland/DevTools/HackStudio/FindInFilesWidget.cpp +++ b/Userland/DevTools/HackStudio/FindInFilesWidget.cpp @@ -110,7 +110,7 @@ static RefPtr find_in_files(const StringView& text) } }); - return adopt(*new SearchResultsModel(move(matches))); + return adopt_ref(*new SearchResultsModel(move(matches))); } FindInFilesWidget::FindInFilesWidget() diff --git a/Userland/DevTools/HackStudio/Git/GitFilesModel.cpp b/Userland/DevTools/HackStudio/Git/GitFilesModel.cpp index 89b24e4691d..99cb8a6f4e5 100644 --- a/Userland/DevTools/HackStudio/Git/GitFilesModel.cpp +++ b/Userland/DevTools/HackStudio/Git/GitFilesModel.cpp @@ -10,7 +10,7 @@ namespace HackStudio { NonnullRefPtr GitFilesModel::create(Vector&& files) { - return adopt(*new GitFilesModel(move(files))); + return adopt_ref(*new GitFilesModel(move(files))); } GitFilesModel::GitFilesModel(Vector&& files) diff --git a/Userland/DevTools/HackStudio/Git/GitRepo.cpp b/Userland/DevTools/HackStudio/Git/GitRepo.cpp index 50506fd13a3..f42f8329944 100644 --- a/Userland/DevTools/HackStudio/Git/GitRepo.cpp +++ b/Userland/DevTools/HackStudio/Git/GitRepo.cpp @@ -20,7 +20,7 @@ GitRepo::CreateResult GitRepo::try_to_create(const LexicalPath& repository_root) return { CreateResult::Type::NoGitRepo, nullptr }; } - return { CreateResult::Type::Success, adopt(*new GitRepo(repository_root)) }; + return { CreateResult::Type::Success, adopt_ref(*new GitRepo(repository_root)) }; } RefPtr GitRepo::initialize_repository(const LexicalPath& repository_root) @@ -30,7 +30,7 @@ RefPtr GitRepo::initialize_repository(const LexicalPath& repository_roo return {}; VERIFY(git_repo_exists(repository_root)); - return adopt(*new GitRepo(repository_root)); + return adopt_ref(*new GitRepo(repository_root)); } Vector GitRepo::unstaged_files() const diff --git a/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp b/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp index ee608fba20f..0dc64cb6a35 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp @@ -26,7 +26,7 @@ RefPtr FileDB::get(const String& file_name) auto document = reinterpret_cast(this)->get(file_name); if (document.is_null()) return nullptr; - return adopt(*const_cast(document.leak_ref())); + return adopt_ref(*const_cast(document.leak_ref())); } RefPtr FileDB::get_or_create_from_filesystem(const String& file_name) const @@ -43,7 +43,7 @@ RefPtr FileDB::get_or_create_from_filesystem(const String& fi auto document = reinterpret_cast(this)->get_or_create_from_filesystem(file_name); if (document.is_null()) return nullptr; - return adopt(*const_cast(document.leak_ref())); + return adopt_ref(*const_cast(document.leak_ref())); } bool FileDB::is_open(const String& file_name) const diff --git a/Userland/DevTools/HackStudio/Locator.cpp b/Userland/DevTools/HackStudio/Locator.cpp index 3d24bca48a4..44eba20f231 100644 --- a/Userland/DevTools/HackStudio/Locator.cpp +++ b/Userland/DevTools/HackStudio/Locator.cpp @@ -211,7 +211,7 @@ void Locator::update_suggestions() bool has_suggestions = !suggestions.is_empty(); - m_suggestion_view->set_model(adopt(*new LocatorSuggestionModel(move(suggestions)))); + m_suggestion_view->set_model(adopt_ref(*new LocatorSuggestionModel(move(suggestions)))); if (!has_suggestions) m_suggestion_view->selection().clear(); diff --git a/Userland/DevTools/HackStudio/ProjectFile.h b/Userland/DevTools/HackStudio/ProjectFile.h index c44362e8b03..72fc3e7a240 100644 --- a/Userland/DevTools/HackStudio/ProjectFile.h +++ b/Userland/DevTools/HackStudio/ProjectFile.h @@ -18,7 +18,7 @@ class ProjectFile : public RefCounted { public: static NonnullRefPtr construct_with_name(const String& name) { - return adopt(*new ProjectFile(name)); + return adopt_ref(*new ProjectFile(name)); } const String& name() const { return m_name; } diff --git a/Userland/DevTools/HackStudio/ProjectTemplate.cpp b/Userland/DevTools/HackStudio/ProjectTemplate.cpp index 84e8b95d0bc..8c0f6c3f82a 100644 --- a/Userland/DevTools/HackStudio/ProjectTemplate.cpp +++ b/Userland/DevTools/HackStudio/ProjectTemplate.cpp @@ -62,7 +62,7 @@ RefPtr ProjectTemplate::load_from_manifest(const String& manife icon = GUI::Icon(move(bitmap32)); } - return adopt(*new ProjectTemplate(id, name, description, icon, priority)); + return adopt_ref(*new ProjectTemplate(id, name, description, icon, priority)); } Result ProjectTemplate::create_project(const String& name, const String& path) diff --git a/Userland/DevTools/HackStudio/WidgetTreeModel.h b/Userland/DevTools/HackStudio/WidgetTreeModel.h index f487aacf3ea..c8dacf9e543 100644 --- a/Userland/DevTools/HackStudio/WidgetTreeModel.h +++ b/Userland/DevTools/HackStudio/WidgetTreeModel.h @@ -13,7 +13,7 @@ namespace HackStudio { class WidgetTreeModel final : public GUI::Model { public: - static NonnullRefPtr create(GUI::Widget& root) { return adopt(*new WidgetTreeModel(root)); } + static NonnullRefPtr create(GUI::Widget& root) { return adopt_ref(*new WidgetTreeModel(root)); } virtual ~WidgetTreeModel() override; virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; diff --git a/Userland/DevTools/Inspector/RemoteObjectGraphModel.h b/Userland/DevTools/Inspector/RemoteObjectGraphModel.h index ae8986e7532..dd2aec79481 100644 --- a/Userland/DevTools/Inspector/RemoteObjectGraphModel.h +++ b/Userland/DevTools/Inspector/RemoteObjectGraphModel.h @@ -20,7 +20,7 @@ class RemoteObjectGraphModel final : public GUI::Model { public: static NonnullRefPtr create(RemoteProcess& process) { - return adopt(*new RemoteObjectGraphModel(process)); + return adopt_ref(*new RemoteObjectGraphModel(process)); } virtual ~RemoteObjectGraphModel() override; diff --git a/Userland/DevTools/Inspector/RemoteObjectPropertyModel.h b/Userland/DevTools/Inspector/RemoteObjectPropertyModel.h index d8f1d263527..fca20109fe2 100644 --- a/Userland/DevTools/Inspector/RemoteObjectPropertyModel.h +++ b/Userland/DevTools/Inspector/RemoteObjectPropertyModel.h @@ -20,7 +20,7 @@ public: virtual ~RemoteObjectPropertyModel() override { } static NonnullRefPtr create(RemoteObject& object) { - return adopt(*new RemoteObjectPropertyModel(object)); + return adopt_ref(*new RemoteObjectPropertyModel(object)); } enum Column { diff --git a/Userland/DevTools/Profiler/DisassemblyModel.h b/Userland/DevTools/Profiler/DisassemblyModel.h index 961570a0c98..382c384fde0 100644 --- a/Userland/DevTools/Profiler/DisassemblyModel.h +++ b/Userland/DevTools/Profiler/DisassemblyModel.h @@ -25,7 +25,7 @@ class DisassemblyModel final : public GUI::Model { public: static NonnullRefPtr create(Profile& profile, ProfileNode& node) { - return adopt(*new DisassemblyModel(profile, node)); + return adopt_ref(*new DisassemblyModel(profile, node)); } enum Column { diff --git a/Userland/DevTools/Profiler/IndividualSampleModel.h b/Userland/DevTools/Profiler/IndividualSampleModel.h index cdd70089671..7ff5dacd733 100644 --- a/Userland/DevTools/Profiler/IndividualSampleModel.h +++ b/Userland/DevTools/Profiler/IndividualSampleModel.h @@ -14,7 +14,7 @@ class IndividualSampleModel final : public GUI::Model { public: static NonnullRefPtr create(Profile& profile, size_t event_index) { - return adopt(*new IndividualSampleModel(profile, event_index)); + return adopt_ref(*new IndividualSampleModel(profile, event_index)); } enum Column { diff --git a/Userland/DevTools/Profiler/Profile.h b/Userland/DevTools/Profiler/Profile.h index 54e5c34bc98..659d0b6d126 100644 --- a/Userland/DevTools/Profiler/Profile.h +++ b/Userland/DevTools/Profiler/Profile.h @@ -71,7 +71,7 @@ class ProfileNode : public RefCounted { public: static NonnullRefPtr create(FlyString object_name, String symbol, u32 address, u32 offset, u64 timestamp, pid_t pid) { - return adopt(*new ProfileNode(move(object_name), move(symbol), address, offset, timestamp, pid)); + return adopt_ref(*new ProfileNode(move(object_name), move(symbol), address, offset, timestamp, pid)); } // These functions are only relevant for root nodes diff --git a/Userland/DevTools/Profiler/ProfileModel.h b/Userland/DevTools/Profiler/ProfileModel.h index 21ebbc837e7..b9612c28948 100644 --- a/Userland/DevTools/Profiler/ProfileModel.h +++ b/Userland/DevTools/Profiler/ProfileModel.h @@ -14,7 +14,7 @@ class ProfileModel final : public GUI::Model { public: static NonnullRefPtr create(Profile& profile) { - return adopt(*new ProfileModel(profile)); + return adopt_ref(*new ProfileModel(profile)); } enum Column { diff --git a/Userland/DevTools/Profiler/SamplesModel.h b/Userland/DevTools/Profiler/SamplesModel.h index d3ef72556e5..9ebf18c049d 100644 --- a/Userland/DevTools/Profiler/SamplesModel.h +++ b/Userland/DevTools/Profiler/SamplesModel.h @@ -14,7 +14,7 @@ class SamplesModel final : public GUI::Model { public: static NonnullRefPtr create(Profile& profile) { - return adopt(*new SamplesModel(profile)); + return adopt_ref(*new SamplesModel(profile)); } enum Column { diff --git a/Userland/Libraries/LibAudio/Buffer.h b/Userland/Libraries/LibAudio/Buffer.h index bf9f7bfa306..fda5e0ef9cb 100644 --- a/Userland/Libraries/LibAudio/Buffer.h +++ b/Userland/Libraries/LibAudio/Buffer.h @@ -93,11 +93,11 @@ public: static RefPtr from_pcm_stream(InputMemoryStream& stream, ResampleHelper& resampler, int num_channels, int bits_per_sample, int num_samples); static NonnullRefPtr create_with_samples(Vector&& samples) { - return adopt(*new Buffer(move(samples))); + return adopt_ref(*new Buffer(move(samples))); } static NonnullRefPtr create_with_anonymous_buffer(Core::AnonymousBuffer buffer, i32 buffer_id, int sample_count) { - return adopt(*new Buffer(move(buffer), buffer_id, sample_count)); + return adopt_ref(*new Buffer(move(buffer), buffer_id, sample_count)); } const Frame* samples() const { return (const Frame*)data(); } diff --git a/Userland/Libraries/LibAudio/Loader.h b/Userland/Libraries/LibAudio/Loader.h index 1e92262079f..5cd605934df 100644 --- a/Userland/Libraries/LibAudio/Loader.h +++ b/Userland/Libraries/LibAudio/Loader.h @@ -39,8 +39,8 @@ public: class Loader : public RefCounted { public: - static NonnullRefPtr create(const StringView& path) { return adopt(*new Loader(path)); } - static NonnullRefPtr create(const ByteBuffer& buffer) { return adopt(*new Loader(buffer)); } + static NonnullRefPtr create(const StringView& path) { return adopt_ref(*new Loader(path)); } + static NonnullRefPtr create(const ByteBuffer& buffer) { return adopt_ref(*new Loader(buffer)); } bool has_error() const { return m_plugin ? m_plugin->has_error() : true; } const char* error_string() const { return m_plugin ? m_plugin->error_string() : "No loader plugin available"; } diff --git a/Userland/Libraries/LibCore/AnonymousBuffer.cpp b/Userland/Libraries/LibCore/AnonymousBuffer.cpp index f0a8033490b..1c733999137 100644 --- a/Userland/Libraries/LibCore/AnonymousBuffer.cpp +++ b/Userland/Libraries/LibCore/AnonymousBuffer.cpp @@ -61,7 +61,7 @@ RefPtr AnonymousBufferImpl::create(int fd, size_t size) perror("mmap"); return {}; } - return adopt(*new AnonymousBufferImpl(fd, size, data)); + return adopt_ref(*new AnonymousBufferImpl(fd, size, data)); } AnonymousBufferImpl::~AnonymousBufferImpl() diff --git a/Userland/Libraries/LibCore/ConfigFile.cpp b/Userland/Libraries/LibCore/ConfigFile.cpp index f55ec626ef8..7bb69df9acb 100644 --- a/Userland/Libraries/LibCore/ConfigFile.cpp +++ b/Userland/Libraries/LibCore/ConfigFile.cpp @@ -20,25 +20,25 @@ NonnullRefPtr ConfigFile::get_for_lib(const String& lib_name) String directory = StandardPaths::config_directory(); auto path = String::formatted("{}/lib/{}.ini", directory, lib_name); - return adopt(*new ConfigFile(path)); + return adopt_ref(*new ConfigFile(path)); } NonnullRefPtr ConfigFile::get_for_app(const String& app_name) { String directory = StandardPaths::config_directory(); auto path = String::formatted("{}/{}.ini", directory, app_name); - return adopt(*new ConfigFile(path)); + return adopt_ref(*new ConfigFile(path)); } NonnullRefPtr ConfigFile::get_for_system(const String& app_name) { auto path = String::formatted("/etc/{}.ini", app_name); - return adopt(*new ConfigFile(path)); + return adopt_ref(*new ConfigFile(path)); } NonnullRefPtr ConfigFile::open(const String& path) { - return adopt(*new ConfigFile(path)); + return adopt_ref(*new ConfigFile(path)); } ConfigFile::ConfigFile(const String& file_name) diff --git a/Userland/Libraries/LibCore/EventLoop.cpp b/Userland/Libraries/LibCore/EventLoop.cpp index 0e91e6825a4..3fee668783f 100644 --- a/Userland/Libraries/LibCore/EventLoop.cpp +++ b/Userland/Libraries/LibCore/EventLoop.cpp @@ -525,7 +525,7 @@ int EventLoop::register_signal(int signo, Function handler) auto& info = *signals_info(); auto handlers = info.signal_handlers.find(signo); if (handlers == info.signal_handlers.end()) { - auto signal_handlers = adopt(*new SignalHandlers(signo, EventLoop::handle_signal)); + auto signal_handlers = adopt_ref(*new SignalHandlers(signo, EventLoop::handle_signal)); auto handler_id = signal_handlers->add(move(handler)); info.signal_handlers.set(signo, move(signal_handlers)); return handler_id; diff --git a/Userland/Libraries/LibCore/FileWatcher.cpp b/Userland/Libraries/LibCore/FileWatcher.cpp index 67113999db7..a023434931b 100644 --- a/Userland/Libraries/LibCore/FileWatcher.cpp +++ b/Userland/Libraries/LibCore/FileWatcher.cpp @@ -103,7 +103,7 @@ Result, String> FileWatcher::watch(const String& path dbgln_if(FILE_WATCHER_DEBUG, "Started watcher for file '{}'", path.characters()); auto notifier = Notifier::construct(watch_fd, Notifier::Event::Read); - return adopt(*new FileWatcher(move(notifier), move(path))); + return adopt_ref(*new FileWatcher(move(notifier), move(path))); } FileWatcher::FileWatcher(NonnullRefPtr notifier, const String& path) diff --git a/Userland/Libraries/LibCore/Object.h b/Userland/Libraries/LibCore/Object.h index cf0dc7cef1d..c171c395f7e 100644 --- a/Userland/Libraries/LibCore/Object.h +++ b/Userland/Libraries/LibCore/Object.h @@ -32,7 +32,7 @@ public: \ template \ static inline NonnullRefPtr construct(Args&&... args) \ { \ - return adopt(*new klass(forward(args)...)); \ + return adopt_ref(*new klass(forward(args)...)); \ } #define C_OBJECT_ABSTRACT(klass) \ diff --git a/Userland/Libraries/LibCore/Timer.h b/Userland/Libraries/LibCore/Timer.h index 32d36ab0ebf..7e790224f03 100644 --- a/Userland/Libraries/LibCore/Timer.h +++ b/Userland/Libraries/LibCore/Timer.h @@ -17,13 +17,13 @@ class Timer final : public Object { public: static NonnullRefPtr create_repeating(int interval, Function&& timeout_handler, Object* parent = nullptr) { - auto timer = adopt(*new Timer(interval, move(timeout_handler), parent)); + auto timer = adopt_ref(*new Timer(interval, move(timeout_handler), parent)); timer->stop(); return timer; } static NonnullRefPtr create_single_shot(int interval, Function&& timeout_handler, Object* parent = nullptr) { - auto timer = adopt(*new Timer(interval, move(timeout_handler), parent)); + auto timer = adopt_ref(*new Timer(interval, move(timeout_handler), parent)); timer->set_single_shot(true); timer->stop(); return timer; diff --git a/Userland/Libraries/LibCpp/Parser.h b/Userland/Libraries/LibCpp/Parser.h index 085d4edcdb9..90107c398d2 100644 --- a/Userland/Libraries/LibCpp/Parser.h +++ b/Userland/Libraries/LibCpp/Parser.h @@ -139,7 +139,7 @@ private: NonnullRefPtr create_ast_node(ASTNode& parent, const Position& start, Optional end, Args&&... args) { - auto node = adopt(*new T(&parent, start, end, m_filename, forward(args)...)); + auto node = adopt_ref(*new T(&parent, start, end, m_filename, forward(args)...)); if (!parent.is_dummy_node()) { m_state.nodes.append(node); } @@ -149,7 +149,7 @@ private: NonnullRefPtr create_root_ast_node(const Position& start, Position end) { - auto node = adopt(*new TranslationUnit(nullptr, start, end, m_filename)); + auto node = adopt_ref(*new TranslationUnit(nullptr, start, end, m_filename)); m_state.nodes.append(node); m_root_node = node; return node; @@ -157,7 +157,7 @@ private: DummyAstNode& get_dummy_node() { - static NonnullRefPtr dummy = adopt(*new DummyAstNode(nullptr, {}, {}, {})); + static NonnullRefPtr dummy = adopt_ref(*new DummyAstNode(nullptr, {}, {}, {})); return dummy; } diff --git a/Userland/Libraries/LibDesktop/AppFile.cpp b/Userland/Libraries/LibDesktop/AppFile.cpp index ecb4b318c55..dee54d7631f 100644 --- a/Userland/Libraries/LibDesktop/AppFile.cpp +++ b/Userland/Libraries/LibDesktop/AppFile.cpp @@ -20,7 +20,7 @@ NonnullRefPtr AppFile::get_for_app(const StringView& app_name) NonnullRefPtr AppFile::open(const StringView& path) { - return adopt(*new AppFile(path)); + return adopt_ref(*new AppFile(path)); } void AppFile::for_each(Function)> callback, const StringView& directory) diff --git a/Userland/Libraries/LibDesktop/Launcher.cpp b/Userland/Libraries/LibDesktop/Launcher.cpp index 90ce83bc7ea..da1a321c356 100644 --- a/Userland/Libraries/LibDesktop/Launcher.cpp +++ b/Userland/Libraries/LibDesktop/Launcher.cpp @@ -16,7 +16,7 @@ namespace Desktop { auto Launcher::Details::from_details_str(const String& details_str) -> NonnullRefPtr
{ - auto details = adopt(*new Details); + auto details = adopt_ref(*new Details); auto json = JsonValue::from_string(details_str); VERIFY(json.has_value()); auto obj = json.value().as_object(); diff --git a/Userland/Libraries/LibELF/DynamicLoader.cpp b/Userland/Libraries/LibELF/DynamicLoader.cpp index 5eeac24cd56..d211617dfa7 100644 --- a/Userland/Libraries/LibELF/DynamicLoader.cpp +++ b/Userland/Libraries/LibELF/DynamicLoader.cpp @@ -54,7 +54,7 @@ RefPtr DynamicLoader::try_create(int fd, String filename) return {}; } - return adopt(*new DynamicLoader(fd, move(filename), data, size)); + return adopt_ref(*new DynamicLoader(fd, move(filename), data, size)); } DynamicLoader::DynamicLoader(int fd, String filename, void* data, size_t size) diff --git a/Userland/Libraries/LibELF/DynamicObject.cpp b/Userland/Libraries/LibELF/DynamicObject.cpp index cd101632ea3..7c5b2957cf5 100644 --- a/Userland/Libraries/LibELF/DynamicObject.cpp +++ b/Userland/Libraries/LibELF/DynamicObject.cpp @@ -444,7 +444,7 @@ auto DynamicObject::lookup_symbol(const StringView& name, u32 gnu_hash, u32 sysv NonnullRefPtr DynamicObject::create(const String& filename, VirtualAddress base_address, VirtualAddress dynamic_section_address) { - return adopt(*new DynamicObject(filename, base_address, dynamic_section_address)); + return adopt_ref(*new DynamicObject(filename, base_address, dynamic_section_address)); } // offset is in PLT relocation table diff --git a/Userland/Libraries/LibGUI/Action.cpp b/Userland/Libraries/LibGUI/Action.cpp index 666bbbf5956..64aee3d1015 100644 --- a/Userland/Libraries/LibGUI/Action.cpp +++ b/Userland/Libraries/LibGUI/Action.cpp @@ -158,42 +158,42 @@ NonnullRefPtr make_properties_action(Function callback, C NonnullRefPtr Action::create(String text, Function callback, Core::Object* parent) { - return adopt(*new Action(move(text), move(callback), parent)); + return adopt_ref(*new Action(move(text), move(callback), parent)); } NonnullRefPtr Action::create(String text, RefPtr icon, Function callback, Core::Object* parent) { - return adopt(*new Action(move(text), move(icon), move(callback), parent)); + return adopt_ref(*new Action(move(text), move(icon), move(callback), parent)); } NonnullRefPtr Action::create(String text, const Shortcut& shortcut, Function callback, Core::Object* parent) { - return adopt(*new Action(move(text), shortcut, move(callback), parent)); + return adopt_ref(*new Action(move(text), shortcut, move(callback), parent)); } NonnullRefPtr Action::create(String text, const Shortcut& shortcut, RefPtr icon, Function callback, Core::Object* parent) { - return adopt(*new Action(move(text), shortcut, move(icon), move(callback), parent)); + return adopt_ref(*new Action(move(text), shortcut, move(icon), move(callback), parent)); } NonnullRefPtr Action::create_checkable(String text, Function callback, Core::Object* parent) { - return adopt(*new Action(move(text), move(callback), parent, true)); + return adopt_ref(*new Action(move(text), move(callback), parent, true)); } NonnullRefPtr Action::create_checkable(String text, RefPtr icon, Function callback, Core::Object* parent) { - return adopt(*new Action(move(text), move(icon), move(callback), parent, true)); + return adopt_ref(*new Action(move(text), move(icon), move(callback), parent, true)); } NonnullRefPtr Action::create_checkable(String text, const Shortcut& shortcut, Function callback, Core::Object* parent) { - return adopt(*new Action(move(text), shortcut, move(callback), parent, true)); + return adopt_ref(*new Action(move(text), shortcut, move(callback), parent, true)); } NonnullRefPtr Action::create_checkable(String text, const Shortcut& shortcut, RefPtr icon, Function callback, Core::Object* parent) { - return adopt(*new Action(move(text), shortcut, move(icon), move(callback), parent, true)); + return adopt_ref(*new Action(move(text), shortcut, move(icon), move(callback), parent, true)); } Action::Action(String text, Function on_activation_callback, Core::Object* parent, bool checkable) diff --git a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp index 306b5c2355b..990eefd06e6 100644 --- a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp +++ b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp @@ -98,7 +98,7 @@ void AutocompleteBox::update_suggestions(Vector&& s auto& model = *static_cast(m_suggestion_view->model()); model.set_suggestions(move(suggestions)); } else { - m_suggestion_view->set_model(adopt(*new AutocompleteSuggestionModel(move(suggestions)))); + m_suggestion_view->set_model(adopt_ref(*new AutocompleteSuggestionModel(move(suggestions)))); m_suggestion_view->update(); if (has_suggestions) m_suggestion_view->set_cursor(m_suggestion_view->model()->index(0), GUI::AbstractView::SelectionUpdate::Set); diff --git a/Userland/Libraries/LibGUI/DisplayLink.cpp b/Userland/Libraries/LibGUI/DisplayLink.cpp index ed3aea7efa3..cd64dd4dd80 100644 --- a/Userland/Libraries/LibGUI/DisplayLink.cpp +++ b/Userland/Libraries/LibGUI/DisplayLink.cpp @@ -46,7 +46,7 @@ i32 DisplayLink::register_callback(Function callback) WindowServerConnection::the().post_message(Messages::WindowServer::EnableDisplayLink()); i32 callback_id = s_next_callback_id++; - callbacks().set(callback_id, adopt(*new DisplayLinkCallback(callback_id, move(callback)))); + callbacks().set(callback_id, adopt_ref(*new DisplayLinkCallback(callback_id, move(callback)))); return callback_id; } diff --git a/Userland/Libraries/LibGUI/FileSystemModel.h b/Userland/Libraries/LibGUI/FileSystemModel.h index 16da76a3a4d..6b7c7544aa4 100644 --- a/Userland/Libraries/LibGUI/FileSystemModel.h +++ b/Userland/Libraries/LibGUI/FileSystemModel.h @@ -100,7 +100,7 @@ public: static NonnullRefPtr create(String root_path = "/", Mode mode = Mode::FilesAndDirectories) { - return adopt(*new FileSystemModel(root_path, mode)); + return adopt_ref(*new FileSystemModel(root_path, mode)); } virtual ~FileSystemModel() override; diff --git a/Userland/Libraries/LibGUI/FilteringProxyModel.h b/Userland/Libraries/LibGUI/FilteringProxyModel.h index 7c6f74accb4..a83fb0f52fc 100644 --- a/Userland/Libraries/LibGUI/FilteringProxyModel.h +++ b/Userland/Libraries/LibGUI/FilteringProxyModel.h @@ -18,7 +18,7 @@ class FilteringProxyModel final : public Model { public: static NonnullRefPtr construct(Model& model) { - return adopt(*new FilteringProxyModel(model)); + return adopt_ref(*new FilteringProxyModel(model)); } virtual ~FilteringProxyModel() override {}; diff --git a/Userland/Libraries/LibGUI/FontPicker.cpp b/Userland/Libraries/LibGUI/FontPicker.cpp index b26871edba3..140c094f955 100644 --- a/Userland/Libraries/LibGUI/FontPicker.cpp +++ b/Userland/Libraries/LibGUI/FontPicker.cpp @@ -35,7 +35,7 @@ FontPicker::FontPicker(Window* parent_window, const Gfx::Font* current_font, boo m_family_list_view->horizontal_scrollbar().set_visible(false); m_weight_list_view = *widget.find_descendant_of_type_named("weight_list_view"); - m_weight_list_view->set_model(adopt(*new FontWeightListModel(m_weights))); + m_weight_list_view->set_model(adopt_ref(*new FontWeightListModel(m_weights))); m_weight_list_view->horizontal_scrollbar().set_visible(false); m_size_spin_box = *widget.find_descendant_of_type_named("size_spin_box"); diff --git a/Userland/Libraries/LibGUI/Icon.h b/Userland/Libraries/LibGUI/Icon.h index f33c11a7cc8..3be0b7a3c42 100644 --- a/Userland/Libraries/LibGUI/Icon.h +++ b/Userland/Libraries/LibGUI/Icon.h @@ -15,7 +15,7 @@ namespace GUI { class IconImpl : public RefCounted { public: - static NonnullRefPtr create() { return adopt(*new IconImpl); } + static NonnullRefPtr create() { return adopt_ref(*new IconImpl); } ~IconImpl() { } const Gfx::Bitmap* bitmap_for_size(int) const; diff --git a/Userland/Libraries/LibGUI/ItemListModel.h b/Userland/Libraries/LibGUI/ItemListModel.h index ed2f6f8ae37..fc6cbca461b 100644 --- a/Userland/Libraries/LibGUI/ItemListModel.h +++ b/Userland/Libraries/LibGUI/ItemListModel.h @@ -27,11 +27,11 @@ public: static NonnullRefPtr create(const Container& data, const ColumnNamesT& column_names, const Optional& row_count = {}) requires(IsTwoDimensional) { - return adopt(*new ItemListModel(data, column_names, row_count)); + return adopt_ref(*new ItemListModel(data, column_names, row_count)); } static NonnullRefPtr create(const Container& data, const Optional& row_count = {}) requires(!IsTwoDimensional) { - return adopt(*new ItemListModel(data, row_count)); + return adopt_ref(*new ItemListModel(data, row_count)); } virtual ~ItemListModel() override { } diff --git a/Userland/Libraries/LibGUI/JsonArrayModel.h b/Userland/Libraries/LibGUI/JsonArrayModel.h index e5a12f35076..c8233bd15e9 100644 --- a/Userland/Libraries/LibGUI/JsonArrayModel.h +++ b/Userland/Libraries/LibGUI/JsonArrayModel.h @@ -41,7 +41,7 @@ public: static NonnullRefPtr create(const String& json_path, Vector&& fields) { - return adopt(*new JsonArrayModel(json_path, move(fields))); + return adopt_ref(*new JsonArrayModel(json_path, move(fields))); } virtual ~JsonArrayModel() override { } diff --git a/Userland/Libraries/LibGUI/RunningProcessesModel.cpp b/Userland/Libraries/LibGUI/RunningProcessesModel.cpp index 2223d02f1ce..653c4901011 100644 --- a/Userland/Libraries/LibGUI/RunningProcessesModel.cpp +++ b/Userland/Libraries/LibGUI/RunningProcessesModel.cpp @@ -12,7 +12,7 @@ namespace GUI { NonnullRefPtr RunningProcessesModel::create() { - return adopt(*new RunningProcessesModel); + return adopt_ref(*new RunningProcessesModel); } RunningProcessesModel::RunningProcessesModel() diff --git a/Userland/Libraries/LibGUI/SortingProxyModel.h b/Userland/Libraries/LibGUI/SortingProxyModel.h index 6937302956a..57da81998f7 100644 --- a/Userland/Libraries/LibGUI/SortingProxyModel.h +++ b/Userland/Libraries/LibGUI/SortingProxyModel.h @@ -14,7 +14,7 @@ class SortingProxyModel : public Model , private ModelClient { public: - static NonnullRefPtr create(NonnullRefPtr source) { return adopt(*new SortingProxyModel(move(source))); } + static NonnullRefPtr create(NonnullRefPtr source) { return adopt_ref(*new SortingProxyModel(move(source))); } virtual ~SortingProxyModel() override; virtual int row_count(const ModelIndex& = ModelIndex()) const override; diff --git a/Userland/Libraries/LibGUI/TextDocument.cpp b/Userland/Libraries/LibGUI/TextDocument.cpp index f719a87b77c..8c7f6dfb6e2 100644 --- a/Userland/Libraries/LibGUI/TextDocument.cpp +++ b/Userland/Libraries/LibGUI/TextDocument.cpp @@ -18,7 +18,7 @@ namespace GUI { NonnullRefPtr TextDocument::create(Client* client) { - return adopt(*new TextDocument(client)); + return adopt_ref(*new TextDocument(client)); } TextDocument::TextDocument(Client* client) diff --git a/Userland/Libraries/LibGemini/Document.cpp b/Userland/Libraries/LibGemini/Document.cpp index ee8ad53a22e..566a565af95 100644 --- a/Userland/Libraries/LibGemini/Document.cpp +++ b/Userland/Libraries/LibGemini/Document.cpp @@ -30,7 +30,7 @@ String Document::render_to_html() const NonnullRefPtr Document::parse(const StringView& lines, const URL& url) { - auto document = adopt(*new Document(url)); + auto document = adopt_ref(*new Document(url)); document->read_lines(lines); return document; } diff --git a/Userland/Libraries/LibGemini/GeminiResponse.h b/Userland/Libraries/LibGemini/GeminiResponse.h index 192ece3fff4..a69a686cc0d 100644 --- a/Userland/Libraries/LibGemini/GeminiResponse.h +++ b/Userland/Libraries/LibGemini/GeminiResponse.h @@ -16,7 +16,7 @@ public: virtual ~GeminiResponse() override; static NonnullRefPtr create(int status, String meta) { - return adopt(*new GeminiResponse(status, meta)); + return adopt_ref(*new GeminiResponse(status, meta)); } int status() const { return m_status; } diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp index 325d3116294..201e334a0b9 100644 --- a/Userland/Libraries/LibGfx/Bitmap.cpp +++ b/Userland/Libraries/LibGfx/Bitmap.cpp @@ -73,7 +73,7 @@ RefPtr Bitmap::create(BitmapFormat format, const IntSize& size, int scal auto backing_store = Bitmap::allocate_backing_store(format, size, scale_factor, Purgeable::No); if (!backing_store.has_value()) return nullptr; - return adopt(*new Bitmap(format, size, scale_factor, Purgeable::No, backing_store.value())); + return adopt_ref(*new Bitmap(format, size, scale_factor, Purgeable::No, backing_store.value())); } RefPtr Bitmap::create_purgeable(BitmapFormat format, const IntSize& size, int scale_factor) @@ -81,7 +81,7 @@ RefPtr Bitmap::create_purgeable(BitmapFormat format, const IntSize& size auto backing_store = Bitmap::allocate_backing_store(format, size, scale_factor, Purgeable::Yes); if (!backing_store.has_value()) return nullptr; - return adopt(*new Bitmap(format, size, scale_factor, Purgeable::Yes, backing_store.value())); + return adopt_ref(*new Bitmap(format, size, scale_factor, Purgeable::Yes, backing_store.value())); } #ifdef __serenity__ @@ -120,7 +120,7 @@ RefPtr Bitmap::create_wrapper(BitmapFormat format, const IntSize& size, { if (size_would_overflow(format, size, scale_factor)) return nullptr; - return adopt(*new Bitmap(format, size, scale_factor, pitch, data)); + return adopt_ref(*new Bitmap(format, size, scale_factor, pitch, data)); } RefPtr Bitmap::load_from_file(String const& path, int scale_factor) @@ -219,7 +219,7 @@ RefPtr Bitmap::create_with_anon_fd(BitmapFormat format, int anon_fd, con } } - return adopt(*new Bitmap(format, anon_fd, size, scale_factor, data, palette)); + return adopt_ref(*new Bitmap(format, anon_fd, size, scale_factor, data, palette)); } /// Read a bitmap as described by: diff --git a/Userland/Libraries/LibGfx/BitmapFont.cpp b/Userland/Libraries/LibGfx/BitmapFont.cpp index eeac6e90554..a50ba1b4548 100644 --- a/Userland/Libraries/LibGfx/BitmapFont.cpp +++ b/Userland/Libraries/LibGfx/BitmapFont.cpp @@ -44,7 +44,7 @@ NonnullRefPtr BitmapFont::clone() const memcpy(new_rows, m_rows, bytes_per_glyph * m_glyph_count); auto* new_widths = static_cast(malloc(m_glyph_count)); memcpy(new_widths, m_glyph_widths, m_glyph_count); - return adopt(*new BitmapFont(m_name, m_family, new_rows, new_widths, m_fixed_width, m_glyph_width, m_glyph_height, m_glyph_spacing, m_type, m_baseline, m_mean_line, m_presentation_size, m_weight, true)); + return adopt_ref(*new BitmapFont(m_name, m_family, new_rows, new_widths, m_fixed_width, m_glyph_width, m_glyph_height, m_glyph_spacing, m_type, m_baseline, m_mean_line, m_presentation_size, m_weight, true)); } NonnullRefPtr BitmapFont::create(u8 glyph_height, u8 glyph_width, bool fixed, FontTypes type) @@ -55,7 +55,7 @@ NonnullRefPtr BitmapFont::create(u8 glyph_height, u8 glyph_width, bo memset(new_rows, 0, bytes_per_glyph * count); auto* new_widths = static_cast(malloc(count)); memset(new_widths, 0, count); - return adopt(*new BitmapFont("Untitled", "Untitled", new_rows, new_widths, fixed, glyph_width, glyph_height, 1, type, 0, 0, 0, 400, true)); + return adopt_ref(*new BitmapFont("Untitled", "Untitled", new_rows, new_widths, fixed, glyph_width, glyph_height, 1, type, 0, 0, 0, 400, true)); } BitmapFont::BitmapFont(String name, String family, unsigned* rows, u8* widths, bool is_fixed_width, u8 glyph_width, u8 glyph_height, u8 glyph_spacing, FontTypes type, u8 baseline, u8 mean_line, u8 presentation_size, u16 weight, bool owns_arrays) @@ -137,7 +137,7 @@ RefPtr BitmapFont::load_from_memory(const u8* data) auto* rows = const_cast((const unsigned*)(data + sizeof(FontFileHeader))); u8* widths = (u8*)(rows) + count * bytes_per_glyph; - return adopt(*new BitmapFont(String(header.name), String(header.family), rows, widths, !header.is_variable_width, header.glyph_width, header.glyph_height, header.glyph_spacing, type, header.baseline, header.mean_line, header.presentation_size, header.weight)); + return adopt_ref(*new BitmapFont(String(header.name), String(header.family), rows, widths, !header.is_variable_width, header.glyph_width, header.glyph_height, header.glyph_spacing, type, header.baseline, header.mean_line, header.presentation_size, header.weight)); } size_t BitmapFont::glyph_count_by_type(FontTypes type) diff --git a/Userland/Libraries/LibGfx/CharacterBitmap.cpp b/Userland/Libraries/LibGfx/CharacterBitmap.cpp index 86943ba63bb..5f9d2843ae1 100644 --- a/Userland/Libraries/LibGfx/CharacterBitmap.cpp +++ b/Userland/Libraries/LibGfx/CharacterBitmap.cpp @@ -20,7 +20,7 @@ CharacterBitmap::~CharacterBitmap() NonnullRefPtr CharacterBitmap::create_from_ascii(const char* asciiData, unsigned width, unsigned height) { - return adopt(*new CharacterBitmap(asciiData, width, height)); + return adopt_ref(*new CharacterBitmap(asciiData, width, height)); } } diff --git a/Userland/Libraries/LibGfx/FontDatabase.cpp b/Userland/Libraries/LibGfx/FontDatabase.cpp index 7840549c176..44b934d1095 100644 --- a/Userland/Libraries/LibGfx/FontDatabase.cpp +++ b/Userland/Libraries/LibGfx/FontDatabase.cpp @@ -158,7 +158,7 @@ RefPtr FontDatabase::get_or_create_typeface(const String& family, cons if (typeface->family() == family && typeface->variant() == variant) return typeface; } - auto typeface = adopt(*new Typeface(family, variant)); + auto typeface = adopt_ref(*new Typeface(family, variant)); m_private->typefaces.append(typeface); return typeface; } diff --git a/Userland/Libraries/LibGfx/ImageDecoder.h b/Userland/Libraries/LibGfx/ImageDecoder.h index 497cfd9ed64..0855673871d 100644 --- a/Userland/Libraries/LibGfx/ImageDecoder.h +++ b/Userland/Libraries/LibGfx/ImageDecoder.h @@ -48,8 +48,8 @@ protected: class ImageDecoder : public RefCounted { public: - static NonnullRefPtr create(const u8* data, size_t size) { return adopt(*new ImageDecoder(data, size)); } - static NonnullRefPtr create(const ByteBuffer& data) { return adopt(*new ImageDecoder(data.data(), data.size())); } + static NonnullRefPtr create(const u8* data, size_t size) { return adopt_ref(*new ImageDecoder(data, size)); } + static NonnullRefPtr create(const ByteBuffer& data) { return adopt_ref(*new ImageDecoder(data.data(), data.size())); } ~ImageDecoder(); bool is_valid() const { return m_plugin; } diff --git a/Userland/Libraries/LibGfx/Palette.cpp b/Userland/Libraries/LibGfx/Palette.cpp index 761765db8bf..d45b6c0881c 100644 --- a/Userland/Libraries/LibGfx/Palette.cpp +++ b/Userland/Libraries/LibGfx/Palette.cpp @@ -12,7 +12,7 @@ namespace Gfx { NonnullRefPtr PaletteImpl::create_with_anonymous_buffer(Core::AnonymousBuffer buffer) { - return adopt(*new PaletteImpl(move(buffer))); + return adopt_ref(*new PaletteImpl(move(buffer))); } PaletteImpl::PaletteImpl(Core::AnonymousBuffer buffer) @@ -45,7 +45,7 @@ NonnullRefPtr PaletteImpl::clone() const { auto new_theme_buffer = Core::AnonymousBuffer::create_with_size(m_theme_buffer.size()); memcpy(new_theme_buffer.data(), &theme(), m_theme_buffer.size()); - return adopt(*new PaletteImpl(move(new_theme_buffer))); + return adopt_ref(*new PaletteImpl(move(new_theme_buffer))); } void Palette::set_color(ColorRole role, Color color) diff --git a/Userland/Libraries/LibGfx/Path.h b/Userland/Libraries/LibGfx/Path.h index 40cfdcc769d..62a7a80558a 100644 --- a/Userland/Libraries/LibGfx/Path.h +++ b/Userland/Libraries/LibGfx/Path.h @@ -197,7 +197,7 @@ private: template void append_segment(Args&&... args) { - m_segments.append(adopt(*new T(forward(args)...))); + m_segments.append(adopt_ref(*new T(forward(args)...))); } NonnullRefPtrVector m_segments {}; diff --git a/Userland/Libraries/LibGfx/Typeface.cpp b/Userland/Libraries/LibGfx/Typeface.cpp index b8f7cc2ce20..4fe7bba05a8 100644 --- a/Userland/Libraries/LibGfx/Typeface.cpp +++ b/Userland/Libraries/LibGfx/Typeface.cpp @@ -46,7 +46,7 @@ RefPtr Typeface::get_font(unsigned size) } if (m_ttf_font) - return adopt(*new TTF::ScaledFont(*m_ttf_font, size, size)); + return adopt_ref(*new TTF::ScaledFont(*m_ttf_font, size, size)); return {}; } diff --git a/Userland/Libraries/LibHTTP/HttpResponse.h b/Userland/Libraries/LibHTTP/HttpResponse.h index d46e30c32a7..897e0136845 100644 --- a/Userland/Libraries/LibHTTP/HttpResponse.h +++ b/Userland/Libraries/LibHTTP/HttpResponse.h @@ -17,7 +17,7 @@ public: virtual ~HttpResponse() override; static NonnullRefPtr create(int code, HashMap&& headers) { - return adopt(*new HttpResponse(code, move(headers))); + return adopt_ref(*new HttpResponse(code, move(headers))); } int code() const { return m_code; } diff --git a/Userland/Libraries/LibJS/AST.h b/Userland/Libraries/LibJS/AST.h index 488bf090adc..e307e08eade 100644 --- a/Userland/Libraries/LibJS/AST.h +++ b/Userland/Libraries/LibJS/AST.h @@ -27,7 +27,7 @@ template static inline NonnullRefPtr create_ast_node(SourceRange range, Args&&... args) { - return adopt(*new T(range, forward(args)...)); + return adopt_ref(*new T(range, forward(args)...)); } class ASTNode : public RefCounted { diff --git a/Userland/Libraries/LibJS/Heap/Handle.h b/Userland/Libraries/LibJS/Heap/Handle.h index ef720584c1a..ace0257aded 100644 --- a/Userland/Libraries/LibJS/Heap/Handle.h +++ b/Userland/Libraries/LibJS/Heap/Handle.h @@ -39,7 +39,7 @@ public: static Handle create(T* cell) { - return Handle(adopt(*new HandleImpl(cell))); + return Handle(adopt_ref(*new HandleImpl(cell))); } T* cell() { return static_cast(m_impl->cell()); } diff --git a/Userland/Libraries/LibJS/Parser.cpp b/Userland/Libraries/LibJS/Parser.cpp index be5bf07337f..f34d6eb2e2f 100644 --- a/Userland/Libraries/LibJS/Parser.cpp +++ b/Userland/Libraries/LibJS/Parser.cpp @@ -228,7 +228,7 @@ NonnullRefPtr Parser::parse_program() { auto rule_start = push_start(); ScopePusher scope(*this, ScopePusher::Var | ScopePusher::Let | ScopePusher::Function); - auto program = adopt(*new Program({ m_filename, rule_start.position(), position() })); + auto program = adopt_ref(*new Program({ m_filename, rule_start.position(), position() })); bool first = true; while (!done()) { diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp index da77d31b401..b7fc15c7816 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.cpp +++ b/Userland/Libraries/LibJS/Runtime/VM.cpp @@ -24,7 +24,7 @@ namespace JS { NonnullRefPtr VM::create() { - return adopt(*new VM); + return adopt_ref(*new VM); } VM::VM() diff --git a/Userland/Libraries/LibPCIDB/Database.cpp b/Userland/Libraries/LibPCIDB/Database.cpp index 5b93cd21711..3821049d689 100644 --- a/Userland/Libraries/LibPCIDB/Database.cpp +++ b/Userland/Libraries/LibPCIDB/Database.cpp @@ -17,7 +17,7 @@ RefPtr Database::open(const String& file_name) auto file_or_error = MappedFile::map(file_name); if (file_or_error.is_error()) return nullptr; - auto res = adopt(*new Database(file_or_error.release_value())); + auto res = adopt_ref(*new Database(file_or_error.release_value())); if (res->init() != 0) return nullptr; return res; diff --git a/Userland/Libraries/LibProtocol/Download.h b/Userland/Libraries/LibProtocol/Download.h index ec2ac28d951..8dfdd470365 100644 --- a/Userland/Libraries/LibProtocol/Download.h +++ b/Userland/Libraries/LibProtocol/Download.h @@ -30,7 +30,7 @@ public: static NonnullRefPtr create_from_id(Badge, Client& client, i32 download_id) { - return adopt(*new Download(client, download_id)); + return adopt_ref(*new Download(client, download_id)); } int id() const { return m_download_id; } diff --git a/Userland/Libraries/LibSQL/AST.h b/Userland/Libraries/LibSQL/AST.h index fed6eaf0c01..922432b48ac 100644 --- a/Userland/Libraries/LibSQL/AST.h +++ b/Userland/Libraries/LibSQL/AST.h @@ -20,7 +20,7 @@ template static inline NonnullRefPtr create_ast_node(Args&&... args) { - return adopt(*new T(forward(args)...)); + return adopt_ref(*new T(forward(args)...)); } class ASTNode : public RefCounted { diff --git a/Userland/Libraries/LibTTF/Font.cpp b/Userland/Libraries/LibTTF/Font.cpp index 73388f6f370..71d28bdb93b 100644 --- a/Userland/Libraries/LibTTF/Font.cpp +++ b/Userland/Libraries/LibTTF/Font.cpp @@ -389,7 +389,7 @@ RefPtr Font::load_from_offset(ByteBuffer&& buffer, u32 offset) } } - return adopt(*new Font(move(buffer), move(head), move(name), move(hhea), move(maxp), move(hmtx), move(cmap), move(loca), move(glyf))); + return adopt_ref(*new Font(move(buffer), move(head), move(name), move(hhea), move(maxp), move(hmtx), move(cmap), move(loca), move(glyf))); } ScaledFontMetrics Font::metrics(float x_scale, float y_scale) const diff --git a/Userland/Libraries/LibThread/BackgroundAction.h b/Userland/Libraries/LibThread/BackgroundAction.h index 066770fad46..c3664db039d 100644 --- a/Userland/Libraries/LibThread/BackgroundAction.h +++ b/Userland/Libraries/LibThread/BackgroundAction.h @@ -42,7 +42,7 @@ public: Function action, Function on_complete = nullptr) { - return adopt(*new BackgroundAction(move(action), move(on_complete))); + return adopt_ref(*new BackgroundAction(move(action), move(on_complete))); } virtual ~BackgroundAction() { } diff --git a/Userland/Libraries/LibWeb/CSS/CSSImportRule.h b/Userland/Libraries/LibWeb/CSS/CSSImportRule.h index 6b5c3d376c8..cd3cc32b819 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSImportRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSImportRule.h @@ -18,7 +18,7 @@ class CSSImportRule : public CSSRule { public: static NonnullRefPtr create(URL url) { - return adopt(*new CSSImportRule(move(url))); + return adopt_ref(*new CSSImportRule(move(url))); } ~CSSImportRule(); diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h index 92f97d2a640..2a8ad6a672d 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h @@ -27,7 +27,7 @@ public: static NonnullRefPtr create(Vector&& properties) { - return adopt(*new CSSStyleDeclaration(move(properties))); + return adopt_ref(*new CSSStyleDeclaration(move(properties))); } virtual ~CSSStyleDeclaration(); @@ -48,7 +48,7 @@ private: class ElementInlineCSSStyleDeclaration final : public CSSStyleDeclaration { public: - static NonnullRefPtr create(DOM::Element& element) { return adopt(*new ElementInlineCSSStyleDeclaration(element)); } + static NonnullRefPtr create(DOM::Element& element) { return adopt_ref(*new ElementInlineCSSStyleDeclaration(element)); } virtual ~ElementInlineCSSStyleDeclaration() override; DOM::Element* element() { return m_element.ptr(); } diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h index c778df7b3b7..41dce31a78c 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h @@ -21,7 +21,7 @@ class CSSStyleRule : public CSSRule { public: static NonnullRefPtr create(Vector&& selectors, NonnullRefPtr&& declaration) { - return adopt(*new CSSStyleRule(move(selectors), move(declaration))); + return adopt_ref(*new CSSStyleRule(move(selectors), move(declaration))); } ~CSSStyleRule(); diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h index 3ad97bc56ed..ea9904de492 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h @@ -21,7 +21,7 @@ public: static NonnullRefPtr create(NonnullRefPtrVector rules) { - return adopt(*new CSSStyleSheet(move(rules))); + return adopt_ref(*new CSSStyleSheet(move(rules))); } virtual ~CSSStyleSheet() override; diff --git a/Userland/Libraries/LibWeb/CSS/Screen.h b/Userland/Libraries/LibWeb/CSS/Screen.h index c17197afc92..7ca9b0f6d04 100644 --- a/Userland/Libraries/LibWeb/CSS/Screen.h +++ b/Userland/Libraries/LibWeb/CSS/Screen.h @@ -21,7 +21,7 @@ public: static NonnullRefPtr create(DOM::Window& window) { - return adopt(*new Screen(window)); + return adopt_ref(*new Screen(window)); } i32 width() const { return screen_rect().width(); } diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index 739ace583e1..853ca513dd7 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -28,7 +28,7 @@ StyleProperties::StyleProperties(const StyleProperties& other) NonnullRefPtr StyleProperties::clone() const { - return adopt(*new StyleProperties(*this)); + return adopt_ref(*new StyleProperties(*this)); } void StyleProperties::set_property(CSS::PropertyID id, NonnullRefPtr value) diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.h b/Userland/Libraries/LibWeb/CSS/StyleProperties.h index 1b493d50631..6cdaafcff5e 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.h +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.h @@ -21,7 +21,7 @@ public: explicit StyleProperties(const StyleProperties&); - static NonnullRefPtr create() { return adopt(*new StyleProperties); } + static NonnullRefPtr create() { return adopt_ref(*new StyleProperties); } NonnullRefPtr clone() const; diff --git a/Userland/Libraries/LibWeb/CSS/StyleSheetList.h b/Userland/Libraries/LibWeb/CSS/StyleSheetList.h index ff4d63fee1c..5b52008f3ae 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleSheetList.h +++ b/Userland/Libraries/LibWeb/CSS/StyleSheetList.h @@ -22,7 +22,7 @@ public: static NonnullRefPtr create(DOM::Document& document) { - return adopt(*new StyleSheetList(document)); + return adopt_ref(*new StyleSheetList(document)); } void add_sheet(NonnullRefPtr); diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index 0051b72a3fe..d4ad707d38a 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -232,7 +232,7 @@ class StringStyleValue : public StyleValue { public: static NonnullRefPtr create(const String& string) { - return adopt(*new StringStyleValue(string)); + return adopt_ref(*new StringStyleValue(string)); } virtual ~StringStyleValue() override { } @@ -252,7 +252,7 @@ class LengthStyleValue : public StyleValue { public: static NonnullRefPtr create(const Length& length) { - return adopt(*new LengthStyleValue(length)); + return adopt_ref(*new LengthStyleValue(length)); } virtual ~LengthStyleValue() override { } @@ -282,7 +282,7 @@ private: class InitialStyleValue final : public StyleValue { public: - static NonnullRefPtr create() { return adopt(*new InitialStyleValue); } + static NonnullRefPtr create() { return adopt_ref(*new InitialStyleValue); } virtual ~InitialStyleValue() override { } String to_string() const override { return "initial"; } @@ -296,7 +296,7 @@ private: class InheritStyleValue final : public StyleValue { public: - static NonnullRefPtr create() { return adopt(*new InheritStyleValue); } + static NonnullRefPtr create() { return adopt_ref(*new InheritStyleValue); } virtual ~InheritStyleValue() override { } String to_string() const override { return "inherit"; } @@ -312,7 +312,7 @@ class ColorStyleValue : public StyleValue { public: static NonnullRefPtr create(Color color) { - return adopt(*new ColorStyleValue(color)); + return adopt_ref(*new ColorStyleValue(color)); } virtual ~ColorStyleValue() override { } @@ -341,7 +341,7 @@ class IdentifierStyleValue final : public StyleValue { public: static NonnullRefPtr create(CSS::ValueID id) { - return adopt(*new IdentifierStyleValue(id)); + return adopt_ref(*new IdentifierStyleValue(id)); } virtual ~IdentifierStyleValue() override { } @@ -371,7 +371,7 @@ class ImageStyleValue final : public StyleValue , public ImageResourceClient { public: - static NonnullRefPtr create(const URL& url, DOM::Document& document) { return adopt(*new ImageStyleValue(url, document)); } + static NonnullRefPtr create(const URL& url, DOM::Document& document) { return adopt_ref(*new ImageStyleValue(url, document)); } virtual ~ImageStyleValue() override { } String to_string() const override { return String::formatted("Image({})", m_url.to_string()); } diff --git a/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp b/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp index 52d2e80e412..470135b4ae5 100644 --- a/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp +++ b/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp @@ -553,7 +553,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter vm.throw_exception(global_object, JS::ErrorType::NotA, "Function"); @return_statement@ } - @cpp_name@ = adopt(*new EventListener(JS::make_handle(&@js_name@@js_suffix@.as_function()))); + @cpp_name@ = adopt_ref(*new EventListener(JS::make_handle(&@js_name@@js_suffix@.as_function()))); } )~~~"); } else { @@ -562,7 +562,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter vm.throw_exception(global_object, JS::ErrorType::NotA, "Function"); @return_statement@ } - auto @cpp_name@ = adopt(*new EventListener(JS::make_handle(&@js_name@@js_suffix@.as_function()))); + auto @cpp_name@ = adopt_ref(*new EventListener(JS::make_handle(&@js_name@@js_suffix@.as_function()))); )~~~"); } } else if (is_wrappable_type(parameter.type)) { diff --git a/Userland/Libraries/LibWeb/DOM/DOMException.h b/Userland/Libraries/LibWeb/DOM/DOMException.h index 6b67558b616..6e837ec22d8 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMException.h +++ b/Userland/Libraries/LibWeb/DOM/DOMException.h @@ -98,13 +98,13 @@ public: static NonnullRefPtr create(const FlyString& name, const FlyString& message) { - return adopt(*new DOMException(name, message)); + return adopt_ref(*new DOMException(name, message)); } // JS constructor has message first, name second static NonnullRefPtr create_with_global_object(Bindings::WindowObject&, const FlyString& message, const FlyString& name) { - return adopt(*new DOMException(name, message)); + return adopt_ref(*new DOMException(name, message)); } const FlyString& name() const { return m_name; } diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp index 4e602f92313..04493eda8b7 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp @@ -26,7 +26,7 @@ const NonnullRefPtr DOMImplementation::create_html_document(const Stri html_document->set_content_type("text/html"); html_document->set_ready_for_post_load_tasks(true); - auto doctype = adopt(*new DocumentType(html_document)); + auto doctype = adopt_ref(*new DocumentType(html_document)); doctype->set_name("html"); html_document->append_child(doctype); @@ -40,7 +40,7 @@ const NonnullRefPtr DOMImplementation::create_html_document(const Stri auto title_element = create_element(html_document, HTML::TagNames::title, Namespace::HTML); head_element->append_child(title_element); - auto text_node = adopt(*new Text(html_document, title)); + auto text_node = adopt_ref(*new Text(html_document, title)); title_element->append_child(text_node); } diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h index 759c1d0b4ba..2635030adcb 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h +++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h @@ -22,7 +22,7 @@ public: static NonnullRefPtr create(Document& document) { - return adopt(*new DOMImplementation(document)); + return adopt_ref(*new DOMImplementation(document)); } const NonnullRefPtr create_html_document(const String& title) const; diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index c6e1b41f96d..3e3e8e82a24 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -269,7 +269,7 @@ void Document::set_title(const String& title) } title_element->remove_all_children(true); - title_element->append_child(adopt(*new Text(*this, title))); + title_element->append_child(adopt_ref(*new Text(*this, title))); if (auto* page = this->page()) { if (frame() == &page->main_frame()) @@ -433,7 +433,7 @@ void Document::update_style() RefPtr Document::create_layout_node() { - return adopt(*new Layout::InitialContainingBlockBox(*this, CSS::StyleProperties::create())); + return adopt_ref(*new Layout::InitialContainingBlockBox(*this, CSS::StyleProperties::create())); } void Document::set_link_color(Color color) @@ -598,17 +598,17 @@ NonnullRefPtr Document::create_element_ns(const String& namespace_, con NonnullRefPtr Document::create_document_fragment() { - return adopt(*new DocumentFragment(*this)); + return adopt_ref(*new DocumentFragment(*this)); } NonnullRefPtr Document::create_text_node(const String& data) { - return adopt(*new Text(*this, data)); + return adopt_ref(*new Text(*this, data)); } NonnullRefPtr Document::create_comment(const String& data) { - return adopt(*new Comment(*this, data)); + return adopt_ref(*new Comment(*this, data)); } NonnullRefPtr Document::create_range() @@ -732,10 +732,10 @@ void Document::adopt_node(Node& node) ExceptionOr> Document::adopt_node_binding(NonnullRefPtr node) { if (is(*node)) - return DOM ::NotSupportedError::create("Cannot adopt a document into a document"); + return DOM ::NotSupportedError::create("Cannot adopt_ref a document into a document"); if (is(*node)) - return DOM::HierarchyRequestError::create("Cannot adopt a shadow root into a document"); + return DOM::HierarchyRequestError::create("Cannot adopt_ref a shadow root into a document"); if (is(*node) && downcast(*node).host()) return node; diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index f070ac17fd5..d1c062507c0 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -45,7 +45,7 @@ public: static NonnullRefPtr create(const URL& url = "about:blank") { - return adopt(*new Document(url)); + return adopt_ref(*new Document(url)); } static NonnullRefPtr create_with_global_object(Bindings::WindowObject&) { diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 8ec37bd14a0..37cff6ec5f1 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -115,35 +115,35 @@ RefPtr Element::create_layout_node() VERIFY_NOT_REACHED(); break; case CSS::Display::Block: - return adopt(*new Layout::BlockBox(document(), this, move(style))); + return adopt_ref(*new Layout::BlockBox(document(), this, move(style))); case CSS::Display::Inline: if (style->float_().value_or(CSS::Float::None) != CSS::Float::None) - return adopt(*new Layout::BlockBox(document(), this, move(style))); - return adopt(*new Layout::InlineNode(document(), *this, move(style))); + return adopt_ref(*new Layout::BlockBox(document(), this, move(style))); + return adopt_ref(*new Layout::InlineNode(document(), *this, move(style))); case CSS::Display::ListItem: - return adopt(*new Layout::ListItemBox(document(), *this, move(style))); + return adopt_ref(*new Layout::ListItemBox(document(), *this, move(style))); case CSS::Display::Table: - return adopt(*new Layout::TableBox(document(), this, move(style))); + return adopt_ref(*new Layout::TableBox(document(), this, move(style))); case CSS::Display::TableRow: - return adopt(*new Layout::TableRowBox(document(), this, move(style))); + return adopt_ref(*new Layout::TableRowBox(document(), this, move(style))); case CSS::Display::TableCell: - return adopt(*new Layout::TableCellBox(document(), this, move(style))); + return adopt_ref(*new Layout::TableCellBox(document(), this, move(style))); case CSS::Display::TableRowGroup: case CSS::Display::TableHeaderGroup: case CSS::Display::TableFooterGroup: - return adopt(*new Layout::TableRowGroupBox(document(), *this, move(style))); + return adopt_ref(*new Layout::TableRowGroupBox(document(), *this, move(style))); case CSS::Display::InlineBlock: { - auto inline_block = adopt(*new Layout::BlockBox(document(), this, move(style))); + auto inline_block = adopt_ref(*new Layout::BlockBox(document(), this, move(style))); inline_block->set_inline(true); return inline_block; } case CSS::Display::Flex: - return adopt(*new Layout::BlockBox(document(), this, move(style))); + return adopt_ref(*new Layout::BlockBox(document(), this, move(style))); case CSS::Display::TableColumn: case CSS::Display::TableColumnGroup: case CSS::Display::TableCaption: // FIXME: This is just an incorrect placeholder until we improve table layout support. - return adopt(*new Layout::BlockBox(document(), this, move(style))); + return adopt_ref(*new Layout::BlockBox(document(), this, move(style))); } VERIFY_NOT_REACHED(); } diff --git a/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp b/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp index 3601cd9704e..db06933113c 100644 --- a/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp +++ b/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp @@ -88,157 +88,157 @@ NonnullRefPtr create_element(Document& document, const FlyString& tag_n // FIXME: Add prefix when we support it. auto qualified_name = QualifiedName(tag_name, {}, namespace_); if (lowercase_tag_name == HTML::TagNames::a) - return adopt(*new HTML::HTMLAnchorElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLAnchorElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::area) - return adopt(*new HTML::HTMLAreaElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLAreaElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::audio) - return adopt(*new HTML::HTMLAudioElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLAudioElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::base) - return adopt(*new HTML::HTMLBaseElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLBaseElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::blink) - return adopt(*new HTML::HTMLBlinkElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLBlinkElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::body) - return adopt(*new HTML::HTMLBodyElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLBodyElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::br) - return adopt(*new HTML::HTMLBRElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLBRElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::button) - return adopt(*new HTML::HTMLButtonElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLButtonElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::canvas) - return adopt(*new HTML::HTMLCanvasElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLCanvasElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::data) - return adopt(*new HTML::HTMLDataElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLDataElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::datalist) - return adopt(*new HTML::HTMLDataListElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLDataListElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::details) - return adopt(*new HTML::HTMLDetailsElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLDetailsElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::dialog) - return adopt(*new HTML::HTMLDialogElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLDialogElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::dir) - return adopt(*new HTML::HTMLDirectoryElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLDirectoryElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::div) - return adopt(*new HTML::HTMLDivElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLDivElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::dl) - return adopt(*new HTML::HTMLDListElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLDListElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::embed) - return adopt(*new HTML::HTMLEmbedElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLEmbedElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::fieldset) - return adopt(*new HTML::HTMLFieldSetElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLFieldSetElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::font) - return adopt(*new HTML::HTMLFontElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLFontElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::form) - return adopt(*new HTML::HTMLFormElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLFormElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::frame) - return adopt(*new HTML::HTMLFrameElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLFrameElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::frameset) - return adopt(*new HTML::HTMLFrameSetElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLFrameSetElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::head) - return adopt(*new HTML::HTMLHeadElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLHeadElement(document, move(qualified_name))); if (lowercase_tag_name.is_one_of(HTML::TagNames::h1, HTML::TagNames::h2, HTML::TagNames::h3, HTML::TagNames::h4, HTML::TagNames::h5, HTML::TagNames::h6)) - return adopt(*new HTML::HTMLHeadingElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLHeadingElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::hr) - return adopt(*new HTML::HTMLHRElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLHRElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::html) - return adopt(*new HTML::HTMLHtmlElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLHtmlElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::iframe) - return adopt(*new HTML::HTMLIFrameElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLIFrameElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::img) - return adopt(*new HTML::HTMLImageElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLImageElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::input) - return adopt(*new HTML::HTMLInputElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLInputElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::label) - return adopt(*new HTML::HTMLLabelElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLLabelElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::legend) - return adopt(*new HTML::HTMLLegendElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLLegendElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::li) - return adopt(*new HTML::HTMLLIElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLLIElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::link) - return adopt(*new HTML::HTMLLinkElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLLinkElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::map) - return adopt(*new HTML::HTMLMapElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLMapElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::marquee) - return adopt(*new HTML::HTMLMarqueeElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLMarqueeElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::menu) - return adopt(*new HTML::HTMLMenuElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLMenuElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::meta) - return adopt(*new HTML::HTMLMetaElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLMetaElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::meter) - return adopt(*new HTML::HTMLMeterElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLMeterElement(document, move(qualified_name))); if (lowercase_tag_name.is_one_of(HTML::TagNames::ins, HTML::TagNames::del)) - return adopt(*new HTML::HTMLModElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLModElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::object) - return adopt(*new HTML::HTMLObjectElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLObjectElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::ol) - return adopt(*new HTML::HTMLOListElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLOListElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::optgroup) - return adopt(*new HTML::HTMLOptGroupElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLOptGroupElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::option) - return adopt(*new HTML::HTMLOptionElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLOptionElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::output) - return adopt(*new HTML::HTMLOutputElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLOutputElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::p) - return adopt(*new HTML::HTMLParagraphElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLParagraphElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::param) - return adopt(*new HTML::HTMLParamElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLParamElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::picture) - return adopt(*new HTML::HTMLPictureElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLPictureElement(document, move(qualified_name))); // NOTE: The obsolete elements "listing" and "xmp" are explicitly mapped to HTMLPreElement in the specification. if (lowercase_tag_name.is_one_of(HTML::TagNames::pre, HTML::TagNames::listing, HTML::TagNames::xmp)) - return adopt(*new HTML::HTMLPreElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLPreElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::progress) - return adopt(*new HTML::HTMLProgressElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLProgressElement(document, move(qualified_name))); if (lowercase_tag_name.is_one_of(HTML::TagNames::blockquote, HTML::TagNames::q)) - return adopt(*new HTML::HTMLQuoteElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLQuoteElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::script) - return adopt(*new HTML::HTMLScriptElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLScriptElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::select) - return adopt(*new HTML::HTMLSelectElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLSelectElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::slot) - return adopt(*new HTML::HTMLSlotElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLSlotElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::source) - return adopt(*new HTML::HTMLSourceElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLSourceElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::span) - return adopt(*new HTML::HTMLSpanElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLSpanElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::style) - return adopt(*new HTML::HTMLStyleElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLStyleElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::caption) - return adopt(*new HTML::HTMLTableCaptionElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLTableCaptionElement(document, move(qualified_name))); if (lowercase_tag_name.is_one_of(Web::HTML::TagNames::td, Web::HTML::TagNames::th)) - return adopt(*new HTML::HTMLTableCellElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLTableCellElement(document, move(qualified_name))); if (lowercase_tag_name.is_one_of(HTML::TagNames::colgroup, HTML::TagNames::col)) - return adopt(*new HTML::HTMLTableColElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLTableColElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::table) - return adopt(*new HTML::HTMLTableElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLTableElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::tr) - return adopt(*new HTML::HTMLTableRowElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLTableRowElement(document, move(qualified_name))); if (lowercase_tag_name.is_one_of(HTML::TagNames::tbody, HTML::TagNames::thead, HTML::TagNames::tfoot)) - return adopt(*new HTML::HTMLTableSectionElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLTableSectionElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::template_) - return adopt(*new HTML::HTMLTemplateElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLTemplateElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::textarea) - return adopt(*new HTML::HTMLTextAreaElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLTextAreaElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::time) - return adopt(*new HTML::HTMLTimeElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLTimeElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::title) - return adopt(*new HTML::HTMLTitleElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLTitleElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::track) - return adopt(*new HTML::HTMLTrackElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLTrackElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::ul) - return adopt(*new HTML::HTMLUListElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLUListElement(document, move(qualified_name))); if (lowercase_tag_name == HTML::TagNames::video) - return adopt(*new HTML::HTMLVideoElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLVideoElement(document, move(qualified_name))); if (lowercase_tag_name.is_one_of( HTML::TagNames::article, HTML::TagNames::section, HTML::TagNames::nav, HTML::TagNames::aside, HTML::TagNames::hgroup, HTML::TagNames::header, HTML::TagNames::footer, HTML::TagNames::address, HTML::TagNames::dt, HTML::TagNames::dd, HTML::TagNames::figure, HTML::TagNames::figcaption, HTML::TagNames::main, HTML::TagNames::em, HTML::TagNames::strong, HTML::TagNames::small, HTML::TagNames::s, HTML::TagNames::cite, HTML::TagNames::dfn, HTML::TagNames::abbr, HTML::TagNames::ruby, HTML::TagNames::rt, HTML::TagNames::rp, HTML::TagNames::code, HTML::TagNames::var, HTML::TagNames::samp, HTML::TagNames::kbd, HTML::TagNames::sub, HTML::TagNames::sup, HTML::TagNames::i, HTML::TagNames::b, HTML::TagNames::u, HTML::TagNames::mark, HTML::TagNames::bdi, HTML::TagNames::bdo, HTML::TagNames::wbr, HTML::TagNames::summary, HTML::TagNames::noscript, // Obsolete HTML::TagNames::acronym, HTML::TagNames::basefont, HTML::TagNames::big, HTML::TagNames::center, HTML::TagNames::nobr, HTML::TagNames::noembed, HTML::TagNames::noframes, HTML::TagNames::plaintext, HTML::TagNames::rb, HTML::TagNames::rtc, HTML::TagNames::strike, HTML::TagNames::tt)) - return adopt(*new HTML::HTMLElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLElement(document, move(qualified_name))); if (lowercase_tag_name == SVG::TagNames::svg) - return adopt(*new SVG::SVGSVGElement(document, move(qualified_name))); + return adopt_ref(*new SVG::SVGSVGElement(document, move(qualified_name))); if (lowercase_tag_name == SVG::TagNames::path) - return adopt(*new SVG::SVGPathElement(document, move(qualified_name))); + return adopt_ref(*new SVG::SVGPathElement(document, move(qualified_name))); // FIXME: If name is a valid custom element name, then return HTMLElement. - return adopt(*new HTML::HTMLUnknownElement(document, move(qualified_name))); + return adopt_ref(*new HTML::HTMLUnknownElement(document, move(qualified_name))); } } diff --git a/Userland/Libraries/LibWeb/DOM/Event.h b/Userland/Libraries/LibWeb/DOM/Event.h index 7fbe7db1a2a..1da8eadc4ea 100644 --- a/Userland/Libraries/LibWeb/DOM/Event.h +++ b/Userland/Libraries/LibWeb/DOM/Event.h @@ -43,7 +43,7 @@ public: static NonnullRefPtr create(const FlyString& event_name) { - return adopt(*new Event(event_name)); + return adopt_ref(*new Event(event_name)); } static NonnullRefPtr create_with_global_object(Bindings::WindowObject&, const FlyString& event_name) { diff --git a/Userland/Libraries/LibWeb/DOM/HTMLCollection.h b/Userland/Libraries/LibWeb/DOM/HTMLCollection.h index a4c87f4fe43..8ee6c69d53a 100644 --- a/Userland/Libraries/LibWeb/DOM/HTMLCollection.h +++ b/Userland/Libraries/LibWeb/DOM/HTMLCollection.h @@ -36,7 +36,7 @@ public: static NonnullRefPtr create(ParentNode& root, Function filter) { - return adopt(*new HTMLCollection(root, move(filter))); + return adopt_ref(*new HTMLCollection(root, move(filter))); } ~HTMLCollection(); diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index e8c66af51d3..058dda44ccb 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -354,7 +354,7 @@ NonnullRefPtr Node::clone_node(Document* document, bool clone_children) co if (is(this)) { auto& element = *downcast(this); auto qualified_name = QualifiedName(element.local_name(), element.prefix(), element.namespace_()); - auto element_copy = adopt(*new Element(*document, move(qualified_name))); + auto element_copy = adopt_ref(*new Element(*document, move(qualified_name))); element.for_each_attribute([&](auto& name, auto& value) { element_copy->set_attribute(name, value); }); @@ -370,22 +370,22 @@ NonnullRefPtr Node::clone_node(Document* document, bool clone_children) co copy = move(document_copy); } else if (is(this)) { auto document_type = downcast(this); - auto document_type_copy = adopt(*new DocumentType(*document)); + auto document_type_copy = adopt_ref(*new DocumentType(*document)); document_type_copy->set_name(document_type->name()); document_type_copy->set_public_id(document_type->public_id()); document_type_copy->set_system_id(document_type->system_id()); copy = move(document_type_copy); } else if (is(this)) { auto text = downcast(this); - auto text_copy = adopt(*new Text(*document, text->data())); + auto text_copy = adopt_ref(*new Text(*document, text->data())); copy = move(text_copy); } else if (is(this)) { auto comment = downcast(this); - auto comment_copy = adopt(*new Comment(*document, comment->data())); + auto comment_copy = adopt_ref(*new Comment(*document, comment->data())); copy = move(comment_copy); } else if (is(this)) { auto processing_instruction = downcast(this); - auto processing_instruction_copy = adopt(*new ProcessingInstruction(*document, processing_instruction->data(), processing_instruction->target())); + auto processing_instruction_copy = adopt_ref(*new ProcessingInstruction(*document, processing_instruction->data(), processing_instruction->target())); copy = move(processing_instruction_copy); } else { dbgln("clone_node() not implemented for NodeType {}", (u16)m_type); diff --git a/Userland/Libraries/LibWeb/DOM/Range.cpp b/Userland/Libraries/LibWeb/DOM/Range.cpp index b74e8dfe94e..3125a41b984 100644 --- a/Userland/Libraries/LibWeb/DOM/Range.cpp +++ b/Userland/Libraries/LibWeb/DOM/Range.cpp @@ -18,12 +18,12 @@ NonnullRefPtr Range::create(Window& window) NonnullRefPtr Range::create(Document& document) { - return adopt(*new Range(document)); + return adopt_ref(*new Range(document)); } NonnullRefPtr Range::create(Node& start_container, size_t start_offset, Node& end_container, size_t end_offset) { - return adopt(*new Range(start_container, start_offset, end_container, end_offset)); + return adopt_ref(*new Range(start_container, start_offset, end_container, end_offset)); } NonnullRefPtr Range::create_with_global_object(Bindings::WindowObject& window) { @@ -45,12 +45,12 @@ Range::Range(Node& start_container, size_t start_offset, Node& end_container, si NonnullRefPtr Range::clone_range() const { - return adopt(*new Range(const_cast(*m_start_container), m_start_offset, const_cast(*m_end_container), m_end_offset)); + return adopt_ref(*new Range(const_cast(*m_start_container), m_start_offset, const_cast(*m_end_container), m_end_offset)); } NonnullRefPtr Range::inverted() const { - return adopt(*new Range(const_cast(*m_end_container), m_end_offset, const_cast(*m_start_container), m_start_offset)); + return adopt_ref(*new Range(const_cast(*m_end_container), m_end_offset, const_cast(*m_start_container), m_start_offset)); } NonnullRefPtr Range::normalized() const diff --git a/Userland/Libraries/LibWeb/DOM/ShadowRoot.cpp b/Userland/Libraries/LibWeb/DOM/ShadowRoot.cpp index f108e52fd12..de9b47db754 100644 --- a/Userland/Libraries/LibWeb/DOM/ShadowRoot.cpp +++ b/Userland/Libraries/LibWeb/DOM/ShadowRoot.cpp @@ -29,7 +29,7 @@ EventTarget* ShadowRoot::get_parent(const Event& event) RefPtr ShadowRoot::create_layout_node() { - return adopt(*new Layout::BlockBox(document(), this, CSS::ComputedValues {})); + return adopt_ref(*new Layout::BlockBox(document(), this, CSS::ComputedValues {})); } } diff --git a/Userland/Libraries/LibWeb/DOM/Text.cpp b/Userland/Libraries/LibWeb/DOM/Text.cpp index 6e3755ce921..03bf69d26aa 100644 --- a/Userland/Libraries/LibWeb/DOM/Text.cpp +++ b/Userland/Libraries/LibWeb/DOM/Text.cpp @@ -20,7 +20,7 @@ Text::~Text() RefPtr Text::create_layout_node() { - return adopt(*new Layout::TextNode(document(), *this)); + return adopt_ref(*new Layout::TextNode(document(), *this)); } } diff --git a/Userland/Libraries/LibWeb/DOM/Timer.cpp b/Userland/Libraries/LibWeb/DOM/Timer.cpp index f628e5e33b6..4ef944a9eb5 100644 --- a/Userland/Libraries/LibWeb/DOM/Timer.cpp +++ b/Userland/Libraries/LibWeb/DOM/Timer.cpp @@ -13,12 +13,12 @@ namespace Web::DOM { NonnullRefPtr Timer::create_interval(Window& window, int milliseconds, JS::Function& callback) { - return adopt(*new Timer(window, Type::Interval, milliseconds, callback)); + return adopt_ref(*new Timer(window, Type::Interval, milliseconds, callback)); } NonnullRefPtr Timer::create_timeout(Window& window, int milliseconds, JS::Function& callback) { - return adopt(*new Timer(window, Type::Timeout, milliseconds, callback)); + return adopt_ref(*new Timer(window, Type::Timeout, milliseconds, callback)); } Timer::Timer(Window& window, Type type, int milliseconds, JS::Function& callback) diff --git a/Userland/Libraries/LibWeb/DOM/Window.cpp b/Userland/Libraries/LibWeb/DOM/Window.cpp index e54b3831453..1b9f70e320c 100644 --- a/Userland/Libraries/LibWeb/DOM/Window.cpp +++ b/Userland/Libraries/LibWeb/DOM/Window.cpp @@ -20,7 +20,7 @@ namespace Web::DOM { NonnullRefPtr Window::create_with_document(Document& document) { - return adopt(*new Window(document)); + return adopt_ref(*new Window(document)); } Window::Window(Document& document) diff --git a/Userland/Libraries/LibWeb/DOMTreeModel.h b/Userland/Libraries/LibWeb/DOMTreeModel.h index a8488d83b65..7a0c6656e48 100644 --- a/Userland/Libraries/LibWeb/DOMTreeModel.h +++ b/Userland/Libraries/LibWeb/DOMTreeModel.h @@ -15,7 +15,7 @@ class DOMTreeModel final : public GUI::Model { public: static NonnullRefPtr create(DOM::Document& document) { - return adopt(*new DOMTreeModel(document)); + return adopt_ref(*new DOMTreeModel(document)); } virtual ~DOMTreeModel() override; diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h index a87b63b2ab6..1896e336b03 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h @@ -27,7 +27,7 @@ class CanvasRenderingContext2D public: using WrapperType = Bindings::CanvasRenderingContext2DWrapper; - static NonnullRefPtr create(HTMLCanvasElement& element) { return adopt(*new CanvasRenderingContext2D(element)); } + static NonnullRefPtr create(HTMLCanvasElement& element) { return adopt_ref(*new CanvasRenderingContext2D(element)); } ~CanvasRenderingContext2D(); void set_fill_style(String); diff --git a/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.cpp b/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.cpp index 89f41eb5fe8..f6f49a72d88 100644 --- a/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.cpp +++ b/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.cpp @@ -39,7 +39,7 @@ void GlobalEventHandlers::set_event_handler_attribute(const FlyString& name, HTM RefPtr listener; if (!value.callback.is_null()) { - listener = adopt(*new DOM::EventListener(move(value.callback))); + listener = adopt_ref(*new DOM::EventListener(move(value.callback))); } else { StringBuilder builder; builder.appendff("function {}(event) {{\n{}\n}}", name, value.string); @@ -51,7 +51,7 @@ void GlobalEventHandlers::set_event_handler_attribute(const FlyString& name, HTM } auto* function = JS::ScriptFunction::create(self.script_execution_context()->interpreter().global_object(), name, program->body(), program->parameters(), program->function_length(), nullptr, false, false); VERIFY(function); - listener = adopt(*new DOM::EventListener(JS::make_handle(static_cast(function)))); + listener = adopt_ref(*new DOM::EventListener(JS::make_handle(static_cast(function)))); } if (listener) { for (auto& registered_listener : self.listeners()) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp index 9e783d2d10e..91db220071d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp @@ -20,7 +20,7 @@ HTMLBRElement::~HTMLBRElement() RefPtr HTMLBRElement::create_layout_node() { - return adopt(*new Layout::BreakNode(document(), *this)); + return adopt_ref(*new Layout::BreakNode(document(), *this)); } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp index 697d5145fee..0b0f2561c30 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp @@ -42,7 +42,7 @@ RefPtr HTMLCanvasElement::create_layout_node() auto style = document().style_resolver().resolve_style(*this); if (style->display() == CSS::Display::None) return nullptr; - return adopt(*new Layout::CanvasBox(document(), *this, move(style))); + return adopt_ref(*new Layout::CanvasBox(document(), *this, move(style))); } CanvasRenderingContext2D* HTMLCanvasElement::get_context(String type) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index fd5dca1ad5f..736a446457b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -24,7 +24,7 @@ HTMLIFrameElement::~HTMLIFrameElement() RefPtr HTMLIFrameElement::create_layout_node() { auto style = document().style_resolver().resolve_style(*this); - return adopt(*new Layout::FrameBox(document(), *this, move(style))); + return adopt_ref(*new Layout::FrameBox(document(), *this, move(style))); } void HTMLIFrameElement::parse_attribute(const FlyString& name, const String& value) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp index 192f85dca76..75cf9b45866 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp @@ -69,7 +69,7 @@ RefPtr HTMLImageElement::create_layout_node() auto style = document().style_resolver().resolve_style(*this); if (style->display() == CSS::Display::None) return nullptr; - return adopt(*new Layout::ImageBox(document(), *this, move(style), m_image_loader)); + return adopt_ref(*new Layout::ImageBox(document(), *this, move(style), m_image_loader)); } const Gfx::Bitmap* HTMLImageElement::bitmap() const diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index f79a02951a7..27fcc3e7bd6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -53,16 +53,16 @@ RefPtr HTMLInputElement::create_layout_node() return nullptr; if (type().equals_ignoring_case("submit") || type().equals_ignoring_case("button")) - return adopt(*new Layout::ButtonBox(document(), *this, move(style))); + return adopt_ref(*new Layout::ButtonBox(document(), *this, move(style))); if (type() == "checkbox") - return adopt(*new Layout::CheckBox(document(), *this, move(style))); + return adopt_ref(*new Layout::CheckBox(document(), *this, move(style))); if (type() == "radio") - return adopt(*new Layout::RadioButton(document(), *this, move(style))); + return adopt_ref(*new Layout::RadioButton(document(), *this, move(style))); create_shadow_tree_if_needed(); - auto layout_node = adopt(*new Layout::BlockBox(document(), this, move(style))); + auto layout_node = adopt_ref(*new Layout::BlockBox(document(), this, move(style))); layout_node->set_inline(true); return layout_node; } @@ -105,13 +105,13 @@ void HTMLInputElement::create_shadow_tree_if_needed() return; // FIXME: This assumes that we want a text box. Is that always true? - auto shadow_root = adopt(*new DOM::ShadowRoot(document(), *this)); + auto shadow_root = adopt_ref(*new DOM::ShadowRoot(document(), *this)); auto initial_value = attribute(HTML::AttributeNames::value); if (initial_value.is_null()) initial_value = String::empty(); auto element = document().create_element(HTML::TagNames::div); element->set_attribute(HTML::AttributeNames::style, "white-space: pre"); - m_text_node = adopt(*new DOM::Text(document(), initial_value)); + m_text_node = adopt_ref(*new DOM::Text(document(), initial_value)); m_text_node->set_always_editable(true); element->append_child(*m_text_node); shadow_root->append_child(move(element)); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp index ff3512031d7..07c22801344 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp @@ -25,7 +25,7 @@ RefPtr HTMLLabelElement::create_layout_node() if (style->display() == CSS::Display::None) return nullptr; - auto layout_node = adopt(*new Layout::Label(document(), this, move(style))); + auto layout_node = adopt_ref(*new Layout::Label(document(), this, move(style))); layout_node->set_inline(true); return layout_node; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp index 6909c1a7b77..1908feb99e6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp @@ -50,7 +50,7 @@ RefPtr HTMLObjectElement::create_layout_node() if (style->display() == CSS::Display::None) return nullptr; if (m_image_loader.has_image()) - return adopt(*new Layout::ImageBox(document(), *this, move(style), m_image_loader)); + return adopt_ref(*new Layout::ImageBox(document(), *this, move(style), m_image_loader)); return nullptr; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp index 1c159bdd369..b752fdf6f49 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp @@ -12,7 +12,7 @@ namespace Web::HTML { HTMLTemplateElement::HTMLTemplateElement(DOM::Document& document, QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) { - m_content = adopt(*new DOM::DocumentFragment(appropriate_template_contents_owner_document(document))); + m_content = adopt_ref(*new DOM::DocumentFragment(appropriate_template_contents_owner_document(document))); m_content->set_host(*this); } diff --git a/Userland/Libraries/LibWeb/HTML/ImageData.cpp b/Userland/Libraries/LibWeb/HTML/ImageData.cpp index 3af5c6785ce..b44bb247a2f 100644 --- a/Userland/Libraries/LibWeb/HTML/ImageData.cpp +++ b/Userland/Libraries/LibWeb/HTML/ImageData.cpp @@ -29,7 +29,7 @@ RefPtr ImageData::create_with_size(JS::GlobalObject& global_object, i auto bitmap = Gfx::Bitmap::create_wrapper(Gfx::BitmapFormat::RGBA8888, Gfx::IntSize(width, height), 1, width * sizeof(u32), (u32*)data->data()); if (!bitmap) return nullptr; - return adopt(*new ImageData(bitmap.release_nonnull(), move(data_handle))); + return adopt_ref(*new ImageData(bitmap.release_nonnull(), move(data_handle))); } ImageData::ImageData(NonnullRefPtr bitmap, JS::Handle data) diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp index a26dd711ae5..56e3da4eff1 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp @@ -313,13 +313,13 @@ void HTMLDocumentParser::handle_initial(HTMLToken& token) } if (token.is_comment()) { - auto comment = adopt(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string())); + auto comment = adopt_ref(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string())); document().append_child(move(comment)); return; } if (token.is_doctype()) { - auto doctype = adopt(*new DOM::DocumentType(document())); + auto doctype = adopt_ref(*new DOM::DocumentType(document())); doctype->set_name(token.m_doctype.name.to_string()); doctype->set_public_id(token.m_doctype.public_identifier.to_string()); doctype->set_system_id(token.m_doctype.system_identifier.to_string()); @@ -343,7 +343,7 @@ void HTMLDocumentParser::handle_before_html(HTMLToken& token) } if (token.is_comment()) { - auto comment = adopt(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string())); + auto comment = adopt_ref(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string())); document().append_child(move(comment)); return; } @@ -518,7 +518,7 @@ void HTMLDocumentParser::insert_comment(HTMLToken& token) { auto data = token.m_comment_or_character.data.to_string(); auto adjusted_insertion_location = find_appropriate_place_for_inserting_node(); - adjusted_insertion_location.parent->insert_before(adopt(*new DOM::Comment(document(), data)), adjusted_insertion_location.insert_before_sibling); + adjusted_insertion_location.parent->insert_before(adopt_ref(*new DOM::Comment(document(), data)), adjusted_insertion_location.insert_before_sibling); } void HTMLDocumentParser::handle_in_head(HTMLToken& token) @@ -703,7 +703,7 @@ DOM::Text* HTMLDocumentParser::find_character_insertion_node() return nullptr; if (adjusted_insertion_location.parent->last_child() && adjusted_insertion_location.parent->last_child()->is_text()) return downcast(adjusted_insertion_location.parent->last_child()); - auto new_text_node = adopt(*new DOM::Text(document(), "")); + auto new_text_node = adopt_ref(*new DOM::Text(document(), "")); adjusted_insertion_location.parent->append_child(new_text_node); return new_text_node; } @@ -830,7 +830,7 @@ void HTMLDocumentParser::handle_after_body(HTMLToken& token) if (token.is_comment()) { auto data = token.m_comment_or_character.data.to_string(); auto& insertion_location = m_stack_of_open_elements.first(); - insertion_location.append_child(adopt(*new DOM::Comment(document(), data))); + insertion_location.append_child(adopt_ref(*new DOM::Comment(document(), data))); return; } @@ -866,7 +866,7 @@ void HTMLDocumentParser::handle_after_body(HTMLToken& token) void HTMLDocumentParser::handle_after_after_body(HTMLToken& token) { if (token.is_comment()) { - auto comment = adopt(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string())); + auto comment = adopt_ref(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string())); document().append_child(move(comment)); return; } @@ -2748,7 +2748,7 @@ void HTMLDocumentParser::handle_after_frameset(HTMLToken& token) void HTMLDocumentParser::handle_after_after_frameset(HTMLToken& token) { if (token.is_comment()) { - auto comment = adopt(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string())); + auto comment = adopt_ref(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string())); document().append_child(move(comment)); return; } diff --git a/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp b/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp index 86b06f58eb6..fc63ef6ded9 100644 --- a/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp @@ -11,7 +11,7 @@ namespace Web::HTML { NonnullRefPtr SubmitEvent::create(const FlyString& event_name, RefPtr submitter) { - return adopt(*new SubmitEvent(event_name, move(submitter))); + return adopt_ref(*new SubmitEvent(event_name, move(submitter))); } SubmitEvent::SubmitEvent(const FlyString& event_name, RefPtr submitter) diff --git a/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp b/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp index b524588de75..38c27373c62 100644 --- a/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp @@ -31,7 +31,7 @@ void ListItemBox::layout_marker() if (!m_marker) { int child_index = parent()->index_of_child(*this).value(); - m_marker = adopt(*new ListItemMarkerBox(document(), computed_values().list_style_type(), child_index + 1)); + m_marker = adopt_ref(*new ListItemMarkerBox(document(), computed_values().list_style_type(), child_index + 1)); if (first_child()) m_marker->set_inline(first_child()->is_inline()); append_child(*m_marker); diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp index 809b44aaaa2..51b5b826019 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.cpp +++ b/Userland/Libraries/LibWeb/Layout/Node.cpp @@ -346,7 +346,7 @@ bool Node::is_inline_block() const NonnullRefPtr NodeWithStyle::create_anonymous_wrapper() const { - auto wrapper = adopt(*new BlockBox(const_cast(document()), nullptr, m_computed_values.clone_inherited_values())); + auto wrapper = adopt_ref(*new BlockBox(const_cast(document()), nullptr, m_computed_values.clone_inherited_values())); wrapper->m_font = m_font; wrapper->m_font_size = m_font_size; wrapper->m_line_height = m_line_height; diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp index 2beae5b090a..7b2c1ce4168 100644 --- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -60,7 +60,7 @@ static Layout::Node& insertion_parent_for_block_node(Layout::Node& layout_parent layout_parent.remove_child(*child); children.append(child.release_nonnull()); } - layout_parent.append_child(adopt(*new BlockBox(layout_node.document(), nullptr, layout_parent.computed_values().clone_inherited_values()))); + layout_parent.append_child(adopt_ref(*new BlockBox(layout_node.document(), nullptr, layout_parent.computed_values().clone_inherited_values()))); layout_parent.set_children_are_inline(false); for (auto& child : children) { layout_parent.last_child()->append_child(child); @@ -247,7 +247,7 @@ static void wrap_in_anonymous(NonnullRefPtrVector& sequence, Node* nearest auto& parent = *sequence.first().parent(); auto computed_values = parent.computed_values().clone_inherited_values(); static_cast(computed_values).set_display(WrapperBoxType::static_display()); - auto wrapper = adopt(*new WrapperBoxType(parent.document(), nullptr, move(computed_values))); + auto wrapper = adopt_ref(*new WrapperBoxType(parent.document(), nullptr, move(computed_values))); for (auto& child : sequence) { parent.remove_child(child); wrapper->append_child(child); diff --git a/Userland/Libraries/LibWeb/LayoutTreeModel.h b/Userland/Libraries/LibWeb/LayoutTreeModel.h index d7930c79eaf..ec203227d27 100644 --- a/Userland/Libraries/LibWeb/LayoutTreeModel.h +++ b/Userland/Libraries/LibWeb/LayoutTreeModel.h @@ -15,7 +15,7 @@ class LayoutTreeModel final : public GUI::Model { public: static NonnullRefPtr create(DOM::Document& document) { - return adopt(*new LayoutTreeModel(document)); + return adopt_ref(*new LayoutTreeModel(document)); } virtual ~LayoutTreeModel() override; diff --git a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp index 40ecda858cd..8c1f6dd4c4c 100644 --- a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp @@ -82,7 +82,7 @@ static bool build_image_document(DOM::Document& document, const ByteBuffer& data head_element->append_child(title_element); auto basename = LexicalPath(document.url().path()).basename(); - auto title_text = adopt(*new DOM::Text(document, String::formatted("{} [{}x{}]", basename, bitmap->width(), bitmap->height()))); + auto title_text = adopt_ref(*new DOM::Text(document, String::formatted("{} [{}x{}]", basename, bitmap->width(), bitmap->height()))); title_element->append_child(title_text); auto body_element = document.create_element("body"); diff --git a/Userland/Libraries/LibWeb/Loader/Resource.cpp b/Userland/Libraries/LibWeb/Loader/Resource.cpp index e5bed81e4e7..9223145f96e 100644 --- a/Userland/Libraries/LibWeb/Loader/Resource.cpp +++ b/Userland/Libraries/LibWeb/Loader/Resource.cpp @@ -15,8 +15,8 @@ namespace Web { NonnullRefPtr Resource::create(Badge, Type type, const LoadRequest& request) { if (type == Type::Image) - return adopt(*new ImageResource(request)); - return adopt(*new Resource(type, request)); + return adopt_ref(*new ImageResource(request)); + return adopt_ref(*new Resource(type, request)); } Resource::Resource(Type type, const LoadRequest& request) diff --git a/Userland/Libraries/LibWeb/Page/Frame.h b/Userland/Libraries/LibWeb/Page/Frame.h index 17b507122d0..49370b86837 100644 --- a/Userland/Libraries/LibWeb/Page/Frame.h +++ b/Userland/Libraries/LibWeb/Page/Frame.h @@ -23,8 +23,8 @@ namespace Web { class Frame : public TreeNode { public: - static NonnullRefPtr create_subframe(DOM::Element& host_element, Frame& main_frame) { return adopt(*new Frame(host_element, main_frame)); } - static NonnullRefPtr create(Page& page) { return adopt(*new Frame(page)); } + static NonnullRefPtr create_subframe(DOM::Element& host_element, Frame& main_frame) { return adopt_ref(*new Frame(host_element, main_frame)); } + static NonnullRefPtr create(Page& page) { return adopt_ref(*new Frame(page)); } ~Frame(); class ViewportClient { diff --git a/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp index 84d67212955..9cd4b1a30a4 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp @@ -447,7 +447,7 @@ RefPtr SVGPathElement::create_layout_node() auto style = document().style_resolver().resolve_style(*this); if (style->display() == CSS::Display::None) return nullptr; - return adopt(*new Layout::SVGPathBox(document(), *this, move(style))); + return adopt_ref(*new Layout::SVGPathBox(document(), *this, move(style))); } void SVGPathElement::parse_attribute(const FlyString& name, const String& value) diff --git a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp index 218af6175d4..effcf8edcb9 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp @@ -25,7 +25,7 @@ RefPtr SVGSVGElement::create_layout_node() auto style = document().style_resolver().resolve_style(*this); if (style->display() == CSS::Display::None) return nullptr; - return adopt(*new Layout::SVGSVGBox(document(), *this, move(style))); + return adopt_ref(*new Layout::SVGSVGBox(document(), *this, move(style))); } unsigned SVGSVGElement::width() const diff --git a/Userland/Libraries/LibWeb/StylePropertiesModel.h b/Userland/Libraries/LibWeb/StylePropertiesModel.h index 56cf0df533b..eba05177084 100644 --- a/Userland/Libraries/LibWeb/StylePropertiesModel.h +++ b/Userland/Libraries/LibWeb/StylePropertiesModel.h @@ -22,7 +22,7 @@ public: __Count }; - static NonnullRefPtr create(const CSS::StyleProperties& properties) { return adopt(*new StylePropertiesModel(properties)); } + static NonnullRefPtr create(const CSS::StyleProperties& properties) { return adopt_ref(*new StylePropertiesModel(properties)); } virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; } diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h index 8535c93cbdb..8f56dac9e54 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h @@ -17,7 +17,7 @@ public: static NonnullRefPtr create(const FlyString& event_name, i32 offset_x, i32 offset_y, i32 client_x, i32 client_y) { - return adopt(*new MouseEvent(event_name, offset_x, offset_y, client_x, client_y)); + return adopt_ref(*new MouseEvent(event_name, offset_x, offset_y, client_x, client_y)); } virtual ~MouseEvent() override; diff --git a/Userland/Libraries/LibWeb/XHR/ProgressEvent.h b/Userland/Libraries/LibWeb/XHR/ProgressEvent.h index eab22a4b783..7cd2ca49d10 100644 --- a/Userland/Libraries/LibWeb/XHR/ProgressEvent.h +++ b/Userland/Libraries/LibWeb/XHR/ProgressEvent.h @@ -19,7 +19,7 @@ public: static NonnullRefPtr create(const FlyString& event_name, u32 transmitted, u32 length) { - return adopt(*new ProgressEvent(event_name, transmitted, length)); + return adopt_ref(*new ProgressEvent(event_name, transmitted, length)); } virtual ~ProgressEvent() override { } diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h index 1c1e91241ea..2b3f46d2717 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h @@ -35,7 +35,7 @@ public: static NonnullRefPtr create(DOM::Window& window) { - return adopt(*new XMLHttpRequest(window)); + return adopt_ref(*new XMLHttpRequest(window)); } static NonnullRefPtr create_with_global_object(Bindings::WindowObject& window) { diff --git a/Userland/Libraries/LibWebSocket/WebSocket.cpp b/Userland/Libraries/LibWebSocket/WebSocket.cpp index a2ddefb0e49..75843ac71d5 100644 --- a/Userland/Libraries/LibWebSocket/WebSocket.cpp +++ b/Userland/Libraries/LibWebSocket/WebSocket.cpp @@ -21,7 +21,7 @@ namespace WebSocket { NonnullRefPtr WebSocket::create(ConnectionInfo connection) { - return adopt(*new WebSocket(connection)); + return adopt_ref(*new WebSocket(connection)); } WebSocket::WebSocket(ConnectionInfo connection) diff --git a/Userland/Services/AudioServer/Mixer.cpp b/Userland/Services/AudioServer/Mixer.cpp index 8ef098a76df..7de474120df 100644 --- a/Userland/Services/AudioServer/Mixer.cpp +++ b/Userland/Services/AudioServer/Mixer.cpp @@ -42,7 +42,7 @@ Mixer::~Mixer() NonnullRefPtr Mixer::create_queue(ClientConnection& client) { - auto queue = adopt(*new BufferQueue(client)); + auto queue = adopt_ref(*new BufferQueue(client)); pthread_mutex_lock(&m_pending_mutex); m_pending_mixing.append(*queue); m_added_queue = true; diff --git a/Userland/Services/EchoServer/Client.h b/Userland/Services/EchoServer/Client.h index 9793d5d436a..d9c30768810 100644 --- a/Userland/Services/EchoServer/Client.h +++ b/Userland/Services/EchoServer/Client.h @@ -12,7 +12,7 @@ class Client : public RefCounted { public: static NonnullRefPtr create(int id, RefPtr socket) { - return adopt(*new Client(id, move(socket))); + return adopt_ref(*new Client(id, move(socket))); } Function on_exit; diff --git a/Userland/Services/TelnetServer/Client.h b/Userland/Services/TelnetServer/Client.h index 3908782bcba..e717aee4b31 100644 --- a/Userland/Services/TelnetServer/Client.h +++ b/Userland/Services/TelnetServer/Client.h @@ -19,7 +19,7 @@ class Client : public RefCounted { public: static NonnullRefPtr create(int id, RefPtr socket, int ptm_fd) { - return adopt(*new Client(id, move(socket), ptm_fd)); + return adopt_ref(*new Client(id, move(socket), ptm_fd)); } Function on_exit; diff --git a/Userland/Services/WindowServer/Cursor.cpp b/Userland/Services/WindowServer/Cursor.cpp index f100a8cf2f1..9722be3390a 100644 --- a/Userland/Services/WindowServer/Cursor.cpp +++ b/Userland/Services/WindowServer/Cursor.cpp @@ -117,13 +117,13 @@ Cursor::~Cursor() NonnullRefPtr Cursor::create(NonnullRefPtr&& bitmap) { auto hotspot = bitmap->rect().center(); - return adopt(*new Cursor(move(bitmap), CursorParams(hotspot))); + return adopt_ref(*new Cursor(move(bitmap), CursorParams(hotspot))); } NonnullRefPtr Cursor::create(NonnullRefPtr&& bitmap, const StringView& filename) { auto default_hotspot = bitmap->rect().center(); - return adopt(*new Cursor(move(bitmap), CursorParams::parse_from_file_name(filename, default_hotspot))); + return adopt_ref(*new Cursor(move(bitmap), CursorParams::parse_from_file_name(filename, default_hotspot))); } RefPtr Cursor::create(Gfx::StandardCursor standard_cursor) diff --git a/Userland/Services/WindowServer/Menubar.h b/Userland/Services/WindowServer/Menubar.h index d1c84f404d5..03e10d14c57 100644 --- a/Userland/Services/WindowServer/Menubar.h +++ b/Userland/Services/WindowServer/Menubar.h @@ -17,7 +17,7 @@ class Menubar : public RefCounted , public Weakable { public: - static NonnullRefPtr create(ClientConnection& client, int menubar_id) { return adopt(*new Menubar(client, menubar_id)); } + static NonnullRefPtr create(ClientConnection& client, int menubar_id) { return adopt_ref(*new Menubar(client, menubar_id)); } ~Menubar(); ClientConnection& client() { return m_client; } diff --git a/Userland/Shell/AST.cpp b/Userland/Shell/AST.cpp index 8600392784a..e66566039b8 100644 --- a/Userland/Shell/AST.cpp +++ b/Userland/Shell/AST.cpp @@ -829,7 +829,7 @@ RefPtr CloseFdRedirection::run(RefPtr) { Command command; command.position = position(); - command.redirections.append(adopt(*new CloseRedirection(m_fd))); + command.redirections.append(adopt_ref(*new CloseRedirection(m_fd))); return create(move(command)); } @@ -3249,7 +3249,7 @@ ListValue::ListValue(Vector values) return; m_contained_values.ensure_capacity(values.size()); for (auto& str : values) - m_contained_values.append(adopt(*new StringValue(move(str)))); + m_contained_values.append(adopt_ref(*new StringValue(move(str)))); } NonnullRefPtr Value::with_slices(NonnullRefPtr slice) const& @@ -3447,7 +3447,7 @@ Vector TildeValue::resolve_as_list(RefPtr shell) Result, String> CloseRedirection::apply() const { - return adopt(*new Rewiring(fd, fd, Rewiring::Close::ImmediatelyCloseNew)); + return adopt_ref(*new Rewiring(fd, fd, Rewiring::Close::ImmediatelyCloseNew)); } CloseRedirection::~CloseRedirection() @@ -3462,7 +3462,7 @@ Result, String> PathRedirection::apply() const dbgln("open() failed for '{}' with {}", path, error); return error; } - return adopt(*new Rewiring(fd, my_fd, Rewiring::Close::Old)); + return adopt_ref(*new Rewiring(fd, my_fd, Rewiring::Close::Old)); }; switch (direction) { case AST::PathRedirection::WriteAppend: diff --git a/Userland/Shell/AST.h b/Userland/Shell/AST.h index 629fe69c70d..69be321f107 100644 --- a/Userland/Shell/AST.h +++ b/Userland/Shell/AST.h @@ -24,13 +24,13 @@ namespace Shell::AST { template static inline NonnullRefPtr create(Args... args) { - return adopt(*new T(args...)); + return adopt_ref(*new T(args...)); } template static inline NonnullRefPtr create(std::initializer_list> arg) { - return adopt(*new T(arg)); + return adopt_ref(*new T(arg)); } struct HighlightMetadata { @@ -122,7 +122,7 @@ struct PathRedirection : public Redirection { static NonnullRefPtr create(String path, int fd, decltype(direction) direction) { - return adopt(*new PathRedirection(move(path), fd, direction)); + return adopt_ref(*new PathRedirection(move(path), fd, direction)); } virtual Result, String> apply() const override; @@ -143,19 +143,19 @@ struct FdRedirection : public Redirection { public: static NonnullRefPtr create(int old_fd, int new_fd, Rewiring::Close close) { - return adopt(*new FdRedirection(old_fd, new_fd, close)); + return adopt_ref(*new FdRedirection(old_fd, new_fd, close)); } static NonnullRefPtr create(int old_fd, int new_fd, FdRedirection* pipe_end, Rewiring::Close close) { - return adopt(*new FdRedirection(old_fd, new_fd, pipe_end, close)); + return adopt_ref(*new FdRedirection(old_fd, new_fd, pipe_end, close)); } virtual ~FdRedirection(); virtual Result, String> apply() const override { - return adopt(*new Rewiring(old_fd, new_fd, other_pipe_end, action)); + return adopt_ref(*new Rewiring(old_fd, new_fd, other_pipe_end, action)); } int old_fd { -1 }; diff --git a/Userland/Shell/Builtin.cpp b/Userland/Shell/Builtin.cpp index e1fa12ba54c..ff1ca7f6344 100644 --- a/Userland/Shell/Builtin.cpp +++ b/Userland/Shell/Builtin.cpp @@ -767,7 +767,7 @@ int Shell::builtin_shift(int argc, const char** argv) } if (!argv_->is_list()) - argv_ = adopt(*new AST::ListValue({ argv_.release_nonnull() })); + argv_ = adopt_ref(*new AST::ListValue({ argv_.release_nonnull() })); auto& values = static_cast(argv_.ptr())->values(); if ((size_t)count > values.size()) { diff --git a/Userland/Shell/Job.h b/Userland/Shell/Job.h index d99219f91ee..fd84b6c94e3 100644 --- a/Userland/Shell/Job.h +++ b/Userland/Shell/Job.h @@ -27,7 +27,7 @@ struct LocalFrame; class Job : public RefCounted { public: - static NonnullRefPtr create(pid_t pid, pid_t pgid, String cmd, u64 job_id, AST::Command&& command) { return adopt(*new Job(pid, pgid, move(cmd), job_id, move(command))); } + static NonnullRefPtr create(pid_t pid, pid_t pgid, String cmd, u64 job_id, AST::Command&& command) { return adopt_ref(*new Job(pid, pgid, move(cmd), job_id, move(command))); } ~Job() { diff --git a/Userland/Shell/Parser.cpp b/Userland/Shell/Parser.cpp index 742c17039e5..d1e422f6d83 100644 --- a/Userland/Shell/Parser.cpp +++ b/Userland/Shell/Parser.cpp @@ -84,7 +84,7 @@ bool Parser::expect(const StringView& expected) template NonnullRefPtr Parser::create(Args... args) { - return adopt(*new A(AST::Position { m_rule_start_offsets.last(), m_offset, m_rule_start_lines.last(), line() }, args...)); + return adopt_ref(*new A(AST::Position { m_rule_start_offsets.last(), m_offset, m_rule_start_lines.last(), line() }, args...)); } [[nodiscard]] OwnPtr Parser::push_start() diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp index 317e68a5e0f..6d0500bd858 100644 --- a/Userland/Shell/Shell.cpp +++ b/Userland/Shell/Shell.cpp @@ -297,9 +297,9 @@ Vector Shell::expand_aliases(Vector initial_commands subcommand_ast = ast->command(); } auto subcommand_nonnull = subcommand_ast.release_nonnull(); - NonnullRefPtr substitute = adopt(*new AST::Join(subcommand_nonnull->position(), + NonnullRefPtr substitute = adopt_ref(*new AST::Join(subcommand_nonnull->position(), subcommand_nonnull, - adopt(*new AST::CommandLiteral(subcommand_nonnull->position(), command)))); + adopt_ref(*new AST::CommandLiteral(subcommand_nonnull->position(), command)))); auto res = substitute->run(*this); for (auto& subst_command : res->resolve_as_commands(*this)) { if (!subst_command.argv.is_empty() && subst_command.argv.first() == argv0) // Disallow an alias resolving to itself. @@ -356,7 +356,7 @@ RefPtr Shell::lookup_local_variable(const String& name) RefPtr Shell::get_argument(size_t index) { if (index == 0) - return adopt(*new AST::StringValue(current_script)); + return adopt_ref(*new AST::StringValue(current_script)); --index; if (auto argv = lookup_local_variable("ARGV")) { @@ -452,12 +452,12 @@ bool Shell::invoke_function(const AST::Command& command, int& retval) size_t index = 0; for (auto& arg : function.arguments) { ++index; - set_local_variable(arg, adopt(*new AST::StringValue(command.argv[index])), true); + set_local_variable(arg, adopt_ref(*new AST::StringValue(command.argv[index])), true); } auto argv = command.argv; argv.take_first(); - set_local_variable("ARGV", adopt(*new AST::ListValue(move(argv))), true); + set_local_variable("ARGV", adopt_ref(*new AST::ListValue(move(argv))), true); Core::EventLoop loop; setup_signals(); @@ -910,8 +910,8 @@ void Shell::run_tail(const AST::Command& invoking_command, const AST::NodeWithAc } auto node = next_in_chain.node; if (!invoking_command.should_wait) - node = adopt(static_cast(*new AST::Background(next_in_chain.node->position(), move(node)))); - adopt(static_cast(*new AST::Execute(next_in_chain.node->position(), move(node))))->run(*this); + node = adopt_ref(static_cast(*new AST::Background(next_in_chain.node->position(), move(node)))); + adopt_ref(static_cast(*new AST::Execute(next_in_chain.node->position(), move(node))))->run(*this); }; switch (next_in_chain.action) { case AST::NodeWithAction::And: diff --git a/Userland/Shell/main.cpp b/Userland/Shell/main.cpp index c5428e5301d..f8a15f76360 100644 --- a/Userland/Shell/main.cpp +++ b/Userland/Shell/main.cpp @@ -163,7 +163,7 @@ int main(int argc, char** argv) Vector args; for (auto* arg : script_args) args.empend(arg); - shell->set_local_variable("ARGV", adopt(*new Shell::AST::ListValue(move(args)))); + shell->set_local_variable("ARGV", adopt_ref(*new Shell::AST::ListValue(move(args)))); } if (command_to_run) {