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

#include "py.Windows.Phone.System.h"

namespace py::cpp::Windows::Phone::System
{
    // ----- SystemProtection class --------------------

    static PyObject* _new_SystemProtection(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Phone::System::SystemProtection>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Phone::System::SystemProtection>::type_name);
        return nullptr;
    }

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

        if (arg_count == 0)
        {
            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.Phone.System.SystemProtection", L"RequestScreenUnlock", 0);
                }

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

                winrt::Windows::Phone::System::SystemProtection::RequestScreenUnlock();
                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* SystemProtection_get_ScreenLocked(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.Phone.System.SystemProtection", L"ScreenLocked");
            }

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

            return py::convert(winrt::Windows::Phone::System::SystemProtection::ScreenLocked());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_SystemProtection[] = {
        { }
    };

    static PyGetSetDef _getset_SystemProtection[] = {
        { }
    };

    static PyType_Slot _type_slots_SystemProtection[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_SystemProtection) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_SystemProtection) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_SystemProtection) },
        { }
    };

    static PyType_Spec type_spec_SystemProtection = {
        "winrt._winrt_windows_phone_system.SystemProtection",
        0,
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_SystemProtection};

    static PyGetSetDef getset_SystemProtection_Static[] = {
        { "screen_locked", reinterpret_cast<getter>(SystemProtection_get_ScreenLocked), nullptr, nullptr, nullptr },
        { }
    };

    static PyMethodDef methods_SystemProtection_Static[] = {
        { "request_screen_unlock", reinterpret_cast<PyCFunction>(SystemProtection_RequestScreenUnlock), METH_VARARGS, nullptr },
        { }
    };

    static PyType_Slot type_slots_SystemProtection_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_SystemProtection_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_SystemProtection_Static) },
        { }
    };

    static PyType_Spec type_spec_SystemProtection_Static =
    {
        "winrt._winrt_windows_phone_system.SystemProtection_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_SystemProtection_Static
    };

    // ----- Windows.Phone.System Initialization --------------------

    PyDoc_STRVAR(module_doc, "Windows.Phone.System");

    static PyModuleDef module_def = {
        PyModuleDef_HEAD_INIT,
        "_winrt_windows_phone_system",
        module_doc,
        0,
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        nullptr};
} // py::cpp::Windows::Phone::System

PyMODINIT_FUNC PyInit__winrt_windows_phone_system(void) noexcept
{
    using namespace py::cpp::Windows::Phone::System;

    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_SystemProtection_Static{PyType_FromSpec(&type_spec_SystemProtection_Static)};
    if (!type_SystemProtection_Static)
    {
        return nullptr;
    }

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


    return module.detach();
}
