[gobject-introspection] Implement "rename to" annotation for records



commit 764366f7e4ef5a765a24ffac8c60b811f38b9ad9
Author: Jon Nordby <jononor gmail com>
Date:   Sat Jun 23 13:59:12 2012 +0200

    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.

 giscanner/maintransformer.py |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 77a66d2..eb6b8b3 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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]