[gobject-introspection] annotationparser: Only accept certain tags



commit bdeccbd7de9c1e42a879a6f9b01756280a138f47
Author: Colin Walters <walters verbum org>
Date:   Sat Aug 13 09:35:10 2011 -0400

    annotationparser: Only accept certain tags
    
    Previously we were eating any line form "* [A-Za-z]: " as a tag,
    but this is a problem since e.g. gtk/gtk/gtkcssprovder.c had literal
    CSS e.g. block: which erroneously matched.
    
    Fix this by only accepting particular tags, similar to what gtk-doc
    does (although we accept a superset, e.g. transfer too).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=656458

 giscanner/annotationparser.py          |   20 +++++++++++++++++---
 tests/scanner/Regress-1.0-expected.gir |    6 ++++--
 2 files changed, 21 insertions(+), 5 deletions(-)
---
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 0d7672e..67ba72b 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -25,9 +25,10 @@ import re
 from . import message
 from .odict import odict
 
-# Tags - annotations applyed to comment blocks
+# Tags - annotations applied to comment blocks
 TAG_VFUNC = 'virtual'
 TAG_SINCE = 'since'
+TAG_STABILITY = 'stability'
 TAG_DEPRECATED = 'deprecated'
 TAG_RETURNS = 'returns'
 TAG_ATTRIBUTES = 'attributes'
@@ -37,6 +38,20 @@ TAG_UNREF_FUNC = 'unref func'
 TAG_REF_FUNC = 'ref func'
 TAG_SET_VALUE_FUNC = 'set value func'
 TAG_GET_VALUE_FUNC = 'get value func'
+TAG_TRANSFER = 'transfer'
+_ALL_TAGS = [TAG_VFUNC,
+             TAG_SINCE,
+             TAG_STABILITY,
+             TAG_DEPRECATED,
+             TAG_RETURNS,
+             TAG_ATTRIBUTES,
+             TAG_RENAME_TO,
+             TAG_TYPE,
+             TAG_UNREF_FUNC,
+             TAG_REF_FUNC,
+             TAG_SET_VALUE_FUNC,
+             TAG_GET_VALUE_FUNC,
+             TAG_TRANSFER]
 
 # Options - annotations for parameters and return values
 OPT_ALLOW_NONE = 'allow-none'
@@ -416,7 +431,6 @@ class AnnotationParser(object):
     COMMENT_HEADER_RE = re.compile(r'^\*[ \t]*\n[\t ]')
     COMMENT_HEADER_START_RE = re.compile(r'\n[\t ]')
     WHITESPACE_RE = re.compile(r'^\s*$')
-    ASCII_TEXT_RE = re.compile(r'\s*[A-Za-z]+')
     OPTION_RE = re.compile(r'\([A-Za-z]+[^(]*\)')
     RETURNS_RE = re.compile(r'^return(s?)( value)?:', re.IGNORECASE)
 
@@ -572,7 +586,7 @@ class AnnotationParser(object):
                 # The line is of the form "Tag: some value here", like:
                 # Since: 0.8
                 tag_name = line[:first_colonspace_index]
-                if self.ASCII_TEXT_RE.match(tag_name):
+                if tag_name.lower() in _ALL_TAGS:
                     tag_name = tag_name.lower()
                     tag = DocTag(block, tag_name)
                     tag.value = line[first_colonspace_index+2:]
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index 33ceeae..8904d62 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -862,7 +862,8 @@ case.</doc>
         <type name="utf8" c:type="char*"/>
       </field>
       <glib:signal name="sig-with-array-prop">
-        <doc xml:whitespace="preserve">This test signal is like TelepathyGlib's</doc>
+        <doc xml:whitespace="preserve">This test signal is like TelepathyGlib's
+TpChannel:: group-members-changed-detailed:</doc>
         <return-value transfer-ownership="none">
           <type name="none"/>
         </return-value>
@@ -1908,7 +1909,8 @@ call and can be released on return.</doc>
     </function>
     <function name="test_ghash_nested_everything_return2"
               c:identifier="regress_test_ghash_nested_everything_return2">
-      <doc xml:whitespace="preserve">element-type annotation.</doc>
+      <doc xml:whitespace="preserve">Another way of specifying nested parameterized types: using the
+element-type annotation.</doc>
       <return-value transfer-ownership="full">
         <type name="GLib.HashTable" c:type="GHashTable*">
           <type name="utf8"/>



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