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

#include "sipAPI_glcanvas.h"

        #include <wx/glcanvas.h>

        #include <wx/glcanvas.h>
        #include <wx/object.h>
        #include <wx/object.h>
        #include <wx/object.h>


class sipwxGLContext : public  ::wxGLContext
{
public:
    sipwxGLContext( ::wxGLCanvas*,const  ::wxGLContext*);
    virtual ~sipwxGLContext();

    /*
     * There is a protected method for every virtual method visible from
     * this class.
     */
protected:
    bool SetCurrent(const  ::wxGLCanvas&) const SIP_OVERRIDE;

public:
    sipSimpleWrapper *sipPySelf;

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

    char sipPyMethods[1];
};

sipwxGLContext::sipwxGLContext( ::wxGLCanvas*win,const  ::wxGLContext*other):  ::wxGLContext(win,other), sipPySelf(SIP_NULLPTR)
{
    memset(sipPyMethods, 0, sizeof (sipPyMethods));
}

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

bool sipwxGLContext::SetCurrent(const  ::wxGLCanvas& win) const
{
    sip_gilstate_t sipGILState;
    PyObject *sipMeth;

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

    if (!sipMeth)
        return  ::wxGLContext::SetCurrent(win);

    extern bool sipVH__glcanvas_0(sip_gilstate_t, sipVirtErrorHandlerFunc, sipSimpleWrapper *, PyObject *, const  ::wxGLCanvas&);

    return sipVH__glcanvas_0(sipGILState, 0, sipPySelf, sipMeth, win);
}


PyDoc_STRVAR(doc_wxGLContext_SetCurrent, "SetCurrent(win) -> bool\n"
"\n"
"Makes the OpenGL state that is represented by this rendering context\n"
"current with the wxGLCanvas win.");

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

    {
        const  ::wxGLCanvas* win;
        const  ::wxGLContext *sipCpp;

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

        if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, SIP_NULLPTR, "BJ9", &sipSelf, sipType_wxGLContext, &sipCpp, sipType_wxGLCanvas, &win))
        {
            bool sipRes;

            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
            sipRes = (sipSelfWasArg ? sipCpp-> ::wxGLContext::SetCurrent(*win) : sipCpp->SetCurrent(*win));
            Py_END_ALLOW_THREADS

            if (PyErr_Occurred())
                return 0;

            return PyBool_FromLong(sipRes);
        }
    }

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

    return SIP_NULLPTR;
}


/* Cast a pointer to a type somewhere in its inheritance hierarchy. */
extern "C" {static void *cast_wxGLContext(void *, const sipTypeDef *);}
static void *cast_wxGLContext(void *sipCppV, const sipTypeDef *targetType)
{
     ::wxGLContext *sipCpp = reinterpret_cast< ::wxGLContext *>(sipCppV);

    if (targetType == sipType_wxObject)
        return static_cast< ::wxObject *>(sipCpp);

    return sipCppV;
}


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

    if (sipState & SIP_DERIVED_CLASS)
        delete reinterpret_cast<sipwxGLContext *>(sipCppV);
    else
        delete reinterpret_cast< ::wxGLContext *>(sipCppV);

    Py_END_ALLOW_THREADS
}


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

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


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

    {
         ::wxGLCanvas* win;
        const  ::wxGLContext* other = 0;

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

        if (sipParseKwdArgs(sipParseErr, sipArgs, sipKwds, sipKwdList, sipUnused, "J8|J8", sipType_wxGLCanvas, &win, sipType_wxGLContext, &other))
        {

        if (!wxPyCheckForApp()) return NULL;

            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
            sipCpp = new sipwxGLContext(win,other);
            Py_END_ALLOW_THREADS

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

            sipCpp->sipPySelf = sipSelf;

            return sipCpp;
        }
    }

    return SIP_NULLPTR;
}


/* Define this type's super-types. */
static sipEncodedTypeDef supers_wxGLContext[] = {{4, 0, 1}};


static PyMethodDef methods_wxGLContext[] = {
    {SIP_MLNAME_CAST(sipName_SetCurrent), SIP_MLMETH_CAST(meth_wxGLContext_SetCurrent), METH_VARARGS|METH_KEYWORDS, SIP_MLDOC_CAST(doc_wxGLContext_SetCurrent)}
};

PyDoc_STRVAR(doc_wxGLContext, "GLContext(win, other=None)\n"
"\n"
"An instance of a wxGLContext represents the state of an OpenGL state\n"
"machine and the connection between OpenGL and the system.");


sipClassTypeDef sipTypeDef__glcanvas_wxGLContext = {
    {
        -1,
        SIP_NULLPTR,
        SIP_NULLPTR,
        SIP_TYPE_SCC|SIP_TYPE_CLASS,
        sipNameNr_wxGLContext,
        {SIP_NULLPTR},
        SIP_NULLPTR
    },
    {
        sipNameNr_GLContext,
        {0, 0, 1},
        1, methods_wxGLContext,
        0, SIP_NULLPTR,
        0, SIP_NULLPTR,
        {SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR},
    },
    doc_wxGLContext,
    -1,
    -1,
    supers_wxGLContext,
    SIP_NULLPTR,
    init_type_wxGLContext,
    SIP_NULLPTR,
    SIP_NULLPTR,
#if PY_MAJOR_VERSION >= 3
    SIP_NULLPTR,
    SIP_NULLPTR,
#else
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
#endif
    dealloc_wxGLContext,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    release_wxGLContext,
    cast_wxGLContext,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR
};
