diff options
author | C. Scott Ananian <cscott@litl.com> | 2009-04-27 10:48:12 -0400 |
---|---|---|
committer | Johan Bilien <jobi@litl.com> | 2009-05-12 16:00:32 +0100 |
commit | 2fe114c880585f475c757277c4b7f0e78a5eb27e (patch) | |
tree | 08ce524601483421ff6665393c9eafbe54bab5cc /giscanner/annotationparser.py | |
parent | 95a407d7bf263600e1f7b9708159dd17cc9226fe (diff) |
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.
Diffstat (limited to 'giscanner/annotationparser.py')
-rw-r--r-- | 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: |