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

#include "py.Windows.Devices.Pwm.h"

namespace py::cpp::Windows::Devices::Pwm
{
    // ----- PwmController class --------------------

    static PyObject* _new_PwmController(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Devices::Pwm::PwmController>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Devices::Pwm::PwmController>::type_name);
        return nullptr;
    }

    static void _dealloc_PwmController(py::wrapper::Windows::Devices::Pwm::PwmController* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* PwmController_FromIdAsync(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Pwm.PwmController", L"FromIdAsync", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::hstring>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Devices::Pwm::PwmController::FromIdAsync(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* PwmController_GetControllersAsync(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Pwm.PwmController", L"GetControllersAsync", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Devices::Pwm::Provider::IPwmProvider>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Devices::Pwm::PwmController::GetControllersAsync(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* PwmController_GetDefaultAsync(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Pwm.PwmController", L"GetDefaultAsync", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Devices::Pwm::PwmController::GetDefaultAsync();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* PwmController_GetDeviceSelector(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Pwm.PwmController", L"GetDeviceSelector", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Devices::Pwm::PwmController::GetDeviceSelector();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* PwmController_GetDeviceSelectorFromFriendlyName(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Pwm.PwmController", L"GetDeviceSelector", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::hstring>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Devices::Pwm::PwmController::GetDeviceSelector(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* PwmController_OpenPin(py::wrapper::Windows::Devices::Pwm::PwmController* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Pwm.PwmController", L"OpenPin", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<int32_t>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.OpenPin(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* PwmController_SetDesiredFrequency(py::wrapper::Windows::Devices::Pwm::PwmController* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Pwm.PwmController", L"SetDesiredFrequency", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<double>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.SetDesiredFrequency(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* PwmController_get_ActualFrequency(py::wrapper::Windows::Devices::Pwm::PwmController* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Pwm.PwmController", L"ActualFrequency");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.ActualFrequency();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PwmController_get_MaxFrequency(py::wrapper::Windows::Devices::Pwm::PwmController* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Pwm.PwmController", L"MaxFrequency");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.MaxFrequency();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PwmController_get_MinFrequency(py::wrapper::Windows::Devices::Pwm::PwmController* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Pwm.PwmController", L"MinFrequency");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.MinFrequency();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PwmController_get_PinCount(py::wrapper::Windows::Devices::Pwm::PwmController* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Pwm.PwmController", L"PinCount");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.PinCount();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_PwmController(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Devices::Pwm::PwmController>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_PwmController(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::Devices::Pwm::PwmController>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_PwmController[] = {
        { "open_pin", reinterpret_cast<PyCFunction>(PwmController_OpenPin), METH_VARARGS, nullptr },
        { "set_desired_frequency", reinterpret_cast<PyCFunction>(PwmController_SetDesiredFrequency), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_PwmController, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_PwmController), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_PwmController[] = {
        { "actual_frequency", reinterpret_cast<getter>(PwmController_get_ActualFrequency), nullptr, nullptr, nullptr },
        { "max_frequency", reinterpret_cast<getter>(PwmController_get_MaxFrequency), nullptr, nullptr, nullptr },
        { "min_frequency", reinterpret_cast<getter>(PwmController_get_MinFrequency), nullptr, nullptr, nullptr },
        { "pin_count", reinterpret_cast<getter>(PwmController_get_PinCount), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_PwmController[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_PwmController) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_PwmController) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_PwmController) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_PwmController) },
        { }};

    static PyType_Spec type_spec_PwmController = {
        "winrt._winrt_windows_devices_pwm.PwmController",
        sizeof(py::wrapper::Windows::Devices::Pwm::PwmController),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_PwmController};

    static PyGetSetDef getset_PwmController_Static[] = {
        { }};

    static PyMethodDef methods_PwmController_Static[] = {
        { "from_id_async", reinterpret_cast<PyCFunction>(PwmController_FromIdAsync), METH_VARARGS, nullptr },
        { "get_controllers_async", reinterpret_cast<PyCFunction>(PwmController_GetControllersAsync), METH_VARARGS, nullptr },
        { "get_default_async", reinterpret_cast<PyCFunction>(PwmController_GetDefaultAsync), METH_VARARGS, nullptr },
        { "get_device_selector", reinterpret_cast<PyCFunction>(PwmController_GetDeviceSelector), METH_VARARGS, nullptr },
        { "get_device_selector_from_friendly_name", reinterpret_cast<PyCFunction>(PwmController_GetDeviceSelectorFromFriendlyName), METH_VARARGS, nullptr },
        { }};

    static PyType_Slot type_slots_PwmController_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_PwmController_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_PwmController_Static) },
        { }
    };

    static PyType_Spec type_spec_PwmController_Static = {
        "winrt._winrt_windows_devices_pwm.PwmController_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_PwmController_Static};

    // ----- PwmPin class --------------------

    static PyObject* _new_PwmPin(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Devices::Pwm::PwmPin>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Devices::Pwm::PwmPin>::type_name);
        return nullptr;
    }

    static void _dealloc_PwmPin(py::wrapper::Windows::Devices::Pwm::PwmPin* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* PwmPin_Close(py::wrapper::Windows::Devices::Pwm::PwmPin* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Pwm.PwmPin", L"Close", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                {
                    auto _gil = release_gil();
                    self->obj.Close();
                }

                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* PwmPin_GetActiveDutyCyclePercentage(py::wrapper::Windows::Devices::Pwm::PwmPin* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Pwm.PwmPin", L"GetActiveDutyCyclePercentage", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.GetActiveDutyCyclePercentage();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* PwmPin_SetActiveDutyCyclePercentage(py::wrapper::Windows::Devices::Pwm::PwmPin* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Pwm.PwmPin", L"SetActiveDutyCyclePercentage", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<double>(args, 0);

                {
                    auto _gil = release_gil();
                    self->obj.SetActiveDutyCyclePercentage(param0);
                }

                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* PwmPin_Start(py::wrapper::Windows::Devices::Pwm::PwmPin* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Pwm.PwmPin", L"Start", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                {
                    auto _gil = release_gil();
                    self->obj.Start();
                }

                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* PwmPin_Stop(py::wrapper::Windows::Devices::Pwm::PwmPin* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Pwm.PwmPin", L"Stop", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                {
                    auto _gil = release_gil();
                    self->obj.Stop();
                }

                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* PwmPin_get_Polarity(py::wrapper::Windows::Devices::Pwm::PwmPin* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Pwm.PwmPin", L"Polarity");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Polarity();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int PwmPin_put_Polarity(py::wrapper::Windows::Devices::Pwm::PwmPin* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!arg)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Pwm.PwmPin", L"Polarity");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::Windows::Devices::Pwm::PwmPulsePolarity>(arg);

            {
                auto _gil = release_gil();
                self->obj.Polarity(param0);
            }

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

    static PyObject* PwmPin_get_Controller(py::wrapper::Windows::Devices::Pwm::PwmPin* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Pwm.PwmPin", L"Controller");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Controller();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PwmPin_get_IsStarted(py::wrapper::Windows::Devices::Pwm::PwmPin* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Pwm.PwmPin", L"IsStarted");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.IsStarted();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_PwmPin(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Devices::Pwm::PwmPin>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_PwmPin(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::Devices::Pwm::PwmPin>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _enter_PwmPin(py::wrapper::Windows::Devices::Pwm::PwmPin* self, PyObject* /*unused*/) noexcept
    {
        return Py_NewRef(self);
    }

    static PyObject* _exit_PwmPin(py::wrapper::Windows::Devices::Pwm::PwmPin* self, PyObject* /*unused*/) noexcept
    {
        try
        {
            {
                auto _gil = py::release_gil();
                self->obj.Close();
            }

            Py_RETURN_FALSE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_PwmPin[] = {
        { "close", reinterpret_cast<PyCFunction>(PwmPin_Close), METH_VARARGS, nullptr },
        { "get_active_duty_cycle_percentage", reinterpret_cast<PyCFunction>(PwmPin_GetActiveDutyCyclePercentage), METH_VARARGS, nullptr },
        { "set_active_duty_cycle_percentage", reinterpret_cast<PyCFunction>(PwmPin_SetActiveDutyCyclePercentage), METH_VARARGS, nullptr },
        { "start", reinterpret_cast<PyCFunction>(PwmPin_Start), METH_VARARGS, nullptr },
        { "stop", reinterpret_cast<PyCFunction>(PwmPin_Stop), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_PwmPin, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_PwmPin), METH_O | METH_STATIC, nullptr },
        { "__enter__", reinterpret_cast<PyCFunction>(_enter_PwmPin), METH_NOARGS, nullptr },
        { "__exit__", reinterpret_cast<PyCFunction>(_exit_PwmPin), METH_VARARGS, nullptr },
        { }};

    static PyGetSetDef _getset_PwmPin[] = {
        { "polarity", reinterpret_cast<getter>(PwmPin_get_Polarity), reinterpret_cast<setter>(PwmPin_put_Polarity), nullptr, nullptr },
        { "controller", reinterpret_cast<getter>(PwmPin_get_Controller), nullptr, nullptr, nullptr },
        { "is_started", reinterpret_cast<getter>(PwmPin_get_IsStarted), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_PwmPin[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_PwmPin) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_PwmPin) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_PwmPin) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_PwmPin) },
        { }};

    static PyType_Spec type_spec_PwmPin = {
        "winrt._winrt_windows_devices_pwm.PwmPin",
        sizeof(py::wrapper::Windows::Devices::Pwm::PwmPin),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_PwmPin};

    // ----- Windows.Devices.Pwm Initialization --------------------

    PyDoc_STRVAR(module_doc, "Windows.Devices.Pwm");

    static PyModuleDef module_def = {
        PyModuleDef_HEAD_INIT,
        "_winrt_windows_devices_pwm",
        module_doc,
        0,
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        nullptr};
} // py::cpp::Windows::Devices::Pwm

PyMODINIT_FUNC PyInit__winrt_windows_devices_pwm(void) noexcept
{
    using namespace py::cpp::Windows::Devices::Pwm;

    if (py::import_winrt_runtime() == -1)
    {
        return nullptr;
    }

    py::pyobj_handle module{PyModule_Create(&module_def)};

    if (!module)
    {
        return nullptr;
    }

    auto inspectable_meta_type = py::get_inspectable_meta_type();
    if (!inspectable_meta_type)
    {
        return nullptr;
    }

    auto object_type = py::get_object_type();
    if (!object_type)
    {
        return nullptr;
    }

    py::pyobj_handle object_bases{PyTuple_Pack(1, object_type)};

    if (!object_bases)
    {
        return nullptr;
    }

    py::pyobj_handle PwmController_Static_bases{PyTuple_Pack(1, reinterpret_cast<PyObject*>(inspectable_meta_type))};
    if (!PwmController_Static_bases)
    {
        return nullptr;
    }

    py::pyobj_handle type_PwmController_Static{PyType_FromSpecWithBases(&type_spec_PwmController_Static, PwmController_Static_bases.get())};
    if (!type_PwmController_Static)
    {
        return nullptr;
    }

    py::pytype_handle PwmController_type{py::register_python_type(module.get(), &type_spec_PwmController, object_bases.get(), reinterpret_cast<PyTypeObject*>(type_PwmController_Static.get()))};
    if (!PwmController_type)
    {
        return nullptr;
    }

    py::pytype_handle PwmPin_type{py::register_python_type(module.get(), &type_spec_PwmPin, object_bases.get(), inspectable_meta_type)};
    if (!PwmPin_type)
    {
        return nullptr;
    }


    return module.detach();
}
