/*
 * Interface wrapper code.
 *
 * Generated by SIP 4.19.16
 *
 *     Copyright: (c) 2018 by Total Control Software
 *     License:   wxWindows License
 */

#include "sipAPI_html2.h"

        #include <wx/webview.h>

        #include <wx/filesys.h>


class sipwxWebViewHandler : public  ::wxWebViewHandler
{
public:
    sipwxWebViewHandler(const  ::wxString&);
    sipwxWebViewHandler(const  ::wxWebViewHandler&);
    virtual ~sipwxWebViewHandler();

    /*
     * There is a protected method for every virtual method visible from
     * this class.
     */
protected:
     ::wxString GetName() const SIP_OVERRIDE;
     ::wxFSFile* GetFile(const  ::wxString&) SIP_OVERRIDE;

public:
    sipSimpleWrapper *sipPySelf;

private:
    sipwxWebViewHandler(const sipwxWebViewHandler &);
    sipwxWebViewHandler &operator = (const sipwxWebViewHandler &);

    char sipPyMethods[2];
};

sipwxWebViewHandler::sipwxWebViewHandler(const  ::wxString& scheme):  ::wxWebViewHandler(scheme), sipPySelf(SIP_NULLPTR)
{
    memset(sipPyMethods, 0, sizeof (sipPyMethods));
}

sipwxWebViewHandler::sipwxWebViewHandler(const  ::wxWebViewHandler& a0):  ::wxWebViewHandler(a0), sipPySelf(SIP_NULLPTR)
{
    memset(sipPyMethods, 0, sizeof (sipPyMethods));
}

sipwxWebViewHandler::~sipwxWebViewHandler()
{
    sipInstanceDestroyedEx(&sipPySelf);
}

 ::wxString sipwxWebViewHandler::GetName() const
{
    sip_gilstate_t sipGILState;
    PyObject *sipMeth;

    sipMeth = sipIsPyMethod(&sipGILState,const_cast<char *>(&sipPyMethods[0]),sipPySelf,SIP_NULLPTR,sipName_GetName);

    if (!sipMeth)
        return  ::wxWebViewHandler::GetName();

    extern  ::wxString sipVH__html2_1(sip_gilstate_t, sipVirtErrorHandlerFunc, sipSimpleWrapper *, PyObject *);

    return sipVH__html2_1(sipGILState, 0, sipPySelf, sipMeth);
}

 ::wxFSFile* sipwxWebViewHandler::GetFile(const  ::wxString& uri)
{
    sip_gilstate_t sipGILState;
    PyObject *sipMeth;

    sipMeth = sipIsPyMethod(&sipGILState,&sipPyMethods[1],sipPySelf,sipName_WebViewHandler,sipName_GetFile);

    if (!sipMeth)
        return 0;

    extern  ::wxFSFile* sipVH__html2_0(sip_gilstate_t, sipVirtErrorHandlerFunc, sipSimpleWrapper *, PyObject *, const  ::wxString&);

    return sipVH__html2_0(sipGILState, 0, sipPySelf, sipMeth, uri);
}


PyDoc_STRVAR(doc_wxWebViewHandler_GetFile, "GetFile(uri) -> wx.FSFile");

extern "C" {static PyObject *meth_wxWebViewHandler_GetFile(PyObject *, PyObject *, PyObject *);}
static PyObject *meth_wxWebViewHandler_GetFile(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
{
    PyObject *sipParseErr = SIP_NULLPTR;
    PyObject *sipOrigSelf = sipSelf;

    {
        const  ::wxString* uri;
        int uriState = 0;
         ::wxWebViewHandler *sipCpp;

        static const char *sipKwdList[] = {
            sipName_uri,
        };

        if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, SIP_NULLPTR, "BJ1", &sipSelf, sipType_wxWebViewHandler, &sipCpp, sipType_wxString,&uri, &uriState))
        {
             ::wxFSFile*sipRes;

            if (!sipOrigSelf)
            {
                sipAbstractMethod(sipName_WebViewHandler, sipName_GetFile);
                return SIP_NULLPTR;
            }

            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
            sipRes = sipCpp->GetFile(*uri);
            Py_END_ALLOW_THREADS
            sipReleaseType(const_cast< ::wxString *>(uri),sipType_wxString,uriState);

            if (PyErr_Occurred())
                return 0;

            return sipConvertFromNewType(sipRes,sipType_wxFSFile,SIP_NULLPTR);
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_WebViewHandler, sipName_GetFile, SIP_NULLPTR);

    return SIP_NULLPTR;
}


PyDoc_STRVAR(doc_wxWebViewHandler_GetName, "GetName() -> String");

extern "C" {static PyObject *meth_wxWebViewHandler_GetName(PyObject *, PyObject *);}
static PyObject *meth_wxWebViewHandler_GetName(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = SIP_NULLPTR;
    bool sipSelfWasArg = (!sipSelf || sipIsDerivedClass((sipSimpleWrapper *)sipSelf));

    {
        const  ::wxWebViewHandler *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_wxWebViewHandler, &sipCpp))
        {
             ::wxString*sipRes;

            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
            sipRes = new  ::wxString((sipSelfWasArg ? sipCpp-> ::wxWebViewHandler::GetName() : sipCpp->GetName()));
            Py_END_ALLOW_THREADS

            if (PyErr_Occurred())
                return 0;

            return sipConvertFromNewType(sipRes,sipType_wxString,SIP_NULLPTR);
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_WebViewHandler, sipName_GetName, SIP_NULLPTR);

    return SIP_NULLPTR;
}


/* Call the instance's destructor. */
extern "C" {static void release_wxWebViewHandler(void *, int);}
static void release_wxWebViewHandler(void *sipCppV, int sipState)
{
    Py_BEGIN_ALLOW_THREADS

    if (sipState & SIP_DERIVED_CLASS)
        delete reinterpret_cast<sipwxWebViewHandler *>(sipCppV);
    else
        delete reinterpret_cast< ::wxWebViewHandler *>(sipCppV);

    Py_END_ALLOW_THREADS
}


extern "C" {static void dealloc_wxWebViewHandler(sipSimpleWrapper *);}
static void dealloc_wxWebViewHandler(sipSimpleWrapper *sipSelf)
{
    if (sipIsDerivedClass(sipSelf))
        reinterpret_cast<sipwxWebViewHandler *>(sipGetAddress(sipSelf))->sipPySelf = SIP_NULLPTR;

    if (sipIsOwnedByPython(sipSelf))
    {
        release_wxWebViewHandler(sipGetAddress(sipSelf), sipIsDerivedClass(sipSelf));
    }
}


extern "C" {static void *init_type_wxWebViewHandler(sipSimpleWrapper *, PyObject *, PyObject *, PyObject **, PyObject **, PyObject **);}
static void *init_type_wxWebViewHandler(sipSimpleWrapper *sipSelf, PyObject *sipArgs, PyObject *sipKwds, PyObject **sipUnused, PyObject **, PyObject **sipParseErr)
{
    sipwxWebViewHandler *sipCpp = SIP_NULLPTR;

    {
        const  ::wxString* scheme;
        int schemeState = 0;

        static const char *sipKwdList[] = {
            sipName_scheme,
        };

        if (sipParseKwdArgs(sipParseErr, sipArgs, sipKwds, sipKwdList, sipUnused, "J1", sipType_wxString,&scheme, &schemeState))
        {
            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
            sipCpp = new sipwxWebViewHandler(*scheme);
            Py_END_ALLOW_THREADS
            sipReleaseType(const_cast< ::wxString *>(scheme),sipType_wxString,schemeState);

            if (PyErr_Occurred())
            {
                delete sipCpp;
                return SIP_NULLPTR;
            }

            sipCpp->sipPySelf = sipSelf;

            return sipCpp;
        }
    }

    {
        const  ::wxWebViewHandler* a0;

        if (sipParseKwdArgs(sipParseErr, sipArgs, sipKwds, SIP_NULLPTR, sipUnused, "J9", sipType_wxWebViewHandler, &a0))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp = new sipwxWebViewHandler(*a0);
            Py_END_ALLOW_THREADS

            sipCpp->sipPySelf = sipSelf;

            return sipCpp;
        }
    }

    return SIP_NULLPTR;
}


static PyMethodDef methods_wxWebViewHandler[] = {
    {SIP_MLNAME_CAST(sipName_GetFile), SIP_MLMETH_CAST(meth_wxWebViewHandler_GetFile), METH_VARARGS|METH_KEYWORDS, SIP_MLDOC_CAST(doc_wxWebViewHandler_GetFile)},
    {SIP_MLNAME_CAST(sipName_GetName), meth_wxWebViewHandler_GetName, METH_VARARGS, SIP_MLDOC_CAST(doc_wxWebViewHandler_GetName)}
};

sipVariableDef variables_wxWebViewHandler[] = {
    {PropertyVariable, sipName_Name, &methods_wxWebViewHandler[1], SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR},
};

PyDoc_STRVAR(doc_wxWebViewHandler, "WebViewHandler(scheme)\n"
"\n"
"The base class for handling custom schemes in wxWebView, for example\n"
"to allow virtual file system support.");


sipClassTypeDef sipTypeDef__html2_wxWebViewHandler = {
    {
        -1,
        SIP_NULLPTR,
        SIP_NULLPTR,
        SIP_TYPE_ABSTRACT|SIP_TYPE_CLASS,
        sipNameNr_wxWebViewHandler,
        {SIP_NULLPTR},
        SIP_NULLPTR
    },
    {
        sipNameNr_WebViewHandler,
        {0, 0, 1},
        2, methods_wxWebViewHandler,
        0, SIP_NULLPTR,
        1, variables_wxWebViewHandler,
        {SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR},
    },
    doc_wxWebViewHandler,
    -1,
    -1,
    SIP_NULLPTR,
    SIP_NULLPTR,
    init_type_wxWebViewHandler,
    SIP_NULLPTR,
    SIP_NULLPTR,
#if PY_MAJOR_VERSION >= 3
    SIP_NULLPTR,
    SIP_NULLPTR,
#else
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
#endif
    dealloc_wxWebViewHandler,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    release_wxWebViewHandler,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR
};
