Changes to how overridable C++ methods are virtualized for Python.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37369 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2006-02-07 03:56:44 +00:00
parent e4c37d10dd
commit a7a0141800
25 changed files with 890 additions and 766 deletions

View File

@@ -25,6 +25,59 @@ wx.EventLoop is now implemented for wxMac.
Added wxPython wrappers for the new wx.Treebook and wx.Toolbook
classes.
Solved a problem that has been around for a very long time in how C++
methods are virtualized for overriding in derived Python classes.
Previously we couldn't do it for methods that needed to exist in the
base class wrappers such that they could be called normally. (The
reasons are long and complex, but suffice it to say that it was due to
mixing C++'s dynamic dispatch, and Python's runtime lookup of the
method attributes resulting in endless recursion of function calls.)
Because of this problem I used a hack that I have always hated, and
that is renaming the base class methods with a "base_" prefix, for
example wx.Printout.base_OnBeginDocument. Now that the problem has
finally been solved I have replaced all the base_Whatever() methods
with the real Whatever() method as well as a simple wrapper named
base_Whatever that is marked as deprecated. So now instead of writing
your overridden methods like this:
def OnBeginDocument(self, start, end):
# do something here
return self.base_OnBeginDocument(start, end)
You can do it the *right way* like this:
def OnBeginDocument(self, start, end):
# do something here
return super(MyPrintout, self).OnBeginDocument(start, end)
Note that the old way still works, but you will get a
DeprecationWarning from calling base_OnBeginDocument. The classes
affected by this are:
* wx.DropSource
* wx.DropTarget
* wx.TextDropTarget
* wx.FileDropTarget
* wx.PyLog (also added the ability to override Flush)
* wx.PyApp (also added the ability to override ExitMainLoop)
* wx.Printout
* wx.PyPrintPreview
* wx.PyPreviewFrame
* wx.PreviewControlBar
* wx.Process
* wx.PyControl
* wx.PyPanel
* wx.PyScrolledWindow
* wx.PyWindow
* wx.Timer
* wx.grid.PyGridCellRenderer
* wx.grid.PyGridCellEditor
* wx.grid.PyGridCellAttrProvider
* wx.grid.PyGridTableBase
* wx.html.HtmlWindow
* wx.wizard.PyWizardPage