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

#include "py.Windows.Phone.Media.Devices.h"


namespace py::cpp::Windows::Phone::Media::Devices
{
    // ----- AudioRoutingManager class --------------------

    static PyObject* _new_AudioRoutingManager(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Phone::Media::Devices::AudioRoutingManager>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Phone::Media::Devices::AudioRoutingManager>::type_name);
        return nullptr;
    }

    static void _dealloc_AudioRoutingManager(py::wrapper::Windows::Phone::Media::Devices::AudioRoutingManager* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* AudioRoutingManager_GetAudioEndpoint(py::wrapper::Windows::Phone::Media::Devices::AudioRoutingManager* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 0)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Phone.Media.Devices.AudioRoutingManager", L"GetAudioEndpoint", 0))
            {
                py::set_arg_count_version_error(0);
                return nullptr;
            }

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

    static PyObject* AudioRoutingManager_GetDefault(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 0)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Phone.Media.Devices.AudioRoutingManager", L"GetDefault", 0))
            {
                py::set_arg_count_version_error(0);
                return nullptr;
            }

            try
            {
                return py::convert(winrt::Windows::Phone::Media::Devices::AudioRoutingManager::GetDefault());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* AudioRoutingManager_SetAudioEndpoint(py::wrapper::Windows::Phone::Media::Devices::AudioRoutingManager* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 1)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Phone.Media.Devices.AudioRoutingManager", L"SetAudioEndpoint", 1))
            {
                py::set_arg_count_version_error(1);
                return nullptr;
            }

            try
            {
                auto param0 = py::convert_to<winrt::Windows::Phone::Media::Devices::AudioRoutingEndpoint>(args, 0);

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

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

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

    static PyObject* AudioRoutingManager_add_AudioEndpointChanged(py::wrapper::Windows::Phone::Media::Devices::AudioRoutingManager* self, PyObject* arg) noexcept
    {
        if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Phone.Media.Devices.AudioRoutingManager", L"AudioEndpointChanged"))
        {
            PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
            return nullptr;
        }

        try
        {
            auto param0 = py::convert_to<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Phone::Media::Devices::AudioRoutingManager, winrt::Windows::Foundation::IInspectable>>(arg);

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

    static PyObject* AudioRoutingManager_remove_AudioEndpointChanged(py::wrapper::Windows::Phone::Media::Devices::AudioRoutingManager* self, PyObject* arg) noexcept
    {
        if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Phone.Media.Devices.AudioRoutingManager", L"AudioEndpointChanged"))
        {
            PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
            return nullptr;
        }

        try
        {
            auto param0 = py::convert_to<winrt::event_token>(arg);

            self->obj.AudioEndpointChanged(param0);
            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

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

    static PyObject* _from_AudioRoutingManager(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::Phone::Media::Devices::AudioRoutingManager>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_AudioRoutingManager[] = {
        { "get_audio_endpoint", reinterpret_cast<PyCFunction>(AudioRoutingManager_GetAudioEndpoint), METH_VARARGS, nullptr },
        { "set_audio_endpoint", reinterpret_cast<PyCFunction>(AudioRoutingManager_SetAudioEndpoint), METH_VARARGS, nullptr },
        { "add_audio_endpoint_changed", reinterpret_cast<PyCFunction>(AudioRoutingManager_add_AudioEndpointChanged), METH_O, nullptr },
        { "remove_audio_endpoint_changed", reinterpret_cast<PyCFunction>(AudioRoutingManager_remove_AudioEndpointChanged), METH_O, nullptr },
        { "_assign_array_", _assign_array_AudioRoutingManager, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_AudioRoutingManager), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_AudioRoutingManager[] = {
        { "available_audio_endpoints", reinterpret_cast<getter>(AudioRoutingManager_get_AvailableAudioEndpoints), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_AudioRoutingManager[] = 
    {
        { Py_tp_new, reinterpret_cast<void*>(_new_AudioRoutingManager) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_AudioRoutingManager) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_AudioRoutingManager) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_AudioRoutingManager) },
        { },
    };

    static PyType_Spec type_spec_AudioRoutingManager =
    {
        "winrt._winrt_windows_phone_media_devices.AudioRoutingManager",
        sizeof(py::wrapper::Windows::Phone::Media::Devices::AudioRoutingManager),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_AudioRoutingManager
    };

    static PyGetSetDef getset_AudioRoutingManager_Static[] = {
        { }
    };

    static PyMethodDef methods_AudioRoutingManager_Static[] = {
        { "get_default", reinterpret_cast<PyCFunction>(AudioRoutingManager_GetDefault), METH_VARARGS, nullptr },
        { }
    };

    static PyType_Slot type_slots_AudioRoutingManager_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_AudioRoutingManager_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_AudioRoutingManager_Static) },
        { }
    };

    static PyType_Spec type_spec_AudioRoutingManager_Static =
    {
        "winrt._winrt_windows_phone_media_devices.AudioRoutingManager_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_AudioRoutingManager_Static
    };

    // ----- Windows.Phone.Media.Devices Initialization --------------------
    PyDoc_STRVAR(module_doc, "Windows::Phone::Media::Devices");


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

} // py::cpp::Windows::Phone::Media::Devices

PyMODINIT_FUNC PyInit__winrt_windows_phone_media_devices(void) noexcept
{
    using namespace py::cpp::Windows::Phone::Media::Devices;

    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::pyobj_handle type_AudioRoutingManager_Static{PyType_FromSpec(&type_spec_AudioRoutingManager_Static)};
    if (!type_AudioRoutingManager_Static)
    {
        return nullptr;
    }

    if (py::register_python_type(module.get(), &type_spec_AudioRoutingManager, object_bases.get(), reinterpret_cast<PyTypeObject*>(type_AudioRoutingManager_Static.get())) == -1)
    {
        return nullptr;
    }


    return module.detach();
}
