[gobject-introspection] giscanner: make _pass_read_annotations2() more readable
- From: Dieter Verfaillie <dieterv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] giscanner: make _pass_read_annotations2() more readable
- Date: Tue, 7 May 2013 14:07:36 +0000 (UTC)
commit beadfeff33302a3012fb5df1a7197cb4fac8f6f6
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date: Tue Apr 9 12:04:08 2013 +0200
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 files changed, 22 insertions(+), 26 deletions(-)
---
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index fb19986..6cf5a00 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."""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]