[gobject-introspection] maintransformer: Don't warn on (optional) annotations on (inout)



commit 361aa17c5302d5d9501b71ec352b39452dea6d23
Author: Guido Günther <agx sigxcpu org>
Date:   Sun Jan 13 14:00:28 2019 +0100

    maintransformer: Don't warn on (optional) annotations on (inout)
    
    This makes the scanner consistent with the docs.

 giscanner/maintransformer.py  |  5 +++--
 tests/warn/invalid-optional.h | 10 +++++-----
 2 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 23cbb942..e1536b93 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -657,11 +657,12 @@ class MainTransformer(object):
 
         if ANN_OPTIONAL in annotations:
             if (not isinstance(node, ast.Return) and
-                    node.direction == ast.PARAM_DIRECTION_OUT):
+                    node.direction in [ast.PARAM_DIRECTION_OUT,
+                                       ast.PARAM_DIRECTION_INOUT]):
                 node.optional = True
             else:
                 message.warn('invalid "optional" annotation: '
-                             'only valid for out parameters',
+                             'only valid for out and inout parameters',
                              annotations.position)
 
         if ANN_ALLOW_NONE in annotations:
diff --git a/tests/warn/invalid-optional.h b/tests/warn/invalid-optional.h
index bcd8df6e..b9d3f279 100644
--- a/tests/warn/invalid-optional.h
+++ b/tests/warn/invalid-optional.h
@@ -4,13 +4,13 @@
  * test_invalid_optional:
  * @param: (optional):
  * @param2: (optional):
- * @param3: (optional) (inout):
+ * @param3: (optional) (in):
  *
  * Returns: (optional):
  */
 int *test_invalid_optional(int param, GObject *param2, int *param3);
 
-// EXPECT:5: Warning: Test: invalid "optional" annotation: only valid for out parameters
-// EXPECT:6: Warning: Test: invalid "optional" annotation: only valid for out parameters
-// EXPECT:7: Warning: Test: invalid "optional" annotation: only valid for out parameters
-// EXPECT:9: Warning: Test: invalid "optional" annotation: only valid for out parameters
+// EXPECT:5: Warning: Test: invalid "optional" annotation: only valid for out and inout parameters
+// EXPECT:6: Warning: Test: invalid "optional" annotation: only valid for out and inout parameters
+// EXPECT:7: Warning: Test: invalid "optional" annotation: only valid for out and inout parameters
+// EXPECT:9: Warning: Test: invalid "optional" annotation: only valid for out and inout parameters


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]