summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDieter Verfaillie <dieterv@optionexplicit.be>2013-04-09 12:04:08 +0200
committerDieter Verfaillie <dieterv@optionexplicit.be>2013-05-07 15:36:09 +0200
commitbeadfeff33302a3012fb5df1a7197cb4fac8f6f6 (patch)
treebc6bf92033375a83e3de55797c84ae89b98f968b
parent5460b7f12b3d7b5989307707c59a5d67aed69a44 (diff)
downloadgobject-introspection-beadfeff33302a3012fb5df1a7197cb4fac8f6f6.tar.gz
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
-rw-r--r--giscanner/maintransformer.py48
1 files 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."""