[gobject-introspection] Recognize constructors ending in 'newv'
- From: Torsten SchÃnfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] Recognize constructors ending in 'newv'
- Date: Sun, 14 Aug 2011 08:56:32 +0000 (UTC)
commit 736924a8ed80b6d8ef14f342abf3440a8e9c9541
Author: Torsten SchÃnfeld <kaffeetisch gmx de>
Date: Sat Aug 13 16:32:48 2011 +0200
Recognize constructors ending in 'newv'
Like gtk_list_store_newv and gtk_tree_store_newv.
https://bugzilla.gnome.org/show_bug.cgi?id=656460
giscanner/maintransformer.py | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index a86c722..8c07fda 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))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]