diff options
author | 2020-09-09 21:29:45 +1000 | |
---|---|---|
committer | 2020-09-09 21:29:45 +1000 | |
commit | b2158bd6ed6d7bb1ed0e7cf665b04f56ecbe3403 (patch) | |
tree | f65e54627e2836bcdccfaa12516fa23ed7e1fcfe /scripts/build/complay.py | |
parent | 7f0a34d52d7914ff0fd0100f283a22eb7baf176c (diff) |
-Eliminate remaining <bezel> elements from internal layouts.
These layouts have changes to element stacking order that can't be
avoided without changing the group structure in the layout files. I
think it's harmless, but it's possible it could have had a detrimental
effect on risc2500 (I tested it and didn't see any changes, but I might
not have known what to look for).
-complay.py: Added basic checks for dupicate collection names.
As with other checks of this kind, it doesn't actually instantiate the
layout so it doesn't check things when variable substitution is
involved.
Diffstat (limited to 'scripts/build/complay.py')
-rwxr-xr-x | scripts/build/complay.py | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/scripts/build/complay.py b/scripts/build/complay.py index 5dfee05e018..9b3334d96c2 100755 --- a/scripts/build/complay.py +++ b/scripts/build/complay.py @@ -97,7 +97,7 @@ class LayoutChecker(Minifyer): VARPATTERN = re.compile('^.*~[0-9A-Za-z_]+~.*$') FLOATCHARS = re.compile('^.*[.eE].*$') SHAPES = frozenset(('disk', 'dotmatrix', 'dotmatrix5dot', 'dotmatrixdot', 'led14seg', 'led14segsc', 'led16seg', 'led16segsc', 'led7seg', 'led8seg_gts1', 'rect')) - OBJECTS = frozenset(('backdrop', 'bezel')) + OBJECTS = frozenset(('backdrop', )) ORIENTATIONS = frozenset((0, 90, 180, 270)) YESNO = frozenset(('yes', 'no')) BLENDMODES = frozenset(('none', 'alpha', 'multiply', 'add')) @@ -111,6 +111,8 @@ class LayoutChecker(Minifyer): self.views = { } self.referenced_elements = { } self.referenced_groups = { } + self.group_collections = { } + self.current_collections = None def formatLocation(self): return '%s:%d:%d' % (self.locator.getSystemId(), self.locator.getLineNumber(), self.locator.getColumnNumber()) @@ -320,6 +322,7 @@ class LayoutChecker(Minifyer): self.handleError('Element element attribute defstate "%s" is negative' % (attrs['defstate'], )) self.handlers.append((self.elementStartHandler, self.elementEndHandler)) elif 'group' == name: + self.current_collections = { } if 'name' not in attrs: self.handleError('Element group missing attribute name') else: @@ -328,6 +331,8 @@ class LayoutChecker(Minifyer): self.generated_group_names = True if attrs['name'] not in self.groups: self.groups[attrs['name']] = self.formatLocation() + if not generated_name: + self.group_collections[attrs['name']] = self.current_collections elif not generated_name: self.handleError('Element group has duplicate name (previous %s)' % (self.groups[attrs['name']], )) self.handlers.append((self.groupViewStartHandler, self.groupViewEndHandler)) @@ -335,6 +340,7 @@ class LayoutChecker(Minifyer): self.repeat_depth.append(0) self.have_bounds.append(False) elif ('view' == name) and (not self.repeat_depth[-1]): + self.current_collections = { } if 'name' not in attrs: self.handleError('Element view missing attribute name') else: @@ -475,7 +481,7 @@ class LayoutChecker(Minifyer): if ('element' != name) and not self.has_legacy_object: self.has_legacy_object = True if self.has_collection: - self.handleError('Layout contains collection as well as legacy backdrop/bezel elements') + self.handleError('Layout contains collection as well as legacy backdrop elements') self.handlers.append((self.objectStartHandler, self.objectEndHandler)) self.have_bounds.append(False) self.have_orientation.append(False) @@ -497,8 +503,15 @@ class LayoutChecker(Minifyer): elif 'group' == name: if 'ref' not in attrs: self.handleError('Element group missing attribute ref') - elif attrs['ref'] not in self.referenced_groups: - self.referenced_groups[attrs['ref']] = self.formatLocation() + else: + if attrs['ref'] not in self.referenced_groups: + self.referenced_groups[attrs['ref']] = self.formatLocation() + if (not self.VARPATTERN.match(attrs['ref'])) and (attrs['ref'] in self.group_collections): + for n, l in self.group_collections[attrs['ref']].items(): + if n not in self.current_collections: + self.current_collections[n] = l + else: + self.handleError('Element group instantiates collection with duplicate name "%s" from %s (previous %s)' % (n, l, self.current_collections[n])) self.handlers.append((self.objectStartHandler, self.objectEndHandler)) self.have_bounds.append(False) self.have_orientation.append(False) @@ -514,12 +527,17 @@ class LayoutChecker(Minifyer): elif 'collection' == name: if 'name' not in attrs: self.handleError('Element collection missing attribute name') + elif not self.VARPATTERN.match(attrs['name']): + if attrs['name'] not in self.current_collections: + self.current_collections[attrs['name']] = self.formatLocation() + else: + self.handleError('Element collection has duplicate name (previous %s)' % (self.current_collections[attrs['name']], )) if attrs.get('visible', 'yes') not in self.YESNO: self.handleError('Element collection attribute visible "%s" is not "yes" or "no"' % (attrs['visible'], )) if not self.has_collection: self.has_collection = True if self.has_legacy_object: - self.handleError('Layout contains collection as well as legacy backdrop/bezel elements') + self.handleError('Layout contains collection as well as legacy backdrop elements') self.variable_scopes.append({ }) self.collection_depth += 1 elif 'param' == name: @@ -543,6 +561,7 @@ class LayoutChecker(Minifyer): elif self.repeat_depth[-1]: self.repeat_depth[-1] -= 1 else: + self.current_collections = None self.repeat_depth.pop() self.have_bounds.pop() self.handlers.pop() @@ -585,6 +604,8 @@ class LayoutChecker(Minifyer): self.views.clear() self.referenced_elements.clear() self.referenced_groups.clear() + self.group_collections.clear() + self.current_collections = None del self.handlers del self.ignored_depth del self.variable_scopes |