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

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


namespace py::cpp::Windows::Devices::Adc::Provider
{
    struct module_state
    {
        PyObject* type_ProviderAdcChannelMode;
        PyTypeObject* type_IAdcControllerProvider;
        PyTypeObject* type_IAdcProvider;
    };

    static PyObject* register_ProviderAdcChannelMode(PyObject* module, PyObject* type) noexcept
    {
        auto state = reinterpret_cast<module_state*>(PyModule_GetState(module));
        assert(state);

        if (state->type_ProviderAdcChannelMode)
        {
            PyErr_SetString(PyExc_RuntimeError, "type has already been registered");
            return nullptr;
        }

        if (!PyType_Check(type))
        {
            PyErr_SetString(PyExc_TypeError, "argument is not a type");
            return nullptr;
        }

        state->type_ProviderAdcChannelMode = type;
        Py_INCREF(state->type_ProviderAdcChannelMode);


        Py_RETURN_NONE;
    }

    // ----- IAdcControllerProvider interface --------------------
    static constexpr const char* const type_name_IAdcControllerProvider = "IAdcControllerProvider";

    static PyObject* _new_IAdcControllerProvider(PyTypeObject* /* unused */, PyObject* /* unused */, PyObject* /* unused */) noexcept
    {
        py::set_invalid_activation_error(type_name_IAdcControllerProvider);
        return nullptr;
    }

    static void _dealloc_IAdcControllerProvider(py::wrapper::Windows::Devices::Adc::Provider::IAdcControllerProvider* self) noexcept
    {
        auto tp = Py_TYPE(self);

        if (PyType_IS_GC(tp))
        {
            PyObject_GC_UnTrack(self);
        }

        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* IAdcControllerProvider_AcquireChannel(py::wrapper::Windows::Devices::Adc::Provider::IAdcControllerProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

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

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

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

    static PyObject* IAdcControllerProvider_IsChannelModeSupported(py::wrapper::Windows::Devices::Adc::Provider::IAdcControllerProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

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

            try
            {
                auto param0 = py::convert_to<winrt::Windows::Devices::Adc::Provider::ProviderAdcChannelMode>(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* IAdcControllerProvider_ReadValue(py::wrapper::Windows::Devices::Adc::Provider::IAdcControllerProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

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

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

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

    static PyObject* IAdcControllerProvider_ReleaseChannel(py::wrapper::Windows::Devices::Adc::Provider::IAdcControllerProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

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

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

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

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

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

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

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

    static int IAdcControllerProvider_put_ChannelMode(py::wrapper::Windows::Devices::Adc::Provider::IAdcControllerProvider* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Adc.Provider.IAdcControllerProvider", L"ChannelMode"))
        {
            PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
            return -1;
        }

        if (arg == nullptr)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            auto param0 = py::convert_to<winrt::Windows::Devices::Adc::Provider::ProviderAdcChannelMode>(arg);

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

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

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

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

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

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

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

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

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

    static PyMethodDef _methods_IAdcControllerProvider[] = {
        { "acquire_channel", reinterpret_cast<PyCFunction>(IAdcControllerProvider_AcquireChannel), METH_VARARGS, nullptr },
        { "is_channel_mode_supported", reinterpret_cast<PyCFunction>(IAdcControllerProvider_IsChannelModeSupported), METH_VARARGS, nullptr },
        { "read_value", reinterpret_cast<PyCFunction>(IAdcControllerProvider_ReadValue), METH_VARARGS, nullptr },
        { "release_channel", reinterpret_cast<PyCFunction>(IAdcControllerProvider_ReleaseChannel), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_IAdcControllerProvider, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_IAdcControllerProvider), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_IAdcControllerProvider[] = {
        { "channel_count", reinterpret_cast<getter>(IAdcControllerProvider_get_ChannelCount), nullptr, nullptr, nullptr },
        { "channel_mode", reinterpret_cast<getter>(IAdcControllerProvider_get_ChannelMode), reinterpret_cast<setter>(IAdcControllerProvider_put_ChannelMode), nullptr, nullptr },
        { "max_value", reinterpret_cast<getter>(IAdcControllerProvider_get_MaxValue), nullptr, nullptr, nullptr },
        { "min_value", reinterpret_cast<getter>(IAdcControllerProvider_get_MinValue), nullptr, nullptr, nullptr },
        { "resolution_in_bits", reinterpret_cast<getter>(IAdcControllerProvider_get_ResolutionInBits), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_IAdcControllerProvider[] = 
    {
        { Py_tp_new, reinterpret_cast<void*>(_new_IAdcControllerProvider) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_IAdcControllerProvider) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_IAdcControllerProvider) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_IAdcControllerProvider) },
        { },
    };

    static PyType_Spec type_spec_IAdcControllerProvider =
    {
        "_winsdk_Windows_Devices_Adc_Provider.IAdcControllerProvider",
        sizeof(py::wrapper::Windows::Devices::Adc::Provider::IAdcControllerProvider),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_IAdcControllerProvider
    };

    // ----- IAdcProvider interface --------------------
    static constexpr const char* const type_name_IAdcProvider = "IAdcProvider";

    static PyObject* _new_IAdcProvider(PyTypeObject* /* unused */, PyObject* /* unused */, PyObject* /* unused */) noexcept
    {
        py::set_invalid_activation_error(type_name_IAdcProvider);
        return nullptr;
    }

    static void _dealloc_IAdcProvider(py::wrapper::Windows::Devices::Adc::Provider::IAdcProvider* self) noexcept
    {
        auto tp = Py_TYPE(self);

        if (PyType_IS_GC(tp))
        {
            PyObject_GC_UnTrack(self);
        }

        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* IAdcProvider_GetControllers(py::wrapper::Windows::Devices::Adc::Provider::IAdcProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 0)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Adc.Provider.IAdcProvider", 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_IAdcProvider(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Devices::Adc::Provider::IAdcProvider>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

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

    static PyMethodDef _methods_IAdcProvider[] = {
        { "get_controllers", reinterpret_cast<PyCFunction>(IAdcProvider_GetControllers), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_IAdcProvider, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_IAdcProvider), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_IAdcProvider[] = {
        { }
    };

    static PyType_Slot _type_slots_IAdcProvider[] = 
    {
        { Py_tp_new, reinterpret_cast<void*>(_new_IAdcProvider) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_IAdcProvider) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_IAdcProvider) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_IAdcProvider) },
        { },
    };

    static PyType_Spec type_spec_IAdcProvider =
    {
        "_winsdk_Windows_Devices_Adc_Provider.IAdcProvider",
        sizeof(py::wrapper::Windows::Devices::Adc::Provider::IAdcProvider),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_IAdcProvider
    };

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

    static PyMethodDef module_methods[] = {
        {"_register_ProviderAdcChannelMode", register_ProviderAdcChannelMode, METH_O, "registers type"},
        {}};


    static int module_traverse(PyObject* module, visitproc visit, void* arg) noexcept
    {
        auto state = reinterpret_cast<module_state*>(PyModule_GetState(module));

        if (!state)
        {
            return 0;
        }

        Py_VISIT(state->type_ProviderAdcChannelMode);
        Py_VISIT(state->type_IAdcControllerProvider);
        Py_VISIT(state->type_IAdcProvider);

        return 0;
    }

    static int module_clear(PyObject* module) noexcept
    {
        auto state = reinterpret_cast<module_state*>(PyModule_GetState(module));

        if (!state)
        {
            return 0;
        }

        Py_CLEAR(state->type_ProviderAdcChannelMode);
        Py_CLEAR(state->type_IAdcControllerProvider);
        Py_CLEAR(state->type_IAdcProvider);

        return 0;
    }


    static PyModuleDef module_def
        = {PyModuleDef_HEAD_INIT,
           "_winsdk_Windows_Devices_Adc_Provider",
           module_doc,
           sizeof(module_state),
           module_methods,
           nullptr,
           module_traverse,
           module_clear,
           nullptr};

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

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

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

    if (!module)
    {
        return nullptr;
    }

    auto object_type = py::get_python_type<py::Object>();
    if (!object_type)
    {
        return nullptr;
    }

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

    if (!bases)
    {
        return nullptr;
    }

    py::pyobj_handle collections_abc_module{PyImport_ImportModule("collections.abc")};

    if (!collections_abc_module)
    {
        return nullptr;
    }

    py::pyobj_handle sequence_type{PyObject_GetAttrString(collections_abc_module.get(), "Sequence")};

    if (!sequence_type)
    {
        return nullptr;
    }

    py::pyobj_handle sequence_bases{PyTuple_Pack(2, object_type, sequence_type.get())};

    if (!sequence_bases)
    {
        return nullptr;
    }

    py::pyobj_handle mutable_sequence_type{PyObject_GetAttrString(collections_abc_module.get(), "MutableSequence")};

    if (!mutable_sequence_type)
    {
        return nullptr;
    }

    py::pyobj_handle mutable_sequence_bases{PyTuple_Pack(2, object_type, mutable_sequence_type.get())};

    if (!mutable_sequence_bases)
    {
        return nullptr;
    }

    py::pyobj_handle mapping_type{PyObject_GetAttrString(collections_abc_module.get(), "Mapping")};

    if (!mapping_type)
    {
        return nullptr;
    }

    py::pyobj_handle mapping_bases{PyTuple_Pack(2, object_type, mapping_type.get())};

    if (!mapping_bases)
    {
        return nullptr;
    }

    py::pyobj_handle mutable_mapping_type{PyObject_GetAttrString(collections_abc_module.get(), "MutableMapping")};

    if (!mutable_mapping_type)
    {
        return nullptr;
    }

    py::pyobj_handle mutable_mapping_bases{PyTuple_Pack(2, object_type, mutable_mapping_type.get())};

    if (!mutable_mapping_bases)
    {
        return nullptr;
    }

    auto state = reinterpret_cast<module_state*>(PyModule_GetState(module.get()));
    assert(state);

    state->type_IAdcControllerProvider = py::register_python_type(module.get(), type_name_IAdcControllerProvider, &type_spec_IAdcControllerProvider, bases.get(), nullptr);
    if (!state->type_IAdcControllerProvider)
    {
        return nullptr;
    }

    state->type_IAdcProvider = py::register_python_type(module.get(), type_name_IAdcProvider, &type_spec_IAdcProvider, bases.get(), nullptr);
    if (!state->type_IAdcProvider)
    {
        return nullptr;
    }


    return module.detach();
}

PyObject* py::py_type<winrt::Windows::Devices::Adc::Provider::ProviderAdcChannelMode>::get_python_type() noexcept {
    using namespace py::cpp::Windows::Devices::Adc::Provider;

    PyObject* module = PyState_FindModule(&module_def);

    if (!module) {
        PyErr_SetString(PyExc_RuntimeError, "could not find module for Windows::Devices::Adc::Provider");
        return nullptr;
    }

    auto state = reinterpret_cast<module_state*>(PyModule_GetState(module));
    assert(state);

    auto python_type = state->type_ProviderAdcChannelMode;

    if (!python_type) {
        PyErr_SetString(PyExc_RuntimeError, "type winrt::Windows::Devices::Adc::Provider::ProviderAdcChannelMode is not registered");
        return nullptr;
    }

    return python_type;
}

PyTypeObject* py::winrt_type<winrt::Windows::Devices::Adc::Provider::IAdcControllerProvider>::get_python_type() noexcept {
    using namespace py::cpp::Windows::Devices::Adc::Provider;

    PyObject* module = PyState_FindModule(&module_def);

    if (!module) {
        PyErr_SetString(PyExc_RuntimeError, "could not find module for Windows::Devices::Adc::Provider");
        return nullptr;
    }

    auto state = reinterpret_cast<module_state*>(PyModule_GetState(module));
    assert(state);

    auto python_type = state->type_IAdcControllerProvider;

    if (!python_type) {
        PyErr_SetString(PyExc_RuntimeError, "type winrt::Windows::Devices::Adc::Provider::IAdcControllerProvider is not registered");
        return nullptr;
    }

    return python_type;
}

PyTypeObject* py::winrt_type<winrt::Windows::Devices::Adc::Provider::IAdcProvider>::get_python_type() noexcept {
    using namespace py::cpp::Windows::Devices::Adc::Provider;

    PyObject* module = PyState_FindModule(&module_def);

    if (!module) {
        PyErr_SetString(PyExc_RuntimeError, "could not find module for Windows::Devices::Adc::Provider");
        return nullptr;
    }

    auto state = reinterpret_cast<module_state*>(PyModule_GetState(module));
    assert(state);

    auto python_type = state->type_IAdcProvider;

    if (!python_type) {
        PyErr_SetString(PyExc_RuntimeError, "type winrt::Windows::Devices::Adc::Provider::IAdcProvider is not registered");
        return nullptr;
    }

    return python_type;
}
