X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/19a97bd6f98edc899ee0c3b2f2c4fe4ee8a0082b..b9ac87bc5cbe46227195e32c44e25831f8206e3c:/wxPython/contrib/ogl/ogl.cpp diff --git a/wxPython/contrib/ogl/ogl.cpp b/wxPython/contrib/ogl/ogl.cpp index 604a13e63e..cb54c18b03 100644 --- a/wxPython/contrib/ogl/ogl.cpp +++ b/wxPython/contrib/ogl/ogl.cpp @@ -1,15 +1,15 @@ /* * FILE : contrib/ogl/ogl.cpp - * + * * This file was automatically generated by : * Simplified Wrapper and Interface Generator (SWIG) * Version 1.1 (Build 883) - * + * * Portions Copyright (c) 1995-1998 * The University of Utah and The Regents of the University of California. * Permission is granted to distribute this file in any manner provided * this notice remains intact. - * + * * Do not make changes to this file--changes will be lost! * */ @@ -19,6 +19,8 @@ /* Implementation : PYTHON */ #define SWIGPYTHON +#include "Python.h" + #include #include /* Definitions for Windows/Unix exporting */ @@ -36,12 +38,9 @@ # define SWIGEXPORT(a) a #endif -#include "Python.h" - #ifdef __cplusplus extern "C" { #endif - extern void SWIG_MakePtr(char *, void *, char *); extern void SWIG_RegisterMapping(char *, char *, void *(*)(void *)); extern char *SWIG_GetPtr(char *, void **, char *); @@ -55,7 +54,7 @@ extern PyObject *SWIG_newvarlink(void); #define SWIG_name "oglc" -#include "export.h" +#include "wxPython.h" #include "oglhelpers.h" @@ -85,28 +84,22 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) { return target; } -#if PYTHON_API_VERSION >= 1009 - static char* wxStringErrorMsg = "String or Unicode type required"; -#else - static char* wxStringErrorMsg = "string type is required for parameter"; -#endif - //--------------------------------------------------------------------------- // This one will work for any class for the VERY generic cases, but beyond that // the helper needs to know more about the type. wxList* wxPy_wxListHelper(PyObject* pyList, char* className) { - wxPyTState* state = wxPyBeginBlockThreads(); + wxPyBeginBlockThreads(); if (!PyList_Check(pyList)) { PyErr_SetString(PyExc_TypeError, "Expected a list object."); - wxPyEndBlockThreads(state); + wxPyEndBlockThreads(); return NULL; } int count = PyList_Size(pyList); wxList* list = new wxList; if (! list) { PyErr_SetString(PyExc_MemoryError, "Unable to allocate wxList object"); - wxPyEndBlockThreads(state); + wxPyEndBlockThreads(); return NULL; } for (int x=0; xAppend(wxo); } - wxPyEndBlockThreads(state); + wxPyEndBlockThreads(); return list; } //--------------------------------------------------------------------------- wxList* wxPy_wxRealPoint_ListHelper(PyObject* pyList) { - wxPyTState* state = wxPyBeginBlockThreads(); + wxPyBeginBlockThreads(); if (!PyList_Check(pyList)) { PyErr_SetString(PyExc_TypeError, "Expected a list object."); - wxPyEndBlockThreads(state); + wxPyEndBlockThreads(); return NULL; } int count = PyList_Size(pyList); wxList* list = new wxList; if (! list) { PyErr_SetString(PyExc_MemoryError, "Unable to allocate wxList object"); - wxPyEndBlockThreads(state); + wxPyEndBlockThreads(); return NULL; } for (int x=0; xAppend((wxObject*) new wxRealPoint(*wxo)); } } - wxPyEndBlockThreads(state); + wxPyEndBlockThreads(); return list; } +//--------------------------------------------------------------------------- + +PyObject* wxPyMake_wxShapeEvtHandler(wxShapeEvtHandler* source) { + PyObject* target = NULL; + + if (source && wxIsKindOf(source, wxShapeEvtHandler)) { + // If it's derived from wxShapeEvtHandler then there may + // already be a pointer to a Python object that we can use + // in the OOR data. + wxShapeEvtHandler* seh = (wxShapeEvtHandler*)source; + wxPyOORClientData* data = (wxPyOORClientData*)seh->GetClientObject(); + if (data) { + target = data->m_obj; + Py_INCREF(target); + } + } + if (! target) { + target = wxPyMake_wxObject2(source, FALSE); + if (target != Py_None) + ((wxShapeEvtHandler*)source)->SetClientObject(new wxPyOORClientData(target)); + } + return target; +} + +//--------------------------------------------------------------------------- + +PyObject* wxPy_ConvertShapeList(wxListBase* listbase, const char* className) { + wxList* list = (wxList*)listbase; + PyObject* pyList; + PyObject* pyObj; + wxObject* wxObj; + wxNode* node = list->GetFirst(); + + wxPyBeginBlockThreads(); + pyList = PyList_New(0); + while (node) { + wxObj = node->GetData(); + pyObj = wxPyMake_wxShapeEvtHandler((wxShapeEvtHandler*)wxObj); + PyList_Append(pyList, pyObj); + node = node->GetNext(); + } + wxPyEndBlockThreads(); + return pyList; +} + //--------------------------------------------------------------------------- @@ -201,13 +239,14 @@ static PyObject *_wrap_wxOGLInitialize(PyObject *self, PyObject *args, PyObject char *_kwnames[] = { NULL }; self = self; - if(!PyArg_ParseTupleAndKeywords(args,kwargs,":wxOGLInitialize",_kwnames)) + if(!PyArg_ParseTupleAndKeywords(args,kwargs,":wxOGLInitialize",_kwnames)) return NULL; { - wxPy_BEGIN_ALLOW_THREADS; - wxOGLInitialize(); + PyThreadState* __tstate = wxPyBeginAllowThreads(); + wxOGLInitialize(); - wxPy_END_ALLOW_THREADS; + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; } Py_INCREF(Py_None); _resultobj = Py_None; return _resultobj; @@ -218,13 +257,14 @@ static PyObject *_wrap_wxOGLCleanUp(PyObject *self, PyObject *args, PyObject *kw char *_kwnames[] = { NULL }; self = self; - if(!PyArg_ParseTupleAndKeywords(args,kwargs,":wxOGLCleanUp",_kwnames)) + if(!PyArg_ParseTupleAndKeywords(args,kwargs,":wxOGLCleanUp",_kwnames)) return NULL; { - wxPy_BEGIN_ALLOW_THREADS; - wxOGLCleanUp(); + PyThreadState* __tstate = wxPyBeginAllowThreads(); + wxOGLCleanUp(); - wxPy_END_ALLOW_THREADS; + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; } Py_INCREF(Py_None); _resultobj = Py_None; return _resultobj; @@ -346,7 +386,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = { static PyObject *SWIG_globals; #ifdef __cplusplus -extern "C" +extern "C" #endif SWIGEXPORT(void) initoglc() { PyObject *m, *d;