Massive code changes and cleanup to allow wxPython to be split into
multiple extension modules again. A Python CObject is used to allow the "export" of SWIG and other common helper functions from the wxc module to other modules, even if they are in separate shared libraries. Should also be usable from 3rd party code, just include wxPython/src/export.h Changed the default setup so the following are built as separate extension modules: calendar, glcanvas, grid, html, ogl, stc, and utils. Will probably add more later. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8984 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -55,7 +55,7 @@ extern PyObject *SWIG_newvarlink(void);
|
||||
|
||||
#define SWIG_name "oglc"
|
||||
|
||||
#include "helpers.h"
|
||||
#include "export.h"
|
||||
#include "oglhelpers.h"
|
||||
|
||||
static PyObject* l_output_helper(PyObject* target, PyObject* o) {
|
||||
@@ -106,6 +106,87 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) {
|
||||
|
||||
static char* wxStringErrorMsg = "string type is required for parameter";
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// 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) {
|
||||
bool doSave = wxPyRestoreThread();
|
||||
if (!PyList_Check(pyList)) {
|
||||
PyErr_SetString(PyExc_TypeError, "Expected a list object.");
|
||||
wxPySaveThread(doSave);
|
||||
return NULL;
|
||||
}
|
||||
int count = PyList_Size(pyList);
|
||||
wxList* list = new wxList;
|
||||
if (! list) {
|
||||
PyErr_SetString(PyExc_MemoryError, "Unable to allocate wxList object");
|
||||
wxPySaveThread(doSave);
|
||||
return NULL;
|
||||
}
|
||||
for (int x=0; x<count; x++) {
|
||||
PyObject* pyo = PyList_GetItem(pyList, x);
|
||||
wxObject* wxo = NULL;
|
||||
|
||||
if (SWIG_GetPtrObj(pyo, (void **)&wxo, className)) {
|
||||
char errmsg[1024];
|
||||
sprintf(errmsg, "Type error, expected list of %s objects", className);
|
||||
PyErr_SetString(PyExc_TypeError, errmsg);
|
||||
wxPySaveThread(doSave);
|
||||
return NULL;
|
||||
}
|
||||
list->Append(wxo);
|
||||
}
|
||||
wxPySaveThread(doSave);
|
||||
return list;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
wxList* wxPy_wxRealPoint_ListHelper(PyObject* pyList) {
|
||||
bool doSave = wxPyRestoreThread();
|
||||
if (!PyList_Check(pyList)) {
|
||||
PyErr_SetString(PyExc_TypeError, "Expected a list object.");
|
||||
wxPySaveThread(doSave);
|
||||
return NULL;
|
||||
}
|
||||
int count = PyList_Size(pyList);
|
||||
wxList* list = new wxList;
|
||||
if (! list) {
|
||||
PyErr_SetString(PyExc_MemoryError, "Unable to allocate wxList object");
|
||||
wxPySaveThread(doSave);
|
||||
return NULL;
|
||||
}
|
||||
for (int x=0; x<count; x++) {
|
||||
PyObject* pyo = PyList_GetItem(pyList, x);
|
||||
|
||||
if (PyTuple_Check(pyo)) {
|
||||
PyObject* o1 = PyNumber_Float(PyTuple_GetItem(pyo, 0));
|
||||
PyObject* o2 = PyNumber_Float(PyTuple_GetItem(pyo, 1));
|
||||
|
||||
double val1 = (o1 ? PyFloat_AsDouble(o1) : 0.0);
|
||||
double val2 = (o2 ? PyFloat_AsDouble(o2) : 0.0);
|
||||
|
||||
list->Append((wxObject*) new wxRealPoint(val1, val2));
|
||||
|
||||
} else {
|
||||
wxRealPoint* wxo = NULL;
|
||||
if (SWIG_GetPtrObj(pyo, (void **)&wxo, "_wxRealPoint_p")) {
|
||||
PyErr_SetString(PyExc_TypeError, "Type error, expected list of wxRealPoint objects or 2-tuples");
|
||||
wxPySaveThread(doSave);
|
||||
return NULL;
|
||||
}
|
||||
list->Append((wxObject*) new wxRealPoint(*wxo));
|
||||
}
|
||||
}
|
||||
wxPySaveThread(doSave);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
extern "C" SWIGEXPORT(void) initoglbasicc();
|
||||
extern "C" SWIGEXPORT(void) initoglshapesc();
|
||||
extern "C" SWIGEXPORT(void) initoglshapes2c();
|
||||
@@ -268,6 +349,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
|
||||
{ "_class_wxRealPoint","_wxRealPoint",0},
|
||||
{ "_wxNavigationKeyEvent","_class_wxNavigationKeyEvent",0},
|
||||
{ "_wxPNMHandler","_class_wxPNMHandler",0},
|
||||
{ "_wxPrinterDC","_class_wxPrinterDC",0},
|
||||
{ "_wxWindowCreateEvent","_class_wxWindowCreateEvent",0},
|
||||
{ "_wxLogGui","_class_wxLogGui",0},
|
||||
{ "_class_wxPyShapeEvtHandler","_wxPyShapeEvtHandler",0},
|
||||
@@ -279,7 +361,6 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
|
||||
{ "_class_wxPySizer","_wxPySizer",0},
|
||||
{ "_class_wxPyCompositeShape","_wxPyCompositeShape",0},
|
||||
{ "_wxPyPolygonShape","_class_wxPyPolygonShape",0},
|
||||
{ "_class_wxPostScriptDC","_wxPostScriptDC",0},
|
||||
{ "_wxPanel","_class_wxPanel",0},
|
||||
{ "_wxInitDialogEvent","_class_wxInitDialogEvent",0},
|
||||
{ "_wxCheckBox","_class_wxCheckBox",0},
|
||||
@@ -345,6 +426,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
|
||||
{ "_class_wxZipFSHandler","_wxZipFSHandler",0},
|
||||
{ "_char","_wxChar",0},
|
||||
{ "_wxBitmap","_class_wxBitmap",0},
|
||||
{ "_wxTaskBarIcon","_class_wxTaskBarIcon",0},
|
||||
{ "_wxPrintDialog","_class_wxPrintDialog",0},
|
||||
{ "_wxPyControlPoint","_class_wxPyControlPoint",0},
|
||||
{ "_wxWindowDC","_class_wxWindowDC",0},
|
||||
@@ -436,6 +518,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
|
||||
{ "_class_wxTextCtrl","_wxTextCtrl",0},
|
||||
{ "_class_wxListItemAttr","_wxListItemAttr",0},
|
||||
{ "_wxLayoutConstraints","_class_wxLayoutConstraints",0},
|
||||
{ "_wxMetaFileDC","_class_wxMetaFileDC",0},
|
||||
{ "_class_wxTextDataObject","_wxTextDataObject",0},
|
||||
{ "_wxMenu","_class_wxMenu",0},
|
||||
{ "_class_wxMoveEvent","_wxMoveEvent",0},
|
||||
@@ -489,6 +572,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
|
||||
{ "_signed_short","_short",0},
|
||||
{ "_wxMemoryDC","_class_wxMemoryDC",0},
|
||||
{ "_wxPyTextDataObject","_class_wxPyTextDataObject",0},
|
||||
{ "_class_wxTaskBarIcon","_wxTaskBarIcon",0},
|
||||
{ "_class_wxPrintDialog","_wxPrintDialog",0},
|
||||
{ "_wxPyFileSystemHandler","_class_wxPyFileSystemHandler",0},
|
||||
{ "_class_wxPyControlPoint","_wxPyControlPoint",0},
|
||||
@@ -499,7 +583,6 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
|
||||
{ "_wxStatusBar","_class_wxStatusBar",0},
|
||||
{ "_class_wxAcceleratorEntry","_wxAcceleratorEntry",0},
|
||||
{ "_class_wxCursor","_wxCursor",0},
|
||||
{ "_wxPostScriptDC","_class_wxPostScriptDC",0},
|
||||
{ "_wxPyFileDropTarget","_class_wxPyFileDropTarget",0},
|
||||
{ "_class_wxPyProcess","_wxPyProcess",0},
|
||||
{ "_class_wxImageHandler","_wxImageHandler",0},
|
||||
@@ -508,6 +591,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
|
||||
{ "_class_wxLog","_wxLog",0},
|
||||
{ "_wxTreeItemId","_class_wxTreeItemId",0},
|
||||
{ "_unsigned_char","_byte",0},
|
||||
{ "_class_wxMetaFileDC","_wxMetaFileDC",0},
|
||||
{ "_class_wxMenu","_wxMenu",0},
|
||||
{ "_wxControl","_class_wxControl",0},
|
||||
{ "_class_wxListBox","_wxListBox",0},
|
||||
@@ -595,6 +679,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
|
||||
{ "_class_wxPyApp","_wxPyApp",0},
|
||||
{ "_wxSize","_class_wxSize",0},
|
||||
{ "_wxRegionIterator","_class_wxRegionIterator",0},
|
||||
{ "_class_wxPrinterDC","_wxPrinterDC",0},
|
||||
{ "_class_wxPyTextDataObject","_wxPyTextDataObject",0},
|
||||
{ "_class_wxLogTextCtrl","_wxLogTextCtrl",0},
|
||||
{ "_class_wxLogGui","_wxLogGui",0},
|
||||
@@ -790,8 +875,8 @@ SWIGEXPORT(void) initoglc() {
|
||||
initoglcanvasc();
|
||||
|
||||
|
||||
wxClassInfo::CleanUpClasses();
|
||||
wxClassInfo::InitializeClasses();
|
||||
// wxClassInfo::CleanUpClasses();
|
||||
// wxClassInfo::InitializeClasses();
|
||||
|
||||
{
|
||||
int i;
|
||||
|
Reference in New Issue
Block a user