summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2011-07-22 16:46:10 -0400
committerJasper St. Pierre <jstpierre@mecheye.net>2011-07-22 17:17:11 -0400
commiteda7d98cb70de1445239955a99b44e128802dcc9 (patch)
tree29fa16b5d1f63ec25930cc1219859a170f683122
parent834f928f2032434fa8f54f68c51cc40fa8271733 (diff)
downloadgobject-introspection-eda7d98cb70de1445239955a99b44e128802dcc9.tar.gz
giscanner: Make comments starting with tab characters work
https://bugzilla.gnome.org/show_bug.cgi?id=655149
-rw-r--r--giscanner/annotationparser.py8
-rw-r--r--tests/scanner/Annotation-1.0-expected.gir9
-rw-r--r--tests/scanner/annotation.c22
3 files changed, 35 insertions, 4 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 2a22ece3..ac6430d6 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -413,7 +413,8 @@ class DocOption(object):
class AnnotationParser(object):
- COMMENT_HEADER_RE = re.compile(r'^\*[ \t]*\n ')
+ 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]+[^(]*\)')
@@ -451,9 +452,10 @@ class AnnotationParser(object):
return
comment = comment[2:]
- pos = comment.find('\n ')
- if pos == -1:
+ match = self.COMMENT_HEADER_START_RE.search(comment)
+ if match is None:
return
+ pos = match.start()
block_header = comment[:pos]
block_header = block_header.strip()
cpos = block_header.find(': ')
diff --git a/tests/scanner/Annotation-1.0-expected.gir b/tests/scanner/Annotation-1.0-expected.gir
index f650c256..8ae17f5d 100644
--- a/tests/scanner/Annotation-1.0-expected.gir
+++ b/tests/scanner/Annotation-1.0-expected.gir
@@ -537,6 +537,15 @@ annotation_object_watch_full().</doc>
<doc xml:whitespace="preserve">This is a property which is a string</doc>
<type name="utf8"/>
</property>
+ <property name="tab-property"
+ version="1.2"
+ writable="1"
+ construct="1"
+ transfer-ownership="none">
+ <doc xml:whitespace="preserve">This is a property annotation intentionally indented with a mix
+of tabs and strings to test the tab handling capabilities of the scanner.</doc>
+ <type name="utf8"/>
+ </property>
<field name="parent_instance">
<type name="GObject.Object" c:type="GObject"/>
</field>
diff --git a/tests/scanner/annotation.c b/tests/scanner/annotation.c
index f7046e89..29036b3c 100644
--- a/tests/scanner/annotation.c
+++ b/tests/scanner/annotation.c
@@ -7,7 +7,8 @@ G_DEFINE_TYPE (AnnotationObject, annotation_object, G_TYPE_OBJECT);
enum {
PROP_0,
PROP_STRING_PROPERTY,
- PROP_FUNCTION_PROPERTY
+ PROP_FUNCTION_PROPERTY,
+ PROP_TAB_PROPERTY
};
enum {
@@ -32,6 +33,8 @@ annotation_object_set_property (GObject *object,
break;
case PROP_FUNCTION_PROPERTY:
break;
+ case PROP_TAB_PROPERTY:
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -50,6 +53,8 @@ annotation_object_get_property (GObject *object,
break;
case PROP_FUNCTION_PROPERTY:
break;
+ case PROP_TAB_PROPERTY:
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -168,6 +173,21 @@ annotation_object_class_init (AnnotationObjectClass *klass)
"This property is a function pointer",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ /**
+ * AnnotationObject:tab-property:
+ *
+ * This is a property annotation intentionally indented with a mix
+ * of tabs and strings to test the tab handling capabilities of the scanner.
+ *
+ * Since: 1.2
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_TAB_PROPERTY,
+ g_param_spec_string ("tab-property",
+ "Tab property",
+ "This property is a thing",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
}
static void