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

#include "py.Windows.Media.Core.Preview.h"

namespace py::cpp::Windows::Media::Core::Preview
{
    // ----- SoundLevelBroker class --------------------

    static PyObject* _new_SoundLevelBroker(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Media::Core::Preview::SoundLevelBroker>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Media::Core::Preview::SoundLevelBroker>::type_name);
        return nullptr;
    }

    static PyObject* SoundLevelBroker_get_SoundLevel(PyObject* /*unused*/, 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.Media.Core.Preview.SoundLevelBroker", L"SoundLevel");
            }

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

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return winrt::Windows::Media::Core::Preview::SoundLevelBroker::SoundLevel();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* SoundLevelBroker_add_SoundLevelChanged(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Media.Core.Preview.SoundLevelBroker", L"SoundLevelChanged");
            }

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

            auto param0 = py::convert_to<winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable>>(arg);

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return winrt::Windows::Media::Core::Preview::SoundLevelBroker::SoundLevelChanged(param0);
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* SoundLevelBroker_remove_SoundLevelChanged(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Media.Core.Preview.SoundLevelBroker", L"SoundLevelChanged");
            }

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

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

            {
                auto _gil = release_gil();
                winrt::Windows::Media::Core::Preview::SoundLevelBroker::SoundLevelChanged(param0);
            }

            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_SoundLevelBroker[] = {
        { }};

    static PyGetSetDef _getset_SoundLevelBroker[] = {
        { }};

    static PyType_Slot _type_slots_SoundLevelBroker[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_SoundLevelBroker) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_SoundLevelBroker) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_SoundLevelBroker) },
        { }};

    static PyType_Spec type_spec_SoundLevelBroker = {
        "winrt._winrt_windows_media_core_preview.SoundLevelBroker",
        0,
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_SoundLevelBroker};

    static PyGetSetDef getset_SoundLevelBroker_Static[] = {
        { "sound_level", reinterpret_cast<getter>(SoundLevelBroker_get_SoundLevel), nullptr, nullptr, nullptr },
        { }};

    static PyMethodDef methods_SoundLevelBroker_Static[] = {
        { "add_sound_level_changed", reinterpret_cast<PyCFunction>(SoundLevelBroker_add_SoundLevelChanged), METH_O, nullptr },
        { "remove_sound_level_changed", reinterpret_cast<PyCFunction>(SoundLevelBroker_remove_SoundLevelChanged), METH_O, nullptr },
        { }};

    static PyType_Slot type_slots_SoundLevelBroker_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_SoundLevelBroker_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_SoundLevelBroker_Static) },
        { }
    };

    static PyType_Spec type_spec_SoundLevelBroker_Static = {
        "winrt._winrt_windows_media_core_preview.SoundLevelBroker_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_SoundLevelBroker_Static};

    // ----- Windows.Media.Core.Preview Initialization --------------------

    PyDoc_STRVAR(module_doc, "Windows.Media.Core.Preview");

    static PyModuleDef module_def = {
        PyModuleDef_HEAD_INIT,
        "_winrt_windows_media_core_preview",
        module_doc,
        0,
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        nullptr};
} // py::cpp::Windows::Media::Core::Preview

PyMODINIT_FUNC PyInit__winrt_windows_media_core_preview(void) noexcept
{
    using namespace py::cpp::Windows::Media::Core::Preview;

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

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

    if (!module)
    {
        return nullptr;
    }

    auto inspectable_meta_type = py::get_inspectable_meta_type();
    if (!inspectable_meta_type)
    {
        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 SoundLevelBroker_Static_bases{PyTuple_Pack(1, reinterpret_cast<PyObject*>(inspectable_meta_type))};
    if (!SoundLevelBroker_Static_bases)
    {
        return nullptr;
    }

    py::pyobj_handle type_SoundLevelBroker_Static{PyType_FromSpecWithBases(&type_spec_SoundLevelBroker_Static, SoundLevelBroker_Static_bases.get())};
    if (!type_SoundLevelBroker_Static)
    {
        return nullptr;
    }

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


    return module.detach();
}
