Merge pull request #838 from RobinD42/fix-issue836

Copy MethodDefs for Start and GetNext from base class
This commit is contained in:
Robin Dunn
2018-04-30 22:07:24 -07:00
parent 21fc134bd7
commit 156fece679
3 changed files with 21 additions and 1 deletions

View File

@@ -32,13 +32,16 @@ def run():
# Tweak the parsed meta objects in the module object as needed for
# customizing the generated code and docstrings.
c = module.find('wxTextCompleter')
c = tc = module.find('wxTextCompleter')
assert isinstance(c, etgtools.ClassDef)
c.addPrivateCopyCtor()
c.addDefaultCtor(prot='public')
c = module.find('wxTextCompleterSimple')
c.addDefaultCtor(prot='public')
c.copyFromClass(tc, 'Start')
c.copyFromClass(tc, 'GetNext')
# TODO: Change GetCompletions to return the wxArrayString instead of
# passing it as a parameter?

View File

@@ -16,6 +16,7 @@ import sys
import os
import pprint
import xml.etree.ElementTree as et
import copy
from .tweaker_tools import FixWxPrefix, magicMethods, \
guessTypeInt, guessTypeFloat, guessTypeStr, \
@@ -1106,6 +1107,21 @@ private:
self.mustHaveAppFlag = value
def copyFromClass(self, klass, name):
"""
Copy an item from another class into this class. If it is a pure
virtual method in the other class then assume that it has a concrete
implementation in this class and change the flag.
Returns the new item.
"""
item = copy.deepcopy(klass.find(name))
if isinstance(item, MethodDef) and item.isPureVirtual:
item.isPureVirtual = False
self.addItem(item)
return item
#---------------------------------------------------------------------------
class EnumDef(BaseDef):

View File

@@ -22,6 +22,7 @@ class testcompleter_Tests(wtc.WidgetTestCase):
t = wx.TextCtrl(self.frame)
t.AutoComplete(MyTextCompleter())
def test_textCompleterSimple(self):
class MyTextCompleterSimple(wx.TextCompleterSimple):
def __init__(self):