summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLenny Maiorani <lenny@serenityos.org>2022-02-26 09:09:45 -0700
committerBrian Gianforcaro <b.gianfo@gmail.com>2022-03-10 18:04:26 -0800
commitea58b8d9275b16e50d69b585519fbb4f1a850415 (patch)
tree629147d3d309f193923dee1793b54348d86404cd /Userland
parentc6dcb12b000a04a6e2cf840b71fc051078c96256 (diff)
downloadserenity-ea58b8d9275b16e50d69b585519fbb4f1a850415.zip
Libraries: Use default constructors/destructors in LibCore
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibCore/AnonymousBuffer.h3
-rw-r--r--Userland/Libraries/LibCore/CMakeLists.txt1
-rw-r--r--Userland/Libraries/LibCore/DeferredInvocationContext.h3
-rw-r--r--Userland/Libraries/LibCore/Event.cpp5
-rw-r--r--Userland/Libraries/LibCore/Event.h15
-rw-r--r--Userland/Libraries/LibCore/EventLoop.cpp5
-rw-r--r--Userland/Libraries/LibCore/EventLoop.h3
-rw-r--r--Userland/Libraries/LibCore/FileWatcher.h4
-rw-r--r--Userland/Libraries/LibCore/IODevice.cpp5
-rw-r--r--Userland/Libraries/LibCore/IODevice.h3
-rw-r--r--Userland/Libraries/LibCore/MimeData.h5
-rw-r--r--Userland/Libraries/LibCore/NetworkJob.cpp5
-rw-r--r--Userland/Libraries/LibCore/NetworkJob.h3
-rw-r--r--Userland/Libraries/LibCore/NetworkResponse.cpp19
-rw-r--r--Userland/Libraries/LibCore/NetworkResponse.h5
-rw-r--r--Userland/Libraries/LibCore/Object.cpp5
-rw-r--r--Userland/Libraries/LibCore/Object.h3
-rw-r--r--Userland/Libraries/LibCore/Property.cpp5
-rw-r--r--Userland/Libraries/LibCore/Property.h3
-rw-r--r--Userland/Libraries/LibCore/SocketAddress.h3
-rw-r--r--Userland/Libraries/LibCore/Stream.h9
-rw-r--r--Userland/Libraries/LibCore/Timer.cpp5
-rw-r--r--Userland/Libraries/LibCore/Timer.h3
23 files changed, 46 insertions, 74 deletions
diff --git a/Userland/Libraries/LibCore/AnonymousBuffer.h b/Userland/Libraries/LibCore/AnonymousBuffer.h
index 2daf0d5dea..895bfec464 100644
--- a/Userland/Libraries/LibCore/AnonymousBuffer.h
+++ b/Userland/Libraries/LibCore/AnonymousBuffer.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -38,7 +39,7 @@ public:
static ErrorOr<AnonymousBuffer> create_with_size(size_t);
static ErrorOr<AnonymousBuffer> create_from_anon_fd(int fd, size_t);
- AnonymousBuffer() { }
+ AnonymousBuffer() = default;
bool is_valid() const { return m_impl; }
diff --git a/Userland/Libraries/LibCore/CMakeLists.txt b/Userland/Libraries/LibCore/CMakeLists.txt
index 07b18a271b..eb3332cab0 100644
--- a/Userland/Libraries/LibCore/CMakeLists.txt
+++ b/Userland/Libraries/LibCore/CMakeLists.txt
@@ -20,7 +20,6 @@ set(SOURCES
MappedFile.cpp
MimeData.cpp
NetworkJob.cpp
- NetworkResponse.cpp
Notifier.cpp
Object.cpp
Process.cpp
diff --git a/Userland/Libraries/LibCore/DeferredInvocationContext.h b/Userland/Libraries/LibCore/DeferredInvocationContext.h
index b0e0e19c2b..80626379bb 100644
--- a/Userland/Libraries/LibCore/DeferredInvocationContext.h
+++ b/Userland/Libraries/LibCore/DeferredInvocationContext.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, sin-ack <sin-ack@protonmail.com>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -13,7 +14,7 @@ namespace Core {
class DeferredInvocationContext final : public Core::Object {
C_OBJECT(DeferredInvocationContext)
private:
- DeferredInvocationContext() { }
+ DeferredInvocationContext() = default;
};
}
diff --git a/Userland/Libraries/LibCore/Event.cpp b/Userland/Libraries/LibCore/Event.cpp
index 117936043a..37cc05d95c 100644
--- a/Userland/Libraries/LibCore/Event.cpp
+++ b/Userland/Libraries/LibCore/Event.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -17,10 +18,6 @@ ChildEvent::ChildEvent(Type type, Object& child, Object* insertion_before_child)
{
}
-ChildEvent::~ChildEvent()
-{
-}
-
Object* ChildEvent::child()
{
if (auto ref = m_child.strong_ref())
diff --git a/Userland/Libraries/LibCore/Event.h b/Userland/Libraries/LibCore/Event.h
index bc7045704b..164580b0c7 100644
--- a/Userland/Libraries/LibCore/Event.h
+++ b/Userland/Libraries/LibCore/Event.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -29,12 +30,12 @@ public:
Custom,
};
- Event() { }
+ Event() = default;
explicit Event(unsigned type)
: m_type(type)
{
}
- virtual ~Event() { }
+ virtual ~Event() = default;
unsigned type() const { return m_type; }
@@ -70,7 +71,7 @@ public:
, m_timer_id(timer_id)
{
}
- ~TimerEvent() { }
+ ~TimerEvent() = default;
int timer_id() const { return m_timer_id; }
@@ -85,7 +86,7 @@ public:
, m_fd(fd)
{
}
- ~NotifierReadEvent() { }
+ ~NotifierReadEvent() = default;
int fd() const { return m_fd; }
@@ -100,7 +101,7 @@ public:
, m_fd(fd)
{
}
- ~NotifierWriteEvent() { }
+ ~NotifierWriteEvent() = default;
int fd() const { return m_fd; }
@@ -111,7 +112,7 @@ private:
class ChildEvent final : public Event {
public:
ChildEvent(Type, Object& child, Object* insertion_before_child = nullptr);
- ~ChildEvent();
+ ~ChildEvent() = default;
Object* child();
const Object* child() const;
@@ -131,7 +132,7 @@ public:
, m_custom_type(custom_type)
{
}
- ~CustomEvent() { }
+ ~CustomEvent() = default;
int custom_type() const { return m_custom_type; }
diff --git a/Userland/Libraries/LibCore/EventLoop.cpp b/Userland/Libraries/LibCore/EventLoop.cpp
index ed755ceeb6..43200a1ef3 100644
--- a/Userland/Libraries/LibCore/EventLoop.cpp
+++ b/Userland/Libraries/LibCore/EventLoop.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, kleines Filmröllchen <malu.bertsch@gmail.com>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -875,8 +876,4 @@ EventLoop::QueuedEvent::QueuedEvent(QueuedEvent&& other)
{
}
-EventLoop::QueuedEvent::~QueuedEvent()
-{
-}
-
}
diff --git a/Userland/Libraries/LibCore/EventLoop.h b/Userland/Libraries/LibCore/EventLoop.h
index 294be5bbec..6e625b0d1d 100644
--- a/Userland/Libraries/LibCore/EventLoop.h
+++ b/Userland/Libraries/LibCore/EventLoop.h
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, kleines Filmröllchen <malu.bertsch@gmail.com>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -117,7 +118,7 @@ private:
public:
QueuedEvent(Object& receiver, NonnullOwnPtr<Event>);
QueuedEvent(QueuedEvent&&);
- ~QueuedEvent();
+ ~QueuedEvent() = default;
WeakPtr<Object> receiver;
NonnullOwnPtr<Event> event;
diff --git a/Userland/Libraries/LibCore/FileWatcher.h b/Userland/Libraries/LibCore/FileWatcher.h
index 56c21f3978..c8d70011dd 100644
--- a/Userland/Libraries/LibCore/FileWatcher.h
+++ b/Userland/Libraries/LibCore/FileWatcher.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
- * Copyright (c) 2021, the SerenityOS developers.
+ * Copyright (c) 2021-2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -36,7 +36,7 @@ AK_ENUM_BITWISE_OPERATORS(FileWatcherEvent::Type);
class FileWatcherBase {
public:
- virtual ~FileWatcherBase() { }
+ virtual ~FileWatcherBase() = default;
ErrorOr<bool> add_watch(String path, FileWatcherEvent::Type event_mask);
ErrorOr<bool> remove_watch(String path);
diff --git a/Userland/Libraries/LibCore/IODevice.cpp b/Userland/Libraries/LibCore/IODevice.cpp
index 889e49a5c0..a0d792e85e 100644
--- a/Userland/Libraries/LibCore/IODevice.cpp
+++ b/Userland/Libraries/LibCore/IODevice.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -21,10 +22,6 @@ IODevice::IODevice(Object* parent)
{
}
-IODevice::~IODevice()
-{
-}
-
const char* IODevice::error_string() const
{
return strerror(m_error);
diff --git a/Userland/Libraries/LibCore/IODevice.h b/Userland/Libraries/LibCore/IODevice.h
index 752963483b..6fb3255155 100644
--- a/Userland/Libraries/LibCore/IODevice.h
+++ b/Userland/Libraries/LibCore/IODevice.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -72,7 +73,7 @@ AK_ENUM_BITWISE_OPERATORS(OpenMode)
class IODevice : public Object {
C_OBJECT_ABSTRACT(IODevice)
public:
- virtual ~IODevice() override;
+ virtual ~IODevice() override = default;
int fd() const { return m_fd; }
OpenMode mode() const { return m_mode; }
diff --git a/Userland/Libraries/LibCore/MimeData.h b/Userland/Libraries/LibCore/MimeData.h
index 71c9f32a9c..d3f6b05df8 100644
--- a/Userland/Libraries/LibCore/MimeData.h
+++ b/Userland/Libraries/LibCore/MimeData.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -17,7 +18,7 @@ class MimeData : public Object {
C_OBJECT(MimeData);
public:
- virtual ~MimeData() { }
+ virtual ~MimeData() = default;
ByteBuffer data(const String& mime_type) const { return m_data.get(mime_type).value_or({}); }
void set_data(const String& mime_type, ByteBuffer&& data) { m_data.set(mime_type, move(data)); }
@@ -38,7 +39,7 @@ public:
const HashMap<String, ByteBuffer>& all_data() const { return m_data; }
private:
- MimeData() { }
+ MimeData() = default;
explicit MimeData(const HashMap<String, ByteBuffer>& data)
: m_data(data)
{
diff --git a/Userland/Libraries/LibCore/NetworkJob.cpp b/Userland/Libraries/LibCore/NetworkJob.cpp
index 03efac0069..9c031f4f39 100644
--- a/Userland/Libraries/LibCore/NetworkJob.cpp
+++ b/Userland/Libraries/LibCore/NetworkJob.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -15,10 +16,6 @@ NetworkJob::NetworkJob(Core::Stream::Stream& output_stream)
{
}
-NetworkJob::~NetworkJob()
-{
-}
-
void NetworkJob::start(Core::Stream::Socket&)
{
}
diff --git a/Userland/Libraries/LibCore/NetworkJob.h b/Userland/Libraries/LibCore/NetworkJob.h
index e17f531796..84bdc2dbc4 100644
--- a/Userland/Libraries/LibCore/NetworkJob.h
+++ b/Userland/Libraries/LibCore/NetworkJob.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -24,7 +25,7 @@ public:
ProtocolFailed,
Cancelled,
};
- virtual ~NetworkJob() override;
+ virtual ~NetworkJob() override = default;
// Could fire twice, after Headers and after Trailers!
Function<void(const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> response_code)> on_headers_received;
diff --git a/Userland/Libraries/LibCore/NetworkResponse.cpp b/Userland/Libraries/LibCore/NetworkResponse.cpp
deleted file mode 100644
index 99ed43095c..0000000000
--- a/Userland/Libraries/LibCore/NetworkResponse.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibCore/NetworkResponse.h>
-
-namespace Core {
-
-NetworkResponse::NetworkResponse()
-{
-}
-
-NetworkResponse::~NetworkResponse()
-{
-}
-
-}
diff --git a/Userland/Libraries/LibCore/NetworkResponse.h b/Userland/Libraries/LibCore/NetworkResponse.h
index b916592fc1..87cab28667 100644
--- a/Userland/Libraries/LibCore/NetworkResponse.h
+++ b/Userland/Libraries/LibCore/NetworkResponse.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -13,12 +14,12 @@ namespace Core {
class NetworkResponse : public RefCounted<NetworkResponse> {
public:
- virtual ~NetworkResponse();
+ virtual ~NetworkResponse() = default;
bool is_error() const { return m_error; }
protected:
- explicit NetworkResponse();
+ explicit NetworkResponse() = default;
bool m_error { false };
};
diff --git a/Userland/Libraries/LibCore/Object.cpp b/Userland/Libraries/LibCore/Object.cpp
index 66c47b0bf5..62f9d54939 100644
--- a/Userland/Libraries/LibCore/Object.cpp
+++ b/Userland/Libraries/LibCore/Object.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -270,10 +271,6 @@ ObjectClassRegistration::ObjectClassRegistration(StringView class_name, Function
object_classes().set(class_name, this);
}
-ObjectClassRegistration::~ObjectClassRegistration()
-{
-}
-
bool ObjectClassRegistration::is_derived_from(const ObjectClassRegistration& base_class) const
{
if (&base_class == this)
diff --git a/Userland/Libraries/LibCore/Object.h b/Userland/Libraries/LibCore/Object.h
index 3ab4c8fbf9..5e29bc857b 100644
--- a/Userland/Libraries/LibCore/Object.h
+++ b/Userland/Libraries/LibCore/Object.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -40,7 +41,7 @@ class ObjectClassRegistration {
public:
ObjectClassRegistration(StringView class_name, Function<RefPtr<Object>()> factory, ObjectClassRegistration* parent_class = nullptr);
- ~ObjectClassRegistration();
+ ~ObjectClassRegistration() = default;
String class_name() const { return m_class_name; }
const ObjectClassRegistration* parent_class() const { return m_parent_class; }
diff --git a/Userland/Libraries/LibCore/Property.cpp b/Userland/Libraries/LibCore/Property.cpp
index faf00e25ed..16443a0171 100644
--- a/Userland/Libraries/LibCore/Property.cpp
+++ b/Userland/Libraries/LibCore/Property.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -15,8 +16,4 @@ Property::Property(String name, Function<JsonValue()> getter, Function<bool(cons
{
}
-Property::~Property()
-{
-}
-
}
diff --git a/Userland/Libraries/LibCore/Property.h b/Userland/Libraries/LibCore/Property.h
index 3716520f00..8370bdf5a4 100644
--- a/Userland/Libraries/LibCore/Property.h
+++ b/Userland/Libraries/LibCore/Property.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -16,7 +17,7 @@ class Property {
public:
Property(String name, Function<JsonValue()> getter, Function<bool(const JsonValue&)> setter = nullptr);
- ~Property();
+ ~Property() = default;
bool set(const JsonValue& value)
{
diff --git a/Userland/Libraries/LibCore/SocketAddress.h b/Userland/Libraries/LibCore/SocketAddress.h
index 417d329bad..b575ff339d 100644
--- a/Userland/Libraries/LibCore/SocketAddress.h
+++ b/Userland/Libraries/LibCore/SocketAddress.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -23,7 +24,7 @@ public:
Local
};
- SocketAddress() { }
+ SocketAddress() = default;
SocketAddress(const IPv4Address& address)
: m_type(Type::IPv4)
, m_ipv4_address(address)
diff --git a/Userland/Libraries/LibCore/Stream.h b/Userland/Libraries/LibCore/Stream.h
index 8aba029f45..4eb13eb64e 100644
--- a/Userland/Libraries/LibCore/Stream.h
+++ b/Userland/Libraries/LibCore/Stream.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2021, sin-ack <sin-ack@protonmail.com>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -382,7 +383,7 @@ public:
virtual ~UDPSocket() override { close(); }
private:
- UDPSocket() { }
+ UDPSocket() = default;
void setup_notifier()
{
@@ -452,7 +453,7 @@ public:
virtual ~LocalSocket() { close(); }
private:
- LocalSocket() { }
+ LocalSocket() = default;
void setup_notifier()
{
@@ -774,7 +775,7 @@ public:
size_t buffer_size() const { return m_helper.buffer_size(); }
- virtual ~BufferedSeekable() override { }
+ virtual ~BufferedSeekable() override = default;
private:
BufferedSeekable(NonnullOwnPtr<T> stream, ByteBuffer buffer)
@@ -843,7 +844,7 @@ public:
virtual size_t buffer_size() const override { return m_helper.buffer_size(); }
- virtual ~BufferedSocket() override { }
+ virtual ~BufferedSocket() override = default;
private:
BufferedSocket(NonnullOwnPtr<T> stream, ByteBuffer buffer)
diff --git a/Userland/Libraries/LibCore/Timer.cpp b/Userland/Libraries/LibCore/Timer.cpp
index c58f6d2bc5..1942a262a4 100644
--- a/Userland/Libraries/LibCore/Timer.cpp
+++ b/Userland/Libraries/LibCore/Timer.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -20,10 +21,6 @@ Timer::Timer(int interval_ms, Function<void()>&& timeout_handler, Object* parent
start(interval_ms);
}
-Timer::~Timer()
-{
-}
-
void Timer::start()
{
start(m_interval_ms);
diff --git a/Userland/Libraries/LibCore/Timer.h b/Userland/Libraries/LibCore/Timer.h
index 2edadc6af1..b41caa4f54 100644
--- a/Userland/Libraries/LibCore/Timer.h
+++ b/Userland/Libraries/LibCore/Timer.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -29,7 +30,7 @@ public:
return timer;
}
- virtual ~Timer() override;
+ virtual ~Timer() override = default;
void start();
void start(int interval_ms);