[gobject-introspection] Validate scope annotation values
- From: Owen Taylor <otaylor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] Validate scope annotation values
- Date: Fri, 7 May 2010 16:09:26 +0000 (UTC)
commit a78f828cceab49038f4777dd85e2c898f86d51ab
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Thu May 6 18:15:37 2010 -0400
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
giscanner/annotationparser.py | 10 ++++++++++
giscanner/ast.py | 4 ++++
2 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 99da0bf..5fa7cfc 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 9b43202..1265883 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'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]