#include <Core/HAL/Display/DisplayDevice.h>
#include <Core/HAL/Display/Win32/Win32DisplayEvent.h>
#include <Core/HAL/Display/Win32/Win32Window.h>
#include <Core/Memory/Allocator.h>
#include <Core/Memory/EngineArena.h>
#include <Core/Memory/Utils.h>

namespace Juliet::Win32
{
    namespace
    {
        bool Initialize(NonNullPtr<DisplayDevice> /*self*/)
        {
            return true;
        }
        void Shutdown(NonNullPtr<DisplayDevice> /*self*/) {}
        void Free(NonNullPtr<DisplayDevice> /*self*/) {}

        DisplayDevice* CreateDevice()
        {
            auto device = ArenaPushType<DisplayDevice>(GetEngineArena(), ConstString("DisplayDevice"));

            if (!device)
            {
                return nullptr;
            }

            device->Initialize = Initialize;
            device->Shutdown   = Shutdown;
            device->Free       = Free;

            device->CreatePlatformWindow  = CreatePlatformWindow;
            device->DestroyPlatformWindow = DestroyPlatformWindow;
            device->ShowWindow            = ShowWindow;
            device->HideWindow            = HideWindow;

            device->PumpEvents = PumpEvents;

            return device;
        }
    } // namespace

} // namespace Juliet::Win32

// Factory cannot be in an anonymous/unknown namespace
namespace Juliet
{
    DisplayDeviceFactory Win32DisplayDeviceFactory = { .Name = "Win32", .CreateDevice = Win32::CreateDevice };
}
