diff options
author | Torsten Schönfeld <kaffeetisch@gmx.de> | 2011-08-13 16:32:48 +0200 |
---|---|---|
committer | Torsten Schönfeld <kaffeetisch@gmx.de> | 2011-08-14 09:35:27 +0200 |
commit | 736924a8ed80b6d8ef14f342abf3440a8e9c9541 (patch) | |
tree | f427804d8f0766aede9e6ca055664145d7348d1d | |
parent | e6ff50d62ce10c9faec56f7401a5801015ed286b (diff) | |
download | gobject-introspection-736924a8ed80b6d8ef14f342abf3440a8e9c9541.tar.gz |
Recognize constructors ending in 'newv'
Like gtk_list_store_newv and gtk_tree_store_newv.
https://bugzilla.gnome.org/show_bug.cgi?id=656460
-rw-r--r-- | giscanner/maintransformer.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py index a86c7224..8c07fda5 100644 --- a/giscanner/maintransformer.py +++ b/giscanner/maintransformer.py @@ -1064,15 +1064,26 @@ method or constructor of some type.""" return name + def _guess_constructor_by_name(self, symbol): + # Normal constructors, gtk_button_new etc + if symbol.endswith('_new'): + return True + # Alternative constructor, gtk_button_new_with_label + if '_new_' in symbol: + return True + # gtk_list_store_newv,gtk_tree_store_newv etc + if symbol.endswith('_newv'): + return True + return False + def _is_constructor(self, func, subsymbol): if False and func.symbol == 'regress_constructor': import pdb pdb.set_trace() # func.is_constructor will be True if we have a (constructor) annotation - if not func.is_constructor and \ - not (func.symbol.find('_new_') >= 0 or \ - func.symbol.endswith('_new')): - return False + if not func.is_constructor: + if not self._guess_constructor_by_name(func.symbol): + return False target = self._transformer.lookup_typenode(func.retval.type) if not (isinstance(target, ast.Class) or (isinstance(target, (ast.Record, ast.Union, ast.Boxed)) |