// WARNING: Please don't edit this file. It was generated by Python/WinRT v1.0.0-beta.8

#include "pybase.h"
#include "py.Windows.Data.Xml.Xsl.h"


namespace py::cpp::Windows::Data::Xml::Xsl
{
    struct module_state
    {
        PyTypeObject* type_XsltProcessor;
    };

    // ----- XsltProcessor class --------------------
    constexpr const char* const type_name_XsltProcessor = "XsltProcessor";

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

        auto arg_count = PyTuple_Size(args);
        if (arg_count == 1)
        {
            try
            {
                auto param0 = py::convert_to<winrt::Windows::Data::Xml::Dom::XmlDocument>(args, 0);

                winrt::Windows::Data::Xml::Xsl::XsltProcessor instance{ param0 };
                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_XsltProcessor(py::wrapper::Windows::Data::Xml::Xsl::XsltProcessor* self) noexcept
    {
        auto tp = Py_TYPE(self);

        if (PyType_IS_GC(tp))
        {
            PyObject_GC_UnTrack(self);
        }

        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* XsltProcessor_TransformToDocument(py::wrapper::Windows::Data::Xml::Xsl::XsltProcessor* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 1)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Data.Xml.Xsl.XsltProcessor", L"TransformToDocument", 1))
            {
                py::set_arg_count_version_error(1);
                return nullptr;
            }

            try
            {
                auto param0 = py::convert_to<winrt::Windows::Data::Xml::Dom::IXmlNode>(args, 0);

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

    static PyObject* XsltProcessor_TransformToString(py::wrapper::Windows::Data::Xml::Xsl::XsltProcessor* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 1)
        {
            if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Data.Xml.Xsl.XsltProcessor", L"TransformToString", 1))
            {
                py::set_arg_count_version_error(1);
                return nullptr;
            }

            try
            {
                auto param0 = py::convert_to<winrt::Windows::Data::Xml::Dom::IXmlNode>(args, 0);

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

    static PyObject* _assign_array_XsltProcessor(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Data::Xml::Xsl::XsltProcessor>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_XsltProcessor(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::Data::Xml::Xsl::XsltProcessor>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_XsltProcessor[] = {
        { "transform_to_document", reinterpret_cast<PyCFunction>(XsltProcessor_TransformToDocument), METH_VARARGS, nullptr },
        { "transform_to_string", reinterpret_cast<PyCFunction>(XsltProcessor_TransformToString), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_XsltProcessor, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_XsltProcessor), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_XsltProcessor[] = {
        { }
    };

    static PyType_Slot _type_slots_XsltProcessor[] = 
    {
        { Py_tp_new, _new_XsltProcessor },
        { Py_tp_dealloc, _dealloc_XsltProcessor },
        { Py_tp_methods, _methods_XsltProcessor },
        { Py_tp_getset, _getset_XsltProcessor },
        { },
    };

    static PyType_Spec type_spec_XsltProcessor =
    {
        "_winsdk_Windows_Data_Xml_Xsl.XsltProcessor",
        sizeof(py::wrapper::Windows::Data::Xml::Xsl::XsltProcessor),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_XsltProcessor
    };

    // ----- Windows.Data.Xml.Xsl Initialization --------------------
    PyDoc_STRVAR(module_doc, "Windows::Data::Xml::Xsl");

    static PyMethodDef module_methods[] = {
        {}};


    static int module_traverse(PyObject* module, visitproc visit, void* arg) noexcept
    {
        auto state = reinterpret_cast<module_state*>(PyModule_GetState(module));

        if (!state)
        {
            return 0;
        }

        Py_VISIT(state->type_XsltProcessor);

        return 0;
    }

    static int module_clear(PyObject* module) noexcept
    {
        auto state = reinterpret_cast<module_state*>(PyModule_GetState(module));

        if (!state)
        {
            return 0;
        }

        Py_CLEAR(state->type_XsltProcessor);

        return 0;
    }


    static PyModuleDef module_def
        = {PyModuleDef_HEAD_INIT,
           "_winsdk_Windows_Data_Xml_Xsl",
           module_doc,
           sizeof(module_state),
           module_methods,
           nullptr,
           module_traverse,
           module_clear,
           nullptr};

} // py::cpp::Windows::Data::Xml::Xsl

PyMODINIT_FUNC PyInit__winsdk_Windows_Data_Xml_Xsl(void) noexcept
{
    using namespace py::cpp::Windows::Data::Xml::Xsl;

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

    if (!module)
    {
        return nullptr;
    }

    auto object_type = py::get_python_type<py::Object>();
    if (!object_type)
    {
        return nullptr;
    }

    py::pyobj_handle bases{PyTuple_Pack(1, object_type)};

    if (!bases)
    {
        return nullptr;
    }

    py::pyobj_handle collections_abc_module{PyImport_ImportModule("collections.abc")};

    if (!collections_abc_module)
    {
        return nullptr;
    }

    py::pyobj_handle sequence_type{PyObject_GetAttrString(collections_abc_module.get(), "Sequence")};

    if (!sequence_type)
    {
        return nullptr;
    }

    py::pyobj_handle sequence_bases{PyTuple_Pack(2, object_type, sequence_type.get())};

    if (!sequence_bases)
    {
        return nullptr;
    }

    py::pyobj_handle mutable_sequence_type{PyObject_GetAttrString(collections_abc_module.get(), "MutableSequence")};

    if (!mutable_sequence_type)
    {
        return nullptr;
    }

    py::pyobj_handle mutable_sequence_bases{PyTuple_Pack(2, object_type, mutable_sequence_type.get())};

    if (!mutable_sequence_bases)
    {
        return nullptr;
    }

    py::pyobj_handle mapping_type{PyObject_GetAttrString(collections_abc_module.get(), "Mapping")};

    if (!mapping_type)
    {
        return nullptr;
    }

    py::pyobj_handle mapping_bases{PyTuple_Pack(2, object_type, mapping_type.get())};

    if (!mapping_bases)
    {
        return nullptr;
    }

    py::pyobj_handle mutable_mapping_type{PyObject_GetAttrString(collections_abc_module.get(), "MutableMapping")};

    if (!mutable_mapping_type)
    {
        return nullptr;
    }

    py::pyobj_handle mutable_mapping_bases{PyTuple_Pack(2, object_type, mutable_mapping_type.get())};

    if (!mutable_mapping_bases)
    {
        return nullptr;
    }

    auto state = reinterpret_cast<module_state*>(PyModule_GetState(module.get()));
    assert(state);

    state->type_XsltProcessor = py::register_python_type(module.get(), type_name_XsltProcessor, &type_spec_XsltProcessor, bases.get(), nullptr);
    if (!state->type_XsltProcessor)
    {
        return nullptr;
    }


    return module.detach();
}

PyTypeObject* py::winrt_type<winrt::Windows::Data::Xml::Xsl::XsltProcessor>::get_python_type() noexcept {
    using namespace py::cpp::Windows::Data::Xml::Xsl;

    PyObject* module = PyState_FindModule(&module_def);

    if (!module) {
        PyErr_SetString(PyExc_RuntimeError, "could not find module for Windows::Data::Xml::Xsl");
        return nullptr;
    }

    auto state = reinterpret_cast<module_state*>(PyModule_GetState(module));
    assert(state);

    auto python_type = state->type_XsltProcessor;

    if (!python_type) {
        PyErr_SetString(PyExc_RuntimeError, "type winrt::Windows::Data::Xml::Xsl::XsltProcessor is not registered");
        return nullptr;
    }

    return python_type;
}
