summaryrefslogtreecommitdiff
path: root/giscanner
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagna@src.gnome.org>2014-02-25 03:37:38 +0100
committerGiovanni Campagna <gcampagna@src.gnome.org>2014-02-26 17:27:08 +0100
commita9203dd3e98665982b380a40867eeb6f4e5f678b (patch)
tree495af770200da607f3671a72deb65bc14c159f3a /giscanner
parent15caff9c3e67e49763a7ff9368f4c0c8eda36f24 (diff)
downloadgobject-introspection-a9203dd3e98665982b380a40867eeb6f4e5f678b.tar.gz
docwriter/gjs: fix constructors
We should only look at introspectable constructors when resolving the default and zero args. Also, a disguised structure or one with zero fields can't be allocated directly. In addition, restore availability of all constructors, because we need a page to document the default one, and because some classes have problems with GObject construction.
Diffstat (limited to 'giscanner')
-rw-r--r--giscanner/docwriter.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py
index afad77b7..b0f80e6d 100644
--- a/giscanner/docwriter.py
+++ b/giscanner/docwriter.py
@@ -580,7 +580,10 @@ class DocFormatterGjs(DocFormatterIntrospectableBase):
zero_args_constructor = None
default_constructor = None
- for c in node.constructors:
+ introspectable_constructors = \
+ filter(lambda c: getattr(c, 'introspectable', True),
+ node.constructors)
+ for c in introspectable_constructors:
if zero_args_constructor is None and \
len(c.parameters) == 0:
zero_args_constructor = c
@@ -590,8 +593,8 @@ class DocFormatterGjs(DocFormatterIntrospectableBase):
if default_constructor is None:
default_constructor = zero_args_constructor
if default_constructor is None and \
- len(node.constructors) > 0:
- default_constructor = node.constructors[0]
+ len(introspectable_constructors) > 0:
+ default_constructor = introspectable_constructors[0]
node.gjs_default_constructor = default_constructor
node.gjs_zero_args_constructor = zero_args_constructor
@@ -626,16 +629,11 @@ class DocFormatterGjs(DocFormatterIntrospectableBase):
parent.name == 'ParamSpec':
is_gparam_subclass = True
break
+ if parent.parent_type is None:
+ break
parent = self._transformer.lookup_typenode(parent.parent_type)
if is_gparam_subclass:
return False
- if isinstance(node, ast.Function) and node.is_constructor:
- parent = node.parent
- if isinstance(parent, (ast.Compound, ast.Boxed)):
- if node == parent.gjs_default_constructor:
- return False
- if isinstance(parent, ast.Class):
- return False
return super(DocFormatterGjs, self).should_render_node(node)
@@ -814,6 +812,9 @@ class DocFormatterGjs(DocFormatterIntrospectableBase):
return True
def _struct_is_simple(self, node):
+ if node.disguised or len(node.fields) == 0:
+ return False
+
for f in node.fields:
if not self.field_is_writable(f):
return False
@@ -823,8 +824,8 @@ class DocFormatterGjs(DocFormatterIntrospectableBase):
if node.namespace.name == 'GLib' and node.name == 'Variant':
return 'signature: String, value: Any'
- zero_args_constructor = node.gjs_default_constructor
- default_constructor = node.gjs_zero_args_constructor
+ zero_args_constructor = node.gjs_zero_args_constructor
+ default_constructor = node.gjs_default_constructor
can_allocate = zero_args_constructor is not None
if not can_allocate and isinstance(node, ast.Record):