diff --git a/etg/textcompleter.py b/etg/textcompleter.py index 38210206..8f190e17 100644 --- a/etg/textcompleter.py +++ b/etg/textcompleter.py @@ -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? diff --git a/etgtools/extractors.py b/etgtools/extractors.py index 02306581..acfb8392 100644 --- a/etgtools/extractors.py +++ b/etgtools/extractors.py @@ -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): diff --git a/unittests/test_textcompleter.py b/unittests/test_textcompleter.py index bd7e7844..eca337c9 100644 --- a/unittests/test_textcompleter.py +++ b/unittests/test_textcompleter.py @@ -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):