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

#include "py.Windows.Media.Ocr.h"

namespace py::cpp::Windows::Media::Ocr
{
    // ----- OcrEngine class --------------------

    static PyObject* _new_OcrEngine(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Media::Ocr::OcrEngine>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Media::Ocr::OcrEngine>::type_name);
        return nullptr;
    }

    static void _dealloc_OcrEngine(py::wrapper::Windows::Media::Ocr::OcrEngine* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

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

        if (arg_count == 1)
        {
            try
            {
                if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Media.Ocr.OcrEngine", L"IsLanguageSupported", 1))
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Globalization::Language>(args, 0);

                return py::convert(winrt::Windows::Media::Ocr::OcrEngine::IsLanguageSupported(param0));
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* OcrEngine_RecognizeAsync(py::wrapper::Windows::Media::Ocr::OcrEngine* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 1)
        {
            try
            {
                if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Media.Ocr.OcrEngine", L"RecognizeAsync", 1))
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Graphics::Imaging::SoftwareBitmap>(args, 0);

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

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

        if (arg_count == 1)
        {
            try
            {
                if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Media.Ocr.OcrEngine", L"TryCreateFromLanguage", 1))
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Globalization::Language>(args, 0);

                return py::convert(winrt::Windows::Media::Ocr::OcrEngine::TryCreateFromLanguage(param0));
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

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

        if (arg_count == 0)
        {
            try
            {
                if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Media.Ocr.OcrEngine", L"TryCreateFromUserProfileLanguages", 0))
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert(winrt::Windows::Media::Ocr::OcrEngine::TryCreateFromUserProfileLanguages());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

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

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

    static PyObject* OcrEngine_get_AvailableRecognizerLanguages(PyObject* /*unused*/, void* /*unused*/) noexcept
    {
        try
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Ocr.OcrEngine", L"AvailableRecognizerLanguages"))
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(winrt::Windows::Media::Ocr::OcrEngine::AvailableRecognizerLanguages());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* OcrEngine_get_MaxImageDimension(PyObject* /*unused*/, void* /*unused*/) noexcept
    {
        try
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Media.Ocr.OcrEngine", L"MaxImageDimension"))
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(winrt::Windows::Media::Ocr::OcrEngine::MaxImageDimension());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

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

    static PyObject* _from_OcrEngine(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::Media::Ocr::OcrEngine>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_OcrEngine[] = {
        { "recognize_async", reinterpret_cast<PyCFunction>(OcrEngine_RecognizeAsync), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_OcrEngine, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_OcrEngine), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_OcrEngine[] = {
        { "recognizer_language", reinterpret_cast<getter>(OcrEngine_get_RecognizerLanguage), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_OcrEngine[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_OcrEngine) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_OcrEngine) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_OcrEngine) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_OcrEngine) },
        { }
    };

    static PyType_Spec type_spec_OcrEngine = {
        "winrt._winrt_windows_media_ocr.OcrEngine",
        sizeof(py::wrapper::Windows::Media::Ocr::OcrEngine),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_OcrEngine};

    static PyGetSetDef getset_OcrEngine_Static[] = {
        { "available_recognizer_languages", reinterpret_cast<getter>(OcrEngine_get_AvailableRecognizerLanguages), nullptr, nullptr, nullptr },
        { "max_image_dimension", reinterpret_cast<getter>(OcrEngine_get_MaxImageDimension), nullptr, nullptr, nullptr },
        { }
    };

    static PyMethodDef methods_OcrEngine_Static[] = {
        { "is_language_supported", reinterpret_cast<PyCFunction>(OcrEngine_IsLanguageSupported), METH_VARARGS, nullptr },
        { "try_create_from_language", reinterpret_cast<PyCFunction>(OcrEngine_TryCreateFromLanguage), METH_VARARGS, nullptr },
        { "try_create_from_user_profile_languages", reinterpret_cast<PyCFunction>(OcrEngine_TryCreateFromUserProfileLanguages), METH_VARARGS, nullptr },
        { }
    };

    static PyType_Slot type_slots_OcrEngine_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_OcrEngine_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_OcrEngine_Static) },
        { }
    };

    static PyType_Spec type_spec_OcrEngine_Static =
    {
        "winrt._winrt_windows_media_ocr.OcrEngine_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_OcrEngine_Static
    };

    // ----- OcrLine class --------------------

    static PyObject* _new_OcrLine(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Media::Ocr::OcrLine>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Media::Ocr::OcrLine>::type_name);
        return nullptr;
    }

    static void _dealloc_OcrLine(py::wrapper::Windows::Media::Ocr::OcrLine* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

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

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

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

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

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

    static PyObject* _from_OcrLine(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::Media::Ocr::OcrLine>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_OcrLine[] = {
        { "_assign_array_", _assign_array_OcrLine, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_OcrLine), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_OcrLine[] = {
        { "text", reinterpret_cast<getter>(OcrLine_get_Text), nullptr, nullptr, nullptr },
        { "words", reinterpret_cast<getter>(OcrLine_get_Words), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_OcrLine[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_OcrLine) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_OcrLine) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_OcrLine) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_OcrLine) },
        { }
    };

    static PyType_Spec type_spec_OcrLine = {
        "winrt._winrt_windows_media_ocr.OcrLine",
        sizeof(py::wrapper::Windows::Media::Ocr::OcrLine),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_OcrLine};

    // ----- OcrResult class --------------------

    static PyObject* _new_OcrResult(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Media::Ocr::OcrResult>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Media::Ocr::OcrResult>::type_name);
        return nullptr;
    }

    static void _dealloc_OcrResult(py::wrapper::Windows::Media::Ocr::OcrResult* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

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

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

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

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

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

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

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

    static PyObject* _from_OcrResult(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::Media::Ocr::OcrResult>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_OcrResult[] = {
        { "_assign_array_", _assign_array_OcrResult, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_OcrResult), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_OcrResult[] = {
        { "lines", reinterpret_cast<getter>(OcrResult_get_Lines), nullptr, nullptr, nullptr },
        { "text", reinterpret_cast<getter>(OcrResult_get_Text), nullptr, nullptr, nullptr },
        { "text_angle", reinterpret_cast<getter>(OcrResult_get_TextAngle), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_OcrResult[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_OcrResult) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_OcrResult) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_OcrResult) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_OcrResult) },
        { }
    };

    static PyType_Spec type_spec_OcrResult = {
        "winrt._winrt_windows_media_ocr.OcrResult",
        sizeof(py::wrapper::Windows::Media::Ocr::OcrResult),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_OcrResult};

    // ----- OcrWord class --------------------

    static PyObject* _new_OcrWord(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Media::Ocr::OcrWord>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Media::Ocr::OcrWord>::type_name);
        return nullptr;
    }

    static void _dealloc_OcrWord(py::wrapper::Windows::Media::Ocr::OcrWord* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

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

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

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

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

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

    static PyObject* _from_OcrWord(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::Media::Ocr::OcrWord>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_OcrWord[] = {
        { "_assign_array_", _assign_array_OcrWord, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_OcrWord), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_OcrWord[] = {
        { "bounding_rect", reinterpret_cast<getter>(OcrWord_get_BoundingRect), nullptr, nullptr, nullptr },
        { "text", reinterpret_cast<getter>(OcrWord_get_Text), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_OcrWord[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_OcrWord) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_OcrWord) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_OcrWord) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_OcrWord) },
        { }
    };

    static PyType_Spec type_spec_OcrWord = {
        "winrt._winrt_windows_media_ocr.OcrWord",
        sizeof(py::wrapper::Windows::Media::Ocr::OcrWord),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_OcrWord};

    // ----- Windows.Media.Ocr Initialization --------------------

    PyDoc_STRVAR(module_doc, "Windows.Media.Ocr");

    static PyModuleDef module_def = {
        PyModuleDef_HEAD_INIT,
        "_winrt_windows_media_ocr",
        module_doc,
        0,
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        nullptr};
} // py::cpp::Windows::Media::Ocr

PyMODINIT_FUNC PyInit__winrt_windows_media_ocr(void) noexcept
{
    using namespace py::cpp::Windows::Media::Ocr;

    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_OcrEngine_Static{PyType_FromSpec(&type_spec_OcrEngine_Static)};
    if (!type_OcrEngine_Static)
    {
        return nullptr;
    }

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

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

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

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


    return module.detach();
}
