[gobject-introspection] Allow the use of the "Rename To" annotation for literal method renaming.



commit 2fe114c880585f475c757277c4b7f0e78a5eb27e
Author: C. Scott Ananian <cscott litl com>
Date:   Mon Apr 27 10:48:12 2009 -0400

    Allow the use of the "Rename To" annotation for literal method renaming.
    
    As originally implemented, this annotation was only used for method
    overloading (argument signature polymorphism).  Allow it to be used to
    clean up historically poorly-named methods as well.
---
 giscanner/annotationparser.py |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 30b0eed..5458ee1 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -692,8 +692,21 @@ class AnnotationApplier(object):
             return True
 
         self._namespace.remove_matching(shadowed_filter)
-        assert len(shadowed) == 1
-        node.name = shadowed[0].name
+        if len(shadowed) == 1:
+            # method override; use the same (stripped) name as the overloaded
+            # method referenced.
+            # Note that 'g_timeout_add_full' may specify a new_name of
+            # 'g_timeout_add' but the *real* name desired is the stripped name
+            # of 'g_timeout_add' which is 'timeout_add' (for example).
+            node.name = shadowed[0].name
+        elif len(shadowed) == 0:
+            # literal rename, to force a particular prefix strip or whatever
+            # Example: the "nm-utils" package uses a "NM" prefix in most places
+            # but some functions have an "nm_utils_" prefix; the 'Rename To:'
+            # annotation in this case is used to strip the 'utils_' part off.
+            node.name = new_name
+        else:
+            assert False # more than two shadowed methods?  Shouldn't happen.
 
     def _guess_direction(self, node):
         if node.direction:



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