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

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


namespace py::cpp::Windows::Devices::Pwm::Provider
{
    // ----- IPwmControllerProvider interface --------------------

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

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

    static PyObject* IPwmControllerProvider_AcquirePin(py::wrapper::Windows::Devices::Pwm::Provider::IPwmControllerProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 1)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Pwm.Provider.IPwmControllerProvider", L"AcquirePin", 1))
            {
                py::set_arg_count_version_error(1);
                return nullptr;
            }

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

                self->obj.AcquirePin(param0);
                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* IPwmControllerProvider_DisablePin(py::wrapper::Windows::Devices::Pwm::Provider::IPwmControllerProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 1)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Pwm.Provider.IPwmControllerProvider", L"DisablePin", 1))
            {
                py::set_arg_count_version_error(1);
                return nullptr;
            }

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

                self->obj.DisablePin(param0);
                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* IPwmControllerProvider_EnablePin(py::wrapper::Windows::Devices::Pwm::Provider::IPwmControllerProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 1)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Pwm.Provider.IPwmControllerProvider", L"EnablePin", 1))
            {
                py::set_arg_count_version_error(1);
                return nullptr;
            }

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

                self->obj.EnablePin(param0);
                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* IPwmControllerProvider_ReleasePin(py::wrapper::Windows::Devices::Pwm::Provider::IPwmControllerProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 1)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Pwm.Provider.IPwmControllerProvider", L"ReleasePin", 1))
            {
                py::set_arg_count_version_error(1);
                return nullptr;
            }

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

                self->obj.ReleasePin(param0);
                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* IPwmControllerProvider_SetDesiredFrequency(py::wrapper::Windows::Devices::Pwm::Provider::IPwmControllerProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 1)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Pwm.Provider.IPwmControllerProvider", L"SetDesiredFrequency", 1))
            {
                py::set_arg_count_version_error(1);
                return nullptr;
            }

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

                return py::convert(self->obj.SetDesiredFrequency(param0));
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* IPwmControllerProvider_SetPulseParameters(py::wrapper::Windows::Devices::Pwm::Provider::IPwmControllerProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 3)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Pwm.Provider.IPwmControllerProvider", L"SetPulseParameters", 3))
            {
                py::set_arg_count_version_error(3);
                return nullptr;
            }

            try
            {
                auto param0 = py::convert_to<int32_t>(args, 0);
                auto param1 = py::convert_to<double>(args, 1);
                auto param2 = py::convert_to<bool>(args, 2);

                self->obj.SetPulseParameters(param0, param1, param2);
                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* IPwmControllerProvider_get_ActualFrequency(py::wrapper::Windows::Devices::Pwm::Provider::IPwmControllerProvider* self, void* /*unused*/) noexcept
    {
        if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Pwm.Provider.IPwmControllerProvider", L"ActualFrequency"))
        {
            PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
            return nullptr;
        }

        try
        {
            return py::convert(self->obj.ActualFrequency());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* IPwmControllerProvider_get_MaxFrequency(py::wrapper::Windows::Devices::Pwm::Provider::IPwmControllerProvider* self, void* /*unused*/) noexcept
    {
        if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Pwm.Provider.IPwmControllerProvider", L"MaxFrequency"))
        {
            PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
            return nullptr;
        }

        try
        {
            return py::convert(self->obj.MaxFrequency());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* IPwmControllerProvider_get_MinFrequency(py::wrapper::Windows::Devices::Pwm::Provider::IPwmControllerProvider* self, void* /*unused*/) noexcept
    {
        if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Pwm.Provider.IPwmControllerProvider", L"MinFrequency"))
        {
            PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
            return nullptr;
        }

        try
        {
            return py::convert(self->obj.MinFrequency());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* IPwmControllerProvider_get_PinCount(py::wrapper::Windows::Devices::Pwm::Provider::IPwmControllerProvider* self, void* /*unused*/) noexcept
    {
        if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Pwm.Provider.IPwmControllerProvider", L"PinCount"))
        {
            PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
            return nullptr;
        }

        try
        {
            return py::convert(self->obj.PinCount());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

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

    static PyObject* _from_IPwmControllerProvider(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::Provider::IPwmControllerProvider>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_IPwmControllerProvider[] = {
        { "acquire_pin", reinterpret_cast<PyCFunction>(IPwmControllerProvider_AcquirePin), METH_VARARGS, nullptr },
        { "disable_pin", reinterpret_cast<PyCFunction>(IPwmControllerProvider_DisablePin), METH_VARARGS, nullptr },
        { "enable_pin", reinterpret_cast<PyCFunction>(IPwmControllerProvider_EnablePin), METH_VARARGS, nullptr },
        { "release_pin", reinterpret_cast<PyCFunction>(IPwmControllerProvider_ReleasePin), METH_VARARGS, nullptr },
        { "set_desired_frequency", reinterpret_cast<PyCFunction>(IPwmControllerProvider_SetDesiredFrequency), METH_VARARGS, nullptr },
        { "set_pulse_parameters", reinterpret_cast<PyCFunction>(IPwmControllerProvider_SetPulseParameters), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_IPwmControllerProvider, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_IPwmControllerProvider), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_IPwmControllerProvider[] = {
        { "actual_frequency", reinterpret_cast<getter>(IPwmControllerProvider_get_ActualFrequency), nullptr, nullptr, nullptr },
        { "max_frequency", reinterpret_cast<getter>(IPwmControllerProvider_get_MaxFrequency), nullptr, nullptr, nullptr },
        { "min_frequency", reinterpret_cast<getter>(IPwmControllerProvider_get_MinFrequency), nullptr, nullptr, nullptr },
        { "pin_count", reinterpret_cast<getter>(IPwmControllerProvider_get_PinCount), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_IPwmControllerProvider[] = 
    {
        { Py_tp_new, reinterpret_cast<void*>(_new_IPwmControllerProvider) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_IPwmControllerProvider) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_IPwmControllerProvider) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_IPwmControllerProvider) },
        { },
    };

    static PyType_Spec type_spec_IPwmControllerProvider =
    {
        "winrt._winrt_windows_devices_pwm_provider.IPwmControllerProvider",
        sizeof(py::wrapper::Windows::Devices::Pwm::Provider::IPwmControllerProvider),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_IPwmControllerProvider
    };

    // ----- IPwmProvider interface --------------------

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

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

    static PyObject* IPwmProvider_GetControllers(py::wrapper::Windows::Devices::Pwm::Provider::IPwmProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 0)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Pwm.Provider.IPwmProvider", L"GetControllers", 0))
            {
                py::set_arg_count_version_error(0);
                return nullptr;
            }

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

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

    static PyObject* _from_IPwmProvider(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::Provider::IPwmProvider>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_IPwmProvider[] = {
        { "get_controllers", reinterpret_cast<PyCFunction>(IPwmProvider_GetControllers), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_IPwmProvider, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_IPwmProvider), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_IPwmProvider[] = {
        { }
    };

    static PyType_Slot _type_slots_IPwmProvider[] = 
    {
        { Py_tp_new, reinterpret_cast<void*>(_new_IPwmProvider) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_IPwmProvider) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_IPwmProvider) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_IPwmProvider) },
        { },
    };

    static PyType_Spec type_spec_IPwmProvider =
    {
        "winrt._winrt_windows_devices_pwm_provider.IPwmProvider",
        sizeof(py::wrapper::Windows::Devices::Pwm::Provider::IPwmProvider),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_IPwmProvider
    };

    // ----- Windows.Devices.Pwm.Provider Initialization --------------------
    PyDoc_STRVAR(module_doc, "Windows::Devices::Pwm::Provider");


    static PyModuleDef module_def
        = {PyModuleDef_HEAD_INIT,
           "_winrt_windows_devices_pwm_provider",
           module_doc,
           0,
           nullptr,
           nullptr,
           nullptr,
           nullptr,
           nullptr};

} // py::cpp::Windows::Devices::Pwm::Provider

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

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

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

    if (!module)
    {
        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;
    }

    if (py::register_python_type(module.get(), &type_spec_IPwmControllerProvider, object_bases.get(), nullptr) == -1)
    {
        return nullptr;
    }

    if (py::register_python_type(module.get(), &type_spec_IPwmProvider, object_bases.get(), nullptr) == -1)
    {
        return nullptr;
    }


    return module.detach();
}
