From 077eb80a8d9bb2968c2bfac959c2f2ca966ca7e7 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 1 Oct 2024 15:39:18 +0200 Subject: [PATCH] gir: Correct usage of the closure annotation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quoting Ebassi https://www.bassi.io/articles/2023/02/20/bindable-api-2023/: Whenever you’re describing a function that takes a callback, you should always annotate the callback argument with the argument that contains the user data using the (closure argument) annotation You should not annotate the data argument with a unary (closure). The unary (closure) is meant to be used when annotating the callback type Recently gobject-introspection became a bit more strict with this and that generated some warnings: Warning: Cogl: invalid "closure" annotation: only valid on callback parameters This commit fix all the closure annotations. Part-of: --- clutter/clutter/clutter-actor.c | 4 ++-- clutter/clutter/clutter-timeline.c | 5 +++-- cogl/cogl/cogl-onscreen.h | 5 +++-- cogl/cogl/cogl-pipeline.h | 7 +++---- src/tests/clutter-test-utils.c | 5 +++-- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index 1c97d3744..1e6d926d4 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -11013,8 +11013,8 @@ typedef enum * @self: a #ClutterActor * @child: a #ClutterActor * @flags: control flags for actions - * @add_func: delegate function - * @data: (closure): data to pass to @add_func + * @add_func (closure data): delegate function + * @data: data to pass to @add_func * * Adds @child to the list of children of @self. * diff --git a/clutter/clutter/clutter-timeline.c b/clutter/clutter/clutter-timeline.c index 435521d6b..3318b6d78 100644 --- a/clutter/clutter/clutter-timeline.c +++ b/clutter/clutter/clutter-timeline.c @@ -2202,8 +2202,9 @@ clutter_timeline_get_repeat_count (ClutterTimeline *timeline) /** * clutter_timeline_set_progress_func: * @timeline: a #ClutterTimeline - * @func: (scope notified) (allow-none): a progress function, or %NULL - * @data: (closure): data to pass to @func + * @func: (scope notified) (allow-none) (closure data): a progress function, + * or %NULL + * @data: data to pass to @func * @notify: a function to be called when the progress function is removed * or the timeline is disposed * diff --git a/cogl/cogl/cogl-onscreen.h b/cogl/cogl/cogl-onscreen.h index e7b71f190..4deb71906 100644 --- a/cogl/cogl/cogl-onscreen.h +++ b/cogl/cogl/cogl-onscreen.h @@ -348,8 +348,9 @@ GType cogl_frame_closure_get_type (void); /** * cogl_onscreen_add_frame_callback: * @onscreen: A #CoglOnscreen framebuffer - * @callback: (scope notified): A callback function to call for frame events - * @user_data: (closure): A private pointer to be passed to @callback + * @callback: (scope notified) (closure user_data): A callback function + * to call for frame events + * @user_data: A private pointer to be passed to @callback * @destroy: (allow-none): An optional callback to destroy @user_data * when the @callback is removed or @onscreen is freed. * diff --git a/cogl/cogl/cogl-pipeline.h b/cogl/cogl/cogl-pipeline.h index 35af46c4e..183b874e6 100644 --- a/cogl/cogl/cogl-pipeline.h +++ b/cogl/cogl/cogl-pipeline.h @@ -122,10 +122,9 @@ typedef gboolean (*CoglPipelineLayerCallback) (CoglPipeline *pipeline, /** * cogl_pipeline_foreach_layer: * @pipeline: A #CoglPipeline object - * @callback: (scope call): A #CoglPipelineLayerCallback to be - * called for each layer index - * @user_data: (closure): Private data that will be passed to the - * callback + * @callback: (scope call) (closure user_data): A #CoglPipelineLayerCallback + * to be called for each layer index + * @user_data: Private data that will be passed to the callback * * Iterates all the layer indices of the given @pipeline. */ diff --git a/src/tests/clutter-test-utils.c b/src/tests/clutter-test-utils.c index efedf282c..f154c215c 100644 --- a/src/tests/clutter-test-utils.c +++ b/src/tests/clutter-test-utils.c @@ -219,8 +219,9 @@ clutter_test_add_data (const char *test_path, /** * clutter_test_add_data_full: * @test_path: unique path for identifying the test - * @test_func: (scope notified): function containing the test - * @test_data: (closure): data to pass to the test function + * @test_func: (scope notified) (closure test_data): function + * containing the test + * @test_data: data to pass to the test function * @test_notify: function called when the test function ends * * Adds a test unit to the Clutter test environment.