Since the wxPyMake_wxObject typemap is also used for constructors we

need to allow it to use the $owner value to specify if the thisown
attribute shoudl be set to true.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28110 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2004-06-30 20:12:14 +00:00
parent 488256e0a1
commit 6d450e1a20
11 changed files with 111 additions and 115 deletions

View File

@@ -550,8 +550,8 @@ public:
bool found; \
bool blocked = wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* win = wxPyMake_wxObject(a); \
PyObject* dc = wxPyMake_wxObject(&b); \
PyObject* win = wxPyMake_wxObject(a,false); \
PyObject* dc = wxPyMake_wxObject(&b,false); \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
Py_DECREF(win); \
Py_DECREF(dc); \

View File

@@ -32,7 +32,7 @@ struct wxVisualAttributes
%extend {
wxVisualAttributes() { return new wxVisualAttributes; }
~wxVisualAttributes() { delete self; }
}
}
// the font used for control label/text inside it
wxFont font;
@@ -1302,7 +1302,7 @@ themes represent the appearance chosen by the user to be used for all
applications on the system.", "");
DocDeclStr(
void , SetOwnBackroundColour(const wxColour& colour),
void , SetOwnBackgroundColour(const wxColour& colour),
"", "");

View File

@@ -45,17 +45,17 @@ MAKE_CONST_WXSTRING2(DateTimeFormatStr, wxT("%c"));
//---------------------------------------------------------------------------
// OOR related typemaps and helper functions
%typemap(out) wxGridCellRenderer* { $result = wxPyMake_wxGridCellRenderer($1); }
%typemap(out) wxGridCellEditor* { $result = wxPyMake_wxGridCellEditor($1); }
%typemap(out) wxGridCellAttr* { $result = wxPyMake_wxGridCellAttr($1); }
%typemap(out) wxGridCellAttrProvider* { $result = wxPyMake_wxGridCellAttrProvider($1); }
%typemap(out) wxGridTableBase* { $result = wxPyMake_wxGridTableBase($1); }
%typemap(out) wxGridCellRenderer* { $result = wxPyMake_wxGridCellRenderer($1, $owner); }
%typemap(out) wxGridCellEditor* { $result = wxPyMake_wxGridCellEditor($1, $owner); }
%typemap(out) wxGridCellAttr* { $result = wxPyMake_wxGridCellAttr($1, $owner); }
%typemap(out) wxGridCellAttrProvider* { $result = wxPyMake_wxGridCellAttrProvider($1, $owner); }
%typemap(out) wxGridTableBase* { $result = wxPyMake_wxGridTableBase($1, $owner); }
%{
#define wxPyMake_TEMPLATE(TYPE) \
PyObject* wxPyMake_##TYPE(TYPE* source) { \
PyObject* wxPyMake_##TYPE(TYPE* source, bool setThisOwn) { \
PyObject* target = NULL; \
if (source) { \
/* Check if there is already a pointer to a Python object in the \
@@ -68,7 +68,7 @@ PyObject* wxPyMake_##TYPE(TYPE* source) { \
/* Otherwise make a new wrapper for it the old fashioned way and \
give it the OOR treatment */ \
if (! target) { \
target = wxPyConstructObject(source, wxT(#TYPE), False); \
target = wxPyConstructObject(source, wxT(#TYPE), setThisOwn); \
if (target) \
source->SetClientObject(new wxPyOORClientData(target)); \
} \
@@ -126,7 +126,7 @@ wxPyMake_TEMPLATE(wxGridTableBase)
bool blocked = wxPyBeginBlockThreads(); \
bool found; \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* obj = wxPyMake_wxGridCellAttr(attr); \
PyObject* obj = wxPyMake_wxGridCellAttr(attr,false); \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oii)", obj, a, b)); \
Py_DECREF(obj); \
} \
@@ -145,7 +145,7 @@ wxPyMake_TEMPLATE(wxGridTableBase)
bool blocked = wxPyBeginBlockThreads(); \
bool found; \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* obj = wxPyMake_wxGridCellAttr(attr); \
PyObject* obj = wxPyMake_wxGridCellAttr(attr,false); \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, val)); \
Py_DECREF(obj); \
} \
@@ -566,9 +566,9 @@ public:
int row, int col, bool isSelected) {
bool blocked = wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "Draw")) {
PyObject* go = wxPyMake_wxObject(&grid);
PyObject* dco = wxPyMake_wxObject(&dc);
PyObject* ao = wxPyMake_wxGridCellAttr(&attr);
PyObject* go = wxPyMake_wxObject(&grid,false);
PyObject* dco = wxPyMake_wxObject(&dc,false);
PyObject* ao = wxPyMake_wxGridCellAttr(&attr,false);
PyObject* ro = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOOiii)", go, ao, dco, ro,
@@ -588,9 +588,9 @@ public:
if (wxPyCBH_findCallback(m_myInst, "GetBestSize")) {
PyObject* ro;
wxSize* ptr;
PyObject* go = wxPyMake_wxObject(&grid);
PyObject* dco = wxPyMake_wxObject(&dc);
PyObject* ao = wxPyMake_wxGridCellAttr(&attr);
PyObject* go = wxPyMake_wxObject(&grid,false);
PyObject* dco = wxPyMake_wxObject(&dc,false);
PyObject* ao = wxPyMake_wxGridCellAttr(&attr,false);
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOOii)",
go, ao, dco,
@@ -782,8 +782,8 @@ public:
void Create(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler) {
bool blocked = wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "Create")) {
PyObject* po = wxPyMake_wxObject(parent);
PyObject* eo = wxPyMake_wxObject(evtHandler);
PyObject* po = wxPyMake_wxObject(parent,false);
PyObject* eo = wxPyMake_wxObject(evtHandler,false);
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiO)", po, id, eo));
Py_DECREF(po);
@@ -796,7 +796,7 @@ public:
void BeginEdit(int row, int col, wxGrid* grid) {
bool blocked = wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "BeginEdit")) {
PyObject* go = wxPyMake_wxObject(grid);
PyObject* go = wxPyMake_wxObject(grid,false);
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)", row, col, go));
Py_DECREF(go);
}
@@ -808,7 +808,7 @@ public:
bool rv = False;
bool blocked = wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "EndEdit")) {
PyObject* go = wxPyMake_wxObject(grid);
PyObject* go = wxPyMake_wxObject(grid,false);
rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)", row, col, go));
Py_DECREF(go);
}
@@ -839,7 +839,7 @@ public:
bool found;
bool blocked = wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "Show"))) {
PyObject* ao = wxPyMake_wxGridCellAttr(attr);
PyObject* ao = wxPyMake_wxGridCellAttr(attr,false);
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iO)", show, ao));
Py_DECREF(ao);
}
@@ -856,7 +856,7 @@ public:
bool found;
bool blocked = wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "PaintBackground)"))) {
PyObject* ao = wxPyMake_wxGridCellAttr(attr);
PyObject* ao = wxPyMake_wxGridCellAttr(attr,false);
PyObject* ro = wxPyConstructObject((void*)&rectCell, wxT("wxRect"), 0);
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", ro, ao));

View File

@@ -953,7 +953,7 @@ void wxPyPtrTypeMap_Add(const char* commonName, const char* ptrName) {
PyObject* wxPyMake_wxObject(wxObject* source, bool checkEvtHandler) {
PyObject* wxPyMake_wxObject(wxObject* source, bool setThisOwn, bool checkEvtHandler) {
PyObject* target = NULL;
bool isEvtHandler = False;
@@ -986,7 +986,7 @@ PyObject* wxPyMake_wxObject(wxObject* source, bool checkEvtHandler) {
exists = wxPyCheckSwigType(name);
}
if (info) {
target = wxPyConstructObject((void*)source, name, False);
target = wxPyConstructObject((void*)source, name, setThisOwn);
if (target && isEvtHandler)
((wxEvtHandler*)source)->SetClientObject(new wxPyOORClientData(target));
} else {
@@ -1003,7 +1003,7 @@ PyObject* wxPyMake_wxObject(wxObject* source, bool checkEvtHandler) {
}
PyObject* wxPyMake_wxSizer(wxSizer* source) {
PyObject* wxPyMake_wxSizer(wxSizer* source, bool setThisOwn) {
PyObject* target = NULL;
if (source && wxIsKindOf(source, wxSizer)) {
@@ -1018,7 +1018,7 @@ PyObject* wxPyMake_wxSizer(wxSizer* source) {
}
}
if (! target) {
target = wxPyMake_wxObject(source, False);
target = wxPyMake_wxObject(source, setThisOwn, False);
if (target != Py_None)
((wxSizer*)source)->SetClientObject(new wxPyOORClientData(target));
}
@@ -1841,7 +1841,7 @@ PyObject* wxPy_ConvertList(wxListBase* listbase) {
pyList = PyList_New(0);
while (node) {
wxObj = node->GetData();
pyObj = wxPyMake_wxObject(wxObj);
pyObj = wxPyMake_wxObject(wxObj,false);
PyList_Append(pyList, pyObj);
node = node->GetNext();
}

View File

@@ -636,7 +636,7 @@ public:
bool found;
bool blocked = wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "CanRead"))) {
PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file,false); // cast away const
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));
Py_DECREF(obj);
}
@@ -652,7 +652,7 @@ public:
bool found;
bool blocked = wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "ReadFile"))) {
PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file); // cast away const
PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file,false); // cast away const
PyObject* ro;
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj));
Py_DECREF(obj);

View File

@@ -247,7 +247,7 @@
// Typemaps to convert an array of ints to a list for return values
// Typemaps to convert an array of strings to a list for return values
%typemap(out) wxArrayString& {
$result = wxArrayString2PyList_helper(*$1);
}
@@ -340,58 +340,54 @@ SWIG_AsDouble(PyObject *obj)
// to the real derived type, if possible. See wxPyMake_wxObject in
// helpers.cpp
%typemap(out) wxEvtHandler* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxMenu* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxValidator* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxEvtHandler* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxMenu* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxValidator* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxApp* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxPyApp* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxDC* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxFSFile* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxFileSystem* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxGridTableBase* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxImageList* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxListItem* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxMenuItem* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxMouseEvent* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxObject* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxPyPrintout* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxToolBarToolBase* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxToolTip* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxApp* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxPyApp* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxDC* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxFSFile* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxFileSystem* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxGridTableBase* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxImageList* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxListItem* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxMenuItem* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxMouseEvent* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxObject* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxPyPrintout* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxToolBarToolBase* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxToolTip* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxBitmapButton* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxButton* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxControl* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxFrame* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxGrid* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxListCtrl* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxMDIChildFrame* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxMDIClientWindow* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxMenuBar* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxNotebook* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxStaticBox* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxStatusBar* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxTextCtrl* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxToolBar* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxToolBarBase* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxTreeCtrl* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxPyTreeCtrl* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxWindow* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxHtmlWindow* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxPyHtmlWindow* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxWizardPage* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxPanel* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxDialog* { $result = wxPyMake_wxObject($1); }
%typemap(out) wxBitmapButton* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxButton* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxControl* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxFrame* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxGrid* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxListCtrl* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxMDIChildFrame* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxMDIClientWindow* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxMenuBar* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxNotebook* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxStaticBox* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxStatusBar* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxTextCtrl* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxToolBar* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxToolBarBase* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxTreeCtrl* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxPyTreeCtrl* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxWindow* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxHtmlWindow* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxPyHtmlWindow* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxWizardPage* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxPanel* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxScrolledWindow* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxSizer* { $result = wxPyMake_wxSizer($1); }
%typemap(out) wxSizer* { $result = wxPyMake_wxSizer($1, $owner); }
//%typemap(python, out) wxHtmlCell* { $target = wxPyMake_wxObject($source); }
//%typemap(python, out) wxHtmlContainerCell* { $target = wxPyMake_wxObject($source); }
//%typemap(python, out) wxHtmlParser* { $target = wxPyMake_wxObject($source); }
//%typemap(python, out) wxHtmlWinParser* { $target = wxPyMake_wxObject($source); }
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------