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

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


namespace py::cpp::Windows::Devices::I2c::Provider
{
    // ----- ProviderI2cConnectionSettings class --------------------

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

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

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

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

    static int ProviderI2cConnectionSettings_put_SlaveAddress(py::wrapper::Windows::Devices::I2c::Provider::ProviderI2cConnectionSettings* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.I2c.Provider.ProviderI2cConnectionSettings", L"SlaveAddress"))
        {
            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<int32_t>(arg);

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

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

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

    static int ProviderI2cConnectionSettings_put_SharingMode(py::wrapper::Windows::Devices::I2c::Provider::ProviderI2cConnectionSettings* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.I2c.Provider.ProviderI2cConnectionSettings", L"SharingMode"))
        {
            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::I2c::Provider::ProviderI2cSharingMode>(arg);

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

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

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

    static int ProviderI2cConnectionSettings_put_BusSpeed(py::wrapper::Windows::Devices::I2c::Provider::ProviderI2cConnectionSettings* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.I2c.Provider.ProviderI2cConnectionSettings", L"BusSpeed"))
        {
            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::I2c::Provider::ProviderI2cBusSpeed>(arg);

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

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

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

    static PyMethodDef _methods_ProviderI2cConnectionSettings[] = {
        { "_assign_array_", _assign_array_ProviderI2cConnectionSettings, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_ProviderI2cConnectionSettings), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_ProviderI2cConnectionSettings[] = {
        { "slave_address", reinterpret_cast<getter>(ProviderI2cConnectionSettings_get_SlaveAddress), reinterpret_cast<setter>(ProviderI2cConnectionSettings_put_SlaveAddress), nullptr, nullptr },
        { "sharing_mode", reinterpret_cast<getter>(ProviderI2cConnectionSettings_get_SharingMode), reinterpret_cast<setter>(ProviderI2cConnectionSettings_put_SharingMode), nullptr, nullptr },
        { "bus_speed", reinterpret_cast<getter>(ProviderI2cConnectionSettings_get_BusSpeed), reinterpret_cast<setter>(ProviderI2cConnectionSettings_put_BusSpeed), nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_ProviderI2cConnectionSettings[] = 
    {
        { Py_tp_new, reinterpret_cast<void*>(_new_ProviderI2cConnectionSettings) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_ProviderI2cConnectionSettings) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_ProviderI2cConnectionSettings) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_ProviderI2cConnectionSettings) },
        { },
    };

    static PyType_Spec type_spec_ProviderI2cConnectionSettings =
    {
        "winrt._winrt_windows_devices_i2c_provider.ProviderI2cConnectionSettings",
        sizeof(py::wrapper::Windows::Devices::I2c::Provider::ProviderI2cConnectionSettings),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_ProviderI2cConnectionSettings
    };

    // ----- II2cControllerProvider interface --------------------

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

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

    static PyObject* II2cControllerProvider_GetDeviceProvider(py::wrapper::Windows::Devices::I2c::Provider::II2cControllerProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

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

            try
            {
                auto param0 = py::convert_to<winrt::Windows::Devices::I2c::Provider::ProviderI2cConnectionSettings>(args, 0);

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

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

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

    static PyMethodDef _methods_II2cControllerProvider[] = {
        { "get_device_provider", reinterpret_cast<PyCFunction>(II2cControllerProvider_GetDeviceProvider), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_II2cControllerProvider, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_II2cControllerProvider), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_II2cControllerProvider[] = {
        { }
    };

    static PyType_Slot _type_slots_II2cControllerProvider[] = 
    {
        { Py_tp_new, reinterpret_cast<void*>(_new_II2cControllerProvider) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_II2cControllerProvider) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_II2cControllerProvider) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_II2cControllerProvider) },
        { },
    };

    static PyType_Spec type_spec_II2cControllerProvider =
    {
        "winrt._winrt_windows_devices_i2c_provider.II2cControllerProvider",
        sizeof(py::wrapper::Windows::Devices::I2c::Provider::II2cControllerProvider),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_II2cControllerProvider
    };

    // ----- II2cDeviceProvider interface --------------------

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

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

    static PyObject* II2cDeviceProvider_Close(py::wrapper::Windows::Devices::I2c::Provider::II2cDeviceProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 0)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Foundation.IClosable", L"Close", 0))
            {
                py::set_arg_count_version_error(0);
                return nullptr;
            }

            try
            {
                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* II2cDeviceProvider_Read(py::wrapper::Windows::Devices::I2c::Provider::II2cDeviceProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 1)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.I2c.Provider.II2cDeviceProvider", L"Read", 0))
            {
                py::set_arg_count_version_error(0);
                return nullptr;
            }

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

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

    static PyObject* II2cDeviceProvider_ReadPartial(py::wrapper::Windows::Devices::I2c::Provider::II2cDeviceProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 1)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.I2c.Provider.II2cDeviceProvider", L"ReadPartial", 0))
            {
                py::set_arg_count_version_error(0);
                return nullptr;
            }

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

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

    static PyObject* II2cDeviceProvider_Write(py::wrapper::Windows::Devices::I2c::Provider::II2cDeviceProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

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

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

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

    static PyObject* II2cDeviceProvider_WritePartial(py::wrapper::Windows::Devices::I2c::Provider::II2cDeviceProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

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

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

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

    static PyObject* II2cDeviceProvider_WriteRead(py::wrapper::Windows::Devices::I2c::Provider::II2cDeviceProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 2)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.I2c.Provider.II2cDeviceProvider", L"WriteRead", 1))
            {
                py::set_arg_count_version_error(1);
                return nullptr;
            }

            try
            {
                auto param0 = py::convert_to<py::pybuf_view<uint8_t, false>>(args, 0);
                auto param1 = py::convert_to<py::pybuf_view<uint8_t, true>>(args, 1);

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

    static PyObject* II2cDeviceProvider_WriteReadPartial(py::wrapper::Windows::Devices::I2c::Provider::II2cDeviceProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 2)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.I2c.Provider.II2cDeviceProvider", L"WriteReadPartial", 1))
            {
                py::set_arg_count_version_error(1);
                return nullptr;
            }

            try
            {
                auto param0 = py::convert_to<py::pybuf_view<uint8_t, false>>(args, 0);
                auto param1 = py::convert_to<py::pybuf_view<uint8_t, true>>(args, 1);

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

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

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

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

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

    static PyObject* _enter_II2cDeviceProvider(py::wrapper::Windows::Devices::I2c::Provider::II2cDeviceProvider* self, PyObject* /*unused*/) noexcept
    {
        return Py_NewRef(self);
    }

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

    static PyMethodDef _methods_II2cDeviceProvider[] = {
        { "close", reinterpret_cast<PyCFunction>(II2cDeviceProvider_Close), METH_VARARGS, nullptr },
        { "read", reinterpret_cast<PyCFunction>(II2cDeviceProvider_Read), METH_VARARGS, nullptr },
        { "read_partial", reinterpret_cast<PyCFunction>(II2cDeviceProvider_ReadPartial), METH_VARARGS, nullptr },
        { "write", reinterpret_cast<PyCFunction>(II2cDeviceProvider_Write), METH_VARARGS, nullptr },
        { "write_partial", reinterpret_cast<PyCFunction>(II2cDeviceProvider_WritePartial), METH_VARARGS, nullptr },
        { "write_read", reinterpret_cast<PyCFunction>(II2cDeviceProvider_WriteRead), METH_VARARGS, nullptr },
        { "write_read_partial", reinterpret_cast<PyCFunction>(II2cDeviceProvider_WriteReadPartial), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_II2cDeviceProvider, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_II2cDeviceProvider), METH_O | METH_STATIC, nullptr },
        { "__enter__", reinterpret_cast<PyCFunction>(_enter_II2cDeviceProvider), METH_NOARGS, nullptr },
        { "__exit__",  reinterpret_cast<PyCFunction>(_exit_II2cDeviceProvider), METH_VARARGS, nullptr },
        { }
    };

    static PyGetSetDef _getset_II2cDeviceProvider[] = {
        { "device_id", reinterpret_cast<getter>(II2cDeviceProvider_get_DeviceId), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_II2cDeviceProvider[] = 
    {
        { Py_tp_new, reinterpret_cast<void*>(_new_II2cDeviceProvider) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_II2cDeviceProvider) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_II2cDeviceProvider) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_II2cDeviceProvider) },
        { },
    };

    static PyType_Spec type_spec_II2cDeviceProvider =
    {
        "winrt._winrt_windows_devices_i2c_provider.II2cDeviceProvider",
        sizeof(py::wrapper::Windows::Devices::I2c::Provider::II2cDeviceProvider),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_II2cDeviceProvider
    };

    // ----- II2cProvider interface --------------------

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

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

    static PyObject* II2cProvider_GetControllersAsync(py::wrapper::Windows::Devices::I2c::Provider::II2cProvider* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

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

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

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

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

    static PyMethodDef _methods_II2cProvider[] = {
        { "get_controllers_async", reinterpret_cast<PyCFunction>(II2cProvider_GetControllersAsync), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_II2cProvider, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_II2cProvider), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_II2cProvider[] = {
        { }
    };

    static PyType_Slot _type_slots_II2cProvider[] = 
    {
        { Py_tp_new, reinterpret_cast<void*>(_new_II2cProvider) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_II2cProvider) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_II2cProvider) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_II2cProvider) },
        { },
    };

    static PyType_Spec type_spec_II2cProvider =
    {
        "winrt._winrt_windows_devices_i2c_provider.II2cProvider",
        sizeof(py::wrapper::Windows::Devices::I2c::Provider::II2cProvider),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_II2cProvider
    };

    // ----- ProviderI2cTransferResult struct --------------------

    winrt_struct_wrapper<winrt::Windows::Devices::I2c::Provider::ProviderI2cTransferResult>* _new_ProviderI2cTransferResult(PyTypeObject* subclass, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        auto self = reinterpret_cast<winrt_struct_wrapper<winrt::Windows::Devices::I2c::Provider::ProviderI2cTransferResult>*>(subclass->tp_alloc(subclass, 0));

        if (!self)
        {
            return nullptr;
        }

        std::construct_at(&self->obj);

        return self;
    }

    int _init_ProviderI2cTransferResult(winrt_struct_wrapper<winrt::Windows::Devices::I2c::Provider::ProviderI2cTransferResult>* self, PyObject* args, PyObject* kwds) noexcept
    {
        auto tuple_size = PyTuple_Size(args);

        if ((tuple_size == 0) && (kwds == nullptr))
        {
            self->obj = {};
            return 0;
        }

        int32_t _Status{};
        uint32_t _BytesTransferred{};

        static const char* kwlist[] = {"status", "bytes_transferred", nullptr};
        if (!PyArg_ParseTupleAndKeywords(args, kwds, "iI", const_cast<char**>(kwlist), &_Status, &_BytesTransferred))
        {
            return -1;
        }

        try
        {
            self->obj = {static_cast<winrt::Windows::Devices::I2c::Provider::ProviderI2cTransferStatus>(_Status), _BytesTransferred};
            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

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

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

    static PyMethodDef _methods_ProviderI2cTransferResult[] = {
        { "_assign_array_", _assign_array_ProviderI2cTransferResult, METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyObject* ProviderI2cTransferResult_get_Status(py::wrapper::Windows::Devices::I2c::Provider::ProviderI2cTransferResult* self, void* /*unused*/) noexcept
    {
        try
        {
            return py::convert(self->obj.Status);
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int ProviderI2cTransferResult_set_Status(py::wrapper::Windows::Devices::I2c::Provider::ProviderI2cTransferResult* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (arg == nullptr)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            self->obj.Status = py::converter<winrt::Windows::Devices::I2c::Provider::ProviderI2cTransferStatus>::convert_to(arg);
            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* ProviderI2cTransferResult_get_BytesTransferred(py::wrapper::Windows::Devices::I2c::Provider::ProviderI2cTransferResult* self, void* /*unused*/) noexcept
    {
        try
        {
            return py::convert(self->obj.BytesTransferred);
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int ProviderI2cTransferResult_set_BytesTransferred(py::wrapper::Windows::Devices::I2c::Provider::ProviderI2cTransferResult* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (arg == nullptr)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            self->obj.BytesTransferred = py::converter<uint32_t>::convert_to(arg);
            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyGetSetDef _getset_ProviderI2cTransferResult[] = {
        { "status", reinterpret_cast<getter>(ProviderI2cTransferResult_get_Status), reinterpret_cast<setter>(ProviderI2cTransferResult_set_Status), nullptr, nullptr },
        { "bytes_transferred", reinterpret_cast<getter>(ProviderI2cTransferResult_get_BytesTransferred), reinterpret_cast<setter>(ProviderI2cTransferResult_set_BytesTransferred), nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_ProviderI2cTransferResult[] = 
    {
        { Py_tp_new, reinterpret_cast<void*>(_new_ProviderI2cTransferResult) },
        { Py_tp_init, reinterpret_cast<void*>(_init_ProviderI2cTransferResult) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_ProviderI2cTransferResult) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_ProviderI2cTransferResult) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_ProviderI2cTransferResult) },
        { },
    };

    static PyType_Spec type_spec_ProviderI2cTransferResult =
    {
        "winrt._winrt_windows_devices_i2c_provider.ProviderI2cTransferResult",
        sizeof(py::wrapper::Windows::Devices::I2c::Provider::ProviderI2cTransferResult),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_ProviderI2cTransferResult
    };

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


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

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

PyMODINIT_FUNC PyInit__winrt_windows_devices_i2c_provider(void) noexcept
{
    using namespace py::cpp::Windows::Devices::I2c::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_ProviderI2cConnectionSettings, object_bases.get(), nullptr) == -1)
    {
        return nullptr;
    }

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

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

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

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


    return module.detach();
}
