summaryrefslogtreecommitdiff
path: root/giscanner/annotationparser.py
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2010-09-23 18:36:37 -0300
committerJohan Dahlin <johan@gnome.org>2010-09-23 18:53:55 -0300
commitb57c12a01e48e6b75aab97d409d45ce110978536 (patch)
tree537d11ff830e7627280c7485491701812e0f89a2 /giscanner/annotationparser.py
parentb8bad329f62755984e9e23f1fc50f119acf4625c (diff)
downloadgobject-introspection-b57c12a01e48e6b75aab97d409d45ce110978536.tar.gz
Validate transfer annnotations
Diffstat (limited to 'giscanner/annotationparser.py')
-rw-r--r--giscanner/annotationparser.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 376919dd..4febc598 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -84,6 +84,12 @@ OPT_SCOPE_ASYNC = 'async'
OPT_SCOPE_CALL = 'call'
OPT_SCOPE_NOTIFIED = 'notified'
+# Transfer options
+OPT_TRANSFER_NONE = 'none'
+OPT_TRANSFER_CONTAINER = 'container'
+OPT_TRANSFER_FULL = 'full'
+
+
class DocBlock(object):
def __init__(self, name):
@@ -124,7 +130,22 @@ class DocTag(object):
if not option in ALL_OPTIONS:
message.warn('invalid option: %s' % (option, ),
positions=self.position)
-
+ if option == OPT_TRANSFER:
+ value = self.options[option]
+ if value is None:
+ message.warn('transfer needs a value',
+ self.position)
+ continue
+ if value.length() != 1:
+ message.warn('transfer needs one value, not %d' % (
+ value.length()), self.position)
+ continue
+ valuestr = value.one()
+ if valuestr not in [OPT_TRANSFER_NONE,
+ OPT_TRANSFER_CONTAINER,
+ OPT_TRANSFER_FULL]:
+ message.warn('invalid transfer value: %r' % (
+ valuestr, ), self.position)
class DocOptions(object):
def __init__(self):
@@ -178,6 +199,9 @@ class DocOption(object):
def __repr__(self):
return '<DocOption %r>' % (self._array, )
+ def length(self):
+ return len(self._array)
+
def one(self):
assert len(self._array) == 1
return self._array[0]