summaryrefslogtreecommitdiff
path: root/giscanner/introspectablepass.py
diff options
context:
space:
mode:
Diffstat (limited to 'giscanner/introspectablepass.py')
-rw-r--r--giscanner/introspectablepass.py56
1 files changed, 30 insertions, 26 deletions
diff --git a/giscanner/introspectablepass.py b/giscanner/introspectablepass.py
index 97ccfe71..3d67c73e 100644
--- a/giscanner/introspectablepass.py
+++ b/giscanner/introspectablepass.py
@@ -21,6 +21,7 @@ from . import ast
from . import message
from .annotationparser import TAG_RETURNS
+
class IntrospectablePass(object):
def __init__(self, transformer, blocks):
@@ -58,7 +59,7 @@ class IntrospectablePass(object):
else:
context = "return value: "
if block:
- return_tag = block.get_tag(TAG_RETURNS)
+ return_tag = block.tags.get(TAG_RETURNS)
if return_tag:
position = return_tag.position
message.warn_node(parent, prefix + context + text,
@@ -79,7 +80,7 @@ class IntrospectablePass(object):
if not node.type.resolved:
self._parameter_warning(parent, node,
-"Unresolved type: %r" % (node.type.unresolved_string, ))
+ "Unresolved type: %r" % (node.type.unresolved_string, ))
parent.introspectable = False
return
@@ -87,23 +88,24 @@ class IntrospectablePass(object):
parent.introspectable = False
return
- if (isinstance(node.type, ast.List)
- and node.type.element_type == ast.TYPE_ANY):
+ if (isinstance(node.type, (ast.List, ast.Array))
+ and node.type.element_type == ast.TYPE_ANY):
self._parameter_warning(parent, node, "Missing (element-type) annotation")
parent.introspectable = False
return
if (is_parameter
- and isinstance(target, ast.Callback)
- and not node.type.target_giname in ('GLib.DestroyNotify',
- 'Gio.AsyncReadyCallback')
- and node.scope is None):
- self._parameter_warning(parent, node,
- ("Missing (scope) annotation for callback" +
- " without GDestroyNotify (valid: %s, %s)")
- % (ast.PARAM_SCOPE_CALL, ast.PARAM_SCOPE_ASYNC))
- parent.introspectable = False
- return
+ and isinstance(target, ast.Callback)
+ and not node.type.target_giname in ('GLib.DestroyNotify', 'Gio.AsyncReadyCallback')
+ and node.scope is None):
+ self._parameter_warning(
+ parent,
+ node,
+ "Missing (scope) annotation for callback without "
+ "GDestroyNotify (valid: %s, %s)" % (ast.PARAM_SCOPE_CALL, ast.PARAM_SCOPE_ASYNC))
+
+ parent.introspectable = False
+ return
if is_return and isinstance(target, ast.Callback):
self._parameter_warning(parent, node, "Callbacks cannot be return values; use (skip)")
@@ -111,12 +113,14 @@ class IntrospectablePass(object):
return
if (is_return
- and isinstance(target, (ast.Record, ast.Union))
- and target.get_type is None
- and not target.foreign):
+ and isinstance(target, (ast.Record, ast.Union))
+ and target.get_type is None
+ and not target.foreign):
if node.transfer != ast.PARAM_TRANSFER_NONE:
- self._parameter_warning(parent, node,
-"Invalid non-constant return of bare structure or union; register as boxed type or (skip)")
+ self._parameter_warning(
+ parent, node,
+ "Invalid non-constant return of bare structure or union; "
+ "register as boxed type or (skip)")
parent.introspectable = False
return
@@ -143,10 +147,10 @@ class IntrospectablePass(object):
# These are not introspectable pending us adding
# larger type tags to the typelib (in theory these could
# be 128 bit or larger)
- if typeval.is_equiv((ast.TYPE_LONG_LONG, ast.TYPE_LONG_ULONG,
- ast.TYPE_LONG_DOUBLE)):
+ elif typeval.is_equiv((ast.TYPE_LONG_LONG, ast.TYPE_LONG_ULONG, ast.TYPE_LONG_DOUBLE)):
return False
- return True
+ else:
+ return True
target = self._transformer.lookup_typenode(typeval)
if not target:
return False
@@ -229,8 +233,8 @@ class IntrospectablePass(object):
def _remove_non_reachable_backcompat_copies(self, obj, stack):
if obj.skip:
return False
- if (isinstance(obj, ast.Function)
- and not obj.introspectable
- and obj.moved_to is not None):
- self._namespace.remove(obj)
+ if (isinstance(obj, ast.Function) and obj.moved_to is not None):
+ # remove functions that are not introspectable
+ if not obj.introspectable:
+ obj.internal_skipped = True
return True