Move the ConvertToSubClas code to a tool function so it can be reused elsewhere.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71409 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2012-05-10 22:39:18 +00:00
parent ec06cdb967
commit 2bd3ad68b6
3 changed files with 24 additions and 18 deletions

View File

@@ -81,24 +81,8 @@ def run():
doc='Deletes the C++ object this Python object is a proxy for.',
transferThis=True) # TODO: Check this
# Teach SIP how to convert to specific class types
c.addItem(etgtools.WigCode("""\
%ConvertToSubClassCode
const wxClassInfo* info = sipCpp->GetClassInfo();
wxString name = info->GetClassName();
bool exists = sipFindType(name) != NULL;
while (info && !exists) {
info = info->GetBaseClass1();
name = info->GetClassName();
exists = sipFindType(name) != NULL;
}
if (info)
sipType = sipFindType(name);
else
sipType = NULL;
%End
"""))
tools.addSipConvertToSubClassCode(c)
#-----------------------------------------------------------------
tools.doCommonTweaks(module)

View File

@@ -249,6 +249,7 @@ def run():
##c.addProperty('GtkWidget GetGtkWidget')
tools.fixWindowClass(c)
tools.addSipConvertToSubClassCode(c)
# for compatibility with Classic
c.addPyMethod('GetPositionTuple', '(self)', 'return self.GetPosition()', deprecated=True)

View File

@@ -275,6 +275,27 @@ def addWindowVirtuals(klass):
klass.addItem(extractors.WigCode(txt))
klass.addPublic()
def addSipConvertToSubClassCode(klass):
"""
Teach SIP how to convert to specific subclass types
"""
klass.addItem(extractors.WigCode("""\
%ConvertToSubClassCode
const wxClassInfo* info = sipCpp->GetClassInfo();
wxString name = info->GetClassName();
bool exists = sipFindType(name) != NULL;
while (info && !exists) {
info = info->GetBaseClass1();
name = info->GetClassName();
exists = sipFindType(name) != NULL;
}
if (info)
sipType = sipFindType(name);
else
sipType = NULL;
%End
"""))
def getEtgFiles(names):