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

#include "py.Windows.UI.Accessibility.h"

namespace py::cpp::Windows::UI::Accessibility
{
    // ----- ScreenReaderPositionChangedEventArgs class --------------------

    static PyObject* _new_ScreenReaderPositionChangedEventArgs(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::UI::Accessibility::ScreenReaderPositionChangedEventArgs>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::UI::Accessibility::ScreenReaderPositionChangedEventArgs>::type_name);
        return nullptr;
    }

    static void _dealloc_ScreenReaderPositionChangedEventArgs(py::wrapper::Windows::UI::Accessibility::ScreenReaderPositionChangedEventArgs* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* ScreenReaderPositionChangedEventArgs_get_IsReadingText(py::wrapper::Windows::UI::Accessibility::ScreenReaderPositionChangedEventArgs* 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.UI.Accessibility.ScreenReaderPositionChangedEventArgs", L"IsReadingText");
            }

            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 self->obj.IsReadingText();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* ScreenReaderPositionChangedEventArgs_get_ScreenPositionInRawPixels(py::wrapper::Windows::UI::Accessibility::ScreenReaderPositionChangedEventArgs* 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.UI.Accessibility.ScreenReaderPositionChangedEventArgs", L"ScreenPositionInRawPixels");
            }

            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 self->obj.ScreenPositionInRawPixels();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

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

    static PyObject* _from_ScreenReaderPositionChangedEventArgs(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::UI::Accessibility::ScreenReaderPositionChangedEventArgs>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_ScreenReaderPositionChangedEventArgs[] = {
        { "_assign_array_", _assign_array_ScreenReaderPositionChangedEventArgs, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_ScreenReaderPositionChangedEventArgs), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_ScreenReaderPositionChangedEventArgs[] = {
        { "is_reading_text", reinterpret_cast<getter>(ScreenReaderPositionChangedEventArgs_get_IsReadingText), nullptr, nullptr, nullptr },
        { "screen_position_in_raw_pixels", reinterpret_cast<getter>(ScreenReaderPositionChangedEventArgs_get_ScreenPositionInRawPixels), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_ScreenReaderPositionChangedEventArgs[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_ScreenReaderPositionChangedEventArgs) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_ScreenReaderPositionChangedEventArgs) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_ScreenReaderPositionChangedEventArgs) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_ScreenReaderPositionChangedEventArgs) },
        { }};

    static PyType_Spec type_spec_ScreenReaderPositionChangedEventArgs = {
        "winrt._winrt_windows_ui_accessibility.ScreenReaderPositionChangedEventArgs",
        sizeof(py::wrapper::Windows::UI::Accessibility::ScreenReaderPositionChangedEventArgs),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_ScreenReaderPositionChangedEventArgs};

    // ----- ScreenReaderService class --------------------

    static PyObject* _new_ScreenReaderService(PyTypeObject* type, PyObject* args, PyObject* kwds) noexcept
    {
        if (kwds)
        {
            py::set_invalid_kwd_args_error();
            return nullptr;
        }

        auto arg_count = PyTuple_GET_SIZE(args);
        if (arg_count == 0)
        {
            try
            {
                winrt::Windows::UI::Accessibility::ScreenReaderService instance{};
                return py::wrap(instance, type);
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static void _dealloc_ScreenReaderService(py::wrapper::Windows::UI::Accessibility::ScreenReaderService* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* ScreenReaderService_get_CurrentScreenReaderPosition(py::wrapper::Windows::UI::Accessibility::ScreenReaderService* 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.UI.Accessibility.ScreenReaderService", L"CurrentScreenReaderPosition");
            }

            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 self->obj.CurrentScreenReaderPosition();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* ScreenReaderService_add_ScreenReaderPositionChanged(py::wrapper::Windows::UI::Accessibility::ScreenReaderService* self, 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.UI.Accessibility.ScreenReaderService", L"ScreenReaderPositionChanged");
            }

            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::TypedEventHandler<winrt::Windows::UI::Accessibility::ScreenReaderService, winrt::Windows::UI::Accessibility::ScreenReaderPositionChangedEventArgs>>(arg);

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.ScreenReaderPositionChanged(param0);
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* ScreenReaderService_remove_ScreenReaderPositionChanged(py::wrapper::Windows::UI::Accessibility::ScreenReaderService* self, 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.UI.Accessibility.ScreenReaderService", L"ScreenReaderPositionChanged");
            }

            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();
                self->obj.ScreenReaderPositionChanged(param0);
            }

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

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

    static PyObject* _from_ScreenReaderService(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::UI::Accessibility::ScreenReaderService>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_ScreenReaderService[] = {
        { "add_screen_reader_position_changed", reinterpret_cast<PyCFunction>(ScreenReaderService_add_ScreenReaderPositionChanged), METH_O, nullptr },
        { "remove_screen_reader_position_changed", reinterpret_cast<PyCFunction>(ScreenReaderService_remove_ScreenReaderPositionChanged), METH_O, nullptr },
        { "_assign_array_", _assign_array_ScreenReaderService, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_ScreenReaderService), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_ScreenReaderService[] = {
        { "current_screen_reader_position", reinterpret_cast<getter>(ScreenReaderService_get_CurrentScreenReaderPosition), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_ScreenReaderService[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_ScreenReaderService) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_ScreenReaderService) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_ScreenReaderService) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_ScreenReaderService) },
        { }};

    static PyType_Spec type_spec_ScreenReaderService = {
        "winrt._winrt_windows_ui_accessibility.ScreenReaderService",
        sizeof(py::wrapper::Windows::UI::Accessibility::ScreenReaderService),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_ScreenReaderService};

    // ----- Windows.UI.Accessibility Initialization --------------------

    PyDoc_STRVAR(module_doc, "Windows.UI.Accessibility");

    static PyModuleDef module_def = {
        PyModuleDef_HEAD_INIT,
        "_winrt_windows_ui_accessibility",
        module_doc,
        0,
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        nullptr};
} // py::cpp::Windows::UI::Accessibility

PyMODINIT_FUNC PyInit__winrt_windows_ui_accessibility(void) noexcept
{
    using namespace py::cpp::Windows::UI::Accessibility;

    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::pytype_handle ScreenReaderPositionChangedEventArgs_type{py::register_python_type(module.get(), &type_spec_ScreenReaderPositionChangedEventArgs, object_bases.get(), inspectable_meta_type)};
    if (!ScreenReaderPositionChangedEventArgs_type)
    {
        return nullptr;
    }

    py::pytype_handle ScreenReaderService_type{py::register_python_type(module.get(), &type_spec_ScreenReaderService, object_bases.get(), inspectable_meta_type)};
    if (!ScreenReaderService_type)
    {
        return nullptr;
    }


    return module.detach();
}
