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

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

namespace py::cpp::Windows::Devices::Adc
{
    // ----- AdcChannel class --------------------

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

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

    static PyObject* AdcChannel_Close(py::wrapper::Windows::Devices::Adc::AdcChannel* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_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.Adc.AdcChannel", L"Close", 0);
                }

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

                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* AdcChannel_ReadRatio(py::wrapper::Windows::Devices::Adc::AdcChannel* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_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.Adc.AdcChannel", L"ReadRatio", 0);
                }

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

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

    static PyObject* AdcChannel_ReadValue(py::wrapper::Windows::Devices::Adc::AdcChannel* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_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.Adc.AdcChannel", L"ReadValue", 0);
                }

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

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

    static PyObject* AdcChannel_get_Controller(py::wrapper::Windows::Devices::Adc::AdcChannel* 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.Adc.AdcChannel", 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(self->obj.Controller());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

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

    static PyObject* _from_AdcChannel(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::Adc::AdcChannel>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _enter_AdcChannel(py::wrapper::Windows::Devices::Adc::AdcChannel* self, PyObject* /*unused*/) noexcept
    {
        return Py_NewRef(self);
    }

    static PyObject* _exit_AdcChannel(py::wrapper::Windows::Devices::Adc::AdcChannel* self, PyObject* /*unused*/) noexcept
    {
        try
        {
            self->obj.Close();
            Py_RETURN_FALSE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_AdcChannel[] = {
        { "close", reinterpret_cast<PyCFunction>(AdcChannel_Close), METH_VARARGS, nullptr },
        { "read_ratio", reinterpret_cast<PyCFunction>(AdcChannel_ReadRatio), METH_VARARGS, nullptr },
        { "read_value", reinterpret_cast<PyCFunction>(AdcChannel_ReadValue), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_AdcChannel, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_AdcChannel), METH_O | METH_STATIC, nullptr },
        { "__enter__", reinterpret_cast<PyCFunction>(_enter_AdcChannel), METH_NOARGS, nullptr },
        { "__exit__", reinterpret_cast<PyCFunction>(_exit_AdcChannel), METH_VARARGS, nullptr },
        { }
    };

    static PyGetSetDef _getset_AdcChannel[] = {
        { "controller", reinterpret_cast<getter>(AdcChannel_get_Controller), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_AdcChannel[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_AdcChannel) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_AdcChannel) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_AdcChannel) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_AdcChannel) },
        { }
    };

    static PyType_Spec type_spec_AdcChannel = {
        "winrt._winrt_windows_devices_adc.AdcChannel",
        sizeof(py::wrapper::Windows::Devices::Adc::AdcChannel),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_AdcChannel};

    // ----- AdcController class --------------------

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

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

    static PyObject* AdcController_GetControllersAsync(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_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.Adc.AdcController", 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::Adc::Provider::IAdcProvider>(args, 0);

                return py::convert(winrt::Windows::Devices::Adc::AdcController::GetControllersAsync(param0));
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* AdcController_GetDefaultAsync(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_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.Adc.AdcController", L"GetDefaultAsync", 0);
                }

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

                return py::convert(winrt::Windows::Devices::Adc::AdcController::GetDefaultAsync());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* AdcController_IsChannelModeSupported(py::wrapper::Windows::Devices::Adc::AdcController* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_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.Adc.AdcController", L"IsChannelModeSupported", 1);
                }

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

                auto param0 = py::convert_to<winrt::Windows::Devices::Adc::AdcChannelMode>(args, 0);

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

    static PyObject* AdcController_OpenChannel(py::wrapper::Windows::Devices::Adc::AdcController* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_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.Adc.AdcController", L"OpenChannel", 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(self->obj.OpenChannel(param0));
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* AdcController_get_ChannelMode(py::wrapper::Windows::Devices::Adc::AdcController* 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.Adc.AdcController", L"ChannelMode");
            }

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

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

    static int AdcController_put_ChannelMode(py::wrapper::Windows::Devices::Adc::AdcController* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (arg == nullptr)
        {
            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.Adc.AdcController", L"ChannelMode");
            }

            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::Adc::AdcChannelMode>(arg);

            self->obj.ChannelMode(param0);
            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* AdcController_get_ChannelCount(py::wrapper::Windows::Devices::Adc::AdcController* 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.Adc.AdcController", L"ChannelCount");
            }

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

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

    static PyObject* AdcController_get_MaxValue(py::wrapper::Windows::Devices::Adc::AdcController* 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.Adc.AdcController", L"MaxValue");
            }

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

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

    static PyObject* AdcController_get_MinValue(py::wrapper::Windows::Devices::Adc::AdcController* 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.Adc.AdcController", L"MinValue");
            }

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

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

    static PyObject* AdcController_get_ResolutionInBits(py::wrapper::Windows::Devices::Adc::AdcController* 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.Adc.AdcController", L"ResolutionInBits");
            }

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

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

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

    static PyObject* _from_AdcController(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::Adc::AdcController>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_AdcController[] = {
        { "is_channel_mode_supported", reinterpret_cast<PyCFunction>(AdcController_IsChannelModeSupported), METH_VARARGS, nullptr },
        { "open_channel", reinterpret_cast<PyCFunction>(AdcController_OpenChannel), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_AdcController, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_AdcController), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_AdcController[] = {
        { "channel_mode", reinterpret_cast<getter>(AdcController_get_ChannelMode), reinterpret_cast<setter>(AdcController_put_ChannelMode), nullptr, nullptr },
        { "channel_count", reinterpret_cast<getter>(AdcController_get_ChannelCount), nullptr, nullptr, nullptr },
        { "max_value", reinterpret_cast<getter>(AdcController_get_MaxValue), nullptr, nullptr, nullptr },
        { "min_value", reinterpret_cast<getter>(AdcController_get_MinValue), nullptr, nullptr, nullptr },
        { "resolution_in_bits", reinterpret_cast<getter>(AdcController_get_ResolutionInBits), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_AdcController[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_AdcController) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_AdcController) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_AdcController) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_AdcController) },
        { }
    };

    static PyType_Spec type_spec_AdcController = {
        "winrt._winrt_windows_devices_adc.AdcController",
        sizeof(py::wrapper::Windows::Devices::Adc::AdcController),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_AdcController};

    static PyGetSetDef getset_AdcController_Static[] = {
        { }
    };

    static PyMethodDef methods_AdcController_Static[] = {
        { "get_controllers_async", reinterpret_cast<PyCFunction>(AdcController_GetControllersAsync), METH_VARARGS, nullptr },
        { "get_default_async", reinterpret_cast<PyCFunction>(AdcController_GetDefaultAsync), METH_VARARGS, nullptr },
        { }
    };

    static PyType_Slot type_slots_AdcController_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_AdcController_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_AdcController_Static) },
        { }
    };

    static PyType_Spec type_spec_AdcController_Static =
    {
        "winrt._winrt_windows_devices_adc.AdcController_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_AdcController_Static
    };

    // ----- Windows.Devices.Adc Initialization --------------------

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

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

PyMODINIT_FUNC PyInit__winrt_windows_devices_adc(void) noexcept
{
    using namespace py::cpp::Windows::Devices::Adc;

    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;
    }

    py::pytype_handle AdcChannel_type{py::register_python_type(module.get(), &type_spec_AdcChannel, object_bases.get(), nullptr)};
    if (!AdcChannel_type)
    {
        return nullptr;
    }

    py::pyobj_handle type_AdcController_Static{PyType_FromSpec(&type_spec_AdcController_Static)};
    if (!type_AdcController_Static)
    {
        return nullptr;
    }

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


    return module.detach();
}
