From 78ddc567f9fb371c16c81ba271ac880f96791e7d Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Fri, 5 Jun 2015 12:41:23 +0300 Subject: [PATCH] Python generator: moved base class handling to the generate step --- modules/python/src2/gen2.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/modules/python/src2/gen2.py b/modules/python/src2/gen2.py index 1648e53abe..20c5c812cc 100755 --- a/modules/python/src2/gen2.py +++ b/modules/python/src2/gen2.py @@ -757,19 +757,6 @@ class PythonWrapperGenerator(object): sys.exit(-1) self.classes[classinfo.name] = classinfo - if classinfo.base: - chunks = classinfo.base.split('_') - base = '_'.join(chunks) - while base not in self.classes and len(chunks)>1: - del chunks[-2] - base = '_'.join(chunks) - if base not in self.classes: - print("Generator error: unable to resolve base %s for %s" - % (classinfo.base, classinfo.name)) - sys.exit(-1) - classinfo.base = base - classinfo.isalgorithm |= self.classes[base].isalgorithm - def split_decl_name(self, name): chunks = name.split('.') namespace = chunks[:-1] @@ -881,6 +868,22 @@ class PythonWrapperGenerator(object): # function self.add_func(decl) + # step 1.5 check if all base classes exist + for name, classinfo in self.classes.items(): + if classinfo.base: + chunks = classinfo.base.split('_') + base = '_'.join(chunks) + while base not in self.classes and len(chunks)>1: + del chunks[-2] + base = '_'.join(chunks) + if base not in self.classes: + print("Generator error: unable to resolve base %s for %s" + % (classinfo.base, classinfo.name)) + sys.exit(-1) + classinfo.base = base + classinfo.isalgorithm |= self.classes[base].isalgorithm + self.classes[name] = classinfo + # step 2: generate code for the classes and their methods classlist = list(self.classes.items()) classlist.sort()