[gobject-introspection/scope-forever] Add "forever" scope
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection/scope-forever] Add "forever" scope
- Date: Wed, 8 Apr 2020 19:11:18 +0000 (UTC)
commit 20208eacdd0f72784e4c4cc23274e0025c45e214
Author: Emmanuele Bassi <ebassi gnome org>
Date: Wed Apr 8 20:04:03 2020 +0100
Add "forever" scope
Some functions are meant to exist for the entire duration of the
process, and thus have no need for a notification function because
one will never be called.
Fixes: #49
girepository/girparser.c | 2 ++
girepository/girwriter.c | 3 +++
girepository/gitypes.h | 7 +++++--
giscanner/annotationparser.py | 4 +++-
giscanner/ast.py | 1 +
giscanner/introspectablepass.py | 2 +-
tests/warn/callback-invalid-scope.h | 4 ++--
tests/warn/callback-missing-scope.h | 2 +-
8 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/girepository/girparser.c b/girepository/girparser.c
index 53450baf..0370a38c 100644
--- a/girepository/girparser.c
+++ b/girepository/girparser.c
@@ -1221,6 +1221,8 @@ start_parameter (GMarkupParseContext *context,
param->scope = GI_SCOPE_TYPE_ASYNC;
else if (scope && strcmp (scope, "notified") == 0)
param->scope = GI_SCOPE_TYPE_NOTIFIED;
+ else if (scope && strcmp (scope, "forever") == 0)
+ param->scope = GI_SCOPE_TYPE_FOREVER;
else
param->scope = GI_SCOPE_TYPE_INVALID;
diff --git a/girepository/girwriter.c b/girepository/girwriter.c
index 7b255423..7efa31a9 100644
--- a/girepository/girwriter.c
+++ b/girepository/girwriter.c
@@ -531,6 +531,9 @@ write_callable_info (const gchar *namespace,
case GI_SCOPE_TYPE_NOTIFIED:
xml_printf (file, " scope=\"notified\"");
break;
+ case GI_SCOPE_TYPE_FOREVER:
+ xml_printf (file, " scope=\"forever\"");
+ break;
default:
g_assert_not_reached ();
}
diff --git a/girepository/gitypes.h b/girepository/gitypes.h
index 33897520..301ccf16 100644
--- a/girepository/gitypes.h
+++ b/girepository/gitypes.h
@@ -362,8 +362,10 @@ typedef enum {
* @GI_SCOPE_TYPE_ASYNC: The callback and associated user_data is
* only used until the callback is invoked, and the callback.
* is invoked always exactly once.
- * @GI_SCOPE_TYPE_NOTIFIED: The callback and and associated
+ * @GI_SCOPE_TYPE_NOTIFIED: The callback and associated
* user_data is used until the caller is notfied via the destroy_notify.
+ * @GI_SCOPE_TYPE_FOREVER: The callback and associated user_data is
+ * is used until the process terminates
*
* Scope type of a #GIArgInfo representing callback, determines how the
* callback is invoked and is used to decided when the invoke structs
@@ -373,7 +375,8 @@ typedef enum {
GI_SCOPE_TYPE_INVALID,
GI_SCOPE_TYPE_CALL,
GI_SCOPE_TYPE_ASYNC,
- GI_SCOPE_TYPE_NOTIFIED
+ GI_SCOPE_TYPE_NOTIFIED,
+ GI_SCOPE_TYPE_FOREVER
} GIScopeType;
/**
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 9ab629b3..340d92e0 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -277,10 +277,12 @@ NOT_OPTIONS = [OPT_NOT_NULLABLE]
OPT_SCOPE_ASYNC = 'async'
OPT_SCOPE_CALL = 'call'
OPT_SCOPE_NOTIFIED = 'notified'
+OPT_SCOPE_FOREVER = 'forever'
SCOPE_OPTIONS = [OPT_SCOPE_ASYNC,
OPT_SCOPE_CALL,
- OPT_SCOPE_NOTIFIED]
+ OPT_SCOPE_NOTIFIED,
+ OPT_SCOPE_FOREVER]
# (transfer) annotation options
OPT_TRANSFER_CONTAINER = 'container'
diff --git a/giscanner/ast.py b/giscanner/ast.py
index 66fe0cf1..d5b6c3be 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -363,6 +363,7 @@ PARAM_DIRECTION_INOUT = 'inout'
PARAM_SCOPE_CALL = 'call'
PARAM_SCOPE_ASYNC = 'async'
PARAM_SCOPE_NOTIFIED = 'notified'
+PARAM_SCOPE_FOREVER = 'forever'
PARAM_TRANSFER_NONE = 'none'
PARAM_TRANSFER_CONTAINER = 'container'
diff --git a/giscanner/introspectablepass.py b/giscanner/introspectablepass.py
index e2056b42..bb3580c6 100644
--- a/giscanner/introspectablepass.py
+++ b/giscanner/introspectablepass.py
@@ -102,7 +102,7 @@ class IntrospectablePass(object):
parent,
node,
"Missing (scope) annotation for callback without "
- "GDestroyNotify (valid: %s, %s)" % (ast.PARAM_SCOPE_CALL, ast.PARAM_SCOPE_ASYNC))
+ "GDestroyNotify (valid: %s, %s, %s)" % (ast.PARAM_SCOPE_CALL, ast.PARAM_SCOPE_ASYNC,
ast.PARAM_SCOPE_FOREVER))
parent.introspectable = False
return
diff --git a/tests/warn/callback-invalid-scope.h b/tests/warn/callback-invalid-scope.h
index 34292a89..a0d18abf 100644
--- a/tests/warn/callback-invalid-scope.h
+++ b/tests/warn/callback-invalid-scope.h
@@ -28,5 +28,5 @@ void test_callback_invalid3(GCallback *callback, gpointer user_data);
// EXPECT:23: Warning: Test: "scope" annotation needs one option, 2 given
// EXPECT:23: Warning: Test: invalid "scope" annotation option: "invalid"
-// EXPECT:12: Warning: Test: test_callback_invalid2: argument callback: Missing (scope) annotation for
callback without GDestroyNotify (valid: call, async)
-// EXPECT:21: Warning: Test: test_callback_invalid3: argument callback: Missing (scope) annotation for
callback without GDestroyNotify (valid: call, async)
+// EXPECT:12: Warning: Test: test_callback_invalid2: argument callback: Missing (scope) annotation for
callback without GDestroyNotify (valid: call, async, forever)
+// EXPECT:21: Warning: Test: test_callback_invalid3: argument callback: Missing (scope) annotation for
callback without GDestroyNotify (valid: call, async, forever)
diff --git a/tests/warn/callback-missing-scope.h b/tests/warn/callback-missing-scope.h
index 7932198e..7fa0e732 100644
--- a/tests/warn/callback-missing-scope.h
+++ b/tests/warn/callback-missing-scope.h
@@ -2,4 +2,4 @@
void test_callback(GCallback *callback, gpointer user_data);
-// EXPECT:3: Warning: Test: test_callback: argument callback: Missing (scope) annotation for callback
without GDestroyNotify (valid: call, async)
+// EXPECT:3: Warning: Test: test_callback: argument callback: Missing (scope) annotation for callback
without GDestroyNotify (valid: call, async, forever)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]