summaryrefslogtreecommitdiff
path: root/giscanner
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-06-08 16:40:35 +0200
committerTomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-06-08 17:35:12 +0200
commit22ae017ffd3052c0b81822b2ca6e41626b76b9c4 (patch)
treeb280bde67eaa4096bd8a83ad539a8fe9c7c14f5c /giscanner
parent862cdbe9ed2464c722e566238980895d08a48106 (diff)
downloadgobject-introspection-22ae017ffd3052c0b81822b2ca6e41626b76b9c4.tar.gz
Support the (transfer) annotation for properties.
* girepository/*: Add g_property_info_get_ownership_transfer() and write the transfer attribute of properties into the typelib. * giscanner/*: Parse the (transfer) annotation and write it into the .gir. * tools/generate.c: Read the transfer annotation for properties and write to the .tgir. https://bugzilla.gnome.org/show_bug.cgi?id=620484
Diffstat (limited to 'giscanner')
-rw-r--r--giscanner/annotationparser.py15
-rw-r--r--giscanner/ast.py6
-rw-r--r--giscanner/girwriter.py1
3 files changed, 17 insertions, 5 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index d632174c..d5cc7f63 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -24,8 +24,8 @@ import re
import sys
from .ast import (Array, Bitfield, Callback, Class, Enum, Field, Function,
- Interface, List, Map, Parameter, Record, Return, Type, Union,
- Varargs,
+ Interface, List, Map, Parameter, Property, Record, Return,
+ Type, Union, Varargs,
default_array_types,
BASIC_GIR_TYPES,
PARAM_DIRECTION_INOUT,
@@ -53,6 +53,7 @@ TAG_RETURNS_ALT = 'return value'
TAG_ATTRIBUTES = 'attributes'
TAG_RENAME_TO = 'rename to'
TAG_TYPE = 'type'
+TAG_TRANSFER = 'transfer'
# Options - annotations for parameters and return values
OPT_ALLOW_NONE = 'allow-none'
@@ -418,6 +419,14 @@ class AnnotationApplier(object):
self._parse_node_common(prop, block)
if block:
prop.doc = block.comment
+
+ transfer_tag = self._get_tag(block, TAG_TRANSFER)
+ if transfer_tag is not None:
+ options = {OPT_TRANSFER: Option(transfer_tag.value)}
+ else:
+ options = {}
+ prop.transfer = self._extract_transfer(parent, prop, options)
+
type_tag = self._get_tag(block, TAG_TYPE)
if type_tag:
prop.type = self._resolve(type_tag.value, prop.type)
@@ -946,5 +955,7 @@ class AnnotationApplier(object):
return PARAM_TRANSFER_FULL
elif isinstance(node, Field):
return PARAM_TRANSFER_NONE
+ elif isinstance(node, Property):
+ return PARAM_TRANSFER_NONE
else:
raise AssertionError(node)
diff --git a/giscanner/ast.py b/giscanner/ast.py
index 902a3f6f..0e9f112d 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -521,12 +521,12 @@ class Constant(Node):
self.name, self.type, self.value)
-class Property(Node):
+class Property(TypeContainer):
def __init__(self, name, type_name, readable, writable,
- construct, construct_only, ctype=None):
- Node.__init__(self, name)
+ construct, construct_only, ctype=None, transfer=None):
self.type = Type(type_name, ctype)
+ TypeContainer.__init__(self, name, self.type, transfer)
self.readable = readable
self.writable = writable
self.construct = construct
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index 48791b11..7fe5bad1 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -400,6 +400,7 @@ and/or use gtk-doc annotations. ''')
attrs.append(('construct', '1'))
if prop.construct_only:
attrs.append(('construct-only', '1'))
+ attrs.append(('transfer-ownership', prop.transfer))
if prop.doc:
attrs.append(('doc', prop.doc))
with self.tagcontext('property', attrs):