[gobject-introspection] giscanner: don't accept (allow-none) on Returns:



commit 0839e696e9fbc1942ac5c61054de3b47e9578152
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date:   Sat Sep 7 00:14:24 2013 +0200

    giscanner: don't accept (allow-none) on Returns:
    
    The old annotationparser.py happily parsed this, but
    giscanner/girwriter.py never serialized an allow-none
    attribute to the .gir file and girepository/girparser.c
    never looked for an allow-none attribute either.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=660879

 giscanner/annotationparser.py                      |    2 +-
 .../annotationparser/gi/annotation_allow_none.xml  |    9 +----
 tests/scanner/annotationparser/gi/tag.xml          |   29 +++++++++++--------
 tests/scanner/annotationparser/gi/tag_returns.xml  |   30 ++++++++++----------
 .../gtkdoc/annotations/tester.c.xml                |    3 ++
 tests/scanner/regress.c                            |    2 +-
 6 files changed, 39 insertions(+), 36 deletions(-)
---
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index a00bac1..5ded419 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -955,7 +955,7 @@ class GtkDocTag(GtkDocAnnotatable):
 
     __slots__ = ('name', 'value', 'description')
 
-    valid_annotations = (ANN_ALLOW_NONE, ANN_ARRAY, ANN_ATTRIBUTES, ANN_ELEMENT_TYPE, ANN_SKIP,
+    valid_annotations = (ANN_ARRAY, ANN_ATTRIBUTES, ANN_ELEMENT_TYPE, ANN_SKIP,
                          ANN_TRANSFER, ANN_TYPE)
 
     def __init__(self, name, position=None):
diff --git a/tests/scanner/annotationparser/gi/annotation_allow_none.xml 
b/tests/scanner/annotationparser/gi/annotation_allow_none.xml
index ae6b3b3..877c60f 100644
--- a/tests/scanner/annotationparser/gi/annotation_allow_none.xml
+++ b/tests/scanner/annotationparser/gi/annotation_allow_none.xml
@@ -10,7 +10,7 @@
  *
  * This is a test for out arguments
  *
- * Return value: (allow-none): an int
+ * Return value: an int
  */</input>
   <parser>
     <docblock>
@@ -39,11 +39,6 @@
       <tags>
         <tag>
           <name>returns</name>
-          <annotations>
-            <annotation>
-              <name>allow-none</name>
-            </annotation>
-          </annotations>
           <description>an int</description>
         </tag>
       </tags>
@@ -56,7 +51,7 @@
  *
  * This is a test for out arguments
  *
- * Returns: (allow-none): an int
+ * Returns: an int
  */</output>
 </test>
 
diff --git a/tests/scanner/annotationparser/gi/tag.xml b/tests/scanner/annotationparser/gi/tag.xml
index 8480d4b..a89b3ad 100644
--- a/tests/scanner/annotationparser/gi/tag.xml
+++ b/tests/scanner/annotationparser/gi/tag.xml
@@ -8,7 +8,7 @@
  *
  * Forgotten colon below will result in a warning.
  *
- * Returns: (allow-none) return value
+ * Returns: (transfer none) return value
  **/</input>
   <parser>
     <docblock>
@@ -21,7 +21,12 @@
           <name>returns</name>
           <annotations>
             <annotation>
-              <name>allow-none</name>
+              <name>transfer</name>
+              <options>
+                <option>
+                  <name>none</name>
+                </option>
+              </options>
             </annotation>
           </annotations>
           <description>return value</description>
@@ -29,9 +34,9 @@
       </tags>
     </docblock>
     <messages>
-      <message>6: Warning: Test: missing ":" at column 25:
- * Returns: (allow-none) return value
-                        ^</message>
+      <message>6: Warning: Test: missing ":" at column 28:
+ * Returns: (transfer none) return value
+                           ^</message>
     </messages>
   </parser>
   <output>/**
@@ -39,7 +44,7 @@
  *
  * Forgotten colon below will result in a warning.
  *
- * Returns: (allow-none): return value
+ * Returns: (transfer none): return value
  */</output>
 </test>
 
@@ -171,7 +176,7 @@ Moo: anything</description>
  *
  * Annotations spanning multiple lines are not valid
  *
- * Returns: (allow-none)
+ * Returns: (skip)
  * (transfer full): something
  **/</input>
   <parser>
@@ -185,7 +190,7 @@ Moo: anything</description>
           <name>returns</name>
           <annotations>
             <annotation>
-              <name>allow-none</name>
+              <name>skip</name>
             </annotation>
           </annotations>
           <description>
@@ -204,7 +209,7 @@ Moo: anything</description>
  *
  * Annotations spanning multiple lines are not valid
  *
- * Returns: (allow-none):
+ * Returns: (skip):
  * (transfer full): something
  */</output>
 </test>
@@ -215,7 +220,7 @@ Moo: anything</description>
  *
  * Annotations spanning multiple lines are not valid
  *
- * Returns: (allow-none): Returns tag having a second line which looks
+ * Returns: (skip): Returns tag having a second line which looks
  * (like an annotation), but isn't. This should not result in a warning.
  **/</input>
   <parser>
@@ -229,7 +234,7 @@ Moo: anything</description>
           <name>returns</name>
           <annotations>
             <annotation>
-              <name>allow-none</name>
+              <name>skip</name>
             </annotation>
           </annotations>
           <description>Returns tag having a second line which looks
@@ -243,7 +248,7 @@ Moo: anything</description>
  *
  * Annotations spanning multiple lines are not valid
  *
- * Returns: (allow-none): Returns tag having a second line which looks
+ * Returns: (skip): Returns tag having a second line which looks
  * (like an annotation), but isn't. This should not result in a warning.
  */</output>
 </test>
diff --git a/tests/scanner/annotationparser/gi/tag_returns.xml 
b/tests/scanner/annotationparser/gi/tag_returns.xml
index 8ccfaa6..49389c2 100644
--- a/tests/scanner/annotationparser/gi/tag_returns.xml
+++ b/tests/scanner/annotationparser/gi/tag_returns.xml
@@ -8,7 +8,7 @@
  *
  * Test returning a string as an out parameter
  *
- * Returns: (allow-none): some boolean
+ * Returns: (skip): some boolean
  **/</input>
   <parser>
     <docblock>
@@ -21,7 +21,7 @@
           <name>returns</name>
           <annotations>
             <annotation>
-              <name>allow-none</name>
+              <name>skip</name>
             </annotation>
           </annotations>
           <description>some boolean</description>
@@ -34,7 +34,7 @@
  *
  * Test returning a string as an out parameter
  *
- * Returns: (allow-none): some boolean
+ * Returns: (skip): some boolean
  */</output>
 </test>
 
@@ -44,7 +44,7 @@
  *
  * Test returning a string as an out parameter
  *
- * Returns: (allow-none)): some boolean
+ * Returns: (skip)): some boolean
  **/</input>
   <parser>
     <docblock>
@@ -60,8 +60,8 @@
     </docblock>
     <messages>
       <message>6: Error: Test: unbalanced parentheses, annotations will be ignored:
- * Returns: (allow-none)): some boolean
-                        ^</message>
+ * Returns: (skip)): some boolean
+                  ^</message>
     </messages>
   </parser>
   <output>/**
@@ -121,7 +121,7 @@ Tags should go after the comment block description</description>
  *
  * Test returning a string as an out parameter
  *
- * Return value: (allow-none): some boolean
+ * Return value: (skip): some boolean
  **/</input>
   <parser>
     <docblock>
@@ -134,7 +134,7 @@ Tags should go after the comment block description</description>
           <name>returns</name>
           <annotations>
             <annotation>
-              <name>allow-none</name>
+              <name>skip</name>
             </annotation>
           </annotations>
           <description>some boolean</description>
@@ -147,7 +147,7 @@ Tags should go after the comment block description</description>
  *
  * Test returning a string as an out parameter
  *
- * Returns: (allow-none): some boolean
+ * Returns: (skip): some boolean
  */</output>
 </test>
 
@@ -157,7 +157,7 @@ Tags should go after the comment block description</description>
   -->
   <input>/**
  * annotation_object_string_out:
- * @returns: (allow-none): some boolean
+ * @returns: (skip): some boolean
  *
  * Test returning a string as an out parameter
  **/</input>
@@ -172,7 +172,7 @@ Tags should go after the comment block description</description>
           <name>returns</name>
           <annotations>
             <annotation>
-              <name>allow-none</name>
+              <name>skip</name>
             </annotation>
           </annotations>
           <description>some boolean</description>
@@ -185,7 +185,7 @@ Tags should go after the comment block description</description>
  *
  * Test returning a string as an out parameter
  *
- * Returns: (allow-none): some boolean
+ * Returns: (skip): some boolean
  */</output>
 </test>
 
@@ -195,7 +195,7 @@ Tags should go after the comment block description</description>
   -->
   <input>/**
  * annotation_object_string_out:
- * @returns: (allow-none)): some boolean
+ * @returns: (skip)): some boolean
  *
  * Test returning a string as an out parameter
  **/</input>
@@ -213,8 +213,8 @@ Tags should go after the comment block description</description>
     </docblock>
     <messages>
       <message>3: Error: Test: unbalanced parentheses, annotations will be ignored:
- * @returns: (allow-none)): some boolean
-                         ^</message>
+ * @returns: (skip)): some boolean
+                   ^</message>
     </messages>
   </parser>
   <output>/**
diff --git a/tests/scanner/annotationparser/gtkdoc/annotations/tester.c.xml 
b/tests/scanner/annotationparser/gtkdoc/annotations/tester.c.xml
index d28d5d9..9bdbc0e 100644
--- a/tests/scanner/annotationparser/gtkdoc/annotations/tester.c.xml
+++ b/tests/scanner/annotationparser/gtkdoc/annotations/tester.c.xml
@@ -138,6 +138,9 @@
         </tag>
       </tags>
     </docblock>
+    <messages>
+      <message>9: Warning: Test: unexpected annotation: allow-none</message>
+    </messages>
   </parser>
   <output>/**
  * annotation_nullable:
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c
index 1bad36e..875b136 100644
--- a/tests/scanner/regress.c
+++ b/tests/scanner/regress.c
@@ -1189,7 +1189,7 @@ regress_test_table_ghash_const (void)
 /**
  * regress_test_ghash_null_return:
  *
- * Return value: (element-type utf8 utf8) (transfer none) (allow-none):
+ * Return value: (element-type utf8 utf8) (transfer none):
  */
 const GHashTable *
 regress_test_ghash_null_return (void)


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