// WARNING: Please don't edit this file. It was generated by Python/WinRT v3.2.1

#pragma once

#include "pybase.h"
static_assert(winrt::check_version(PYWINRT_VERSION, "3.2.1"), "Mismatched Py/WinRT headers.");
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.System.Threading.h>

#include <winrt/Windows.System.Threading.Core.h>

namespace py::proj::Windows::System::Threading::Core
{
}

namespace py
{

    template<>
    struct py_type<winrt::Windows::System::Threading::Core::PreallocatedWorkItem>
    {
        static constexpr std::string_view qualified_name = "winrt.windows.system.threading.core.PreallocatedWorkItem";
        static constexpr const char* module_name = "winrt.windows.system.threading.core";
        static constexpr const char* type_name = "PreallocatedWorkItem";
    };

    template<>
    struct py_type<winrt::Windows::System::Threading::Core::SignalNotifier>
    {
        static constexpr std::string_view qualified_name = "winrt.windows.system.threading.core.SignalNotifier";
        static constexpr const char* module_name = "winrt.windows.system.threading.core";
        static constexpr const char* type_name = "SignalNotifier";
    };
}

#if __has_include("py.Windows.Foundation.h")
#include "py.Windows.Foundation.h"
#endif

#if __has_include("py.Windows.System.Threading.h")
#include "py.Windows.System.Threading.h"
#endif

namespace py::impl::Windows::System::Threading::Core
{
    struct SignalHandler
    {
        static winrt::Windows::System::Threading::Core::SignalHandler get(PyObject* callable)
        {
            py::delegate_callable _delegate{ callable };

            return [delegate = std::move(_delegate)](winrt::Windows::System::Threading::Core::SignalNotifier const& param0, bool param1)
            {
                auto gil = py::ensure_gil();

                try
                {
                    py::pyobj_handle py_param0{py::convert(param0)};
                    if (!py_param0)
                    {
                        throw python_exception();
                    }

                    py::pyobj_handle py_param1{py::convert(param1)};
                    if (!py_param1)
                    {
                        throw python_exception();
                    }

                    py::pyobj_handle args{PyTuple_Pack(2, py_param0.get(), py_param1.get())};
                    if (!args)
                    {
                        throw python_exception();
                    }

                    py::pyobj_handle return_value{PyObject_CallObject(delegate.callable(), args.get())};
                    if (!return_value)
                    {
                        throw python_exception();
                    }
                }
                catch (python_exception)
                {
                    py::write_unraisable_and_throw();
                }
            };
        };
    };
}

namespace py::wrapper::Windows::System::Threading::Core
{
    using PreallocatedWorkItem = py::winrt_wrapper<winrt::Windows::System::Threading::Core::PreallocatedWorkItem>;
    using SignalNotifier = py::winrt_wrapper<winrt::Windows::System::Threading::Core::SignalNotifier>;
}

namespace py
{
    template <>
    struct delegate_python_type<winrt::Windows::System::Threading::Core::SignalHandler>
    {
        using type = py::impl::Windows::System::Threading::Core::SignalHandler;
    };

}
