Skip to content

Commit 8f7333f

Browse files
committed
LibCore: Add a forward declaration header
This patch adds <LibCore/Forward.h> and uses it in various places to shrink the header dependency graph.
1 parent 3bbf461 commit 8f7333f

35 files changed

+143
-38
lines changed

AK/Forward.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ class NonnullRefPtr;
7070
template<typename T>
7171
class NonnullOwnPtr;
7272

73+
template<typename T>
74+
class Optional;
75+
7376
template<typename T>
7477
class RefPtr;
7578

@@ -98,6 +101,7 @@ using AK::JsonObject;
98101
using AK::JsonValue;
99102
using AK::NonnullOwnPtr;
100103
using AK::NonnullRefPtr;
104+
using AK::Optional;
101105
using AK::OwnPtr;
102106
using AK::RefPtr;
103107
using AK::SinglyLinkedList;

AK/IntrusiveList.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
#pragma once
2828

29+
#include <AK/Assertions.h>
30+
2931
namespace AK {
3032

3133
class IntrusiveListNode;

AK/Optional.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include <AK/Platform.h>
3131
#include <AK/StdLibExtras.h>
3232

33+
namespace AK {
34+
3335
template<typename T>
3436
class CONSUMABLE(unknown) alignas(T) Optional {
3537
public:
@@ -161,3 +163,7 @@ class CONSUMABLE(unknown) alignas(T) Optional {
161163
char m_storage[sizeof(T)];
162164
bool m_has_value { false };
163165
};
166+
167+
}
168+
169+
using AK::Optional;

Applications/Help/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include "History.h"
2828
#include "ManualModel.h"
29+
#include <AK/ByteBuffer.h>
2930
#include <LibCore/File.h>
3031
#include <LibGUI/AboutDialog.h>
3132
#include <LibGUI/Action.h>

Applications/SystemMonitor/ProcessStacksWidget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*/
2626

2727
#include "ProcessStacksWidget.h"
28+
#include <AK/ByteBuffer.h>
2829
#include <LibCore/File.h>
2930
#include <LibCore/Timer.h>
3031
#include <LibGUI/BoxLayout.h>

DevTools/HackStudio/Editor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include "Editor.h"
2828
#include "EditorWrapper.h"
29+
#include <AK/ByteBuffer.h>
2930
#include <AK/FileSystemPath.h>
3031
#include <LibCore/DirIterator.h>
3132
#include <LibCore/File.h>

DevTools/IPCCompiler/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*/
2626

2727
#include <AK/BufferStream.h>
28+
#include <AK/Function.h>
2829
#include <AK/HashMap.h>
2930
#include <AK/StringBuilder.h>
3031
#include <LibCore/File.h>

Libraries/LibAudio/WavLoader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*/
2626

2727
#include <AK/BufferStream.h>
28+
#include <AK/OwnPtr.h>
2829
#include <LibAudio/WavLoader.h>
2930
#include <LibCore/File.h>
3031
#include <LibCore/IODeviceStreamReader.h>

Libraries/LibCore/Event.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@
3030
#include <AK/String.h>
3131
#include <AK/Types.h>
3232
#include <AK/WeakPtr.h>
33+
#include <LibCore/Forward.h>
3334

3435
namespace Core {
3536

36-
class Object;
37-
3837
class Event {
3938
public:
4039
enum Type {

Libraries/LibCore/EventLoop.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@
2424
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2525
*/
2626

27+
#include <AK/Badge.h>
2728
#include <AK/IDAllocator.h>
2829
#include <AK/JsonObject.h>
2930
#include <AK/JsonValue.h>
3031
#include <AK/Time.h>
3132
#include <LibCore/Event.h>
3233
#include <LibCore/EventLoop.h>
34+
#include <LibCore/LocalServer.h>
3335
#include <LibCore/LocalSocket.h>
3436
#include <LibCore/Notifier.h>
3537
#include <LibCore/Object.h>
@@ -328,7 +330,7 @@ void EventLoop::post_event(Object& receiver, NonnullOwnPtr<Event>&& event)
328330
#ifdef CEVENTLOOP_DEBUG
329331
dbg() << "Core::EventLoop::post_event: {" << m_queued_events.size() << "} << receiver=" << receiver << ", event=" << event;
330332
#endif
331-
m_queued_events.append({ receiver.make_weak_ptr(), move(event) });
333+
m_queued_events.empend(receiver, move(event));
332334
}
333335

334336
void EventLoop::wait_for_event(WaitMode mode)
@@ -509,4 +511,20 @@ void EventLoop::wake()
509511
}
510512
}
511513

514+
EventLoop::QueuedEvent::QueuedEvent(Object& receiver, NonnullOwnPtr<Event> event)
515+
: receiver(receiver.make_weak_ptr())
516+
, event(move(event))
517+
{
518+
}
519+
520+
EventLoop::QueuedEvent::QueuedEvent(QueuedEvent&& other)
521+
: receiver(other.receiver)
522+
, event(move(other.event))
523+
{
524+
}
525+
526+
EventLoop::QueuedEvent::~QueuedEvent()
527+
{
528+
}
529+
512530
}

0 commit comments

Comments
 (0)