summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen W. Taylor <otaylor@fishsoup.net>2010-05-06 18:15:37 -0400
committerOwen W. Taylor <otaylor@fishsoup.net>2010-05-07 12:05:57 -0400
commita78f828cceab49038f4777dd85e2c898f86d51ab (patch)
treec093dc220e440e6ca971774ef4bd205fc65ba00c
parent2f7066d7ba462641e1c5b6bc8d5fc5ee850ca87f (diff)
downloadgobject-introspection-a78f828cceab49038f4777dd85e2c898f86d51ab.tar.gz
Validate scope annotation values
Make sure that the value specified for scope in a callback annotation is one of the legal values. https://bugzilla.gnome.org/show_bug.cgi?id=617978
-rw-r--r--giscanner/annotationparser.py10
-rw-r--r--giscanner/ast.py4
2 files changed, 14 insertions, 0 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 99da0bfe..5fa7cfc0 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -31,6 +31,9 @@ from .ast import (Array, Bitfield, Callback, Class, Enum, Field, Function,
PARAM_DIRECTION_INOUT,
PARAM_DIRECTION_IN,
PARAM_DIRECTION_OUT,
+ PARAM_SCOPE_CALL,
+ PARAM_SCOPE_ASYNC,
+ PARAM_SCOPE_NOTIFIED,
PARAM_TRANSFER_NONE,
PARAM_TRANSFER_CONTAINER,
PARAM_TRANSFER_FULL,
@@ -526,6 +529,13 @@ class AnnotationApplier(object):
scope = options.get(OPT_SCOPE)
if scope:
param.scope = scope.one()
+ if param.scope not in [PARAM_SCOPE_CALL,
+ PARAM_SCOPE_ASYNC,
+ PARAM_SCOPE_NOTIFIED]:
+ raise InvalidAnnotationError(
+ "scope for %s of %r is invalid (%r), must be one of "
+ "call, async, notified."
+ % (param.name, parent.name, param.scope))
param.transfer = PARAM_TRANSFER_NONE
elif (param.type.ctype == 'GAsyncReadyCallback' or
param.type.name == 'Gio.AsyncReadyCallback'):
diff --git a/giscanner/ast.py b/giscanner/ast.py
index 9b432023..1265883a 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -82,6 +82,10 @@ PARAM_DIRECTION_IN = 'in'
PARAM_DIRECTION_OUT = 'out'
PARAM_DIRECTION_INOUT = 'inout'
+PARAM_SCOPE_CALL = 'call'
+PARAM_SCOPE_ASYNC = 'async'
+PARAM_SCOPE_NOTIFIED = 'notified'
+
PARAM_TRANSFER_NONE = 'none'
PARAM_TRANSFER_CONTAINER = 'container'
PARAM_TRANSFER_FULL = 'full'