From 20ddc3ae90e07fcb3a6d82f1bbe52a54ff4edadd Mon Sep 17 00:00:00 2001 From: Devaraj Ranganna Date: Wed, 13 Nov 2019 10:10:19 +0000 Subject: [PATCH] Improve multiple inheritance support Current algorithm doesn't support multiple inheritance when inheritance depth is more than 1 on two parents. It'll not parse the "_add" or "_remove" attributes on a second parent which is at the same level as that of a parent that defines the attribute. This change ensures that second parent which is at the same level as that of a parent that defines the attribute is parsed for "_add" or "_remove" attributes. However, this change will parse the parent which defines the attributes twice, once to evaluate the attribute and then to evaluate the "_add" or "_remove" attribute. But, no target is allowed to define an attribute and also "_add" or "_remove" for the same attribute. Signed-off-by: Devaraj Ranganna --- tools/targets/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/targets/__init__.py b/tools/targets/__init__.py index 66dd070951..5836c63fbe 100644 --- a/tools/targets/__init__.py +++ b/tools/targets/__init__.py @@ -292,7 +292,10 @@ class Target(namedtuple( # inheritance level, left to right order to figure out all the # other classes that change the definition by adding or removing # elements - for idx in range(self.resolution_order[def_idx][1] - 1, -1, -1): + highest_order = 0 + for t in self.resolution_order: + highest_order = highest_order if highest_order > t[1] else t[1] + for idx in range(highest_order - 1, -1, -1): same_level_targets = [tar[0] for tar in self.resolution_order if tar[1] == idx] for tar in same_level_targets: