summaryrefslogtreecommitdiff
path: root/giscanner/maintransformer.py
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-09-11 14:25:27 +0200
committerTomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-09-17 10:04:25 +0200
commita18d88dd1a42ef646852b32dc00b07d7895b6dc7 (patch)
tree74680b7c15f9b82a242c3f073fb139812b50493d /giscanner/maintransformer.py
parentc2f808b1171c6b5e6de5063040f305dbf37fbd73 (diff)
downloadgobject-introspection-a18d88dd1a42ef646852b32dc00b07d7895b6dc7.tar.gz
Make Full the default transfer for returned foreign structs.
For that we also need to read the annotations for foreign structs before guessing the transfer mode of return values. https://bugzilla.gnome.org/show_bug.cgi?id=629188
Diffstat (limited to 'giscanner/maintransformer.py')
-rw-r--r--giscanner/maintransformer.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index f2527b51..b7d64a63 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -65,6 +65,9 @@ class MainTransformer(object):
# Type() types and see if they match up with something.
self._namespace.walk(self._pass_type_resolution)
+ # Read in annotations needed early
+ self._namespace.walk(self._pass_read_annotations_early)
+
# Determine some default values for transfer etc.
# based on the current tree.
self._namespace.walk(self._pass_callable_defaults)
@@ -166,6 +169,15 @@ usage is void (*_gtk_reserved1)(void);"""
block = self._blocks.get(node.symbol)
self._apply_annotations_callable(node, chain, block)
+ def _pass_read_annotations_early(self, node, chain):
+ if isinstance(node, ast.Record):
+ if node.ctype is not None:
+ block = self._blocks.get(node.ctype)
+ else:
+ block = self._blocks.get(node.c_name)
+ self._apply_annotations_annotated(node, block)
+ return True
+
def _pass_callable_defaults(self, node, chain):
if isinstance(node, (ast.Callable, ast.Signal)):
for param in node.parameters:
@@ -198,9 +210,8 @@ usage is void (*_gtk_reserved1)(void);"""
self._apply_annotations_function(node, chain)
if isinstance(node, ast.Callback):
self._apply_annotations_callable(node, chain, block = self._get_block(node))
- if isinstance(node, (ast.Class, ast.Interface, ast.Record,
- ast.Union, ast.Enum, ast.Bitfield,
- ast.Callback)):
+ if isinstance(node, (ast.Class, ast.Interface, ast.Union, ast.Enum,
+ ast.Bitfield, ast.Callback)):
self._apply_annotations_annotated(node, self._get_block(node))
if isinstance(node, (ast.Class, ast.Interface, ast.Record, ast.Union)):
block = self._get_block(node)
@@ -384,7 +395,8 @@ usage is void (*_gtk_reserved1)(void);"""
if isinstance(target, ast.Alias):
return self._get_transfer_default_returntype_basic(target.target)
elif (isinstance(target, ast.Boxed)
- or (isinstance(target, (ast.Record, ast.Union)) and target.gtype_name is not None)):
+ or (isinstance(target, (ast.Record, ast.Union))
+ and (target.gtype_name is not None or target.foreign))):
return ast.PARAM_TRANSFER_FULL
elif isinstance(target, (ast.Enum, ast.Bitfield)):
return ast.PARAM_TRANSFER_NONE