From beadfeff33302a3012fb5df1a7197cb4fac8f6f6 Mon Sep 17 00:00:00 2001 From: Dieter Verfaillie Date: Tue, 9 Apr 2013 12:04:08 +0200 Subject: giscanner: make _pass_read_annotations2() more readable _apply_annotations2_function() is only ever called by _pass_read_annotations2() so there's no need to go and hide what's being done behind an extra method call. Also change the 'if not something; return' into a more readable 'if something: do something'... https://bugzilla.gnome.org/show_bug.cgi?id=697622 --- giscanner/maintransformer.py | 48 ++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py index fb199861..6cf5a006 100644 --- a/giscanner/maintransformer.py +++ b/giscanner/maintransformer.py @@ -831,34 +831,30 @@ usage is void (*_gtk_reserved1)(void);""" def _pass_read_annotations2(self, node, chain): if isinstance(node, ast.Function): - self._apply_annotations2_function(node, chain) + block = self._blocks.get(node.symbol) + + self._apply_annotation_rename_to(node, chain, block) + + # Handle virtual invokers + parent = chain[-1] if chain else None + if (block and parent): + virtual_annotation = block.get_tag(TAG_VFUNC) + if virtual_annotation: + invoker_name = virtual_annotation.value + matched = False + for vfunc in parent.virtual_methods: + if vfunc.name == invoker_name: + matched = True + vfunc.invoker = node.name + # Also merge in annotations + self._apply_annotations_callable(vfunc, [parent], block) + break + if not matched: + message.warn_node(node, + "Virtual slot %r not found for %r annotation" % (invoker_name, + TAG_VFUNC)) return True - def _apply_annotations2_function(self, node, chain): - block = self._blocks.get(node.symbol) - - self._apply_annotation_rename_to(node, chain, block) - - # Handle virtual invokers - parent = chain[-1] if chain else None - if not (block and parent): - return - virtual = block.get_tag(TAG_VFUNC) - if not virtual: - return - invoker_name = virtual.value - matched = False - for vfunc in parent.virtual_methods: - if vfunc.name == invoker_name: - matched = True - vfunc.invoker = node.name - # Also merge in annotations - self._apply_annotations_callable(vfunc, [parent], block) - break - if not matched: - message.warn_node(node, - "Virtual slot %r not found for %r annotation" % (invoker_name, TAG_VFUNC)) - def _resolve_and_filter_type_list(self, typelist): """Given a list of Type instances, return a new list of types with the ones that failed to resolve removed.""" -- cgit v1.2.1