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

#include "py.Windows.Management.Deployment.Preview.h"

namespace py::cpp::Windows::Management::Deployment::Preview
{
    // ----- ClassicAppManager class --------------------

    static PyObject* _new_ClassicAppManager(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Management::Deployment::Preview::ClassicAppManager>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Management::Deployment::Preview::ClassicAppManager>::type_name);
        return nullptr;
    }

    static PyObject* ClassicAppManager_FindInstalledApp(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Management.Deployment.Preview.ClassicAppManager", L"FindInstalledApp", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::hstring>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Management::Deployment::Preview::ClassicAppManager::FindInstalledApp(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyMethodDef _methods_ClassicAppManager[] = {
        { }};

    static PyGetSetDef _getset_ClassicAppManager[] = {
        { }};

    static PyType_Slot _type_slots_ClassicAppManager[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_ClassicAppManager) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_ClassicAppManager) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_ClassicAppManager) },
        { }};

    static PyType_Spec type_spec_ClassicAppManager = {
        "winrt._winrt_windows_management_deployment_preview.ClassicAppManager",
        0,
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_ClassicAppManager};

    static PyGetSetDef getset_ClassicAppManager_Static[] = {
        { }};

    static PyMethodDef methods_ClassicAppManager_Static[] = {
        { "find_installed_app", reinterpret_cast<PyCFunction>(ClassicAppManager_FindInstalledApp), METH_VARARGS, nullptr },
        { }};

    static PyType_Slot type_slots_ClassicAppManager_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_ClassicAppManager_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_ClassicAppManager_Static) },
        { }
    };

    static PyType_Spec type_spec_ClassicAppManager_Static = {
        "winrt._winrt_windows_management_deployment_preview.ClassicAppManager_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_ClassicAppManager_Static};

    // ----- InstalledClassicAppInfo class --------------------

    static PyObject* _new_InstalledClassicAppInfo(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Management::Deployment::Preview::InstalledClassicAppInfo>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Management::Deployment::Preview::InstalledClassicAppInfo>::type_name);
        return nullptr;
    }

    static void _dealloc_InstalledClassicAppInfo(py::wrapper::Windows::Management::Deployment::Preview::InstalledClassicAppInfo* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* InstalledClassicAppInfo_get_DisplayName(py::wrapper::Windows::Management::Deployment::Preview::InstalledClassicAppInfo* 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.Management.Deployment.Preview.InstalledClassicAppInfo", L"DisplayName");
            }

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

    static PyObject* InstalledClassicAppInfo_get_DisplayVersion(py::wrapper::Windows::Management::Deployment::Preview::InstalledClassicAppInfo* 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.Management.Deployment.Preview.InstalledClassicAppInfo", L"DisplayVersion");
            }

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

    static PyObject* _assign_array_InstalledClassicAppInfo(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Management::Deployment::Preview::InstalledClassicAppInfo>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_InstalledClassicAppInfo(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::Management::Deployment::Preview::InstalledClassicAppInfo>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_InstalledClassicAppInfo[] = {
        { "_assign_array_", _assign_array_InstalledClassicAppInfo, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_InstalledClassicAppInfo), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_InstalledClassicAppInfo[] = {
        { "display_name", reinterpret_cast<getter>(InstalledClassicAppInfo_get_DisplayName), nullptr, nullptr, nullptr },
        { "display_version", reinterpret_cast<getter>(InstalledClassicAppInfo_get_DisplayVersion), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_InstalledClassicAppInfo[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_InstalledClassicAppInfo) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_InstalledClassicAppInfo) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_InstalledClassicAppInfo) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_InstalledClassicAppInfo) },
        { }};

    static PyType_Spec type_spec_InstalledClassicAppInfo = {
        "winrt._winrt_windows_management_deployment_preview.InstalledClassicAppInfo",
        sizeof(py::wrapper::Windows::Management::Deployment::Preview::InstalledClassicAppInfo),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_InstalledClassicAppInfo};

    // ----- Windows.Management.Deployment.Preview Initialization --------------------

    PyDoc_STRVAR(module_doc, "Windows.Management.Deployment.Preview");

    static PyModuleDef module_def = {
        PyModuleDef_HEAD_INIT,
        "_winrt_windows_management_deployment_preview",
        module_doc,
        0,
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        nullptr};
} // py::cpp::Windows::Management::Deployment::Preview

PyMODINIT_FUNC PyInit__winrt_windows_management_deployment_preview(void) noexcept
{
    using namespace py::cpp::Windows::Management::Deployment::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 ClassicAppManager_Static_bases{PyTuple_Pack(1, reinterpret_cast<PyObject*>(inspectable_meta_type))};
    if (!ClassicAppManager_Static_bases)
    {
        return nullptr;
    }

    py::pyobj_handle type_ClassicAppManager_Static{PyType_FromSpecWithBases(&type_spec_ClassicAppManager_Static, ClassicAppManager_Static_bases.get())};
    if (!type_ClassicAppManager_Static)
    {
        return nullptr;
    }

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

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


    return module.detach();
}
