// WARNING: Please don't edit this file. It was generated by Python/WinRT v1.0.0-beta.2

#include "pybase.h"
#include "py.Windows.System.Threading.Core.h"

PyTypeObject* py::winrt_type<winrt::Windows::System::Threading::Core::PreallocatedWorkItem>::python_type;
PyTypeObject* py::winrt_type<winrt::Windows::System::Threading::Core::SignalNotifier>::python_type;

namespace py::cpp::Windows::System::Threading::Core
{
    // ----- PreallocatedWorkItem class --------------------
    constexpr const char* const _type_name_PreallocatedWorkItem = "PreallocatedWorkItem";

    static PyObject* _new_PreallocatedWorkItem(PyTypeObject* type, PyObject* args, PyObject* kwds) noexcept
    {
        if (kwds != nullptr)
        {
            py::set_invalid_kwd_args_error();
            return nullptr;
        }

        Py_ssize_t arg_count = PyTuple_Size(args);
        if (arg_count == 1)
        {
            try
            {
                auto param0 = py::convert_to<winrt::Windows::System::Threading::WorkItemHandler>(args, 0);

                winrt::Windows::System::Threading::Core::PreallocatedWorkItem instance{ param0 };
                return py::wrap(instance, type);
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else if (arg_count == 2)
        {
            try
            {
                auto param0 = py::convert_to<winrt::Windows::System::Threading::WorkItemHandler>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::System::Threading::WorkItemPriority>(args, 1);

                winrt::Windows::System::Threading::Core::PreallocatedWorkItem instance{ param0, param1 };
                return py::wrap(instance, type);
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else if (arg_count == 3)
        {
            try
            {
                auto param0 = py::convert_to<winrt::Windows::System::Threading::WorkItemHandler>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::System::Threading::WorkItemPriority>(args, 1);
                auto param2 = py::convert_to<winrt::Windows::System::Threading::WorkItemOptions>(args, 2);

                winrt::Windows::System::Threading::Core::PreallocatedWorkItem instance{ param0, param1, param2 };
                return py::wrap(instance, type);
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static void _dealloc_PreallocatedWorkItem(py::wrapper::Windows::System::Threading::Core::PreallocatedWorkItem* self)
    {
        auto hash_value = std::hash<winrt::Windows::Foundation::IInspectable>{}(self->obj);
        py::wrapped_instance(hash_value, nullptr);
        self->obj = nullptr;
    }

    static PyObject* PreallocatedWorkItem_RunAsync(py::wrapper::Windows::System::Threading::Core::PreallocatedWorkItem* self, PyObject* args) noexcept
    {
        Py_ssize_t arg_count = PyTuple_Size(args);

        if (arg_count == 0)
        {
            try
            {
                return py::convert(self->obj.RunAsync());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* _from_PreallocatedWorkItem(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::System::Threading::Core::PreallocatedWorkItem>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_PreallocatedWorkItem[] = {
        { "run_async", reinterpret_cast<PyCFunction>(PreallocatedWorkItem_RunAsync), METH_VARARGS, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_PreallocatedWorkItem), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_PreallocatedWorkItem[] = {
        { }
    };

    static PyType_Slot _type_slots_PreallocatedWorkItem[] = 
    {
        { Py_tp_new, _new_PreallocatedWorkItem },
        { Py_tp_dealloc, _dealloc_PreallocatedWorkItem },
        { Py_tp_methods, _methods_PreallocatedWorkItem },
        { Py_tp_getset, _getset_PreallocatedWorkItem },
        { },
    };

    static PyType_Spec _type_spec_PreallocatedWorkItem =
    {
        "_winsdk_Windows_System_Threading_Core.PreallocatedWorkItem",
        sizeof(py::wrapper::Windows::System::Threading::Core::PreallocatedWorkItem),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_PreallocatedWorkItem
    };

    // ----- SignalNotifier class --------------------
    constexpr const char* const _type_name_SignalNotifier = "SignalNotifier";

    static PyObject* _new_SignalNotifier(PyTypeObject* type, PyObject* args, PyObject* kwds) noexcept
    {
        py::set_invalid_activation_error(_type_name_SignalNotifier);
        return nullptr;
    }

    static void _dealloc_SignalNotifier(py::wrapper::Windows::System::Threading::Core::SignalNotifier* self)
    {
        auto hash_value = std::hash<winrt::Windows::Foundation::IInspectable>{}(self->obj);
        py::wrapped_instance(hash_value, nullptr);
        self->obj = nullptr;
    }

    static PyObject* SignalNotifier_AttachToEvent(PyObject* /*unused*/, PyObject* args) noexcept
    {
        Py_ssize_t arg_count = PyTuple_Size(args);

        if (arg_count == 2)
        {
            try
            {
                auto param0 = py::convert_to<winrt::hstring>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::System::Threading::Core::SignalHandler>(args, 1);

                return py::convert(winrt::Windows::System::Threading::Core::SignalNotifier::AttachToEvent(param0, param1));
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else if (arg_count == 3)
        {
            try
            {
                auto param0 = py::convert_to<winrt::hstring>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::System::Threading::Core::SignalHandler>(args, 1);
                auto param2 = py::convert_to<winrt::Windows::Foundation::TimeSpan>(args, 2);

                return py::convert(winrt::Windows::System::Threading::Core::SignalNotifier::AttachToEvent(param0, param1, param2));
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* SignalNotifier_AttachToSemaphore(PyObject* /*unused*/, PyObject* args) noexcept
    {
        Py_ssize_t arg_count = PyTuple_Size(args);

        if (arg_count == 2)
        {
            try
            {
                auto param0 = py::convert_to<winrt::hstring>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::System::Threading::Core::SignalHandler>(args, 1);

                return py::convert(winrt::Windows::System::Threading::Core::SignalNotifier::AttachToSemaphore(param0, param1));
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else if (arg_count == 3)
        {
            try
            {
                auto param0 = py::convert_to<winrt::hstring>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::System::Threading::Core::SignalHandler>(args, 1);
                auto param2 = py::convert_to<winrt::Windows::Foundation::TimeSpan>(args, 2);

                return py::convert(winrt::Windows::System::Threading::Core::SignalNotifier::AttachToSemaphore(param0, param1, param2));
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* SignalNotifier_Enable(py::wrapper::Windows::System::Threading::Core::SignalNotifier* self, PyObject* args) noexcept
    {
        Py_ssize_t arg_count = PyTuple_Size(args);

        if (arg_count == 0)
        {
            try
            {
                self->obj.Enable();
                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* SignalNotifier_Terminate(py::wrapper::Windows::System::Threading::Core::SignalNotifier* self, PyObject* args) noexcept
    {
        Py_ssize_t arg_count = PyTuple_Size(args);

        if (arg_count == 0)
        {
            try
            {
                self->obj.Terminate();
                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* _from_SignalNotifier(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::System::Threading::Core::SignalNotifier>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_SignalNotifier[] = {
        { "attach_to_event", reinterpret_cast<PyCFunction>(SignalNotifier_AttachToEvent), METH_VARARGS | METH_STATIC, nullptr },
        { "attach_to_semaphore", reinterpret_cast<PyCFunction>(SignalNotifier_AttachToSemaphore), METH_VARARGS | METH_STATIC, nullptr },
        { "enable", reinterpret_cast<PyCFunction>(SignalNotifier_Enable), METH_VARARGS, nullptr },
        { "terminate", reinterpret_cast<PyCFunction>(SignalNotifier_Terminate), METH_VARARGS, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_SignalNotifier), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_SignalNotifier[] = {
        { }
    };

    static PyType_Slot _type_slots_SignalNotifier[] = 
    {
        { Py_tp_new, _new_SignalNotifier },
        { Py_tp_dealloc, _dealloc_SignalNotifier },
        { Py_tp_methods, _methods_SignalNotifier },
        { Py_tp_getset, _getset_SignalNotifier },
        { },
    };

    static PyType_Spec _type_spec_SignalNotifier =
    {
        "_winsdk_Windows_System_Threading_Core.SignalNotifier",
        sizeof(py::wrapper::Windows::System::Threading::Core::SignalNotifier),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_SignalNotifier
    };

    // ----- Windows.System.Threading.Core Initialization --------------------
    static int module_exec(PyObject* module) noexcept
    {
        try
        {
            py::pyobj_handle bases { PyTuple_Pack(1, py::winrt_type<py::Object>::python_type) };

            py::winrt_type<winrt::Windows::System::Threading::Core::PreallocatedWorkItem>::python_type = py::register_python_type(module, _type_name_PreallocatedWorkItem, &_type_spec_PreallocatedWorkItem, bases.get());
            py::winrt_type<winrt::Windows::System::Threading::Core::SignalNotifier>::python_type = py::register_python_type(module, _type_name_SignalNotifier, &_type_spec_SignalNotifier, bases.get());

            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyModuleDef_Slot module_slots[] = {{Py_mod_exec, module_exec}, {}};

    PyDoc_STRVAR(module_doc, "Windows.System.Threading.Core");

    static PyModuleDef module_def
        = {PyModuleDef_HEAD_INIT,
           "_winsdk_Windows_System_Threading_Core",
           module_doc,
           0,
           nullptr,
           module_slots,
           nullptr,
           nullptr,
           nullptr};
} // py::cpp::Windows::System::Threading::Core

PyMODINIT_FUNC
PyInit__winsdk_Windows_System_Threading_Core (void) noexcept
{
    return PyModuleDef_Init(&py::cpp::Windows::System::Threading::Core::module_def);
}
