summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Nordby <jononor@gmail.com>2012-06-23 13:59:12 +0200
committerJon Nordby <jononor@gmail.com>2012-07-27 21:36:36 +0200
commit764366f7e4ef5a765a24ffac8c60b811f38b9ad9 (patch)
tree4d6a4a80df3ab45a84ad9bf1cfa47abc7096a3fc
parenta42b954db6e057780a054a7d5a3fe7d5f5eb6dd1 (diff)
downloadgobject-introspection-764366f7e4ef5a765a24ffac8c60b811f38b9ad9.tar.gz
Implement "rename to" annotation for records
https://bugzilla.gnome.org/show_bug.cgi?id=675985 Moving the early annotation pass is needed to avoid the first type resolve pass to resolve to the not-renamed type.
-rw-r--r--giscanner/maintransformer.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 77a66d21..eb6b8b38 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -60,14 +60,14 @@ class MainTransformer(object):
# Some initial namespace surgery
self._namespace.walk(self._pass_fixup_hidden_fields)
+ # Read in annotations needed early
+ self._namespace.walk(self._pass_read_annotations_early)
+
# We have a rough tree which should have most of of the types
# we know about. Let's attempt closure; walk over all of the
# Type() types and see if they match up with something.
self._namespace.walk(self._pass_type_resolution)
- # Read in annotations needed early
- self._namespace.walk(self._pass_read_annotations_early)
-
# Determine some default values for transfer etc.
# based on the current tree.
self._namespace.walk(self._pass_callable_defaults)
@@ -139,7 +139,16 @@ usage is void (*_gtk_reserved1)(void);"""
return param.argname
- def _apply_annotation_rename_to(self, node, chain, block):
+ def _apply_annotation_rename_to_record(self, node, chain, block):
+ if not block:
+ return
+ rename_to = block.get_tag(TAG_RENAME_TO)
+ if not rename_to:
+ return
+
+ node.name = rename_to.value
+
+ def _apply_annotation_rename_to_function(self, node, chain, block):
if not block:
return
rename_to = block.get_tag(TAG_RENAME_TO)
@@ -177,6 +186,7 @@ usage is void (*_gtk_reserved1)(void);"""
block = self._blocks.get(node.ctype)
else:
block = self._blocks.get(node.c_name)
+ self._apply_annotation_rename_to_record(node, chain, block)
self._apply_annotations_annotated(node, block)
return True
@@ -828,7 +838,7 @@ usage is void (*_gtk_reserved1)(void);"""
def _apply_annotations2_function(self, node, chain):
block = self._blocks.get(node.symbol)
- self._apply_annotation_rename_to(node, chain, block)
+ self._apply_annotation_rename_to_function(node, chain, block)
# Handle virtual invokers
parent = chain[-1] if chain else None